1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #ifdef RTE_EXEC_ENV_FREEBSD
15 #include <sys/socket.h>
17 #include <netinet/in.h>
19 #include <sys/queue.h>
21 #include <rte_common.h>
22 #include <rte_byteorder.h>
24 #include <rte_debug.h>
25 #include <rte_cycles.h>
26 #include <rte_memory.h>
27 #include <rte_memzone.h>
28 #include <rte_malloc.h>
29 #include <rte_launch.h>
31 #include <rte_per_lcore.h>
32 #include <rte_lcore.h>
33 #include <rte_atomic.h>
34 #include <rte_branch_prediction.h>
36 #include <rte_mempool.h>
37 #include <rte_interrupts.h>
39 #include <rte_ether.h>
40 #include <rte_ethdev.h>
41 #include <rte_string_fns.h>
42 #include <rte_devargs.h>
46 #include <cmdline_rdline.h>
47 #include <cmdline_parse.h>
48 #include <cmdline_parse_num.h>
49 #include <cmdline_parse_string.h>
50 #include <cmdline_parse_ipaddr.h>
51 #include <cmdline_parse_etheraddr.h>
52 #include <cmdline_socket.h>
54 #ifdef RTE_LIBRTE_PMD_BOND
55 #include <rte_eth_bond.h>
56 #include <rte_eth_bond_8023ad.h>
58 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
59 #include <rte_pmd_dpaa.h>
61 #ifdef RTE_LIBRTE_IXGBE_PMD
62 #include <rte_pmd_ixgbe.h>
64 #ifdef RTE_LIBRTE_I40E_PMD
65 #include <rte_pmd_i40e.h>
67 #ifdef RTE_LIBRTE_BNXT_PMD
68 #include <rte_pmd_bnxt.h>
71 #include "cmdline_mtr.h"
72 #include "cmdline_tm.h"
75 static struct cmdline *testpmd_cl;
77 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
79 /* *** Help command with introduction. *** */
80 struct cmd_help_brief_result {
81 cmdline_fixed_string_t help;
84 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
86 __attribute__((unused)) void *data)
91 "Help is available for the following sections:\n\n"
92 " help control : Start and stop forwarding.\n"
93 " help display : Displaying port, stats and config "
95 " help config : Configuration information.\n"
96 " help ports : Configuring ports.\n"
97 " help registers : Reading and setting port registers.\n"
98 " help filters : Filters configuration help.\n"
99 " help traffic_management : Traffic Management commmands.\n"
100 " help devices : Device related cmds.\n"
101 " help all : All of the above sections.\n\n"
106 cmdline_parse_token_string_t cmd_help_brief_help =
107 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
109 cmdline_parse_inst_t cmd_help_brief = {
110 .f = cmd_help_brief_parsed,
112 .help_str = "help: Show help",
114 (void *)&cmd_help_brief_help,
119 /* *** Help command with help sections. *** */
120 struct cmd_help_long_result {
121 cmdline_fixed_string_t help;
122 cmdline_fixed_string_t section;
125 static void cmd_help_long_parsed(void *parsed_result,
127 __attribute__((unused)) void *data)
130 struct cmd_help_long_result *res = parsed_result;
132 if (!strcmp(res->section, "all"))
135 if (show_all || !strcmp(res->section, "control")) {
140 "Control forwarding:\n"
141 "-------------------\n\n"
144 " Start packet forwarding with current configuration.\n\n"
147 " Start packet forwarding with current config"
148 " after sending one burst of packets.\n\n"
151 " Stop packet forwarding, and display accumulated"
155 " Quit to prompt.\n\n"
159 if (show_all || !strcmp(res->section, "display")) {
167 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
168 " Display information for port_id, or all.\n\n"
170 "show port X rss reta (size) (mask0,mask1,...)\n"
171 " Display the rss redirection table entry indicated"
172 " by masks on port X. size is used to indicate the"
173 " hardware supported reta size\n\n"
175 "show port (port_id) rss-hash [key]\n"
176 " Display the RSS hash functions and RSS hash key of port\n\n"
178 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
179 " Clear information for port_id, or all.\n\n"
181 "show (rxq|txq) info (port_id) (queue_id)\n"
182 " Display information for configured RX/TX queue.\n\n"
184 "show config (rxtx|cores|fwd|txpkts)\n"
185 " Display the given configuration.\n\n"
187 "read rxd (port_id) (queue_id) (rxd_id)\n"
188 " Display an RX descriptor of a port RX queue.\n\n"
190 "read txd (port_id) (queue_id) (txd_id)\n"
191 " Display a TX descriptor of a port TX queue.\n\n"
193 "ddp get list (port_id)\n"
194 " Get ddp profile info list\n\n"
196 "ddp get info (profile_path)\n"
197 " Get ddp profile information.\n\n"
199 "show vf stats (port_id) (vf_id)\n"
200 " Display a VF's statistics.\n\n"
202 "clear vf stats (port_id) (vf_id)\n"
203 " Reset a VF's statistics.\n\n"
205 "show port (port_id) pctype mapping\n"
206 " Get flow ptype to pctype mapping on a port\n\n"
208 "show port meter stats (port_id) (meter_id) (clear)\n"
209 " Get meter stats on a port\n\n"
211 "show fwd stats all\n"
212 " Display statistics for all fwd engines.\n\n"
214 "clear fwd stats all\n"
215 " Clear statistics for all fwd engines.\n\n"
217 "show port (port_id) rx_offload capabilities\n"
218 " List all per queue and per port Rx offloading"
219 " capabilities of a port\n\n"
221 "show port (port_id) rx_offload configuration\n"
222 " List port level and all queue level"
223 " Rx offloading configuration\n\n"
225 "show port (port_id) tx_offload capabilities\n"
226 " List all per queue and per port"
227 " Tx offloading capabilities of a port\n\n"
229 "show port (port_id) tx_offload configuration\n"
230 " List port level and all queue level"
231 " Tx offloading configuration\n\n"
233 "show port (port_id) tx_metadata\n"
234 " Show Tx metadata value set"
235 " for a specific port\n\n"
237 "show port (port_id) ptypes\n"
238 " Show port supported ptypes"
239 " for a specific port\n\n"
241 "show device info (<identifier>|all)"
242 " Show general information about devices probed.\n\n"
246 if (show_all || !strcmp(res->section, "config")) {
252 "Configuration changes only become active when"
253 " forwarding is started/restarted.\n\n"
256 " Reset forwarding to the default configuration.\n\n"
258 "set verbose (level)\n"
259 " Set the debug verbosity level X.\n\n"
261 "set log global|(type) (level)\n"
262 " Set the log level.\n\n"
265 " Set number of ports.\n\n"
268 " Set number of cores.\n\n"
270 "set coremask (mask)\n"
271 " Set the forwarding cores hexadecimal mask.\n\n"
273 "set portmask (mask)\n"
274 " Set the forwarding ports hexadecimal mask.\n\n"
277 " Set number of packets per burst.\n\n"
279 "set burst tx delay (microseconds) retry (num)\n"
280 " Set the transmit delay time and number of retries,"
281 " effective when retry is enabled.\n\n"
283 "set txpkts (x[,y]*)\n"
284 " Set the length of each segment of TXONLY"
285 " and optionally CSUM packets.\n\n"
287 "set txsplit (off|on|rand)\n"
288 " Set the split policy for the TX packets."
289 " Right now only applicable for CSUM and TXONLY"
292 "set corelist (x[,y]*)\n"
293 " Set the list of forwarding cores.\n\n"
295 "set portlist (x[,y]*)\n"
296 " Set the list of forwarding ports.\n\n"
298 "set port setup on (iterator|event)\n"
299 " Select how attached port is retrieved for setup.\n\n"
301 "set tx loopback (port_id) (on|off)\n"
302 " Enable or disable tx loopback.\n\n"
304 "set all queues drop (port_id) (on|off)\n"
305 " Set drop enable bit for all queues.\n\n"
307 "set vf split drop (port_id) (vf_id) (on|off)\n"
308 " Set split drop enable bit for a VF from the PF.\n\n"
310 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
311 " Set MAC antispoof for a VF from the PF.\n\n"
313 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
314 " Enable MACsec offload.\n\n"
316 "set macsec offload (port_id) off\n"
317 " Disable MACsec offload.\n\n"
319 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
320 " Configure MACsec secure connection (SC).\n\n"
322 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
323 " Configure MACsec secure association (SA).\n\n"
325 "set vf broadcast (port_id) (vf_id) (on|off)\n"
326 " Set VF broadcast for a VF from the PF.\n\n"
328 "vlan set stripq (on|off) (port_id,queue_id)\n"
329 " Set the VLAN strip for a queue on a port.\n\n"
331 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
332 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
334 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
335 " Set VLAN insert for a VF from the PF.\n\n"
337 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
338 " Set VLAN antispoof for a VF from the PF.\n\n"
340 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
341 " Set VLAN tag for a VF from the PF.\n\n"
343 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
344 " Set a VF's max bandwidth(Mbps).\n\n"
346 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
347 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
349 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
350 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
352 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
353 " Set some TCs' strict link priority mode on a physical port.\n\n"
355 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
356 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
358 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
359 " Set the VLAN strip or filter or qinq strip or extend\n\n"
361 "vlan set (inner|outer) tpid (value) (port_id)\n"
362 " Set the VLAN TPID for Packet Filtering on"
365 "rx_vlan add (vlan_id|all) (port_id)\n"
366 " Add a vlan_id, or all identifiers, to the set"
367 " of VLAN identifiers filtered by port_id.\n\n"
369 "rx_vlan rm (vlan_id|all) (port_id)\n"
370 " Remove a vlan_id, or all identifiers, from the set"
371 " of VLAN identifiers filtered by port_id.\n\n"
373 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
374 " Add a vlan_id, to the set of VLAN identifiers"
375 "filtered for VF(s) from port_id.\n\n"
377 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
378 " Remove a vlan_id, to the set of VLAN identifiers"
379 "filtered for VF(s) from port_id.\n\n"
381 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
382 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
383 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
384 " add a tunnel filter of a port.\n\n"
386 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 " remove a tunnel filter of a port.\n\n"
391 "rx_vxlan_port add (udp_port) (port_id)\n"
392 " Add an UDP port for VXLAN packet filter on a port\n\n"
394 "rx_vxlan_port rm (udp_port) (port_id)\n"
395 " Remove an UDP port for VXLAN packet filter on a port\n\n"
397 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
398 " Set hardware insertion of VLAN IDs (single or double VLAN "
399 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
401 "tx_vlan set pvid port_id vlan_id (on|off)\n"
402 " Set port based TX VLAN insertion.\n\n"
404 "tx_vlan reset (port_id)\n"
405 " Disable hardware insertion of a VLAN header in"
406 " packets sent on a port.\n\n"
408 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
409 " Select hardware or software calculation of the"
410 " checksum when transmitting a packet using the"
411 " csum forward engine.\n"
412 " ip|udp|tcp|sctp always concern the inner layer.\n"
413 " outer-ip concerns the outer IP layer in"
414 " outer-udp concerns the outer UDP layer in"
415 " case the packet is recognized as a tunnel packet by"
416 " the forward engine (vxlan, gre and ipip are supported)\n"
417 " Please check the NIC datasheet for HW limits.\n\n"
419 "csum parse-tunnel (on|off) (tx_port_id)\n"
420 " If disabled, treat tunnel packets as non-tunneled"
421 " packets (treat inner headers as payload). The port\n"
422 " argument is the port used for TX in csum forward"
425 "csum show (port_id)\n"
426 " Display tx checksum offload configuration\n\n"
428 "tso set (segsize) (portid)\n"
429 " Enable TCP Segmentation Offload in csum forward"
431 " Please check the NIC datasheet for HW limits.\n\n"
434 " Display the status of TCP Segmentation Offload.\n\n"
436 "set port (port_id) gro on|off\n"
437 " Enable or disable Generic Receive Offload in"
438 " csum forwarding engine.\n\n"
440 "show port (port_id) gro\n"
441 " Display GRO configuration.\n\n"
443 "set gro flush (cycles)\n"
444 " Set the cycle to flush GROed packets from"
445 " reassembly tables.\n\n"
447 "set port (port_id) gso (on|off)"
448 " Enable or disable Generic Segmentation Offload in"
449 " csum forwarding engine.\n\n"
451 "set gso segsz (length)\n"
452 " Set max packet length for output GSO segments,"
453 " including packet header and payload.\n\n"
455 "show port (port_id) gso\n"
456 " Show GSO configuration.\n\n"
459 " Set packet forwarding mode.\n\n"
461 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
462 " Add a MAC address on port_id.\n\n"
464 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
465 " Remove a MAC address from port_id.\n\n"
467 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
468 " Set the default MAC address for port_id.\n\n"
470 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
471 " Add a MAC address for a VF on the port.\n\n"
473 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
474 " Set the MAC address for a VF from the PF.\n\n"
476 "set eth-peer (port_id) (peer_addr)\n"
477 " set the peer address for certain port.\n\n"
479 "set port (port_id) uta (mac_address|all) (on|off)\n"
480 " Add/Remove a or all unicast hash filter(s)"
483 "set promisc (port_id|all) (on|off)\n"
484 " Set the promiscuous mode on port_id, or all.\n\n"
486 "set allmulti (port_id|all) (on|off)\n"
487 " Set the allmulti mode on port_id, or all.\n\n"
489 "set vf promisc (port_id) (vf_id) (on|off)\n"
490 " Set unicast promiscuous mode for a VF from the PF.\n\n"
492 "set vf allmulti (port_id) (vf_id) (on|off)\n"
493 " Set multicast promiscuous mode for a VF from the PF.\n\n"
495 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
496 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
497 " (on|off) autoneg (on|off) (port_id)\n"
498 "set flow_ctrl rx (on|off) (portid)\n"
499 "set flow_ctrl tx (on|off) (portid)\n"
500 "set flow_ctrl high_water (high_water) (portid)\n"
501 "set flow_ctrl low_water (low_water) (portid)\n"
502 "set flow_ctrl pause_time (pause_time) (portid)\n"
503 "set flow_ctrl send_xon (send_xon) (portid)\n"
504 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
505 "set flow_ctrl autoneg (on|off) (port_id)\n"
506 " Set the link flow control parameter on a port.\n\n"
508 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
509 " (low_water) (pause_time) (priority) (port_id)\n"
510 " Set the priority flow control parameter on a"
513 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
514 " Set statistics mapping (qmapping 0..15) for RX/TX"
516 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
517 " on port 0 to mapping 5.\n\n"
519 "set xstats-hide-zero on|off\n"
520 " Set the option to hide the zero values"
521 " for xstats display.\n"
523 "set port (port_id) vf (vf_id) rx|tx on|off\n"
524 " Enable/Disable a VF receive/tranmit from a port\n\n"
526 "set port (port_id) vf (vf_id) (mac_addr)"
527 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
528 " Add/Remove unicast or multicast MAC addr filter"
531 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
533 " AUPE:accepts untagged VLAN;"
534 "ROPE:accept unicast hash\n\n"
535 " BAM:accepts broadcast packets;"
536 "MPE:accepts all multicast packets\n\n"
537 " Enable/Disable a VF receive mode of a port\n\n"
539 "set port (port_id) queue (queue_id) rate (rate_num)\n"
540 " Set rate limit for a queue of a port\n\n"
542 "set port (port_id) vf (vf_id) rate (rate_num) "
543 "queue_mask (queue_mask_value)\n"
544 " Set rate limit for queues in VF of a port\n\n"
546 "set port (port_id) mirror-rule (rule_id)"
547 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
548 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
549 " Set pool or vlan type mirror rule on a port.\n"
550 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
551 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
554 "set port (port_id) mirror-rule (rule_id)"
555 " (uplink-mirror|downlink-mirror) dst-pool"
556 " (pool_id) (on|off)\n"
557 " Set uplink or downlink type mirror rule on a port.\n"
558 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
559 " 0 on' enable mirror income traffic to pool 0.\n\n"
561 "reset port (port_id) mirror-rule (rule_id)\n"
562 " Reset a mirror rule.\n\n"
564 "set flush_rx (on|off)\n"
565 " Flush (default) or don't flush RX streams before"
566 " forwarding. Mainly used with PCAP drivers.\n\n"
568 "set bypass mode (normal|bypass|isolate) (port_id)\n"
569 " Set the bypass mode for the lowest port on bypass enabled"
572 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
573 "mode (normal|bypass|isolate) (port_id)\n"
574 " Set the event required to initiate specified bypass mode for"
575 " the lowest port on a bypass enabled NIC where:\n"
576 " timeout = enable bypass after watchdog timeout.\n"
577 " os_on = enable bypass when OS/board is powered on.\n"
578 " os_off = enable bypass when OS/board is powered off.\n"
579 " power_on = enable bypass when power supply is turned on.\n"
580 " power_off = enable bypass when power supply is turned off."
583 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
584 " Set the bypass watchdog timeout to 'n' seconds"
585 " where 0 = instant.\n\n"
587 "show bypass config (port_id)\n"
588 " Show the bypass configuration for a bypass enabled NIC"
589 " using the lowest port on the NIC.\n\n"
591 #ifdef RTE_LIBRTE_PMD_BOND
592 "create bonded device (mode) (socket)\n"
593 " Create a new bonded device with specific bonding mode and socket.\n\n"
595 "add bonding slave (slave_id) (port_id)\n"
596 " Add a slave device to a bonded device.\n\n"
598 "remove bonding slave (slave_id) (port_id)\n"
599 " Remove a slave device from a bonded device.\n\n"
601 "set bonding mode (value) (port_id)\n"
602 " Set the bonding mode on a bonded device.\n\n"
604 "set bonding primary (slave_id) (port_id)\n"
605 " Set the primary slave for a bonded device.\n\n"
607 "show bonding config (port_id)\n"
608 " Show the bonding config for port_id.\n\n"
610 "set bonding mac_addr (port_id) (address)\n"
611 " Set the MAC address of a bonded device.\n\n"
613 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
614 " Set Aggregation mode for IEEE802.3AD (mode 4)"
616 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
617 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
619 "set bonding mon_period (port_id) (value)\n"
620 " Set the bonding link status monitoring polling period in ms.\n\n"
622 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
623 " Enable/disable dedicated queues for LACP control traffic.\n\n"
626 "set link-up port (port_id)\n"
627 " Set link up for a port.\n\n"
629 "set link-down port (port_id)\n"
630 " Set link down for a port.\n\n"
632 "E-tag set insertion on port-tag-id (value)"
633 " port (port_id) vf (vf_id)\n"
634 " Enable E-tag insertion for a VF on a port\n\n"
636 "E-tag set insertion off port (port_id) vf (vf_id)\n"
637 " Disable E-tag insertion for a VF on a port\n\n"
639 "E-tag set stripping (on|off) port (port_id)\n"
640 " Enable/disable E-tag stripping on a port\n\n"
642 "E-tag set forwarding (on|off) port (port_id)\n"
643 " Enable/disable E-tag based forwarding"
646 "E-tag set filter add e-tag-id (value) dst-pool"
647 " (pool_id) port (port_id)\n"
648 " Add an E-tag forwarding filter on a port\n\n"
650 "E-tag set filter del e-tag-id (value) port (port_id)\n"
651 " Delete an E-tag forwarding filter on a port\n\n"
653 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
654 " Load a profile package on a port\n\n"
656 "ddp del (port_id) (backup_profile_path)\n"
657 " Delete a profile package from a port\n\n"
659 "ptype mapping get (port_id) (valid_only)\n"
660 " Get ptype mapping on a port\n\n"
662 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
663 " Replace target with the pkt_type in ptype mapping\n\n"
665 "ptype mapping reset (port_id)\n"
666 " Reset ptype mapping on a port\n\n"
668 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
669 " Update a ptype mapping item on a port\n\n"
671 "set port (port_id) queue-region region_id (value) "
672 "queue_start_index (value) queue_num (value)\n"
673 " Set a queue region on a port\n\n"
675 "set port (port_id) queue-region region_id (value) "
677 " Set a flowtype region index on a port\n\n"
679 "set port (port_id) queue-region UP (value) region_id (value)\n"
680 " Set the mapping of User Priority to "
681 "queue region on a port\n\n"
683 "set port (port_id) queue-region flush (on|off)\n"
684 " flush all queue region related configuration\n\n"
686 "show port meter cap (port_id)\n"
687 " Show port meter capability information\n\n"
689 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
690 " meter profile add - srtcm rfc 2697\n\n"
692 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
693 " meter profile add - trtcm rfc 2698\n\n"
695 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
696 " meter profile add - trtcm rfc 4115\n\n"
698 "del port meter profile (port_id) (profile_id)\n"
699 " meter profile delete\n\n"
701 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
702 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
703 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
704 "(dscp_tbl_entry63)]\n"
707 "enable port meter (port_id) (mtr_id)\n"
710 "disable port meter (port_id) (mtr_id)\n"
713 "del port meter (port_id) (mtr_id)\n"
716 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
717 " meter update meter profile\n\n"
719 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
720 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
721 " update meter dscp table entries\n\n"
723 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
724 "(action0) [(action1) (action2)]\n"
725 " meter update policer action\n\n"
727 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
728 " meter update stats\n\n"
730 "show port (port_id) queue-region\n"
731 " show all queue region related configuration info\n\n"
733 , list_pkt_forwarding_modes()
737 if (show_all || !strcmp(res->section, "ports")) {
743 "----------------\n\n"
745 "port start (port_id|all)\n"
746 " Start all ports or port_id.\n\n"
748 "port stop (port_id|all)\n"
749 " Stop all ports or port_id.\n\n"
751 "port close (port_id|all)\n"
752 " Close all ports or port_id.\n\n"
754 "port reset (port_id|all)\n"
755 " Reset 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 drop-en (on|off)\n"
778 " Enable or disable packet drop on all RX queues of all ports when no "
779 "receive buffers available.\n\n"
781 "port config all rss (all|default|ip|tcp|udp|sctp|"
782 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
783 " Set the RSS mode.\n\n"
785 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
786 " Set the RSS redirection table.\n\n"
788 "port config (port_id) dcb vt (on|off) (traffic_class)"
790 " Set the DCB mode.\n\n"
792 "port config all burst (value)\n"
793 " Set the number of packets per burst.\n\n"
795 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
797 " Set the ring prefetch/host/writeback threshold"
798 " for tx/rx queue.\n\n"
800 "port config all (txfreet|txrst|rxfreet) (value)\n"
801 " Set free threshold for rx/tx, or set"
802 " tx rs bit threshold.\n\n"
803 "port config mtu X value\n"
804 " Set the MTU of port X to a given value\n\n"
806 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
807 " Set a rx/tx queue's ring size configuration, the new"
808 " value will take effect after command that (re-)start the port"
809 " or command that setup the specific queue\n\n"
811 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
812 " Start/stop a rx/tx queue of port X. Only take effect"
813 " when port X is started\n\n"
815 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
816 " Switch on/off a deferred start of port X rx/tx queue. Only"
817 " take effect when port X is stopped.\n\n"
819 "port (port_id) (rxq|txq) (queue_id) setup\n"
820 " Setup a rx/tx queue of port X.\n\n"
822 "port config (port_id|all) l2-tunnel E-tag ether-type"
824 " Set the value of E-tag ether-type.\n\n"
826 "port config (port_id|all) l2-tunnel E-tag"
827 " (enable|disable)\n"
828 " Enable/disable the E-tag support.\n\n"
830 "port config (port_id) pctype mapping reset\n"
831 " Reset flow type to pctype mapping on a port\n\n"
833 "port config (port_id) pctype mapping update"
834 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
835 " Update a flow type to pctype mapping item on a port\n\n"
837 "port config (port_id) pctype (pctype_id) hash_inset|"
838 "fdir_inset|fdir_flx_inset get|set|clear field\n"
840 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
842 "port config (port_id) pctype (pctype_id) hash_inset|"
843 "fdir_inset|fdir_flx_inset clear all"
844 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
846 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
847 " Add/remove UDP tunnel port for tunneling offload\n\n"
849 "port config <port_id> rx_offload vlan_strip|"
850 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
851 "outer_ipv4_cksum|macsec_strip|header_split|"
852 "vlan_filter|vlan_extend|jumbo_frame|"
853 "scatter|timestamp|security|keep_crc on|off\n"
854 " Enable or disable a per port Rx offloading"
855 " on all Rx queues of a port\n\n"
857 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
858 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
859 "outer_ipv4_cksum|macsec_strip|header_split|"
860 "vlan_filter|vlan_extend|jumbo_frame|"
861 "scatter|timestamp|security|keep_crc on|off\n"
862 " Enable or disable a per queue Rx offloading"
863 " only on a specific Rx queue\n\n"
865 "port config (port_id) tx_offload vlan_insert|"
866 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
867 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
868 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
869 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
870 "security|match_metadata on|off\n"
871 " Enable or disable a per port Tx offloading"
872 " on all Tx queues of a port\n\n"
874 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
875 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
876 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
877 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
878 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
880 " Enable or disable a per queue Tx offloading"
881 " only on a specific Tx queue\n\n"
883 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
884 " Load an eBPF program as a callback"
885 " for particular RX/TX queue\n\n"
887 "bpf-unload rx|tx (port) (queue)\n"
888 " Unload previously loaded eBPF program"
889 " for particular RX/TX queue\n\n"
891 "port config (port_id) tx_metadata (value)\n"
892 " Set Tx metadata value per port. Testpmd will add this value"
893 " to any Tx packet sent from this port\n\n"
897 if (show_all || !strcmp(res->section, "registers")) {
905 "read reg (port_id) (address)\n"
906 " Display value of a port register.\n\n"
908 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
909 " Display a port register bit field.\n\n"
911 "read regbit (port_id) (address) (bit_x)\n"
912 " Display a single port register bit.\n\n"
914 "write reg (port_id) (address) (value)\n"
915 " Set value of a port register.\n\n"
917 "write regfield (port_id) (address) (bit_x) (bit_y)"
919 " Set bit field of a port register.\n\n"
921 "write regbit (port_id) (address) (bit_x) (value)\n"
922 " Set single bit value of a port register.\n\n"
925 if (show_all || !strcmp(res->section, "filters")) {
933 "ethertype_filter (port_id) (add|del)"
934 " (mac_addr|mac_ignr) (mac_address) ethertype"
935 " (ether_type) (drop|fwd) queue (queue_id)\n"
936 " Add/Del an ethertype filter.\n\n"
938 "2tuple_filter (port_id) (add|del)"
939 " dst_port (dst_port_value) protocol (protocol_value)"
940 " mask (mask_value) tcp_flags (tcp_flags_value)"
941 " priority (prio_value) queue (queue_id)\n"
942 " Add/Del a 2tuple filter.\n\n"
944 "5tuple_filter (port_id) (add|del)"
945 " dst_ip (dst_address) src_ip (src_address)"
946 " dst_port (dst_port_value) src_port (src_port_value)"
947 " protocol (protocol_value)"
948 " mask (mask_value) tcp_flags (tcp_flags_value)"
949 " priority (prio_value) queue (queue_id)\n"
950 " Add/Del a 5tuple filter.\n\n"
952 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
953 " Add/Del syn filter.\n\n"
955 "flex_filter (port_id) (add|del) len (len_value)"
956 " bytes (bytes_value) mask (mask_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a flex filter.\n\n"
960 "flow_director_filter (port_id) mode IP (add|del|update)"
961 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
962 " src (src_ip_address) dst (dst_ip_address)"
963 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
964 " vlan (vlan_value) flexbytes (flexbytes_value)"
965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
966 " fd_id (fd_id_value)\n"
967 " Add/Del an IP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
971 " src (src_ip_address) (src_port)"
972 " dst (dst_ip_address) (dst_port)"
973 " tos (tos_value) ttl (ttl_value)"
974 " vlan (vlan_value) flexbytes (flexbytes_value)"
975 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
976 " fd_id (fd_id_value)\n"
977 " Add/Del an UDP/TCP type flow director filter.\n\n"
979 "flow_director_filter (port_id) mode IP (add|del|update)"
980 " flow (ipv4-sctp|ipv6-sctp)"
981 " src (src_ip_address) (src_port)"
982 " dst (dst_ip_address) (dst_port)"
983 " tag (verification_tag) "
984 " tos (tos_value) ttl (ttl_value)"
986 " flexbytes (flexbytes_value) (drop|fwd)"
987 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
988 " Add/Del a SCTP type flow director filter.\n\n"
990 "flow_director_filter (port_id) mode IP (add|del|update)"
991 " flow l2_payload ether (ethertype)"
992 " flexbytes (flexbytes_value) (drop|fwd)"
993 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
994 " Add/Del a l2 payload type flow director filter.\n\n"
996 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
997 " mac (mac_address) vlan (vlan_value)"
998 " flexbytes (flexbytes_value) (drop|fwd)"
999 " queue (queue_id) fd_id (fd_id_value)\n"
1000 " Add/Del a MAC-VLAN flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1003 " mac (mac_address) vlan (vlan_value)"
1004 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1005 " flexbytes (flexbytes_value) (drop|fwd)"
1006 " queue (queue_id) fd_id (fd_id_value)\n"
1007 " Add/Del a Tunnel flow director filter.\n\n"
1009 "flow_director_filter (port_id) mode raw (add|del|update)"
1010 " flow (flow_id) (drop|fwd) queue (queue_id)"
1011 " fd_id (fd_id_value) packet (packet file name)\n"
1012 " Add/Del a raw type flow director filter.\n\n"
1014 "flush_flow_director (port_id)\n"
1015 " Flush all flow director entries of a device.\n\n"
1017 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1018 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1019 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1020 " Set flow director IP mask.\n\n"
1022 "flow_director_mask (port_id) mode MAC-VLAN"
1023 " vlan (vlan_value)\n"
1024 " Set flow director MAC-VLAN mask.\n\n"
1026 "flow_director_mask (port_id) mode Tunnel"
1027 " vlan (vlan_value) mac (mac_value)"
1028 " tunnel-type (tunnel_type_value)"
1029 " tunnel-id (tunnel_id_value)\n"
1030 " Set flow director Tunnel mask.\n\n"
1032 "flow_director_flex_mask (port_id)"
1033 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1034 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1036 " Configure mask of flex payload.\n\n"
1038 "flow_director_flex_payload (port_id)"
1039 " (raw|l2|l3|l4) (config)\n"
1040 " Configure flex payload selection.\n\n"
1042 "get_sym_hash_ena_per_port (port_id)\n"
1043 " get symmetric hash enable configuration per port.\n\n"
1045 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1046 " set symmetric hash enable configuration per port"
1047 " to enable or disable.\n\n"
1049 "get_hash_global_config (port_id)\n"
1050 " Get the global configurations of hash filters.\n\n"
1052 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1053 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1054 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1055 " (enable|disable)\n"
1056 " Set the global configurations of hash filters.\n\n"
1058 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1059 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1060 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1061 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1062 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1063 "ipv6-next-header|udp-src-port|udp-dst-port|"
1064 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1065 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1066 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1067 "fld-8th|none) (select|add)\n"
1068 " Set the input set for hash.\n\n"
1070 "set_fdir_input_set (port_id) "
1071 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1072 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1073 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1074 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1075 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1076 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1077 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1079 " Set the input set for FDir.\n\n"
1081 "flow validate {port_id}"
1082 " [group {group_id}] [priority {level}]"
1083 " [ingress] [egress]"
1084 " pattern {item} [/ {item} [...]] / end"
1085 " actions {action} [/ {action} [...]] / end\n"
1086 " Check whether a flow rule can be created.\n\n"
1088 "flow create {port_id}"
1089 " [group {group_id}] [priority {level}]"
1090 " [ingress] [egress]"
1091 " pattern {item} [/ {item} [...]] / end"
1092 " actions {action} [/ {action} [...]] / end\n"
1093 " Create a flow rule.\n\n"
1095 "flow destroy {port_id} rule {rule_id} [...]\n"
1096 " Destroy specific flow rules.\n\n"
1098 "flow flush {port_id}\n"
1099 " Destroy all flow rules.\n\n"
1101 "flow query {port_id} {rule_id} {action}\n"
1102 " Query an existing flow rule.\n\n"
1104 "flow list {port_id} [group {group_id}] [...]\n"
1105 " List existing flow rules sorted by priority,"
1106 " filtered by group identifiers.\n\n"
1108 "flow isolate {port_id} {boolean}\n"
1109 " Restrict ingress traffic to the defined"
1112 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1113 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1114 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1115 " Configure the VXLAN encapsulation for flows.\n\n"
1117 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1118 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1119 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1120 " eth-dst (eth-dst)\n"
1121 " Configure the VXLAN encapsulation for flows.\n\n"
1123 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1124 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1125 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1126 " eth-dst (eth-dst)\n"
1127 " Configure the VXLAN encapsulation for flows.\n\n"
1129 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1130 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1132 " Configure the NVGRE encapsulation for flows.\n\n"
1134 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1135 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1136 " eth-src (eth-src) eth-dst (eth-dst)\n"
1137 " Configure the NVGRE encapsulation for flows.\n\n"
1139 "set raw_encap {flow items}\n"
1140 " Configure the encapsulation with raw data.\n\n"
1142 "set raw_decap {flow items}\n"
1143 " Configure the decapsulation with raw data.\n\n"
1148 if (show_all || !strcmp(res->section, "traffic_management")) {
1152 "Traffic Management:\n"
1154 "show port tm cap (port_id)\n"
1155 " Display the port TM capability.\n\n"
1157 "show port tm level cap (port_id) (level_id)\n"
1158 " Display the port TM hierarchical level capability.\n\n"
1160 "show port tm node cap (port_id) (node_id)\n"
1161 " Display the port TM node capability.\n\n"
1163 "show port tm node type (port_id) (node_id)\n"
1164 " Display the port TM node type.\n\n"
1166 "show port tm node stats (port_id) (node_id) (clear)\n"
1167 " Display the port TM node stats.\n\n"
1169 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1170 "set port tm hierarchy default (port_id)\n"
1171 " Set default traffic Management hierarchy on a port\n\n"
1174 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1175 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1176 " (packet_length_adjust)\n"
1177 " Add port tm node private shaper profile.\n\n"
1179 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1180 " Delete port tm node private shaper profile.\n\n"
1182 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1183 " (shaper_profile_id)\n"
1184 " Add/update port tm node shared shaper.\n\n"
1186 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1187 " Delete port tm node shared shaper.\n\n"
1189 "set port tm node shaper profile (port_id) (node_id)"
1190 " (shaper_profile_id)\n"
1191 " Set port tm node shaper profile.\n\n"
1193 "add port tm node wred profile (port_id) (wred_profile_id)"
1194 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1195 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1196 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1197 " Add port tm node wred profile.\n\n"
1199 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1200 " Delete port tm node wred profile.\n\n"
1202 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1203 " (priority) (weight) (level_id) (shaper_profile_id)"
1204 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1205 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1206 " Add port tm nonleaf node.\n\n"
1208 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1209 " (priority) (weight) (level_id) (shaper_profile_id)"
1210 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1211 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1212 " Add port tm leaf node.\n\n"
1214 "del port tm node (port_id) (node_id)\n"
1215 " Delete port tm node.\n\n"
1217 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1218 " (priority) (weight)\n"
1219 " Set port tm node parent.\n\n"
1221 "suspend port tm node (port_id) (node_id)"
1222 " Suspend tm node.\n\n"
1224 "resume port tm node (port_id) (node_id)"
1225 " Resume tm node.\n\n"
1227 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1228 " Commit tm hierarchy.\n\n"
1230 "set port tm mark ip_ecn (port) (green) (yellow)"
1232 " Enables/Disables the traffic management marking"
1233 " for IP ECN (Explicit Congestion Notification)"
1234 " packets on a given port\n\n"
1236 "set port tm mark ip_dscp (port) (green) (yellow)"
1238 " Enables/Disables the traffic management marking"
1239 " on the port for IP dscp packets\n\n"
1241 "set port tm mark vlan_dei (port) (green) (yellow)"
1243 " Enables/Disables the traffic management marking"
1244 " on the port for VLAN packets with DEI enabled\n\n"
1248 if (show_all || !strcmp(res->section, "devices")) {
1252 "Device Operations:\n"
1254 "device detach (identifier)\n"
1255 " Detach device by identifier.\n\n"
1261 cmdline_parse_token_string_t cmd_help_long_help =
1262 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1264 cmdline_parse_token_string_t cmd_help_long_section =
1265 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1266 "all#control#display#config#"
1267 "ports#registers#filters#traffic_management#devices");
1269 cmdline_parse_inst_t cmd_help_long = {
1270 .f = cmd_help_long_parsed,
1272 .help_str = "help all|control|display|config|ports|register|"
1273 "filters|traffic_management|devices: "
1276 (void *)&cmd_help_long_help,
1277 (void *)&cmd_help_long_section,
1283 /* *** start/stop/close all ports *** */
1284 struct cmd_operate_port_result {
1285 cmdline_fixed_string_t keyword;
1286 cmdline_fixed_string_t name;
1287 cmdline_fixed_string_t value;
1290 static void cmd_operate_port_parsed(void *parsed_result,
1291 __attribute__((unused)) struct cmdline *cl,
1292 __attribute__((unused)) void *data)
1294 struct cmd_operate_port_result *res = parsed_result;
1296 if (!strcmp(res->name, "start"))
1297 start_port(RTE_PORT_ALL);
1298 else if (!strcmp(res->name, "stop"))
1299 stop_port(RTE_PORT_ALL);
1300 else if (!strcmp(res->name, "close"))
1301 close_port(RTE_PORT_ALL);
1302 else if (!strcmp(res->name, "reset"))
1303 reset_port(RTE_PORT_ALL);
1305 printf("Unknown parameter\n");
1308 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1309 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1311 cmdline_parse_token_string_t cmd_operate_port_all_port =
1312 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1313 "start#stop#close#reset");
1314 cmdline_parse_token_string_t cmd_operate_port_all_all =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1317 cmdline_parse_inst_t cmd_operate_port = {
1318 .f = cmd_operate_port_parsed,
1320 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1322 (void *)&cmd_operate_port_all_cmd,
1323 (void *)&cmd_operate_port_all_port,
1324 (void *)&cmd_operate_port_all_all,
1329 /* *** start/stop/close specific port *** */
1330 struct cmd_operate_specific_port_result {
1331 cmdline_fixed_string_t keyword;
1332 cmdline_fixed_string_t name;
1336 static void cmd_operate_specific_port_parsed(void *parsed_result,
1337 __attribute__((unused)) struct cmdline *cl,
1338 __attribute__((unused)) void *data)
1340 struct cmd_operate_specific_port_result *res = parsed_result;
1342 if (!strcmp(res->name, "start"))
1343 start_port(res->value);
1344 else if (!strcmp(res->name, "stop"))
1345 stop_port(res->value);
1346 else if (!strcmp(res->name, "close"))
1347 close_port(res->value);
1348 else if (!strcmp(res->name, "reset"))
1349 reset_port(res->value);
1351 printf("Unknown parameter\n");
1354 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1355 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1357 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1358 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1359 name, "start#stop#close#reset");
1360 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1361 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1364 cmdline_parse_inst_t cmd_operate_specific_port = {
1365 .f = cmd_operate_specific_port_parsed,
1367 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1369 (void *)&cmd_operate_specific_port_cmd,
1370 (void *)&cmd_operate_specific_port_port,
1371 (void *)&cmd_operate_specific_port_id,
1376 /* *** enable port setup (after attach) via iterator or event *** */
1377 struct cmd_set_port_setup_on_result {
1378 cmdline_fixed_string_t set;
1379 cmdline_fixed_string_t port;
1380 cmdline_fixed_string_t setup;
1381 cmdline_fixed_string_t on;
1382 cmdline_fixed_string_t mode;
1385 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1386 __attribute__((unused)) struct cmdline *cl,
1387 __attribute__((unused)) void *data)
1389 struct cmd_set_port_setup_on_result *res = parsed_result;
1391 if (strcmp(res->mode, "event") == 0)
1392 setup_on_probe_event = true;
1393 else if (strcmp(res->mode, "iterator") == 0)
1394 setup_on_probe_event = false;
1396 printf("Unknown mode\n");
1399 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1400 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1402 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1403 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1405 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1406 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1408 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1411 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1412 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1413 mode, "iterator#event");
1415 cmdline_parse_inst_t cmd_set_port_setup_on = {
1416 .f = cmd_set_port_setup_on_parsed,
1418 .help_str = "set port setup on iterator|event",
1420 (void *)&cmd_set_port_setup_on_set,
1421 (void *)&cmd_set_port_setup_on_port,
1422 (void *)&cmd_set_port_setup_on_setup,
1423 (void *)&cmd_set_port_setup_on_on,
1424 (void *)&cmd_set_port_setup_on_mode,
1429 /* *** attach a specified port *** */
1430 struct cmd_operate_attach_port_result {
1431 cmdline_fixed_string_t port;
1432 cmdline_fixed_string_t keyword;
1433 cmdline_fixed_string_t identifier;
1436 static void cmd_operate_attach_port_parsed(void *parsed_result,
1437 __attribute__((unused)) struct cmdline *cl,
1438 __attribute__((unused)) void *data)
1440 struct cmd_operate_attach_port_result *res = parsed_result;
1442 if (!strcmp(res->keyword, "attach"))
1443 attach_port(res->identifier);
1445 printf("Unknown parameter\n");
1448 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1449 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1451 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1452 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1454 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1458 cmdline_parse_inst_t cmd_operate_attach_port = {
1459 .f = cmd_operate_attach_port_parsed,
1461 .help_str = "port attach <identifier>: "
1462 "(identifier: pci address or virtual dev name)",
1464 (void *)&cmd_operate_attach_port_port,
1465 (void *)&cmd_operate_attach_port_keyword,
1466 (void *)&cmd_operate_attach_port_identifier,
1471 /* *** detach a specified port *** */
1472 struct cmd_operate_detach_port_result {
1473 cmdline_fixed_string_t port;
1474 cmdline_fixed_string_t keyword;
1478 static void cmd_operate_detach_port_parsed(void *parsed_result,
1479 __attribute__((unused)) struct cmdline *cl,
1480 __attribute__((unused)) void *data)
1482 struct cmd_operate_detach_port_result *res = parsed_result;
1484 if (!strcmp(res->keyword, "detach"))
1485 detach_port_device(res->port_id);
1487 printf("Unknown parameter\n");
1490 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1491 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1493 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1494 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1496 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1497 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1500 cmdline_parse_inst_t cmd_operate_detach_port = {
1501 .f = cmd_operate_detach_port_parsed,
1503 .help_str = "port detach <port_id>",
1505 (void *)&cmd_operate_detach_port_port,
1506 (void *)&cmd_operate_detach_port_keyword,
1507 (void *)&cmd_operate_detach_port_port_id,
1512 /* *** detach device by identifier *** */
1513 struct cmd_operate_detach_device_result {
1514 cmdline_fixed_string_t device;
1515 cmdline_fixed_string_t keyword;
1516 cmdline_fixed_string_t identifier;
1519 static void cmd_operate_detach_device_parsed(void *parsed_result,
1520 __attribute__((unused)) struct cmdline *cl,
1521 __attribute__((unused)) void *data)
1523 struct cmd_operate_detach_device_result *res = parsed_result;
1525 if (!strcmp(res->keyword, "detach"))
1526 detach_device(res->identifier);
1528 printf("Unknown parameter\n");
1531 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1532 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1534 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1535 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1537 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1538 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1541 cmdline_parse_inst_t cmd_operate_detach_device = {
1542 .f = cmd_operate_detach_device_parsed,
1544 .help_str = "device detach <identifier>:"
1545 "(identifier: pci address or virtual dev name)",
1547 (void *)&cmd_operate_detach_device_device,
1548 (void *)&cmd_operate_detach_device_keyword,
1549 (void *)&cmd_operate_detach_device_identifier,
1553 /* *** configure speed for all ports *** */
1554 struct cmd_config_speed_all {
1555 cmdline_fixed_string_t port;
1556 cmdline_fixed_string_t keyword;
1557 cmdline_fixed_string_t all;
1558 cmdline_fixed_string_t item1;
1559 cmdline_fixed_string_t item2;
1560 cmdline_fixed_string_t value1;
1561 cmdline_fixed_string_t value2;
1565 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1570 if (!strcmp(duplexstr, "half")) {
1571 duplex = ETH_LINK_HALF_DUPLEX;
1572 } else if (!strcmp(duplexstr, "full")) {
1573 duplex = ETH_LINK_FULL_DUPLEX;
1574 } else if (!strcmp(duplexstr, "auto")) {
1575 duplex = ETH_LINK_FULL_DUPLEX;
1577 printf("Unknown duplex parameter\n");
1581 if (!strcmp(speedstr, "10")) {
1582 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1583 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1584 } else if (!strcmp(speedstr, "100")) {
1585 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1586 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1588 if (duplex != ETH_LINK_FULL_DUPLEX) {
1589 printf("Invalid speed/duplex parameters\n");
1592 if (!strcmp(speedstr, "1000")) {
1593 *speed = ETH_LINK_SPEED_1G;
1594 } else if (!strcmp(speedstr, "10000")) {
1595 *speed = ETH_LINK_SPEED_10G;
1596 } else if (!strcmp(speedstr, "25000")) {
1597 *speed = ETH_LINK_SPEED_25G;
1598 } else if (!strcmp(speedstr, "40000")) {
1599 *speed = ETH_LINK_SPEED_40G;
1600 } else if (!strcmp(speedstr, "50000")) {
1601 *speed = ETH_LINK_SPEED_50G;
1602 } else if (!strcmp(speedstr, "100000")) {
1603 *speed = ETH_LINK_SPEED_100G;
1604 } else if (!strcmp(speedstr, "auto")) {
1605 *speed = ETH_LINK_SPEED_AUTONEG;
1607 printf("Unknown speed parameter\n");
1616 cmd_config_speed_all_parsed(void *parsed_result,
1617 __attribute__((unused)) struct cmdline *cl,
1618 __attribute__((unused)) void *data)
1620 struct cmd_config_speed_all *res = parsed_result;
1621 uint32_t link_speed;
1624 if (!all_ports_stopped()) {
1625 printf("Please stop all ports first\n");
1629 if (parse_and_check_speed_duplex(res->value1, res->value2,
1633 RTE_ETH_FOREACH_DEV(pid) {
1634 ports[pid].dev_conf.link_speeds = link_speed;
1637 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1640 cmdline_parse_token_string_t cmd_config_speed_all_port =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1642 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1645 cmdline_parse_token_string_t cmd_config_speed_all_all =
1646 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1647 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1649 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1651 "10#100#1000#10000#25000#40000#50000#100000#auto");
1652 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1654 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1658 cmdline_parse_inst_t cmd_config_speed_all = {
1659 .f = cmd_config_speed_all_parsed,
1661 .help_str = "port config all speed "
1662 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1665 (void *)&cmd_config_speed_all_port,
1666 (void *)&cmd_config_speed_all_keyword,
1667 (void *)&cmd_config_speed_all_all,
1668 (void *)&cmd_config_speed_all_item1,
1669 (void *)&cmd_config_speed_all_value1,
1670 (void *)&cmd_config_speed_all_item2,
1671 (void *)&cmd_config_speed_all_value2,
1676 /* *** configure speed for specific port *** */
1677 struct cmd_config_speed_specific {
1678 cmdline_fixed_string_t port;
1679 cmdline_fixed_string_t keyword;
1681 cmdline_fixed_string_t item1;
1682 cmdline_fixed_string_t item2;
1683 cmdline_fixed_string_t value1;
1684 cmdline_fixed_string_t value2;
1688 cmd_config_speed_specific_parsed(void *parsed_result,
1689 __attribute__((unused)) struct cmdline *cl,
1690 __attribute__((unused)) void *data)
1692 struct cmd_config_speed_specific *res = parsed_result;
1693 uint32_t link_speed;
1695 if (!all_ports_stopped()) {
1696 printf("Please stop all ports first\n");
1700 if (port_id_is_invalid(res->id, ENABLED_WARN))
1703 if (parse_and_check_speed_duplex(res->value1, res->value2,
1707 ports[res->id].dev_conf.link_speeds = link_speed;
1709 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1713 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1716 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1719 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1720 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1721 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1724 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1726 "10#100#1000#10000#25000#40000#50000#100000#auto");
1727 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1730 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1734 cmdline_parse_inst_t cmd_config_speed_specific = {
1735 .f = cmd_config_speed_specific_parsed,
1737 .help_str = "port config <port_id> speed "
1738 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1741 (void *)&cmd_config_speed_specific_port,
1742 (void *)&cmd_config_speed_specific_keyword,
1743 (void *)&cmd_config_speed_specific_id,
1744 (void *)&cmd_config_speed_specific_item1,
1745 (void *)&cmd_config_speed_specific_value1,
1746 (void *)&cmd_config_speed_specific_item2,
1747 (void *)&cmd_config_speed_specific_value2,
1752 /* *** configure loopback for all ports *** */
1753 struct cmd_config_loopback_all {
1754 cmdline_fixed_string_t port;
1755 cmdline_fixed_string_t keyword;
1756 cmdline_fixed_string_t all;
1757 cmdline_fixed_string_t item;
1762 cmd_config_loopback_all_parsed(void *parsed_result,
1763 __attribute__((unused)) struct cmdline *cl,
1764 __attribute__((unused)) void *data)
1766 struct cmd_config_loopback_all *res = parsed_result;
1769 if (!all_ports_stopped()) {
1770 printf("Please stop all ports first\n");
1774 RTE_ETH_FOREACH_DEV(pid) {
1775 ports[pid].dev_conf.lpbk_mode = res->mode;
1778 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1781 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1783 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1784 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1786 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1788 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1791 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1792 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1794 cmdline_parse_inst_t cmd_config_loopback_all = {
1795 .f = cmd_config_loopback_all_parsed,
1797 .help_str = "port config all loopback <mode>",
1799 (void *)&cmd_config_loopback_all_port,
1800 (void *)&cmd_config_loopback_all_keyword,
1801 (void *)&cmd_config_loopback_all_all,
1802 (void *)&cmd_config_loopback_all_item,
1803 (void *)&cmd_config_loopback_all_mode,
1808 /* *** configure loopback for specific port *** */
1809 struct cmd_config_loopback_specific {
1810 cmdline_fixed_string_t port;
1811 cmdline_fixed_string_t keyword;
1813 cmdline_fixed_string_t item;
1818 cmd_config_loopback_specific_parsed(void *parsed_result,
1819 __attribute__((unused)) struct cmdline *cl,
1820 __attribute__((unused)) void *data)
1822 struct cmd_config_loopback_specific *res = parsed_result;
1824 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1827 if (!port_is_stopped(res->port_id)) {
1828 printf("Please stop port %u first\n", res->port_id);
1832 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1834 cmd_reconfig_device_queue(res->port_id, 1, 1);
1838 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1841 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1844 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1845 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1847 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1850 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1851 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1854 cmdline_parse_inst_t cmd_config_loopback_specific = {
1855 .f = cmd_config_loopback_specific_parsed,
1857 .help_str = "port config <port_id> loopback <mode>",
1859 (void *)&cmd_config_loopback_specific_port,
1860 (void *)&cmd_config_loopback_specific_keyword,
1861 (void *)&cmd_config_loopback_specific_id,
1862 (void *)&cmd_config_loopback_specific_item,
1863 (void *)&cmd_config_loopback_specific_mode,
1868 /* *** configure txq/rxq, txd/rxd *** */
1869 struct cmd_config_rx_tx {
1870 cmdline_fixed_string_t port;
1871 cmdline_fixed_string_t keyword;
1872 cmdline_fixed_string_t all;
1873 cmdline_fixed_string_t name;
1878 cmd_config_rx_tx_parsed(void *parsed_result,
1879 __attribute__((unused)) struct cmdline *cl,
1880 __attribute__((unused)) void *data)
1882 struct cmd_config_rx_tx *res = parsed_result;
1884 if (!all_ports_stopped()) {
1885 printf("Please stop all ports first\n");
1888 if (!strcmp(res->name, "rxq")) {
1889 if (!res->value && !nb_txq) {
1890 printf("Warning: Either rx or tx queues should be non zero\n");
1893 if (check_nb_rxq(res->value) != 0)
1895 nb_rxq = res->value;
1897 else if (!strcmp(res->name, "txq")) {
1898 if (!res->value && !nb_rxq) {
1899 printf("Warning: Either rx or tx queues should be non zero\n");
1902 if (check_nb_txq(res->value) != 0)
1904 nb_txq = res->value;
1906 else if (!strcmp(res->name, "rxd")) {
1907 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1908 printf("rxd %d invalid - must be > 0 && <= %d\n",
1909 res->value, RTE_TEST_RX_DESC_MAX);
1912 nb_rxd = res->value;
1913 } else if (!strcmp(res->name, "txd")) {
1914 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1915 printf("txd %d invalid - must be > 0 && <= %d\n",
1916 res->value, RTE_TEST_TX_DESC_MAX);
1919 nb_txd = res->value;
1921 printf("Unknown parameter\n");
1929 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1932 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1934 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1936 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1938 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1941 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1942 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1944 cmdline_parse_inst_t cmd_config_rx_tx = {
1945 .f = cmd_config_rx_tx_parsed,
1947 .help_str = "port config all rxq|txq|rxd|txd <value>",
1949 (void *)&cmd_config_rx_tx_port,
1950 (void *)&cmd_config_rx_tx_keyword,
1951 (void *)&cmd_config_rx_tx_all,
1952 (void *)&cmd_config_rx_tx_name,
1953 (void *)&cmd_config_rx_tx_value,
1958 /* *** config max packet length *** */
1959 struct cmd_config_max_pkt_len_result {
1960 cmdline_fixed_string_t port;
1961 cmdline_fixed_string_t keyword;
1962 cmdline_fixed_string_t all;
1963 cmdline_fixed_string_t name;
1968 cmd_config_max_pkt_len_parsed(void *parsed_result,
1969 __attribute__((unused)) struct cmdline *cl,
1970 __attribute__((unused)) void *data)
1972 struct cmd_config_max_pkt_len_result *res = parsed_result;
1975 if (!all_ports_stopped()) {
1976 printf("Please stop all ports first\n");
1980 RTE_ETH_FOREACH_DEV(pid) {
1981 struct rte_port *port = &ports[pid];
1982 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1984 if (!strcmp(res->name, "max-pkt-len")) {
1985 if (res->value < RTE_ETHER_MIN_LEN) {
1986 printf("max-pkt-len can not be less than %d\n",
1990 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1993 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1994 if (res->value > RTE_ETHER_MAX_LEN)
1995 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1997 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1998 port->dev_conf.rxmode.offloads = rx_offloads;
2000 printf("Unknown parameter\n");
2007 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2010 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2013 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2016 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2022 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2023 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2026 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2027 .f = cmd_config_max_pkt_len_parsed,
2029 .help_str = "port config all max-pkt-len <value>",
2031 (void *)&cmd_config_max_pkt_len_port,
2032 (void *)&cmd_config_max_pkt_len_keyword,
2033 (void *)&cmd_config_max_pkt_len_all,
2034 (void *)&cmd_config_max_pkt_len_name,
2035 (void *)&cmd_config_max_pkt_len_value,
2040 /* *** configure port MTU *** */
2041 struct cmd_config_mtu_result {
2042 cmdline_fixed_string_t port;
2043 cmdline_fixed_string_t keyword;
2044 cmdline_fixed_string_t mtu;
2050 cmd_config_mtu_parsed(void *parsed_result,
2051 __attribute__((unused)) struct cmdline *cl,
2052 __attribute__((unused)) void *data)
2054 struct cmd_config_mtu_result *res = parsed_result;
2056 if (res->value < RTE_ETHER_MIN_LEN) {
2057 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2060 port_mtu_set(res->port_id, res->value);
2063 cmdline_parse_token_string_t cmd_config_mtu_port =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2066 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2069 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2072 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2073 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2074 cmdline_parse_token_num_t cmd_config_mtu_value =
2075 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2077 cmdline_parse_inst_t cmd_config_mtu = {
2078 .f = cmd_config_mtu_parsed,
2080 .help_str = "port config mtu <port_id> <value>",
2082 (void *)&cmd_config_mtu_port,
2083 (void *)&cmd_config_mtu_keyword,
2084 (void *)&cmd_config_mtu_mtu,
2085 (void *)&cmd_config_mtu_port_id,
2086 (void *)&cmd_config_mtu_value,
2091 /* *** configure rx mode *** */
2092 struct cmd_config_rx_mode_flag {
2093 cmdline_fixed_string_t port;
2094 cmdline_fixed_string_t keyword;
2095 cmdline_fixed_string_t all;
2096 cmdline_fixed_string_t name;
2097 cmdline_fixed_string_t value;
2101 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2102 __attribute__((unused)) struct cmdline *cl,
2103 __attribute__((unused)) void *data)
2105 struct cmd_config_rx_mode_flag *res = parsed_result;
2107 if (!all_ports_stopped()) {
2108 printf("Please stop all ports first\n");
2112 if (!strcmp(res->name, "drop-en")) {
2113 if (!strcmp(res->value, "on"))
2115 else if (!strcmp(res->value, "off"))
2118 printf("Unknown parameter\n");
2122 printf("Unknown parameter\n");
2128 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2131 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2133 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2142 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2145 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2146 .f = cmd_config_rx_mode_flag_parsed,
2148 .help_str = "port config all drop-en on|off",
2150 (void *)&cmd_config_rx_mode_flag_port,
2151 (void *)&cmd_config_rx_mode_flag_keyword,
2152 (void *)&cmd_config_rx_mode_flag_all,
2153 (void *)&cmd_config_rx_mode_flag_name,
2154 (void *)&cmd_config_rx_mode_flag_value,
2159 /* *** configure rss *** */
2160 struct cmd_config_rss {
2161 cmdline_fixed_string_t port;
2162 cmdline_fixed_string_t keyword;
2163 cmdline_fixed_string_t all;
2164 cmdline_fixed_string_t name;
2165 cmdline_fixed_string_t value;
2169 cmd_config_rss_parsed(void *parsed_result,
2170 __attribute__((unused)) struct cmdline *cl,
2171 __attribute__((unused)) void *data)
2173 struct cmd_config_rss *res = parsed_result;
2174 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2175 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2176 int use_default = 0;
2177 int all_updated = 1;
2182 if (!strcmp(res->value, "all"))
2183 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2184 ETH_RSS_UDP | ETH_RSS_SCTP |
2186 else if (!strcmp(res->value, "ip"))
2187 rss_conf.rss_hf = ETH_RSS_IP;
2188 else if (!strcmp(res->value, "udp"))
2189 rss_conf.rss_hf = ETH_RSS_UDP;
2190 else if (!strcmp(res->value, "tcp"))
2191 rss_conf.rss_hf = ETH_RSS_TCP;
2192 else if (!strcmp(res->value, "sctp"))
2193 rss_conf.rss_hf = ETH_RSS_SCTP;
2194 else if (!strcmp(res->value, "ether"))
2195 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2196 else if (!strcmp(res->value, "port"))
2197 rss_conf.rss_hf = ETH_RSS_PORT;
2198 else if (!strcmp(res->value, "vxlan"))
2199 rss_conf.rss_hf = ETH_RSS_VXLAN;
2200 else if (!strcmp(res->value, "geneve"))
2201 rss_conf.rss_hf = ETH_RSS_GENEVE;
2202 else if (!strcmp(res->value, "nvgre"))
2203 rss_conf.rss_hf = ETH_RSS_NVGRE;
2204 else if (!strcmp(res->value, "l3-src-only"))
2205 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2206 else if (!strcmp(res->value, "l3-dst-only"))
2207 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2208 else if (!strcmp(res->value, "l4-src-only"))
2209 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2210 else if (!strcmp(res->value, "l4-dst-only"))
2211 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2212 else if (!strcmp(res->value, "none"))
2213 rss_conf.rss_hf = 0;
2214 else if (!strcmp(res->value, "default"))
2216 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2217 atoi(res->value) < 64)
2218 rss_conf.rss_hf = 1ULL << atoi(res->value);
2220 printf("Unknown parameter\n");
2223 rss_conf.rss_key = NULL;
2224 /* Update global configuration for RSS types. */
2225 RTE_ETH_FOREACH_DEV(i) {
2226 struct rte_eth_rss_conf local_rss_conf;
2228 ret = eth_dev_info_get_print_err(i, &dev_info);
2233 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2235 local_rss_conf = rss_conf;
2236 local_rss_conf.rss_hf = rss_conf.rss_hf &
2237 dev_info.flow_type_rss_offloads;
2238 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2239 printf("Port %u modified RSS hash function based on hardware support,"
2240 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2241 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2243 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2246 printf("Configuration of RSS hash at ethernet port %d "
2247 "failed with error (%d): %s.\n",
2248 i, -diag, strerror(-diag));
2251 if (all_updated && !use_default)
2252 rss_hf = rss_conf.rss_hf;
2255 cmdline_parse_token_string_t cmd_config_rss_port =
2256 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2257 cmdline_parse_token_string_t cmd_config_rss_keyword =
2258 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2259 cmdline_parse_token_string_t cmd_config_rss_all =
2260 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2261 cmdline_parse_token_string_t cmd_config_rss_name =
2262 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2263 cmdline_parse_token_string_t cmd_config_rss_value =
2264 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2266 cmdline_parse_inst_t cmd_config_rss = {
2267 .f = cmd_config_rss_parsed,
2269 .help_str = "port config all rss "
2270 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2272 (void *)&cmd_config_rss_port,
2273 (void *)&cmd_config_rss_keyword,
2274 (void *)&cmd_config_rss_all,
2275 (void *)&cmd_config_rss_name,
2276 (void *)&cmd_config_rss_value,
2281 /* *** configure rss hash key *** */
2282 struct cmd_config_rss_hash_key {
2283 cmdline_fixed_string_t port;
2284 cmdline_fixed_string_t config;
2286 cmdline_fixed_string_t rss_hash_key;
2287 cmdline_fixed_string_t rss_type;
2288 cmdline_fixed_string_t key;
2292 hexa_digit_to_value(char hexa_digit)
2294 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2295 return (uint8_t) (hexa_digit - '0');
2296 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2297 return (uint8_t) ((hexa_digit - 'a') + 10);
2298 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2299 return (uint8_t) ((hexa_digit - 'A') + 10);
2300 /* Invalid hexa digit */
2305 parse_and_check_key_hexa_digit(char *key, int idx)
2309 hexa_v = hexa_digit_to_value(key[idx]);
2311 printf("invalid key: character %c at position %d is not a "
2312 "valid hexa digit\n", key[idx], idx);
2317 cmd_config_rss_hash_key_parsed(void *parsed_result,
2318 __attribute__((unused)) struct cmdline *cl,
2319 __attribute__((unused)) void *data)
2321 struct cmd_config_rss_hash_key *res = parsed_result;
2322 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2326 struct rte_eth_dev_info dev_info;
2327 uint8_t hash_key_size;
2331 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2335 if (dev_info.hash_key_size > 0 &&
2336 dev_info.hash_key_size <= sizeof(hash_key))
2337 hash_key_size = dev_info.hash_key_size;
2339 printf("dev_info did not provide a valid hash key size\n");
2342 /* Check the length of the RSS hash key */
2343 key_len = strlen(res->key);
2344 if (key_len != (hash_key_size * 2)) {
2345 printf("key length: %d invalid - key must be a string of %d"
2346 " hexa-decimal numbers\n",
2347 (int) key_len, hash_key_size * 2);
2350 /* Translate RSS hash key into binary representation */
2351 for (i = 0; i < hash_key_size; i++) {
2352 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2355 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2358 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2360 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2364 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2365 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2366 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2367 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2369 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2370 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2371 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2372 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2373 rss_hash_key, "rss-hash-key");
2374 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2375 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2376 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2377 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2378 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2379 "ipv6-tcp-ex#ipv6-udp-ex#"
2380 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2381 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2382 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2384 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2385 .f = cmd_config_rss_hash_key_parsed,
2387 .help_str = "port config <port_id> rss-hash-key "
2388 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2389 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2390 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2391 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2392 "<string of hex digits (variable length, NIC dependent)>",
2394 (void *)&cmd_config_rss_hash_key_port,
2395 (void *)&cmd_config_rss_hash_key_config,
2396 (void *)&cmd_config_rss_hash_key_port_id,
2397 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2398 (void *)&cmd_config_rss_hash_key_rss_type,
2399 (void *)&cmd_config_rss_hash_key_value,
2404 /* *** configure port rxq/txq ring size *** */
2405 struct cmd_config_rxtx_ring_size {
2406 cmdline_fixed_string_t port;
2407 cmdline_fixed_string_t config;
2409 cmdline_fixed_string_t rxtxq;
2411 cmdline_fixed_string_t rsize;
2416 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2417 __attribute__((unused)) struct cmdline *cl,
2418 __attribute__((unused)) void *data)
2420 struct cmd_config_rxtx_ring_size *res = parsed_result;
2421 struct rte_port *port;
2424 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2427 if (res->portid == (portid_t)RTE_PORT_ALL) {
2428 printf("Invalid port id\n");
2432 port = &ports[res->portid];
2434 if (!strcmp(res->rxtxq, "rxq"))
2436 else if (!strcmp(res->rxtxq, "txq"))
2439 printf("Unknown parameter\n");
2443 if (isrx && rx_queue_id_is_invalid(res->qid))
2445 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2448 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2449 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2455 port->nb_rx_desc[res->qid] = res->size;
2457 port->nb_tx_desc[res->qid] = res->size;
2459 cmd_reconfig_device_queue(res->portid, 0, 1);
2462 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2463 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2465 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2466 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2468 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2469 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2471 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2472 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2474 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2475 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2477 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2478 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2479 rsize, "ring_size");
2480 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2481 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2484 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2485 .f = cmd_config_rxtx_ring_size_parsed,
2487 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2489 (void *)&cmd_config_rxtx_ring_size_port,
2490 (void *)&cmd_config_rxtx_ring_size_config,
2491 (void *)&cmd_config_rxtx_ring_size_portid,
2492 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2493 (void *)&cmd_config_rxtx_ring_size_qid,
2494 (void *)&cmd_config_rxtx_ring_size_rsize,
2495 (void *)&cmd_config_rxtx_ring_size_size,
2500 /* *** configure port rxq/txq start/stop *** */
2501 struct cmd_config_rxtx_queue {
2502 cmdline_fixed_string_t port;
2504 cmdline_fixed_string_t rxtxq;
2506 cmdline_fixed_string_t opname;
2510 cmd_config_rxtx_queue_parsed(void *parsed_result,
2511 __attribute__((unused)) struct cmdline *cl,
2512 __attribute__((unused)) void *data)
2514 struct cmd_config_rxtx_queue *res = parsed_result;
2519 if (test_done == 0) {
2520 printf("Please stop forwarding first\n");
2524 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2527 if (port_is_started(res->portid) != 1) {
2528 printf("Please start port %u first\n", res->portid);
2532 if (!strcmp(res->rxtxq, "rxq"))
2534 else if (!strcmp(res->rxtxq, "txq"))
2537 printf("Unknown parameter\n");
2541 if (isrx && rx_queue_id_is_invalid(res->qid))
2543 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2546 if (!strcmp(res->opname, "start"))
2548 else if (!strcmp(res->opname, "stop"))
2551 printf("Unknown parameter\n");
2555 if (isstart && isrx)
2556 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2557 else if (!isstart && isrx)
2558 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2559 else if (isstart && !isrx)
2560 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2562 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2564 if (ret == -ENOTSUP)
2565 printf("Function not supported in PMD driver\n");
2568 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2569 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2570 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2571 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2572 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2573 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2574 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2575 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2576 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2577 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2580 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2581 .f = cmd_config_rxtx_queue_parsed,
2583 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2585 (void *)&cmd_config_rxtx_queue_port,
2586 (void *)&cmd_config_rxtx_queue_portid,
2587 (void *)&cmd_config_rxtx_queue_rxtxq,
2588 (void *)&cmd_config_rxtx_queue_qid,
2589 (void *)&cmd_config_rxtx_queue_opname,
2594 /* *** configure port rxq/txq deferred start on/off *** */
2595 struct cmd_config_deferred_start_rxtx_queue {
2596 cmdline_fixed_string_t port;
2598 cmdline_fixed_string_t rxtxq;
2600 cmdline_fixed_string_t opname;
2601 cmdline_fixed_string_t state;
2605 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2606 __attribute__((unused)) struct cmdline *cl,
2607 __attribute__((unused)) void *data)
2609 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2610 struct rte_port *port;
2613 uint8_t needreconfig = 0;
2615 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2618 if (port_is_started(res->port_id) != 0) {
2619 printf("Please stop port %u first\n", res->port_id);
2623 port = &ports[res->port_id];
2625 isrx = !strcmp(res->rxtxq, "rxq");
2627 if (isrx && rx_queue_id_is_invalid(res->qid))
2629 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2632 ison = !strcmp(res->state, "on");
2634 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2635 port->rx_conf[res->qid].rx_deferred_start = ison;
2637 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2638 port->tx_conf[res->qid].tx_deferred_start = ison;
2643 cmd_reconfig_device_queue(res->port_id, 0, 1);
2646 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2647 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2649 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2650 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2652 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2653 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2655 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2656 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2658 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2659 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2660 opname, "deferred_start");
2661 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2662 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2665 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2666 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2668 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2670 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2671 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2672 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2673 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2674 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2675 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2680 /* *** configure port rxq/txq setup *** */
2681 struct cmd_setup_rxtx_queue {
2682 cmdline_fixed_string_t port;
2684 cmdline_fixed_string_t rxtxq;
2686 cmdline_fixed_string_t setup;
2689 /* Common CLI fields for queue setup */
2690 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2691 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2692 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2693 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2694 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2695 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2696 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2697 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2698 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2699 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2702 cmd_setup_rxtx_queue_parsed(
2703 void *parsed_result,
2704 __attribute__((unused)) struct cmdline *cl,
2705 __attribute__((unused)) void *data)
2707 struct cmd_setup_rxtx_queue *res = parsed_result;
2708 struct rte_port *port;
2709 struct rte_mempool *mp;
2710 unsigned int socket_id;
2714 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2717 if (res->portid == (portid_t)RTE_PORT_ALL) {
2718 printf("Invalid port id\n");
2722 if (!strcmp(res->rxtxq, "rxq"))
2724 else if (!strcmp(res->rxtxq, "txq"))
2727 printf("Unknown parameter\n");
2731 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2732 printf("Invalid rx queue\n");
2734 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2735 printf("Invalid tx queue\n");
2739 port = &ports[res->portid];
2741 socket_id = rxring_numa[res->portid];
2742 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2743 socket_id = port->socket_id;
2745 mp = mbuf_pool_find(socket_id);
2747 printf("Failed to setup RX queue: "
2748 "No mempool allocation"
2749 " on the socket %d\n",
2750 rxring_numa[res->portid]);
2753 ret = rte_eth_rx_queue_setup(res->portid,
2755 port->nb_rx_desc[res->qid],
2757 &port->rx_conf[res->qid],
2760 printf("Failed to setup RX queue\n");
2762 socket_id = txring_numa[res->portid];
2763 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2764 socket_id = port->socket_id;
2766 ret = rte_eth_tx_queue_setup(res->portid,
2768 port->nb_tx_desc[res->qid],
2770 &port->tx_conf[res->qid]);
2772 printf("Failed to setup TX queue\n");
2776 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2777 .f = cmd_setup_rxtx_queue_parsed,
2779 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2781 (void *)&cmd_setup_rxtx_queue_port,
2782 (void *)&cmd_setup_rxtx_queue_portid,
2783 (void *)&cmd_setup_rxtx_queue_rxtxq,
2784 (void *)&cmd_setup_rxtx_queue_qid,
2785 (void *)&cmd_setup_rxtx_queue_setup,
2791 /* *** Configure RSS RETA *** */
2792 struct cmd_config_rss_reta {
2793 cmdline_fixed_string_t port;
2794 cmdline_fixed_string_t keyword;
2796 cmdline_fixed_string_t name;
2797 cmdline_fixed_string_t list_name;
2798 cmdline_fixed_string_t list_of_items;
2802 parse_reta_config(const char *str,
2803 struct rte_eth_rss_reta_entry64 *reta_conf,
2804 uint16_t nb_entries)
2808 uint16_t hash_index, idx, shift;
2811 const char *p, *p0 = str;
2818 unsigned long int_fld[_NUM_FLD];
2819 char *str_fld[_NUM_FLD];
2821 while ((p = strchr(p0,'(')) != NULL) {
2823 if((p0 = strchr(p,')')) == NULL)
2827 if(size >= sizeof(s))
2830 snprintf(s, sizeof(s), "%.*s", size, p);
2831 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2833 for (i = 0; i < _NUM_FLD; i++) {
2835 int_fld[i] = strtoul(str_fld[i], &end, 0);
2836 if (errno != 0 || end == str_fld[i] ||
2841 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2842 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2844 if (hash_index >= nb_entries) {
2845 printf("Invalid RETA hash index=%d\n", hash_index);
2849 idx = hash_index / RTE_RETA_GROUP_SIZE;
2850 shift = hash_index % RTE_RETA_GROUP_SIZE;
2851 reta_conf[idx].mask |= (1ULL << shift);
2852 reta_conf[idx].reta[shift] = nb_queue;
2859 cmd_set_rss_reta_parsed(void *parsed_result,
2860 __attribute__((unused)) struct cmdline *cl,
2861 __attribute__((unused)) void *data)
2864 struct rte_eth_dev_info dev_info;
2865 struct rte_eth_rss_reta_entry64 reta_conf[8];
2866 struct cmd_config_rss_reta *res = parsed_result;
2868 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2872 if (dev_info.reta_size == 0) {
2873 printf("Redirection table size is 0 which is "
2874 "invalid for RSS\n");
2877 printf("The reta size of port %d is %u\n",
2878 res->port_id, dev_info.reta_size);
2879 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2880 printf("Currently do not support more than %u entries of "
2881 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2885 memset(reta_conf, 0, sizeof(reta_conf));
2886 if (!strcmp(res->list_name, "reta")) {
2887 if (parse_reta_config(res->list_of_items, reta_conf,
2888 dev_info.reta_size)) {
2889 printf("Invalid RSS Redirection Table "
2890 "config entered\n");
2893 ret = rte_eth_dev_rss_reta_update(res->port_id,
2894 reta_conf, dev_info.reta_size);
2896 printf("Bad redirection table parameter, "
2897 "return code = %d \n", ret);
2901 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2903 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2904 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2905 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2906 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2907 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2909 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2910 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2911 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2912 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2914 cmdline_parse_inst_t cmd_config_rss_reta = {
2915 .f = cmd_set_rss_reta_parsed,
2917 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2919 (void *)&cmd_config_rss_reta_port,
2920 (void *)&cmd_config_rss_reta_keyword,
2921 (void *)&cmd_config_rss_reta_port_id,
2922 (void *)&cmd_config_rss_reta_name,
2923 (void *)&cmd_config_rss_reta_list_name,
2924 (void *)&cmd_config_rss_reta_list_of_items,
2929 /* *** SHOW PORT RETA INFO *** */
2930 struct cmd_showport_reta {
2931 cmdline_fixed_string_t show;
2932 cmdline_fixed_string_t port;
2934 cmdline_fixed_string_t rss;
2935 cmdline_fixed_string_t reta;
2937 cmdline_fixed_string_t list_of_items;
2941 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2942 uint16_t nb_entries,
2946 const char *p, *p0 = str;
2951 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2952 RTE_RETA_GROUP_SIZE;
2955 p = strchr(p0, '(');
2959 p0 = strchr(p, ')');
2963 if (size >= sizeof(s)) {
2964 printf("The string size exceeds the internal buffer size\n");
2967 snprintf(s, sizeof(s), "%.*s", size, p);
2968 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2969 if (ret <= 0 || ret != num) {
2970 printf("The bits of masks do not match the number of "
2971 "reta entries: %u\n", num);
2974 for (i = 0; i < ret; i++)
2975 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2981 cmd_showport_reta_parsed(void *parsed_result,
2982 __attribute__((unused)) struct cmdline *cl,
2983 __attribute__((unused)) void *data)
2985 struct cmd_showport_reta *res = parsed_result;
2986 struct rte_eth_rss_reta_entry64 reta_conf[8];
2987 struct rte_eth_dev_info dev_info;
2988 uint16_t max_reta_size;
2991 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2995 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2996 if (res->size == 0 || res->size > max_reta_size) {
2997 printf("Invalid redirection table size: %u (1-%u)\n",
2998 res->size, max_reta_size);
3002 memset(reta_conf, 0, sizeof(reta_conf));
3003 if (showport_parse_reta_config(reta_conf, res->size,
3004 res->list_of_items) < 0) {
3005 printf("Invalid string: %s for reta masks\n",
3006 res->list_of_items);
3009 port_rss_reta_info(res->port_id, reta_conf, res->size);
3012 cmdline_parse_token_string_t cmd_showport_reta_show =
3013 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3014 cmdline_parse_token_string_t cmd_showport_reta_port =
3015 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3016 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3017 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3018 cmdline_parse_token_string_t cmd_showport_reta_rss =
3019 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3020 cmdline_parse_token_string_t cmd_showport_reta_reta =
3021 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3022 cmdline_parse_token_num_t cmd_showport_reta_size =
3023 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3024 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3025 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3026 list_of_items, NULL);
3028 cmdline_parse_inst_t cmd_showport_reta = {
3029 .f = cmd_showport_reta_parsed,
3031 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3033 (void *)&cmd_showport_reta_show,
3034 (void *)&cmd_showport_reta_port,
3035 (void *)&cmd_showport_reta_port_id,
3036 (void *)&cmd_showport_reta_rss,
3037 (void *)&cmd_showport_reta_reta,
3038 (void *)&cmd_showport_reta_size,
3039 (void *)&cmd_showport_reta_list_of_items,
3044 /* *** Show RSS hash configuration *** */
3045 struct cmd_showport_rss_hash {
3046 cmdline_fixed_string_t show;
3047 cmdline_fixed_string_t port;
3049 cmdline_fixed_string_t rss_hash;
3050 cmdline_fixed_string_t rss_type;
3051 cmdline_fixed_string_t key; /* optional argument */
3054 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3055 __attribute__((unused)) struct cmdline *cl,
3058 struct cmd_showport_rss_hash *res = parsed_result;
3060 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3063 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3064 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3065 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3066 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3067 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3068 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3069 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3070 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3072 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3073 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3075 cmdline_parse_inst_t cmd_showport_rss_hash = {
3076 .f = cmd_showport_rss_hash_parsed,
3078 .help_str = "show port <port_id> rss-hash",
3080 (void *)&cmd_showport_rss_hash_show,
3081 (void *)&cmd_showport_rss_hash_port,
3082 (void *)&cmd_showport_rss_hash_port_id,
3083 (void *)&cmd_showport_rss_hash_rss_hash,
3088 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3089 .f = cmd_showport_rss_hash_parsed,
3091 .help_str = "show port <port_id> rss-hash key",
3093 (void *)&cmd_showport_rss_hash_show,
3094 (void *)&cmd_showport_rss_hash_port,
3095 (void *)&cmd_showport_rss_hash_port_id,
3096 (void *)&cmd_showport_rss_hash_rss_hash,
3097 (void *)&cmd_showport_rss_hash_rss_key,
3102 /* *** Configure DCB *** */
3103 struct cmd_config_dcb {
3104 cmdline_fixed_string_t port;
3105 cmdline_fixed_string_t config;
3107 cmdline_fixed_string_t dcb;
3108 cmdline_fixed_string_t vt;
3109 cmdline_fixed_string_t vt_en;
3111 cmdline_fixed_string_t pfc;
3112 cmdline_fixed_string_t pfc_en;
3116 cmd_config_dcb_parsed(void *parsed_result,
3117 __attribute__((unused)) struct cmdline *cl,
3118 __attribute__((unused)) void *data)
3120 struct cmd_config_dcb *res = parsed_result;
3121 portid_t port_id = res->port_id;
3122 struct rte_port *port;
3126 port = &ports[port_id];
3127 /** Check if the port is not started **/
3128 if (port->port_status != RTE_PORT_STOPPED) {
3129 printf("Please stop port %d first\n", port_id);
3133 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3134 printf("The invalid number of traffic class,"
3135 " only 4 or 8 allowed.\n");
3139 if (nb_fwd_lcores < res->num_tcs) {
3140 printf("nb_cores shouldn't be less than number of TCs.\n");
3143 if (!strncmp(res->pfc_en, "on", 2))
3148 /* DCB in VT mode */
3149 if (!strncmp(res->vt_en, "on", 2))
3150 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3151 (enum rte_eth_nb_tcs)res->num_tcs,
3154 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3155 (enum rte_eth_nb_tcs)res->num_tcs,
3160 printf("Cannot initialize network ports.\n");
3164 cmd_reconfig_device_queue(port_id, 1, 1);
3167 cmdline_parse_token_string_t cmd_config_dcb_port =
3168 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3169 cmdline_parse_token_string_t cmd_config_dcb_config =
3170 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3171 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3172 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3173 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3174 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3175 cmdline_parse_token_string_t cmd_config_dcb_vt =
3176 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3177 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3178 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3179 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3180 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3181 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3182 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3183 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3184 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3186 cmdline_parse_inst_t cmd_config_dcb = {
3187 .f = cmd_config_dcb_parsed,
3189 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3191 (void *)&cmd_config_dcb_port,
3192 (void *)&cmd_config_dcb_config,
3193 (void *)&cmd_config_dcb_port_id,
3194 (void *)&cmd_config_dcb_dcb,
3195 (void *)&cmd_config_dcb_vt,
3196 (void *)&cmd_config_dcb_vt_en,
3197 (void *)&cmd_config_dcb_num_tcs,
3198 (void *)&cmd_config_dcb_pfc,
3199 (void *)&cmd_config_dcb_pfc_en,
3204 /* *** configure number of packets per burst *** */
3205 struct cmd_config_burst {
3206 cmdline_fixed_string_t port;
3207 cmdline_fixed_string_t keyword;
3208 cmdline_fixed_string_t all;
3209 cmdline_fixed_string_t name;
3214 cmd_config_burst_parsed(void *parsed_result,
3215 __attribute__((unused)) struct cmdline *cl,
3216 __attribute__((unused)) void *data)
3218 struct cmd_config_burst *res = parsed_result;
3219 struct rte_eth_dev_info dev_info;
3220 uint16_t rec_nb_pkts;
3223 if (!all_ports_stopped()) {
3224 printf("Please stop all ports first\n");
3228 if (!strcmp(res->name, "burst")) {
3229 if (res->value == 0) {
3230 /* If user gives a value of zero, query the PMD for
3231 * its recommended Rx burst size. Testpmd uses a single
3232 * size for all ports, so assume all ports are the same
3233 * NIC model and use the values from Port 0.
3235 ret = eth_dev_info_get_print_err(0, &dev_info);
3239 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3241 if (rec_nb_pkts == 0) {
3242 printf("PMD does not recommend a burst size.\n"
3243 "User provided value must be between"
3244 " 1 and %d\n", MAX_PKT_BURST);
3246 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3247 printf("PMD recommended burst size of %d"
3248 " exceeds maximum value of %d\n",
3249 rec_nb_pkts, MAX_PKT_BURST);
3252 printf("Using PMD-provided burst value of %d\n",
3254 nb_pkt_per_burst = rec_nb_pkts;
3255 } else if (res->value > MAX_PKT_BURST) {
3256 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3259 nb_pkt_per_burst = res->value;
3261 printf("Unknown parameter\n");
3267 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3270 cmdline_parse_token_string_t cmd_config_burst_port =
3271 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3272 cmdline_parse_token_string_t cmd_config_burst_keyword =
3273 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3274 cmdline_parse_token_string_t cmd_config_burst_all =
3275 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3276 cmdline_parse_token_string_t cmd_config_burst_name =
3277 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3278 cmdline_parse_token_num_t cmd_config_burst_value =
3279 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3281 cmdline_parse_inst_t cmd_config_burst = {
3282 .f = cmd_config_burst_parsed,
3284 .help_str = "port config all burst <value>",
3286 (void *)&cmd_config_burst_port,
3287 (void *)&cmd_config_burst_keyword,
3288 (void *)&cmd_config_burst_all,
3289 (void *)&cmd_config_burst_name,
3290 (void *)&cmd_config_burst_value,
3295 /* *** configure rx/tx queues *** */
3296 struct cmd_config_thresh {
3297 cmdline_fixed_string_t port;
3298 cmdline_fixed_string_t keyword;
3299 cmdline_fixed_string_t all;
3300 cmdline_fixed_string_t name;
3305 cmd_config_thresh_parsed(void *parsed_result,
3306 __attribute__((unused)) struct cmdline *cl,
3307 __attribute__((unused)) void *data)
3309 struct cmd_config_thresh *res = parsed_result;
3311 if (!all_ports_stopped()) {
3312 printf("Please stop all ports first\n");
3316 if (!strcmp(res->name, "txpt"))
3317 tx_pthresh = res->value;
3318 else if(!strcmp(res->name, "txht"))
3319 tx_hthresh = res->value;
3320 else if(!strcmp(res->name, "txwt"))
3321 tx_wthresh = res->value;
3322 else if(!strcmp(res->name, "rxpt"))
3323 rx_pthresh = res->value;
3324 else if(!strcmp(res->name, "rxht"))
3325 rx_hthresh = res->value;
3326 else if(!strcmp(res->name, "rxwt"))
3327 rx_wthresh = res->value;
3329 printf("Unknown parameter\n");
3335 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3338 cmdline_parse_token_string_t cmd_config_thresh_port =
3339 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3340 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3341 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3342 cmdline_parse_token_string_t cmd_config_thresh_all =
3343 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3344 cmdline_parse_token_string_t cmd_config_thresh_name =
3345 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3346 "txpt#txht#txwt#rxpt#rxht#rxwt");
3347 cmdline_parse_token_num_t cmd_config_thresh_value =
3348 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3350 cmdline_parse_inst_t cmd_config_thresh = {
3351 .f = cmd_config_thresh_parsed,
3353 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3355 (void *)&cmd_config_thresh_port,
3356 (void *)&cmd_config_thresh_keyword,
3357 (void *)&cmd_config_thresh_all,
3358 (void *)&cmd_config_thresh_name,
3359 (void *)&cmd_config_thresh_value,
3364 /* *** configure free/rs threshold *** */
3365 struct cmd_config_threshold {
3366 cmdline_fixed_string_t port;
3367 cmdline_fixed_string_t keyword;
3368 cmdline_fixed_string_t all;
3369 cmdline_fixed_string_t name;
3374 cmd_config_threshold_parsed(void *parsed_result,
3375 __attribute__((unused)) struct cmdline *cl,
3376 __attribute__((unused)) void *data)
3378 struct cmd_config_threshold *res = parsed_result;
3380 if (!all_ports_stopped()) {
3381 printf("Please stop all ports first\n");
3385 if (!strcmp(res->name, "txfreet"))
3386 tx_free_thresh = res->value;
3387 else if (!strcmp(res->name, "txrst"))
3388 tx_rs_thresh = res->value;
3389 else if (!strcmp(res->name, "rxfreet"))
3390 rx_free_thresh = res->value;
3392 printf("Unknown parameter\n");
3398 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3401 cmdline_parse_token_string_t cmd_config_threshold_port =
3402 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3403 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3404 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3406 cmdline_parse_token_string_t cmd_config_threshold_all =
3407 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3408 cmdline_parse_token_string_t cmd_config_threshold_name =
3409 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3410 "txfreet#txrst#rxfreet");
3411 cmdline_parse_token_num_t cmd_config_threshold_value =
3412 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3414 cmdline_parse_inst_t cmd_config_threshold = {
3415 .f = cmd_config_threshold_parsed,
3417 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3419 (void *)&cmd_config_threshold_port,
3420 (void *)&cmd_config_threshold_keyword,
3421 (void *)&cmd_config_threshold_all,
3422 (void *)&cmd_config_threshold_name,
3423 (void *)&cmd_config_threshold_value,
3429 struct cmd_stop_result {
3430 cmdline_fixed_string_t stop;
3433 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3434 __attribute__((unused)) struct cmdline *cl,
3435 __attribute__((unused)) void *data)
3437 stop_packet_forwarding();
3440 cmdline_parse_token_string_t cmd_stop_stop =
3441 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3443 cmdline_parse_inst_t cmd_stop = {
3444 .f = cmd_stop_parsed,
3446 .help_str = "stop: Stop packet forwarding",
3448 (void *)&cmd_stop_stop,
3453 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3456 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3457 unsigned int *parsed_items, int check_unique_values)
3459 unsigned int nb_item;
3467 * First parse all items in the list and store their value.
3472 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3474 if ((c >= '0') && (c <= '9')) {
3475 value = (unsigned int) (value * 10 + (c - '0'));
3480 printf("character %c is not a decimal digit\n", c);
3484 printf("No valid value before comma\n");
3487 if (nb_item < max_items) {
3488 parsed_items[nb_item] = value;
3494 if (nb_item >= max_items) {
3495 printf("Number of %s = %u > %u (maximum items)\n",
3496 item_name, nb_item + 1, max_items);
3499 parsed_items[nb_item++] = value;
3500 if (! check_unique_values)
3504 * Then, check that all values in the list are differents.
3505 * No optimization here...
3507 for (i = 0; i < nb_item; i++) {
3508 for (j = i + 1; j < nb_item; j++) {
3509 if (parsed_items[j] == parsed_items[i]) {
3510 printf("duplicated %s %u at index %u and %u\n",
3511 item_name, parsed_items[i], i, j);
3519 struct cmd_set_list_result {
3520 cmdline_fixed_string_t cmd_keyword;
3521 cmdline_fixed_string_t list_name;
3522 cmdline_fixed_string_t list_of_items;
3525 static void cmd_set_list_parsed(void *parsed_result,
3526 __attribute__((unused)) struct cmdline *cl,
3527 __attribute__((unused)) void *data)
3529 struct cmd_set_list_result *res;
3531 unsigned int lcorelist[RTE_MAX_LCORE];
3532 unsigned int portlist[RTE_MAX_ETHPORTS];
3534 unsigned int nb_item;
3536 if (test_done == 0) {
3537 printf("Please stop forwarding first\n");
3541 res = parsed_result;
3542 if (!strcmp(res->list_name, "corelist")) {
3543 nb_item = parse_item_list(res->list_of_items, "core",
3545 parsed_items.lcorelist, 1);
3547 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3552 if (!strcmp(res->list_name, "portlist")) {
3553 nb_item = parse_item_list(res->list_of_items, "port",
3555 parsed_items.portlist, 1);
3557 set_fwd_ports_list(parsed_items.portlist, nb_item);
3563 cmdline_parse_token_string_t cmd_set_list_keyword =
3564 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3566 cmdline_parse_token_string_t cmd_set_list_name =
3567 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3568 "corelist#portlist");
3569 cmdline_parse_token_string_t cmd_set_list_of_items =
3570 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3573 cmdline_parse_inst_t cmd_set_fwd_list = {
3574 .f = cmd_set_list_parsed,
3576 .help_str = "set corelist|portlist <list0[,list1]*>",
3578 (void *)&cmd_set_list_keyword,
3579 (void *)&cmd_set_list_name,
3580 (void *)&cmd_set_list_of_items,
3585 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3587 struct cmd_setmask_result {
3588 cmdline_fixed_string_t set;
3589 cmdline_fixed_string_t mask;
3593 static void cmd_set_mask_parsed(void *parsed_result,
3594 __attribute__((unused)) struct cmdline *cl,
3595 __attribute__((unused)) void *data)
3597 struct cmd_setmask_result *res = parsed_result;
3599 if (test_done == 0) {
3600 printf("Please stop forwarding first\n");
3603 if (!strcmp(res->mask, "coremask")) {
3604 set_fwd_lcores_mask(res->hexavalue);
3606 } else if (!strcmp(res->mask, "portmask")) {
3607 set_fwd_ports_mask(res->hexavalue);
3612 cmdline_parse_token_string_t cmd_setmask_set =
3613 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3614 cmdline_parse_token_string_t cmd_setmask_mask =
3615 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3616 "coremask#portmask");
3617 cmdline_parse_token_num_t cmd_setmask_value =
3618 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3620 cmdline_parse_inst_t cmd_set_fwd_mask = {
3621 .f = cmd_set_mask_parsed,
3623 .help_str = "set coremask|portmask <hexadecimal value>",
3625 (void *)&cmd_setmask_set,
3626 (void *)&cmd_setmask_mask,
3627 (void *)&cmd_setmask_value,
3633 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3635 struct cmd_set_result {
3636 cmdline_fixed_string_t set;
3637 cmdline_fixed_string_t what;
3641 static void cmd_set_parsed(void *parsed_result,
3642 __attribute__((unused)) struct cmdline *cl,
3643 __attribute__((unused)) void *data)
3645 struct cmd_set_result *res = parsed_result;
3646 if (!strcmp(res->what, "nbport")) {
3647 set_fwd_ports_number(res->value);
3649 } else if (!strcmp(res->what, "nbcore")) {
3650 set_fwd_lcores_number(res->value);
3652 } else if (!strcmp(res->what, "burst"))
3653 set_nb_pkt_per_burst(res->value);
3654 else if (!strcmp(res->what, "verbose"))
3655 set_verbose_level(res->value);
3658 cmdline_parse_token_string_t cmd_set_set =
3659 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3660 cmdline_parse_token_string_t cmd_set_what =
3661 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3662 "nbport#nbcore#burst#verbose");
3663 cmdline_parse_token_num_t cmd_set_value =
3664 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3666 cmdline_parse_inst_t cmd_set_numbers = {
3667 .f = cmd_set_parsed,
3669 .help_str = "set nbport|nbcore|burst|verbose <value>",
3671 (void *)&cmd_set_set,
3672 (void *)&cmd_set_what,
3673 (void *)&cmd_set_value,
3678 /* *** SET LOG LEVEL CONFIGURATION *** */
3680 struct cmd_set_log_result {
3681 cmdline_fixed_string_t set;
3682 cmdline_fixed_string_t log;
3683 cmdline_fixed_string_t type;
3688 cmd_set_log_parsed(void *parsed_result,
3689 __attribute__((unused)) struct cmdline *cl,
3690 __attribute__((unused)) void *data)
3692 struct cmd_set_log_result *res;
3695 res = parsed_result;
3696 if (!strcmp(res->type, "global"))
3697 rte_log_set_global_level(res->level);
3699 ret = rte_log_set_level_regexp(res->type, res->level);
3701 printf("Unable to set log level\n");
3705 cmdline_parse_token_string_t cmd_set_log_set =
3706 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3707 cmdline_parse_token_string_t cmd_set_log_log =
3708 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3709 cmdline_parse_token_string_t cmd_set_log_type =
3710 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3711 cmdline_parse_token_num_t cmd_set_log_level =
3712 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3714 cmdline_parse_inst_t cmd_set_log = {
3715 .f = cmd_set_log_parsed,
3717 .help_str = "set log global|<type> <level>",
3719 (void *)&cmd_set_log_set,
3720 (void *)&cmd_set_log_log,
3721 (void *)&cmd_set_log_type,
3722 (void *)&cmd_set_log_level,
3727 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3729 struct cmd_set_txpkts_result {
3730 cmdline_fixed_string_t cmd_keyword;
3731 cmdline_fixed_string_t txpkts;
3732 cmdline_fixed_string_t seg_lengths;
3736 cmd_set_txpkts_parsed(void *parsed_result,
3737 __attribute__((unused)) struct cmdline *cl,
3738 __attribute__((unused)) void *data)
3740 struct cmd_set_txpkts_result *res;
3741 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3742 unsigned int nb_segs;
3744 res = parsed_result;
3745 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3746 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3748 set_tx_pkt_segments(seg_lengths, nb_segs);
3751 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3752 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3753 cmd_keyword, "set");
3754 cmdline_parse_token_string_t cmd_set_txpkts_name =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3757 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3758 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3761 cmdline_parse_inst_t cmd_set_txpkts = {
3762 .f = cmd_set_txpkts_parsed,
3764 .help_str = "set txpkts <len0[,len1]*>",
3766 (void *)&cmd_set_txpkts_keyword,
3767 (void *)&cmd_set_txpkts_name,
3768 (void *)&cmd_set_txpkts_lengths,
3773 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3775 struct cmd_set_txsplit_result {
3776 cmdline_fixed_string_t cmd_keyword;
3777 cmdline_fixed_string_t txsplit;
3778 cmdline_fixed_string_t mode;
3782 cmd_set_txsplit_parsed(void *parsed_result,
3783 __attribute__((unused)) struct cmdline *cl,
3784 __attribute__((unused)) void *data)
3786 struct cmd_set_txsplit_result *res;
3788 res = parsed_result;
3789 set_tx_pkt_split(res->mode);
3792 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3793 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3794 cmd_keyword, "set");
3795 cmdline_parse_token_string_t cmd_set_txsplit_name =
3796 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3797 txsplit, "txsplit");
3798 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3799 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3802 cmdline_parse_inst_t cmd_set_txsplit = {
3803 .f = cmd_set_txsplit_parsed,
3805 .help_str = "set txsplit on|off|rand",
3807 (void *)&cmd_set_txsplit_keyword,
3808 (void *)&cmd_set_txsplit_name,
3809 (void *)&cmd_set_txsplit_mode,
3814 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3815 struct cmd_rx_vlan_filter_all_result {
3816 cmdline_fixed_string_t rx_vlan;
3817 cmdline_fixed_string_t what;
3818 cmdline_fixed_string_t all;
3823 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3824 __attribute__((unused)) struct cmdline *cl,
3825 __attribute__((unused)) void *data)
3827 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3829 if (!strcmp(res->what, "add"))
3830 rx_vlan_all_filter_set(res->port_id, 1);
3832 rx_vlan_all_filter_set(res->port_id, 0);
3835 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3836 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3837 rx_vlan, "rx_vlan");
3838 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3839 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3841 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3842 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3844 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3845 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3848 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3849 .f = cmd_rx_vlan_filter_all_parsed,
3851 .help_str = "rx_vlan add|rm all <port_id>: "
3852 "Add/Remove all identifiers to/from the set of VLAN "
3853 "identifiers filtered by a port",
3855 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3856 (void *)&cmd_rx_vlan_filter_all_what,
3857 (void *)&cmd_rx_vlan_filter_all_all,
3858 (void *)&cmd_rx_vlan_filter_all_portid,
3863 /* *** VLAN OFFLOAD SET ON A PORT *** */
3864 struct cmd_vlan_offload_result {
3865 cmdline_fixed_string_t vlan;
3866 cmdline_fixed_string_t set;
3867 cmdline_fixed_string_t vlan_type;
3868 cmdline_fixed_string_t what;
3869 cmdline_fixed_string_t on;
3870 cmdline_fixed_string_t port_id;
3874 cmd_vlan_offload_parsed(void *parsed_result,
3875 __attribute__((unused)) struct cmdline *cl,
3876 __attribute__((unused)) void *data)
3879 struct cmd_vlan_offload_result *res = parsed_result;
3882 portid_t port_id = 0;
3886 len = strnlen(str, STR_TOKEN_SIZE);
3888 /* Get port_id first */
3896 tmp = strtoul(str, NULL, 0);
3897 /* If port_id greater that what portid_t can represent, return */
3898 if(tmp >= RTE_MAX_ETHPORTS)
3900 port_id = (portid_t)tmp;
3902 if (!strcmp(res->on, "on"))
3907 if (!strcmp(res->what, "strip"))
3908 rx_vlan_strip_set(port_id, on);
3909 else if(!strcmp(res->what, "stripq")){
3910 uint16_t queue_id = 0;
3912 /* No queue_id, return */
3914 printf("must specify (port,queue_id)\n");
3917 tmp = strtoul(str + i + 1, NULL, 0);
3918 /* If queue_id greater that what 16-bits can represent, return */
3922 queue_id = (uint16_t)tmp;
3923 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3925 else if (!strcmp(res->what, "filter"))
3926 rx_vlan_filter_set(port_id, on);
3927 else if (!strcmp(res->what, "qinq_strip"))
3928 rx_vlan_qinq_strip_set(port_id, on);
3930 vlan_extend_set(port_id, on);
3935 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3936 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3938 cmdline_parse_token_string_t cmd_vlan_offload_set =
3939 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3941 cmdline_parse_token_string_t cmd_vlan_offload_what =
3942 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3943 what, "strip#filter#qinq_strip#extend#stripq");
3944 cmdline_parse_token_string_t cmd_vlan_offload_on =
3945 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3947 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3948 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3951 cmdline_parse_inst_t cmd_vlan_offload = {
3952 .f = cmd_vlan_offload_parsed,
3954 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
3955 "<port_id[,queue_id]>: "
3956 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
3958 (void *)&cmd_vlan_offload_vlan,
3959 (void *)&cmd_vlan_offload_set,
3960 (void *)&cmd_vlan_offload_what,
3961 (void *)&cmd_vlan_offload_on,
3962 (void *)&cmd_vlan_offload_portid,
3967 /* *** VLAN TPID SET ON A PORT *** */
3968 struct cmd_vlan_tpid_result {
3969 cmdline_fixed_string_t vlan;
3970 cmdline_fixed_string_t set;
3971 cmdline_fixed_string_t vlan_type;
3972 cmdline_fixed_string_t what;
3978 cmd_vlan_tpid_parsed(void *parsed_result,
3979 __attribute__((unused)) struct cmdline *cl,
3980 __attribute__((unused)) void *data)
3982 struct cmd_vlan_tpid_result *res = parsed_result;
3983 enum rte_vlan_type vlan_type;
3985 if (!strcmp(res->vlan_type, "inner"))
3986 vlan_type = ETH_VLAN_TYPE_INNER;
3987 else if (!strcmp(res->vlan_type, "outer"))
3988 vlan_type = ETH_VLAN_TYPE_OUTER;
3990 printf("Unknown vlan type\n");
3993 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3996 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3997 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3999 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4000 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4002 cmdline_parse_token_string_t cmd_vlan_type =
4003 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4004 vlan_type, "inner#outer");
4005 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4006 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4008 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4009 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4011 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4012 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4015 cmdline_parse_inst_t cmd_vlan_tpid = {
4016 .f = cmd_vlan_tpid_parsed,
4018 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4019 "Set the VLAN Ether type",
4021 (void *)&cmd_vlan_tpid_vlan,
4022 (void *)&cmd_vlan_tpid_set,
4023 (void *)&cmd_vlan_type,
4024 (void *)&cmd_vlan_tpid_what,
4025 (void *)&cmd_vlan_tpid_tpid,
4026 (void *)&cmd_vlan_tpid_portid,
4031 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4032 struct cmd_rx_vlan_filter_result {
4033 cmdline_fixed_string_t rx_vlan;
4034 cmdline_fixed_string_t what;
4040 cmd_rx_vlan_filter_parsed(void *parsed_result,
4041 __attribute__((unused)) struct cmdline *cl,
4042 __attribute__((unused)) void *data)
4044 struct cmd_rx_vlan_filter_result *res = parsed_result;
4046 if (!strcmp(res->what, "add"))
4047 rx_vft_set(res->port_id, res->vlan_id, 1);
4049 rx_vft_set(res->port_id, res->vlan_id, 0);
4052 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4053 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4054 rx_vlan, "rx_vlan");
4055 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4056 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4058 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4059 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4061 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4062 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4065 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4066 .f = cmd_rx_vlan_filter_parsed,
4068 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4069 "Add/Remove a VLAN identifier to/from the set of VLAN "
4070 "identifiers filtered by a port",
4072 (void *)&cmd_rx_vlan_filter_rx_vlan,
4073 (void *)&cmd_rx_vlan_filter_what,
4074 (void *)&cmd_rx_vlan_filter_vlanid,
4075 (void *)&cmd_rx_vlan_filter_portid,
4080 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4081 struct cmd_tx_vlan_set_result {
4082 cmdline_fixed_string_t tx_vlan;
4083 cmdline_fixed_string_t set;
4089 cmd_tx_vlan_set_parsed(void *parsed_result,
4090 __attribute__((unused)) struct cmdline *cl,
4091 __attribute__((unused)) void *data)
4093 struct cmd_tx_vlan_set_result *res = parsed_result;
4095 if (!port_is_stopped(res->port_id)) {
4096 printf("Please stop port %d first\n", res->port_id);
4100 tx_vlan_set(res->port_id, res->vlan_id);
4102 cmd_reconfig_device_queue(res->port_id, 1, 1);
4105 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4106 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4107 tx_vlan, "tx_vlan");
4108 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4109 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4111 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4112 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4114 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4115 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4118 cmdline_parse_inst_t cmd_tx_vlan_set = {
4119 .f = cmd_tx_vlan_set_parsed,
4121 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4122 "Enable hardware insertion of a single VLAN header "
4123 "with a given TAG Identifier in packets sent on a port",
4125 (void *)&cmd_tx_vlan_set_tx_vlan,
4126 (void *)&cmd_tx_vlan_set_set,
4127 (void *)&cmd_tx_vlan_set_portid,
4128 (void *)&cmd_tx_vlan_set_vlanid,
4133 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4134 struct cmd_tx_vlan_set_qinq_result {
4135 cmdline_fixed_string_t tx_vlan;
4136 cmdline_fixed_string_t set;
4139 uint16_t vlan_id_outer;
4143 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4144 __attribute__((unused)) struct cmdline *cl,
4145 __attribute__((unused)) void *data)
4147 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4149 if (!port_is_stopped(res->port_id)) {
4150 printf("Please stop port %d first\n", res->port_id);
4154 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4156 cmd_reconfig_device_queue(res->port_id, 1, 1);
4159 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4160 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4161 tx_vlan, "tx_vlan");
4162 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4163 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4165 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4166 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4168 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4169 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4171 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4172 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4173 vlan_id_outer, UINT16);
4175 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4176 .f = cmd_tx_vlan_set_qinq_parsed,
4178 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4179 "Enable hardware insertion of double VLAN header "
4180 "with given TAG Identifiers in packets sent on a port",
4182 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4183 (void *)&cmd_tx_vlan_set_qinq_set,
4184 (void *)&cmd_tx_vlan_set_qinq_portid,
4185 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4186 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4191 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4192 struct cmd_tx_vlan_set_pvid_result {
4193 cmdline_fixed_string_t tx_vlan;
4194 cmdline_fixed_string_t set;
4195 cmdline_fixed_string_t pvid;
4198 cmdline_fixed_string_t mode;
4202 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4203 __attribute__((unused)) struct cmdline *cl,
4204 __attribute__((unused)) void *data)
4206 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4208 if (strcmp(res->mode, "on") == 0)
4209 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4211 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4214 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4215 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4216 tx_vlan, "tx_vlan");
4217 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4218 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4223 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4224 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4226 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4227 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4229 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4230 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4233 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4234 .f = cmd_tx_vlan_set_pvid_parsed,
4236 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4238 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4239 (void *)&cmd_tx_vlan_set_pvid_set,
4240 (void *)&cmd_tx_vlan_set_pvid_pvid,
4241 (void *)&cmd_tx_vlan_set_pvid_port_id,
4242 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4243 (void *)&cmd_tx_vlan_set_pvid_mode,
4248 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4249 struct cmd_tx_vlan_reset_result {
4250 cmdline_fixed_string_t tx_vlan;
4251 cmdline_fixed_string_t reset;
4256 cmd_tx_vlan_reset_parsed(void *parsed_result,
4257 __attribute__((unused)) struct cmdline *cl,
4258 __attribute__((unused)) void *data)
4260 struct cmd_tx_vlan_reset_result *res = parsed_result;
4262 if (!port_is_stopped(res->port_id)) {
4263 printf("Please stop port %d first\n", res->port_id);
4267 tx_vlan_reset(res->port_id);
4269 cmd_reconfig_device_queue(res->port_id, 1, 1);
4272 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4273 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4274 tx_vlan, "tx_vlan");
4275 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4276 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4278 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4279 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4282 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4283 .f = cmd_tx_vlan_reset_parsed,
4285 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4286 "VLAN header in packets sent on a port",
4288 (void *)&cmd_tx_vlan_reset_tx_vlan,
4289 (void *)&cmd_tx_vlan_reset_reset,
4290 (void *)&cmd_tx_vlan_reset_portid,
4296 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4297 struct cmd_csum_result {
4298 cmdline_fixed_string_t csum;
4299 cmdline_fixed_string_t mode;
4300 cmdline_fixed_string_t proto;
4301 cmdline_fixed_string_t hwsw;
4306 csum_show(int port_id)
4308 struct rte_eth_dev_info dev_info;
4309 uint64_t tx_offloads;
4312 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4313 printf("Parse tunnel is %s\n",
4314 (ports[port_id].parse_tunnel) ? "on" : "off");
4315 printf("IP checksum offload is %s\n",
4316 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4317 printf("UDP checksum offload is %s\n",
4318 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4319 printf("TCP checksum offload is %s\n",
4320 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4321 printf("SCTP checksum offload is %s\n",
4322 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4323 printf("Outer-Ip checksum offload is %s\n",
4324 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4325 printf("Outer-Udp checksum offload is %s\n",
4326 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4328 /* display warnings if configuration is not supported by the NIC */
4329 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4333 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4334 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4335 printf("Warning: hardware IP checksum enabled but not "
4336 "supported by port %d\n", port_id);
4338 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4339 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4340 printf("Warning: hardware UDP checksum enabled but not "
4341 "supported by port %d\n", port_id);
4343 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4344 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4345 printf("Warning: hardware TCP checksum enabled but not "
4346 "supported by port %d\n", port_id);
4348 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4349 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4350 printf("Warning: hardware SCTP checksum enabled but not "
4351 "supported by port %d\n", port_id);
4353 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4354 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4355 printf("Warning: hardware outer IP checksum enabled but not "
4356 "supported by port %d\n", port_id);
4358 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4359 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4361 printf("Warning: hardware outer UDP checksum enabled but not "
4362 "supported by port %d\n", port_id);
4367 cmd_config_queue_tx_offloads(struct rte_port *port)
4371 /* Apply queue tx offloads configuration */
4372 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4373 port->tx_conf[k].offloads =
4374 port->dev_conf.txmode.offloads;
4378 cmd_csum_parsed(void *parsed_result,
4379 __attribute__((unused)) struct cmdline *cl,
4380 __attribute__((unused)) void *data)
4382 struct cmd_csum_result *res = parsed_result;
4384 uint64_t csum_offloads = 0;
4385 struct rte_eth_dev_info dev_info;
4388 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4389 printf("invalid port %d\n", res->port_id);
4392 if (!port_is_stopped(res->port_id)) {
4393 printf("Please stop port %d first\n", res->port_id);
4397 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4401 if (!strcmp(res->mode, "set")) {
4403 if (!strcmp(res->hwsw, "hw"))
4406 if (!strcmp(res->proto, "ip")) {
4407 if (hw == 0 || (dev_info.tx_offload_capa &
4408 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4409 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4411 printf("IP checksum offload is not supported "
4412 "by port %u\n", res->port_id);
4414 } else if (!strcmp(res->proto, "udp")) {
4415 if (hw == 0 || (dev_info.tx_offload_capa &
4416 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4417 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4419 printf("UDP checksum offload is not supported "
4420 "by port %u\n", res->port_id);
4422 } else if (!strcmp(res->proto, "tcp")) {
4423 if (hw == 0 || (dev_info.tx_offload_capa &
4424 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4425 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4427 printf("TCP checksum offload is not supported "
4428 "by port %u\n", res->port_id);
4430 } else if (!strcmp(res->proto, "sctp")) {
4431 if (hw == 0 || (dev_info.tx_offload_capa &
4432 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4433 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4435 printf("SCTP checksum offload is not supported "
4436 "by port %u\n", res->port_id);
4438 } else if (!strcmp(res->proto, "outer-ip")) {
4439 if (hw == 0 || (dev_info.tx_offload_capa &
4440 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4442 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4444 printf("Outer IP checksum offload is not "
4445 "supported by port %u\n", res->port_id);
4447 } else if (!strcmp(res->proto, "outer-udp")) {
4448 if (hw == 0 || (dev_info.tx_offload_capa &
4449 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4451 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4453 printf("Outer UDP checksum offload is not "
4454 "supported by port %u\n", res->port_id);
4459 ports[res->port_id].dev_conf.txmode.offloads |=
4462 ports[res->port_id].dev_conf.txmode.offloads &=
4465 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4467 csum_show(res->port_id);
4469 cmd_reconfig_device_queue(res->port_id, 1, 1);
4472 cmdline_parse_token_string_t cmd_csum_csum =
4473 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4475 cmdline_parse_token_string_t cmd_csum_mode =
4476 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4478 cmdline_parse_token_string_t cmd_csum_proto =
4479 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4480 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4481 cmdline_parse_token_string_t cmd_csum_hwsw =
4482 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4484 cmdline_parse_token_num_t cmd_csum_portid =
4485 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4488 cmdline_parse_inst_t cmd_csum_set = {
4489 .f = cmd_csum_parsed,
4491 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4492 "Enable/Disable hardware calculation of L3/L4 checksum when "
4493 "using csum forward engine",
4495 (void *)&cmd_csum_csum,
4496 (void *)&cmd_csum_mode,
4497 (void *)&cmd_csum_proto,
4498 (void *)&cmd_csum_hwsw,
4499 (void *)&cmd_csum_portid,
4504 cmdline_parse_token_string_t cmd_csum_mode_show =
4505 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4508 cmdline_parse_inst_t cmd_csum_show = {
4509 .f = cmd_csum_parsed,
4511 .help_str = "csum show <port_id>: Show checksum offload configuration",
4513 (void *)&cmd_csum_csum,
4514 (void *)&cmd_csum_mode_show,
4515 (void *)&cmd_csum_portid,
4520 /* Enable/disable tunnel parsing */
4521 struct cmd_csum_tunnel_result {
4522 cmdline_fixed_string_t csum;
4523 cmdline_fixed_string_t parse;
4524 cmdline_fixed_string_t onoff;
4529 cmd_csum_tunnel_parsed(void *parsed_result,
4530 __attribute__((unused)) struct cmdline *cl,
4531 __attribute__((unused)) void *data)
4533 struct cmd_csum_tunnel_result *res = parsed_result;
4535 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4538 if (!strcmp(res->onoff, "on"))
4539 ports[res->port_id].parse_tunnel = 1;
4541 ports[res->port_id].parse_tunnel = 0;
4543 csum_show(res->port_id);
4546 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4547 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4549 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4550 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4551 parse, "parse-tunnel");
4552 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4553 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4555 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4556 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4559 cmdline_parse_inst_t cmd_csum_tunnel = {
4560 .f = cmd_csum_tunnel_parsed,
4562 .help_str = "csum parse-tunnel on|off <port_id>: "
4563 "Enable/Disable parsing of tunnels for csum engine",
4565 (void *)&cmd_csum_tunnel_csum,
4566 (void *)&cmd_csum_tunnel_parse,
4567 (void *)&cmd_csum_tunnel_onoff,
4568 (void *)&cmd_csum_tunnel_portid,
4573 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4574 struct cmd_tso_set_result {
4575 cmdline_fixed_string_t tso;
4576 cmdline_fixed_string_t mode;
4582 cmd_tso_set_parsed(void *parsed_result,
4583 __attribute__((unused)) struct cmdline *cl,
4584 __attribute__((unused)) void *data)
4586 struct cmd_tso_set_result *res = parsed_result;
4587 struct rte_eth_dev_info dev_info;
4590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4592 if (!port_is_stopped(res->port_id)) {
4593 printf("Please stop port %d first\n", res->port_id);
4597 if (!strcmp(res->mode, "set"))
4598 ports[res->port_id].tso_segsz = res->tso_segsz;
4600 ret = eth_dev_info_get_print_err(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 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4628 if ((ports[res->port_id].tso_segsz != 0) &&
4629 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4630 printf("Warning: TSO enabled but not "
4631 "supported by port %d\n", res->port_id);
4634 cmd_reconfig_device_queue(res->port_id, 1, 1);
4637 cmdline_parse_token_string_t cmd_tso_set_tso =
4638 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4640 cmdline_parse_token_string_t cmd_tso_set_mode =
4641 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4643 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4644 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4646 cmdline_parse_token_num_t cmd_tso_set_portid =
4647 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4650 cmdline_parse_inst_t cmd_tso_set = {
4651 .f = cmd_tso_set_parsed,
4653 .help_str = "tso set <tso_segsz> <port_id>: "
4654 "Set TSO segment size of non-tunneled packets for csum engine "
4657 (void *)&cmd_tso_set_tso,
4658 (void *)&cmd_tso_set_mode,
4659 (void *)&cmd_tso_set_tso_segsz,
4660 (void *)&cmd_tso_set_portid,
4665 cmdline_parse_token_string_t cmd_tso_show_mode =
4666 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4670 cmdline_parse_inst_t cmd_tso_show = {
4671 .f = cmd_tso_set_parsed,
4673 .help_str = "tso show <port_id>: "
4674 "Show TSO segment size of non-tunneled packets for csum engine",
4676 (void *)&cmd_tso_set_tso,
4677 (void *)&cmd_tso_show_mode,
4678 (void *)&cmd_tso_set_portid,
4683 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4684 struct cmd_tunnel_tso_set_result {
4685 cmdline_fixed_string_t tso;
4686 cmdline_fixed_string_t mode;
4691 static struct rte_eth_dev_info
4692 check_tunnel_tso_nic_support(portid_t port_id)
4694 struct rte_eth_dev_info dev_info;
4696 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4699 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4700 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4701 "not enabled for port %d\n", port_id);
4702 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4703 printf("Warning: GRE TUNNEL TSO not supported therefore "
4704 "not enabled for port %d\n", port_id);
4705 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4706 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4707 "not enabled for port %d\n", port_id);
4708 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4709 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4710 "not enabled for port %d\n", port_id);
4711 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4712 printf("Warning: IP TUNNEL TSO not supported therefore "
4713 "not enabled for port %d\n", port_id);
4714 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4715 printf("Warning: UDP TUNNEL TSO not supported therefore "
4716 "not enabled for port %d\n", port_id);
4721 cmd_tunnel_tso_set_parsed(void *parsed_result,
4722 __attribute__((unused)) struct cmdline *cl,
4723 __attribute__((unused)) void *data)
4725 struct cmd_tunnel_tso_set_result *res = parsed_result;
4726 struct rte_eth_dev_info dev_info;
4728 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4730 if (!port_is_stopped(res->port_id)) {
4731 printf("Please stop port %d first\n", res->port_id);
4735 if (!strcmp(res->mode, "set"))
4736 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4738 dev_info = check_tunnel_tso_nic_support(res->port_id);
4739 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4740 ports[res->port_id].dev_conf.txmode.offloads &=
4741 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4742 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4743 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4744 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4745 DEV_TX_OFFLOAD_IP_TNL_TSO |
4746 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4747 printf("TSO for tunneled packets is disabled\n");
4749 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4750 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4751 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4752 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4753 DEV_TX_OFFLOAD_IP_TNL_TSO |
4754 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4756 ports[res->port_id].dev_conf.txmode.offloads |=
4757 (tso_offloads & dev_info.tx_offload_capa);
4758 printf("TSO segment size for tunneled packets is %d\n",
4759 ports[res->port_id].tunnel_tso_segsz);
4761 /* Below conditions are needed to make it work:
4762 * (1) tunnel TSO is supported by the NIC;
4763 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4765 * (3) for tunneled pkts with outer L3 of IPv4,
4766 * "csum set outer-ip" must be set to hw, because after tso,
4767 * total_len of outer IP header is changed, and the checksum
4768 * of outer IP header calculated by sw should be wrong; that
4769 * is not necessary for IPv6 tunneled pkts because there's no
4770 * checksum in IP header anymore.
4773 if (!ports[res->port_id].parse_tunnel)
4774 printf("Warning: csum parse_tunnel must be set "
4775 "so that tunneled packets are recognized\n");
4776 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4777 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4778 printf("Warning: csum set outer-ip must be set to hw "
4779 "if outer L3 is IPv4; not necessary for IPv6\n");
4782 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4783 cmd_reconfig_device_queue(res->port_id, 1, 1);
4786 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4787 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4789 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4790 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4792 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4793 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4795 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4796 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4799 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4800 .f = cmd_tunnel_tso_set_parsed,
4802 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4803 "Set TSO segment size of tunneled packets for csum engine "
4806 (void *)&cmd_tunnel_tso_set_tso,
4807 (void *)&cmd_tunnel_tso_set_mode,
4808 (void *)&cmd_tunnel_tso_set_tso_segsz,
4809 (void *)&cmd_tunnel_tso_set_portid,
4814 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4815 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4819 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4820 .f = cmd_tunnel_tso_set_parsed,
4822 .help_str = "tunnel_tso show <port_id> "
4823 "Show TSO segment size of tunneled packets for csum engine",
4825 (void *)&cmd_tunnel_tso_set_tso,
4826 (void *)&cmd_tunnel_tso_show_mode,
4827 (void *)&cmd_tunnel_tso_set_portid,
4832 /* *** SET GRO FOR A PORT *** */
4833 struct cmd_gro_enable_result {
4834 cmdline_fixed_string_t cmd_set;
4835 cmdline_fixed_string_t cmd_port;
4836 cmdline_fixed_string_t cmd_keyword;
4837 cmdline_fixed_string_t cmd_onoff;
4842 cmd_gro_enable_parsed(void *parsed_result,
4843 __attribute__((unused)) struct cmdline *cl,
4844 __attribute__((unused)) void *data)
4846 struct cmd_gro_enable_result *res;
4848 res = parsed_result;
4849 if (!strcmp(res->cmd_keyword, "gro"))
4850 setup_gro(res->cmd_onoff, res->cmd_pid);
4853 cmdline_parse_token_string_t cmd_gro_enable_set =
4854 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4856 cmdline_parse_token_string_t cmd_gro_enable_port =
4857 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4858 cmd_keyword, "port");
4859 cmdline_parse_token_num_t cmd_gro_enable_pid =
4860 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4862 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4863 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4864 cmd_keyword, "gro");
4865 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4866 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4867 cmd_onoff, "on#off");
4869 cmdline_parse_inst_t cmd_gro_enable = {
4870 .f = cmd_gro_enable_parsed,
4872 .help_str = "set port <port_id> gro on|off",
4874 (void *)&cmd_gro_enable_set,
4875 (void *)&cmd_gro_enable_port,
4876 (void *)&cmd_gro_enable_pid,
4877 (void *)&cmd_gro_enable_keyword,
4878 (void *)&cmd_gro_enable_onoff,
4883 /* *** DISPLAY GRO CONFIGURATION *** */
4884 struct cmd_gro_show_result {
4885 cmdline_fixed_string_t cmd_show;
4886 cmdline_fixed_string_t cmd_port;
4887 cmdline_fixed_string_t cmd_keyword;
4892 cmd_gro_show_parsed(void *parsed_result,
4893 __attribute__((unused)) struct cmdline *cl,
4894 __attribute__((unused)) void *data)
4896 struct cmd_gro_show_result *res;
4898 res = parsed_result;
4899 if (!strcmp(res->cmd_keyword, "gro"))
4900 show_gro(res->cmd_pid);
4903 cmdline_parse_token_string_t cmd_gro_show_show =
4904 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4906 cmdline_parse_token_string_t cmd_gro_show_port =
4907 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4909 cmdline_parse_token_num_t cmd_gro_show_pid =
4910 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4912 cmdline_parse_token_string_t cmd_gro_show_keyword =
4913 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4914 cmd_keyword, "gro");
4916 cmdline_parse_inst_t cmd_gro_show = {
4917 .f = cmd_gro_show_parsed,
4919 .help_str = "show port <port_id> gro",
4921 (void *)&cmd_gro_show_show,
4922 (void *)&cmd_gro_show_port,
4923 (void *)&cmd_gro_show_pid,
4924 (void *)&cmd_gro_show_keyword,
4929 /* *** SET FLUSH CYCLES FOR GRO *** */
4930 struct cmd_gro_flush_result {
4931 cmdline_fixed_string_t cmd_set;
4932 cmdline_fixed_string_t cmd_keyword;
4933 cmdline_fixed_string_t cmd_flush;
4938 cmd_gro_flush_parsed(void *parsed_result,
4939 __attribute__((unused)) struct cmdline *cl,
4940 __attribute__((unused)) void *data)
4942 struct cmd_gro_flush_result *res;
4944 res = parsed_result;
4945 if ((!strcmp(res->cmd_keyword, "gro")) &&
4946 (!strcmp(res->cmd_flush, "flush")))
4947 setup_gro_flush_cycles(res->cmd_cycles);
4950 cmdline_parse_token_string_t cmd_gro_flush_set =
4951 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4953 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4954 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4955 cmd_keyword, "gro");
4956 cmdline_parse_token_string_t cmd_gro_flush_flush =
4957 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4958 cmd_flush, "flush");
4959 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4960 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4963 cmdline_parse_inst_t cmd_gro_flush = {
4964 .f = cmd_gro_flush_parsed,
4966 .help_str = "set gro flush <cycles>",
4968 (void *)&cmd_gro_flush_set,
4969 (void *)&cmd_gro_flush_keyword,
4970 (void *)&cmd_gro_flush_flush,
4971 (void *)&cmd_gro_flush_cycles,
4976 /* *** ENABLE/DISABLE GSO *** */
4977 struct cmd_gso_enable_result {
4978 cmdline_fixed_string_t cmd_set;
4979 cmdline_fixed_string_t cmd_port;
4980 cmdline_fixed_string_t cmd_keyword;
4981 cmdline_fixed_string_t cmd_mode;
4986 cmd_gso_enable_parsed(void *parsed_result,
4987 __attribute__((unused)) struct cmdline *cl,
4988 __attribute__((unused)) void *data)
4990 struct cmd_gso_enable_result *res;
4992 res = parsed_result;
4993 if (!strcmp(res->cmd_keyword, "gso"))
4994 setup_gso(res->cmd_mode, res->cmd_pid);
4997 cmdline_parse_token_string_t cmd_gso_enable_set =
4998 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5000 cmdline_parse_token_string_t cmd_gso_enable_port =
5001 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5003 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5004 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5005 cmd_keyword, "gso");
5006 cmdline_parse_token_string_t cmd_gso_enable_mode =
5007 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5008 cmd_mode, "on#off");
5009 cmdline_parse_token_num_t cmd_gso_enable_pid =
5010 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5013 cmdline_parse_inst_t cmd_gso_enable = {
5014 .f = cmd_gso_enable_parsed,
5016 .help_str = "set port <port_id> gso on|off",
5018 (void *)&cmd_gso_enable_set,
5019 (void *)&cmd_gso_enable_port,
5020 (void *)&cmd_gso_enable_pid,
5021 (void *)&cmd_gso_enable_keyword,
5022 (void *)&cmd_gso_enable_mode,
5027 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5028 struct cmd_gso_size_result {
5029 cmdline_fixed_string_t cmd_set;
5030 cmdline_fixed_string_t cmd_keyword;
5031 cmdline_fixed_string_t cmd_segsz;
5036 cmd_gso_size_parsed(void *parsed_result,
5037 __attribute__((unused)) struct cmdline *cl,
5038 __attribute__((unused)) void *data)
5040 struct cmd_gso_size_result *res = parsed_result;
5042 if (test_done == 0) {
5043 printf("Before setting GSO segsz, please first"
5044 " stop fowarding\n");
5048 if (!strcmp(res->cmd_keyword, "gso") &&
5049 !strcmp(res->cmd_segsz, "segsz")) {
5050 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5051 printf("gso_size should be larger than %zu."
5052 " Please input a legal value\n",
5053 RTE_GSO_SEG_SIZE_MIN);
5055 gso_max_segment_size = res->cmd_size;
5059 cmdline_parse_token_string_t cmd_gso_size_set =
5060 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5062 cmdline_parse_token_string_t cmd_gso_size_keyword =
5063 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5064 cmd_keyword, "gso");
5065 cmdline_parse_token_string_t cmd_gso_size_segsz =
5066 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5067 cmd_segsz, "segsz");
5068 cmdline_parse_token_num_t cmd_gso_size_size =
5069 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5072 cmdline_parse_inst_t cmd_gso_size = {
5073 .f = cmd_gso_size_parsed,
5075 .help_str = "set gso segsz <length>",
5077 (void *)&cmd_gso_size_set,
5078 (void *)&cmd_gso_size_keyword,
5079 (void *)&cmd_gso_size_segsz,
5080 (void *)&cmd_gso_size_size,
5085 /* *** SHOW GSO CONFIGURATION *** */
5086 struct cmd_gso_show_result {
5087 cmdline_fixed_string_t cmd_show;
5088 cmdline_fixed_string_t cmd_port;
5089 cmdline_fixed_string_t cmd_keyword;
5094 cmd_gso_show_parsed(void *parsed_result,
5095 __attribute__((unused)) struct cmdline *cl,
5096 __attribute__((unused)) void *data)
5098 struct cmd_gso_show_result *res = parsed_result;
5100 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5101 printf("invalid port id %u\n", res->cmd_pid);
5104 if (!strcmp(res->cmd_keyword, "gso")) {
5105 if (gso_ports[res->cmd_pid].enable) {
5106 printf("Max GSO'd packet size: %uB\n"
5107 "Supported GSO types: TCP/IPv4, "
5108 "UDP/IPv4, VxLAN with inner "
5109 "TCP/IPv4 packet, GRE with inner "
5110 "TCP/IPv4 packet\n",
5111 gso_max_segment_size);
5113 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5117 cmdline_parse_token_string_t cmd_gso_show_show =
5118 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5120 cmdline_parse_token_string_t cmd_gso_show_port =
5121 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5123 cmdline_parse_token_string_t cmd_gso_show_keyword =
5124 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5125 cmd_keyword, "gso");
5126 cmdline_parse_token_num_t cmd_gso_show_pid =
5127 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5130 cmdline_parse_inst_t cmd_gso_show = {
5131 .f = cmd_gso_show_parsed,
5133 .help_str = "show port <port_id> gso",
5135 (void *)&cmd_gso_show_show,
5136 (void *)&cmd_gso_show_port,
5137 (void *)&cmd_gso_show_pid,
5138 (void *)&cmd_gso_show_keyword,
5143 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5144 struct cmd_set_flush_rx {
5145 cmdline_fixed_string_t set;
5146 cmdline_fixed_string_t flush_rx;
5147 cmdline_fixed_string_t mode;
5151 cmd_set_flush_rx_parsed(void *parsed_result,
5152 __attribute__((unused)) struct cmdline *cl,
5153 __attribute__((unused)) void *data)
5155 struct cmd_set_flush_rx *res = parsed_result;
5156 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5159 cmdline_parse_token_string_t cmd_setflushrx_set =
5160 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5162 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5163 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5164 flush_rx, "flush_rx");
5165 cmdline_parse_token_string_t cmd_setflushrx_mode =
5166 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5170 cmdline_parse_inst_t cmd_set_flush_rx = {
5171 .f = cmd_set_flush_rx_parsed,
5172 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5175 (void *)&cmd_setflushrx_set,
5176 (void *)&cmd_setflushrx_flush_rx,
5177 (void *)&cmd_setflushrx_mode,
5182 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5183 struct cmd_set_link_check {
5184 cmdline_fixed_string_t set;
5185 cmdline_fixed_string_t link_check;
5186 cmdline_fixed_string_t mode;
5190 cmd_set_link_check_parsed(void *parsed_result,
5191 __attribute__((unused)) struct cmdline *cl,
5192 __attribute__((unused)) void *data)
5194 struct cmd_set_link_check *res = parsed_result;
5195 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5198 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5199 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5201 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5202 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5203 link_check, "link_check");
5204 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5205 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5209 cmdline_parse_inst_t cmd_set_link_check = {
5210 .f = cmd_set_link_check_parsed,
5211 .help_str = "set link_check on|off: Enable/Disable link status check "
5212 "when starting/stopping a port",
5215 (void *)&cmd_setlinkcheck_set,
5216 (void *)&cmd_setlinkcheck_link_check,
5217 (void *)&cmd_setlinkcheck_mode,
5222 /* *** SET NIC BYPASS MODE *** */
5223 struct cmd_set_bypass_mode_result {
5224 cmdline_fixed_string_t set;
5225 cmdline_fixed_string_t bypass;
5226 cmdline_fixed_string_t mode;
5227 cmdline_fixed_string_t value;
5232 cmd_set_bypass_mode_parsed(void *parsed_result,
5233 __attribute__((unused)) struct cmdline *cl,
5234 __attribute__((unused)) void *data)
5236 struct cmd_set_bypass_mode_result *res = parsed_result;
5237 portid_t port_id = res->port_id;
5238 int32_t rc = -EINVAL;
5240 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5241 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5243 if (!strcmp(res->value, "bypass"))
5244 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5245 else if (!strcmp(res->value, "isolate"))
5246 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5248 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5250 /* Set the bypass mode for the relevant port. */
5251 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5254 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5257 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5258 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5260 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5261 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5263 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5264 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5266 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5267 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5268 value, "normal#bypass#isolate");
5269 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5270 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5273 cmdline_parse_inst_t cmd_set_bypass_mode = {
5274 .f = cmd_set_bypass_mode_parsed,
5275 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5276 "Set the NIC bypass mode for port_id",
5279 (void *)&cmd_setbypass_mode_set,
5280 (void *)&cmd_setbypass_mode_bypass,
5281 (void *)&cmd_setbypass_mode_mode,
5282 (void *)&cmd_setbypass_mode_value,
5283 (void *)&cmd_setbypass_mode_port,
5288 /* *** SET NIC BYPASS EVENT *** */
5289 struct cmd_set_bypass_event_result {
5290 cmdline_fixed_string_t set;
5291 cmdline_fixed_string_t bypass;
5292 cmdline_fixed_string_t event;
5293 cmdline_fixed_string_t event_value;
5294 cmdline_fixed_string_t mode;
5295 cmdline_fixed_string_t mode_value;
5300 cmd_set_bypass_event_parsed(void *parsed_result,
5301 __attribute__((unused)) struct cmdline *cl,
5302 __attribute__((unused)) void *data)
5304 int32_t rc = -EINVAL;
5305 struct cmd_set_bypass_event_result *res = parsed_result;
5306 portid_t port_id = res->port_id;
5308 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5309 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5310 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5312 if (!strcmp(res->event_value, "timeout"))
5313 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5314 else if (!strcmp(res->event_value, "os_on"))
5315 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5316 else if (!strcmp(res->event_value, "os_off"))
5317 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5318 else if (!strcmp(res->event_value, "power_on"))
5319 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5320 else if (!strcmp(res->event_value, "power_off"))
5321 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5323 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5325 if (!strcmp(res->mode_value, "bypass"))
5326 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5327 else if (!strcmp(res->mode_value, "isolate"))
5328 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5330 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5332 /* Set the watchdog timeout. */
5333 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5336 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5337 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5341 printf("Failed to set timeout value %u "
5342 "for port %d, errto code: %d.\n",
5343 bypass_timeout, port_id, rc);
5347 /* Set the bypass event to transition to bypass mode. */
5348 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5353 printf("\t Failed to set bypass event for port = %d.\n",
5357 cmdline_parse_token_string_t cmd_setbypass_event_set =
5358 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5360 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5361 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5363 cmdline_parse_token_string_t cmd_setbypass_event_event =
5364 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5366 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5367 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5368 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5369 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5370 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5372 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5374 mode_value, "normal#bypass#isolate");
5375 cmdline_parse_token_num_t cmd_setbypass_event_port =
5376 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5379 cmdline_parse_inst_t cmd_set_bypass_event = {
5380 .f = cmd_set_bypass_event_parsed,
5381 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5382 "power_off mode normal|bypass|isolate <port_id>: "
5383 "Set the NIC bypass event mode for port_id",
5386 (void *)&cmd_setbypass_event_set,
5387 (void *)&cmd_setbypass_event_bypass,
5388 (void *)&cmd_setbypass_event_event,
5389 (void *)&cmd_setbypass_event_event_value,
5390 (void *)&cmd_setbypass_event_mode,
5391 (void *)&cmd_setbypass_event_mode_value,
5392 (void *)&cmd_setbypass_event_port,
5398 /* *** SET NIC BYPASS TIMEOUT *** */
5399 struct cmd_set_bypass_timeout_result {
5400 cmdline_fixed_string_t set;
5401 cmdline_fixed_string_t bypass;
5402 cmdline_fixed_string_t timeout;
5403 cmdline_fixed_string_t value;
5407 cmd_set_bypass_timeout_parsed(void *parsed_result,
5408 __attribute__((unused)) struct cmdline *cl,
5409 __attribute__((unused)) void *data)
5411 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5413 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5414 if (!strcmp(res->value, "1.5"))
5415 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5416 else if (!strcmp(res->value, "2"))
5417 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5418 else if (!strcmp(res->value, "3"))
5419 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5420 else if (!strcmp(res->value, "4"))
5421 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5422 else if (!strcmp(res->value, "8"))
5423 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5424 else if (!strcmp(res->value, "16"))
5425 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5426 else if (!strcmp(res->value, "32"))
5427 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5429 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5433 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5434 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5436 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5439 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5441 timeout, "timeout");
5442 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5444 value, "0#1.5#2#3#4#8#16#32");
5446 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5447 .f = cmd_set_bypass_timeout_parsed,
5448 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5449 "Set the NIC bypass watchdog timeout in seconds",
5452 (void *)&cmd_setbypass_timeout_set,
5453 (void *)&cmd_setbypass_timeout_bypass,
5454 (void *)&cmd_setbypass_timeout_timeout,
5455 (void *)&cmd_setbypass_timeout_value,
5460 /* *** SHOW NIC BYPASS MODE *** */
5461 struct cmd_show_bypass_config_result {
5462 cmdline_fixed_string_t show;
5463 cmdline_fixed_string_t bypass;
5464 cmdline_fixed_string_t config;
5469 cmd_show_bypass_config_parsed(void *parsed_result,
5470 __attribute__((unused)) struct cmdline *cl,
5471 __attribute__((unused)) void *data)
5473 struct cmd_show_bypass_config_result *res = parsed_result;
5474 portid_t port_id = res->port_id;
5476 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5477 uint32_t event_mode;
5478 uint32_t bypass_mode;
5479 uint32_t timeout = bypass_timeout;
5482 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5483 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5484 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5485 {"UNKNOWN", "normal", "bypass", "isolate"};
5486 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5493 int num_events = (sizeof events) / (sizeof events[0]);
5495 /* Display the bypass mode.*/
5496 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5497 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5501 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5502 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5504 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5507 /* Display the bypass timeout.*/
5508 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5509 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5511 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5513 /* Display the bypass events and associated modes. */
5514 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5516 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5517 printf("\tFailed to get bypass mode for event = %s\n",
5520 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5521 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5523 printf("\tbypass event: %-16s = %s\n", events[i],
5529 printf("\tFailed to get bypass configuration for port = %d\n",
5533 cmdline_parse_token_string_t cmd_showbypass_config_show =
5534 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5536 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5537 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5539 cmdline_parse_token_string_t cmd_showbypass_config_config =
5540 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5542 cmdline_parse_token_num_t cmd_showbypass_config_port =
5543 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5546 cmdline_parse_inst_t cmd_show_bypass_config = {
5547 .f = cmd_show_bypass_config_parsed,
5548 .help_str = "show bypass config <port_id>: "
5549 "Show the NIC bypass config for port_id",
5552 (void *)&cmd_showbypass_config_show,
5553 (void *)&cmd_showbypass_config_bypass,
5554 (void *)&cmd_showbypass_config_config,
5555 (void *)&cmd_showbypass_config_port,
5560 #ifdef RTE_LIBRTE_PMD_BOND
5561 /* *** SET BONDING MODE *** */
5562 struct cmd_set_bonding_mode_result {
5563 cmdline_fixed_string_t set;
5564 cmdline_fixed_string_t bonding;
5565 cmdline_fixed_string_t mode;
5570 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5571 __attribute__((unused)) struct cmdline *cl,
5572 __attribute__((unused)) void *data)
5574 struct cmd_set_bonding_mode_result *res = parsed_result;
5575 portid_t port_id = res->port_id;
5577 /* Set the bonding mode for the relevant port. */
5578 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5579 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5582 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5583 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5585 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5586 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5587 bonding, "bonding");
5588 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5589 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5591 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5592 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5594 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5595 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5598 cmdline_parse_inst_t cmd_set_bonding_mode = {
5599 .f = cmd_set_bonding_mode_parsed,
5600 .help_str = "set bonding mode <mode_value> <port_id>: "
5601 "Set the bonding mode for port_id",
5604 (void *) &cmd_setbonding_mode_set,
5605 (void *) &cmd_setbonding_mode_bonding,
5606 (void *) &cmd_setbonding_mode_mode,
5607 (void *) &cmd_setbonding_mode_value,
5608 (void *) &cmd_setbonding_mode_port,
5613 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5614 struct cmd_set_bonding_lacp_dedicated_queues_result {
5615 cmdline_fixed_string_t set;
5616 cmdline_fixed_string_t bonding;
5617 cmdline_fixed_string_t lacp;
5618 cmdline_fixed_string_t dedicated_queues;
5620 cmdline_fixed_string_t mode;
5623 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5624 __attribute__((unused)) struct cmdline *cl,
5625 __attribute__((unused)) void *data)
5627 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5628 portid_t port_id = res->port_id;
5629 struct rte_port *port;
5631 port = &ports[port_id];
5633 /** Check if the port is not started **/
5634 if (port->port_status != RTE_PORT_STOPPED) {
5635 printf("Please stop port %d first\n", port_id);
5639 if (!strcmp(res->mode, "enable")) {
5640 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5641 printf("Dedicate queues for LACP control packets"
5644 printf("Enabling dedicate queues for LACP control "
5645 "packets on port %d failed\n", port_id);
5646 } else if (!strcmp(res->mode, "disable")) {
5647 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5648 printf("Dedicated queues for LACP control packets "
5651 printf("Disabling dedicated queues for LACP control "
5652 "traffic on port %d failed\n", port_id);
5656 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5657 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5659 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5660 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5661 bonding, "bonding");
5662 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5663 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5665 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5666 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5667 dedicated_queues, "dedicated_queues");
5668 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5669 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5671 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5672 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5673 mode, "enable#disable");
5675 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5676 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5677 .help_str = "set bonding lacp dedicated_queues <port_id> "
5679 "Enable/disable dedicated queues for LACP control traffic for port_id",
5682 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5683 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5684 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5685 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5686 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5687 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5692 /* *** SET BALANCE XMIT POLICY *** */
5693 struct cmd_set_bonding_balance_xmit_policy_result {
5694 cmdline_fixed_string_t set;
5695 cmdline_fixed_string_t bonding;
5696 cmdline_fixed_string_t balance_xmit_policy;
5698 cmdline_fixed_string_t policy;
5701 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5702 __attribute__((unused)) struct cmdline *cl,
5703 __attribute__((unused)) void *data)
5705 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5706 portid_t port_id = res->port_id;
5709 if (!strcmp(res->policy, "l2")) {
5710 policy = BALANCE_XMIT_POLICY_LAYER2;
5711 } else if (!strcmp(res->policy, "l23")) {
5712 policy = BALANCE_XMIT_POLICY_LAYER23;
5713 } else if (!strcmp(res->policy, "l34")) {
5714 policy = BALANCE_XMIT_POLICY_LAYER34;
5716 printf("\t Invalid xmit policy selection");
5720 /* Set the bonding mode for the relevant port. */
5721 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5722 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5727 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5728 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5730 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5731 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5732 bonding, "bonding");
5733 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5734 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5735 balance_xmit_policy, "balance_xmit_policy");
5736 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5737 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5739 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5740 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5741 policy, "l2#l23#l34");
5743 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5744 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5745 .help_str = "set bonding balance_xmit_policy <port_id> "
5747 "Set the bonding balance_xmit_policy for port_id",
5750 (void *)&cmd_setbonding_balance_xmit_policy_set,
5751 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5752 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5753 (void *)&cmd_setbonding_balance_xmit_policy_port,
5754 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5759 /* *** SHOW NIC BONDING CONFIGURATION *** */
5760 struct cmd_show_bonding_config_result {
5761 cmdline_fixed_string_t show;
5762 cmdline_fixed_string_t bonding;
5763 cmdline_fixed_string_t config;
5767 static void cmd_show_bonding_config_parsed(void *parsed_result,
5768 __attribute__((unused)) struct cmdline *cl,
5769 __attribute__((unused)) void *data)
5771 struct cmd_show_bonding_config_result *res = parsed_result;
5772 int bonding_mode, agg_mode;
5773 portid_t slaves[RTE_MAX_ETHPORTS];
5774 int num_slaves, num_active_slaves;
5777 portid_t port_id = res->port_id;
5779 /* Display the bonding mode.*/
5780 bonding_mode = rte_eth_bond_mode_get(port_id);
5781 if (bonding_mode < 0) {
5782 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5785 printf("\tBonding mode: %d\n", bonding_mode);
5787 if (bonding_mode == BONDING_MODE_BALANCE) {
5788 int balance_xmit_policy;
5790 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5791 if (balance_xmit_policy < 0) {
5792 printf("\tFailed to get balance xmit policy for port = %d\n",
5796 printf("\tBalance Xmit Policy: ");
5798 switch (balance_xmit_policy) {
5799 case BALANCE_XMIT_POLICY_LAYER2:
5800 printf("BALANCE_XMIT_POLICY_LAYER2");
5802 case BALANCE_XMIT_POLICY_LAYER23:
5803 printf("BALANCE_XMIT_POLICY_LAYER23");
5805 case BALANCE_XMIT_POLICY_LAYER34:
5806 printf("BALANCE_XMIT_POLICY_LAYER34");
5813 if (bonding_mode == BONDING_MODE_8023AD) {
5814 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5815 printf("\tIEEE802.3AD Aggregator Mode: ");
5818 printf("bandwidth");
5830 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5832 if (num_slaves < 0) {
5833 printf("\tFailed to get slave list for port = %d\n", port_id);
5836 if (num_slaves > 0) {
5837 printf("\tSlaves (%d): [", num_slaves);
5838 for (i = 0; i < num_slaves - 1; i++)
5839 printf("%d ", slaves[i]);
5841 printf("%d]\n", slaves[num_slaves - 1]);
5843 printf("\tSlaves: []\n");
5847 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5850 if (num_active_slaves < 0) {
5851 printf("\tFailed to get active slave list for port = %d\n", port_id);
5854 if (num_active_slaves > 0) {
5855 printf("\tActive Slaves (%d): [", num_active_slaves);
5856 for (i = 0; i < num_active_slaves - 1; i++)
5857 printf("%d ", slaves[i]);
5859 printf("%d]\n", slaves[num_active_slaves - 1]);
5862 printf("\tActive Slaves: []\n");
5866 primary_id = rte_eth_bond_primary_get(port_id);
5867 if (primary_id < 0) {
5868 printf("\tFailed to get primary slave for port = %d\n", port_id);
5871 printf("\tPrimary: [%d]\n", primary_id);
5875 cmdline_parse_token_string_t cmd_showbonding_config_show =
5876 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5878 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5879 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5880 bonding, "bonding");
5881 cmdline_parse_token_string_t cmd_showbonding_config_config =
5882 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5884 cmdline_parse_token_num_t cmd_showbonding_config_port =
5885 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5888 cmdline_parse_inst_t cmd_show_bonding_config = {
5889 .f = cmd_show_bonding_config_parsed,
5890 .help_str = "show bonding config <port_id>: "
5891 "Show the bonding config for port_id",
5894 (void *)&cmd_showbonding_config_show,
5895 (void *)&cmd_showbonding_config_bonding,
5896 (void *)&cmd_showbonding_config_config,
5897 (void *)&cmd_showbonding_config_port,
5902 /* *** SET BONDING PRIMARY *** */
5903 struct cmd_set_bonding_primary_result {
5904 cmdline_fixed_string_t set;
5905 cmdline_fixed_string_t bonding;
5906 cmdline_fixed_string_t primary;
5911 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5912 __attribute__((unused)) struct cmdline *cl,
5913 __attribute__((unused)) void *data)
5915 struct cmd_set_bonding_primary_result *res = parsed_result;
5916 portid_t master_port_id = res->port_id;
5917 portid_t slave_port_id = res->slave_id;
5919 /* Set the primary slave for a bonded device. */
5920 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5921 printf("\t Failed to set primary slave for port = %d.\n",
5928 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5929 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5931 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5933 bonding, "bonding");
5934 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5936 primary, "primary");
5937 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5938 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5940 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5941 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5944 cmdline_parse_inst_t cmd_set_bonding_primary = {
5945 .f = cmd_set_bonding_primary_parsed,
5946 .help_str = "set bonding primary <slave_id> <port_id>: "
5947 "Set the primary slave for port_id",
5950 (void *)&cmd_setbonding_primary_set,
5951 (void *)&cmd_setbonding_primary_bonding,
5952 (void *)&cmd_setbonding_primary_primary,
5953 (void *)&cmd_setbonding_primary_slave,
5954 (void *)&cmd_setbonding_primary_port,
5959 /* *** ADD SLAVE *** */
5960 struct cmd_add_bonding_slave_result {
5961 cmdline_fixed_string_t add;
5962 cmdline_fixed_string_t bonding;
5963 cmdline_fixed_string_t slave;
5968 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5969 __attribute__((unused)) struct cmdline *cl,
5970 __attribute__((unused)) void *data)
5972 struct cmd_add_bonding_slave_result *res = parsed_result;
5973 portid_t master_port_id = res->port_id;
5974 portid_t slave_port_id = res->slave_id;
5976 /* add the slave for a bonded device. */
5977 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5978 printf("\t Failed to add slave %d to master port = %d.\n",
5979 slave_port_id, master_port_id);
5983 set_port_slave_flag(slave_port_id);
5986 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5987 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5989 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5990 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5991 bonding, "bonding");
5992 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5993 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5995 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5996 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5998 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5999 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6002 cmdline_parse_inst_t cmd_add_bonding_slave = {
6003 .f = cmd_add_bonding_slave_parsed,
6004 .help_str = "add bonding slave <slave_id> <port_id>: "
6005 "Add a slave device to a bonded device",
6008 (void *)&cmd_addbonding_slave_add,
6009 (void *)&cmd_addbonding_slave_bonding,
6010 (void *)&cmd_addbonding_slave_slave,
6011 (void *)&cmd_addbonding_slave_slaveid,
6012 (void *)&cmd_addbonding_slave_port,
6017 /* *** REMOVE SLAVE *** */
6018 struct cmd_remove_bonding_slave_result {
6019 cmdline_fixed_string_t remove;
6020 cmdline_fixed_string_t bonding;
6021 cmdline_fixed_string_t slave;
6026 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6027 __attribute__((unused)) struct cmdline *cl,
6028 __attribute__((unused)) void *data)
6030 struct cmd_remove_bonding_slave_result *res = parsed_result;
6031 portid_t master_port_id = res->port_id;
6032 portid_t slave_port_id = res->slave_id;
6034 /* remove the slave from a bonded device. */
6035 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6036 printf("\t Failed to remove slave %d from master port = %d.\n",
6037 slave_port_id, master_port_id);
6041 clear_port_slave_flag(slave_port_id);
6044 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6045 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6047 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6048 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6049 bonding, "bonding");
6050 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6051 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6053 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6054 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6056 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6057 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6060 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6061 .f = cmd_remove_bonding_slave_parsed,
6062 .help_str = "remove bonding slave <slave_id> <port_id>: "
6063 "Remove a slave device from a bonded device",
6066 (void *)&cmd_removebonding_slave_remove,
6067 (void *)&cmd_removebonding_slave_bonding,
6068 (void *)&cmd_removebonding_slave_slave,
6069 (void *)&cmd_removebonding_slave_slaveid,
6070 (void *)&cmd_removebonding_slave_port,
6075 /* *** CREATE BONDED DEVICE *** */
6076 struct cmd_create_bonded_device_result {
6077 cmdline_fixed_string_t create;
6078 cmdline_fixed_string_t bonded;
6079 cmdline_fixed_string_t device;
6084 static int bond_dev_num = 0;
6086 static void cmd_create_bonded_device_parsed(void *parsed_result,
6087 __attribute__((unused)) struct cmdline *cl,
6088 __attribute__((unused)) void *data)
6090 struct cmd_create_bonded_device_result *res = parsed_result;
6091 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6095 if (test_done == 0) {
6096 printf("Please stop forwarding first\n");
6100 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6103 /* Create a new bonded device. */
6104 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6106 printf("\t Failed to create bonded device.\n");
6109 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6112 /* Update number of ports */
6113 nb_ports = rte_eth_dev_count_avail();
6114 reconfig(port_id, res->socket);
6115 ret = rte_eth_promiscuous_enable(port_id);
6117 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6118 port_id, rte_strerror(-ret));
6120 ports[port_id].need_setup = 0;
6121 ports[port_id].port_status = RTE_PORT_STOPPED;
6126 cmdline_parse_token_string_t cmd_createbonded_device_create =
6127 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6129 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6130 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6132 cmdline_parse_token_string_t cmd_createbonded_device_device =
6133 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6135 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6136 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6138 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6139 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6142 cmdline_parse_inst_t cmd_create_bonded_device = {
6143 .f = cmd_create_bonded_device_parsed,
6144 .help_str = "create bonded device <mode> <socket>: "
6145 "Create a new bonded device with specific bonding mode and socket",
6148 (void *)&cmd_createbonded_device_create,
6149 (void *)&cmd_createbonded_device_bonded,
6150 (void *)&cmd_createbonded_device_device,
6151 (void *)&cmd_createbonded_device_mode,
6152 (void *)&cmd_createbonded_device_socket,
6157 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6158 struct cmd_set_bond_mac_addr_result {
6159 cmdline_fixed_string_t set;
6160 cmdline_fixed_string_t bonding;
6161 cmdline_fixed_string_t mac_addr;
6163 struct rte_ether_addr address;
6166 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6167 __attribute__((unused)) struct cmdline *cl,
6168 __attribute__((unused)) void *data)
6170 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6173 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6176 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6178 /* check the return value and print it if is < 0 */
6180 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6183 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6184 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6185 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6186 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6188 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6189 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6191 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6192 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6194 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6195 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6197 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6198 .f = cmd_set_bond_mac_addr_parsed,
6200 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6202 (void *)&cmd_set_bond_mac_addr_set,
6203 (void *)&cmd_set_bond_mac_addr_bonding,
6204 (void *)&cmd_set_bond_mac_addr_mac,
6205 (void *)&cmd_set_bond_mac_addr_portnum,
6206 (void *)&cmd_set_bond_mac_addr_addr,
6212 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6213 struct cmd_set_bond_mon_period_result {
6214 cmdline_fixed_string_t set;
6215 cmdline_fixed_string_t bonding;
6216 cmdline_fixed_string_t mon_period;
6221 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6222 __attribute__((unused)) struct cmdline *cl,
6223 __attribute__((unused)) void *data)
6225 struct cmd_set_bond_mon_period_result *res = parsed_result;
6228 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6230 /* check the return value and print it if is < 0 */
6232 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6235 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6236 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6238 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6239 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6240 bonding, "bonding");
6241 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6242 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6243 mon_period, "mon_period");
6244 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6245 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6247 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6248 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6251 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6252 .f = cmd_set_bond_mon_period_parsed,
6254 .help_str = "set bonding mon_period <port_id> <period_ms>",
6256 (void *)&cmd_set_bond_mon_period_set,
6257 (void *)&cmd_set_bond_mon_period_bonding,
6258 (void *)&cmd_set_bond_mon_period_mon_period,
6259 (void *)&cmd_set_bond_mon_period_portnum,
6260 (void *)&cmd_set_bond_mon_period_period_ms,
6267 struct cmd_set_bonding_agg_mode_policy_result {
6268 cmdline_fixed_string_t set;
6269 cmdline_fixed_string_t bonding;
6270 cmdline_fixed_string_t agg_mode;
6272 cmdline_fixed_string_t policy;
6277 cmd_set_bonding_agg_mode(void *parsed_result,
6278 __attribute__((unused)) struct cmdline *cl,
6279 __attribute__((unused)) void *data)
6281 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6282 uint8_t policy = AGG_BANDWIDTH;
6284 if (!strcmp(res->policy, "bandwidth"))
6285 policy = AGG_BANDWIDTH;
6286 else if (!strcmp(res->policy, "stable"))
6287 policy = AGG_STABLE;
6288 else if (!strcmp(res->policy, "count"))
6291 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6295 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6296 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6298 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6299 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6300 bonding, "bonding");
6302 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6303 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6304 agg_mode, "agg_mode");
6306 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6307 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6310 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6311 TOKEN_STRING_INITIALIZER(
6312 struct cmd_set_bonding_balance_xmit_policy_result,
6313 policy, "stable#bandwidth#count");
6315 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6316 .f = cmd_set_bonding_agg_mode,
6318 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6320 (void *)&cmd_set_bonding_agg_mode_set,
6321 (void *)&cmd_set_bonding_agg_mode_bonding,
6322 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6323 (void *)&cmd_set_bonding_agg_mode_portnum,
6324 (void *)&cmd_set_bonding_agg_mode_policy_string,
6330 #endif /* RTE_LIBRTE_PMD_BOND */
6332 /* *** SET FORWARDING MODE *** */
6333 struct cmd_set_fwd_mode_result {
6334 cmdline_fixed_string_t set;
6335 cmdline_fixed_string_t fwd;
6336 cmdline_fixed_string_t mode;
6339 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6340 __attribute__((unused)) struct cmdline *cl,
6341 __attribute__((unused)) void *data)
6343 struct cmd_set_fwd_mode_result *res = parsed_result;
6346 set_pkt_forwarding_mode(res->mode);
6349 cmdline_parse_token_string_t cmd_setfwd_set =
6350 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6351 cmdline_parse_token_string_t cmd_setfwd_fwd =
6352 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6353 cmdline_parse_token_string_t cmd_setfwd_mode =
6354 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6355 "" /* defined at init */);
6357 cmdline_parse_inst_t cmd_set_fwd_mode = {
6358 .f = cmd_set_fwd_mode_parsed,
6360 .help_str = NULL, /* defined at init */
6362 (void *)&cmd_setfwd_set,
6363 (void *)&cmd_setfwd_fwd,
6364 (void *)&cmd_setfwd_mode,
6369 static void cmd_set_fwd_mode_init(void)
6372 static char token[128];
6373 static char help[256];
6374 cmdline_parse_token_string_t *token_struct;
6376 modes = list_pkt_forwarding_modes();
6377 snprintf(help, sizeof(help), "set fwd %s: "
6378 "Set packet forwarding mode", modes);
6379 cmd_set_fwd_mode.help_str = help;
6381 /* string token separator is # */
6382 for (c = token; *modes != '\0'; modes++)
6387 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6388 token_struct->string_data.str = token;
6391 /* *** SET RETRY FORWARDING MODE *** */
6392 struct cmd_set_fwd_retry_mode_result {
6393 cmdline_fixed_string_t set;
6394 cmdline_fixed_string_t fwd;
6395 cmdline_fixed_string_t mode;
6396 cmdline_fixed_string_t retry;
6399 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6400 __attribute__((unused)) struct cmdline *cl,
6401 __attribute__((unused)) void *data)
6403 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6406 set_pkt_forwarding_mode(res->mode);
6409 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6410 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6412 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6413 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6415 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6416 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6418 "" /* defined at init */);
6419 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6420 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6423 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6424 .f = cmd_set_fwd_retry_mode_parsed,
6426 .help_str = NULL, /* defined at init */
6428 (void *)&cmd_setfwd_retry_set,
6429 (void *)&cmd_setfwd_retry_fwd,
6430 (void *)&cmd_setfwd_retry_mode,
6431 (void *)&cmd_setfwd_retry_retry,
6436 static void cmd_set_fwd_retry_mode_init(void)
6439 static char token[128];
6440 static char help[256];
6441 cmdline_parse_token_string_t *token_struct;
6443 modes = list_pkt_forwarding_retry_modes();
6444 snprintf(help, sizeof(help), "set fwd %s retry: "
6445 "Set packet forwarding mode with retry", modes);
6446 cmd_set_fwd_retry_mode.help_str = help;
6448 /* string token separator is # */
6449 for (c = token; *modes != '\0'; modes++)
6454 token_struct = (cmdline_parse_token_string_t *)
6455 cmd_set_fwd_retry_mode.tokens[2];
6456 token_struct->string_data.str = token;
6459 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6460 struct cmd_set_burst_tx_retry_result {
6461 cmdline_fixed_string_t set;
6462 cmdline_fixed_string_t burst;
6463 cmdline_fixed_string_t tx;
6464 cmdline_fixed_string_t delay;
6466 cmdline_fixed_string_t retry;
6470 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6471 __attribute__((unused)) struct cmdline *cl,
6472 __attribute__((unused)) void *data)
6474 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6476 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6477 && !strcmp(res->tx, "tx")) {
6478 if (!strcmp(res->delay, "delay"))
6479 burst_tx_delay_time = res->time;
6480 if (!strcmp(res->retry, "retry"))
6481 burst_tx_retry_num = res->retry_num;
6486 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6487 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6488 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6491 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6492 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6493 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6495 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6496 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6497 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6498 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6499 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6500 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6502 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6503 .f = cmd_set_burst_tx_retry_parsed,
6504 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6506 (void *)&cmd_set_burst_tx_retry_set,
6507 (void *)&cmd_set_burst_tx_retry_burst,
6508 (void *)&cmd_set_burst_tx_retry_tx,
6509 (void *)&cmd_set_burst_tx_retry_delay,
6510 (void *)&cmd_set_burst_tx_retry_time,
6511 (void *)&cmd_set_burst_tx_retry_retry,
6512 (void *)&cmd_set_burst_tx_retry_retry_num,
6517 /* *** SET PROMISC MODE *** */
6518 struct cmd_set_promisc_mode_result {
6519 cmdline_fixed_string_t set;
6520 cmdline_fixed_string_t promisc;
6521 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6522 uint16_t port_num; /* valid if "allports" argument == 0 */
6523 cmdline_fixed_string_t mode;
6526 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6527 __attribute__((unused)) struct cmdline *cl,
6530 struct cmd_set_promisc_mode_result *res = parsed_result;
6534 if (!strcmp(res->mode, "on"))
6541 RTE_ETH_FOREACH_DEV(i)
6542 eth_set_promisc_mode(i, enable);
6544 eth_set_promisc_mode(res->port_num, enable);
6548 cmdline_parse_token_string_t cmd_setpromisc_set =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6550 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6551 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6553 cmdline_parse_token_string_t cmd_setpromisc_portall =
6554 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6556 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6557 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6559 cmdline_parse_token_string_t cmd_setpromisc_mode =
6560 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6563 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6564 .f = cmd_set_promisc_mode_parsed,
6566 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6568 (void *)&cmd_setpromisc_set,
6569 (void *)&cmd_setpromisc_promisc,
6570 (void *)&cmd_setpromisc_portall,
6571 (void *)&cmd_setpromisc_mode,
6576 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6577 .f = cmd_set_promisc_mode_parsed,
6579 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6581 (void *)&cmd_setpromisc_set,
6582 (void *)&cmd_setpromisc_promisc,
6583 (void *)&cmd_setpromisc_portnum,
6584 (void *)&cmd_setpromisc_mode,
6589 /* *** SET ALLMULTI MODE *** */
6590 struct cmd_set_allmulti_mode_result {
6591 cmdline_fixed_string_t set;
6592 cmdline_fixed_string_t allmulti;
6593 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6594 uint16_t port_num; /* valid if "allports" argument == 0 */
6595 cmdline_fixed_string_t mode;
6598 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6599 __attribute__((unused)) struct cmdline *cl,
6602 struct cmd_set_allmulti_mode_result *res = parsed_result;
6606 if (!strcmp(res->mode, "on"))
6613 RTE_ETH_FOREACH_DEV(i) {
6614 eth_set_allmulticast_mode(i, enable);
6618 eth_set_allmulticast_mode(res->port_num, enable);
6622 cmdline_parse_token_string_t cmd_setallmulti_set =
6623 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6624 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6625 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6627 cmdline_parse_token_string_t cmd_setallmulti_portall =
6628 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6630 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6631 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6633 cmdline_parse_token_string_t cmd_setallmulti_mode =
6634 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6637 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6638 .f = cmd_set_allmulti_mode_parsed,
6640 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6642 (void *)&cmd_setallmulti_set,
6643 (void *)&cmd_setallmulti_allmulti,
6644 (void *)&cmd_setallmulti_portall,
6645 (void *)&cmd_setallmulti_mode,
6650 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6651 .f = cmd_set_allmulti_mode_parsed,
6653 .help_str = "set allmulti <port_id> on|off: "
6654 "Set allmulti mode on port_id",
6656 (void *)&cmd_setallmulti_set,
6657 (void *)&cmd_setallmulti_allmulti,
6658 (void *)&cmd_setallmulti_portnum,
6659 (void *)&cmd_setallmulti_mode,
6664 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6665 struct cmd_link_flow_ctrl_set_result {
6666 cmdline_fixed_string_t set;
6667 cmdline_fixed_string_t flow_ctrl;
6668 cmdline_fixed_string_t rx;
6669 cmdline_fixed_string_t rx_lfc_mode;
6670 cmdline_fixed_string_t tx;
6671 cmdline_fixed_string_t tx_lfc_mode;
6672 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6673 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6674 cmdline_fixed_string_t autoneg_str;
6675 cmdline_fixed_string_t autoneg;
6676 cmdline_fixed_string_t hw_str;
6677 uint32_t high_water;
6678 cmdline_fixed_string_t lw_str;
6680 cmdline_fixed_string_t pt_str;
6681 uint16_t pause_time;
6682 cmdline_fixed_string_t xon_str;
6687 cmdline_parse_token_string_t cmd_lfc_set_set =
6688 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6690 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6691 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6692 flow_ctrl, "flow_ctrl");
6693 cmdline_parse_token_string_t cmd_lfc_set_rx =
6694 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6696 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6697 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6698 rx_lfc_mode, "on#off");
6699 cmdline_parse_token_string_t cmd_lfc_set_tx =
6700 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6702 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6703 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6704 tx_lfc_mode, "on#off");
6705 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6706 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6707 hw_str, "high_water");
6708 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6709 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6710 high_water, UINT32);
6711 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6712 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6713 lw_str, "low_water");
6714 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6715 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6717 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6718 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6719 pt_str, "pause_time");
6720 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6721 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6722 pause_time, UINT16);
6723 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6724 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6725 xon_str, "send_xon");
6726 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6727 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6729 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6730 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6731 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6732 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6733 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6734 mac_ctrl_frame_fwd_mode, "on#off");
6735 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6736 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6737 autoneg_str, "autoneg");
6738 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6739 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6741 cmdline_parse_token_num_t cmd_lfc_set_portid =
6742 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6745 /* forward declaration */
6747 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6750 cmdline_parse_inst_t cmd_link_flow_control_set = {
6751 .f = cmd_link_flow_ctrl_set_parsed,
6753 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6754 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6755 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6757 (void *)&cmd_lfc_set_set,
6758 (void *)&cmd_lfc_set_flow_ctrl,
6759 (void *)&cmd_lfc_set_rx,
6760 (void *)&cmd_lfc_set_rx_mode,
6761 (void *)&cmd_lfc_set_tx,
6762 (void *)&cmd_lfc_set_tx_mode,
6763 (void *)&cmd_lfc_set_high_water,
6764 (void *)&cmd_lfc_set_low_water,
6765 (void *)&cmd_lfc_set_pause_time,
6766 (void *)&cmd_lfc_set_send_xon,
6767 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6768 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6769 (void *)&cmd_lfc_set_autoneg_str,
6770 (void *)&cmd_lfc_set_autoneg,
6771 (void *)&cmd_lfc_set_portid,
6776 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6777 .f = cmd_link_flow_ctrl_set_parsed,
6778 .data = (void *)&cmd_link_flow_control_set_rx,
6779 .help_str = "set flow_ctrl rx on|off <port_id>: "
6780 "Change rx flow control parameter",
6782 (void *)&cmd_lfc_set_set,
6783 (void *)&cmd_lfc_set_flow_ctrl,
6784 (void *)&cmd_lfc_set_rx,
6785 (void *)&cmd_lfc_set_rx_mode,
6786 (void *)&cmd_lfc_set_portid,
6791 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6792 .f = cmd_link_flow_ctrl_set_parsed,
6793 .data = (void *)&cmd_link_flow_control_set_tx,
6794 .help_str = "set flow_ctrl tx on|off <port_id>: "
6795 "Change tx flow control parameter",
6797 (void *)&cmd_lfc_set_set,
6798 (void *)&cmd_lfc_set_flow_ctrl,
6799 (void *)&cmd_lfc_set_tx,
6800 (void *)&cmd_lfc_set_tx_mode,
6801 (void *)&cmd_lfc_set_portid,
6806 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6807 .f = cmd_link_flow_ctrl_set_parsed,
6808 .data = (void *)&cmd_link_flow_control_set_hw,
6809 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6810 "Change high water flow control parameter",
6812 (void *)&cmd_lfc_set_set,
6813 (void *)&cmd_lfc_set_flow_ctrl,
6814 (void *)&cmd_lfc_set_high_water_str,
6815 (void *)&cmd_lfc_set_high_water,
6816 (void *)&cmd_lfc_set_portid,
6821 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6822 .f = cmd_link_flow_ctrl_set_parsed,
6823 .data = (void *)&cmd_link_flow_control_set_lw,
6824 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6825 "Change low water flow control parameter",
6827 (void *)&cmd_lfc_set_set,
6828 (void *)&cmd_lfc_set_flow_ctrl,
6829 (void *)&cmd_lfc_set_low_water_str,
6830 (void *)&cmd_lfc_set_low_water,
6831 (void *)&cmd_lfc_set_portid,
6836 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6837 .f = cmd_link_flow_ctrl_set_parsed,
6838 .data = (void *)&cmd_link_flow_control_set_pt,
6839 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6840 "Change pause time flow control parameter",
6842 (void *)&cmd_lfc_set_set,
6843 (void *)&cmd_lfc_set_flow_ctrl,
6844 (void *)&cmd_lfc_set_pause_time_str,
6845 (void *)&cmd_lfc_set_pause_time,
6846 (void *)&cmd_lfc_set_portid,
6851 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6852 .f = cmd_link_flow_ctrl_set_parsed,
6853 .data = (void *)&cmd_link_flow_control_set_xon,
6854 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6855 "Change send_xon flow control parameter",
6857 (void *)&cmd_lfc_set_set,
6858 (void *)&cmd_lfc_set_flow_ctrl,
6859 (void *)&cmd_lfc_set_send_xon_str,
6860 (void *)&cmd_lfc_set_send_xon,
6861 (void *)&cmd_lfc_set_portid,
6866 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6867 .f = cmd_link_flow_ctrl_set_parsed,
6868 .data = (void *)&cmd_link_flow_control_set_macfwd,
6869 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6870 "Change mac ctrl fwd flow control parameter",
6872 (void *)&cmd_lfc_set_set,
6873 (void *)&cmd_lfc_set_flow_ctrl,
6874 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6875 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6876 (void *)&cmd_lfc_set_portid,
6881 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6882 .f = cmd_link_flow_ctrl_set_parsed,
6883 .data = (void *)&cmd_link_flow_control_set_autoneg,
6884 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6885 "Change autoneg flow control parameter",
6887 (void *)&cmd_lfc_set_set,
6888 (void *)&cmd_lfc_set_flow_ctrl,
6889 (void *)&cmd_lfc_set_autoneg_str,
6890 (void *)&cmd_lfc_set_autoneg,
6891 (void *)&cmd_lfc_set_portid,
6897 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6898 __attribute__((unused)) struct cmdline *cl,
6901 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6902 cmdline_parse_inst_t *cmd = data;
6903 struct rte_eth_fc_conf fc_conf;
6909 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6910 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6911 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6912 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6914 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6915 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6918 /* Partial command line, retrieve current configuration */
6920 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6922 printf("cannot get current flow ctrl parameters, return"
6923 "code = %d\n", ret);
6927 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6928 (fc_conf.mode == RTE_FC_FULL))
6930 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6931 (fc_conf.mode == RTE_FC_FULL))
6935 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6936 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6938 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6939 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6941 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6943 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6944 fc_conf.high_water = res->high_water;
6946 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6947 fc_conf.low_water = res->low_water;
6949 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6950 fc_conf.pause_time = res->pause_time;
6952 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6953 fc_conf.send_xon = res->send_xon;
6955 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6956 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6957 fc_conf.mac_ctrl_frame_fwd = 1;
6959 fc_conf.mac_ctrl_frame_fwd = 0;
6962 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6963 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6965 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6967 printf("bad flow contrl parameter, return code = %d \n", ret);
6970 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6971 struct cmd_priority_flow_ctrl_set_result {
6972 cmdline_fixed_string_t set;
6973 cmdline_fixed_string_t pfc_ctrl;
6974 cmdline_fixed_string_t rx;
6975 cmdline_fixed_string_t rx_pfc_mode;
6976 cmdline_fixed_string_t tx;
6977 cmdline_fixed_string_t tx_pfc_mode;
6978 uint32_t high_water;
6980 uint16_t pause_time;
6986 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6987 __attribute__((unused)) struct cmdline *cl,
6988 __attribute__((unused)) void *data)
6990 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6991 struct rte_eth_pfc_conf pfc_conf;
6992 int rx_fc_enable, tx_fc_enable;
6996 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6997 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6998 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6999 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7001 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7002 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7005 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7006 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7007 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7008 pfc_conf.fc.high_water = res->high_water;
7009 pfc_conf.fc.low_water = res->low_water;
7010 pfc_conf.fc.pause_time = res->pause_time;
7011 pfc_conf.priority = res->priority;
7013 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7015 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7018 cmdline_parse_token_string_t cmd_pfc_set_set =
7019 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7021 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7022 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7023 pfc_ctrl, "pfc_ctrl");
7024 cmdline_parse_token_string_t cmd_pfc_set_rx =
7025 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7027 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7028 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7029 rx_pfc_mode, "on#off");
7030 cmdline_parse_token_string_t cmd_pfc_set_tx =
7031 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7033 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7034 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7035 tx_pfc_mode, "on#off");
7036 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7037 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7038 high_water, UINT32);
7039 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7040 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7042 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7043 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7044 pause_time, UINT16);
7045 cmdline_parse_token_num_t cmd_pfc_set_priority =
7046 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7048 cmdline_parse_token_num_t cmd_pfc_set_portid =
7049 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7052 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7053 .f = cmd_priority_flow_ctrl_set_parsed,
7055 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7056 "<pause_time> <priority> <port_id>: "
7057 "Configure the Ethernet priority flow control",
7059 (void *)&cmd_pfc_set_set,
7060 (void *)&cmd_pfc_set_flow_ctrl,
7061 (void *)&cmd_pfc_set_rx,
7062 (void *)&cmd_pfc_set_rx_mode,
7063 (void *)&cmd_pfc_set_tx,
7064 (void *)&cmd_pfc_set_tx_mode,
7065 (void *)&cmd_pfc_set_high_water,
7066 (void *)&cmd_pfc_set_low_water,
7067 (void *)&cmd_pfc_set_pause_time,
7068 (void *)&cmd_pfc_set_priority,
7069 (void *)&cmd_pfc_set_portid,
7074 /* *** RESET CONFIGURATION *** */
7075 struct cmd_reset_result {
7076 cmdline_fixed_string_t reset;
7077 cmdline_fixed_string_t def;
7080 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7082 __attribute__((unused)) void *data)
7084 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7085 set_def_fwd_config();
7088 cmdline_parse_token_string_t cmd_reset_set =
7089 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7090 cmdline_parse_token_string_t cmd_reset_def =
7091 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7094 cmdline_parse_inst_t cmd_reset = {
7095 .f = cmd_reset_parsed,
7097 .help_str = "set default: Reset default forwarding configuration",
7099 (void *)&cmd_reset_set,
7100 (void *)&cmd_reset_def,
7105 /* *** START FORWARDING *** */
7106 struct cmd_start_result {
7107 cmdline_fixed_string_t start;
7110 cmdline_parse_token_string_t cmd_start_start =
7111 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7113 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7114 __attribute__((unused)) struct cmdline *cl,
7115 __attribute__((unused)) void *data)
7117 start_packet_forwarding(0);
7120 cmdline_parse_inst_t cmd_start = {
7121 .f = cmd_start_parsed,
7123 .help_str = "start: Start packet forwarding",
7125 (void *)&cmd_start_start,
7130 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7131 struct cmd_start_tx_first_result {
7132 cmdline_fixed_string_t start;
7133 cmdline_fixed_string_t tx_first;
7137 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7138 __attribute__((unused)) struct cmdline *cl,
7139 __attribute__((unused)) void *data)
7141 start_packet_forwarding(1);
7144 cmdline_parse_token_string_t cmd_start_tx_first_start =
7145 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7147 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7148 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7149 tx_first, "tx_first");
7151 cmdline_parse_inst_t cmd_start_tx_first = {
7152 .f = cmd_start_tx_first_parsed,
7154 .help_str = "start tx_first: Start packet forwarding, "
7155 "after sending 1 burst of packets",
7157 (void *)&cmd_start_tx_first_start,
7158 (void *)&cmd_start_tx_first_tx_first,
7163 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7164 struct cmd_start_tx_first_n_result {
7165 cmdline_fixed_string_t start;
7166 cmdline_fixed_string_t tx_first;
7171 cmd_start_tx_first_n_parsed(void *parsed_result,
7172 __attribute__((unused)) struct cmdline *cl,
7173 __attribute__((unused)) void *data)
7175 struct cmd_start_tx_first_n_result *res = parsed_result;
7177 start_packet_forwarding(res->tx_num);
7180 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7181 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7183 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7184 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7185 tx_first, "tx_first");
7186 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7187 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7190 cmdline_parse_inst_t cmd_start_tx_first_n = {
7191 .f = cmd_start_tx_first_n_parsed,
7193 .help_str = "start tx_first <num>: "
7194 "packet forwarding, after sending <num> bursts of packets",
7196 (void *)&cmd_start_tx_first_n_start,
7197 (void *)&cmd_start_tx_first_n_tx_first,
7198 (void *)&cmd_start_tx_first_n_tx_num,
7203 /* *** SET LINK UP *** */
7204 struct cmd_set_link_up_result {
7205 cmdline_fixed_string_t set;
7206 cmdline_fixed_string_t link_up;
7207 cmdline_fixed_string_t port;
7211 cmdline_parse_token_string_t cmd_set_link_up_set =
7212 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7213 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7214 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7216 cmdline_parse_token_string_t cmd_set_link_up_port =
7217 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7218 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7219 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7221 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7222 __attribute__((unused)) struct cmdline *cl,
7223 __attribute__((unused)) void *data)
7225 struct cmd_set_link_up_result *res = parsed_result;
7226 dev_set_link_up(res->port_id);
7229 cmdline_parse_inst_t cmd_set_link_up = {
7230 .f = cmd_set_link_up_parsed,
7232 .help_str = "set link-up port <port id>",
7234 (void *)&cmd_set_link_up_set,
7235 (void *)&cmd_set_link_up_link_up,
7236 (void *)&cmd_set_link_up_port,
7237 (void *)&cmd_set_link_up_port_id,
7242 /* *** SET LINK DOWN *** */
7243 struct cmd_set_link_down_result {
7244 cmdline_fixed_string_t set;
7245 cmdline_fixed_string_t link_down;
7246 cmdline_fixed_string_t port;
7250 cmdline_parse_token_string_t cmd_set_link_down_set =
7251 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7252 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7253 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7255 cmdline_parse_token_string_t cmd_set_link_down_port =
7256 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7257 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7258 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7260 static void cmd_set_link_down_parsed(
7261 __attribute__((unused)) void *parsed_result,
7262 __attribute__((unused)) struct cmdline *cl,
7263 __attribute__((unused)) void *data)
7265 struct cmd_set_link_down_result *res = parsed_result;
7266 dev_set_link_down(res->port_id);
7269 cmdline_parse_inst_t cmd_set_link_down = {
7270 .f = cmd_set_link_down_parsed,
7272 .help_str = "set link-down port <port id>",
7274 (void *)&cmd_set_link_down_set,
7275 (void *)&cmd_set_link_down_link_down,
7276 (void *)&cmd_set_link_down_port,
7277 (void *)&cmd_set_link_down_port_id,
7282 /* *** SHOW CFG *** */
7283 struct cmd_showcfg_result {
7284 cmdline_fixed_string_t show;
7285 cmdline_fixed_string_t cfg;
7286 cmdline_fixed_string_t what;
7289 static void cmd_showcfg_parsed(void *parsed_result,
7290 __attribute__((unused)) struct cmdline *cl,
7291 __attribute__((unused)) void *data)
7293 struct cmd_showcfg_result *res = parsed_result;
7294 if (!strcmp(res->what, "rxtx"))
7295 rxtx_config_display();
7296 else if (!strcmp(res->what, "cores"))
7297 fwd_lcores_config_display();
7298 else if (!strcmp(res->what, "fwd"))
7299 pkt_fwd_config_display(&cur_fwd_config);
7300 else if (!strcmp(res->what, "txpkts"))
7301 show_tx_pkt_segments();
7304 cmdline_parse_token_string_t cmd_showcfg_show =
7305 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7306 cmdline_parse_token_string_t cmd_showcfg_port =
7307 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7308 cmdline_parse_token_string_t cmd_showcfg_what =
7309 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7310 "rxtx#cores#fwd#txpkts");
7312 cmdline_parse_inst_t cmd_showcfg = {
7313 .f = cmd_showcfg_parsed,
7315 .help_str = "show config rxtx|cores|fwd|txpkts",
7317 (void *)&cmd_showcfg_show,
7318 (void *)&cmd_showcfg_port,
7319 (void *)&cmd_showcfg_what,
7324 /* *** SHOW ALL PORT INFO *** */
7325 struct cmd_showportall_result {
7326 cmdline_fixed_string_t show;
7327 cmdline_fixed_string_t port;
7328 cmdline_fixed_string_t what;
7329 cmdline_fixed_string_t all;
7332 static void cmd_showportall_parsed(void *parsed_result,
7333 __attribute__((unused)) struct cmdline *cl,
7334 __attribute__((unused)) void *data)
7338 struct cmd_showportall_result *res = parsed_result;
7339 if (!strcmp(res->show, "clear")) {
7340 if (!strcmp(res->what, "stats"))
7341 RTE_ETH_FOREACH_DEV(i)
7343 else if (!strcmp(res->what, "xstats"))
7344 RTE_ETH_FOREACH_DEV(i)
7345 nic_xstats_clear(i);
7346 } else if (!strcmp(res->what, "info"))
7347 RTE_ETH_FOREACH_DEV(i)
7348 port_infos_display(i);
7349 else if (!strcmp(res->what, "summary")) {
7350 port_summary_header_display();
7351 RTE_ETH_FOREACH_DEV(i)
7352 port_summary_display(i);
7354 else if (!strcmp(res->what, "stats"))
7355 RTE_ETH_FOREACH_DEV(i)
7356 nic_stats_display(i);
7357 else if (!strcmp(res->what, "xstats"))
7358 RTE_ETH_FOREACH_DEV(i)
7359 nic_xstats_display(i);
7360 else if (!strcmp(res->what, "fdir"))
7361 RTE_ETH_FOREACH_DEV(i)
7363 else if (!strcmp(res->what, "stat_qmap"))
7364 RTE_ETH_FOREACH_DEV(i)
7365 nic_stats_mapping_display(i);
7366 else if (!strcmp(res->what, "dcb_tc"))
7367 RTE_ETH_FOREACH_DEV(i)
7368 port_dcb_info_display(i);
7369 else if (!strcmp(res->what, "cap"))
7370 RTE_ETH_FOREACH_DEV(i)
7371 port_offload_cap_display(i);
7374 cmdline_parse_token_string_t cmd_showportall_show =
7375 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7377 cmdline_parse_token_string_t cmd_showportall_port =
7378 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7379 cmdline_parse_token_string_t cmd_showportall_what =
7380 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7381 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7382 cmdline_parse_token_string_t cmd_showportall_all =
7383 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7384 cmdline_parse_inst_t cmd_showportall = {
7385 .f = cmd_showportall_parsed,
7387 .help_str = "show|clear port "
7388 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7390 (void *)&cmd_showportall_show,
7391 (void *)&cmd_showportall_port,
7392 (void *)&cmd_showportall_what,
7393 (void *)&cmd_showportall_all,
7398 /* *** SHOW PORT INFO *** */
7399 struct cmd_showport_result {
7400 cmdline_fixed_string_t show;
7401 cmdline_fixed_string_t port;
7402 cmdline_fixed_string_t what;
7406 static void cmd_showport_parsed(void *parsed_result,
7407 __attribute__((unused)) struct cmdline *cl,
7408 __attribute__((unused)) void *data)
7410 struct cmd_showport_result *res = parsed_result;
7411 if (!strcmp(res->show, "clear")) {
7412 if (!strcmp(res->what, "stats"))
7413 nic_stats_clear(res->portnum);
7414 else if (!strcmp(res->what, "xstats"))
7415 nic_xstats_clear(res->portnum);
7416 } else if (!strcmp(res->what, "info"))
7417 port_infos_display(res->portnum);
7418 else if (!strcmp(res->what, "summary")) {
7419 port_summary_header_display();
7420 port_summary_display(res->portnum);
7422 else if (!strcmp(res->what, "stats"))
7423 nic_stats_display(res->portnum);
7424 else if (!strcmp(res->what, "xstats"))
7425 nic_xstats_display(res->portnum);
7426 else if (!strcmp(res->what, "fdir"))
7427 fdir_get_infos(res->portnum);
7428 else if (!strcmp(res->what, "stat_qmap"))
7429 nic_stats_mapping_display(res->portnum);
7430 else if (!strcmp(res->what, "dcb_tc"))
7431 port_dcb_info_display(res->portnum);
7432 else if (!strcmp(res->what, "cap"))
7433 port_offload_cap_display(res->portnum);
7436 cmdline_parse_token_string_t cmd_showport_show =
7437 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7439 cmdline_parse_token_string_t cmd_showport_port =
7440 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7441 cmdline_parse_token_string_t cmd_showport_what =
7442 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7443 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7444 cmdline_parse_token_num_t cmd_showport_portnum =
7445 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7447 cmdline_parse_inst_t cmd_showport = {
7448 .f = cmd_showport_parsed,
7450 .help_str = "show|clear port "
7451 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7454 (void *)&cmd_showport_show,
7455 (void *)&cmd_showport_port,
7456 (void *)&cmd_showport_what,
7457 (void *)&cmd_showport_portnum,
7462 /* *** SHOW DEVICE INFO *** */
7463 struct cmd_showdevice_result {
7464 cmdline_fixed_string_t show;
7465 cmdline_fixed_string_t device;
7466 cmdline_fixed_string_t what;
7467 cmdline_fixed_string_t identifier;
7470 static void cmd_showdevice_parsed(void *parsed_result,
7471 __attribute__((unused)) struct cmdline *cl,
7472 __attribute__((unused)) void *data)
7474 struct cmd_showdevice_result *res = parsed_result;
7475 if (!strcmp(res->what, "info")) {
7476 if (!strcmp(res->identifier, "all"))
7477 device_infos_display(NULL);
7479 device_infos_display(res->identifier);
7483 cmdline_parse_token_string_t cmd_showdevice_show =
7484 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7486 cmdline_parse_token_string_t cmd_showdevice_device =
7487 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7488 cmdline_parse_token_string_t cmd_showdevice_what =
7489 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7491 cmdline_parse_token_string_t cmd_showdevice_identifier =
7492 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7495 cmdline_parse_inst_t cmd_showdevice = {
7496 .f = cmd_showdevice_parsed,
7498 .help_str = "show device info <identifier>|all",
7500 (void *)&cmd_showdevice_show,
7501 (void *)&cmd_showdevice_device,
7502 (void *)&cmd_showdevice_what,
7503 (void *)&cmd_showdevice_identifier,
7507 /* *** SHOW QUEUE INFO *** */
7508 struct cmd_showqueue_result {
7509 cmdline_fixed_string_t show;
7510 cmdline_fixed_string_t type;
7511 cmdline_fixed_string_t what;
7517 cmd_showqueue_parsed(void *parsed_result,
7518 __attribute__((unused)) struct cmdline *cl,
7519 __attribute__((unused)) void *data)
7521 struct cmd_showqueue_result *res = parsed_result;
7523 if (!strcmp(res->type, "rxq"))
7524 rx_queue_infos_display(res->portnum, res->queuenum);
7525 else if (!strcmp(res->type, "txq"))
7526 tx_queue_infos_display(res->portnum, res->queuenum);
7529 cmdline_parse_token_string_t cmd_showqueue_show =
7530 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7531 cmdline_parse_token_string_t cmd_showqueue_type =
7532 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7533 cmdline_parse_token_string_t cmd_showqueue_what =
7534 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7535 cmdline_parse_token_num_t cmd_showqueue_portnum =
7536 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7537 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7538 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7540 cmdline_parse_inst_t cmd_showqueue = {
7541 .f = cmd_showqueue_parsed,
7543 .help_str = "show rxq|txq info <port_id> <queue_id>",
7545 (void *)&cmd_showqueue_show,
7546 (void *)&cmd_showqueue_type,
7547 (void *)&cmd_showqueue_what,
7548 (void *)&cmd_showqueue_portnum,
7549 (void *)&cmd_showqueue_queuenum,
7554 /* show/clear fwd engine statistics */
7556 cmdline_fixed_string_t action;
7557 cmdline_fixed_string_t fwd;
7558 cmdline_fixed_string_t stats;
7559 cmdline_fixed_string_t all;
7562 cmdline_parse_token_string_t cmd_fwd_action =
7563 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7564 cmdline_parse_token_string_t cmd_fwd_fwd =
7565 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7566 cmdline_parse_token_string_t cmd_fwd_stats =
7567 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7568 cmdline_parse_token_string_t cmd_fwd_all =
7569 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7572 cmd_showfwdall_parsed(void *parsed_result,
7573 __rte_unused struct cmdline *cl,
7574 __rte_unused void *data)
7576 struct fwd_result *res = parsed_result;
7578 if (!strcmp(res->action, "show"))
7579 fwd_stats_display();
7584 static cmdline_parse_inst_t cmd_showfwdall = {
7585 .f = cmd_showfwdall_parsed,
7587 .help_str = "show|clear fwd stats all",
7589 (void *)&cmd_fwd_action,
7590 (void *)&cmd_fwd_fwd,
7591 (void *)&cmd_fwd_stats,
7592 (void *)&cmd_fwd_all,
7597 /* *** READ PORT REGISTER *** */
7598 struct cmd_read_reg_result {
7599 cmdline_fixed_string_t read;
7600 cmdline_fixed_string_t reg;
7606 cmd_read_reg_parsed(void *parsed_result,
7607 __attribute__((unused)) struct cmdline *cl,
7608 __attribute__((unused)) void *data)
7610 struct cmd_read_reg_result *res = parsed_result;
7611 port_reg_display(res->port_id, res->reg_off);
7614 cmdline_parse_token_string_t cmd_read_reg_read =
7615 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7616 cmdline_parse_token_string_t cmd_read_reg_reg =
7617 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7618 cmdline_parse_token_num_t cmd_read_reg_port_id =
7619 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7620 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7621 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7623 cmdline_parse_inst_t cmd_read_reg = {
7624 .f = cmd_read_reg_parsed,
7626 .help_str = "read reg <port_id> <reg_off>",
7628 (void *)&cmd_read_reg_read,
7629 (void *)&cmd_read_reg_reg,
7630 (void *)&cmd_read_reg_port_id,
7631 (void *)&cmd_read_reg_reg_off,
7636 /* *** READ PORT REGISTER BIT FIELD *** */
7637 struct cmd_read_reg_bit_field_result {
7638 cmdline_fixed_string_t read;
7639 cmdline_fixed_string_t regfield;
7647 cmd_read_reg_bit_field_parsed(void *parsed_result,
7648 __attribute__((unused)) struct cmdline *cl,
7649 __attribute__((unused)) void *data)
7651 struct cmd_read_reg_bit_field_result *res = parsed_result;
7652 port_reg_bit_field_display(res->port_id, res->reg_off,
7653 res->bit1_pos, res->bit2_pos);
7656 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7657 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7659 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7660 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7661 regfield, "regfield");
7662 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7663 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7665 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7666 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7668 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7669 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7671 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7672 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7675 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7676 .f = cmd_read_reg_bit_field_parsed,
7678 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7679 "Read register bit field between bit_x and bit_y included",
7681 (void *)&cmd_read_reg_bit_field_read,
7682 (void *)&cmd_read_reg_bit_field_regfield,
7683 (void *)&cmd_read_reg_bit_field_port_id,
7684 (void *)&cmd_read_reg_bit_field_reg_off,
7685 (void *)&cmd_read_reg_bit_field_bit1_pos,
7686 (void *)&cmd_read_reg_bit_field_bit2_pos,
7691 /* *** READ PORT REGISTER BIT *** */
7692 struct cmd_read_reg_bit_result {
7693 cmdline_fixed_string_t read;
7694 cmdline_fixed_string_t regbit;
7701 cmd_read_reg_bit_parsed(void *parsed_result,
7702 __attribute__((unused)) struct cmdline *cl,
7703 __attribute__((unused)) void *data)
7705 struct cmd_read_reg_bit_result *res = parsed_result;
7706 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7709 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7710 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7711 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7712 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7714 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7715 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7716 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7717 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7718 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7719 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7721 cmdline_parse_inst_t cmd_read_reg_bit = {
7722 .f = cmd_read_reg_bit_parsed,
7724 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7726 (void *)&cmd_read_reg_bit_read,
7727 (void *)&cmd_read_reg_bit_regbit,
7728 (void *)&cmd_read_reg_bit_port_id,
7729 (void *)&cmd_read_reg_bit_reg_off,
7730 (void *)&cmd_read_reg_bit_bit_pos,
7735 /* *** WRITE PORT REGISTER *** */
7736 struct cmd_write_reg_result {
7737 cmdline_fixed_string_t write;
7738 cmdline_fixed_string_t reg;
7745 cmd_write_reg_parsed(void *parsed_result,
7746 __attribute__((unused)) struct cmdline *cl,
7747 __attribute__((unused)) void *data)
7749 struct cmd_write_reg_result *res = parsed_result;
7750 port_reg_set(res->port_id, res->reg_off, res->value);
7753 cmdline_parse_token_string_t cmd_write_reg_write =
7754 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7755 cmdline_parse_token_string_t cmd_write_reg_reg =
7756 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7757 cmdline_parse_token_num_t cmd_write_reg_port_id =
7758 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7759 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7760 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7761 cmdline_parse_token_num_t cmd_write_reg_value =
7762 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7764 cmdline_parse_inst_t cmd_write_reg = {
7765 .f = cmd_write_reg_parsed,
7767 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7769 (void *)&cmd_write_reg_write,
7770 (void *)&cmd_write_reg_reg,
7771 (void *)&cmd_write_reg_port_id,
7772 (void *)&cmd_write_reg_reg_off,
7773 (void *)&cmd_write_reg_value,
7778 /* *** WRITE PORT REGISTER BIT FIELD *** */
7779 struct cmd_write_reg_bit_field_result {
7780 cmdline_fixed_string_t write;
7781 cmdline_fixed_string_t regfield;
7790 cmd_write_reg_bit_field_parsed(void *parsed_result,
7791 __attribute__((unused)) struct cmdline *cl,
7792 __attribute__((unused)) void *data)
7794 struct cmd_write_reg_bit_field_result *res = parsed_result;
7795 port_reg_bit_field_set(res->port_id, res->reg_off,
7796 res->bit1_pos, res->bit2_pos, res->value);
7799 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7800 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7802 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7803 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7804 regfield, "regfield");
7805 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7806 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7808 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7809 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7811 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7812 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7814 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7815 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7817 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7818 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7821 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7822 .f = cmd_write_reg_bit_field_parsed,
7824 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7826 "Set register bit field between bit_x and bit_y included",
7828 (void *)&cmd_write_reg_bit_field_write,
7829 (void *)&cmd_write_reg_bit_field_regfield,
7830 (void *)&cmd_write_reg_bit_field_port_id,
7831 (void *)&cmd_write_reg_bit_field_reg_off,
7832 (void *)&cmd_write_reg_bit_field_bit1_pos,
7833 (void *)&cmd_write_reg_bit_field_bit2_pos,
7834 (void *)&cmd_write_reg_bit_field_value,
7839 /* *** WRITE PORT REGISTER BIT *** */
7840 struct cmd_write_reg_bit_result {
7841 cmdline_fixed_string_t write;
7842 cmdline_fixed_string_t regbit;
7850 cmd_write_reg_bit_parsed(void *parsed_result,
7851 __attribute__((unused)) struct cmdline *cl,
7852 __attribute__((unused)) void *data)
7854 struct cmd_write_reg_bit_result *res = parsed_result;
7855 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7858 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7859 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7861 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7862 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7864 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7865 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7866 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7867 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7868 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7869 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7870 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7871 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7873 cmdline_parse_inst_t cmd_write_reg_bit = {
7874 .f = cmd_write_reg_bit_parsed,
7876 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7879 (void *)&cmd_write_reg_bit_write,
7880 (void *)&cmd_write_reg_bit_regbit,
7881 (void *)&cmd_write_reg_bit_port_id,
7882 (void *)&cmd_write_reg_bit_reg_off,
7883 (void *)&cmd_write_reg_bit_bit_pos,
7884 (void *)&cmd_write_reg_bit_value,
7889 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7890 struct cmd_read_rxd_txd_result {
7891 cmdline_fixed_string_t read;
7892 cmdline_fixed_string_t rxd_txd;
7899 cmd_read_rxd_txd_parsed(void *parsed_result,
7900 __attribute__((unused)) struct cmdline *cl,
7901 __attribute__((unused)) void *data)
7903 struct cmd_read_rxd_txd_result *res = parsed_result;
7905 if (!strcmp(res->rxd_txd, "rxd"))
7906 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7907 else if (!strcmp(res->rxd_txd, "txd"))
7908 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7911 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7912 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7913 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7914 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7916 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7917 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7918 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7919 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7920 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7921 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7923 cmdline_parse_inst_t cmd_read_rxd_txd = {
7924 .f = cmd_read_rxd_txd_parsed,
7926 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7928 (void *)&cmd_read_rxd_txd_read,
7929 (void *)&cmd_read_rxd_txd_rxd_txd,
7930 (void *)&cmd_read_rxd_txd_port_id,
7931 (void *)&cmd_read_rxd_txd_queue_id,
7932 (void *)&cmd_read_rxd_txd_desc_id,
7938 struct cmd_quit_result {
7939 cmdline_fixed_string_t quit;
7942 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7944 __attribute__((unused)) void *data)
7949 cmdline_parse_token_string_t cmd_quit_quit =
7950 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7952 cmdline_parse_inst_t cmd_quit = {
7953 .f = cmd_quit_parsed,
7955 .help_str = "quit: Exit application",
7957 (void *)&cmd_quit_quit,
7962 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7963 struct cmd_mac_addr_result {
7964 cmdline_fixed_string_t mac_addr_cmd;
7965 cmdline_fixed_string_t what;
7967 struct rte_ether_addr address;
7970 static void cmd_mac_addr_parsed(void *parsed_result,
7971 __attribute__((unused)) struct cmdline *cl,
7972 __attribute__((unused)) void *data)
7974 struct cmd_mac_addr_result *res = parsed_result;
7977 if (strcmp(res->what, "add") == 0)
7978 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7979 else if (strcmp(res->what, "set") == 0)
7980 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7983 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7985 /* check the return value and print it if is < 0 */
7987 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7991 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7992 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7994 cmdline_parse_token_string_t cmd_mac_addr_what =
7995 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7997 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7998 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8000 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8001 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8003 cmdline_parse_inst_t cmd_mac_addr = {
8004 .f = cmd_mac_addr_parsed,
8006 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8007 "Add/Remove/Set MAC address on port_id",
8009 (void *)&cmd_mac_addr_cmd,
8010 (void *)&cmd_mac_addr_what,
8011 (void *)&cmd_mac_addr_portnum,
8012 (void *)&cmd_mac_addr_addr,
8017 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8018 struct cmd_eth_peer_result {
8019 cmdline_fixed_string_t set;
8020 cmdline_fixed_string_t eth_peer;
8022 cmdline_fixed_string_t peer_addr;
8025 static void cmd_set_eth_peer_parsed(void *parsed_result,
8026 __attribute__((unused)) struct cmdline *cl,
8027 __attribute__((unused)) void *data)
8029 struct cmd_eth_peer_result *res = parsed_result;
8031 if (test_done == 0) {
8032 printf("Please stop forwarding first\n");
8035 if (!strcmp(res->eth_peer, "eth-peer")) {
8036 set_fwd_eth_peer(res->port_id, res->peer_addr);
8040 cmdline_parse_token_string_t cmd_eth_peer_set =
8041 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8042 cmdline_parse_token_string_t cmd_eth_peer =
8043 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8044 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8045 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8046 cmdline_parse_token_string_t cmd_eth_peer_addr =
8047 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8049 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8050 .f = cmd_set_eth_peer_parsed,
8052 .help_str = "set eth-peer <port_id> <peer_mac>",
8054 (void *)&cmd_eth_peer_set,
8055 (void *)&cmd_eth_peer,
8056 (void *)&cmd_eth_peer_port_id,
8057 (void *)&cmd_eth_peer_addr,
8062 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8063 struct cmd_set_qmap_result {
8064 cmdline_fixed_string_t set;
8065 cmdline_fixed_string_t qmap;
8066 cmdline_fixed_string_t what;
8073 cmd_set_qmap_parsed(void *parsed_result,
8074 __attribute__((unused)) struct cmdline *cl,
8075 __attribute__((unused)) void *data)
8077 struct cmd_set_qmap_result *res = parsed_result;
8078 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8080 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8083 cmdline_parse_token_string_t cmd_setqmap_set =
8084 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8086 cmdline_parse_token_string_t cmd_setqmap_qmap =
8087 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8089 cmdline_parse_token_string_t cmd_setqmap_what =
8090 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8092 cmdline_parse_token_num_t cmd_setqmap_portid =
8093 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8095 cmdline_parse_token_num_t cmd_setqmap_queueid =
8096 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8098 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8099 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8102 cmdline_parse_inst_t cmd_set_qmap = {
8103 .f = cmd_set_qmap_parsed,
8105 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8106 "Set statistics mapping value on tx|rx queue_id of port_id",
8108 (void *)&cmd_setqmap_set,
8109 (void *)&cmd_setqmap_qmap,
8110 (void *)&cmd_setqmap_what,
8111 (void *)&cmd_setqmap_portid,
8112 (void *)&cmd_setqmap_queueid,
8113 (void *)&cmd_setqmap_mapvalue,
8118 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8119 struct cmd_set_xstats_hide_zero_result {
8120 cmdline_fixed_string_t keyword;
8121 cmdline_fixed_string_t name;
8122 cmdline_fixed_string_t on_off;
8126 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8127 __attribute__((unused)) struct cmdline *cl,
8128 __attribute__((unused)) void *data)
8130 struct cmd_set_xstats_hide_zero_result *res;
8131 uint16_t on_off = 0;
8133 res = parsed_result;
8134 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8135 set_xstats_hide_zero(on_off);
8138 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8139 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8141 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8142 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8143 name, "xstats-hide-zero");
8144 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8145 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8148 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8149 .f = cmd_set_xstats_hide_zero_parsed,
8151 .help_str = "set xstats-hide-zero on|off",
8153 (void *)&cmd_set_xstats_hide_zero_keyword,
8154 (void *)&cmd_set_xstats_hide_zero_name,
8155 (void *)&cmd_set_xstats_hide_zero_on_off,
8160 /* *** CONFIGURE UNICAST HASH TABLE *** */
8161 struct cmd_set_uc_hash_table {
8162 cmdline_fixed_string_t set;
8163 cmdline_fixed_string_t port;
8165 cmdline_fixed_string_t what;
8166 struct rte_ether_addr address;
8167 cmdline_fixed_string_t mode;
8171 cmd_set_uc_hash_parsed(void *parsed_result,
8172 __attribute__((unused)) struct cmdline *cl,
8173 __attribute__((unused)) void *data)
8176 struct cmd_set_uc_hash_table *res = parsed_result;
8178 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8180 if (strcmp(res->what, "uta") == 0)
8181 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8182 &res->address,(uint8_t)is_on);
8184 printf("bad unicast hash table parameter, return code = %d \n", ret);
8188 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8189 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8191 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8192 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8194 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8195 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8197 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8198 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8200 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8201 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8203 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8204 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8207 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8208 .f = cmd_set_uc_hash_parsed,
8210 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8212 (void *)&cmd_set_uc_hash_set,
8213 (void *)&cmd_set_uc_hash_port,
8214 (void *)&cmd_set_uc_hash_portid,
8215 (void *)&cmd_set_uc_hash_what,
8216 (void *)&cmd_set_uc_hash_mac,
8217 (void *)&cmd_set_uc_hash_mode,
8222 struct cmd_set_uc_all_hash_table {
8223 cmdline_fixed_string_t set;
8224 cmdline_fixed_string_t port;
8226 cmdline_fixed_string_t what;
8227 cmdline_fixed_string_t value;
8228 cmdline_fixed_string_t mode;
8232 cmd_set_uc_all_hash_parsed(void *parsed_result,
8233 __attribute__((unused)) struct cmdline *cl,
8234 __attribute__((unused)) void *data)
8237 struct cmd_set_uc_all_hash_table *res = parsed_result;
8239 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8241 if ((strcmp(res->what, "uta") == 0) &&
8242 (strcmp(res->value, "all") == 0))
8243 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8245 printf("bad unicast hash table parameter,"
8246 "return code = %d \n", ret);
8249 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8250 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8252 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8253 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8255 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8256 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8258 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8259 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8261 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8262 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8264 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8265 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8268 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8269 .f = cmd_set_uc_all_hash_parsed,
8271 .help_str = "set port <port_id> uta all on|off",
8273 (void *)&cmd_set_uc_all_hash_set,
8274 (void *)&cmd_set_uc_all_hash_port,
8275 (void *)&cmd_set_uc_all_hash_portid,
8276 (void *)&cmd_set_uc_all_hash_what,
8277 (void *)&cmd_set_uc_all_hash_value,
8278 (void *)&cmd_set_uc_all_hash_mode,
8283 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8284 struct cmd_set_vf_macvlan_filter {
8285 cmdline_fixed_string_t set;
8286 cmdline_fixed_string_t port;
8288 cmdline_fixed_string_t vf;
8290 struct rte_ether_addr address;
8291 cmdline_fixed_string_t filter_type;
8292 cmdline_fixed_string_t mode;
8296 cmd_set_vf_macvlan_parsed(void *parsed_result,
8297 __attribute__((unused)) struct cmdline *cl,
8298 __attribute__((unused)) void *data)
8301 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8302 struct rte_eth_mac_filter filter;
8304 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8306 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8308 /* set VF MAC filter */
8312 filter.dst_id = res->vf_id;
8314 if (!strcmp(res->filter_type, "exact-mac"))
8315 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8316 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8317 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8318 else if (!strcmp(res->filter_type, "hashmac"))
8319 filter.filter_type = RTE_MAC_HASH_MATCH;
8320 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8321 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8323 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8326 ret = rte_eth_dev_filter_ctrl(res->port_id,
8327 RTE_ETH_FILTER_MACVLAN,
8331 ret = rte_eth_dev_filter_ctrl(res->port_id,
8332 RTE_ETH_FILTER_MACVLAN,
8333 RTE_ETH_FILTER_DELETE,
8337 printf("bad set MAC hash parameter, return code = %d\n", ret);
8341 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8342 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8344 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8345 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8347 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8348 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8350 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8353 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8354 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8356 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8357 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8359 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8360 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8361 filter_type, "exact-mac#exact-mac-vlan"
8362 "#hashmac#hashmac-vlan");
8363 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8364 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8367 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8368 .f = cmd_set_vf_macvlan_parsed,
8370 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8371 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8372 "Exact match rule: exact match of MAC or MAC and VLAN; "
8373 "hash match rule: hash match of MAC and exact match of VLAN",
8375 (void *)&cmd_set_vf_macvlan_set,
8376 (void *)&cmd_set_vf_macvlan_port,
8377 (void *)&cmd_set_vf_macvlan_portid,
8378 (void *)&cmd_set_vf_macvlan_vf,
8379 (void *)&cmd_set_vf_macvlan_vf_id,
8380 (void *)&cmd_set_vf_macvlan_mac,
8381 (void *)&cmd_set_vf_macvlan_filter_type,
8382 (void *)&cmd_set_vf_macvlan_mode,
8387 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8388 struct cmd_set_vf_traffic {
8389 cmdline_fixed_string_t set;
8390 cmdline_fixed_string_t port;
8392 cmdline_fixed_string_t vf;
8394 cmdline_fixed_string_t what;
8395 cmdline_fixed_string_t mode;
8399 cmd_set_vf_traffic_parsed(void *parsed_result,
8400 __attribute__((unused)) struct cmdline *cl,
8401 __attribute__((unused)) void *data)
8403 struct cmd_set_vf_traffic *res = parsed_result;
8404 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8405 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8407 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8410 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8411 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8413 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8414 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8416 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8417 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8419 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8420 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8422 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8423 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8425 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8426 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8428 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8429 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8432 cmdline_parse_inst_t cmd_set_vf_traffic = {
8433 .f = cmd_set_vf_traffic_parsed,
8435 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8437 (void *)&cmd_setvf_traffic_set,
8438 (void *)&cmd_setvf_traffic_port,
8439 (void *)&cmd_setvf_traffic_portid,
8440 (void *)&cmd_setvf_traffic_vf,
8441 (void *)&cmd_setvf_traffic_vfid,
8442 (void *)&cmd_setvf_traffic_what,
8443 (void *)&cmd_setvf_traffic_mode,
8448 /* *** CONFIGURE VF RECEIVE MODE *** */
8449 struct cmd_set_vf_rxmode {
8450 cmdline_fixed_string_t set;
8451 cmdline_fixed_string_t port;
8453 cmdline_fixed_string_t vf;
8455 cmdline_fixed_string_t what;
8456 cmdline_fixed_string_t mode;
8457 cmdline_fixed_string_t on;
8461 cmd_set_vf_rxmode_parsed(void *parsed_result,
8462 __attribute__((unused)) struct cmdline *cl,
8463 __attribute__((unused)) void *data)
8466 uint16_t vf_rxmode = 0;
8467 struct cmd_set_vf_rxmode *res = parsed_result;
8469 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8470 if (!strcmp(res->what,"rxmode")) {
8471 if (!strcmp(res->mode, "AUPE"))
8472 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8473 else if (!strcmp(res->mode, "ROPE"))
8474 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8475 else if (!strcmp(res->mode, "BAM"))
8476 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8477 else if (!strncmp(res->mode, "MPE",3))
8478 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8481 RTE_SET_USED(is_on);
8483 #ifdef RTE_LIBRTE_IXGBE_PMD
8484 if (ret == -ENOTSUP)
8485 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8486 vf_rxmode, (uint8_t)is_on);
8488 #ifdef RTE_LIBRTE_BNXT_PMD
8489 if (ret == -ENOTSUP)
8490 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8491 vf_rxmode, (uint8_t)is_on);
8494 printf("bad VF receive mode parameter, return code = %d \n",
8498 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8499 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8501 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8502 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8504 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8505 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8507 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8510 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8511 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8513 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8514 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8516 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8517 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8518 mode, "AUPE#ROPE#BAM#MPE");
8519 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8523 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8524 .f = cmd_set_vf_rxmode_parsed,
8526 .help_str = "set port <port_id> vf <vf_id> rxmode "
8527 "AUPE|ROPE|BAM|MPE on|off",
8529 (void *)&cmd_set_vf_rxmode_set,
8530 (void *)&cmd_set_vf_rxmode_port,
8531 (void *)&cmd_set_vf_rxmode_portid,
8532 (void *)&cmd_set_vf_rxmode_vf,
8533 (void *)&cmd_set_vf_rxmode_vfid,
8534 (void *)&cmd_set_vf_rxmode_what,
8535 (void *)&cmd_set_vf_rxmode_mode,
8536 (void *)&cmd_set_vf_rxmode_on,
8541 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8542 struct cmd_vf_mac_addr_result {
8543 cmdline_fixed_string_t mac_addr_cmd;
8544 cmdline_fixed_string_t what;
8545 cmdline_fixed_string_t port;
8547 cmdline_fixed_string_t vf;
8549 struct rte_ether_addr address;
8552 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8553 __attribute__((unused)) struct cmdline *cl,
8554 __attribute__((unused)) void *data)
8556 struct cmd_vf_mac_addr_result *res = parsed_result;
8559 if (strcmp(res->what, "add") != 0)
8562 #ifdef RTE_LIBRTE_I40E_PMD
8563 if (ret == -ENOTSUP)
8564 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8567 #ifdef RTE_LIBRTE_BNXT_PMD
8568 if (ret == -ENOTSUP)
8569 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8574 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8578 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8579 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8580 mac_addr_cmd,"mac_addr");
8581 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8582 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8584 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8585 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8587 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8588 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8590 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8591 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8593 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8594 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8596 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8597 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8600 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8601 .f = cmd_vf_mac_addr_parsed,
8603 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8604 "Add MAC address filtering for a VF on port_id",
8606 (void *)&cmd_vf_mac_addr_cmd,
8607 (void *)&cmd_vf_mac_addr_what,
8608 (void *)&cmd_vf_mac_addr_port,
8609 (void *)&cmd_vf_mac_addr_portnum,
8610 (void *)&cmd_vf_mac_addr_vf,
8611 (void *)&cmd_vf_mac_addr_vfnum,
8612 (void *)&cmd_vf_mac_addr_addr,
8617 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8618 struct cmd_vf_rx_vlan_filter {
8619 cmdline_fixed_string_t rx_vlan;
8620 cmdline_fixed_string_t what;
8622 cmdline_fixed_string_t port;
8624 cmdline_fixed_string_t vf;
8629 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8630 __attribute__((unused)) struct cmdline *cl,
8631 __attribute__((unused)) void *data)
8633 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8636 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8638 #ifdef RTE_LIBRTE_IXGBE_PMD
8639 if (ret == -ENOTSUP)
8640 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8641 res->vlan_id, res->vf_mask, is_add);
8643 #ifdef RTE_LIBRTE_I40E_PMD
8644 if (ret == -ENOTSUP)
8645 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8646 res->vlan_id, res->vf_mask, is_add);
8648 #ifdef RTE_LIBRTE_BNXT_PMD
8649 if (ret == -ENOTSUP)
8650 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8651 res->vlan_id, res->vf_mask, is_add);
8658 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8659 res->vlan_id, res->vf_mask);
8662 printf("invalid port_id %d\n", res->port_id);
8665 printf("function not implemented or supported\n");
8668 printf("programming error: (%s)\n", strerror(-ret));
8672 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8673 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8674 rx_vlan, "rx_vlan");
8675 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8676 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8678 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8679 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8681 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8682 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8684 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8685 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8687 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8688 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8690 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8691 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8694 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8695 .f = cmd_vf_rx_vlan_filter_parsed,
8697 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8698 "(vf_mask = hexadecimal VF mask)",
8700 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8701 (void *)&cmd_vf_rx_vlan_filter_what,
8702 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8703 (void *)&cmd_vf_rx_vlan_filter_port,
8704 (void *)&cmd_vf_rx_vlan_filter_portid,
8705 (void *)&cmd_vf_rx_vlan_filter_vf,
8706 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8711 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8712 struct cmd_queue_rate_limit_result {
8713 cmdline_fixed_string_t set;
8714 cmdline_fixed_string_t port;
8716 cmdline_fixed_string_t queue;
8718 cmdline_fixed_string_t rate;
8722 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8723 __attribute__((unused)) struct cmdline *cl,
8724 __attribute__((unused)) void *data)
8726 struct cmd_queue_rate_limit_result *res = parsed_result;
8729 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8730 && (strcmp(res->queue, "queue") == 0)
8731 && (strcmp(res->rate, "rate") == 0))
8732 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8735 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8739 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8740 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8742 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8743 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8745 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8746 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8748 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8749 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8751 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8752 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8754 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8755 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8757 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8758 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8761 cmdline_parse_inst_t cmd_queue_rate_limit = {
8762 .f = cmd_queue_rate_limit_parsed,
8764 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8765 "Set rate limit for a queue on port_id",
8767 (void *)&cmd_queue_rate_limit_set,
8768 (void *)&cmd_queue_rate_limit_port,
8769 (void *)&cmd_queue_rate_limit_portnum,
8770 (void *)&cmd_queue_rate_limit_queue,
8771 (void *)&cmd_queue_rate_limit_queuenum,
8772 (void *)&cmd_queue_rate_limit_rate,
8773 (void *)&cmd_queue_rate_limit_ratenum,
8778 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8779 struct cmd_vf_rate_limit_result {
8780 cmdline_fixed_string_t set;
8781 cmdline_fixed_string_t port;
8783 cmdline_fixed_string_t vf;
8785 cmdline_fixed_string_t rate;
8787 cmdline_fixed_string_t q_msk;
8791 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8792 __attribute__((unused)) struct cmdline *cl,
8793 __attribute__((unused)) void *data)
8795 struct cmd_vf_rate_limit_result *res = parsed_result;
8798 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8799 && (strcmp(res->vf, "vf") == 0)
8800 && (strcmp(res->rate, "rate") == 0)
8801 && (strcmp(res->q_msk, "queue_mask") == 0))
8802 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8803 res->rate_num, res->q_msk_val);
8805 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8809 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8810 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8812 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8813 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8815 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8816 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8818 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8819 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8821 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8822 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8824 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8825 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8827 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8828 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8830 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8831 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8832 q_msk, "queue_mask");
8833 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8834 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8837 cmdline_parse_inst_t cmd_vf_rate_limit = {
8838 .f = cmd_vf_rate_limit_parsed,
8840 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8841 "queue_mask <queue_mask_value>: "
8842 "Set rate limit for queues of VF on port_id",
8844 (void *)&cmd_vf_rate_limit_set,
8845 (void *)&cmd_vf_rate_limit_port,
8846 (void *)&cmd_vf_rate_limit_portnum,
8847 (void *)&cmd_vf_rate_limit_vf,
8848 (void *)&cmd_vf_rate_limit_vfnum,
8849 (void *)&cmd_vf_rate_limit_rate,
8850 (void *)&cmd_vf_rate_limit_ratenum,
8851 (void *)&cmd_vf_rate_limit_q_msk,
8852 (void *)&cmd_vf_rate_limit_q_msk_val,
8857 /* *** ADD TUNNEL FILTER OF A PORT *** */
8858 struct cmd_tunnel_filter_result {
8859 cmdline_fixed_string_t cmd;
8860 cmdline_fixed_string_t what;
8862 struct rte_ether_addr outer_mac;
8863 struct rte_ether_addr inner_mac;
8864 cmdline_ipaddr_t ip_value;
8865 uint16_t inner_vlan;
8866 cmdline_fixed_string_t tunnel_type;
8867 cmdline_fixed_string_t filter_type;
8873 cmd_tunnel_filter_parsed(void *parsed_result,
8874 __attribute__((unused)) struct cmdline *cl,
8875 __attribute__((unused)) void *data)
8877 struct cmd_tunnel_filter_result *res = parsed_result;
8878 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8881 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8883 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8884 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8885 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8887 if (res->ip_value.family == AF_INET) {
8888 tunnel_filter_conf.ip_addr.ipv4_addr =
8889 res->ip_value.addr.ipv4.s_addr;
8890 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8892 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8893 &(res->ip_value.addr.ipv6),
8894 sizeof(struct in6_addr));
8895 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8898 if (!strcmp(res->filter_type, "imac-ivlan"))
8899 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8900 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8901 tunnel_filter_conf.filter_type =
8902 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8903 else if (!strcmp(res->filter_type, "imac-tenid"))
8904 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8905 else if (!strcmp(res->filter_type, "imac"))
8906 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8907 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8908 tunnel_filter_conf.filter_type =
8909 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8910 else if (!strcmp(res->filter_type, "oip"))
8911 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8912 else if (!strcmp(res->filter_type, "iip"))
8913 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8915 printf("The filter type is not supported");
8919 if (!strcmp(res->tunnel_type, "vxlan"))
8920 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8921 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8922 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8923 else if (!strcmp(res->tunnel_type, "nvgre"))
8924 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8925 else if (!strcmp(res->tunnel_type, "ipingre"))
8926 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8928 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8932 tunnel_filter_conf.tenant_id = res->tenant_id;
8933 tunnel_filter_conf.queue_id = res->queue_num;
8934 if (!strcmp(res->what, "add"))
8935 ret = rte_eth_dev_filter_ctrl(res->port_id,
8936 RTE_ETH_FILTER_TUNNEL,
8938 &tunnel_filter_conf);
8940 ret = rte_eth_dev_filter_ctrl(res->port_id,
8941 RTE_ETH_FILTER_TUNNEL,
8942 RTE_ETH_FILTER_DELETE,
8943 &tunnel_filter_conf);
8945 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8949 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8950 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8951 cmd, "tunnel_filter");
8952 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8953 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8955 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8956 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8958 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8959 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8961 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8962 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8964 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8965 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8966 inner_vlan, UINT16);
8967 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8968 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8970 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8971 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8972 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8974 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8975 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8976 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8977 "imac#omac-imac-tenid");
8978 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8979 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8981 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8982 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8985 cmdline_parse_inst_t cmd_tunnel_filter = {
8986 .f = cmd_tunnel_filter_parsed,
8988 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8989 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8990 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8991 "<queue_id>: Add/Rm tunnel filter of a port",
8993 (void *)&cmd_tunnel_filter_cmd,
8994 (void *)&cmd_tunnel_filter_what,
8995 (void *)&cmd_tunnel_filter_port_id,
8996 (void *)&cmd_tunnel_filter_outer_mac,
8997 (void *)&cmd_tunnel_filter_inner_mac,
8998 (void *)&cmd_tunnel_filter_ip_value,
8999 (void *)&cmd_tunnel_filter_innner_vlan,
9000 (void *)&cmd_tunnel_filter_tunnel_type,
9001 (void *)&cmd_tunnel_filter_filter_type,
9002 (void *)&cmd_tunnel_filter_tenant_id,
9003 (void *)&cmd_tunnel_filter_queue_num,
9008 /* *** CONFIGURE TUNNEL UDP PORT *** */
9009 struct cmd_tunnel_udp_config {
9010 cmdline_fixed_string_t cmd;
9011 cmdline_fixed_string_t what;
9017 cmd_tunnel_udp_config_parsed(void *parsed_result,
9018 __attribute__((unused)) struct cmdline *cl,
9019 __attribute__((unused)) void *data)
9021 struct cmd_tunnel_udp_config *res = parsed_result;
9022 struct rte_eth_udp_tunnel tunnel_udp;
9025 tunnel_udp.udp_port = res->udp_port;
9027 if (!strcmp(res->cmd, "rx_vxlan_port"))
9028 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9030 if (!strcmp(res->what, "add"))
9031 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9034 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9038 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9041 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9042 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9043 cmd, "rx_vxlan_port");
9044 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9045 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9047 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9048 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9050 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9051 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9054 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9055 .f = cmd_tunnel_udp_config_parsed,
9057 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9058 "Add/Remove a tunneling UDP port filter",
9060 (void *)&cmd_tunnel_udp_config_cmd,
9061 (void *)&cmd_tunnel_udp_config_what,
9062 (void *)&cmd_tunnel_udp_config_udp_port,
9063 (void *)&cmd_tunnel_udp_config_port_id,
9068 struct cmd_config_tunnel_udp_port {
9069 cmdline_fixed_string_t port;
9070 cmdline_fixed_string_t config;
9072 cmdline_fixed_string_t udp_tunnel_port;
9073 cmdline_fixed_string_t action;
9074 cmdline_fixed_string_t tunnel_type;
9079 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9080 __attribute__((unused)) struct cmdline *cl,
9081 __attribute__((unused)) void *data)
9083 struct cmd_config_tunnel_udp_port *res = parsed_result;
9084 struct rte_eth_udp_tunnel tunnel_udp;
9087 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9090 tunnel_udp.udp_port = res->udp_port;
9092 if (!strcmp(res->tunnel_type, "vxlan")) {
9093 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9094 } else if (!strcmp(res->tunnel_type, "geneve")) {
9095 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9096 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9097 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9099 printf("Invalid tunnel type\n");
9103 if (!strcmp(res->action, "add"))
9104 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9107 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9111 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9114 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9115 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9117 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9118 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9120 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9121 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9123 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9124 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9127 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9128 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9130 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9131 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9132 "vxlan#geneve#vxlan-gpe");
9133 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9134 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9137 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9138 .f = cmd_cfg_tunnel_udp_port_parsed,
9140 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9142 (void *)&cmd_config_tunnel_udp_port_port,
9143 (void *)&cmd_config_tunnel_udp_port_config,
9144 (void *)&cmd_config_tunnel_udp_port_port_id,
9145 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9146 (void *)&cmd_config_tunnel_udp_port_action,
9147 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9148 (void *)&cmd_config_tunnel_udp_port_value,
9153 /* *** GLOBAL CONFIG *** */
9154 struct cmd_global_config_result {
9155 cmdline_fixed_string_t cmd;
9157 cmdline_fixed_string_t cfg_type;
9162 cmd_global_config_parsed(void *parsed_result,
9163 __attribute__((unused)) struct cmdline *cl,
9164 __attribute__((unused)) void *data)
9166 struct cmd_global_config_result *res = parsed_result;
9167 struct rte_eth_global_cfg conf;
9170 memset(&conf, 0, sizeof(conf));
9171 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9172 conf.cfg.gre_key_len = res->len;
9173 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9174 RTE_ETH_FILTER_SET, &conf);
9176 printf("Global config error\n");
9179 cmdline_parse_token_string_t cmd_global_config_cmd =
9180 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9182 cmdline_parse_token_num_t cmd_global_config_port_id =
9183 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9185 cmdline_parse_token_string_t cmd_global_config_type =
9186 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9187 cfg_type, "gre-key-len");
9188 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9189 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9192 cmdline_parse_inst_t cmd_global_config = {
9193 .f = cmd_global_config_parsed,
9194 .data = (void *)NULL,
9195 .help_str = "global_config <port_id> gre-key-len <key_len>",
9197 (void *)&cmd_global_config_cmd,
9198 (void *)&cmd_global_config_port_id,
9199 (void *)&cmd_global_config_type,
9200 (void *)&cmd_global_config_gre_key_len,
9205 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9206 struct cmd_set_mirror_mask_result {
9207 cmdline_fixed_string_t set;
9208 cmdline_fixed_string_t port;
9210 cmdline_fixed_string_t mirror;
9212 cmdline_fixed_string_t what;
9213 cmdline_fixed_string_t value;
9214 cmdline_fixed_string_t dstpool;
9216 cmdline_fixed_string_t on;
9219 cmdline_parse_token_string_t cmd_mirror_mask_set =
9220 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9222 cmdline_parse_token_string_t cmd_mirror_mask_port =
9223 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9225 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9226 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9228 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9229 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9230 mirror, "mirror-rule");
9231 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9232 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9234 cmdline_parse_token_string_t cmd_mirror_mask_what =
9235 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9236 what, "pool-mirror-up#pool-mirror-down"
9238 cmdline_parse_token_string_t cmd_mirror_mask_value =
9239 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9241 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9242 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9243 dstpool, "dst-pool");
9244 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9245 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9247 cmdline_parse_token_string_t cmd_mirror_mask_on =
9248 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9252 cmd_set_mirror_mask_parsed(void *parsed_result,
9253 __attribute__((unused)) struct cmdline *cl,
9254 __attribute__((unused)) void *data)
9257 struct cmd_set_mirror_mask_result *res = parsed_result;
9258 struct rte_eth_mirror_conf mr_conf;
9260 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9262 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9264 mr_conf.dst_pool = res->dstpool_id;
9266 if (!strcmp(res->what, "pool-mirror-up")) {
9267 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9268 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9269 } else if (!strcmp(res->what, "pool-mirror-down")) {
9270 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9271 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9272 } else if (!strcmp(res->what, "vlan-mirror")) {
9273 mr_conf.rule_type = ETH_MIRROR_VLAN;
9274 nb_item = parse_item_list(res->value, "vlan",
9275 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9279 for (i = 0; i < nb_item; i++) {
9280 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9281 printf("Invalid vlan_id: must be < 4096\n");
9285 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9286 mr_conf.vlan.vlan_mask |= 1ULL << i;
9290 if (!strcmp(res->on, "on"))
9291 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9294 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9297 printf("mirror rule add error: (%s)\n", strerror(-ret));
9300 cmdline_parse_inst_t cmd_set_mirror_mask = {
9301 .f = cmd_set_mirror_mask_parsed,
9303 .help_str = "set port <port_id> mirror-rule <rule_id> "
9304 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9305 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9307 (void *)&cmd_mirror_mask_set,
9308 (void *)&cmd_mirror_mask_port,
9309 (void *)&cmd_mirror_mask_portid,
9310 (void *)&cmd_mirror_mask_mirror,
9311 (void *)&cmd_mirror_mask_ruleid,
9312 (void *)&cmd_mirror_mask_what,
9313 (void *)&cmd_mirror_mask_value,
9314 (void *)&cmd_mirror_mask_dstpool,
9315 (void *)&cmd_mirror_mask_poolid,
9316 (void *)&cmd_mirror_mask_on,
9321 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9322 struct cmd_set_mirror_link_result {
9323 cmdline_fixed_string_t set;
9324 cmdline_fixed_string_t port;
9326 cmdline_fixed_string_t mirror;
9328 cmdline_fixed_string_t what;
9329 cmdline_fixed_string_t dstpool;
9331 cmdline_fixed_string_t on;
9334 cmdline_parse_token_string_t cmd_mirror_link_set =
9335 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9337 cmdline_parse_token_string_t cmd_mirror_link_port =
9338 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9340 cmdline_parse_token_num_t cmd_mirror_link_portid =
9341 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9343 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9344 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9345 mirror, "mirror-rule");
9346 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9347 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9349 cmdline_parse_token_string_t cmd_mirror_link_what =
9350 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9351 what, "uplink-mirror#downlink-mirror");
9352 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9353 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9354 dstpool, "dst-pool");
9355 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9356 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9358 cmdline_parse_token_string_t cmd_mirror_link_on =
9359 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9363 cmd_set_mirror_link_parsed(void *parsed_result,
9364 __attribute__((unused)) struct cmdline *cl,
9365 __attribute__((unused)) void *data)
9368 struct cmd_set_mirror_link_result *res = parsed_result;
9369 struct rte_eth_mirror_conf mr_conf;
9371 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9372 if (!strcmp(res->what, "uplink-mirror"))
9373 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9375 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9377 mr_conf.dst_pool = res->dstpool_id;
9379 if (!strcmp(res->on, "on"))
9380 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9383 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9386 /* check the return value and print it if is < 0 */
9388 printf("mirror rule add error: (%s)\n", strerror(-ret));
9392 cmdline_parse_inst_t cmd_set_mirror_link = {
9393 .f = cmd_set_mirror_link_parsed,
9395 .help_str = "set port <port_id> mirror-rule <rule_id> "
9396 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9398 (void *)&cmd_mirror_link_set,
9399 (void *)&cmd_mirror_link_port,
9400 (void *)&cmd_mirror_link_portid,
9401 (void *)&cmd_mirror_link_mirror,
9402 (void *)&cmd_mirror_link_ruleid,
9403 (void *)&cmd_mirror_link_what,
9404 (void *)&cmd_mirror_link_dstpool,
9405 (void *)&cmd_mirror_link_poolid,
9406 (void *)&cmd_mirror_link_on,
9411 /* *** RESET VM MIRROR RULE *** */
9412 struct cmd_rm_mirror_rule_result {
9413 cmdline_fixed_string_t reset;
9414 cmdline_fixed_string_t port;
9416 cmdline_fixed_string_t mirror;
9420 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9421 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9423 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9424 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9426 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9427 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9429 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9430 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9431 mirror, "mirror-rule");
9432 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9433 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9437 cmd_reset_mirror_rule_parsed(void *parsed_result,
9438 __attribute__((unused)) struct cmdline *cl,
9439 __attribute__((unused)) void *data)
9442 struct cmd_set_mirror_link_result *res = parsed_result;
9444 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9446 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9449 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9450 .f = cmd_reset_mirror_rule_parsed,
9452 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9454 (void *)&cmd_rm_mirror_rule_reset,
9455 (void *)&cmd_rm_mirror_rule_port,
9456 (void *)&cmd_rm_mirror_rule_portid,
9457 (void *)&cmd_rm_mirror_rule_mirror,
9458 (void *)&cmd_rm_mirror_rule_ruleid,
9463 /* ******************************************************************************** */
9465 struct cmd_dump_result {
9466 cmdline_fixed_string_t dump;
9470 dump_struct_sizes(void)
9472 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9473 DUMP_SIZE(struct rte_mbuf);
9474 DUMP_SIZE(struct rte_mempool);
9475 DUMP_SIZE(struct rte_ring);
9479 static void cmd_dump_parsed(void *parsed_result,
9480 __attribute__((unused)) struct cmdline *cl,
9481 __attribute__((unused)) void *data)
9483 struct cmd_dump_result *res = parsed_result;
9485 if (!strcmp(res->dump, "dump_physmem"))
9486 rte_dump_physmem_layout(stdout);
9487 else if (!strcmp(res->dump, "dump_memzone"))
9488 rte_memzone_dump(stdout);
9489 else if (!strcmp(res->dump, "dump_struct_sizes"))
9490 dump_struct_sizes();
9491 else if (!strcmp(res->dump, "dump_ring"))
9492 rte_ring_list_dump(stdout);
9493 else if (!strcmp(res->dump, "dump_mempool"))
9494 rte_mempool_list_dump(stdout);
9495 else if (!strcmp(res->dump, "dump_devargs"))
9496 rte_devargs_dump(stdout);
9497 else if (!strcmp(res->dump, "dump_log_types"))
9498 rte_log_dump(stdout);
9501 cmdline_parse_token_string_t cmd_dump_dump =
9502 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9505 "dump_struct_sizes#"
9511 cmdline_parse_inst_t cmd_dump = {
9512 .f = cmd_dump_parsed, /* function to call */
9513 .data = NULL, /* 2nd arg of func */
9514 .help_str = "Dump status",
9515 .tokens = { /* token list, NULL terminated */
9516 (void *)&cmd_dump_dump,
9521 /* ******************************************************************************** */
9523 struct cmd_dump_one_result {
9524 cmdline_fixed_string_t dump;
9525 cmdline_fixed_string_t name;
9528 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9529 __attribute__((unused)) void *data)
9531 struct cmd_dump_one_result *res = parsed_result;
9533 if (!strcmp(res->dump, "dump_ring")) {
9535 r = rte_ring_lookup(res->name);
9537 cmdline_printf(cl, "Cannot find ring\n");
9540 rte_ring_dump(stdout, r);
9541 } else if (!strcmp(res->dump, "dump_mempool")) {
9542 struct rte_mempool *mp;
9543 mp = rte_mempool_lookup(res->name);
9545 cmdline_printf(cl, "Cannot find mempool\n");
9548 rte_mempool_dump(stdout, mp);
9552 cmdline_parse_token_string_t cmd_dump_one_dump =
9553 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9554 "dump_ring#dump_mempool");
9556 cmdline_parse_token_string_t cmd_dump_one_name =
9557 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9559 cmdline_parse_inst_t cmd_dump_one = {
9560 .f = cmd_dump_one_parsed, /* function to call */
9561 .data = NULL, /* 2nd arg of func */
9562 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9563 .tokens = { /* token list, NULL terminated */
9564 (void *)&cmd_dump_one_dump,
9565 (void *)&cmd_dump_one_name,
9570 /* *** Add/Del syn filter *** */
9571 struct cmd_syn_filter_result {
9572 cmdline_fixed_string_t filter;
9574 cmdline_fixed_string_t ops;
9575 cmdline_fixed_string_t priority;
9576 cmdline_fixed_string_t high;
9577 cmdline_fixed_string_t queue;
9582 cmd_syn_filter_parsed(void *parsed_result,
9583 __attribute__((unused)) struct cmdline *cl,
9584 __attribute__((unused)) void *data)
9586 struct cmd_syn_filter_result *res = parsed_result;
9587 struct rte_eth_syn_filter syn_filter;
9590 ret = rte_eth_dev_filter_supported(res->port_id,
9591 RTE_ETH_FILTER_SYN);
9593 printf("syn filter is not supported on port %u.\n",
9598 memset(&syn_filter, 0, sizeof(syn_filter));
9600 if (!strcmp(res->ops, "add")) {
9601 if (!strcmp(res->high, "high"))
9602 syn_filter.hig_pri = 1;
9604 syn_filter.hig_pri = 0;
9606 syn_filter.queue = res->queue_id;
9607 ret = rte_eth_dev_filter_ctrl(res->port_id,
9612 ret = rte_eth_dev_filter_ctrl(res->port_id,
9614 RTE_ETH_FILTER_DELETE,
9618 printf("syn filter programming error: (%s)\n",
9622 cmdline_parse_token_string_t cmd_syn_filter_filter =
9623 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9624 filter, "syn_filter");
9625 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9626 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9628 cmdline_parse_token_string_t cmd_syn_filter_ops =
9629 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9631 cmdline_parse_token_string_t cmd_syn_filter_priority =
9632 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9633 priority, "priority");
9634 cmdline_parse_token_string_t cmd_syn_filter_high =
9635 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9637 cmdline_parse_token_string_t cmd_syn_filter_queue =
9638 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9640 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9641 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9644 cmdline_parse_inst_t cmd_syn_filter = {
9645 .f = cmd_syn_filter_parsed,
9647 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9648 "<queue_id>: Add/Delete syn filter",
9650 (void *)&cmd_syn_filter_filter,
9651 (void *)&cmd_syn_filter_port_id,
9652 (void *)&cmd_syn_filter_ops,
9653 (void *)&cmd_syn_filter_priority,
9654 (void *)&cmd_syn_filter_high,
9655 (void *)&cmd_syn_filter_queue,
9656 (void *)&cmd_syn_filter_queue_id,
9661 /* *** queue region set *** */
9662 struct cmd_queue_region_result {
9663 cmdline_fixed_string_t set;
9664 cmdline_fixed_string_t port;
9666 cmdline_fixed_string_t cmd;
9667 cmdline_fixed_string_t region;
9669 cmdline_fixed_string_t queue_start_index;
9671 cmdline_fixed_string_t queue_num;
9672 uint8_t queue_num_value;
9676 cmd_queue_region_parsed(void *parsed_result,
9677 __attribute__((unused)) struct cmdline *cl,
9678 __attribute__((unused)) void *data)
9680 struct cmd_queue_region_result *res = parsed_result;
9682 #ifdef RTE_LIBRTE_I40E_PMD
9683 struct rte_pmd_i40e_queue_region_conf region_conf;
9684 enum rte_pmd_i40e_queue_region_op op_type;
9687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9690 #ifdef RTE_LIBRTE_I40E_PMD
9691 memset(®ion_conf, 0, sizeof(region_conf));
9692 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9693 region_conf.region_id = res->region_id;
9694 region_conf.queue_num = res->queue_num_value;
9695 region_conf.queue_start_index = res->queue_id;
9697 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9698 op_type, ®ion_conf);
9705 printf("function not implemented or supported\n");
9708 printf("queue region config error: (%s)\n", strerror(-ret));
9712 cmdline_parse_token_string_t cmd_queue_region_set =
9713 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9715 cmdline_parse_token_string_t cmd_queue_region_port =
9716 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9717 cmdline_parse_token_num_t cmd_queue_region_port_id =
9718 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9720 cmdline_parse_token_string_t cmd_queue_region_cmd =
9721 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9722 cmd, "queue-region");
9723 cmdline_parse_token_string_t cmd_queue_region_id =
9724 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9725 region, "region_id");
9726 cmdline_parse_token_num_t cmd_queue_region_index =
9727 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9729 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9730 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9731 queue_start_index, "queue_start_index");
9732 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9733 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9735 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9736 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9737 queue_num, "queue_num");
9738 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9739 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9740 queue_num_value, UINT8);
9742 cmdline_parse_inst_t cmd_queue_region = {
9743 .f = cmd_queue_region_parsed,
9745 .help_str = "set port <port_id> queue-region region_id <value> "
9746 "queue_start_index <value> queue_num <value>: Set a queue region",
9748 (void *)&cmd_queue_region_set,
9749 (void *)&cmd_queue_region_port,
9750 (void *)&cmd_queue_region_port_id,
9751 (void *)&cmd_queue_region_cmd,
9752 (void *)&cmd_queue_region_id,
9753 (void *)&cmd_queue_region_index,
9754 (void *)&cmd_queue_region_queue_start_index,
9755 (void *)&cmd_queue_region_queue_id,
9756 (void *)&cmd_queue_region_queue_num,
9757 (void *)&cmd_queue_region_queue_num_value,
9762 /* *** queue region and flowtype set *** */
9763 struct cmd_region_flowtype_result {
9764 cmdline_fixed_string_t set;
9765 cmdline_fixed_string_t port;
9767 cmdline_fixed_string_t cmd;
9768 cmdline_fixed_string_t region;
9770 cmdline_fixed_string_t flowtype;
9771 uint8_t flowtype_id;
9775 cmd_region_flowtype_parsed(void *parsed_result,
9776 __attribute__((unused)) struct cmdline *cl,
9777 __attribute__((unused)) void *data)
9779 struct cmd_region_flowtype_result *res = parsed_result;
9781 #ifdef RTE_LIBRTE_I40E_PMD
9782 struct rte_pmd_i40e_queue_region_conf region_conf;
9783 enum rte_pmd_i40e_queue_region_op op_type;
9786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9789 #ifdef RTE_LIBRTE_I40E_PMD
9790 memset(®ion_conf, 0, sizeof(region_conf));
9792 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9793 region_conf.region_id = res->region_id;
9794 region_conf.hw_flowtype = res->flowtype_id;
9796 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9797 op_type, ®ion_conf);
9804 printf("function not implemented or supported\n");
9807 printf("region flowtype config error: (%s)\n", strerror(-ret));
9811 cmdline_parse_token_string_t cmd_region_flowtype_set =
9812 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9814 cmdline_parse_token_string_t cmd_region_flowtype_port =
9815 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9817 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9818 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9820 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9821 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9822 cmd, "queue-region");
9823 cmdline_parse_token_string_t cmd_region_flowtype_index =
9824 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9825 region, "region_id");
9826 cmdline_parse_token_num_t cmd_region_flowtype_id =
9827 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9829 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9830 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9831 flowtype, "flowtype");
9832 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9833 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9834 flowtype_id, UINT8);
9835 cmdline_parse_inst_t cmd_region_flowtype = {
9836 .f = cmd_region_flowtype_parsed,
9838 .help_str = "set port <port_id> queue-region region_id <value> "
9839 "flowtype <value>: Set a flowtype region index",
9841 (void *)&cmd_region_flowtype_set,
9842 (void *)&cmd_region_flowtype_port,
9843 (void *)&cmd_region_flowtype_port_index,
9844 (void *)&cmd_region_flowtype_cmd,
9845 (void *)&cmd_region_flowtype_index,
9846 (void *)&cmd_region_flowtype_id,
9847 (void *)&cmd_region_flowtype_flow_index,
9848 (void *)&cmd_region_flowtype_flow_id,
9853 /* *** User Priority (UP) to queue region (region_id) set *** */
9854 struct cmd_user_priority_region_result {
9855 cmdline_fixed_string_t set;
9856 cmdline_fixed_string_t port;
9858 cmdline_fixed_string_t cmd;
9859 cmdline_fixed_string_t user_priority;
9860 uint8_t user_priority_id;
9861 cmdline_fixed_string_t region;
9866 cmd_user_priority_region_parsed(void *parsed_result,
9867 __attribute__((unused)) struct cmdline *cl,
9868 __attribute__((unused)) void *data)
9870 struct cmd_user_priority_region_result *res = parsed_result;
9872 #ifdef RTE_LIBRTE_I40E_PMD
9873 struct rte_pmd_i40e_queue_region_conf region_conf;
9874 enum rte_pmd_i40e_queue_region_op op_type;
9877 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9880 #ifdef RTE_LIBRTE_I40E_PMD
9881 memset(®ion_conf, 0, sizeof(region_conf));
9882 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9883 region_conf.user_priority = res->user_priority_id;
9884 region_conf.region_id = res->region_id;
9886 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9887 op_type, ®ion_conf);
9894 printf("function not implemented or supported\n");
9897 printf("user_priority region config error: (%s)\n",
9902 cmdline_parse_token_string_t cmd_user_priority_region_set =
9903 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9905 cmdline_parse_token_string_t cmd_user_priority_region_port =
9906 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9908 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9909 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9911 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9912 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9913 cmd, "queue-region");
9914 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9915 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9916 user_priority, "UP");
9917 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9918 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9919 user_priority_id, UINT8);
9920 cmdline_parse_token_string_t cmd_user_priority_region_region =
9921 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9922 region, "region_id");
9923 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9924 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9927 cmdline_parse_inst_t cmd_user_priority_region = {
9928 .f = cmd_user_priority_region_parsed,
9930 .help_str = "set port <port_id> queue-region UP <value> "
9931 "region_id <value>: Set the mapping of User Priority (UP) "
9932 "to queue region (region_id) ",
9934 (void *)&cmd_user_priority_region_set,
9935 (void *)&cmd_user_priority_region_port,
9936 (void *)&cmd_user_priority_region_port_index,
9937 (void *)&cmd_user_priority_region_cmd,
9938 (void *)&cmd_user_priority_region_UP,
9939 (void *)&cmd_user_priority_region_UP_id,
9940 (void *)&cmd_user_priority_region_region,
9941 (void *)&cmd_user_priority_region_region_id,
9946 /* *** flush all queue region related configuration *** */
9947 struct cmd_flush_queue_region_result {
9948 cmdline_fixed_string_t set;
9949 cmdline_fixed_string_t port;
9951 cmdline_fixed_string_t cmd;
9952 cmdline_fixed_string_t flush;
9953 cmdline_fixed_string_t what;
9957 cmd_flush_queue_region_parsed(void *parsed_result,
9958 __attribute__((unused)) struct cmdline *cl,
9959 __attribute__((unused)) void *data)
9961 struct cmd_flush_queue_region_result *res = parsed_result;
9963 #ifdef RTE_LIBRTE_I40E_PMD
9964 struct rte_pmd_i40e_queue_region_conf region_conf;
9965 enum rte_pmd_i40e_queue_region_op op_type;
9968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9971 #ifdef RTE_LIBRTE_I40E_PMD
9972 memset(®ion_conf, 0, sizeof(region_conf));
9974 if (strcmp(res->what, "on") == 0)
9975 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9977 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9979 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9980 op_type, ®ion_conf);
9987 printf("function not implemented or supported\n");
9990 printf("queue region config flush error: (%s)\n",
9995 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9996 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9998 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9999 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10001 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10002 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10004 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10005 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10006 cmd, "queue-region");
10007 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10008 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10010 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10011 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10014 cmdline_parse_inst_t cmd_flush_queue_region = {
10015 .f = cmd_flush_queue_region_parsed,
10017 .help_str = "set port <port_id> queue-region flush on|off"
10018 ": flush all queue region related configuration",
10020 (void *)&cmd_flush_queue_region_set,
10021 (void *)&cmd_flush_queue_region_port,
10022 (void *)&cmd_flush_queue_region_port_index,
10023 (void *)&cmd_flush_queue_region_cmd,
10024 (void *)&cmd_flush_queue_region_flush,
10025 (void *)&cmd_flush_queue_region_what,
10030 /* *** get all queue region related configuration info *** */
10031 struct cmd_show_queue_region_info {
10032 cmdline_fixed_string_t show;
10033 cmdline_fixed_string_t port;
10035 cmdline_fixed_string_t cmd;
10039 cmd_show_queue_region_info_parsed(void *parsed_result,
10040 __attribute__((unused)) struct cmdline *cl,
10041 __attribute__((unused)) void *data)
10043 struct cmd_show_queue_region_info *res = parsed_result;
10044 int ret = -ENOTSUP;
10045 #ifdef RTE_LIBRTE_I40E_PMD
10046 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10047 enum rte_pmd_i40e_queue_region_op op_type;
10050 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10053 #ifdef RTE_LIBRTE_I40E_PMD
10054 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10056 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10058 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10059 op_type, &rte_pmd_regions);
10061 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10068 printf("function not implemented or supported\n");
10071 printf("queue region config info show error: (%s)\n",
10076 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10077 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10079 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10080 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10082 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10083 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10085 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10086 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10087 cmd, "queue-region");
10089 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10090 .f = cmd_show_queue_region_info_parsed,
10092 .help_str = "show port <port_id> queue-region"
10093 ": show all queue region related configuration info",
10095 (void *)&cmd_show_queue_region_info_get,
10096 (void *)&cmd_show_queue_region_info_port,
10097 (void *)&cmd_show_queue_region_info_port_index,
10098 (void *)&cmd_show_queue_region_info_cmd,
10103 /* *** ADD/REMOVE A 2tuple FILTER *** */
10104 struct cmd_2tuple_filter_result {
10105 cmdline_fixed_string_t filter;
10107 cmdline_fixed_string_t ops;
10108 cmdline_fixed_string_t dst_port;
10109 uint16_t dst_port_value;
10110 cmdline_fixed_string_t protocol;
10111 uint8_t protocol_value;
10112 cmdline_fixed_string_t mask;
10113 uint8_t mask_value;
10114 cmdline_fixed_string_t tcp_flags;
10115 uint8_t tcp_flags_value;
10116 cmdline_fixed_string_t priority;
10117 uint8_t priority_value;
10118 cmdline_fixed_string_t queue;
10123 cmd_2tuple_filter_parsed(void *parsed_result,
10124 __attribute__((unused)) struct cmdline *cl,
10125 __attribute__((unused)) void *data)
10127 struct rte_eth_ntuple_filter filter;
10128 struct cmd_2tuple_filter_result *res = parsed_result;
10131 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10133 printf("ntuple filter is not supported on port %u.\n",
10138 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10140 filter.flags = RTE_2TUPLE_FLAGS;
10141 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10142 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10143 filter.proto = res->protocol_value;
10144 filter.priority = res->priority_value;
10145 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10146 printf("nonzero tcp_flags is only meaningful"
10147 " when protocol is TCP.\n");
10150 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10151 printf("invalid TCP flags.\n");
10155 if (res->tcp_flags_value != 0) {
10156 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10157 filter.tcp_flags = res->tcp_flags_value;
10160 /* need convert to big endian. */
10161 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10162 filter.queue = res->queue_id;
10164 if (!strcmp(res->ops, "add"))
10165 ret = rte_eth_dev_filter_ctrl(res->port_id,
10166 RTE_ETH_FILTER_NTUPLE,
10167 RTE_ETH_FILTER_ADD,
10170 ret = rte_eth_dev_filter_ctrl(res->port_id,
10171 RTE_ETH_FILTER_NTUPLE,
10172 RTE_ETH_FILTER_DELETE,
10175 printf("2tuple filter programming error: (%s)\n",
10180 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10181 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10182 filter, "2tuple_filter");
10183 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10184 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10186 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10187 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10189 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10190 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10191 dst_port, "dst_port");
10192 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10193 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10194 dst_port_value, UINT16);
10195 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10196 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10197 protocol, "protocol");
10198 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10199 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10200 protocol_value, UINT8);
10201 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10202 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10204 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10205 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10207 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10208 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10209 tcp_flags, "tcp_flags");
10210 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10211 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10212 tcp_flags_value, UINT8);
10213 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10214 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10215 priority, "priority");
10216 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10217 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10218 priority_value, UINT8);
10219 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10220 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10222 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10223 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10226 cmdline_parse_inst_t cmd_2tuple_filter = {
10227 .f = cmd_2tuple_filter_parsed,
10229 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10230 "<value> mask <value> tcp_flags <value> priority <value> queue "
10231 "<queue_id>: Add a 2tuple filter",
10233 (void *)&cmd_2tuple_filter_filter,
10234 (void *)&cmd_2tuple_filter_port_id,
10235 (void *)&cmd_2tuple_filter_ops,
10236 (void *)&cmd_2tuple_filter_dst_port,
10237 (void *)&cmd_2tuple_filter_dst_port_value,
10238 (void *)&cmd_2tuple_filter_protocol,
10239 (void *)&cmd_2tuple_filter_protocol_value,
10240 (void *)&cmd_2tuple_filter_mask,
10241 (void *)&cmd_2tuple_filter_mask_value,
10242 (void *)&cmd_2tuple_filter_tcp_flags,
10243 (void *)&cmd_2tuple_filter_tcp_flags_value,
10244 (void *)&cmd_2tuple_filter_priority,
10245 (void *)&cmd_2tuple_filter_priority_value,
10246 (void *)&cmd_2tuple_filter_queue,
10247 (void *)&cmd_2tuple_filter_queue_id,
10252 /* *** ADD/REMOVE A 5tuple FILTER *** */
10253 struct cmd_5tuple_filter_result {
10254 cmdline_fixed_string_t filter;
10256 cmdline_fixed_string_t ops;
10257 cmdline_fixed_string_t dst_ip;
10258 cmdline_ipaddr_t dst_ip_value;
10259 cmdline_fixed_string_t src_ip;
10260 cmdline_ipaddr_t src_ip_value;
10261 cmdline_fixed_string_t dst_port;
10262 uint16_t dst_port_value;
10263 cmdline_fixed_string_t src_port;
10264 uint16_t src_port_value;
10265 cmdline_fixed_string_t protocol;
10266 uint8_t protocol_value;
10267 cmdline_fixed_string_t mask;
10268 uint8_t mask_value;
10269 cmdline_fixed_string_t tcp_flags;
10270 uint8_t tcp_flags_value;
10271 cmdline_fixed_string_t priority;
10272 uint8_t priority_value;
10273 cmdline_fixed_string_t queue;
10278 cmd_5tuple_filter_parsed(void *parsed_result,
10279 __attribute__((unused)) struct cmdline *cl,
10280 __attribute__((unused)) void *data)
10282 struct rte_eth_ntuple_filter filter;
10283 struct cmd_5tuple_filter_result *res = parsed_result;
10286 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10288 printf("ntuple filter is not supported on port %u.\n",
10293 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10295 filter.flags = RTE_5TUPLE_FLAGS;
10296 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10297 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10298 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10299 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10300 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10301 filter.proto = res->protocol_value;
10302 filter.priority = res->priority_value;
10303 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10304 printf("nonzero tcp_flags is only meaningful"
10305 " when protocol is TCP.\n");
10308 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10309 printf("invalid TCP flags.\n");
10313 if (res->tcp_flags_value != 0) {
10314 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10315 filter.tcp_flags = res->tcp_flags_value;
10318 if (res->dst_ip_value.family == AF_INET)
10319 /* no need to convert, already big endian. */
10320 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10322 if (filter.dst_ip_mask == 0) {
10323 printf("can not support ipv6 involved compare.\n");
10329 if (res->src_ip_value.family == AF_INET)
10330 /* no need to convert, already big endian. */
10331 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10333 if (filter.src_ip_mask == 0) {
10334 printf("can not support ipv6 involved compare.\n");
10339 /* need convert to big endian. */
10340 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10341 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10342 filter.queue = res->queue_id;
10344 if (!strcmp(res->ops, "add"))
10345 ret = rte_eth_dev_filter_ctrl(res->port_id,
10346 RTE_ETH_FILTER_NTUPLE,
10347 RTE_ETH_FILTER_ADD,
10350 ret = rte_eth_dev_filter_ctrl(res->port_id,
10351 RTE_ETH_FILTER_NTUPLE,
10352 RTE_ETH_FILTER_DELETE,
10355 printf("5tuple filter programming error: (%s)\n",
10359 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10360 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10361 filter, "5tuple_filter");
10362 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10363 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10365 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10366 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10368 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10369 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10371 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10372 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10374 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10375 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10377 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10378 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10380 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10381 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10382 dst_port, "dst_port");
10383 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10384 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10385 dst_port_value, UINT16);
10386 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10387 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10388 src_port, "src_port");
10389 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10390 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10391 src_port_value, UINT16);
10392 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10393 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10394 protocol, "protocol");
10395 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10396 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10397 protocol_value, UINT8);
10398 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10399 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10401 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10402 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10404 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10405 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10406 tcp_flags, "tcp_flags");
10407 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10408 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10409 tcp_flags_value, UINT8);
10410 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10411 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10412 priority, "priority");
10413 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10414 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10415 priority_value, UINT8);
10416 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10417 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10419 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10420 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10423 cmdline_parse_inst_t cmd_5tuple_filter = {
10424 .f = cmd_5tuple_filter_parsed,
10426 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10427 "src_ip <value> dst_port <value> src_port <value> "
10428 "protocol <value> mask <value> tcp_flags <value> "
10429 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10431 (void *)&cmd_5tuple_filter_filter,
10432 (void *)&cmd_5tuple_filter_port_id,
10433 (void *)&cmd_5tuple_filter_ops,
10434 (void *)&cmd_5tuple_filter_dst_ip,
10435 (void *)&cmd_5tuple_filter_dst_ip_value,
10436 (void *)&cmd_5tuple_filter_src_ip,
10437 (void *)&cmd_5tuple_filter_src_ip_value,
10438 (void *)&cmd_5tuple_filter_dst_port,
10439 (void *)&cmd_5tuple_filter_dst_port_value,
10440 (void *)&cmd_5tuple_filter_src_port,
10441 (void *)&cmd_5tuple_filter_src_port_value,
10442 (void *)&cmd_5tuple_filter_protocol,
10443 (void *)&cmd_5tuple_filter_protocol_value,
10444 (void *)&cmd_5tuple_filter_mask,
10445 (void *)&cmd_5tuple_filter_mask_value,
10446 (void *)&cmd_5tuple_filter_tcp_flags,
10447 (void *)&cmd_5tuple_filter_tcp_flags_value,
10448 (void *)&cmd_5tuple_filter_priority,
10449 (void *)&cmd_5tuple_filter_priority_value,
10450 (void *)&cmd_5tuple_filter_queue,
10451 (void *)&cmd_5tuple_filter_queue_id,
10456 /* *** ADD/REMOVE A flex FILTER *** */
10457 struct cmd_flex_filter_result {
10458 cmdline_fixed_string_t filter;
10459 cmdline_fixed_string_t ops;
10461 cmdline_fixed_string_t len;
10463 cmdline_fixed_string_t bytes;
10464 cmdline_fixed_string_t bytes_value;
10465 cmdline_fixed_string_t mask;
10466 cmdline_fixed_string_t mask_value;
10467 cmdline_fixed_string_t priority;
10468 uint8_t priority_value;
10469 cmdline_fixed_string_t queue;
10473 static int xdigit2val(unsigned char c)
10478 else if (isupper(c))
10479 val = c - 'A' + 10;
10481 val = c - 'a' + 10;
10486 cmd_flex_filter_parsed(void *parsed_result,
10487 __attribute__((unused)) struct cmdline *cl,
10488 __attribute__((unused)) void *data)
10491 struct rte_eth_flex_filter filter;
10492 struct cmd_flex_filter_result *res = parsed_result;
10493 char *bytes_ptr, *mask_ptr;
10494 uint16_t len, i, j = 0;
10499 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10500 printf("the len exceed the max length 128\n");
10503 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10504 filter.len = res->len_value;
10505 filter.priority = res->priority_value;
10506 filter.queue = res->queue_id;
10507 bytes_ptr = res->bytes_value;
10508 mask_ptr = res->mask_value;
10510 /* translate bytes string to array. */
10511 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10512 (bytes_ptr[1] == 'X')))
10514 len = strnlen(bytes_ptr, res->len_value * 2);
10515 if (len == 0 || (len % 8 != 0)) {
10516 printf("please check len and bytes input\n");
10519 for (i = 0; i < len; i++) {
10521 if (isxdigit(c) == 0) {
10522 /* invalid characters. */
10523 printf("invalid input\n");
10526 val = xdigit2val(c);
10529 filter.bytes[j] = byte;
10530 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10537 /* translate mask string to uint8_t array. */
10538 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10539 (mask_ptr[1] == 'X')))
10541 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10543 printf("invalid input\n");
10548 for (i = 0; i < len; i++) {
10550 if (isxdigit(c) == 0) {
10551 /* invalid characters. */
10552 printf("invalid input\n");
10555 val = xdigit2val(c);
10558 filter.mask[j] = byte;
10559 printf("mask[%d]:%02x ", j, filter.mask[j]);
10567 if (!strcmp(res->ops, "add"))
10568 ret = rte_eth_dev_filter_ctrl(res->port_id,
10569 RTE_ETH_FILTER_FLEXIBLE,
10570 RTE_ETH_FILTER_ADD,
10573 ret = rte_eth_dev_filter_ctrl(res->port_id,
10574 RTE_ETH_FILTER_FLEXIBLE,
10575 RTE_ETH_FILTER_DELETE,
10579 printf("flex filter setting error: (%s)\n", strerror(-ret));
10582 cmdline_parse_token_string_t cmd_flex_filter_filter =
10583 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10584 filter, "flex_filter");
10585 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10586 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10588 cmdline_parse_token_string_t cmd_flex_filter_ops =
10589 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10591 cmdline_parse_token_string_t cmd_flex_filter_len =
10592 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10594 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10595 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10597 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10598 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10600 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10601 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10602 bytes_value, NULL);
10603 cmdline_parse_token_string_t cmd_flex_filter_mask =
10604 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10606 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10607 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10609 cmdline_parse_token_string_t cmd_flex_filter_priority =
10610 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10611 priority, "priority");
10612 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10613 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10614 priority_value, UINT8);
10615 cmdline_parse_token_string_t cmd_flex_filter_queue =
10616 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10618 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10619 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10621 cmdline_parse_inst_t cmd_flex_filter = {
10622 .f = cmd_flex_filter_parsed,
10624 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10625 "<value> mask <value> priority <value> queue <queue_id>: "
10626 "Add/Del a flex filter",
10628 (void *)&cmd_flex_filter_filter,
10629 (void *)&cmd_flex_filter_port_id,
10630 (void *)&cmd_flex_filter_ops,
10631 (void *)&cmd_flex_filter_len,
10632 (void *)&cmd_flex_filter_len_value,
10633 (void *)&cmd_flex_filter_bytes,
10634 (void *)&cmd_flex_filter_bytes_value,
10635 (void *)&cmd_flex_filter_mask,
10636 (void *)&cmd_flex_filter_mask_value,
10637 (void *)&cmd_flex_filter_priority,
10638 (void *)&cmd_flex_filter_priority_value,
10639 (void *)&cmd_flex_filter_queue,
10640 (void *)&cmd_flex_filter_queue_id,
10645 /* *** Filters Control *** */
10647 /* *** deal with ethertype filter *** */
10648 struct cmd_ethertype_filter_result {
10649 cmdline_fixed_string_t filter;
10651 cmdline_fixed_string_t ops;
10652 cmdline_fixed_string_t mac;
10653 struct rte_ether_addr mac_addr;
10654 cmdline_fixed_string_t ethertype;
10655 uint16_t ethertype_value;
10656 cmdline_fixed_string_t drop;
10657 cmdline_fixed_string_t queue;
10661 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10662 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10663 filter, "ethertype_filter");
10664 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10665 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10667 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10668 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10670 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10671 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10672 mac, "mac_addr#mac_ignr");
10673 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10674 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10676 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10677 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10678 ethertype, "ethertype");
10679 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10680 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10681 ethertype_value, UINT16);
10682 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10683 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10685 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10686 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10688 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10689 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10693 cmd_ethertype_filter_parsed(void *parsed_result,
10694 __attribute__((unused)) struct cmdline *cl,
10695 __attribute__((unused)) void *data)
10697 struct cmd_ethertype_filter_result *res = parsed_result;
10698 struct rte_eth_ethertype_filter filter;
10701 ret = rte_eth_dev_filter_supported(res->port_id,
10702 RTE_ETH_FILTER_ETHERTYPE);
10704 printf("ethertype filter is not supported on port %u.\n",
10709 memset(&filter, 0, sizeof(filter));
10710 if (!strcmp(res->mac, "mac_addr")) {
10711 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10712 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10713 sizeof(struct rte_ether_addr));
10715 if (!strcmp(res->drop, "drop"))
10716 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10717 filter.ether_type = res->ethertype_value;
10718 filter.queue = res->queue_id;
10720 if (!strcmp(res->ops, "add"))
10721 ret = rte_eth_dev_filter_ctrl(res->port_id,
10722 RTE_ETH_FILTER_ETHERTYPE,
10723 RTE_ETH_FILTER_ADD,
10726 ret = rte_eth_dev_filter_ctrl(res->port_id,
10727 RTE_ETH_FILTER_ETHERTYPE,
10728 RTE_ETH_FILTER_DELETE,
10731 printf("ethertype filter programming error: (%s)\n",
10735 cmdline_parse_inst_t cmd_ethertype_filter = {
10736 .f = cmd_ethertype_filter_parsed,
10738 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10739 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10740 "Add or delete an ethertype filter entry",
10742 (void *)&cmd_ethertype_filter_filter,
10743 (void *)&cmd_ethertype_filter_port_id,
10744 (void *)&cmd_ethertype_filter_ops,
10745 (void *)&cmd_ethertype_filter_mac,
10746 (void *)&cmd_ethertype_filter_mac_addr,
10747 (void *)&cmd_ethertype_filter_ethertype,
10748 (void *)&cmd_ethertype_filter_ethertype_value,
10749 (void *)&cmd_ethertype_filter_drop,
10750 (void *)&cmd_ethertype_filter_queue,
10751 (void *)&cmd_ethertype_filter_queue_id,
10756 /* *** deal with flow director filter *** */
10757 struct cmd_flow_director_result {
10758 cmdline_fixed_string_t flow_director_filter;
10760 cmdline_fixed_string_t mode;
10761 cmdline_fixed_string_t mode_value;
10762 cmdline_fixed_string_t ops;
10763 cmdline_fixed_string_t flow;
10764 cmdline_fixed_string_t flow_type;
10765 cmdline_fixed_string_t ether;
10766 uint16_t ether_type;
10767 cmdline_fixed_string_t src;
10768 cmdline_ipaddr_t ip_src;
10770 cmdline_fixed_string_t dst;
10771 cmdline_ipaddr_t ip_dst;
10773 cmdline_fixed_string_t verify_tag;
10774 uint32_t verify_tag_value;
10775 cmdline_fixed_string_t tos;
10777 cmdline_fixed_string_t proto;
10778 uint8_t proto_value;
10779 cmdline_fixed_string_t ttl;
10781 cmdline_fixed_string_t vlan;
10782 uint16_t vlan_value;
10783 cmdline_fixed_string_t flexbytes;
10784 cmdline_fixed_string_t flexbytes_value;
10785 cmdline_fixed_string_t pf_vf;
10786 cmdline_fixed_string_t drop;
10787 cmdline_fixed_string_t queue;
10789 cmdline_fixed_string_t fd_id;
10790 uint32_t fd_id_value;
10791 cmdline_fixed_string_t mac;
10792 struct rte_ether_addr mac_addr;
10793 cmdline_fixed_string_t tunnel;
10794 cmdline_fixed_string_t tunnel_type;
10795 cmdline_fixed_string_t tunnel_id;
10796 uint32_t tunnel_id_value;
10797 cmdline_fixed_string_t packet;
10802 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10805 const char *p, *p0 = q_arg;
10807 unsigned long int_fld;
10808 char *str_fld[max_num];
10813 p = strchr(p0, '(');
10817 p0 = strchr(p, ')');
10822 if (size >= sizeof(s))
10825 snprintf(s, sizeof(s), "%.*s", size, p);
10826 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10827 if (ret < 0 || ret > max_num)
10829 for (i = 0; i < ret; i++) {
10831 int_fld = strtoul(str_fld[i], &end, 0);
10832 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10834 flexbytes[i] = (uint8_t)int_fld;
10840 str2flowtype(char *string)
10843 static const struct {
10846 } flowtype_str[] = {
10847 {"raw", RTE_ETH_FLOW_RAW},
10848 {"ipv4", RTE_ETH_FLOW_IPV4},
10849 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10850 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10851 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10852 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10853 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10854 {"ipv6", RTE_ETH_FLOW_IPV6},
10855 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10856 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10857 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10858 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10859 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10860 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10863 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10864 if (!strcmp(flowtype_str[i].str, string))
10865 return flowtype_str[i].type;
10868 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10869 return (uint16_t)atoi(string);
10871 return RTE_ETH_FLOW_UNKNOWN;
10874 static enum rte_eth_fdir_tunnel_type
10875 str2fdir_tunneltype(char *string)
10879 static const struct {
10881 enum rte_eth_fdir_tunnel_type type;
10882 } tunneltype_str[] = {
10883 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10884 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10887 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10888 if (!strcmp(tunneltype_str[i].str, string))
10889 return tunneltype_str[i].type;
10891 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10894 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10896 if ((ip_addr).family == AF_INET) \
10897 (ip) = (ip_addr).addr.ipv4.s_addr; \
10899 printf("invalid parameter.\n"); \
10904 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10906 if ((ip_addr).family == AF_INET6) \
10907 rte_memcpy(&(ip), \
10908 &((ip_addr).addr.ipv6), \
10909 sizeof(struct in6_addr)); \
10911 printf("invalid parameter.\n"); \
10917 cmd_flow_director_filter_parsed(void *parsed_result,
10918 __attribute__((unused)) struct cmdline *cl,
10919 __attribute__((unused)) void *data)
10921 struct cmd_flow_director_result *res = parsed_result;
10922 struct rte_eth_fdir_filter entry;
10923 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10925 unsigned long vf_id;
10928 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10930 printf("flow director is not supported on port %u.\n",
10934 memset(flexbytes, 0, sizeof(flexbytes));
10935 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10937 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10938 if (strcmp(res->mode_value, "MAC-VLAN")) {
10939 printf("Please set mode to MAC-VLAN.\n");
10942 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10943 if (strcmp(res->mode_value, "Tunnel")) {
10944 printf("Please set mode to Tunnel.\n");
10948 if (!strcmp(res->mode_value, "raw")) {
10949 #ifdef RTE_LIBRTE_I40E_PMD
10950 struct rte_pmd_i40e_flow_type_mapping
10951 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10952 struct rte_pmd_i40e_pkt_template_conf conf;
10953 uint16_t flow_type = str2flowtype(res->flow_type);
10954 uint16_t i, port = res->port_id;
10957 memset(&conf, 0, sizeof(conf));
10959 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10960 printf("Invalid flow type specified.\n");
10963 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10967 if (mapping[flow_type].pctype == 0ULL) {
10968 printf("Invalid flow type specified.\n");
10971 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10972 if (mapping[flow_type].pctype & (1ULL << i)) {
10973 conf.input.pctype = i;
10978 conf.input.packet = open_file(res->filepath,
10979 &conf.input.length);
10980 if (!conf.input.packet)
10982 if (!strcmp(res->drop, "drop"))
10983 conf.action.behavior =
10984 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10986 conf.action.behavior =
10987 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10988 conf.action.report_status =
10989 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10990 conf.action.rx_queue = res->queue_id;
10991 conf.soft_id = res->fd_id_value;
10992 add = strcmp(res->ops, "del") ? 1 : 0;
10993 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10997 printf("flow director config error: (%s)\n",
10999 close_file(conf.input.packet);
11002 } else if (strcmp(res->mode_value, "IP")) {
11003 printf("Please set mode to IP or raw.\n");
11006 entry.input.flow_type = str2flowtype(res->flow_type);
11009 ret = parse_flexbytes(res->flexbytes_value,
11011 RTE_ETH_FDIR_MAX_FLEXLEN);
11013 printf("error: Cannot parse flexbytes input.\n");
11017 switch (entry.input.flow_type) {
11018 case RTE_ETH_FLOW_FRAG_IPV4:
11019 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11020 entry.input.flow.ip4_flow.proto = res->proto_value;
11022 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11023 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11024 IPV4_ADDR_TO_UINT(res->ip_dst,
11025 entry.input.flow.ip4_flow.dst_ip);
11026 IPV4_ADDR_TO_UINT(res->ip_src,
11027 entry.input.flow.ip4_flow.src_ip);
11028 entry.input.flow.ip4_flow.tos = res->tos_value;
11029 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11030 /* need convert to big endian. */
11031 entry.input.flow.udp4_flow.dst_port =
11032 rte_cpu_to_be_16(res->port_dst);
11033 entry.input.flow.udp4_flow.src_port =
11034 rte_cpu_to_be_16(res->port_src);
11036 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11037 IPV4_ADDR_TO_UINT(res->ip_dst,
11038 entry.input.flow.sctp4_flow.ip.dst_ip);
11039 IPV4_ADDR_TO_UINT(res->ip_src,
11040 entry.input.flow.sctp4_flow.ip.src_ip);
11041 entry.input.flow.ip4_flow.tos = res->tos_value;
11042 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11043 /* need convert to big endian. */
11044 entry.input.flow.sctp4_flow.dst_port =
11045 rte_cpu_to_be_16(res->port_dst);
11046 entry.input.flow.sctp4_flow.src_port =
11047 rte_cpu_to_be_16(res->port_src);
11048 entry.input.flow.sctp4_flow.verify_tag =
11049 rte_cpu_to_be_32(res->verify_tag_value);
11051 case RTE_ETH_FLOW_FRAG_IPV6:
11052 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11053 entry.input.flow.ipv6_flow.proto = res->proto_value;
11055 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11056 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11057 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11058 entry.input.flow.ipv6_flow.dst_ip);
11059 IPV6_ADDR_TO_ARRAY(res->ip_src,
11060 entry.input.flow.ipv6_flow.src_ip);
11061 entry.input.flow.ipv6_flow.tc = res->tos_value;
11062 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11063 /* need convert to big endian. */
11064 entry.input.flow.udp6_flow.dst_port =
11065 rte_cpu_to_be_16(res->port_dst);
11066 entry.input.flow.udp6_flow.src_port =
11067 rte_cpu_to_be_16(res->port_src);
11069 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11070 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11071 entry.input.flow.sctp6_flow.ip.dst_ip);
11072 IPV6_ADDR_TO_ARRAY(res->ip_src,
11073 entry.input.flow.sctp6_flow.ip.src_ip);
11074 entry.input.flow.ipv6_flow.tc = res->tos_value;
11075 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11076 /* need convert to big endian. */
11077 entry.input.flow.sctp6_flow.dst_port =
11078 rte_cpu_to_be_16(res->port_dst);
11079 entry.input.flow.sctp6_flow.src_port =
11080 rte_cpu_to_be_16(res->port_src);
11081 entry.input.flow.sctp6_flow.verify_tag =
11082 rte_cpu_to_be_32(res->verify_tag_value);
11084 case RTE_ETH_FLOW_L2_PAYLOAD:
11085 entry.input.flow.l2_flow.ether_type =
11086 rte_cpu_to_be_16(res->ether_type);
11092 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11093 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11095 sizeof(struct rte_ether_addr));
11097 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11098 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11100 sizeof(struct rte_ether_addr));
11101 entry.input.flow.tunnel_flow.tunnel_type =
11102 str2fdir_tunneltype(res->tunnel_type);
11103 entry.input.flow.tunnel_flow.tunnel_id =
11104 rte_cpu_to_be_32(res->tunnel_id_value);
11107 rte_memcpy(entry.input.flow_ext.flexbytes,
11109 RTE_ETH_FDIR_MAX_FLEXLEN);
11111 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11113 entry.action.flex_off = 0; /*use 0 by default */
11114 if (!strcmp(res->drop, "drop"))
11115 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11117 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11119 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11120 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11121 if (!strcmp(res->pf_vf, "pf"))
11122 entry.input.flow_ext.is_vf = 0;
11123 else if (!strncmp(res->pf_vf, "vf", 2)) {
11124 struct rte_eth_dev_info dev_info;
11126 ret = eth_dev_info_get_print_err(res->port_id,
11132 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11133 if (errno != 0 || *end != '\0' ||
11134 vf_id >= dev_info.max_vfs) {
11135 printf("invalid parameter %s.\n", res->pf_vf);
11138 entry.input.flow_ext.is_vf = 1;
11139 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11141 printf("invalid parameter %s.\n", res->pf_vf);
11146 /* set to report FD ID by default */
11147 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11148 entry.action.rx_queue = res->queue_id;
11149 entry.soft_id = res->fd_id_value;
11150 if (!strcmp(res->ops, "add"))
11151 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11152 RTE_ETH_FILTER_ADD, &entry);
11153 else if (!strcmp(res->ops, "del"))
11154 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11155 RTE_ETH_FILTER_DELETE, &entry);
11157 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11158 RTE_ETH_FILTER_UPDATE, &entry);
11160 printf("flow director programming error: (%s)\n",
11164 cmdline_parse_token_string_t cmd_flow_director_filter =
11165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11166 flow_director_filter, "flow_director_filter");
11167 cmdline_parse_token_num_t cmd_flow_director_port_id =
11168 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11170 cmdline_parse_token_string_t cmd_flow_director_ops =
11171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11172 ops, "add#del#update");
11173 cmdline_parse_token_string_t cmd_flow_director_flow =
11174 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11176 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11179 cmdline_parse_token_string_t cmd_flow_director_ether =
11180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11182 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11183 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11184 ether_type, UINT16);
11185 cmdline_parse_token_string_t cmd_flow_director_src =
11186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11188 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11189 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11191 cmdline_parse_token_num_t cmd_flow_director_port_src =
11192 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11194 cmdline_parse_token_string_t cmd_flow_director_dst =
11195 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11197 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11198 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11200 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11201 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11203 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11204 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11205 verify_tag, "verify_tag");
11206 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11207 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11208 verify_tag_value, UINT32);
11209 cmdline_parse_token_string_t cmd_flow_director_tos =
11210 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11212 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11213 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11215 cmdline_parse_token_string_t cmd_flow_director_proto =
11216 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11218 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11219 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11220 proto_value, UINT8);
11221 cmdline_parse_token_string_t cmd_flow_director_ttl =
11222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11224 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11225 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11227 cmdline_parse_token_string_t cmd_flow_director_vlan =
11228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11230 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11231 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11232 vlan_value, UINT16);
11233 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11235 flexbytes, "flexbytes");
11236 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11238 flexbytes_value, NULL);
11239 cmdline_parse_token_string_t cmd_flow_director_drop =
11240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11242 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11245 cmdline_parse_token_string_t cmd_flow_director_queue =
11246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11248 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11251 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11254 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11256 fd_id_value, UINT32);
11258 cmdline_parse_token_string_t cmd_flow_director_mode =
11259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11261 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11264 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11266 mode_value, "MAC-VLAN");
11267 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11269 mode_value, "Tunnel");
11270 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11272 mode_value, "raw");
11273 cmdline_parse_token_string_t cmd_flow_director_mac =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11276 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11277 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11279 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11282 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11284 tunnel_type, "NVGRE#VxLAN");
11285 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11287 tunnel_id, "tunnel-id");
11288 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11290 tunnel_id_value, UINT32);
11291 cmdline_parse_token_string_t cmd_flow_director_packet =
11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11294 cmdline_parse_token_string_t cmd_flow_director_filepath =
11295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11298 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11299 .f = cmd_flow_director_filter_parsed,
11301 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11302 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11303 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11304 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11305 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11306 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11307 "fd_id <fd_id_value>: "
11308 "Add or delete an ip flow director entry on NIC",
11310 (void *)&cmd_flow_director_filter,
11311 (void *)&cmd_flow_director_port_id,
11312 (void *)&cmd_flow_director_mode,
11313 (void *)&cmd_flow_director_mode_ip,
11314 (void *)&cmd_flow_director_ops,
11315 (void *)&cmd_flow_director_flow,
11316 (void *)&cmd_flow_director_flow_type,
11317 (void *)&cmd_flow_director_src,
11318 (void *)&cmd_flow_director_ip_src,
11319 (void *)&cmd_flow_director_dst,
11320 (void *)&cmd_flow_director_ip_dst,
11321 (void *)&cmd_flow_director_tos,
11322 (void *)&cmd_flow_director_tos_value,
11323 (void *)&cmd_flow_director_proto,
11324 (void *)&cmd_flow_director_proto_value,
11325 (void *)&cmd_flow_director_ttl,
11326 (void *)&cmd_flow_director_ttl_value,
11327 (void *)&cmd_flow_director_vlan,
11328 (void *)&cmd_flow_director_vlan_value,
11329 (void *)&cmd_flow_director_flexbytes,
11330 (void *)&cmd_flow_director_flexbytes_value,
11331 (void *)&cmd_flow_director_drop,
11332 (void *)&cmd_flow_director_pf_vf,
11333 (void *)&cmd_flow_director_queue,
11334 (void *)&cmd_flow_director_queue_id,
11335 (void *)&cmd_flow_director_fd_id,
11336 (void *)&cmd_flow_director_fd_id_value,
11341 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11342 .f = cmd_flow_director_filter_parsed,
11344 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11345 "director entry on NIC",
11347 (void *)&cmd_flow_director_filter,
11348 (void *)&cmd_flow_director_port_id,
11349 (void *)&cmd_flow_director_mode,
11350 (void *)&cmd_flow_director_mode_ip,
11351 (void *)&cmd_flow_director_ops,
11352 (void *)&cmd_flow_director_flow,
11353 (void *)&cmd_flow_director_flow_type,
11354 (void *)&cmd_flow_director_src,
11355 (void *)&cmd_flow_director_ip_src,
11356 (void *)&cmd_flow_director_port_src,
11357 (void *)&cmd_flow_director_dst,
11358 (void *)&cmd_flow_director_ip_dst,
11359 (void *)&cmd_flow_director_port_dst,
11360 (void *)&cmd_flow_director_tos,
11361 (void *)&cmd_flow_director_tos_value,
11362 (void *)&cmd_flow_director_ttl,
11363 (void *)&cmd_flow_director_ttl_value,
11364 (void *)&cmd_flow_director_vlan,
11365 (void *)&cmd_flow_director_vlan_value,
11366 (void *)&cmd_flow_director_flexbytes,
11367 (void *)&cmd_flow_director_flexbytes_value,
11368 (void *)&cmd_flow_director_drop,
11369 (void *)&cmd_flow_director_pf_vf,
11370 (void *)&cmd_flow_director_queue,
11371 (void *)&cmd_flow_director_queue_id,
11372 (void *)&cmd_flow_director_fd_id,
11373 (void *)&cmd_flow_director_fd_id_value,
11378 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11379 .f = cmd_flow_director_filter_parsed,
11381 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11382 "director entry on NIC",
11384 (void *)&cmd_flow_director_filter,
11385 (void *)&cmd_flow_director_port_id,
11386 (void *)&cmd_flow_director_mode,
11387 (void *)&cmd_flow_director_mode_ip,
11388 (void *)&cmd_flow_director_ops,
11389 (void *)&cmd_flow_director_flow,
11390 (void *)&cmd_flow_director_flow_type,
11391 (void *)&cmd_flow_director_src,
11392 (void *)&cmd_flow_director_ip_src,
11393 (void *)&cmd_flow_director_port_src,
11394 (void *)&cmd_flow_director_dst,
11395 (void *)&cmd_flow_director_ip_dst,
11396 (void *)&cmd_flow_director_port_dst,
11397 (void *)&cmd_flow_director_verify_tag,
11398 (void *)&cmd_flow_director_verify_tag_value,
11399 (void *)&cmd_flow_director_tos,
11400 (void *)&cmd_flow_director_tos_value,
11401 (void *)&cmd_flow_director_ttl,
11402 (void *)&cmd_flow_director_ttl_value,
11403 (void *)&cmd_flow_director_vlan,
11404 (void *)&cmd_flow_director_vlan_value,
11405 (void *)&cmd_flow_director_flexbytes,
11406 (void *)&cmd_flow_director_flexbytes_value,
11407 (void *)&cmd_flow_director_drop,
11408 (void *)&cmd_flow_director_pf_vf,
11409 (void *)&cmd_flow_director_queue,
11410 (void *)&cmd_flow_director_queue_id,
11411 (void *)&cmd_flow_director_fd_id,
11412 (void *)&cmd_flow_director_fd_id_value,
11417 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11418 .f = cmd_flow_director_filter_parsed,
11420 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11421 "director entry on NIC",
11423 (void *)&cmd_flow_director_filter,
11424 (void *)&cmd_flow_director_port_id,
11425 (void *)&cmd_flow_director_mode,
11426 (void *)&cmd_flow_director_mode_ip,
11427 (void *)&cmd_flow_director_ops,
11428 (void *)&cmd_flow_director_flow,
11429 (void *)&cmd_flow_director_flow_type,
11430 (void *)&cmd_flow_director_ether,
11431 (void *)&cmd_flow_director_ether_type,
11432 (void *)&cmd_flow_director_flexbytes,
11433 (void *)&cmd_flow_director_flexbytes_value,
11434 (void *)&cmd_flow_director_drop,
11435 (void *)&cmd_flow_director_pf_vf,
11436 (void *)&cmd_flow_director_queue,
11437 (void *)&cmd_flow_director_queue_id,
11438 (void *)&cmd_flow_director_fd_id,
11439 (void *)&cmd_flow_director_fd_id_value,
11444 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11445 .f = cmd_flow_director_filter_parsed,
11447 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11448 "director entry on NIC",
11450 (void *)&cmd_flow_director_filter,
11451 (void *)&cmd_flow_director_port_id,
11452 (void *)&cmd_flow_director_mode,
11453 (void *)&cmd_flow_director_mode_mac_vlan,
11454 (void *)&cmd_flow_director_ops,
11455 (void *)&cmd_flow_director_mac,
11456 (void *)&cmd_flow_director_mac_addr,
11457 (void *)&cmd_flow_director_vlan,
11458 (void *)&cmd_flow_director_vlan_value,
11459 (void *)&cmd_flow_director_flexbytes,
11460 (void *)&cmd_flow_director_flexbytes_value,
11461 (void *)&cmd_flow_director_drop,
11462 (void *)&cmd_flow_director_queue,
11463 (void *)&cmd_flow_director_queue_id,
11464 (void *)&cmd_flow_director_fd_id,
11465 (void *)&cmd_flow_director_fd_id_value,
11470 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11471 .f = cmd_flow_director_filter_parsed,
11473 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11474 "director entry on NIC",
11476 (void *)&cmd_flow_director_filter,
11477 (void *)&cmd_flow_director_port_id,
11478 (void *)&cmd_flow_director_mode,
11479 (void *)&cmd_flow_director_mode_tunnel,
11480 (void *)&cmd_flow_director_ops,
11481 (void *)&cmd_flow_director_mac,
11482 (void *)&cmd_flow_director_mac_addr,
11483 (void *)&cmd_flow_director_vlan,
11484 (void *)&cmd_flow_director_vlan_value,
11485 (void *)&cmd_flow_director_tunnel,
11486 (void *)&cmd_flow_director_tunnel_type,
11487 (void *)&cmd_flow_director_tunnel_id,
11488 (void *)&cmd_flow_director_tunnel_id_value,
11489 (void *)&cmd_flow_director_flexbytes,
11490 (void *)&cmd_flow_director_flexbytes_value,
11491 (void *)&cmd_flow_director_drop,
11492 (void *)&cmd_flow_director_queue,
11493 (void *)&cmd_flow_director_queue_id,
11494 (void *)&cmd_flow_director_fd_id,
11495 (void *)&cmd_flow_director_fd_id_value,
11500 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11501 .f = cmd_flow_director_filter_parsed,
11503 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11504 "director entry on NIC",
11506 (void *)&cmd_flow_director_filter,
11507 (void *)&cmd_flow_director_port_id,
11508 (void *)&cmd_flow_director_mode,
11509 (void *)&cmd_flow_director_mode_raw,
11510 (void *)&cmd_flow_director_ops,
11511 (void *)&cmd_flow_director_flow,
11512 (void *)&cmd_flow_director_flow_type,
11513 (void *)&cmd_flow_director_drop,
11514 (void *)&cmd_flow_director_queue,
11515 (void *)&cmd_flow_director_queue_id,
11516 (void *)&cmd_flow_director_fd_id,
11517 (void *)&cmd_flow_director_fd_id_value,
11518 (void *)&cmd_flow_director_packet,
11519 (void *)&cmd_flow_director_filepath,
11524 struct cmd_flush_flow_director_result {
11525 cmdline_fixed_string_t flush_flow_director;
11529 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11530 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11531 flush_flow_director, "flush_flow_director");
11532 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11533 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11537 cmd_flush_flow_director_parsed(void *parsed_result,
11538 __attribute__((unused)) struct cmdline *cl,
11539 __attribute__((unused)) void *data)
11541 struct cmd_flow_director_result *res = parsed_result;
11544 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11546 printf("flow director is not supported on port %u.\n",
11551 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11552 RTE_ETH_FILTER_FLUSH, NULL);
11554 printf("flow director table flushing error: (%s)\n",
11558 cmdline_parse_inst_t cmd_flush_flow_director = {
11559 .f = cmd_flush_flow_director_parsed,
11561 .help_str = "flush_flow_director <port_id>: "
11562 "Flush all flow director entries of a device on NIC",
11564 (void *)&cmd_flush_flow_director_flush,
11565 (void *)&cmd_flush_flow_director_port_id,
11570 /* *** deal with flow director mask *** */
11571 struct cmd_flow_director_mask_result {
11572 cmdline_fixed_string_t flow_director_mask;
11574 cmdline_fixed_string_t mode;
11575 cmdline_fixed_string_t mode_value;
11576 cmdline_fixed_string_t vlan;
11577 uint16_t vlan_mask;
11578 cmdline_fixed_string_t src_mask;
11579 cmdline_ipaddr_t ipv4_src;
11580 cmdline_ipaddr_t ipv6_src;
11582 cmdline_fixed_string_t dst_mask;
11583 cmdline_ipaddr_t ipv4_dst;
11584 cmdline_ipaddr_t ipv6_dst;
11586 cmdline_fixed_string_t mac;
11587 uint8_t mac_addr_byte_mask;
11588 cmdline_fixed_string_t tunnel_id;
11589 uint32_t tunnel_id_mask;
11590 cmdline_fixed_string_t tunnel_type;
11591 uint8_t tunnel_type_mask;
11595 cmd_flow_director_mask_parsed(void *parsed_result,
11596 __attribute__((unused)) struct cmdline *cl,
11597 __attribute__((unused)) void *data)
11599 struct cmd_flow_director_mask_result *res = parsed_result;
11600 struct rte_eth_fdir_masks *mask;
11601 struct rte_port *port;
11603 port = &ports[res->port_id];
11604 /** Check if the port is not started **/
11605 if (port->port_status != RTE_PORT_STOPPED) {
11606 printf("Please stop port %d first\n", res->port_id);
11610 mask = &port->dev_conf.fdir_conf.mask;
11612 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11613 if (strcmp(res->mode_value, "MAC-VLAN")) {
11614 printf("Please set mode to MAC-VLAN.\n");
11618 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11619 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11620 if (strcmp(res->mode_value, "Tunnel")) {
11621 printf("Please set mode to Tunnel.\n");
11625 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11626 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11627 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11628 mask->tunnel_type_mask = res->tunnel_type_mask;
11630 if (strcmp(res->mode_value, "IP")) {
11631 printf("Please set mode to IP.\n");
11635 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11636 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11637 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11638 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11639 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11640 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11641 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11644 cmd_reconfig_device_queue(res->port_id, 1, 1);
11647 cmdline_parse_token_string_t cmd_flow_director_mask =
11648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11649 flow_director_mask, "flow_director_mask");
11650 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11651 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11653 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11656 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11657 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11658 vlan_mask, UINT16);
11659 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11661 src_mask, "src_mask");
11662 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11663 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11665 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11666 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11668 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11669 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11671 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11673 dst_mask, "dst_mask");
11674 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11675 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11677 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11678 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11680 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11681 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11684 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11687 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11690 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11692 mode_value, "MAC-VLAN");
11693 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11695 mode_value, "Tunnel");
11696 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11697 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11699 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11700 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11701 mac_addr_byte_mask, UINT8);
11702 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11703 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11704 tunnel_type, "tunnel-type");
11705 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11706 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11707 tunnel_type_mask, UINT8);
11708 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11709 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11710 tunnel_id, "tunnel-id");
11711 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11712 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11713 tunnel_id_mask, UINT32);
11715 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11716 .f = cmd_flow_director_mask_parsed,
11718 .help_str = "flow_director_mask ... : "
11719 "Set IP mode flow director's mask on NIC",
11721 (void *)&cmd_flow_director_mask,
11722 (void *)&cmd_flow_director_mask_port_id,
11723 (void *)&cmd_flow_director_mask_mode,
11724 (void *)&cmd_flow_director_mask_mode_ip,
11725 (void *)&cmd_flow_director_mask_vlan,
11726 (void *)&cmd_flow_director_mask_vlan_value,
11727 (void *)&cmd_flow_director_mask_src,
11728 (void *)&cmd_flow_director_mask_ipv4_src,
11729 (void *)&cmd_flow_director_mask_ipv6_src,
11730 (void *)&cmd_flow_director_mask_port_src,
11731 (void *)&cmd_flow_director_mask_dst,
11732 (void *)&cmd_flow_director_mask_ipv4_dst,
11733 (void *)&cmd_flow_director_mask_ipv6_dst,
11734 (void *)&cmd_flow_director_mask_port_dst,
11739 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11740 .f = cmd_flow_director_mask_parsed,
11742 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11743 "flow director's mask on NIC",
11745 (void *)&cmd_flow_director_mask,
11746 (void *)&cmd_flow_director_mask_port_id,
11747 (void *)&cmd_flow_director_mask_mode,
11748 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11749 (void *)&cmd_flow_director_mask_vlan,
11750 (void *)&cmd_flow_director_mask_vlan_value,
11755 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11756 .f = cmd_flow_director_mask_parsed,
11758 .help_str = "flow_director_mask ... : Set tunnel mode "
11759 "flow director's mask on NIC",
11761 (void *)&cmd_flow_director_mask,
11762 (void *)&cmd_flow_director_mask_port_id,
11763 (void *)&cmd_flow_director_mask_mode,
11764 (void *)&cmd_flow_director_mask_mode_tunnel,
11765 (void *)&cmd_flow_director_mask_vlan,
11766 (void *)&cmd_flow_director_mask_vlan_value,
11767 (void *)&cmd_flow_director_mask_mac,
11768 (void *)&cmd_flow_director_mask_mac_value,
11769 (void *)&cmd_flow_director_mask_tunnel_type,
11770 (void *)&cmd_flow_director_mask_tunnel_type_value,
11771 (void *)&cmd_flow_director_mask_tunnel_id,
11772 (void *)&cmd_flow_director_mask_tunnel_id_value,
11777 /* *** deal with flow director mask on flexible payload *** */
11778 struct cmd_flow_director_flex_mask_result {
11779 cmdline_fixed_string_t flow_director_flexmask;
11781 cmdline_fixed_string_t flow;
11782 cmdline_fixed_string_t flow_type;
11783 cmdline_fixed_string_t mask;
11787 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11788 __attribute__((unused)) struct cmdline *cl,
11789 __attribute__((unused)) void *data)
11791 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11792 struct rte_eth_fdir_info fdir_info;
11793 struct rte_eth_fdir_flex_mask flex_mask;
11794 struct rte_port *port;
11795 uint64_t flow_type_mask;
11799 port = &ports[res->port_id];
11800 /** Check if the port is not started **/
11801 if (port->port_status != RTE_PORT_STOPPED) {
11802 printf("Please stop port %d first\n", res->port_id);
11806 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11807 ret = parse_flexbytes(res->mask,
11809 RTE_ETH_FDIR_MAX_FLEXLEN);
11811 printf("error: Cannot parse mask input.\n");
11815 memset(&fdir_info, 0, sizeof(fdir_info));
11816 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11817 RTE_ETH_FILTER_INFO, &fdir_info);
11819 printf("Cannot get FDir filter info\n");
11823 if (!strcmp(res->flow_type, "none")) {
11824 /* means don't specify the flow type */
11825 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11826 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11827 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11828 0, sizeof(struct rte_eth_fdir_flex_mask));
11829 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11830 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11832 sizeof(struct rte_eth_fdir_flex_mask));
11833 cmd_reconfig_device_queue(res->port_id, 1, 1);
11836 flow_type_mask = fdir_info.flow_types_mask[0];
11837 if (!strcmp(res->flow_type, "all")) {
11838 if (!flow_type_mask) {
11839 printf("No flow type supported\n");
11842 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11843 if (flow_type_mask & (1ULL << i)) {
11844 flex_mask.flow_type = i;
11845 fdir_set_flex_mask(res->port_id, &flex_mask);
11848 cmd_reconfig_device_queue(res->port_id, 1, 1);
11851 flex_mask.flow_type = str2flowtype(res->flow_type);
11852 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11853 printf("Flow type %s not supported on port %d\n",
11854 res->flow_type, res->port_id);
11857 fdir_set_flex_mask(res->port_id, &flex_mask);
11858 cmd_reconfig_device_queue(res->port_id, 1, 1);
11861 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11863 flow_director_flexmask,
11864 "flow_director_flex_mask");
11865 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11866 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11868 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11871 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11873 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11874 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11875 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11879 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11880 .f = cmd_flow_director_flex_mask_parsed,
11882 .help_str = "flow_director_flex_mask ... : "
11883 "Set flow director's flex mask on NIC",
11885 (void *)&cmd_flow_director_flexmask,
11886 (void *)&cmd_flow_director_flexmask_port_id,
11887 (void *)&cmd_flow_director_flexmask_flow,
11888 (void *)&cmd_flow_director_flexmask_flow_type,
11889 (void *)&cmd_flow_director_flexmask_mask,
11894 /* *** deal with flow director flexible payload configuration *** */
11895 struct cmd_flow_director_flexpayload_result {
11896 cmdline_fixed_string_t flow_director_flexpayload;
11898 cmdline_fixed_string_t payload_layer;
11899 cmdline_fixed_string_t payload_cfg;
11903 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11906 const char *p, *p0 = q_arg;
11908 unsigned long int_fld;
11909 char *str_fld[max_num];
11914 p = strchr(p0, '(');
11918 p0 = strchr(p, ')');
11923 if (size >= sizeof(s))
11926 snprintf(s, sizeof(s), "%.*s", size, p);
11927 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11928 if (ret < 0 || ret > max_num)
11930 for (i = 0; i < ret; i++) {
11932 int_fld = strtoul(str_fld[i], &end, 0);
11933 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11935 offsets[i] = (uint16_t)int_fld;
11941 cmd_flow_director_flxpld_parsed(void *parsed_result,
11942 __attribute__((unused)) struct cmdline *cl,
11943 __attribute__((unused)) void *data)
11945 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11946 struct rte_eth_flex_payload_cfg flex_cfg;
11947 struct rte_port *port;
11950 port = &ports[res->port_id];
11951 /** Check if the port is not started **/
11952 if (port->port_status != RTE_PORT_STOPPED) {
11953 printf("Please stop port %d first\n", res->port_id);
11957 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11959 if (!strcmp(res->payload_layer, "raw"))
11960 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11961 else if (!strcmp(res->payload_layer, "l2"))
11962 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11963 else if (!strcmp(res->payload_layer, "l3"))
11964 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11965 else if (!strcmp(res->payload_layer, "l4"))
11966 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11968 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11969 RTE_ETH_FDIR_MAX_FLEXLEN);
11971 printf("error: Cannot parse flex payload input.\n");
11975 fdir_set_flex_payload(res->port_id, &flex_cfg);
11976 cmd_reconfig_device_queue(res->port_id, 1, 1);
11979 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11981 flow_director_flexpayload,
11982 "flow_director_flex_payload");
11983 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11984 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11986 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11987 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11988 payload_layer, "raw#l2#l3#l4");
11989 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11990 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11991 payload_cfg, NULL);
11993 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11994 .f = cmd_flow_director_flxpld_parsed,
11996 .help_str = "flow_director_flexpayload ... : "
11997 "Set flow director's flex payload on NIC",
11999 (void *)&cmd_flow_director_flexpayload,
12000 (void *)&cmd_flow_director_flexpayload_port_id,
12001 (void *)&cmd_flow_director_flexpayload_payload_layer,
12002 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12007 /* Generic flow interface command. */
12008 extern cmdline_parse_inst_t cmd_flow;
12010 /* *** Classification Filters Control *** */
12011 /* *** Get symmetric hash enable per port *** */
12012 struct cmd_get_sym_hash_ena_per_port_result {
12013 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12018 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12019 __rte_unused struct cmdline *cl,
12020 __rte_unused void *data)
12022 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12023 struct rte_eth_hash_filter_info info;
12026 if (rte_eth_dev_filter_supported(res->port_id,
12027 RTE_ETH_FILTER_HASH) < 0) {
12028 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12033 memset(&info, 0, sizeof(info));
12034 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12035 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12036 RTE_ETH_FILTER_GET, &info);
12039 printf("Cannot get symmetric hash enable per port "
12040 "on port %u\n", res->port_id);
12044 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12045 "enabled" : "disabled", res->port_id);
12048 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12049 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12050 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12051 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12052 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12055 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12056 .f = cmd_get_sym_hash_per_port_parsed,
12058 .help_str = "get_sym_hash_ena_per_port <port_id>",
12060 (void *)&cmd_get_sym_hash_ena_per_port_all,
12061 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12066 /* *** Set symmetric hash enable per port *** */
12067 struct cmd_set_sym_hash_ena_per_port_result {
12068 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12069 cmdline_fixed_string_t enable;
12074 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12075 __rte_unused struct cmdline *cl,
12076 __rte_unused void *data)
12078 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12079 struct rte_eth_hash_filter_info info;
12082 if (rte_eth_dev_filter_supported(res->port_id,
12083 RTE_ETH_FILTER_HASH) < 0) {
12084 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12089 memset(&info, 0, sizeof(info));
12090 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12091 if (!strcmp(res->enable, "enable"))
12092 info.info.enable = 1;
12093 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12094 RTE_ETH_FILTER_SET, &info);
12096 printf("Cannot set symmetric hash enable per port on "
12097 "port %u\n", res->port_id);
12100 printf("Symmetric hash has been set to %s on port %u\n",
12101 res->enable, res->port_id);
12104 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12105 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12106 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12107 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12108 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12110 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12111 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12112 enable, "enable#disable");
12114 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12115 .f = cmd_set_sym_hash_per_port_parsed,
12117 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12119 (void *)&cmd_set_sym_hash_ena_per_port_all,
12120 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12121 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12126 /* Get global config of hash function */
12127 struct cmd_get_hash_global_config_result {
12128 cmdline_fixed_string_t get_hash_global_config;
12133 flowtype_to_str(uint16_t ftype)
12139 } ftype_table[] = {
12140 {"ipv4", RTE_ETH_FLOW_IPV4},
12141 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12142 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12143 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12144 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12145 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12146 {"ipv6", RTE_ETH_FLOW_IPV6},
12147 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12148 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12149 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12150 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12151 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12152 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12153 {"port", RTE_ETH_FLOW_PORT},
12154 {"vxlan", RTE_ETH_FLOW_VXLAN},
12155 {"geneve", RTE_ETH_FLOW_GENEVE},
12156 {"nvgre", RTE_ETH_FLOW_NVGRE},
12157 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12160 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12161 if (ftype_table[i].ftype == ftype)
12162 return ftype_table[i].str;
12169 cmd_get_hash_global_config_parsed(void *parsed_result,
12170 __rte_unused struct cmdline *cl,
12171 __rte_unused void *data)
12173 struct cmd_get_hash_global_config_result *res = parsed_result;
12174 struct rte_eth_hash_filter_info info;
12175 uint32_t idx, offset;
12180 if (rte_eth_dev_filter_supported(res->port_id,
12181 RTE_ETH_FILTER_HASH) < 0) {
12182 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12187 memset(&info, 0, sizeof(info));
12188 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12189 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12190 RTE_ETH_FILTER_GET, &info);
12192 printf("Cannot get hash global configurations by port %d\n",
12197 switch (info.info.global_conf.hash_func) {
12198 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12199 printf("Hash function is Toeplitz\n");
12201 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12202 printf("Hash function is Simple XOR\n");
12204 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12205 printf("Hash function is Symmetric Toeplitz\n");
12208 printf("Unknown hash function\n");
12212 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12213 idx = i / UINT64_BIT;
12214 offset = i % UINT64_BIT;
12215 if (!(info.info.global_conf.valid_bit_mask[idx] &
12218 str = flowtype_to_str(i);
12221 printf("Symmetric hash is %s globally for flow type %s "
12223 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12224 (1ULL << offset)) ? "enabled" : "disabled"), str,
12229 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12230 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12231 get_hash_global_config, "get_hash_global_config");
12232 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12233 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12236 cmdline_parse_inst_t cmd_get_hash_global_config = {
12237 .f = cmd_get_hash_global_config_parsed,
12239 .help_str = "get_hash_global_config <port_id>",
12241 (void *)&cmd_get_hash_global_config_all,
12242 (void *)&cmd_get_hash_global_config_port_id,
12247 /* Set global config of hash function */
12248 struct cmd_set_hash_global_config_result {
12249 cmdline_fixed_string_t set_hash_global_config;
12251 cmdline_fixed_string_t hash_func;
12252 cmdline_fixed_string_t flow_type;
12253 cmdline_fixed_string_t enable;
12257 cmd_set_hash_global_config_parsed(void *parsed_result,
12258 __rte_unused struct cmdline *cl,
12259 __rte_unused void *data)
12261 struct cmd_set_hash_global_config_result *res = parsed_result;
12262 struct rte_eth_hash_filter_info info;
12263 uint32_t ftype, idx, offset;
12266 if (rte_eth_dev_filter_supported(res->port_id,
12267 RTE_ETH_FILTER_HASH) < 0) {
12268 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12272 memset(&info, 0, sizeof(info));
12273 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12274 if (!strcmp(res->hash_func, "toeplitz"))
12275 info.info.global_conf.hash_func =
12276 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12277 else if (!strcmp(res->hash_func, "simple_xor"))
12278 info.info.global_conf.hash_func =
12279 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12280 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12281 info.info.global_conf.hash_func =
12282 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12283 else if (!strcmp(res->hash_func, "default"))
12284 info.info.global_conf.hash_func =
12285 RTE_ETH_HASH_FUNCTION_DEFAULT;
12287 ftype = str2flowtype(res->flow_type);
12288 idx = ftype / UINT64_BIT;
12289 offset = ftype % UINT64_BIT;
12290 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12291 if (!strcmp(res->enable, "enable"))
12292 info.info.global_conf.sym_hash_enable_mask[idx] |=
12294 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12295 RTE_ETH_FILTER_SET, &info);
12297 printf("Cannot set global hash configurations by port %d\n",
12300 printf("Global hash configurations have been set "
12301 "successfully by port %d\n", res->port_id);
12304 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12305 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12306 set_hash_global_config, "set_hash_global_config");
12307 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12308 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12310 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12311 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12312 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12313 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12314 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12316 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12317 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12318 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12319 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12320 enable, "enable#disable");
12322 cmdline_parse_inst_t cmd_set_hash_global_config = {
12323 .f = cmd_set_hash_global_config_parsed,
12325 .help_str = "set_hash_global_config <port_id> "
12326 "toeplitz|simple_xor|symmetric_toeplitz|default "
12327 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12328 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12329 "l2_payload enable|disable",
12331 (void *)&cmd_set_hash_global_config_all,
12332 (void *)&cmd_set_hash_global_config_port_id,
12333 (void *)&cmd_set_hash_global_config_hash_func,
12334 (void *)&cmd_set_hash_global_config_flow_type,
12335 (void *)&cmd_set_hash_global_config_enable,
12340 /* Set hash input set */
12341 struct cmd_set_hash_input_set_result {
12342 cmdline_fixed_string_t set_hash_input_set;
12344 cmdline_fixed_string_t flow_type;
12345 cmdline_fixed_string_t inset_field;
12346 cmdline_fixed_string_t select;
12349 static enum rte_eth_input_set_field
12350 str2inset(char *string)
12354 static const struct {
12356 enum rte_eth_input_set_field inset;
12357 } inset_table[] = {
12358 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12359 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12360 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12361 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12362 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12363 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12364 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12365 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12366 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12367 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12368 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12369 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12370 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12371 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12372 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12373 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12374 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12375 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12376 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12377 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12378 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12379 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12380 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12381 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12382 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12383 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12384 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12385 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12386 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12387 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12388 {"none", RTE_ETH_INPUT_SET_NONE},
12391 for (i = 0; i < RTE_DIM(inset_table); i++) {
12392 if (!strcmp(string, inset_table[i].str))
12393 return inset_table[i].inset;
12396 return RTE_ETH_INPUT_SET_UNKNOWN;
12400 cmd_set_hash_input_set_parsed(void *parsed_result,
12401 __rte_unused struct cmdline *cl,
12402 __rte_unused void *data)
12404 struct cmd_set_hash_input_set_result *res = parsed_result;
12405 struct rte_eth_hash_filter_info info;
12407 memset(&info, 0, sizeof(info));
12408 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12409 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12410 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12411 info.info.input_set_conf.inset_size = 1;
12412 if (!strcmp(res->select, "select"))
12413 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12414 else if (!strcmp(res->select, "add"))
12415 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12416 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12417 RTE_ETH_FILTER_SET, &info);
12420 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12421 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12422 set_hash_input_set, "set_hash_input_set");
12423 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12424 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12426 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12427 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12429 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12430 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12432 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12433 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12434 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12435 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12436 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12438 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12439 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12440 select, "select#add");
12442 cmdline_parse_inst_t cmd_set_hash_input_set = {
12443 .f = cmd_set_hash_input_set_parsed,
12445 .help_str = "set_hash_input_set <port_id> "
12446 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12447 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12448 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12449 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12450 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12451 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12452 "fld-7th|fld-8th|none select|add",
12454 (void *)&cmd_set_hash_input_set_cmd,
12455 (void *)&cmd_set_hash_input_set_port_id,
12456 (void *)&cmd_set_hash_input_set_flow_type,
12457 (void *)&cmd_set_hash_input_set_field,
12458 (void *)&cmd_set_hash_input_set_select,
12463 /* Set flow director input set */
12464 struct cmd_set_fdir_input_set_result {
12465 cmdline_fixed_string_t set_fdir_input_set;
12467 cmdline_fixed_string_t flow_type;
12468 cmdline_fixed_string_t inset_field;
12469 cmdline_fixed_string_t select;
12473 cmd_set_fdir_input_set_parsed(void *parsed_result,
12474 __rte_unused struct cmdline *cl,
12475 __rte_unused void *data)
12477 struct cmd_set_fdir_input_set_result *res = parsed_result;
12478 struct rte_eth_fdir_filter_info info;
12480 memset(&info, 0, sizeof(info));
12481 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12482 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12483 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12484 info.info.input_set_conf.inset_size = 1;
12485 if (!strcmp(res->select, "select"))
12486 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12487 else if (!strcmp(res->select, "add"))
12488 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12489 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12490 RTE_ETH_FILTER_SET, &info);
12493 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12494 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12495 set_fdir_input_set, "set_fdir_input_set");
12496 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12497 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12499 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12500 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12502 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12503 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12504 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12505 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12507 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12508 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12509 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12510 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12511 "sctp-veri-tag#none");
12512 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12513 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12514 select, "select#add");
12516 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12517 .f = cmd_set_fdir_input_set_parsed,
12519 .help_str = "set_fdir_input_set <port_id> "
12520 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12521 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12522 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12523 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12524 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12525 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12526 "sctp-veri-tag|none select|add",
12528 (void *)&cmd_set_fdir_input_set_cmd,
12529 (void *)&cmd_set_fdir_input_set_port_id,
12530 (void *)&cmd_set_fdir_input_set_flow_type,
12531 (void *)&cmd_set_fdir_input_set_field,
12532 (void *)&cmd_set_fdir_input_set_select,
12537 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12538 struct cmd_mcast_addr_result {
12539 cmdline_fixed_string_t mcast_addr_cmd;
12540 cmdline_fixed_string_t what;
12542 struct rte_ether_addr mc_addr;
12545 static void cmd_mcast_addr_parsed(void *parsed_result,
12546 __attribute__((unused)) struct cmdline *cl,
12547 __attribute__((unused)) void *data)
12549 struct cmd_mcast_addr_result *res = parsed_result;
12551 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12552 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12553 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12554 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12555 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12558 if (strcmp(res->what, "add") == 0)
12559 mcast_addr_add(res->port_num, &res->mc_addr);
12561 mcast_addr_remove(res->port_num, &res->mc_addr);
12564 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12565 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12566 mcast_addr_cmd, "mcast_addr");
12567 cmdline_parse_token_string_t cmd_mcast_addr_what =
12568 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12570 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12571 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12572 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12573 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12575 cmdline_parse_inst_t cmd_mcast_addr = {
12576 .f = cmd_mcast_addr_parsed,
12578 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12579 "Add/Remove multicast MAC address on port_id",
12581 (void *)&cmd_mcast_addr_cmd,
12582 (void *)&cmd_mcast_addr_what,
12583 (void *)&cmd_mcast_addr_portnum,
12584 (void *)&cmd_mcast_addr_addr,
12589 /* l2 tunnel config
12590 * only support E-tag now.
12593 /* Ether type config */
12594 struct cmd_config_l2_tunnel_eth_type_result {
12595 cmdline_fixed_string_t port;
12596 cmdline_fixed_string_t config;
12597 cmdline_fixed_string_t all;
12599 cmdline_fixed_string_t l2_tunnel;
12600 cmdline_fixed_string_t l2_tunnel_type;
12601 cmdline_fixed_string_t eth_type;
12602 uint16_t eth_type_val;
12605 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12606 TOKEN_STRING_INITIALIZER
12607 (struct cmd_config_l2_tunnel_eth_type_result,
12609 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12610 TOKEN_STRING_INITIALIZER
12611 (struct cmd_config_l2_tunnel_eth_type_result,
12613 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12614 TOKEN_STRING_INITIALIZER
12615 (struct cmd_config_l2_tunnel_eth_type_result,
12617 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12618 TOKEN_NUM_INITIALIZER
12619 (struct cmd_config_l2_tunnel_eth_type_result,
12621 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12622 TOKEN_STRING_INITIALIZER
12623 (struct cmd_config_l2_tunnel_eth_type_result,
12624 l2_tunnel, "l2-tunnel");
12625 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12626 TOKEN_STRING_INITIALIZER
12627 (struct cmd_config_l2_tunnel_eth_type_result,
12628 l2_tunnel_type, "E-tag");
12629 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12630 TOKEN_STRING_INITIALIZER
12631 (struct cmd_config_l2_tunnel_eth_type_result,
12632 eth_type, "ether-type");
12633 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12634 TOKEN_NUM_INITIALIZER
12635 (struct cmd_config_l2_tunnel_eth_type_result,
12636 eth_type_val, UINT16);
12638 static enum rte_eth_tunnel_type
12639 str2fdir_l2_tunnel_type(char *string)
12643 static const struct {
12645 enum rte_eth_tunnel_type type;
12646 } l2_tunnel_type_str[] = {
12647 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12650 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12651 if (!strcmp(l2_tunnel_type_str[i].str, string))
12652 return l2_tunnel_type_str[i].type;
12654 return RTE_TUNNEL_TYPE_NONE;
12657 /* ether type config for all ports */
12659 cmd_config_l2_tunnel_eth_type_all_parsed
12660 (void *parsed_result,
12661 __attribute__((unused)) struct cmdline *cl,
12662 __attribute__((unused)) void *data)
12664 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12665 struct rte_eth_l2_tunnel_conf entry;
12668 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12669 entry.ether_type = res->eth_type_val;
12671 RTE_ETH_FOREACH_DEV(pid) {
12672 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12676 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12677 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12679 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12681 (void *)&cmd_config_l2_tunnel_eth_type_port,
12682 (void *)&cmd_config_l2_tunnel_eth_type_config,
12683 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12684 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12685 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12686 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12687 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12692 /* ether type config for a specific port */
12694 cmd_config_l2_tunnel_eth_type_specific_parsed(
12695 void *parsed_result,
12696 __attribute__((unused)) struct cmdline *cl,
12697 __attribute__((unused)) void *data)
12699 struct cmd_config_l2_tunnel_eth_type_result *res =
12701 struct rte_eth_l2_tunnel_conf entry;
12703 if (port_id_is_invalid(res->id, ENABLED_WARN))
12706 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12707 entry.ether_type = res->eth_type_val;
12709 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12712 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12713 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12715 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12717 (void *)&cmd_config_l2_tunnel_eth_type_port,
12718 (void *)&cmd_config_l2_tunnel_eth_type_config,
12719 (void *)&cmd_config_l2_tunnel_eth_type_id,
12720 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12721 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12722 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12723 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12728 /* Enable/disable l2 tunnel */
12729 struct cmd_config_l2_tunnel_en_dis_result {
12730 cmdline_fixed_string_t port;
12731 cmdline_fixed_string_t config;
12732 cmdline_fixed_string_t all;
12734 cmdline_fixed_string_t l2_tunnel;
12735 cmdline_fixed_string_t l2_tunnel_type;
12736 cmdline_fixed_string_t en_dis;
12739 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12740 TOKEN_STRING_INITIALIZER
12741 (struct cmd_config_l2_tunnel_en_dis_result,
12743 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12744 TOKEN_STRING_INITIALIZER
12745 (struct cmd_config_l2_tunnel_en_dis_result,
12747 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12748 TOKEN_STRING_INITIALIZER
12749 (struct cmd_config_l2_tunnel_en_dis_result,
12751 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12752 TOKEN_NUM_INITIALIZER
12753 (struct cmd_config_l2_tunnel_en_dis_result,
12755 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12756 TOKEN_STRING_INITIALIZER
12757 (struct cmd_config_l2_tunnel_en_dis_result,
12758 l2_tunnel, "l2-tunnel");
12759 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12760 TOKEN_STRING_INITIALIZER
12761 (struct cmd_config_l2_tunnel_en_dis_result,
12762 l2_tunnel_type, "E-tag");
12763 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12764 TOKEN_STRING_INITIALIZER
12765 (struct cmd_config_l2_tunnel_en_dis_result,
12766 en_dis, "enable#disable");
12768 /* enable/disable l2 tunnel for all ports */
12770 cmd_config_l2_tunnel_en_dis_all_parsed(
12771 void *parsed_result,
12772 __attribute__((unused)) struct cmdline *cl,
12773 __attribute__((unused)) void *data)
12775 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12776 struct rte_eth_l2_tunnel_conf entry;
12780 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12782 if (!strcmp("enable", res->en_dis))
12787 RTE_ETH_FOREACH_DEV(pid) {
12788 rte_eth_dev_l2_tunnel_offload_set(pid,
12790 ETH_L2_TUNNEL_ENABLE_MASK,
12795 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12796 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12798 .help_str = "port config all l2-tunnel E-tag enable|disable",
12800 (void *)&cmd_config_l2_tunnel_en_dis_port,
12801 (void *)&cmd_config_l2_tunnel_en_dis_config,
12802 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12803 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12804 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12805 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12810 /* enable/disable l2 tunnel for a port */
12812 cmd_config_l2_tunnel_en_dis_specific_parsed(
12813 void *parsed_result,
12814 __attribute__((unused)) struct cmdline *cl,
12815 __attribute__((unused)) void *data)
12817 struct cmd_config_l2_tunnel_en_dis_result *res =
12819 struct rte_eth_l2_tunnel_conf entry;
12821 if (port_id_is_invalid(res->id, ENABLED_WARN))
12824 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12826 if (!strcmp("enable", res->en_dis))
12827 rte_eth_dev_l2_tunnel_offload_set(res->id,
12829 ETH_L2_TUNNEL_ENABLE_MASK,
12832 rte_eth_dev_l2_tunnel_offload_set(res->id,
12834 ETH_L2_TUNNEL_ENABLE_MASK,
12838 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12839 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12841 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12843 (void *)&cmd_config_l2_tunnel_en_dis_port,
12844 (void *)&cmd_config_l2_tunnel_en_dis_config,
12845 (void *)&cmd_config_l2_tunnel_en_dis_id,
12846 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12847 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12848 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12853 /* E-tag configuration */
12855 /* Common result structure for all E-tag configuration */
12856 struct cmd_config_e_tag_result {
12857 cmdline_fixed_string_t e_tag;
12858 cmdline_fixed_string_t set;
12859 cmdline_fixed_string_t insertion;
12860 cmdline_fixed_string_t stripping;
12861 cmdline_fixed_string_t forwarding;
12862 cmdline_fixed_string_t filter;
12863 cmdline_fixed_string_t add;
12864 cmdline_fixed_string_t del;
12865 cmdline_fixed_string_t on;
12866 cmdline_fixed_string_t off;
12867 cmdline_fixed_string_t on_off;
12868 cmdline_fixed_string_t port_tag_id;
12869 uint32_t port_tag_id_val;
12870 cmdline_fixed_string_t e_tag_id;
12871 uint16_t e_tag_id_val;
12872 cmdline_fixed_string_t dst_pool;
12873 uint8_t dst_pool_val;
12874 cmdline_fixed_string_t port;
12876 cmdline_fixed_string_t vf;
12880 /* Common CLI fields for all E-tag configuration */
12881 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12882 TOKEN_STRING_INITIALIZER
12883 (struct cmd_config_e_tag_result,
12885 cmdline_parse_token_string_t cmd_config_e_tag_set =
12886 TOKEN_STRING_INITIALIZER
12887 (struct cmd_config_e_tag_result,
12889 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12890 TOKEN_STRING_INITIALIZER
12891 (struct cmd_config_e_tag_result,
12892 insertion, "insertion");
12893 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12894 TOKEN_STRING_INITIALIZER
12895 (struct cmd_config_e_tag_result,
12896 stripping, "stripping");
12897 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12898 TOKEN_STRING_INITIALIZER
12899 (struct cmd_config_e_tag_result,
12900 forwarding, "forwarding");
12901 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12902 TOKEN_STRING_INITIALIZER
12903 (struct cmd_config_e_tag_result,
12905 cmdline_parse_token_string_t cmd_config_e_tag_add =
12906 TOKEN_STRING_INITIALIZER
12907 (struct cmd_config_e_tag_result,
12909 cmdline_parse_token_string_t cmd_config_e_tag_del =
12910 TOKEN_STRING_INITIALIZER
12911 (struct cmd_config_e_tag_result,
12913 cmdline_parse_token_string_t cmd_config_e_tag_on =
12914 TOKEN_STRING_INITIALIZER
12915 (struct cmd_config_e_tag_result,
12917 cmdline_parse_token_string_t cmd_config_e_tag_off =
12918 TOKEN_STRING_INITIALIZER
12919 (struct cmd_config_e_tag_result,
12921 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12922 TOKEN_STRING_INITIALIZER
12923 (struct cmd_config_e_tag_result,
12925 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12926 TOKEN_STRING_INITIALIZER
12927 (struct cmd_config_e_tag_result,
12928 port_tag_id, "port-tag-id");
12929 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12930 TOKEN_NUM_INITIALIZER
12931 (struct cmd_config_e_tag_result,
12932 port_tag_id_val, UINT32);
12933 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12934 TOKEN_STRING_INITIALIZER
12935 (struct cmd_config_e_tag_result,
12936 e_tag_id, "e-tag-id");
12937 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12938 TOKEN_NUM_INITIALIZER
12939 (struct cmd_config_e_tag_result,
12940 e_tag_id_val, UINT16);
12941 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12942 TOKEN_STRING_INITIALIZER
12943 (struct cmd_config_e_tag_result,
12944 dst_pool, "dst-pool");
12945 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12946 TOKEN_NUM_INITIALIZER
12947 (struct cmd_config_e_tag_result,
12948 dst_pool_val, UINT8);
12949 cmdline_parse_token_string_t cmd_config_e_tag_port =
12950 TOKEN_STRING_INITIALIZER
12951 (struct cmd_config_e_tag_result,
12953 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12954 TOKEN_NUM_INITIALIZER
12955 (struct cmd_config_e_tag_result,
12957 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12958 TOKEN_STRING_INITIALIZER
12959 (struct cmd_config_e_tag_result,
12961 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12962 TOKEN_NUM_INITIALIZER
12963 (struct cmd_config_e_tag_result,
12966 /* E-tag insertion configuration */
12968 cmd_config_e_tag_insertion_en_parsed(
12969 void *parsed_result,
12970 __attribute__((unused)) struct cmdline *cl,
12971 __attribute__((unused)) void *data)
12973 struct cmd_config_e_tag_result *res =
12975 struct rte_eth_l2_tunnel_conf entry;
12977 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12980 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12981 entry.tunnel_id = res->port_tag_id_val;
12982 entry.vf_id = res->vf_id;
12983 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12985 ETH_L2_TUNNEL_INSERTION_MASK,
12990 cmd_config_e_tag_insertion_dis_parsed(
12991 void *parsed_result,
12992 __attribute__((unused)) struct cmdline *cl,
12993 __attribute__((unused)) void *data)
12995 struct cmd_config_e_tag_result *res =
12997 struct rte_eth_l2_tunnel_conf entry;
12999 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13002 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13003 entry.vf_id = res->vf_id;
13005 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13007 ETH_L2_TUNNEL_INSERTION_MASK,
13011 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13012 .f = cmd_config_e_tag_insertion_en_parsed,
13014 .help_str = "E-tag ... : E-tag insertion enable",
13016 (void *)&cmd_config_e_tag_e_tag,
13017 (void *)&cmd_config_e_tag_set,
13018 (void *)&cmd_config_e_tag_insertion,
13019 (void *)&cmd_config_e_tag_on,
13020 (void *)&cmd_config_e_tag_port_tag_id,
13021 (void *)&cmd_config_e_tag_port_tag_id_val,
13022 (void *)&cmd_config_e_tag_port,
13023 (void *)&cmd_config_e_tag_port_id,
13024 (void *)&cmd_config_e_tag_vf,
13025 (void *)&cmd_config_e_tag_vf_id,
13030 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13031 .f = cmd_config_e_tag_insertion_dis_parsed,
13033 .help_str = "E-tag ... : E-tag insertion disable",
13035 (void *)&cmd_config_e_tag_e_tag,
13036 (void *)&cmd_config_e_tag_set,
13037 (void *)&cmd_config_e_tag_insertion,
13038 (void *)&cmd_config_e_tag_off,
13039 (void *)&cmd_config_e_tag_port,
13040 (void *)&cmd_config_e_tag_port_id,
13041 (void *)&cmd_config_e_tag_vf,
13042 (void *)&cmd_config_e_tag_vf_id,
13047 /* E-tag stripping configuration */
13049 cmd_config_e_tag_stripping_parsed(
13050 void *parsed_result,
13051 __attribute__((unused)) struct cmdline *cl,
13052 __attribute__((unused)) void *data)
13054 struct cmd_config_e_tag_result *res =
13056 struct rte_eth_l2_tunnel_conf entry;
13058 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13061 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13063 if (!strcmp(res->on_off, "on"))
13064 rte_eth_dev_l2_tunnel_offload_set
13067 ETH_L2_TUNNEL_STRIPPING_MASK,
13070 rte_eth_dev_l2_tunnel_offload_set
13073 ETH_L2_TUNNEL_STRIPPING_MASK,
13077 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13078 .f = cmd_config_e_tag_stripping_parsed,
13080 .help_str = "E-tag ... : E-tag stripping enable/disable",
13082 (void *)&cmd_config_e_tag_e_tag,
13083 (void *)&cmd_config_e_tag_set,
13084 (void *)&cmd_config_e_tag_stripping,
13085 (void *)&cmd_config_e_tag_on_off,
13086 (void *)&cmd_config_e_tag_port,
13087 (void *)&cmd_config_e_tag_port_id,
13092 /* E-tag forwarding configuration */
13094 cmd_config_e_tag_forwarding_parsed(
13095 void *parsed_result,
13096 __attribute__((unused)) struct cmdline *cl,
13097 __attribute__((unused)) void *data)
13099 struct cmd_config_e_tag_result *res = parsed_result;
13100 struct rte_eth_l2_tunnel_conf entry;
13102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13105 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13107 if (!strcmp(res->on_off, "on"))
13108 rte_eth_dev_l2_tunnel_offload_set
13111 ETH_L2_TUNNEL_FORWARDING_MASK,
13114 rte_eth_dev_l2_tunnel_offload_set
13117 ETH_L2_TUNNEL_FORWARDING_MASK,
13121 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13122 .f = cmd_config_e_tag_forwarding_parsed,
13124 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13126 (void *)&cmd_config_e_tag_e_tag,
13127 (void *)&cmd_config_e_tag_set,
13128 (void *)&cmd_config_e_tag_forwarding,
13129 (void *)&cmd_config_e_tag_on_off,
13130 (void *)&cmd_config_e_tag_port,
13131 (void *)&cmd_config_e_tag_port_id,
13136 /* E-tag filter configuration */
13138 cmd_config_e_tag_filter_add_parsed(
13139 void *parsed_result,
13140 __attribute__((unused)) struct cmdline *cl,
13141 __attribute__((unused)) void *data)
13143 struct cmd_config_e_tag_result *res = parsed_result;
13144 struct rte_eth_l2_tunnel_conf entry;
13147 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13150 if (res->e_tag_id_val > 0x3fff) {
13151 printf("e-tag-id must be equal or less than 0x3fff.\n");
13155 ret = rte_eth_dev_filter_supported(res->port_id,
13156 RTE_ETH_FILTER_L2_TUNNEL);
13158 printf("E-tag filter is not supported on port %u.\n",
13163 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13164 entry.tunnel_id = res->e_tag_id_val;
13165 entry.pool = res->dst_pool_val;
13167 ret = rte_eth_dev_filter_ctrl(res->port_id,
13168 RTE_ETH_FILTER_L2_TUNNEL,
13169 RTE_ETH_FILTER_ADD,
13172 printf("E-tag filter programming error: (%s)\n",
13176 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13177 .f = cmd_config_e_tag_filter_add_parsed,
13179 .help_str = "E-tag ... : E-tag filter add",
13181 (void *)&cmd_config_e_tag_e_tag,
13182 (void *)&cmd_config_e_tag_set,
13183 (void *)&cmd_config_e_tag_filter,
13184 (void *)&cmd_config_e_tag_add,
13185 (void *)&cmd_config_e_tag_e_tag_id,
13186 (void *)&cmd_config_e_tag_e_tag_id_val,
13187 (void *)&cmd_config_e_tag_dst_pool,
13188 (void *)&cmd_config_e_tag_dst_pool_val,
13189 (void *)&cmd_config_e_tag_port,
13190 (void *)&cmd_config_e_tag_port_id,
13196 cmd_config_e_tag_filter_del_parsed(
13197 void *parsed_result,
13198 __attribute__((unused)) struct cmdline *cl,
13199 __attribute__((unused)) void *data)
13201 struct cmd_config_e_tag_result *res = parsed_result;
13202 struct rte_eth_l2_tunnel_conf entry;
13205 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13208 if (res->e_tag_id_val > 0x3fff) {
13209 printf("e-tag-id must be less than 0x3fff.\n");
13213 ret = rte_eth_dev_filter_supported(res->port_id,
13214 RTE_ETH_FILTER_L2_TUNNEL);
13216 printf("E-tag filter is not supported on port %u.\n",
13221 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13222 entry.tunnel_id = res->e_tag_id_val;
13224 ret = rte_eth_dev_filter_ctrl(res->port_id,
13225 RTE_ETH_FILTER_L2_TUNNEL,
13226 RTE_ETH_FILTER_DELETE,
13229 printf("E-tag filter programming error: (%s)\n",
13233 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13234 .f = cmd_config_e_tag_filter_del_parsed,
13236 .help_str = "E-tag ... : E-tag filter delete",
13238 (void *)&cmd_config_e_tag_e_tag,
13239 (void *)&cmd_config_e_tag_set,
13240 (void *)&cmd_config_e_tag_filter,
13241 (void *)&cmd_config_e_tag_del,
13242 (void *)&cmd_config_e_tag_e_tag_id,
13243 (void *)&cmd_config_e_tag_e_tag_id_val,
13244 (void *)&cmd_config_e_tag_port,
13245 (void *)&cmd_config_e_tag_port_id,
13250 /* vf vlan anti spoof configuration */
13252 /* Common result structure for vf vlan anti spoof */
13253 struct cmd_vf_vlan_anti_spoof_result {
13254 cmdline_fixed_string_t set;
13255 cmdline_fixed_string_t vf;
13256 cmdline_fixed_string_t vlan;
13257 cmdline_fixed_string_t antispoof;
13260 cmdline_fixed_string_t on_off;
13263 /* Common CLI fields for vf vlan anti spoof enable disable */
13264 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13265 TOKEN_STRING_INITIALIZER
13266 (struct cmd_vf_vlan_anti_spoof_result,
13268 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13269 TOKEN_STRING_INITIALIZER
13270 (struct cmd_vf_vlan_anti_spoof_result,
13272 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13273 TOKEN_STRING_INITIALIZER
13274 (struct cmd_vf_vlan_anti_spoof_result,
13276 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13277 TOKEN_STRING_INITIALIZER
13278 (struct cmd_vf_vlan_anti_spoof_result,
13279 antispoof, "antispoof");
13280 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13281 TOKEN_NUM_INITIALIZER
13282 (struct cmd_vf_vlan_anti_spoof_result,
13284 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13285 TOKEN_NUM_INITIALIZER
13286 (struct cmd_vf_vlan_anti_spoof_result,
13288 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13289 TOKEN_STRING_INITIALIZER
13290 (struct cmd_vf_vlan_anti_spoof_result,
13294 cmd_set_vf_vlan_anti_spoof_parsed(
13295 void *parsed_result,
13296 __attribute__((unused)) struct cmdline *cl,
13297 __attribute__((unused)) void *data)
13299 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13300 int ret = -ENOTSUP;
13302 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13304 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13307 #ifdef RTE_LIBRTE_IXGBE_PMD
13308 if (ret == -ENOTSUP)
13309 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13310 res->vf_id, is_on);
13312 #ifdef RTE_LIBRTE_I40E_PMD
13313 if (ret == -ENOTSUP)
13314 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13315 res->vf_id, is_on);
13317 #ifdef RTE_LIBRTE_BNXT_PMD
13318 if (ret == -ENOTSUP)
13319 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13320 res->vf_id, is_on);
13327 printf("invalid vf_id %d\n", res->vf_id);
13330 printf("invalid port_id %d\n", res->port_id);
13333 printf("function not implemented\n");
13336 printf("programming error: (%s)\n", strerror(-ret));
13340 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13341 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13343 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13345 (void *)&cmd_vf_vlan_anti_spoof_set,
13346 (void *)&cmd_vf_vlan_anti_spoof_vf,
13347 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13348 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13349 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13350 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13351 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13356 /* vf mac anti spoof configuration */
13358 /* Common result structure for vf mac anti spoof */
13359 struct cmd_vf_mac_anti_spoof_result {
13360 cmdline_fixed_string_t set;
13361 cmdline_fixed_string_t vf;
13362 cmdline_fixed_string_t mac;
13363 cmdline_fixed_string_t antispoof;
13366 cmdline_fixed_string_t on_off;
13369 /* Common CLI fields for vf mac anti spoof enable disable */
13370 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13371 TOKEN_STRING_INITIALIZER
13372 (struct cmd_vf_mac_anti_spoof_result,
13374 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13375 TOKEN_STRING_INITIALIZER
13376 (struct cmd_vf_mac_anti_spoof_result,
13378 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13379 TOKEN_STRING_INITIALIZER
13380 (struct cmd_vf_mac_anti_spoof_result,
13382 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13383 TOKEN_STRING_INITIALIZER
13384 (struct cmd_vf_mac_anti_spoof_result,
13385 antispoof, "antispoof");
13386 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13387 TOKEN_NUM_INITIALIZER
13388 (struct cmd_vf_mac_anti_spoof_result,
13390 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13391 TOKEN_NUM_INITIALIZER
13392 (struct cmd_vf_mac_anti_spoof_result,
13394 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13395 TOKEN_STRING_INITIALIZER
13396 (struct cmd_vf_mac_anti_spoof_result,
13400 cmd_set_vf_mac_anti_spoof_parsed(
13401 void *parsed_result,
13402 __attribute__((unused)) struct cmdline *cl,
13403 __attribute__((unused)) void *data)
13405 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13406 int ret = -ENOTSUP;
13408 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13410 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13413 #ifdef RTE_LIBRTE_IXGBE_PMD
13414 if (ret == -ENOTSUP)
13415 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13416 res->vf_id, is_on);
13418 #ifdef RTE_LIBRTE_I40E_PMD
13419 if (ret == -ENOTSUP)
13420 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13421 res->vf_id, is_on);
13423 #ifdef RTE_LIBRTE_BNXT_PMD
13424 if (ret == -ENOTSUP)
13425 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13426 res->vf_id, is_on);
13433 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13436 printf("invalid port_id %d\n", res->port_id);
13439 printf("function not implemented\n");
13442 printf("programming error: (%s)\n", strerror(-ret));
13446 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13447 .f = cmd_set_vf_mac_anti_spoof_parsed,
13449 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13451 (void *)&cmd_vf_mac_anti_spoof_set,
13452 (void *)&cmd_vf_mac_anti_spoof_vf,
13453 (void *)&cmd_vf_mac_anti_spoof_mac,
13454 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13455 (void *)&cmd_vf_mac_anti_spoof_port_id,
13456 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13457 (void *)&cmd_vf_mac_anti_spoof_on_off,
13462 /* vf vlan strip queue configuration */
13464 /* Common result structure for vf mac anti spoof */
13465 struct cmd_vf_vlan_stripq_result {
13466 cmdline_fixed_string_t set;
13467 cmdline_fixed_string_t vf;
13468 cmdline_fixed_string_t vlan;
13469 cmdline_fixed_string_t stripq;
13472 cmdline_fixed_string_t on_off;
13475 /* Common CLI fields for vf vlan strip enable disable */
13476 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13477 TOKEN_STRING_INITIALIZER
13478 (struct cmd_vf_vlan_stripq_result,
13480 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13481 TOKEN_STRING_INITIALIZER
13482 (struct cmd_vf_vlan_stripq_result,
13484 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13485 TOKEN_STRING_INITIALIZER
13486 (struct cmd_vf_vlan_stripq_result,
13488 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13489 TOKEN_STRING_INITIALIZER
13490 (struct cmd_vf_vlan_stripq_result,
13492 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13493 TOKEN_NUM_INITIALIZER
13494 (struct cmd_vf_vlan_stripq_result,
13496 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13497 TOKEN_NUM_INITIALIZER
13498 (struct cmd_vf_vlan_stripq_result,
13500 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13501 TOKEN_STRING_INITIALIZER
13502 (struct cmd_vf_vlan_stripq_result,
13506 cmd_set_vf_vlan_stripq_parsed(
13507 void *parsed_result,
13508 __attribute__((unused)) struct cmdline *cl,
13509 __attribute__((unused)) void *data)
13511 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13512 int ret = -ENOTSUP;
13514 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13516 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13519 #ifdef RTE_LIBRTE_IXGBE_PMD
13520 if (ret == -ENOTSUP)
13521 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13522 res->vf_id, is_on);
13524 #ifdef RTE_LIBRTE_I40E_PMD
13525 if (ret == -ENOTSUP)
13526 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13527 res->vf_id, is_on);
13529 #ifdef RTE_LIBRTE_BNXT_PMD
13530 if (ret == -ENOTSUP)
13531 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13532 res->vf_id, is_on);
13539 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13542 printf("invalid port_id %d\n", res->port_id);
13545 printf("function not implemented\n");
13548 printf("programming error: (%s)\n", strerror(-ret));
13552 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13553 .f = cmd_set_vf_vlan_stripq_parsed,
13555 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13557 (void *)&cmd_vf_vlan_stripq_set,
13558 (void *)&cmd_vf_vlan_stripq_vf,
13559 (void *)&cmd_vf_vlan_stripq_vlan,
13560 (void *)&cmd_vf_vlan_stripq_stripq,
13561 (void *)&cmd_vf_vlan_stripq_port_id,
13562 (void *)&cmd_vf_vlan_stripq_vf_id,
13563 (void *)&cmd_vf_vlan_stripq_on_off,
13568 /* vf vlan insert configuration */
13570 /* Common result structure for vf vlan insert */
13571 struct cmd_vf_vlan_insert_result {
13572 cmdline_fixed_string_t set;
13573 cmdline_fixed_string_t vf;
13574 cmdline_fixed_string_t vlan;
13575 cmdline_fixed_string_t insert;
13581 /* Common CLI fields for vf vlan insert enable disable */
13582 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13583 TOKEN_STRING_INITIALIZER
13584 (struct cmd_vf_vlan_insert_result,
13586 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13587 TOKEN_STRING_INITIALIZER
13588 (struct cmd_vf_vlan_insert_result,
13590 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13591 TOKEN_STRING_INITIALIZER
13592 (struct cmd_vf_vlan_insert_result,
13594 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13595 TOKEN_STRING_INITIALIZER
13596 (struct cmd_vf_vlan_insert_result,
13598 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13599 TOKEN_NUM_INITIALIZER
13600 (struct cmd_vf_vlan_insert_result,
13602 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13603 TOKEN_NUM_INITIALIZER
13604 (struct cmd_vf_vlan_insert_result,
13606 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13607 TOKEN_NUM_INITIALIZER
13608 (struct cmd_vf_vlan_insert_result,
13612 cmd_set_vf_vlan_insert_parsed(
13613 void *parsed_result,
13614 __attribute__((unused)) struct cmdline *cl,
13615 __attribute__((unused)) void *data)
13617 struct cmd_vf_vlan_insert_result *res = parsed_result;
13618 int ret = -ENOTSUP;
13620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13623 #ifdef RTE_LIBRTE_IXGBE_PMD
13624 if (ret == -ENOTSUP)
13625 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13628 #ifdef RTE_LIBRTE_I40E_PMD
13629 if (ret == -ENOTSUP)
13630 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13633 #ifdef RTE_LIBRTE_BNXT_PMD
13634 if (ret == -ENOTSUP)
13635 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13643 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13646 printf("invalid port_id %d\n", res->port_id);
13649 printf("function not implemented\n");
13652 printf("programming error: (%s)\n", strerror(-ret));
13656 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13657 .f = cmd_set_vf_vlan_insert_parsed,
13659 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13661 (void *)&cmd_vf_vlan_insert_set,
13662 (void *)&cmd_vf_vlan_insert_vf,
13663 (void *)&cmd_vf_vlan_insert_vlan,
13664 (void *)&cmd_vf_vlan_insert_insert,
13665 (void *)&cmd_vf_vlan_insert_port_id,
13666 (void *)&cmd_vf_vlan_insert_vf_id,
13667 (void *)&cmd_vf_vlan_insert_vlan_id,
13672 /* tx loopback configuration */
13674 /* Common result structure for tx loopback */
13675 struct cmd_tx_loopback_result {
13676 cmdline_fixed_string_t set;
13677 cmdline_fixed_string_t tx;
13678 cmdline_fixed_string_t loopback;
13680 cmdline_fixed_string_t on_off;
13683 /* Common CLI fields for tx loopback enable disable */
13684 cmdline_parse_token_string_t cmd_tx_loopback_set =
13685 TOKEN_STRING_INITIALIZER
13686 (struct cmd_tx_loopback_result,
13688 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13689 TOKEN_STRING_INITIALIZER
13690 (struct cmd_tx_loopback_result,
13692 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13693 TOKEN_STRING_INITIALIZER
13694 (struct cmd_tx_loopback_result,
13695 loopback, "loopback");
13696 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13697 TOKEN_NUM_INITIALIZER
13698 (struct cmd_tx_loopback_result,
13700 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13701 TOKEN_STRING_INITIALIZER
13702 (struct cmd_tx_loopback_result,
13706 cmd_set_tx_loopback_parsed(
13707 void *parsed_result,
13708 __attribute__((unused)) struct cmdline *cl,
13709 __attribute__((unused)) void *data)
13711 struct cmd_tx_loopback_result *res = parsed_result;
13712 int ret = -ENOTSUP;
13714 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13719 #ifdef RTE_LIBRTE_IXGBE_PMD
13720 if (ret == -ENOTSUP)
13721 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13723 #ifdef RTE_LIBRTE_I40E_PMD
13724 if (ret == -ENOTSUP)
13725 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13727 #ifdef RTE_LIBRTE_BNXT_PMD
13728 if (ret == -ENOTSUP)
13729 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13731 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13732 if (ret == -ENOTSUP)
13733 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13740 printf("invalid is_on %d\n", is_on);
13743 printf("invalid port_id %d\n", res->port_id);
13746 printf("function not implemented\n");
13749 printf("programming error: (%s)\n", strerror(-ret));
13753 cmdline_parse_inst_t cmd_set_tx_loopback = {
13754 .f = cmd_set_tx_loopback_parsed,
13756 .help_str = "set tx loopback <port_id> on|off",
13758 (void *)&cmd_tx_loopback_set,
13759 (void *)&cmd_tx_loopback_tx,
13760 (void *)&cmd_tx_loopback_loopback,
13761 (void *)&cmd_tx_loopback_port_id,
13762 (void *)&cmd_tx_loopback_on_off,
13767 /* all queues drop enable configuration */
13769 /* Common result structure for all queues drop enable */
13770 struct cmd_all_queues_drop_en_result {
13771 cmdline_fixed_string_t set;
13772 cmdline_fixed_string_t all;
13773 cmdline_fixed_string_t queues;
13774 cmdline_fixed_string_t drop;
13776 cmdline_fixed_string_t on_off;
13779 /* Common CLI fields for tx loopback enable disable */
13780 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13781 TOKEN_STRING_INITIALIZER
13782 (struct cmd_all_queues_drop_en_result,
13784 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13785 TOKEN_STRING_INITIALIZER
13786 (struct cmd_all_queues_drop_en_result,
13788 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13789 TOKEN_STRING_INITIALIZER
13790 (struct cmd_all_queues_drop_en_result,
13792 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13793 TOKEN_STRING_INITIALIZER
13794 (struct cmd_all_queues_drop_en_result,
13796 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13797 TOKEN_NUM_INITIALIZER
13798 (struct cmd_all_queues_drop_en_result,
13800 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13801 TOKEN_STRING_INITIALIZER
13802 (struct cmd_all_queues_drop_en_result,
13806 cmd_set_all_queues_drop_en_parsed(
13807 void *parsed_result,
13808 __attribute__((unused)) struct cmdline *cl,
13809 __attribute__((unused)) void *data)
13811 struct cmd_all_queues_drop_en_result *res = parsed_result;
13812 int ret = -ENOTSUP;
13813 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13815 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13818 #ifdef RTE_LIBRTE_IXGBE_PMD
13819 if (ret == -ENOTSUP)
13820 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13822 #ifdef RTE_LIBRTE_BNXT_PMD
13823 if (ret == -ENOTSUP)
13824 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13830 printf("invalid is_on %d\n", is_on);
13833 printf("invalid port_id %d\n", res->port_id);
13836 printf("function not implemented\n");
13839 printf("programming error: (%s)\n", strerror(-ret));
13843 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13844 .f = cmd_set_all_queues_drop_en_parsed,
13846 .help_str = "set all queues drop <port_id> on|off",
13848 (void *)&cmd_all_queues_drop_en_set,
13849 (void *)&cmd_all_queues_drop_en_all,
13850 (void *)&cmd_all_queues_drop_en_queues,
13851 (void *)&cmd_all_queues_drop_en_drop,
13852 (void *)&cmd_all_queues_drop_en_port_id,
13853 (void *)&cmd_all_queues_drop_en_on_off,
13858 /* vf split drop enable configuration */
13860 /* Common result structure for vf split drop enable */
13861 struct cmd_vf_split_drop_en_result {
13862 cmdline_fixed_string_t set;
13863 cmdline_fixed_string_t vf;
13864 cmdline_fixed_string_t split;
13865 cmdline_fixed_string_t drop;
13868 cmdline_fixed_string_t on_off;
13871 /* Common CLI fields for vf split drop enable disable */
13872 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13873 TOKEN_STRING_INITIALIZER
13874 (struct cmd_vf_split_drop_en_result,
13876 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13877 TOKEN_STRING_INITIALIZER
13878 (struct cmd_vf_split_drop_en_result,
13880 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13881 TOKEN_STRING_INITIALIZER
13882 (struct cmd_vf_split_drop_en_result,
13884 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13885 TOKEN_STRING_INITIALIZER
13886 (struct cmd_vf_split_drop_en_result,
13888 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13889 TOKEN_NUM_INITIALIZER
13890 (struct cmd_vf_split_drop_en_result,
13892 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13893 TOKEN_NUM_INITIALIZER
13894 (struct cmd_vf_split_drop_en_result,
13896 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13897 TOKEN_STRING_INITIALIZER
13898 (struct cmd_vf_split_drop_en_result,
13902 cmd_set_vf_split_drop_en_parsed(
13903 void *parsed_result,
13904 __attribute__((unused)) struct cmdline *cl,
13905 __attribute__((unused)) void *data)
13907 struct cmd_vf_split_drop_en_result *res = parsed_result;
13908 int ret = -ENOTSUP;
13909 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13911 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13914 #ifdef RTE_LIBRTE_IXGBE_PMD
13915 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13922 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13925 printf("invalid port_id %d\n", res->port_id);
13928 printf("not supported on port %d\n", res->port_id);
13931 printf("programming error: (%s)\n", strerror(-ret));
13935 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13936 .f = cmd_set_vf_split_drop_en_parsed,
13938 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13940 (void *)&cmd_vf_split_drop_en_set,
13941 (void *)&cmd_vf_split_drop_en_vf,
13942 (void *)&cmd_vf_split_drop_en_split,
13943 (void *)&cmd_vf_split_drop_en_drop,
13944 (void *)&cmd_vf_split_drop_en_port_id,
13945 (void *)&cmd_vf_split_drop_en_vf_id,
13946 (void *)&cmd_vf_split_drop_en_on_off,
13951 /* vf mac address configuration */
13953 /* Common result structure for vf mac address */
13954 struct cmd_set_vf_mac_addr_result {
13955 cmdline_fixed_string_t set;
13956 cmdline_fixed_string_t vf;
13957 cmdline_fixed_string_t mac;
13958 cmdline_fixed_string_t addr;
13961 struct rte_ether_addr mac_addr;
13965 /* Common CLI fields for vf split drop enable disable */
13966 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13967 TOKEN_STRING_INITIALIZER
13968 (struct cmd_set_vf_mac_addr_result,
13970 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13971 TOKEN_STRING_INITIALIZER
13972 (struct cmd_set_vf_mac_addr_result,
13974 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13975 TOKEN_STRING_INITIALIZER
13976 (struct cmd_set_vf_mac_addr_result,
13978 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13979 TOKEN_STRING_INITIALIZER
13980 (struct cmd_set_vf_mac_addr_result,
13982 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13983 TOKEN_NUM_INITIALIZER
13984 (struct cmd_set_vf_mac_addr_result,
13986 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13987 TOKEN_NUM_INITIALIZER
13988 (struct cmd_set_vf_mac_addr_result,
13990 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13991 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13995 cmd_set_vf_mac_addr_parsed(
13996 void *parsed_result,
13997 __attribute__((unused)) struct cmdline *cl,
13998 __attribute__((unused)) void *data)
14000 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14001 int ret = -ENOTSUP;
14003 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14006 #ifdef RTE_LIBRTE_IXGBE_PMD
14007 if (ret == -ENOTSUP)
14008 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14011 #ifdef RTE_LIBRTE_I40E_PMD
14012 if (ret == -ENOTSUP)
14013 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14016 #ifdef RTE_LIBRTE_BNXT_PMD
14017 if (ret == -ENOTSUP)
14018 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14026 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14029 printf("invalid port_id %d\n", res->port_id);
14032 printf("function not implemented\n");
14035 printf("programming error: (%s)\n", strerror(-ret));
14039 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14040 .f = cmd_set_vf_mac_addr_parsed,
14042 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14044 (void *)&cmd_set_vf_mac_addr_set,
14045 (void *)&cmd_set_vf_mac_addr_vf,
14046 (void *)&cmd_set_vf_mac_addr_mac,
14047 (void *)&cmd_set_vf_mac_addr_addr,
14048 (void *)&cmd_set_vf_mac_addr_port_id,
14049 (void *)&cmd_set_vf_mac_addr_vf_id,
14050 (void *)&cmd_set_vf_mac_addr_mac_addr,
14055 /* MACsec configuration */
14057 /* Common result structure for MACsec offload enable */
14058 struct cmd_macsec_offload_on_result {
14059 cmdline_fixed_string_t set;
14060 cmdline_fixed_string_t macsec;
14061 cmdline_fixed_string_t offload;
14063 cmdline_fixed_string_t on;
14064 cmdline_fixed_string_t encrypt;
14065 cmdline_fixed_string_t en_on_off;
14066 cmdline_fixed_string_t replay_protect;
14067 cmdline_fixed_string_t rp_on_off;
14070 /* Common CLI fields for MACsec offload disable */
14071 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14072 TOKEN_STRING_INITIALIZER
14073 (struct cmd_macsec_offload_on_result,
14075 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14076 TOKEN_STRING_INITIALIZER
14077 (struct cmd_macsec_offload_on_result,
14079 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14080 TOKEN_STRING_INITIALIZER
14081 (struct cmd_macsec_offload_on_result,
14082 offload, "offload");
14083 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14084 TOKEN_NUM_INITIALIZER
14085 (struct cmd_macsec_offload_on_result,
14087 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14088 TOKEN_STRING_INITIALIZER
14089 (struct cmd_macsec_offload_on_result,
14091 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14092 TOKEN_STRING_INITIALIZER
14093 (struct cmd_macsec_offload_on_result,
14094 encrypt, "encrypt");
14095 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14096 TOKEN_STRING_INITIALIZER
14097 (struct cmd_macsec_offload_on_result,
14098 en_on_off, "on#off");
14099 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14100 TOKEN_STRING_INITIALIZER
14101 (struct cmd_macsec_offload_on_result,
14102 replay_protect, "replay-protect");
14103 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14104 TOKEN_STRING_INITIALIZER
14105 (struct cmd_macsec_offload_on_result,
14106 rp_on_off, "on#off");
14109 cmd_set_macsec_offload_on_parsed(
14110 void *parsed_result,
14111 __attribute__((unused)) struct cmdline *cl,
14112 __attribute__((unused)) void *data)
14114 struct cmd_macsec_offload_on_result *res = parsed_result;
14115 int ret = -ENOTSUP;
14116 portid_t port_id = res->port_id;
14117 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14118 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14119 struct rte_eth_dev_info dev_info;
14121 if (port_id_is_invalid(port_id, ENABLED_WARN))
14123 if (!port_is_stopped(port_id)) {
14124 printf("Please stop port %d first\n", port_id);
14128 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14132 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14133 #ifdef RTE_LIBRTE_IXGBE_PMD
14134 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14142 ports[port_id].dev_conf.txmode.offloads |=
14143 DEV_TX_OFFLOAD_MACSEC_INSERT;
14144 cmd_reconfig_device_queue(port_id, 1, 1);
14147 printf("invalid port_id %d\n", port_id);
14150 printf("not supported on port %d\n", port_id);
14153 printf("programming error: (%s)\n", strerror(-ret));
14157 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14158 .f = cmd_set_macsec_offload_on_parsed,
14160 .help_str = "set macsec offload <port_id> on "
14161 "encrypt on|off replay-protect on|off",
14163 (void *)&cmd_macsec_offload_on_set,
14164 (void *)&cmd_macsec_offload_on_macsec,
14165 (void *)&cmd_macsec_offload_on_offload,
14166 (void *)&cmd_macsec_offload_on_port_id,
14167 (void *)&cmd_macsec_offload_on_on,
14168 (void *)&cmd_macsec_offload_on_encrypt,
14169 (void *)&cmd_macsec_offload_on_en_on_off,
14170 (void *)&cmd_macsec_offload_on_replay_protect,
14171 (void *)&cmd_macsec_offload_on_rp_on_off,
14176 /* Common result structure for MACsec offload disable */
14177 struct cmd_macsec_offload_off_result {
14178 cmdline_fixed_string_t set;
14179 cmdline_fixed_string_t macsec;
14180 cmdline_fixed_string_t offload;
14182 cmdline_fixed_string_t off;
14185 /* Common CLI fields for MACsec offload disable */
14186 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14187 TOKEN_STRING_INITIALIZER
14188 (struct cmd_macsec_offload_off_result,
14190 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14191 TOKEN_STRING_INITIALIZER
14192 (struct cmd_macsec_offload_off_result,
14194 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14195 TOKEN_STRING_INITIALIZER
14196 (struct cmd_macsec_offload_off_result,
14197 offload, "offload");
14198 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14199 TOKEN_NUM_INITIALIZER
14200 (struct cmd_macsec_offload_off_result,
14202 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14203 TOKEN_STRING_INITIALIZER
14204 (struct cmd_macsec_offload_off_result,
14208 cmd_set_macsec_offload_off_parsed(
14209 void *parsed_result,
14210 __attribute__((unused)) struct cmdline *cl,
14211 __attribute__((unused)) void *data)
14213 struct cmd_macsec_offload_off_result *res = parsed_result;
14214 int ret = -ENOTSUP;
14215 struct rte_eth_dev_info dev_info;
14216 portid_t port_id = res->port_id;
14218 if (port_id_is_invalid(port_id, ENABLED_WARN))
14220 if (!port_is_stopped(port_id)) {
14221 printf("Please stop port %d first\n", port_id);
14225 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14229 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14230 #ifdef RTE_LIBRTE_IXGBE_PMD
14231 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14236 ports[port_id].dev_conf.txmode.offloads &=
14237 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14238 cmd_reconfig_device_queue(port_id, 1, 1);
14241 printf("invalid port_id %d\n", port_id);
14244 printf("not supported on port %d\n", port_id);
14247 printf("programming error: (%s)\n", strerror(-ret));
14251 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14252 .f = cmd_set_macsec_offload_off_parsed,
14254 .help_str = "set macsec offload <port_id> off",
14256 (void *)&cmd_macsec_offload_off_set,
14257 (void *)&cmd_macsec_offload_off_macsec,
14258 (void *)&cmd_macsec_offload_off_offload,
14259 (void *)&cmd_macsec_offload_off_port_id,
14260 (void *)&cmd_macsec_offload_off_off,
14265 /* Common result structure for MACsec secure connection configure */
14266 struct cmd_macsec_sc_result {
14267 cmdline_fixed_string_t set;
14268 cmdline_fixed_string_t macsec;
14269 cmdline_fixed_string_t sc;
14270 cmdline_fixed_string_t tx_rx;
14272 struct rte_ether_addr mac;
14276 /* Common CLI fields for MACsec secure connection configure */
14277 cmdline_parse_token_string_t cmd_macsec_sc_set =
14278 TOKEN_STRING_INITIALIZER
14279 (struct cmd_macsec_sc_result,
14281 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14282 TOKEN_STRING_INITIALIZER
14283 (struct cmd_macsec_sc_result,
14285 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14286 TOKEN_STRING_INITIALIZER
14287 (struct cmd_macsec_sc_result,
14289 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14290 TOKEN_STRING_INITIALIZER
14291 (struct cmd_macsec_sc_result,
14293 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14294 TOKEN_NUM_INITIALIZER
14295 (struct cmd_macsec_sc_result,
14297 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14298 TOKEN_ETHERADDR_INITIALIZER
14299 (struct cmd_macsec_sc_result,
14301 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14302 TOKEN_NUM_INITIALIZER
14303 (struct cmd_macsec_sc_result,
14307 cmd_set_macsec_sc_parsed(
14308 void *parsed_result,
14309 __attribute__((unused)) struct cmdline *cl,
14310 __attribute__((unused)) void *data)
14312 struct cmd_macsec_sc_result *res = parsed_result;
14313 int ret = -ENOTSUP;
14314 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14316 #ifdef RTE_LIBRTE_IXGBE_PMD
14318 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14319 res->mac.addr_bytes) :
14320 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14321 res->mac.addr_bytes, res->pi);
14323 RTE_SET_USED(is_tx);
14329 printf("invalid port_id %d\n", res->port_id);
14332 printf("not supported on port %d\n", res->port_id);
14335 printf("programming error: (%s)\n", strerror(-ret));
14339 cmdline_parse_inst_t cmd_set_macsec_sc = {
14340 .f = cmd_set_macsec_sc_parsed,
14342 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14344 (void *)&cmd_macsec_sc_set,
14345 (void *)&cmd_macsec_sc_macsec,
14346 (void *)&cmd_macsec_sc_sc,
14347 (void *)&cmd_macsec_sc_tx_rx,
14348 (void *)&cmd_macsec_sc_port_id,
14349 (void *)&cmd_macsec_sc_mac,
14350 (void *)&cmd_macsec_sc_pi,
14355 /* Common result structure for MACsec secure connection configure */
14356 struct cmd_macsec_sa_result {
14357 cmdline_fixed_string_t set;
14358 cmdline_fixed_string_t macsec;
14359 cmdline_fixed_string_t sa;
14360 cmdline_fixed_string_t tx_rx;
14365 cmdline_fixed_string_t key;
14368 /* Common CLI fields for MACsec secure connection configure */
14369 cmdline_parse_token_string_t cmd_macsec_sa_set =
14370 TOKEN_STRING_INITIALIZER
14371 (struct cmd_macsec_sa_result,
14373 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14374 TOKEN_STRING_INITIALIZER
14375 (struct cmd_macsec_sa_result,
14377 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14378 TOKEN_STRING_INITIALIZER
14379 (struct cmd_macsec_sa_result,
14381 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14382 TOKEN_STRING_INITIALIZER
14383 (struct cmd_macsec_sa_result,
14385 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14386 TOKEN_NUM_INITIALIZER
14387 (struct cmd_macsec_sa_result,
14389 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14390 TOKEN_NUM_INITIALIZER
14391 (struct cmd_macsec_sa_result,
14393 cmdline_parse_token_num_t cmd_macsec_sa_an =
14394 TOKEN_NUM_INITIALIZER
14395 (struct cmd_macsec_sa_result,
14397 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14398 TOKEN_NUM_INITIALIZER
14399 (struct cmd_macsec_sa_result,
14401 cmdline_parse_token_string_t cmd_macsec_sa_key =
14402 TOKEN_STRING_INITIALIZER
14403 (struct cmd_macsec_sa_result,
14407 cmd_set_macsec_sa_parsed(
14408 void *parsed_result,
14409 __attribute__((unused)) struct cmdline *cl,
14410 __attribute__((unused)) void *data)
14412 struct cmd_macsec_sa_result *res = parsed_result;
14413 int ret = -ENOTSUP;
14414 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14415 uint8_t key[16] = { 0 };
14421 key_len = strlen(res->key) / 2;
14425 for (i = 0; i < key_len; i++) {
14426 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14429 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14432 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14435 #ifdef RTE_LIBRTE_IXGBE_PMD
14437 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14438 res->idx, res->an, res->pn, key) :
14439 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14440 res->idx, res->an, res->pn, key);
14442 RTE_SET_USED(is_tx);
14449 printf("invalid idx %d or an %d\n", res->idx, res->an);
14452 printf("invalid port_id %d\n", res->port_id);
14455 printf("not supported on port %d\n", res->port_id);
14458 printf("programming error: (%s)\n", strerror(-ret));
14462 cmdline_parse_inst_t cmd_set_macsec_sa = {
14463 .f = cmd_set_macsec_sa_parsed,
14465 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14467 (void *)&cmd_macsec_sa_set,
14468 (void *)&cmd_macsec_sa_macsec,
14469 (void *)&cmd_macsec_sa_sa,
14470 (void *)&cmd_macsec_sa_tx_rx,
14471 (void *)&cmd_macsec_sa_port_id,
14472 (void *)&cmd_macsec_sa_idx,
14473 (void *)&cmd_macsec_sa_an,
14474 (void *)&cmd_macsec_sa_pn,
14475 (void *)&cmd_macsec_sa_key,
14480 /* VF unicast promiscuous mode configuration */
14482 /* Common result structure for VF unicast promiscuous mode */
14483 struct cmd_vf_promisc_result {
14484 cmdline_fixed_string_t set;
14485 cmdline_fixed_string_t vf;
14486 cmdline_fixed_string_t promisc;
14489 cmdline_fixed_string_t on_off;
14492 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14493 cmdline_parse_token_string_t cmd_vf_promisc_set =
14494 TOKEN_STRING_INITIALIZER
14495 (struct cmd_vf_promisc_result,
14497 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14498 TOKEN_STRING_INITIALIZER
14499 (struct cmd_vf_promisc_result,
14501 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14502 TOKEN_STRING_INITIALIZER
14503 (struct cmd_vf_promisc_result,
14504 promisc, "promisc");
14505 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14506 TOKEN_NUM_INITIALIZER
14507 (struct cmd_vf_promisc_result,
14509 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14510 TOKEN_NUM_INITIALIZER
14511 (struct cmd_vf_promisc_result,
14513 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14514 TOKEN_STRING_INITIALIZER
14515 (struct cmd_vf_promisc_result,
14519 cmd_set_vf_promisc_parsed(
14520 void *parsed_result,
14521 __attribute__((unused)) struct cmdline *cl,
14522 __attribute__((unused)) void *data)
14524 struct cmd_vf_promisc_result *res = parsed_result;
14525 int ret = -ENOTSUP;
14527 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14532 #ifdef RTE_LIBRTE_I40E_PMD
14533 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14534 res->vf_id, is_on);
14541 printf("invalid vf_id %d\n", res->vf_id);
14544 printf("invalid port_id %d\n", res->port_id);
14547 printf("function not implemented\n");
14550 printf("programming error: (%s)\n", strerror(-ret));
14554 cmdline_parse_inst_t cmd_set_vf_promisc = {
14555 .f = cmd_set_vf_promisc_parsed,
14557 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14558 "Set unicast promiscuous mode for a VF from the PF",
14560 (void *)&cmd_vf_promisc_set,
14561 (void *)&cmd_vf_promisc_vf,
14562 (void *)&cmd_vf_promisc_promisc,
14563 (void *)&cmd_vf_promisc_port_id,
14564 (void *)&cmd_vf_promisc_vf_id,
14565 (void *)&cmd_vf_promisc_on_off,
14570 /* VF multicast promiscuous mode configuration */
14572 /* Common result structure for VF multicast promiscuous mode */
14573 struct cmd_vf_allmulti_result {
14574 cmdline_fixed_string_t set;
14575 cmdline_fixed_string_t vf;
14576 cmdline_fixed_string_t allmulti;
14579 cmdline_fixed_string_t on_off;
14582 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14583 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14584 TOKEN_STRING_INITIALIZER
14585 (struct cmd_vf_allmulti_result,
14587 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14588 TOKEN_STRING_INITIALIZER
14589 (struct cmd_vf_allmulti_result,
14591 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14592 TOKEN_STRING_INITIALIZER
14593 (struct cmd_vf_allmulti_result,
14594 allmulti, "allmulti");
14595 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14596 TOKEN_NUM_INITIALIZER
14597 (struct cmd_vf_allmulti_result,
14599 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14600 TOKEN_NUM_INITIALIZER
14601 (struct cmd_vf_allmulti_result,
14603 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14604 TOKEN_STRING_INITIALIZER
14605 (struct cmd_vf_allmulti_result,
14609 cmd_set_vf_allmulti_parsed(
14610 void *parsed_result,
14611 __attribute__((unused)) struct cmdline *cl,
14612 __attribute__((unused)) void *data)
14614 struct cmd_vf_allmulti_result *res = parsed_result;
14615 int ret = -ENOTSUP;
14617 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14619 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14622 #ifdef RTE_LIBRTE_I40E_PMD
14623 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14624 res->vf_id, is_on);
14631 printf("invalid vf_id %d\n", res->vf_id);
14634 printf("invalid port_id %d\n", res->port_id);
14637 printf("function not implemented\n");
14640 printf("programming error: (%s)\n", strerror(-ret));
14644 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14645 .f = cmd_set_vf_allmulti_parsed,
14647 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14648 "Set multicast promiscuous mode for a VF from the PF",
14650 (void *)&cmd_vf_allmulti_set,
14651 (void *)&cmd_vf_allmulti_vf,
14652 (void *)&cmd_vf_allmulti_allmulti,
14653 (void *)&cmd_vf_allmulti_port_id,
14654 (void *)&cmd_vf_allmulti_vf_id,
14655 (void *)&cmd_vf_allmulti_on_off,
14660 /* vf broadcast mode configuration */
14662 /* Common result structure for vf broadcast */
14663 struct cmd_set_vf_broadcast_result {
14664 cmdline_fixed_string_t set;
14665 cmdline_fixed_string_t vf;
14666 cmdline_fixed_string_t broadcast;
14669 cmdline_fixed_string_t on_off;
14672 /* Common CLI fields for vf broadcast enable disable */
14673 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14674 TOKEN_STRING_INITIALIZER
14675 (struct cmd_set_vf_broadcast_result,
14677 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14678 TOKEN_STRING_INITIALIZER
14679 (struct cmd_set_vf_broadcast_result,
14681 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14682 TOKEN_STRING_INITIALIZER
14683 (struct cmd_set_vf_broadcast_result,
14684 broadcast, "broadcast");
14685 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14686 TOKEN_NUM_INITIALIZER
14687 (struct cmd_set_vf_broadcast_result,
14689 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14690 TOKEN_NUM_INITIALIZER
14691 (struct cmd_set_vf_broadcast_result,
14693 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14694 TOKEN_STRING_INITIALIZER
14695 (struct cmd_set_vf_broadcast_result,
14699 cmd_set_vf_broadcast_parsed(
14700 void *parsed_result,
14701 __attribute__((unused)) struct cmdline *cl,
14702 __attribute__((unused)) void *data)
14704 struct cmd_set_vf_broadcast_result *res = parsed_result;
14705 int ret = -ENOTSUP;
14707 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14712 #ifdef RTE_LIBRTE_I40E_PMD
14713 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14714 res->vf_id, is_on);
14721 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14724 printf("invalid port_id %d\n", res->port_id);
14727 printf("function not implemented\n");
14730 printf("programming error: (%s)\n", strerror(-ret));
14734 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14735 .f = cmd_set_vf_broadcast_parsed,
14737 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14739 (void *)&cmd_set_vf_broadcast_set,
14740 (void *)&cmd_set_vf_broadcast_vf,
14741 (void *)&cmd_set_vf_broadcast_broadcast,
14742 (void *)&cmd_set_vf_broadcast_port_id,
14743 (void *)&cmd_set_vf_broadcast_vf_id,
14744 (void *)&cmd_set_vf_broadcast_on_off,
14749 /* vf vlan tag configuration */
14751 /* Common result structure for vf vlan tag */
14752 struct cmd_set_vf_vlan_tag_result {
14753 cmdline_fixed_string_t set;
14754 cmdline_fixed_string_t vf;
14755 cmdline_fixed_string_t vlan;
14756 cmdline_fixed_string_t tag;
14759 cmdline_fixed_string_t on_off;
14762 /* Common CLI fields for vf vlan tag enable disable */
14763 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14764 TOKEN_STRING_INITIALIZER
14765 (struct cmd_set_vf_vlan_tag_result,
14767 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14768 TOKEN_STRING_INITIALIZER
14769 (struct cmd_set_vf_vlan_tag_result,
14771 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14772 TOKEN_STRING_INITIALIZER
14773 (struct cmd_set_vf_vlan_tag_result,
14775 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14776 TOKEN_STRING_INITIALIZER
14777 (struct cmd_set_vf_vlan_tag_result,
14779 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14780 TOKEN_NUM_INITIALIZER
14781 (struct cmd_set_vf_vlan_tag_result,
14783 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14784 TOKEN_NUM_INITIALIZER
14785 (struct cmd_set_vf_vlan_tag_result,
14787 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14788 TOKEN_STRING_INITIALIZER
14789 (struct cmd_set_vf_vlan_tag_result,
14793 cmd_set_vf_vlan_tag_parsed(
14794 void *parsed_result,
14795 __attribute__((unused)) struct cmdline *cl,
14796 __attribute__((unused)) void *data)
14798 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14799 int ret = -ENOTSUP;
14801 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14806 #ifdef RTE_LIBRTE_I40E_PMD
14807 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14808 res->vf_id, is_on);
14815 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14818 printf("invalid port_id %d\n", res->port_id);
14821 printf("function not implemented\n");
14824 printf("programming error: (%s)\n", strerror(-ret));
14828 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14829 .f = cmd_set_vf_vlan_tag_parsed,
14831 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14833 (void *)&cmd_set_vf_vlan_tag_set,
14834 (void *)&cmd_set_vf_vlan_tag_vf,
14835 (void *)&cmd_set_vf_vlan_tag_vlan,
14836 (void *)&cmd_set_vf_vlan_tag_tag,
14837 (void *)&cmd_set_vf_vlan_tag_port_id,
14838 (void *)&cmd_set_vf_vlan_tag_vf_id,
14839 (void *)&cmd_set_vf_vlan_tag_on_off,
14844 /* Common definition of VF and TC TX bandwidth configuration */
14845 struct cmd_vf_tc_bw_result {
14846 cmdline_fixed_string_t set;
14847 cmdline_fixed_string_t vf;
14848 cmdline_fixed_string_t tc;
14849 cmdline_fixed_string_t tx;
14850 cmdline_fixed_string_t min_bw;
14851 cmdline_fixed_string_t max_bw;
14852 cmdline_fixed_string_t strict_link_prio;
14857 cmdline_fixed_string_t bw_list;
14861 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14862 TOKEN_STRING_INITIALIZER
14863 (struct cmd_vf_tc_bw_result,
14865 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14866 TOKEN_STRING_INITIALIZER
14867 (struct cmd_vf_tc_bw_result,
14869 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14870 TOKEN_STRING_INITIALIZER
14871 (struct cmd_vf_tc_bw_result,
14873 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14874 TOKEN_STRING_INITIALIZER
14875 (struct cmd_vf_tc_bw_result,
14877 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14878 TOKEN_STRING_INITIALIZER
14879 (struct cmd_vf_tc_bw_result,
14880 strict_link_prio, "strict-link-priority");
14881 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14882 TOKEN_STRING_INITIALIZER
14883 (struct cmd_vf_tc_bw_result,
14884 min_bw, "min-bandwidth");
14885 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14886 TOKEN_STRING_INITIALIZER
14887 (struct cmd_vf_tc_bw_result,
14888 max_bw, "max-bandwidth");
14889 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14890 TOKEN_NUM_INITIALIZER
14891 (struct cmd_vf_tc_bw_result,
14893 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14894 TOKEN_NUM_INITIALIZER
14895 (struct cmd_vf_tc_bw_result,
14897 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14898 TOKEN_NUM_INITIALIZER
14899 (struct cmd_vf_tc_bw_result,
14901 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14902 TOKEN_NUM_INITIALIZER
14903 (struct cmd_vf_tc_bw_result,
14905 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14906 TOKEN_STRING_INITIALIZER
14907 (struct cmd_vf_tc_bw_result,
14909 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14910 TOKEN_NUM_INITIALIZER
14911 (struct cmd_vf_tc_bw_result,
14914 /* VF max bandwidth setting */
14916 cmd_vf_max_bw_parsed(
14917 void *parsed_result,
14918 __attribute__((unused)) struct cmdline *cl,
14919 __attribute__((unused)) void *data)
14921 struct cmd_vf_tc_bw_result *res = parsed_result;
14922 int ret = -ENOTSUP;
14924 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14927 #ifdef RTE_LIBRTE_I40E_PMD
14928 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14929 res->vf_id, res->bw);
14936 printf("invalid vf_id %d or bandwidth %d\n",
14937 res->vf_id, res->bw);
14940 printf("invalid port_id %d\n", res->port_id);
14943 printf("function not implemented\n");
14946 printf("programming error: (%s)\n", strerror(-ret));
14950 cmdline_parse_inst_t cmd_vf_max_bw = {
14951 .f = cmd_vf_max_bw_parsed,
14953 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14955 (void *)&cmd_vf_tc_bw_set,
14956 (void *)&cmd_vf_tc_bw_vf,
14957 (void *)&cmd_vf_tc_bw_tx,
14958 (void *)&cmd_vf_tc_bw_max_bw,
14959 (void *)&cmd_vf_tc_bw_port_id,
14960 (void *)&cmd_vf_tc_bw_vf_id,
14961 (void *)&cmd_vf_tc_bw_bw,
14967 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14972 const char *p, *p0 = str;
14979 p = strchr(p0, '(');
14981 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14985 p0 = strchr(p, ')');
14987 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14991 if (size >= sizeof(s)) {
14992 printf("The string size exceeds the internal buffer size\n");
14995 snprintf(s, sizeof(s), "%.*s", size, p);
14996 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14998 printf("Failed to get the bandwidth list. ");
15002 for (i = 0; i < ret; i++)
15003 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15008 /* TC min bandwidth setting */
15010 cmd_vf_tc_min_bw_parsed(
15011 void *parsed_result,
15012 __attribute__((unused)) struct cmdline *cl,
15013 __attribute__((unused)) void *data)
15015 struct cmd_vf_tc_bw_result *res = parsed_result;
15018 int ret = -ENOTSUP;
15020 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15023 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15027 #ifdef RTE_LIBRTE_I40E_PMD
15028 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15036 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15039 printf("invalid port_id %d\n", res->port_id);
15042 printf("function not implemented\n");
15045 printf("programming error: (%s)\n", strerror(-ret));
15049 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15050 .f = cmd_vf_tc_min_bw_parsed,
15052 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15053 " <bw1, bw2, ...>",
15055 (void *)&cmd_vf_tc_bw_set,
15056 (void *)&cmd_vf_tc_bw_vf,
15057 (void *)&cmd_vf_tc_bw_tc,
15058 (void *)&cmd_vf_tc_bw_tx,
15059 (void *)&cmd_vf_tc_bw_min_bw,
15060 (void *)&cmd_vf_tc_bw_port_id,
15061 (void *)&cmd_vf_tc_bw_vf_id,
15062 (void *)&cmd_vf_tc_bw_bw_list,
15068 cmd_tc_min_bw_parsed(
15069 void *parsed_result,
15070 __attribute__((unused)) struct cmdline *cl,
15071 __attribute__((unused)) void *data)
15073 struct cmd_vf_tc_bw_result *res = parsed_result;
15074 struct rte_port *port;
15077 int ret = -ENOTSUP;
15079 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15082 port = &ports[res->port_id];
15083 /** Check if the port is not started **/
15084 if (port->port_status != RTE_PORT_STOPPED) {
15085 printf("Please stop port %d first\n", res->port_id);
15089 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15093 #ifdef RTE_LIBRTE_IXGBE_PMD
15094 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15101 printf("invalid bandwidth\n");
15104 printf("invalid port_id %d\n", res->port_id);
15107 printf("function not implemented\n");
15110 printf("programming error: (%s)\n", strerror(-ret));
15114 cmdline_parse_inst_t cmd_tc_min_bw = {
15115 .f = cmd_tc_min_bw_parsed,
15117 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15119 (void *)&cmd_vf_tc_bw_set,
15120 (void *)&cmd_vf_tc_bw_tc,
15121 (void *)&cmd_vf_tc_bw_tx,
15122 (void *)&cmd_vf_tc_bw_min_bw,
15123 (void *)&cmd_vf_tc_bw_port_id,
15124 (void *)&cmd_vf_tc_bw_bw_list,
15129 /* TC max bandwidth setting */
15131 cmd_vf_tc_max_bw_parsed(
15132 void *parsed_result,
15133 __attribute__((unused)) struct cmdline *cl,
15134 __attribute__((unused)) void *data)
15136 struct cmd_vf_tc_bw_result *res = parsed_result;
15137 int ret = -ENOTSUP;
15139 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15142 #ifdef RTE_LIBRTE_I40E_PMD
15143 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15144 res->tc_no, res->bw);
15151 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15152 res->vf_id, res->tc_no, res->bw);
15155 printf("invalid port_id %d\n", res->port_id);
15158 printf("function not implemented\n");
15161 printf("programming error: (%s)\n", strerror(-ret));
15165 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15166 .f = cmd_vf_tc_max_bw_parsed,
15168 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15171 (void *)&cmd_vf_tc_bw_set,
15172 (void *)&cmd_vf_tc_bw_vf,
15173 (void *)&cmd_vf_tc_bw_tc,
15174 (void *)&cmd_vf_tc_bw_tx,
15175 (void *)&cmd_vf_tc_bw_max_bw,
15176 (void *)&cmd_vf_tc_bw_port_id,
15177 (void *)&cmd_vf_tc_bw_vf_id,
15178 (void *)&cmd_vf_tc_bw_tc_no,
15179 (void *)&cmd_vf_tc_bw_bw,
15185 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15187 /* *** Set Port default Traffic Management Hierarchy *** */
15188 struct cmd_set_port_tm_hierarchy_default_result {
15189 cmdline_fixed_string_t set;
15190 cmdline_fixed_string_t port;
15191 cmdline_fixed_string_t tm;
15192 cmdline_fixed_string_t hierarchy;
15193 cmdline_fixed_string_t def;
15197 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15198 TOKEN_STRING_INITIALIZER(
15199 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15200 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15201 TOKEN_STRING_INITIALIZER(
15202 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15203 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15204 TOKEN_STRING_INITIALIZER(
15205 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15206 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15207 TOKEN_STRING_INITIALIZER(
15208 struct cmd_set_port_tm_hierarchy_default_result,
15209 hierarchy, "hierarchy");
15210 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15211 TOKEN_STRING_INITIALIZER(
15212 struct cmd_set_port_tm_hierarchy_default_result,
15214 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15215 TOKEN_NUM_INITIALIZER(
15216 struct cmd_set_port_tm_hierarchy_default_result,
15219 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15220 __attribute__((unused)) struct cmdline *cl,
15221 __attribute__((unused)) void *data)
15223 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15224 struct rte_port *p;
15225 portid_t port_id = res->port_id;
15227 if (port_id_is_invalid(port_id, ENABLED_WARN))
15230 p = &ports[port_id];
15232 /* Forward mode: tm */
15233 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15234 printf(" softnicfwd mode not enabled(error)\n");
15238 /* Set the default tm hierarchy */
15239 p->softport.default_tm_hierarchy_enable = 1;
15242 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15243 .f = cmd_set_port_tm_hierarchy_default_parsed,
15245 .help_str = "set port tm hierarchy default <port_id>",
15247 (void *)&cmd_set_port_tm_hierarchy_default_set,
15248 (void *)&cmd_set_port_tm_hierarchy_default_port,
15249 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15250 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15251 (void *)&cmd_set_port_tm_hierarchy_default_default,
15252 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15258 /** Set VXLAN encapsulation details */
15259 struct cmd_set_vxlan_result {
15260 cmdline_fixed_string_t set;
15261 cmdline_fixed_string_t vxlan;
15262 cmdline_fixed_string_t pos_token;
15263 cmdline_fixed_string_t ip_version;
15264 uint32_t vlan_present:1;
15268 cmdline_ipaddr_t ip_src;
15269 cmdline_ipaddr_t ip_dst;
15273 struct rte_ether_addr eth_src;
15274 struct rte_ether_addr eth_dst;
15277 cmdline_parse_token_string_t cmd_set_vxlan_set =
15278 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15279 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15280 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15281 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15282 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15284 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15285 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15286 "vxlan-with-vlan");
15287 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15288 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15290 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15291 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15293 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15294 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15296 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15297 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15298 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15299 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15301 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15302 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15303 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15304 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15306 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15307 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15308 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15309 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15311 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15312 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15313 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15314 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15316 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15317 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15318 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15319 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15321 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15322 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15323 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15324 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15326 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15327 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15328 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15329 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15331 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15332 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15333 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15334 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15336 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15337 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15338 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15339 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15341 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15342 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15344 static void cmd_set_vxlan_parsed(void *parsed_result,
15345 __attribute__((unused)) struct cmdline *cl,
15346 __attribute__((unused)) void *data)
15348 struct cmd_set_vxlan_result *res = parsed_result;
15353 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15356 vxlan_encap_conf.select_tos_ttl = 0;
15357 if (strcmp(res->vxlan, "vxlan") == 0)
15358 vxlan_encap_conf.select_vlan = 0;
15359 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15360 vxlan_encap_conf.select_vlan = 1;
15361 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15362 vxlan_encap_conf.select_vlan = 0;
15363 vxlan_encap_conf.select_tos_ttl = 1;
15365 if (strcmp(res->ip_version, "ipv4") == 0)
15366 vxlan_encap_conf.select_ipv4 = 1;
15367 else if (strcmp(res->ip_version, "ipv6") == 0)
15368 vxlan_encap_conf.select_ipv4 = 0;
15371 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15372 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15373 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15374 vxlan_encap_conf.ip_tos = res->tos;
15375 vxlan_encap_conf.ip_ttl = res->ttl;
15376 if (vxlan_encap_conf.select_ipv4) {
15377 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15378 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15380 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15381 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15383 if (vxlan_encap_conf.select_vlan)
15384 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15385 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15386 RTE_ETHER_ADDR_LEN);
15387 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15388 RTE_ETHER_ADDR_LEN);
15391 cmdline_parse_inst_t cmd_set_vxlan = {
15392 .f = cmd_set_vxlan_parsed,
15394 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15395 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15396 " eth-src <eth-src> eth-dst <eth-dst>",
15398 (void *)&cmd_set_vxlan_set,
15399 (void *)&cmd_set_vxlan_vxlan,
15400 (void *)&cmd_set_vxlan_ip_version,
15401 (void *)&cmd_set_vxlan_ip_version_value,
15402 (void *)&cmd_set_vxlan_vni,
15403 (void *)&cmd_set_vxlan_vni_value,
15404 (void *)&cmd_set_vxlan_udp_src,
15405 (void *)&cmd_set_vxlan_udp_src_value,
15406 (void *)&cmd_set_vxlan_udp_dst,
15407 (void *)&cmd_set_vxlan_udp_dst_value,
15408 (void *)&cmd_set_vxlan_ip_src,
15409 (void *)&cmd_set_vxlan_ip_src_value,
15410 (void *)&cmd_set_vxlan_ip_dst,
15411 (void *)&cmd_set_vxlan_ip_dst_value,
15412 (void *)&cmd_set_vxlan_eth_src,
15413 (void *)&cmd_set_vxlan_eth_src_value,
15414 (void *)&cmd_set_vxlan_eth_dst,
15415 (void *)&cmd_set_vxlan_eth_dst_value,
15420 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15421 .f = cmd_set_vxlan_parsed,
15423 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15424 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15425 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15426 " eth-dst <eth-dst>",
15428 (void *)&cmd_set_vxlan_set,
15429 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15430 (void *)&cmd_set_vxlan_ip_version,
15431 (void *)&cmd_set_vxlan_ip_version_value,
15432 (void *)&cmd_set_vxlan_vni,
15433 (void *)&cmd_set_vxlan_vni_value,
15434 (void *)&cmd_set_vxlan_udp_src,
15435 (void *)&cmd_set_vxlan_udp_src_value,
15436 (void *)&cmd_set_vxlan_udp_dst,
15437 (void *)&cmd_set_vxlan_udp_dst_value,
15438 (void *)&cmd_set_vxlan_ip_tos,
15439 (void *)&cmd_set_vxlan_ip_tos_value,
15440 (void *)&cmd_set_vxlan_ip_ttl,
15441 (void *)&cmd_set_vxlan_ip_ttl_value,
15442 (void *)&cmd_set_vxlan_ip_src,
15443 (void *)&cmd_set_vxlan_ip_src_value,
15444 (void *)&cmd_set_vxlan_ip_dst,
15445 (void *)&cmd_set_vxlan_ip_dst_value,
15446 (void *)&cmd_set_vxlan_eth_src,
15447 (void *)&cmd_set_vxlan_eth_src_value,
15448 (void *)&cmd_set_vxlan_eth_dst,
15449 (void *)&cmd_set_vxlan_eth_dst_value,
15454 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15455 .f = cmd_set_vxlan_parsed,
15457 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15458 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15459 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15462 (void *)&cmd_set_vxlan_set,
15463 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15464 (void *)&cmd_set_vxlan_ip_version,
15465 (void *)&cmd_set_vxlan_ip_version_value,
15466 (void *)&cmd_set_vxlan_vni,
15467 (void *)&cmd_set_vxlan_vni_value,
15468 (void *)&cmd_set_vxlan_udp_src,
15469 (void *)&cmd_set_vxlan_udp_src_value,
15470 (void *)&cmd_set_vxlan_udp_dst,
15471 (void *)&cmd_set_vxlan_udp_dst_value,
15472 (void *)&cmd_set_vxlan_ip_src,
15473 (void *)&cmd_set_vxlan_ip_src_value,
15474 (void *)&cmd_set_vxlan_ip_dst,
15475 (void *)&cmd_set_vxlan_ip_dst_value,
15476 (void *)&cmd_set_vxlan_vlan,
15477 (void *)&cmd_set_vxlan_vlan_value,
15478 (void *)&cmd_set_vxlan_eth_src,
15479 (void *)&cmd_set_vxlan_eth_src_value,
15480 (void *)&cmd_set_vxlan_eth_dst,
15481 (void *)&cmd_set_vxlan_eth_dst_value,
15486 /** Set NVGRE encapsulation details */
15487 struct cmd_set_nvgre_result {
15488 cmdline_fixed_string_t set;
15489 cmdline_fixed_string_t nvgre;
15490 cmdline_fixed_string_t pos_token;
15491 cmdline_fixed_string_t ip_version;
15493 cmdline_ipaddr_t ip_src;
15494 cmdline_ipaddr_t ip_dst;
15496 struct rte_ether_addr eth_src;
15497 struct rte_ether_addr eth_dst;
15500 cmdline_parse_token_string_t cmd_set_nvgre_set =
15501 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15502 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15503 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15504 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15505 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15506 "nvgre-with-vlan");
15507 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15508 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15510 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15511 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15513 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15514 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15516 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15517 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15518 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15519 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15521 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15522 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15523 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15524 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15526 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15527 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15528 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15529 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15531 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15532 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15533 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15534 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15536 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15537 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15538 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15539 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15541 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15542 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15544 static void cmd_set_nvgre_parsed(void *parsed_result,
15545 __attribute__((unused)) struct cmdline *cl,
15546 __attribute__((unused)) void *data)
15548 struct cmd_set_nvgre_result *res = parsed_result;
15550 uint32_t nvgre_tni;
15553 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15556 if (strcmp(res->nvgre, "nvgre") == 0)
15557 nvgre_encap_conf.select_vlan = 0;
15558 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15559 nvgre_encap_conf.select_vlan = 1;
15560 if (strcmp(res->ip_version, "ipv4") == 0)
15561 nvgre_encap_conf.select_ipv4 = 1;
15562 else if (strcmp(res->ip_version, "ipv6") == 0)
15563 nvgre_encap_conf.select_ipv4 = 0;
15566 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15567 if (nvgre_encap_conf.select_ipv4) {
15568 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15569 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15571 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15572 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15574 if (nvgre_encap_conf.select_vlan)
15575 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15576 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15577 RTE_ETHER_ADDR_LEN);
15578 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15579 RTE_ETHER_ADDR_LEN);
15582 cmdline_parse_inst_t cmd_set_nvgre = {
15583 .f = cmd_set_nvgre_parsed,
15585 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15586 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15587 " eth-dst <eth-dst>",
15589 (void *)&cmd_set_nvgre_set,
15590 (void *)&cmd_set_nvgre_nvgre,
15591 (void *)&cmd_set_nvgre_ip_version,
15592 (void *)&cmd_set_nvgre_ip_version_value,
15593 (void *)&cmd_set_nvgre_tni,
15594 (void *)&cmd_set_nvgre_tni_value,
15595 (void *)&cmd_set_nvgre_ip_src,
15596 (void *)&cmd_set_nvgre_ip_src_value,
15597 (void *)&cmd_set_nvgre_ip_dst,
15598 (void *)&cmd_set_nvgre_ip_dst_value,
15599 (void *)&cmd_set_nvgre_eth_src,
15600 (void *)&cmd_set_nvgre_eth_src_value,
15601 (void *)&cmd_set_nvgre_eth_dst,
15602 (void *)&cmd_set_nvgre_eth_dst_value,
15607 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15608 .f = cmd_set_nvgre_parsed,
15610 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15611 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15612 " eth-src <eth-src> eth-dst <eth-dst>",
15614 (void *)&cmd_set_nvgre_set,
15615 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15616 (void *)&cmd_set_nvgre_ip_version,
15617 (void *)&cmd_set_nvgre_ip_version_value,
15618 (void *)&cmd_set_nvgre_tni,
15619 (void *)&cmd_set_nvgre_tni_value,
15620 (void *)&cmd_set_nvgre_ip_src,
15621 (void *)&cmd_set_nvgre_ip_src_value,
15622 (void *)&cmd_set_nvgre_ip_dst,
15623 (void *)&cmd_set_nvgre_ip_dst_value,
15624 (void *)&cmd_set_nvgre_vlan,
15625 (void *)&cmd_set_nvgre_vlan_value,
15626 (void *)&cmd_set_nvgre_eth_src,
15627 (void *)&cmd_set_nvgre_eth_src_value,
15628 (void *)&cmd_set_nvgre_eth_dst,
15629 (void *)&cmd_set_nvgre_eth_dst_value,
15634 /** Set L2 encapsulation details */
15635 struct cmd_set_l2_encap_result {
15636 cmdline_fixed_string_t set;
15637 cmdline_fixed_string_t l2_encap;
15638 cmdline_fixed_string_t pos_token;
15639 cmdline_fixed_string_t ip_version;
15640 uint32_t vlan_present:1;
15642 struct rte_ether_addr eth_src;
15643 struct rte_ether_addr eth_dst;
15646 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15647 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15648 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15649 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15650 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15651 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15652 "l2_encap-with-vlan");
15653 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15654 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15656 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15657 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15659 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15660 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15662 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15663 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15664 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15665 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15667 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15668 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15669 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15670 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15672 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15673 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15675 static void cmd_set_l2_encap_parsed(void *parsed_result,
15676 __attribute__((unused)) struct cmdline *cl,
15677 __attribute__((unused)) void *data)
15679 struct cmd_set_l2_encap_result *res = parsed_result;
15681 if (strcmp(res->l2_encap, "l2_encap") == 0)
15682 l2_encap_conf.select_vlan = 0;
15683 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15684 l2_encap_conf.select_vlan = 1;
15685 if (strcmp(res->ip_version, "ipv4") == 0)
15686 l2_encap_conf.select_ipv4 = 1;
15687 else if (strcmp(res->ip_version, "ipv6") == 0)
15688 l2_encap_conf.select_ipv4 = 0;
15691 if (l2_encap_conf.select_vlan)
15692 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15693 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15694 RTE_ETHER_ADDR_LEN);
15695 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15696 RTE_ETHER_ADDR_LEN);
15699 cmdline_parse_inst_t cmd_set_l2_encap = {
15700 .f = cmd_set_l2_encap_parsed,
15702 .help_str = "set l2_encap ip-version ipv4|ipv6"
15703 " eth-src <eth-src> eth-dst <eth-dst>",
15705 (void *)&cmd_set_l2_encap_set,
15706 (void *)&cmd_set_l2_encap_l2_encap,
15707 (void *)&cmd_set_l2_encap_ip_version,
15708 (void *)&cmd_set_l2_encap_ip_version_value,
15709 (void *)&cmd_set_l2_encap_eth_src,
15710 (void *)&cmd_set_l2_encap_eth_src_value,
15711 (void *)&cmd_set_l2_encap_eth_dst,
15712 (void *)&cmd_set_l2_encap_eth_dst_value,
15717 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15718 .f = cmd_set_l2_encap_parsed,
15720 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15721 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15723 (void *)&cmd_set_l2_encap_set,
15724 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15725 (void *)&cmd_set_l2_encap_ip_version,
15726 (void *)&cmd_set_l2_encap_ip_version_value,
15727 (void *)&cmd_set_l2_encap_vlan,
15728 (void *)&cmd_set_l2_encap_vlan_value,
15729 (void *)&cmd_set_l2_encap_eth_src,
15730 (void *)&cmd_set_l2_encap_eth_src_value,
15731 (void *)&cmd_set_l2_encap_eth_dst,
15732 (void *)&cmd_set_l2_encap_eth_dst_value,
15737 /** Set L2 decapsulation details */
15738 struct cmd_set_l2_decap_result {
15739 cmdline_fixed_string_t set;
15740 cmdline_fixed_string_t l2_decap;
15741 cmdline_fixed_string_t pos_token;
15742 uint32_t vlan_present:1;
15745 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15746 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15747 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15748 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15750 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15751 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15752 "l2_decap-with-vlan");
15754 static void cmd_set_l2_decap_parsed(void *parsed_result,
15755 __attribute__((unused)) struct cmdline *cl,
15756 __attribute__((unused)) void *data)
15758 struct cmd_set_l2_decap_result *res = parsed_result;
15760 if (strcmp(res->l2_decap, "l2_decap") == 0)
15761 l2_decap_conf.select_vlan = 0;
15762 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15763 l2_decap_conf.select_vlan = 1;
15766 cmdline_parse_inst_t cmd_set_l2_decap = {
15767 .f = cmd_set_l2_decap_parsed,
15769 .help_str = "set l2_decap",
15771 (void *)&cmd_set_l2_decap_set,
15772 (void *)&cmd_set_l2_decap_l2_decap,
15777 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15778 .f = cmd_set_l2_decap_parsed,
15780 .help_str = "set l2_decap-with-vlan",
15782 (void *)&cmd_set_l2_decap_set,
15783 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15788 /** Set MPLSoGRE encapsulation details */
15789 struct cmd_set_mplsogre_encap_result {
15790 cmdline_fixed_string_t set;
15791 cmdline_fixed_string_t mplsogre;
15792 cmdline_fixed_string_t pos_token;
15793 cmdline_fixed_string_t ip_version;
15794 uint32_t vlan_present:1;
15796 cmdline_ipaddr_t ip_src;
15797 cmdline_ipaddr_t ip_dst;
15799 struct rte_ether_addr eth_src;
15800 struct rte_ether_addr eth_dst;
15803 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15804 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15806 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15807 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15809 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15810 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15811 mplsogre, "mplsogre_encap-with-vlan");
15812 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15813 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15814 pos_token, "ip-version");
15815 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15816 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15817 ip_version, "ipv4#ipv6");
15818 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15819 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15820 pos_token, "label");
15821 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15822 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15824 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15825 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15826 pos_token, "ip-src");
15827 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15828 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15829 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15830 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15831 pos_token, "ip-dst");
15832 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15833 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15834 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15835 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15836 pos_token, "vlan-tci");
15837 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15838 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15840 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15841 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15842 pos_token, "eth-src");
15843 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15844 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15846 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15847 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15848 pos_token, "eth-dst");
15849 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15850 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15853 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15854 __attribute__((unused)) struct cmdline *cl,
15855 __attribute__((unused)) void *data)
15857 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15859 uint32_t mplsogre_label;
15862 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15865 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15866 mplsogre_encap_conf.select_vlan = 0;
15867 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15868 mplsogre_encap_conf.select_vlan = 1;
15869 if (strcmp(res->ip_version, "ipv4") == 0)
15870 mplsogre_encap_conf.select_ipv4 = 1;
15871 else if (strcmp(res->ip_version, "ipv6") == 0)
15872 mplsogre_encap_conf.select_ipv4 = 0;
15875 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15876 if (mplsogre_encap_conf.select_ipv4) {
15877 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15878 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15880 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15881 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15883 if (mplsogre_encap_conf.select_vlan)
15884 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15885 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15886 RTE_ETHER_ADDR_LEN);
15887 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15888 RTE_ETHER_ADDR_LEN);
15891 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15892 .f = cmd_set_mplsogre_encap_parsed,
15894 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15895 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15896 " eth-dst <eth-dst>",
15898 (void *)&cmd_set_mplsogre_encap_set,
15899 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15900 (void *)&cmd_set_mplsogre_encap_ip_version,
15901 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15902 (void *)&cmd_set_mplsogre_encap_label,
15903 (void *)&cmd_set_mplsogre_encap_label_value,
15904 (void *)&cmd_set_mplsogre_encap_ip_src,
15905 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15906 (void *)&cmd_set_mplsogre_encap_ip_dst,
15907 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15908 (void *)&cmd_set_mplsogre_encap_eth_src,
15909 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15910 (void *)&cmd_set_mplsogre_encap_eth_dst,
15911 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15916 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15917 .f = cmd_set_mplsogre_encap_parsed,
15919 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15920 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15921 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15923 (void *)&cmd_set_mplsogre_encap_set,
15924 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15925 (void *)&cmd_set_mplsogre_encap_ip_version,
15926 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15927 (void *)&cmd_set_mplsogre_encap_label,
15928 (void *)&cmd_set_mplsogre_encap_label_value,
15929 (void *)&cmd_set_mplsogre_encap_ip_src,
15930 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15931 (void *)&cmd_set_mplsogre_encap_ip_dst,
15932 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15933 (void *)&cmd_set_mplsogre_encap_vlan,
15934 (void *)&cmd_set_mplsogre_encap_vlan_value,
15935 (void *)&cmd_set_mplsogre_encap_eth_src,
15936 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15937 (void *)&cmd_set_mplsogre_encap_eth_dst,
15938 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15943 /** Set MPLSoGRE decapsulation details */
15944 struct cmd_set_mplsogre_decap_result {
15945 cmdline_fixed_string_t set;
15946 cmdline_fixed_string_t mplsogre;
15947 cmdline_fixed_string_t pos_token;
15948 cmdline_fixed_string_t ip_version;
15949 uint32_t vlan_present:1;
15952 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15953 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15955 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15956 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15958 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15959 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15960 mplsogre, "mplsogre_decap-with-vlan");
15961 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15962 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15963 pos_token, "ip-version");
15964 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15965 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15966 ip_version, "ipv4#ipv6");
15968 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15969 __attribute__((unused)) struct cmdline *cl,
15970 __attribute__((unused)) void *data)
15972 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15974 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15975 mplsogre_decap_conf.select_vlan = 0;
15976 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15977 mplsogre_decap_conf.select_vlan = 1;
15978 if (strcmp(res->ip_version, "ipv4") == 0)
15979 mplsogre_decap_conf.select_ipv4 = 1;
15980 else if (strcmp(res->ip_version, "ipv6") == 0)
15981 mplsogre_decap_conf.select_ipv4 = 0;
15984 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15985 .f = cmd_set_mplsogre_decap_parsed,
15987 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15989 (void *)&cmd_set_mplsogre_decap_set,
15990 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15991 (void *)&cmd_set_mplsogre_decap_ip_version,
15992 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15997 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15998 .f = cmd_set_mplsogre_decap_parsed,
16000 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16002 (void *)&cmd_set_mplsogre_decap_set,
16003 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16004 (void *)&cmd_set_mplsogre_decap_ip_version,
16005 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16010 /** Set MPLSoUDP encapsulation details */
16011 struct cmd_set_mplsoudp_encap_result {
16012 cmdline_fixed_string_t set;
16013 cmdline_fixed_string_t mplsoudp;
16014 cmdline_fixed_string_t pos_token;
16015 cmdline_fixed_string_t ip_version;
16016 uint32_t vlan_present:1;
16020 cmdline_ipaddr_t ip_src;
16021 cmdline_ipaddr_t ip_dst;
16023 struct rte_ether_addr eth_src;
16024 struct rte_ether_addr eth_dst;
16027 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16028 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16030 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16031 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16033 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16035 mplsoudp, "mplsoudp_encap-with-vlan");
16036 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16037 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16038 pos_token, "ip-version");
16039 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16040 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16041 ip_version, "ipv4#ipv6");
16042 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16043 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16044 pos_token, "label");
16045 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16046 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16048 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16049 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16050 pos_token, "udp-src");
16051 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16052 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16054 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16055 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16056 pos_token, "udp-dst");
16057 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16058 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16060 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16061 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16062 pos_token, "ip-src");
16063 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16064 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16065 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16066 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16067 pos_token, "ip-dst");
16068 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16069 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16070 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16071 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16072 pos_token, "vlan-tci");
16073 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16074 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16076 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16077 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16078 pos_token, "eth-src");
16079 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16080 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16082 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16083 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16084 pos_token, "eth-dst");
16085 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16086 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16089 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16090 __attribute__((unused)) struct cmdline *cl,
16091 __attribute__((unused)) void *data)
16093 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16095 uint32_t mplsoudp_label;
16098 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16101 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16102 mplsoudp_encap_conf.select_vlan = 0;
16103 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16104 mplsoudp_encap_conf.select_vlan = 1;
16105 if (strcmp(res->ip_version, "ipv4") == 0)
16106 mplsoudp_encap_conf.select_ipv4 = 1;
16107 else if (strcmp(res->ip_version, "ipv6") == 0)
16108 mplsoudp_encap_conf.select_ipv4 = 0;
16111 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16112 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16113 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16114 if (mplsoudp_encap_conf.select_ipv4) {
16115 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16116 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16118 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16119 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16121 if (mplsoudp_encap_conf.select_vlan)
16122 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16123 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16124 RTE_ETHER_ADDR_LEN);
16125 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16126 RTE_ETHER_ADDR_LEN);
16129 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16130 .f = cmd_set_mplsoudp_encap_parsed,
16132 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16133 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16134 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16136 (void *)&cmd_set_mplsoudp_encap_set,
16137 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16138 (void *)&cmd_set_mplsoudp_encap_ip_version,
16139 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16140 (void *)&cmd_set_mplsoudp_encap_label,
16141 (void *)&cmd_set_mplsoudp_encap_label_value,
16142 (void *)&cmd_set_mplsoudp_encap_udp_src,
16143 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16144 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16145 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16146 (void *)&cmd_set_mplsoudp_encap_ip_src,
16147 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16148 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16149 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16150 (void *)&cmd_set_mplsoudp_encap_eth_src,
16151 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16152 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16153 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16158 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16159 .f = cmd_set_mplsoudp_encap_parsed,
16161 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16162 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16163 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16164 " eth-src <eth-src> eth-dst <eth-dst>",
16166 (void *)&cmd_set_mplsoudp_encap_set,
16167 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16168 (void *)&cmd_set_mplsoudp_encap_ip_version,
16169 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16170 (void *)&cmd_set_mplsoudp_encap_label,
16171 (void *)&cmd_set_mplsoudp_encap_label_value,
16172 (void *)&cmd_set_mplsoudp_encap_udp_src,
16173 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16174 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16175 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16176 (void *)&cmd_set_mplsoudp_encap_ip_src,
16177 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16178 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16179 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16180 (void *)&cmd_set_mplsoudp_encap_vlan,
16181 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16182 (void *)&cmd_set_mplsoudp_encap_eth_src,
16183 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16184 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16185 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16190 /** Set MPLSoUDP decapsulation details */
16191 struct cmd_set_mplsoudp_decap_result {
16192 cmdline_fixed_string_t set;
16193 cmdline_fixed_string_t mplsoudp;
16194 cmdline_fixed_string_t pos_token;
16195 cmdline_fixed_string_t ip_version;
16196 uint32_t vlan_present:1;
16199 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16200 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16202 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16203 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16205 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16206 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16207 mplsoudp, "mplsoudp_decap-with-vlan");
16208 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16209 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16210 pos_token, "ip-version");
16211 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16212 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16213 ip_version, "ipv4#ipv6");
16215 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16216 __attribute__((unused)) struct cmdline *cl,
16217 __attribute__((unused)) void *data)
16219 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16221 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16222 mplsoudp_decap_conf.select_vlan = 0;
16223 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16224 mplsoudp_decap_conf.select_vlan = 1;
16225 if (strcmp(res->ip_version, "ipv4") == 0)
16226 mplsoudp_decap_conf.select_ipv4 = 1;
16227 else if (strcmp(res->ip_version, "ipv6") == 0)
16228 mplsoudp_decap_conf.select_ipv4 = 0;
16231 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16232 .f = cmd_set_mplsoudp_decap_parsed,
16234 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16236 (void *)&cmd_set_mplsoudp_decap_set,
16237 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16238 (void *)&cmd_set_mplsoudp_decap_ip_version,
16239 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16244 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16245 .f = cmd_set_mplsoudp_decap_parsed,
16247 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16249 (void *)&cmd_set_mplsoudp_decap_set,
16250 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16251 (void *)&cmd_set_mplsoudp_decap_ip_version,
16252 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16257 /* Strict link priority scheduling mode setting */
16259 cmd_strict_link_prio_parsed(
16260 void *parsed_result,
16261 __attribute__((unused)) struct cmdline *cl,
16262 __attribute__((unused)) void *data)
16264 struct cmd_vf_tc_bw_result *res = parsed_result;
16265 int ret = -ENOTSUP;
16267 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16270 #ifdef RTE_LIBRTE_I40E_PMD
16271 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16278 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16281 printf("invalid port_id %d\n", res->port_id);
16284 printf("function not implemented\n");
16287 printf("programming error: (%s)\n", strerror(-ret));
16291 cmdline_parse_inst_t cmd_strict_link_prio = {
16292 .f = cmd_strict_link_prio_parsed,
16294 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16296 (void *)&cmd_vf_tc_bw_set,
16297 (void *)&cmd_vf_tc_bw_tx,
16298 (void *)&cmd_vf_tc_bw_strict_link_prio,
16299 (void *)&cmd_vf_tc_bw_port_id,
16300 (void *)&cmd_vf_tc_bw_tc_map,
16305 /* Load dynamic device personalization*/
16306 struct cmd_ddp_add_result {
16307 cmdline_fixed_string_t ddp;
16308 cmdline_fixed_string_t add;
16313 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16314 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16315 cmdline_parse_token_string_t cmd_ddp_add_add =
16316 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16317 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16318 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16319 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16320 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16323 cmd_ddp_add_parsed(
16324 void *parsed_result,
16325 __attribute__((unused)) struct cmdline *cl,
16326 __attribute__((unused)) void *data)
16328 struct cmd_ddp_add_result *res = parsed_result;
16334 int ret = -ENOTSUP;
16336 if (!all_ports_stopped()) {
16337 printf("Please stop all ports first\n");
16341 filepath = strdup(res->filepath);
16342 if (filepath == NULL) {
16343 printf("Failed to allocate memory\n");
16346 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16348 buff = open_file(file_fld[0], &size);
16350 free((void *)filepath);
16354 #ifdef RTE_LIBRTE_I40E_PMD
16355 if (ret == -ENOTSUP)
16356 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16358 RTE_PMD_I40E_PKG_OP_WR_ADD);
16361 if (ret == -EEXIST)
16362 printf("Profile has already existed.\n");
16364 printf("Failed to load profile.\n");
16365 else if (file_num == 2)
16366 save_file(file_fld[1], buff, size);
16369 free((void *)filepath);
16372 cmdline_parse_inst_t cmd_ddp_add = {
16373 .f = cmd_ddp_add_parsed,
16375 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16377 (void *)&cmd_ddp_add_ddp,
16378 (void *)&cmd_ddp_add_add,
16379 (void *)&cmd_ddp_add_port_id,
16380 (void *)&cmd_ddp_add_filepath,
16385 /* Delete dynamic device personalization*/
16386 struct cmd_ddp_del_result {
16387 cmdline_fixed_string_t ddp;
16388 cmdline_fixed_string_t del;
16393 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16394 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16395 cmdline_parse_token_string_t cmd_ddp_del_del =
16396 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16397 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16398 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16399 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16400 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16403 cmd_ddp_del_parsed(
16404 void *parsed_result,
16405 __attribute__((unused)) struct cmdline *cl,
16406 __attribute__((unused)) void *data)
16408 struct cmd_ddp_del_result *res = parsed_result;
16411 int ret = -ENOTSUP;
16413 if (!all_ports_stopped()) {
16414 printf("Please stop all ports first\n");
16418 buff = open_file(res->filepath, &size);
16422 #ifdef RTE_LIBRTE_I40E_PMD
16423 if (ret == -ENOTSUP)
16424 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16426 RTE_PMD_I40E_PKG_OP_WR_DEL);
16429 if (ret == -EACCES)
16430 printf("Profile does not exist.\n");
16432 printf("Failed to delete profile.\n");
16437 cmdline_parse_inst_t cmd_ddp_del = {
16438 .f = cmd_ddp_del_parsed,
16440 .help_str = "ddp del <port_id> <backup_profile_path>",
16442 (void *)&cmd_ddp_del_ddp,
16443 (void *)&cmd_ddp_del_del,
16444 (void *)&cmd_ddp_del_port_id,
16445 (void *)&cmd_ddp_del_filepath,
16450 /* Get dynamic device personalization profile info */
16451 struct cmd_ddp_info_result {
16452 cmdline_fixed_string_t ddp;
16453 cmdline_fixed_string_t get;
16454 cmdline_fixed_string_t info;
16458 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16459 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16460 cmdline_parse_token_string_t cmd_ddp_info_get =
16461 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16462 cmdline_parse_token_string_t cmd_ddp_info_info =
16463 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16464 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16465 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16468 cmd_ddp_info_parsed(
16469 void *parsed_result,
16470 __attribute__((unused)) struct cmdline *cl,
16471 __attribute__((unused)) void *data)
16473 struct cmd_ddp_info_result *res = parsed_result;
16476 int ret = -ENOTSUP;
16477 #ifdef RTE_LIBRTE_I40E_PMD
16480 uint32_t buff_size = 0;
16481 struct rte_pmd_i40e_profile_info info;
16482 uint32_t dev_num = 0;
16483 struct rte_pmd_i40e_ddp_device_id *devs;
16484 uint32_t proto_num = 0;
16485 struct rte_pmd_i40e_proto_info *proto = NULL;
16486 uint32_t pctype_num = 0;
16487 struct rte_pmd_i40e_ptype_info *pctype;
16488 uint32_t ptype_num = 0;
16489 struct rte_pmd_i40e_ptype_info *ptype;
16494 pkg = open_file(res->filepath, &pkg_size);
16498 #ifdef RTE_LIBRTE_I40E_PMD
16499 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16500 (uint8_t *)&info, sizeof(info),
16501 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16503 printf("Global Track id: 0x%x\n", info.track_id);
16504 printf("Global Version: %d.%d.%d.%d\n",
16505 info.version.major,
16506 info.version.minor,
16507 info.version.update,
16508 info.version.draft);
16509 printf("Global Package name: %s\n\n", info.name);
16512 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16513 (uint8_t *)&info, sizeof(info),
16514 RTE_PMD_I40E_PKG_INFO_HEADER);
16516 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16517 printf("i40e Profile Version: %d.%d.%d.%d\n",
16518 info.version.major,
16519 info.version.minor,
16520 info.version.update,
16521 info.version.draft);
16522 printf("i40e Profile name: %s\n\n", info.name);
16525 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16526 (uint8_t *)&buff_size, sizeof(buff_size),
16527 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16528 if (!ret && buff_size) {
16529 buff = (uint8_t *)malloc(buff_size);
16531 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16533 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16535 printf("Package Notes:\n%s\n\n", buff);
16540 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16541 (uint8_t *)&dev_num, sizeof(dev_num),
16542 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16543 if (!ret && dev_num) {
16544 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16545 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16547 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16548 (uint8_t *)devs, buff_size,
16549 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16551 printf("List of supported devices:\n");
16552 for (i = 0; i < dev_num; i++) {
16553 printf(" %04X:%04X %04X:%04X\n",
16554 devs[i].vendor_dev_id >> 16,
16555 devs[i].vendor_dev_id & 0xFFFF,
16556 devs[i].sub_vendor_dev_id >> 16,
16557 devs[i].sub_vendor_dev_id & 0xFFFF);
16565 /* get information about protocols and packet types */
16566 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16567 (uint8_t *)&proto_num, sizeof(proto_num),
16568 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16569 if (ret || !proto_num)
16570 goto no_print_return;
16572 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16573 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16575 goto no_print_return;
16577 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16579 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16581 printf("List of used protocols:\n");
16582 for (i = 0; i < proto_num; i++)
16583 printf(" %2u: %s\n", proto[i].proto_id,
16587 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16588 (uint8_t *)&pctype_num, sizeof(pctype_num),
16589 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16590 if (ret || !pctype_num)
16591 goto no_print_pctypes;
16593 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16594 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16596 goto no_print_pctypes;
16598 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16600 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16603 goto no_print_pctypes;
16606 printf("List of defined packet classification types:\n");
16607 for (i = 0; i < pctype_num; i++) {
16608 printf(" %2u:", pctype[i].ptype_id);
16609 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16610 proto_id = pctype[i].protocols[j];
16611 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16612 for (n = 0; n < proto_num; n++) {
16613 if (proto[n].proto_id == proto_id) {
16614 printf(" %s", proto[n].name);
16627 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16629 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16630 if (ret || !ptype_num)
16631 goto no_print_return;
16633 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16634 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16636 goto no_print_return;
16638 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16640 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16643 goto no_print_return;
16645 printf("List of defined packet types:\n");
16646 for (i = 0; i < ptype_num; i++) {
16647 printf(" %2u:", ptype[i].ptype_id);
16648 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16649 proto_id = ptype[i].protocols[j];
16650 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16651 for (n = 0; n < proto_num; n++) {
16652 if (proto[n].proto_id == proto_id) {
16653 printf(" %s", proto[n].name);
16669 if (ret == -ENOTSUP)
16670 printf("Function not supported in PMD driver\n");
16674 cmdline_parse_inst_t cmd_ddp_get_info = {
16675 .f = cmd_ddp_info_parsed,
16677 .help_str = "ddp get info <profile_path>",
16679 (void *)&cmd_ddp_info_ddp,
16680 (void *)&cmd_ddp_info_get,
16681 (void *)&cmd_ddp_info_info,
16682 (void *)&cmd_ddp_info_filepath,
16687 /* Get dynamic device personalization profile info list*/
16688 #define PROFILE_INFO_SIZE 48
16689 #define MAX_PROFILE_NUM 16
16691 struct cmd_ddp_get_list_result {
16692 cmdline_fixed_string_t ddp;
16693 cmdline_fixed_string_t get;
16694 cmdline_fixed_string_t list;
16698 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16699 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16700 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16701 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16702 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16703 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16704 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16705 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16708 cmd_ddp_get_list_parsed(
16709 __attribute__((unused)) void *parsed_result,
16710 __attribute__((unused)) struct cmdline *cl,
16711 __attribute__((unused)) void *data)
16713 #ifdef RTE_LIBRTE_I40E_PMD
16714 struct cmd_ddp_get_list_result *res = parsed_result;
16715 struct rte_pmd_i40e_profile_list *p_list;
16716 struct rte_pmd_i40e_profile_info *p_info;
16721 int ret = -ENOTSUP;
16723 #ifdef RTE_LIBRTE_I40E_PMD
16724 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16725 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16727 printf("%s: Failed to malloc buffer\n", __func__);
16729 if (ret == -ENOTSUP)
16730 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16731 (uint8_t *)p_list, size);
16734 p_num = p_list->p_count;
16735 printf("Profile number is: %d\n\n", p_num);
16737 for (i = 0; i < p_num; i++) {
16738 p_info = &p_list->p_info[i];
16739 printf("Profile %d:\n", i);
16740 printf("Track id: 0x%x\n", p_info->track_id);
16741 printf("Version: %d.%d.%d.%d\n",
16742 p_info->version.major,
16743 p_info->version.minor,
16744 p_info->version.update,
16745 p_info->version.draft);
16746 printf("Profile name: %s\n\n", p_info->name);
16754 printf("Failed to get ddp list\n");
16757 cmdline_parse_inst_t cmd_ddp_get_list = {
16758 .f = cmd_ddp_get_list_parsed,
16760 .help_str = "ddp get list <port_id>",
16762 (void *)&cmd_ddp_get_list_ddp,
16763 (void *)&cmd_ddp_get_list_get,
16764 (void *)&cmd_ddp_get_list_list,
16765 (void *)&cmd_ddp_get_list_port_id,
16770 /* Configure input set */
16771 struct cmd_cfg_input_set_result {
16772 cmdline_fixed_string_t port;
16773 cmdline_fixed_string_t cfg;
16775 cmdline_fixed_string_t pctype;
16777 cmdline_fixed_string_t inset_type;
16778 cmdline_fixed_string_t opt;
16779 cmdline_fixed_string_t field;
16784 cmd_cfg_input_set_parsed(
16785 __attribute__((unused)) void *parsed_result,
16786 __attribute__((unused)) struct cmdline *cl,
16787 __attribute__((unused)) void *data)
16789 #ifdef RTE_LIBRTE_I40E_PMD
16790 struct cmd_cfg_input_set_result *res = parsed_result;
16791 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16792 struct rte_pmd_i40e_inset inset;
16794 int ret = -ENOTSUP;
16796 if (!all_ports_stopped()) {
16797 printf("Please stop all ports first\n");
16801 #ifdef RTE_LIBRTE_I40E_PMD
16802 if (!strcmp(res->inset_type, "hash_inset"))
16803 inset_type = INSET_HASH;
16804 else if (!strcmp(res->inset_type, "fdir_inset"))
16805 inset_type = INSET_FDIR;
16806 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16807 inset_type = INSET_FDIR_FLX;
16808 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16809 &inset, inset_type);
16811 printf("Failed to get input set.\n");
16815 if (!strcmp(res->opt, "get")) {
16816 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16819 printf("Field index %d is enabled.\n", res->field_idx);
16821 printf("Field index %d is disabled.\n", res->field_idx);
16823 } else if (!strcmp(res->opt, "set"))
16824 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16826 else if (!strcmp(res->opt, "clear"))
16827 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16830 printf("Failed to configure input set field.\n");
16834 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16835 &inset, inset_type);
16837 printf("Failed to set input set.\n");
16842 if (ret == -ENOTSUP)
16843 printf("Function not supported\n");
16846 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16847 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16849 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16850 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16852 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16853 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16855 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16856 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16858 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16859 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16861 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16862 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16864 "hash_inset#fdir_inset#fdir_flx_inset");
16865 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16866 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16867 opt, "get#set#clear");
16868 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16869 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16871 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16872 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16875 cmdline_parse_inst_t cmd_cfg_input_set = {
16876 .f = cmd_cfg_input_set_parsed,
16878 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16879 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16881 (void *)&cmd_cfg_input_set_port,
16882 (void *)&cmd_cfg_input_set_cfg,
16883 (void *)&cmd_cfg_input_set_port_id,
16884 (void *)&cmd_cfg_input_set_pctype,
16885 (void *)&cmd_cfg_input_set_pctype_id,
16886 (void *)&cmd_cfg_input_set_inset_type,
16887 (void *)&cmd_cfg_input_set_opt,
16888 (void *)&cmd_cfg_input_set_field,
16889 (void *)&cmd_cfg_input_set_field_idx,
16894 /* Clear input set */
16895 struct cmd_clear_input_set_result {
16896 cmdline_fixed_string_t port;
16897 cmdline_fixed_string_t cfg;
16899 cmdline_fixed_string_t pctype;
16901 cmdline_fixed_string_t inset_type;
16902 cmdline_fixed_string_t clear;
16903 cmdline_fixed_string_t all;
16907 cmd_clear_input_set_parsed(
16908 __attribute__((unused)) void *parsed_result,
16909 __attribute__((unused)) struct cmdline *cl,
16910 __attribute__((unused)) void *data)
16912 #ifdef RTE_LIBRTE_I40E_PMD
16913 struct cmd_clear_input_set_result *res = parsed_result;
16914 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16915 struct rte_pmd_i40e_inset inset;
16917 int ret = -ENOTSUP;
16919 if (!all_ports_stopped()) {
16920 printf("Please stop all ports first\n");
16924 #ifdef RTE_LIBRTE_I40E_PMD
16925 if (!strcmp(res->inset_type, "hash_inset"))
16926 inset_type = INSET_HASH;
16927 else if (!strcmp(res->inset_type, "fdir_inset"))
16928 inset_type = INSET_FDIR;
16929 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16930 inset_type = INSET_FDIR_FLX;
16932 memset(&inset, 0, sizeof(inset));
16934 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16935 &inset, inset_type);
16937 printf("Failed to clear input set.\n");
16943 if (ret == -ENOTSUP)
16944 printf("Function not supported\n");
16947 cmdline_parse_token_string_t cmd_clear_input_set_port =
16948 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16950 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16951 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16953 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16954 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16956 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16957 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16959 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16960 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16962 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16963 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16965 "hash_inset#fdir_inset#fdir_flx_inset");
16966 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16967 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16969 cmdline_parse_token_string_t cmd_clear_input_set_all =
16970 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16973 cmdline_parse_inst_t cmd_clear_input_set = {
16974 .f = cmd_clear_input_set_parsed,
16976 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16977 "fdir_inset|fdir_flx_inset clear all",
16979 (void *)&cmd_clear_input_set_port,
16980 (void *)&cmd_clear_input_set_cfg,
16981 (void *)&cmd_clear_input_set_port_id,
16982 (void *)&cmd_clear_input_set_pctype,
16983 (void *)&cmd_clear_input_set_pctype_id,
16984 (void *)&cmd_clear_input_set_inset_type,
16985 (void *)&cmd_clear_input_set_clear,
16986 (void *)&cmd_clear_input_set_all,
16991 /* show vf stats */
16993 /* Common result structure for show vf stats */
16994 struct cmd_show_vf_stats_result {
16995 cmdline_fixed_string_t show;
16996 cmdline_fixed_string_t vf;
16997 cmdline_fixed_string_t stats;
17002 /* Common CLI fields show vf stats*/
17003 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17004 TOKEN_STRING_INITIALIZER
17005 (struct cmd_show_vf_stats_result,
17007 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17008 TOKEN_STRING_INITIALIZER
17009 (struct cmd_show_vf_stats_result,
17011 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17012 TOKEN_STRING_INITIALIZER
17013 (struct cmd_show_vf_stats_result,
17015 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17016 TOKEN_NUM_INITIALIZER
17017 (struct cmd_show_vf_stats_result,
17019 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17020 TOKEN_NUM_INITIALIZER
17021 (struct cmd_show_vf_stats_result,
17025 cmd_show_vf_stats_parsed(
17026 void *parsed_result,
17027 __attribute__((unused)) struct cmdline *cl,
17028 __attribute__((unused)) void *data)
17030 struct cmd_show_vf_stats_result *res = parsed_result;
17031 struct rte_eth_stats stats;
17032 int ret = -ENOTSUP;
17033 static const char *nic_stats_border = "########################";
17035 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17038 memset(&stats, 0, sizeof(stats));
17040 #ifdef RTE_LIBRTE_I40E_PMD
17041 if (ret == -ENOTSUP)
17042 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17046 #ifdef RTE_LIBRTE_BNXT_PMD
17047 if (ret == -ENOTSUP)
17048 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17057 printf("invalid vf_id %d\n", res->vf_id);
17060 printf("invalid port_id %d\n", res->port_id);
17063 printf("function not implemented\n");
17066 printf("programming error: (%s)\n", strerror(-ret));
17069 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17070 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17072 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17074 stats.ipackets, stats.imissed, stats.ibytes);
17075 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17076 printf(" RX-nombuf: %-10"PRIu64"\n",
17078 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17080 stats.opackets, stats.oerrors, stats.obytes);
17082 printf(" %s############################%s\n",
17083 nic_stats_border, nic_stats_border);
17086 cmdline_parse_inst_t cmd_show_vf_stats = {
17087 .f = cmd_show_vf_stats_parsed,
17089 .help_str = "show vf stats <port_id> <vf_id>",
17091 (void *)&cmd_show_vf_stats_show,
17092 (void *)&cmd_show_vf_stats_vf,
17093 (void *)&cmd_show_vf_stats_stats,
17094 (void *)&cmd_show_vf_stats_port_id,
17095 (void *)&cmd_show_vf_stats_vf_id,
17100 /* clear vf stats */
17102 /* Common result structure for clear vf stats */
17103 struct cmd_clear_vf_stats_result {
17104 cmdline_fixed_string_t clear;
17105 cmdline_fixed_string_t vf;
17106 cmdline_fixed_string_t stats;
17111 /* Common CLI fields clear vf stats*/
17112 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17113 TOKEN_STRING_INITIALIZER
17114 (struct cmd_clear_vf_stats_result,
17116 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17117 TOKEN_STRING_INITIALIZER
17118 (struct cmd_clear_vf_stats_result,
17120 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17121 TOKEN_STRING_INITIALIZER
17122 (struct cmd_clear_vf_stats_result,
17124 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17125 TOKEN_NUM_INITIALIZER
17126 (struct cmd_clear_vf_stats_result,
17128 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17129 TOKEN_NUM_INITIALIZER
17130 (struct cmd_clear_vf_stats_result,
17134 cmd_clear_vf_stats_parsed(
17135 void *parsed_result,
17136 __attribute__((unused)) struct cmdline *cl,
17137 __attribute__((unused)) void *data)
17139 struct cmd_clear_vf_stats_result *res = parsed_result;
17140 int ret = -ENOTSUP;
17142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17145 #ifdef RTE_LIBRTE_I40E_PMD
17146 if (ret == -ENOTSUP)
17147 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17150 #ifdef RTE_LIBRTE_BNXT_PMD
17151 if (ret == -ENOTSUP)
17152 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17160 printf("invalid vf_id %d\n", res->vf_id);
17163 printf("invalid port_id %d\n", res->port_id);
17166 printf("function not implemented\n");
17169 printf("programming error: (%s)\n", strerror(-ret));
17173 cmdline_parse_inst_t cmd_clear_vf_stats = {
17174 .f = cmd_clear_vf_stats_parsed,
17176 .help_str = "clear vf stats <port_id> <vf_id>",
17178 (void *)&cmd_clear_vf_stats_clear,
17179 (void *)&cmd_clear_vf_stats_vf,
17180 (void *)&cmd_clear_vf_stats_stats,
17181 (void *)&cmd_clear_vf_stats_port_id,
17182 (void *)&cmd_clear_vf_stats_vf_id,
17187 /* port config pctype mapping reset */
17189 /* Common result structure for port config pctype mapping reset */
17190 struct cmd_pctype_mapping_reset_result {
17191 cmdline_fixed_string_t port;
17192 cmdline_fixed_string_t config;
17194 cmdline_fixed_string_t pctype;
17195 cmdline_fixed_string_t mapping;
17196 cmdline_fixed_string_t reset;
17199 /* Common CLI fields for port config pctype mapping reset*/
17200 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17201 TOKEN_STRING_INITIALIZER
17202 (struct cmd_pctype_mapping_reset_result,
17204 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17205 TOKEN_STRING_INITIALIZER
17206 (struct cmd_pctype_mapping_reset_result,
17208 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17209 TOKEN_NUM_INITIALIZER
17210 (struct cmd_pctype_mapping_reset_result,
17212 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17213 TOKEN_STRING_INITIALIZER
17214 (struct cmd_pctype_mapping_reset_result,
17216 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17217 TOKEN_STRING_INITIALIZER
17218 (struct cmd_pctype_mapping_reset_result,
17219 mapping, "mapping");
17220 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17221 TOKEN_STRING_INITIALIZER
17222 (struct cmd_pctype_mapping_reset_result,
17226 cmd_pctype_mapping_reset_parsed(
17227 void *parsed_result,
17228 __attribute__((unused)) struct cmdline *cl,
17229 __attribute__((unused)) void *data)
17231 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17232 int ret = -ENOTSUP;
17234 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17237 #ifdef RTE_LIBRTE_I40E_PMD
17238 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17245 printf("invalid port_id %d\n", res->port_id);
17248 printf("function not implemented\n");
17251 printf("programming error: (%s)\n", strerror(-ret));
17255 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17256 .f = cmd_pctype_mapping_reset_parsed,
17258 .help_str = "port config <port_id> pctype mapping reset",
17260 (void *)&cmd_pctype_mapping_reset_port,
17261 (void *)&cmd_pctype_mapping_reset_config,
17262 (void *)&cmd_pctype_mapping_reset_port_id,
17263 (void *)&cmd_pctype_mapping_reset_pctype,
17264 (void *)&cmd_pctype_mapping_reset_mapping,
17265 (void *)&cmd_pctype_mapping_reset_reset,
17270 /* show port pctype mapping */
17272 /* Common result structure for show port pctype mapping */
17273 struct cmd_pctype_mapping_get_result {
17274 cmdline_fixed_string_t show;
17275 cmdline_fixed_string_t port;
17277 cmdline_fixed_string_t pctype;
17278 cmdline_fixed_string_t mapping;
17281 /* Common CLI fields for pctype mapping get */
17282 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17283 TOKEN_STRING_INITIALIZER
17284 (struct cmd_pctype_mapping_get_result,
17286 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17287 TOKEN_STRING_INITIALIZER
17288 (struct cmd_pctype_mapping_get_result,
17290 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17291 TOKEN_NUM_INITIALIZER
17292 (struct cmd_pctype_mapping_get_result,
17294 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17295 TOKEN_STRING_INITIALIZER
17296 (struct cmd_pctype_mapping_get_result,
17298 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17299 TOKEN_STRING_INITIALIZER
17300 (struct cmd_pctype_mapping_get_result,
17301 mapping, "mapping");
17304 cmd_pctype_mapping_get_parsed(
17305 void *parsed_result,
17306 __attribute__((unused)) struct cmdline *cl,
17307 __attribute__((unused)) void *data)
17309 struct cmd_pctype_mapping_get_result *res = parsed_result;
17310 int ret = -ENOTSUP;
17311 #ifdef RTE_LIBRTE_I40E_PMD
17312 struct rte_pmd_i40e_flow_type_mapping
17313 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17314 int i, j, first_pctype;
17317 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17320 #ifdef RTE_LIBRTE_I40E_PMD
17321 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17328 printf("invalid port_id %d\n", res->port_id);
17331 printf("function not implemented\n");
17334 printf("programming error: (%s)\n", strerror(-ret));
17338 #ifdef RTE_LIBRTE_I40E_PMD
17339 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17340 if (mapping[i].pctype != 0ULL) {
17343 printf("pctype: ");
17344 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17345 if (mapping[i].pctype & (1ULL << j)) {
17346 printf(first_pctype ?
17347 "%02d" : ",%02d", j);
17351 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17357 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17358 .f = cmd_pctype_mapping_get_parsed,
17360 .help_str = "show port <port_id> pctype mapping",
17362 (void *)&cmd_pctype_mapping_get_show,
17363 (void *)&cmd_pctype_mapping_get_port,
17364 (void *)&cmd_pctype_mapping_get_port_id,
17365 (void *)&cmd_pctype_mapping_get_pctype,
17366 (void *)&cmd_pctype_mapping_get_mapping,
17371 /* port config pctype mapping update */
17373 /* Common result structure for port config pctype mapping update */
17374 struct cmd_pctype_mapping_update_result {
17375 cmdline_fixed_string_t port;
17376 cmdline_fixed_string_t config;
17378 cmdline_fixed_string_t pctype;
17379 cmdline_fixed_string_t mapping;
17380 cmdline_fixed_string_t update;
17381 cmdline_fixed_string_t pctype_list;
17382 uint16_t flow_type;
17385 /* Common CLI fields for pctype mapping update*/
17386 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17387 TOKEN_STRING_INITIALIZER
17388 (struct cmd_pctype_mapping_update_result,
17390 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17391 TOKEN_STRING_INITIALIZER
17392 (struct cmd_pctype_mapping_update_result,
17394 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17395 TOKEN_NUM_INITIALIZER
17396 (struct cmd_pctype_mapping_update_result,
17398 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17399 TOKEN_STRING_INITIALIZER
17400 (struct cmd_pctype_mapping_update_result,
17402 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17403 TOKEN_STRING_INITIALIZER
17404 (struct cmd_pctype_mapping_update_result,
17405 mapping, "mapping");
17406 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17407 TOKEN_STRING_INITIALIZER
17408 (struct cmd_pctype_mapping_update_result,
17410 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17411 TOKEN_STRING_INITIALIZER
17412 (struct cmd_pctype_mapping_update_result,
17413 pctype_list, NULL);
17414 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17415 TOKEN_NUM_INITIALIZER
17416 (struct cmd_pctype_mapping_update_result,
17417 flow_type, UINT16);
17420 cmd_pctype_mapping_update_parsed(
17421 void *parsed_result,
17422 __attribute__((unused)) struct cmdline *cl,
17423 __attribute__((unused)) void *data)
17425 struct cmd_pctype_mapping_update_result *res = parsed_result;
17426 int ret = -ENOTSUP;
17427 #ifdef RTE_LIBRTE_I40E_PMD
17428 struct rte_pmd_i40e_flow_type_mapping mapping;
17430 unsigned int nb_item;
17431 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17434 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17437 #ifdef RTE_LIBRTE_I40E_PMD
17438 nb_item = parse_item_list(res->pctype_list, "pctypes",
17439 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17440 mapping.flow_type = res->flow_type;
17441 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17442 mapping.pctype |= (1ULL << pctype_list[i]);
17443 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17453 printf("invalid pctype or flow type\n");
17456 printf("invalid port_id %d\n", res->port_id);
17459 printf("function not implemented\n");
17462 printf("programming error: (%s)\n", strerror(-ret));
17466 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17467 .f = cmd_pctype_mapping_update_parsed,
17469 .help_str = "port config <port_id> pctype mapping update"
17470 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17472 (void *)&cmd_pctype_mapping_update_port,
17473 (void *)&cmd_pctype_mapping_update_config,
17474 (void *)&cmd_pctype_mapping_update_port_id,
17475 (void *)&cmd_pctype_mapping_update_pctype,
17476 (void *)&cmd_pctype_mapping_update_mapping,
17477 (void *)&cmd_pctype_mapping_update_update,
17478 (void *)&cmd_pctype_mapping_update_pc_type,
17479 (void *)&cmd_pctype_mapping_update_flow_type,
17484 /* ptype mapping get */
17486 /* Common result structure for ptype mapping get */
17487 struct cmd_ptype_mapping_get_result {
17488 cmdline_fixed_string_t ptype;
17489 cmdline_fixed_string_t mapping;
17490 cmdline_fixed_string_t get;
17492 uint8_t valid_only;
17495 /* Common CLI fields for ptype mapping get */
17496 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17497 TOKEN_STRING_INITIALIZER
17498 (struct cmd_ptype_mapping_get_result,
17500 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17501 TOKEN_STRING_INITIALIZER
17502 (struct cmd_ptype_mapping_get_result,
17503 mapping, "mapping");
17504 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17505 TOKEN_STRING_INITIALIZER
17506 (struct cmd_ptype_mapping_get_result,
17508 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17509 TOKEN_NUM_INITIALIZER
17510 (struct cmd_ptype_mapping_get_result,
17512 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17513 TOKEN_NUM_INITIALIZER
17514 (struct cmd_ptype_mapping_get_result,
17515 valid_only, UINT8);
17518 cmd_ptype_mapping_get_parsed(
17519 void *parsed_result,
17520 __attribute__((unused)) struct cmdline *cl,
17521 __attribute__((unused)) void *data)
17523 struct cmd_ptype_mapping_get_result *res = parsed_result;
17524 int ret = -ENOTSUP;
17525 #ifdef RTE_LIBRTE_I40E_PMD
17526 int max_ptype_num = 256;
17527 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17532 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17535 #ifdef RTE_LIBRTE_I40E_PMD
17536 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17547 printf("invalid port_id %d\n", res->port_id);
17550 printf("function not implemented\n");
17553 printf("programming error: (%s)\n", strerror(-ret));
17556 #ifdef RTE_LIBRTE_I40E_PMD
17558 for (i = 0; i < count; i++)
17559 printf("%3d\t0x%08x\n",
17560 mapping[i].hw_ptype, mapping[i].sw_ptype);
17565 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17566 .f = cmd_ptype_mapping_get_parsed,
17568 .help_str = "ptype mapping get <port_id> <valid_only>",
17570 (void *)&cmd_ptype_mapping_get_ptype,
17571 (void *)&cmd_ptype_mapping_get_mapping,
17572 (void *)&cmd_ptype_mapping_get_get,
17573 (void *)&cmd_ptype_mapping_get_port_id,
17574 (void *)&cmd_ptype_mapping_get_valid_only,
17579 /* ptype mapping replace */
17581 /* Common result structure for ptype mapping replace */
17582 struct cmd_ptype_mapping_replace_result {
17583 cmdline_fixed_string_t ptype;
17584 cmdline_fixed_string_t mapping;
17585 cmdline_fixed_string_t replace;
17592 /* Common CLI fields for ptype mapping replace */
17593 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17594 TOKEN_STRING_INITIALIZER
17595 (struct cmd_ptype_mapping_replace_result,
17597 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17598 TOKEN_STRING_INITIALIZER
17599 (struct cmd_ptype_mapping_replace_result,
17600 mapping, "mapping");
17601 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17602 TOKEN_STRING_INITIALIZER
17603 (struct cmd_ptype_mapping_replace_result,
17604 replace, "replace");
17605 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17606 TOKEN_NUM_INITIALIZER
17607 (struct cmd_ptype_mapping_replace_result,
17609 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17610 TOKEN_NUM_INITIALIZER
17611 (struct cmd_ptype_mapping_replace_result,
17613 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17614 TOKEN_NUM_INITIALIZER
17615 (struct cmd_ptype_mapping_replace_result,
17617 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17618 TOKEN_NUM_INITIALIZER
17619 (struct cmd_ptype_mapping_replace_result,
17623 cmd_ptype_mapping_replace_parsed(
17624 void *parsed_result,
17625 __attribute__((unused)) struct cmdline *cl,
17626 __attribute__((unused)) void *data)
17628 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17629 int ret = -ENOTSUP;
17631 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17634 #ifdef RTE_LIBRTE_I40E_PMD
17635 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17645 printf("invalid ptype 0x%8x or 0x%8x\n",
17646 res->target, res->pkt_type);
17649 printf("invalid port_id %d\n", res->port_id);
17652 printf("function not implemented\n");
17655 printf("programming error: (%s)\n", strerror(-ret));
17659 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17660 .f = cmd_ptype_mapping_replace_parsed,
17663 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17665 (void *)&cmd_ptype_mapping_replace_ptype,
17666 (void *)&cmd_ptype_mapping_replace_mapping,
17667 (void *)&cmd_ptype_mapping_replace_replace,
17668 (void *)&cmd_ptype_mapping_replace_port_id,
17669 (void *)&cmd_ptype_mapping_replace_target,
17670 (void *)&cmd_ptype_mapping_replace_mask,
17671 (void *)&cmd_ptype_mapping_replace_pkt_type,
17676 /* ptype mapping reset */
17678 /* Common result structure for ptype mapping reset */
17679 struct cmd_ptype_mapping_reset_result {
17680 cmdline_fixed_string_t ptype;
17681 cmdline_fixed_string_t mapping;
17682 cmdline_fixed_string_t reset;
17686 /* Common CLI fields for ptype mapping reset*/
17687 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17688 TOKEN_STRING_INITIALIZER
17689 (struct cmd_ptype_mapping_reset_result,
17691 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17692 TOKEN_STRING_INITIALIZER
17693 (struct cmd_ptype_mapping_reset_result,
17694 mapping, "mapping");
17695 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17696 TOKEN_STRING_INITIALIZER
17697 (struct cmd_ptype_mapping_reset_result,
17699 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17700 TOKEN_NUM_INITIALIZER
17701 (struct cmd_ptype_mapping_reset_result,
17705 cmd_ptype_mapping_reset_parsed(
17706 void *parsed_result,
17707 __attribute__((unused)) struct cmdline *cl,
17708 __attribute__((unused)) void *data)
17710 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17711 int ret = -ENOTSUP;
17713 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17716 #ifdef RTE_LIBRTE_I40E_PMD
17717 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17724 printf("invalid port_id %d\n", res->port_id);
17727 printf("function not implemented\n");
17730 printf("programming error: (%s)\n", strerror(-ret));
17734 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17735 .f = cmd_ptype_mapping_reset_parsed,
17737 .help_str = "ptype mapping reset <port_id>",
17739 (void *)&cmd_ptype_mapping_reset_ptype,
17740 (void *)&cmd_ptype_mapping_reset_mapping,
17741 (void *)&cmd_ptype_mapping_reset_reset,
17742 (void *)&cmd_ptype_mapping_reset_port_id,
17747 /* ptype mapping update */
17749 /* Common result structure for ptype mapping update */
17750 struct cmd_ptype_mapping_update_result {
17751 cmdline_fixed_string_t ptype;
17752 cmdline_fixed_string_t mapping;
17753 cmdline_fixed_string_t reset;
17759 /* Common CLI fields for ptype mapping update*/
17760 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17761 TOKEN_STRING_INITIALIZER
17762 (struct cmd_ptype_mapping_update_result,
17764 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17765 TOKEN_STRING_INITIALIZER
17766 (struct cmd_ptype_mapping_update_result,
17767 mapping, "mapping");
17768 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17769 TOKEN_STRING_INITIALIZER
17770 (struct cmd_ptype_mapping_update_result,
17772 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17773 TOKEN_NUM_INITIALIZER
17774 (struct cmd_ptype_mapping_update_result,
17776 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17777 TOKEN_NUM_INITIALIZER
17778 (struct cmd_ptype_mapping_update_result,
17780 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17781 TOKEN_NUM_INITIALIZER
17782 (struct cmd_ptype_mapping_update_result,
17786 cmd_ptype_mapping_update_parsed(
17787 void *parsed_result,
17788 __attribute__((unused)) struct cmdline *cl,
17789 __attribute__((unused)) void *data)
17791 struct cmd_ptype_mapping_update_result *res = parsed_result;
17792 int ret = -ENOTSUP;
17793 #ifdef RTE_LIBRTE_I40E_PMD
17794 struct rte_pmd_i40e_ptype_mapping mapping;
17796 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17799 #ifdef RTE_LIBRTE_I40E_PMD
17800 mapping.hw_ptype = res->hw_ptype;
17801 mapping.sw_ptype = res->sw_ptype;
17802 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17812 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17815 printf("invalid port_id %d\n", res->port_id);
17818 printf("function not implemented\n");
17821 printf("programming error: (%s)\n", strerror(-ret));
17825 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17826 .f = cmd_ptype_mapping_update_parsed,
17828 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17830 (void *)&cmd_ptype_mapping_update_ptype,
17831 (void *)&cmd_ptype_mapping_update_mapping,
17832 (void *)&cmd_ptype_mapping_update_update,
17833 (void *)&cmd_ptype_mapping_update_port_id,
17834 (void *)&cmd_ptype_mapping_update_hw_ptype,
17835 (void *)&cmd_ptype_mapping_update_sw_ptype,
17840 /* Common result structure for file commands */
17841 struct cmd_cmdfile_result {
17842 cmdline_fixed_string_t load;
17843 cmdline_fixed_string_t filename;
17846 /* Common CLI fields for file commands */
17847 cmdline_parse_token_string_t cmd_load_cmdfile =
17848 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17849 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17850 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17853 cmd_load_from_file_parsed(
17854 void *parsed_result,
17855 __attribute__((unused)) struct cmdline *cl,
17856 __attribute__((unused)) void *data)
17858 struct cmd_cmdfile_result *res = parsed_result;
17860 cmdline_read_from_file(res->filename);
17863 cmdline_parse_inst_t cmd_load_from_file = {
17864 .f = cmd_load_from_file_parsed,
17866 .help_str = "load <filename>",
17868 (void *)&cmd_load_cmdfile,
17869 (void *)&cmd_load_cmdfile_filename,
17874 /* Get Rx offloads capabilities */
17875 struct cmd_rx_offload_get_capa_result {
17876 cmdline_fixed_string_t show;
17877 cmdline_fixed_string_t port;
17879 cmdline_fixed_string_t rx_offload;
17880 cmdline_fixed_string_t capabilities;
17883 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17884 TOKEN_STRING_INITIALIZER
17885 (struct cmd_rx_offload_get_capa_result,
17887 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17888 TOKEN_STRING_INITIALIZER
17889 (struct cmd_rx_offload_get_capa_result,
17891 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17892 TOKEN_NUM_INITIALIZER
17893 (struct cmd_rx_offload_get_capa_result,
17895 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17896 TOKEN_STRING_INITIALIZER
17897 (struct cmd_rx_offload_get_capa_result,
17898 rx_offload, "rx_offload");
17899 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17900 TOKEN_STRING_INITIALIZER
17901 (struct cmd_rx_offload_get_capa_result,
17902 capabilities, "capabilities");
17905 print_rx_offloads(uint64_t offloads)
17907 uint64_t single_offload;
17915 begin = __builtin_ctzll(offloads);
17916 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17918 single_offload = 1ULL << begin;
17919 for (bit = begin; bit < end; bit++) {
17920 if (offloads & single_offload)
17922 rte_eth_dev_rx_offload_name(single_offload));
17923 single_offload <<= 1;
17928 cmd_rx_offload_get_capa_parsed(
17929 void *parsed_result,
17930 __attribute__((unused)) struct cmdline *cl,
17931 __attribute__((unused)) void *data)
17933 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17934 struct rte_eth_dev_info dev_info;
17935 portid_t port_id = res->port_id;
17936 uint64_t queue_offloads;
17937 uint64_t port_offloads;
17940 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17944 queue_offloads = dev_info.rx_queue_offload_capa;
17945 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17947 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17948 printf(" Per Queue :");
17949 print_rx_offloads(queue_offloads);
17952 printf(" Per Port :");
17953 print_rx_offloads(port_offloads);
17957 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17958 .f = cmd_rx_offload_get_capa_parsed,
17960 .help_str = "show port <port_id> rx_offload capabilities",
17962 (void *)&cmd_rx_offload_get_capa_show,
17963 (void *)&cmd_rx_offload_get_capa_port,
17964 (void *)&cmd_rx_offload_get_capa_port_id,
17965 (void *)&cmd_rx_offload_get_capa_rx_offload,
17966 (void *)&cmd_rx_offload_get_capa_capabilities,
17971 /* Get Rx offloads configuration */
17972 struct cmd_rx_offload_get_configuration_result {
17973 cmdline_fixed_string_t show;
17974 cmdline_fixed_string_t port;
17976 cmdline_fixed_string_t rx_offload;
17977 cmdline_fixed_string_t configuration;
17980 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17981 TOKEN_STRING_INITIALIZER
17982 (struct cmd_rx_offload_get_configuration_result,
17984 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17985 TOKEN_STRING_INITIALIZER
17986 (struct cmd_rx_offload_get_configuration_result,
17988 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17989 TOKEN_NUM_INITIALIZER
17990 (struct cmd_rx_offload_get_configuration_result,
17992 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17993 TOKEN_STRING_INITIALIZER
17994 (struct cmd_rx_offload_get_configuration_result,
17995 rx_offload, "rx_offload");
17996 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17997 TOKEN_STRING_INITIALIZER
17998 (struct cmd_rx_offload_get_configuration_result,
17999 configuration, "configuration");
18002 cmd_rx_offload_get_configuration_parsed(
18003 void *parsed_result,
18004 __attribute__((unused)) struct cmdline *cl,
18005 __attribute__((unused)) void *data)
18007 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18008 struct rte_eth_dev_info dev_info;
18009 portid_t port_id = res->port_id;
18010 struct rte_port *port = &ports[port_id];
18011 uint64_t port_offloads;
18012 uint64_t queue_offloads;
18013 uint16_t nb_rx_queues;
18017 printf("Rx Offloading Configuration of port %d :\n", port_id);
18019 port_offloads = port->dev_conf.rxmode.offloads;
18021 print_rx_offloads(port_offloads);
18024 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18028 nb_rx_queues = dev_info.nb_rx_queues;
18029 for (q = 0; q < nb_rx_queues; q++) {
18030 queue_offloads = port->rx_conf[q].offloads;
18031 printf(" Queue[%2d] :", q);
18032 print_rx_offloads(queue_offloads);
18038 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18039 .f = cmd_rx_offload_get_configuration_parsed,
18041 .help_str = "show port <port_id> rx_offload configuration",
18043 (void *)&cmd_rx_offload_get_configuration_show,
18044 (void *)&cmd_rx_offload_get_configuration_port,
18045 (void *)&cmd_rx_offload_get_configuration_port_id,
18046 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18047 (void *)&cmd_rx_offload_get_configuration_configuration,
18052 /* Enable/Disable a per port offloading */
18053 struct cmd_config_per_port_rx_offload_result {
18054 cmdline_fixed_string_t port;
18055 cmdline_fixed_string_t config;
18057 cmdline_fixed_string_t rx_offload;
18058 cmdline_fixed_string_t offload;
18059 cmdline_fixed_string_t on_off;
18062 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18063 TOKEN_STRING_INITIALIZER
18064 (struct cmd_config_per_port_rx_offload_result,
18066 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18067 TOKEN_STRING_INITIALIZER
18068 (struct cmd_config_per_port_rx_offload_result,
18070 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18071 TOKEN_NUM_INITIALIZER
18072 (struct cmd_config_per_port_rx_offload_result,
18074 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18075 TOKEN_STRING_INITIALIZER
18076 (struct cmd_config_per_port_rx_offload_result,
18077 rx_offload, "rx_offload");
18078 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18079 TOKEN_STRING_INITIALIZER
18080 (struct cmd_config_per_port_rx_offload_result,
18081 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18082 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18083 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18084 "scatter#timestamp#security#keep_crc");
18085 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18086 TOKEN_STRING_INITIALIZER
18087 (struct cmd_config_per_port_rx_offload_result,
18091 search_rx_offload(const char *name)
18093 uint64_t single_offload;
18094 const char *single_name;
18098 single_offload = 1;
18099 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18100 single_name = rte_eth_dev_rx_offload_name(single_offload);
18101 if (!strcasecmp(single_name, name)) {
18105 single_offload <<= 1;
18109 return single_offload;
18115 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18116 __attribute__((unused)) struct cmdline *cl,
18117 __attribute__((unused)) void *data)
18119 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18120 portid_t port_id = res->port_id;
18121 struct rte_eth_dev_info dev_info;
18122 struct rte_port *port = &ports[port_id];
18123 uint64_t single_offload;
18124 uint16_t nb_rx_queues;
18128 if (port->port_status != RTE_PORT_STOPPED) {
18129 printf("Error: Can't config offload when Port %d "
18130 "is not stopped\n", port_id);
18134 single_offload = search_rx_offload(res->offload);
18135 if (single_offload == 0) {
18136 printf("Unknown offload name: %s\n", res->offload);
18140 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18144 nb_rx_queues = dev_info.nb_rx_queues;
18145 if (!strcmp(res->on_off, "on")) {
18146 port->dev_conf.rxmode.offloads |= single_offload;
18147 for (q = 0; q < nb_rx_queues; q++)
18148 port->rx_conf[q].offloads |= single_offload;
18150 port->dev_conf.rxmode.offloads &= ~single_offload;
18151 for (q = 0; q < nb_rx_queues; q++)
18152 port->rx_conf[q].offloads &= ~single_offload;
18155 cmd_reconfig_device_queue(port_id, 1, 1);
18158 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18159 .f = cmd_config_per_port_rx_offload_parsed,
18161 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18162 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18163 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18164 "jumbo_frame|scatter|timestamp|security|keep_crc "
18167 (void *)&cmd_config_per_port_rx_offload_result_port,
18168 (void *)&cmd_config_per_port_rx_offload_result_config,
18169 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18170 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18171 (void *)&cmd_config_per_port_rx_offload_result_offload,
18172 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18177 /* Enable/Disable a per queue offloading */
18178 struct cmd_config_per_queue_rx_offload_result {
18179 cmdline_fixed_string_t port;
18181 cmdline_fixed_string_t rxq;
18183 cmdline_fixed_string_t rx_offload;
18184 cmdline_fixed_string_t offload;
18185 cmdline_fixed_string_t on_off;
18188 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18189 TOKEN_STRING_INITIALIZER
18190 (struct cmd_config_per_queue_rx_offload_result,
18192 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18193 TOKEN_NUM_INITIALIZER
18194 (struct cmd_config_per_queue_rx_offload_result,
18196 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18197 TOKEN_STRING_INITIALIZER
18198 (struct cmd_config_per_queue_rx_offload_result,
18200 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18201 TOKEN_NUM_INITIALIZER
18202 (struct cmd_config_per_queue_rx_offload_result,
18204 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18205 TOKEN_STRING_INITIALIZER
18206 (struct cmd_config_per_queue_rx_offload_result,
18207 rx_offload, "rx_offload");
18208 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18209 TOKEN_STRING_INITIALIZER
18210 (struct cmd_config_per_queue_rx_offload_result,
18211 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18212 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18213 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18214 "scatter#timestamp#security#keep_crc");
18215 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18216 TOKEN_STRING_INITIALIZER
18217 (struct cmd_config_per_queue_rx_offload_result,
18221 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18222 __attribute__((unused)) struct cmdline *cl,
18223 __attribute__((unused)) void *data)
18225 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18226 struct rte_eth_dev_info dev_info;
18227 portid_t port_id = res->port_id;
18228 uint16_t queue_id = res->queue_id;
18229 struct rte_port *port = &ports[port_id];
18230 uint64_t single_offload;
18233 if (port->port_status != RTE_PORT_STOPPED) {
18234 printf("Error: Can't config offload when Port %d "
18235 "is not stopped\n", port_id);
18239 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18243 if (queue_id >= dev_info.nb_rx_queues) {
18244 printf("Error: input queue_id should be 0 ... "
18245 "%d\n", dev_info.nb_rx_queues - 1);
18249 single_offload = search_rx_offload(res->offload);
18250 if (single_offload == 0) {
18251 printf("Unknown offload name: %s\n", res->offload);
18255 if (!strcmp(res->on_off, "on"))
18256 port->rx_conf[queue_id].offloads |= single_offload;
18258 port->rx_conf[queue_id].offloads &= ~single_offload;
18260 cmd_reconfig_device_queue(port_id, 1, 1);
18263 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18264 .f = cmd_config_per_queue_rx_offload_parsed,
18266 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18267 "vlan_strip|ipv4_cksum|"
18268 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18269 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18270 "jumbo_frame|scatter|timestamp|security|keep_crc "
18273 (void *)&cmd_config_per_queue_rx_offload_result_port,
18274 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18275 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18276 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18277 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18278 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18279 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18284 /* Get Tx offloads capabilities */
18285 struct cmd_tx_offload_get_capa_result {
18286 cmdline_fixed_string_t show;
18287 cmdline_fixed_string_t port;
18289 cmdline_fixed_string_t tx_offload;
18290 cmdline_fixed_string_t capabilities;
18293 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18294 TOKEN_STRING_INITIALIZER
18295 (struct cmd_tx_offload_get_capa_result,
18297 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18298 TOKEN_STRING_INITIALIZER
18299 (struct cmd_tx_offload_get_capa_result,
18301 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18302 TOKEN_NUM_INITIALIZER
18303 (struct cmd_tx_offload_get_capa_result,
18305 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18306 TOKEN_STRING_INITIALIZER
18307 (struct cmd_tx_offload_get_capa_result,
18308 tx_offload, "tx_offload");
18309 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18310 TOKEN_STRING_INITIALIZER
18311 (struct cmd_tx_offload_get_capa_result,
18312 capabilities, "capabilities");
18315 print_tx_offloads(uint64_t offloads)
18317 uint64_t single_offload;
18325 begin = __builtin_ctzll(offloads);
18326 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18328 single_offload = 1ULL << begin;
18329 for (bit = begin; bit < end; bit++) {
18330 if (offloads & single_offload)
18332 rte_eth_dev_tx_offload_name(single_offload));
18333 single_offload <<= 1;
18338 cmd_tx_offload_get_capa_parsed(
18339 void *parsed_result,
18340 __attribute__((unused)) struct cmdline *cl,
18341 __attribute__((unused)) void *data)
18343 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18344 struct rte_eth_dev_info dev_info;
18345 portid_t port_id = res->port_id;
18346 uint64_t queue_offloads;
18347 uint64_t port_offloads;
18350 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18354 queue_offloads = dev_info.tx_queue_offload_capa;
18355 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18357 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18358 printf(" Per Queue :");
18359 print_tx_offloads(queue_offloads);
18362 printf(" Per Port :");
18363 print_tx_offloads(port_offloads);
18367 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18368 .f = cmd_tx_offload_get_capa_parsed,
18370 .help_str = "show port <port_id> tx_offload capabilities",
18372 (void *)&cmd_tx_offload_get_capa_show,
18373 (void *)&cmd_tx_offload_get_capa_port,
18374 (void *)&cmd_tx_offload_get_capa_port_id,
18375 (void *)&cmd_tx_offload_get_capa_tx_offload,
18376 (void *)&cmd_tx_offload_get_capa_capabilities,
18381 /* Get Tx offloads configuration */
18382 struct cmd_tx_offload_get_configuration_result {
18383 cmdline_fixed_string_t show;
18384 cmdline_fixed_string_t port;
18386 cmdline_fixed_string_t tx_offload;
18387 cmdline_fixed_string_t configuration;
18390 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18391 TOKEN_STRING_INITIALIZER
18392 (struct cmd_tx_offload_get_configuration_result,
18394 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18395 TOKEN_STRING_INITIALIZER
18396 (struct cmd_tx_offload_get_configuration_result,
18398 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18399 TOKEN_NUM_INITIALIZER
18400 (struct cmd_tx_offload_get_configuration_result,
18402 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18403 TOKEN_STRING_INITIALIZER
18404 (struct cmd_tx_offload_get_configuration_result,
18405 tx_offload, "tx_offload");
18406 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18407 TOKEN_STRING_INITIALIZER
18408 (struct cmd_tx_offload_get_configuration_result,
18409 configuration, "configuration");
18412 cmd_tx_offload_get_configuration_parsed(
18413 void *parsed_result,
18414 __attribute__((unused)) struct cmdline *cl,
18415 __attribute__((unused)) void *data)
18417 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18418 struct rte_eth_dev_info dev_info;
18419 portid_t port_id = res->port_id;
18420 struct rte_port *port = &ports[port_id];
18421 uint64_t port_offloads;
18422 uint64_t queue_offloads;
18423 uint16_t nb_tx_queues;
18427 printf("Tx Offloading Configuration of port %d :\n", port_id);
18429 port_offloads = port->dev_conf.txmode.offloads;
18431 print_tx_offloads(port_offloads);
18434 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18438 nb_tx_queues = dev_info.nb_tx_queues;
18439 for (q = 0; q < nb_tx_queues; q++) {
18440 queue_offloads = port->tx_conf[q].offloads;
18441 printf(" Queue[%2d] :", q);
18442 print_tx_offloads(queue_offloads);
18448 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18449 .f = cmd_tx_offload_get_configuration_parsed,
18451 .help_str = "show port <port_id> tx_offload configuration",
18453 (void *)&cmd_tx_offload_get_configuration_show,
18454 (void *)&cmd_tx_offload_get_configuration_port,
18455 (void *)&cmd_tx_offload_get_configuration_port_id,
18456 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18457 (void *)&cmd_tx_offload_get_configuration_configuration,
18462 /* Enable/Disable a per port offloading */
18463 struct cmd_config_per_port_tx_offload_result {
18464 cmdline_fixed_string_t port;
18465 cmdline_fixed_string_t config;
18467 cmdline_fixed_string_t tx_offload;
18468 cmdline_fixed_string_t offload;
18469 cmdline_fixed_string_t on_off;
18472 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18473 TOKEN_STRING_INITIALIZER
18474 (struct cmd_config_per_port_tx_offload_result,
18476 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18477 TOKEN_STRING_INITIALIZER
18478 (struct cmd_config_per_port_tx_offload_result,
18480 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18481 TOKEN_NUM_INITIALIZER
18482 (struct cmd_config_per_port_tx_offload_result,
18484 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18485 TOKEN_STRING_INITIALIZER
18486 (struct cmd_config_per_port_tx_offload_result,
18487 tx_offload, "tx_offload");
18488 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18489 TOKEN_STRING_INITIALIZER
18490 (struct cmd_config_per_port_tx_offload_result,
18491 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18492 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18493 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18494 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18495 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18497 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18498 TOKEN_STRING_INITIALIZER
18499 (struct cmd_config_per_port_tx_offload_result,
18503 search_tx_offload(const char *name)
18505 uint64_t single_offload;
18506 const char *single_name;
18510 single_offload = 1;
18511 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18512 single_name = rte_eth_dev_tx_offload_name(single_offload);
18513 if (single_name == NULL)
18515 if (!strcasecmp(single_name, name)) {
18518 } else if (!strcasecmp(single_name, "UNKNOWN"))
18520 single_offload <<= 1;
18524 return single_offload;
18530 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18531 __attribute__((unused)) struct cmdline *cl,
18532 __attribute__((unused)) void *data)
18534 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18535 portid_t port_id = res->port_id;
18536 struct rte_eth_dev_info dev_info;
18537 struct rte_port *port = &ports[port_id];
18538 uint64_t single_offload;
18539 uint16_t nb_tx_queues;
18543 if (port->port_status != RTE_PORT_STOPPED) {
18544 printf("Error: Can't config offload when Port %d "
18545 "is not stopped\n", port_id);
18549 single_offload = search_tx_offload(res->offload);
18550 if (single_offload == 0) {
18551 printf("Unknown offload name: %s\n", res->offload);
18555 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18559 nb_tx_queues = dev_info.nb_tx_queues;
18560 if (!strcmp(res->on_off, "on")) {
18561 port->dev_conf.txmode.offloads |= single_offload;
18562 for (q = 0; q < nb_tx_queues; q++)
18563 port->tx_conf[q].offloads |= single_offload;
18565 port->dev_conf.txmode.offloads &= ~single_offload;
18566 for (q = 0; q < nb_tx_queues; q++)
18567 port->tx_conf[q].offloads &= ~single_offload;
18570 cmd_reconfig_device_queue(port_id, 1, 1);
18573 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18574 .f = cmd_config_per_port_tx_offload_parsed,
18576 .help_str = "port config <port_id> tx_offload "
18577 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18578 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18579 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18580 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18581 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18582 "match_metadata on|off",
18584 (void *)&cmd_config_per_port_tx_offload_result_port,
18585 (void *)&cmd_config_per_port_tx_offload_result_config,
18586 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18587 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18588 (void *)&cmd_config_per_port_tx_offload_result_offload,
18589 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18594 /* Enable/Disable a per queue offloading */
18595 struct cmd_config_per_queue_tx_offload_result {
18596 cmdline_fixed_string_t port;
18598 cmdline_fixed_string_t txq;
18600 cmdline_fixed_string_t tx_offload;
18601 cmdline_fixed_string_t offload;
18602 cmdline_fixed_string_t on_off;
18605 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18606 TOKEN_STRING_INITIALIZER
18607 (struct cmd_config_per_queue_tx_offload_result,
18609 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18610 TOKEN_NUM_INITIALIZER
18611 (struct cmd_config_per_queue_tx_offload_result,
18613 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18614 TOKEN_STRING_INITIALIZER
18615 (struct cmd_config_per_queue_tx_offload_result,
18617 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18618 TOKEN_NUM_INITIALIZER
18619 (struct cmd_config_per_queue_tx_offload_result,
18621 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18622 TOKEN_STRING_INITIALIZER
18623 (struct cmd_config_per_queue_tx_offload_result,
18624 tx_offload, "tx_offload");
18625 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18626 TOKEN_STRING_INITIALIZER
18627 (struct cmd_config_per_queue_tx_offload_result,
18628 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18629 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18630 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18631 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18632 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18633 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18634 TOKEN_STRING_INITIALIZER
18635 (struct cmd_config_per_queue_tx_offload_result,
18639 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18640 __attribute__((unused)) struct cmdline *cl,
18641 __attribute__((unused)) void *data)
18643 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18644 struct rte_eth_dev_info dev_info;
18645 portid_t port_id = res->port_id;
18646 uint16_t queue_id = res->queue_id;
18647 struct rte_port *port = &ports[port_id];
18648 uint64_t single_offload;
18651 if (port->port_status != RTE_PORT_STOPPED) {
18652 printf("Error: Can't config offload when Port %d "
18653 "is not stopped\n", port_id);
18657 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18661 if (queue_id >= dev_info.nb_tx_queues) {
18662 printf("Error: input queue_id should be 0 ... "
18663 "%d\n", dev_info.nb_tx_queues - 1);
18667 single_offload = search_tx_offload(res->offload);
18668 if (single_offload == 0) {
18669 printf("Unknown offload name: %s\n", res->offload);
18673 if (!strcmp(res->on_off, "on"))
18674 port->tx_conf[queue_id].offloads |= single_offload;
18676 port->tx_conf[queue_id].offloads &= ~single_offload;
18678 cmd_reconfig_device_queue(port_id, 1, 1);
18681 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18682 .f = cmd_config_per_queue_tx_offload_parsed,
18684 .help_str = "port <port_id> txq <queue_id> tx_offload "
18685 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18686 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18687 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18688 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18689 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18692 (void *)&cmd_config_per_queue_tx_offload_result_port,
18693 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18694 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18695 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18696 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18697 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18698 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18703 /* *** configure tx_metadata for specific port *** */
18704 struct cmd_config_tx_metadata_specific_result {
18705 cmdline_fixed_string_t port;
18706 cmdline_fixed_string_t keyword;
18708 cmdline_fixed_string_t item;
18713 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18714 __attribute__((unused)) struct cmdline *cl,
18715 __attribute__((unused)) void *data)
18717 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18721 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18722 /* Add/remove callback to insert valid metadata in every Tx packet. */
18723 if (ports[res->port_id].tx_metadata)
18724 add_tx_md_callback(res->port_id);
18726 remove_tx_md_callback(res->port_id);
18729 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18730 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18732 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18733 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18734 keyword, "config");
18735 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18736 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18738 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18739 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18740 item, "tx_metadata");
18741 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18742 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18745 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18746 .f = cmd_config_tx_metadata_specific_parsed,
18748 .help_str = "port config <port_id> tx_metadata <value>",
18750 (void *)&cmd_config_tx_metadata_specific_port,
18751 (void *)&cmd_config_tx_metadata_specific_keyword,
18752 (void *)&cmd_config_tx_metadata_specific_id,
18753 (void *)&cmd_config_tx_metadata_specific_item,
18754 (void *)&cmd_config_tx_metadata_specific_value,
18759 /* *** display tx_metadata per port configuration *** */
18760 struct cmd_show_tx_metadata_result {
18761 cmdline_fixed_string_t cmd_show;
18762 cmdline_fixed_string_t cmd_port;
18763 cmdline_fixed_string_t cmd_keyword;
18768 cmd_show_tx_metadata_parsed(void *parsed_result,
18769 __attribute__((unused)) struct cmdline *cl,
18770 __attribute__((unused)) void *data)
18772 struct cmd_show_tx_metadata_result *res = parsed_result;
18774 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18775 printf("invalid port id %u\n", res->cmd_pid);
18778 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18779 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18780 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18784 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18785 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18787 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18788 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18790 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18791 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18793 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18794 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18795 cmd_keyword, "tx_metadata");
18797 cmdline_parse_inst_t cmd_show_tx_metadata = {
18798 .f = cmd_show_tx_metadata_parsed,
18800 .help_str = "show port <port_id> tx_metadata",
18802 (void *)&cmd_show_tx_metadata_show,
18803 (void *)&cmd_show_tx_metadata_port,
18804 (void *)&cmd_show_tx_metadata_pid,
18805 (void *)&cmd_show_tx_metadata_keyword,
18810 /* show port supported ptypes */
18812 /* Common result structure for show port ptypes */
18813 struct cmd_show_port_supported_ptypes_result {
18814 cmdline_fixed_string_t show;
18815 cmdline_fixed_string_t port;
18817 cmdline_fixed_string_t ptypes;
18820 /* Common CLI fields for show port ptypes */
18821 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18822 TOKEN_STRING_INITIALIZER
18823 (struct cmd_show_port_supported_ptypes_result,
18825 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18826 TOKEN_STRING_INITIALIZER
18827 (struct cmd_show_port_supported_ptypes_result,
18829 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18830 TOKEN_NUM_INITIALIZER
18831 (struct cmd_show_port_supported_ptypes_result,
18833 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18834 TOKEN_STRING_INITIALIZER
18835 (struct cmd_show_port_supported_ptypes_result,
18839 cmd_show_port_supported_ptypes_parsed(
18840 void *parsed_result,
18841 __attribute__((unused)) struct cmdline *cl,
18842 __attribute__((unused)) void *data)
18844 #define RSVD_PTYPE_MASK 0xf0000000
18845 #define MAX_PTYPES_PER_LAYER 16
18846 #define LTYPE_NAMESIZE 32
18847 #define PTYPE_NAMESIZE 256
18848 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18849 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18850 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18851 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18852 uint16_t port_id = res->port_id;
18855 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18859 while (ptype_mask != RSVD_PTYPE_MASK) {
18861 switch (ptype_mask) {
18862 case RTE_PTYPE_L2_MASK:
18863 strlcpy(ltype, "L2", sizeof(ltype));
18865 case RTE_PTYPE_L3_MASK:
18866 strlcpy(ltype, "L3", sizeof(ltype));
18868 case RTE_PTYPE_L4_MASK:
18869 strlcpy(ltype, "L4", sizeof(ltype));
18871 case RTE_PTYPE_TUNNEL_MASK:
18872 strlcpy(ltype, "Tunnel", sizeof(ltype));
18874 case RTE_PTYPE_INNER_L2_MASK:
18875 strlcpy(ltype, "Inner L2", sizeof(ltype));
18877 case RTE_PTYPE_INNER_L3_MASK:
18878 strlcpy(ltype, "Inner L3", sizeof(ltype));
18880 case RTE_PTYPE_INNER_L4_MASK:
18881 strlcpy(ltype, "Inner L4", sizeof(ltype));
18887 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18888 ptype_mask, ptypes,
18889 MAX_PTYPES_PER_LAYER);
18892 printf("Supported %s ptypes:\n", ltype);
18894 printf("%s ptypes unsupported\n", ltype);
18896 for (i = 0; i < ret; ++i) {
18897 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18898 printf("%s\n", buf);
18905 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18906 .f = cmd_show_port_supported_ptypes_parsed,
18908 .help_str = "show port <port_id> ptypes",
18910 (void *)&cmd_show_port_supported_ptypes_show,
18911 (void *)&cmd_show_port_supported_ptypes_port,
18912 (void *)&cmd_show_port_supported_ptypes_port_id,
18913 (void *)&cmd_show_port_supported_ptypes_ptypes,
18918 /* ******************************************************************************** */
18920 /* list of instructions */
18921 cmdline_parse_ctx_t main_ctx[] = {
18922 (cmdline_parse_inst_t *)&cmd_help_brief,
18923 (cmdline_parse_inst_t *)&cmd_help_long,
18924 (cmdline_parse_inst_t *)&cmd_quit,
18925 (cmdline_parse_inst_t *)&cmd_load_from_file,
18926 (cmdline_parse_inst_t *)&cmd_showport,
18927 (cmdline_parse_inst_t *)&cmd_showqueue,
18928 (cmdline_parse_inst_t *)&cmd_showportall,
18929 (cmdline_parse_inst_t *)&cmd_showdevice,
18930 (cmdline_parse_inst_t *)&cmd_showcfg,
18931 (cmdline_parse_inst_t *)&cmd_showfwdall,
18932 (cmdline_parse_inst_t *)&cmd_start,
18933 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18934 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18935 (cmdline_parse_inst_t *)&cmd_set_link_up,
18936 (cmdline_parse_inst_t *)&cmd_set_link_down,
18937 (cmdline_parse_inst_t *)&cmd_reset,
18938 (cmdline_parse_inst_t *)&cmd_set_numbers,
18939 (cmdline_parse_inst_t *)&cmd_set_log,
18940 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18941 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18942 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18943 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18944 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18945 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18946 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18947 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18948 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18949 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18950 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18951 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18952 (cmdline_parse_inst_t *)&cmd_set_link_check,
18953 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18954 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18955 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18956 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18957 #ifdef RTE_LIBRTE_PMD_BOND
18958 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18959 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18960 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18961 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18962 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18963 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18964 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18965 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18966 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18967 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18968 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18970 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18971 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18972 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18973 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18974 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18975 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18976 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18977 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18978 (cmdline_parse_inst_t *)&cmd_csum_set,
18979 (cmdline_parse_inst_t *)&cmd_csum_show,
18980 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18981 (cmdline_parse_inst_t *)&cmd_tso_set,
18982 (cmdline_parse_inst_t *)&cmd_tso_show,
18983 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18984 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18985 (cmdline_parse_inst_t *)&cmd_gro_enable,
18986 (cmdline_parse_inst_t *)&cmd_gro_flush,
18987 (cmdline_parse_inst_t *)&cmd_gro_show,
18988 (cmdline_parse_inst_t *)&cmd_gso_enable,
18989 (cmdline_parse_inst_t *)&cmd_gso_size,
18990 (cmdline_parse_inst_t *)&cmd_gso_show,
18991 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18992 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18993 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18994 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18995 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18996 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18997 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18998 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18999 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19000 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19001 (cmdline_parse_inst_t *)&cmd_config_dcb,
19002 (cmdline_parse_inst_t *)&cmd_read_reg,
19003 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19004 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19005 (cmdline_parse_inst_t *)&cmd_write_reg,
19006 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19007 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19008 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19009 (cmdline_parse_inst_t *)&cmd_stop,
19010 (cmdline_parse_inst_t *)&cmd_mac_addr,
19011 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19012 (cmdline_parse_inst_t *)&cmd_set_qmap,
19013 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19014 (cmdline_parse_inst_t *)&cmd_operate_port,
19015 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19016 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19017 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19018 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19019 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19020 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19021 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19022 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19023 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19024 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19025 (cmdline_parse_inst_t *)&cmd_config_mtu,
19026 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19027 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19028 (cmdline_parse_inst_t *)&cmd_config_rss,
19029 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19030 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19031 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19032 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19033 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19034 (cmdline_parse_inst_t *)&cmd_showport_reta,
19035 (cmdline_parse_inst_t *)&cmd_config_burst,
19036 (cmdline_parse_inst_t *)&cmd_config_thresh,
19037 (cmdline_parse_inst_t *)&cmd_config_threshold,
19038 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19039 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19040 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19041 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19042 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19043 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19044 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19045 (cmdline_parse_inst_t *)&cmd_global_config,
19046 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19047 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19048 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19049 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19050 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19051 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19052 (cmdline_parse_inst_t *)&cmd_dump,
19053 (cmdline_parse_inst_t *)&cmd_dump_one,
19054 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19055 (cmdline_parse_inst_t *)&cmd_syn_filter,
19056 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19057 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19058 (cmdline_parse_inst_t *)&cmd_flex_filter,
19059 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19060 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19061 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19062 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19063 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19064 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19065 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19066 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19067 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19068 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19069 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19070 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19071 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19072 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19073 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19074 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19075 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19076 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19077 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19078 (cmdline_parse_inst_t *)&cmd_flow,
19079 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19080 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19081 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19082 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19083 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19084 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19085 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19086 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19087 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19088 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19089 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19090 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19091 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19092 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19093 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19094 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19095 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19096 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19097 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19098 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19099 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19100 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19101 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19102 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19103 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19104 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19105 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19106 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19107 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19108 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19109 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19110 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19111 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19112 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19113 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19114 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19115 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19116 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19117 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19118 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19119 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19120 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19121 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19122 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19123 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19124 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19125 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19126 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19127 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19128 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19129 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19131 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19132 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19133 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19134 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19135 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19136 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19137 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19138 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19139 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19140 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19141 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19142 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19143 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19144 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19145 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19146 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19147 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19148 (cmdline_parse_inst_t *)&cmd_ddp_add,
19149 (cmdline_parse_inst_t *)&cmd_ddp_del,
19150 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19151 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19152 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19153 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19154 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19155 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19156 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19157 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19158 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19159 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19160 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19162 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19163 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19164 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19165 (cmdline_parse_inst_t *)&cmd_queue_region,
19166 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19167 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19168 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19169 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19170 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19171 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19172 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19173 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19174 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19175 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19176 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19177 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19178 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19179 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19180 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19181 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19182 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19183 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19184 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19185 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19186 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19187 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19188 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19189 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19190 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19191 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19192 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19193 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19194 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19195 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19196 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19197 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19198 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19199 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19200 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19201 #ifdef RTE_LIBRTE_BPF
19202 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19203 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19205 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19206 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19207 (cmdline_parse_inst_t *)&cmd_set_raw,
19208 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19209 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19213 /* read cmdline commands from file */
19215 cmdline_read_from_file(const char *filename)
19217 struct cmdline *cl;
19219 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19221 printf("Failed to create file based cmdline context: %s\n",
19226 cmdline_interact(cl);
19231 printf("Read CLI commands from %s\n", filename);
19234 /* prompt function, called from main on MASTER lcore */
19238 /* initialize non-constant commands */
19239 cmd_set_fwd_mode_init();
19240 cmd_set_fwd_retry_mode_init();
19242 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19243 if (testpmd_cl == NULL)
19245 cmdline_interact(testpmd_cl);
19246 cmdline_stdin_exit(testpmd_cl);
19252 if (testpmd_cl != NULL)
19253 cmdline_quit(testpmd_cl);
19257 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19259 if (id == (portid_t)RTE_PORT_ALL) {
19262 RTE_ETH_FOREACH_DEV(pid) {
19263 /* check if need_reconfig has been set to 1 */
19264 if (ports[pid].need_reconfig == 0)
19265 ports[pid].need_reconfig = dev;
19266 /* check if need_reconfig_queues has been set to 1 */
19267 if (ports[pid].need_reconfig_queues == 0)
19268 ports[pid].need_reconfig_queues = queue;
19270 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19271 /* check if need_reconfig has been set to 1 */
19272 if (ports[id].need_reconfig == 0)
19273 ports[id].need_reconfig = dev;
19274 /* check if need_reconfig_queues has been set to 1 */
19275 if (ports[id].need_reconfig_queues == 0)
19276 ports[id].need_reconfig_queues = queue;