1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
44 #include <cmdline_rdline.h>
45 #include <cmdline_parse.h>
46 #include <cmdline_parse_num.h>
47 #include <cmdline_parse_string.h>
48 #include <cmdline_parse_ipaddr.h>
49 #include <cmdline_parse_etheraddr.h>
50 #include <cmdline_socket.h>
52 #ifdef RTE_LIBRTE_PMD_BOND
53 #include <rte_eth_bond.h>
54 #include <rte_eth_bond_8023ad.h>
56 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
57 #include <rte_pmd_dpaa.h>
59 #ifdef RTE_LIBRTE_IXGBE_PMD
60 #include <rte_pmd_ixgbe.h>
62 #ifdef RTE_LIBRTE_I40E_PMD
63 #include <rte_pmd_i40e.h>
65 #ifdef RTE_LIBRTE_BNXT_PMD
66 #include <rte_pmd_bnxt.h>
69 #include "cmdline_mtr.h"
70 #include "cmdline_tm.h"
73 static struct cmdline *testpmd_cl;
75 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
77 /* *** Help command with introduction. *** */
78 struct cmd_help_brief_result {
79 cmdline_fixed_string_t help;
82 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
84 __attribute__((unused)) void *data)
89 "Help is available for the following sections:\n\n"
90 " help control : Start and stop forwarding.\n"
91 " help display : Displaying port, stats and config "
93 " help config : Configuration information.\n"
94 " help ports : Configuring ports.\n"
95 " help registers : Reading and setting port registers.\n"
96 " help filters : Filters configuration help.\n"
97 " help traffic_management : Traffic Management commmands.\n"
98 " help devices : Device related cmds.\n"
99 " help all : All of the above sections.\n\n"
104 cmdline_parse_token_string_t cmd_help_brief_help =
105 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 cmdline_parse_inst_t cmd_help_brief = {
108 .f = cmd_help_brief_parsed,
110 .help_str = "help: Show help",
112 (void *)&cmd_help_brief_help,
117 /* *** Help command with help sections. *** */
118 struct cmd_help_long_result {
119 cmdline_fixed_string_t help;
120 cmdline_fixed_string_t section;
123 static void cmd_help_long_parsed(void *parsed_result,
125 __attribute__((unused)) void *data)
128 struct cmd_help_long_result *res = parsed_result;
130 if (!strcmp(res->section, "all"))
133 if (show_all || !strcmp(res->section, "control")) {
138 "Control forwarding:\n"
139 "-------------------\n\n"
142 " Start packet forwarding with current configuration.\n\n"
145 " Start packet forwarding with current config"
146 " after sending one burst of packets.\n\n"
149 " Stop packet forwarding, and display accumulated"
153 " Quit to prompt.\n\n"
157 if (show_all || !strcmp(res->section, "display")) {
165 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
166 " Display information for port_id, or all.\n\n"
168 "show port X rss reta (size) (mask0,mask1,...)\n"
169 " Display the rss redirection table entry indicated"
170 " by masks on port X. size is used to indicate the"
171 " hardware supported reta size\n\n"
173 "show port (port_id) rss-hash [key]\n"
174 " Display the RSS hash functions and RSS hash key of port\n\n"
176 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
177 " Clear information for port_id, or all.\n\n"
179 "show (rxq|txq) info (port_id) (queue_id)\n"
180 " Display information for configured RX/TX queue.\n\n"
182 "show config (rxtx|cores|fwd|txpkts)\n"
183 " Display the given configuration.\n\n"
185 "read rxd (port_id) (queue_id) (rxd_id)\n"
186 " Display an RX descriptor of a port RX queue.\n\n"
188 "read txd (port_id) (queue_id) (txd_id)\n"
189 " Display a TX descriptor of a port TX queue.\n\n"
191 "ddp get list (port_id)\n"
192 " Get ddp profile info list\n\n"
194 "ddp get info (profile_path)\n"
195 " Get ddp profile information.\n\n"
197 "show vf stats (port_id) (vf_id)\n"
198 " Display a VF's statistics.\n\n"
200 "clear vf stats (port_id) (vf_id)\n"
201 " Reset a VF's statistics.\n\n"
203 "show port (port_id) pctype mapping\n"
204 " Get flow ptype to pctype mapping on a port\n\n"
206 "show port meter stats (port_id) (meter_id) (clear)\n"
207 " Get meter stats on a port\n\n"
209 "show fwd stats all\n"
210 " Display statistics for all fwd engines.\n\n"
212 "clear fwd stats all\n"
213 " Clear statistics for all fwd engines.\n\n"
215 "show port (port_id) rx_offload capabilities\n"
216 " List all per queue and per port Rx offloading"
217 " capabilities of a port\n\n"
219 "show port (port_id) rx_offload configuration\n"
220 " List port level and all queue level"
221 " Rx offloading configuration\n\n"
223 "show port (port_id) tx_offload capabilities\n"
224 " List all per queue and per port"
225 " Tx offloading capabilities of a port\n\n"
227 "show port (port_id) tx_offload configuration\n"
228 " List port level and all queue level"
229 " Tx offloading configuration\n\n"
231 "show port (port_id) tx_metadata\n"
232 " Show Tx metadata value set"
233 " for a specific port\n\n"
235 "show port (port_id) ptypes\n"
236 " Show port supported ptypes"
237 " for a specific port\n\n"
239 "show device info (<identifier>|all)"
240 " Show general information about devices probed.\n\n"
242 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
243 " Show status of rx|tx descriptor.\n\n"
245 "show port (port_id) macs|mcast_macs"
246 " Display list of mac addresses added to port.\n\n"
250 if (show_all || !strcmp(res->section, "config")) {
256 "Configuration changes only become active when"
257 " forwarding is started/restarted.\n\n"
260 " Reset forwarding to the default configuration.\n\n"
262 "set verbose (level)\n"
263 " Set the debug verbosity level X.\n\n"
265 "set log global|(type) (level)\n"
266 " Set the log level.\n\n"
269 " Set number of ports.\n\n"
272 " Set number of cores.\n\n"
274 "set coremask (mask)\n"
275 " Set the forwarding cores hexadecimal mask.\n\n"
277 "set portmask (mask)\n"
278 " Set the forwarding ports hexadecimal mask.\n\n"
281 " Set number of packets per burst.\n\n"
283 "set burst tx delay (microseconds) retry (num)\n"
284 " Set the transmit delay time and number of retries,"
285 " effective when retry is enabled.\n\n"
287 "set txpkts (x[,y]*)\n"
288 " Set the length of each segment of TXONLY"
289 " and optionally CSUM packets.\n\n"
291 "set txsplit (off|on|rand)\n"
292 " Set the split policy for the TX packets."
293 " Right now only applicable for CSUM and TXONLY"
296 "set corelist (x[,y]*)\n"
297 " Set the list of forwarding cores.\n\n"
299 "set portlist (x[,y]*)\n"
300 " Set the list of forwarding ports.\n\n"
302 "set port setup on (iterator|event)\n"
303 " Select how attached port is retrieved for setup.\n\n"
305 "set tx loopback (port_id) (on|off)\n"
306 " Enable or disable tx loopback.\n\n"
308 "set all queues drop (port_id) (on|off)\n"
309 " Set drop enable bit for all queues.\n\n"
311 "set vf split drop (port_id) (vf_id) (on|off)\n"
312 " Set split drop enable bit for a VF from the PF.\n\n"
314 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
315 " Set MAC antispoof for a VF from the PF.\n\n"
317 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
318 " Enable MACsec offload.\n\n"
320 "set macsec offload (port_id) off\n"
321 " Disable MACsec offload.\n\n"
323 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
324 " Configure MACsec secure connection (SC).\n\n"
326 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
327 " Configure MACsec secure association (SA).\n\n"
329 "set vf broadcast (port_id) (vf_id) (on|off)\n"
330 " Set VF broadcast for a VF from the PF.\n\n"
332 "vlan set stripq (on|off) (port_id,queue_id)\n"
333 " Set the VLAN strip for a queue on a port.\n\n"
335 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
336 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
338 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
339 " Set VLAN insert for a VF from the PF.\n\n"
341 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
342 " Set VLAN antispoof for a VF from the PF.\n\n"
344 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
345 " Set VLAN tag for a VF from the PF.\n\n"
347 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
348 " Set a VF's max bandwidth(Mbps).\n\n"
350 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
351 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
353 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
354 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
356 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
357 " Set some TCs' strict link priority mode on a physical port.\n\n"
359 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
360 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
362 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
363 " Set the VLAN strip or filter or qinq strip or extend\n\n"
365 "vlan set (inner|outer) tpid (value) (port_id)\n"
366 " Set the VLAN TPID for Packet Filtering on"
369 "rx_vlan add (vlan_id|all) (port_id)\n"
370 " Add a vlan_id, or all identifiers, to the set"
371 " of VLAN identifiers filtered by port_id.\n\n"
373 "rx_vlan rm (vlan_id|all) (port_id)\n"
374 " Remove a vlan_id, or all identifiers, from the set"
375 " of VLAN identifiers filtered by port_id.\n\n"
377 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
378 " Add a vlan_id, to the set of VLAN identifiers"
379 "filtered for VF(s) from port_id.\n\n"
381 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
382 " Remove a vlan_id, to the set of VLAN identifiers"
383 "filtered for VF(s) from port_id.\n\n"
385 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
386 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
387 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
388 " add a tunnel filter of a port.\n\n"
390 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
391 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
392 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
393 " remove a tunnel filter of a port.\n\n"
395 "rx_vxlan_port add (udp_port) (port_id)\n"
396 " Add an UDP port for VXLAN packet filter on a port\n\n"
398 "rx_vxlan_port rm (udp_port) (port_id)\n"
399 " Remove an UDP port for VXLAN packet filter on a port\n\n"
401 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
402 " Set hardware insertion of VLAN IDs (single or double VLAN "
403 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
405 "tx_vlan set pvid port_id vlan_id (on|off)\n"
406 " Set port based TX VLAN insertion.\n\n"
408 "tx_vlan reset (port_id)\n"
409 " Disable hardware insertion of a VLAN header in"
410 " packets sent on a port.\n\n"
412 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
413 " Select hardware or software calculation of the"
414 " checksum when transmitting a packet using the"
415 " csum forward engine.\n"
416 " ip|udp|tcp|sctp always concern the inner layer.\n"
417 " outer-ip concerns the outer IP layer in"
418 " outer-udp concerns the outer UDP layer in"
419 " case the packet is recognized as a tunnel packet by"
420 " the forward engine (vxlan, gre and ipip are supported)\n"
421 " Please check the NIC datasheet for HW limits.\n\n"
423 "csum parse-tunnel (on|off) (tx_port_id)\n"
424 " If disabled, treat tunnel packets as non-tunneled"
425 " packets (treat inner headers as payload). The port\n"
426 " argument is the port used for TX in csum forward"
429 "csum show (port_id)\n"
430 " Display tx checksum offload configuration\n\n"
432 "tso set (segsize) (portid)\n"
433 " Enable TCP Segmentation Offload in csum forward"
435 " Please check the NIC datasheet for HW limits.\n\n"
438 " Display the status of TCP Segmentation Offload.\n\n"
440 "set port (port_id) gro on|off\n"
441 " Enable or disable Generic Receive Offload in"
442 " csum forwarding engine.\n\n"
444 "show port (port_id) gro\n"
445 " Display GRO configuration.\n\n"
447 "set gro flush (cycles)\n"
448 " Set the cycle to flush GROed packets from"
449 " reassembly tables.\n\n"
451 "set port (port_id) gso (on|off)"
452 " Enable or disable Generic Segmentation Offload in"
453 " csum forwarding engine.\n\n"
455 "set gso segsz (length)\n"
456 " Set max packet length for output GSO segments,"
457 " including packet header and payload.\n\n"
459 "show port (port_id) gso\n"
460 " Show GSO configuration.\n\n"
463 " Set packet forwarding mode.\n\n"
465 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
466 " Add a MAC address on port_id.\n\n"
468 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
469 " Remove a MAC address from port_id.\n\n"
471 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
472 " Set the default MAC address for port_id.\n\n"
474 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
475 " Add a MAC address for a VF on the port.\n\n"
477 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Set the MAC address for a VF from the PF.\n\n"
480 "set eth-peer (port_id) (peer_addr)\n"
481 " set the peer address for certain port.\n\n"
483 "set port (port_id) uta (mac_address|all) (on|off)\n"
484 " Add/Remove a or all unicast hash filter(s)"
487 "set promisc (port_id|all) (on|off)\n"
488 " Set the promiscuous mode on port_id, or all.\n\n"
490 "set allmulti (port_id|all) (on|off)\n"
491 " Set the allmulti mode on port_id, or all.\n\n"
493 "set vf promisc (port_id) (vf_id) (on|off)\n"
494 " Set unicast promiscuous mode for a VF from the PF.\n\n"
496 "set vf allmulti (port_id) (vf_id) (on|off)\n"
497 " Set multicast promiscuous mode for a VF from the PF.\n\n"
499 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
500 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
501 " (on|off) autoneg (on|off) (port_id)\n"
502 "set flow_ctrl rx (on|off) (portid)\n"
503 "set flow_ctrl tx (on|off) (portid)\n"
504 "set flow_ctrl high_water (high_water) (portid)\n"
505 "set flow_ctrl low_water (low_water) (portid)\n"
506 "set flow_ctrl pause_time (pause_time) (portid)\n"
507 "set flow_ctrl send_xon (send_xon) (portid)\n"
508 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
509 "set flow_ctrl autoneg (on|off) (port_id)\n"
510 " Set the link flow control parameter on a port.\n\n"
512 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
513 " (low_water) (pause_time) (priority) (port_id)\n"
514 " Set the priority flow control parameter on a"
517 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
518 " Set statistics mapping (qmapping 0..15) for RX/TX"
520 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
521 " on port 0 to mapping 5.\n\n"
523 "set xstats-hide-zero on|off\n"
524 " Set the option to hide the zero values"
525 " for xstats display.\n"
527 "set port (port_id) vf (vf_id) rx|tx on|off\n"
528 " Enable/Disable a VF receive/tranmit from a port\n\n"
530 "set port (port_id) vf (vf_id) (mac_addr)"
531 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
532 " Add/Remove unicast or multicast MAC addr filter"
535 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
537 " AUPE:accepts untagged VLAN;"
538 "ROPE:accept unicast hash\n\n"
539 " BAM:accepts broadcast packets;"
540 "MPE:accepts all multicast packets\n\n"
541 " Enable/Disable a VF receive mode of a port\n\n"
543 "set port (port_id) queue (queue_id) rate (rate_num)\n"
544 " Set rate limit for a queue of a port\n\n"
546 "set port (port_id) vf (vf_id) rate (rate_num) "
547 "queue_mask (queue_mask_value)\n"
548 " Set rate limit for queues in VF of a port\n\n"
550 "set port (port_id) mirror-rule (rule_id)"
551 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
552 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
553 " Set pool or vlan type mirror rule on a port.\n"
554 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
555 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
558 "set port (port_id) mirror-rule (rule_id)"
559 " (uplink-mirror|downlink-mirror) dst-pool"
560 " (pool_id) (on|off)\n"
561 " Set uplink or downlink type mirror rule on a port.\n"
562 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
563 " 0 on' enable mirror income traffic to pool 0.\n\n"
565 "reset port (port_id) mirror-rule (rule_id)\n"
566 " Reset a mirror rule.\n\n"
568 "set flush_rx (on|off)\n"
569 " Flush (default) or don't flush RX streams before"
570 " forwarding. Mainly used with PCAP drivers.\n\n"
572 "set bypass mode (normal|bypass|isolate) (port_id)\n"
573 " Set the bypass mode for the lowest port on bypass enabled"
576 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
577 "mode (normal|bypass|isolate) (port_id)\n"
578 " Set the event required to initiate specified bypass mode for"
579 " the lowest port on a bypass enabled NIC where:\n"
580 " timeout = enable bypass after watchdog timeout.\n"
581 " os_on = enable bypass when OS/board is powered on.\n"
582 " os_off = enable bypass when OS/board is powered off.\n"
583 " power_on = enable bypass when power supply is turned on.\n"
584 " power_off = enable bypass when power supply is turned off."
587 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
588 " Set the bypass watchdog timeout to 'n' seconds"
589 " where 0 = instant.\n\n"
591 "show bypass config (port_id)\n"
592 " Show the bypass configuration for a bypass enabled NIC"
593 " using the lowest port on the NIC.\n\n"
595 #ifdef RTE_LIBRTE_PMD_BOND
596 "create bonded device (mode) (socket)\n"
597 " Create a new bonded device with specific bonding mode and socket.\n\n"
599 "add bonding slave (slave_id) (port_id)\n"
600 " Add a slave device to a bonded device.\n\n"
602 "remove bonding slave (slave_id) (port_id)\n"
603 " Remove a slave device from a bonded device.\n\n"
605 "set bonding mode (value) (port_id)\n"
606 " Set the bonding mode on a bonded device.\n\n"
608 "set bonding primary (slave_id) (port_id)\n"
609 " Set the primary slave for a bonded device.\n\n"
611 "show bonding config (port_id)\n"
612 " Show the bonding config for port_id.\n\n"
614 "set bonding mac_addr (port_id) (address)\n"
615 " Set the MAC address of a bonded device.\n\n"
617 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
618 " Set Aggregation mode for IEEE802.3AD (mode 4)"
620 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
621 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
623 "set bonding mon_period (port_id) (value)\n"
624 " Set the bonding link status monitoring polling period in ms.\n\n"
626 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
627 " Enable/disable dedicated queues for LACP control traffic.\n\n"
630 "set link-up port (port_id)\n"
631 " Set link up for a port.\n\n"
633 "set link-down port (port_id)\n"
634 " Set link down for a port.\n\n"
636 "E-tag set insertion on port-tag-id (value)"
637 " port (port_id) vf (vf_id)\n"
638 " Enable E-tag insertion for a VF on a port\n\n"
640 "E-tag set insertion off port (port_id) vf (vf_id)\n"
641 " Disable E-tag insertion for a VF on a port\n\n"
643 "E-tag set stripping (on|off) port (port_id)\n"
644 " Enable/disable E-tag stripping on a port\n\n"
646 "E-tag set forwarding (on|off) port (port_id)\n"
647 " Enable/disable E-tag based forwarding"
650 "E-tag set filter add e-tag-id (value) dst-pool"
651 " (pool_id) port (port_id)\n"
652 " Add an E-tag forwarding filter on a port\n\n"
654 "E-tag set filter del e-tag-id (value) port (port_id)\n"
655 " Delete an E-tag forwarding filter on a port\n\n"
657 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
658 " Load a profile package on a port\n\n"
660 "ddp del (port_id) (backup_profile_path)\n"
661 " Delete a profile package from a port\n\n"
663 "ptype mapping get (port_id) (valid_only)\n"
664 " Get ptype mapping on a port\n\n"
666 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
667 " Replace target with the pkt_type in ptype mapping\n\n"
669 "ptype mapping reset (port_id)\n"
670 " Reset ptype mapping on a port\n\n"
672 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
673 " Update a ptype mapping item on a port\n\n"
675 "set port (port_id) ptype_mask (ptype_mask)\n"
676 " set packet types classification for a specific port\n\n"
678 "set port (port_id) queue-region region_id (value) "
679 "queue_start_index (value) queue_num (value)\n"
680 " Set a queue region on a port\n\n"
682 "set port (port_id) queue-region region_id (value) "
684 " Set a flowtype region index on a port\n\n"
686 "set port (port_id) queue-region UP (value) region_id (value)\n"
687 " Set the mapping of User Priority to "
688 "queue region on a port\n\n"
690 "set port (port_id) queue-region flush (on|off)\n"
691 " flush all queue region related configuration\n\n"
693 "show port meter cap (port_id)\n"
694 " Show port meter capability information\n\n"
696 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
697 " meter profile add - srtcm rfc 2697\n\n"
699 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
700 " meter profile add - trtcm rfc 2698\n\n"
702 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
703 " meter profile add - trtcm rfc 4115\n\n"
705 "del port meter profile (port_id) (profile_id)\n"
706 " meter profile delete\n\n"
708 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
709 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
710 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
711 "(dscp_tbl_entry63)]\n"
714 "enable port meter (port_id) (mtr_id)\n"
717 "disable port meter (port_id) (mtr_id)\n"
720 "del port meter (port_id) (mtr_id)\n"
723 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
724 " meter update meter profile\n\n"
726 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
727 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
728 " update meter dscp table entries\n\n"
730 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
731 "(action0) [(action1) (action2)]\n"
732 " meter update policer action\n\n"
734 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
735 " meter update stats\n\n"
737 "show port (port_id) queue-region\n"
738 " show all queue region related configuration info\n\n"
740 , list_pkt_forwarding_modes()
744 if (show_all || !strcmp(res->section, "ports")) {
750 "----------------\n\n"
752 "port start (port_id|all)\n"
753 " Start all ports or port_id.\n\n"
755 "port stop (port_id|all)\n"
756 " Stop all ports or port_id.\n\n"
758 "port close (port_id|all)\n"
759 " Close all ports or port_id.\n\n"
761 "port reset (port_id|all)\n"
762 " Reset all ports or port_id.\n\n"
764 "port attach (ident)\n"
765 " Attach physical or virtual dev by pci address or virtual device name\n\n"
767 "port detach (port_id)\n"
768 " Detach physical or virtual dev by port_id\n\n"
770 "port config (port_id|all)"
771 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
772 " duplex (half|full|auto)\n"
773 " Set speed and duplex for all ports or port_id\n\n"
775 "port config (port_id|all) loopback (mode)\n"
776 " Set loopback mode for all ports or port_id\n\n"
778 "port config all (rxq|txq|rxd|txd) (value)\n"
779 " Set number for rxq/txq/rxd/txd.\n\n"
781 "port config all max-pkt-len (value)\n"
782 " Set the max packet length.\n\n"
784 "port config all max-lro-pkt-size (value)\n"
785 " Set the max LRO aggregated packet size.\n\n"
787 "port config all drop-en (on|off)\n"
788 " Enable or disable packet drop on all RX queues of all ports when no "
789 "receive buffers available.\n\n"
791 "port config all rss (all|default|ip|tcp|udp|sctp|"
792 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
793 " Set the RSS mode.\n\n"
795 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
796 " Set the RSS redirection table.\n\n"
798 "port config (port_id) dcb vt (on|off) (traffic_class)"
800 " Set the DCB mode.\n\n"
802 "port config all burst (value)\n"
803 " Set the number of packets per burst.\n\n"
805 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
807 " Set the ring prefetch/host/writeback threshold"
808 " for tx/rx queue.\n\n"
810 "port config all (txfreet|txrst|rxfreet) (value)\n"
811 " Set free threshold for rx/tx, or set"
812 " tx rs bit threshold.\n\n"
813 "port config mtu X value\n"
814 " Set the MTU of port X to a given value\n\n"
816 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
817 " Set a rx/tx queue's ring size configuration, the new"
818 " value will take effect after command that (re-)start the port"
819 " or command that setup the specific queue\n\n"
821 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
822 " Start/stop a rx/tx queue of port X. Only take effect"
823 " when port X is started\n\n"
825 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
826 " Switch on/off a deferred start of port X rx/tx queue. Only"
827 " take effect when port X is stopped.\n\n"
829 "port (port_id) (rxq|txq) (queue_id) setup\n"
830 " Setup a rx/tx queue of port X.\n\n"
832 "port config (port_id|all) l2-tunnel E-tag ether-type"
834 " Set the value of E-tag ether-type.\n\n"
836 "port config (port_id|all) l2-tunnel E-tag"
837 " (enable|disable)\n"
838 " Enable/disable the E-tag support.\n\n"
840 "port config (port_id) pctype mapping reset\n"
841 " Reset flow type to pctype mapping on a port\n\n"
843 "port config (port_id) pctype mapping update"
844 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
845 " Update a flow type to pctype mapping item on a port\n\n"
847 "port config (port_id) pctype (pctype_id) hash_inset|"
848 "fdir_inset|fdir_flx_inset get|set|clear field\n"
850 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
852 "port config (port_id) pctype (pctype_id) hash_inset|"
853 "fdir_inset|fdir_flx_inset clear all"
854 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
856 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
857 " Add/remove UDP tunnel port for tunneling offload\n\n"
859 "port config <port_id> rx_offload vlan_strip|"
860 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
861 "outer_ipv4_cksum|macsec_strip|header_split|"
862 "vlan_filter|vlan_extend|jumbo_frame|"
863 "scatter|timestamp|security|keep_crc on|off\n"
864 " Enable or disable a per port Rx offloading"
865 " on all Rx queues of a port\n\n"
867 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
868 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
869 "outer_ipv4_cksum|macsec_strip|header_split|"
870 "vlan_filter|vlan_extend|jumbo_frame|"
871 "scatter|timestamp|security|keep_crc on|off\n"
872 " Enable or disable a per queue Rx offloading"
873 " only on a specific Rx queue\n\n"
875 "port config (port_id) tx_offload vlan_insert|"
876 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
877 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
878 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
879 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
881 " Enable or disable a per port Tx offloading"
882 " on all Tx queues of a port\n\n"
884 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
885 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
886 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
887 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
888 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
890 " Enable or disable a per queue Tx offloading"
891 " only on a specific Tx queue\n\n"
893 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
894 " Load an eBPF program as a callback"
895 " for particular RX/TX queue\n\n"
897 "bpf-unload rx|tx (port) (queue)\n"
898 " Unload previously loaded eBPF program"
899 " for particular RX/TX queue\n\n"
901 "port config (port_id) tx_metadata (value)\n"
902 " Set Tx metadata value per port. Testpmd will add this value"
903 " to any Tx packet sent from this port\n\n"
907 if (show_all || !strcmp(res->section, "registers")) {
915 "read reg (port_id) (address)\n"
916 " Display value of a port register.\n\n"
918 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
919 " Display a port register bit field.\n\n"
921 "read regbit (port_id) (address) (bit_x)\n"
922 " Display a single port register bit.\n\n"
924 "write reg (port_id) (address) (value)\n"
925 " Set value of a port register.\n\n"
927 "write regfield (port_id) (address) (bit_x) (bit_y)"
929 " Set bit field of a port register.\n\n"
931 "write regbit (port_id) (address) (bit_x) (value)\n"
932 " Set single bit value of a port register.\n\n"
935 if (show_all || !strcmp(res->section, "filters")) {
943 "ethertype_filter (port_id) (add|del)"
944 " (mac_addr|mac_ignr) (mac_address) ethertype"
945 " (ether_type) (drop|fwd) queue (queue_id)\n"
946 " Add/Del an ethertype filter.\n\n"
948 "2tuple_filter (port_id) (add|del)"
949 " dst_port (dst_port_value) protocol (protocol_value)"
950 " mask (mask_value) tcp_flags (tcp_flags_value)"
951 " priority (prio_value) queue (queue_id)\n"
952 " Add/Del a 2tuple filter.\n\n"
954 "5tuple_filter (port_id) (add|del)"
955 " dst_ip (dst_address) src_ip (src_address)"
956 " dst_port (dst_port_value) src_port (src_port_value)"
957 " protocol (protocol_value)"
958 " mask (mask_value) tcp_flags (tcp_flags_value)"
959 " priority (prio_value) queue (queue_id)\n"
960 " Add/Del a 5tuple filter.\n\n"
962 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
963 " Add/Del syn filter.\n\n"
965 "flex_filter (port_id) (add|del) len (len_value)"
966 " bytes (bytes_value) mask (mask_value)"
967 " priority (prio_value) queue (queue_id)\n"
968 " Add/Del a flex filter.\n\n"
970 "flow_director_filter (port_id) mode IP (add|del|update)"
971 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
972 " src (src_ip_address) dst (dst_ip_address)"
973 " tos (tos_value) proto (proto_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 IP type flow director filter.\n\n"
979 "flow_director_filter (port_id) mode IP (add|del|update)"
980 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
981 " src (src_ip_address) (src_port)"
982 " dst (dst_ip_address) (dst_port)"
983 " tos (tos_value) ttl (ttl_value)"
984 " vlan (vlan_value) flexbytes (flexbytes_value)"
985 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
986 " fd_id (fd_id_value)\n"
987 " Add/Del an UDP/TCP type flow director filter.\n\n"
989 "flow_director_filter (port_id) mode IP (add|del|update)"
990 " flow (ipv4-sctp|ipv6-sctp)"
991 " src (src_ip_address) (src_port)"
992 " dst (dst_ip_address) (dst_port)"
993 " tag (verification_tag) "
994 " tos (tos_value) ttl (ttl_value)"
996 " flexbytes (flexbytes_value) (drop|fwd)"
997 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
998 " Add/Del a SCTP type flow director filter.\n\n"
1000 "flow_director_filter (port_id) mode IP (add|del|update)"
1001 " flow l2_payload ether (ethertype)"
1002 " flexbytes (flexbytes_value) (drop|fwd)"
1003 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1004 " Add/Del a l2 payload type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1007 " mac (mac_address) vlan (vlan_value)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a MAC-VLAN flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1013 " mac (mac_address) vlan (vlan_value)"
1014 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1015 " flexbytes (flexbytes_value) (drop|fwd)"
1016 " queue (queue_id) fd_id (fd_id_value)\n"
1017 " Add/Del a Tunnel flow director filter.\n\n"
1019 "flow_director_filter (port_id) mode raw (add|del|update)"
1020 " flow (flow_id) (drop|fwd) queue (queue_id)"
1021 " fd_id (fd_id_value) packet (packet file name)\n"
1022 " Add/Del a raw type flow director filter.\n\n"
1024 "flush_flow_director (port_id)\n"
1025 " Flush all flow director entries of a device.\n\n"
1027 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1028 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1029 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1030 " Set flow director IP mask.\n\n"
1032 "flow_director_mask (port_id) mode MAC-VLAN"
1033 " vlan (vlan_value)\n"
1034 " Set flow director MAC-VLAN mask.\n\n"
1036 "flow_director_mask (port_id) mode Tunnel"
1037 " vlan (vlan_value) mac (mac_value)"
1038 " tunnel-type (tunnel_type_value)"
1039 " tunnel-id (tunnel_id_value)\n"
1040 " Set flow director Tunnel mask.\n\n"
1042 "flow_director_flex_mask (port_id)"
1043 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1044 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1046 " Configure mask of flex payload.\n\n"
1048 "flow_director_flex_payload (port_id)"
1049 " (raw|l2|l3|l4) (config)\n"
1050 " Configure flex payload selection.\n\n"
1052 "get_sym_hash_ena_per_port (port_id)\n"
1053 " get symmetric hash enable configuration per port.\n\n"
1055 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1056 " set symmetric hash enable configuration per port"
1057 " to enable or disable.\n\n"
1059 "get_hash_global_config (port_id)\n"
1060 " Get the global configurations of hash filters.\n\n"
1062 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1063 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1064 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1065 " (enable|disable)\n"
1066 " Set the global configurations of hash filters.\n\n"
1068 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1069 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1070 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1071 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1072 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1073 "ipv6-next-header|udp-src-port|udp-dst-port|"
1074 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1075 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1076 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1077 "fld-8th|none) (select|add)\n"
1078 " Set the input set for hash.\n\n"
1080 "set_fdir_input_set (port_id) "
1081 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1082 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1083 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1084 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1085 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1086 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1087 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1089 " Set the input set for FDir.\n\n"
1091 "flow validate {port_id}"
1092 " [group {group_id}] [priority {level}]"
1093 " [ingress] [egress]"
1094 " pattern {item} [/ {item} [...]] / end"
1095 " actions {action} [/ {action} [...]] / end\n"
1096 " Check whether a flow rule can be created.\n\n"
1098 "flow create {port_id}"
1099 " [group {group_id}] [priority {level}]"
1100 " [ingress] [egress]"
1101 " pattern {item} [/ {item} [...]] / end"
1102 " actions {action} [/ {action} [...]] / end\n"
1103 " Create a flow rule.\n\n"
1105 "flow destroy {port_id} rule {rule_id} [...]\n"
1106 " Destroy specific flow rules.\n\n"
1108 "flow flush {port_id}\n"
1109 " Destroy all flow rules.\n\n"
1111 "flow query {port_id} {rule_id} {action}\n"
1112 " Query an existing flow rule.\n\n"
1114 "flow list {port_id} [group {group_id}] [...]\n"
1115 " List existing flow rules sorted by priority,"
1116 " filtered by group identifiers.\n\n"
1118 "flow isolate {port_id} {boolean}\n"
1119 " Restrict ingress traffic to the defined"
1122 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1123 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1124 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1125 " Configure the VXLAN encapsulation for flows.\n\n"
1127 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1128 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1129 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1130 " eth-dst (eth-dst)\n"
1131 " Configure the VXLAN encapsulation for flows.\n\n"
1133 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1134 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1135 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1136 " eth-dst (eth-dst)\n"
1137 " Configure the VXLAN encapsulation for flows.\n\n"
1139 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1140 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1142 " Configure the NVGRE encapsulation for flows.\n\n"
1144 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1145 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1146 " eth-src (eth-src) eth-dst (eth-dst)\n"
1147 " Configure the NVGRE encapsulation for flows.\n\n"
1149 "set raw_encap {flow items}\n"
1150 " Configure the encapsulation with raw data.\n\n"
1152 "set raw_decap {flow items}\n"
1153 " Configure the decapsulation with raw data.\n\n"
1158 if (show_all || !strcmp(res->section, "traffic_management")) {
1162 "Traffic Management:\n"
1164 "show port tm cap (port_id)\n"
1165 " Display the port TM capability.\n\n"
1167 "show port tm level cap (port_id) (level_id)\n"
1168 " Display the port TM hierarchical level capability.\n\n"
1170 "show port tm node cap (port_id) (node_id)\n"
1171 " Display the port TM node capability.\n\n"
1173 "show port tm node type (port_id) (node_id)\n"
1174 " Display the port TM node type.\n\n"
1176 "show port tm node stats (port_id) (node_id) (clear)\n"
1177 " Display the port TM node stats.\n\n"
1179 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1180 "set port tm hierarchy default (port_id)\n"
1181 " Set default traffic Management hierarchy on a port\n\n"
1184 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1185 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1186 " (packet_length_adjust)\n"
1187 " Add port tm node private shaper profile.\n\n"
1189 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1190 " Delete port tm node private shaper profile.\n\n"
1192 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1193 " (shaper_profile_id)\n"
1194 " Add/update port tm node shared shaper.\n\n"
1196 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1197 " Delete port tm node shared shaper.\n\n"
1199 "set port tm node shaper profile (port_id) (node_id)"
1200 " (shaper_profile_id)\n"
1201 " Set port tm node shaper profile.\n\n"
1203 "add port tm node wred profile (port_id) (wred_profile_id)"
1204 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1205 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1206 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1207 " Add port tm node wred profile.\n\n"
1209 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1210 " Delete port tm node wred profile.\n\n"
1212 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1213 " (priority) (weight) (level_id) (shaper_profile_id)"
1214 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1215 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1216 " Add port tm nonleaf node.\n\n"
1218 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1219 " (priority) (weight) (level_id) (shaper_profile_id)"
1220 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1221 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1222 " Add port tm leaf node.\n\n"
1224 "del port tm node (port_id) (node_id)\n"
1225 " Delete port tm node.\n\n"
1227 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1228 " (priority) (weight)\n"
1229 " Set port tm node parent.\n\n"
1231 "suspend port tm node (port_id) (node_id)"
1232 " Suspend tm node.\n\n"
1234 "resume port tm node (port_id) (node_id)"
1235 " Resume tm node.\n\n"
1237 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1238 " Commit tm hierarchy.\n\n"
1240 "set port tm mark ip_ecn (port) (green) (yellow)"
1242 " Enables/Disables the traffic management marking"
1243 " for IP ECN (Explicit Congestion Notification)"
1244 " packets on a given port\n\n"
1246 "set port tm mark ip_dscp (port) (green) (yellow)"
1248 " Enables/Disables the traffic management marking"
1249 " on the port for IP dscp packets\n\n"
1251 "set port tm mark vlan_dei (port) (green) (yellow)"
1253 " Enables/Disables the traffic management marking"
1254 " on the port for VLAN packets with DEI enabled\n\n"
1258 if (show_all || !strcmp(res->section, "devices")) {
1262 "Device Operations:\n"
1264 "device detach (identifier)\n"
1265 " Detach device by identifier.\n\n"
1271 cmdline_parse_token_string_t cmd_help_long_help =
1272 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1274 cmdline_parse_token_string_t cmd_help_long_section =
1275 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1276 "all#control#display#config#"
1277 "ports#registers#filters#traffic_management#devices");
1279 cmdline_parse_inst_t cmd_help_long = {
1280 .f = cmd_help_long_parsed,
1282 .help_str = "help all|control|display|config|ports|register|"
1283 "filters|traffic_management|devices: "
1286 (void *)&cmd_help_long_help,
1287 (void *)&cmd_help_long_section,
1293 /* *** start/stop/close all ports *** */
1294 struct cmd_operate_port_result {
1295 cmdline_fixed_string_t keyword;
1296 cmdline_fixed_string_t name;
1297 cmdline_fixed_string_t value;
1300 static void cmd_operate_port_parsed(void *parsed_result,
1301 __attribute__((unused)) struct cmdline *cl,
1302 __attribute__((unused)) void *data)
1304 struct cmd_operate_port_result *res = parsed_result;
1306 if (!strcmp(res->name, "start"))
1307 start_port(RTE_PORT_ALL);
1308 else if (!strcmp(res->name, "stop"))
1309 stop_port(RTE_PORT_ALL);
1310 else if (!strcmp(res->name, "close"))
1311 close_port(RTE_PORT_ALL);
1312 else if (!strcmp(res->name, "reset"))
1313 reset_port(RTE_PORT_ALL);
1315 printf("Unknown parameter\n");
1318 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1319 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1321 cmdline_parse_token_string_t cmd_operate_port_all_port =
1322 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1323 "start#stop#close#reset");
1324 cmdline_parse_token_string_t cmd_operate_port_all_all =
1325 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1327 cmdline_parse_inst_t cmd_operate_port = {
1328 .f = cmd_operate_port_parsed,
1330 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1332 (void *)&cmd_operate_port_all_cmd,
1333 (void *)&cmd_operate_port_all_port,
1334 (void *)&cmd_operate_port_all_all,
1339 /* *** start/stop/close specific port *** */
1340 struct cmd_operate_specific_port_result {
1341 cmdline_fixed_string_t keyword;
1342 cmdline_fixed_string_t name;
1346 static void cmd_operate_specific_port_parsed(void *parsed_result,
1347 __attribute__((unused)) struct cmdline *cl,
1348 __attribute__((unused)) void *data)
1350 struct cmd_operate_specific_port_result *res = parsed_result;
1352 if (!strcmp(res->name, "start"))
1353 start_port(res->value);
1354 else if (!strcmp(res->name, "stop"))
1355 stop_port(res->value);
1356 else if (!strcmp(res->name, "close"))
1357 close_port(res->value);
1358 else if (!strcmp(res->name, "reset"))
1359 reset_port(res->value);
1361 printf("Unknown parameter\n");
1364 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1365 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1367 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1368 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1369 name, "start#stop#close#reset");
1370 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1371 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1374 cmdline_parse_inst_t cmd_operate_specific_port = {
1375 .f = cmd_operate_specific_port_parsed,
1377 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1379 (void *)&cmd_operate_specific_port_cmd,
1380 (void *)&cmd_operate_specific_port_port,
1381 (void *)&cmd_operate_specific_port_id,
1386 /* *** enable port setup (after attach) via iterator or event *** */
1387 struct cmd_set_port_setup_on_result {
1388 cmdline_fixed_string_t set;
1389 cmdline_fixed_string_t port;
1390 cmdline_fixed_string_t setup;
1391 cmdline_fixed_string_t on;
1392 cmdline_fixed_string_t mode;
1395 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1396 __attribute__((unused)) struct cmdline *cl,
1397 __attribute__((unused)) void *data)
1399 struct cmd_set_port_setup_on_result *res = parsed_result;
1401 if (strcmp(res->mode, "event") == 0)
1402 setup_on_probe_event = true;
1403 else if (strcmp(res->mode, "iterator") == 0)
1404 setup_on_probe_event = false;
1406 printf("Unknown mode\n");
1409 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1410 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1412 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1413 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1419 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1422 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1423 mode, "iterator#event");
1425 cmdline_parse_inst_t cmd_set_port_setup_on = {
1426 .f = cmd_set_port_setup_on_parsed,
1428 .help_str = "set port setup on iterator|event",
1430 (void *)&cmd_set_port_setup_on_set,
1431 (void *)&cmd_set_port_setup_on_port,
1432 (void *)&cmd_set_port_setup_on_setup,
1433 (void *)&cmd_set_port_setup_on_on,
1434 (void *)&cmd_set_port_setup_on_mode,
1439 /* *** attach a specified port *** */
1440 struct cmd_operate_attach_port_result {
1441 cmdline_fixed_string_t port;
1442 cmdline_fixed_string_t keyword;
1443 cmdline_fixed_string_t identifier;
1446 static void cmd_operate_attach_port_parsed(void *parsed_result,
1447 __attribute__((unused)) struct cmdline *cl,
1448 __attribute__((unused)) void *data)
1450 struct cmd_operate_attach_port_result *res = parsed_result;
1452 if (!strcmp(res->keyword, "attach"))
1453 attach_port(res->identifier);
1455 printf("Unknown parameter\n");
1458 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1459 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1461 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1462 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1464 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1465 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1468 cmdline_parse_inst_t cmd_operate_attach_port = {
1469 .f = cmd_operate_attach_port_parsed,
1471 .help_str = "port attach <identifier>: "
1472 "(identifier: pci address or virtual dev name)",
1474 (void *)&cmd_operate_attach_port_port,
1475 (void *)&cmd_operate_attach_port_keyword,
1476 (void *)&cmd_operate_attach_port_identifier,
1481 /* *** detach a specified port *** */
1482 struct cmd_operate_detach_port_result {
1483 cmdline_fixed_string_t port;
1484 cmdline_fixed_string_t keyword;
1488 static void cmd_operate_detach_port_parsed(void *parsed_result,
1489 __attribute__((unused)) struct cmdline *cl,
1490 __attribute__((unused)) void *data)
1492 struct cmd_operate_detach_port_result *res = parsed_result;
1494 if (!strcmp(res->keyword, "detach"))
1495 detach_port_device(res->port_id);
1497 printf("Unknown parameter\n");
1500 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1501 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1503 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1504 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1506 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1507 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1510 cmdline_parse_inst_t cmd_operate_detach_port = {
1511 .f = cmd_operate_detach_port_parsed,
1513 .help_str = "port detach <port_id>",
1515 (void *)&cmd_operate_detach_port_port,
1516 (void *)&cmd_operate_detach_port_keyword,
1517 (void *)&cmd_operate_detach_port_port_id,
1522 /* *** detach device by identifier *** */
1523 struct cmd_operate_detach_device_result {
1524 cmdline_fixed_string_t device;
1525 cmdline_fixed_string_t keyword;
1526 cmdline_fixed_string_t identifier;
1529 static void cmd_operate_detach_device_parsed(void *parsed_result,
1530 __attribute__((unused)) struct cmdline *cl,
1531 __attribute__((unused)) void *data)
1533 struct cmd_operate_detach_device_result *res = parsed_result;
1535 if (!strcmp(res->keyword, "detach"))
1536 detach_device(res->identifier);
1538 printf("Unknown parameter\n");
1541 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1542 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1544 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1545 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1547 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1548 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1551 cmdline_parse_inst_t cmd_operate_detach_device = {
1552 .f = cmd_operate_detach_device_parsed,
1554 .help_str = "device detach <identifier>:"
1555 "(identifier: pci address or virtual dev name)",
1557 (void *)&cmd_operate_detach_device_device,
1558 (void *)&cmd_operate_detach_device_keyword,
1559 (void *)&cmd_operate_detach_device_identifier,
1563 /* *** configure speed for all ports *** */
1564 struct cmd_config_speed_all {
1565 cmdline_fixed_string_t port;
1566 cmdline_fixed_string_t keyword;
1567 cmdline_fixed_string_t all;
1568 cmdline_fixed_string_t item1;
1569 cmdline_fixed_string_t item2;
1570 cmdline_fixed_string_t value1;
1571 cmdline_fixed_string_t value2;
1575 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1580 if (!strcmp(duplexstr, "half")) {
1581 duplex = ETH_LINK_HALF_DUPLEX;
1582 } else if (!strcmp(duplexstr, "full")) {
1583 duplex = ETH_LINK_FULL_DUPLEX;
1584 } else if (!strcmp(duplexstr, "auto")) {
1585 duplex = ETH_LINK_FULL_DUPLEX;
1587 printf("Unknown duplex parameter\n");
1591 if (!strcmp(speedstr, "10")) {
1592 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1593 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1594 } else if (!strcmp(speedstr, "100")) {
1595 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1596 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1598 if (duplex != ETH_LINK_FULL_DUPLEX) {
1599 printf("Invalid speed/duplex parameters\n");
1602 if (!strcmp(speedstr, "1000")) {
1603 *speed = ETH_LINK_SPEED_1G;
1604 } else if (!strcmp(speedstr, "10000")) {
1605 *speed = ETH_LINK_SPEED_10G;
1606 } else if (!strcmp(speedstr, "25000")) {
1607 *speed = ETH_LINK_SPEED_25G;
1608 } else if (!strcmp(speedstr, "40000")) {
1609 *speed = ETH_LINK_SPEED_40G;
1610 } else if (!strcmp(speedstr, "50000")) {
1611 *speed = ETH_LINK_SPEED_50G;
1612 } else if (!strcmp(speedstr, "100000")) {
1613 *speed = ETH_LINK_SPEED_100G;
1614 } else if (!strcmp(speedstr, "auto")) {
1615 *speed = ETH_LINK_SPEED_AUTONEG;
1617 printf("Unknown speed parameter\n");
1626 cmd_config_speed_all_parsed(void *parsed_result,
1627 __attribute__((unused)) struct cmdline *cl,
1628 __attribute__((unused)) void *data)
1630 struct cmd_config_speed_all *res = parsed_result;
1631 uint32_t link_speed;
1634 if (!all_ports_stopped()) {
1635 printf("Please stop all ports first\n");
1639 if (parse_and_check_speed_duplex(res->value1, res->value2,
1643 RTE_ETH_FOREACH_DEV(pid) {
1644 ports[pid].dev_conf.link_speeds = link_speed;
1647 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1650 cmdline_parse_token_string_t cmd_config_speed_all_port =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1652 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1655 cmdline_parse_token_string_t cmd_config_speed_all_all =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1657 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1659 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1661 "10#100#1000#10000#25000#40000#50000#100000#auto");
1662 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1663 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1664 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1668 cmdline_parse_inst_t cmd_config_speed_all = {
1669 .f = cmd_config_speed_all_parsed,
1671 .help_str = "port config all speed "
1672 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1675 (void *)&cmd_config_speed_all_port,
1676 (void *)&cmd_config_speed_all_keyword,
1677 (void *)&cmd_config_speed_all_all,
1678 (void *)&cmd_config_speed_all_item1,
1679 (void *)&cmd_config_speed_all_value1,
1680 (void *)&cmd_config_speed_all_item2,
1681 (void *)&cmd_config_speed_all_value2,
1686 /* *** configure speed for specific port *** */
1687 struct cmd_config_speed_specific {
1688 cmdline_fixed_string_t port;
1689 cmdline_fixed_string_t keyword;
1691 cmdline_fixed_string_t item1;
1692 cmdline_fixed_string_t item2;
1693 cmdline_fixed_string_t value1;
1694 cmdline_fixed_string_t value2;
1698 cmd_config_speed_specific_parsed(void *parsed_result,
1699 __attribute__((unused)) struct cmdline *cl,
1700 __attribute__((unused)) void *data)
1702 struct cmd_config_speed_specific *res = parsed_result;
1703 uint32_t link_speed;
1705 if (!all_ports_stopped()) {
1706 printf("Please stop all ports first\n");
1710 if (port_id_is_invalid(res->id, ENABLED_WARN))
1713 if (parse_and_check_speed_duplex(res->value1, res->value2,
1717 ports[res->id].dev_conf.link_speeds = link_speed;
1719 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1723 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1724 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1726 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1727 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1729 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1730 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1731 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1734 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1736 "10#100#1000#10000#25000#40000#50000#100000#auto");
1737 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1740 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1744 cmdline_parse_inst_t cmd_config_speed_specific = {
1745 .f = cmd_config_speed_specific_parsed,
1747 .help_str = "port config <port_id> speed "
1748 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1751 (void *)&cmd_config_speed_specific_port,
1752 (void *)&cmd_config_speed_specific_keyword,
1753 (void *)&cmd_config_speed_specific_id,
1754 (void *)&cmd_config_speed_specific_item1,
1755 (void *)&cmd_config_speed_specific_value1,
1756 (void *)&cmd_config_speed_specific_item2,
1757 (void *)&cmd_config_speed_specific_value2,
1762 /* *** configure loopback for all ports *** */
1763 struct cmd_config_loopback_all {
1764 cmdline_fixed_string_t port;
1765 cmdline_fixed_string_t keyword;
1766 cmdline_fixed_string_t all;
1767 cmdline_fixed_string_t item;
1772 cmd_config_loopback_all_parsed(void *parsed_result,
1773 __attribute__((unused)) struct cmdline *cl,
1774 __attribute__((unused)) void *data)
1776 struct cmd_config_loopback_all *res = parsed_result;
1779 if (!all_ports_stopped()) {
1780 printf("Please stop all ports first\n");
1784 RTE_ETH_FOREACH_DEV(pid) {
1785 ports[pid].dev_conf.lpbk_mode = res->mode;
1788 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1791 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1793 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1796 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1798 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1799 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1801 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1802 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1804 cmdline_parse_inst_t cmd_config_loopback_all = {
1805 .f = cmd_config_loopback_all_parsed,
1807 .help_str = "port config all loopback <mode>",
1809 (void *)&cmd_config_loopback_all_port,
1810 (void *)&cmd_config_loopback_all_keyword,
1811 (void *)&cmd_config_loopback_all_all,
1812 (void *)&cmd_config_loopback_all_item,
1813 (void *)&cmd_config_loopback_all_mode,
1818 /* *** configure loopback for specific port *** */
1819 struct cmd_config_loopback_specific {
1820 cmdline_fixed_string_t port;
1821 cmdline_fixed_string_t keyword;
1823 cmdline_fixed_string_t item;
1828 cmd_config_loopback_specific_parsed(void *parsed_result,
1829 __attribute__((unused)) struct cmdline *cl,
1830 __attribute__((unused)) void *data)
1832 struct cmd_config_loopback_specific *res = parsed_result;
1834 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1837 if (!port_is_stopped(res->port_id)) {
1838 printf("Please stop port %u first\n", res->port_id);
1842 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1844 cmd_reconfig_device_queue(res->port_id, 1, 1);
1848 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1851 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1854 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1855 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1857 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1860 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1861 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1864 cmdline_parse_inst_t cmd_config_loopback_specific = {
1865 .f = cmd_config_loopback_specific_parsed,
1867 .help_str = "port config <port_id> loopback <mode>",
1869 (void *)&cmd_config_loopback_specific_port,
1870 (void *)&cmd_config_loopback_specific_keyword,
1871 (void *)&cmd_config_loopback_specific_id,
1872 (void *)&cmd_config_loopback_specific_item,
1873 (void *)&cmd_config_loopback_specific_mode,
1878 /* *** configure txq/rxq, txd/rxd *** */
1879 struct cmd_config_rx_tx {
1880 cmdline_fixed_string_t port;
1881 cmdline_fixed_string_t keyword;
1882 cmdline_fixed_string_t all;
1883 cmdline_fixed_string_t name;
1888 cmd_config_rx_tx_parsed(void *parsed_result,
1889 __attribute__((unused)) struct cmdline *cl,
1890 __attribute__((unused)) void *data)
1892 struct cmd_config_rx_tx *res = parsed_result;
1894 if (!all_ports_stopped()) {
1895 printf("Please stop all ports first\n");
1898 if (!strcmp(res->name, "rxq")) {
1899 if (!res->value && !nb_txq) {
1900 printf("Warning: Either rx or tx queues should be non zero\n");
1903 if (check_nb_rxq(res->value) != 0)
1905 nb_rxq = res->value;
1907 else if (!strcmp(res->name, "txq")) {
1908 if (!res->value && !nb_rxq) {
1909 printf("Warning: Either rx or tx queues should be non zero\n");
1912 if (check_nb_txq(res->value) != 0)
1914 nb_txq = res->value;
1916 else if (!strcmp(res->name, "rxd")) {
1917 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1918 printf("rxd %d invalid - must be > 0 && <= %d\n",
1919 res->value, RTE_TEST_RX_DESC_MAX);
1922 nb_rxd = res->value;
1923 } else if (!strcmp(res->name, "txd")) {
1924 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1925 printf("txd %d invalid - must be > 0 && <= %d\n",
1926 res->value, RTE_TEST_TX_DESC_MAX);
1929 nb_txd = res->value;
1931 printf("Unknown parameter\n");
1939 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1942 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1943 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1944 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1946 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1947 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1948 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1951 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1952 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1954 cmdline_parse_inst_t cmd_config_rx_tx = {
1955 .f = cmd_config_rx_tx_parsed,
1957 .help_str = "port config all rxq|txq|rxd|txd <value>",
1959 (void *)&cmd_config_rx_tx_port,
1960 (void *)&cmd_config_rx_tx_keyword,
1961 (void *)&cmd_config_rx_tx_all,
1962 (void *)&cmd_config_rx_tx_name,
1963 (void *)&cmd_config_rx_tx_value,
1968 /* *** config max packet length *** */
1969 struct cmd_config_max_pkt_len_result {
1970 cmdline_fixed_string_t port;
1971 cmdline_fixed_string_t keyword;
1972 cmdline_fixed_string_t all;
1973 cmdline_fixed_string_t name;
1978 cmd_config_max_pkt_len_parsed(void *parsed_result,
1979 __attribute__((unused)) struct cmdline *cl,
1980 __attribute__((unused)) void *data)
1982 struct cmd_config_max_pkt_len_result *res = parsed_result;
1985 if (!all_ports_stopped()) {
1986 printf("Please stop all ports first\n");
1990 RTE_ETH_FOREACH_DEV(pid) {
1991 struct rte_port *port = &ports[pid];
1992 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1994 if (!strcmp(res->name, "max-pkt-len")) {
1995 if (res->value < RTE_ETHER_MIN_LEN) {
1996 printf("max-pkt-len can not be less than %d\n",
2000 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2003 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2004 if (res->value > RTE_ETHER_MAX_LEN)
2005 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2007 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2008 port->dev_conf.rxmode.offloads = rx_offloads;
2010 printf("Unknown parameter\n");
2017 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2020 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2021 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2023 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2024 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2026 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2029 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2032 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2033 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2036 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2037 .f = cmd_config_max_pkt_len_parsed,
2039 .help_str = "port config all max-pkt-len <value>",
2041 (void *)&cmd_config_max_pkt_len_port,
2042 (void *)&cmd_config_max_pkt_len_keyword,
2043 (void *)&cmd_config_max_pkt_len_all,
2044 (void *)&cmd_config_max_pkt_len_name,
2045 (void *)&cmd_config_max_pkt_len_value,
2050 /* *** config max LRO aggregated packet size *** */
2051 struct cmd_config_max_lro_pkt_size_result {
2052 cmdline_fixed_string_t port;
2053 cmdline_fixed_string_t keyword;
2054 cmdline_fixed_string_t all;
2055 cmdline_fixed_string_t name;
2060 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2061 __attribute__((unused)) struct cmdline *cl,
2062 __attribute__((unused)) void *data)
2064 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2067 if (!all_ports_stopped()) {
2068 printf("Please stop all ports first\n");
2072 RTE_ETH_FOREACH_DEV(pid) {
2073 struct rte_port *port = &ports[pid];
2075 if (!strcmp(res->name, "max-lro-pkt-size")) {
2077 port->dev_conf.rxmode.max_lro_pkt_size)
2080 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2082 printf("Unknown parameter\n");
2089 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2092 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2093 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2095 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2096 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2098 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2099 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2101 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2102 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2103 name, "max-lro-pkt-size");
2104 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2105 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2108 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2109 .f = cmd_config_max_lro_pkt_size_parsed,
2111 .help_str = "port config all max-lro-pkt-size <value>",
2113 (void *)&cmd_config_max_lro_pkt_size_port,
2114 (void *)&cmd_config_max_lro_pkt_size_keyword,
2115 (void *)&cmd_config_max_lro_pkt_size_all,
2116 (void *)&cmd_config_max_lro_pkt_size_name,
2117 (void *)&cmd_config_max_lro_pkt_size_value,
2122 /* *** configure port MTU *** */
2123 struct cmd_config_mtu_result {
2124 cmdline_fixed_string_t port;
2125 cmdline_fixed_string_t keyword;
2126 cmdline_fixed_string_t mtu;
2132 cmd_config_mtu_parsed(void *parsed_result,
2133 __attribute__((unused)) struct cmdline *cl,
2134 __attribute__((unused)) void *data)
2136 struct cmd_config_mtu_result *res = parsed_result;
2138 if (res->value < RTE_ETHER_MIN_LEN) {
2139 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2142 port_mtu_set(res->port_id, res->value);
2145 cmdline_parse_token_string_t cmd_config_mtu_port =
2146 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2148 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2151 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2152 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2154 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2155 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2156 cmdline_parse_token_num_t cmd_config_mtu_value =
2157 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2159 cmdline_parse_inst_t cmd_config_mtu = {
2160 .f = cmd_config_mtu_parsed,
2162 .help_str = "port config mtu <port_id> <value>",
2164 (void *)&cmd_config_mtu_port,
2165 (void *)&cmd_config_mtu_keyword,
2166 (void *)&cmd_config_mtu_mtu,
2167 (void *)&cmd_config_mtu_port_id,
2168 (void *)&cmd_config_mtu_value,
2173 /* *** configure rx mode *** */
2174 struct cmd_config_rx_mode_flag {
2175 cmdline_fixed_string_t port;
2176 cmdline_fixed_string_t keyword;
2177 cmdline_fixed_string_t all;
2178 cmdline_fixed_string_t name;
2179 cmdline_fixed_string_t value;
2183 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2184 __attribute__((unused)) struct cmdline *cl,
2185 __attribute__((unused)) void *data)
2187 struct cmd_config_rx_mode_flag *res = parsed_result;
2189 if (!all_ports_stopped()) {
2190 printf("Please stop all ports first\n");
2194 if (!strcmp(res->name, "drop-en")) {
2195 if (!strcmp(res->value, "on"))
2197 else if (!strcmp(res->value, "off"))
2200 printf("Unknown parameter\n");
2204 printf("Unknown parameter\n");
2210 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2213 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2214 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2215 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2216 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2218 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2219 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2220 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2221 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2223 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2224 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2227 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2228 .f = cmd_config_rx_mode_flag_parsed,
2230 .help_str = "port config all drop-en on|off",
2232 (void *)&cmd_config_rx_mode_flag_port,
2233 (void *)&cmd_config_rx_mode_flag_keyword,
2234 (void *)&cmd_config_rx_mode_flag_all,
2235 (void *)&cmd_config_rx_mode_flag_name,
2236 (void *)&cmd_config_rx_mode_flag_value,
2241 /* *** configure rss *** */
2242 struct cmd_config_rss {
2243 cmdline_fixed_string_t port;
2244 cmdline_fixed_string_t keyword;
2245 cmdline_fixed_string_t all;
2246 cmdline_fixed_string_t name;
2247 cmdline_fixed_string_t value;
2251 cmd_config_rss_parsed(void *parsed_result,
2252 __attribute__((unused)) struct cmdline *cl,
2253 __attribute__((unused)) void *data)
2255 struct cmd_config_rss *res = parsed_result;
2256 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2257 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2258 int use_default = 0;
2259 int all_updated = 1;
2264 if (!strcmp(res->value, "all"))
2265 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2266 ETH_RSS_UDP | ETH_RSS_SCTP |
2268 else if (!strcmp(res->value, "ip"))
2269 rss_conf.rss_hf = ETH_RSS_IP;
2270 else if (!strcmp(res->value, "udp"))
2271 rss_conf.rss_hf = ETH_RSS_UDP;
2272 else if (!strcmp(res->value, "tcp"))
2273 rss_conf.rss_hf = ETH_RSS_TCP;
2274 else if (!strcmp(res->value, "sctp"))
2275 rss_conf.rss_hf = ETH_RSS_SCTP;
2276 else if (!strcmp(res->value, "ether"))
2277 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2278 else if (!strcmp(res->value, "port"))
2279 rss_conf.rss_hf = ETH_RSS_PORT;
2280 else if (!strcmp(res->value, "vxlan"))
2281 rss_conf.rss_hf = ETH_RSS_VXLAN;
2282 else if (!strcmp(res->value, "geneve"))
2283 rss_conf.rss_hf = ETH_RSS_GENEVE;
2284 else if (!strcmp(res->value, "nvgre"))
2285 rss_conf.rss_hf = ETH_RSS_NVGRE;
2286 else if (!strcmp(res->value, "l3-src-only"))
2287 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2288 else if (!strcmp(res->value, "l3-dst-only"))
2289 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2290 else if (!strcmp(res->value, "l4-src-only"))
2291 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2292 else if (!strcmp(res->value, "l4-dst-only"))
2293 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2294 else if (!strcmp(res->value, "none"))
2295 rss_conf.rss_hf = 0;
2296 else if (!strcmp(res->value, "default"))
2298 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2299 atoi(res->value) < 64)
2300 rss_conf.rss_hf = 1ULL << atoi(res->value);
2302 printf("Unknown parameter\n");
2305 rss_conf.rss_key = NULL;
2306 /* Update global configuration for RSS types. */
2307 RTE_ETH_FOREACH_DEV(i) {
2308 struct rte_eth_rss_conf local_rss_conf;
2310 ret = eth_dev_info_get_print_err(i, &dev_info);
2315 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2317 local_rss_conf = rss_conf;
2318 local_rss_conf.rss_hf = rss_conf.rss_hf &
2319 dev_info.flow_type_rss_offloads;
2320 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2321 printf("Port %u modified RSS hash function based on hardware support,"
2322 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2323 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2325 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2328 printf("Configuration of RSS hash at ethernet port %d "
2329 "failed with error (%d): %s.\n",
2330 i, -diag, strerror(-diag));
2333 if (all_updated && !use_default)
2334 rss_hf = rss_conf.rss_hf;
2337 cmdline_parse_token_string_t cmd_config_rss_port =
2338 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2339 cmdline_parse_token_string_t cmd_config_rss_keyword =
2340 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2341 cmdline_parse_token_string_t cmd_config_rss_all =
2342 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2343 cmdline_parse_token_string_t cmd_config_rss_name =
2344 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2345 cmdline_parse_token_string_t cmd_config_rss_value =
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2348 cmdline_parse_inst_t cmd_config_rss = {
2349 .f = cmd_config_rss_parsed,
2351 .help_str = "port config all rss "
2352 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2354 (void *)&cmd_config_rss_port,
2355 (void *)&cmd_config_rss_keyword,
2356 (void *)&cmd_config_rss_all,
2357 (void *)&cmd_config_rss_name,
2358 (void *)&cmd_config_rss_value,
2363 /* *** configure rss hash key *** */
2364 struct cmd_config_rss_hash_key {
2365 cmdline_fixed_string_t port;
2366 cmdline_fixed_string_t config;
2368 cmdline_fixed_string_t rss_hash_key;
2369 cmdline_fixed_string_t rss_type;
2370 cmdline_fixed_string_t key;
2374 hexa_digit_to_value(char hexa_digit)
2376 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2377 return (uint8_t) (hexa_digit - '0');
2378 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2379 return (uint8_t) ((hexa_digit - 'a') + 10);
2380 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2381 return (uint8_t) ((hexa_digit - 'A') + 10);
2382 /* Invalid hexa digit */
2387 parse_and_check_key_hexa_digit(char *key, int idx)
2391 hexa_v = hexa_digit_to_value(key[idx]);
2393 printf("invalid key: character %c at position %d is not a "
2394 "valid hexa digit\n", key[idx], idx);
2399 cmd_config_rss_hash_key_parsed(void *parsed_result,
2400 __attribute__((unused)) struct cmdline *cl,
2401 __attribute__((unused)) void *data)
2403 struct cmd_config_rss_hash_key *res = parsed_result;
2404 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2408 struct rte_eth_dev_info dev_info;
2409 uint8_t hash_key_size;
2413 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2417 if (dev_info.hash_key_size > 0 &&
2418 dev_info.hash_key_size <= sizeof(hash_key))
2419 hash_key_size = dev_info.hash_key_size;
2421 printf("dev_info did not provide a valid hash key size\n");
2424 /* Check the length of the RSS hash key */
2425 key_len = strlen(res->key);
2426 if (key_len != (hash_key_size * 2)) {
2427 printf("key length: %d invalid - key must be a string of %d"
2428 " hexa-decimal numbers\n",
2429 (int) key_len, hash_key_size * 2);
2432 /* Translate RSS hash key into binary representation */
2433 for (i = 0; i < hash_key_size; i++) {
2434 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2437 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2440 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2442 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2446 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2447 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2448 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2449 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2451 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2452 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2453 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2454 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2455 rss_hash_key, "rss-hash-key");
2456 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2457 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2458 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2459 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2460 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2461 "ipv6-tcp-ex#ipv6-udp-ex#"
2462 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2463 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2464 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2466 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2467 .f = cmd_config_rss_hash_key_parsed,
2469 .help_str = "port config <port_id> rss-hash-key "
2470 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2471 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2472 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2473 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2474 "<string of hex digits (variable length, NIC dependent)>",
2476 (void *)&cmd_config_rss_hash_key_port,
2477 (void *)&cmd_config_rss_hash_key_config,
2478 (void *)&cmd_config_rss_hash_key_port_id,
2479 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2480 (void *)&cmd_config_rss_hash_key_rss_type,
2481 (void *)&cmd_config_rss_hash_key_value,
2486 /* *** configure port rxq/txq ring size *** */
2487 struct cmd_config_rxtx_ring_size {
2488 cmdline_fixed_string_t port;
2489 cmdline_fixed_string_t config;
2491 cmdline_fixed_string_t rxtxq;
2493 cmdline_fixed_string_t rsize;
2498 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2499 __attribute__((unused)) struct cmdline *cl,
2500 __attribute__((unused)) void *data)
2502 struct cmd_config_rxtx_ring_size *res = parsed_result;
2503 struct rte_port *port;
2506 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2509 if (res->portid == (portid_t)RTE_PORT_ALL) {
2510 printf("Invalid port id\n");
2514 port = &ports[res->portid];
2516 if (!strcmp(res->rxtxq, "rxq"))
2518 else if (!strcmp(res->rxtxq, "txq"))
2521 printf("Unknown parameter\n");
2525 if (isrx && rx_queue_id_is_invalid(res->qid))
2527 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2530 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2531 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2537 port->nb_rx_desc[res->qid] = res->size;
2539 port->nb_tx_desc[res->qid] = res->size;
2541 cmd_reconfig_device_queue(res->portid, 0, 1);
2544 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2545 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2547 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2548 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2550 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2551 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2553 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2554 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2556 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2557 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2559 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2561 rsize, "ring_size");
2562 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2563 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2566 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2567 .f = cmd_config_rxtx_ring_size_parsed,
2569 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2571 (void *)&cmd_config_rxtx_ring_size_port,
2572 (void *)&cmd_config_rxtx_ring_size_config,
2573 (void *)&cmd_config_rxtx_ring_size_portid,
2574 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2575 (void *)&cmd_config_rxtx_ring_size_qid,
2576 (void *)&cmd_config_rxtx_ring_size_rsize,
2577 (void *)&cmd_config_rxtx_ring_size_size,
2582 /* *** configure port rxq/txq start/stop *** */
2583 struct cmd_config_rxtx_queue {
2584 cmdline_fixed_string_t port;
2586 cmdline_fixed_string_t rxtxq;
2588 cmdline_fixed_string_t opname;
2592 cmd_config_rxtx_queue_parsed(void *parsed_result,
2593 __attribute__((unused)) struct cmdline *cl,
2594 __attribute__((unused)) void *data)
2596 struct cmd_config_rxtx_queue *res = parsed_result;
2601 if (test_done == 0) {
2602 printf("Please stop forwarding first\n");
2606 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2609 if (port_is_started(res->portid) != 1) {
2610 printf("Please start port %u first\n", res->portid);
2614 if (!strcmp(res->rxtxq, "rxq"))
2616 else if (!strcmp(res->rxtxq, "txq"))
2619 printf("Unknown parameter\n");
2623 if (isrx && rx_queue_id_is_invalid(res->qid))
2625 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2628 if (!strcmp(res->opname, "start"))
2630 else if (!strcmp(res->opname, "stop"))
2633 printf("Unknown parameter\n");
2637 if (isstart && isrx)
2638 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2639 else if (!isstart && isrx)
2640 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2641 else if (isstart && !isrx)
2642 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2644 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2646 if (ret == -ENOTSUP)
2647 printf("Function not supported in PMD driver\n");
2650 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2651 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2652 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2653 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2654 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2655 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2656 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2657 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2658 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2659 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2662 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2663 .f = cmd_config_rxtx_queue_parsed,
2665 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2667 (void *)&cmd_config_rxtx_queue_port,
2668 (void *)&cmd_config_rxtx_queue_portid,
2669 (void *)&cmd_config_rxtx_queue_rxtxq,
2670 (void *)&cmd_config_rxtx_queue_qid,
2671 (void *)&cmd_config_rxtx_queue_opname,
2676 /* *** configure port rxq/txq deferred start on/off *** */
2677 struct cmd_config_deferred_start_rxtx_queue {
2678 cmdline_fixed_string_t port;
2680 cmdline_fixed_string_t rxtxq;
2682 cmdline_fixed_string_t opname;
2683 cmdline_fixed_string_t state;
2687 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2688 __attribute__((unused)) struct cmdline *cl,
2689 __attribute__((unused)) void *data)
2691 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2692 struct rte_port *port;
2695 uint8_t needreconfig = 0;
2697 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2700 if (port_is_started(res->port_id) != 0) {
2701 printf("Please stop port %u first\n", res->port_id);
2705 port = &ports[res->port_id];
2707 isrx = !strcmp(res->rxtxq, "rxq");
2709 if (isrx && rx_queue_id_is_invalid(res->qid))
2711 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2714 ison = !strcmp(res->state, "on");
2716 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2717 port->rx_conf[res->qid].rx_deferred_start = ison;
2719 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2720 port->tx_conf[res->qid].tx_deferred_start = ison;
2725 cmd_reconfig_device_queue(res->port_id, 0, 1);
2728 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2729 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2731 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2732 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2734 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2735 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2737 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2738 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2740 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2741 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2742 opname, "deferred_start");
2743 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2744 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2747 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2748 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2750 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2752 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2753 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2754 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2755 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2756 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2757 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2762 /* *** configure port rxq/txq setup *** */
2763 struct cmd_setup_rxtx_queue {
2764 cmdline_fixed_string_t port;
2766 cmdline_fixed_string_t rxtxq;
2768 cmdline_fixed_string_t setup;
2771 /* Common CLI fields for queue setup */
2772 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2773 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2774 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2775 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2776 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2777 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2778 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2779 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2780 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2781 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2784 cmd_setup_rxtx_queue_parsed(
2785 void *parsed_result,
2786 __attribute__((unused)) struct cmdline *cl,
2787 __attribute__((unused)) void *data)
2789 struct cmd_setup_rxtx_queue *res = parsed_result;
2790 struct rte_port *port;
2791 struct rte_mempool *mp;
2792 unsigned int socket_id;
2796 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2799 if (res->portid == (portid_t)RTE_PORT_ALL) {
2800 printf("Invalid port id\n");
2804 if (!strcmp(res->rxtxq, "rxq"))
2806 else if (!strcmp(res->rxtxq, "txq"))
2809 printf("Unknown parameter\n");
2813 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2814 printf("Invalid rx queue\n");
2816 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2817 printf("Invalid tx queue\n");
2821 port = &ports[res->portid];
2823 socket_id = rxring_numa[res->portid];
2824 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2825 socket_id = port->socket_id;
2827 mp = mbuf_pool_find(socket_id);
2829 printf("Failed to setup RX queue: "
2830 "No mempool allocation"
2831 " on the socket %d\n",
2832 rxring_numa[res->portid]);
2835 ret = rte_eth_rx_queue_setup(res->portid,
2837 port->nb_rx_desc[res->qid],
2839 &port->rx_conf[res->qid],
2842 printf("Failed to setup RX queue\n");
2844 socket_id = txring_numa[res->portid];
2845 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2846 socket_id = port->socket_id;
2848 ret = rte_eth_tx_queue_setup(res->portid,
2850 port->nb_tx_desc[res->qid],
2852 &port->tx_conf[res->qid]);
2854 printf("Failed to setup TX queue\n");
2858 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2859 .f = cmd_setup_rxtx_queue_parsed,
2861 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2863 (void *)&cmd_setup_rxtx_queue_port,
2864 (void *)&cmd_setup_rxtx_queue_portid,
2865 (void *)&cmd_setup_rxtx_queue_rxtxq,
2866 (void *)&cmd_setup_rxtx_queue_qid,
2867 (void *)&cmd_setup_rxtx_queue_setup,
2873 /* *** Configure RSS RETA *** */
2874 struct cmd_config_rss_reta {
2875 cmdline_fixed_string_t port;
2876 cmdline_fixed_string_t keyword;
2878 cmdline_fixed_string_t name;
2879 cmdline_fixed_string_t list_name;
2880 cmdline_fixed_string_t list_of_items;
2884 parse_reta_config(const char *str,
2885 struct rte_eth_rss_reta_entry64 *reta_conf,
2886 uint16_t nb_entries)
2890 uint16_t hash_index, idx, shift;
2893 const char *p, *p0 = str;
2900 unsigned long int_fld[_NUM_FLD];
2901 char *str_fld[_NUM_FLD];
2903 while ((p = strchr(p0,'(')) != NULL) {
2905 if((p0 = strchr(p,')')) == NULL)
2909 if(size >= sizeof(s))
2912 snprintf(s, sizeof(s), "%.*s", size, p);
2913 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2915 for (i = 0; i < _NUM_FLD; i++) {
2917 int_fld[i] = strtoul(str_fld[i], &end, 0);
2918 if (errno != 0 || end == str_fld[i] ||
2923 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2924 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2926 if (hash_index >= nb_entries) {
2927 printf("Invalid RETA hash index=%d\n", hash_index);
2931 idx = hash_index / RTE_RETA_GROUP_SIZE;
2932 shift = hash_index % RTE_RETA_GROUP_SIZE;
2933 reta_conf[idx].mask |= (1ULL << shift);
2934 reta_conf[idx].reta[shift] = nb_queue;
2941 cmd_set_rss_reta_parsed(void *parsed_result,
2942 __attribute__((unused)) struct cmdline *cl,
2943 __attribute__((unused)) void *data)
2946 struct rte_eth_dev_info dev_info;
2947 struct rte_eth_rss_reta_entry64 reta_conf[8];
2948 struct cmd_config_rss_reta *res = parsed_result;
2950 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2954 if (dev_info.reta_size == 0) {
2955 printf("Redirection table size is 0 which is "
2956 "invalid for RSS\n");
2959 printf("The reta size of port %d is %u\n",
2960 res->port_id, dev_info.reta_size);
2961 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2962 printf("Currently do not support more than %u entries of "
2963 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2967 memset(reta_conf, 0, sizeof(reta_conf));
2968 if (!strcmp(res->list_name, "reta")) {
2969 if (parse_reta_config(res->list_of_items, reta_conf,
2970 dev_info.reta_size)) {
2971 printf("Invalid RSS Redirection Table "
2972 "config entered\n");
2975 ret = rte_eth_dev_rss_reta_update(res->port_id,
2976 reta_conf, dev_info.reta_size);
2978 printf("Bad redirection table parameter, "
2979 "return code = %d \n", ret);
2983 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2984 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2985 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2986 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2987 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2988 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2989 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2990 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2991 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2992 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2993 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2994 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2996 cmdline_parse_inst_t cmd_config_rss_reta = {
2997 .f = cmd_set_rss_reta_parsed,
2999 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3001 (void *)&cmd_config_rss_reta_port,
3002 (void *)&cmd_config_rss_reta_keyword,
3003 (void *)&cmd_config_rss_reta_port_id,
3004 (void *)&cmd_config_rss_reta_name,
3005 (void *)&cmd_config_rss_reta_list_name,
3006 (void *)&cmd_config_rss_reta_list_of_items,
3011 /* *** SHOW PORT RETA INFO *** */
3012 struct cmd_showport_reta {
3013 cmdline_fixed_string_t show;
3014 cmdline_fixed_string_t port;
3016 cmdline_fixed_string_t rss;
3017 cmdline_fixed_string_t reta;
3019 cmdline_fixed_string_t list_of_items;
3023 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3024 uint16_t nb_entries,
3028 const char *p, *p0 = str;
3033 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3034 RTE_RETA_GROUP_SIZE;
3037 p = strchr(p0, '(');
3041 p0 = strchr(p, ')');
3045 if (size >= sizeof(s)) {
3046 printf("The string size exceeds the internal buffer size\n");
3049 snprintf(s, sizeof(s), "%.*s", size, p);
3050 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3051 if (ret <= 0 || ret != num) {
3052 printf("The bits of masks do not match the number of "
3053 "reta entries: %u\n", num);
3056 for (i = 0; i < ret; i++)
3057 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3063 cmd_showport_reta_parsed(void *parsed_result,
3064 __attribute__((unused)) struct cmdline *cl,
3065 __attribute__((unused)) void *data)
3067 struct cmd_showport_reta *res = parsed_result;
3068 struct rte_eth_rss_reta_entry64 reta_conf[8];
3069 struct rte_eth_dev_info dev_info;
3070 uint16_t max_reta_size;
3073 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3077 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3078 if (res->size == 0 || res->size > max_reta_size) {
3079 printf("Invalid redirection table size: %u (1-%u)\n",
3080 res->size, max_reta_size);
3084 memset(reta_conf, 0, sizeof(reta_conf));
3085 if (showport_parse_reta_config(reta_conf, res->size,
3086 res->list_of_items) < 0) {
3087 printf("Invalid string: %s for reta masks\n",
3088 res->list_of_items);
3091 port_rss_reta_info(res->port_id, reta_conf, res->size);
3094 cmdline_parse_token_string_t cmd_showport_reta_show =
3095 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3096 cmdline_parse_token_string_t cmd_showport_reta_port =
3097 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3098 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3099 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3100 cmdline_parse_token_string_t cmd_showport_reta_rss =
3101 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3102 cmdline_parse_token_string_t cmd_showport_reta_reta =
3103 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3104 cmdline_parse_token_num_t cmd_showport_reta_size =
3105 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3106 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3107 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3108 list_of_items, NULL);
3110 cmdline_parse_inst_t cmd_showport_reta = {
3111 .f = cmd_showport_reta_parsed,
3113 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3115 (void *)&cmd_showport_reta_show,
3116 (void *)&cmd_showport_reta_port,
3117 (void *)&cmd_showport_reta_port_id,
3118 (void *)&cmd_showport_reta_rss,
3119 (void *)&cmd_showport_reta_reta,
3120 (void *)&cmd_showport_reta_size,
3121 (void *)&cmd_showport_reta_list_of_items,
3126 /* *** Show RSS hash configuration *** */
3127 struct cmd_showport_rss_hash {
3128 cmdline_fixed_string_t show;
3129 cmdline_fixed_string_t port;
3131 cmdline_fixed_string_t rss_hash;
3132 cmdline_fixed_string_t rss_type;
3133 cmdline_fixed_string_t key; /* optional argument */
3136 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3137 __attribute__((unused)) struct cmdline *cl,
3140 struct cmd_showport_rss_hash *res = parsed_result;
3142 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3145 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3146 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3147 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3148 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3149 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3150 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3151 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3152 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3154 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3155 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3157 cmdline_parse_inst_t cmd_showport_rss_hash = {
3158 .f = cmd_showport_rss_hash_parsed,
3160 .help_str = "show port <port_id> rss-hash",
3162 (void *)&cmd_showport_rss_hash_show,
3163 (void *)&cmd_showport_rss_hash_port,
3164 (void *)&cmd_showport_rss_hash_port_id,
3165 (void *)&cmd_showport_rss_hash_rss_hash,
3170 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3171 .f = cmd_showport_rss_hash_parsed,
3173 .help_str = "show port <port_id> rss-hash key",
3175 (void *)&cmd_showport_rss_hash_show,
3176 (void *)&cmd_showport_rss_hash_port,
3177 (void *)&cmd_showport_rss_hash_port_id,
3178 (void *)&cmd_showport_rss_hash_rss_hash,
3179 (void *)&cmd_showport_rss_hash_rss_key,
3184 /* *** Configure DCB *** */
3185 struct cmd_config_dcb {
3186 cmdline_fixed_string_t port;
3187 cmdline_fixed_string_t config;
3189 cmdline_fixed_string_t dcb;
3190 cmdline_fixed_string_t vt;
3191 cmdline_fixed_string_t vt_en;
3193 cmdline_fixed_string_t pfc;
3194 cmdline_fixed_string_t pfc_en;
3198 cmd_config_dcb_parsed(void *parsed_result,
3199 __attribute__((unused)) struct cmdline *cl,
3200 __attribute__((unused)) void *data)
3202 struct cmd_config_dcb *res = parsed_result;
3203 portid_t port_id = res->port_id;
3204 struct rte_port *port;
3208 port = &ports[port_id];
3209 /** Check if the port is not started **/
3210 if (port->port_status != RTE_PORT_STOPPED) {
3211 printf("Please stop port %d first\n", port_id);
3215 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3216 printf("The invalid number of traffic class,"
3217 " only 4 or 8 allowed.\n");
3221 if (nb_fwd_lcores < res->num_tcs) {
3222 printf("nb_cores shouldn't be less than number of TCs.\n");
3225 if (!strncmp(res->pfc_en, "on", 2))
3230 /* DCB in VT mode */
3231 if (!strncmp(res->vt_en, "on", 2))
3232 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3233 (enum rte_eth_nb_tcs)res->num_tcs,
3236 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3237 (enum rte_eth_nb_tcs)res->num_tcs,
3242 printf("Cannot initialize network ports.\n");
3246 cmd_reconfig_device_queue(port_id, 1, 1);
3249 cmdline_parse_token_string_t cmd_config_dcb_port =
3250 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3251 cmdline_parse_token_string_t cmd_config_dcb_config =
3252 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3253 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3254 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3255 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3256 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3257 cmdline_parse_token_string_t cmd_config_dcb_vt =
3258 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3259 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3260 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3261 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3262 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3263 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3264 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3265 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3266 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3268 cmdline_parse_inst_t cmd_config_dcb = {
3269 .f = cmd_config_dcb_parsed,
3271 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3273 (void *)&cmd_config_dcb_port,
3274 (void *)&cmd_config_dcb_config,
3275 (void *)&cmd_config_dcb_port_id,
3276 (void *)&cmd_config_dcb_dcb,
3277 (void *)&cmd_config_dcb_vt,
3278 (void *)&cmd_config_dcb_vt_en,
3279 (void *)&cmd_config_dcb_num_tcs,
3280 (void *)&cmd_config_dcb_pfc,
3281 (void *)&cmd_config_dcb_pfc_en,
3286 /* *** configure number of packets per burst *** */
3287 struct cmd_config_burst {
3288 cmdline_fixed_string_t port;
3289 cmdline_fixed_string_t keyword;
3290 cmdline_fixed_string_t all;
3291 cmdline_fixed_string_t name;
3296 cmd_config_burst_parsed(void *parsed_result,
3297 __attribute__((unused)) struct cmdline *cl,
3298 __attribute__((unused)) void *data)
3300 struct cmd_config_burst *res = parsed_result;
3301 struct rte_eth_dev_info dev_info;
3302 uint16_t rec_nb_pkts;
3305 if (!all_ports_stopped()) {
3306 printf("Please stop all ports first\n");
3310 if (!strcmp(res->name, "burst")) {
3311 if (res->value == 0) {
3312 /* If user gives a value of zero, query the PMD for
3313 * its recommended Rx burst size. Testpmd uses a single
3314 * size for all ports, so assume all ports are the same
3315 * NIC model and use the values from Port 0.
3317 ret = eth_dev_info_get_print_err(0, &dev_info);
3321 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3323 if (rec_nb_pkts == 0) {
3324 printf("PMD does not recommend a burst size.\n"
3325 "User provided value must be between"
3326 " 1 and %d\n", MAX_PKT_BURST);
3328 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3329 printf("PMD recommended burst size of %d"
3330 " exceeds maximum value of %d\n",
3331 rec_nb_pkts, MAX_PKT_BURST);
3334 printf("Using PMD-provided burst value of %d\n",
3336 nb_pkt_per_burst = rec_nb_pkts;
3337 } else if (res->value > MAX_PKT_BURST) {
3338 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3341 nb_pkt_per_burst = res->value;
3343 printf("Unknown parameter\n");
3349 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3352 cmdline_parse_token_string_t cmd_config_burst_port =
3353 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3354 cmdline_parse_token_string_t cmd_config_burst_keyword =
3355 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3356 cmdline_parse_token_string_t cmd_config_burst_all =
3357 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3358 cmdline_parse_token_string_t cmd_config_burst_name =
3359 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3360 cmdline_parse_token_num_t cmd_config_burst_value =
3361 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3363 cmdline_parse_inst_t cmd_config_burst = {
3364 .f = cmd_config_burst_parsed,
3366 .help_str = "port config all burst <value>",
3368 (void *)&cmd_config_burst_port,
3369 (void *)&cmd_config_burst_keyword,
3370 (void *)&cmd_config_burst_all,
3371 (void *)&cmd_config_burst_name,
3372 (void *)&cmd_config_burst_value,
3377 /* *** configure rx/tx queues *** */
3378 struct cmd_config_thresh {
3379 cmdline_fixed_string_t port;
3380 cmdline_fixed_string_t keyword;
3381 cmdline_fixed_string_t all;
3382 cmdline_fixed_string_t name;
3387 cmd_config_thresh_parsed(void *parsed_result,
3388 __attribute__((unused)) struct cmdline *cl,
3389 __attribute__((unused)) void *data)
3391 struct cmd_config_thresh *res = parsed_result;
3393 if (!all_ports_stopped()) {
3394 printf("Please stop all ports first\n");
3398 if (!strcmp(res->name, "txpt"))
3399 tx_pthresh = res->value;
3400 else if(!strcmp(res->name, "txht"))
3401 tx_hthresh = res->value;
3402 else if(!strcmp(res->name, "txwt"))
3403 tx_wthresh = res->value;
3404 else if(!strcmp(res->name, "rxpt"))
3405 rx_pthresh = res->value;
3406 else if(!strcmp(res->name, "rxht"))
3407 rx_hthresh = res->value;
3408 else if(!strcmp(res->name, "rxwt"))
3409 rx_wthresh = res->value;
3411 printf("Unknown parameter\n");
3417 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3420 cmdline_parse_token_string_t cmd_config_thresh_port =
3421 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3422 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3423 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3424 cmdline_parse_token_string_t cmd_config_thresh_all =
3425 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3426 cmdline_parse_token_string_t cmd_config_thresh_name =
3427 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3428 "txpt#txht#txwt#rxpt#rxht#rxwt");
3429 cmdline_parse_token_num_t cmd_config_thresh_value =
3430 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3432 cmdline_parse_inst_t cmd_config_thresh = {
3433 .f = cmd_config_thresh_parsed,
3435 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3437 (void *)&cmd_config_thresh_port,
3438 (void *)&cmd_config_thresh_keyword,
3439 (void *)&cmd_config_thresh_all,
3440 (void *)&cmd_config_thresh_name,
3441 (void *)&cmd_config_thresh_value,
3446 /* *** configure free/rs threshold *** */
3447 struct cmd_config_threshold {
3448 cmdline_fixed_string_t port;
3449 cmdline_fixed_string_t keyword;
3450 cmdline_fixed_string_t all;
3451 cmdline_fixed_string_t name;
3456 cmd_config_threshold_parsed(void *parsed_result,
3457 __attribute__((unused)) struct cmdline *cl,
3458 __attribute__((unused)) void *data)
3460 struct cmd_config_threshold *res = parsed_result;
3462 if (!all_ports_stopped()) {
3463 printf("Please stop all ports first\n");
3467 if (!strcmp(res->name, "txfreet"))
3468 tx_free_thresh = res->value;
3469 else if (!strcmp(res->name, "txrst"))
3470 tx_rs_thresh = res->value;
3471 else if (!strcmp(res->name, "rxfreet"))
3472 rx_free_thresh = res->value;
3474 printf("Unknown parameter\n");
3480 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3483 cmdline_parse_token_string_t cmd_config_threshold_port =
3484 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3485 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3486 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3488 cmdline_parse_token_string_t cmd_config_threshold_all =
3489 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3490 cmdline_parse_token_string_t cmd_config_threshold_name =
3491 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3492 "txfreet#txrst#rxfreet");
3493 cmdline_parse_token_num_t cmd_config_threshold_value =
3494 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3496 cmdline_parse_inst_t cmd_config_threshold = {
3497 .f = cmd_config_threshold_parsed,
3499 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3501 (void *)&cmd_config_threshold_port,
3502 (void *)&cmd_config_threshold_keyword,
3503 (void *)&cmd_config_threshold_all,
3504 (void *)&cmd_config_threshold_name,
3505 (void *)&cmd_config_threshold_value,
3511 struct cmd_stop_result {
3512 cmdline_fixed_string_t stop;
3515 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3516 __attribute__((unused)) struct cmdline *cl,
3517 __attribute__((unused)) void *data)
3519 stop_packet_forwarding();
3522 cmdline_parse_token_string_t cmd_stop_stop =
3523 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3525 cmdline_parse_inst_t cmd_stop = {
3526 .f = cmd_stop_parsed,
3528 .help_str = "stop: Stop packet forwarding",
3530 (void *)&cmd_stop_stop,
3535 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3538 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3539 unsigned int *parsed_items, int check_unique_values)
3541 unsigned int nb_item;
3549 * First parse all items in the list and store their value.
3554 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3556 if ((c >= '0') && (c <= '9')) {
3557 value = (unsigned int) (value * 10 + (c - '0'));
3562 printf("character %c is not a decimal digit\n", c);
3566 printf("No valid value before comma\n");
3569 if (nb_item < max_items) {
3570 parsed_items[nb_item] = value;
3576 if (nb_item >= max_items) {
3577 printf("Number of %s = %u > %u (maximum items)\n",
3578 item_name, nb_item + 1, max_items);
3581 parsed_items[nb_item++] = value;
3582 if (! check_unique_values)
3586 * Then, check that all values in the list are differents.
3587 * No optimization here...
3589 for (i = 0; i < nb_item; i++) {
3590 for (j = i + 1; j < nb_item; j++) {
3591 if (parsed_items[j] == parsed_items[i]) {
3592 printf("duplicated %s %u at index %u and %u\n",
3593 item_name, parsed_items[i], i, j);
3601 struct cmd_set_list_result {
3602 cmdline_fixed_string_t cmd_keyword;
3603 cmdline_fixed_string_t list_name;
3604 cmdline_fixed_string_t list_of_items;
3607 static void cmd_set_list_parsed(void *parsed_result,
3608 __attribute__((unused)) struct cmdline *cl,
3609 __attribute__((unused)) void *data)
3611 struct cmd_set_list_result *res;
3613 unsigned int lcorelist[RTE_MAX_LCORE];
3614 unsigned int portlist[RTE_MAX_ETHPORTS];
3616 unsigned int nb_item;
3618 if (test_done == 0) {
3619 printf("Please stop forwarding first\n");
3623 res = parsed_result;
3624 if (!strcmp(res->list_name, "corelist")) {
3625 nb_item = parse_item_list(res->list_of_items, "core",
3627 parsed_items.lcorelist, 1);
3629 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3634 if (!strcmp(res->list_name, "portlist")) {
3635 nb_item = parse_item_list(res->list_of_items, "port",
3637 parsed_items.portlist, 1);
3639 set_fwd_ports_list(parsed_items.portlist, nb_item);
3645 cmdline_parse_token_string_t cmd_set_list_keyword =
3646 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3648 cmdline_parse_token_string_t cmd_set_list_name =
3649 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3650 "corelist#portlist");
3651 cmdline_parse_token_string_t cmd_set_list_of_items =
3652 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3655 cmdline_parse_inst_t cmd_set_fwd_list = {
3656 .f = cmd_set_list_parsed,
3658 .help_str = "set corelist|portlist <list0[,list1]*>",
3660 (void *)&cmd_set_list_keyword,
3661 (void *)&cmd_set_list_name,
3662 (void *)&cmd_set_list_of_items,
3667 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3669 struct cmd_setmask_result {
3670 cmdline_fixed_string_t set;
3671 cmdline_fixed_string_t mask;
3675 static void cmd_set_mask_parsed(void *parsed_result,
3676 __attribute__((unused)) struct cmdline *cl,
3677 __attribute__((unused)) void *data)
3679 struct cmd_setmask_result *res = parsed_result;
3681 if (test_done == 0) {
3682 printf("Please stop forwarding first\n");
3685 if (!strcmp(res->mask, "coremask")) {
3686 set_fwd_lcores_mask(res->hexavalue);
3688 } else if (!strcmp(res->mask, "portmask")) {
3689 set_fwd_ports_mask(res->hexavalue);
3694 cmdline_parse_token_string_t cmd_setmask_set =
3695 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3696 cmdline_parse_token_string_t cmd_setmask_mask =
3697 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3698 "coremask#portmask");
3699 cmdline_parse_token_num_t cmd_setmask_value =
3700 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3702 cmdline_parse_inst_t cmd_set_fwd_mask = {
3703 .f = cmd_set_mask_parsed,
3705 .help_str = "set coremask|portmask <hexadecimal value>",
3707 (void *)&cmd_setmask_set,
3708 (void *)&cmd_setmask_mask,
3709 (void *)&cmd_setmask_value,
3715 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3717 struct cmd_set_result {
3718 cmdline_fixed_string_t set;
3719 cmdline_fixed_string_t what;
3723 static void cmd_set_parsed(void *parsed_result,
3724 __attribute__((unused)) struct cmdline *cl,
3725 __attribute__((unused)) void *data)
3727 struct cmd_set_result *res = parsed_result;
3728 if (!strcmp(res->what, "nbport")) {
3729 set_fwd_ports_number(res->value);
3731 } else if (!strcmp(res->what, "nbcore")) {
3732 set_fwd_lcores_number(res->value);
3734 } else if (!strcmp(res->what, "burst"))
3735 set_nb_pkt_per_burst(res->value);
3736 else if (!strcmp(res->what, "verbose"))
3737 set_verbose_level(res->value);
3740 cmdline_parse_token_string_t cmd_set_set =
3741 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3742 cmdline_parse_token_string_t cmd_set_what =
3743 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3744 "nbport#nbcore#burst#verbose");
3745 cmdline_parse_token_num_t cmd_set_value =
3746 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3748 cmdline_parse_inst_t cmd_set_numbers = {
3749 .f = cmd_set_parsed,
3751 .help_str = "set nbport|nbcore|burst|verbose <value>",
3753 (void *)&cmd_set_set,
3754 (void *)&cmd_set_what,
3755 (void *)&cmd_set_value,
3760 /* *** SET LOG LEVEL CONFIGURATION *** */
3762 struct cmd_set_log_result {
3763 cmdline_fixed_string_t set;
3764 cmdline_fixed_string_t log;
3765 cmdline_fixed_string_t type;
3770 cmd_set_log_parsed(void *parsed_result,
3771 __attribute__((unused)) struct cmdline *cl,
3772 __attribute__((unused)) void *data)
3774 struct cmd_set_log_result *res;
3777 res = parsed_result;
3778 if (!strcmp(res->type, "global"))
3779 rte_log_set_global_level(res->level);
3781 ret = rte_log_set_level_regexp(res->type, res->level);
3783 printf("Unable to set log level\n");
3787 cmdline_parse_token_string_t cmd_set_log_set =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3789 cmdline_parse_token_string_t cmd_set_log_log =
3790 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3791 cmdline_parse_token_string_t cmd_set_log_type =
3792 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3793 cmdline_parse_token_num_t cmd_set_log_level =
3794 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3796 cmdline_parse_inst_t cmd_set_log = {
3797 .f = cmd_set_log_parsed,
3799 .help_str = "set log global|<type> <level>",
3801 (void *)&cmd_set_log_set,
3802 (void *)&cmd_set_log_log,
3803 (void *)&cmd_set_log_type,
3804 (void *)&cmd_set_log_level,
3809 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3811 struct cmd_set_txpkts_result {
3812 cmdline_fixed_string_t cmd_keyword;
3813 cmdline_fixed_string_t txpkts;
3814 cmdline_fixed_string_t seg_lengths;
3818 cmd_set_txpkts_parsed(void *parsed_result,
3819 __attribute__((unused)) struct cmdline *cl,
3820 __attribute__((unused)) void *data)
3822 struct cmd_set_txpkts_result *res;
3823 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3824 unsigned int nb_segs;
3826 res = parsed_result;
3827 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3828 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3830 set_tx_pkt_segments(seg_lengths, nb_segs);
3833 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3835 cmd_keyword, "set");
3836 cmdline_parse_token_string_t cmd_set_txpkts_name =
3837 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3839 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3840 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3843 cmdline_parse_inst_t cmd_set_txpkts = {
3844 .f = cmd_set_txpkts_parsed,
3846 .help_str = "set txpkts <len0[,len1]*>",
3848 (void *)&cmd_set_txpkts_keyword,
3849 (void *)&cmd_set_txpkts_name,
3850 (void *)&cmd_set_txpkts_lengths,
3855 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3857 struct cmd_set_txsplit_result {
3858 cmdline_fixed_string_t cmd_keyword;
3859 cmdline_fixed_string_t txsplit;
3860 cmdline_fixed_string_t mode;
3864 cmd_set_txsplit_parsed(void *parsed_result,
3865 __attribute__((unused)) struct cmdline *cl,
3866 __attribute__((unused)) void *data)
3868 struct cmd_set_txsplit_result *res;
3870 res = parsed_result;
3871 set_tx_pkt_split(res->mode);
3874 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3875 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3876 cmd_keyword, "set");
3877 cmdline_parse_token_string_t cmd_set_txsplit_name =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3879 txsplit, "txsplit");
3880 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3881 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3884 cmdline_parse_inst_t cmd_set_txsplit = {
3885 .f = cmd_set_txsplit_parsed,
3887 .help_str = "set txsplit on|off|rand",
3889 (void *)&cmd_set_txsplit_keyword,
3890 (void *)&cmd_set_txsplit_name,
3891 (void *)&cmd_set_txsplit_mode,
3896 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3897 struct cmd_rx_vlan_filter_all_result {
3898 cmdline_fixed_string_t rx_vlan;
3899 cmdline_fixed_string_t what;
3900 cmdline_fixed_string_t all;
3905 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3906 __attribute__((unused)) struct cmdline *cl,
3907 __attribute__((unused)) void *data)
3909 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3911 if (!strcmp(res->what, "add"))
3912 rx_vlan_all_filter_set(res->port_id, 1);
3914 rx_vlan_all_filter_set(res->port_id, 0);
3917 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3918 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3919 rx_vlan, "rx_vlan");
3920 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3921 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3923 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3924 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3926 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3927 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3930 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3931 .f = cmd_rx_vlan_filter_all_parsed,
3933 .help_str = "rx_vlan add|rm all <port_id>: "
3934 "Add/Remove all identifiers to/from the set of VLAN "
3935 "identifiers filtered by a port",
3937 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3938 (void *)&cmd_rx_vlan_filter_all_what,
3939 (void *)&cmd_rx_vlan_filter_all_all,
3940 (void *)&cmd_rx_vlan_filter_all_portid,
3945 /* *** VLAN OFFLOAD SET ON A PORT *** */
3946 struct cmd_vlan_offload_result {
3947 cmdline_fixed_string_t vlan;
3948 cmdline_fixed_string_t set;
3949 cmdline_fixed_string_t vlan_type;
3950 cmdline_fixed_string_t what;
3951 cmdline_fixed_string_t on;
3952 cmdline_fixed_string_t port_id;
3956 cmd_vlan_offload_parsed(void *parsed_result,
3957 __attribute__((unused)) struct cmdline *cl,
3958 __attribute__((unused)) void *data)
3961 struct cmd_vlan_offload_result *res = parsed_result;
3964 portid_t port_id = 0;
3968 len = strnlen(str, STR_TOKEN_SIZE);
3970 /* Get port_id first */
3978 tmp = strtoul(str, NULL, 0);
3979 /* If port_id greater that what portid_t can represent, return */
3980 if(tmp >= RTE_MAX_ETHPORTS)
3982 port_id = (portid_t)tmp;
3984 if (!strcmp(res->on, "on"))
3989 if (!strcmp(res->what, "strip"))
3990 rx_vlan_strip_set(port_id, on);
3991 else if(!strcmp(res->what, "stripq")){
3992 uint16_t queue_id = 0;
3994 /* No queue_id, return */
3996 printf("must specify (port,queue_id)\n");
3999 tmp = strtoul(str + i + 1, NULL, 0);
4000 /* If queue_id greater that what 16-bits can represent, return */
4004 queue_id = (uint16_t)tmp;
4005 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4007 else if (!strcmp(res->what, "filter"))
4008 rx_vlan_filter_set(port_id, on);
4009 else if (!strcmp(res->what, "qinq_strip"))
4010 rx_vlan_qinq_strip_set(port_id, on);
4012 vlan_extend_set(port_id, on);
4017 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4018 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4020 cmdline_parse_token_string_t cmd_vlan_offload_set =
4021 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4023 cmdline_parse_token_string_t cmd_vlan_offload_what =
4024 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4025 what, "strip#filter#qinq_strip#extend#stripq");
4026 cmdline_parse_token_string_t cmd_vlan_offload_on =
4027 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4029 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4030 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4033 cmdline_parse_inst_t cmd_vlan_offload = {
4034 .f = cmd_vlan_offload_parsed,
4036 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4037 "<port_id[,queue_id]>: "
4038 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4040 (void *)&cmd_vlan_offload_vlan,
4041 (void *)&cmd_vlan_offload_set,
4042 (void *)&cmd_vlan_offload_what,
4043 (void *)&cmd_vlan_offload_on,
4044 (void *)&cmd_vlan_offload_portid,
4049 /* *** VLAN TPID SET ON A PORT *** */
4050 struct cmd_vlan_tpid_result {
4051 cmdline_fixed_string_t vlan;
4052 cmdline_fixed_string_t set;
4053 cmdline_fixed_string_t vlan_type;
4054 cmdline_fixed_string_t what;
4060 cmd_vlan_tpid_parsed(void *parsed_result,
4061 __attribute__((unused)) struct cmdline *cl,
4062 __attribute__((unused)) void *data)
4064 struct cmd_vlan_tpid_result *res = parsed_result;
4065 enum rte_vlan_type vlan_type;
4067 if (!strcmp(res->vlan_type, "inner"))
4068 vlan_type = ETH_VLAN_TYPE_INNER;
4069 else if (!strcmp(res->vlan_type, "outer"))
4070 vlan_type = ETH_VLAN_TYPE_OUTER;
4072 printf("Unknown vlan type\n");
4075 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4078 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4079 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4081 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4082 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4084 cmdline_parse_token_string_t cmd_vlan_type =
4085 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4086 vlan_type, "inner#outer");
4087 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4088 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4090 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4091 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4093 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4094 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4097 cmdline_parse_inst_t cmd_vlan_tpid = {
4098 .f = cmd_vlan_tpid_parsed,
4100 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4101 "Set the VLAN Ether type",
4103 (void *)&cmd_vlan_tpid_vlan,
4104 (void *)&cmd_vlan_tpid_set,
4105 (void *)&cmd_vlan_type,
4106 (void *)&cmd_vlan_tpid_what,
4107 (void *)&cmd_vlan_tpid_tpid,
4108 (void *)&cmd_vlan_tpid_portid,
4113 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4114 struct cmd_rx_vlan_filter_result {
4115 cmdline_fixed_string_t rx_vlan;
4116 cmdline_fixed_string_t what;
4122 cmd_rx_vlan_filter_parsed(void *parsed_result,
4123 __attribute__((unused)) struct cmdline *cl,
4124 __attribute__((unused)) void *data)
4126 struct cmd_rx_vlan_filter_result *res = parsed_result;
4128 if (!strcmp(res->what, "add"))
4129 rx_vft_set(res->port_id, res->vlan_id, 1);
4131 rx_vft_set(res->port_id, res->vlan_id, 0);
4134 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4135 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4136 rx_vlan, "rx_vlan");
4137 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4138 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4140 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4141 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4143 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4144 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4147 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4148 .f = cmd_rx_vlan_filter_parsed,
4150 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4151 "Add/Remove a VLAN identifier to/from the set of VLAN "
4152 "identifiers filtered by a port",
4154 (void *)&cmd_rx_vlan_filter_rx_vlan,
4155 (void *)&cmd_rx_vlan_filter_what,
4156 (void *)&cmd_rx_vlan_filter_vlanid,
4157 (void *)&cmd_rx_vlan_filter_portid,
4162 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4163 struct cmd_tx_vlan_set_result {
4164 cmdline_fixed_string_t tx_vlan;
4165 cmdline_fixed_string_t set;
4171 cmd_tx_vlan_set_parsed(void *parsed_result,
4172 __attribute__((unused)) struct cmdline *cl,
4173 __attribute__((unused)) void *data)
4175 struct cmd_tx_vlan_set_result *res = parsed_result;
4177 if (!port_is_stopped(res->port_id)) {
4178 printf("Please stop port %d first\n", res->port_id);
4182 tx_vlan_set(res->port_id, res->vlan_id);
4184 cmd_reconfig_device_queue(res->port_id, 1, 1);
4187 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4188 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4189 tx_vlan, "tx_vlan");
4190 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4191 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4193 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4194 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4196 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4197 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4200 cmdline_parse_inst_t cmd_tx_vlan_set = {
4201 .f = cmd_tx_vlan_set_parsed,
4203 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4204 "Enable hardware insertion of a single VLAN header "
4205 "with a given TAG Identifier in packets sent on a port",
4207 (void *)&cmd_tx_vlan_set_tx_vlan,
4208 (void *)&cmd_tx_vlan_set_set,
4209 (void *)&cmd_tx_vlan_set_portid,
4210 (void *)&cmd_tx_vlan_set_vlanid,
4215 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4216 struct cmd_tx_vlan_set_qinq_result {
4217 cmdline_fixed_string_t tx_vlan;
4218 cmdline_fixed_string_t set;
4221 uint16_t vlan_id_outer;
4225 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4226 __attribute__((unused)) struct cmdline *cl,
4227 __attribute__((unused)) void *data)
4229 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4231 if (!port_is_stopped(res->port_id)) {
4232 printf("Please stop port %d first\n", res->port_id);
4236 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4238 cmd_reconfig_device_queue(res->port_id, 1, 1);
4241 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4242 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4243 tx_vlan, "tx_vlan");
4244 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4245 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4247 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4248 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4250 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4251 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4253 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4254 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4255 vlan_id_outer, UINT16);
4257 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4258 .f = cmd_tx_vlan_set_qinq_parsed,
4260 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4261 "Enable hardware insertion of double VLAN header "
4262 "with given TAG Identifiers in packets sent on a port",
4264 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4265 (void *)&cmd_tx_vlan_set_qinq_set,
4266 (void *)&cmd_tx_vlan_set_qinq_portid,
4267 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4268 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4273 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4274 struct cmd_tx_vlan_set_pvid_result {
4275 cmdline_fixed_string_t tx_vlan;
4276 cmdline_fixed_string_t set;
4277 cmdline_fixed_string_t pvid;
4280 cmdline_fixed_string_t mode;
4284 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4285 __attribute__((unused)) struct cmdline *cl,
4286 __attribute__((unused)) void *data)
4288 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4290 if (strcmp(res->mode, "on") == 0)
4291 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4293 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4296 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4297 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4298 tx_vlan, "tx_vlan");
4299 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4300 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4302 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4303 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4305 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4306 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4308 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4309 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4311 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4312 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4315 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4316 .f = cmd_tx_vlan_set_pvid_parsed,
4318 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4320 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4321 (void *)&cmd_tx_vlan_set_pvid_set,
4322 (void *)&cmd_tx_vlan_set_pvid_pvid,
4323 (void *)&cmd_tx_vlan_set_pvid_port_id,
4324 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4325 (void *)&cmd_tx_vlan_set_pvid_mode,
4330 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4331 struct cmd_tx_vlan_reset_result {
4332 cmdline_fixed_string_t tx_vlan;
4333 cmdline_fixed_string_t reset;
4338 cmd_tx_vlan_reset_parsed(void *parsed_result,
4339 __attribute__((unused)) struct cmdline *cl,
4340 __attribute__((unused)) void *data)
4342 struct cmd_tx_vlan_reset_result *res = parsed_result;
4344 if (!port_is_stopped(res->port_id)) {
4345 printf("Please stop port %d first\n", res->port_id);
4349 tx_vlan_reset(res->port_id);
4351 cmd_reconfig_device_queue(res->port_id, 1, 1);
4354 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4355 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4356 tx_vlan, "tx_vlan");
4357 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4358 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4360 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4361 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4364 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4365 .f = cmd_tx_vlan_reset_parsed,
4367 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4368 "VLAN header in packets sent on a port",
4370 (void *)&cmd_tx_vlan_reset_tx_vlan,
4371 (void *)&cmd_tx_vlan_reset_reset,
4372 (void *)&cmd_tx_vlan_reset_portid,
4378 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4379 struct cmd_csum_result {
4380 cmdline_fixed_string_t csum;
4381 cmdline_fixed_string_t mode;
4382 cmdline_fixed_string_t proto;
4383 cmdline_fixed_string_t hwsw;
4388 csum_show(int port_id)
4390 struct rte_eth_dev_info dev_info;
4391 uint64_t tx_offloads;
4394 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4395 printf("Parse tunnel is %s\n",
4396 (ports[port_id].parse_tunnel) ? "on" : "off");
4397 printf("IP checksum offload is %s\n",
4398 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4399 printf("UDP checksum offload is %s\n",
4400 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4401 printf("TCP checksum offload is %s\n",
4402 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4403 printf("SCTP checksum offload is %s\n",
4404 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4405 printf("Outer-Ip checksum offload is %s\n",
4406 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4407 printf("Outer-Udp checksum offload is %s\n",
4408 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4410 /* display warnings if configuration is not supported by the NIC */
4411 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4415 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4416 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4417 printf("Warning: hardware IP checksum enabled but not "
4418 "supported by port %d\n", port_id);
4420 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4421 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4422 printf("Warning: hardware UDP checksum enabled but not "
4423 "supported by port %d\n", port_id);
4425 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4426 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4427 printf("Warning: hardware TCP checksum enabled but not "
4428 "supported by port %d\n", port_id);
4430 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4431 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4432 printf("Warning: hardware SCTP checksum enabled but not "
4433 "supported by port %d\n", port_id);
4435 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4436 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4437 printf("Warning: hardware outer IP checksum enabled but not "
4438 "supported by port %d\n", port_id);
4440 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4441 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4443 printf("Warning: hardware outer UDP checksum enabled but not "
4444 "supported by port %d\n", port_id);
4449 cmd_config_queue_tx_offloads(struct rte_port *port)
4453 /* Apply queue tx offloads configuration */
4454 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4455 port->tx_conf[k].offloads =
4456 port->dev_conf.txmode.offloads;
4460 cmd_csum_parsed(void *parsed_result,
4461 __attribute__((unused)) struct cmdline *cl,
4462 __attribute__((unused)) void *data)
4464 struct cmd_csum_result *res = parsed_result;
4466 uint64_t csum_offloads = 0;
4467 struct rte_eth_dev_info dev_info;
4470 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4471 printf("invalid port %d\n", res->port_id);
4474 if (!port_is_stopped(res->port_id)) {
4475 printf("Please stop port %d first\n", res->port_id);
4479 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4483 if (!strcmp(res->mode, "set")) {
4485 if (!strcmp(res->hwsw, "hw"))
4488 if (!strcmp(res->proto, "ip")) {
4489 if (hw == 0 || (dev_info.tx_offload_capa &
4490 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4491 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4493 printf("IP checksum offload is not supported "
4494 "by port %u\n", res->port_id);
4496 } else if (!strcmp(res->proto, "udp")) {
4497 if (hw == 0 || (dev_info.tx_offload_capa &
4498 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4499 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4501 printf("UDP checksum offload is not supported "
4502 "by port %u\n", res->port_id);
4504 } else if (!strcmp(res->proto, "tcp")) {
4505 if (hw == 0 || (dev_info.tx_offload_capa &
4506 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4507 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4509 printf("TCP checksum offload is not supported "
4510 "by port %u\n", res->port_id);
4512 } else if (!strcmp(res->proto, "sctp")) {
4513 if (hw == 0 || (dev_info.tx_offload_capa &
4514 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4515 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4517 printf("SCTP checksum offload is not supported "
4518 "by port %u\n", res->port_id);
4520 } else if (!strcmp(res->proto, "outer-ip")) {
4521 if (hw == 0 || (dev_info.tx_offload_capa &
4522 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4524 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4526 printf("Outer IP checksum offload is not "
4527 "supported by port %u\n", res->port_id);
4529 } else if (!strcmp(res->proto, "outer-udp")) {
4530 if (hw == 0 || (dev_info.tx_offload_capa &
4531 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4533 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4535 printf("Outer UDP checksum offload is not "
4536 "supported by port %u\n", res->port_id);
4541 ports[res->port_id].dev_conf.txmode.offloads |=
4544 ports[res->port_id].dev_conf.txmode.offloads &=
4547 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4549 csum_show(res->port_id);
4551 cmd_reconfig_device_queue(res->port_id, 1, 1);
4554 cmdline_parse_token_string_t cmd_csum_csum =
4555 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4557 cmdline_parse_token_string_t cmd_csum_mode =
4558 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4560 cmdline_parse_token_string_t cmd_csum_proto =
4561 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4562 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4563 cmdline_parse_token_string_t cmd_csum_hwsw =
4564 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4566 cmdline_parse_token_num_t cmd_csum_portid =
4567 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4570 cmdline_parse_inst_t cmd_csum_set = {
4571 .f = cmd_csum_parsed,
4573 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4574 "Enable/Disable hardware calculation of L3/L4 checksum when "
4575 "using csum forward engine",
4577 (void *)&cmd_csum_csum,
4578 (void *)&cmd_csum_mode,
4579 (void *)&cmd_csum_proto,
4580 (void *)&cmd_csum_hwsw,
4581 (void *)&cmd_csum_portid,
4586 cmdline_parse_token_string_t cmd_csum_mode_show =
4587 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4590 cmdline_parse_inst_t cmd_csum_show = {
4591 .f = cmd_csum_parsed,
4593 .help_str = "csum show <port_id>: Show checksum offload configuration",
4595 (void *)&cmd_csum_csum,
4596 (void *)&cmd_csum_mode_show,
4597 (void *)&cmd_csum_portid,
4602 /* Enable/disable tunnel parsing */
4603 struct cmd_csum_tunnel_result {
4604 cmdline_fixed_string_t csum;
4605 cmdline_fixed_string_t parse;
4606 cmdline_fixed_string_t onoff;
4611 cmd_csum_tunnel_parsed(void *parsed_result,
4612 __attribute__((unused)) struct cmdline *cl,
4613 __attribute__((unused)) void *data)
4615 struct cmd_csum_tunnel_result *res = parsed_result;
4617 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4620 if (!strcmp(res->onoff, "on"))
4621 ports[res->port_id].parse_tunnel = 1;
4623 ports[res->port_id].parse_tunnel = 0;
4625 csum_show(res->port_id);
4628 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4629 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4631 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4632 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4633 parse, "parse-tunnel");
4634 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4635 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4637 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4638 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4641 cmdline_parse_inst_t cmd_csum_tunnel = {
4642 .f = cmd_csum_tunnel_parsed,
4644 .help_str = "csum parse-tunnel on|off <port_id>: "
4645 "Enable/Disable parsing of tunnels for csum engine",
4647 (void *)&cmd_csum_tunnel_csum,
4648 (void *)&cmd_csum_tunnel_parse,
4649 (void *)&cmd_csum_tunnel_onoff,
4650 (void *)&cmd_csum_tunnel_portid,
4655 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4656 struct cmd_tso_set_result {
4657 cmdline_fixed_string_t tso;
4658 cmdline_fixed_string_t mode;
4664 cmd_tso_set_parsed(void *parsed_result,
4665 __attribute__((unused)) struct cmdline *cl,
4666 __attribute__((unused)) void *data)
4668 struct cmd_tso_set_result *res = parsed_result;
4669 struct rte_eth_dev_info dev_info;
4672 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4674 if (!port_is_stopped(res->port_id)) {
4675 printf("Please stop port %d first\n", res->port_id);
4679 if (!strcmp(res->mode, "set"))
4680 ports[res->port_id].tso_segsz = res->tso_segsz;
4682 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4686 if ((ports[res->port_id].tso_segsz != 0) &&
4687 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4688 printf("Error: TSO is not supported by port %d\n",
4693 if (ports[res->port_id].tso_segsz == 0) {
4694 ports[res->port_id].dev_conf.txmode.offloads &=
4695 ~DEV_TX_OFFLOAD_TCP_TSO;
4696 printf("TSO for non-tunneled packets is disabled\n");
4698 ports[res->port_id].dev_conf.txmode.offloads |=
4699 DEV_TX_OFFLOAD_TCP_TSO;
4700 printf("TSO segment size for non-tunneled packets is %d\n",
4701 ports[res->port_id].tso_segsz);
4703 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4705 /* display warnings if configuration is not supported by the NIC */
4706 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4710 if ((ports[res->port_id].tso_segsz != 0) &&
4711 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4712 printf("Warning: TSO enabled but not "
4713 "supported by port %d\n", res->port_id);
4716 cmd_reconfig_device_queue(res->port_id, 1, 1);
4719 cmdline_parse_token_string_t cmd_tso_set_tso =
4720 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4722 cmdline_parse_token_string_t cmd_tso_set_mode =
4723 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4725 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4726 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4728 cmdline_parse_token_num_t cmd_tso_set_portid =
4729 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4732 cmdline_parse_inst_t cmd_tso_set = {
4733 .f = cmd_tso_set_parsed,
4735 .help_str = "tso set <tso_segsz> <port_id>: "
4736 "Set TSO segment size of non-tunneled packets for csum engine "
4739 (void *)&cmd_tso_set_tso,
4740 (void *)&cmd_tso_set_mode,
4741 (void *)&cmd_tso_set_tso_segsz,
4742 (void *)&cmd_tso_set_portid,
4747 cmdline_parse_token_string_t cmd_tso_show_mode =
4748 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4752 cmdline_parse_inst_t cmd_tso_show = {
4753 .f = cmd_tso_set_parsed,
4755 .help_str = "tso show <port_id>: "
4756 "Show TSO segment size of non-tunneled packets for csum engine",
4758 (void *)&cmd_tso_set_tso,
4759 (void *)&cmd_tso_show_mode,
4760 (void *)&cmd_tso_set_portid,
4765 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4766 struct cmd_tunnel_tso_set_result {
4767 cmdline_fixed_string_t tso;
4768 cmdline_fixed_string_t mode;
4773 static struct rte_eth_dev_info
4774 check_tunnel_tso_nic_support(portid_t port_id)
4776 struct rte_eth_dev_info dev_info;
4778 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4781 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4782 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4783 "not enabled for port %d\n", port_id);
4784 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4785 printf("Warning: GRE TUNNEL TSO not supported therefore "
4786 "not enabled for port %d\n", port_id);
4787 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4788 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4789 "not enabled for port %d\n", port_id);
4790 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4791 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4792 "not enabled for port %d\n", port_id);
4793 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4794 printf("Warning: IP TUNNEL TSO not supported therefore "
4795 "not enabled for port %d\n", port_id);
4796 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4797 printf("Warning: UDP TUNNEL TSO not supported therefore "
4798 "not enabled for port %d\n", port_id);
4803 cmd_tunnel_tso_set_parsed(void *parsed_result,
4804 __attribute__((unused)) struct cmdline *cl,
4805 __attribute__((unused)) void *data)
4807 struct cmd_tunnel_tso_set_result *res = parsed_result;
4808 struct rte_eth_dev_info dev_info;
4810 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4812 if (!port_is_stopped(res->port_id)) {
4813 printf("Please stop port %d first\n", res->port_id);
4817 if (!strcmp(res->mode, "set"))
4818 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4820 dev_info = check_tunnel_tso_nic_support(res->port_id);
4821 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4822 ports[res->port_id].dev_conf.txmode.offloads &=
4823 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4824 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4825 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4826 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4827 DEV_TX_OFFLOAD_IP_TNL_TSO |
4828 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4829 printf("TSO for tunneled packets is disabled\n");
4831 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4832 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4833 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4834 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4835 DEV_TX_OFFLOAD_IP_TNL_TSO |
4836 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4838 ports[res->port_id].dev_conf.txmode.offloads |=
4839 (tso_offloads & dev_info.tx_offload_capa);
4840 printf("TSO segment size for tunneled packets is %d\n",
4841 ports[res->port_id].tunnel_tso_segsz);
4843 /* Below conditions are needed to make it work:
4844 * (1) tunnel TSO is supported by the NIC;
4845 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4847 * (3) for tunneled pkts with outer L3 of IPv4,
4848 * "csum set outer-ip" must be set to hw, because after tso,
4849 * total_len of outer IP header is changed, and the checksum
4850 * of outer IP header calculated by sw should be wrong; that
4851 * is not necessary for IPv6 tunneled pkts because there's no
4852 * checksum in IP header anymore.
4855 if (!ports[res->port_id].parse_tunnel)
4856 printf("Warning: csum parse_tunnel must be set "
4857 "so that tunneled packets are recognized\n");
4858 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4859 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4860 printf("Warning: csum set outer-ip must be set to hw "
4861 "if outer L3 is IPv4; not necessary for IPv6\n");
4864 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4865 cmd_reconfig_device_queue(res->port_id, 1, 1);
4868 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4869 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4871 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4872 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4874 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4875 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4877 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4878 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4881 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4882 .f = cmd_tunnel_tso_set_parsed,
4884 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4885 "Set TSO segment size of tunneled packets for csum engine "
4888 (void *)&cmd_tunnel_tso_set_tso,
4889 (void *)&cmd_tunnel_tso_set_mode,
4890 (void *)&cmd_tunnel_tso_set_tso_segsz,
4891 (void *)&cmd_tunnel_tso_set_portid,
4896 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4897 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4901 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4902 .f = cmd_tunnel_tso_set_parsed,
4904 .help_str = "tunnel_tso show <port_id> "
4905 "Show TSO segment size of tunneled packets for csum engine",
4907 (void *)&cmd_tunnel_tso_set_tso,
4908 (void *)&cmd_tunnel_tso_show_mode,
4909 (void *)&cmd_tunnel_tso_set_portid,
4914 /* *** SET GRO FOR A PORT *** */
4915 struct cmd_gro_enable_result {
4916 cmdline_fixed_string_t cmd_set;
4917 cmdline_fixed_string_t cmd_port;
4918 cmdline_fixed_string_t cmd_keyword;
4919 cmdline_fixed_string_t cmd_onoff;
4924 cmd_gro_enable_parsed(void *parsed_result,
4925 __attribute__((unused)) struct cmdline *cl,
4926 __attribute__((unused)) void *data)
4928 struct cmd_gro_enable_result *res;
4930 res = parsed_result;
4931 if (!strcmp(res->cmd_keyword, "gro"))
4932 setup_gro(res->cmd_onoff, res->cmd_pid);
4935 cmdline_parse_token_string_t cmd_gro_enable_set =
4936 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4938 cmdline_parse_token_string_t cmd_gro_enable_port =
4939 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4940 cmd_keyword, "port");
4941 cmdline_parse_token_num_t cmd_gro_enable_pid =
4942 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4944 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4945 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4946 cmd_keyword, "gro");
4947 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4948 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4949 cmd_onoff, "on#off");
4951 cmdline_parse_inst_t cmd_gro_enable = {
4952 .f = cmd_gro_enable_parsed,
4954 .help_str = "set port <port_id> gro on|off",
4956 (void *)&cmd_gro_enable_set,
4957 (void *)&cmd_gro_enable_port,
4958 (void *)&cmd_gro_enable_pid,
4959 (void *)&cmd_gro_enable_keyword,
4960 (void *)&cmd_gro_enable_onoff,
4965 /* *** DISPLAY GRO CONFIGURATION *** */
4966 struct cmd_gro_show_result {
4967 cmdline_fixed_string_t cmd_show;
4968 cmdline_fixed_string_t cmd_port;
4969 cmdline_fixed_string_t cmd_keyword;
4974 cmd_gro_show_parsed(void *parsed_result,
4975 __attribute__((unused)) struct cmdline *cl,
4976 __attribute__((unused)) void *data)
4978 struct cmd_gro_show_result *res;
4980 res = parsed_result;
4981 if (!strcmp(res->cmd_keyword, "gro"))
4982 show_gro(res->cmd_pid);
4985 cmdline_parse_token_string_t cmd_gro_show_show =
4986 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4988 cmdline_parse_token_string_t cmd_gro_show_port =
4989 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4991 cmdline_parse_token_num_t cmd_gro_show_pid =
4992 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4994 cmdline_parse_token_string_t cmd_gro_show_keyword =
4995 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4996 cmd_keyword, "gro");
4998 cmdline_parse_inst_t cmd_gro_show = {
4999 .f = cmd_gro_show_parsed,
5001 .help_str = "show port <port_id> gro",
5003 (void *)&cmd_gro_show_show,
5004 (void *)&cmd_gro_show_port,
5005 (void *)&cmd_gro_show_pid,
5006 (void *)&cmd_gro_show_keyword,
5011 /* *** SET FLUSH CYCLES FOR GRO *** */
5012 struct cmd_gro_flush_result {
5013 cmdline_fixed_string_t cmd_set;
5014 cmdline_fixed_string_t cmd_keyword;
5015 cmdline_fixed_string_t cmd_flush;
5020 cmd_gro_flush_parsed(void *parsed_result,
5021 __attribute__((unused)) struct cmdline *cl,
5022 __attribute__((unused)) void *data)
5024 struct cmd_gro_flush_result *res;
5026 res = parsed_result;
5027 if ((!strcmp(res->cmd_keyword, "gro")) &&
5028 (!strcmp(res->cmd_flush, "flush")))
5029 setup_gro_flush_cycles(res->cmd_cycles);
5032 cmdline_parse_token_string_t cmd_gro_flush_set =
5033 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5035 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5036 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5037 cmd_keyword, "gro");
5038 cmdline_parse_token_string_t cmd_gro_flush_flush =
5039 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5040 cmd_flush, "flush");
5041 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5042 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5045 cmdline_parse_inst_t cmd_gro_flush = {
5046 .f = cmd_gro_flush_parsed,
5048 .help_str = "set gro flush <cycles>",
5050 (void *)&cmd_gro_flush_set,
5051 (void *)&cmd_gro_flush_keyword,
5052 (void *)&cmd_gro_flush_flush,
5053 (void *)&cmd_gro_flush_cycles,
5058 /* *** ENABLE/DISABLE GSO *** */
5059 struct cmd_gso_enable_result {
5060 cmdline_fixed_string_t cmd_set;
5061 cmdline_fixed_string_t cmd_port;
5062 cmdline_fixed_string_t cmd_keyword;
5063 cmdline_fixed_string_t cmd_mode;
5068 cmd_gso_enable_parsed(void *parsed_result,
5069 __attribute__((unused)) struct cmdline *cl,
5070 __attribute__((unused)) void *data)
5072 struct cmd_gso_enable_result *res;
5074 res = parsed_result;
5075 if (!strcmp(res->cmd_keyword, "gso"))
5076 setup_gso(res->cmd_mode, res->cmd_pid);
5079 cmdline_parse_token_string_t cmd_gso_enable_set =
5080 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5082 cmdline_parse_token_string_t cmd_gso_enable_port =
5083 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5085 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5086 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5087 cmd_keyword, "gso");
5088 cmdline_parse_token_string_t cmd_gso_enable_mode =
5089 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5090 cmd_mode, "on#off");
5091 cmdline_parse_token_num_t cmd_gso_enable_pid =
5092 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5095 cmdline_parse_inst_t cmd_gso_enable = {
5096 .f = cmd_gso_enable_parsed,
5098 .help_str = "set port <port_id> gso on|off",
5100 (void *)&cmd_gso_enable_set,
5101 (void *)&cmd_gso_enable_port,
5102 (void *)&cmd_gso_enable_pid,
5103 (void *)&cmd_gso_enable_keyword,
5104 (void *)&cmd_gso_enable_mode,
5109 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5110 struct cmd_gso_size_result {
5111 cmdline_fixed_string_t cmd_set;
5112 cmdline_fixed_string_t cmd_keyword;
5113 cmdline_fixed_string_t cmd_segsz;
5118 cmd_gso_size_parsed(void *parsed_result,
5119 __attribute__((unused)) struct cmdline *cl,
5120 __attribute__((unused)) void *data)
5122 struct cmd_gso_size_result *res = parsed_result;
5124 if (test_done == 0) {
5125 printf("Before setting GSO segsz, please first"
5126 " stop fowarding\n");
5130 if (!strcmp(res->cmd_keyword, "gso") &&
5131 !strcmp(res->cmd_segsz, "segsz")) {
5132 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5133 printf("gso_size should be larger than %zu."
5134 " Please input a legal value\n",
5135 RTE_GSO_SEG_SIZE_MIN);
5137 gso_max_segment_size = res->cmd_size;
5141 cmdline_parse_token_string_t cmd_gso_size_set =
5142 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5144 cmdline_parse_token_string_t cmd_gso_size_keyword =
5145 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5146 cmd_keyword, "gso");
5147 cmdline_parse_token_string_t cmd_gso_size_segsz =
5148 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5149 cmd_segsz, "segsz");
5150 cmdline_parse_token_num_t cmd_gso_size_size =
5151 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5154 cmdline_parse_inst_t cmd_gso_size = {
5155 .f = cmd_gso_size_parsed,
5157 .help_str = "set gso segsz <length>",
5159 (void *)&cmd_gso_size_set,
5160 (void *)&cmd_gso_size_keyword,
5161 (void *)&cmd_gso_size_segsz,
5162 (void *)&cmd_gso_size_size,
5167 /* *** SHOW GSO CONFIGURATION *** */
5168 struct cmd_gso_show_result {
5169 cmdline_fixed_string_t cmd_show;
5170 cmdline_fixed_string_t cmd_port;
5171 cmdline_fixed_string_t cmd_keyword;
5176 cmd_gso_show_parsed(void *parsed_result,
5177 __attribute__((unused)) struct cmdline *cl,
5178 __attribute__((unused)) void *data)
5180 struct cmd_gso_show_result *res = parsed_result;
5182 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5183 printf("invalid port id %u\n", res->cmd_pid);
5186 if (!strcmp(res->cmd_keyword, "gso")) {
5187 if (gso_ports[res->cmd_pid].enable) {
5188 printf("Max GSO'd packet size: %uB\n"
5189 "Supported GSO types: TCP/IPv4, "
5190 "UDP/IPv4, VxLAN with inner "
5191 "TCP/IPv4 packet, GRE with inner "
5192 "TCP/IPv4 packet\n",
5193 gso_max_segment_size);
5195 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5199 cmdline_parse_token_string_t cmd_gso_show_show =
5200 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5202 cmdline_parse_token_string_t cmd_gso_show_port =
5203 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5205 cmdline_parse_token_string_t cmd_gso_show_keyword =
5206 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5207 cmd_keyword, "gso");
5208 cmdline_parse_token_num_t cmd_gso_show_pid =
5209 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5212 cmdline_parse_inst_t cmd_gso_show = {
5213 .f = cmd_gso_show_parsed,
5215 .help_str = "show port <port_id> gso",
5217 (void *)&cmd_gso_show_show,
5218 (void *)&cmd_gso_show_port,
5219 (void *)&cmd_gso_show_pid,
5220 (void *)&cmd_gso_show_keyword,
5225 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5226 struct cmd_set_flush_rx {
5227 cmdline_fixed_string_t set;
5228 cmdline_fixed_string_t flush_rx;
5229 cmdline_fixed_string_t mode;
5233 cmd_set_flush_rx_parsed(void *parsed_result,
5234 __attribute__((unused)) struct cmdline *cl,
5235 __attribute__((unused)) void *data)
5237 struct cmd_set_flush_rx *res = parsed_result;
5238 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5241 cmdline_parse_token_string_t cmd_setflushrx_set =
5242 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5244 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5245 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5246 flush_rx, "flush_rx");
5247 cmdline_parse_token_string_t cmd_setflushrx_mode =
5248 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5252 cmdline_parse_inst_t cmd_set_flush_rx = {
5253 .f = cmd_set_flush_rx_parsed,
5254 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5257 (void *)&cmd_setflushrx_set,
5258 (void *)&cmd_setflushrx_flush_rx,
5259 (void *)&cmd_setflushrx_mode,
5264 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5265 struct cmd_set_link_check {
5266 cmdline_fixed_string_t set;
5267 cmdline_fixed_string_t link_check;
5268 cmdline_fixed_string_t mode;
5272 cmd_set_link_check_parsed(void *parsed_result,
5273 __attribute__((unused)) struct cmdline *cl,
5274 __attribute__((unused)) void *data)
5276 struct cmd_set_link_check *res = parsed_result;
5277 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5280 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5281 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5283 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5284 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5285 link_check, "link_check");
5286 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5287 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5291 cmdline_parse_inst_t cmd_set_link_check = {
5292 .f = cmd_set_link_check_parsed,
5293 .help_str = "set link_check on|off: Enable/Disable link status check "
5294 "when starting/stopping a port",
5297 (void *)&cmd_setlinkcheck_set,
5298 (void *)&cmd_setlinkcheck_link_check,
5299 (void *)&cmd_setlinkcheck_mode,
5304 /* *** SET NIC BYPASS MODE *** */
5305 struct cmd_set_bypass_mode_result {
5306 cmdline_fixed_string_t set;
5307 cmdline_fixed_string_t bypass;
5308 cmdline_fixed_string_t mode;
5309 cmdline_fixed_string_t value;
5314 cmd_set_bypass_mode_parsed(void *parsed_result,
5315 __attribute__((unused)) struct cmdline *cl,
5316 __attribute__((unused)) void *data)
5318 struct cmd_set_bypass_mode_result *res = parsed_result;
5319 portid_t port_id = res->port_id;
5320 int32_t rc = -EINVAL;
5322 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5323 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5325 if (!strcmp(res->value, "bypass"))
5326 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5327 else if (!strcmp(res->value, "isolate"))
5328 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5330 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5332 /* Set the bypass mode for the relevant port. */
5333 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5336 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5339 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5340 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5342 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5343 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5345 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5346 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5348 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5349 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5350 value, "normal#bypass#isolate");
5351 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5352 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5355 cmdline_parse_inst_t cmd_set_bypass_mode = {
5356 .f = cmd_set_bypass_mode_parsed,
5357 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5358 "Set the NIC bypass mode for port_id",
5361 (void *)&cmd_setbypass_mode_set,
5362 (void *)&cmd_setbypass_mode_bypass,
5363 (void *)&cmd_setbypass_mode_mode,
5364 (void *)&cmd_setbypass_mode_value,
5365 (void *)&cmd_setbypass_mode_port,
5370 /* *** SET NIC BYPASS EVENT *** */
5371 struct cmd_set_bypass_event_result {
5372 cmdline_fixed_string_t set;
5373 cmdline_fixed_string_t bypass;
5374 cmdline_fixed_string_t event;
5375 cmdline_fixed_string_t event_value;
5376 cmdline_fixed_string_t mode;
5377 cmdline_fixed_string_t mode_value;
5382 cmd_set_bypass_event_parsed(void *parsed_result,
5383 __attribute__((unused)) struct cmdline *cl,
5384 __attribute__((unused)) void *data)
5386 int32_t rc = -EINVAL;
5387 struct cmd_set_bypass_event_result *res = parsed_result;
5388 portid_t port_id = res->port_id;
5390 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5391 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5392 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5394 if (!strcmp(res->event_value, "timeout"))
5395 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5396 else if (!strcmp(res->event_value, "os_on"))
5397 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5398 else if (!strcmp(res->event_value, "os_off"))
5399 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5400 else if (!strcmp(res->event_value, "power_on"))
5401 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5402 else if (!strcmp(res->event_value, "power_off"))
5403 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5405 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5407 if (!strcmp(res->mode_value, "bypass"))
5408 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5409 else if (!strcmp(res->mode_value, "isolate"))
5410 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5412 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5414 /* Set the watchdog timeout. */
5415 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5418 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5419 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5423 printf("Failed to set timeout value %u "
5424 "for port %d, errto code: %d.\n",
5425 bypass_timeout, port_id, rc);
5429 /* Set the bypass event to transition to bypass mode. */
5430 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5435 printf("\t Failed to set bypass event for port = %d.\n",
5439 cmdline_parse_token_string_t cmd_setbypass_event_set =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5442 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5445 cmdline_parse_token_string_t cmd_setbypass_event_event =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5448 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5450 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5451 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5454 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5455 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5456 mode_value, "normal#bypass#isolate");
5457 cmdline_parse_token_num_t cmd_setbypass_event_port =
5458 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5461 cmdline_parse_inst_t cmd_set_bypass_event = {
5462 .f = cmd_set_bypass_event_parsed,
5463 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5464 "power_off mode normal|bypass|isolate <port_id>: "
5465 "Set the NIC bypass event mode for port_id",
5468 (void *)&cmd_setbypass_event_set,
5469 (void *)&cmd_setbypass_event_bypass,
5470 (void *)&cmd_setbypass_event_event,
5471 (void *)&cmd_setbypass_event_event_value,
5472 (void *)&cmd_setbypass_event_mode,
5473 (void *)&cmd_setbypass_event_mode_value,
5474 (void *)&cmd_setbypass_event_port,
5480 /* *** SET NIC BYPASS TIMEOUT *** */
5481 struct cmd_set_bypass_timeout_result {
5482 cmdline_fixed_string_t set;
5483 cmdline_fixed_string_t bypass;
5484 cmdline_fixed_string_t timeout;
5485 cmdline_fixed_string_t value;
5489 cmd_set_bypass_timeout_parsed(void *parsed_result,
5490 __attribute__((unused)) struct cmdline *cl,
5491 __attribute__((unused)) void *data)
5493 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5495 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5496 if (!strcmp(res->value, "1.5"))
5497 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5498 else if (!strcmp(res->value, "2"))
5499 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5500 else if (!strcmp(res->value, "3"))
5501 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5502 else if (!strcmp(res->value, "4"))
5503 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5504 else if (!strcmp(res->value, "8"))
5505 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5506 else if (!strcmp(res->value, "16"))
5507 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5508 else if (!strcmp(res->value, "32"))
5509 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5511 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5515 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5516 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5518 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5519 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5521 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5522 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5523 timeout, "timeout");
5524 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5525 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5526 value, "0#1.5#2#3#4#8#16#32");
5528 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5529 .f = cmd_set_bypass_timeout_parsed,
5530 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5531 "Set the NIC bypass watchdog timeout in seconds",
5534 (void *)&cmd_setbypass_timeout_set,
5535 (void *)&cmd_setbypass_timeout_bypass,
5536 (void *)&cmd_setbypass_timeout_timeout,
5537 (void *)&cmd_setbypass_timeout_value,
5542 /* *** SHOW NIC BYPASS MODE *** */
5543 struct cmd_show_bypass_config_result {
5544 cmdline_fixed_string_t show;
5545 cmdline_fixed_string_t bypass;
5546 cmdline_fixed_string_t config;
5551 cmd_show_bypass_config_parsed(void *parsed_result,
5552 __attribute__((unused)) struct cmdline *cl,
5553 __attribute__((unused)) void *data)
5555 struct cmd_show_bypass_config_result *res = parsed_result;
5556 portid_t port_id = res->port_id;
5558 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5559 uint32_t event_mode;
5560 uint32_t bypass_mode;
5561 uint32_t timeout = bypass_timeout;
5564 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5565 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5566 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5567 {"UNKNOWN", "normal", "bypass", "isolate"};
5568 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5575 int num_events = (sizeof events) / (sizeof events[0]);
5577 /* Display the bypass mode.*/
5578 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5579 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5583 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5584 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5586 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5589 /* Display the bypass timeout.*/
5590 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5591 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5593 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5595 /* Display the bypass events and associated modes. */
5596 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5598 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5599 printf("\tFailed to get bypass mode for event = %s\n",
5602 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5603 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5605 printf("\tbypass event: %-16s = %s\n", events[i],
5611 printf("\tFailed to get bypass configuration for port = %d\n",
5615 cmdline_parse_token_string_t cmd_showbypass_config_show =
5616 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5618 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5619 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5621 cmdline_parse_token_string_t cmd_showbypass_config_config =
5622 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5624 cmdline_parse_token_num_t cmd_showbypass_config_port =
5625 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5628 cmdline_parse_inst_t cmd_show_bypass_config = {
5629 .f = cmd_show_bypass_config_parsed,
5630 .help_str = "show bypass config <port_id>: "
5631 "Show the NIC bypass config for port_id",
5634 (void *)&cmd_showbypass_config_show,
5635 (void *)&cmd_showbypass_config_bypass,
5636 (void *)&cmd_showbypass_config_config,
5637 (void *)&cmd_showbypass_config_port,
5642 #ifdef RTE_LIBRTE_PMD_BOND
5643 /* *** SET BONDING MODE *** */
5644 struct cmd_set_bonding_mode_result {
5645 cmdline_fixed_string_t set;
5646 cmdline_fixed_string_t bonding;
5647 cmdline_fixed_string_t mode;
5652 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5653 __attribute__((unused)) struct cmdline *cl,
5654 __attribute__((unused)) void *data)
5656 struct cmd_set_bonding_mode_result *res = parsed_result;
5657 portid_t port_id = res->port_id;
5659 /* Set the bonding mode for the relevant port. */
5660 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5661 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5664 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5665 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5667 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5668 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5669 bonding, "bonding");
5670 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5673 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5674 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5676 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5677 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5680 cmdline_parse_inst_t cmd_set_bonding_mode = {
5681 .f = cmd_set_bonding_mode_parsed,
5682 .help_str = "set bonding mode <mode_value> <port_id>: "
5683 "Set the bonding mode for port_id",
5686 (void *) &cmd_setbonding_mode_set,
5687 (void *) &cmd_setbonding_mode_bonding,
5688 (void *) &cmd_setbonding_mode_mode,
5689 (void *) &cmd_setbonding_mode_value,
5690 (void *) &cmd_setbonding_mode_port,
5695 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5696 struct cmd_set_bonding_lacp_dedicated_queues_result {
5697 cmdline_fixed_string_t set;
5698 cmdline_fixed_string_t bonding;
5699 cmdline_fixed_string_t lacp;
5700 cmdline_fixed_string_t dedicated_queues;
5702 cmdline_fixed_string_t mode;
5705 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5706 __attribute__((unused)) struct cmdline *cl,
5707 __attribute__((unused)) void *data)
5709 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5710 portid_t port_id = res->port_id;
5711 struct rte_port *port;
5713 port = &ports[port_id];
5715 /** Check if the port is not started **/
5716 if (port->port_status != RTE_PORT_STOPPED) {
5717 printf("Please stop port %d first\n", port_id);
5721 if (!strcmp(res->mode, "enable")) {
5722 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5723 printf("Dedicate queues for LACP control packets"
5726 printf("Enabling dedicate queues for LACP control "
5727 "packets on port %d failed\n", port_id);
5728 } else if (!strcmp(res->mode, "disable")) {
5729 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5730 printf("Dedicated queues for LACP control packets "
5733 printf("Disabling dedicated queues for LACP control "
5734 "traffic on port %d failed\n", port_id);
5738 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5739 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5741 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5742 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5743 bonding, "bonding");
5744 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5747 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5748 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5749 dedicated_queues, "dedicated_queues");
5750 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5751 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5753 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5754 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5755 mode, "enable#disable");
5757 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5758 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5759 .help_str = "set bonding lacp dedicated_queues <port_id> "
5761 "Enable/disable dedicated queues for LACP control traffic for port_id",
5764 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5765 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5766 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5767 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5768 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5769 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5774 /* *** SET BALANCE XMIT POLICY *** */
5775 struct cmd_set_bonding_balance_xmit_policy_result {
5776 cmdline_fixed_string_t set;
5777 cmdline_fixed_string_t bonding;
5778 cmdline_fixed_string_t balance_xmit_policy;
5780 cmdline_fixed_string_t policy;
5783 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5784 __attribute__((unused)) struct cmdline *cl,
5785 __attribute__((unused)) void *data)
5787 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5788 portid_t port_id = res->port_id;
5791 if (!strcmp(res->policy, "l2")) {
5792 policy = BALANCE_XMIT_POLICY_LAYER2;
5793 } else if (!strcmp(res->policy, "l23")) {
5794 policy = BALANCE_XMIT_POLICY_LAYER23;
5795 } else if (!strcmp(res->policy, "l34")) {
5796 policy = BALANCE_XMIT_POLICY_LAYER34;
5798 printf("\t Invalid xmit policy selection");
5802 /* Set the bonding mode for the relevant port. */
5803 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5804 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5809 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5810 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5812 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5813 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5814 bonding, "bonding");
5815 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5816 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5817 balance_xmit_policy, "balance_xmit_policy");
5818 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5819 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5821 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5822 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5823 policy, "l2#l23#l34");
5825 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5826 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5827 .help_str = "set bonding balance_xmit_policy <port_id> "
5829 "Set the bonding balance_xmit_policy for port_id",
5832 (void *)&cmd_setbonding_balance_xmit_policy_set,
5833 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5834 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5835 (void *)&cmd_setbonding_balance_xmit_policy_port,
5836 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5841 /* *** SHOW NIC BONDING CONFIGURATION *** */
5842 struct cmd_show_bonding_config_result {
5843 cmdline_fixed_string_t show;
5844 cmdline_fixed_string_t bonding;
5845 cmdline_fixed_string_t config;
5849 static void cmd_show_bonding_config_parsed(void *parsed_result,
5850 __attribute__((unused)) struct cmdline *cl,
5851 __attribute__((unused)) void *data)
5853 struct cmd_show_bonding_config_result *res = parsed_result;
5854 int bonding_mode, agg_mode;
5855 portid_t slaves[RTE_MAX_ETHPORTS];
5856 int num_slaves, num_active_slaves;
5859 portid_t port_id = res->port_id;
5861 /* Display the bonding mode.*/
5862 bonding_mode = rte_eth_bond_mode_get(port_id);
5863 if (bonding_mode < 0) {
5864 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5867 printf("\tBonding mode: %d\n", bonding_mode);
5869 if (bonding_mode == BONDING_MODE_BALANCE) {
5870 int balance_xmit_policy;
5872 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5873 if (balance_xmit_policy < 0) {
5874 printf("\tFailed to get balance xmit policy for port = %d\n",
5878 printf("\tBalance Xmit Policy: ");
5880 switch (balance_xmit_policy) {
5881 case BALANCE_XMIT_POLICY_LAYER2:
5882 printf("BALANCE_XMIT_POLICY_LAYER2");
5884 case BALANCE_XMIT_POLICY_LAYER23:
5885 printf("BALANCE_XMIT_POLICY_LAYER23");
5887 case BALANCE_XMIT_POLICY_LAYER34:
5888 printf("BALANCE_XMIT_POLICY_LAYER34");
5895 if (bonding_mode == BONDING_MODE_8023AD) {
5896 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5897 printf("\tIEEE802.3AD Aggregator Mode: ");
5900 printf("bandwidth");
5912 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5914 if (num_slaves < 0) {
5915 printf("\tFailed to get slave list for port = %d\n", port_id);
5918 if (num_slaves > 0) {
5919 printf("\tSlaves (%d): [", num_slaves);
5920 for (i = 0; i < num_slaves - 1; i++)
5921 printf("%d ", slaves[i]);
5923 printf("%d]\n", slaves[num_slaves - 1]);
5925 printf("\tSlaves: []\n");
5929 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5932 if (num_active_slaves < 0) {
5933 printf("\tFailed to get active slave list for port = %d\n", port_id);
5936 if (num_active_slaves > 0) {
5937 printf("\tActive Slaves (%d): [", num_active_slaves);
5938 for (i = 0; i < num_active_slaves - 1; i++)
5939 printf("%d ", slaves[i]);
5941 printf("%d]\n", slaves[num_active_slaves - 1]);
5944 printf("\tActive Slaves: []\n");
5948 primary_id = rte_eth_bond_primary_get(port_id);
5949 if (primary_id < 0) {
5950 printf("\tFailed to get primary slave for port = %d\n", port_id);
5953 printf("\tPrimary: [%d]\n", primary_id);
5957 cmdline_parse_token_string_t cmd_showbonding_config_show =
5958 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5960 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5961 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5962 bonding, "bonding");
5963 cmdline_parse_token_string_t cmd_showbonding_config_config =
5964 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5966 cmdline_parse_token_num_t cmd_showbonding_config_port =
5967 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5970 cmdline_parse_inst_t cmd_show_bonding_config = {
5971 .f = cmd_show_bonding_config_parsed,
5972 .help_str = "show bonding config <port_id>: "
5973 "Show the bonding config for port_id",
5976 (void *)&cmd_showbonding_config_show,
5977 (void *)&cmd_showbonding_config_bonding,
5978 (void *)&cmd_showbonding_config_config,
5979 (void *)&cmd_showbonding_config_port,
5984 /* *** SET BONDING PRIMARY *** */
5985 struct cmd_set_bonding_primary_result {
5986 cmdline_fixed_string_t set;
5987 cmdline_fixed_string_t bonding;
5988 cmdline_fixed_string_t primary;
5993 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5994 __attribute__((unused)) struct cmdline *cl,
5995 __attribute__((unused)) void *data)
5997 struct cmd_set_bonding_primary_result *res = parsed_result;
5998 portid_t master_port_id = res->port_id;
5999 portid_t slave_port_id = res->slave_id;
6001 /* Set the primary slave for a bonded device. */
6002 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6003 printf("\t Failed to set primary slave for port = %d.\n",
6010 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6011 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6013 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6014 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6015 bonding, "bonding");
6016 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6017 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6018 primary, "primary");
6019 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6020 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6022 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6023 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6026 cmdline_parse_inst_t cmd_set_bonding_primary = {
6027 .f = cmd_set_bonding_primary_parsed,
6028 .help_str = "set bonding primary <slave_id> <port_id>: "
6029 "Set the primary slave for port_id",
6032 (void *)&cmd_setbonding_primary_set,
6033 (void *)&cmd_setbonding_primary_bonding,
6034 (void *)&cmd_setbonding_primary_primary,
6035 (void *)&cmd_setbonding_primary_slave,
6036 (void *)&cmd_setbonding_primary_port,
6041 /* *** ADD SLAVE *** */
6042 struct cmd_add_bonding_slave_result {
6043 cmdline_fixed_string_t add;
6044 cmdline_fixed_string_t bonding;
6045 cmdline_fixed_string_t slave;
6050 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6051 __attribute__((unused)) struct cmdline *cl,
6052 __attribute__((unused)) void *data)
6054 struct cmd_add_bonding_slave_result *res = parsed_result;
6055 portid_t master_port_id = res->port_id;
6056 portid_t slave_port_id = res->slave_id;
6058 /* add the slave for a bonded device. */
6059 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6060 printf("\t Failed to add slave %d to master port = %d.\n",
6061 slave_port_id, master_port_id);
6065 set_port_slave_flag(slave_port_id);
6068 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6069 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6071 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6072 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6073 bonding, "bonding");
6074 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6075 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6077 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6078 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6080 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6081 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6084 cmdline_parse_inst_t cmd_add_bonding_slave = {
6085 .f = cmd_add_bonding_slave_parsed,
6086 .help_str = "add bonding slave <slave_id> <port_id>: "
6087 "Add a slave device to a bonded device",
6090 (void *)&cmd_addbonding_slave_add,
6091 (void *)&cmd_addbonding_slave_bonding,
6092 (void *)&cmd_addbonding_slave_slave,
6093 (void *)&cmd_addbonding_slave_slaveid,
6094 (void *)&cmd_addbonding_slave_port,
6099 /* *** REMOVE SLAVE *** */
6100 struct cmd_remove_bonding_slave_result {
6101 cmdline_fixed_string_t remove;
6102 cmdline_fixed_string_t bonding;
6103 cmdline_fixed_string_t slave;
6108 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6109 __attribute__((unused)) struct cmdline *cl,
6110 __attribute__((unused)) void *data)
6112 struct cmd_remove_bonding_slave_result *res = parsed_result;
6113 portid_t master_port_id = res->port_id;
6114 portid_t slave_port_id = res->slave_id;
6116 /* remove the slave from a bonded device. */
6117 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6118 printf("\t Failed to remove slave %d from master port = %d.\n",
6119 slave_port_id, master_port_id);
6123 clear_port_slave_flag(slave_port_id);
6126 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6127 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6129 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6130 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6131 bonding, "bonding");
6132 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6133 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6135 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6136 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6138 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6139 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6142 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6143 .f = cmd_remove_bonding_slave_parsed,
6144 .help_str = "remove bonding slave <slave_id> <port_id>: "
6145 "Remove a slave device from a bonded device",
6148 (void *)&cmd_removebonding_slave_remove,
6149 (void *)&cmd_removebonding_slave_bonding,
6150 (void *)&cmd_removebonding_slave_slave,
6151 (void *)&cmd_removebonding_slave_slaveid,
6152 (void *)&cmd_removebonding_slave_port,
6157 /* *** CREATE BONDED DEVICE *** */
6158 struct cmd_create_bonded_device_result {
6159 cmdline_fixed_string_t create;
6160 cmdline_fixed_string_t bonded;
6161 cmdline_fixed_string_t device;
6166 static int bond_dev_num = 0;
6168 static void cmd_create_bonded_device_parsed(void *parsed_result,
6169 __attribute__((unused)) struct cmdline *cl,
6170 __attribute__((unused)) void *data)
6172 struct cmd_create_bonded_device_result *res = parsed_result;
6173 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6177 if (test_done == 0) {
6178 printf("Please stop forwarding first\n");
6182 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6185 /* Create a new bonded device. */
6186 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6188 printf("\t Failed to create bonded device.\n");
6191 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6194 /* Update number of ports */
6195 nb_ports = rte_eth_dev_count_avail();
6196 reconfig(port_id, res->socket);
6197 ret = rte_eth_promiscuous_enable(port_id);
6199 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6200 port_id, rte_strerror(-ret));
6202 ports[port_id].need_setup = 0;
6203 ports[port_id].port_status = RTE_PORT_STOPPED;
6208 cmdline_parse_token_string_t cmd_createbonded_device_create =
6209 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6211 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6212 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6214 cmdline_parse_token_string_t cmd_createbonded_device_device =
6215 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6217 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6218 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6220 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6221 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6224 cmdline_parse_inst_t cmd_create_bonded_device = {
6225 .f = cmd_create_bonded_device_parsed,
6226 .help_str = "create bonded device <mode> <socket>: "
6227 "Create a new bonded device with specific bonding mode and socket",
6230 (void *)&cmd_createbonded_device_create,
6231 (void *)&cmd_createbonded_device_bonded,
6232 (void *)&cmd_createbonded_device_device,
6233 (void *)&cmd_createbonded_device_mode,
6234 (void *)&cmd_createbonded_device_socket,
6239 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6240 struct cmd_set_bond_mac_addr_result {
6241 cmdline_fixed_string_t set;
6242 cmdline_fixed_string_t bonding;
6243 cmdline_fixed_string_t mac_addr;
6245 struct rte_ether_addr address;
6248 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6249 __attribute__((unused)) struct cmdline *cl,
6250 __attribute__((unused)) void *data)
6252 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6255 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6258 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6260 /* check the return value and print it if is < 0 */
6262 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6265 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6266 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6267 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6268 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6270 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6271 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6273 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6274 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6276 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6277 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6279 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6280 .f = cmd_set_bond_mac_addr_parsed,
6282 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6284 (void *)&cmd_set_bond_mac_addr_set,
6285 (void *)&cmd_set_bond_mac_addr_bonding,
6286 (void *)&cmd_set_bond_mac_addr_mac,
6287 (void *)&cmd_set_bond_mac_addr_portnum,
6288 (void *)&cmd_set_bond_mac_addr_addr,
6294 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6295 struct cmd_set_bond_mon_period_result {
6296 cmdline_fixed_string_t set;
6297 cmdline_fixed_string_t bonding;
6298 cmdline_fixed_string_t mon_period;
6303 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6304 __attribute__((unused)) struct cmdline *cl,
6305 __attribute__((unused)) void *data)
6307 struct cmd_set_bond_mon_period_result *res = parsed_result;
6310 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6312 /* check the return value and print it if is < 0 */
6314 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6317 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6318 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6320 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6321 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6322 bonding, "bonding");
6323 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6324 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6325 mon_period, "mon_period");
6326 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6327 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6329 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6330 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6333 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6334 .f = cmd_set_bond_mon_period_parsed,
6336 .help_str = "set bonding mon_period <port_id> <period_ms>",
6338 (void *)&cmd_set_bond_mon_period_set,
6339 (void *)&cmd_set_bond_mon_period_bonding,
6340 (void *)&cmd_set_bond_mon_period_mon_period,
6341 (void *)&cmd_set_bond_mon_period_portnum,
6342 (void *)&cmd_set_bond_mon_period_period_ms,
6349 struct cmd_set_bonding_agg_mode_policy_result {
6350 cmdline_fixed_string_t set;
6351 cmdline_fixed_string_t bonding;
6352 cmdline_fixed_string_t agg_mode;
6354 cmdline_fixed_string_t policy;
6359 cmd_set_bonding_agg_mode(void *parsed_result,
6360 __attribute__((unused)) struct cmdline *cl,
6361 __attribute__((unused)) void *data)
6363 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6364 uint8_t policy = AGG_BANDWIDTH;
6366 if (!strcmp(res->policy, "bandwidth"))
6367 policy = AGG_BANDWIDTH;
6368 else if (!strcmp(res->policy, "stable"))
6369 policy = AGG_STABLE;
6370 else if (!strcmp(res->policy, "count"))
6373 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6377 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6378 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6380 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6381 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6382 bonding, "bonding");
6384 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6385 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6386 agg_mode, "agg_mode");
6388 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6389 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6392 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6393 TOKEN_STRING_INITIALIZER(
6394 struct cmd_set_bonding_balance_xmit_policy_result,
6395 policy, "stable#bandwidth#count");
6397 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6398 .f = cmd_set_bonding_agg_mode,
6400 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6402 (void *)&cmd_set_bonding_agg_mode_set,
6403 (void *)&cmd_set_bonding_agg_mode_bonding,
6404 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6405 (void *)&cmd_set_bonding_agg_mode_portnum,
6406 (void *)&cmd_set_bonding_agg_mode_policy_string,
6412 #endif /* RTE_LIBRTE_PMD_BOND */
6414 /* *** SET FORWARDING MODE *** */
6415 struct cmd_set_fwd_mode_result {
6416 cmdline_fixed_string_t set;
6417 cmdline_fixed_string_t fwd;
6418 cmdline_fixed_string_t mode;
6421 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6422 __attribute__((unused)) struct cmdline *cl,
6423 __attribute__((unused)) void *data)
6425 struct cmd_set_fwd_mode_result *res = parsed_result;
6428 set_pkt_forwarding_mode(res->mode);
6431 cmdline_parse_token_string_t cmd_setfwd_set =
6432 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6433 cmdline_parse_token_string_t cmd_setfwd_fwd =
6434 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6435 cmdline_parse_token_string_t cmd_setfwd_mode =
6436 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6437 "" /* defined at init */);
6439 cmdline_parse_inst_t cmd_set_fwd_mode = {
6440 .f = cmd_set_fwd_mode_parsed,
6442 .help_str = NULL, /* defined at init */
6444 (void *)&cmd_setfwd_set,
6445 (void *)&cmd_setfwd_fwd,
6446 (void *)&cmd_setfwd_mode,
6451 static void cmd_set_fwd_mode_init(void)
6454 static char token[128];
6455 static char help[256];
6456 cmdline_parse_token_string_t *token_struct;
6458 modes = list_pkt_forwarding_modes();
6459 snprintf(help, sizeof(help), "set fwd %s: "
6460 "Set packet forwarding mode", modes);
6461 cmd_set_fwd_mode.help_str = help;
6463 /* string token separator is # */
6464 for (c = token; *modes != '\0'; modes++)
6469 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6470 token_struct->string_data.str = token;
6473 /* *** SET RETRY FORWARDING MODE *** */
6474 struct cmd_set_fwd_retry_mode_result {
6475 cmdline_fixed_string_t set;
6476 cmdline_fixed_string_t fwd;
6477 cmdline_fixed_string_t mode;
6478 cmdline_fixed_string_t retry;
6481 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6482 __attribute__((unused)) struct cmdline *cl,
6483 __attribute__((unused)) void *data)
6485 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6488 set_pkt_forwarding_mode(res->mode);
6491 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6492 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6494 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6495 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6497 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6498 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6500 "" /* defined at init */);
6501 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6502 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6505 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6506 .f = cmd_set_fwd_retry_mode_parsed,
6508 .help_str = NULL, /* defined at init */
6510 (void *)&cmd_setfwd_retry_set,
6511 (void *)&cmd_setfwd_retry_fwd,
6512 (void *)&cmd_setfwd_retry_mode,
6513 (void *)&cmd_setfwd_retry_retry,
6518 static void cmd_set_fwd_retry_mode_init(void)
6521 static char token[128];
6522 static char help[256];
6523 cmdline_parse_token_string_t *token_struct;
6525 modes = list_pkt_forwarding_retry_modes();
6526 snprintf(help, sizeof(help), "set fwd %s retry: "
6527 "Set packet forwarding mode with retry", modes);
6528 cmd_set_fwd_retry_mode.help_str = help;
6530 /* string token separator is # */
6531 for (c = token; *modes != '\0'; modes++)
6536 token_struct = (cmdline_parse_token_string_t *)
6537 cmd_set_fwd_retry_mode.tokens[2];
6538 token_struct->string_data.str = token;
6541 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6542 struct cmd_set_burst_tx_retry_result {
6543 cmdline_fixed_string_t set;
6544 cmdline_fixed_string_t burst;
6545 cmdline_fixed_string_t tx;
6546 cmdline_fixed_string_t delay;
6548 cmdline_fixed_string_t retry;
6552 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6553 __attribute__((unused)) struct cmdline *cl,
6554 __attribute__((unused)) void *data)
6556 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6558 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6559 && !strcmp(res->tx, "tx")) {
6560 if (!strcmp(res->delay, "delay"))
6561 burst_tx_delay_time = res->time;
6562 if (!strcmp(res->retry, "retry"))
6563 burst_tx_retry_num = res->retry_num;
6568 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6569 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6570 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6571 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6573 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6574 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6575 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6577 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6578 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6579 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6580 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6581 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6582 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6584 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6585 .f = cmd_set_burst_tx_retry_parsed,
6586 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6588 (void *)&cmd_set_burst_tx_retry_set,
6589 (void *)&cmd_set_burst_tx_retry_burst,
6590 (void *)&cmd_set_burst_tx_retry_tx,
6591 (void *)&cmd_set_burst_tx_retry_delay,
6592 (void *)&cmd_set_burst_tx_retry_time,
6593 (void *)&cmd_set_burst_tx_retry_retry,
6594 (void *)&cmd_set_burst_tx_retry_retry_num,
6599 /* *** SET PROMISC MODE *** */
6600 struct cmd_set_promisc_mode_result {
6601 cmdline_fixed_string_t set;
6602 cmdline_fixed_string_t promisc;
6603 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6604 uint16_t port_num; /* valid if "allports" argument == 0 */
6605 cmdline_fixed_string_t mode;
6608 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6609 __attribute__((unused)) struct cmdline *cl,
6612 struct cmd_set_promisc_mode_result *res = parsed_result;
6616 if (!strcmp(res->mode, "on"))
6623 RTE_ETH_FOREACH_DEV(i)
6624 eth_set_promisc_mode(i, enable);
6626 eth_set_promisc_mode(res->port_num, enable);
6630 cmdline_parse_token_string_t cmd_setpromisc_set =
6631 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6632 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6633 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6635 cmdline_parse_token_string_t cmd_setpromisc_portall =
6636 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6638 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6639 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6641 cmdline_parse_token_string_t cmd_setpromisc_mode =
6642 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6645 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6646 .f = cmd_set_promisc_mode_parsed,
6648 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6650 (void *)&cmd_setpromisc_set,
6651 (void *)&cmd_setpromisc_promisc,
6652 (void *)&cmd_setpromisc_portall,
6653 (void *)&cmd_setpromisc_mode,
6658 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6659 .f = cmd_set_promisc_mode_parsed,
6661 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6663 (void *)&cmd_setpromisc_set,
6664 (void *)&cmd_setpromisc_promisc,
6665 (void *)&cmd_setpromisc_portnum,
6666 (void *)&cmd_setpromisc_mode,
6671 /* *** SET ALLMULTI MODE *** */
6672 struct cmd_set_allmulti_mode_result {
6673 cmdline_fixed_string_t set;
6674 cmdline_fixed_string_t allmulti;
6675 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6676 uint16_t port_num; /* valid if "allports" argument == 0 */
6677 cmdline_fixed_string_t mode;
6680 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6681 __attribute__((unused)) struct cmdline *cl,
6684 struct cmd_set_allmulti_mode_result *res = parsed_result;
6688 if (!strcmp(res->mode, "on"))
6695 RTE_ETH_FOREACH_DEV(i) {
6696 eth_set_allmulticast_mode(i, enable);
6700 eth_set_allmulticast_mode(res->port_num, enable);
6704 cmdline_parse_token_string_t cmd_setallmulti_set =
6705 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6706 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6707 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6709 cmdline_parse_token_string_t cmd_setallmulti_portall =
6710 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6712 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6713 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6715 cmdline_parse_token_string_t cmd_setallmulti_mode =
6716 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6719 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6720 .f = cmd_set_allmulti_mode_parsed,
6722 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6724 (void *)&cmd_setallmulti_set,
6725 (void *)&cmd_setallmulti_allmulti,
6726 (void *)&cmd_setallmulti_portall,
6727 (void *)&cmd_setallmulti_mode,
6732 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6733 .f = cmd_set_allmulti_mode_parsed,
6735 .help_str = "set allmulti <port_id> on|off: "
6736 "Set allmulti mode on port_id",
6738 (void *)&cmd_setallmulti_set,
6739 (void *)&cmd_setallmulti_allmulti,
6740 (void *)&cmd_setallmulti_portnum,
6741 (void *)&cmd_setallmulti_mode,
6746 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6747 struct cmd_link_flow_ctrl_set_result {
6748 cmdline_fixed_string_t set;
6749 cmdline_fixed_string_t flow_ctrl;
6750 cmdline_fixed_string_t rx;
6751 cmdline_fixed_string_t rx_lfc_mode;
6752 cmdline_fixed_string_t tx;
6753 cmdline_fixed_string_t tx_lfc_mode;
6754 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6755 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6756 cmdline_fixed_string_t autoneg_str;
6757 cmdline_fixed_string_t autoneg;
6758 cmdline_fixed_string_t hw_str;
6759 uint32_t high_water;
6760 cmdline_fixed_string_t lw_str;
6762 cmdline_fixed_string_t pt_str;
6763 uint16_t pause_time;
6764 cmdline_fixed_string_t xon_str;
6769 cmdline_parse_token_string_t cmd_lfc_set_set =
6770 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6772 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6773 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6774 flow_ctrl, "flow_ctrl");
6775 cmdline_parse_token_string_t cmd_lfc_set_rx =
6776 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6778 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6779 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6780 rx_lfc_mode, "on#off");
6781 cmdline_parse_token_string_t cmd_lfc_set_tx =
6782 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6784 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6785 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6786 tx_lfc_mode, "on#off");
6787 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6788 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6789 hw_str, "high_water");
6790 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6791 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6792 high_water, UINT32);
6793 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6794 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6795 lw_str, "low_water");
6796 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6797 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6799 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6800 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6801 pt_str, "pause_time");
6802 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6803 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6804 pause_time, UINT16);
6805 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6806 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6807 xon_str, "send_xon");
6808 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6809 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6811 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6812 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6813 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6814 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6815 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6816 mac_ctrl_frame_fwd_mode, "on#off");
6817 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6818 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6819 autoneg_str, "autoneg");
6820 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6821 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6823 cmdline_parse_token_num_t cmd_lfc_set_portid =
6824 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6827 /* forward declaration */
6829 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6832 cmdline_parse_inst_t cmd_link_flow_control_set = {
6833 .f = cmd_link_flow_ctrl_set_parsed,
6835 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6836 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6837 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6839 (void *)&cmd_lfc_set_set,
6840 (void *)&cmd_lfc_set_flow_ctrl,
6841 (void *)&cmd_lfc_set_rx,
6842 (void *)&cmd_lfc_set_rx_mode,
6843 (void *)&cmd_lfc_set_tx,
6844 (void *)&cmd_lfc_set_tx_mode,
6845 (void *)&cmd_lfc_set_high_water,
6846 (void *)&cmd_lfc_set_low_water,
6847 (void *)&cmd_lfc_set_pause_time,
6848 (void *)&cmd_lfc_set_send_xon,
6849 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6850 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6851 (void *)&cmd_lfc_set_autoneg_str,
6852 (void *)&cmd_lfc_set_autoneg,
6853 (void *)&cmd_lfc_set_portid,
6858 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6859 .f = cmd_link_flow_ctrl_set_parsed,
6860 .data = (void *)&cmd_link_flow_control_set_rx,
6861 .help_str = "set flow_ctrl rx on|off <port_id>: "
6862 "Change rx flow control parameter",
6864 (void *)&cmd_lfc_set_set,
6865 (void *)&cmd_lfc_set_flow_ctrl,
6866 (void *)&cmd_lfc_set_rx,
6867 (void *)&cmd_lfc_set_rx_mode,
6868 (void *)&cmd_lfc_set_portid,
6873 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6874 .f = cmd_link_flow_ctrl_set_parsed,
6875 .data = (void *)&cmd_link_flow_control_set_tx,
6876 .help_str = "set flow_ctrl tx on|off <port_id>: "
6877 "Change tx flow control parameter",
6879 (void *)&cmd_lfc_set_set,
6880 (void *)&cmd_lfc_set_flow_ctrl,
6881 (void *)&cmd_lfc_set_tx,
6882 (void *)&cmd_lfc_set_tx_mode,
6883 (void *)&cmd_lfc_set_portid,
6888 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6889 .f = cmd_link_flow_ctrl_set_parsed,
6890 .data = (void *)&cmd_link_flow_control_set_hw,
6891 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6892 "Change high water flow control parameter",
6894 (void *)&cmd_lfc_set_set,
6895 (void *)&cmd_lfc_set_flow_ctrl,
6896 (void *)&cmd_lfc_set_high_water_str,
6897 (void *)&cmd_lfc_set_high_water,
6898 (void *)&cmd_lfc_set_portid,
6903 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6904 .f = cmd_link_flow_ctrl_set_parsed,
6905 .data = (void *)&cmd_link_flow_control_set_lw,
6906 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6907 "Change low water flow control parameter",
6909 (void *)&cmd_lfc_set_set,
6910 (void *)&cmd_lfc_set_flow_ctrl,
6911 (void *)&cmd_lfc_set_low_water_str,
6912 (void *)&cmd_lfc_set_low_water,
6913 (void *)&cmd_lfc_set_portid,
6918 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6919 .f = cmd_link_flow_ctrl_set_parsed,
6920 .data = (void *)&cmd_link_flow_control_set_pt,
6921 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6922 "Change pause time flow control parameter",
6924 (void *)&cmd_lfc_set_set,
6925 (void *)&cmd_lfc_set_flow_ctrl,
6926 (void *)&cmd_lfc_set_pause_time_str,
6927 (void *)&cmd_lfc_set_pause_time,
6928 (void *)&cmd_lfc_set_portid,
6933 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6934 .f = cmd_link_flow_ctrl_set_parsed,
6935 .data = (void *)&cmd_link_flow_control_set_xon,
6936 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6937 "Change send_xon flow control parameter",
6939 (void *)&cmd_lfc_set_set,
6940 (void *)&cmd_lfc_set_flow_ctrl,
6941 (void *)&cmd_lfc_set_send_xon_str,
6942 (void *)&cmd_lfc_set_send_xon,
6943 (void *)&cmd_lfc_set_portid,
6948 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6949 .f = cmd_link_flow_ctrl_set_parsed,
6950 .data = (void *)&cmd_link_flow_control_set_macfwd,
6951 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6952 "Change mac ctrl fwd flow control parameter",
6954 (void *)&cmd_lfc_set_set,
6955 (void *)&cmd_lfc_set_flow_ctrl,
6956 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6957 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6958 (void *)&cmd_lfc_set_portid,
6963 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6964 .f = cmd_link_flow_ctrl_set_parsed,
6965 .data = (void *)&cmd_link_flow_control_set_autoneg,
6966 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6967 "Change autoneg flow control parameter",
6969 (void *)&cmd_lfc_set_set,
6970 (void *)&cmd_lfc_set_flow_ctrl,
6971 (void *)&cmd_lfc_set_autoneg_str,
6972 (void *)&cmd_lfc_set_autoneg,
6973 (void *)&cmd_lfc_set_portid,
6979 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6980 __attribute__((unused)) struct cmdline *cl,
6983 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6984 cmdline_parse_inst_t *cmd = data;
6985 struct rte_eth_fc_conf fc_conf;
6991 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6992 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6993 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6994 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6996 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6997 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7000 /* Partial command line, retrieve current configuration */
7002 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7004 printf("cannot get current flow ctrl parameters, return"
7005 "code = %d\n", ret);
7009 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7010 (fc_conf.mode == RTE_FC_FULL))
7012 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7013 (fc_conf.mode == RTE_FC_FULL))
7017 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7018 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7020 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7021 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7023 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7025 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7026 fc_conf.high_water = res->high_water;
7028 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7029 fc_conf.low_water = res->low_water;
7031 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7032 fc_conf.pause_time = res->pause_time;
7034 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7035 fc_conf.send_xon = res->send_xon;
7037 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7038 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7039 fc_conf.mac_ctrl_frame_fwd = 1;
7041 fc_conf.mac_ctrl_frame_fwd = 0;
7044 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7045 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7047 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7049 printf("bad flow contrl parameter, return code = %d \n", ret);
7052 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7053 struct cmd_priority_flow_ctrl_set_result {
7054 cmdline_fixed_string_t set;
7055 cmdline_fixed_string_t pfc_ctrl;
7056 cmdline_fixed_string_t rx;
7057 cmdline_fixed_string_t rx_pfc_mode;
7058 cmdline_fixed_string_t tx;
7059 cmdline_fixed_string_t tx_pfc_mode;
7060 uint32_t high_water;
7062 uint16_t pause_time;
7068 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7069 __attribute__((unused)) struct cmdline *cl,
7070 __attribute__((unused)) void *data)
7072 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7073 struct rte_eth_pfc_conf pfc_conf;
7074 int rx_fc_enable, tx_fc_enable;
7078 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7079 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7080 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7081 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7083 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7084 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7087 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7088 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7089 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7090 pfc_conf.fc.high_water = res->high_water;
7091 pfc_conf.fc.low_water = res->low_water;
7092 pfc_conf.fc.pause_time = res->pause_time;
7093 pfc_conf.priority = res->priority;
7095 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7097 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7100 cmdline_parse_token_string_t cmd_pfc_set_set =
7101 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7103 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7104 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7105 pfc_ctrl, "pfc_ctrl");
7106 cmdline_parse_token_string_t cmd_pfc_set_rx =
7107 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7109 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7110 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7111 rx_pfc_mode, "on#off");
7112 cmdline_parse_token_string_t cmd_pfc_set_tx =
7113 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7115 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7116 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7117 tx_pfc_mode, "on#off");
7118 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7119 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7120 high_water, UINT32);
7121 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7122 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7124 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7125 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7126 pause_time, UINT16);
7127 cmdline_parse_token_num_t cmd_pfc_set_priority =
7128 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7130 cmdline_parse_token_num_t cmd_pfc_set_portid =
7131 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7134 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7135 .f = cmd_priority_flow_ctrl_set_parsed,
7137 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7138 "<pause_time> <priority> <port_id>: "
7139 "Configure the Ethernet priority flow control",
7141 (void *)&cmd_pfc_set_set,
7142 (void *)&cmd_pfc_set_flow_ctrl,
7143 (void *)&cmd_pfc_set_rx,
7144 (void *)&cmd_pfc_set_rx_mode,
7145 (void *)&cmd_pfc_set_tx,
7146 (void *)&cmd_pfc_set_tx_mode,
7147 (void *)&cmd_pfc_set_high_water,
7148 (void *)&cmd_pfc_set_low_water,
7149 (void *)&cmd_pfc_set_pause_time,
7150 (void *)&cmd_pfc_set_priority,
7151 (void *)&cmd_pfc_set_portid,
7156 /* *** RESET CONFIGURATION *** */
7157 struct cmd_reset_result {
7158 cmdline_fixed_string_t reset;
7159 cmdline_fixed_string_t def;
7162 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7164 __attribute__((unused)) void *data)
7166 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7167 set_def_fwd_config();
7170 cmdline_parse_token_string_t cmd_reset_set =
7171 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7172 cmdline_parse_token_string_t cmd_reset_def =
7173 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7176 cmdline_parse_inst_t cmd_reset = {
7177 .f = cmd_reset_parsed,
7179 .help_str = "set default: Reset default forwarding configuration",
7181 (void *)&cmd_reset_set,
7182 (void *)&cmd_reset_def,
7187 /* *** START FORWARDING *** */
7188 struct cmd_start_result {
7189 cmdline_fixed_string_t start;
7192 cmdline_parse_token_string_t cmd_start_start =
7193 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7195 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7196 __attribute__((unused)) struct cmdline *cl,
7197 __attribute__((unused)) void *data)
7199 start_packet_forwarding(0);
7202 cmdline_parse_inst_t cmd_start = {
7203 .f = cmd_start_parsed,
7205 .help_str = "start: Start packet forwarding",
7207 (void *)&cmd_start_start,
7212 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7213 struct cmd_start_tx_first_result {
7214 cmdline_fixed_string_t start;
7215 cmdline_fixed_string_t tx_first;
7219 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7220 __attribute__((unused)) struct cmdline *cl,
7221 __attribute__((unused)) void *data)
7223 start_packet_forwarding(1);
7226 cmdline_parse_token_string_t cmd_start_tx_first_start =
7227 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7229 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7230 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7231 tx_first, "tx_first");
7233 cmdline_parse_inst_t cmd_start_tx_first = {
7234 .f = cmd_start_tx_first_parsed,
7236 .help_str = "start tx_first: Start packet forwarding, "
7237 "after sending 1 burst of packets",
7239 (void *)&cmd_start_tx_first_start,
7240 (void *)&cmd_start_tx_first_tx_first,
7245 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7246 struct cmd_start_tx_first_n_result {
7247 cmdline_fixed_string_t start;
7248 cmdline_fixed_string_t tx_first;
7253 cmd_start_tx_first_n_parsed(void *parsed_result,
7254 __attribute__((unused)) struct cmdline *cl,
7255 __attribute__((unused)) void *data)
7257 struct cmd_start_tx_first_n_result *res = parsed_result;
7259 start_packet_forwarding(res->tx_num);
7262 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7263 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7265 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7266 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7267 tx_first, "tx_first");
7268 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7269 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7272 cmdline_parse_inst_t cmd_start_tx_first_n = {
7273 .f = cmd_start_tx_first_n_parsed,
7275 .help_str = "start tx_first <num>: "
7276 "packet forwarding, after sending <num> bursts of packets",
7278 (void *)&cmd_start_tx_first_n_start,
7279 (void *)&cmd_start_tx_first_n_tx_first,
7280 (void *)&cmd_start_tx_first_n_tx_num,
7285 /* *** SET LINK UP *** */
7286 struct cmd_set_link_up_result {
7287 cmdline_fixed_string_t set;
7288 cmdline_fixed_string_t link_up;
7289 cmdline_fixed_string_t port;
7293 cmdline_parse_token_string_t cmd_set_link_up_set =
7294 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7295 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7296 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7298 cmdline_parse_token_string_t cmd_set_link_up_port =
7299 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7300 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7301 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7303 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7304 __attribute__((unused)) struct cmdline *cl,
7305 __attribute__((unused)) void *data)
7307 struct cmd_set_link_up_result *res = parsed_result;
7308 dev_set_link_up(res->port_id);
7311 cmdline_parse_inst_t cmd_set_link_up = {
7312 .f = cmd_set_link_up_parsed,
7314 .help_str = "set link-up port <port id>",
7316 (void *)&cmd_set_link_up_set,
7317 (void *)&cmd_set_link_up_link_up,
7318 (void *)&cmd_set_link_up_port,
7319 (void *)&cmd_set_link_up_port_id,
7324 /* *** SET LINK DOWN *** */
7325 struct cmd_set_link_down_result {
7326 cmdline_fixed_string_t set;
7327 cmdline_fixed_string_t link_down;
7328 cmdline_fixed_string_t port;
7332 cmdline_parse_token_string_t cmd_set_link_down_set =
7333 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7334 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7335 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7337 cmdline_parse_token_string_t cmd_set_link_down_port =
7338 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7339 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7340 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7342 static void cmd_set_link_down_parsed(
7343 __attribute__((unused)) void *parsed_result,
7344 __attribute__((unused)) struct cmdline *cl,
7345 __attribute__((unused)) void *data)
7347 struct cmd_set_link_down_result *res = parsed_result;
7348 dev_set_link_down(res->port_id);
7351 cmdline_parse_inst_t cmd_set_link_down = {
7352 .f = cmd_set_link_down_parsed,
7354 .help_str = "set link-down port <port id>",
7356 (void *)&cmd_set_link_down_set,
7357 (void *)&cmd_set_link_down_link_down,
7358 (void *)&cmd_set_link_down_port,
7359 (void *)&cmd_set_link_down_port_id,
7364 /* *** SHOW CFG *** */
7365 struct cmd_showcfg_result {
7366 cmdline_fixed_string_t show;
7367 cmdline_fixed_string_t cfg;
7368 cmdline_fixed_string_t what;
7371 static void cmd_showcfg_parsed(void *parsed_result,
7372 __attribute__((unused)) struct cmdline *cl,
7373 __attribute__((unused)) void *data)
7375 struct cmd_showcfg_result *res = parsed_result;
7376 if (!strcmp(res->what, "rxtx"))
7377 rxtx_config_display();
7378 else if (!strcmp(res->what, "cores"))
7379 fwd_lcores_config_display();
7380 else if (!strcmp(res->what, "fwd"))
7381 pkt_fwd_config_display(&cur_fwd_config);
7382 else if (!strcmp(res->what, "txpkts"))
7383 show_tx_pkt_segments();
7386 cmdline_parse_token_string_t cmd_showcfg_show =
7387 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7388 cmdline_parse_token_string_t cmd_showcfg_port =
7389 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7390 cmdline_parse_token_string_t cmd_showcfg_what =
7391 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7392 "rxtx#cores#fwd#txpkts");
7394 cmdline_parse_inst_t cmd_showcfg = {
7395 .f = cmd_showcfg_parsed,
7397 .help_str = "show config rxtx|cores|fwd|txpkts",
7399 (void *)&cmd_showcfg_show,
7400 (void *)&cmd_showcfg_port,
7401 (void *)&cmd_showcfg_what,
7406 /* *** SHOW ALL PORT INFO *** */
7407 struct cmd_showportall_result {
7408 cmdline_fixed_string_t show;
7409 cmdline_fixed_string_t port;
7410 cmdline_fixed_string_t what;
7411 cmdline_fixed_string_t all;
7414 static void cmd_showportall_parsed(void *parsed_result,
7415 __attribute__((unused)) struct cmdline *cl,
7416 __attribute__((unused)) void *data)
7420 struct cmd_showportall_result *res = parsed_result;
7421 if (!strcmp(res->show, "clear")) {
7422 if (!strcmp(res->what, "stats"))
7423 RTE_ETH_FOREACH_DEV(i)
7425 else if (!strcmp(res->what, "xstats"))
7426 RTE_ETH_FOREACH_DEV(i)
7427 nic_xstats_clear(i);
7428 } else if (!strcmp(res->what, "info"))
7429 RTE_ETH_FOREACH_DEV(i)
7430 port_infos_display(i);
7431 else if (!strcmp(res->what, "summary")) {
7432 port_summary_header_display();
7433 RTE_ETH_FOREACH_DEV(i)
7434 port_summary_display(i);
7436 else if (!strcmp(res->what, "stats"))
7437 RTE_ETH_FOREACH_DEV(i)
7438 nic_stats_display(i);
7439 else if (!strcmp(res->what, "xstats"))
7440 RTE_ETH_FOREACH_DEV(i)
7441 nic_xstats_display(i);
7442 else if (!strcmp(res->what, "fdir"))
7443 RTE_ETH_FOREACH_DEV(i)
7445 else if (!strcmp(res->what, "stat_qmap"))
7446 RTE_ETH_FOREACH_DEV(i)
7447 nic_stats_mapping_display(i);
7448 else if (!strcmp(res->what, "dcb_tc"))
7449 RTE_ETH_FOREACH_DEV(i)
7450 port_dcb_info_display(i);
7451 else if (!strcmp(res->what, "cap"))
7452 RTE_ETH_FOREACH_DEV(i)
7453 port_offload_cap_display(i);
7456 cmdline_parse_token_string_t cmd_showportall_show =
7457 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7459 cmdline_parse_token_string_t cmd_showportall_port =
7460 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7461 cmdline_parse_token_string_t cmd_showportall_what =
7462 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7463 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7464 cmdline_parse_token_string_t cmd_showportall_all =
7465 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7466 cmdline_parse_inst_t cmd_showportall = {
7467 .f = cmd_showportall_parsed,
7469 .help_str = "show|clear port "
7470 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7472 (void *)&cmd_showportall_show,
7473 (void *)&cmd_showportall_port,
7474 (void *)&cmd_showportall_what,
7475 (void *)&cmd_showportall_all,
7480 /* *** SHOW PORT INFO *** */
7481 struct cmd_showport_result {
7482 cmdline_fixed_string_t show;
7483 cmdline_fixed_string_t port;
7484 cmdline_fixed_string_t what;
7488 static void cmd_showport_parsed(void *parsed_result,
7489 __attribute__((unused)) struct cmdline *cl,
7490 __attribute__((unused)) void *data)
7492 struct cmd_showport_result *res = parsed_result;
7493 if (!strcmp(res->show, "clear")) {
7494 if (!strcmp(res->what, "stats"))
7495 nic_stats_clear(res->portnum);
7496 else if (!strcmp(res->what, "xstats"))
7497 nic_xstats_clear(res->portnum);
7498 } else if (!strcmp(res->what, "info"))
7499 port_infos_display(res->portnum);
7500 else if (!strcmp(res->what, "summary")) {
7501 port_summary_header_display();
7502 port_summary_display(res->portnum);
7504 else if (!strcmp(res->what, "stats"))
7505 nic_stats_display(res->portnum);
7506 else if (!strcmp(res->what, "xstats"))
7507 nic_xstats_display(res->portnum);
7508 else if (!strcmp(res->what, "fdir"))
7509 fdir_get_infos(res->portnum);
7510 else if (!strcmp(res->what, "stat_qmap"))
7511 nic_stats_mapping_display(res->portnum);
7512 else if (!strcmp(res->what, "dcb_tc"))
7513 port_dcb_info_display(res->portnum);
7514 else if (!strcmp(res->what, "cap"))
7515 port_offload_cap_display(res->portnum);
7518 cmdline_parse_token_string_t cmd_showport_show =
7519 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7521 cmdline_parse_token_string_t cmd_showport_port =
7522 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7523 cmdline_parse_token_string_t cmd_showport_what =
7524 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7525 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7526 cmdline_parse_token_num_t cmd_showport_portnum =
7527 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7529 cmdline_parse_inst_t cmd_showport = {
7530 .f = cmd_showport_parsed,
7532 .help_str = "show|clear port "
7533 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7536 (void *)&cmd_showport_show,
7537 (void *)&cmd_showport_port,
7538 (void *)&cmd_showport_what,
7539 (void *)&cmd_showport_portnum,
7544 /* *** SHOW DEVICE INFO *** */
7545 struct cmd_showdevice_result {
7546 cmdline_fixed_string_t show;
7547 cmdline_fixed_string_t device;
7548 cmdline_fixed_string_t what;
7549 cmdline_fixed_string_t identifier;
7552 static void cmd_showdevice_parsed(void *parsed_result,
7553 __attribute__((unused)) struct cmdline *cl,
7554 __attribute__((unused)) void *data)
7556 struct cmd_showdevice_result *res = parsed_result;
7557 if (!strcmp(res->what, "info")) {
7558 if (!strcmp(res->identifier, "all"))
7559 device_infos_display(NULL);
7561 device_infos_display(res->identifier);
7565 cmdline_parse_token_string_t cmd_showdevice_show =
7566 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7568 cmdline_parse_token_string_t cmd_showdevice_device =
7569 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7570 cmdline_parse_token_string_t cmd_showdevice_what =
7571 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7573 cmdline_parse_token_string_t cmd_showdevice_identifier =
7574 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7577 cmdline_parse_inst_t cmd_showdevice = {
7578 .f = cmd_showdevice_parsed,
7580 .help_str = "show device info <identifier>|all",
7582 (void *)&cmd_showdevice_show,
7583 (void *)&cmd_showdevice_device,
7584 (void *)&cmd_showdevice_what,
7585 (void *)&cmd_showdevice_identifier,
7589 /* *** SHOW QUEUE INFO *** */
7590 struct cmd_showqueue_result {
7591 cmdline_fixed_string_t show;
7592 cmdline_fixed_string_t type;
7593 cmdline_fixed_string_t what;
7599 cmd_showqueue_parsed(void *parsed_result,
7600 __attribute__((unused)) struct cmdline *cl,
7601 __attribute__((unused)) void *data)
7603 struct cmd_showqueue_result *res = parsed_result;
7605 if (!strcmp(res->type, "rxq"))
7606 rx_queue_infos_display(res->portnum, res->queuenum);
7607 else if (!strcmp(res->type, "txq"))
7608 tx_queue_infos_display(res->portnum, res->queuenum);
7611 cmdline_parse_token_string_t cmd_showqueue_show =
7612 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7613 cmdline_parse_token_string_t cmd_showqueue_type =
7614 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7615 cmdline_parse_token_string_t cmd_showqueue_what =
7616 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7617 cmdline_parse_token_num_t cmd_showqueue_portnum =
7618 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7619 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7620 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7622 cmdline_parse_inst_t cmd_showqueue = {
7623 .f = cmd_showqueue_parsed,
7625 .help_str = "show rxq|txq info <port_id> <queue_id>",
7627 (void *)&cmd_showqueue_show,
7628 (void *)&cmd_showqueue_type,
7629 (void *)&cmd_showqueue_what,
7630 (void *)&cmd_showqueue_portnum,
7631 (void *)&cmd_showqueue_queuenum,
7636 /* show/clear fwd engine statistics */
7638 cmdline_fixed_string_t action;
7639 cmdline_fixed_string_t fwd;
7640 cmdline_fixed_string_t stats;
7641 cmdline_fixed_string_t all;
7644 cmdline_parse_token_string_t cmd_fwd_action =
7645 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7646 cmdline_parse_token_string_t cmd_fwd_fwd =
7647 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7648 cmdline_parse_token_string_t cmd_fwd_stats =
7649 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7650 cmdline_parse_token_string_t cmd_fwd_all =
7651 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7654 cmd_showfwdall_parsed(void *parsed_result,
7655 __rte_unused struct cmdline *cl,
7656 __rte_unused void *data)
7658 struct fwd_result *res = parsed_result;
7660 if (!strcmp(res->action, "show"))
7661 fwd_stats_display();
7666 static cmdline_parse_inst_t cmd_showfwdall = {
7667 .f = cmd_showfwdall_parsed,
7669 .help_str = "show|clear fwd stats all",
7671 (void *)&cmd_fwd_action,
7672 (void *)&cmd_fwd_fwd,
7673 (void *)&cmd_fwd_stats,
7674 (void *)&cmd_fwd_all,
7679 /* *** READ PORT REGISTER *** */
7680 struct cmd_read_reg_result {
7681 cmdline_fixed_string_t read;
7682 cmdline_fixed_string_t reg;
7688 cmd_read_reg_parsed(void *parsed_result,
7689 __attribute__((unused)) struct cmdline *cl,
7690 __attribute__((unused)) void *data)
7692 struct cmd_read_reg_result *res = parsed_result;
7693 port_reg_display(res->port_id, res->reg_off);
7696 cmdline_parse_token_string_t cmd_read_reg_read =
7697 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7698 cmdline_parse_token_string_t cmd_read_reg_reg =
7699 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7700 cmdline_parse_token_num_t cmd_read_reg_port_id =
7701 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7702 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7703 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7705 cmdline_parse_inst_t cmd_read_reg = {
7706 .f = cmd_read_reg_parsed,
7708 .help_str = "read reg <port_id> <reg_off>",
7710 (void *)&cmd_read_reg_read,
7711 (void *)&cmd_read_reg_reg,
7712 (void *)&cmd_read_reg_port_id,
7713 (void *)&cmd_read_reg_reg_off,
7718 /* *** READ PORT REGISTER BIT FIELD *** */
7719 struct cmd_read_reg_bit_field_result {
7720 cmdline_fixed_string_t read;
7721 cmdline_fixed_string_t regfield;
7729 cmd_read_reg_bit_field_parsed(void *parsed_result,
7730 __attribute__((unused)) struct cmdline *cl,
7731 __attribute__((unused)) void *data)
7733 struct cmd_read_reg_bit_field_result *res = parsed_result;
7734 port_reg_bit_field_display(res->port_id, res->reg_off,
7735 res->bit1_pos, res->bit2_pos);
7738 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7739 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7741 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7742 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7743 regfield, "regfield");
7744 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7745 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7747 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7748 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7750 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7751 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7753 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7754 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7757 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7758 .f = cmd_read_reg_bit_field_parsed,
7760 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7761 "Read register bit field between bit_x and bit_y included",
7763 (void *)&cmd_read_reg_bit_field_read,
7764 (void *)&cmd_read_reg_bit_field_regfield,
7765 (void *)&cmd_read_reg_bit_field_port_id,
7766 (void *)&cmd_read_reg_bit_field_reg_off,
7767 (void *)&cmd_read_reg_bit_field_bit1_pos,
7768 (void *)&cmd_read_reg_bit_field_bit2_pos,
7773 /* *** READ PORT REGISTER BIT *** */
7774 struct cmd_read_reg_bit_result {
7775 cmdline_fixed_string_t read;
7776 cmdline_fixed_string_t regbit;
7783 cmd_read_reg_bit_parsed(void *parsed_result,
7784 __attribute__((unused)) struct cmdline *cl,
7785 __attribute__((unused)) void *data)
7787 struct cmd_read_reg_bit_result *res = parsed_result;
7788 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7791 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7792 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7793 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7794 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7796 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7797 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7798 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7799 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7800 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7801 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7803 cmdline_parse_inst_t cmd_read_reg_bit = {
7804 .f = cmd_read_reg_bit_parsed,
7806 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7808 (void *)&cmd_read_reg_bit_read,
7809 (void *)&cmd_read_reg_bit_regbit,
7810 (void *)&cmd_read_reg_bit_port_id,
7811 (void *)&cmd_read_reg_bit_reg_off,
7812 (void *)&cmd_read_reg_bit_bit_pos,
7817 /* *** WRITE PORT REGISTER *** */
7818 struct cmd_write_reg_result {
7819 cmdline_fixed_string_t write;
7820 cmdline_fixed_string_t reg;
7827 cmd_write_reg_parsed(void *parsed_result,
7828 __attribute__((unused)) struct cmdline *cl,
7829 __attribute__((unused)) void *data)
7831 struct cmd_write_reg_result *res = parsed_result;
7832 port_reg_set(res->port_id, res->reg_off, res->value);
7835 cmdline_parse_token_string_t cmd_write_reg_write =
7836 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7837 cmdline_parse_token_string_t cmd_write_reg_reg =
7838 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7839 cmdline_parse_token_num_t cmd_write_reg_port_id =
7840 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7841 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7842 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7843 cmdline_parse_token_num_t cmd_write_reg_value =
7844 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7846 cmdline_parse_inst_t cmd_write_reg = {
7847 .f = cmd_write_reg_parsed,
7849 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7851 (void *)&cmd_write_reg_write,
7852 (void *)&cmd_write_reg_reg,
7853 (void *)&cmd_write_reg_port_id,
7854 (void *)&cmd_write_reg_reg_off,
7855 (void *)&cmd_write_reg_value,
7860 /* *** WRITE PORT REGISTER BIT FIELD *** */
7861 struct cmd_write_reg_bit_field_result {
7862 cmdline_fixed_string_t write;
7863 cmdline_fixed_string_t regfield;
7872 cmd_write_reg_bit_field_parsed(void *parsed_result,
7873 __attribute__((unused)) struct cmdline *cl,
7874 __attribute__((unused)) void *data)
7876 struct cmd_write_reg_bit_field_result *res = parsed_result;
7877 port_reg_bit_field_set(res->port_id, res->reg_off,
7878 res->bit1_pos, res->bit2_pos, res->value);
7881 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7882 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7884 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7885 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7886 regfield, "regfield");
7887 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7888 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7890 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7891 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7893 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7894 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7896 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7897 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7899 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7900 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7903 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7904 .f = cmd_write_reg_bit_field_parsed,
7906 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7908 "Set register bit field between bit_x and bit_y included",
7910 (void *)&cmd_write_reg_bit_field_write,
7911 (void *)&cmd_write_reg_bit_field_regfield,
7912 (void *)&cmd_write_reg_bit_field_port_id,
7913 (void *)&cmd_write_reg_bit_field_reg_off,
7914 (void *)&cmd_write_reg_bit_field_bit1_pos,
7915 (void *)&cmd_write_reg_bit_field_bit2_pos,
7916 (void *)&cmd_write_reg_bit_field_value,
7921 /* *** WRITE PORT REGISTER BIT *** */
7922 struct cmd_write_reg_bit_result {
7923 cmdline_fixed_string_t write;
7924 cmdline_fixed_string_t regbit;
7932 cmd_write_reg_bit_parsed(void *parsed_result,
7933 __attribute__((unused)) struct cmdline *cl,
7934 __attribute__((unused)) void *data)
7936 struct cmd_write_reg_bit_result *res = parsed_result;
7937 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7940 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7941 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7943 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7944 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7946 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7947 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7948 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7949 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7950 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7951 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7952 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7953 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7955 cmdline_parse_inst_t cmd_write_reg_bit = {
7956 .f = cmd_write_reg_bit_parsed,
7958 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7961 (void *)&cmd_write_reg_bit_write,
7962 (void *)&cmd_write_reg_bit_regbit,
7963 (void *)&cmd_write_reg_bit_port_id,
7964 (void *)&cmd_write_reg_bit_reg_off,
7965 (void *)&cmd_write_reg_bit_bit_pos,
7966 (void *)&cmd_write_reg_bit_value,
7971 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7972 struct cmd_read_rxd_txd_result {
7973 cmdline_fixed_string_t read;
7974 cmdline_fixed_string_t rxd_txd;
7981 cmd_read_rxd_txd_parsed(void *parsed_result,
7982 __attribute__((unused)) struct cmdline *cl,
7983 __attribute__((unused)) void *data)
7985 struct cmd_read_rxd_txd_result *res = parsed_result;
7987 if (!strcmp(res->rxd_txd, "rxd"))
7988 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7989 else if (!strcmp(res->rxd_txd, "txd"))
7990 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7993 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7994 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7995 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7996 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7998 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7999 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8000 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8001 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8002 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8003 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8005 cmdline_parse_inst_t cmd_read_rxd_txd = {
8006 .f = cmd_read_rxd_txd_parsed,
8008 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8010 (void *)&cmd_read_rxd_txd_read,
8011 (void *)&cmd_read_rxd_txd_rxd_txd,
8012 (void *)&cmd_read_rxd_txd_port_id,
8013 (void *)&cmd_read_rxd_txd_queue_id,
8014 (void *)&cmd_read_rxd_txd_desc_id,
8020 struct cmd_quit_result {
8021 cmdline_fixed_string_t quit;
8024 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
8026 __attribute__((unused)) void *data)
8031 cmdline_parse_token_string_t cmd_quit_quit =
8032 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8034 cmdline_parse_inst_t cmd_quit = {
8035 .f = cmd_quit_parsed,
8037 .help_str = "quit: Exit application",
8039 (void *)&cmd_quit_quit,
8044 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8045 struct cmd_mac_addr_result {
8046 cmdline_fixed_string_t mac_addr_cmd;
8047 cmdline_fixed_string_t what;
8049 struct rte_ether_addr address;
8052 static void cmd_mac_addr_parsed(void *parsed_result,
8053 __attribute__((unused)) struct cmdline *cl,
8054 __attribute__((unused)) void *data)
8056 struct cmd_mac_addr_result *res = parsed_result;
8059 if (strcmp(res->what, "add") == 0)
8060 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8061 else if (strcmp(res->what, "set") == 0)
8062 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8065 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8067 /* check the return value and print it if is < 0 */
8069 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8073 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8074 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8076 cmdline_parse_token_string_t cmd_mac_addr_what =
8077 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8079 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8080 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8082 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8083 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8085 cmdline_parse_inst_t cmd_mac_addr = {
8086 .f = cmd_mac_addr_parsed,
8088 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8089 "Add/Remove/Set MAC address on port_id",
8091 (void *)&cmd_mac_addr_cmd,
8092 (void *)&cmd_mac_addr_what,
8093 (void *)&cmd_mac_addr_portnum,
8094 (void *)&cmd_mac_addr_addr,
8099 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8100 struct cmd_eth_peer_result {
8101 cmdline_fixed_string_t set;
8102 cmdline_fixed_string_t eth_peer;
8104 cmdline_fixed_string_t peer_addr;
8107 static void cmd_set_eth_peer_parsed(void *parsed_result,
8108 __attribute__((unused)) struct cmdline *cl,
8109 __attribute__((unused)) void *data)
8111 struct cmd_eth_peer_result *res = parsed_result;
8113 if (test_done == 0) {
8114 printf("Please stop forwarding first\n");
8117 if (!strcmp(res->eth_peer, "eth-peer")) {
8118 set_fwd_eth_peer(res->port_id, res->peer_addr);
8122 cmdline_parse_token_string_t cmd_eth_peer_set =
8123 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8124 cmdline_parse_token_string_t cmd_eth_peer =
8125 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8126 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8127 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8128 cmdline_parse_token_string_t cmd_eth_peer_addr =
8129 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8131 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8132 .f = cmd_set_eth_peer_parsed,
8134 .help_str = "set eth-peer <port_id> <peer_mac>",
8136 (void *)&cmd_eth_peer_set,
8137 (void *)&cmd_eth_peer,
8138 (void *)&cmd_eth_peer_port_id,
8139 (void *)&cmd_eth_peer_addr,
8144 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8145 struct cmd_set_qmap_result {
8146 cmdline_fixed_string_t set;
8147 cmdline_fixed_string_t qmap;
8148 cmdline_fixed_string_t what;
8155 cmd_set_qmap_parsed(void *parsed_result,
8156 __attribute__((unused)) struct cmdline *cl,
8157 __attribute__((unused)) void *data)
8159 struct cmd_set_qmap_result *res = parsed_result;
8160 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8162 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8165 cmdline_parse_token_string_t cmd_setqmap_set =
8166 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8168 cmdline_parse_token_string_t cmd_setqmap_qmap =
8169 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8171 cmdline_parse_token_string_t cmd_setqmap_what =
8172 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8174 cmdline_parse_token_num_t cmd_setqmap_portid =
8175 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8177 cmdline_parse_token_num_t cmd_setqmap_queueid =
8178 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8180 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8181 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8184 cmdline_parse_inst_t cmd_set_qmap = {
8185 .f = cmd_set_qmap_parsed,
8187 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8188 "Set statistics mapping value on tx|rx queue_id of port_id",
8190 (void *)&cmd_setqmap_set,
8191 (void *)&cmd_setqmap_qmap,
8192 (void *)&cmd_setqmap_what,
8193 (void *)&cmd_setqmap_portid,
8194 (void *)&cmd_setqmap_queueid,
8195 (void *)&cmd_setqmap_mapvalue,
8200 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8201 struct cmd_set_xstats_hide_zero_result {
8202 cmdline_fixed_string_t keyword;
8203 cmdline_fixed_string_t name;
8204 cmdline_fixed_string_t on_off;
8208 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8209 __attribute__((unused)) struct cmdline *cl,
8210 __attribute__((unused)) void *data)
8212 struct cmd_set_xstats_hide_zero_result *res;
8213 uint16_t on_off = 0;
8215 res = parsed_result;
8216 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8217 set_xstats_hide_zero(on_off);
8220 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8223 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8224 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8225 name, "xstats-hide-zero");
8226 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8227 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8230 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8231 .f = cmd_set_xstats_hide_zero_parsed,
8233 .help_str = "set xstats-hide-zero on|off",
8235 (void *)&cmd_set_xstats_hide_zero_keyword,
8236 (void *)&cmd_set_xstats_hide_zero_name,
8237 (void *)&cmd_set_xstats_hide_zero_on_off,
8242 /* *** CONFIGURE UNICAST HASH TABLE *** */
8243 struct cmd_set_uc_hash_table {
8244 cmdline_fixed_string_t set;
8245 cmdline_fixed_string_t port;
8247 cmdline_fixed_string_t what;
8248 struct rte_ether_addr address;
8249 cmdline_fixed_string_t mode;
8253 cmd_set_uc_hash_parsed(void *parsed_result,
8254 __attribute__((unused)) struct cmdline *cl,
8255 __attribute__((unused)) void *data)
8258 struct cmd_set_uc_hash_table *res = parsed_result;
8260 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8262 if (strcmp(res->what, "uta") == 0)
8263 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8264 &res->address,(uint8_t)is_on);
8266 printf("bad unicast hash table parameter, return code = %d \n", ret);
8270 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8271 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8273 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8274 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8276 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8277 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8279 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8280 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8282 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8283 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8285 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8286 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8289 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8290 .f = cmd_set_uc_hash_parsed,
8292 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8294 (void *)&cmd_set_uc_hash_set,
8295 (void *)&cmd_set_uc_hash_port,
8296 (void *)&cmd_set_uc_hash_portid,
8297 (void *)&cmd_set_uc_hash_what,
8298 (void *)&cmd_set_uc_hash_mac,
8299 (void *)&cmd_set_uc_hash_mode,
8304 struct cmd_set_uc_all_hash_table {
8305 cmdline_fixed_string_t set;
8306 cmdline_fixed_string_t port;
8308 cmdline_fixed_string_t what;
8309 cmdline_fixed_string_t value;
8310 cmdline_fixed_string_t mode;
8314 cmd_set_uc_all_hash_parsed(void *parsed_result,
8315 __attribute__((unused)) struct cmdline *cl,
8316 __attribute__((unused)) void *data)
8319 struct cmd_set_uc_all_hash_table *res = parsed_result;
8321 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8323 if ((strcmp(res->what, "uta") == 0) &&
8324 (strcmp(res->value, "all") == 0))
8325 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8327 printf("bad unicast hash table parameter,"
8328 "return code = %d \n", ret);
8331 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8334 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8335 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8337 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8338 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8340 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8341 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8343 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8344 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8346 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8347 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8350 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8351 .f = cmd_set_uc_all_hash_parsed,
8353 .help_str = "set port <port_id> uta all on|off",
8355 (void *)&cmd_set_uc_all_hash_set,
8356 (void *)&cmd_set_uc_all_hash_port,
8357 (void *)&cmd_set_uc_all_hash_portid,
8358 (void *)&cmd_set_uc_all_hash_what,
8359 (void *)&cmd_set_uc_all_hash_value,
8360 (void *)&cmd_set_uc_all_hash_mode,
8365 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8366 struct cmd_set_vf_macvlan_filter {
8367 cmdline_fixed_string_t set;
8368 cmdline_fixed_string_t port;
8370 cmdline_fixed_string_t vf;
8372 struct rte_ether_addr address;
8373 cmdline_fixed_string_t filter_type;
8374 cmdline_fixed_string_t mode;
8378 cmd_set_vf_macvlan_parsed(void *parsed_result,
8379 __attribute__((unused)) struct cmdline *cl,
8380 __attribute__((unused)) void *data)
8383 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8384 struct rte_eth_mac_filter filter;
8386 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8388 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8390 /* set VF MAC filter */
8394 filter.dst_id = res->vf_id;
8396 if (!strcmp(res->filter_type, "exact-mac"))
8397 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8398 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8399 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8400 else if (!strcmp(res->filter_type, "hashmac"))
8401 filter.filter_type = RTE_MAC_HASH_MATCH;
8402 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8403 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8405 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8408 ret = rte_eth_dev_filter_ctrl(res->port_id,
8409 RTE_ETH_FILTER_MACVLAN,
8413 ret = rte_eth_dev_filter_ctrl(res->port_id,
8414 RTE_ETH_FILTER_MACVLAN,
8415 RTE_ETH_FILTER_DELETE,
8419 printf("bad set MAC hash parameter, return code = %d\n", ret);
8423 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8424 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8426 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8427 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8429 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8430 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8432 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8433 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8435 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8436 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8438 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8439 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8441 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8442 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8443 filter_type, "exact-mac#exact-mac-vlan"
8444 "#hashmac#hashmac-vlan");
8445 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8446 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8449 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8450 .f = cmd_set_vf_macvlan_parsed,
8452 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8453 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8454 "Exact match rule: exact match of MAC or MAC and VLAN; "
8455 "hash match rule: hash match of MAC and exact match of VLAN",
8457 (void *)&cmd_set_vf_macvlan_set,
8458 (void *)&cmd_set_vf_macvlan_port,
8459 (void *)&cmd_set_vf_macvlan_portid,
8460 (void *)&cmd_set_vf_macvlan_vf,
8461 (void *)&cmd_set_vf_macvlan_vf_id,
8462 (void *)&cmd_set_vf_macvlan_mac,
8463 (void *)&cmd_set_vf_macvlan_filter_type,
8464 (void *)&cmd_set_vf_macvlan_mode,
8469 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8470 struct cmd_set_vf_traffic {
8471 cmdline_fixed_string_t set;
8472 cmdline_fixed_string_t port;
8474 cmdline_fixed_string_t vf;
8476 cmdline_fixed_string_t what;
8477 cmdline_fixed_string_t mode;
8481 cmd_set_vf_traffic_parsed(void *parsed_result,
8482 __attribute__((unused)) struct cmdline *cl,
8483 __attribute__((unused)) void *data)
8485 struct cmd_set_vf_traffic *res = parsed_result;
8486 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8487 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8489 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8492 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8493 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8495 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8496 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8498 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8499 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8501 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8502 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8504 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8505 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8507 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8510 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8511 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8514 cmdline_parse_inst_t cmd_set_vf_traffic = {
8515 .f = cmd_set_vf_traffic_parsed,
8517 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8519 (void *)&cmd_setvf_traffic_set,
8520 (void *)&cmd_setvf_traffic_port,
8521 (void *)&cmd_setvf_traffic_portid,
8522 (void *)&cmd_setvf_traffic_vf,
8523 (void *)&cmd_setvf_traffic_vfid,
8524 (void *)&cmd_setvf_traffic_what,
8525 (void *)&cmd_setvf_traffic_mode,
8530 /* *** CONFIGURE VF RECEIVE MODE *** */
8531 struct cmd_set_vf_rxmode {
8532 cmdline_fixed_string_t set;
8533 cmdline_fixed_string_t port;
8535 cmdline_fixed_string_t vf;
8537 cmdline_fixed_string_t what;
8538 cmdline_fixed_string_t mode;
8539 cmdline_fixed_string_t on;
8543 cmd_set_vf_rxmode_parsed(void *parsed_result,
8544 __attribute__((unused)) struct cmdline *cl,
8545 __attribute__((unused)) void *data)
8548 uint16_t vf_rxmode = 0;
8549 struct cmd_set_vf_rxmode *res = parsed_result;
8551 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8552 if (!strcmp(res->what,"rxmode")) {
8553 if (!strcmp(res->mode, "AUPE"))
8554 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8555 else if (!strcmp(res->mode, "ROPE"))
8556 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8557 else if (!strcmp(res->mode, "BAM"))
8558 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8559 else if (!strncmp(res->mode, "MPE",3))
8560 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8563 RTE_SET_USED(is_on);
8565 #ifdef RTE_LIBRTE_IXGBE_PMD
8566 if (ret == -ENOTSUP)
8567 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8568 vf_rxmode, (uint8_t)is_on);
8570 #ifdef RTE_LIBRTE_BNXT_PMD
8571 if (ret == -ENOTSUP)
8572 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8573 vf_rxmode, (uint8_t)is_on);
8576 printf("bad VF receive mode parameter, return code = %d \n",
8580 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8581 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8583 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8584 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8586 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8587 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8589 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8590 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8592 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8593 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8595 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8596 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8598 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8599 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8600 mode, "AUPE#ROPE#BAM#MPE");
8601 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8602 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8605 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8606 .f = cmd_set_vf_rxmode_parsed,
8608 .help_str = "set port <port_id> vf <vf_id> rxmode "
8609 "AUPE|ROPE|BAM|MPE on|off",
8611 (void *)&cmd_set_vf_rxmode_set,
8612 (void *)&cmd_set_vf_rxmode_port,
8613 (void *)&cmd_set_vf_rxmode_portid,
8614 (void *)&cmd_set_vf_rxmode_vf,
8615 (void *)&cmd_set_vf_rxmode_vfid,
8616 (void *)&cmd_set_vf_rxmode_what,
8617 (void *)&cmd_set_vf_rxmode_mode,
8618 (void *)&cmd_set_vf_rxmode_on,
8623 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8624 struct cmd_vf_mac_addr_result {
8625 cmdline_fixed_string_t mac_addr_cmd;
8626 cmdline_fixed_string_t what;
8627 cmdline_fixed_string_t port;
8629 cmdline_fixed_string_t vf;
8631 struct rte_ether_addr address;
8634 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8635 __attribute__((unused)) struct cmdline *cl,
8636 __attribute__((unused)) void *data)
8638 struct cmd_vf_mac_addr_result *res = parsed_result;
8641 if (strcmp(res->what, "add") != 0)
8644 #ifdef RTE_LIBRTE_I40E_PMD
8645 if (ret == -ENOTSUP)
8646 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8649 #ifdef RTE_LIBRTE_BNXT_PMD
8650 if (ret == -ENOTSUP)
8651 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8656 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8660 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8661 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8662 mac_addr_cmd,"mac_addr");
8663 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8664 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8666 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8667 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8669 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8670 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8672 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8673 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8675 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8676 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8678 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8679 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8682 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8683 .f = cmd_vf_mac_addr_parsed,
8685 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8686 "Add MAC address filtering for a VF on port_id",
8688 (void *)&cmd_vf_mac_addr_cmd,
8689 (void *)&cmd_vf_mac_addr_what,
8690 (void *)&cmd_vf_mac_addr_port,
8691 (void *)&cmd_vf_mac_addr_portnum,
8692 (void *)&cmd_vf_mac_addr_vf,
8693 (void *)&cmd_vf_mac_addr_vfnum,
8694 (void *)&cmd_vf_mac_addr_addr,
8699 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8700 struct cmd_vf_rx_vlan_filter {
8701 cmdline_fixed_string_t rx_vlan;
8702 cmdline_fixed_string_t what;
8704 cmdline_fixed_string_t port;
8706 cmdline_fixed_string_t vf;
8711 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8712 __attribute__((unused)) struct cmdline *cl,
8713 __attribute__((unused)) void *data)
8715 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8718 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8720 #ifdef RTE_LIBRTE_IXGBE_PMD
8721 if (ret == -ENOTSUP)
8722 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8723 res->vlan_id, res->vf_mask, is_add);
8725 #ifdef RTE_LIBRTE_I40E_PMD
8726 if (ret == -ENOTSUP)
8727 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8728 res->vlan_id, res->vf_mask, is_add);
8730 #ifdef RTE_LIBRTE_BNXT_PMD
8731 if (ret == -ENOTSUP)
8732 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8733 res->vlan_id, res->vf_mask, is_add);
8740 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8741 res->vlan_id, res->vf_mask);
8744 printf("invalid port_id %d\n", res->port_id);
8747 printf("function not implemented or supported\n");
8750 printf("programming error: (%s)\n", strerror(-ret));
8754 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8755 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8756 rx_vlan, "rx_vlan");
8757 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8758 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8760 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8761 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8763 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8764 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8766 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8767 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8769 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8770 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8772 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8773 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8776 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8777 .f = cmd_vf_rx_vlan_filter_parsed,
8779 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8780 "(vf_mask = hexadecimal VF mask)",
8782 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8783 (void *)&cmd_vf_rx_vlan_filter_what,
8784 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8785 (void *)&cmd_vf_rx_vlan_filter_port,
8786 (void *)&cmd_vf_rx_vlan_filter_portid,
8787 (void *)&cmd_vf_rx_vlan_filter_vf,
8788 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8793 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8794 struct cmd_queue_rate_limit_result {
8795 cmdline_fixed_string_t set;
8796 cmdline_fixed_string_t port;
8798 cmdline_fixed_string_t queue;
8800 cmdline_fixed_string_t rate;
8804 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8805 __attribute__((unused)) struct cmdline *cl,
8806 __attribute__((unused)) void *data)
8808 struct cmd_queue_rate_limit_result *res = parsed_result;
8811 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8812 && (strcmp(res->queue, "queue") == 0)
8813 && (strcmp(res->rate, "rate") == 0))
8814 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8817 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8821 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8822 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8824 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8825 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8827 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8828 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8830 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8831 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8833 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8834 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8836 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8837 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8839 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8840 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8843 cmdline_parse_inst_t cmd_queue_rate_limit = {
8844 .f = cmd_queue_rate_limit_parsed,
8846 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8847 "Set rate limit for a queue on port_id",
8849 (void *)&cmd_queue_rate_limit_set,
8850 (void *)&cmd_queue_rate_limit_port,
8851 (void *)&cmd_queue_rate_limit_portnum,
8852 (void *)&cmd_queue_rate_limit_queue,
8853 (void *)&cmd_queue_rate_limit_queuenum,
8854 (void *)&cmd_queue_rate_limit_rate,
8855 (void *)&cmd_queue_rate_limit_ratenum,
8860 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8861 struct cmd_vf_rate_limit_result {
8862 cmdline_fixed_string_t set;
8863 cmdline_fixed_string_t port;
8865 cmdline_fixed_string_t vf;
8867 cmdline_fixed_string_t rate;
8869 cmdline_fixed_string_t q_msk;
8873 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8874 __attribute__((unused)) struct cmdline *cl,
8875 __attribute__((unused)) void *data)
8877 struct cmd_vf_rate_limit_result *res = parsed_result;
8880 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8881 && (strcmp(res->vf, "vf") == 0)
8882 && (strcmp(res->rate, "rate") == 0)
8883 && (strcmp(res->q_msk, "queue_mask") == 0))
8884 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8885 res->rate_num, res->q_msk_val);
8887 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8891 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8892 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8894 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8895 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8897 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8898 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8900 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8901 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8903 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8904 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8906 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8907 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8909 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8910 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8912 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8913 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8914 q_msk, "queue_mask");
8915 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8916 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8919 cmdline_parse_inst_t cmd_vf_rate_limit = {
8920 .f = cmd_vf_rate_limit_parsed,
8922 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8923 "queue_mask <queue_mask_value>: "
8924 "Set rate limit for queues of VF on port_id",
8926 (void *)&cmd_vf_rate_limit_set,
8927 (void *)&cmd_vf_rate_limit_port,
8928 (void *)&cmd_vf_rate_limit_portnum,
8929 (void *)&cmd_vf_rate_limit_vf,
8930 (void *)&cmd_vf_rate_limit_vfnum,
8931 (void *)&cmd_vf_rate_limit_rate,
8932 (void *)&cmd_vf_rate_limit_ratenum,
8933 (void *)&cmd_vf_rate_limit_q_msk,
8934 (void *)&cmd_vf_rate_limit_q_msk_val,
8939 /* *** ADD TUNNEL FILTER OF A PORT *** */
8940 struct cmd_tunnel_filter_result {
8941 cmdline_fixed_string_t cmd;
8942 cmdline_fixed_string_t what;
8944 struct rte_ether_addr outer_mac;
8945 struct rte_ether_addr inner_mac;
8946 cmdline_ipaddr_t ip_value;
8947 uint16_t inner_vlan;
8948 cmdline_fixed_string_t tunnel_type;
8949 cmdline_fixed_string_t filter_type;
8955 cmd_tunnel_filter_parsed(void *parsed_result,
8956 __attribute__((unused)) struct cmdline *cl,
8957 __attribute__((unused)) void *data)
8959 struct cmd_tunnel_filter_result *res = parsed_result;
8960 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8963 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8965 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8966 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8967 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8969 if (res->ip_value.family == AF_INET) {
8970 tunnel_filter_conf.ip_addr.ipv4_addr =
8971 res->ip_value.addr.ipv4.s_addr;
8972 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8974 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8975 &(res->ip_value.addr.ipv6),
8976 sizeof(struct in6_addr));
8977 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8980 if (!strcmp(res->filter_type, "imac-ivlan"))
8981 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8982 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8983 tunnel_filter_conf.filter_type =
8984 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8985 else if (!strcmp(res->filter_type, "imac-tenid"))
8986 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8987 else if (!strcmp(res->filter_type, "imac"))
8988 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8989 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8990 tunnel_filter_conf.filter_type =
8991 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8992 else if (!strcmp(res->filter_type, "oip"))
8993 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8994 else if (!strcmp(res->filter_type, "iip"))
8995 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8997 printf("The filter type is not supported");
9001 if (!strcmp(res->tunnel_type, "vxlan"))
9002 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9003 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9004 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9005 else if (!strcmp(res->tunnel_type, "nvgre"))
9006 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9007 else if (!strcmp(res->tunnel_type, "ipingre"))
9008 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9010 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9014 tunnel_filter_conf.tenant_id = res->tenant_id;
9015 tunnel_filter_conf.queue_id = res->queue_num;
9016 if (!strcmp(res->what, "add"))
9017 ret = rte_eth_dev_filter_ctrl(res->port_id,
9018 RTE_ETH_FILTER_TUNNEL,
9020 &tunnel_filter_conf);
9022 ret = rte_eth_dev_filter_ctrl(res->port_id,
9023 RTE_ETH_FILTER_TUNNEL,
9024 RTE_ETH_FILTER_DELETE,
9025 &tunnel_filter_conf);
9027 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9031 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9032 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9033 cmd, "tunnel_filter");
9034 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9037 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9038 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9040 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9041 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9043 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9044 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9046 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9047 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9048 inner_vlan, UINT16);
9049 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9050 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9052 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9053 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9054 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9056 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9057 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9058 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9059 "imac#omac-imac-tenid");
9060 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9061 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9063 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9064 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9067 cmdline_parse_inst_t cmd_tunnel_filter = {
9068 .f = cmd_tunnel_filter_parsed,
9070 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9071 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9072 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9073 "<queue_id>: Add/Rm tunnel filter of a port",
9075 (void *)&cmd_tunnel_filter_cmd,
9076 (void *)&cmd_tunnel_filter_what,
9077 (void *)&cmd_tunnel_filter_port_id,
9078 (void *)&cmd_tunnel_filter_outer_mac,
9079 (void *)&cmd_tunnel_filter_inner_mac,
9080 (void *)&cmd_tunnel_filter_ip_value,
9081 (void *)&cmd_tunnel_filter_innner_vlan,
9082 (void *)&cmd_tunnel_filter_tunnel_type,
9083 (void *)&cmd_tunnel_filter_filter_type,
9084 (void *)&cmd_tunnel_filter_tenant_id,
9085 (void *)&cmd_tunnel_filter_queue_num,
9090 /* *** CONFIGURE TUNNEL UDP PORT *** */
9091 struct cmd_tunnel_udp_config {
9092 cmdline_fixed_string_t cmd;
9093 cmdline_fixed_string_t what;
9099 cmd_tunnel_udp_config_parsed(void *parsed_result,
9100 __attribute__((unused)) struct cmdline *cl,
9101 __attribute__((unused)) void *data)
9103 struct cmd_tunnel_udp_config *res = parsed_result;
9104 struct rte_eth_udp_tunnel tunnel_udp;
9107 tunnel_udp.udp_port = res->udp_port;
9109 if (!strcmp(res->cmd, "rx_vxlan_port"))
9110 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9112 if (!strcmp(res->what, "add"))
9113 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9116 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9120 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9123 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9125 cmd, "rx_vxlan_port");
9126 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9127 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9129 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9132 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9133 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9136 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9137 .f = cmd_tunnel_udp_config_parsed,
9139 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9140 "Add/Remove a tunneling UDP port filter",
9142 (void *)&cmd_tunnel_udp_config_cmd,
9143 (void *)&cmd_tunnel_udp_config_what,
9144 (void *)&cmd_tunnel_udp_config_udp_port,
9145 (void *)&cmd_tunnel_udp_config_port_id,
9150 struct cmd_config_tunnel_udp_port {
9151 cmdline_fixed_string_t port;
9152 cmdline_fixed_string_t config;
9154 cmdline_fixed_string_t udp_tunnel_port;
9155 cmdline_fixed_string_t action;
9156 cmdline_fixed_string_t tunnel_type;
9161 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9162 __attribute__((unused)) struct cmdline *cl,
9163 __attribute__((unused)) void *data)
9165 struct cmd_config_tunnel_udp_port *res = parsed_result;
9166 struct rte_eth_udp_tunnel tunnel_udp;
9169 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9172 tunnel_udp.udp_port = res->udp_port;
9174 if (!strcmp(res->tunnel_type, "vxlan")) {
9175 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9176 } else if (!strcmp(res->tunnel_type, "geneve")) {
9177 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9178 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9179 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9181 printf("Invalid tunnel type\n");
9185 if (!strcmp(res->action, "add"))
9186 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9189 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9193 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9196 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9197 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9199 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9200 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9202 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9203 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9205 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9206 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9209 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9210 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9212 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9213 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9214 "vxlan#geneve#vxlan-gpe");
9215 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9216 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9219 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9220 .f = cmd_cfg_tunnel_udp_port_parsed,
9222 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9224 (void *)&cmd_config_tunnel_udp_port_port,
9225 (void *)&cmd_config_tunnel_udp_port_config,
9226 (void *)&cmd_config_tunnel_udp_port_port_id,
9227 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9228 (void *)&cmd_config_tunnel_udp_port_action,
9229 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9230 (void *)&cmd_config_tunnel_udp_port_value,
9235 /* *** GLOBAL CONFIG *** */
9236 struct cmd_global_config_result {
9237 cmdline_fixed_string_t cmd;
9239 cmdline_fixed_string_t cfg_type;
9244 cmd_global_config_parsed(void *parsed_result,
9245 __attribute__((unused)) struct cmdline *cl,
9246 __attribute__((unused)) void *data)
9248 struct cmd_global_config_result *res = parsed_result;
9249 struct rte_eth_global_cfg conf;
9252 memset(&conf, 0, sizeof(conf));
9253 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9254 conf.cfg.gre_key_len = res->len;
9255 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9256 RTE_ETH_FILTER_SET, &conf);
9258 printf("Global config error\n");
9261 cmdline_parse_token_string_t cmd_global_config_cmd =
9262 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9264 cmdline_parse_token_num_t cmd_global_config_port_id =
9265 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9267 cmdline_parse_token_string_t cmd_global_config_type =
9268 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9269 cfg_type, "gre-key-len");
9270 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9271 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9274 cmdline_parse_inst_t cmd_global_config = {
9275 .f = cmd_global_config_parsed,
9276 .data = (void *)NULL,
9277 .help_str = "global_config <port_id> gre-key-len <key_len>",
9279 (void *)&cmd_global_config_cmd,
9280 (void *)&cmd_global_config_port_id,
9281 (void *)&cmd_global_config_type,
9282 (void *)&cmd_global_config_gre_key_len,
9287 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9288 struct cmd_set_mirror_mask_result {
9289 cmdline_fixed_string_t set;
9290 cmdline_fixed_string_t port;
9292 cmdline_fixed_string_t mirror;
9294 cmdline_fixed_string_t what;
9295 cmdline_fixed_string_t value;
9296 cmdline_fixed_string_t dstpool;
9298 cmdline_fixed_string_t on;
9301 cmdline_parse_token_string_t cmd_mirror_mask_set =
9302 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9304 cmdline_parse_token_string_t cmd_mirror_mask_port =
9305 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9307 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9308 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9310 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9311 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9312 mirror, "mirror-rule");
9313 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9314 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9316 cmdline_parse_token_string_t cmd_mirror_mask_what =
9317 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9318 what, "pool-mirror-up#pool-mirror-down"
9320 cmdline_parse_token_string_t cmd_mirror_mask_value =
9321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9323 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9324 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9325 dstpool, "dst-pool");
9326 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9327 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9329 cmdline_parse_token_string_t cmd_mirror_mask_on =
9330 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9334 cmd_set_mirror_mask_parsed(void *parsed_result,
9335 __attribute__((unused)) struct cmdline *cl,
9336 __attribute__((unused)) void *data)
9339 struct cmd_set_mirror_mask_result *res = parsed_result;
9340 struct rte_eth_mirror_conf mr_conf;
9342 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9344 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9346 mr_conf.dst_pool = res->dstpool_id;
9348 if (!strcmp(res->what, "pool-mirror-up")) {
9349 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9350 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9351 } else if (!strcmp(res->what, "pool-mirror-down")) {
9352 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9353 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9354 } else if (!strcmp(res->what, "vlan-mirror")) {
9355 mr_conf.rule_type = ETH_MIRROR_VLAN;
9356 nb_item = parse_item_list(res->value, "vlan",
9357 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9361 for (i = 0; i < nb_item; i++) {
9362 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9363 printf("Invalid vlan_id: must be < 4096\n");
9367 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9368 mr_conf.vlan.vlan_mask |= 1ULL << i;
9372 if (!strcmp(res->on, "on"))
9373 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9376 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9379 printf("mirror rule add error: (%s)\n", strerror(-ret));
9382 cmdline_parse_inst_t cmd_set_mirror_mask = {
9383 .f = cmd_set_mirror_mask_parsed,
9385 .help_str = "set port <port_id> mirror-rule <rule_id> "
9386 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9387 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9389 (void *)&cmd_mirror_mask_set,
9390 (void *)&cmd_mirror_mask_port,
9391 (void *)&cmd_mirror_mask_portid,
9392 (void *)&cmd_mirror_mask_mirror,
9393 (void *)&cmd_mirror_mask_ruleid,
9394 (void *)&cmd_mirror_mask_what,
9395 (void *)&cmd_mirror_mask_value,
9396 (void *)&cmd_mirror_mask_dstpool,
9397 (void *)&cmd_mirror_mask_poolid,
9398 (void *)&cmd_mirror_mask_on,
9403 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9404 struct cmd_set_mirror_link_result {
9405 cmdline_fixed_string_t set;
9406 cmdline_fixed_string_t port;
9408 cmdline_fixed_string_t mirror;
9410 cmdline_fixed_string_t what;
9411 cmdline_fixed_string_t dstpool;
9413 cmdline_fixed_string_t on;
9416 cmdline_parse_token_string_t cmd_mirror_link_set =
9417 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9419 cmdline_parse_token_string_t cmd_mirror_link_port =
9420 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9422 cmdline_parse_token_num_t cmd_mirror_link_portid =
9423 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9425 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9426 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9427 mirror, "mirror-rule");
9428 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9429 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9431 cmdline_parse_token_string_t cmd_mirror_link_what =
9432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9433 what, "uplink-mirror#downlink-mirror");
9434 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9435 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9436 dstpool, "dst-pool");
9437 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9438 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9440 cmdline_parse_token_string_t cmd_mirror_link_on =
9441 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9445 cmd_set_mirror_link_parsed(void *parsed_result,
9446 __attribute__((unused)) struct cmdline *cl,
9447 __attribute__((unused)) void *data)
9450 struct cmd_set_mirror_link_result *res = parsed_result;
9451 struct rte_eth_mirror_conf mr_conf;
9453 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9454 if (!strcmp(res->what, "uplink-mirror"))
9455 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9457 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9459 mr_conf.dst_pool = res->dstpool_id;
9461 if (!strcmp(res->on, "on"))
9462 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9465 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9468 /* check the return value and print it if is < 0 */
9470 printf("mirror rule add error: (%s)\n", strerror(-ret));
9474 cmdline_parse_inst_t cmd_set_mirror_link = {
9475 .f = cmd_set_mirror_link_parsed,
9477 .help_str = "set port <port_id> mirror-rule <rule_id> "
9478 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9480 (void *)&cmd_mirror_link_set,
9481 (void *)&cmd_mirror_link_port,
9482 (void *)&cmd_mirror_link_portid,
9483 (void *)&cmd_mirror_link_mirror,
9484 (void *)&cmd_mirror_link_ruleid,
9485 (void *)&cmd_mirror_link_what,
9486 (void *)&cmd_mirror_link_dstpool,
9487 (void *)&cmd_mirror_link_poolid,
9488 (void *)&cmd_mirror_link_on,
9493 /* *** RESET VM MIRROR RULE *** */
9494 struct cmd_rm_mirror_rule_result {
9495 cmdline_fixed_string_t reset;
9496 cmdline_fixed_string_t port;
9498 cmdline_fixed_string_t mirror;
9502 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9503 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9505 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9506 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9508 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9509 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9511 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9512 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9513 mirror, "mirror-rule");
9514 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9515 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9519 cmd_reset_mirror_rule_parsed(void *parsed_result,
9520 __attribute__((unused)) struct cmdline *cl,
9521 __attribute__((unused)) void *data)
9524 struct cmd_set_mirror_link_result *res = parsed_result;
9526 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9528 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9531 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9532 .f = cmd_reset_mirror_rule_parsed,
9534 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9536 (void *)&cmd_rm_mirror_rule_reset,
9537 (void *)&cmd_rm_mirror_rule_port,
9538 (void *)&cmd_rm_mirror_rule_portid,
9539 (void *)&cmd_rm_mirror_rule_mirror,
9540 (void *)&cmd_rm_mirror_rule_ruleid,
9545 /* ******************************************************************************** */
9547 struct cmd_dump_result {
9548 cmdline_fixed_string_t dump;
9552 dump_struct_sizes(void)
9554 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9555 DUMP_SIZE(struct rte_mbuf);
9556 DUMP_SIZE(struct rte_mempool);
9557 DUMP_SIZE(struct rte_ring);
9561 static void cmd_dump_parsed(void *parsed_result,
9562 __attribute__((unused)) struct cmdline *cl,
9563 __attribute__((unused)) void *data)
9565 struct cmd_dump_result *res = parsed_result;
9567 if (!strcmp(res->dump, "dump_physmem"))
9568 rte_dump_physmem_layout(stdout);
9569 else if (!strcmp(res->dump, "dump_memzone"))
9570 rte_memzone_dump(stdout);
9571 else if (!strcmp(res->dump, "dump_struct_sizes"))
9572 dump_struct_sizes();
9573 else if (!strcmp(res->dump, "dump_ring"))
9574 rte_ring_list_dump(stdout);
9575 else if (!strcmp(res->dump, "dump_mempool"))
9576 rte_mempool_list_dump(stdout);
9577 else if (!strcmp(res->dump, "dump_devargs"))
9578 rte_devargs_dump(stdout);
9579 else if (!strcmp(res->dump, "dump_log_types"))
9580 rte_log_dump(stdout);
9583 cmdline_parse_token_string_t cmd_dump_dump =
9584 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9587 "dump_struct_sizes#"
9593 cmdline_parse_inst_t cmd_dump = {
9594 .f = cmd_dump_parsed, /* function to call */
9595 .data = NULL, /* 2nd arg of func */
9596 .help_str = "Dump status",
9597 .tokens = { /* token list, NULL terminated */
9598 (void *)&cmd_dump_dump,
9603 /* ******************************************************************************** */
9605 struct cmd_dump_one_result {
9606 cmdline_fixed_string_t dump;
9607 cmdline_fixed_string_t name;
9610 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9611 __attribute__((unused)) void *data)
9613 struct cmd_dump_one_result *res = parsed_result;
9615 if (!strcmp(res->dump, "dump_ring")) {
9617 r = rte_ring_lookup(res->name);
9619 cmdline_printf(cl, "Cannot find ring\n");
9622 rte_ring_dump(stdout, r);
9623 } else if (!strcmp(res->dump, "dump_mempool")) {
9624 struct rte_mempool *mp;
9625 mp = rte_mempool_lookup(res->name);
9627 cmdline_printf(cl, "Cannot find mempool\n");
9630 rte_mempool_dump(stdout, mp);
9634 cmdline_parse_token_string_t cmd_dump_one_dump =
9635 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9636 "dump_ring#dump_mempool");
9638 cmdline_parse_token_string_t cmd_dump_one_name =
9639 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9641 cmdline_parse_inst_t cmd_dump_one = {
9642 .f = cmd_dump_one_parsed, /* function to call */
9643 .data = NULL, /* 2nd arg of func */
9644 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9645 .tokens = { /* token list, NULL terminated */
9646 (void *)&cmd_dump_one_dump,
9647 (void *)&cmd_dump_one_name,
9652 /* *** Add/Del syn filter *** */
9653 struct cmd_syn_filter_result {
9654 cmdline_fixed_string_t filter;
9656 cmdline_fixed_string_t ops;
9657 cmdline_fixed_string_t priority;
9658 cmdline_fixed_string_t high;
9659 cmdline_fixed_string_t queue;
9664 cmd_syn_filter_parsed(void *parsed_result,
9665 __attribute__((unused)) struct cmdline *cl,
9666 __attribute__((unused)) void *data)
9668 struct cmd_syn_filter_result *res = parsed_result;
9669 struct rte_eth_syn_filter syn_filter;
9672 ret = rte_eth_dev_filter_supported(res->port_id,
9673 RTE_ETH_FILTER_SYN);
9675 printf("syn filter is not supported on port %u.\n",
9680 memset(&syn_filter, 0, sizeof(syn_filter));
9682 if (!strcmp(res->ops, "add")) {
9683 if (!strcmp(res->high, "high"))
9684 syn_filter.hig_pri = 1;
9686 syn_filter.hig_pri = 0;
9688 syn_filter.queue = res->queue_id;
9689 ret = rte_eth_dev_filter_ctrl(res->port_id,
9694 ret = rte_eth_dev_filter_ctrl(res->port_id,
9696 RTE_ETH_FILTER_DELETE,
9700 printf("syn filter programming error: (%s)\n",
9704 cmdline_parse_token_string_t cmd_syn_filter_filter =
9705 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9706 filter, "syn_filter");
9707 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9708 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9710 cmdline_parse_token_string_t cmd_syn_filter_ops =
9711 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9713 cmdline_parse_token_string_t cmd_syn_filter_priority =
9714 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9715 priority, "priority");
9716 cmdline_parse_token_string_t cmd_syn_filter_high =
9717 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9719 cmdline_parse_token_string_t cmd_syn_filter_queue =
9720 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9722 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9723 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9726 cmdline_parse_inst_t cmd_syn_filter = {
9727 .f = cmd_syn_filter_parsed,
9729 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9730 "<queue_id>: Add/Delete syn filter",
9732 (void *)&cmd_syn_filter_filter,
9733 (void *)&cmd_syn_filter_port_id,
9734 (void *)&cmd_syn_filter_ops,
9735 (void *)&cmd_syn_filter_priority,
9736 (void *)&cmd_syn_filter_high,
9737 (void *)&cmd_syn_filter_queue,
9738 (void *)&cmd_syn_filter_queue_id,
9743 /* *** queue region set *** */
9744 struct cmd_queue_region_result {
9745 cmdline_fixed_string_t set;
9746 cmdline_fixed_string_t port;
9748 cmdline_fixed_string_t cmd;
9749 cmdline_fixed_string_t region;
9751 cmdline_fixed_string_t queue_start_index;
9753 cmdline_fixed_string_t queue_num;
9754 uint8_t queue_num_value;
9758 cmd_queue_region_parsed(void *parsed_result,
9759 __attribute__((unused)) struct cmdline *cl,
9760 __attribute__((unused)) void *data)
9762 struct cmd_queue_region_result *res = parsed_result;
9764 #ifdef RTE_LIBRTE_I40E_PMD
9765 struct rte_pmd_i40e_queue_region_conf region_conf;
9766 enum rte_pmd_i40e_queue_region_op op_type;
9769 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9772 #ifdef RTE_LIBRTE_I40E_PMD
9773 memset(®ion_conf, 0, sizeof(region_conf));
9774 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9775 region_conf.region_id = res->region_id;
9776 region_conf.queue_num = res->queue_num_value;
9777 region_conf.queue_start_index = res->queue_id;
9779 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9780 op_type, ®ion_conf);
9787 printf("function not implemented or supported\n");
9790 printf("queue region config error: (%s)\n", strerror(-ret));
9794 cmdline_parse_token_string_t cmd_queue_region_set =
9795 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9797 cmdline_parse_token_string_t cmd_queue_region_port =
9798 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9799 cmdline_parse_token_num_t cmd_queue_region_port_id =
9800 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9802 cmdline_parse_token_string_t cmd_queue_region_cmd =
9803 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9804 cmd, "queue-region");
9805 cmdline_parse_token_string_t cmd_queue_region_id =
9806 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9807 region, "region_id");
9808 cmdline_parse_token_num_t cmd_queue_region_index =
9809 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9811 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9812 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9813 queue_start_index, "queue_start_index");
9814 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9815 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9817 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9818 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9819 queue_num, "queue_num");
9820 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9821 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9822 queue_num_value, UINT8);
9824 cmdline_parse_inst_t cmd_queue_region = {
9825 .f = cmd_queue_region_parsed,
9827 .help_str = "set port <port_id> queue-region region_id <value> "
9828 "queue_start_index <value> queue_num <value>: Set a queue region",
9830 (void *)&cmd_queue_region_set,
9831 (void *)&cmd_queue_region_port,
9832 (void *)&cmd_queue_region_port_id,
9833 (void *)&cmd_queue_region_cmd,
9834 (void *)&cmd_queue_region_id,
9835 (void *)&cmd_queue_region_index,
9836 (void *)&cmd_queue_region_queue_start_index,
9837 (void *)&cmd_queue_region_queue_id,
9838 (void *)&cmd_queue_region_queue_num,
9839 (void *)&cmd_queue_region_queue_num_value,
9844 /* *** queue region and flowtype set *** */
9845 struct cmd_region_flowtype_result {
9846 cmdline_fixed_string_t set;
9847 cmdline_fixed_string_t port;
9849 cmdline_fixed_string_t cmd;
9850 cmdline_fixed_string_t region;
9852 cmdline_fixed_string_t flowtype;
9853 uint8_t flowtype_id;
9857 cmd_region_flowtype_parsed(void *parsed_result,
9858 __attribute__((unused)) struct cmdline *cl,
9859 __attribute__((unused)) void *data)
9861 struct cmd_region_flowtype_result *res = parsed_result;
9863 #ifdef RTE_LIBRTE_I40E_PMD
9864 struct rte_pmd_i40e_queue_region_conf region_conf;
9865 enum rte_pmd_i40e_queue_region_op op_type;
9868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9871 #ifdef RTE_LIBRTE_I40E_PMD
9872 memset(®ion_conf, 0, sizeof(region_conf));
9874 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9875 region_conf.region_id = res->region_id;
9876 region_conf.hw_flowtype = res->flowtype_id;
9878 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9879 op_type, ®ion_conf);
9886 printf("function not implemented or supported\n");
9889 printf("region flowtype config error: (%s)\n", strerror(-ret));
9893 cmdline_parse_token_string_t cmd_region_flowtype_set =
9894 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9896 cmdline_parse_token_string_t cmd_region_flowtype_port =
9897 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9899 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9900 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9902 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9903 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9904 cmd, "queue-region");
9905 cmdline_parse_token_string_t cmd_region_flowtype_index =
9906 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9907 region, "region_id");
9908 cmdline_parse_token_num_t cmd_region_flowtype_id =
9909 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9911 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9912 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9913 flowtype, "flowtype");
9914 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9915 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9916 flowtype_id, UINT8);
9917 cmdline_parse_inst_t cmd_region_flowtype = {
9918 .f = cmd_region_flowtype_parsed,
9920 .help_str = "set port <port_id> queue-region region_id <value> "
9921 "flowtype <value>: Set a flowtype region index",
9923 (void *)&cmd_region_flowtype_set,
9924 (void *)&cmd_region_flowtype_port,
9925 (void *)&cmd_region_flowtype_port_index,
9926 (void *)&cmd_region_flowtype_cmd,
9927 (void *)&cmd_region_flowtype_index,
9928 (void *)&cmd_region_flowtype_id,
9929 (void *)&cmd_region_flowtype_flow_index,
9930 (void *)&cmd_region_flowtype_flow_id,
9935 /* *** User Priority (UP) to queue region (region_id) set *** */
9936 struct cmd_user_priority_region_result {
9937 cmdline_fixed_string_t set;
9938 cmdline_fixed_string_t port;
9940 cmdline_fixed_string_t cmd;
9941 cmdline_fixed_string_t user_priority;
9942 uint8_t user_priority_id;
9943 cmdline_fixed_string_t region;
9948 cmd_user_priority_region_parsed(void *parsed_result,
9949 __attribute__((unused)) struct cmdline *cl,
9950 __attribute__((unused)) void *data)
9952 struct cmd_user_priority_region_result *res = parsed_result;
9954 #ifdef RTE_LIBRTE_I40E_PMD
9955 struct rte_pmd_i40e_queue_region_conf region_conf;
9956 enum rte_pmd_i40e_queue_region_op op_type;
9959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9962 #ifdef RTE_LIBRTE_I40E_PMD
9963 memset(®ion_conf, 0, sizeof(region_conf));
9964 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9965 region_conf.user_priority = res->user_priority_id;
9966 region_conf.region_id = res->region_id;
9968 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9969 op_type, ®ion_conf);
9976 printf("function not implemented or supported\n");
9979 printf("user_priority region config error: (%s)\n",
9984 cmdline_parse_token_string_t cmd_user_priority_region_set =
9985 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9987 cmdline_parse_token_string_t cmd_user_priority_region_port =
9988 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9990 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9991 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9993 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9994 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9995 cmd, "queue-region");
9996 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9997 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9998 user_priority, "UP");
9999 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10000 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10001 user_priority_id, UINT8);
10002 cmdline_parse_token_string_t cmd_user_priority_region_region =
10003 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10004 region, "region_id");
10005 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10006 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10009 cmdline_parse_inst_t cmd_user_priority_region = {
10010 .f = cmd_user_priority_region_parsed,
10012 .help_str = "set port <port_id> queue-region UP <value> "
10013 "region_id <value>: Set the mapping of User Priority (UP) "
10014 "to queue region (region_id) ",
10016 (void *)&cmd_user_priority_region_set,
10017 (void *)&cmd_user_priority_region_port,
10018 (void *)&cmd_user_priority_region_port_index,
10019 (void *)&cmd_user_priority_region_cmd,
10020 (void *)&cmd_user_priority_region_UP,
10021 (void *)&cmd_user_priority_region_UP_id,
10022 (void *)&cmd_user_priority_region_region,
10023 (void *)&cmd_user_priority_region_region_id,
10028 /* *** flush all queue region related configuration *** */
10029 struct cmd_flush_queue_region_result {
10030 cmdline_fixed_string_t set;
10031 cmdline_fixed_string_t port;
10033 cmdline_fixed_string_t cmd;
10034 cmdline_fixed_string_t flush;
10035 cmdline_fixed_string_t what;
10039 cmd_flush_queue_region_parsed(void *parsed_result,
10040 __attribute__((unused)) struct cmdline *cl,
10041 __attribute__((unused)) void *data)
10043 struct cmd_flush_queue_region_result *res = parsed_result;
10044 int ret = -ENOTSUP;
10045 #ifdef RTE_LIBRTE_I40E_PMD
10046 struct rte_pmd_i40e_queue_region_conf region_conf;
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(®ion_conf, 0, sizeof(region_conf));
10056 if (strcmp(res->what, "on") == 0)
10057 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10059 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10061 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10062 op_type, ®ion_conf);
10069 printf("function not implemented or supported\n");
10072 printf("queue region config flush error: (%s)\n",
10077 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10078 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10080 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10081 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10083 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10084 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10086 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10087 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10088 cmd, "queue-region");
10089 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10090 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10092 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10093 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10096 cmdline_parse_inst_t cmd_flush_queue_region = {
10097 .f = cmd_flush_queue_region_parsed,
10099 .help_str = "set port <port_id> queue-region flush on|off"
10100 ": flush all queue region related configuration",
10102 (void *)&cmd_flush_queue_region_set,
10103 (void *)&cmd_flush_queue_region_port,
10104 (void *)&cmd_flush_queue_region_port_index,
10105 (void *)&cmd_flush_queue_region_cmd,
10106 (void *)&cmd_flush_queue_region_flush,
10107 (void *)&cmd_flush_queue_region_what,
10112 /* *** get all queue region related configuration info *** */
10113 struct cmd_show_queue_region_info {
10114 cmdline_fixed_string_t show;
10115 cmdline_fixed_string_t port;
10117 cmdline_fixed_string_t cmd;
10121 cmd_show_queue_region_info_parsed(void *parsed_result,
10122 __attribute__((unused)) struct cmdline *cl,
10123 __attribute__((unused)) void *data)
10125 struct cmd_show_queue_region_info *res = parsed_result;
10126 int ret = -ENOTSUP;
10127 #ifdef RTE_LIBRTE_I40E_PMD
10128 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10129 enum rte_pmd_i40e_queue_region_op op_type;
10132 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10135 #ifdef RTE_LIBRTE_I40E_PMD
10136 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10138 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10140 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10141 op_type, &rte_pmd_regions);
10143 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10150 printf("function not implemented or supported\n");
10153 printf("queue region config info show error: (%s)\n",
10158 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10159 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10161 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10162 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10164 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10165 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10167 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10168 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10169 cmd, "queue-region");
10171 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10172 .f = cmd_show_queue_region_info_parsed,
10174 .help_str = "show port <port_id> queue-region"
10175 ": show all queue region related configuration info",
10177 (void *)&cmd_show_queue_region_info_get,
10178 (void *)&cmd_show_queue_region_info_port,
10179 (void *)&cmd_show_queue_region_info_port_index,
10180 (void *)&cmd_show_queue_region_info_cmd,
10185 /* *** ADD/REMOVE A 2tuple FILTER *** */
10186 struct cmd_2tuple_filter_result {
10187 cmdline_fixed_string_t filter;
10189 cmdline_fixed_string_t ops;
10190 cmdline_fixed_string_t dst_port;
10191 uint16_t dst_port_value;
10192 cmdline_fixed_string_t protocol;
10193 uint8_t protocol_value;
10194 cmdline_fixed_string_t mask;
10195 uint8_t mask_value;
10196 cmdline_fixed_string_t tcp_flags;
10197 uint8_t tcp_flags_value;
10198 cmdline_fixed_string_t priority;
10199 uint8_t priority_value;
10200 cmdline_fixed_string_t queue;
10205 cmd_2tuple_filter_parsed(void *parsed_result,
10206 __attribute__((unused)) struct cmdline *cl,
10207 __attribute__((unused)) void *data)
10209 struct rte_eth_ntuple_filter filter;
10210 struct cmd_2tuple_filter_result *res = parsed_result;
10213 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10215 printf("ntuple filter is not supported on port %u.\n",
10220 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10222 filter.flags = RTE_2TUPLE_FLAGS;
10223 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10224 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10225 filter.proto = res->protocol_value;
10226 filter.priority = res->priority_value;
10227 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10228 printf("nonzero tcp_flags is only meaningful"
10229 " when protocol is TCP.\n");
10232 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10233 printf("invalid TCP flags.\n");
10237 if (res->tcp_flags_value != 0) {
10238 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10239 filter.tcp_flags = res->tcp_flags_value;
10242 /* need convert to big endian. */
10243 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10244 filter.queue = res->queue_id;
10246 if (!strcmp(res->ops, "add"))
10247 ret = rte_eth_dev_filter_ctrl(res->port_id,
10248 RTE_ETH_FILTER_NTUPLE,
10249 RTE_ETH_FILTER_ADD,
10252 ret = rte_eth_dev_filter_ctrl(res->port_id,
10253 RTE_ETH_FILTER_NTUPLE,
10254 RTE_ETH_FILTER_DELETE,
10257 printf("2tuple filter programming error: (%s)\n",
10262 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10263 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10264 filter, "2tuple_filter");
10265 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10266 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10268 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10269 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10271 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10272 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10273 dst_port, "dst_port");
10274 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10275 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10276 dst_port_value, UINT16);
10277 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10278 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10279 protocol, "protocol");
10280 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10281 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10282 protocol_value, UINT8);
10283 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10284 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10286 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10287 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10289 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10290 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10291 tcp_flags, "tcp_flags");
10292 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10293 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10294 tcp_flags_value, UINT8);
10295 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10296 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10297 priority, "priority");
10298 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10299 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10300 priority_value, UINT8);
10301 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10302 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10304 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10305 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10308 cmdline_parse_inst_t cmd_2tuple_filter = {
10309 .f = cmd_2tuple_filter_parsed,
10311 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10312 "<value> mask <value> tcp_flags <value> priority <value> queue "
10313 "<queue_id>: Add a 2tuple filter",
10315 (void *)&cmd_2tuple_filter_filter,
10316 (void *)&cmd_2tuple_filter_port_id,
10317 (void *)&cmd_2tuple_filter_ops,
10318 (void *)&cmd_2tuple_filter_dst_port,
10319 (void *)&cmd_2tuple_filter_dst_port_value,
10320 (void *)&cmd_2tuple_filter_protocol,
10321 (void *)&cmd_2tuple_filter_protocol_value,
10322 (void *)&cmd_2tuple_filter_mask,
10323 (void *)&cmd_2tuple_filter_mask_value,
10324 (void *)&cmd_2tuple_filter_tcp_flags,
10325 (void *)&cmd_2tuple_filter_tcp_flags_value,
10326 (void *)&cmd_2tuple_filter_priority,
10327 (void *)&cmd_2tuple_filter_priority_value,
10328 (void *)&cmd_2tuple_filter_queue,
10329 (void *)&cmd_2tuple_filter_queue_id,
10334 /* *** ADD/REMOVE A 5tuple FILTER *** */
10335 struct cmd_5tuple_filter_result {
10336 cmdline_fixed_string_t filter;
10338 cmdline_fixed_string_t ops;
10339 cmdline_fixed_string_t dst_ip;
10340 cmdline_ipaddr_t dst_ip_value;
10341 cmdline_fixed_string_t src_ip;
10342 cmdline_ipaddr_t src_ip_value;
10343 cmdline_fixed_string_t dst_port;
10344 uint16_t dst_port_value;
10345 cmdline_fixed_string_t src_port;
10346 uint16_t src_port_value;
10347 cmdline_fixed_string_t protocol;
10348 uint8_t protocol_value;
10349 cmdline_fixed_string_t mask;
10350 uint8_t mask_value;
10351 cmdline_fixed_string_t tcp_flags;
10352 uint8_t tcp_flags_value;
10353 cmdline_fixed_string_t priority;
10354 uint8_t priority_value;
10355 cmdline_fixed_string_t queue;
10360 cmd_5tuple_filter_parsed(void *parsed_result,
10361 __attribute__((unused)) struct cmdline *cl,
10362 __attribute__((unused)) void *data)
10364 struct rte_eth_ntuple_filter filter;
10365 struct cmd_5tuple_filter_result *res = parsed_result;
10368 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10370 printf("ntuple filter is not supported on port %u.\n",
10375 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10377 filter.flags = RTE_5TUPLE_FLAGS;
10378 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10379 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10380 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10381 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10382 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10383 filter.proto = res->protocol_value;
10384 filter.priority = res->priority_value;
10385 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10386 printf("nonzero tcp_flags is only meaningful"
10387 " when protocol is TCP.\n");
10390 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10391 printf("invalid TCP flags.\n");
10395 if (res->tcp_flags_value != 0) {
10396 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10397 filter.tcp_flags = res->tcp_flags_value;
10400 if (res->dst_ip_value.family == AF_INET)
10401 /* no need to convert, already big endian. */
10402 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10404 if (filter.dst_ip_mask == 0) {
10405 printf("can not support ipv6 involved compare.\n");
10411 if (res->src_ip_value.family == AF_INET)
10412 /* no need to convert, already big endian. */
10413 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10415 if (filter.src_ip_mask == 0) {
10416 printf("can not support ipv6 involved compare.\n");
10421 /* need convert to big endian. */
10422 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10423 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10424 filter.queue = res->queue_id;
10426 if (!strcmp(res->ops, "add"))
10427 ret = rte_eth_dev_filter_ctrl(res->port_id,
10428 RTE_ETH_FILTER_NTUPLE,
10429 RTE_ETH_FILTER_ADD,
10432 ret = rte_eth_dev_filter_ctrl(res->port_id,
10433 RTE_ETH_FILTER_NTUPLE,
10434 RTE_ETH_FILTER_DELETE,
10437 printf("5tuple filter programming error: (%s)\n",
10441 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10442 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10443 filter, "5tuple_filter");
10444 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10445 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10447 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10448 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10450 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10451 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10453 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10454 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10456 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10457 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10459 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10460 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10462 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10463 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10464 dst_port, "dst_port");
10465 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10466 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10467 dst_port_value, UINT16);
10468 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10469 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10470 src_port, "src_port");
10471 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10472 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10473 src_port_value, UINT16);
10474 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10475 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10476 protocol, "protocol");
10477 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10478 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10479 protocol_value, UINT8);
10480 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10481 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10483 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10484 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10486 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10487 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10488 tcp_flags, "tcp_flags");
10489 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10490 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10491 tcp_flags_value, UINT8);
10492 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10493 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10494 priority, "priority");
10495 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10496 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10497 priority_value, UINT8);
10498 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10499 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10501 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10502 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10505 cmdline_parse_inst_t cmd_5tuple_filter = {
10506 .f = cmd_5tuple_filter_parsed,
10508 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10509 "src_ip <value> dst_port <value> src_port <value> "
10510 "protocol <value> mask <value> tcp_flags <value> "
10511 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10513 (void *)&cmd_5tuple_filter_filter,
10514 (void *)&cmd_5tuple_filter_port_id,
10515 (void *)&cmd_5tuple_filter_ops,
10516 (void *)&cmd_5tuple_filter_dst_ip,
10517 (void *)&cmd_5tuple_filter_dst_ip_value,
10518 (void *)&cmd_5tuple_filter_src_ip,
10519 (void *)&cmd_5tuple_filter_src_ip_value,
10520 (void *)&cmd_5tuple_filter_dst_port,
10521 (void *)&cmd_5tuple_filter_dst_port_value,
10522 (void *)&cmd_5tuple_filter_src_port,
10523 (void *)&cmd_5tuple_filter_src_port_value,
10524 (void *)&cmd_5tuple_filter_protocol,
10525 (void *)&cmd_5tuple_filter_protocol_value,
10526 (void *)&cmd_5tuple_filter_mask,
10527 (void *)&cmd_5tuple_filter_mask_value,
10528 (void *)&cmd_5tuple_filter_tcp_flags,
10529 (void *)&cmd_5tuple_filter_tcp_flags_value,
10530 (void *)&cmd_5tuple_filter_priority,
10531 (void *)&cmd_5tuple_filter_priority_value,
10532 (void *)&cmd_5tuple_filter_queue,
10533 (void *)&cmd_5tuple_filter_queue_id,
10538 /* *** ADD/REMOVE A flex FILTER *** */
10539 struct cmd_flex_filter_result {
10540 cmdline_fixed_string_t filter;
10541 cmdline_fixed_string_t ops;
10543 cmdline_fixed_string_t len;
10545 cmdline_fixed_string_t bytes;
10546 cmdline_fixed_string_t bytes_value;
10547 cmdline_fixed_string_t mask;
10548 cmdline_fixed_string_t mask_value;
10549 cmdline_fixed_string_t priority;
10550 uint8_t priority_value;
10551 cmdline_fixed_string_t queue;
10555 static int xdigit2val(unsigned char c)
10560 else if (isupper(c))
10561 val = c - 'A' + 10;
10563 val = c - 'a' + 10;
10568 cmd_flex_filter_parsed(void *parsed_result,
10569 __attribute__((unused)) struct cmdline *cl,
10570 __attribute__((unused)) void *data)
10573 struct rte_eth_flex_filter filter;
10574 struct cmd_flex_filter_result *res = parsed_result;
10575 char *bytes_ptr, *mask_ptr;
10576 uint16_t len, i, j = 0;
10581 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10582 printf("the len exceed the max length 128\n");
10585 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10586 filter.len = res->len_value;
10587 filter.priority = res->priority_value;
10588 filter.queue = res->queue_id;
10589 bytes_ptr = res->bytes_value;
10590 mask_ptr = res->mask_value;
10592 /* translate bytes string to array. */
10593 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10594 (bytes_ptr[1] == 'X')))
10596 len = strnlen(bytes_ptr, res->len_value * 2);
10597 if (len == 0 || (len % 8 != 0)) {
10598 printf("please check len and bytes input\n");
10601 for (i = 0; i < len; i++) {
10603 if (isxdigit(c) == 0) {
10604 /* invalid characters. */
10605 printf("invalid input\n");
10608 val = xdigit2val(c);
10611 filter.bytes[j] = byte;
10612 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10619 /* translate mask string to uint8_t array. */
10620 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10621 (mask_ptr[1] == 'X')))
10623 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10625 printf("invalid input\n");
10630 for (i = 0; i < len; i++) {
10632 if (isxdigit(c) == 0) {
10633 /* invalid characters. */
10634 printf("invalid input\n");
10637 val = xdigit2val(c);
10640 filter.mask[j] = byte;
10641 printf("mask[%d]:%02x ", j, filter.mask[j]);
10649 if (!strcmp(res->ops, "add"))
10650 ret = rte_eth_dev_filter_ctrl(res->port_id,
10651 RTE_ETH_FILTER_FLEXIBLE,
10652 RTE_ETH_FILTER_ADD,
10655 ret = rte_eth_dev_filter_ctrl(res->port_id,
10656 RTE_ETH_FILTER_FLEXIBLE,
10657 RTE_ETH_FILTER_DELETE,
10661 printf("flex filter setting error: (%s)\n", strerror(-ret));
10664 cmdline_parse_token_string_t cmd_flex_filter_filter =
10665 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10666 filter, "flex_filter");
10667 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10668 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10670 cmdline_parse_token_string_t cmd_flex_filter_ops =
10671 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10673 cmdline_parse_token_string_t cmd_flex_filter_len =
10674 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10676 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10677 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10679 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10680 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10682 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10683 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10684 bytes_value, NULL);
10685 cmdline_parse_token_string_t cmd_flex_filter_mask =
10686 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10688 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10689 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10691 cmdline_parse_token_string_t cmd_flex_filter_priority =
10692 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10693 priority, "priority");
10694 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10695 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10696 priority_value, UINT8);
10697 cmdline_parse_token_string_t cmd_flex_filter_queue =
10698 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10700 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10701 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10703 cmdline_parse_inst_t cmd_flex_filter = {
10704 .f = cmd_flex_filter_parsed,
10706 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10707 "<value> mask <value> priority <value> queue <queue_id>: "
10708 "Add/Del a flex filter",
10710 (void *)&cmd_flex_filter_filter,
10711 (void *)&cmd_flex_filter_port_id,
10712 (void *)&cmd_flex_filter_ops,
10713 (void *)&cmd_flex_filter_len,
10714 (void *)&cmd_flex_filter_len_value,
10715 (void *)&cmd_flex_filter_bytes,
10716 (void *)&cmd_flex_filter_bytes_value,
10717 (void *)&cmd_flex_filter_mask,
10718 (void *)&cmd_flex_filter_mask_value,
10719 (void *)&cmd_flex_filter_priority,
10720 (void *)&cmd_flex_filter_priority_value,
10721 (void *)&cmd_flex_filter_queue,
10722 (void *)&cmd_flex_filter_queue_id,
10727 /* *** Filters Control *** */
10729 /* *** deal with ethertype filter *** */
10730 struct cmd_ethertype_filter_result {
10731 cmdline_fixed_string_t filter;
10733 cmdline_fixed_string_t ops;
10734 cmdline_fixed_string_t mac;
10735 struct rte_ether_addr mac_addr;
10736 cmdline_fixed_string_t ethertype;
10737 uint16_t ethertype_value;
10738 cmdline_fixed_string_t drop;
10739 cmdline_fixed_string_t queue;
10743 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10744 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10745 filter, "ethertype_filter");
10746 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10747 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10749 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10750 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10752 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10753 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10754 mac, "mac_addr#mac_ignr");
10755 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10756 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10758 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10759 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10760 ethertype, "ethertype");
10761 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10762 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10763 ethertype_value, UINT16);
10764 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10765 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10767 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10768 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10770 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10771 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10775 cmd_ethertype_filter_parsed(void *parsed_result,
10776 __attribute__((unused)) struct cmdline *cl,
10777 __attribute__((unused)) void *data)
10779 struct cmd_ethertype_filter_result *res = parsed_result;
10780 struct rte_eth_ethertype_filter filter;
10783 ret = rte_eth_dev_filter_supported(res->port_id,
10784 RTE_ETH_FILTER_ETHERTYPE);
10786 printf("ethertype filter is not supported on port %u.\n",
10791 memset(&filter, 0, sizeof(filter));
10792 if (!strcmp(res->mac, "mac_addr")) {
10793 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10794 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10795 sizeof(struct rte_ether_addr));
10797 if (!strcmp(res->drop, "drop"))
10798 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10799 filter.ether_type = res->ethertype_value;
10800 filter.queue = res->queue_id;
10802 if (!strcmp(res->ops, "add"))
10803 ret = rte_eth_dev_filter_ctrl(res->port_id,
10804 RTE_ETH_FILTER_ETHERTYPE,
10805 RTE_ETH_FILTER_ADD,
10808 ret = rte_eth_dev_filter_ctrl(res->port_id,
10809 RTE_ETH_FILTER_ETHERTYPE,
10810 RTE_ETH_FILTER_DELETE,
10813 printf("ethertype filter programming error: (%s)\n",
10817 cmdline_parse_inst_t cmd_ethertype_filter = {
10818 .f = cmd_ethertype_filter_parsed,
10820 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10821 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10822 "Add or delete an ethertype filter entry",
10824 (void *)&cmd_ethertype_filter_filter,
10825 (void *)&cmd_ethertype_filter_port_id,
10826 (void *)&cmd_ethertype_filter_ops,
10827 (void *)&cmd_ethertype_filter_mac,
10828 (void *)&cmd_ethertype_filter_mac_addr,
10829 (void *)&cmd_ethertype_filter_ethertype,
10830 (void *)&cmd_ethertype_filter_ethertype_value,
10831 (void *)&cmd_ethertype_filter_drop,
10832 (void *)&cmd_ethertype_filter_queue,
10833 (void *)&cmd_ethertype_filter_queue_id,
10838 /* *** deal with flow director filter *** */
10839 struct cmd_flow_director_result {
10840 cmdline_fixed_string_t flow_director_filter;
10842 cmdline_fixed_string_t mode;
10843 cmdline_fixed_string_t mode_value;
10844 cmdline_fixed_string_t ops;
10845 cmdline_fixed_string_t flow;
10846 cmdline_fixed_string_t flow_type;
10847 cmdline_fixed_string_t ether;
10848 uint16_t ether_type;
10849 cmdline_fixed_string_t src;
10850 cmdline_ipaddr_t ip_src;
10852 cmdline_fixed_string_t dst;
10853 cmdline_ipaddr_t ip_dst;
10855 cmdline_fixed_string_t verify_tag;
10856 uint32_t verify_tag_value;
10857 cmdline_fixed_string_t tos;
10859 cmdline_fixed_string_t proto;
10860 uint8_t proto_value;
10861 cmdline_fixed_string_t ttl;
10863 cmdline_fixed_string_t vlan;
10864 uint16_t vlan_value;
10865 cmdline_fixed_string_t flexbytes;
10866 cmdline_fixed_string_t flexbytes_value;
10867 cmdline_fixed_string_t pf_vf;
10868 cmdline_fixed_string_t drop;
10869 cmdline_fixed_string_t queue;
10871 cmdline_fixed_string_t fd_id;
10872 uint32_t fd_id_value;
10873 cmdline_fixed_string_t mac;
10874 struct rte_ether_addr mac_addr;
10875 cmdline_fixed_string_t tunnel;
10876 cmdline_fixed_string_t tunnel_type;
10877 cmdline_fixed_string_t tunnel_id;
10878 uint32_t tunnel_id_value;
10879 cmdline_fixed_string_t packet;
10884 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10887 const char *p, *p0 = q_arg;
10889 unsigned long int_fld;
10890 char *str_fld[max_num];
10895 p = strchr(p0, '(');
10899 p0 = strchr(p, ')');
10904 if (size >= sizeof(s))
10907 snprintf(s, sizeof(s), "%.*s", size, p);
10908 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10909 if (ret < 0 || ret > max_num)
10911 for (i = 0; i < ret; i++) {
10913 int_fld = strtoul(str_fld[i], &end, 0);
10914 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10916 flexbytes[i] = (uint8_t)int_fld;
10922 str2flowtype(char *string)
10925 static const struct {
10928 } flowtype_str[] = {
10929 {"raw", RTE_ETH_FLOW_RAW},
10930 {"ipv4", RTE_ETH_FLOW_IPV4},
10931 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10932 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10933 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10934 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10935 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10936 {"ipv6", RTE_ETH_FLOW_IPV6},
10937 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10938 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10939 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10940 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10941 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10942 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10945 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10946 if (!strcmp(flowtype_str[i].str, string))
10947 return flowtype_str[i].type;
10950 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10951 return (uint16_t)atoi(string);
10953 return RTE_ETH_FLOW_UNKNOWN;
10956 static enum rte_eth_fdir_tunnel_type
10957 str2fdir_tunneltype(char *string)
10961 static const struct {
10963 enum rte_eth_fdir_tunnel_type type;
10964 } tunneltype_str[] = {
10965 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10966 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10969 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10970 if (!strcmp(tunneltype_str[i].str, string))
10971 return tunneltype_str[i].type;
10973 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10976 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10978 if ((ip_addr).family == AF_INET) \
10979 (ip) = (ip_addr).addr.ipv4.s_addr; \
10981 printf("invalid parameter.\n"); \
10986 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10988 if ((ip_addr).family == AF_INET6) \
10989 rte_memcpy(&(ip), \
10990 &((ip_addr).addr.ipv6), \
10991 sizeof(struct in6_addr)); \
10993 printf("invalid parameter.\n"); \
10999 cmd_flow_director_filter_parsed(void *parsed_result,
11000 __attribute__((unused)) struct cmdline *cl,
11001 __attribute__((unused)) void *data)
11003 struct cmd_flow_director_result *res = parsed_result;
11004 struct rte_eth_fdir_filter entry;
11005 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11007 unsigned long vf_id;
11010 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11012 printf("flow director is not supported on port %u.\n",
11016 memset(flexbytes, 0, sizeof(flexbytes));
11017 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11019 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11020 if (strcmp(res->mode_value, "MAC-VLAN")) {
11021 printf("Please set mode to MAC-VLAN.\n");
11024 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11025 if (strcmp(res->mode_value, "Tunnel")) {
11026 printf("Please set mode to Tunnel.\n");
11030 if (!strcmp(res->mode_value, "raw")) {
11031 #ifdef RTE_LIBRTE_I40E_PMD
11032 struct rte_pmd_i40e_flow_type_mapping
11033 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11034 struct rte_pmd_i40e_pkt_template_conf conf;
11035 uint16_t flow_type = str2flowtype(res->flow_type);
11036 uint16_t i, port = res->port_id;
11039 memset(&conf, 0, sizeof(conf));
11041 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11042 printf("Invalid flow type specified.\n");
11045 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11049 if (mapping[flow_type].pctype == 0ULL) {
11050 printf("Invalid flow type specified.\n");
11053 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11054 if (mapping[flow_type].pctype & (1ULL << i)) {
11055 conf.input.pctype = i;
11060 conf.input.packet = open_file(res->filepath,
11061 &conf.input.length);
11062 if (!conf.input.packet)
11064 if (!strcmp(res->drop, "drop"))
11065 conf.action.behavior =
11066 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11068 conf.action.behavior =
11069 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11070 conf.action.report_status =
11071 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11072 conf.action.rx_queue = res->queue_id;
11073 conf.soft_id = res->fd_id_value;
11074 add = strcmp(res->ops, "del") ? 1 : 0;
11075 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11079 printf("flow director config error: (%s)\n",
11081 close_file(conf.input.packet);
11084 } else if (strcmp(res->mode_value, "IP")) {
11085 printf("Please set mode to IP or raw.\n");
11088 entry.input.flow_type = str2flowtype(res->flow_type);
11091 ret = parse_flexbytes(res->flexbytes_value,
11093 RTE_ETH_FDIR_MAX_FLEXLEN);
11095 printf("error: Cannot parse flexbytes input.\n");
11099 switch (entry.input.flow_type) {
11100 case RTE_ETH_FLOW_FRAG_IPV4:
11101 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11102 entry.input.flow.ip4_flow.proto = res->proto_value;
11104 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11105 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11106 IPV4_ADDR_TO_UINT(res->ip_dst,
11107 entry.input.flow.ip4_flow.dst_ip);
11108 IPV4_ADDR_TO_UINT(res->ip_src,
11109 entry.input.flow.ip4_flow.src_ip);
11110 entry.input.flow.ip4_flow.tos = res->tos_value;
11111 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11112 /* need convert to big endian. */
11113 entry.input.flow.udp4_flow.dst_port =
11114 rte_cpu_to_be_16(res->port_dst);
11115 entry.input.flow.udp4_flow.src_port =
11116 rte_cpu_to_be_16(res->port_src);
11118 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11119 IPV4_ADDR_TO_UINT(res->ip_dst,
11120 entry.input.flow.sctp4_flow.ip.dst_ip);
11121 IPV4_ADDR_TO_UINT(res->ip_src,
11122 entry.input.flow.sctp4_flow.ip.src_ip);
11123 entry.input.flow.ip4_flow.tos = res->tos_value;
11124 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11125 /* need convert to big endian. */
11126 entry.input.flow.sctp4_flow.dst_port =
11127 rte_cpu_to_be_16(res->port_dst);
11128 entry.input.flow.sctp4_flow.src_port =
11129 rte_cpu_to_be_16(res->port_src);
11130 entry.input.flow.sctp4_flow.verify_tag =
11131 rte_cpu_to_be_32(res->verify_tag_value);
11133 case RTE_ETH_FLOW_FRAG_IPV6:
11134 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11135 entry.input.flow.ipv6_flow.proto = res->proto_value;
11137 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11138 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11139 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11140 entry.input.flow.ipv6_flow.dst_ip);
11141 IPV6_ADDR_TO_ARRAY(res->ip_src,
11142 entry.input.flow.ipv6_flow.src_ip);
11143 entry.input.flow.ipv6_flow.tc = res->tos_value;
11144 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11145 /* need convert to big endian. */
11146 entry.input.flow.udp6_flow.dst_port =
11147 rte_cpu_to_be_16(res->port_dst);
11148 entry.input.flow.udp6_flow.src_port =
11149 rte_cpu_to_be_16(res->port_src);
11151 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11152 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11153 entry.input.flow.sctp6_flow.ip.dst_ip);
11154 IPV6_ADDR_TO_ARRAY(res->ip_src,
11155 entry.input.flow.sctp6_flow.ip.src_ip);
11156 entry.input.flow.ipv6_flow.tc = res->tos_value;
11157 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11158 /* need convert to big endian. */
11159 entry.input.flow.sctp6_flow.dst_port =
11160 rte_cpu_to_be_16(res->port_dst);
11161 entry.input.flow.sctp6_flow.src_port =
11162 rte_cpu_to_be_16(res->port_src);
11163 entry.input.flow.sctp6_flow.verify_tag =
11164 rte_cpu_to_be_32(res->verify_tag_value);
11166 case RTE_ETH_FLOW_L2_PAYLOAD:
11167 entry.input.flow.l2_flow.ether_type =
11168 rte_cpu_to_be_16(res->ether_type);
11174 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11175 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11177 sizeof(struct rte_ether_addr));
11179 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11180 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11182 sizeof(struct rte_ether_addr));
11183 entry.input.flow.tunnel_flow.tunnel_type =
11184 str2fdir_tunneltype(res->tunnel_type);
11185 entry.input.flow.tunnel_flow.tunnel_id =
11186 rte_cpu_to_be_32(res->tunnel_id_value);
11189 rte_memcpy(entry.input.flow_ext.flexbytes,
11191 RTE_ETH_FDIR_MAX_FLEXLEN);
11193 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11195 entry.action.flex_off = 0; /*use 0 by default */
11196 if (!strcmp(res->drop, "drop"))
11197 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11199 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11201 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11202 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11203 if (!strcmp(res->pf_vf, "pf"))
11204 entry.input.flow_ext.is_vf = 0;
11205 else if (!strncmp(res->pf_vf, "vf", 2)) {
11206 struct rte_eth_dev_info dev_info;
11208 ret = eth_dev_info_get_print_err(res->port_id,
11214 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11215 if (errno != 0 || *end != '\0' ||
11216 vf_id >= dev_info.max_vfs) {
11217 printf("invalid parameter %s.\n", res->pf_vf);
11220 entry.input.flow_ext.is_vf = 1;
11221 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11223 printf("invalid parameter %s.\n", res->pf_vf);
11228 /* set to report FD ID by default */
11229 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11230 entry.action.rx_queue = res->queue_id;
11231 entry.soft_id = res->fd_id_value;
11232 if (!strcmp(res->ops, "add"))
11233 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11234 RTE_ETH_FILTER_ADD, &entry);
11235 else if (!strcmp(res->ops, "del"))
11236 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11237 RTE_ETH_FILTER_DELETE, &entry);
11239 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11240 RTE_ETH_FILTER_UPDATE, &entry);
11242 printf("flow director programming error: (%s)\n",
11246 cmdline_parse_token_string_t cmd_flow_director_filter =
11247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11248 flow_director_filter, "flow_director_filter");
11249 cmdline_parse_token_num_t cmd_flow_director_port_id =
11250 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11252 cmdline_parse_token_string_t cmd_flow_director_ops =
11253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11254 ops, "add#del#update");
11255 cmdline_parse_token_string_t cmd_flow_director_flow =
11256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11258 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11261 cmdline_parse_token_string_t cmd_flow_director_ether =
11262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11264 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11265 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11266 ether_type, UINT16);
11267 cmdline_parse_token_string_t cmd_flow_director_src =
11268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11270 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11271 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11273 cmdline_parse_token_num_t cmd_flow_director_port_src =
11274 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11276 cmdline_parse_token_string_t cmd_flow_director_dst =
11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11279 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11280 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11282 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11283 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11285 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11287 verify_tag, "verify_tag");
11288 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11290 verify_tag_value, UINT32);
11291 cmdline_parse_token_string_t cmd_flow_director_tos =
11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11294 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11295 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11297 cmdline_parse_token_string_t cmd_flow_director_proto =
11298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11300 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11301 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11302 proto_value, UINT8);
11303 cmdline_parse_token_string_t cmd_flow_director_ttl =
11304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11306 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11307 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11309 cmdline_parse_token_string_t cmd_flow_director_vlan =
11310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11312 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11313 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11314 vlan_value, UINT16);
11315 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11316 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11317 flexbytes, "flexbytes");
11318 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11320 flexbytes_value, NULL);
11321 cmdline_parse_token_string_t cmd_flow_director_drop =
11322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11324 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11327 cmdline_parse_token_string_t cmd_flow_director_queue =
11328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11330 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11331 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11333 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11336 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11338 fd_id_value, UINT32);
11340 cmdline_parse_token_string_t cmd_flow_director_mode =
11341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11343 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11346 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11348 mode_value, "MAC-VLAN");
11349 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11351 mode_value, "Tunnel");
11352 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11354 mode_value, "raw");
11355 cmdline_parse_token_string_t cmd_flow_director_mac =
11356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11358 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11359 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11361 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11364 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11366 tunnel_type, "NVGRE#VxLAN");
11367 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11369 tunnel_id, "tunnel-id");
11370 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11371 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11372 tunnel_id_value, UINT32);
11373 cmdline_parse_token_string_t cmd_flow_director_packet =
11374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11376 cmdline_parse_token_string_t cmd_flow_director_filepath =
11377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11380 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11381 .f = cmd_flow_director_filter_parsed,
11383 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11384 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11385 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11386 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11387 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11388 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11389 "fd_id <fd_id_value>: "
11390 "Add or delete an ip flow director entry on NIC",
11392 (void *)&cmd_flow_director_filter,
11393 (void *)&cmd_flow_director_port_id,
11394 (void *)&cmd_flow_director_mode,
11395 (void *)&cmd_flow_director_mode_ip,
11396 (void *)&cmd_flow_director_ops,
11397 (void *)&cmd_flow_director_flow,
11398 (void *)&cmd_flow_director_flow_type,
11399 (void *)&cmd_flow_director_src,
11400 (void *)&cmd_flow_director_ip_src,
11401 (void *)&cmd_flow_director_dst,
11402 (void *)&cmd_flow_director_ip_dst,
11403 (void *)&cmd_flow_director_tos,
11404 (void *)&cmd_flow_director_tos_value,
11405 (void *)&cmd_flow_director_proto,
11406 (void *)&cmd_flow_director_proto_value,
11407 (void *)&cmd_flow_director_ttl,
11408 (void *)&cmd_flow_director_ttl_value,
11409 (void *)&cmd_flow_director_vlan,
11410 (void *)&cmd_flow_director_vlan_value,
11411 (void *)&cmd_flow_director_flexbytes,
11412 (void *)&cmd_flow_director_flexbytes_value,
11413 (void *)&cmd_flow_director_drop,
11414 (void *)&cmd_flow_director_pf_vf,
11415 (void *)&cmd_flow_director_queue,
11416 (void *)&cmd_flow_director_queue_id,
11417 (void *)&cmd_flow_director_fd_id,
11418 (void *)&cmd_flow_director_fd_id_value,
11423 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11424 .f = cmd_flow_director_filter_parsed,
11426 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11427 "director entry on NIC",
11429 (void *)&cmd_flow_director_filter,
11430 (void *)&cmd_flow_director_port_id,
11431 (void *)&cmd_flow_director_mode,
11432 (void *)&cmd_flow_director_mode_ip,
11433 (void *)&cmd_flow_director_ops,
11434 (void *)&cmd_flow_director_flow,
11435 (void *)&cmd_flow_director_flow_type,
11436 (void *)&cmd_flow_director_src,
11437 (void *)&cmd_flow_director_ip_src,
11438 (void *)&cmd_flow_director_port_src,
11439 (void *)&cmd_flow_director_dst,
11440 (void *)&cmd_flow_director_ip_dst,
11441 (void *)&cmd_flow_director_port_dst,
11442 (void *)&cmd_flow_director_tos,
11443 (void *)&cmd_flow_director_tos_value,
11444 (void *)&cmd_flow_director_ttl,
11445 (void *)&cmd_flow_director_ttl_value,
11446 (void *)&cmd_flow_director_vlan,
11447 (void *)&cmd_flow_director_vlan_value,
11448 (void *)&cmd_flow_director_flexbytes,
11449 (void *)&cmd_flow_director_flexbytes_value,
11450 (void *)&cmd_flow_director_drop,
11451 (void *)&cmd_flow_director_pf_vf,
11452 (void *)&cmd_flow_director_queue,
11453 (void *)&cmd_flow_director_queue_id,
11454 (void *)&cmd_flow_director_fd_id,
11455 (void *)&cmd_flow_director_fd_id_value,
11460 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11461 .f = cmd_flow_director_filter_parsed,
11463 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11464 "director entry on NIC",
11466 (void *)&cmd_flow_director_filter,
11467 (void *)&cmd_flow_director_port_id,
11468 (void *)&cmd_flow_director_mode,
11469 (void *)&cmd_flow_director_mode_ip,
11470 (void *)&cmd_flow_director_ops,
11471 (void *)&cmd_flow_director_flow,
11472 (void *)&cmd_flow_director_flow_type,
11473 (void *)&cmd_flow_director_src,
11474 (void *)&cmd_flow_director_ip_src,
11475 (void *)&cmd_flow_director_port_src,
11476 (void *)&cmd_flow_director_dst,
11477 (void *)&cmd_flow_director_ip_dst,
11478 (void *)&cmd_flow_director_port_dst,
11479 (void *)&cmd_flow_director_verify_tag,
11480 (void *)&cmd_flow_director_verify_tag_value,
11481 (void *)&cmd_flow_director_tos,
11482 (void *)&cmd_flow_director_tos_value,
11483 (void *)&cmd_flow_director_ttl,
11484 (void *)&cmd_flow_director_ttl_value,
11485 (void *)&cmd_flow_director_vlan,
11486 (void *)&cmd_flow_director_vlan_value,
11487 (void *)&cmd_flow_director_flexbytes,
11488 (void *)&cmd_flow_director_flexbytes_value,
11489 (void *)&cmd_flow_director_drop,
11490 (void *)&cmd_flow_director_pf_vf,
11491 (void *)&cmd_flow_director_queue,
11492 (void *)&cmd_flow_director_queue_id,
11493 (void *)&cmd_flow_director_fd_id,
11494 (void *)&cmd_flow_director_fd_id_value,
11499 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11500 .f = cmd_flow_director_filter_parsed,
11502 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11503 "director entry on NIC",
11505 (void *)&cmd_flow_director_filter,
11506 (void *)&cmd_flow_director_port_id,
11507 (void *)&cmd_flow_director_mode,
11508 (void *)&cmd_flow_director_mode_ip,
11509 (void *)&cmd_flow_director_ops,
11510 (void *)&cmd_flow_director_flow,
11511 (void *)&cmd_flow_director_flow_type,
11512 (void *)&cmd_flow_director_ether,
11513 (void *)&cmd_flow_director_ether_type,
11514 (void *)&cmd_flow_director_flexbytes,
11515 (void *)&cmd_flow_director_flexbytes_value,
11516 (void *)&cmd_flow_director_drop,
11517 (void *)&cmd_flow_director_pf_vf,
11518 (void *)&cmd_flow_director_queue,
11519 (void *)&cmd_flow_director_queue_id,
11520 (void *)&cmd_flow_director_fd_id,
11521 (void *)&cmd_flow_director_fd_id_value,
11526 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11527 .f = cmd_flow_director_filter_parsed,
11529 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11530 "director entry on NIC",
11532 (void *)&cmd_flow_director_filter,
11533 (void *)&cmd_flow_director_port_id,
11534 (void *)&cmd_flow_director_mode,
11535 (void *)&cmd_flow_director_mode_mac_vlan,
11536 (void *)&cmd_flow_director_ops,
11537 (void *)&cmd_flow_director_mac,
11538 (void *)&cmd_flow_director_mac_addr,
11539 (void *)&cmd_flow_director_vlan,
11540 (void *)&cmd_flow_director_vlan_value,
11541 (void *)&cmd_flow_director_flexbytes,
11542 (void *)&cmd_flow_director_flexbytes_value,
11543 (void *)&cmd_flow_director_drop,
11544 (void *)&cmd_flow_director_queue,
11545 (void *)&cmd_flow_director_queue_id,
11546 (void *)&cmd_flow_director_fd_id,
11547 (void *)&cmd_flow_director_fd_id_value,
11552 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11553 .f = cmd_flow_director_filter_parsed,
11555 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11556 "director entry on NIC",
11558 (void *)&cmd_flow_director_filter,
11559 (void *)&cmd_flow_director_port_id,
11560 (void *)&cmd_flow_director_mode,
11561 (void *)&cmd_flow_director_mode_tunnel,
11562 (void *)&cmd_flow_director_ops,
11563 (void *)&cmd_flow_director_mac,
11564 (void *)&cmd_flow_director_mac_addr,
11565 (void *)&cmd_flow_director_vlan,
11566 (void *)&cmd_flow_director_vlan_value,
11567 (void *)&cmd_flow_director_tunnel,
11568 (void *)&cmd_flow_director_tunnel_type,
11569 (void *)&cmd_flow_director_tunnel_id,
11570 (void *)&cmd_flow_director_tunnel_id_value,
11571 (void *)&cmd_flow_director_flexbytes,
11572 (void *)&cmd_flow_director_flexbytes_value,
11573 (void *)&cmd_flow_director_drop,
11574 (void *)&cmd_flow_director_queue,
11575 (void *)&cmd_flow_director_queue_id,
11576 (void *)&cmd_flow_director_fd_id,
11577 (void *)&cmd_flow_director_fd_id_value,
11582 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11583 .f = cmd_flow_director_filter_parsed,
11585 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11586 "director entry on NIC",
11588 (void *)&cmd_flow_director_filter,
11589 (void *)&cmd_flow_director_port_id,
11590 (void *)&cmd_flow_director_mode,
11591 (void *)&cmd_flow_director_mode_raw,
11592 (void *)&cmd_flow_director_ops,
11593 (void *)&cmd_flow_director_flow,
11594 (void *)&cmd_flow_director_flow_type,
11595 (void *)&cmd_flow_director_drop,
11596 (void *)&cmd_flow_director_queue,
11597 (void *)&cmd_flow_director_queue_id,
11598 (void *)&cmd_flow_director_fd_id,
11599 (void *)&cmd_flow_director_fd_id_value,
11600 (void *)&cmd_flow_director_packet,
11601 (void *)&cmd_flow_director_filepath,
11606 struct cmd_flush_flow_director_result {
11607 cmdline_fixed_string_t flush_flow_director;
11611 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11612 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11613 flush_flow_director, "flush_flow_director");
11614 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11615 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11619 cmd_flush_flow_director_parsed(void *parsed_result,
11620 __attribute__((unused)) struct cmdline *cl,
11621 __attribute__((unused)) void *data)
11623 struct cmd_flow_director_result *res = parsed_result;
11626 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11628 printf("flow director is not supported on port %u.\n",
11633 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11634 RTE_ETH_FILTER_FLUSH, NULL);
11636 printf("flow director table flushing error: (%s)\n",
11640 cmdline_parse_inst_t cmd_flush_flow_director = {
11641 .f = cmd_flush_flow_director_parsed,
11643 .help_str = "flush_flow_director <port_id>: "
11644 "Flush all flow director entries of a device on NIC",
11646 (void *)&cmd_flush_flow_director_flush,
11647 (void *)&cmd_flush_flow_director_port_id,
11652 /* *** deal with flow director mask *** */
11653 struct cmd_flow_director_mask_result {
11654 cmdline_fixed_string_t flow_director_mask;
11656 cmdline_fixed_string_t mode;
11657 cmdline_fixed_string_t mode_value;
11658 cmdline_fixed_string_t vlan;
11659 uint16_t vlan_mask;
11660 cmdline_fixed_string_t src_mask;
11661 cmdline_ipaddr_t ipv4_src;
11662 cmdline_ipaddr_t ipv6_src;
11664 cmdline_fixed_string_t dst_mask;
11665 cmdline_ipaddr_t ipv4_dst;
11666 cmdline_ipaddr_t ipv6_dst;
11668 cmdline_fixed_string_t mac;
11669 uint8_t mac_addr_byte_mask;
11670 cmdline_fixed_string_t tunnel_id;
11671 uint32_t tunnel_id_mask;
11672 cmdline_fixed_string_t tunnel_type;
11673 uint8_t tunnel_type_mask;
11677 cmd_flow_director_mask_parsed(void *parsed_result,
11678 __attribute__((unused)) struct cmdline *cl,
11679 __attribute__((unused)) void *data)
11681 struct cmd_flow_director_mask_result *res = parsed_result;
11682 struct rte_eth_fdir_masks *mask;
11683 struct rte_port *port;
11685 port = &ports[res->port_id];
11686 /** Check if the port is not started **/
11687 if (port->port_status != RTE_PORT_STOPPED) {
11688 printf("Please stop port %d first\n", res->port_id);
11692 mask = &port->dev_conf.fdir_conf.mask;
11694 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11695 if (strcmp(res->mode_value, "MAC-VLAN")) {
11696 printf("Please set mode to MAC-VLAN.\n");
11700 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11701 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11702 if (strcmp(res->mode_value, "Tunnel")) {
11703 printf("Please set mode to Tunnel.\n");
11707 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11708 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11709 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11710 mask->tunnel_type_mask = res->tunnel_type_mask;
11712 if (strcmp(res->mode_value, "IP")) {
11713 printf("Please set mode to IP.\n");
11717 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11718 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11719 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11720 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11721 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11722 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11723 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11726 cmd_reconfig_device_queue(res->port_id, 1, 1);
11729 cmdline_parse_token_string_t cmd_flow_director_mask =
11730 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11731 flow_director_mask, "flow_director_mask");
11732 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11733 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11735 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11738 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11739 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11740 vlan_mask, UINT16);
11741 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11743 src_mask, "src_mask");
11744 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11745 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11747 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11748 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11750 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11751 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11753 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11755 dst_mask, "dst_mask");
11756 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11757 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11759 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11760 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11762 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11766 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11769 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11770 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11772 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11774 mode_value, "MAC-VLAN");
11775 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11777 mode_value, "Tunnel");
11778 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11781 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11782 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11783 mac_addr_byte_mask, UINT8);
11784 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11786 tunnel_type, "tunnel-type");
11787 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11788 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11789 tunnel_type_mask, UINT8);
11790 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11792 tunnel_id, "tunnel-id");
11793 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11794 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11795 tunnel_id_mask, UINT32);
11797 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11798 .f = cmd_flow_director_mask_parsed,
11800 .help_str = "flow_director_mask ... : "
11801 "Set IP mode flow director's mask on NIC",
11803 (void *)&cmd_flow_director_mask,
11804 (void *)&cmd_flow_director_mask_port_id,
11805 (void *)&cmd_flow_director_mask_mode,
11806 (void *)&cmd_flow_director_mask_mode_ip,
11807 (void *)&cmd_flow_director_mask_vlan,
11808 (void *)&cmd_flow_director_mask_vlan_value,
11809 (void *)&cmd_flow_director_mask_src,
11810 (void *)&cmd_flow_director_mask_ipv4_src,
11811 (void *)&cmd_flow_director_mask_ipv6_src,
11812 (void *)&cmd_flow_director_mask_port_src,
11813 (void *)&cmd_flow_director_mask_dst,
11814 (void *)&cmd_flow_director_mask_ipv4_dst,
11815 (void *)&cmd_flow_director_mask_ipv6_dst,
11816 (void *)&cmd_flow_director_mask_port_dst,
11821 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11822 .f = cmd_flow_director_mask_parsed,
11824 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11825 "flow director's mask on NIC",
11827 (void *)&cmd_flow_director_mask,
11828 (void *)&cmd_flow_director_mask_port_id,
11829 (void *)&cmd_flow_director_mask_mode,
11830 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11831 (void *)&cmd_flow_director_mask_vlan,
11832 (void *)&cmd_flow_director_mask_vlan_value,
11837 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11838 .f = cmd_flow_director_mask_parsed,
11840 .help_str = "flow_director_mask ... : Set tunnel mode "
11841 "flow director's mask on NIC",
11843 (void *)&cmd_flow_director_mask,
11844 (void *)&cmd_flow_director_mask_port_id,
11845 (void *)&cmd_flow_director_mask_mode,
11846 (void *)&cmd_flow_director_mask_mode_tunnel,
11847 (void *)&cmd_flow_director_mask_vlan,
11848 (void *)&cmd_flow_director_mask_vlan_value,
11849 (void *)&cmd_flow_director_mask_mac,
11850 (void *)&cmd_flow_director_mask_mac_value,
11851 (void *)&cmd_flow_director_mask_tunnel_type,
11852 (void *)&cmd_flow_director_mask_tunnel_type_value,
11853 (void *)&cmd_flow_director_mask_tunnel_id,
11854 (void *)&cmd_flow_director_mask_tunnel_id_value,
11859 /* *** deal with flow director mask on flexible payload *** */
11860 struct cmd_flow_director_flex_mask_result {
11861 cmdline_fixed_string_t flow_director_flexmask;
11863 cmdline_fixed_string_t flow;
11864 cmdline_fixed_string_t flow_type;
11865 cmdline_fixed_string_t mask;
11869 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11870 __attribute__((unused)) struct cmdline *cl,
11871 __attribute__((unused)) void *data)
11873 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11874 struct rte_eth_fdir_info fdir_info;
11875 struct rte_eth_fdir_flex_mask flex_mask;
11876 struct rte_port *port;
11877 uint64_t flow_type_mask;
11881 port = &ports[res->port_id];
11882 /** Check if the port is not started **/
11883 if (port->port_status != RTE_PORT_STOPPED) {
11884 printf("Please stop port %d first\n", res->port_id);
11888 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11889 ret = parse_flexbytes(res->mask,
11891 RTE_ETH_FDIR_MAX_FLEXLEN);
11893 printf("error: Cannot parse mask input.\n");
11897 memset(&fdir_info, 0, sizeof(fdir_info));
11898 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11899 RTE_ETH_FILTER_INFO, &fdir_info);
11901 printf("Cannot get FDir filter info\n");
11905 if (!strcmp(res->flow_type, "none")) {
11906 /* means don't specify the flow type */
11907 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11908 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11909 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11910 0, sizeof(struct rte_eth_fdir_flex_mask));
11911 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11912 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11914 sizeof(struct rte_eth_fdir_flex_mask));
11915 cmd_reconfig_device_queue(res->port_id, 1, 1);
11918 flow_type_mask = fdir_info.flow_types_mask[0];
11919 if (!strcmp(res->flow_type, "all")) {
11920 if (!flow_type_mask) {
11921 printf("No flow type supported\n");
11924 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11925 if (flow_type_mask & (1ULL << i)) {
11926 flex_mask.flow_type = i;
11927 fdir_set_flex_mask(res->port_id, &flex_mask);
11930 cmd_reconfig_device_queue(res->port_id, 1, 1);
11933 flex_mask.flow_type = str2flowtype(res->flow_type);
11934 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11935 printf("Flow type %s not supported on port %d\n",
11936 res->flow_type, res->port_id);
11939 fdir_set_flex_mask(res->port_id, &flex_mask);
11940 cmd_reconfig_device_queue(res->port_id, 1, 1);
11943 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11945 flow_director_flexmask,
11946 "flow_director_flex_mask");
11947 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11948 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11950 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11951 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11953 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11954 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11955 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11956 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11957 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11958 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11961 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11962 .f = cmd_flow_director_flex_mask_parsed,
11964 .help_str = "flow_director_flex_mask ... : "
11965 "Set flow director's flex mask on NIC",
11967 (void *)&cmd_flow_director_flexmask,
11968 (void *)&cmd_flow_director_flexmask_port_id,
11969 (void *)&cmd_flow_director_flexmask_flow,
11970 (void *)&cmd_flow_director_flexmask_flow_type,
11971 (void *)&cmd_flow_director_flexmask_mask,
11976 /* *** deal with flow director flexible payload configuration *** */
11977 struct cmd_flow_director_flexpayload_result {
11978 cmdline_fixed_string_t flow_director_flexpayload;
11980 cmdline_fixed_string_t payload_layer;
11981 cmdline_fixed_string_t payload_cfg;
11985 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11988 const char *p, *p0 = q_arg;
11990 unsigned long int_fld;
11991 char *str_fld[max_num];
11996 p = strchr(p0, '(');
12000 p0 = strchr(p, ')');
12005 if (size >= sizeof(s))
12008 snprintf(s, sizeof(s), "%.*s", size, p);
12009 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12010 if (ret < 0 || ret > max_num)
12012 for (i = 0; i < ret; i++) {
12014 int_fld = strtoul(str_fld[i], &end, 0);
12015 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12017 offsets[i] = (uint16_t)int_fld;
12023 cmd_flow_director_flxpld_parsed(void *parsed_result,
12024 __attribute__((unused)) struct cmdline *cl,
12025 __attribute__((unused)) void *data)
12027 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12028 struct rte_eth_flex_payload_cfg flex_cfg;
12029 struct rte_port *port;
12032 port = &ports[res->port_id];
12033 /** Check if the port is not started **/
12034 if (port->port_status != RTE_PORT_STOPPED) {
12035 printf("Please stop port %d first\n", res->port_id);
12039 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12041 if (!strcmp(res->payload_layer, "raw"))
12042 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12043 else if (!strcmp(res->payload_layer, "l2"))
12044 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12045 else if (!strcmp(res->payload_layer, "l3"))
12046 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12047 else if (!strcmp(res->payload_layer, "l4"))
12048 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12050 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12051 RTE_ETH_FDIR_MAX_FLEXLEN);
12053 printf("error: Cannot parse flex payload input.\n");
12057 fdir_set_flex_payload(res->port_id, &flex_cfg);
12058 cmd_reconfig_device_queue(res->port_id, 1, 1);
12061 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12062 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12063 flow_director_flexpayload,
12064 "flow_director_flex_payload");
12065 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12066 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12068 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12069 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12070 payload_layer, "raw#l2#l3#l4");
12071 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12072 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12073 payload_cfg, NULL);
12075 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12076 .f = cmd_flow_director_flxpld_parsed,
12078 .help_str = "flow_director_flexpayload ... : "
12079 "Set flow director's flex payload on NIC",
12081 (void *)&cmd_flow_director_flexpayload,
12082 (void *)&cmd_flow_director_flexpayload_port_id,
12083 (void *)&cmd_flow_director_flexpayload_payload_layer,
12084 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12089 /* Generic flow interface command. */
12090 extern cmdline_parse_inst_t cmd_flow;
12092 /* *** Classification Filters Control *** */
12093 /* *** Get symmetric hash enable per port *** */
12094 struct cmd_get_sym_hash_ena_per_port_result {
12095 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12100 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12101 __rte_unused struct cmdline *cl,
12102 __rte_unused void *data)
12104 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12105 struct rte_eth_hash_filter_info info;
12108 if (rte_eth_dev_filter_supported(res->port_id,
12109 RTE_ETH_FILTER_HASH) < 0) {
12110 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12115 memset(&info, 0, sizeof(info));
12116 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12117 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12118 RTE_ETH_FILTER_GET, &info);
12121 printf("Cannot get symmetric hash enable per port "
12122 "on port %u\n", res->port_id);
12126 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12127 "enabled" : "disabled", res->port_id);
12130 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12131 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12132 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12133 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12134 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12137 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12138 .f = cmd_get_sym_hash_per_port_parsed,
12140 .help_str = "get_sym_hash_ena_per_port <port_id>",
12142 (void *)&cmd_get_sym_hash_ena_per_port_all,
12143 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12148 /* *** Set symmetric hash enable per port *** */
12149 struct cmd_set_sym_hash_ena_per_port_result {
12150 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12151 cmdline_fixed_string_t enable;
12156 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12157 __rte_unused struct cmdline *cl,
12158 __rte_unused void *data)
12160 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12161 struct rte_eth_hash_filter_info info;
12164 if (rte_eth_dev_filter_supported(res->port_id,
12165 RTE_ETH_FILTER_HASH) < 0) {
12166 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12171 memset(&info, 0, sizeof(info));
12172 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12173 if (!strcmp(res->enable, "enable"))
12174 info.info.enable = 1;
12175 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12176 RTE_ETH_FILTER_SET, &info);
12178 printf("Cannot set symmetric hash enable per port on "
12179 "port %u\n", res->port_id);
12182 printf("Symmetric hash has been set to %s on port %u\n",
12183 res->enable, res->port_id);
12186 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12187 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12188 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12189 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12190 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12192 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12193 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12194 enable, "enable#disable");
12196 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12197 .f = cmd_set_sym_hash_per_port_parsed,
12199 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12201 (void *)&cmd_set_sym_hash_ena_per_port_all,
12202 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12203 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12208 /* Get global config of hash function */
12209 struct cmd_get_hash_global_config_result {
12210 cmdline_fixed_string_t get_hash_global_config;
12215 flowtype_to_str(uint16_t ftype)
12221 } ftype_table[] = {
12222 {"ipv4", RTE_ETH_FLOW_IPV4},
12223 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12224 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12225 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12226 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12227 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12228 {"ipv6", RTE_ETH_FLOW_IPV6},
12229 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12230 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12231 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12232 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12233 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12234 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12235 {"port", RTE_ETH_FLOW_PORT},
12236 {"vxlan", RTE_ETH_FLOW_VXLAN},
12237 {"geneve", RTE_ETH_FLOW_GENEVE},
12238 {"nvgre", RTE_ETH_FLOW_NVGRE},
12239 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12242 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12243 if (ftype_table[i].ftype == ftype)
12244 return ftype_table[i].str;
12251 cmd_get_hash_global_config_parsed(void *parsed_result,
12252 __rte_unused struct cmdline *cl,
12253 __rte_unused void *data)
12255 struct cmd_get_hash_global_config_result *res = parsed_result;
12256 struct rte_eth_hash_filter_info info;
12257 uint32_t idx, offset;
12262 if (rte_eth_dev_filter_supported(res->port_id,
12263 RTE_ETH_FILTER_HASH) < 0) {
12264 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12269 memset(&info, 0, sizeof(info));
12270 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12271 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12272 RTE_ETH_FILTER_GET, &info);
12274 printf("Cannot get hash global configurations by port %d\n",
12279 switch (info.info.global_conf.hash_func) {
12280 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12281 printf("Hash function is Toeplitz\n");
12283 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12284 printf("Hash function is Simple XOR\n");
12286 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12287 printf("Hash function is Symmetric Toeplitz\n");
12290 printf("Unknown hash function\n");
12294 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12295 idx = i / UINT64_BIT;
12296 offset = i % UINT64_BIT;
12297 if (!(info.info.global_conf.valid_bit_mask[idx] &
12300 str = flowtype_to_str(i);
12303 printf("Symmetric hash is %s globally for flow type %s "
12305 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12306 (1ULL << offset)) ? "enabled" : "disabled"), str,
12311 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12312 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12313 get_hash_global_config, "get_hash_global_config");
12314 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12315 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12318 cmdline_parse_inst_t cmd_get_hash_global_config = {
12319 .f = cmd_get_hash_global_config_parsed,
12321 .help_str = "get_hash_global_config <port_id>",
12323 (void *)&cmd_get_hash_global_config_all,
12324 (void *)&cmd_get_hash_global_config_port_id,
12329 /* Set global config of hash function */
12330 struct cmd_set_hash_global_config_result {
12331 cmdline_fixed_string_t set_hash_global_config;
12333 cmdline_fixed_string_t hash_func;
12334 cmdline_fixed_string_t flow_type;
12335 cmdline_fixed_string_t enable;
12339 cmd_set_hash_global_config_parsed(void *parsed_result,
12340 __rte_unused struct cmdline *cl,
12341 __rte_unused void *data)
12343 struct cmd_set_hash_global_config_result *res = parsed_result;
12344 struct rte_eth_hash_filter_info info;
12345 uint32_t ftype, idx, offset;
12348 if (rte_eth_dev_filter_supported(res->port_id,
12349 RTE_ETH_FILTER_HASH) < 0) {
12350 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12354 memset(&info, 0, sizeof(info));
12355 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12356 if (!strcmp(res->hash_func, "toeplitz"))
12357 info.info.global_conf.hash_func =
12358 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12359 else if (!strcmp(res->hash_func, "simple_xor"))
12360 info.info.global_conf.hash_func =
12361 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12362 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12363 info.info.global_conf.hash_func =
12364 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12365 else if (!strcmp(res->hash_func, "default"))
12366 info.info.global_conf.hash_func =
12367 RTE_ETH_HASH_FUNCTION_DEFAULT;
12369 ftype = str2flowtype(res->flow_type);
12370 idx = ftype / UINT64_BIT;
12371 offset = ftype % UINT64_BIT;
12372 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12373 if (!strcmp(res->enable, "enable"))
12374 info.info.global_conf.sym_hash_enable_mask[idx] |=
12376 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12377 RTE_ETH_FILTER_SET, &info);
12379 printf("Cannot set global hash configurations by port %d\n",
12382 printf("Global hash configurations have been set "
12383 "successfully by port %d\n", res->port_id);
12386 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12387 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12388 set_hash_global_config, "set_hash_global_config");
12389 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12390 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12392 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12393 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12394 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12395 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12396 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12398 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12399 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12400 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12401 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12402 enable, "enable#disable");
12404 cmdline_parse_inst_t cmd_set_hash_global_config = {
12405 .f = cmd_set_hash_global_config_parsed,
12407 .help_str = "set_hash_global_config <port_id> "
12408 "toeplitz|simple_xor|symmetric_toeplitz|default "
12409 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12410 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12411 "l2_payload enable|disable",
12413 (void *)&cmd_set_hash_global_config_all,
12414 (void *)&cmd_set_hash_global_config_port_id,
12415 (void *)&cmd_set_hash_global_config_hash_func,
12416 (void *)&cmd_set_hash_global_config_flow_type,
12417 (void *)&cmd_set_hash_global_config_enable,
12422 /* Set hash input set */
12423 struct cmd_set_hash_input_set_result {
12424 cmdline_fixed_string_t set_hash_input_set;
12426 cmdline_fixed_string_t flow_type;
12427 cmdline_fixed_string_t inset_field;
12428 cmdline_fixed_string_t select;
12431 static enum rte_eth_input_set_field
12432 str2inset(char *string)
12436 static const struct {
12438 enum rte_eth_input_set_field inset;
12439 } inset_table[] = {
12440 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12441 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12442 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12443 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12444 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12445 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12446 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12447 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12448 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12449 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12450 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12451 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12452 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12453 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12454 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12455 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12456 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12457 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12458 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12459 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12460 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12461 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12462 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12463 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12464 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12465 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12466 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12467 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12468 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12469 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12470 {"none", RTE_ETH_INPUT_SET_NONE},
12473 for (i = 0; i < RTE_DIM(inset_table); i++) {
12474 if (!strcmp(string, inset_table[i].str))
12475 return inset_table[i].inset;
12478 return RTE_ETH_INPUT_SET_UNKNOWN;
12482 cmd_set_hash_input_set_parsed(void *parsed_result,
12483 __rte_unused struct cmdline *cl,
12484 __rte_unused void *data)
12486 struct cmd_set_hash_input_set_result *res = parsed_result;
12487 struct rte_eth_hash_filter_info info;
12489 memset(&info, 0, sizeof(info));
12490 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12491 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12492 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12493 info.info.input_set_conf.inset_size = 1;
12494 if (!strcmp(res->select, "select"))
12495 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12496 else if (!strcmp(res->select, "add"))
12497 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12498 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12499 RTE_ETH_FILTER_SET, &info);
12502 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12503 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12504 set_hash_input_set, "set_hash_input_set");
12505 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12506 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12508 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12509 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12511 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12512 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12514 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12515 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12516 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12517 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12518 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12520 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12521 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12522 select, "select#add");
12524 cmdline_parse_inst_t cmd_set_hash_input_set = {
12525 .f = cmd_set_hash_input_set_parsed,
12527 .help_str = "set_hash_input_set <port_id> "
12528 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12529 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12530 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12531 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12532 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12533 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12534 "fld-7th|fld-8th|none select|add",
12536 (void *)&cmd_set_hash_input_set_cmd,
12537 (void *)&cmd_set_hash_input_set_port_id,
12538 (void *)&cmd_set_hash_input_set_flow_type,
12539 (void *)&cmd_set_hash_input_set_field,
12540 (void *)&cmd_set_hash_input_set_select,
12545 /* Set flow director input set */
12546 struct cmd_set_fdir_input_set_result {
12547 cmdline_fixed_string_t set_fdir_input_set;
12549 cmdline_fixed_string_t flow_type;
12550 cmdline_fixed_string_t inset_field;
12551 cmdline_fixed_string_t select;
12555 cmd_set_fdir_input_set_parsed(void *parsed_result,
12556 __rte_unused struct cmdline *cl,
12557 __rte_unused void *data)
12559 struct cmd_set_fdir_input_set_result *res = parsed_result;
12560 struct rte_eth_fdir_filter_info info;
12562 memset(&info, 0, sizeof(info));
12563 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12564 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12565 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12566 info.info.input_set_conf.inset_size = 1;
12567 if (!strcmp(res->select, "select"))
12568 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12569 else if (!strcmp(res->select, "add"))
12570 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12571 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12572 RTE_ETH_FILTER_SET, &info);
12575 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12576 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12577 set_fdir_input_set, "set_fdir_input_set");
12578 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12579 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12581 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12582 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12584 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12585 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12586 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12587 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12589 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12590 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12591 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12592 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12593 "sctp-veri-tag#none");
12594 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12595 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12596 select, "select#add");
12598 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12599 .f = cmd_set_fdir_input_set_parsed,
12601 .help_str = "set_fdir_input_set <port_id> "
12602 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12603 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12604 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12605 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12606 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12607 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12608 "sctp-veri-tag|none select|add",
12610 (void *)&cmd_set_fdir_input_set_cmd,
12611 (void *)&cmd_set_fdir_input_set_port_id,
12612 (void *)&cmd_set_fdir_input_set_flow_type,
12613 (void *)&cmd_set_fdir_input_set_field,
12614 (void *)&cmd_set_fdir_input_set_select,
12619 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12620 struct cmd_mcast_addr_result {
12621 cmdline_fixed_string_t mcast_addr_cmd;
12622 cmdline_fixed_string_t what;
12624 struct rte_ether_addr mc_addr;
12627 static void cmd_mcast_addr_parsed(void *parsed_result,
12628 __attribute__((unused)) struct cmdline *cl,
12629 __attribute__((unused)) void *data)
12631 struct cmd_mcast_addr_result *res = parsed_result;
12633 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12634 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12635 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12636 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12637 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12640 if (strcmp(res->what, "add") == 0)
12641 mcast_addr_add(res->port_num, &res->mc_addr);
12643 mcast_addr_remove(res->port_num, &res->mc_addr);
12646 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12647 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12648 mcast_addr_cmd, "mcast_addr");
12649 cmdline_parse_token_string_t cmd_mcast_addr_what =
12650 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12652 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12653 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12654 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12655 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12657 cmdline_parse_inst_t cmd_mcast_addr = {
12658 .f = cmd_mcast_addr_parsed,
12660 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12661 "Add/Remove multicast MAC address on port_id",
12663 (void *)&cmd_mcast_addr_cmd,
12664 (void *)&cmd_mcast_addr_what,
12665 (void *)&cmd_mcast_addr_portnum,
12666 (void *)&cmd_mcast_addr_addr,
12671 /* l2 tunnel config
12672 * only support E-tag now.
12675 /* Ether type config */
12676 struct cmd_config_l2_tunnel_eth_type_result {
12677 cmdline_fixed_string_t port;
12678 cmdline_fixed_string_t config;
12679 cmdline_fixed_string_t all;
12681 cmdline_fixed_string_t l2_tunnel;
12682 cmdline_fixed_string_t l2_tunnel_type;
12683 cmdline_fixed_string_t eth_type;
12684 uint16_t eth_type_val;
12687 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12688 TOKEN_STRING_INITIALIZER
12689 (struct cmd_config_l2_tunnel_eth_type_result,
12691 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12692 TOKEN_STRING_INITIALIZER
12693 (struct cmd_config_l2_tunnel_eth_type_result,
12695 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12696 TOKEN_STRING_INITIALIZER
12697 (struct cmd_config_l2_tunnel_eth_type_result,
12699 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12700 TOKEN_NUM_INITIALIZER
12701 (struct cmd_config_l2_tunnel_eth_type_result,
12703 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12704 TOKEN_STRING_INITIALIZER
12705 (struct cmd_config_l2_tunnel_eth_type_result,
12706 l2_tunnel, "l2-tunnel");
12707 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12708 TOKEN_STRING_INITIALIZER
12709 (struct cmd_config_l2_tunnel_eth_type_result,
12710 l2_tunnel_type, "E-tag");
12711 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12712 TOKEN_STRING_INITIALIZER
12713 (struct cmd_config_l2_tunnel_eth_type_result,
12714 eth_type, "ether-type");
12715 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12716 TOKEN_NUM_INITIALIZER
12717 (struct cmd_config_l2_tunnel_eth_type_result,
12718 eth_type_val, UINT16);
12720 static enum rte_eth_tunnel_type
12721 str2fdir_l2_tunnel_type(char *string)
12725 static const struct {
12727 enum rte_eth_tunnel_type type;
12728 } l2_tunnel_type_str[] = {
12729 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12732 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12733 if (!strcmp(l2_tunnel_type_str[i].str, string))
12734 return l2_tunnel_type_str[i].type;
12736 return RTE_TUNNEL_TYPE_NONE;
12739 /* ether type config for all ports */
12741 cmd_config_l2_tunnel_eth_type_all_parsed
12742 (void *parsed_result,
12743 __attribute__((unused)) struct cmdline *cl,
12744 __attribute__((unused)) void *data)
12746 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12747 struct rte_eth_l2_tunnel_conf entry;
12750 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12751 entry.ether_type = res->eth_type_val;
12753 RTE_ETH_FOREACH_DEV(pid) {
12754 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12758 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12759 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12761 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12763 (void *)&cmd_config_l2_tunnel_eth_type_port,
12764 (void *)&cmd_config_l2_tunnel_eth_type_config,
12765 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12766 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12767 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12768 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12769 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12774 /* ether type config for a specific port */
12776 cmd_config_l2_tunnel_eth_type_specific_parsed(
12777 void *parsed_result,
12778 __attribute__((unused)) struct cmdline *cl,
12779 __attribute__((unused)) void *data)
12781 struct cmd_config_l2_tunnel_eth_type_result *res =
12783 struct rte_eth_l2_tunnel_conf entry;
12785 if (port_id_is_invalid(res->id, ENABLED_WARN))
12788 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12789 entry.ether_type = res->eth_type_val;
12791 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12794 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12795 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12797 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12799 (void *)&cmd_config_l2_tunnel_eth_type_port,
12800 (void *)&cmd_config_l2_tunnel_eth_type_config,
12801 (void *)&cmd_config_l2_tunnel_eth_type_id,
12802 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12803 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12804 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12805 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12810 /* Enable/disable l2 tunnel */
12811 struct cmd_config_l2_tunnel_en_dis_result {
12812 cmdline_fixed_string_t port;
12813 cmdline_fixed_string_t config;
12814 cmdline_fixed_string_t all;
12816 cmdline_fixed_string_t l2_tunnel;
12817 cmdline_fixed_string_t l2_tunnel_type;
12818 cmdline_fixed_string_t en_dis;
12821 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12822 TOKEN_STRING_INITIALIZER
12823 (struct cmd_config_l2_tunnel_en_dis_result,
12825 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12826 TOKEN_STRING_INITIALIZER
12827 (struct cmd_config_l2_tunnel_en_dis_result,
12829 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12830 TOKEN_STRING_INITIALIZER
12831 (struct cmd_config_l2_tunnel_en_dis_result,
12833 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12834 TOKEN_NUM_INITIALIZER
12835 (struct cmd_config_l2_tunnel_en_dis_result,
12837 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12838 TOKEN_STRING_INITIALIZER
12839 (struct cmd_config_l2_tunnel_en_dis_result,
12840 l2_tunnel, "l2-tunnel");
12841 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12842 TOKEN_STRING_INITIALIZER
12843 (struct cmd_config_l2_tunnel_en_dis_result,
12844 l2_tunnel_type, "E-tag");
12845 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12846 TOKEN_STRING_INITIALIZER
12847 (struct cmd_config_l2_tunnel_en_dis_result,
12848 en_dis, "enable#disable");
12850 /* enable/disable l2 tunnel for all ports */
12852 cmd_config_l2_tunnel_en_dis_all_parsed(
12853 void *parsed_result,
12854 __attribute__((unused)) struct cmdline *cl,
12855 __attribute__((unused)) void *data)
12857 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12858 struct rte_eth_l2_tunnel_conf entry;
12862 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12864 if (!strcmp("enable", res->en_dis))
12869 RTE_ETH_FOREACH_DEV(pid) {
12870 rte_eth_dev_l2_tunnel_offload_set(pid,
12872 ETH_L2_TUNNEL_ENABLE_MASK,
12877 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12878 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12880 .help_str = "port config all l2-tunnel E-tag enable|disable",
12882 (void *)&cmd_config_l2_tunnel_en_dis_port,
12883 (void *)&cmd_config_l2_tunnel_en_dis_config,
12884 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12885 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12886 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12887 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12892 /* enable/disable l2 tunnel for a port */
12894 cmd_config_l2_tunnel_en_dis_specific_parsed(
12895 void *parsed_result,
12896 __attribute__((unused)) struct cmdline *cl,
12897 __attribute__((unused)) void *data)
12899 struct cmd_config_l2_tunnel_en_dis_result *res =
12901 struct rte_eth_l2_tunnel_conf entry;
12903 if (port_id_is_invalid(res->id, ENABLED_WARN))
12906 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12908 if (!strcmp("enable", res->en_dis))
12909 rte_eth_dev_l2_tunnel_offload_set(res->id,
12911 ETH_L2_TUNNEL_ENABLE_MASK,
12914 rte_eth_dev_l2_tunnel_offload_set(res->id,
12916 ETH_L2_TUNNEL_ENABLE_MASK,
12920 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12921 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12923 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12925 (void *)&cmd_config_l2_tunnel_en_dis_port,
12926 (void *)&cmd_config_l2_tunnel_en_dis_config,
12927 (void *)&cmd_config_l2_tunnel_en_dis_id,
12928 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12929 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12930 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12935 /* E-tag configuration */
12937 /* Common result structure for all E-tag configuration */
12938 struct cmd_config_e_tag_result {
12939 cmdline_fixed_string_t e_tag;
12940 cmdline_fixed_string_t set;
12941 cmdline_fixed_string_t insertion;
12942 cmdline_fixed_string_t stripping;
12943 cmdline_fixed_string_t forwarding;
12944 cmdline_fixed_string_t filter;
12945 cmdline_fixed_string_t add;
12946 cmdline_fixed_string_t del;
12947 cmdline_fixed_string_t on;
12948 cmdline_fixed_string_t off;
12949 cmdline_fixed_string_t on_off;
12950 cmdline_fixed_string_t port_tag_id;
12951 uint32_t port_tag_id_val;
12952 cmdline_fixed_string_t e_tag_id;
12953 uint16_t e_tag_id_val;
12954 cmdline_fixed_string_t dst_pool;
12955 uint8_t dst_pool_val;
12956 cmdline_fixed_string_t port;
12958 cmdline_fixed_string_t vf;
12962 /* Common CLI fields for all E-tag configuration */
12963 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12964 TOKEN_STRING_INITIALIZER
12965 (struct cmd_config_e_tag_result,
12967 cmdline_parse_token_string_t cmd_config_e_tag_set =
12968 TOKEN_STRING_INITIALIZER
12969 (struct cmd_config_e_tag_result,
12971 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12972 TOKEN_STRING_INITIALIZER
12973 (struct cmd_config_e_tag_result,
12974 insertion, "insertion");
12975 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12976 TOKEN_STRING_INITIALIZER
12977 (struct cmd_config_e_tag_result,
12978 stripping, "stripping");
12979 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12980 TOKEN_STRING_INITIALIZER
12981 (struct cmd_config_e_tag_result,
12982 forwarding, "forwarding");
12983 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12984 TOKEN_STRING_INITIALIZER
12985 (struct cmd_config_e_tag_result,
12987 cmdline_parse_token_string_t cmd_config_e_tag_add =
12988 TOKEN_STRING_INITIALIZER
12989 (struct cmd_config_e_tag_result,
12991 cmdline_parse_token_string_t cmd_config_e_tag_del =
12992 TOKEN_STRING_INITIALIZER
12993 (struct cmd_config_e_tag_result,
12995 cmdline_parse_token_string_t cmd_config_e_tag_on =
12996 TOKEN_STRING_INITIALIZER
12997 (struct cmd_config_e_tag_result,
12999 cmdline_parse_token_string_t cmd_config_e_tag_off =
13000 TOKEN_STRING_INITIALIZER
13001 (struct cmd_config_e_tag_result,
13003 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13004 TOKEN_STRING_INITIALIZER
13005 (struct cmd_config_e_tag_result,
13007 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13008 TOKEN_STRING_INITIALIZER
13009 (struct cmd_config_e_tag_result,
13010 port_tag_id, "port-tag-id");
13011 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13012 TOKEN_NUM_INITIALIZER
13013 (struct cmd_config_e_tag_result,
13014 port_tag_id_val, UINT32);
13015 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13016 TOKEN_STRING_INITIALIZER
13017 (struct cmd_config_e_tag_result,
13018 e_tag_id, "e-tag-id");
13019 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13020 TOKEN_NUM_INITIALIZER
13021 (struct cmd_config_e_tag_result,
13022 e_tag_id_val, UINT16);
13023 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13024 TOKEN_STRING_INITIALIZER
13025 (struct cmd_config_e_tag_result,
13026 dst_pool, "dst-pool");
13027 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13028 TOKEN_NUM_INITIALIZER
13029 (struct cmd_config_e_tag_result,
13030 dst_pool_val, UINT8);
13031 cmdline_parse_token_string_t cmd_config_e_tag_port =
13032 TOKEN_STRING_INITIALIZER
13033 (struct cmd_config_e_tag_result,
13035 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13036 TOKEN_NUM_INITIALIZER
13037 (struct cmd_config_e_tag_result,
13039 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13040 TOKEN_STRING_INITIALIZER
13041 (struct cmd_config_e_tag_result,
13043 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13044 TOKEN_NUM_INITIALIZER
13045 (struct cmd_config_e_tag_result,
13048 /* E-tag insertion configuration */
13050 cmd_config_e_tag_insertion_en_parsed(
13051 void *parsed_result,
13052 __attribute__((unused)) struct cmdline *cl,
13053 __attribute__((unused)) void *data)
13055 struct cmd_config_e_tag_result *res =
13057 struct rte_eth_l2_tunnel_conf entry;
13059 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13062 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13063 entry.tunnel_id = res->port_tag_id_val;
13064 entry.vf_id = res->vf_id;
13065 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13067 ETH_L2_TUNNEL_INSERTION_MASK,
13072 cmd_config_e_tag_insertion_dis_parsed(
13073 void *parsed_result,
13074 __attribute__((unused)) struct cmdline *cl,
13075 __attribute__((unused)) void *data)
13077 struct cmd_config_e_tag_result *res =
13079 struct rte_eth_l2_tunnel_conf entry;
13081 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13084 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13085 entry.vf_id = res->vf_id;
13087 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13089 ETH_L2_TUNNEL_INSERTION_MASK,
13093 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13094 .f = cmd_config_e_tag_insertion_en_parsed,
13096 .help_str = "E-tag ... : E-tag insertion enable",
13098 (void *)&cmd_config_e_tag_e_tag,
13099 (void *)&cmd_config_e_tag_set,
13100 (void *)&cmd_config_e_tag_insertion,
13101 (void *)&cmd_config_e_tag_on,
13102 (void *)&cmd_config_e_tag_port_tag_id,
13103 (void *)&cmd_config_e_tag_port_tag_id_val,
13104 (void *)&cmd_config_e_tag_port,
13105 (void *)&cmd_config_e_tag_port_id,
13106 (void *)&cmd_config_e_tag_vf,
13107 (void *)&cmd_config_e_tag_vf_id,
13112 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13113 .f = cmd_config_e_tag_insertion_dis_parsed,
13115 .help_str = "E-tag ... : E-tag insertion disable",
13117 (void *)&cmd_config_e_tag_e_tag,
13118 (void *)&cmd_config_e_tag_set,
13119 (void *)&cmd_config_e_tag_insertion,
13120 (void *)&cmd_config_e_tag_off,
13121 (void *)&cmd_config_e_tag_port,
13122 (void *)&cmd_config_e_tag_port_id,
13123 (void *)&cmd_config_e_tag_vf,
13124 (void *)&cmd_config_e_tag_vf_id,
13129 /* E-tag stripping configuration */
13131 cmd_config_e_tag_stripping_parsed(
13132 void *parsed_result,
13133 __attribute__((unused)) struct cmdline *cl,
13134 __attribute__((unused)) void *data)
13136 struct cmd_config_e_tag_result *res =
13138 struct rte_eth_l2_tunnel_conf entry;
13140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13143 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13145 if (!strcmp(res->on_off, "on"))
13146 rte_eth_dev_l2_tunnel_offload_set
13149 ETH_L2_TUNNEL_STRIPPING_MASK,
13152 rte_eth_dev_l2_tunnel_offload_set
13155 ETH_L2_TUNNEL_STRIPPING_MASK,
13159 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13160 .f = cmd_config_e_tag_stripping_parsed,
13162 .help_str = "E-tag ... : E-tag stripping enable/disable",
13164 (void *)&cmd_config_e_tag_e_tag,
13165 (void *)&cmd_config_e_tag_set,
13166 (void *)&cmd_config_e_tag_stripping,
13167 (void *)&cmd_config_e_tag_on_off,
13168 (void *)&cmd_config_e_tag_port,
13169 (void *)&cmd_config_e_tag_port_id,
13174 /* E-tag forwarding configuration */
13176 cmd_config_e_tag_forwarding_parsed(
13177 void *parsed_result,
13178 __attribute__((unused)) struct cmdline *cl,
13179 __attribute__((unused)) void *data)
13181 struct cmd_config_e_tag_result *res = parsed_result;
13182 struct rte_eth_l2_tunnel_conf entry;
13184 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13187 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13189 if (!strcmp(res->on_off, "on"))
13190 rte_eth_dev_l2_tunnel_offload_set
13193 ETH_L2_TUNNEL_FORWARDING_MASK,
13196 rte_eth_dev_l2_tunnel_offload_set
13199 ETH_L2_TUNNEL_FORWARDING_MASK,
13203 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13204 .f = cmd_config_e_tag_forwarding_parsed,
13206 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13208 (void *)&cmd_config_e_tag_e_tag,
13209 (void *)&cmd_config_e_tag_set,
13210 (void *)&cmd_config_e_tag_forwarding,
13211 (void *)&cmd_config_e_tag_on_off,
13212 (void *)&cmd_config_e_tag_port,
13213 (void *)&cmd_config_e_tag_port_id,
13218 /* E-tag filter configuration */
13220 cmd_config_e_tag_filter_add_parsed(
13221 void *parsed_result,
13222 __attribute__((unused)) struct cmdline *cl,
13223 __attribute__((unused)) void *data)
13225 struct cmd_config_e_tag_result *res = parsed_result;
13226 struct rte_eth_l2_tunnel_conf entry;
13229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13232 if (res->e_tag_id_val > 0x3fff) {
13233 printf("e-tag-id must be equal or less than 0x3fff.\n");
13237 ret = rte_eth_dev_filter_supported(res->port_id,
13238 RTE_ETH_FILTER_L2_TUNNEL);
13240 printf("E-tag filter is not supported on port %u.\n",
13245 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13246 entry.tunnel_id = res->e_tag_id_val;
13247 entry.pool = res->dst_pool_val;
13249 ret = rte_eth_dev_filter_ctrl(res->port_id,
13250 RTE_ETH_FILTER_L2_TUNNEL,
13251 RTE_ETH_FILTER_ADD,
13254 printf("E-tag filter programming error: (%s)\n",
13258 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13259 .f = cmd_config_e_tag_filter_add_parsed,
13261 .help_str = "E-tag ... : E-tag filter add",
13263 (void *)&cmd_config_e_tag_e_tag,
13264 (void *)&cmd_config_e_tag_set,
13265 (void *)&cmd_config_e_tag_filter,
13266 (void *)&cmd_config_e_tag_add,
13267 (void *)&cmd_config_e_tag_e_tag_id,
13268 (void *)&cmd_config_e_tag_e_tag_id_val,
13269 (void *)&cmd_config_e_tag_dst_pool,
13270 (void *)&cmd_config_e_tag_dst_pool_val,
13271 (void *)&cmd_config_e_tag_port,
13272 (void *)&cmd_config_e_tag_port_id,
13278 cmd_config_e_tag_filter_del_parsed(
13279 void *parsed_result,
13280 __attribute__((unused)) struct cmdline *cl,
13281 __attribute__((unused)) void *data)
13283 struct cmd_config_e_tag_result *res = parsed_result;
13284 struct rte_eth_l2_tunnel_conf entry;
13287 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13290 if (res->e_tag_id_val > 0x3fff) {
13291 printf("e-tag-id must be less than 0x3fff.\n");
13295 ret = rte_eth_dev_filter_supported(res->port_id,
13296 RTE_ETH_FILTER_L2_TUNNEL);
13298 printf("E-tag filter is not supported on port %u.\n",
13303 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13304 entry.tunnel_id = res->e_tag_id_val;
13306 ret = rte_eth_dev_filter_ctrl(res->port_id,
13307 RTE_ETH_FILTER_L2_TUNNEL,
13308 RTE_ETH_FILTER_DELETE,
13311 printf("E-tag filter programming error: (%s)\n",
13315 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13316 .f = cmd_config_e_tag_filter_del_parsed,
13318 .help_str = "E-tag ... : E-tag filter delete",
13320 (void *)&cmd_config_e_tag_e_tag,
13321 (void *)&cmd_config_e_tag_set,
13322 (void *)&cmd_config_e_tag_filter,
13323 (void *)&cmd_config_e_tag_del,
13324 (void *)&cmd_config_e_tag_e_tag_id,
13325 (void *)&cmd_config_e_tag_e_tag_id_val,
13326 (void *)&cmd_config_e_tag_port,
13327 (void *)&cmd_config_e_tag_port_id,
13332 /* vf vlan anti spoof configuration */
13334 /* Common result structure for vf vlan anti spoof */
13335 struct cmd_vf_vlan_anti_spoof_result {
13336 cmdline_fixed_string_t set;
13337 cmdline_fixed_string_t vf;
13338 cmdline_fixed_string_t vlan;
13339 cmdline_fixed_string_t antispoof;
13342 cmdline_fixed_string_t on_off;
13345 /* Common CLI fields for vf vlan anti spoof enable disable */
13346 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13347 TOKEN_STRING_INITIALIZER
13348 (struct cmd_vf_vlan_anti_spoof_result,
13350 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13351 TOKEN_STRING_INITIALIZER
13352 (struct cmd_vf_vlan_anti_spoof_result,
13354 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13355 TOKEN_STRING_INITIALIZER
13356 (struct cmd_vf_vlan_anti_spoof_result,
13358 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13359 TOKEN_STRING_INITIALIZER
13360 (struct cmd_vf_vlan_anti_spoof_result,
13361 antispoof, "antispoof");
13362 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13363 TOKEN_NUM_INITIALIZER
13364 (struct cmd_vf_vlan_anti_spoof_result,
13366 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13367 TOKEN_NUM_INITIALIZER
13368 (struct cmd_vf_vlan_anti_spoof_result,
13370 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13371 TOKEN_STRING_INITIALIZER
13372 (struct cmd_vf_vlan_anti_spoof_result,
13376 cmd_set_vf_vlan_anti_spoof_parsed(
13377 void *parsed_result,
13378 __attribute__((unused)) struct cmdline *cl,
13379 __attribute__((unused)) void *data)
13381 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13382 int ret = -ENOTSUP;
13384 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13386 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13389 #ifdef RTE_LIBRTE_IXGBE_PMD
13390 if (ret == -ENOTSUP)
13391 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13392 res->vf_id, is_on);
13394 #ifdef RTE_LIBRTE_I40E_PMD
13395 if (ret == -ENOTSUP)
13396 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13397 res->vf_id, is_on);
13399 #ifdef RTE_LIBRTE_BNXT_PMD
13400 if (ret == -ENOTSUP)
13401 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13402 res->vf_id, is_on);
13409 printf("invalid vf_id %d\n", res->vf_id);
13412 printf("invalid port_id %d\n", res->port_id);
13415 printf("function not implemented\n");
13418 printf("programming error: (%s)\n", strerror(-ret));
13422 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13423 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13425 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13427 (void *)&cmd_vf_vlan_anti_spoof_set,
13428 (void *)&cmd_vf_vlan_anti_spoof_vf,
13429 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13430 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13431 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13432 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13433 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13438 /* vf mac anti spoof configuration */
13440 /* Common result structure for vf mac anti spoof */
13441 struct cmd_vf_mac_anti_spoof_result {
13442 cmdline_fixed_string_t set;
13443 cmdline_fixed_string_t vf;
13444 cmdline_fixed_string_t mac;
13445 cmdline_fixed_string_t antispoof;
13448 cmdline_fixed_string_t on_off;
13451 /* Common CLI fields for vf mac anti spoof enable disable */
13452 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13453 TOKEN_STRING_INITIALIZER
13454 (struct cmd_vf_mac_anti_spoof_result,
13456 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13457 TOKEN_STRING_INITIALIZER
13458 (struct cmd_vf_mac_anti_spoof_result,
13460 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_vf_mac_anti_spoof_result,
13464 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13465 TOKEN_STRING_INITIALIZER
13466 (struct cmd_vf_mac_anti_spoof_result,
13467 antispoof, "antispoof");
13468 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13469 TOKEN_NUM_INITIALIZER
13470 (struct cmd_vf_mac_anti_spoof_result,
13472 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13473 TOKEN_NUM_INITIALIZER
13474 (struct cmd_vf_mac_anti_spoof_result,
13476 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13477 TOKEN_STRING_INITIALIZER
13478 (struct cmd_vf_mac_anti_spoof_result,
13482 cmd_set_vf_mac_anti_spoof_parsed(
13483 void *parsed_result,
13484 __attribute__((unused)) struct cmdline *cl,
13485 __attribute__((unused)) void *data)
13487 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13488 int ret = -ENOTSUP;
13490 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13492 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13495 #ifdef RTE_LIBRTE_IXGBE_PMD
13496 if (ret == -ENOTSUP)
13497 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13498 res->vf_id, is_on);
13500 #ifdef RTE_LIBRTE_I40E_PMD
13501 if (ret == -ENOTSUP)
13502 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13503 res->vf_id, is_on);
13505 #ifdef RTE_LIBRTE_BNXT_PMD
13506 if (ret == -ENOTSUP)
13507 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13508 res->vf_id, is_on);
13515 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13518 printf("invalid port_id %d\n", res->port_id);
13521 printf("function not implemented\n");
13524 printf("programming error: (%s)\n", strerror(-ret));
13528 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13529 .f = cmd_set_vf_mac_anti_spoof_parsed,
13531 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13533 (void *)&cmd_vf_mac_anti_spoof_set,
13534 (void *)&cmd_vf_mac_anti_spoof_vf,
13535 (void *)&cmd_vf_mac_anti_spoof_mac,
13536 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13537 (void *)&cmd_vf_mac_anti_spoof_port_id,
13538 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13539 (void *)&cmd_vf_mac_anti_spoof_on_off,
13544 /* vf vlan strip queue configuration */
13546 /* Common result structure for vf mac anti spoof */
13547 struct cmd_vf_vlan_stripq_result {
13548 cmdline_fixed_string_t set;
13549 cmdline_fixed_string_t vf;
13550 cmdline_fixed_string_t vlan;
13551 cmdline_fixed_string_t stripq;
13554 cmdline_fixed_string_t on_off;
13557 /* Common CLI fields for vf vlan strip enable disable */
13558 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13559 TOKEN_STRING_INITIALIZER
13560 (struct cmd_vf_vlan_stripq_result,
13562 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13563 TOKEN_STRING_INITIALIZER
13564 (struct cmd_vf_vlan_stripq_result,
13566 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13567 TOKEN_STRING_INITIALIZER
13568 (struct cmd_vf_vlan_stripq_result,
13570 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13571 TOKEN_STRING_INITIALIZER
13572 (struct cmd_vf_vlan_stripq_result,
13574 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13575 TOKEN_NUM_INITIALIZER
13576 (struct cmd_vf_vlan_stripq_result,
13578 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13579 TOKEN_NUM_INITIALIZER
13580 (struct cmd_vf_vlan_stripq_result,
13582 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13583 TOKEN_STRING_INITIALIZER
13584 (struct cmd_vf_vlan_stripq_result,
13588 cmd_set_vf_vlan_stripq_parsed(
13589 void *parsed_result,
13590 __attribute__((unused)) struct cmdline *cl,
13591 __attribute__((unused)) void *data)
13593 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13594 int ret = -ENOTSUP;
13596 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13598 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13601 #ifdef RTE_LIBRTE_IXGBE_PMD
13602 if (ret == -ENOTSUP)
13603 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13604 res->vf_id, is_on);
13606 #ifdef RTE_LIBRTE_I40E_PMD
13607 if (ret == -ENOTSUP)
13608 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13609 res->vf_id, is_on);
13611 #ifdef RTE_LIBRTE_BNXT_PMD
13612 if (ret == -ENOTSUP)
13613 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13614 res->vf_id, is_on);
13621 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13624 printf("invalid port_id %d\n", res->port_id);
13627 printf("function not implemented\n");
13630 printf("programming error: (%s)\n", strerror(-ret));
13634 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13635 .f = cmd_set_vf_vlan_stripq_parsed,
13637 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13639 (void *)&cmd_vf_vlan_stripq_set,
13640 (void *)&cmd_vf_vlan_stripq_vf,
13641 (void *)&cmd_vf_vlan_stripq_vlan,
13642 (void *)&cmd_vf_vlan_stripq_stripq,
13643 (void *)&cmd_vf_vlan_stripq_port_id,
13644 (void *)&cmd_vf_vlan_stripq_vf_id,
13645 (void *)&cmd_vf_vlan_stripq_on_off,
13650 /* vf vlan insert configuration */
13652 /* Common result structure for vf vlan insert */
13653 struct cmd_vf_vlan_insert_result {
13654 cmdline_fixed_string_t set;
13655 cmdline_fixed_string_t vf;
13656 cmdline_fixed_string_t vlan;
13657 cmdline_fixed_string_t insert;
13663 /* Common CLI fields for vf vlan insert enable disable */
13664 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13665 TOKEN_STRING_INITIALIZER
13666 (struct cmd_vf_vlan_insert_result,
13668 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13669 TOKEN_STRING_INITIALIZER
13670 (struct cmd_vf_vlan_insert_result,
13672 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_vf_vlan_insert_result,
13676 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13677 TOKEN_STRING_INITIALIZER
13678 (struct cmd_vf_vlan_insert_result,
13680 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13681 TOKEN_NUM_INITIALIZER
13682 (struct cmd_vf_vlan_insert_result,
13684 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13685 TOKEN_NUM_INITIALIZER
13686 (struct cmd_vf_vlan_insert_result,
13688 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13689 TOKEN_NUM_INITIALIZER
13690 (struct cmd_vf_vlan_insert_result,
13694 cmd_set_vf_vlan_insert_parsed(
13695 void *parsed_result,
13696 __attribute__((unused)) struct cmdline *cl,
13697 __attribute__((unused)) void *data)
13699 struct cmd_vf_vlan_insert_result *res = parsed_result;
13700 int ret = -ENOTSUP;
13702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13705 #ifdef RTE_LIBRTE_IXGBE_PMD
13706 if (ret == -ENOTSUP)
13707 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13710 #ifdef RTE_LIBRTE_I40E_PMD
13711 if (ret == -ENOTSUP)
13712 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13715 #ifdef RTE_LIBRTE_BNXT_PMD
13716 if (ret == -ENOTSUP)
13717 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13725 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13728 printf("invalid port_id %d\n", res->port_id);
13731 printf("function not implemented\n");
13734 printf("programming error: (%s)\n", strerror(-ret));
13738 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13739 .f = cmd_set_vf_vlan_insert_parsed,
13741 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13743 (void *)&cmd_vf_vlan_insert_set,
13744 (void *)&cmd_vf_vlan_insert_vf,
13745 (void *)&cmd_vf_vlan_insert_vlan,
13746 (void *)&cmd_vf_vlan_insert_insert,
13747 (void *)&cmd_vf_vlan_insert_port_id,
13748 (void *)&cmd_vf_vlan_insert_vf_id,
13749 (void *)&cmd_vf_vlan_insert_vlan_id,
13754 /* tx loopback configuration */
13756 /* Common result structure for tx loopback */
13757 struct cmd_tx_loopback_result {
13758 cmdline_fixed_string_t set;
13759 cmdline_fixed_string_t tx;
13760 cmdline_fixed_string_t loopback;
13762 cmdline_fixed_string_t on_off;
13765 /* Common CLI fields for tx loopback enable disable */
13766 cmdline_parse_token_string_t cmd_tx_loopback_set =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_tx_loopback_result,
13770 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13771 TOKEN_STRING_INITIALIZER
13772 (struct cmd_tx_loopback_result,
13774 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13775 TOKEN_STRING_INITIALIZER
13776 (struct cmd_tx_loopback_result,
13777 loopback, "loopback");
13778 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13779 TOKEN_NUM_INITIALIZER
13780 (struct cmd_tx_loopback_result,
13782 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13783 TOKEN_STRING_INITIALIZER
13784 (struct cmd_tx_loopback_result,
13788 cmd_set_tx_loopback_parsed(
13789 void *parsed_result,
13790 __attribute__((unused)) struct cmdline *cl,
13791 __attribute__((unused)) void *data)
13793 struct cmd_tx_loopback_result *res = parsed_result;
13794 int ret = -ENOTSUP;
13796 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13798 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13801 #ifdef RTE_LIBRTE_IXGBE_PMD
13802 if (ret == -ENOTSUP)
13803 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13805 #ifdef RTE_LIBRTE_I40E_PMD
13806 if (ret == -ENOTSUP)
13807 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13809 #ifdef RTE_LIBRTE_BNXT_PMD
13810 if (ret == -ENOTSUP)
13811 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13813 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13814 if (ret == -ENOTSUP)
13815 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13822 printf("invalid is_on %d\n", is_on);
13825 printf("invalid port_id %d\n", res->port_id);
13828 printf("function not implemented\n");
13831 printf("programming error: (%s)\n", strerror(-ret));
13835 cmdline_parse_inst_t cmd_set_tx_loopback = {
13836 .f = cmd_set_tx_loopback_parsed,
13838 .help_str = "set tx loopback <port_id> on|off",
13840 (void *)&cmd_tx_loopback_set,
13841 (void *)&cmd_tx_loopback_tx,
13842 (void *)&cmd_tx_loopback_loopback,
13843 (void *)&cmd_tx_loopback_port_id,
13844 (void *)&cmd_tx_loopback_on_off,
13849 /* all queues drop enable configuration */
13851 /* Common result structure for all queues drop enable */
13852 struct cmd_all_queues_drop_en_result {
13853 cmdline_fixed_string_t set;
13854 cmdline_fixed_string_t all;
13855 cmdline_fixed_string_t queues;
13856 cmdline_fixed_string_t drop;
13858 cmdline_fixed_string_t on_off;
13861 /* Common CLI fields for tx loopback enable disable */
13862 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_all_queues_drop_en_result,
13866 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13867 TOKEN_STRING_INITIALIZER
13868 (struct cmd_all_queues_drop_en_result,
13870 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13871 TOKEN_STRING_INITIALIZER
13872 (struct cmd_all_queues_drop_en_result,
13874 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13875 TOKEN_STRING_INITIALIZER
13876 (struct cmd_all_queues_drop_en_result,
13878 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13879 TOKEN_NUM_INITIALIZER
13880 (struct cmd_all_queues_drop_en_result,
13882 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13883 TOKEN_STRING_INITIALIZER
13884 (struct cmd_all_queues_drop_en_result,
13888 cmd_set_all_queues_drop_en_parsed(
13889 void *parsed_result,
13890 __attribute__((unused)) struct cmdline *cl,
13891 __attribute__((unused)) void *data)
13893 struct cmd_all_queues_drop_en_result *res = parsed_result;
13894 int ret = -ENOTSUP;
13895 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13900 #ifdef RTE_LIBRTE_IXGBE_PMD
13901 if (ret == -ENOTSUP)
13902 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13904 #ifdef RTE_LIBRTE_BNXT_PMD
13905 if (ret == -ENOTSUP)
13906 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13912 printf("invalid is_on %d\n", is_on);
13915 printf("invalid port_id %d\n", res->port_id);
13918 printf("function not implemented\n");
13921 printf("programming error: (%s)\n", strerror(-ret));
13925 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13926 .f = cmd_set_all_queues_drop_en_parsed,
13928 .help_str = "set all queues drop <port_id> on|off",
13930 (void *)&cmd_all_queues_drop_en_set,
13931 (void *)&cmd_all_queues_drop_en_all,
13932 (void *)&cmd_all_queues_drop_en_queues,
13933 (void *)&cmd_all_queues_drop_en_drop,
13934 (void *)&cmd_all_queues_drop_en_port_id,
13935 (void *)&cmd_all_queues_drop_en_on_off,
13940 /* vf split drop enable configuration */
13942 /* Common result structure for vf split drop enable */
13943 struct cmd_vf_split_drop_en_result {
13944 cmdline_fixed_string_t set;
13945 cmdline_fixed_string_t vf;
13946 cmdline_fixed_string_t split;
13947 cmdline_fixed_string_t drop;
13950 cmdline_fixed_string_t on_off;
13953 /* Common CLI fields for vf split drop enable disable */
13954 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13955 TOKEN_STRING_INITIALIZER
13956 (struct cmd_vf_split_drop_en_result,
13958 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13959 TOKEN_STRING_INITIALIZER
13960 (struct cmd_vf_split_drop_en_result,
13962 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13963 TOKEN_STRING_INITIALIZER
13964 (struct cmd_vf_split_drop_en_result,
13966 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13967 TOKEN_STRING_INITIALIZER
13968 (struct cmd_vf_split_drop_en_result,
13970 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13971 TOKEN_NUM_INITIALIZER
13972 (struct cmd_vf_split_drop_en_result,
13974 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13975 TOKEN_NUM_INITIALIZER
13976 (struct cmd_vf_split_drop_en_result,
13978 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13979 TOKEN_STRING_INITIALIZER
13980 (struct cmd_vf_split_drop_en_result,
13984 cmd_set_vf_split_drop_en_parsed(
13985 void *parsed_result,
13986 __attribute__((unused)) struct cmdline *cl,
13987 __attribute__((unused)) void *data)
13989 struct cmd_vf_split_drop_en_result *res = parsed_result;
13990 int ret = -ENOTSUP;
13991 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13993 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13996 #ifdef RTE_LIBRTE_IXGBE_PMD
13997 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14004 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14007 printf("invalid port_id %d\n", res->port_id);
14010 printf("not supported on port %d\n", res->port_id);
14013 printf("programming error: (%s)\n", strerror(-ret));
14017 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14018 .f = cmd_set_vf_split_drop_en_parsed,
14020 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14022 (void *)&cmd_vf_split_drop_en_set,
14023 (void *)&cmd_vf_split_drop_en_vf,
14024 (void *)&cmd_vf_split_drop_en_split,
14025 (void *)&cmd_vf_split_drop_en_drop,
14026 (void *)&cmd_vf_split_drop_en_port_id,
14027 (void *)&cmd_vf_split_drop_en_vf_id,
14028 (void *)&cmd_vf_split_drop_en_on_off,
14033 /* vf mac address configuration */
14035 /* Common result structure for vf mac address */
14036 struct cmd_set_vf_mac_addr_result {
14037 cmdline_fixed_string_t set;
14038 cmdline_fixed_string_t vf;
14039 cmdline_fixed_string_t mac;
14040 cmdline_fixed_string_t addr;
14043 struct rte_ether_addr mac_addr;
14047 /* Common CLI fields for vf split drop enable disable */
14048 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14049 TOKEN_STRING_INITIALIZER
14050 (struct cmd_set_vf_mac_addr_result,
14052 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14053 TOKEN_STRING_INITIALIZER
14054 (struct cmd_set_vf_mac_addr_result,
14056 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14057 TOKEN_STRING_INITIALIZER
14058 (struct cmd_set_vf_mac_addr_result,
14060 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14061 TOKEN_STRING_INITIALIZER
14062 (struct cmd_set_vf_mac_addr_result,
14064 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14065 TOKEN_NUM_INITIALIZER
14066 (struct cmd_set_vf_mac_addr_result,
14068 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14069 TOKEN_NUM_INITIALIZER
14070 (struct cmd_set_vf_mac_addr_result,
14072 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14073 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14077 cmd_set_vf_mac_addr_parsed(
14078 void *parsed_result,
14079 __attribute__((unused)) struct cmdline *cl,
14080 __attribute__((unused)) void *data)
14082 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14083 int ret = -ENOTSUP;
14085 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14088 #ifdef RTE_LIBRTE_IXGBE_PMD
14089 if (ret == -ENOTSUP)
14090 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14093 #ifdef RTE_LIBRTE_I40E_PMD
14094 if (ret == -ENOTSUP)
14095 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14098 #ifdef RTE_LIBRTE_BNXT_PMD
14099 if (ret == -ENOTSUP)
14100 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14108 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14111 printf("invalid port_id %d\n", res->port_id);
14114 printf("function not implemented\n");
14117 printf("programming error: (%s)\n", strerror(-ret));
14121 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14122 .f = cmd_set_vf_mac_addr_parsed,
14124 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14126 (void *)&cmd_set_vf_mac_addr_set,
14127 (void *)&cmd_set_vf_mac_addr_vf,
14128 (void *)&cmd_set_vf_mac_addr_mac,
14129 (void *)&cmd_set_vf_mac_addr_addr,
14130 (void *)&cmd_set_vf_mac_addr_port_id,
14131 (void *)&cmd_set_vf_mac_addr_vf_id,
14132 (void *)&cmd_set_vf_mac_addr_mac_addr,
14137 /* MACsec configuration */
14139 /* Common result structure for MACsec offload enable */
14140 struct cmd_macsec_offload_on_result {
14141 cmdline_fixed_string_t set;
14142 cmdline_fixed_string_t macsec;
14143 cmdline_fixed_string_t offload;
14145 cmdline_fixed_string_t on;
14146 cmdline_fixed_string_t encrypt;
14147 cmdline_fixed_string_t en_on_off;
14148 cmdline_fixed_string_t replay_protect;
14149 cmdline_fixed_string_t rp_on_off;
14152 /* Common CLI fields for MACsec offload disable */
14153 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14154 TOKEN_STRING_INITIALIZER
14155 (struct cmd_macsec_offload_on_result,
14157 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14158 TOKEN_STRING_INITIALIZER
14159 (struct cmd_macsec_offload_on_result,
14161 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14162 TOKEN_STRING_INITIALIZER
14163 (struct cmd_macsec_offload_on_result,
14164 offload, "offload");
14165 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14166 TOKEN_NUM_INITIALIZER
14167 (struct cmd_macsec_offload_on_result,
14169 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14170 TOKEN_STRING_INITIALIZER
14171 (struct cmd_macsec_offload_on_result,
14173 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14174 TOKEN_STRING_INITIALIZER
14175 (struct cmd_macsec_offload_on_result,
14176 encrypt, "encrypt");
14177 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14178 TOKEN_STRING_INITIALIZER
14179 (struct cmd_macsec_offload_on_result,
14180 en_on_off, "on#off");
14181 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14182 TOKEN_STRING_INITIALIZER
14183 (struct cmd_macsec_offload_on_result,
14184 replay_protect, "replay-protect");
14185 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14186 TOKEN_STRING_INITIALIZER
14187 (struct cmd_macsec_offload_on_result,
14188 rp_on_off, "on#off");
14191 cmd_set_macsec_offload_on_parsed(
14192 void *parsed_result,
14193 __attribute__((unused)) struct cmdline *cl,
14194 __attribute__((unused)) void *data)
14196 struct cmd_macsec_offload_on_result *res = parsed_result;
14197 int ret = -ENOTSUP;
14198 portid_t port_id = res->port_id;
14199 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14200 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14201 struct rte_eth_dev_info dev_info;
14203 if (port_id_is_invalid(port_id, ENABLED_WARN))
14205 if (!port_is_stopped(port_id)) {
14206 printf("Please stop port %d first\n", port_id);
14210 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14214 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14215 #ifdef RTE_LIBRTE_IXGBE_PMD
14216 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14224 ports[port_id].dev_conf.txmode.offloads |=
14225 DEV_TX_OFFLOAD_MACSEC_INSERT;
14226 cmd_reconfig_device_queue(port_id, 1, 1);
14229 printf("invalid port_id %d\n", port_id);
14232 printf("not supported on port %d\n", port_id);
14235 printf("programming error: (%s)\n", strerror(-ret));
14239 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14240 .f = cmd_set_macsec_offload_on_parsed,
14242 .help_str = "set macsec offload <port_id> on "
14243 "encrypt on|off replay-protect on|off",
14245 (void *)&cmd_macsec_offload_on_set,
14246 (void *)&cmd_macsec_offload_on_macsec,
14247 (void *)&cmd_macsec_offload_on_offload,
14248 (void *)&cmd_macsec_offload_on_port_id,
14249 (void *)&cmd_macsec_offload_on_on,
14250 (void *)&cmd_macsec_offload_on_encrypt,
14251 (void *)&cmd_macsec_offload_on_en_on_off,
14252 (void *)&cmd_macsec_offload_on_replay_protect,
14253 (void *)&cmd_macsec_offload_on_rp_on_off,
14258 /* Common result structure for MACsec offload disable */
14259 struct cmd_macsec_offload_off_result {
14260 cmdline_fixed_string_t set;
14261 cmdline_fixed_string_t macsec;
14262 cmdline_fixed_string_t offload;
14264 cmdline_fixed_string_t off;
14267 /* Common CLI fields for MACsec offload disable */
14268 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14269 TOKEN_STRING_INITIALIZER
14270 (struct cmd_macsec_offload_off_result,
14272 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14273 TOKEN_STRING_INITIALIZER
14274 (struct cmd_macsec_offload_off_result,
14276 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14277 TOKEN_STRING_INITIALIZER
14278 (struct cmd_macsec_offload_off_result,
14279 offload, "offload");
14280 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14281 TOKEN_NUM_INITIALIZER
14282 (struct cmd_macsec_offload_off_result,
14284 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14285 TOKEN_STRING_INITIALIZER
14286 (struct cmd_macsec_offload_off_result,
14290 cmd_set_macsec_offload_off_parsed(
14291 void *parsed_result,
14292 __attribute__((unused)) struct cmdline *cl,
14293 __attribute__((unused)) void *data)
14295 struct cmd_macsec_offload_off_result *res = parsed_result;
14296 int ret = -ENOTSUP;
14297 struct rte_eth_dev_info dev_info;
14298 portid_t port_id = res->port_id;
14300 if (port_id_is_invalid(port_id, ENABLED_WARN))
14302 if (!port_is_stopped(port_id)) {
14303 printf("Please stop port %d first\n", port_id);
14307 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14311 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14312 #ifdef RTE_LIBRTE_IXGBE_PMD
14313 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14318 ports[port_id].dev_conf.txmode.offloads &=
14319 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14320 cmd_reconfig_device_queue(port_id, 1, 1);
14323 printf("invalid port_id %d\n", port_id);
14326 printf("not supported on port %d\n", port_id);
14329 printf("programming error: (%s)\n", strerror(-ret));
14333 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14334 .f = cmd_set_macsec_offload_off_parsed,
14336 .help_str = "set macsec offload <port_id> off",
14338 (void *)&cmd_macsec_offload_off_set,
14339 (void *)&cmd_macsec_offload_off_macsec,
14340 (void *)&cmd_macsec_offload_off_offload,
14341 (void *)&cmd_macsec_offload_off_port_id,
14342 (void *)&cmd_macsec_offload_off_off,
14347 /* Common result structure for MACsec secure connection configure */
14348 struct cmd_macsec_sc_result {
14349 cmdline_fixed_string_t set;
14350 cmdline_fixed_string_t macsec;
14351 cmdline_fixed_string_t sc;
14352 cmdline_fixed_string_t tx_rx;
14354 struct rte_ether_addr mac;
14358 /* Common CLI fields for MACsec secure connection configure */
14359 cmdline_parse_token_string_t cmd_macsec_sc_set =
14360 TOKEN_STRING_INITIALIZER
14361 (struct cmd_macsec_sc_result,
14363 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14364 TOKEN_STRING_INITIALIZER
14365 (struct cmd_macsec_sc_result,
14367 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14368 TOKEN_STRING_INITIALIZER
14369 (struct cmd_macsec_sc_result,
14371 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14372 TOKEN_STRING_INITIALIZER
14373 (struct cmd_macsec_sc_result,
14375 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14376 TOKEN_NUM_INITIALIZER
14377 (struct cmd_macsec_sc_result,
14379 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14380 TOKEN_ETHERADDR_INITIALIZER
14381 (struct cmd_macsec_sc_result,
14383 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14384 TOKEN_NUM_INITIALIZER
14385 (struct cmd_macsec_sc_result,
14389 cmd_set_macsec_sc_parsed(
14390 void *parsed_result,
14391 __attribute__((unused)) struct cmdline *cl,
14392 __attribute__((unused)) void *data)
14394 struct cmd_macsec_sc_result *res = parsed_result;
14395 int ret = -ENOTSUP;
14396 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14398 #ifdef RTE_LIBRTE_IXGBE_PMD
14400 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14401 res->mac.addr_bytes) :
14402 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14403 res->mac.addr_bytes, res->pi);
14405 RTE_SET_USED(is_tx);
14411 printf("invalid port_id %d\n", res->port_id);
14414 printf("not supported on port %d\n", res->port_id);
14417 printf("programming error: (%s)\n", strerror(-ret));
14421 cmdline_parse_inst_t cmd_set_macsec_sc = {
14422 .f = cmd_set_macsec_sc_parsed,
14424 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14426 (void *)&cmd_macsec_sc_set,
14427 (void *)&cmd_macsec_sc_macsec,
14428 (void *)&cmd_macsec_sc_sc,
14429 (void *)&cmd_macsec_sc_tx_rx,
14430 (void *)&cmd_macsec_sc_port_id,
14431 (void *)&cmd_macsec_sc_mac,
14432 (void *)&cmd_macsec_sc_pi,
14437 /* Common result structure for MACsec secure connection configure */
14438 struct cmd_macsec_sa_result {
14439 cmdline_fixed_string_t set;
14440 cmdline_fixed_string_t macsec;
14441 cmdline_fixed_string_t sa;
14442 cmdline_fixed_string_t tx_rx;
14447 cmdline_fixed_string_t key;
14450 /* Common CLI fields for MACsec secure connection configure */
14451 cmdline_parse_token_string_t cmd_macsec_sa_set =
14452 TOKEN_STRING_INITIALIZER
14453 (struct cmd_macsec_sa_result,
14455 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14456 TOKEN_STRING_INITIALIZER
14457 (struct cmd_macsec_sa_result,
14459 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14460 TOKEN_STRING_INITIALIZER
14461 (struct cmd_macsec_sa_result,
14463 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14464 TOKEN_STRING_INITIALIZER
14465 (struct cmd_macsec_sa_result,
14467 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14468 TOKEN_NUM_INITIALIZER
14469 (struct cmd_macsec_sa_result,
14471 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14472 TOKEN_NUM_INITIALIZER
14473 (struct cmd_macsec_sa_result,
14475 cmdline_parse_token_num_t cmd_macsec_sa_an =
14476 TOKEN_NUM_INITIALIZER
14477 (struct cmd_macsec_sa_result,
14479 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14480 TOKEN_NUM_INITIALIZER
14481 (struct cmd_macsec_sa_result,
14483 cmdline_parse_token_string_t cmd_macsec_sa_key =
14484 TOKEN_STRING_INITIALIZER
14485 (struct cmd_macsec_sa_result,
14489 cmd_set_macsec_sa_parsed(
14490 void *parsed_result,
14491 __attribute__((unused)) struct cmdline *cl,
14492 __attribute__((unused)) void *data)
14494 struct cmd_macsec_sa_result *res = parsed_result;
14495 int ret = -ENOTSUP;
14496 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14497 uint8_t key[16] = { 0 };
14503 key_len = strlen(res->key) / 2;
14507 for (i = 0; i < key_len; i++) {
14508 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14511 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14514 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14517 #ifdef RTE_LIBRTE_IXGBE_PMD
14519 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14520 res->idx, res->an, res->pn, key) :
14521 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14522 res->idx, res->an, res->pn, key);
14524 RTE_SET_USED(is_tx);
14531 printf("invalid idx %d or an %d\n", res->idx, res->an);
14534 printf("invalid port_id %d\n", res->port_id);
14537 printf("not supported on port %d\n", res->port_id);
14540 printf("programming error: (%s)\n", strerror(-ret));
14544 cmdline_parse_inst_t cmd_set_macsec_sa = {
14545 .f = cmd_set_macsec_sa_parsed,
14547 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14549 (void *)&cmd_macsec_sa_set,
14550 (void *)&cmd_macsec_sa_macsec,
14551 (void *)&cmd_macsec_sa_sa,
14552 (void *)&cmd_macsec_sa_tx_rx,
14553 (void *)&cmd_macsec_sa_port_id,
14554 (void *)&cmd_macsec_sa_idx,
14555 (void *)&cmd_macsec_sa_an,
14556 (void *)&cmd_macsec_sa_pn,
14557 (void *)&cmd_macsec_sa_key,
14562 /* VF unicast promiscuous mode configuration */
14564 /* Common result structure for VF unicast promiscuous mode */
14565 struct cmd_vf_promisc_result {
14566 cmdline_fixed_string_t set;
14567 cmdline_fixed_string_t vf;
14568 cmdline_fixed_string_t promisc;
14571 cmdline_fixed_string_t on_off;
14574 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14575 cmdline_parse_token_string_t cmd_vf_promisc_set =
14576 TOKEN_STRING_INITIALIZER
14577 (struct cmd_vf_promisc_result,
14579 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14580 TOKEN_STRING_INITIALIZER
14581 (struct cmd_vf_promisc_result,
14583 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14584 TOKEN_STRING_INITIALIZER
14585 (struct cmd_vf_promisc_result,
14586 promisc, "promisc");
14587 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14588 TOKEN_NUM_INITIALIZER
14589 (struct cmd_vf_promisc_result,
14591 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14592 TOKEN_NUM_INITIALIZER
14593 (struct cmd_vf_promisc_result,
14595 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14596 TOKEN_STRING_INITIALIZER
14597 (struct cmd_vf_promisc_result,
14601 cmd_set_vf_promisc_parsed(
14602 void *parsed_result,
14603 __attribute__((unused)) struct cmdline *cl,
14604 __attribute__((unused)) void *data)
14606 struct cmd_vf_promisc_result *res = parsed_result;
14607 int ret = -ENOTSUP;
14609 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14611 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14614 #ifdef RTE_LIBRTE_I40E_PMD
14615 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14616 res->vf_id, is_on);
14623 printf("invalid vf_id %d\n", res->vf_id);
14626 printf("invalid port_id %d\n", res->port_id);
14629 printf("function not implemented\n");
14632 printf("programming error: (%s)\n", strerror(-ret));
14636 cmdline_parse_inst_t cmd_set_vf_promisc = {
14637 .f = cmd_set_vf_promisc_parsed,
14639 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14640 "Set unicast promiscuous mode for a VF from the PF",
14642 (void *)&cmd_vf_promisc_set,
14643 (void *)&cmd_vf_promisc_vf,
14644 (void *)&cmd_vf_promisc_promisc,
14645 (void *)&cmd_vf_promisc_port_id,
14646 (void *)&cmd_vf_promisc_vf_id,
14647 (void *)&cmd_vf_promisc_on_off,
14652 /* VF multicast promiscuous mode configuration */
14654 /* Common result structure for VF multicast promiscuous mode */
14655 struct cmd_vf_allmulti_result {
14656 cmdline_fixed_string_t set;
14657 cmdline_fixed_string_t vf;
14658 cmdline_fixed_string_t allmulti;
14661 cmdline_fixed_string_t on_off;
14664 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14665 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14666 TOKEN_STRING_INITIALIZER
14667 (struct cmd_vf_allmulti_result,
14669 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14670 TOKEN_STRING_INITIALIZER
14671 (struct cmd_vf_allmulti_result,
14673 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14674 TOKEN_STRING_INITIALIZER
14675 (struct cmd_vf_allmulti_result,
14676 allmulti, "allmulti");
14677 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14678 TOKEN_NUM_INITIALIZER
14679 (struct cmd_vf_allmulti_result,
14681 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14682 TOKEN_NUM_INITIALIZER
14683 (struct cmd_vf_allmulti_result,
14685 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14686 TOKEN_STRING_INITIALIZER
14687 (struct cmd_vf_allmulti_result,
14691 cmd_set_vf_allmulti_parsed(
14692 void *parsed_result,
14693 __attribute__((unused)) struct cmdline *cl,
14694 __attribute__((unused)) void *data)
14696 struct cmd_vf_allmulti_result *res = parsed_result;
14697 int ret = -ENOTSUP;
14699 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14701 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14704 #ifdef RTE_LIBRTE_I40E_PMD
14705 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14706 res->vf_id, is_on);
14713 printf("invalid vf_id %d\n", res->vf_id);
14716 printf("invalid port_id %d\n", res->port_id);
14719 printf("function not implemented\n");
14722 printf("programming error: (%s)\n", strerror(-ret));
14726 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14727 .f = cmd_set_vf_allmulti_parsed,
14729 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14730 "Set multicast promiscuous mode for a VF from the PF",
14732 (void *)&cmd_vf_allmulti_set,
14733 (void *)&cmd_vf_allmulti_vf,
14734 (void *)&cmd_vf_allmulti_allmulti,
14735 (void *)&cmd_vf_allmulti_port_id,
14736 (void *)&cmd_vf_allmulti_vf_id,
14737 (void *)&cmd_vf_allmulti_on_off,
14742 /* vf broadcast mode configuration */
14744 /* Common result structure for vf broadcast */
14745 struct cmd_set_vf_broadcast_result {
14746 cmdline_fixed_string_t set;
14747 cmdline_fixed_string_t vf;
14748 cmdline_fixed_string_t broadcast;
14751 cmdline_fixed_string_t on_off;
14754 /* Common CLI fields for vf broadcast enable disable */
14755 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14756 TOKEN_STRING_INITIALIZER
14757 (struct cmd_set_vf_broadcast_result,
14759 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14760 TOKEN_STRING_INITIALIZER
14761 (struct cmd_set_vf_broadcast_result,
14763 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14764 TOKEN_STRING_INITIALIZER
14765 (struct cmd_set_vf_broadcast_result,
14766 broadcast, "broadcast");
14767 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14768 TOKEN_NUM_INITIALIZER
14769 (struct cmd_set_vf_broadcast_result,
14771 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14772 TOKEN_NUM_INITIALIZER
14773 (struct cmd_set_vf_broadcast_result,
14775 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14776 TOKEN_STRING_INITIALIZER
14777 (struct cmd_set_vf_broadcast_result,
14781 cmd_set_vf_broadcast_parsed(
14782 void *parsed_result,
14783 __attribute__((unused)) struct cmdline *cl,
14784 __attribute__((unused)) void *data)
14786 struct cmd_set_vf_broadcast_result *res = parsed_result;
14787 int ret = -ENOTSUP;
14789 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14791 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14794 #ifdef RTE_LIBRTE_I40E_PMD
14795 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14796 res->vf_id, is_on);
14803 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14806 printf("invalid port_id %d\n", res->port_id);
14809 printf("function not implemented\n");
14812 printf("programming error: (%s)\n", strerror(-ret));
14816 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14817 .f = cmd_set_vf_broadcast_parsed,
14819 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14821 (void *)&cmd_set_vf_broadcast_set,
14822 (void *)&cmd_set_vf_broadcast_vf,
14823 (void *)&cmd_set_vf_broadcast_broadcast,
14824 (void *)&cmd_set_vf_broadcast_port_id,
14825 (void *)&cmd_set_vf_broadcast_vf_id,
14826 (void *)&cmd_set_vf_broadcast_on_off,
14831 /* vf vlan tag configuration */
14833 /* Common result structure for vf vlan tag */
14834 struct cmd_set_vf_vlan_tag_result {
14835 cmdline_fixed_string_t set;
14836 cmdline_fixed_string_t vf;
14837 cmdline_fixed_string_t vlan;
14838 cmdline_fixed_string_t tag;
14841 cmdline_fixed_string_t on_off;
14844 /* Common CLI fields for vf vlan tag enable disable */
14845 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14846 TOKEN_STRING_INITIALIZER
14847 (struct cmd_set_vf_vlan_tag_result,
14849 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14850 TOKEN_STRING_INITIALIZER
14851 (struct cmd_set_vf_vlan_tag_result,
14853 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14854 TOKEN_STRING_INITIALIZER
14855 (struct cmd_set_vf_vlan_tag_result,
14857 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14858 TOKEN_STRING_INITIALIZER
14859 (struct cmd_set_vf_vlan_tag_result,
14861 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14862 TOKEN_NUM_INITIALIZER
14863 (struct cmd_set_vf_vlan_tag_result,
14865 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14866 TOKEN_NUM_INITIALIZER
14867 (struct cmd_set_vf_vlan_tag_result,
14869 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14870 TOKEN_STRING_INITIALIZER
14871 (struct cmd_set_vf_vlan_tag_result,
14875 cmd_set_vf_vlan_tag_parsed(
14876 void *parsed_result,
14877 __attribute__((unused)) struct cmdline *cl,
14878 __attribute__((unused)) void *data)
14880 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14881 int ret = -ENOTSUP;
14883 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14885 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14888 #ifdef RTE_LIBRTE_I40E_PMD
14889 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14890 res->vf_id, is_on);
14897 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14900 printf("invalid port_id %d\n", res->port_id);
14903 printf("function not implemented\n");
14906 printf("programming error: (%s)\n", strerror(-ret));
14910 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14911 .f = cmd_set_vf_vlan_tag_parsed,
14913 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14915 (void *)&cmd_set_vf_vlan_tag_set,
14916 (void *)&cmd_set_vf_vlan_tag_vf,
14917 (void *)&cmd_set_vf_vlan_tag_vlan,
14918 (void *)&cmd_set_vf_vlan_tag_tag,
14919 (void *)&cmd_set_vf_vlan_tag_port_id,
14920 (void *)&cmd_set_vf_vlan_tag_vf_id,
14921 (void *)&cmd_set_vf_vlan_tag_on_off,
14926 /* Common definition of VF and TC TX bandwidth configuration */
14927 struct cmd_vf_tc_bw_result {
14928 cmdline_fixed_string_t set;
14929 cmdline_fixed_string_t vf;
14930 cmdline_fixed_string_t tc;
14931 cmdline_fixed_string_t tx;
14932 cmdline_fixed_string_t min_bw;
14933 cmdline_fixed_string_t max_bw;
14934 cmdline_fixed_string_t strict_link_prio;
14939 cmdline_fixed_string_t bw_list;
14943 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14944 TOKEN_STRING_INITIALIZER
14945 (struct cmd_vf_tc_bw_result,
14947 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14948 TOKEN_STRING_INITIALIZER
14949 (struct cmd_vf_tc_bw_result,
14951 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14952 TOKEN_STRING_INITIALIZER
14953 (struct cmd_vf_tc_bw_result,
14955 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14956 TOKEN_STRING_INITIALIZER
14957 (struct cmd_vf_tc_bw_result,
14959 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14960 TOKEN_STRING_INITIALIZER
14961 (struct cmd_vf_tc_bw_result,
14962 strict_link_prio, "strict-link-priority");
14963 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14964 TOKEN_STRING_INITIALIZER
14965 (struct cmd_vf_tc_bw_result,
14966 min_bw, "min-bandwidth");
14967 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14968 TOKEN_STRING_INITIALIZER
14969 (struct cmd_vf_tc_bw_result,
14970 max_bw, "max-bandwidth");
14971 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14972 TOKEN_NUM_INITIALIZER
14973 (struct cmd_vf_tc_bw_result,
14975 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14976 TOKEN_NUM_INITIALIZER
14977 (struct cmd_vf_tc_bw_result,
14979 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14980 TOKEN_NUM_INITIALIZER
14981 (struct cmd_vf_tc_bw_result,
14983 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14984 TOKEN_NUM_INITIALIZER
14985 (struct cmd_vf_tc_bw_result,
14987 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14988 TOKEN_STRING_INITIALIZER
14989 (struct cmd_vf_tc_bw_result,
14991 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14992 TOKEN_NUM_INITIALIZER
14993 (struct cmd_vf_tc_bw_result,
14996 /* VF max bandwidth setting */
14998 cmd_vf_max_bw_parsed(
14999 void *parsed_result,
15000 __attribute__((unused)) struct cmdline *cl,
15001 __attribute__((unused)) void *data)
15003 struct cmd_vf_tc_bw_result *res = parsed_result;
15004 int ret = -ENOTSUP;
15006 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15009 #ifdef RTE_LIBRTE_I40E_PMD
15010 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15011 res->vf_id, res->bw);
15018 printf("invalid vf_id %d or bandwidth %d\n",
15019 res->vf_id, res->bw);
15022 printf("invalid port_id %d\n", res->port_id);
15025 printf("function not implemented\n");
15028 printf("programming error: (%s)\n", strerror(-ret));
15032 cmdline_parse_inst_t cmd_vf_max_bw = {
15033 .f = cmd_vf_max_bw_parsed,
15035 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15037 (void *)&cmd_vf_tc_bw_set,
15038 (void *)&cmd_vf_tc_bw_vf,
15039 (void *)&cmd_vf_tc_bw_tx,
15040 (void *)&cmd_vf_tc_bw_max_bw,
15041 (void *)&cmd_vf_tc_bw_port_id,
15042 (void *)&cmd_vf_tc_bw_vf_id,
15043 (void *)&cmd_vf_tc_bw_bw,
15049 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15054 const char *p, *p0 = str;
15061 p = strchr(p0, '(');
15063 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15067 p0 = strchr(p, ')');
15069 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15073 if (size >= sizeof(s)) {
15074 printf("The string size exceeds the internal buffer size\n");
15077 snprintf(s, sizeof(s), "%.*s", size, p);
15078 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15080 printf("Failed to get the bandwidth list. ");
15084 for (i = 0; i < ret; i++)
15085 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15090 /* TC min bandwidth setting */
15092 cmd_vf_tc_min_bw_parsed(
15093 void *parsed_result,
15094 __attribute__((unused)) struct cmdline *cl,
15095 __attribute__((unused)) void *data)
15097 struct cmd_vf_tc_bw_result *res = parsed_result;
15100 int ret = -ENOTSUP;
15102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15105 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15109 #ifdef RTE_LIBRTE_I40E_PMD
15110 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15118 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15121 printf("invalid port_id %d\n", res->port_id);
15124 printf("function not implemented\n");
15127 printf("programming error: (%s)\n", strerror(-ret));
15131 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15132 .f = cmd_vf_tc_min_bw_parsed,
15134 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15135 " <bw1, bw2, ...>",
15137 (void *)&cmd_vf_tc_bw_set,
15138 (void *)&cmd_vf_tc_bw_vf,
15139 (void *)&cmd_vf_tc_bw_tc,
15140 (void *)&cmd_vf_tc_bw_tx,
15141 (void *)&cmd_vf_tc_bw_min_bw,
15142 (void *)&cmd_vf_tc_bw_port_id,
15143 (void *)&cmd_vf_tc_bw_vf_id,
15144 (void *)&cmd_vf_tc_bw_bw_list,
15150 cmd_tc_min_bw_parsed(
15151 void *parsed_result,
15152 __attribute__((unused)) struct cmdline *cl,
15153 __attribute__((unused)) void *data)
15155 struct cmd_vf_tc_bw_result *res = parsed_result;
15156 struct rte_port *port;
15159 int ret = -ENOTSUP;
15161 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15164 port = &ports[res->port_id];
15165 /** Check if the port is not started **/
15166 if (port->port_status != RTE_PORT_STOPPED) {
15167 printf("Please stop port %d first\n", res->port_id);
15171 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15175 #ifdef RTE_LIBRTE_IXGBE_PMD
15176 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15183 printf("invalid bandwidth\n");
15186 printf("invalid port_id %d\n", res->port_id);
15189 printf("function not implemented\n");
15192 printf("programming error: (%s)\n", strerror(-ret));
15196 cmdline_parse_inst_t cmd_tc_min_bw = {
15197 .f = cmd_tc_min_bw_parsed,
15199 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15201 (void *)&cmd_vf_tc_bw_set,
15202 (void *)&cmd_vf_tc_bw_tc,
15203 (void *)&cmd_vf_tc_bw_tx,
15204 (void *)&cmd_vf_tc_bw_min_bw,
15205 (void *)&cmd_vf_tc_bw_port_id,
15206 (void *)&cmd_vf_tc_bw_bw_list,
15211 /* TC max bandwidth setting */
15213 cmd_vf_tc_max_bw_parsed(
15214 void *parsed_result,
15215 __attribute__((unused)) struct cmdline *cl,
15216 __attribute__((unused)) void *data)
15218 struct cmd_vf_tc_bw_result *res = parsed_result;
15219 int ret = -ENOTSUP;
15221 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15224 #ifdef RTE_LIBRTE_I40E_PMD
15225 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15226 res->tc_no, res->bw);
15233 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15234 res->vf_id, res->tc_no, res->bw);
15237 printf("invalid port_id %d\n", res->port_id);
15240 printf("function not implemented\n");
15243 printf("programming error: (%s)\n", strerror(-ret));
15247 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15248 .f = cmd_vf_tc_max_bw_parsed,
15250 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15253 (void *)&cmd_vf_tc_bw_set,
15254 (void *)&cmd_vf_tc_bw_vf,
15255 (void *)&cmd_vf_tc_bw_tc,
15256 (void *)&cmd_vf_tc_bw_tx,
15257 (void *)&cmd_vf_tc_bw_max_bw,
15258 (void *)&cmd_vf_tc_bw_port_id,
15259 (void *)&cmd_vf_tc_bw_vf_id,
15260 (void *)&cmd_vf_tc_bw_tc_no,
15261 (void *)&cmd_vf_tc_bw_bw,
15267 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15269 /* *** Set Port default Traffic Management Hierarchy *** */
15270 struct cmd_set_port_tm_hierarchy_default_result {
15271 cmdline_fixed_string_t set;
15272 cmdline_fixed_string_t port;
15273 cmdline_fixed_string_t tm;
15274 cmdline_fixed_string_t hierarchy;
15275 cmdline_fixed_string_t def;
15279 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15280 TOKEN_STRING_INITIALIZER(
15281 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15282 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15283 TOKEN_STRING_INITIALIZER(
15284 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15285 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15286 TOKEN_STRING_INITIALIZER(
15287 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15288 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15289 TOKEN_STRING_INITIALIZER(
15290 struct cmd_set_port_tm_hierarchy_default_result,
15291 hierarchy, "hierarchy");
15292 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15293 TOKEN_STRING_INITIALIZER(
15294 struct cmd_set_port_tm_hierarchy_default_result,
15296 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15297 TOKEN_NUM_INITIALIZER(
15298 struct cmd_set_port_tm_hierarchy_default_result,
15301 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15302 __attribute__((unused)) struct cmdline *cl,
15303 __attribute__((unused)) void *data)
15305 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15306 struct rte_port *p;
15307 portid_t port_id = res->port_id;
15309 if (port_id_is_invalid(port_id, ENABLED_WARN))
15312 p = &ports[port_id];
15314 /* Forward mode: tm */
15315 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15316 printf(" softnicfwd mode not enabled(error)\n");
15320 /* Set the default tm hierarchy */
15321 p->softport.default_tm_hierarchy_enable = 1;
15324 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15325 .f = cmd_set_port_tm_hierarchy_default_parsed,
15327 .help_str = "set port tm hierarchy default <port_id>",
15329 (void *)&cmd_set_port_tm_hierarchy_default_set,
15330 (void *)&cmd_set_port_tm_hierarchy_default_port,
15331 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15332 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15333 (void *)&cmd_set_port_tm_hierarchy_default_default,
15334 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15340 /** Set VXLAN encapsulation details */
15341 struct cmd_set_vxlan_result {
15342 cmdline_fixed_string_t set;
15343 cmdline_fixed_string_t vxlan;
15344 cmdline_fixed_string_t pos_token;
15345 cmdline_fixed_string_t ip_version;
15346 uint32_t vlan_present:1;
15350 cmdline_ipaddr_t ip_src;
15351 cmdline_ipaddr_t ip_dst;
15355 struct rte_ether_addr eth_src;
15356 struct rte_ether_addr eth_dst;
15359 cmdline_parse_token_string_t cmd_set_vxlan_set =
15360 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15361 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15362 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15363 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15364 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15366 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15367 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15368 "vxlan-with-vlan");
15369 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15370 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15372 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15373 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15375 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15376 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15378 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15379 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15380 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15381 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15383 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15384 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15385 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15386 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15388 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15389 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15390 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15391 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15393 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15394 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15395 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15396 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15398 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15399 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15400 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15401 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15403 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15404 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15405 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15406 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15408 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15409 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15410 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15411 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15413 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15414 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15415 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15416 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15418 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15419 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15420 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15421 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15423 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15424 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15426 static void cmd_set_vxlan_parsed(void *parsed_result,
15427 __attribute__((unused)) struct cmdline *cl,
15428 __attribute__((unused)) void *data)
15430 struct cmd_set_vxlan_result *res = parsed_result;
15435 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15438 vxlan_encap_conf.select_tos_ttl = 0;
15439 if (strcmp(res->vxlan, "vxlan") == 0)
15440 vxlan_encap_conf.select_vlan = 0;
15441 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15442 vxlan_encap_conf.select_vlan = 1;
15443 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15444 vxlan_encap_conf.select_vlan = 0;
15445 vxlan_encap_conf.select_tos_ttl = 1;
15447 if (strcmp(res->ip_version, "ipv4") == 0)
15448 vxlan_encap_conf.select_ipv4 = 1;
15449 else if (strcmp(res->ip_version, "ipv6") == 0)
15450 vxlan_encap_conf.select_ipv4 = 0;
15453 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15454 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15455 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15456 vxlan_encap_conf.ip_tos = res->tos;
15457 vxlan_encap_conf.ip_ttl = res->ttl;
15458 if (vxlan_encap_conf.select_ipv4) {
15459 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15460 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15462 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15463 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15465 if (vxlan_encap_conf.select_vlan)
15466 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15467 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15468 RTE_ETHER_ADDR_LEN);
15469 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15470 RTE_ETHER_ADDR_LEN);
15473 cmdline_parse_inst_t cmd_set_vxlan = {
15474 .f = cmd_set_vxlan_parsed,
15476 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15477 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15478 " eth-src <eth-src> eth-dst <eth-dst>",
15480 (void *)&cmd_set_vxlan_set,
15481 (void *)&cmd_set_vxlan_vxlan,
15482 (void *)&cmd_set_vxlan_ip_version,
15483 (void *)&cmd_set_vxlan_ip_version_value,
15484 (void *)&cmd_set_vxlan_vni,
15485 (void *)&cmd_set_vxlan_vni_value,
15486 (void *)&cmd_set_vxlan_udp_src,
15487 (void *)&cmd_set_vxlan_udp_src_value,
15488 (void *)&cmd_set_vxlan_udp_dst,
15489 (void *)&cmd_set_vxlan_udp_dst_value,
15490 (void *)&cmd_set_vxlan_ip_src,
15491 (void *)&cmd_set_vxlan_ip_src_value,
15492 (void *)&cmd_set_vxlan_ip_dst,
15493 (void *)&cmd_set_vxlan_ip_dst_value,
15494 (void *)&cmd_set_vxlan_eth_src,
15495 (void *)&cmd_set_vxlan_eth_src_value,
15496 (void *)&cmd_set_vxlan_eth_dst,
15497 (void *)&cmd_set_vxlan_eth_dst_value,
15502 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15503 .f = cmd_set_vxlan_parsed,
15505 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15506 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15507 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15508 " eth-dst <eth-dst>",
15510 (void *)&cmd_set_vxlan_set,
15511 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15512 (void *)&cmd_set_vxlan_ip_version,
15513 (void *)&cmd_set_vxlan_ip_version_value,
15514 (void *)&cmd_set_vxlan_vni,
15515 (void *)&cmd_set_vxlan_vni_value,
15516 (void *)&cmd_set_vxlan_udp_src,
15517 (void *)&cmd_set_vxlan_udp_src_value,
15518 (void *)&cmd_set_vxlan_udp_dst,
15519 (void *)&cmd_set_vxlan_udp_dst_value,
15520 (void *)&cmd_set_vxlan_ip_tos,
15521 (void *)&cmd_set_vxlan_ip_tos_value,
15522 (void *)&cmd_set_vxlan_ip_ttl,
15523 (void *)&cmd_set_vxlan_ip_ttl_value,
15524 (void *)&cmd_set_vxlan_ip_src,
15525 (void *)&cmd_set_vxlan_ip_src_value,
15526 (void *)&cmd_set_vxlan_ip_dst,
15527 (void *)&cmd_set_vxlan_ip_dst_value,
15528 (void *)&cmd_set_vxlan_eth_src,
15529 (void *)&cmd_set_vxlan_eth_src_value,
15530 (void *)&cmd_set_vxlan_eth_dst,
15531 (void *)&cmd_set_vxlan_eth_dst_value,
15536 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15537 .f = cmd_set_vxlan_parsed,
15539 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15540 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15541 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15544 (void *)&cmd_set_vxlan_set,
15545 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15546 (void *)&cmd_set_vxlan_ip_version,
15547 (void *)&cmd_set_vxlan_ip_version_value,
15548 (void *)&cmd_set_vxlan_vni,
15549 (void *)&cmd_set_vxlan_vni_value,
15550 (void *)&cmd_set_vxlan_udp_src,
15551 (void *)&cmd_set_vxlan_udp_src_value,
15552 (void *)&cmd_set_vxlan_udp_dst,
15553 (void *)&cmd_set_vxlan_udp_dst_value,
15554 (void *)&cmd_set_vxlan_ip_src,
15555 (void *)&cmd_set_vxlan_ip_src_value,
15556 (void *)&cmd_set_vxlan_ip_dst,
15557 (void *)&cmd_set_vxlan_ip_dst_value,
15558 (void *)&cmd_set_vxlan_vlan,
15559 (void *)&cmd_set_vxlan_vlan_value,
15560 (void *)&cmd_set_vxlan_eth_src,
15561 (void *)&cmd_set_vxlan_eth_src_value,
15562 (void *)&cmd_set_vxlan_eth_dst,
15563 (void *)&cmd_set_vxlan_eth_dst_value,
15568 /** Set NVGRE encapsulation details */
15569 struct cmd_set_nvgre_result {
15570 cmdline_fixed_string_t set;
15571 cmdline_fixed_string_t nvgre;
15572 cmdline_fixed_string_t pos_token;
15573 cmdline_fixed_string_t ip_version;
15575 cmdline_ipaddr_t ip_src;
15576 cmdline_ipaddr_t ip_dst;
15578 struct rte_ether_addr eth_src;
15579 struct rte_ether_addr eth_dst;
15582 cmdline_parse_token_string_t cmd_set_nvgre_set =
15583 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15584 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15585 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15586 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15587 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15588 "nvgre-with-vlan");
15589 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15590 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15592 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15593 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15595 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15596 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15598 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15599 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15600 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15601 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15603 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15604 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15605 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15606 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15608 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15609 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15610 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15611 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15613 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15614 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15615 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15616 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15618 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15619 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15620 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15621 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15623 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15624 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15626 static void cmd_set_nvgre_parsed(void *parsed_result,
15627 __attribute__((unused)) struct cmdline *cl,
15628 __attribute__((unused)) void *data)
15630 struct cmd_set_nvgre_result *res = parsed_result;
15632 uint32_t nvgre_tni;
15635 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15638 if (strcmp(res->nvgre, "nvgre") == 0)
15639 nvgre_encap_conf.select_vlan = 0;
15640 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15641 nvgre_encap_conf.select_vlan = 1;
15642 if (strcmp(res->ip_version, "ipv4") == 0)
15643 nvgre_encap_conf.select_ipv4 = 1;
15644 else if (strcmp(res->ip_version, "ipv6") == 0)
15645 nvgre_encap_conf.select_ipv4 = 0;
15648 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15649 if (nvgre_encap_conf.select_ipv4) {
15650 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15651 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15653 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15654 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15656 if (nvgre_encap_conf.select_vlan)
15657 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15658 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15659 RTE_ETHER_ADDR_LEN);
15660 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15661 RTE_ETHER_ADDR_LEN);
15664 cmdline_parse_inst_t cmd_set_nvgre = {
15665 .f = cmd_set_nvgre_parsed,
15667 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15668 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15669 " eth-dst <eth-dst>",
15671 (void *)&cmd_set_nvgre_set,
15672 (void *)&cmd_set_nvgre_nvgre,
15673 (void *)&cmd_set_nvgre_ip_version,
15674 (void *)&cmd_set_nvgre_ip_version_value,
15675 (void *)&cmd_set_nvgre_tni,
15676 (void *)&cmd_set_nvgre_tni_value,
15677 (void *)&cmd_set_nvgre_ip_src,
15678 (void *)&cmd_set_nvgre_ip_src_value,
15679 (void *)&cmd_set_nvgre_ip_dst,
15680 (void *)&cmd_set_nvgre_ip_dst_value,
15681 (void *)&cmd_set_nvgre_eth_src,
15682 (void *)&cmd_set_nvgre_eth_src_value,
15683 (void *)&cmd_set_nvgre_eth_dst,
15684 (void *)&cmd_set_nvgre_eth_dst_value,
15689 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15690 .f = cmd_set_nvgre_parsed,
15692 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15693 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15694 " eth-src <eth-src> eth-dst <eth-dst>",
15696 (void *)&cmd_set_nvgre_set,
15697 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15698 (void *)&cmd_set_nvgre_ip_version,
15699 (void *)&cmd_set_nvgre_ip_version_value,
15700 (void *)&cmd_set_nvgre_tni,
15701 (void *)&cmd_set_nvgre_tni_value,
15702 (void *)&cmd_set_nvgre_ip_src,
15703 (void *)&cmd_set_nvgre_ip_src_value,
15704 (void *)&cmd_set_nvgre_ip_dst,
15705 (void *)&cmd_set_nvgre_ip_dst_value,
15706 (void *)&cmd_set_nvgre_vlan,
15707 (void *)&cmd_set_nvgre_vlan_value,
15708 (void *)&cmd_set_nvgre_eth_src,
15709 (void *)&cmd_set_nvgre_eth_src_value,
15710 (void *)&cmd_set_nvgre_eth_dst,
15711 (void *)&cmd_set_nvgre_eth_dst_value,
15716 /** Set L2 encapsulation details */
15717 struct cmd_set_l2_encap_result {
15718 cmdline_fixed_string_t set;
15719 cmdline_fixed_string_t l2_encap;
15720 cmdline_fixed_string_t pos_token;
15721 cmdline_fixed_string_t ip_version;
15722 uint32_t vlan_present:1;
15724 struct rte_ether_addr eth_src;
15725 struct rte_ether_addr eth_dst;
15728 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15729 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15730 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15731 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15732 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15733 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15734 "l2_encap-with-vlan");
15735 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15736 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15738 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15739 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15741 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15742 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15744 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15745 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15746 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15747 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15749 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15750 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15751 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15752 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15754 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15755 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15757 static void cmd_set_l2_encap_parsed(void *parsed_result,
15758 __attribute__((unused)) struct cmdline *cl,
15759 __attribute__((unused)) void *data)
15761 struct cmd_set_l2_encap_result *res = parsed_result;
15763 if (strcmp(res->l2_encap, "l2_encap") == 0)
15764 l2_encap_conf.select_vlan = 0;
15765 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15766 l2_encap_conf.select_vlan = 1;
15767 if (strcmp(res->ip_version, "ipv4") == 0)
15768 l2_encap_conf.select_ipv4 = 1;
15769 else if (strcmp(res->ip_version, "ipv6") == 0)
15770 l2_encap_conf.select_ipv4 = 0;
15773 if (l2_encap_conf.select_vlan)
15774 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15775 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15776 RTE_ETHER_ADDR_LEN);
15777 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15778 RTE_ETHER_ADDR_LEN);
15781 cmdline_parse_inst_t cmd_set_l2_encap = {
15782 .f = cmd_set_l2_encap_parsed,
15784 .help_str = "set l2_encap ip-version ipv4|ipv6"
15785 " eth-src <eth-src> eth-dst <eth-dst>",
15787 (void *)&cmd_set_l2_encap_set,
15788 (void *)&cmd_set_l2_encap_l2_encap,
15789 (void *)&cmd_set_l2_encap_ip_version,
15790 (void *)&cmd_set_l2_encap_ip_version_value,
15791 (void *)&cmd_set_l2_encap_eth_src,
15792 (void *)&cmd_set_l2_encap_eth_src_value,
15793 (void *)&cmd_set_l2_encap_eth_dst,
15794 (void *)&cmd_set_l2_encap_eth_dst_value,
15799 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15800 .f = cmd_set_l2_encap_parsed,
15802 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15803 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15805 (void *)&cmd_set_l2_encap_set,
15806 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15807 (void *)&cmd_set_l2_encap_ip_version,
15808 (void *)&cmd_set_l2_encap_ip_version_value,
15809 (void *)&cmd_set_l2_encap_vlan,
15810 (void *)&cmd_set_l2_encap_vlan_value,
15811 (void *)&cmd_set_l2_encap_eth_src,
15812 (void *)&cmd_set_l2_encap_eth_src_value,
15813 (void *)&cmd_set_l2_encap_eth_dst,
15814 (void *)&cmd_set_l2_encap_eth_dst_value,
15819 /** Set L2 decapsulation details */
15820 struct cmd_set_l2_decap_result {
15821 cmdline_fixed_string_t set;
15822 cmdline_fixed_string_t l2_decap;
15823 cmdline_fixed_string_t pos_token;
15824 uint32_t vlan_present:1;
15827 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15828 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15829 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15830 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15832 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15833 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15834 "l2_decap-with-vlan");
15836 static void cmd_set_l2_decap_parsed(void *parsed_result,
15837 __attribute__((unused)) struct cmdline *cl,
15838 __attribute__((unused)) void *data)
15840 struct cmd_set_l2_decap_result *res = parsed_result;
15842 if (strcmp(res->l2_decap, "l2_decap") == 0)
15843 l2_decap_conf.select_vlan = 0;
15844 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15845 l2_decap_conf.select_vlan = 1;
15848 cmdline_parse_inst_t cmd_set_l2_decap = {
15849 .f = cmd_set_l2_decap_parsed,
15851 .help_str = "set l2_decap",
15853 (void *)&cmd_set_l2_decap_set,
15854 (void *)&cmd_set_l2_decap_l2_decap,
15859 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15860 .f = cmd_set_l2_decap_parsed,
15862 .help_str = "set l2_decap-with-vlan",
15864 (void *)&cmd_set_l2_decap_set,
15865 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15870 /** Set MPLSoGRE encapsulation details */
15871 struct cmd_set_mplsogre_encap_result {
15872 cmdline_fixed_string_t set;
15873 cmdline_fixed_string_t mplsogre;
15874 cmdline_fixed_string_t pos_token;
15875 cmdline_fixed_string_t ip_version;
15876 uint32_t vlan_present:1;
15878 cmdline_ipaddr_t ip_src;
15879 cmdline_ipaddr_t ip_dst;
15881 struct rte_ether_addr eth_src;
15882 struct rte_ether_addr eth_dst;
15885 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15888 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15889 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15891 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15893 mplsogre, "mplsogre_encap-with-vlan");
15894 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15895 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15896 pos_token, "ip-version");
15897 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15898 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15899 ip_version, "ipv4#ipv6");
15900 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15901 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15902 pos_token, "label");
15903 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15904 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15906 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15907 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15908 pos_token, "ip-src");
15909 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15910 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15911 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15912 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15913 pos_token, "ip-dst");
15914 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15915 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15916 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15917 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15918 pos_token, "vlan-tci");
15919 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15920 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15922 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15923 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15924 pos_token, "eth-src");
15925 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15926 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15928 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15929 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15930 pos_token, "eth-dst");
15931 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15932 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15935 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15936 __attribute__((unused)) struct cmdline *cl,
15937 __attribute__((unused)) void *data)
15939 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15941 uint32_t mplsogre_label;
15944 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15947 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15948 mplsogre_encap_conf.select_vlan = 0;
15949 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15950 mplsogre_encap_conf.select_vlan = 1;
15951 if (strcmp(res->ip_version, "ipv4") == 0)
15952 mplsogre_encap_conf.select_ipv4 = 1;
15953 else if (strcmp(res->ip_version, "ipv6") == 0)
15954 mplsogre_encap_conf.select_ipv4 = 0;
15957 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15958 if (mplsogre_encap_conf.select_ipv4) {
15959 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15960 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15962 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15963 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15965 if (mplsogre_encap_conf.select_vlan)
15966 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15967 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15968 RTE_ETHER_ADDR_LEN);
15969 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15970 RTE_ETHER_ADDR_LEN);
15973 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15974 .f = cmd_set_mplsogre_encap_parsed,
15976 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15977 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15978 " eth-dst <eth-dst>",
15980 (void *)&cmd_set_mplsogre_encap_set,
15981 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15982 (void *)&cmd_set_mplsogre_encap_ip_version,
15983 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15984 (void *)&cmd_set_mplsogre_encap_label,
15985 (void *)&cmd_set_mplsogre_encap_label_value,
15986 (void *)&cmd_set_mplsogre_encap_ip_src,
15987 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15988 (void *)&cmd_set_mplsogre_encap_ip_dst,
15989 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15990 (void *)&cmd_set_mplsogre_encap_eth_src,
15991 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15992 (void *)&cmd_set_mplsogre_encap_eth_dst,
15993 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15998 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15999 .f = cmd_set_mplsogre_encap_parsed,
16001 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16002 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16003 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16005 (void *)&cmd_set_mplsogre_encap_set,
16006 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16007 (void *)&cmd_set_mplsogre_encap_ip_version,
16008 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16009 (void *)&cmd_set_mplsogre_encap_label,
16010 (void *)&cmd_set_mplsogre_encap_label_value,
16011 (void *)&cmd_set_mplsogre_encap_ip_src,
16012 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16013 (void *)&cmd_set_mplsogre_encap_ip_dst,
16014 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16015 (void *)&cmd_set_mplsogre_encap_vlan,
16016 (void *)&cmd_set_mplsogre_encap_vlan_value,
16017 (void *)&cmd_set_mplsogre_encap_eth_src,
16018 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16019 (void *)&cmd_set_mplsogre_encap_eth_dst,
16020 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16025 /** Set MPLSoGRE decapsulation details */
16026 struct cmd_set_mplsogre_decap_result {
16027 cmdline_fixed_string_t set;
16028 cmdline_fixed_string_t mplsogre;
16029 cmdline_fixed_string_t pos_token;
16030 cmdline_fixed_string_t ip_version;
16031 uint32_t vlan_present:1;
16034 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16035 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16037 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16038 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16040 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16041 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16042 mplsogre, "mplsogre_decap-with-vlan");
16043 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16044 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16045 pos_token, "ip-version");
16046 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16047 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16048 ip_version, "ipv4#ipv6");
16050 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16051 __attribute__((unused)) struct cmdline *cl,
16052 __attribute__((unused)) void *data)
16054 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16056 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16057 mplsogre_decap_conf.select_vlan = 0;
16058 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16059 mplsogre_decap_conf.select_vlan = 1;
16060 if (strcmp(res->ip_version, "ipv4") == 0)
16061 mplsogre_decap_conf.select_ipv4 = 1;
16062 else if (strcmp(res->ip_version, "ipv6") == 0)
16063 mplsogre_decap_conf.select_ipv4 = 0;
16066 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16067 .f = cmd_set_mplsogre_decap_parsed,
16069 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16071 (void *)&cmd_set_mplsogre_decap_set,
16072 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16073 (void *)&cmd_set_mplsogre_decap_ip_version,
16074 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16079 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16080 .f = cmd_set_mplsogre_decap_parsed,
16082 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16084 (void *)&cmd_set_mplsogre_decap_set,
16085 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16086 (void *)&cmd_set_mplsogre_decap_ip_version,
16087 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16092 /** Set MPLSoUDP encapsulation details */
16093 struct cmd_set_mplsoudp_encap_result {
16094 cmdline_fixed_string_t set;
16095 cmdline_fixed_string_t mplsoudp;
16096 cmdline_fixed_string_t pos_token;
16097 cmdline_fixed_string_t ip_version;
16098 uint32_t vlan_present:1;
16102 cmdline_ipaddr_t ip_src;
16103 cmdline_ipaddr_t ip_dst;
16105 struct rte_ether_addr eth_src;
16106 struct rte_ether_addr eth_dst;
16109 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16110 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16112 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16113 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16115 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16116 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16117 mplsoudp, "mplsoudp_encap-with-vlan");
16118 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16119 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16120 pos_token, "ip-version");
16121 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16122 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16123 ip_version, "ipv4#ipv6");
16124 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16125 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16126 pos_token, "label");
16127 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16128 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16130 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16131 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16132 pos_token, "udp-src");
16133 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16134 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16136 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16137 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16138 pos_token, "udp-dst");
16139 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16140 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16142 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16143 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16144 pos_token, "ip-src");
16145 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16146 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16147 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16148 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16149 pos_token, "ip-dst");
16150 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16151 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16152 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16153 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16154 pos_token, "vlan-tci");
16155 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16156 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16158 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16160 pos_token, "eth-src");
16161 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16162 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16164 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16166 pos_token, "eth-dst");
16167 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16168 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16171 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16172 __attribute__((unused)) struct cmdline *cl,
16173 __attribute__((unused)) void *data)
16175 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16177 uint32_t mplsoudp_label;
16180 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16183 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16184 mplsoudp_encap_conf.select_vlan = 0;
16185 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16186 mplsoudp_encap_conf.select_vlan = 1;
16187 if (strcmp(res->ip_version, "ipv4") == 0)
16188 mplsoudp_encap_conf.select_ipv4 = 1;
16189 else if (strcmp(res->ip_version, "ipv6") == 0)
16190 mplsoudp_encap_conf.select_ipv4 = 0;
16193 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16194 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16195 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16196 if (mplsoudp_encap_conf.select_ipv4) {
16197 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16198 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16200 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16201 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16203 if (mplsoudp_encap_conf.select_vlan)
16204 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16205 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16206 RTE_ETHER_ADDR_LEN);
16207 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16208 RTE_ETHER_ADDR_LEN);
16211 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16212 .f = cmd_set_mplsoudp_encap_parsed,
16214 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16215 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16216 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16218 (void *)&cmd_set_mplsoudp_encap_set,
16219 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16220 (void *)&cmd_set_mplsoudp_encap_ip_version,
16221 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16222 (void *)&cmd_set_mplsoudp_encap_label,
16223 (void *)&cmd_set_mplsoudp_encap_label_value,
16224 (void *)&cmd_set_mplsoudp_encap_udp_src,
16225 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16226 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16227 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16228 (void *)&cmd_set_mplsoudp_encap_ip_src,
16229 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16230 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16231 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16232 (void *)&cmd_set_mplsoudp_encap_eth_src,
16233 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16234 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16235 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16240 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16241 .f = cmd_set_mplsoudp_encap_parsed,
16243 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16244 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16245 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16246 " eth-src <eth-src> eth-dst <eth-dst>",
16248 (void *)&cmd_set_mplsoudp_encap_set,
16249 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16250 (void *)&cmd_set_mplsoudp_encap_ip_version,
16251 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16252 (void *)&cmd_set_mplsoudp_encap_label,
16253 (void *)&cmd_set_mplsoudp_encap_label_value,
16254 (void *)&cmd_set_mplsoudp_encap_udp_src,
16255 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16256 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16257 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16258 (void *)&cmd_set_mplsoudp_encap_ip_src,
16259 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16260 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16261 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16262 (void *)&cmd_set_mplsoudp_encap_vlan,
16263 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16264 (void *)&cmd_set_mplsoudp_encap_eth_src,
16265 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16266 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16267 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16272 /** Set MPLSoUDP decapsulation details */
16273 struct cmd_set_mplsoudp_decap_result {
16274 cmdline_fixed_string_t set;
16275 cmdline_fixed_string_t mplsoudp;
16276 cmdline_fixed_string_t pos_token;
16277 cmdline_fixed_string_t ip_version;
16278 uint32_t vlan_present:1;
16281 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16282 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16284 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16285 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16287 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16288 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16289 mplsoudp, "mplsoudp_decap-with-vlan");
16290 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16291 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16292 pos_token, "ip-version");
16293 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16294 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16295 ip_version, "ipv4#ipv6");
16297 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16298 __attribute__((unused)) struct cmdline *cl,
16299 __attribute__((unused)) void *data)
16301 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16303 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16304 mplsoudp_decap_conf.select_vlan = 0;
16305 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16306 mplsoudp_decap_conf.select_vlan = 1;
16307 if (strcmp(res->ip_version, "ipv4") == 0)
16308 mplsoudp_decap_conf.select_ipv4 = 1;
16309 else if (strcmp(res->ip_version, "ipv6") == 0)
16310 mplsoudp_decap_conf.select_ipv4 = 0;
16313 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16314 .f = cmd_set_mplsoudp_decap_parsed,
16316 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16318 (void *)&cmd_set_mplsoudp_decap_set,
16319 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16320 (void *)&cmd_set_mplsoudp_decap_ip_version,
16321 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16326 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16327 .f = cmd_set_mplsoudp_decap_parsed,
16329 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16331 (void *)&cmd_set_mplsoudp_decap_set,
16332 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16333 (void *)&cmd_set_mplsoudp_decap_ip_version,
16334 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16339 /* Strict link priority scheduling mode setting */
16341 cmd_strict_link_prio_parsed(
16342 void *parsed_result,
16343 __attribute__((unused)) struct cmdline *cl,
16344 __attribute__((unused)) void *data)
16346 struct cmd_vf_tc_bw_result *res = parsed_result;
16347 int ret = -ENOTSUP;
16349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16352 #ifdef RTE_LIBRTE_I40E_PMD
16353 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16360 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16363 printf("invalid port_id %d\n", res->port_id);
16366 printf("function not implemented\n");
16369 printf("programming error: (%s)\n", strerror(-ret));
16373 cmdline_parse_inst_t cmd_strict_link_prio = {
16374 .f = cmd_strict_link_prio_parsed,
16376 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16378 (void *)&cmd_vf_tc_bw_set,
16379 (void *)&cmd_vf_tc_bw_tx,
16380 (void *)&cmd_vf_tc_bw_strict_link_prio,
16381 (void *)&cmd_vf_tc_bw_port_id,
16382 (void *)&cmd_vf_tc_bw_tc_map,
16387 /* Load dynamic device personalization*/
16388 struct cmd_ddp_add_result {
16389 cmdline_fixed_string_t ddp;
16390 cmdline_fixed_string_t add;
16395 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16396 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16397 cmdline_parse_token_string_t cmd_ddp_add_add =
16398 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16399 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16400 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16401 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16402 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16405 cmd_ddp_add_parsed(
16406 void *parsed_result,
16407 __attribute__((unused)) struct cmdline *cl,
16408 __attribute__((unused)) void *data)
16410 struct cmd_ddp_add_result *res = parsed_result;
16416 int ret = -ENOTSUP;
16418 if (!all_ports_stopped()) {
16419 printf("Please stop all ports first\n");
16423 filepath = strdup(res->filepath);
16424 if (filepath == NULL) {
16425 printf("Failed to allocate memory\n");
16428 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16430 buff = open_file(file_fld[0], &size);
16432 free((void *)filepath);
16436 #ifdef RTE_LIBRTE_I40E_PMD
16437 if (ret == -ENOTSUP)
16438 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16440 RTE_PMD_I40E_PKG_OP_WR_ADD);
16443 if (ret == -EEXIST)
16444 printf("Profile has already existed.\n");
16446 printf("Failed to load profile.\n");
16447 else if (file_num == 2)
16448 save_file(file_fld[1], buff, size);
16451 free((void *)filepath);
16454 cmdline_parse_inst_t cmd_ddp_add = {
16455 .f = cmd_ddp_add_parsed,
16457 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16459 (void *)&cmd_ddp_add_ddp,
16460 (void *)&cmd_ddp_add_add,
16461 (void *)&cmd_ddp_add_port_id,
16462 (void *)&cmd_ddp_add_filepath,
16467 /* Delete dynamic device personalization*/
16468 struct cmd_ddp_del_result {
16469 cmdline_fixed_string_t ddp;
16470 cmdline_fixed_string_t del;
16475 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16476 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16477 cmdline_parse_token_string_t cmd_ddp_del_del =
16478 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16479 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16480 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16481 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16485 cmd_ddp_del_parsed(
16486 void *parsed_result,
16487 __attribute__((unused)) struct cmdline *cl,
16488 __attribute__((unused)) void *data)
16490 struct cmd_ddp_del_result *res = parsed_result;
16493 int ret = -ENOTSUP;
16495 if (!all_ports_stopped()) {
16496 printf("Please stop all ports first\n");
16500 buff = open_file(res->filepath, &size);
16504 #ifdef RTE_LIBRTE_I40E_PMD
16505 if (ret == -ENOTSUP)
16506 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16508 RTE_PMD_I40E_PKG_OP_WR_DEL);
16511 if (ret == -EACCES)
16512 printf("Profile does not exist.\n");
16514 printf("Failed to delete profile.\n");
16519 cmdline_parse_inst_t cmd_ddp_del = {
16520 .f = cmd_ddp_del_parsed,
16522 .help_str = "ddp del <port_id> <backup_profile_path>",
16524 (void *)&cmd_ddp_del_ddp,
16525 (void *)&cmd_ddp_del_del,
16526 (void *)&cmd_ddp_del_port_id,
16527 (void *)&cmd_ddp_del_filepath,
16532 /* Get dynamic device personalization profile info */
16533 struct cmd_ddp_info_result {
16534 cmdline_fixed_string_t ddp;
16535 cmdline_fixed_string_t get;
16536 cmdline_fixed_string_t info;
16540 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16541 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16542 cmdline_parse_token_string_t cmd_ddp_info_get =
16543 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16544 cmdline_parse_token_string_t cmd_ddp_info_info =
16545 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16546 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16547 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16550 cmd_ddp_info_parsed(
16551 void *parsed_result,
16552 __attribute__((unused)) struct cmdline *cl,
16553 __attribute__((unused)) void *data)
16555 struct cmd_ddp_info_result *res = parsed_result;
16558 int ret = -ENOTSUP;
16559 #ifdef RTE_LIBRTE_I40E_PMD
16562 uint32_t buff_size = 0;
16563 struct rte_pmd_i40e_profile_info info;
16564 uint32_t dev_num = 0;
16565 struct rte_pmd_i40e_ddp_device_id *devs;
16566 uint32_t proto_num = 0;
16567 struct rte_pmd_i40e_proto_info *proto = NULL;
16568 uint32_t pctype_num = 0;
16569 struct rte_pmd_i40e_ptype_info *pctype;
16570 uint32_t ptype_num = 0;
16571 struct rte_pmd_i40e_ptype_info *ptype;
16576 pkg = open_file(res->filepath, &pkg_size);
16580 #ifdef RTE_LIBRTE_I40E_PMD
16581 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16582 (uint8_t *)&info, sizeof(info),
16583 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16585 printf("Global Track id: 0x%x\n", info.track_id);
16586 printf("Global Version: %d.%d.%d.%d\n",
16587 info.version.major,
16588 info.version.minor,
16589 info.version.update,
16590 info.version.draft);
16591 printf("Global Package name: %s\n\n", info.name);
16594 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16595 (uint8_t *)&info, sizeof(info),
16596 RTE_PMD_I40E_PKG_INFO_HEADER);
16598 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16599 printf("i40e Profile Version: %d.%d.%d.%d\n",
16600 info.version.major,
16601 info.version.minor,
16602 info.version.update,
16603 info.version.draft);
16604 printf("i40e Profile name: %s\n\n", info.name);
16607 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16608 (uint8_t *)&buff_size, sizeof(buff_size),
16609 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16610 if (!ret && buff_size) {
16611 buff = (uint8_t *)malloc(buff_size);
16613 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16615 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16617 printf("Package Notes:\n%s\n\n", buff);
16622 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16623 (uint8_t *)&dev_num, sizeof(dev_num),
16624 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16625 if (!ret && dev_num) {
16626 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16627 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16629 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16630 (uint8_t *)devs, buff_size,
16631 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16633 printf("List of supported devices:\n");
16634 for (i = 0; i < dev_num; i++) {
16635 printf(" %04X:%04X %04X:%04X\n",
16636 devs[i].vendor_dev_id >> 16,
16637 devs[i].vendor_dev_id & 0xFFFF,
16638 devs[i].sub_vendor_dev_id >> 16,
16639 devs[i].sub_vendor_dev_id & 0xFFFF);
16647 /* get information about protocols and packet types */
16648 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16649 (uint8_t *)&proto_num, sizeof(proto_num),
16650 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16651 if (ret || !proto_num)
16652 goto no_print_return;
16654 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16655 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16657 goto no_print_return;
16659 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16661 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16663 printf("List of used protocols:\n");
16664 for (i = 0; i < proto_num; i++)
16665 printf(" %2u: %s\n", proto[i].proto_id,
16669 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16670 (uint8_t *)&pctype_num, sizeof(pctype_num),
16671 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16672 if (ret || !pctype_num)
16673 goto no_print_pctypes;
16675 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16676 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16678 goto no_print_pctypes;
16680 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16682 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16685 goto no_print_pctypes;
16688 printf("List of defined packet classification types:\n");
16689 for (i = 0; i < pctype_num; i++) {
16690 printf(" %2u:", pctype[i].ptype_id);
16691 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16692 proto_id = pctype[i].protocols[j];
16693 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16694 for (n = 0; n < proto_num; n++) {
16695 if (proto[n].proto_id == proto_id) {
16696 printf(" %s", proto[n].name);
16709 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16711 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16712 if (ret || !ptype_num)
16713 goto no_print_return;
16715 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16716 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16718 goto no_print_return;
16720 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16722 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16725 goto no_print_return;
16727 printf("List of defined packet types:\n");
16728 for (i = 0; i < ptype_num; i++) {
16729 printf(" %2u:", ptype[i].ptype_id);
16730 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16731 proto_id = ptype[i].protocols[j];
16732 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16733 for (n = 0; n < proto_num; n++) {
16734 if (proto[n].proto_id == proto_id) {
16735 printf(" %s", proto[n].name);
16751 if (ret == -ENOTSUP)
16752 printf("Function not supported in PMD driver\n");
16756 cmdline_parse_inst_t cmd_ddp_get_info = {
16757 .f = cmd_ddp_info_parsed,
16759 .help_str = "ddp get info <profile_path>",
16761 (void *)&cmd_ddp_info_ddp,
16762 (void *)&cmd_ddp_info_get,
16763 (void *)&cmd_ddp_info_info,
16764 (void *)&cmd_ddp_info_filepath,
16769 /* Get dynamic device personalization profile info list*/
16770 #define PROFILE_INFO_SIZE 48
16771 #define MAX_PROFILE_NUM 16
16773 struct cmd_ddp_get_list_result {
16774 cmdline_fixed_string_t ddp;
16775 cmdline_fixed_string_t get;
16776 cmdline_fixed_string_t list;
16780 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16781 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16782 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16783 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16784 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16785 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16786 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16787 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16790 cmd_ddp_get_list_parsed(
16791 __attribute__((unused)) void *parsed_result,
16792 __attribute__((unused)) struct cmdline *cl,
16793 __attribute__((unused)) void *data)
16795 #ifdef RTE_LIBRTE_I40E_PMD
16796 struct cmd_ddp_get_list_result *res = parsed_result;
16797 struct rte_pmd_i40e_profile_list *p_list;
16798 struct rte_pmd_i40e_profile_info *p_info;
16803 int ret = -ENOTSUP;
16805 #ifdef RTE_LIBRTE_I40E_PMD
16806 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16807 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16809 printf("%s: Failed to malloc buffer\n", __func__);
16811 if (ret == -ENOTSUP)
16812 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16813 (uint8_t *)p_list, size);
16816 p_num = p_list->p_count;
16817 printf("Profile number is: %d\n\n", p_num);
16819 for (i = 0; i < p_num; i++) {
16820 p_info = &p_list->p_info[i];
16821 printf("Profile %d:\n", i);
16822 printf("Track id: 0x%x\n", p_info->track_id);
16823 printf("Version: %d.%d.%d.%d\n",
16824 p_info->version.major,
16825 p_info->version.minor,
16826 p_info->version.update,
16827 p_info->version.draft);
16828 printf("Profile name: %s\n\n", p_info->name);
16836 printf("Failed to get ddp list\n");
16839 cmdline_parse_inst_t cmd_ddp_get_list = {
16840 .f = cmd_ddp_get_list_parsed,
16842 .help_str = "ddp get list <port_id>",
16844 (void *)&cmd_ddp_get_list_ddp,
16845 (void *)&cmd_ddp_get_list_get,
16846 (void *)&cmd_ddp_get_list_list,
16847 (void *)&cmd_ddp_get_list_port_id,
16852 /* Configure input set */
16853 struct cmd_cfg_input_set_result {
16854 cmdline_fixed_string_t port;
16855 cmdline_fixed_string_t cfg;
16857 cmdline_fixed_string_t pctype;
16859 cmdline_fixed_string_t inset_type;
16860 cmdline_fixed_string_t opt;
16861 cmdline_fixed_string_t field;
16866 cmd_cfg_input_set_parsed(
16867 __attribute__((unused)) void *parsed_result,
16868 __attribute__((unused)) struct cmdline *cl,
16869 __attribute__((unused)) void *data)
16871 #ifdef RTE_LIBRTE_I40E_PMD
16872 struct cmd_cfg_input_set_result *res = parsed_result;
16873 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16874 struct rte_pmd_i40e_inset inset;
16876 int ret = -ENOTSUP;
16878 if (!all_ports_stopped()) {
16879 printf("Please stop all ports first\n");
16883 #ifdef RTE_LIBRTE_I40E_PMD
16884 if (!strcmp(res->inset_type, "hash_inset"))
16885 inset_type = INSET_HASH;
16886 else if (!strcmp(res->inset_type, "fdir_inset"))
16887 inset_type = INSET_FDIR;
16888 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16889 inset_type = INSET_FDIR_FLX;
16890 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16891 &inset, inset_type);
16893 printf("Failed to get input set.\n");
16897 if (!strcmp(res->opt, "get")) {
16898 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16901 printf("Field index %d is enabled.\n", res->field_idx);
16903 printf("Field index %d is disabled.\n", res->field_idx);
16905 } else if (!strcmp(res->opt, "set"))
16906 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16908 else if (!strcmp(res->opt, "clear"))
16909 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16912 printf("Failed to configure input set field.\n");
16916 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16917 &inset, inset_type);
16919 printf("Failed to set input set.\n");
16924 if (ret == -ENOTSUP)
16925 printf("Function not supported\n");
16928 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16929 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16931 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16932 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16934 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16935 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16937 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16938 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16940 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16941 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16943 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16944 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16946 "hash_inset#fdir_inset#fdir_flx_inset");
16947 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16948 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16949 opt, "get#set#clear");
16950 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16951 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16953 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16954 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16957 cmdline_parse_inst_t cmd_cfg_input_set = {
16958 .f = cmd_cfg_input_set_parsed,
16960 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16961 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16963 (void *)&cmd_cfg_input_set_port,
16964 (void *)&cmd_cfg_input_set_cfg,
16965 (void *)&cmd_cfg_input_set_port_id,
16966 (void *)&cmd_cfg_input_set_pctype,
16967 (void *)&cmd_cfg_input_set_pctype_id,
16968 (void *)&cmd_cfg_input_set_inset_type,
16969 (void *)&cmd_cfg_input_set_opt,
16970 (void *)&cmd_cfg_input_set_field,
16971 (void *)&cmd_cfg_input_set_field_idx,
16976 /* Clear input set */
16977 struct cmd_clear_input_set_result {
16978 cmdline_fixed_string_t port;
16979 cmdline_fixed_string_t cfg;
16981 cmdline_fixed_string_t pctype;
16983 cmdline_fixed_string_t inset_type;
16984 cmdline_fixed_string_t clear;
16985 cmdline_fixed_string_t all;
16989 cmd_clear_input_set_parsed(
16990 __attribute__((unused)) void *parsed_result,
16991 __attribute__((unused)) struct cmdline *cl,
16992 __attribute__((unused)) void *data)
16994 #ifdef RTE_LIBRTE_I40E_PMD
16995 struct cmd_clear_input_set_result *res = parsed_result;
16996 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16997 struct rte_pmd_i40e_inset inset;
16999 int ret = -ENOTSUP;
17001 if (!all_ports_stopped()) {
17002 printf("Please stop all ports first\n");
17006 #ifdef RTE_LIBRTE_I40E_PMD
17007 if (!strcmp(res->inset_type, "hash_inset"))
17008 inset_type = INSET_HASH;
17009 else if (!strcmp(res->inset_type, "fdir_inset"))
17010 inset_type = INSET_FDIR;
17011 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17012 inset_type = INSET_FDIR_FLX;
17014 memset(&inset, 0, sizeof(inset));
17016 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17017 &inset, inset_type);
17019 printf("Failed to clear input set.\n");
17025 if (ret == -ENOTSUP)
17026 printf("Function not supported\n");
17029 cmdline_parse_token_string_t cmd_clear_input_set_port =
17030 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17032 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17033 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17035 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17036 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17038 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17039 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17041 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17042 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17044 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17045 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17047 "hash_inset#fdir_inset#fdir_flx_inset");
17048 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17049 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17051 cmdline_parse_token_string_t cmd_clear_input_set_all =
17052 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17055 cmdline_parse_inst_t cmd_clear_input_set = {
17056 .f = cmd_clear_input_set_parsed,
17058 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17059 "fdir_inset|fdir_flx_inset clear all",
17061 (void *)&cmd_clear_input_set_port,
17062 (void *)&cmd_clear_input_set_cfg,
17063 (void *)&cmd_clear_input_set_port_id,
17064 (void *)&cmd_clear_input_set_pctype,
17065 (void *)&cmd_clear_input_set_pctype_id,
17066 (void *)&cmd_clear_input_set_inset_type,
17067 (void *)&cmd_clear_input_set_clear,
17068 (void *)&cmd_clear_input_set_all,
17073 /* show vf stats */
17075 /* Common result structure for show vf stats */
17076 struct cmd_show_vf_stats_result {
17077 cmdline_fixed_string_t show;
17078 cmdline_fixed_string_t vf;
17079 cmdline_fixed_string_t stats;
17084 /* Common CLI fields show vf stats*/
17085 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17086 TOKEN_STRING_INITIALIZER
17087 (struct cmd_show_vf_stats_result,
17089 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17090 TOKEN_STRING_INITIALIZER
17091 (struct cmd_show_vf_stats_result,
17093 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17094 TOKEN_STRING_INITIALIZER
17095 (struct cmd_show_vf_stats_result,
17097 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17098 TOKEN_NUM_INITIALIZER
17099 (struct cmd_show_vf_stats_result,
17101 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17102 TOKEN_NUM_INITIALIZER
17103 (struct cmd_show_vf_stats_result,
17107 cmd_show_vf_stats_parsed(
17108 void *parsed_result,
17109 __attribute__((unused)) struct cmdline *cl,
17110 __attribute__((unused)) void *data)
17112 struct cmd_show_vf_stats_result *res = parsed_result;
17113 struct rte_eth_stats stats;
17114 int ret = -ENOTSUP;
17115 static const char *nic_stats_border = "########################";
17117 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17120 memset(&stats, 0, sizeof(stats));
17122 #ifdef RTE_LIBRTE_I40E_PMD
17123 if (ret == -ENOTSUP)
17124 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17128 #ifdef RTE_LIBRTE_BNXT_PMD
17129 if (ret == -ENOTSUP)
17130 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17139 printf("invalid vf_id %d\n", res->vf_id);
17142 printf("invalid port_id %d\n", res->port_id);
17145 printf("function not implemented\n");
17148 printf("programming error: (%s)\n", strerror(-ret));
17151 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17152 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17154 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17156 stats.ipackets, stats.imissed, stats.ibytes);
17157 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17158 printf(" RX-nombuf: %-10"PRIu64"\n",
17160 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17162 stats.opackets, stats.oerrors, stats.obytes);
17164 printf(" %s############################%s\n",
17165 nic_stats_border, nic_stats_border);
17168 cmdline_parse_inst_t cmd_show_vf_stats = {
17169 .f = cmd_show_vf_stats_parsed,
17171 .help_str = "show vf stats <port_id> <vf_id>",
17173 (void *)&cmd_show_vf_stats_show,
17174 (void *)&cmd_show_vf_stats_vf,
17175 (void *)&cmd_show_vf_stats_stats,
17176 (void *)&cmd_show_vf_stats_port_id,
17177 (void *)&cmd_show_vf_stats_vf_id,
17182 /* clear vf stats */
17184 /* Common result structure for clear vf stats */
17185 struct cmd_clear_vf_stats_result {
17186 cmdline_fixed_string_t clear;
17187 cmdline_fixed_string_t vf;
17188 cmdline_fixed_string_t stats;
17193 /* Common CLI fields clear vf stats*/
17194 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17195 TOKEN_STRING_INITIALIZER
17196 (struct cmd_clear_vf_stats_result,
17198 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17199 TOKEN_STRING_INITIALIZER
17200 (struct cmd_clear_vf_stats_result,
17202 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17203 TOKEN_STRING_INITIALIZER
17204 (struct cmd_clear_vf_stats_result,
17206 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17207 TOKEN_NUM_INITIALIZER
17208 (struct cmd_clear_vf_stats_result,
17210 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17211 TOKEN_NUM_INITIALIZER
17212 (struct cmd_clear_vf_stats_result,
17216 cmd_clear_vf_stats_parsed(
17217 void *parsed_result,
17218 __attribute__((unused)) struct cmdline *cl,
17219 __attribute__((unused)) void *data)
17221 struct cmd_clear_vf_stats_result *res = parsed_result;
17222 int ret = -ENOTSUP;
17224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17227 #ifdef RTE_LIBRTE_I40E_PMD
17228 if (ret == -ENOTSUP)
17229 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17232 #ifdef RTE_LIBRTE_BNXT_PMD
17233 if (ret == -ENOTSUP)
17234 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17242 printf("invalid vf_id %d\n", res->vf_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_clear_vf_stats = {
17256 .f = cmd_clear_vf_stats_parsed,
17258 .help_str = "clear vf stats <port_id> <vf_id>",
17260 (void *)&cmd_clear_vf_stats_clear,
17261 (void *)&cmd_clear_vf_stats_vf,
17262 (void *)&cmd_clear_vf_stats_stats,
17263 (void *)&cmd_clear_vf_stats_port_id,
17264 (void *)&cmd_clear_vf_stats_vf_id,
17269 /* port config pctype mapping reset */
17271 /* Common result structure for port config pctype mapping reset */
17272 struct cmd_pctype_mapping_reset_result {
17273 cmdline_fixed_string_t port;
17274 cmdline_fixed_string_t config;
17276 cmdline_fixed_string_t pctype;
17277 cmdline_fixed_string_t mapping;
17278 cmdline_fixed_string_t reset;
17281 /* Common CLI fields for port config pctype mapping reset*/
17282 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17283 TOKEN_STRING_INITIALIZER
17284 (struct cmd_pctype_mapping_reset_result,
17286 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17287 TOKEN_STRING_INITIALIZER
17288 (struct cmd_pctype_mapping_reset_result,
17290 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17291 TOKEN_NUM_INITIALIZER
17292 (struct cmd_pctype_mapping_reset_result,
17294 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17295 TOKEN_STRING_INITIALIZER
17296 (struct cmd_pctype_mapping_reset_result,
17298 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17299 TOKEN_STRING_INITIALIZER
17300 (struct cmd_pctype_mapping_reset_result,
17301 mapping, "mapping");
17302 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17303 TOKEN_STRING_INITIALIZER
17304 (struct cmd_pctype_mapping_reset_result,
17308 cmd_pctype_mapping_reset_parsed(
17309 void *parsed_result,
17310 __attribute__((unused)) struct cmdline *cl,
17311 __attribute__((unused)) void *data)
17313 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17314 int ret = -ENOTSUP;
17316 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17319 #ifdef RTE_LIBRTE_I40E_PMD
17320 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17327 printf("invalid port_id %d\n", res->port_id);
17330 printf("function not implemented\n");
17333 printf("programming error: (%s)\n", strerror(-ret));
17337 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17338 .f = cmd_pctype_mapping_reset_parsed,
17340 .help_str = "port config <port_id> pctype mapping reset",
17342 (void *)&cmd_pctype_mapping_reset_port,
17343 (void *)&cmd_pctype_mapping_reset_config,
17344 (void *)&cmd_pctype_mapping_reset_port_id,
17345 (void *)&cmd_pctype_mapping_reset_pctype,
17346 (void *)&cmd_pctype_mapping_reset_mapping,
17347 (void *)&cmd_pctype_mapping_reset_reset,
17352 /* show port pctype mapping */
17354 /* Common result structure for show port pctype mapping */
17355 struct cmd_pctype_mapping_get_result {
17356 cmdline_fixed_string_t show;
17357 cmdline_fixed_string_t port;
17359 cmdline_fixed_string_t pctype;
17360 cmdline_fixed_string_t mapping;
17363 /* Common CLI fields for pctype mapping get */
17364 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17365 TOKEN_STRING_INITIALIZER
17366 (struct cmd_pctype_mapping_get_result,
17368 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17369 TOKEN_STRING_INITIALIZER
17370 (struct cmd_pctype_mapping_get_result,
17372 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17373 TOKEN_NUM_INITIALIZER
17374 (struct cmd_pctype_mapping_get_result,
17376 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17377 TOKEN_STRING_INITIALIZER
17378 (struct cmd_pctype_mapping_get_result,
17380 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17381 TOKEN_STRING_INITIALIZER
17382 (struct cmd_pctype_mapping_get_result,
17383 mapping, "mapping");
17386 cmd_pctype_mapping_get_parsed(
17387 void *parsed_result,
17388 __attribute__((unused)) struct cmdline *cl,
17389 __attribute__((unused)) void *data)
17391 struct cmd_pctype_mapping_get_result *res = parsed_result;
17392 int ret = -ENOTSUP;
17393 #ifdef RTE_LIBRTE_I40E_PMD
17394 struct rte_pmd_i40e_flow_type_mapping
17395 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17396 int i, j, first_pctype;
17399 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17402 #ifdef RTE_LIBRTE_I40E_PMD
17403 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17410 printf("invalid port_id %d\n", res->port_id);
17413 printf("function not implemented\n");
17416 printf("programming error: (%s)\n", strerror(-ret));
17420 #ifdef RTE_LIBRTE_I40E_PMD
17421 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17422 if (mapping[i].pctype != 0ULL) {
17425 printf("pctype: ");
17426 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17427 if (mapping[i].pctype & (1ULL << j)) {
17428 printf(first_pctype ?
17429 "%02d" : ",%02d", j);
17433 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17439 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17440 .f = cmd_pctype_mapping_get_parsed,
17442 .help_str = "show port <port_id> pctype mapping",
17444 (void *)&cmd_pctype_mapping_get_show,
17445 (void *)&cmd_pctype_mapping_get_port,
17446 (void *)&cmd_pctype_mapping_get_port_id,
17447 (void *)&cmd_pctype_mapping_get_pctype,
17448 (void *)&cmd_pctype_mapping_get_mapping,
17453 /* port config pctype mapping update */
17455 /* Common result structure for port config pctype mapping update */
17456 struct cmd_pctype_mapping_update_result {
17457 cmdline_fixed_string_t port;
17458 cmdline_fixed_string_t config;
17460 cmdline_fixed_string_t pctype;
17461 cmdline_fixed_string_t mapping;
17462 cmdline_fixed_string_t update;
17463 cmdline_fixed_string_t pctype_list;
17464 uint16_t flow_type;
17467 /* Common CLI fields for pctype mapping update*/
17468 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17469 TOKEN_STRING_INITIALIZER
17470 (struct cmd_pctype_mapping_update_result,
17472 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17473 TOKEN_STRING_INITIALIZER
17474 (struct cmd_pctype_mapping_update_result,
17476 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17477 TOKEN_NUM_INITIALIZER
17478 (struct cmd_pctype_mapping_update_result,
17480 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17481 TOKEN_STRING_INITIALIZER
17482 (struct cmd_pctype_mapping_update_result,
17484 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17485 TOKEN_STRING_INITIALIZER
17486 (struct cmd_pctype_mapping_update_result,
17487 mapping, "mapping");
17488 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17489 TOKEN_STRING_INITIALIZER
17490 (struct cmd_pctype_mapping_update_result,
17492 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17493 TOKEN_STRING_INITIALIZER
17494 (struct cmd_pctype_mapping_update_result,
17495 pctype_list, NULL);
17496 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17497 TOKEN_NUM_INITIALIZER
17498 (struct cmd_pctype_mapping_update_result,
17499 flow_type, UINT16);
17502 cmd_pctype_mapping_update_parsed(
17503 void *parsed_result,
17504 __attribute__((unused)) struct cmdline *cl,
17505 __attribute__((unused)) void *data)
17507 struct cmd_pctype_mapping_update_result *res = parsed_result;
17508 int ret = -ENOTSUP;
17509 #ifdef RTE_LIBRTE_I40E_PMD
17510 struct rte_pmd_i40e_flow_type_mapping mapping;
17512 unsigned int nb_item;
17513 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17516 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17519 #ifdef RTE_LIBRTE_I40E_PMD
17520 nb_item = parse_item_list(res->pctype_list, "pctypes",
17521 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17522 mapping.flow_type = res->flow_type;
17523 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17524 mapping.pctype |= (1ULL << pctype_list[i]);
17525 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17535 printf("invalid pctype or flow type\n");
17538 printf("invalid port_id %d\n", res->port_id);
17541 printf("function not implemented\n");
17544 printf("programming error: (%s)\n", strerror(-ret));
17548 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17549 .f = cmd_pctype_mapping_update_parsed,
17551 .help_str = "port config <port_id> pctype mapping update"
17552 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17554 (void *)&cmd_pctype_mapping_update_port,
17555 (void *)&cmd_pctype_mapping_update_config,
17556 (void *)&cmd_pctype_mapping_update_port_id,
17557 (void *)&cmd_pctype_mapping_update_pctype,
17558 (void *)&cmd_pctype_mapping_update_mapping,
17559 (void *)&cmd_pctype_mapping_update_update,
17560 (void *)&cmd_pctype_mapping_update_pc_type,
17561 (void *)&cmd_pctype_mapping_update_flow_type,
17566 /* ptype mapping get */
17568 /* Common result structure for ptype mapping get */
17569 struct cmd_ptype_mapping_get_result {
17570 cmdline_fixed_string_t ptype;
17571 cmdline_fixed_string_t mapping;
17572 cmdline_fixed_string_t get;
17574 uint8_t valid_only;
17577 /* Common CLI fields for ptype mapping get */
17578 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17579 TOKEN_STRING_INITIALIZER
17580 (struct cmd_ptype_mapping_get_result,
17582 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17583 TOKEN_STRING_INITIALIZER
17584 (struct cmd_ptype_mapping_get_result,
17585 mapping, "mapping");
17586 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17587 TOKEN_STRING_INITIALIZER
17588 (struct cmd_ptype_mapping_get_result,
17590 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17591 TOKEN_NUM_INITIALIZER
17592 (struct cmd_ptype_mapping_get_result,
17594 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17595 TOKEN_NUM_INITIALIZER
17596 (struct cmd_ptype_mapping_get_result,
17597 valid_only, UINT8);
17600 cmd_ptype_mapping_get_parsed(
17601 void *parsed_result,
17602 __attribute__((unused)) struct cmdline *cl,
17603 __attribute__((unused)) void *data)
17605 struct cmd_ptype_mapping_get_result *res = parsed_result;
17606 int ret = -ENOTSUP;
17607 #ifdef RTE_LIBRTE_I40E_PMD
17608 int max_ptype_num = 256;
17609 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17614 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17617 #ifdef RTE_LIBRTE_I40E_PMD
17618 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17629 printf("invalid port_id %d\n", res->port_id);
17632 printf("function not implemented\n");
17635 printf("programming error: (%s)\n", strerror(-ret));
17638 #ifdef RTE_LIBRTE_I40E_PMD
17640 for (i = 0; i < count; i++)
17641 printf("%3d\t0x%08x\n",
17642 mapping[i].hw_ptype, mapping[i].sw_ptype);
17647 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17648 .f = cmd_ptype_mapping_get_parsed,
17650 .help_str = "ptype mapping get <port_id> <valid_only>",
17652 (void *)&cmd_ptype_mapping_get_ptype,
17653 (void *)&cmd_ptype_mapping_get_mapping,
17654 (void *)&cmd_ptype_mapping_get_get,
17655 (void *)&cmd_ptype_mapping_get_port_id,
17656 (void *)&cmd_ptype_mapping_get_valid_only,
17661 /* ptype mapping replace */
17663 /* Common result structure for ptype mapping replace */
17664 struct cmd_ptype_mapping_replace_result {
17665 cmdline_fixed_string_t ptype;
17666 cmdline_fixed_string_t mapping;
17667 cmdline_fixed_string_t replace;
17674 /* Common CLI fields for ptype mapping replace */
17675 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17676 TOKEN_STRING_INITIALIZER
17677 (struct cmd_ptype_mapping_replace_result,
17679 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17680 TOKEN_STRING_INITIALIZER
17681 (struct cmd_ptype_mapping_replace_result,
17682 mapping, "mapping");
17683 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17684 TOKEN_STRING_INITIALIZER
17685 (struct cmd_ptype_mapping_replace_result,
17686 replace, "replace");
17687 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17688 TOKEN_NUM_INITIALIZER
17689 (struct cmd_ptype_mapping_replace_result,
17691 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17692 TOKEN_NUM_INITIALIZER
17693 (struct cmd_ptype_mapping_replace_result,
17695 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17696 TOKEN_NUM_INITIALIZER
17697 (struct cmd_ptype_mapping_replace_result,
17699 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17700 TOKEN_NUM_INITIALIZER
17701 (struct cmd_ptype_mapping_replace_result,
17705 cmd_ptype_mapping_replace_parsed(
17706 void *parsed_result,
17707 __attribute__((unused)) struct cmdline *cl,
17708 __attribute__((unused)) void *data)
17710 struct cmd_ptype_mapping_replace_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_replace(res->port_id,
17727 printf("invalid ptype 0x%8x or 0x%8x\n",
17728 res->target, res->pkt_type);
17731 printf("invalid port_id %d\n", res->port_id);
17734 printf("function not implemented\n");
17737 printf("programming error: (%s)\n", strerror(-ret));
17741 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17742 .f = cmd_ptype_mapping_replace_parsed,
17745 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17747 (void *)&cmd_ptype_mapping_replace_ptype,
17748 (void *)&cmd_ptype_mapping_replace_mapping,
17749 (void *)&cmd_ptype_mapping_replace_replace,
17750 (void *)&cmd_ptype_mapping_replace_port_id,
17751 (void *)&cmd_ptype_mapping_replace_target,
17752 (void *)&cmd_ptype_mapping_replace_mask,
17753 (void *)&cmd_ptype_mapping_replace_pkt_type,
17758 /* ptype mapping reset */
17760 /* Common result structure for ptype mapping reset */
17761 struct cmd_ptype_mapping_reset_result {
17762 cmdline_fixed_string_t ptype;
17763 cmdline_fixed_string_t mapping;
17764 cmdline_fixed_string_t reset;
17768 /* Common CLI fields for ptype mapping reset*/
17769 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17770 TOKEN_STRING_INITIALIZER
17771 (struct cmd_ptype_mapping_reset_result,
17773 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17774 TOKEN_STRING_INITIALIZER
17775 (struct cmd_ptype_mapping_reset_result,
17776 mapping, "mapping");
17777 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17778 TOKEN_STRING_INITIALIZER
17779 (struct cmd_ptype_mapping_reset_result,
17781 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17782 TOKEN_NUM_INITIALIZER
17783 (struct cmd_ptype_mapping_reset_result,
17787 cmd_ptype_mapping_reset_parsed(
17788 void *parsed_result,
17789 __attribute__((unused)) struct cmdline *cl,
17790 __attribute__((unused)) void *data)
17792 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17793 int ret = -ENOTSUP;
17795 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17798 #ifdef RTE_LIBRTE_I40E_PMD
17799 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17806 printf("invalid port_id %d\n", res->port_id);
17809 printf("function not implemented\n");
17812 printf("programming error: (%s)\n", strerror(-ret));
17816 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17817 .f = cmd_ptype_mapping_reset_parsed,
17819 .help_str = "ptype mapping reset <port_id>",
17821 (void *)&cmd_ptype_mapping_reset_ptype,
17822 (void *)&cmd_ptype_mapping_reset_mapping,
17823 (void *)&cmd_ptype_mapping_reset_reset,
17824 (void *)&cmd_ptype_mapping_reset_port_id,
17829 /* ptype mapping update */
17831 /* Common result structure for ptype mapping update */
17832 struct cmd_ptype_mapping_update_result {
17833 cmdline_fixed_string_t ptype;
17834 cmdline_fixed_string_t mapping;
17835 cmdline_fixed_string_t reset;
17841 /* Common CLI fields for ptype mapping update*/
17842 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17843 TOKEN_STRING_INITIALIZER
17844 (struct cmd_ptype_mapping_update_result,
17846 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17847 TOKEN_STRING_INITIALIZER
17848 (struct cmd_ptype_mapping_update_result,
17849 mapping, "mapping");
17850 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17851 TOKEN_STRING_INITIALIZER
17852 (struct cmd_ptype_mapping_update_result,
17854 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17855 TOKEN_NUM_INITIALIZER
17856 (struct cmd_ptype_mapping_update_result,
17858 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17859 TOKEN_NUM_INITIALIZER
17860 (struct cmd_ptype_mapping_update_result,
17862 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17863 TOKEN_NUM_INITIALIZER
17864 (struct cmd_ptype_mapping_update_result,
17868 cmd_ptype_mapping_update_parsed(
17869 void *parsed_result,
17870 __attribute__((unused)) struct cmdline *cl,
17871 __attribute__((unused)) void *data)
17873 struct cmd_ptype_mapping_update_result *res = parsed_result;
17874 int ret = -ENOTSUP;
17875 #ifdef RTE_LIBRTE_I40E_PMD
17876 struct rte_pmd_i40e_ptype_mapping mapping;
17878 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17881 #ifdef RTE_LIBRTE_I40E_PMD
17882 mapping.hw_ptype = res->hw_ptype;
17883 mapping.sw_ptype = res->sw_ptype;
17884 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17894 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17897 printf("invalid port_id %d\n", res->port_id);
17900 printf("function not implemented\n");
17903 printf("programming error: (%s)\n", strerror(-ret));
17907 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17908 .f = cmd_ptype_mapping_update_parsed,
17910 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17912 (void *)&cmd_ptype_mapping_update_ptype,
17913 (void *)&cmd_ptype_mapping_update_mapping,
17914 (void *)&cmd_ptype_mapping_update_update,
17915 (void *)&cmd_ptype_mapping_update_port_id,
17916 (void *)&cmd_ptype_mapping_update_hw_ptype,
17917 (void *)&cmd_ptype_mapping_update_sw_ptype,
17922 /* Common result structure for file commands */
17923 struct cmd_cmdfile_result {
17924 cmdline_fixed_string_t load;
17925 cmdline_fixed_string_t filename;
17928 /* Common CLI fields for file commands */
17929 cmdline_parse_token_string_t cmd_load_cmdfile =
17930 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17931 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17932 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17935 cmd_load_from_file_parsed(
17936 void *parsed_result,
17937 __attribute__((unused)) struct cmdline *cl,
17938 __attribute__((unused)) void *data)
17940 struct cmd_cmdfile_result *res = parsed_result;
17942 cmdline_read_from_file(res->filename);
17945 cmdline_parse_inst_t cmd_load_from_file = {
17946 .f = cmd_load_from_file_parsed,
17948 .help_str = "load <filename>",
17950 (void *)&cmd_load_cmdfile,
17951 (void *)&cmd_load_cmdfile_filename,
17956 /* Get Rx offloads capabilities */
17957 struct cmd_rx_offload_get_capa_result {
17958 cmdline_fixed_string_t show;
17959 cmdline_fixed_string_t port;
17961 cmdline_fixed_string_t rx_offload;
17962 cmdline_fixed_string_t capabilities;
17965 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17966 TOKEN_STRING_INITIALIZER
17967 (struct cmd_rx_offload_get_capa_result,
17969 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17970 TOKEN_STRING_INITIALIZER
17971 (struct cmd_rx_offload_get_capa_result,
17973 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17974 TOKEN_NUM_INITIALIZER
17975 (struct cmd_rx_offload_get_capa_result,
17977 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17978 TOKEN_STRING_INITIALIZER
17979 (struct cmd_rx_offload_get_capa_result,
17980 rx_offload, "rx_offload");
17981 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17982 TOKEN_STRING_INITIALIZER
17983 (struct cmd_rx_offload_get_capa_result,
17984 capabilities, "capabilities");
17987 print_rx_offloads(uint64_t offloads)
17989 uint64_t single_offload;
17997 begin = __builtin_ctzll(offloads);
17998 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18000 single_offload = 1ULL << begin;
18001 for (bit = begin; bit < end; bit++) {
18002 if (offloads & single_offload)
18004 rte_eth_dev_rx_offload_name(single_offload));
18005 single_offload <<= 1;
18010 cmd_rx_offload_get_capa_parsed(
18011 void *parsed_result,
18012 __attribute__((unused)) struct cmdline *cl,
18013 __attribute__((unused)) void *data)
18015 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18016 struct rte_eth_dev_info dev_info;
18017 portid_t port_id = res->port_id;
18018 uint64_t queue_offloads;
18019 uint64_t port_offloads;
18022 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18026 queue_offloads = dev_info.rx_queue_offload_capa;
18027 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18029 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18030 printf(" Per Queue :");
18031 print_rx_offloads(queue_offloads);
18034 printf(" Per Port :");
18035 print_rx_offloads(port_offloads);
18039 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18040 .f = cmd_rx_offload_get_capa_parsed,
18042 .help_str = "show port <port_id> rx_offload capabilities",
18044 (void *)&cmd_rx_offload_get_capa_show,
18045 (void *)&cmd_rx_offload_get_capa_port,
18046 (void *)&cmd_rx_offload_get_capa_port_id,
18047 (void *)&cmd_rx_offload_get_capa_rx_offload,
18048 (void *)&cmd_rx_offload_get_capa_capabilities,
18053 /* Get Rx offloads configuration */
18054 struct cmd_rx_offload_get_configuration_result {
18055 cmdline_fixed_string_t show;
18056 cmdline_fixed_string_t port;
18058 cmdline_fixed_string_t rx_offload;
18059 cmdline_fixed_string_t configuration;
18062 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18063 TOKEN_STRING_INITIALIZER
18064 (struct cmd_rx_offload_get_configuration_result,
18066 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18067 TOKEN_STRING_INITIALIZER
18068 (struct cmd_rx_offload_get_configuration_result,
18070 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18071 TOKEN_NUM_INITIALIZER
18072 (struct cmd_rx_offload_get_configuration_result,
18074 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18075 TOKEN_STRING_INITIALIZER
18076 (struct cmd_rx_offload_get_configuration_result,
18077 rx_offload, "rx_offload");
18078 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18079 TOKEN_STRING_INITIALIZER
18080 (struct cmd_rx_offload_get_configuration_result,
18081 configuration, "configuration");
18084 cmd_rx_offload_get_configuration_parsed(
18085 void *parsed_result,
18086 __attribute__((unused)) struct cmdline *cl,
18087 __attribute__((unused)) void *data)
18089 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18090 struct rte_eth_dev_info dev_info;
18091 portid_t port_id = res->port_id;
18092 struct rte_port *port = &ports[port_id];
18093 uint64_t port_offloads;
18094 uint64_t queue_offloads;
18095 uint16_t nb_rx_queues;
18099 printf("Rx Offloading Configuration of port %d :\n", port_id);
18101 port_offloads = port->dev_conf.rxmode.offloads;
18103 print_rx_offloads(port_offloads);
18106 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18110 nb_rx_queues = dev_info.nb_rx_queues;
18111 for (q = 0; q < nb_rx_queues; q++) {
18112 queue_offloads = port->rx_conf[q].offloads;
18113 printf(" Queue[%2d] :", q);
18114 print_rx_offloads(queue_offloads);
18120 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18121 .f = cmd_rx_offload_get_configuration_parsed,
18123 .help_str = "show port <port_id> rx_offload configuration",
18125 (void *)&cmd_rx_offload_get_configuration_show,
18126 (void *)&cmd_rx_offload_get_configuration_port,
18127 (void *)&cmd_rx_offload_get_configuration_port_id,
18128 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18129 (void *)&cmd_rx_offload_get_configuration_configuration,
18134 /* Enable/Disable a per port offloading */
18135 struct cmd_config_per_port_rx_offload_result {
18136 cmdline_fixed_string_t port;
18137 cmdline_fixed_string_t config;
18139 cmdline_fixed_string_t rx_offload;
18140 cmdline_fixed_string_t offload;
18141 cmdline_fixed_string_t on_off;
18144 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18145 TOKEN_STRING_INITIALIZER
18146 (struct cmd_config_per_port_rx_offload_result,
18148 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18149 TOKEN_STRING_INITIALIZER
18150 (struct cmd_config_per_port_rx_offload_result,
18152 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18153 TOKEN_NUM_INITIALIZER
18154 (struct cmd_config_per_port_rx_offload_result,
18156 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18157 TOKEN_STRING_INITIALIZER
18158 (struct cmd_config_per_port_rx_offload_result,
18159 rx_offload, "rx_offload");
18160 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18161 TOKEN_STRING_INITIALIZER
18162 (struct cmd_config_per_port_rx_offload_result,
18163 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18164 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18165 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18166 "scatter#timestamp#security#keep_crc#rss_hash");
18167 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18168 TOKEN_STRING_INITIALIZER
18169 (struct cmd_config_per_port_rx_offload_result,
18173 search_rx_offload(const char *name)
18175 uint64_t single_offload;
18176 const char *single_name;
18180 single_offload = 1;
18181 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18182 single_name = rte_eth_dev_rx_offload_name(single_offload);
18183 if (!strcasecmp(single_name, name)) {
18187 single_offload <<= 1;
18191 return single_offload;
18197 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18198 __attribute__((unused)) struct cmdline *cl,
18199 __attribute__((unused)) void *data)
18201 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18202 portid_t port_id = res->port_id;
18203 struct rte_eth_dev_info dev_info;
18204 struct rte_port *port = &ports[port_id];
18205 uint64_t single_offload;
18206 uint16_t nb_rx_queues;
18210 if (port->port_status != RTE_PORT_STOPPED) {
18211 printf("Error: Can't config offload when Port %d "
18212 "is not stopped\n", port_id);
18216 single_offload = search_rx_offload(res->offload);
18217 if (single_offload == 0) {
18218 printf("Unknown offload name: %s\n", res->offload);
18222 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18226 nb_rx_queues = dev_info.nb_rx_queues;
18227 if (!strcmp(res->on_off, "on")) {
18228 port->dev_conf.rxmode.offloads |= single_offload;
18229 for (q = 0; q < nb_rx_queues; q++)
18230 port->rx_conf[q].offloads |= single_offload;
18232 port->dev_conf.rxmode.offloads &= ~single_offload;
18233 for (q = 0; q < nb_rx_queues; q++)
18234 port->rx_conf[q].offloads &= ~single_offload;
18237 cmd_reconfig_device_queue(port_id, 1, 1);
18240 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18241 .f = cmd_config_per_port_rx_offload_parsed,
18243 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18244 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18245 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18246 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18249 (void *)&cmd_config_per_port_rx_offload_result_port,
18250 (void *)&cmd_config_per_port_rx_offload_result_config,
18251 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18252 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18253 (void *)&cmd_config_per_port_rx_offload_result_offload,
18254 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18259 /* Enable/Disable a per queue offloading */
18260 struct cmd_config_per_queue_rx_offload_result {
18261 cmdline_fixed_string_t port;
18263 cmdline_fixed_string_t rxq;
18265 cmdline_fixed_string_t rx_offload;
18266 cmdline_fixed_string_t offload;
18267 cmdline_fixed_string_t on_off;
18270 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18271 TOKEN_STRING_INITIALIZER
18272 (struct cmd_config_per_queue_rx_offload_result,
18274 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18275 TOKEN_NUM_INITIALIZER
18276 (struct cmd_config_per_queue_rx_offload_result,
18278 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18279 TOKEN_STRING_INITIALIZER
18280 (struct cmd_config_per_queue_rx_offload_result,
18282 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18283 TOKEN_NUM_INITIALIZER
18284 (struct cmd_config_per_queue_rx_offload_result,
18286 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18287 TOKEN_STRING_INITIALIZER
18288 (struct cmd_config_per_queue_rx_offload_result,
18289 rx_offload, "rx_offload");
18290 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18291 TOKEN_STRING_INITIALIZER
18292 (struct cmd_config_per_queue_rx_offload_result,
18293 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18294 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18295 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18296 "scatter#timestamp#security#keep_crc");
18297 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18298 TOKEN_STRING_INITIALIZER
18299 (struct cmd_config_per_queue_rx_offload_result,
18303 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18304 __attribute__((unused)) struct cmdline *cl,
18305 __attribute__((unused)) void *data)
18307 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18308 struct rte_eth_dev_info dev_info;
18309 portid_t port_id = res->port_id;
18310 uint16_t queue_id = res->queue_id;
18311 struct rte_port *port = &ports[port_id];
18312 uint64_t single_offload;
18315 if (port->port_status != RTE_PORT_STOPPED) {
18316 printf("Error: Can't config offload when Port %d "
18317 "is not stopped\n", port_id);
18321 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18325 if (queue_id >= dev_info.nb_rx_queues) {
18326 printf("Error: input queue_id should be 0 ... "
18327 "%d\n", dev_info.nb_rx_queues - 1);
18331 single_offload = search_rx_offload(res->offload);
18332 if (single_offload == 0) {
18333 printf("Unknown offload name: %s\n", res->offload);
18337 if (!strcmp(res->on_off, "on"))
18338 port->rx_conf[queue_id].offloads |= single_offload;
18340 port->rx_conf[queue_id].offloads &= ~single_offload;
18342 cmd_reconfig_device_queue(port_id, 1, 1);
18345 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18346 .f = cmd_config_per_queue_rx_offload_parsed,
18348 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18349 "vlan_strip|ipv4_cksum|"
18350 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18351 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18352 "jumbo_frame|scatter|timestamp|security|keep_crc "
18355 (void *)&cmd_config_per_queue_rx_offload_result_port,
18356 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18357 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18358 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18359 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18360 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18361 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18366 /* Get Tx offloads capabilities */
18367 struct cmd_tx_offload_get_capa_result {
18368 cmdline_fixed_string_t show;
18369 cmdline_fixed_string_t port;
18371 cmdline_fixed_string_t tx_offload;
18372 cmdline_fixed_string_t capabilities;
18375 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18376 TOKEN_STRING_INITIALIZER
18377 (struct cmd_tx_offload_get_capa_result,
18379 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18380 TOKEN_STRING_INITIALIZER
18381 (struct cmd_tx_offload_get_capa_result,
18383 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18384 TOKEN_NUM_INITIALIZER
18385 (struct cmd_tx_offload_get_capa_result,
18387 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18388 TOKEN_STRING_INITIALIZER
18389 (struct cmd_tx_offload_get_capa_result,
18390 tx_offload, "tx_offload");
18391 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18392 TOKEN_STRING_INITIALIZER
18393 (struct cmd_tx_offload_get_capa_result,
18394 capabilities, "capabilities");
18397 print_tx_offloads(uint64_t offloads)
18399 uint64_t single_offload;
18407 begin = __builtin_ctzll(offloads);
18408 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18410 single_offload = 1ULL << begin;
18411 for (bit = begin; bit < end; bit++) {
18412 if (offloads & single_offload)
18414 rte_eth_dev_tx_offload_name(single_offload));
18415 single_offload <<= 1;
18420 cmd_tx_offload_get_capa_parsed(
18421 void *parsed_result,
18422 __attribute__((unused)) struct cmdline *cl,
18423 __attribute__((unused)) void *data)
18425 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18426 struct rte_eth_dev_info dev_info;
18427 portid_t port_id = res->port_id;
18428 uint64_t queue_offloads;
18429 uint64_t port_offloads;
18432 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18436 queue_offloads = dev_info.tx_queue_offload_capa;
18437 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18439 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18440 printf(" Per Queue :");
18441 print_tx_offloads(queue_offloads);
18444 printf(" Per Port :");
18445 print_tx_offloads(port_offloads);
18449 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18450 .f = cmd_tx_offload_get_capa_parsed,
18452 .help_str = "show port <port_id> tx_offload capabilities",
18454 (void *)&cmd_tx_offload_get_capa_show,
18455 (void *)&cmd_tx_offload_get_capa_port,
18456 (void *)&cmd_tx_offload_get_capa_port_id,
18457 (void *)&cmd_tx_offload_get_capa_tx_offload,
18458 (void *)&cmd_tx_offload_get_capa_capabilities,
18463 /* Get Tx offloads configuration */
18464 struct cmd_tx_offload_get_configuration_result {
18465 cmdline_fixed_string_t show;
18466 cmdline_fixed_string_t port;
18468 cmdline_fixed_string_t tx_offload;
18469 cmdline_fixed_string_t configuration;
18472 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18473 TOKEN_STRING_INITIALIZER
18474 (struct cmd_tx_offload_get_configuration_result,
18476 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18477 TOKEN_STRING_INITIALIZER
18478 (struct cmd_tx_offload_get_configuration_result,
18480 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18481 TOKEN_NUM_INITIALIZER
18482 (struct cmd_tx_offload_get_configuration_result,
18484 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18485 TOKEN_STRING_INITIALIZER
18486 (struct cmd_tx_offload_get_configuration_result,
18487 tx_offload, "tx_offload");
18488 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18489 TOKEN_STRING_INITIALIZER
18490 (struct cmd_tx_offload_get_configuration_result,
18491 configuration, "configuration");
18494 cmd_tx_offload_get_configuration_parsed(
18495 void *parsed_result,
18496 __attribute__((unused)) struct cmdline *cl,
18497 __attribute__((unused)) void *data)
18499 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18500 struct rte_eth_dev_info dev_info;
18501 portid_t port_id = res->port_id;
18502 struct rte_port *port = &ports[port_id];
18503 uint64_t port_offloads;
18504 uint64_t queue_offloads;
18505 uint16_t nb_tx_queues;
18509 printf("Tx Offloading Configuration of port %d :\n", port_id);
18511 port_offloads = port->dev_conf.txmode.offloads;
18513 print_tx_offloads(port_offloads);
18516 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18520 nb_tx_queues = dev_info.nb_tx_queues;
18521 for (q = 0; q < nb_tx_queues; q++) {
18522 queue_offloads = port->tx_conf[q].offloads;
18523 printf(" Queue[%2d] :", q);
18524 print_tx_offloads(queue_offloads);
18530 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18531 .f = cmd_tx_offload_get_configuration_parsed,
18533 .help_str = "show port <port_id> tx_offload configuration",
18535 (void *)&cmd_tx_offload_get_configuration_show,
18536 (void *)&cmd_tx_offload_get_configuration_port,
18537 (void *)&cmd_tx_offload_get_configuration_port_id,
18538 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18539 (void *)&cmd_tx_offload_get_configuration_configuration,
18544 /* Enable/Disable a per port offloading */
18545 struct cmd_config_per_port_tx_offload_result {
18546 cmdline_fixed_string_t port;
18547 cmdline_fixed_string_t config;
18549 cmdline_fixed_string_t tx_offload;
18550 cmdline_fixed_string_t offload;
18551 cmdline_fixed_string_t on_off;
18554 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18555 TOKEN_STRING_INITIALIZER
18556 (struct cmd_config_per_port_tx_offload_result,
18558 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18559 TOKEN_STRING_INITIALIZER
18560 (struct cmd_config_per_port_tx_offload_result,
18562 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18563 TOKEN_NUM_INITIALIZER
18564 (struct cmd_config_per_port_tx_offload_result,
18566 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18567 TOKEN_STRING_INITIALIZER
18568 (struct cmd_config_per_port_tx_offload_result,
18569 tx_offload, "tx_offload");
18570 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18571 TOKEN_STRING_INITIALIZER
18572 (struct cmd_config_per_port_tx_offload_result,
18573 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18574 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18575 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18576 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18577 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18578 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18579 TOKEN_STRING_INITIALIZER
18580 (struct cmd_config_per_port_tx_offload_result,
18584 search_tx_offload(const char *name)
18586 uint64_t single_offload;
18587 const char *single_name;
18591 single_offload = 1;
18592 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18593 single_name = rte_eth_dev_tx_offload_name(single_offload);
18594 if (single_name == NULL)
18596 if (!strcasecmp(single_name, name)) {
18599 } else if (!strcasecmp(single_name, "UNKNOWN"))
18601 single_offload <<= 1;
18605 return single_offload;
18611 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18612 __attribute__((unused)) struct cmdline *cl,
18613 __attribute__((unused)) void *data)
18615 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18616 portid_t port_id = res->port_id;
18617 struct rte_eth_dev_info dev_info;
18618 struct rte_port *port = &ports[port_id];
18619 uint64_t single_offload;
18620 uint16_t nb_tx_queues;
18624 if (port->port_status != RTE_PORT_STOPPED) {
18625 printf("Error: Can't config offload when Port %d "
18626 "is not stopped\n", port_id);
18630 single_offload = search_tx_offload(res->offload);
18631 if (single_offload == 0) {
18632 printf("Unknown offload name: %s\n", res->offload);
18636 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18640 nb_tx_queues = dev_info.nb_tx_queues;
18641 if (!strcmp(res->on_off, "on")) {
18642 port->dev_conf.txmode.offloads |= single_offload;
18643 for (q = 0; q < nb_tx_queues; q++)
18644 port->tx_conf[q].offloads |= single_offload;
18646 port->dev_conf.txmode.offloads &= ~single_offload;
18647 for (q = 0; q < nb_tx_queues; q++)
18648 port->tx_conf[q].offloads &= ~single_offload;
18651 cmd_reconfig_device_queue(port_id, 1, 1);
18654 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18655 .f = cmd_config_per_port_tx_offload_parsed,
18657 .help_str = "port config <port_id> tx_offload "
18658 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18659 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18660 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18661 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18662 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18664 (void *)&cmd_config_per_port_tx_offload_result_port,
18665 (void *)&cmd_config_per_port_tx_offload_result_config,
18666 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18667 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18668 (void *)&cmd_config_per_port_tx_offload_result_offload,
18669 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18674 /* Enable/Disable a per queue offloading */
18675 struct cmd_config_per_queue_tx_offload_result {
18676 cmdline_fixed_string_t port;
18678 cmdline_fixed_string_t txq;
18680 cmdline_fixed_string_t tx_offload;
18681 cmdline_fixed_string_t offload;
18682 cmdline_fixed_string_t on_off;
18685 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18686 TOKEN_STRING_INITIALIZER
18687 (struct cmd_config_per_queue_tx_offload_result,
18689 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18690 TOKEN_NUM_INITIALIZER
18691 (struct cmd_config_per_queue_tx_offload_result,
18693 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18694 TOKEN_STRING_INITIALIZER
18695 (struct cmd_config_per_queue_tx_offload_result,
18697 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18698 TOKEN_NUM_INITIALIZER
18699 (struct cmd_config_per_queue_tx_offload_result,
18701 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18702 TOKEN_STRING_INITIALIZER
18703 (struct cmd_config_per_queue_tx_offload_result,
18704 tx_offload, "tx_offload");
18705 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18706 TOKEN_STRING_INITIALIZER
18707 (struct cmd_config_per_queue_tx_offload_result,
18708 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18709 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18710 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18711 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18712 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18713 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18714 TOKEN_STRING_INITIALIZER
18715 (struct cmd_config_per_queue_tx_offload_result,
18719 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18720 __attribute__((unused)) struct cmdline *cl,
18721 __attribute__((unused)) void *data)
18723 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18724 struct rte_eth_dev_info dev_info;
18725 portid_t port_id = res->port_id;
18726 uint16_t queue_id = res->queue_id;
18727 struct rte_port *port = &ports[port_id];
18728 uint64_t single_offload;
18731 if (port->port_status != RTE_PORT_STOPPED) {
18732 printf("Error: Can't config offload when Port %d "
18733 "is not stopped\n", port_id);
18737 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18741 if (queue_id >= dev_info.nb_tx_queues) {
18742 printf("Error: input queue_id should be 0 ... "
18743 "%d\n", dev_info.nb_tx_queues - 1);
18747 single_offload = search_tx_offload(res->offload);
18748 if (single_offload == 0) {
18749 printf("Unknown offload name: %s\n", res->offload);
18753 if (!strcmp(res->on_off, "on"))
18754 port->tx_conf[queue_id].offloads |= single_offload;
18756 port->tx_conf[queue_id].offloads &= ~single_offload;
18758 cmd_reconfig_device_queue(port_id, 1, 1);
18761 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18762 .f = cmd_config_per_queue_tx_offload_parsed,
18764 .help_str = "port <port_id> txq <queue_id> tx_offload "
18765 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18766 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18767 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18768 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18769 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18772 (void *)&cmd_config_per_queue_tx_offload_result_port,
18773 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18774 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18775 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18776 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18777 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18778 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18783 /* *** configure tx_metadata for specific port *** */
18784 struct cmd_config_tx_metadata_specific_result {
18785 cmdline_fixed_string_t port;
18786 cmdline_fixed_string_t keyword;
18788 cmdline_fixed_string_t item;
18793 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18794 __attribute__((unused)) struct cmdline *cl,
18795 __attribute__((unused)) void *data)
18797 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18801 ports[res->port_id].tx_metadata = res->value;
18802 /* Add/remove callback to insert valid metadata in every Tx packet. */
18803 if (ports[res->port_id].tx_metadata)
18804 add_tx_md_callback(res->port_id);
18806 remove_tx_md_callback(res->port_id);
18807 rte_flow_dynf_metadata_register();
18810 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18811 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18813 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18814 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18815 keyword, "config");
18816 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18817 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18819 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18820 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18821 item, "tx_metadata");
18822 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18823 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18826 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18827 .f = cmd_config_tx_metadata_specific_parsed,
18829 .help_str = "port config <port_id> tx_metadata <value>",
18831 (void *)&cmd_config_tx_metadata_specific_port,
18832 (void *)&cmd_config_tx_metadata_specific_keyword,
18833 (void *)&cmd_config_tx_metadata_specific_id,
18834 (void *)&cmd_config_tx_metadata_specific_item,
18835 (void *)&cmd_config_tx_metadata_specific_value,
18840 /* *** display tx_metadata per port configuration *** */
18841 struct cmd_show_tx_metadata_result {
18842 cmdline_fixed_string_t cmd_show;
18843 cmdline_fixed_string_t cmd_port;
18844 cmdline_fixed_string_t cmd_keyword;
18849 cmd_show_tx_metadata_parsed(void *parsed_result,
18850 __attribute__((unused)) struct cmdline *cl,
18851 __attribute__((unused)) void *data)
18853 struct cmd_show_tx_metadata_result *res = parsed_result;
18855 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18856 printf("invalid port id %u\n", res->cmd_pid);
18859 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18860 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18861 ports[res->cmd_pid].tx_metadata);
18865 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18866 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18868 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18869 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18871 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18872 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18874 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18875 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18876 cmd_keyword, "tx_metadata");
18878 cmdline_parse_inst_t cmd_show_tx_metadata = {
18879 .f = cmd_show_tx_metadata_parsed,
18881 .help_str = "show port <port_id> tx_metadata",
18883 (void *)&cmd_show_tx_metadata_show,
18884 (void *)&cmd_show_tx_metadata_port,
18885 (void *)&cmd_show_tx_metadata_pid,
18886 (void *)&cmd_show_tx_metadata_keyword,
18891 /* show port supported ptypes */
18893 /* Common result structure for show port ptypes */
18894 struct cmd_show_port_supported_ptypes_result {
18895 cmdline_fixed_string_t show;
18896 cmdline_fixed_string_t port;
18898 cmdline_fixed_string_t ptypes;
18901 /* Common CLI fields for show port ptypes */
18902 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18903 TOKEN_STRING_INITIALIZER
18904 (struct cmd_show_port_supported_ptypes_result,
18906 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18907 TOKEN_STRING_INITIALIZER
18908 (struct cmd_show_port_supported_ptypes_result,
18910 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18911 TOKEN_NUM_INITIALIZER
18912 (struct cmd_show_port_supported_ptypes_result,
18914 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18915 TOKEN_STRING_INITIALIZER
18916 (struct cmd_show_port_supported_ptypes_result,
18920 cmd_show_port_supported_ptypes_parsed(
18921 void *parsed_result,
18922 __attribute__((unused)) struct cmdline *cl,
18923 __attribute__((unused)) void *data)
18925 #define RSVD_PTYPE_MASK 0xf0000000
18926 #define MAX_PTYPES_PER_LAYER 16
18927 #define LTYPE_NAMESIZE 32
18928 #define PTYPE_NAMESIZE 256
18929 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18930 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18931 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18932 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18933 uint16_t port_id = res->port_id;
18936 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18940 while (ptype_mask != RSVD_PTYPE_MASK) {
18942 switch (ptype_mask) {
18943 case RTE_PTYPE_L2_MASK:
18944 strlcpy(ltype, "L2", sizeof(ltype));
18946 case RTE_PTYPE_L3_MASK:
18947 strlcpy(ltype, "L3", sizeof(ltype));
18949 case RTE_PTYPE_L4_MASK:
18950 strlcpy(ltype, "L4", sizeof(ltype));
18952 case RTE_PTYPE_TUNNEL_MASK:
18953 strlcpy(ltype, "Tunnel", sizeof(ltype));
18955 case RTE_PTYPE_INNER_L2_MASK:
18956 strlcpy(ltype, "Inner L2", sizeof(ltype));
18958 case RTE_PTYPE_INNER_L3_MASK:
18959 strlcpy(ltype, "Inner L3", sizeof(ltype));
18961 case RTE_PTYPE_INNER_L4_MASK:
18962 strlcpy(ltype, "Inner L4", sizeof(ltype));
18968 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18969 ptype_mask, ptypes,
18970 MAX_PTYPES_PER_LAYER);
18973 printf("Supported %s ptypes:\n", ltype);
18975 printf("%s ptypes unsupported\n", ltype);
18977 for (i = 0; i < ret; ++i) {
18978 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18979 printf("%s\n", buf);
18986 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18987 .f = cmd_show_port_supported_ptypes_parsed,
18989 .help_str = "show port <port_id> ptypes",
18991 (void *)&cmd_show_port_supported_ptypes_show,
18992 (void *)&cmd_show_port_supported_ptypes_port,
18993 (void *)&cmd_show_port_supported_ptypes_port_id,
18994 (void *)&cmd_show_port_supported_ptypes_ptypes,
18999 /* *** display rx/tx descriptor status *** */
19000 struct cmd_show_rx_tx_desc_status_result {
19001 cmdline_fixed_string_t cmd_show;
19002 cmdline_fixed_string_t cmd_port;
19003 cmdline_fixed_string_t cmd_keyword;
19004 cmdline_fixed_string_t cmd_desc;
19005 cmdline_fixed_string_t cmd_status;
19012 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19013 __attribute__((unused)) struct cmdline *cl,
19014 __attribute__((unused)) void *data)
19016 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19019 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19020 printf("invalid port id %u\n", res->cmd_pid);
19024 if (!strcmp(res->cmd_keyword, "rxq")) {
19025 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19028 printf("Invalid queueid = %d\n", res->cmd_qid);
19031 if (rc == RTE_ETH_RX_DESC_AVAIL)
19032 printf("Desc status = AVAILABLE\n");
19033 else if (rc == RTE_ETH_RX_DESC_DONE)
19034 printf("Desc status = DONE\n");
19036 printf("Desc status = UNAVAILABLE\n");
19037 } else if (!strcmp(res->cmd_keyword, "txq")) {
19038 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19041 printf("Invalid queueid = %d\n", res->cmd_qid);
19044 if (rc == RTE_ETH_TX_DESC_FULL)
19045 printf("Desc status = FULL\n");
19046 else if (rc == RTE_ETH_TX_DESC_DONE)
19047 printf("Desc status = DONE\n");
19049 printf("Desc status = UNAVAILABLE\n");
19053 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19054 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19056 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19057 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19059 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19060 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19062 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19063 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19064 cmd_keyword, "rxq#txq");
19065 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19066 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19068 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19069 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19071 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19072 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19074 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19075 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19076 cmd_status, "status");
19077 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19078 .f = cmd_show_rx_tx_desc_status_parsed,
19080 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19083 (void *)&cmd_show_rx_tx_desc_status_show,
19084 (void *)&cmd_show_rx_tx_desc_status_port,
19085 (void *)&cmd_show_rx_tx_desc_status_pid,
19086 (void *)&cmd_show_rx_tx_desc_status_keyword,
19087 (void *)&cmd_show_rx_tx_desc_status_qid,
19088 (void *)&cmd_show_rx_tx_desc_status_desc,
19089 (void *)&cmd_show_rx_tx_desc_status_did,
19090 (void *)&cmd_show_rx_tx_desc_status_status,
19095 /* Common result structure for set port ptypes */
19096 struct cmd_set_port_ptypes_result {
19097 cmdline_fixed_string_t set;
19098 cmdline_fixed_string_t port;
19100 cmdline_fixed_string_t ptype_mask;
19104 /* Common CLI fields for set port ptypes */
19105 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19106 TOKEN_STRING_INITIALIZER
19107 (struct cmd_set_port_ptypes_result,
19109 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19110 TOKEN_STRING_INITIALIZER
19111 (struct cmd_set_port_ptypes_result,
19113 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19114 TOKEN_NUM_INITIALIZER
19115 (struct cmd_set_port_ptypes_result,
19117 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19118 TOKEN_STRING_INITIALIZER
19119 (struct cmd_set_port_ptypes_result,
19120 ptype_mask, "ptype_mask");
19121 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19122 TOKEN_NUM_INITIALIZER
19123 (struct cmd_set_port_ptypes_result,
19127 cmd_set_port_ptypes_parsed(
19128 void *parsed_result,
19129 __attribute__((unused)) struct cmdline *cl,
19130 __attribute__((unused)) void *data)
19132 struct cmd_set_port_ptypes_result *res = parsed_result;
19133 #define PTYPE_NAMESIZE 256
19134 char ptype_name[PTYPE_NAMESIZE];
19135 uint16_t port_id = res->port_id;
19136 uint32_t ptype_mask = res->mask;
19139 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19142 printf("Port %d doesn't support any ptypes.\n", port_id);
19146 uint32_t ptypes[ret];
19148 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19150 printf("Unable to set requested ptypes for Port %d\n", port_id);
19154 printf("Successfully set following ptypes for Port %d\n", port_id);
19155 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19156 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19157 printf("%s\n", ptype_name);
19160 clear_ptypes = false;
19163 cmdline_parse_inst_t cmd_set_port_ptypes = {
19164 .f = cmd_set_port_ptypes_parsed,
19166 .help_str = "set port <port_id> ptype_mask <mask>",
19168 (void *)&cmd_set_port_ptypes_set,
19169 (void *)&cmd_set_port_ptypes_port,
19170 (void *)&cmd_set_port_ptypes_port_id,
19171 (void *)&cmd_set_port_ptypes_mask_str,
19172 (void *)&cmd_set_port_ptypes_mask_u32,
19177 /* *** display mac addresses added to a port *** */
19178 struct cmd_showport_macs_result {
19179 cmdline_fixed_string_t cmd_show;
19180 cmdline_fixed_string_t cmd_port;
19181 cmdline_fixed_string_t cmd_keyword;
19186 cmd_showport_macs_parsed(void *parsed_result,
19187 __attribute__((unused)) struct cmdline *cl,
19188 __attribute__((unused)) void *data)
19190 struct cmd_showport_macs_result *res = parsed_result;
19192 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19195 if (!strcmp(res->cmd_keyword, "macs"))
19196 show_macs(res->cmd_pid);
19197 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19198 show_mcast_macs(res->cmd_pid);
19201 cmdline_parse_token_string_t cmd_showport_macs_show =
19202 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19204 cmdline_parse_token_string_t cmd_showport_macs_port =
19205 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19207 cmdline_parse_token_num_t cmd_showport_macs_pid =
19208 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19210 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19211 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19212 cmd_keyword, "macs#mcast_macs");
19214 cmdline_parse_inst_t cmd_showport_macs = {
19215 .f = cmd_showport_macs_parsed,
19217 .help_str = "show port <port_id> macs|mcast_macs",
19219 (void *)&cmd_showport_macs_show,
19220 (void *)&cmd_showport_macs_port,
19221 (void *)&cmd_showport_macs_pid,
19222 (void *)&cmd_showport_macs_keyword,
19227 /* ******************************************************************************** */
19229 /* list of instructions */
19230 cmdline_parse_ctx_t main_ctx[] = {
19231 (cmdline_parse_inst_t *)&cmd_help_brief,
19232 (cmdline_parse_inst_t *)&cmd_help_long,
19233 (cmdline_parse_inst_t *)&cmd_quit,
19234 (cmdline_parse_inst_t *)&cmd_load_from_file,
19235 (cmdline_parse_inst_t *)&cmd_showport,
19236 (cmdline_parse_inst_t *)&cmd_showqueue,
19237 (cmdline_parse_inst_t *)&cmd_showportall,
19238 (cmdline_parse_inst_t *)&cmd_showdevice,
19239 (cmdline_parse_inst_t *)&cmd_showcfg,
19240 (cmdline_parse_inst_t *)&cmd_showfwdall,
19241 (cmdline_parse_inst_t *)&cmd_start,
19242 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19243 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19244 (cmdline_parse_inst_t *)&cmd_set_link_up,
19245 (cmdline_parse_inst_t *)&cmd_set_link_down,
19246 (cmdline_parse_inst_t *)&cmd_reset,
19247 (cmdline_parse_inst_t *)&cmd_set_numbers,
19248 (cmdline_parse_inst_t *)&cmd_set_log,
19249 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19250 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19251 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19252 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19253 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19254 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19255 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19256 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19257 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19258 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19259 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19260 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19261 (cmdline_parse_inst_t *)&cmd_set_link_check,
19262 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19263 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19264 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19265 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19266 #ifdef RTE_LIBRTE_PMD_BOND
19267 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19268 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19269 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19270 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19271 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19272 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19273 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19274 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19275 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19276 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19277 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19279 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19280 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19281 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19282 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19283 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19284 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19285 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19286 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19287 (cmdline_parse_inst_t *)&cmd_csum_set,
19288 (cmdline_parse_inst_t *)&cmd_csum_show,
19289 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19290 (cmdline_parse_inst_t *)&cmd_tso_set,
19291 (cmdline_parse_inst_t *)&cmd_tso_show,
19292 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19293 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19294 (cmdline_parse_inst_t *)&cmd_gro_enable,
19295 (cmdline_parse_inst_t *)&cmd_gro_flush,
19296 (cmdline_parse_inst_t *)&cmd_gro_show,
19297 (cmdline_parse_inst_t *)&cmd_gso_enable,
19298 (cmdline_parse_inst_t *)&cmd_gso_size,
19299 (cmdline_parse_inst_t *)&cmd_gso_show,
19300 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19301 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19302 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19303 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19304 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19305 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19306 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19307 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19308 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19309 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19310 (cmdline_parse_inst_t *)&cmd_config_dcb,
19311 (cmdline_parse_inst_t *)&cmd_read_reg,
19312 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19313 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19314 (cmdline_parse_inst_t *)&cmd_write_reg,
19315 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19316 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19317 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19318 (cmdline_parse_inst_t *)&cmd_stop,
19319 (cmdline_parse_inst_t *)&cmd_mac_addr,
19320 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19321 (cmdline_parse_inst_t *)&cmd_set_qmap,
19322 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19323 (cmdline_parse_inst_t *)&cmd_operate_port,
19324 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19325 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19326 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19327 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19328 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19329 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19330 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19331 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19332 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19333 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19334 (cmdline_parse_inst_t *)&cmd_config_mtu,
19335 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19336 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19337 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19338 (cmdline_parse_inst_t *)&cmd_config_rss,
19339 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19340 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19341 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19342 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19343 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19344 (cmdline_parse_inst_t *)&cmd_showport_reta,
19345 (cmdline_parse_inst_t *)&cmd_showport_macs,
19346 (cmdline_parse_inst_t *)&cmd_config_burst,
19347 (cmdline_parse_inst_t *)&cmd_config_thresh,
19348 (cmdline_parse_inst_t *)&cmd_config_threshold,
19349 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19350 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19351 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19352 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19353 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19354 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19355 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19356 (cmdline_parse_inst_t *)&cmd_global_config,
19357 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19358 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19359 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19360 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19361 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19362 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19363 (cmdline_parse_inst_t *)&cmd_dump,
19364 (cmdline_parse_inst_t *)&cmd_dump_one,
19365 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19366 (cmdline_parse_inst_t *)&cmd_syn_filter,
19367 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19368 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19369 (cmdline_parse_inst_t *)&cmd_flex_filter,
19370 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19371 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19372 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19373 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19374 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19375 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19376 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19377 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19378 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19379 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19380 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19381 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19382 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19383 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19384 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19385 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19386 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19387 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19388 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19389 (cmdline_parse_inst_t *)&cmd_flow,
19390 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19391 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19392 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19393 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19394 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19395 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19396 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19397 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19398 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19399 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19400 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19401 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19402 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19403 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19404 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19405 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19406 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19407 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19408 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19409 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19410 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19411 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19412 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19413 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19414 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19415 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19416 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19417 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19418 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19419 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19420 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19421 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19422 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19423 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19424 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19425 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19426 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19427 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19428 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19429 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19430 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19431 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19432 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19433 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19434 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19435 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19436 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19437 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19438 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19439 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19440 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19442 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19443 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19444 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19445 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19446 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19447 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19448 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19449 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19450 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19451 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19452 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19453 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19454 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19455 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19456 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19457 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19458 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19459 (cmdline_parse_inst_t *)&cmd_ddp_add,
19460 (cmdline_parse_inst_t *)&cmd_ddp_del,
19461 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19462 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19463 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19464 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19465 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19466 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19467 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19468 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19469 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19470 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19471 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19472 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19474 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19475 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19476 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19477 (cmdline_parse_inst_t *)&cmd_queue_region,
19478 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19479 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19480 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19481 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19482 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19483 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19484 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19485 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19486 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19487 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19488 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19489 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19490 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19491 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19492 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19493 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19494 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19495 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19496 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19497 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19498 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19499 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19500 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19501 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19502 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19503 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19504 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19505 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19506 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19507 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19508 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19509 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19510 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19511 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19512 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19513 #ifdef RTE_LIBRTE_BPF
19514 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19515 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19517 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19518 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19519 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19520 (cmdline_parse_inst_t *)&cmd_set_raw,
19521 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19522 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19526 /* read cmdline commands from file */
19528 cmdline_read_from_file(const char *filename)
19530 struct cmdline *cl;
19532 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19534 printf("Failed to create file based cmdline context: %s\n",
19539 cmdline_interact(cl);
19544 printf("Read CLI commands from %s\n", filename);
19547 /* prompt function, called from main on MASTER lcore */
19551 /* initialize non-constant commands */
19552 cmd_set_fwd_mode_init();
19553 cmd_set_fwd_retry_mode_init();
19555 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19556 if (testpmd_cl == NULL)
19558 cmdline_interact(testpmd_cl);
19559 cmdline_stdin_exit(testpmd_cl);
19565 if (testpmd_cl != NULL)
19566 cmdline_quit(testpmd_cl);
19570 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19572 if (id == (portid_t)RTE_PORT_ALL) {
19575 RTE_ETH_FOREACH_DEV(pid) {
19576 /* check if need_reconfig has been set to 1 */
19577 if (ports[pid].need_reconfig == 0)
19578 ports[pid].need_reconfig = dev;
19579 /* check if need_reconfig_queues has been set to 1 */
19580 if (ports[pid].need_reconfig_queues == 0)
19581 ports[pid].need_reconfig_queues = queue;
19583 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19584 /* check if need_reconfig has been set to 1 */
19585 if (ports[id].need_reconfig == 0)
19586 ports[id].need_reconfig = dev;
19587 /* check if need_reconfig_queues has been set to 1 */
19588 if (ports[id].need_reconfig_queues == 0)
19589 ports[id].need_reconfig_queues = queue;