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>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
66 #ifdef RTE_LIBRTE_BNXT_PMD
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
85 __attribute__((unused)) void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commmands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __attribute__((unused)) void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port X rss reta (size) (mask0,mask1,...)\n"
170 " Display the rss redirection table entry indicated"
171 " by masks on port X. size is used to indicate the"
172 " hardware supported reta size\n\n"
174 "show port (port_id) rss-hash [key]\n"
175 " Display the RSS hash functions and RSS hash key of port\n\n"
177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 " Clear information for port_id, or all.\n\n"
180 "show (rxq|txq) info (port_id) (queue_id)\n"
181 " Display information for configured RX/TX queue.\n\n"
183 "show config (rxtx|cores|fwd|txpkts)\n"
184 " Display the given configuration.\n\n"
186 "read rxd (port_id) (queue_id) (rxd_id)\n"
187 " Display an RX descriptor of a port RX queue.\n\n"
189 "read txd (port_id) (queue_id) (txd_id)\n"
190 " Display a TX descriptor of a port TX queue.\n\n"
192 "ddp get list (port_id)\n"
193 " Get ddp profile info list\n\n"
195 "ddp get info (profile_path)\n"
196 " Get ddp profile information.\n\n"
198 "show vf stats (port_id) (vf_id)\n"
199 " Display a VF's statistics.\n\n"
201 "clear vf stats (port_id) (vf_id)\n"
202 " Reset a VF's statistics.\n\n"
204 "show port (port_id) pctype mapping\n"
205 " Get flow ptype to pctype mapping on a port\n\n"
207 "show port meter stats (port_id) (meter_id) (clear)\n"
208 " Get meter stats on a port\n\n"
210 "show fwd stats all\n"
211 " Display statistics for all fwd engines.\n\n"
213 "clear fwd stats all\n"
214 " Clear statistics for all fwd engines.\n\n"
216 "show port (port_id) rx_offload capabilities\n"
217 " List all per queue and per port Rx offloading"
218 " capabilities of a port\n\n"
220 "show port (port_id) rx_offload configuration\n"
221 " List port level and all queue level"
222 " Rx offloading configuration\n\n"
224 "show port (port_id) tx_offload capabilities\n"
225 " List all per queue and per port"
226 " Tx offloading capabilities of a port\n\n"
228 "show port (port_id) tx_offload configuration\n"
229 " List port level and all queue level"
230 " Tx offloading configuration\n\n"
232 "show port (port_id) tx_metadata\n"
233 " Show Tx metadata value set"
234 " for a specific port\n\n"
236 "show port (port_id) ptypes\n"
237 " Show port supported ptypes"
238 " for a specific port\n\n"
240 "show device info (<identifier>|all)"
241 " Show general information about devices probed.\n\n"
243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 " Show status of rx|tx descriptor.\n\n"
246 "show port (port_id) macs|mcast_macs"
247 " Display list of mac addresses added to port.\n\n"
251 if (show_all || !strcmp(res->section, "config")) {
257 "Configuration changes only become active when"
258 " forwarding is started/restarted.\n\n"
261 " Reset forwarding to the default configuration.\n\n"
263 "set verbose (level)\n"
264 " Set the debug verbosity level X.\n\n"
266 "set log global|(type) (level)\n"
267 " Set the log level.\n\n"
270 " Set number of ports.\n\n"
273 " Set number of cores.\n\n"
275 "set coremask (mask)\n"
276 " Set the forwarding cores hexadecimal mask.\n\n"
278 "set portmask (mask)\n"
279 " Set the forwarding ports hexadecimal mask.\n\n"
282 " Set number of packets per burst.\n\n"
284 "set burst tx delay (microseconds) retry (num)\n"
285 " Set the transmit delay time and number of retries,"
286 " effective when retry is enabled.\n\n"
288 "set txpkts (x[,y]*)\n"
289 " Set the length of each segment of TXONLY"
290 " and optionally CSUM packets.\n\n"
292 "set txsplit (off|on|rand)\n"
293 " Set the split policy for the TX packets."
294 " Right now only applicable for CSUM and TXONLY"
297 "set corelist (x[,y]*)\n"
298 " Set the list of forwarding cores.\n\n"
300 "set portlist (x[,y]*)\n"
301 " Set the list of forwarding ports.\n\n"
303 "set port setup on (iterator|event)\n"
304 " Select how attached port is retrieved for setup.\n\n"
306 "set tx loopback (port_id) (on|off)\n"
307 " Enable or disable tx loopback.\n\n"
309 "set all queues drop (port_id) (on|off)\n"
310 " Set drop enable bit for all queues.\n\n"
312 "set vf split drop (port_id) (vf_id) (on|off)\n"
313 " Set split drop enable bit for a VF from the PF.\n\n"
315 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
316 " Set MAC antispoof for a VF from the PF.\n\n"
318 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
319 " Enable MACsec offload.\n\n"
321 "set macsec offload (port_id) off\n"
322 " Disable MACsec offload.\n\n"
324 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
325 " Configure MACsec secure connection (SC).\n\n"
327 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
328 " Configure MACsec secure association (SA).\n\n"
330 "set vf broadcast (port_id) (vf_id) (on|off)\n"
331 " Set VF broadcast for a VF from the PF.\n\n"
333 "vlan set stripq (on|off) (port_id,queue_id)\n"
334 " Set the VLAN strip for a queue on a port.\n\n"
336 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
337 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
339 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
340 " Set VLAN insert for a VF from the PF.\n\n"
342 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
343 " Set VLAN antispoof for a VF from the PF.\n\n"
345 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
346 " Set VLAN tag for a VF from the PF.\n\n"
348 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
349 " Set a VF's max bandwidth(Mbps).\n\n"
351 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
352 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
354 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
355 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
357 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
358 " Set some TCs' strict link priority mode on a physical port.\n\n"
360 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
361 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
363 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
364 " Set the VLAN strip or filter or qinq strip or extend\n\n"
366 "vlan set (inner|outer) tpid (value) (port_id)\n"
367 " Set the VLAN TPID for Packet Filtering on"
370 "rx_vlan add (vlan_id|all) (port_id)\n"
371 " Add a vlan_id, or all identifiers, to the set"
372 " of VLAN identifiers filtered by port_id.\n\n"
374 "rx_vlan rm (vlan_id|all) (port_id)\n"
375 " Remove a vlan_id, or all identifiers, from the set"
376 " of VLAN identifiers filtered by port_id.\n\n"
378 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
379 " Add a vlan_id, to the set of VLAN identifiers"
380 "filtered for VF(s) from port_id.\n\n"
382 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
383 " Remove a vlan_id, to the set of VLAN identifiers"
384 "filtered for VF(s) from port_id.\n\n"
386 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 " add a tunnel filter of a port.\n\n"
391 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
392 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
393 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
394 " remove a tunnel filter of a port.\n\n"
396 "rx_vxlan_port add (udp_port) (port_id)\n"
397 " Add an UDP port for VXLAN packet filter on a port\n\n"
399 "rx_vxlan_port rm (udp_port) (port_id)\n"
400 " Remove an UDP port for VXLAN packet filter on a port\n\n"
402 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
403 " Set hardware insertion of VLAN IDs (single or double VLAN "
404 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
406 "tx_vlan set pvid port_id vlan_id (on|off)\n"
407 " Set port based TX VLAN insertion.\n\n"
409 "tx_vlan reset (port_id)\n"
410 " Disable hardware insertion of a VLAN header in"
411 " packets sent on a port.\n\n"
413 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
414 " Select hardware or software calculation of the"
415 " checksum when transmitting a packet using the"
416 " csum forward engine.\n"
417 " ip|udp|tcp|sctp always concern the inner layer.\n"
418 " outer-ip concerns the outer IP layer in"
419 " outer-udp concerns the outer UDP layer in"
420 " case the packet is recognized as a tunnel packet by"
421 " the forward engine (vxlan, gre and ipip are supported)\n"
422 " Please check the NIC datasheet for HW limits.\n\n"
424 "csum parse-tunnel (on|off) (tx_port_id)\n"
425 " If disabled, treat tunnel packets as non-tunneled"
426 " packets (treat inner headers as payload). The port\n"
427 " argument is the port used for TX in csum forward"
430 "csum show (port_id)\n"
431 " Display tx checksum offload configuration\n\n"
433 "tso set (segsize) (portid)\n"
434 " Enable TCP Segmentation Offload in csum forward"
436 " Please check the NIC datasheet for HW limits.\n\n"
439 " Display the status of TCP Segmentation Offload.\n\n"
441 "set port (port_id) gro on|off\n"
442 " Enable or disable Generic Receive Offload in"
443 " csum forwarding engine.\n\n"
445 "show port (port_id) gro\n"
446 " Display GRO configuration.\n\n"
448 "set gro flush (cycles)\n"
449 " Set the cycle to flush GROed packets from"
450 " reassembly tables.\n\n"
452 "set port (port_id) gso (on|off)"
453 " Enable or disable Generic Segmentation Offload in"
454 " csum forwarding engine.\n\n"
456 "set gso segsz (length)\n"
457 " Set max packet length for output GSO segments,"
458 " including packet header and payload.\n\n"
460 "show port (port_id) gso\n"
461 " Show GSO configuration.\n\n"
464 " Set packet forwarding mode.\n\n"
466 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
467 " Add a MAC address on port_id.\n\n"
469 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
470 " Remove a MAC address from port_id.\n\n"
472 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
473 " Set the default MAC address for port_id.\n\n"
475 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
476 " Add a MAC address for a VF on the port.\n\n"
478 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
479 " Set the MAC address for a VF from the PF.\n\n"
481 "set eth-peer (port_id) (peer_addr)\n"
482 " set the peer address for certain port.\n\n"
484 "set port (port_id) uta (mac_address|all) (on|off)\n"
485 " Add/Remove a or all unicast hash filter(s)"
488 "set promisc (port_id|all) (on|off)\n"
489 " Set the promiscuous mode on port_id, or all.\n\n"
491 "set allmulti (port_id|all) (on|off)\n"
492 " Set the allmulti mode on port_id, or all.\n\n"
494 "set vf promisc (port_id) (vf_id) (on|off)\n"
495 " Set unicast promiscuous mode for a VF from the PF.\n\n"
497 "set vf allmulti (port_id) (vf_id) (on|off)\n"
498 " Set multicast promiscuous mode for a VF from the PF.\n\n"
500 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
501 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
502 " (on|off) autoneg (on|off) (port_id)\n"
503 "set flow_ctrl rx (on|off) (portid)\n"
504 "set flow_ctrl tx (on|off) (portid)\n"
505 "set flow_ctrl high_water (high_water) (portid)\n"
506 "set flow_ctrl low_water (low_water) (portid)\n"
507 "set flow_ctrl pause_time (pause_time) (portid)\n"
508 "set flow_ctrl send_xon (send_xon) (portid)\n"
509 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
510 "set flow_ctrl autoneg (on|off) (port_id)\n"
511 " Set the link flow control parameter on a port.\n\n"
513 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
514 " (low_water) (pause_time) (priority) (port_id)\n"
515 " Set the priority flow control parameter on a"
518 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
519 " Set statistics mapping (qmapping 0..15) for RX/TX"
521 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
522 " on port 0 to mapping 5.\n\n"
524 "set xstats-hide-zero on|off\n"
525 " Set the option to hide the zero values"
526 " for xstats display.\n"
528 "set port (port_id) vf (vf_id) rx|tx on|off\n"
529 " Enable/Disable a VF receive/tranmit from a port\n\n"
531 "set port (port_id) vf (vf_id) (mac_addr)"
532 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
533 " Add/Remove unicast or multicast MAC addr filter"
536 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
538 " AUPE:accepts untagged VLAN;"
539 "ROPE:accept unicast hash\n\n"
540 " BAM:accepts broadcast packets;"
541 "MPE:accepts all multicast packets\n\n"
542 " Enable/Disable a VF receive mode of a port\n\n"
544 "set port (port_id) queue (queue_id) rate (rate_num)\n"
545 " Set rate limit for a queue of a port\n\n"
547 "set port (port_id) vf (vf_id) rate (rate_num) "
548 "queue_mask (queue_mask_value)\n"
549 " Set rate limit for queues in VF of a port\n\n"
551 "set port (port_id) mirror-rule (rule_id)"
552 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
553 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
554 " Set pool or vlan type mirror rule on a port.\n"
555 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
556 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
559 "set port (port_id) mirror-rule (rule_id)"
560 " (uplink-mirror|downlink-mirror) dst-pool"
561 " (pool_id) (on|off)\n"
562 " Set uplink or downlink type mirror rule on a port.\n"
563 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
564 " 0 on' enable mirror income traffic to pool 0.\n\n"
566 "reset port (port_id) mirror-rule (rule_id)\n"
567 " Reset a mirror rule.\n\n"
569 "set flush_rx (on|off)\n"
570 " Flush (default) or don't flush RX streams before"
571 " forwarding. Mainly used with PCAP drivers.\n\n"
573 "set bypass mode (normal|bypass|isolate) (port_id)\n"
574 " Set the bypass mode for the lowest port on bypass enabled"
577 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
578 "mode (normal|bypass|isolate) (port_id)\n"
579 " Set the event required to initiate specified bypass mode for"
580 " the lowest port on a bypass enabled NIC where:\n"
581 " timeout = enable bypass after watchdog timeout.\n"
582 " os_on = enable bypass when OS/board is powered on.\n"
583 " os_off = enable bypass when OS/board is powered off.\n"
584 " power_on = enable bypass when power supply is turned on.\n"
585 " power_off = enable bypass when power supply is turned off."
588 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
589 " Set the bypass watchdog timeout to 'n' seconds"
590 " where 0 = instant.\n\n"
592 "show bypass config (port_id)\n"
593 " Show the bypass configuration for a bypass enabled NIC"
594 " using the lowest port on the NIC.\n\n"
596 #ifdef RTE_LIBRTE_PMD_BOND
597 "create bonded device (mode) (socket)\n"
598 " Create a new bonded device with specific bonding mode and socket.\n\n"
600 "add bonding slave (slave_id) (port_id)\n"
601 " Add a slave device to a bonded device.\n\n"
603 "remove bonding slave (slave_id) (port_id)\n"
604 " Remove a slave device from a bonded device.\n\n"
606 "set bonding mode (value) (port_id)\n"
607 " Set the bonding mode on a bonded device.\n\n"
609 "set bonding primary (slave_id) (port_id)\n"
610 " Set the primary slave for a bonded device.\n\n"
612 "show bonding config (port_id)\n"
613 " Show the bonding config for port_id.\n\n"
615 "set bonding mac_addr (port_id) (address)\n"
616 " Set the MAC address of a bonded device.\n\n"
618 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
619 " Set Aggregation mode for IEEE802.3AD (mode 4)"
621 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
622 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
624 "set bonding mon_period (port_id) (value)\n"
625 " Set the bonding link status monitoring polling period in ms.\n\n"
627 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
628 " Enable/disable dedicated queues for LACP control traffic.\n\n"
631 "set link-up port (port_id)\n"
632 " Set link up for a port.\n\n"
634 "set link-down port (port_id)\n"
635 " Set link down for a port.\n\n"
637 "E-tag set insertion on port-tag-id (value)"
638 " port (port_id) vf (vf_id)\n"
639 " Enable E-tag insertion for a VF on a port\n\n"
641 "E-tag set insertion off port (port_id) vf (vf_id)\n"
642 " Disable E-tag insertion for a VF on a port\n\n"
644 "E-tag set stripping (on|off) port (port_id)\n"
645 " Enable/disable E-tag stripping on a port\n\n"
647 "E-tag set forwarding (on|off) port (port_id)\n"
648 " Enable/disable E-tag based forwarding"
651 "E-tag set filter add e-tag-id (value) dst-pool"
652 " (pool_id) port (port_id)\n"
653 " Add an E-tag forwarding filter on a port\n\n"
655 "E-tag set filter del e-tag-id (value) port (port_id)\n"
656 " Delete an E-tag forwarding filter on a port\n\n"
658 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
659 " Load a profile package on a port\n\n"
661 "ddp del (port_id) (backup_profile_path)\n"
662 " Delete a profile package from a port\n\n"
664 "ptype mapping get (port_id) (valid_only)\n"
665 " Get ptype mapping on a port\n\n"
667 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
668 " Replace target with the pkt_type in ptype mapping\n\n"
670 "ptype mapping reset (port_id)\n"
671 " Reset ptype mapping on a port\n\n"
673 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
674 " Update a ptype mapping item on a port\n\n"
676 "set port (port_id) ptype_mask (ptype_mask)\n"
677 " set packet types classification for a specific port\n\n"
679 "set port (port_id) queue-region region_id (value) "
680 "queue_start_index (value) queue_num (value)\n"
681 " Set a queue region on a port\n\n"
683 "set port (port_id) queue-region region_id (value) "
685 " Set a flowtype region index on a port\n\n"
687 "set port (port_id) queue-region UP (value) region_id (value)\n"
688 " Set the mapping of User Priority to "
689 "queue region on a port\n\n"
691 "set port (port_id) queue-region flush (on|off)\n"
692 " flush all queue region related configuration\n\n"
694 "show port meter cap (port_id)\n"
695 " Show port meter capability information\n\n"
697 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
698 " meter profile add - srtcm rfc 2697\n\n"
700 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
701 " meter profile add - trtcm rfc 2698\n\n"
703 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
704 " meter profile add - trtcm rfc 4115\n\n"
706 "del port meter profile (port_id) (profile_id)\n"
707 " meter profile delete\n\n"
709 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
710 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
711 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
712 "(dscp_tbl_entry63)]\n"
715 "enable port meter (port_id) (mtr_id)\n"
718 "disable port meter (port_id) (mtr_id)\n"
721 "del port meter (port_id) (mtr_id)\n"
724 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 " meter update meter profile\n\n"
727 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 " update meter dscp table entries\n\n"
731 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 "(action0) [(action1) (action2)]\n"
733 " meter update policer action\n\n"
735 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 " meter update stats\n\n"
738 "show port (port_id) queue-region\n"
739 " show all queue region related configuration info\n\n"
741 , list_pkt_forwarding_modes()
745 if (show_all || !strcmp(res->section, "ports")) {
751 "----------------\n\n"
753 "port start (port_id|all)\n"
754 " Start all ports or port_id.\n\n"
756 "port stop (port_id|all)\n"
757 " Stop all ports or port_id.\n\n"
759 "port close (port_id|all)\n"
760 " Close all ports or port_id.\n\n"
762 "port reset (port_id|all)\n"
763 " Reset all ports or port_id.\n\n"
765 "port attach (ident)\n"
766 " Attach physical or virtual dev by pci address or virtual device name\n\n"
768 "port detach (port_id)\n"
769 " Detach physical or virtual dev by port_id\n\n"
771 "port config (port_id|all)"
772 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
773 " duplex (half|full|auto)\n"
774 " Set speed and duplex for all ports or port_id\n\n"
776 "port config (port_id|all) loopback (mode)\n"
777 " Set loopback mode for all ports or port_id\n\n"
779 "port config all (rxq|txq|rxd|txd) (value)\n"
780 " Set number for rxq/txq/rxd/txd.\n\n"
782 "port config all max-pkt-len (value)\n"
783 " Set the max packet length.\n\n"
785 "port config all max-lro-pkt-size (value)\n"
786 " Set the max LRO aggregated packet size.\n\n"
788 "port config all drop-en (on|off)\n"
789 " Enable or disable packet drop on all RX queues of all ports when no "
790 "receive buffers available.\n\n"
792 "port config all rss (all|default|ip|tcp|udp|sctp|"
793 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
794 " Set the RSS mode.\n\n"
796 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
797 " Set the RSS redirection table.\n\n"
799 "port config (port_id) dcb vt (on|off) (traffic_class)"
801 " Set the DCB mode.\n\n"
803 "port config all burst (value)\n"
804 " Set the number of packets per burst.\n\n"
806 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
808 " Set the ring prefetch/host/writeback threshold"
809 " for tx/rx queue.\n\n"
811 "port config all (txfreet|txrst|rxfreet) (value)\n"
812 " Set free threshold for rx/tx, or set"
813 " tx rs bit threshold.\n\n"
814 "port config mtu X value\n"
815 " Set the MTU of port X to a given value\n\n"
817 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
818 " Set a rx/tx queue's ring size configuration, the new"
819 " value will take effect after command that (re-)start the port"
820 " or command that setup the specific queue\n\n"
822 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
823 " Start/stop a rx/tx queue of port X. Only take effect"
824 " when port X is started\n\n"
826 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
827 " Switch on/off a deferred start of port X rx/tx queue. Only"
828 " take effect when port X is stopped.\n\n"
830 "port (port_id) (rxq|txq) (queue_id) setup\n"
831 " Setup a rx/tx queue of port X.\n\n"
833 "port config (port_id|all) l2-tunnel E-tag ether-type"
835 " Set the value of E-tag ether-type.\n\n"
837 "port config (port_id|all) l2-tunnel E-tag"
838 " (enable|disable)\n"
839 " Enable/disable the E-tag support.\n\n"
841 "port config (port_id) pctype mapping reset\n"
842 " Reset flow type to pctype mapping on a port\n\n"
844 "port config (port_id) pctype mapping update"
845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 " Update a flow type to pctype mapping item on a port\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset get|set|clear field\n"
851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset clear all"
855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
858 " Add/remove UDP tunnel port for tunneling offload\n\n"
860 "port config <port_id> rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|"
864 "scatter|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per port Rx offloading"
866 " on all Rx queues of a port\n\n"
868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|"
872 "scatter|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per queue Rx offloading"
874 " only on a specific Rx queue\n\n"
876 "port config (port_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 " Enable or disable a per port Tx offloading"
883 " on all Tx queues of a port\n\n"
885 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 " Enable or disable a per queue Tx offloading"
892 " only on a specific Tx queue\n\n"
894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 " Load an eBPF program as a callback"
896 " for particular RX/TX queue\n\n"
898 "bpf-unload rx|tx (port) (queue)\n"
899 " Unload previously loaded eBPF program"
900 " for particular RX/TX queue\n\n"
902 "port config (port_id) tx_metadata (value)\n"
903 " Set Tx metadata value per port. Testpmd will add this value"
904 " to any Tx packet sent from this port\n\n"
906 "port config (port_id) dynf (name) set|clear\n"
907 " Register a dynf and Set/clear this flag on Tx. "
908 "Testpmd will set this value to any Tx packet "
909 "sent from this port\n\n"
913 if (show_all || !strcmp(res->section, "registers")) {
921 "read reg (port_id) (address)\n"
922 " Display value of a port register.\n\n"
924 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
925 " Display a port register bit field.\n\n"
927 "read regbit (port_id) (address) (bit_x)\n"
928 " Display a single port register bit.\n\n"
930 "write reg (port_id) (address) (value)\n"
931 " Set value of a port register.\n\n"
933 "write regfield (port_id) (address) (bit_x) (bit_y)"
935 " Set bit field of a port register.\n\n"
937 "write regbit (port_id) (address) (bit_x) (value)\n"
938 " Set single bit value of a port register.\n\n"
941 if (show_all || !strcmp(res->section, "filters")) {
949 "ethertype_filter (port_id) (add|del)"
950 " (mac_addr|mac_ignr) (mac_address) ethertype"
951 " (ether_type) (drop|fwd) queue (queue_id)\n"
952 " Add/Del an ethertype filter.\n\n"
954 "2tuple_filter (port_id) (add|del)"
955 " dst_port (dst_port_value) protocol (protocol_value)"
956 " mask (mask_value) tcp_flags (tcp_flags_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a 2tuple filter.\n\n"
960 "5tuple_filter (port_id) (add|del)"
961 " dst_ip (dst_address) src_ip (src_address)"
962 " dst_port (dst_port_value) src_port (src_port_value)"
963 " protocol (protocol_value)"
964 " mask (mask_value) tcp_flags (tcp_flags_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a 5tuple filter.\n\n"
968 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
969 " Add/Del syn filter.\n\n"
971 "flex_filter (port_id) (add|del) len (len_value)"
972 " bytes (bytes_value) mask (mask_value)"
973 " priority (prio_value) queue (queue_id)\n"
974 " Add/Del a flex filter.\n\n"
976 "flow_director_filter (port_id) mode IP (add|del|update)"
977 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
978 " src (src_ip_address) dst (dst_ip_address)"
979 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
980 " vlan (vlan_value) flexbytes (flexbytes_value)"
981 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 " fd_id (fd_id_value)\n"
983 " Add/Del an IP type flow director filter.\n\n"
985 "flow_director_filter (port_id) mode IP (add|del|update)"
986 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
987 " src (src_ip_address) (src_port)"
988 " dst (dst_ip_address) (dst_port)"
989 " tos (tos_value) ttl (ttl_value)"
990 " vlan (vlan_value) flexbytes (flexbytes_value)"
991 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 " fd_id (fd_id_value)\n"
993 " Add/Del an UDP/TCP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow (ipv4-sctp|ipv6-sctp)"
997 " src (src_ip_address) (src_port)"
998 " dst (dst_ip_address) (dst_port)"
999 " tag (verification_tag) "
1000 " tos (tos_value) ttl (ttl_value)"
1001 " vlan (vlan_value)"
1002 " flexbytes (flexbytes_value) (drop|fwd)"
1003 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1004 " Add/Del a SCTP type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow l2_payload ether (ethertype)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a l2 payload type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1013 " mac (mac_address) vlan (vlan_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a MAC-VLAN flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1019 " mac (mac_address) vlan (vlan_value)"
1020 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1021 " flexbytes (flexbytes_value) (drop|fwd)"
1022 " queue (queue_id) fd_id (fd_id_value)\n"
1023 " Add/Del a Tunnel flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode raw (add|del|update)"
1026 " flow (flow_id) (drop|fwd) queue (queue_id)"
1027 " fd_id (fd_id_value) packet (packet file name)\n"
1028 " Add/Del a raw type flow director filter.\n\n"
1030 "flush_flow_director (port_id)\n"
1031 " Flush all flow director entries of a device.\n\n"
1033 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1034 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1035 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1036 " Set flow director IP mask.\n\n"
1038 "flow_director_mask (port_id) mode MAC-VLAN"
1039 " vlan (vlan_value)\n"
1040 " Set flow director MAC-VLAN mask.\n\n"
1042 "flow_director_mask (port_id) mode Tunnel"
1043 " vlan (vlan_value) mac (mac_value)"
1044 " tunnel-type (tunnel_type_value)"
1045 " tunnel-id (tunnel_id_value)\n"
1046 " Set flow director Tunnel mask.\n\n"
1048 "flow_director_flex_mask (port_id)"
1049 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1050 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1052 " Configure mask of flex payload.\n\n"
1054 "flow_director_flex_payload (port_id)"
1055 " (raw|l2|l3|l4) (config)\n"
1056 " Configure flex payload selection.\n\n"
1058 "get_sym_hash_ena_per_port (port_id)\n"
1059 " get symmetric hash enable configuration per port.\n\n"
1061 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1062 " set symmetric hash enable configuration per port"
1063 " to enable or disable.\n\n"
1065 "get_hash_global_config (port_id)\n"
1066 " Get the global configurations of hash filters.\n\n"
1068 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1069 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1070 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1071 " (enable|disable)\n"
1072 " Set the global configurations of hash filters.\n\n"
1074 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1075 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1078 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1079 "ipv6-next-header|udp-src-port|udp-dst-port|"
1080 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1081 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1082 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1083 "fld-8th|none) (select|add)\n"
1084 " Set the input set for hash.\n\n"
1086 "set_fdir_input_set (port_id) "
1087 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1088 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1089 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1090 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1091 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1092 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1093 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1095 " Set the input set for FDir.\n\n"
1097 "flow validate {port_id}"
1098 " [group {group_id}] [priority {level}]"
1099 " [ingress] [egress]"
1100 " pattern {item} [/ {item} [...]] / end"
1101 " actions {action} [/ {action} [...]] / end\n"
1102 " Check whether a flow rule can be created.\n\n"
1104 "flow create {port_id}"
1105 " [group {group_id}] [priority {level}]"
1106 " [ingress] [egress]"
1107 " pattern {item} [/ {item} [...]] / end"
1108 " actions {action} [/ {action} [...]] / end\n"
1109 " Create a flow rule.\n\n"
1111 "flow destroy {port_id} rule {rule_id} [...]\n"
1112 " Destroy specific flow rules.\n\n"
1114 "flow flush {port_id}\n"
1115 " Destroy all flow rules.\n\n"
1117 "flow query {port_id} {rule_id} {action}\n"
1118 " Query an existing flow rule.\n\n"
1120 "flow list {port_id} [group {group_id}] [...]\n"
1121 " List existing flow rules sorted by priority,"
1122 " filtered by group identifiers.\n\n"
1124 "flow isolate {port_id} {boolean}\n"
1125 " Restrict ingress traffic to the defined"
1128 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1129 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1130 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1131 " Configure the VXLAN encapsulation for flows.\n\n"
1133 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1134 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1135 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1136 " eth-dst (eth-dst)\n"
1137 " Configure the VXLAN encapsulation for flows.\n\n"
1139 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1140 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1141 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1142 " eth-dst (eth-dst)\n"
1143 " Configure the VXLAN encapsulation for flows.\n\n"
1145 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1146 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1148 " Configure the NVGRE encapsulation for flows.\n\n"
1150 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1151 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1152 " eth-src (eth-src) eth-dst (eth-dst)\n"
1153 " Configure the NVGRE encapsulation for flows.\n\n"
1155 "set raw_encap {flow items}\n"
1156 " Configure the encapsulation with raw data.\n\n"
1158 "set raw_decap {flow items}\n"
1159 " Configure the decapsulation with raw data.\n\n"
1164 if (show_all || !strcmp(res->section, "traffic_management")) {
1168 "Traffic Management:\n"
1170 "show port tm cap (port_id)\n"
1171 " Display the port TM capability.\n\n"
1173 "show port tm level cap (port_id) (level_id)\n"
1174 " Display the port TM hierarchical level capability.\n\n"
1176 "show port tm node cap (port_id) (node_id)\n"
1177 " Display the port TM node capability.\n\n"
1179 "show port tm node type (port_id) (node_id)\n"
1180 " Display the port TM node type.\n\n"
1182 "show port tm node stats (port_id) (node_id) (clear)\n"
1183 " Display the port TM node stats.\n\n"
1185 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1186 "set port tm hierarchy default (port_id)\n"
1187 " Set default traffic Management hierarchy on a port\n\n"
1190 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1191 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1192 " (packet_length_adjust)\n"
1193 " Add port tm node private shaper profile.\n\n"
1195 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1196 " Delete port tm node private shaper profile.\n\n"
1198 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1199 " (shaper_profile_id)\n"
1200 " Add/update port tm node shared shaper.\n\n"
1202 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1203 " Delete port tm node shared shaper.\n\n"
1205 "set port tm node shaper profile (port_id) (node_id)"
1206 " (shaper_profile_id)\n"
1207 " Set port tm node shaper profile.\n\n"
1209 "add port tm node wred profile (port_id) (wred_profile_id)"
1210 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1211 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1212 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1213 " Add port tm node wred profile.\n\n"
1215 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1216 " Delete port tm node wred profile.\n\n"
1218 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1219 " (priority) (weight) (level_id) (shaper_profile_id)"
1220 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1221 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1222 " Add port tm nonleaf node.\n\n"
1224 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1225 " (priority) (weight) (level_id) (shaper_profile_id)"
1226 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1227 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1228 " Add port tm leaf node.\n\n"
1230 "del port tm node (port_id) (node_id)\n"
1231 " Delete port tm node.\n\n"
1233 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1234 " (priority) (weight)\n"
1235 " Set port tm node parent.\n\n"
1237 "suspend port tm node (port_id) (node_id)"
1238 " Suspend tm node.\n\n"
1240 "resume port tm node (port_id) (node_id)"
1241 " Resume tm node.\n\n"
1243 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1244 " Commit tm hierarchy.\n\n"
1246 "set port tm mark ip_ecn (port) (green) (yellow)"
1248 " Enables/Disables the traffic management marking"
1249 " for IP ECN (Explicit Congestion Notification)"
1250 " packets on a given port\n\n"
1252 "set port tm mark ip_dscp (port) (green) (yellow)"
1254 " Enables/Disables the traffic management marking"
1255 " on the port for IP dscp packets\n\n"
1257 "set port tm mark vlan_dei (port) (green) (yellow)"
1259 " Enables/Disables the traffic management marking"
1260 " on the port for VLAN packets with DEI enabled\n\n"
1264 if (show_all || !strcmp(res->section, "devices")) {
1268 "Device Operations:\n"
1270 "device detach (identifier)\n"
1271 " Detach device by identifier.\n\n"
1277 cmdline_parse_token_string_t cmd_help_long_help =
1278 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1280 cmdline_parse_token_string_t cmd_help_long_section =
1281 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1282 "all#control#display#config#"
1283 "ports#registers#filters#traffic_management#devices");
1285 cmdline_parse_inst_t cmd_help_long = {
1286 .f = cmd_help_long_parsed,
1288 .help_str = "help all|control|display|config|ports|register|"
1289 "filters|traffic_management|devices: "
1292 (void *)&cmd_help_long_help,
1293 (void *)&cmd_help_long_section,
1299 /* *** start/stop/close all ports *** */
1300 struct cmd_operate_port_result {
1301 cmdline_fixed_string_t keyword;
1302 cmdline_fixed_string_t name;
1303 cmdline_fixed_string_t value;
1306 static void cmd_operate_port_parsed(void *parsed_result,
1307 __attribute__((unused)) struct cmdline *cl,
1308 __attribute__((unused)) void *data)
1310 struct cmd_operate_port_result *res = parsed_result;
1312 if (!strcmp(res->name, "start"))
1313 start_port(RTE_PORT_ALL);
1314 else if (!strcmp(res->name, "stop"))
1315 stop_port(RTE_PORT_ALL);
1316 else if (!strcmp(res->name, "close"))
1317 close_port(RTE_PORT_ALL);
1318 else if (!strcmp(res->name, "reset"))
1319 reset_port(RTE_PORT_ALL);
1321 printf("Unknown parameter\n");
1324 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1325 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1327 cmdline_parse_token_string_t cmd_operate_port_all_port =
1328 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1329 "start#stop#close#reset");
1330 cmdline_parse_token_string_t cmd_operate_port_all_all =
1331 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1333 cmdline_parse_inst_t cmd_operate_port = {
1334 .f = cmd_operate_port_parsed,
1336 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1338 (void *)&cmd_operate_port_all_cmd,
1339 (void *)&cmd_operate_port_all_port,
1340 (void *)&cmd_operate_port_all_all,
1345 /* *** start/stop/close specific port *** */
1346 struct cmd_operate_specific_port_result {
1347 cmdline_fixed_string_t keyword;
1348 cmdline_fixed_string_t name;
1352 static void cmd_operate_specific_port_parsed(void *parsed_result,
1353 __attribute__((unused)) struct cmdline *cl,
1354 __attribute__((unused)) void *data)
1356 struct cmd_operate_specific_port_result *res = parsed_result;
1358 if (!strcmp(res->name, "start"))
1359 start_port(res->value);
1360 else if (!strcmp(res->name, "stop"))
1361 stop_port(res->value);
1362 else if (!strcmp(res->name, "close"))
1363 close_port(res->value);
1364 else if (!strcmp(res->name, "reset"))
1365 reset_port(res->value);
1367 printf("Unknown parameter\n");
1370 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1373 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1374 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1375 name, "start#stop#close#reset");
1376 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1377 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1380 cmdline_parse_inst_t cmd_operate_specific_port = {
1381 .f = cmd_operate_specific_port_parsed,
1383 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1385 (void *)&cmd_operate_specific_port_cmd,
1386 (void *)&cmd_operate_specific_port_port,
1387 (void *)&cmd_operate_specific_port_id,
1392 /* *** enable port setup (after attach) via iterator or event *** */
1393 struct cmd_set_port_setup_on_result {
1394 cmdline_fixed_string_t set;
1395 cmdline_fixed_string_t port;
1396 cmdline_fixed_string_t setup;
1397 cmdline_fixed_string_t on;
1398 cmdline_fixed_string_t mode;
1401 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1402 __attribute__((unused)) struct cmdline *cl,
1403 __attribute__((unused)) void *data)
1405 struct cmd_set_port_setup_on_result *res = parsed_result;
1407 if (strcmp(res->mode, "event") == 0)
1408 setup_on_probe_event = true;
1409 else if (strcmp(res->mode, "iterator") == 0)
1410 setup_on_probe_event = false;
1412 printf("Unknown mode\n");
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1419 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1422 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1425 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1428 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1429 mode, "iterator#event");
1431 cmdline_parse_inst_t cmd_set_port_setup_on = {
1432 .f = cmd_set_port_setup_on_parsed,
1434 .help_str = "set port setup on iterator|event",
1436 (void *)&cmd_set_port_setup_on_set,
1437 (void *)&cmd_set_port_setup_on_port,
1438 (void *)&cmd_set_port_setup_on_setup,
1439 (void *)&cmd_set_port_setup_on_on,
1440 (void *)&cmd_set_port_setup_on_mode,
1445 /* *** attach a specified port *** */
1446 struct cmd_operate_attach_port_result {
1447 cmdline_fixed_string_t port;
1448 cmdline_fixed_string_t keyword;
1449 cmdline_fixed_string_t identifier;
1452 static void cmd_operate_attach_port_parsed(void *parsed_result,
1453 __attribute__((unused)) struct cmdline *cl,
1454 __attribute__((unused)) void *data)
1456 struct cmd_operate_attach_port_result *res = parsed_result;
1458 if (!strcmp(res->keyword, "attach"))
1459 attach_port(res->identifier);
1461 printf("Unknown parameter\n");
1464 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1465 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1467 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1468 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1470 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1471 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1474 cmdline_parse_inst_t cmd_operate_attach_port = {
1475 .f = cmd_operate_attach_port_parsed,
1477 .help_str = "port attach <identifier>: "
1478 "(identifier: pci address or virtual dev name)",
1480 (void *)&cmd_operate_attach_port_port,
1481 (void *)&cmd_operate_attach_port_keyword,
1482 (void *)&cmd_operate_attach_port_identifier,
1487 /* *** detach a specified port *** */
1488 struct cmd_operate_detach_port_result {
1489 cmdline_fixed_string_t port;
1490 cmdline_fixed_string_t keyword;
1494 static void cmd_operate_detach_port_parsed(void *parsed_result,
1495 __attribute__((unused)) struct cmdline *cl,
1496 __attribute__((unused)) void *data)
1498 struct cmd_operate_detach_port_result *res = parsed_result;
1500 if (!strcmp(res->keyword, "detach"))
1501 detach_port_device(res->port_id);
1503 printf("Unknown parameter\n");
1506 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1507 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1509 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1510 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1512 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1513 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1516 cmdline_parse_inst_t cmd_operate_detach_port = {
1517 .f = cmd_operate_detach_port_parsed,
1519 .help_str = "port detach <port_id>",
1521 (void *)&cmd_operate_detach_port_port,
1522 (void *)&cmd_operate_detach_port_keyword,
1523 (void *)&cmd_operate_detach_port_port_id,
1528 /* *** detach device by identifier *** */
1529 struct cmd_operate_detach_device_result {
1530 cmdline_fixed_string_t device;
1531 cmdline_fixed_string_t keyword;
1532 cmdline_fixed_string_t identifier;
1535 static void cmd_operate_detach_device_parsed(void *parsed_result,
1536 __attribute__((unused)) struct cmdline *cl,
1537 __attribute__((unused)) void *data)
1539 struct cmd_operate_detach_device_result *res = parsed_result;
1541 if (!strcmp(res->keyword, "detach"))
1542 detach_device(res->identifier);
1544 printf("Unknown parameter\n");
1547 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1548 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1550 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1551 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1553 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1554 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1557 cmdline_parse_inst_t cmd_operate_detach_device = {
1558 .f = cmd_operate_detach_device_parsed,
1560 .help_str = "device detach <identifier>:"
1561 "(identifier: pci address or virtual dev name)",
1563 (void *)&cmd_operate_detach_device_device,
1564 (void *)&cmd_operate_detach_device_keyword,
1565 (void *)&cmd_operate_detach_device_identifier,
1569 /* *** configure speed for all ports *** */
1570 struct cmd_config_speed_all {
1571 cmdline_fixed_string_t port;
1572 cmdline_fixed_string_t keyword;
1573 cmdline_fixed_string_t all;
1574 cmdline_fixed_string_t item1;
1575 cmdline_fixed_string_t item2;
1576 cmdline_fixed_string_t value1;
1577 cmdline_fixed_string_t value2;
1581 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1586 if (!strcmp(duplexstr, "half")) {
1587 duplex = ETH_LINK_HALF_DUPLEX;
1588 } else if (!strcmp(duplexstr, "full")) {
1589 duplex = ETH_LINK_FULL_DUPLEX;
1590 } else if (!strcmp(duplexstr, "auto")) {
1591 duplex = ETH_LINK_FULL_DUPLEX;
1593 printf("Unknown duplex parameter\n");
1597 if (!strcmp(speedstr, "10")) {
1598 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1599 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1600 } else if (!strcmp(speedstr, "100")) {
1601 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1602 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1604 if (duplex != ETH_LINK_FULL_DUPLEX) {
1605 printf("Invalid speed/duplex parameters\n");
1608 if (!strcmp(speedstr, "1000")) {
1609 *speed = ETH_LINK_SPEED_1G;
1610 } else if (!strcmp(speedstr, "10000")) {
1611 *speed = ETH_LINK_SPEED_10G;
1612 } else if (!strcmp(speedstr, "25000")) {
1613 *speed = ETH_LINK_SPEED_25G;
1614 } else if (!strcmp(speedstr, "40000")) {
1615 *speed = ETH_LINK_SPEED_40G;
1616 } else if (!strcmp(speedstr, "50000")) {
1617 *speed = ETH_LINK_SPEED_50G;
1618 } else if (!strcmp(speedstr, "100000")) {
1619 *speed = ETH_LINK_SPEED_100G;
1620 } else if (!strcmp(speedstr, "auto")) {
1621 *speed = ETH_LINK_SPEED_AUTONEG;
1623 printf("Unknown speed parameter\n");
1632 cmd_config_speed_all_parsed(void *parsed_result,
1633 __attribute__((unused)) struct cmdline *cl,
1634 __attribute__((unused)) void *data)
1636 struct cmd_config_speed_all *res = parsed_result;
1637 uint32_t link_speed;
1640 if (!all_ports_stopped()) {
1641 printf("Please stop all ports first\n");
1645 if (parse_and_check_speed_duplex(res->value1, res->value2,
1649 RTE_ETH_FOREACH_DEV(pid) {
1650 ports[pid].dev_conf.link_speeds = link_speed;
1653 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1656 cmdline_parse_token_string_t cmd_config_speed_all_port =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1658 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1661 cmdline_parse_token_string_t cmd_config_speed_all_all =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1663 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1665 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1667 "10#100#1000#10000#25000#40000#50000#100000#auto");
1668 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1670 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1674 cmdline_parse_inst_t cmd_config_speed_all = {
1675 .f = cmd_config_speed_all_parsed,
1677 .help_str = "port config all speed "
1678 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1681 (void *)&cmd_config_speed_all_port,
1682 (void *)&cmd_config_speed_all_keyword,
1683 (void *)&cmd_config_speed_all_all,
1684 (void *)&cmd_config_speed_all_item1,
1685 (void *)&cmd_config_speed_all_value1,
1686 (void *)&cmd_config_speed_all_item2,
1687 (void *)&cmd_config_speed_all_value2,
1692 /* *** configure speed for specific port *** */
1693 struct cmd_config_speed_specific {
1694 cmdline_fixed_string_t port;
1695 cmdline_fixed_string_t keyword;
1697 cmdline_fixed_string_t item1;
1698 cmdline_fixed_string_t item2;
1699 cmdline_fixed_string_t value1;
1700 cmdline_fixed_string_t value2;
1704 cmd_config_speed_specific_parsed(void *parsed_result,
1705 __attribute__((unused)) struct cmdline *cl,
1706 __attribute__((unused)) void *data)
1708 struct cmd_config_speed_specific *res = parsed_result;
1709 uint32_t link_speed;
1711 if (!all_ports_stopped()) {
1712 printf("Please stop all ports first\n");
1716 if (port_id_is_invalid(res->id, ENABLED_WARN))
1719 if (parse_and_check_speed_duplex(res->value1, res->value2,
1723 ports[res->id].dev_conf.link_speeds = link_speed;
1725 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1729 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1730 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1732 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1735 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1736 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1737 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1740 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1742 "10#100#1000#10000#25000#40000#50000#100000#auto");
1743 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1744 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1746 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1747 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1750 cmdline_parse_inst_t cmd_config_speed_specific = {
1751 .f = cmd_config_speed_specific_parsed,
1753 .help_str = "port config <port_id> speed "
1754 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1757 (void *)&cmd_config_speed_specific_port,
1758 (void *)&cmd_config_speed_specific_keyword,
1759 (void *)&cmd_config_speed_specific_id,
1760 (void *)&cmd_config_speed_specific_item1,
1761 (void *)&cmd_config_speed_specific_value1,
1762 (void *)&cmd_config_speed_specific_item2,
1763 (void *)&cmd_config_speed_specific_value2,
1768 /* *** configure loopback for all ports *** */
1769 struct cmd_config_loopback_all {
1770 cmdline_fixed_string_t port;
1771 cmdline_fixed_string_t keyword;
1772 cmdline_fixed_string_t all;
1773 cmdline_fixed_string_t item;
1778 cmd_config_loopback_all_parsed(void *parsed_result,
1779 __attribute__((unused)) struct cmdline *cl,
1780 __attribute__((unused)) void *data)
1782 struct cmd_config_loopback_all *res = parsed_result;
1785 if (!all_ports_stopped()) {
1786 printf("Please stop all ports first\n");
1790 RTE_ETH_FOREACH_DEV(pid) {
1791 ports[pid].dev_conf.lpbk_mode = res->mode;
1794 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1797 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1799 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1802 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1804 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1807 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1808 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1810 cmdline_parse_inst_t cmd_config_loopback_all = {
1811 .f = cmd_config_loopback_all_parsed,
1813 .help_str = "port config all loopback <mode>",
1815 (void *)&cmd_config_loopback_all_port,
1816 (void *)&cmd_config_loopback_all_keyword,
1817 (void *)&cmd_config_loopback_all_all,
1818 (void *)&cmd_config_loopback_all_item,
1819 (void *)&cmd_config_loopback_all_mode,
1824 /* *** configure loopback for specific port *** */
1825 struct cmd_config_loopback_specific {
1826 cmdline_fixed_string_t port;
1827 cmdline_fixed_string_t keyword;
1829 cmdline_fixed_string_t item;
1834 cmd_config_loopback_specific_parsed(void *parsed_result,
1835 __attribute__((unused)) struct cmdline *cl,
1836 __attribute__((unused)) void *data)
1838 struct cmd_config_loopback_specific *res = parsed_result;
1840 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1843 if (!port_is_stopped(res->port_id)) {
1844 printf("Please stop port %u first\n", res->port_id);
1848 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1850 cmd_reconfig_device_queue(res->port_id, 1, 1);
1854 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1857 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1860 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1861 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1863 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1866 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1867 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1870 cmdline_parse_inst_t cmd_config_loopback_specific = {
1871 .f = cmd_config_loopback_specific_parsed,
1873 .help_str = "port config <port_id> loopback <mode>",
1875 (void *)&cmd_config_loopback_specific_port,
1876 (void *)&cmd_config_loopback_specific_keyword,
1877 (void *)&cmd_config_loopback_specific_id,
1878 (void *)&cmd_config_loopback_specific_item,
1879 (void *)&cmd_config_loopback_specific_mode,
1884 /* *** configure txq/rxq, txd/rxd *** */
1885 struct cmd_config_rx_tx {
1886 cmdline_fixed_string_t port;
1887 cmdline_fixed_string_t keyword;
1888 cmdline_fixed_string_t all;
1889 cmdline_fixed_string_t name;
1894 cmd_config_rx_tx_parsed(void *parsed_result,
1895 __attribute__((unused)) struct cmdline *cl,
1896 __attribute__((unused)) void *data)
1898 struct cmd_config_rx_tx *res = parsed_result;
1900 if (!all_ports_stopped()) {
1901 printf("Please stop all ports first\n");
1904 if (!strcmp(res->name, "rxq")) {
1905 if (!res->value && !nb_txq) {
1906 printf("Warning: Either rx or tx queues should be non zero\n");
1909 if (check_nb_rxq(res->value) != 0)
1911 nb_rxq = res->value;
1913 else if (!strcmp(res->name, "txq")) {
1914 if (!res->value && !nb_rxq) {
1915 printf("Warning: Either rx or tx queues should be non zero\n");
1918 if (check_nb_txq(res->value) != 0)
1920 nb_txq = res->value;
1922 else if (!strcmp(res->name, "rxd")) {
1923 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1924 printf("rxd %d invalid - must be > 0 && <= %d\n",
1925 res->value, RTE_TEST_RX_DESC_MAX);
1928 nb_rxd = res->value;
1929 } else if (!strcmp(res->name, "txd")) {
1930 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1931 printf("txd %d invalid - must be > 0 && <= %d\n",
1932 res->value, RTE_TEST_TX_DESC_MAX);
1935 nb_txd = res->value;
1937 printf("Unknown parameter\n");
1945 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1948 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1950 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1952 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1954 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1957 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1958 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1960 cmdline_parse_inst_t cmd_config_rx_tx = {
1961 .f = cmd_config_rx_tx_parsed,
1963 .help_str = "port config all rxq|txq|rxd|txd <value>",
1965 (void *)&cmd_config_rx_tx_port,
1966 (void *)&cmd_config_rx_tx_keyword,
1967 (void *)&cmd_config_rx_tx_all,
1968 (void *)&cmd_config_rx_tx_name,
1969 (void *)&cmd_config_rx_tx_value,
1974 /* *** config max packet length *** */
1975 struct cmd_config_max_pkt_len_result {
1976 cmdline_fixed_string_t port;
1977 cmdline_fixed_string_t keyword;
1978 cmdline_fixed_string_t all;
1979 cmdline_fixed_string_t name;
1984 cmd_config_max_pkt_len_parsed(void *parsed_result,
1985 __attribute__((unused)) struct cmdline *cl,
1986 __attribute__((unused)) void *data)
1988 struct cmd_config_max_pkt_len_result *res = parsed_result;
1991 if (!all_ports_stopped()) {
1992 printf("Please stop all ports first\n");
1996 RTE_ETH_FOREACH_DEV(pid) {
1997 struct rte_port *port = &ports[pid];
1998 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2000 if (!strcmp(res->name, "max-pkt-len")) {
2001 if (res->value < RTE_ETHER_MIN_LEN) {
2002 printf("max-pkt-len can not be less than %d\n",
2006 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2009 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2010 if (res->value > RTE_ETHER_MAX_LEN)
2011 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2013 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2014 port->dev_conf.rxmode.offloads = rx_offloads;
2016 printf("Unknown parameter\n");
2023 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2026 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2029 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2032 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2035 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2038 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2039 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2042 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2043 .f = cmd_config_max_pkt_len_parsed,
2045 .help_str = "port config all max-pkt-len <value>",
2047 (void *)&cmd_config_max_pkt_len_port,
2048 (void *)&cmd_config_max_pkt_len_keyword,
2049 (void *)&cmd_config_max_pkt_len_all,
2050 (void *)&cmd_config_max_pkt_len_name,
2051 (void *)&cmd_config_max_pkt_len_value,
2056 /* *** config max LRO aggregated packet size *** */
2057 struct cmd_config_max_lro_pkt_size_result {
2058 cmdline_fixed_string_t port;
2059 cmdline_fixed_string_t keyword;
2060 cmdline_fixed_string_t all;
2061 cmdline_fixed_string_t name;
2066 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2067 __attribute__((unused)) struct cmdline *cl,
2068 __attribute__((unused)) void *data)
2070 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2073 if (!all_ports_stopped()) {
2074 printf("Please stop all ports first\n");
2078 RTE_ETH_FOREACH_DEV(pid) {
2079 struct rte_port *port = &ports[pid];
2081 if (!strcmp(res->name, "max-lro-pkt-size")) {
2083 port->dev_conf.rxmode.max_lro_pkt_size)
2086 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2088 printf("Unknown parameter\n");
2095 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2098 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2099 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2101 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2102 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2104 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2107 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2108 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2109 name, "max-lro-pkt-size");
2110 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2111 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2114 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2115 .f = cmd_config_max_lro_pkt_size_parsed,
2117 .help_str = "port config all max-lro-pkt-size <value>",
2119 (void *)&cmd_config_max_lro_pkt_size_port,
2120 (void *)&cmd_config_max_lro_pkt_size_keyword,
2121 (void *)&cmd_config_max_lro_pkt_size_all,
2122 (void *)&cmd_config_max_lro_pkt_size_name,
2123 (void *)&cmd_config_max_lro_pkt_size_value,
2128 /* *** configure port MTU *** */
2129 struct cmd_config_mtu_result {
2130 cmdline_fixed_string_t port;
2131 cmdline_fixed_string_t keyword;
2132 cmdline_fixed_string_t mtu;
2138 cmd_config_mtu_parsed(void *parsed_result,
2139 __attribute__((unused)) struct cmdline *cl,
2140 __attribute__((unused)) void *data)
2142 struct cmd_config_mtu_result *res = parsed_result;
2144 if (res->value < RTE_ETHER_MIN_LEN) {
2145 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2148 port_mtu_set(res->port_id, res->value);
2151 cmdline_parse_token_string_t cmd_config_mtu_port =
2152 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2154 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2157 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2158 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2160 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2161 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2162 cmdline_parse_token_num_t cmd_config_mtu_value =
2163 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2165 cmdline_parse_inst_t cmd_config_mtu = {
2166 .f = cmd_config_mtu_parsed,
2168 .help_str = "port config mtu <port_id> <value>",
2170 (void *)&cmd_config_mtu_port,
2171 (void *)&cmd_config_mtu_keyword,
2172 (void *)&cmd_config_mtu_mtu,
2173 (void *)&cmd_config_mtu_port_id,
2174 (void *)&cmd_config_mtu_value,
2179 /* *** configure rx mode *** */
2180 struct cmd_config_rx_mode_flag {
2181 cmdline_fixed_string_t port;
2182 cmdline_fixed_string_t keyword;
2183 cmdline_fixed_string_t all;
2184 cmdline_fixed_string_t name;
2185 cmdline_fixed_string_t value;
2189 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2190 __attribute__((unused)) struct cmdline *cl,
2191 __attribute__((unused)) void *data)
2193 struct cmd_config_rx_mode_flag *res = parsed_result;
2195 if (!all_ports_stopped()) {
2196 printf("Please stop all ports first\n");
2200 if (!strcmp(res->name, "drop-en")) {
2201 if (!strcmp(res->value, "on"))
2203 else if (!strcmp(res->value, "off"))
2206 printf("Unknown parameter\n");
2210 printf("Unknown parameter\n");
2216 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2219 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2220 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2221 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2222 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2224 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2227 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2229 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2230 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2233 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2234 .f = cmd_config_rx_mode_flag_parsed,
2236 .help_str = "port config all drop-en on|off",
2238 (void *)&cmd_config_rx_mode_flag_port,
2239 (void *)&cmd_config_rx_mode_flag_keyword,
2240 (void *)&cmd_config_rx_mode_flag_all,
2241 (void *)&cmd_config_rx_mode_flag_name,
2242 (void *)&cmd_config_rx_mode_flag_value,
2247 /* *** configure rss *** */
2248 struct cmd_config_rss {
2249 cmdline_fixed_string_t port;
2250 cmdline_fixed_string_t keyword;
2251 cmdline_fixed_string_t all;
2252 cmdline_fixed_string_t name;
2253 cmdline_fixed_string_t value;
2257 cmd_config_rss_parsed(void *parsed_result,
2258 __attribute__((unused)) struct cmdline *cl,
2259 __attribute__((unused)) void *data)
2261 struct cmd_config_rss *res = parsed_result;
2262 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2263 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2264 int use_default = 0;
2265 int all_updated = 1;
2270 if (!strcmp(res->value, "all"))
2271 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2272 ETH_RSS_UDP | ETH_RSS_SCTP |
2274 else if (!strcmp(res->value, "ip"))
2275 rss_conf.rss_hf = ETH_RSS_IP;
2276 else if (!strcmp(res->value, "udp"))
2277 rss_conf.rss_hf = ETH_RSS_UDP;
2278 else if (!strcmp(res->value, "tcp"))
2279 rss_conf.rss_hf = ETH_RSS_TCP;
2280 else if (!strcmp(res->value, "sctp"))
2281 rss_conf.rss_hf = ETH_RSS_SCTP;
2282 else if (!strcmp(res->value, "ether"))
2283 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2284 else if (!strcmp(res->value, "port"))
2285 rss_conf.rss_hf = ETH_RSS_PORT;
2286 else if (!strcmp(res->value, "vxlan"))
2287 rss_conf.rss_hf = ETH_RSS_VXLAN;
2288 else if (!strcmp(res->value, "geneve"))
2289 rss_conf.rss_hf = ETH_RSS_GENEVE;
2290 else if (!strcmp(res->value, "nvgre"))
2291 rss_conf.rss_hf = ETH_RSS_NVGRE;
2292 else if (!strcmp(res->value, "l3-src-only"))
2293 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2294 else if (!strcmp(res->value, "l3-dst-only"))
2295 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2296 else if (!strcmp(res->value, "l4-src-only"))
2297 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2298 else if (!strcmp(res->value, "l4-dst-only"))
2299 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2300 else if (!strcmp(res->value, "none"))
2301 rss_conf.rss_hf = 0;
2302 else if (!strcmp(res->value, "default"))
2304 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2305 atoi(res->value) < 64)
2306 rss_conf.rss_hf = 1ULL << atoi(res->value);
2308 printf("Unknown parameter\n");
2311 rss_conf.rss_key = NULL;
2312 /* Update global configuration for RSS types. */
2313 RTE_ETH_FOREACH_DEV(i) {
2314 struct rte_eth_rss_conf local_rss_conf;
2316 ret = eth_dev_info_get_print_err(i, &dev_info);
2321 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2323 local_rss_conf = rss_conf;
2324 local_rss_conf.rss_hf = rss_conf.rss_hf &
2325 dev_info.flow_type_rss_offloads;
2326 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2327 printf("Port %u modified RSS hash function based on hardware support,"
2328 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2329 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2331 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2334 printf("Configuration of RSS hash at ethernet port %d "
2335 "failed with error (%d): %s.\n",
2336 i, -diag, strerror(-diag));
2339 if (all_updated && !use_default)
2340 rss_hf = rss_conf.rss_hf;
2343 cmdline_parse_token_string_t cmd_config_rss_port =
2344 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2345 cmdline_parse_token_string_t cmd_config_rss_keyword =
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2347 cmdline_parse_token_string_t cmd_config_rss_all =
2348 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2349 cmdline_parse_token_string_t cmd_config_rss_name =
2350 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2351 cmdline_parse_token_string_t cmd_config_rss_value =
2352 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2354 cmdline_parse_inst_t cmd_config_rss = {
2355 .f = cmd_config_rss_parsed,
2357 .help_str = "port config all rss "
2358 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2360 (void *)&cmd_config_rss_port,
2361 (void *)&cmd_config_rss_keyword,
2362 (void *)&cmd_config_rss_all,
2363 (void *)&cmd_config_rss_name,
2364 (void *)&cmd_config_rss_value,
2369 /* *** configure rss hash key *** */
2370 struct cmd_config_rss_hash_key {
2371 cmdline_fixed_string_t port;
2372 cmdline_fixed_string_t config;
2374 cmdline_fixed_string_t rss_hash_key;
2375 cmdline_fixed_string_t rss_type;
2376 cmdline_fixed_string_t key;
2380 hexa_digit_to_value(char hexa_digit)
2382 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2383 return (uint8_t) (hexa_digit - '0');
2384 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2385 return (uint8_t) ((hexa_digit - 'a') + 10);
2386 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2387 return (uint8_t) ((hexa_digit - 'A') + 10);
2388 /* Invalid hexa digit */
2393 parse_and_check_key_hexa_digit(char *key, int idx)
2397 hexa_v = hexa_digit_to_value(key[idx]);
2399 printf("invalid key: character %c at position %d is not a "
2400 "valid hexa digit\n", key[idx], idx);
2405 cmd_config_rss_hash_key_parsed(void *parsed_result,
2406 __attribute__((unused)) struct cmdline *cl,
2407 __attribute__((unused)) void *data)
2409 struct cmd_config_rss_hash_key *res = parsed_result;
2410 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2414 struct rte_eth_dev_info dev_info;
2415 uint8_t hash_key_size;
2419 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2423 if (dev_info.hash_key_size > 0 &&
2424 dev_info.hash_key_size <= sizeof(hash_key))
2425 hash_key_size = dev_info.hash_key_size;
2427 printf("dev_info did not provide a valid hash key size\n");
2430 /* Check the length of the RSS hash key */
2431 key_len = strlen(res->key);
2432 if (key_len != (hash_key_size * 2)) {
2433 printf("key length: %d invalid - key must be a string of %d"
2434 " hexa-decimal numbers\n",
2435 (int) key_len, hash_key_size * 2);
2438 /* Translate RSS hash key into binary representation */
2439 for (i = 0; i < hash_key_size; i++) {
2440 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2443 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2446 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2448 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2452 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2454 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2455 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2457 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2458 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2459 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2460 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2461 rss_hash_key, "rss-hash-key");
2462 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2463 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2464 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2465 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2466 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2467 "ipv6-tcp-ex#ipv6-udp-ex#"
2468 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2469 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2470 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2472 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2473 .f = cmd_config_rss_hash_key_parsed,
2475 .help_str = "port config <port_id> rss-hash-key "
2476 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2477 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2478 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2479 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2480 "<string of hex digits (variable length, NIC dependent)>",
2482 (void *)&cmd_config_rss_hash_key_port,
2483 (void *)&cmd_config_rss_hash_key_config,
2484 (void *)&cmd_config_rss_hash_key_port_id,
2485 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2486 (void *)&cmd_config_rss_hash_key_rss_type,
2487 (void *)&cmd_config_rss_hash_key_value,
2492 /* *** configure port rxq/txq ring size *** */
2493 struct cmd_config_rxtx_ring_size {
2494 cmdline_fixed_string_t port;
2495 cmdline_fixed_string_t config;
2497 cmdline_fixed_string_t rxtxq;
2499 cmdline_fixed_string_t rsize;
2504 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2505 __attribute__((unused)) struct cmdline *cl,
2506 __attribute__((unused)) void *data)
2508 struct cmd_config_rxtx_ring_size *res = parsed_result;
2509 struct rte_port *port;
2512 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2515 if (res->portid == (portid_t)RTE_PORT_ALL) {
2516 printf("Invalid port id\n");
2520 port = &ports[res->portid];
2522 if (!strcmp(res->rxtxq, "rxq"))
2524 else if (!strcmp(res->rxtxq, "txq"))
2527 printf("Unknown parameter\n");
2531 if (isrx && rx_queue_id_is_invalid(res->qid))
2533 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2536 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2537 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2543 port->nb_rx_desc[res->qid] = res->size;
2545 port->nb_tx_desc[res->qid] = res->size;
2547 cmd_reconfig_device_queue(res->portid, 0, 1);
2550 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2553 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2554 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2556 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2557 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2559 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2562 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2563 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2565 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2566 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2567 rsize, "ring_size");
2568 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2569 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2572 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2573 .f = cmd_config_rxtx_ring_size_parsed,
2575 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2577 (void *)&cmd_config_rxtx_ring_size_port,
2578 (void *)&cmd_config_rxtx_ring_size_config,
2579 (void *)&cmd_config_rxtx_ring_size_portid,
2580 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2581 (void *)&cmd_config_rxtx_ring_size_qid,
2582 (void *)&cmd_config_rxtx_ring_size_rsize,
2583 (void *)&cmd_config_rxtx_ring_size_size,
2588 /* *** configure port rxq/txq start/stop *** */
2589 struct cmd_config_rxtx_queue {
2590 cmdline_fixed_string_t port;
2592 cmdline_fixed_string_t rxtxq;
2594 cmdline_fixed_string_t opname;
2598 cmd_config_rxtx_queue_parsed(void *parsed_result,
2599 __attribute__((unused)) struct cmdline *cl,
2600 __attribute__((unused)) void *data)
2602 struct cmd_config_rxtx_queue *res = parsed_result;
2607 if (test_done == 0) {
2608 printf("Please stop forwarding first\n");
2612 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2615 if (port_is_started(res->portid) != 1) {
2616 printf("Please start port %u first\n", res->portid);
2620 if (!strcmp(res->rxtxq, "rxq"))
2622 else if (!strcmp(res->rxtxq, "txq"))
2625 printf("Unknown parameter\n");
2629 if (isrx && rx_queue_id_is_invalid(res->qid))
2631 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2634 if (!strcmp(res->opname, "start"))
2636 else if (!strcmp(res->opname, "stop"))
2639 printf("Unknown parameter\n");
2643 if (isstart && isrx)
2644 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2645 else if (!isstart && isrx)
2646 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2647 else if (isstart && !isrx)
2648 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2650 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2652 if (ret == -ENOTSUP)
2653 printf("Function not supported in PMD driver\n");
2656 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2657 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2658 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2659 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2660 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2661 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2662 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2663 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2664 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2665 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2668 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2669 .f = cmd_config_rxtx_queue_parsed,
2671 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2673 (void *)&cmd_config_rxtx_queue_port,
2674 (void *)&cmd_config_rxtx_queue_portid,
2675 (void *)&cmd_config_rxtx_queue_rxtxq,
2676 (void *)&cmd_config_rxtx_queue_qid,
2677 (void *)&cmd_config_rxtx_queue_opname,
2682 /* *** configure port rxq/txq deferred start on/off *** */
2683 struct cmd_config_deferred_start_rxtx_queue {
2684 cmdline_fixed_string_t port;
2686 cmdline_fixed_string_t rxtxq;
2688 cmdline_fixed_string_t opname;
2689 cmdline_fixed_string_t state;
2693 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2694 __attribute__((unused)) struct cmdline *cl,
2695 __attribute__((unused)) void *data)
2697 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2698 struct rte_port *port;
2701 uint8_t needreconfig = 0;
2703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2706 if (port_is_started(res->port_id) != 0) {
2707 printf("Please stop port %u first\n", res->port_id);
2711 port = &ports[res->port_id];
2713 isrx = !strcmp(res->rxtxq, "rxq");
2715 if (isrx && rx_queue_id_is_invalid(res->qid))
2717 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2720 ison = !strcmp(res->state, "on");
2722 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2723 port->rx_conf[res->qid].rx_deferred_start = ison;
2725 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2726 port->tx_conf[res->qid].tx_deferred_start = ison;
2731 cmd_reconfig_device_queue(res->port_id, 0, 1);
2734 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2735 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2737 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2738 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2740 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2741 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2743 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2744 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2746 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2747 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2748 opname, "deferred_start");
2749 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2750 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2753 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2754 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2756 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2758 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2759 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2760 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2761 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2762 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2763 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2768 /* *** configure port rxq/txq setup *** */
2769 struct cmd_setup_rxtx_queue {
2770 cmdline_fixed_string_t port;
2772 cmdline_fixed_string_t rxtxq;
2774 cmdline_fixed_string_t setup;
2777 /* Common CLI fields for queue setup */
2778 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2779 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2780 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2781 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2782 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2783 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2784 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2785 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2786 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2787 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2790 cmd_setup_rxtx_queue_parsed(
2791 void *parsed_result,
2792 __attribute__((unused)) struct cmdline *cl,
2793 __attribute__((unused)) void *data)
2795 struct cmd_setup_rxtx_queue *res = parsed_result;
2796 struct rte_port *port;
2797 struct rte_mempool *mp;
2798 unsigned int socket_id;
2802 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2805 if (res->portid == (portid_t)RTE_PORT_ALL) {
2806 printf("Invalid port id\n");
2810 if (!strcmp(res->rxtxq, "rxq"))
2812 else if (!strcmp(res->rxtxq, "txq"))
2815 printf("Unknown parameter\n");
2819 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2820 printf("Invalid rx queue\n");
2822 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2823 printf("Invalid tx queue\n");
2827 port = &ports[res->portid];
2829 socket_id = rxring_numa[res->portid];
2830 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2831 socket_id = port->socket_id;
2833 mp = mbuf_pool_find(socket_id);
2835 printf("Failed to setup RX queue: "
2836 "No mempool allocation"
2837 " on the socket %d\n",
2838 rxring_numa[res->portid]);
2841 ret = rte_eth_rx_queue_setup(res->portid,
2843 port->nb_rx_desc[res->qid],
2845 &port->rx_conf[res->qid],
2848 printf("Failed to setup RX queue\n");
2850 socket_id = txring_numa[res->portid];
2851 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2852 socket_id = port->socket_id;
2854 ret = rte_eth_tx_queue_setup(res->portid,
2856 port->nb_tx_desc[res->qid],
2858 &port->tx_conf[res->qid]);
2860 printf("Failed to setup TX queue\n");
2864 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2865 .f = cmd_setup_rxtx_queue_parsed,
2867 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2869 (void *)&cmd_setup_rxtx_queue_port,
2870 (void *)&cmd_setup_rxtx_queue_portid,
2871 (void *)&cmd_setup_rxtx_queue_rxtxq,
2872 (void *)&cmd_setup_rxtx_queue_qid,
2873 (void *)&cmd_setup_rxtx_queue_setup,
2879 /* *** Configure RSS RETA *** */
2880 struct cmd_config_rss_reta {
2881 cmdline_fixed_string_t port;
2882 cmdline_fixed_string_t keyword;
2884 cmdline_fixed_string_t name;
2885 cmdline_fixed_string_t list_name;
2886 cmdline_fixed_string_t list_of_items;
2890 parse_reta_config(const char *str,
2891 struct rte_eth_rss_reta_entry64 *reta_conf,
2892 uint16_t nb_entries)
2896 uint16_t hash_index, idx, shift;
2899 const char *p, *p0 = str;
2906 unsigned long int_fld[_NUM_FLD];
2907 char *str_fld[_NUM_FLD];
2909 while ((p = strchr(p0,'(')) != NULL) {
2911 if((p0 = strchr(p,')')) == NULL)
2915 if(size >= sizeof(s))
2918 snprintf(s, sizeof(s), "%.*s", size, p);
2919 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2921 for (i = 0; i < _NUM_FLD; i++) {
2923 int_fld[i] = strtoul(str_fld[i], &end, 0);
2924 if (errno != 0 || end == str_fld[i] ||
2929 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2930 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2932 if (hash_index >= nb_entries) {
2933 printf("Invalid RETA hash index=%d\n", hash_index);
2937 idx = hash_index / RTE_RETA_GROUP_SIZE;
2938 shift = hash_index % RTE_RETA_GROUP_SIZE;
2939 reta_conf[idx].mask |= (1ULL << shift);
2940 reta_conf[idx].reta[shift] = nb_queue;
2947 cmd_set_rss_reta_parsed(void *parsed_result,
2948 __attribute__((unused)) struct cmdline *cl,
2949 __attribute__((unused)) void *data)
2952 struct rte_eth_dev_info dev_info;
2953 struct rte_eth_rss_reta_entry64 reta_conf[8];
2954 struct cmd_config_rss_reta *res = parsed_result;
2956 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2960 if (dev_info.reta_size == 0) {
2961 printf("Redirection table size is 0 which is "
2962 "invalid for RSS\n");
2965 printf("The reta size of port %d is %u\n",
2966 res->port_id, dev_info.reta_size);
2967 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2968 printf("Currently do not support more than %u entries of "
2969 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2973 memset(reta_conf, 0, sizeof(reta_conf));
2974 if (!strcmp(res->list_name, "reta")) {
2975 if (parse_reta_config(res->list_of_items, reta_conf,
2976 dev_info.reta_size)) {
2977 printf("Invalid RSS Redirection Table "
2978 "config entered\n");
2981 ret = rte_eth_dev_rss_reta_update(res->port_id,
2982 reta_conf, dev_info.reta_size);
2984 printf("Bad redirection table parameter, "
2985 "return code = %d \n", ret);
2989 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2990 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2991 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2992 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2993 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2994 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2995 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2996 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2997 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2998 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2999 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3000 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3002 cmdline_parse_inst_t cmd_config_rss_reta = {
3003 .f = cmd_set_rss_reta_parsed,
3005 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3007 (void *)&cmd_config_rss_reta_port,
3008 (void *)&cmd_config_rss_reta_keyword,
3009 (void *)&cmd_config_rss_reta_port_id,
3010 (void *)&cmd_config_rss_reta_name,
3011 (void *)&cmd_config_rss_reta_list_name,
3012 (void *)&cmd_config_rss_reta_list_of_items,
3017 /* *** SHOW PORT RETA INFO *** */
3018 struct cmd_showport_reta {
3019 cmdline_fixed_string_t show;
3020 cmdline_fixed_string_t port;
3022 cmdline_fixed_string_t rss;
3023 cmdline_fixed_string_t reta;
3025 cmdline_fixed_string_t list_of_items;
3029 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3030 uint16_t nb_entries,
3034 const char *p, *p0 = str;
3039 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3040 RTE_RETA_GROUP_SIZE;
3043 p = strchr(p0, '(');
3047 p0 = strchr(p, ')');
3051 if (size >= sizeof(s)) {
3052 printf("The string size exceeds the internal buffer size\n");
3055 snprintf(s, sizeof(s), "%.*s", size, p);
3056 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3057 if (ret <= 0 || ret != num) {
3058 printf("The bits of masks do not match the number of "
3059 "reta entries: %u\n", num);
3062 for (i = 0; i < ret; i++)
3063 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3069 cmd_showport_reta_parsed(void *parsed_result,
3070 __attribute__((unused)) struct cmdline *cl,
3071 __attribute__((unused)) void *data)
3073 struct cmd_showport_reta *res = parsed_result;
3074 struct rte_eth_rss_reta_entry64 reta_conf[8];
3075 struct rte_eth_dev_info dev_info;
3076 uint16_t max_reta_size;
3079 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3083 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3084 if (res->size == 0 || res->size > max_reta_size) {
3085 printf("Invalid redirection table size: %u (1-%u)\n",
3086 res->size, max_reta_size);
3090 memset(reta_conf, 0, sizeof(reta_conf));
3091 if (showport_parse_reta_config(reta_conf, res->size,
3092 res->list_of_items) < 0) {
3093 printf("Invalid string: %s for reta masks\n",
3094 res->list_of_items);
3097 port_rss_reta_info(res->port_id, reta_conf, res->size);
3100 cmdline_parse_token_string_t cmd_showport_reta_show =
3101 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3102 cmdline_parse_token_string_t cmd_showport_reta_port =
3103 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3104 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3105 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3106 cmdline_parse_token_string_t cmd_showport_reta_rss =
3107 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3108 cmdline_parse_token_string_t cmd_showport_reta_reta =
3109 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3110 cmdline_parse_token_num_t cmd_showport_reta_size =
3111 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3112 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3113 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3114 list_of_items, NULL);
3116 cmdline_parse_inst_t cmd_showport_reta = {
3117 .f = cmd_showport_reta_parsed,
3119 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3121 (void *)&cmd_showport_reta_show,
3122 (void *)&cmd_showport_reta_port,
3123 (void *)&cmd_showport_reta_port_id,
3124 (void *)&cmd_showport_reta_rss,
3125 (void *)&cmd_showport_reta_reta,
3126 (void *)&cmd_showport_reta_size,
3127 (void *)&cmd_showport_reta_list_of_items,
3132 /* *** Show RSS hash configuration *** */
3133 struct cmd_showport_rss_hash {
3134 cmdline_fixed_string_t show;
3135 cmdline_fixed_string_t port;
3137 cmdline_fixed_string_t rss_hash;
3138 cmdline_fixed_string_t rss_type;
3139 cmdline_fixed_string_t key; /* optional argument */
3142 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3143 __attribute__((unused)) struct cmdline *cl,
3146 struct cmd_showport_rss_hash *res = parsed_result;
3148 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3151 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3152 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3153 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3154 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3155 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3156 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3157 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3158 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3160 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3161 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3163 cmdline_parse_inst_t cmd_showport_rss_hash = {
3164 .f = cmd_showport_rss_hash_parsed,
3166 .help_str = "show port <port_id> rss-hash",
3168 (void *)&cmd_showport_rss_hash_show,
3169 (void *)&cmd_showport_rss_hash_port,
3170 (void *)&cmd_showport_rss_hash_port_id,
3171 (void *)&cmd_showport_rss_hash_rss_hash,
3176 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3177 .f = cmd_showport_rss_hash_parsed,
3179 .help_str = "show port <port_id> rss-hash key",
3181 (void *)&cmd_showport_rss_hash_show,
3182 (void *)&cmd_showport_rss_hash_port,
3183 (void *)&cmd_showport_rss_hash_port_id,
3184 (void *)&cmd_showport_rss_hash_rss_hash,
3185 (void *)&cmd_showport_rss_hash_rss_key,
3190 /* *** Configure DCB *** */
3191 struct cmd_config_dcb {
3192 cmdline_fixed_string_t port;
3193 cmdline_fixed_string_t config;
3195 cmdline_fixed_string_t dcb;
3196 cmdline_fixed_string_t vt;
3197 cmdline_fixed_string_t vt_en;
3199 cmdline_fixed_string_t pfc;
3200 cmdline_fixed_string_t pfc_en;
3204 cmd_config_dcb_parsed(void *parsed_result,
3205 __attribute__((unused)) struct cmdline *cl,
3206 __attribute__((unused)) void *data)
3208 struct cmd_config_dcb *res = parsed_result;
3209 portid_t port_id = res->port_id;
3210 struct rte_port *port;
3214 port = &ports[port_id];
3215 /** Check if the port is not started **/
3216 if (port->port_status != RTE_PORT_STOPPED) {
3217 printf("Please stop port %d first\n", port_id);
3221 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3222 printf("The invalid number of traffic class,"
3223 " only 4 or 8 allowed.\n");
3227 if (nb_fwd_lcores < res->num_tcs) {
3228 printf("nb_cores shouldn't be less than number of TCs.\n");
3231 if (!strncmp(res->pfc_en, "on", 2))
3236 /* DCB in VT mode */
3237 if (!strncmp(res->vt_en, "on", 2))
3238 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3239 (enum rte_eth_nb_tcs)res->num_tcs,
3242 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3243 (enum rte_eth_nb_tcs)res->num_tcs,
3248 printf("Cannot initialize network ports.\n");
3252 cmd_reconfig_device_queue(port_id, 1, 1);
3255 cmdline_parse_token_string_t cmd_config_dcb_port =
3256 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3257 cmdline_parse_token_string_t cmd_config_dcb_config =
3258 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3259 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3260 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3261 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3262 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3263 cmdline_parse_token_string_t cmd_config_dcb_vt =
3264 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3265 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3266 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3267 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3268 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3269 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3270 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3271 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3272 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3274 cmdline_parse_inst_t cmd_config_dcb = {
3275 .f = cmd_config_dcb_parsed,
3277 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3279 (void *)&cmd_config_dcb_port,
3280 (void *)&cmd_config_dcb_config,
3281 (void *)&cmd_config_dcb_port_id,
3282 (void *)&cmd_config_dcb_dcb,
3283 (void *)&cmd_config_dcb_vt,
3284 (void *)&cmd_config_dcb_vt_en,
3285 (void *)&cmd_config_dcb_num_tcs,
3286 (void *)&cmd_config_dcb_pfc,
3287 (void *)&cmd_config_dcb_pfc_en,
3292 /* *** configure number of packets per burst *** */
3293 struct cmd_config_burst {
3294 cmdline_fixed_string_t port;
3295 cmdline_fixed_string_t keyword;
3296 cmdline_fixed_string_t all;
3297 cmdline_fixed_string_t name;
3302 cmd_config_burst_parsed(void *parsed_result,
3303 __attribute__((unused)) struct cmdline *cl,
3304 __attribute__((unused)) void *data)
3306 struct cmd_config_burst *res = parsed_result;
3307 struct rte_eth_dev_info dev_info;
3308 uint16_t rec_nb_pkts;
3311 if (!all_ports_stopped()) {
3312 printf("Please stop all ports first\n");
3316 if (!strcmp(res->name, "burst")) {
3317 if (res->value == 0) {
3318 /* If user gives a value of zero, query the PMD for
3319 * its recommended Rx burst size. Testpmd uses a single
3320 * size for all ports, so assume all ports are the same
3321 * NIC model and use the values from Port 0.
3323 ret = eth_dev_info_get_print_err(0, &dev_info);
3327 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3329 if (rec_nb_pkts == 0) {
3330 printf("PMD does not recommend a burst size.\n"
3331 "User provided value must be between"
3332 " 1 and %d\n", MAX_PKT_BURST);
3334 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3335 printf("PMD recommended burst size of %d"
3336 " exceeds maximum value of %d\n",
3337 rec_nb_pkts, MAX_PKT_BURST);
3340 printf("Using PMD-provided burst value of %d\n",
3342 nb_pkt_per_burst = rec_nb_pkts;
3343 } else if (res->value > MAX_PKT_BURST) {
3344 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3347 nb_pkt_per_burst = res->value;
3349 printf("Unknown parameter\n");
3355 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3358 cmdline_parse_token_string_t cmd_config_burst_port =
3359 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3360 cmdline_parse_token_string_t cmd_config_burst_keyword =
3361 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3362 cmdline_parse_token_string_t cmd_config_burst_all =
3363 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3364 cmdline_parse_token_string_t cmd_config_burst_name =
3365 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3366 cmdline_parse_token_num_t cmd_config_burst_value =
3367 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3369 cmdline_parse_inst_t cmd_config_burst = {
3370 .f = cmd_config_burst_parsed,
3372 .help_str = "port config all burst <value>",
3374 (void *)&cmd_config_burst_port,
3375 (void *)&cmd_config_burst_keyword,
3376 (void *)&cmd_config_burst_all,
3377 (void *)&cmd_config_burst_name,
3378 (void *)&cmd_config_burst_value,
3383 /* *** configure rx/tx queues *** */
3384 struct cmd_config_thresh {
3385 cmdline_fixed_string_t port;
3386 cmdline_fixed_string_t keyword;
3387 cmdline_fixed_string_t all;
3388 cmdline_fixed_string_t name;
3393 cmd_config_thresh_parsed(void *parsed_result,
3394 __attribute__((unused)) struct cmdline *cl,
3395 __attribute__((unused)) void *data)
3397 struct cmd_config_thresh *res = parsed_result;
3399 if (!all_ports_stopped()) {
3400 printf("Please stop all ports first\n");
3404 if (!strcmp(res->name, "txpt"))
3405 tx_pthresh = res->value;
3406 else if(!strcmp(res->name, "txht"))
3407 tx_hthresh = res->value;
3408 else if(!strcmp(res->name, "txwt"))
3409 tx_wthresh = res->value;
3410 else if(!strcmp(res->name, "rxpt"))
3411 rx_pthresh = res->value;
3412 else if(!strcmp(res->name, "rxht"))
3413 rx_hthresh = res->value;
3414 else if(!strcmp(res->name, "rxwt"))
3415 rx_wthresh = res->value;
3417 printf("Unknown parameter\n");
3423 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3426 cmdline_parse_token_string_t cmd_config_thresh_port =
3427 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3428 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3429 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3430 cmdline_parse_token_string_t cmd_config_thresh_all =
3431 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3432 cmdline_parse_token_string_t cmd_config_thresh_name =
3433 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3434 "txpt#txht#txwt#rxpt#rxht#rxwt");
3435 cmdline_parse_token_num_t cmd_config_thresh_value =
3436 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3438 cmdline_parse_inst_t cmd_config_thresh = {
3439 .f = cmd_config_thresh_parsed,
3441 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3443 (void *)&cmd_config_thresh_port,
3444 (void *)&cmd_config_thresh_keyword,
3445 (void *)&cmd_config_thresh_all,
3446 (void *)&cmd_config_thresh_name,
3447 (void *)&cmd_config_thresh_value,
3452 /* *** configure free/rs threshold *** */
3453 struct cmd_config_threshold {
3454 cmdline_fixed_string_t port;
3455 cmdline_fixed_string_t keyword;
3456 cmdline_fixed_string_t all;
3457 cmdline_fixed_string_t name;
3462 cmd_config_threshold_parsed(void *parsed_result,
3463 __attribute__((unused)) struct cmdline *cl,
3464 __attribute__((unused)) void *data)
3466 struct cmd_config_threshold *res = parsed_result;
3468 if (!all_ports_stopped()) {
3469 printf("Please stop all ports first\n");
3473 if (!strcmp(res->name, "txfreet"))
3474 tx_free_thresh = res->value;
3475 else if (!strcmp(res->name, "txrst"))
3476 tx_rs_thresh = res->value;
3477 else if (!strcmp(res->name, "rxfreet"))
3478 rx_free_thresh = res->value;
3480 printf("Unknown parameter\n");
3486 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3489 cmdline_parse_token_string_t cmd_config_threshold_port =
3490 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3491 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3492 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3494 cmdline_parse_token_string_t cmd_config_threshold_all =
3495 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3496 cmdline_parse_token_string_t cmd_config_threshold_name =
3497 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3498 "txfreet#txrst#rxfreet");
3499 cmdline_parse_token_num_t cmd_config_threshold_value =
3500 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3502 cmdline_parse_inst_t cmd_config_threshold = {
3503 .f = cmd_config_threshold_parsed,
3505 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3507 (void *)&cmd_config_threshold_port,
3508 (void *)&cmd_config_threshold_keyword,
3509 (void *)&cmd_config_threshold_all,
3510 (void *)&cmd_config_threshold_name,
3511 (void *)&cmd_config_threshold_value,
3517 struct cmd_stop_result {
3518 cmdline_fixed_string_t stop;
3521 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3522 __attribute__((unused)) struct cmdline *cl,
3523 __attribute__((unused)) void *data)
3525 stop_packet_forwarding();
3528 cmdline_parse_token_string_t cmd_stop_stop =
3529 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3531 cmdline_parse_inst_t cmd_stop = {
3532 .f = cmd_stop_parsed,
3534 .help_str = "stop: Stop packet forwarding",
3536 (void *)&cmd_stop_stop,
3541 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3544 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3545 unsigned int *parsed_items, int check_unique_values)
3547 unsigned int nb_item;
3555 * First parse all items in the list and store their value.
3560 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3562 if ((c >= '0') && (c <= '9')) {
3563 value = (unsigned int) (value * 10 + (c - '0'));
3568 printf("character %c is not a decimal digit\n", c);
3572 printf("No valid value before comma\n");
3575 if (nb_item < max_items) {
3576 parsed_items[nb_item] = value;
3582 if (nb_item >= max_items) {
3583 printf("Number of %s = %u > %u (maximum items)\n",
3584 item_name, nb_item + 1, max_items);
3587 parsed_items[nb_item++] = value;
3588 if (! check_unique_values)
3592 * Then, check that all values in the list are differents.
3593 * No optimization here...
3595 for (i = 0; i < nb_item; i++) {
3596 for (j = i + 1; j < nb_item; j++) {
3597 if (parsed_items[j] == parsed_items[i]) {
3598 printf("duplicated %s %u at index %u and %u\n",
3599 item_name, parsed_items[i], i, j);
3607 struct cmd_set_list_result {
3608 cmdline_fixed_string_t cmd_keyword;
3609 cmdline_fixed_string_t list_name;
3610 cmdline_fixed_string_t list_of_items;
3613 static void cmd_set_list_parsed(void *parsed_result,
3614 __attribute__((unused)) struct cmdline *cl,
3615 __attribute__((unused)) void *data)
3617 struct cmd_set_list_result *res;
3619 unsigned int lcorelist[RTE_MAX_LCORE];
3620 unsigned int portlist[RTE_MAX_ETHPORTS];
3622 unsigned int nb_item;
3624 if (test_done == 0) {
3625 printf("Please stop forwarding first\n");
3629 res = parsed_result;
3630 if (!strcmp(res->list_name, "corelist")) {
3631 nb_item = parse_item_list(res->list_of_items, "core",
3633 parsed_items.lcorelist, 1);
3635 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3640 if (!strcmp(res->list_name, "portlist")) {
3641 nb_item = parse_item_list(res->list_of_items, "port",
3643 parsed_items.portlist, 1);
3645 set_fwd_ports_list(parsed_items.portlist, nb_item);
3651 cmdline_parse_token_string_t cmd_set_list_keyword =
3652 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3654 cmdline_parse_token_string_t cmd_set_list_name =
3655 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3656 "corelist#portlist");
3657 cmdline_parse_token_string_t cmd_set_list_of_items =
3658 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3661 cmdline_parse_inst_t cmd_set_fwd_list = {
3662 .f = cmd_set_list_parsed,
3664 .help_str = "set corelist|portlist <list0[,list1]*>",
3666 (void *)&cmd_set_list_keyword,
3667 (void *)&cmd_set_list_name,
3668 (void *)&cmd_set_list_of_items,
3673 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3675 struct cmd_setmask_result {
3676 cmdline_fixed_string_t set;
3677 cmdline_fixed_string_t mask;
3681 static void cmd_set_mask_parsed(void *parsed_result,
3682 __attribute__((unused)) struct cmdline *cl,
3683 __attribute__((unused)) void *data)
3685 struct cmd_setmask_result *res = parsed_result;
3687 if (test_done == 0) {
3688 printf("Please stop forwarding first\n");
3691 if (!strcmp(res->mask, "coremask")) {
3692 set_fwd_lcores_mask(res->hexavalue);
3694 } else if (!strcmp(res->mask, "portmask")) {
3695 set_fwd_ports_mask(res->hexavalue);
3700 cmdline_parse_token_string_t cmd_setmask_set =
3701 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3702 cmdline_parse_token_string_t cmd_setmask_mask =
3703 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3704 "coremask#portmask");
3705 cmdline_parse_token_num_t cmd_setmask_value =
3706 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3708 cmdline_parse_inst_t cmd_set_fwd_mask = {
3709 .f = cmd_set_mask_parsed,
3711 .help_str = "set coremask|portmask <hexadecimal value>",
3713 (void *)&cmd_setmask_set,
3714 (void *)&cmd_setmask_mask,
3715 (void *)&cmd_setmask_value,
3721 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3723 struct cmd_set_result {
3724 cmdline_fixed_string_t set;
3725 cmdline_fixed_string_t what;
3729 static void cmd_set_parsed(void *parsed_result,
3730 __attribute__((unused)) struct cmdline *cl,
3731 __attribute__((unused)) void *data)
3733 struct cmd_set_result *res = parsed_result;
3734 if (!strcmp(res->what, "nbport")) {
3735 set_fwd_ports_number(res->value);
3737 } else if (!strcmp(res->what, "nbcore")) {
3738 set_fwd_lcores_number(res->value);
3740 } else if (!strcmp(res->what, "burst"))
3741 set_nb_pkt_per_burst(res->value);
3742 else if (!strcmp(res->what, "verbose"))
3743 set_verbose_level(res->value);
3746 cmdline_parse_token_string_t cmd_set_set =
3747 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3748 cmdline_parse_token_string_t cmd_set_what =
3749 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3750 "nbport#nbcore#burst#verbose");
3751 cmdline_parse_token_num_t cmd_set_value =
3752 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3754 cmdline_parse_inst_t cmd_set_numbers = {
3755 .f = cmd_set_parsed,
3757 .help_str = "set nbport|nbcore|burst|verbose <value>",
3759 (void *)&cmd_set_set,
3760 (void *)&cmd_set_what,
3761 (void *)&cmd_set_value,
3766 /* *** SET LOG LEVEL CONFIGURATION *** */
3768 struct cmd_set_log_result {
3769 cmdline_fixed_string_t set;
3770 cmdline_fixed_string_t log;
3771 cmdline_fixed_string_t type;
3776 cmd_set_log_parsed(void *parsed_result,
3777 __attribute__((unused)) struct cmdline *cl,
3778 __attribute__((unused)) void *data)
3780 struct cmd_set_log_result *res;
3783 res = parsed_result;
3784 if (!strcmp(res->type, "global"))
3785 rte_log_set_global_level(res->level);
3787 ret = rte_log_set_level_regexp(res->type, res->level);
3789 printf("Unable to set log level\n");
3793 cmdline_parse_token_string_t cmd_set_log_set =
3794 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3795 cmdline_parse_token_string_t cmd_set_log_log =
3796 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3797 cmdline_parse_token_string_t cmd_set_log_type =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3799 cmdline_parse_token_num_t cmd_set_log_level =
3800 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3802 cmdline_parse_inst_t cmd_set_log = {
3803 .f = cmd_set_log_parsed,
3805 .help_str = "set log global|<type> <level>",
3807 (void *)&cmd_set_log_set,
3808 (void *)&cmd_set_log_log,
3809 (void *)&cmd_set_log_type,
3810 (void *)&cmd_set_log_level,
3815 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3817 struct cmd_set_txpkts_result {
3818 cmdline_fixed_string_t cmd_keyword;
3819 cmdline_fixed_string_t txpkts;
3820 cmdline_fixed_string_t seg_lengths;
3824 cmd_set_txpkts_parsed(void *parsed_result,
3825 __attribute__((unused)) struct cmdline *cl,
3826 __attribute__((unused)) void *data)
3828 struct cmd_set_txpkts_result *res;
3829 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3830 unsigned int nb_segs;
3832 res = parsed_result;
3833 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3834 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3836 set_tx_pkt_segments(seg_lengths, nb_segs);
3839 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3840 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3841 cmd_keyword, "set");
3842 cmdline_parse_token_string_t cmd_set_txpkts_name =
3843 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3845 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3849 cmdline_parse_inst_t cmd_set_txpkts = {
3850 .f = cmd_set_txpkts_parsed,
3852 .help_str = "set txpkts <len0[,len1]*>",
3854 (void *)&cmd_set_txpkts_keyword,
3855 (void *)&cmd_set_txpkts_name,
3856 (void *)&cmd_set_txpkts_lengths,
3861 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3863 struct cmd_set_txsplit_result {
3864 cmdline_fixed_string_t cmd_keyword;
3865 cmdline_fixed_string_t txsplit;
3866 cmdline_fixed_string_t mode;
3870 cmd_set_txsplit_parsed(void *parsed_result,
3871 __attribute__((unused)) struct cmdline *cl,
3872 __attribute__((unused)) void *data)
3874 struct cmd_set_txsplit_result *res;
3876 res = parsed_result;
3877 set_tx_pkt_split(res->mode);
3880 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3881 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3882 cmd_keyword, "set");
3883 cmdline_parse_token_string_t cmd_set_txsplit_name =
3884 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3885 txsplit, "txsplit");
3886 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3887 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3890 cmdline_parse_inst_t cmd_set_txsplit = {
3891 .f = cmd_set_txsplit_parsed,
3893 .help_str = "set txsplit on|off|rand",
3895 (void *)&cmd_set_txsplit_keyword,
3896 (void *)&cmd_set_txsplit_name,
3897 (void *)&cmd_set_txsplit_mode,
3902 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3903 struct cmd_rx_vlan_filter_all_result {
3904 cmdline_fixed_string_t rx_vlan;
3905 cmdline_fixed_string_t what;
3906 cmdline_fixed_string_t all;
3911 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3912 __attribute__((unused)) struct cmdline *cl,
3913 __attribute__((unused)) void *data)
3915 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3917 if (!strcmp(res->what, "add"))
3918 rx_vlan_all_filter_set(res->port_id, 1);
3920 rx_vlan_all_filter_set(res->port_id, 0);
3923 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3924 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3925 rx_vlan, "rx_vlan");
3926 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3927 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3929 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3930 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3932 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3933 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3936 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3937 .f = cmd_rx_vlan_filter_all_parsed,
3939 .help_str = "rx_vlan add|rm all <port_id>: "
3940 "Add/Remove all identifiers to/from the set of VLAN "
3941 "identifiers filtered by a port",
3943 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3944 (void *)&cmd_rx_vlan_filter_all_what,
3945 (void *)&cmd_rx_vlan_filter_all_all,
3946 (void *)&cmd_rx_vlan_filter_all_portid,
3951 /* *** VLAN OFFLOAD SET ON A PORT *** */
3952 struct cmd_vlan_offload_result {
3953 cmdline_fixed_string_t vlan;
3954 cmdline_fixed_string_t set;
3955 cmdline_fixed_string_t vlan_type;
3956 cmdline_fixed_string_t what;
3957 cmdline_fixed_string_t on;
3958 cmdline_fixed_string_t port_id;
3962 cmd_vlan_offload_parsed(void *parsed_result,
3963 __attribute__((unused)) struct cmdline *cl,
3964 __attribute__((unused)) void *data)
3967 struct cmd_vlan_offload_result *res = parsed_result;
3970 portid_t port_id = 0;
3974 len = strnlen(str, STR_TOKEN_SIZE);
3976 /* Get port_id first */
3984 tmp = strtoul(str, NULL, 0);
3985 /* If port_id greater that what portid_t can represent, return */
3986 if(tmp >= RTE_MAX_ETHPORTS)
3988 port_id = (portid_t)tmp;
3990 if (!strcmp(res->on, "on"))
3995 if (!strcmp(res->what, "strip"))
3996 rx_vlan_strip_set(port_id, on);
3997 else if(!strcmp(res->what, "stripq")){
3998 uint16_t queue_id = 0;
4000 /* No queue_id, return */
4002 printf("must specify (port,queue_id)\n");
4005 tmp = strtoul(str + i + 1, NULL, 0);
4006 /* If queue_id greater that what 16-bits can represent, return */
4010 queue_id = (uint16_t)tmp;
4011 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4013 else if (!strcmp(res->what, "filter"))
4014 rx_vlan_filter_set(port_id, on);
4015 else if (!strcmp(res->what, "qinq_strip"))
4016 rx_vlan_qinq_strip_set(port_id, on);
4018 vlan_extend_set(port_id, on);
4023 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4024 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4026 cmdline_parse_token_string_t cmd_vlan_offload_set =
4027 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4029 cmdline_parse_token_string_t cmd_vlan_offload_what =
4030 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4031 what, "strip#filter#qinq_strip#extend#stripq");
4032 cmdline_parse_token_string_t cmd_vlan_offload_on =
4033 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4035 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4036 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4039 cmdline_parse_inst_t cmd_vlan_offload = {
4040 .f = cmd_vlan_offload_parsed,
4042 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4043 "<port_id[,queue_id]>: "
4044 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4046 (void *)&cmd_vlan_offload_vlan,
4047 (void *)&cmd_vlan_offload_set,
4048 (void *)&cmd_vlan_offload_what,
4049 (void *)&cmd_vlan_offload_on,
4050 (void *)&cmd_vlan_offload_portid,
4055 /* *** VLAN TPID SET ON A PORT *** */
4056 struct cmd_vlan_tpid_result {
4057 cmdline_fixed_string_t vlan;
4058 cmdline_fixed_string_t set;
4059 cmdline_fixed_string_t vlan_type;
4060 cmdline_fixed_string_t what;
4066 cmd_vlan_tpid_parsed(void *parsed_result,
4067 __attribute__((unused)) struct cmdline *cl,
4068 __attribute__((unused)) void *data)
4070 struct cmd_vlan_tpid_result *res = parsed_result;
4071 enum rte_vlan_type vlan_type;
4073 if (!strcmp(res->vlan_type, "inner"))
4074 vlan_type = ETH_VLAN_TYPE_INNER;
4075 else if (!strcmp(res->vlan_type, "outer"))
4076 vlan_type = ETH_VLAN_TYPE_OUTER;
4078 printf("Unknown vlan type\n");
4081 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4084 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4085 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4087 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4088 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4090 cmdline_parse_token_string_t cmd_vlan_type =
4091 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4092 vlan_type, "inner#outer");
4093 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4094 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4096 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4097 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4099 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4100 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4103 cmdline_parse_inst_t cmd_vlan_tpid = {
4104 .f = cmd_vlan_tpid_parsed,
4106 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4107 "Set the VLAN Ether type",
4109 (void *)&cmd_vlan_tpid_vlan,
4110 (void *)&cmd_vlan_tpid_set,
4111 (void *)&cmd_vlan_type,
4112 (void *)&cmd_vlan_tpid_what,
4113 (void *)&cmd_vlan_tpid_tpid,
4114 (void *)&cmd_vlan_tpid_portid,
4119 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4120 struct cmd_rx_vlan_filter_result {
4121 cmdline_fixed_string_t rx_vlan;
4122 cmdline_fixed_string_t what;
4128 cmd_rx_vlan_filter_parsed(void *parsed_result,
4129 __attribute__((unused)) struct cmdline *cl,
4130 __attribute__((unused)) void *data)
4132 struct cmd_rx_vlan_filter_result *res = parsed_result;
4134 if (!strcmp(res->what, "add"))
4135 rx_vft_set(res->port_id, res->vlan_id, 1);
4137 rx_vft_set(res->port_id, res->vlan_id, 0);
4140 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4141 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4142 rx_vlan, "rx_vlan");
4143 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4144 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4146 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4147 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4149 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4150 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4153 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4154 .f = cmd_rx_vlan_filter_parsed,
4156 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4157 "Add/Remove a VLAN identifier to/from the set of VLAN "
4158 "identifiers filtered by a port",
4160 (void *)&cmd_rx_vlan_filter_rx_vlan,
4161 (void *)&cmd_rx_vlan_filter_what,
4162 (void *)&cmd_rx_vlan_filter_vlanid,
4163 (void *)&cmd_rx_vlan_filter_portid,
4168 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4169 struct cmd_tx_vlan_set_result {
4170 cmdline_fixed_string_t tx_vlan;
4171 cmdline_fixed_string_t set;
4177 cmd_tx_vlan_set_parsed(void *parsed_result,
4178 __attribute__((unused)) struct cmdline *cl,
4179 __attribute__((unused)) void *data)
4181 struct cmd_tx_vlan_set_result *res = parsed_result;
4183 if (!port_is_stopped(res->port_id)) {
4184 printf("Please stop port %d first\n", res->port_id);
4188 tx_vlan_set(res->port_id, res->vlan_id);
4190 cmd_reconfig_device_queue(res->port_id, 1, 1);
4193 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4194 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4195 tx_vlan, "tx_vlan");
4196 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4197 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4199 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4200 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4202 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4203 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4206 cmdline_parse_inst_t cmd_tx_vlan_set = {
4207 .f = cmd_tx_vlan_set_parsed,
4209 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4210 "Enable hardware insertion of a single VLAN header "
4211 "with a given TAG Identifier in packets sent on a port",
4213 (void *)&cmd_tx_vlan_set_tx_vlan,
4214 (void *)&cmd_tx_vlan_set_set,
4215 (void *)&cmd_tx_vlan_set_portid,
4216 (void *)&cmd_tx_vlan_set_vlanid,
4221 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4222 struct cmd_tx_vlan_set_qinq_result {
4223 cmdline_fixed_string_t tx_vlan;
4224 cmdline_fixed_string_t set;
4227 uint16_t vlan_id_outer;
4231 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4232 __attribute__((unused)) struct cmdline *cl,
4233 __attribute__((unused)) void *data)
4235 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4237 if (!port_is_stopped(res->port_id)) {
4238 printf("Please stop port %d first\n", res->port_id);
4242 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4244 cmd_reconfig_device_queue(res->port_id, 1, 1);
4247 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4248 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4249 tx_vlan, "tx_vlan");
4250 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4251 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4253 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4254 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4256 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4257 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4259 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4260 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4261 vlan_id_outer, UINT16);
4263 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4264 .f = cmd_tx_vlan_set_qinq_parsed,
4266 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4267 "Enable hardware insertion of double VLAN header "
4268 "with given TAG Identifiers in packets sent on a port",
4270 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4271 (void *)&cmd_tx_vlan_set_qinq_set,
4272 (void *)&cmd_tx_vlan_set_qinq_portid,
4273 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4274 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4279 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4280 struct cmd_tx_vlan_set_pvid_result {
4281 cmdline_fixed_string_t tx_vlan;
4282 cmdline_fixed_string_t set;
4283 cmdline_fixed_string_t pvid;
4286 cmdline_fixed_string_t mode;
4290 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4291 __attribute__((unused)) struct cmdline *cl,
4292 __attribute__((unused)) void *data)
4294 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4296 if (strcmp(res->mode, "on") == 0)
4297 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4299 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4302 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4303 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4304 tx_vlan, "tx_vlan");
4305 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4306 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4308 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4309 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4311 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4312 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4314 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4315 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4317 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4318 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4321 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4322 .f = cmd_tx_vlan_set_pvid_parsed,
4324 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4326 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4327 (void *)&cmd_tx_vlan_set_pvid_set,
4328 (void *)&cmd_tx_vlan_set_pvid_pvid,
4329 (void *)&cmd_tx_vlan_set_pvid_port_id,
4330 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4331 (void *)&cmd_tx_vlan_set_pvid_mode,
4336 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4337 struct cmd_tx_vlan_reset_result {
4338 cmdline_fixed_string_t tx_vlan;
4339 cmdline_fixed_string_t reset;
4344 cmd_tx_vlan_reset_parsed(void *parsed_result,
4345 __attribute__((unused)) struct cmdline *cl,
4346 __attribute__((unused)) void *data)
4348 struct cmd_tx_vlan_reset_result *res = parsed_result;
4350 if (!port_is_stopped(res->port_id)) {
4351 printf("Please stop port %d first\n", res->port_id);
4355 tx_vlan_reset(res->port_id);
4357 cmd_reconfig_device_queue(res->port_id, 1, 1);
4360 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4361 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4362 tx_vlan, "tx_vlan");
4363 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4364 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4366 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4367 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4370 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4371 .f = cmd_tx_vlan_reset_parsed,
4373 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4374 "VLAN header in packets sent on a port",
4376 (void *)&cmd_tx_vlan_reset_tx_vlan,
4377 (void *)&cmd_tx_vlan_reset_reset,
4378 (void *)&cmd_tx_vlan_reset_portid,
4384 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4385 struct cmd_csum_result {
4386 cmdline_fixed_string_t csum;
4387 cmdline_fixed_string_t mode;
4388 cmdline_fixed_string_t proto;
4389 cmdline_fixed_string_t hwsw;
4394 csum_show(int port_id)
4396 struct rte_eth_dev_info dev_info;
4397 uint64_t tx_offloads;
4400 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4401 printf("Parse tunnel is %s\n",
4402 (ports[port_id].parse_tunnel) ? "on" : "off");
4403 printf("IP checksum offload is %s\n",
4404 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4405 printf("UDP checksum offload is %s\n",
4406 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4407 printf("TCP checksum offload is %s\n",
4408 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4409 printf("SCTP checksum offload is %s\n",
4410 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4411 printf("Outer-Ip checksum offload is %s\n",
4412 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4413 printf("Outer-Udp checksum offload is %s\n",
4414 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4416 /* display warnings if configuration is not supported by the NIC */
4417 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4421 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4422 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4423 printf("Warning: hardware IP checksum enabled but not "
4424 "supported by port %d\n", port_id);
4426 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4427 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4428 printf("Warning: hardware UDP checksum enabled but not "
4429 "supported by port %d\n", port_id);
4431 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4432 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4433 printf("Warning: hardware TCP checksum enabled but not "
4434 "supported by port %d\n", port_id);
4436 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4437 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4438 printf("Warning: hardware SCTP checksum enabled but not "
4439 "supported by port %d\n", port_id);
4441 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4442 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4443 printf("Warning: hardware outer IP checksum enabled but not "
4444 "supported by port %d\n", port_id);
4446 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4447 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4449 printf("Warning: hardware outer UDP checksum enabled but not "
4450 "supported by port %d\n", port_id);
4455 cmd_config_queue_tx_offloads(struct rte_port *port)
4459 /* Apply queue tx offloads configuration */
4460 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4461 port->tx_conf[k].offloads =
4462 port->dev_conf.txmode.offloads;
4466 cmd_csum_parsed(void *parsed_result,
4467 __attribute__((unused)) struct cmdline *cl,
4468 __attribute__((unused)) void *data)
4470 struct cmd_csum_result *res = parsed_result;
4472 uint64_t csum_offloads = 0;
4473 struct rte_eth_dev_info dev_info;
4476 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4477 printf("invalid port %d\n", res->port_id);
4480 if (!port_is_stopped(res->port_id)) {
4481 printf("Please stop port %d first\n", res->port_id);
4485 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4489 if (!strcmp(res->mode, "set")) {
4491 if (!strcmp(res->hwsw, "hw"))
4494 if (!strcmp(res->proto, "ip")) {
4495 if (hw == 0 || (dev_info.tx_offload_capa &
4496 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4497 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4499 printf("IP checksum offload is not supported "
4500 "by port %u\n", res->port_id);
4502 } else if (!strcmp(res->proto, "udp")) {
4503 if (hw == 0 || (dev_info.tx_offload_capa &
4504 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4505 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4507 printf("UDP checksum offload is not supported "
4508 "by port %u\n", res->port_id);
4510 } else if (!strcmp(res->proto, "tcp")) {
4511 if (hw == 0 || (dev_info.tx_offload_capa &
4512 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4513 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4515 printf("TCP checksum offload is not supported "
4516 "by port %u\n", res->port_id);
4518 } else if (!strcmp(res->proto, "sctp")) {
4519 if (hw == 0 || (dev_info.tx_offload_capa &
4520 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4521 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4523 printf("SCTP checksum offload is not supported "
4524 "by port %u\n", res->port_id);
4526 } else if (!strcmp(res->proto, "outer-ip")) {
4527 if (hw == 0 || (dev_info.tx_offload_capa &
4528 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4530 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4532 printf("Outer IP checksum offload is not "
4533 "supported by port %u\n", res->port_id);
4535 } else if (!strcmp(res->proto, "outer-udp")) {
4536 if (hw == 0 || (dev_info.tx_offload_capa &
4537 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4539 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4541 printf("Outer UDP checksum offload is not "
4542 "supported by port %u\n", res->port_id);
4547 ports[res->port_id].dev_conf.txmode.offloads |=
4550 ports[res->port_id].dev_conf.txmode.offloads &=
4553 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4555 csum_show(res->port_id);
4557 cmd_reconfig_device_queue(res->port_id, 1, 1);
4560 cmdline_parse_token_string_t cmd_csum_csum =
4561 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4563 cmdline_parse_token_string_t cmd_csum_mode =
4564 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4566 cmdline_parse_token_string_t cmd_csum_proto =
4567 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4568 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4569 cmdline_parse_token_string_t cmd_csum_hwsw =
4570 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4572 cmdline_parse_token_num_t cmd_csum_portid =
4573 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4576 cmdline_parse_inst_t cmd_csum_set = {
4577 .f = cmd_csum_parsed,
4579 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4580 "Enable/Disable hardware calculation of L3/L4 checksum when "
4581 "using csum forward engine",
4583 (void *)&cmd_csum_csum,
4584 (void *)&cmd_csum_mode,
4585 (void *)&cmd_csum_proto,
4586 (void *)&cmd_csum_hwsw,
4587 (void *)&cmd_csum_portid,
4592 cmdline_parse_token_string_t cmd_csum_mode_show =
4593 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4596 cmdline_parse_inst_t cmd_csum_show = {
4597 .f = cmd_csum_parsed,
4599 .help_str = "csum show <port_id>: Show checksum offload configuration",
4601 (void *)&cmd_csum_csum,
4602 (void *)&cmd_csum_mode_show,
4603 (void *)&cmd_csum_portid,
4608 /* Enable/disable tunnel parsing */
4609 struct cmd_csum_tunnel_result {
4610 cmdline_fixed_string_t csum;
4611 cmdline_fixed_string_t parse;
4612 cmdline_fixed_string_t onoff;
4617 cmd_csum_tunnel_parsed(void *parsed_result,
4618 __attribute__((unused)) struct cmdline *cl,
4619 __attribute__((unused)) void *data)
4621 struct cmd_csum_tunnel_result *res = parsed_result;
4623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4626 if (!strcmp(res->onoff, "on"))
4627 ports[res->port_id].parse_tunnel = 1;
4629 ports[res->port_id].parse_tunnel = 0;
4631 csum_show(res->port_id);
4634 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4635 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4637 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4638 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4639 parse, "parse-tunnel");
4640 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4641 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4643 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4644 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4647 cmdline_parse_inst_t cmd_csum_tunnel = {
4648 .f = cmd_csum_tunnel_parsed,
4650 .help_str = "csum parse-tunnel on|off <port_id>: "
4651 "Enable/Disable parsing of tunnels for csum engine",
4653 (void *)&cmd_csum_tunnel_csum,
4654 (void *)&cmd_csum_tunnel_parse,
4655 (void *)&cmd_csum_tunnel_onoff,
4656 (void *)&cmd_csum_tunnel_portid,
4661 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4662 struct cmd_tso_set_result {
4663 cmdline_fixed_string_t tso;
4664 cmdline_fixed_string_t mode;
4670 cmd_tso_set_parsed(void *parsed_result,
4671 __attribute__((unused)) struct cmdline *cl,
4672 __attribute__((unused)) void *data)
4674 struct cmd_tso_set_result *res = parsed_result;
4675 struct rte_eth_dev_info dev_info;
4678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4680 if (!port_is_stopped(res->port_id)) {
4681 printf("Please stop port %d first\n", res->port_id);
4685 if (!strcmp(res->mode, "set"))
4686 ports[res->port_id].tso_segsz = res->tso_segsz;
4688 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4692 if ((ports[res->port_id].tso_segsz != 0) &&
4693 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4694 printf("Error: TSO is not supported by port %d\n",
4699 if (ports[res->port_id].tso_segsz == 0) {
4700 ports[res->port_id].dev_conf.txmode.offloads &=
4701 ~DEV_TX_OFFLOAD_TCP_TSO;
4702 printf("TSO for non-tunneled packets is disabled\n");
4704 ports[res->port_id].dev_conf.txmode.offloads |=
4705 DEV_TX_OFFLOAD_TCP_TSO;
4706 printf("TSO segment size for non-tunneled packets is %d\n",
4707 ports[res->port_id].tso_segsz);
4709 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4711 /* display warnings if configuration is not supported by the NIC */
4712 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4716 if ((ports[res->port_id].tso_segsz != 0) &&
4717 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4718 printf("Warning: TSO enabled but not "
4719 "supported by port %d\n", res->port_id);
4722 cmd_reconfig_device_queue(res->port_id, 1, 1);
4725 cmdline_parse_token_string_t cmd_tso_set_tso =
4726 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4728 cmdline_parse_token_string_t cmd_tso_set_mode =
4729 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4731 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4732 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4734 cmdline_parse_token_num_t cmd_tso_set_portid =
4735 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4738 cmdline_parse_inst_t cmd_tso_set = {
4739 .f = cmd_tso_set_parsed,
4741 .help_str = "tso set <tso_segsz> <port_id>: "
4742 "Set TSO segment size of non-tunneled packets for csum engine "
4745 (void *)&cmd_tso_set_tso,
4746 (void *)&cmd_tso_set_mode,
4747 (void *)&cmd_tso_set_tso_segsz,
4748 (void *)&cmd_tso_set_portid,
4753 cmdline_parse_token_string_t cmd_tso_show_mode =
4754 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4758 cmdline_parse_inst_t cmd_tso_show = {
4759 .f = cmd_tso_set_parsed,
4761 .help_str = "tso show <port_id>: "
4762 "Show TSO segment size of non-tunneled packets for csum engine",
4764 (void *)&cmd_tso_set_tso,
4765 (void *)&cmd_tso_show_mode,
4766 (void *)&cmd_tso_set_portid,
4771 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4772 struct cmd_tunnel_tso_set_result {
4773 cmdline_fixed_string_t tso;
4774 cmdline_fixed_string_t mode;
4779 static struct rte_eth_dev_info
4780 check_tunnel_tso_nic_support(portid_t port_id)
4782 struct rte_eth_dev_info dev_info;
4784 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4787 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4788 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4789 "not enabled for port %d\n", port_id);
4790 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4791 printf("Warning: GRE TUNNEL TSO not supported therefore "
4792 "not enabled for port %d\n", port_id);
4793 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4794 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4795 "not enabled for port %d\n", port_id);
4796 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4797 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4798 "not enabled for port %d\n", port_id);
4799 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4800 printf("Warning: IP TUNNEL TSO not supported therefore "
4801 "not enabled for port %d\n", port_id);
4802 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4803 printf("Warning: UDP TUNNEL TSO not supported therefore "
4804 "not enabled for port %d\n", port_id);
4809 cmd_tunnel_tso_set_parsed(void *parsed_result,
4810 __attribute__((unused)) struct cmdline *cl,
4811 __attribute__((unused)) void *data)
4813 struct cmd_tunnel_tso_set_result *res = parsed_result;
4814 struct rte_eth_dev_info dev_info;
4816 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4818 if (!port_is_stopped(res->port_id)) {
4819 printf("Please stop port %d first\n", res->port_id);
4823 if (!strcmp(res->mode, "set"))
4824 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4826 dev_info = check_tunnel_tso_nic_support(res->port_id);
4827 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4828 ports[res->port_id].dev_conf.txmode.offloads &=
4829 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4830 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4831 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4832 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4833 DEV_TX_OFFLOAD_IP_TNL_TSO |
4834 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4835 printf("TSO for tunneled packets is disabled\n");
4837 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4838 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4839 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4840 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4841 DEV_TX_OFFLOAD_IP_TNL_TSO |
4842 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4844 ports[res->port_id].dev_conf.txmode.offloads |=
4845 (tso_offloads & dev_info.tx_offload_capa);
4846 printf("TSO segment size for tunneled packets is %d\n",
4847 ports[res->port_id].tunnel_tso_segsz);
4849 /* Below conditions are needed to make it work:
4850 * (1) tunnel TSO is supported by the NIC;
4851 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4853 * (3) for tunneled pkts with outer L3 of IPv4,
4854 * "csum set outer-ip" must be set to hw, because after tso,
4855 * total_len of outer IP header is changed, and the checksum
4856 * of outer IP header calculated by sw should be wrong; that
4857 * is not necessary for IPv6 tunneled pkts because there's no
4858 * checksum in IP header anymore.
4861 if (!ports[res->port_id].parse_tunnel)
4862 printf("Warning: csum parse_tunnel must be set "
4863 "so that tunneled packets are recognized\n");
4864 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4865 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4866 printf("Warning: csum set outer-ip must be set to hw "
4867 "if outer L3 is IPv4; not necessary for IPv6\n");
4870 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4871 cmd_reconfig_device_queue(res->port_id, 1, 1);
4874 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4875 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4877 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4878 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4880 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4881 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4883 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4884 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4887 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4888 .f = cmd_tunnel_tso_set_parsed,
4890 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4891 "Set TSO segment size of tunneled packets for csum engine "
4894 (void *)&cmd_tunnel_tso_set_tso,
4895 (void *)&cmd_tunnel_tso_set_mode,
4896 (void *)&cmd_tunnel_tso_set_tso_segsz,
4897 (void *)&cmd_tunnel_tso_set_portid,
4902 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4903 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4907 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4908 .f = cmd_tunnel_tso_set_parsed,
4910 .help_str = "tunnel_tso show <port_id> "
4911 "Show TSO segment size of tunneled packets for csum engine",
4913 (void *)&cmd_tunnel_tso_set_tso,
4914 (void *)&cmd_tunnel_tso_show_mode,
4915 (void *)&cmd_tunnel_tso_set_portid,
4920 /* *** SET GRO FOR A PORT *** */
4921 struct cmd_gro_enable_result {
4922 cmdline_fixed_string_t cmd_set;
4923 cmdline_fixed_string_t cmd_port;
4924 cmdline_fixed_string_t cmd_keyword;
4925 cmdline_fixed_string_t cmd_onoff;
4930 cmd_gro_enable_parsed(void *parsed_result,
4931 __attribute__((unused)) struct cmdline *cl,
4932 __attribute__((unused)) void *data)
4934 struct cmd_gro_enable_result *res;
4936 res = parsed_result;
4937 if (!strcmp(res->cmd_keyword, "gro"))
4938 setup_gro(res->cmd_onoff, res->cmd_pid);
4941 cmdline_parse_token_string_t cmd_gro_enable_set =
4942 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4944 cmdline_parse_token_string_t cmd_gro_enable_port =
4945 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4946 cmd_keyword, "port");
4947 cmdline_parse_token_num_t cmd_gro_enable_pid =
4948 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4950 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4951 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4952 cmd_keyword, "gro");
4953 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4954 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4955 cmd_onoff, "on#off");
4957 cmdline_parse_inst_t cmd_gro_enable = {
4958 .f = cmd_gro_enable_parsed,
4960 .help_str = "set port <port_id> gro on|off",
4962 (void *)&cmd_gro_enable_set,
4963 (void *)&cmd_gro_enable_port,
4964 (void *)&cmd_gro_enable_pid,
4965 (void *)&cmd_gro_enable_keyword,
4966 (void *)&cmd_gro_enable_onoff,
4971 /* *** DISPLAY GRO CONFIGURATION *** */
4972 struct cmd_gro_show_result {
4973 cmdline_fixed_string_t cmd_show;
4974 cmdline_fixed_string_t cmd_port;
4975 cmdline_fixed_string_t cmd_keyword;
4980 cmd_gro_show_parsed(void *parsed_result,
4981 __attribute__((unused)) struct cmdline *cl,
4982 __attribute__((unused)) void *data)
4984 struct cmd_gro_show_result *res;
4986 res = parsed_result;
4987 if (!strcmp(res->cmd_keyword, "gro"))
4988 show_gro(res->cmd_pid);
4991 cmdline_parse_token_string_t cmd_gro_show_show =
4992 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4994 cmdline_parse_token_string_t cmd_gro_show_port =
4995 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4997 cmdline_parse_token_num_t cmd_gro_show_pid =
4998 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5000 cmdline_parse_token_string_t cmd_gro_show_keyword =
5001 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5002 cmd_keyword, "gro");
5004 cmdline_parse_inst_t cmd_gro_show = {
5005 .f = cmd_gro_show_parsed,
5007 .help_str = "show port <port_id> gro",
5009 (void *)&cmd_gro_show_show,
5010 (void *)&cmd_gro_show_port,
5011 (void *)&cmd_gro_show_pid,
5012 (void *)&cmd_gro_show_keyword,
5017 /* *** SET FLUSH CYCLES FOR GRO *** */
5018 struct cmd_gro_flush_result {
5019 cmdline_fixed_string_t cmd_set;
5020 cmdline_fixed_string_t cmd_keyword;
5021 cmdline_fixed_string_t cmd_flush;
5026 cmd_gro_flush_parsed(void *parsed_result,
5027 __attribute__((unused)) struct cmdline *cl,
5028 __attribute__((unused)) void *data)
5030 struct cmd_gro_flush_result *res;
5032 res = parsed_result;
5033 if ((!strcmp(res->cmd_keyword, "gro")) &&
5034 (!strcmp(res->cmd_flush, "flush")))
5035 setup_gro_flush_cycles(res->cmd_cycles);
5038 cmdline_parse_token_string_t cmd_gro_flush_set =
5039 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5041 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5042 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5043 cmd_keyword, "gro");
5044 cmdline_parse_token_string_t cmd_gro_flush_flush =
5045 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5046 cmd_flush, "flush");
5047 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5048 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5051 cmdline_parse_inst_t cmd_gro_flush = {
5052 .f = cmd_gro_flush_parsed,
5054 .help_str = "set gro flush <cycles>",
5056 (void *)&cmd_gro_flush_set,
5057 (void *)&cmd_gro_flush_keyword,
5058 (void *)&cmd_gro_flush_flush,
5059 (void *)&cmd_gro_flush_cycles,
5064 /* *** ENABLE/DISABLE GSO *** */
5065 struct cmd_gso_enable_result {
5066 cmdline_fixed_string_t cmd_set;
5067 cmdline_fixed_string_t cmd_port;
5068 cmdline_fixed_string_t cmd_keyword;
5069 cmdline_fixed_string_t cmd_mode;
5074 cmd_gso_enable_parsed(void *parsed_result,
5075 __attribute__((unused)) struct cmdline *cl,
5076 __attribute__((unused)) void *data)
5078 struct cmd_gso_enable_result *res;
5080 res = parsed_result;
5081 if (!strcmp(res->cmd_keyword, "gso"))
5082 setup_gso(res->cmd_mode, res->cmd_pid);
5085 cmdline_parse_token_string_t cmd_gso_enable_set =
5086 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5088 cmdline_parse_token_string_t cmd_gso_enable_port =
5089 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5091 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5092 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5093 cmd_keyword, "gso");
5094 cmdline_parse_token_string_t cmd_gso_enable_mode =
5095 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5096 cmd_mode, "on#off");
5097 cmdline_parse_token_num_t cmd_gso_enable_pid =
5098 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5101 cmdline_parse_inst_t cmd_gso_enable = {
5102 .f = cmd_gso_enable_parsed,
5104 .help_str = "set port <port_id> gso on|off",
5106 (void *)&cmd_gso_enable_set,
5107 (void *)&cmd_gso_enable_port,
5108 (void *)&cmd_gso_enable_pid,
5109 (void *)&cmd_gso_enable_keyword,
5110 (void *)&cmd_gso_enable_mode,
5115 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5116 struct cmd_gso_size_result {
5117 cmdline_fixed_string_t cmd_set;
5118 cmdline_fixed_string_t cmd_keyword;
5119 cmdline_fixed_string_t cmd_segsz;
5124 cmd_gso_size_parsed(void *parsed_result,
5125 __attribute__((unused)) struct cmdline *cl,
5126 __attribute__((unused)) void *data)
5128 struct cmd_gso_size_result *res = parsed_result;
5130 if (test_done == 0) {
5131 printf("Before setting GSO segsz, please first"
5132 " stop fowarding\n");
5136 if (!strcmp(res->cmd_keyword, "gso") &&
5137 !strcmp(res->cmd_segsz, "segsz")) {
5138 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5139 printf("gso_size should be larger than %zu."
5140 " Please input a legal value\n",
5141 RTE_GSO_SEG_SIZE_MIN);
5143 gso_max_segment_size = res->cmd_size;
5147 cmdline_parse_token_string_t cmd_gso_size_set =
5148 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5150 cmdline_parse_token_string_t cmd_gso_size_keyword =
5151 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5152 cmd_keyword, "gso");
5153 cmdline_parse_token_string_t cmd_gso_size_segsz =
5154 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5155 cmd_segsz, "segsz");
5156 cmdline_parse_token_num_t cmd_gso_size_size =
5157 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5160 cmdline_parse_inst_t cmd_gso_size = {
5161 .f = cmd_gso_size_parsed,
5163 .help_str = "set gso segsz <length>",
5165 (void *)&cmd_gso_size_set,
5166 (void *)&cmd_gso_size_keyword,
5167 (void *)&cmd_gso_size_segsz,
5168 (void *)&cmd_gso_size_size,
5173 /* *** SHOW GSO CONFIGURATION *** */
5174 struct cmd_gso_show_result {
5175 cmdline_fixed_string_t cmd_show;
5176 cmdline_fixed_string_t cmd_port;
5177 cmdline_fixed_string_t cmd_keyword;
5182 cmd_gso_show_parsed(void *parsed_result,
5183 __attribute__((unused)) struct cmdline *cl,
5184 __attribute__((unused)) void *data)
5186 struct cmd_gso_show_result *res = parsed_result;
5188 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5189 printf("invalid port id %u\n", res->cmd_pid);
5192 if (!strcmp(res->cmd_keyword, "gso")) {
5193 if (gso_ports[res->cmd_pid].enable) {
5194 printf("Max GSO'd packet size: %uB\n"
5195 "Supported GSO types: TCP/IPv4, "
5196 "UDP/IPv4, VxLAN with inner "
5197 "TCP/IPv4 packet, GRE with inner "
5198 "TCP/IPv4 packet\n",
5199 gso_max_segment_size);
5201 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5205 cmdline_parse_token_string_t cmd_gso_show_show =
5206 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5208 cmdline_parse_token_string_t cmd_gso_show_port =
5209 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5211 cmdline_parse_token_string_t cmd_gso_show_keyword =
5212 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5213 cmd_keyword, "gso");
5214 cmdline_parse_token_num_t cmd_gso_show_pid =
5215 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5218 cmdline_parse_inst_t cmd_gso_show = {
5219 .f = cmd_gso_show_parsed,
5221 .help_str = "show port <port_id> gso",
5223 (void *)&cmd_gso_show_show,
5224 (void *)&cmd_gso_show_port,
5225 (void *)&cmd_gso_show_pid,
5226 (void *)&cmd_gso_show_keyword,
5231 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5232 struct cmd_set_flush_rx {
5233 cmdline_fixed_string_t set;
5234 cmdline_fixed_string_t flush_rx;
5235 cmdline_fixed_string_t mode;
5239 cmd_set_flush_rx_parsed(void *parsed_result,
5240 __attribute__((unused)) struct cmdline *cl,
5241 __attribute__((unused)) void *data)
5243 struct cmd_set_flush_rx *res = parsed_result;
5244 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5247 cmdline_parse_token_string_t cmd_setflushrx_set =
5248 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5250 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5251 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5252 flush_rx, "flush_rx");
5253 cmdline_parse_token_string_t cmd_setflushrx_mode =
5254 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5258 cmdline_parse_inst_t cmd_set_flush_rx = {
5259 .f = cmd_set_flush_rx_parsed,
5260 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5263 (void *)&cmd_setflushrx_set,
5264 (void *)&cmd_setflushrx_flush_rx,
5265 (void *)&cmd_setflushrx_mode,
5270 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5271 struct cmd_set_link_check {
5272 cmdline_fixed_string_t set;
5273 cmdline_fixed_string_t link_check;
5274 cmdline_fixed_string_t mode;
5278 cmd_set_link_check_parsed(void *parsed_result,
5279 __attribute__((unused)) struct cmdline *cl,
5280 __attribute__((unused)) void *data)
5282 struct cmd_set_link_check *res = parsed_result;
5283 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5286 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5287 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5289 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5290 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5291 link_check, "link_check");
5292 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5293 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5297 cmdline_parse_inst_t cmd_set_link_check = {
5298 .f = cmd_set_link_check_parsed,
5299 .help_str = "set link_check on|off: Enable/Disable link status check "
5300 "when starting/stopping a port",
5303 (void *)&cmd_setlinkcheck_set,
5304 (void *)&cmd_setlinkcheck_link_check,
5305 (void *)&cmd_setlinkcheck_mode,
5310 /* *** SET NIC BYPASS MODE *** */
5311 struct cmd_set_bypass_mode_result {
5312 cmdline_fixed_string_t set;
5313 cmdline_fixed_string_t bypass;
5314 cmdline_fixed_string_t mode;
5315 cmdline_fixed_string_t value;
5320 cmd_set_bypass_mode_parsed(void *parsed_result,
5321 __attribute__((unused)) struct cmdline *cl,
5322 __attribute__((unused)) void *data)
5324 struct cmd_set_bypass_mode_result *res = parsed_result;
5325 portid_t port_id = res->port_id;
5326 int32_t rc = -EINVAL;
5328 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5329 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5331 if (!strcmp(res->value, "bypass"))
5332 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5333 else if (!strcmp(res->value, "isolate"))
5334 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5336 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5338 /* Set the bypass mode for the relevant port. */
5339 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5342 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5345 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5346 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5348 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5349 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5351 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5352 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5354 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5355 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5356 value, "normal#bypass#isolate");
5357 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5358 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5361 cmdline_parse_inst_t cmd_set_bypass_mode = {
5362 .f = cmd_set_bypass_mode_parsed,
5363 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5364 "Set the NIC bypass mode for port_id",
5367 (void *)&cmd_setbypass_mode_set,
5368 (void *)&cmd_setbypass_mode_bypass,
5369 (void *)&cmd_setbypass_mode_mode,
5370 (void *)&cmd_setbypass_mode_value,
5371 (void *)&cmd_setbypass_mode_port,
5376 /* *** SET NIC BYPASS EVENT *** */
5377 struct cmd_set_bypass_event_result {
5378 cmdline_fixed_string_t set;
5379 cmdline_fixed_string_t bypass;
5380 cmdline_fixed_string_t event;
5381 cmdline_fixed_string_t event_value;
5382 cmdline_fixed_string_t mode;
5383 cmdline_fixed_string_t mode_value;
5388 cmd_set_bypass_event_parsed(void *parsed_result,
5389 __attribute__((unused)) struct cmdline *cl,
5390 __attribute__((unused)) void *data)
5392 int32_t rc = -EINVAL;
5393 struct cmd_set_bypass_event_result *res = parsed_result;
5394 portid_t port_id = res->port_id;
5396 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5397 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5398 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5400 if (!strcmp(res->event_value, "timeout"))
5401 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5402 else if (!strcmp(res->event_value, "os_on"))
5403 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5404 else if (!strcmp(res->event_value, "os_off"))
5405 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5406 else if (!strcmp(res->event_value, "power_on"))
5407 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5408 else if (!strcmp(res->event_value, "power_off"))
5409 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5411 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5413 if (!strcmp(res->mode_value, "bypass"))
5414 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5415 else if (!strcmp(res->mode_value, "isolate"))
5416 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5418 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5420 /* Set the watchdog timeout. */
5421 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5424 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5425 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5429 printf("Failed to set timeout value %u "
5430 "for port %d, errto code: %d.\n",
5431 bypass_timeout, port_id, rc);
5435 /* Set the bypass event to transition to bypass mode. */
5436 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5441 printf("\t Failed to set bypass event for port = %d.\n",
5445 cmdline_parse_token_string_t cmd_setbypass_event_set =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5448 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5451 cmdline_parse_token_string_t cmd_setbypass_event_event =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5454 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5455 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5456 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5457 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5458 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5460 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5461 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5462 mode_value, "normal#bypass#isolate");
5463 cmdline_parse_token_num_t cmd_setbypass_event_port =
5464 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5467 cmdline_parse_inst_t cmd_set_bypass_event = {
5468 .f = cmd_set_bypass_event_parsed,
5469 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5470 "power_off mode normal|bypass|isolate <port_id>: "
5471 "Set the NIC bypass event mode for port_id",
5474 (void *)&cmd_setbypass_event_set,
5475 (void *)&cmd_setbypass_event_bypass,
5476 (void *)&cmd_setbypass_event_event,
5477 (void *)&cmd_setbypass_event_event_value,
5478 (void *)&cmd_setbypass_event_mode,
5479 (void *)&cmd_setbypass_event_mode_value,
5480 (void *)&cmd_setbypass_event_port,
5486 /* *** SET NIC BYPASS TIMEOUT *** */
5487 struct cmd_set_bypass_timeout_result {
5488 cmdline_fixed_string_t set;
5489 cmdline_fixed_string_t bypass;
5490 cmdline_fixed_string_t timeout;
5491 cmdline_fixed_string_t value;
5495 cmd_set_bypass_timeout_parsed(void *parsed_result,
5496 __attribute__((unused)) struct cmdline *cl,
5497 __attribute__((unused)) void *data)
5499 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5501 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5502 if (!strcmp(res->value, "1.5"))
5503 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5504 else if (!strcmp(res->value, "2"))
5505 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5506 else if (!strcmp(res->value, "3"))
5507 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5508 else if (!strcmp(res->value, "4"))
5509 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5510 else if (!strcmp(res->value, "8"))
5511 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5512 else if (!strcmp(res->value, "16"))
5513 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5514 else if (!strcmp(res->value, "32"))
5515 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5517 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5521 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5522 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5524 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5525 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5527 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5528 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5529 timeout, "timeout");
5530 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5531 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5532 value, "0#1.5#2#3#4#8#16#32");
5534 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5535 .f = cmd_set_bypass_timeout_parsed,
5536 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5537 "Set the NIC bypass watchdog timeout in seconds",
5540 (void *)&cmd_setbypass_timeout_set,
5541 (void *)&cmd_setbypass_timeout_bypass,
5542 (void *)&cmd_setbypass_timeout_timeout,
5543 (void *)&cmd_setbypass_timeout_value,
5548 /* *** SHOW NIC BYPASS MODE *** */
5549 struct cmd_show_bypass_config_result {
5550 cmdline_fixed_string_t show;
5551 cmdline_fixed_string_t bypass;
5552 cmdline_fixed_string_t config;
5557 cmd_show_bypass_config_parsed(void *parsed_result,
5558 __attribute__((unused)) struct cmdline *cl,
5559 __attribute__((unused)) void *data)
5561 struct cmd_show_bypass_config_result *res = parsed_result;
5562 portid_t port_id = res->port_id;
5564 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5565 uint32_t event_mode;
5566 uint32_t bypass_mode;
5567 uint32_t timeout = bypass_timeout;
5570 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5571 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5572 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5573 {"UNKNOWN", "normal", "bypass", "isolate"};
5574 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5582 /* Display the bypass mode.*/
5583 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5584 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5588 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5589 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5591 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5594 /* Display the bypass timeout.*/
5595 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5596 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5598 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5600 /* Display the bypass events and associated modes. */
5601 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5603 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5604 printf("\tFailed to get bypass mode for event = %s\n",
5607 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5608 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5610 printf("\tbypass event: %-16s = %s\n", events[i],
5616 printf("\tFailed to get bypass configuration for port = %d\n",
5620 cmdline_parse_token_string_t cmd_showbypass_config_show =
5621 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5623 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5624 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5626 cmdline_parse_token_string_t cmd_showbypass_config_config =
5627 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5629 cmdline_parse_token_num_t cmd_showbypass_config_port =
5630 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5633 cmdline_parse_inst_t cmd_show_bypass_config = {
5634 .f = cmd_show_bypass_config_parsed,
5635 .help_str = "show bypass config <port_id>: "
5636 "Show the NIC bypass config for port_id",
5639 (void *)&cmd_showbypass_config_show,
5640 (void *)&cmd_showbypass_config_bypass,
5641 (void *)&cmd_showbypass_config_config,
5642 (void *)&cmd_showbypass_config_port,
5647 #ifdef RTE_LIBRTE_PMD_BOND
5648 /* *** SET BONDING MODE *** */
5649 struct cmd_set_bonding_mode_result {
5650 cmdline_fixed_string_t set;
5651 cmdline_fixed_string_t bonding;
5652 cmdline_fixed_string_t mode;
5657 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5658 __attribute__((unused)) struct cmdline *cl,
5659 __attribute__((unused)) void *data)
5661 struct cmd_set_bonding_mode_result *res = parsed_result;
5662 portid_t port_id = res->port_id;
5664 /* Set the bonding mode for the relevant port. */
5665 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5666 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5669 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5670 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5672 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5673 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5674 bonding, "bonding");
5675 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5678 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5679 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5681 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5682 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5685 cmdline_parse_inst_t cmd_set_bonding_mode = {
5686 .f = cmd_set_bonding_mode_parsed,
5687 .help_str = "set bonding mode <mode_value> <port_id>: "
5688 "Set the bonding mode for port_id",
5691 (void *) &cmd_setbonding_mode_set,
5692 (void *) &cmd_setbonding_mode_bonding,
5693 (void *) &cmd_setbonding_mode_mode,
5694 (void *) &cmd_setbonding_mode_value,
5695 (void *) &cmd_setbonding_mode_port,
5700 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5701 struct cmd_set_bonding_lacp_dedicated_queues_result {
5702 cmdline_fixed_string_t set;
5703 cmdline_fixed_string_t bonding;
5704 cmdline_fixed_string_t lacp;
5705 cmdline_fixed_string_t dedicated_queues;
5707 cmdline_fixed_string_t mode;
5710 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5711 __attribute__((unused)) struct cmdline *cl,
5712 __attribute__((unused)) void *data)
5714 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5715 portid_t port_id = res->port_id;
5716 struct rte_port *port;
5718 port = &ports[port_id];
5720 /** Check if the port is not started **/
5721 if (port->port_status != RTE_PORT_STOPPED) {
5722 printf("Please stop port %d first\n", port_id);
5726 if (!strcmp(res->mode, "enable")) {
5727 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5728 printf("Dedicate queues for LACP control packets"
5731 printf("Enabling dedicate queues for LACP control "
5732 "packets on port %d failed\n", port_id);
5733 } else if (!strcmp(res->mode, "disable")) {
5734 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5735 printf("Dedicated queues for LACP control packets "
5738 printf("Disabling dedicated queues for LACP control "
5739 "traffic on port %d failed\n", port_id);
5743 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5746 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5748 bonding, "bonding");
5749 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5752 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5754 dedicated_queues, "dedicated_queues");
5755 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5756 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5758 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5759 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5760 mode, "enable#disable");
5762 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5763 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5764 .help_str = "set bonding lacp dedicated_queues <port_id> "
5766 "Enable/disable dedicated queues for LACP control traffic for port_id",
5769 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5770 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5771 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5772 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5773 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5774 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5779 /* *** SET BALANCE XMIT POLICY *** */
5780 struct cmd_set_bonding_balance_xmit_policy_result {
5781 cmdline_fixed_string_t set;
5782 cmdline_fixed_string_t bonding;
5783 cmdline_fixed_string_t balance_xmit_policy;
5785 cmdline_fixed_string_t policy;
5788 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5789 __attribute__((unused)) struct cmdline *cl,
5790 __attribute__((unused)) void *data)
5792 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5793 portid_t port_id = res->port_id;
5796 if (!strcmp(res->policy, "l2")) {
5797 policy = BALANCE_XMIT_POLICY_LAYER2;
5798 } else if (!strcmp(res->policy, "l23")) {
5799 policy = BALANCE_XMIT_POLICY_LAYER23;
5800 } else if (!strcmp(res->policy, "l34")) {
5801 policy = BALANCE_XMIT_POLICY_LAYER34;
5803 printf("\t Invalid xmit policy selection");
5807 /* Set the bonding mode for the relevant port. */
5808 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5809 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5814 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5817 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5818 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5819 bonding, "bonding");
5820 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5821 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5822 balance_xmit_policy, "balance_xmit_policy");
5823 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5824 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5826 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5827 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5828 policy, "l2#l23#l34");
5830 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5831 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5832 .help_str = "set bonding balance_xmit_policy <port_id> "
5834 "Set the bonding balance_xmit_policy for port_id",
5837 (void *)&cmd_setbonding_balance_xmit_policy_set,
5838 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5839 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5840 (void *)&cmd_setbonding_balance_xmit_policy_port,
5841 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5846 /* *** SHOW NIC BONDING CONFIGURATION *** */
5847 struct cmd_show_bonding_config_result {
5848 cmdline_fixed_string_t show;
5849 cmdline_fixed_string_t bonding;
5850 cmdline_fixed_string_t config;
5854 static void cmd_show_bonding_config_parsed(void *parsed_result,
5855 __attribute__((unused)) struct cmdline *cl,
5856 __attribute__((unused)) void *data)
5858 struct cmd_show_bonding_config_result *res = parsed_result;
5859 int bonding_mode, agg_mode;
5860 portid_t slaves[RTE_MAX_ETHPORTS];
5861 int num_slaves, num_active_slaves;
5864 portid_t port_id = res->port_id;
5866 /* Display the bonding mode.*/
5867 bonding_mode = rte_eth_bond_mode_get(port_id);
5868 if (bonding_mode < 0) {
5869 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5872 printf("\tBonding mode: %d\n", bonding_mode);
5874 if (bonding_mode == BONDING_MODE_BALANCE) {
5875 int balance_xmit_policy;
5877 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5878 if (balance_xmit_policy < 0) {
5879 printf("\tFailed to get balance xmit policy for port = %d\n",
5883 printf("\tBalance Xmit Policy: ");
5885 switch (balance_xmit_policy) {
5886 case BALANCE_XMIT_POLICY_LAYER2:
5887 printf("BALANCE_XMIT_POLICY_LAYER2");
5889 case BALANCE_XMIT_POLICY_LAYER23:
5890 printf("BALANCE_XMIT_POLICY_LAYER23");
5892 case BALANCE_XMIT_POLICY_LAYER34:
5893 printf("BALANCE_XMIT_POLICY_LAYER34");
5900 if (bonding_mode == BONDING_MODE_8023AD) {
5901 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5902 printf("\tIEEE802.3AD Aggregator Mode: ");
5905 printf("bandwidth");
5917 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5919 if (num_slaves < 0) {
5920 printf("\tFailed to get slave list for port = %d\n", port_id);
5923 if (num_slaves > 0) {
5924 printf("\tSlaves (%d): [", num_slaves);
5925 for (i = 0; i < num_slaves - 1; i++)
5926 printf("%d ", slaves[i]);
5928 printf("%d]\n", slaves[num_slaves - 1]);
5930 printf("\tSlaves: []\n");
5934 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5937 if (num_active_slaves < 0) {
5938 printf("\tFailed to get active slave list for port = %d\n", port_id);
5941 if (num_active_slaves > 0) {
5942 printf("\tActive Slaves (%d): [", num_active_slaves);
5943 for (i = 0; i < num_active_slaves - 1; i++)
5944 printf("%d ", slaves[i]);
5946 printf("%d]\n", slaves[num_active_slaves - 1]);
5949 printf("\tActive Slaves: []\n");
5953 primary_id = rte_eth_bond_primary_get(port_id);
5954 if (primary_id < 0) {
5955 printf("\tFailed to get primary slave for port = %d\n", port_id);
5958 printf("\tPrimary: [%d]\n", primary_id);
5962 cmdline_parse_token_string_t cmd_showbonding_config_show =
5963 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5965 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5966 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5967 bonding, "bonding");
5968 cmdline_parse_token_string_t cmd_showbonding_config_config =
5969 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5971 cmdline_parse_token_num_t cmd_showbonding_config_port =
5972 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5975 cmdline_parse_inst_t cmd_show_bonding_config = {
5976 .f = cmd_show_bonding_config_parsed,
5977 .help_str = "show bonding config <port_id>: "
5978 "Show the bonding config for port_id",
5981 (void *)&cmd_showbonding_config_show,
5982 (void *)&cmd_showbonding_config_bonding,
5983 (void *)&cmd_showbonding_config_config,
5984 (void *)&cmd_showbonding_config_port,
5989 /* *** SET BONDING PRIMARY *** */
5990 struct cmd_set_bonding_primary_result {
5991 cmdline_fixed_string_t set;
5992 cmdline_fixed_string_t bonding;
5993 cmdline_fixed_string_t primary;
5998 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5999 __attribute__((unused)) struct cmdline *cl,
6000 __attribute__((unused)) void *data)
6002 struct cmd_set_bonding_primary_result *res = parsed_result;
6003 portid_t master_port_id = res->port_id;
6004 portid_t slave_port_id = res->slave_id;
6006 /* Set the primary slave for a bonded device. */
6007 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6008 printf("\t Failed to set primary slave for port = %d.\n",
6015 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6018 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6020 bonding, "bonding");
6021 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6023 primary, "primary");
6024 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6025 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6027 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6028 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6031 cmdline_parse_inst_t cmd_set_bonding_primary = {
6032 .f = cmd_set_bonding_primary_parsed,
6033 .help_str = "set bonding primary <slave_id> <port_id>: "
6034 "Set the primary slave for port_id",
6037 (void *)&cmd_setbonding_primary_set,
6038 (void *)&cmd_setbonding_primary_bonding,
6039 (void *)&cmd_setbonding_primary_primary,
6040 (void *)&cmd_setbonding_primary_slave,
6041 (void *)&cmd_setbonding_primary_port,
6046 /* *** ADD SLAVE *** */
6047 struct cmd_add_bonding_slave_result {
6048 cmdline_fixed_string_t add;
6049 cmdline_fixed_string_t bonding;
6050 cmdline_fixed_string_t slave;
6055 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6056 __attribute__((unused)) struct cmdline *cl,
6057 __attribute__((unused)) void *data)
6059 struct cmd_add_bonding_slave_result *res = parsed_result;
6060 portid_t master_port_id = res->port_id;
6061 portid_t slave_port_id = res->slave_id;
6063 /* add the slave for a bonded device. */
6064 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6065 printf("\t Failed to add slave %d to master port = %d.\n",
6066 slave_port_id, master_port_id);
6070 set_port_slave_flag(slave_port_id);
6073 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6074 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6076 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6077 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6078 bonding, "bonding");
6079 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6080 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6082 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6083 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6085 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6086 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6089 cmdline_parse_inst_t cmd_add_bonding_slave = {
6090 .f = cmd_add_bonding_slave_parsed,
6091 .help_str = "add bonding slave <slave_id> <port_id>: "
6092 "Add a slave device to a bonded device",
6095 (void *)&cmd_addbonding_slave_add,
6096 (void *)&cmd_addbonding_slave_bonding,
6097 (void *)&cmd_addbonding_slave_slave,
6098 (void *)&cmd_addbonding_slave_slaveid,
6099 (void *)&cmd_addbonding_slave_port,
6104 /* *** REMOVE SLAVE *** */
6105 struct cmd_remove_bonding_slave_result {
6106 cmdline_fixed_string_t remove;
6107 cmdline_fixed_string_t bonding;
6108 cmdline_fixed_string_t slave;
6113 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6114 __attribute__((unused)) struct cmdline *cl,
6115 __attribute__((unused)) void *data)
6117 struct cmd_remove_bonding_slave_result *res = parsed_result;
6118 portid_t master_port_id = res->port_id;
6119 portid_t slave_port_id = res->slave_id;
6121 /* remove the slave from a bonded device. */
6122 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6123 printf("\t Failed to remove slave %d from master port = %d.\n",
6124 slave_port_id, master_port_id);
6128 clear_port_slave_flag(slave_port_id);
6131 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6132 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6134 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6135 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6136 bonding, "bonding");
6137 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6138 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6140 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6141 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6143 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6144 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6147 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6148 .f = cmd_remove_bonding_slave_parsed,
6149 .help_str = "remove bonding slave <slave_id> <port_id>: "
6150 "Remove a slave device from a bonded device",
6153 (void *)&cmd_removebonding_slave_remove,
6154 (void *)&cmd_removebonding_slave_bonding,
6155 (void *)&cmd_removebonding_slave_slave,
6156 (void *)&cmd_removebonding_slave_slaveid,
6157 (void *)&cmd_removebonding_slave_port,
6162 /* *** CREATE BONDED DEVICE *** */
6163 struct cmd_create_bonded_device_result {
6164 cmdline_fixed_string_t create;
6165 cmdline_fixed_string_t bonded;
6166 cmdline_fixed_string_t device;
6171 static int bond_dev_num = 0;
6173 static void cmd_create_bonded_device_parsed(void *parsed_result,
6174 __attribute__((unused)) struct cmdline *cl,
6175 __attribute__((unused)) void *data)
6177 struct cmd_create_bonded_device_result *res = parsed_result;
6178 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6182 if (test_done == 0) {
6183 printf("Please stop forwarding first\n");
6187 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6190 /* Create a new bonded device. */
6191 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6193 printf("\t Failed to create bonded device.\n");
6196 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6199 /* Update number of ports */
6200 nb_ports = rte_eth_dev_count_avail();
6201 reconfig(port_id, res->socket);
6202 ret = rte_eth_promiscuous_enable(port_id);
6204 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6205 port_id, rte_strerror(-ret));
6207 ports[port_id].need_setup = 0;
6208 ports[port_id].port_status = RTE_PORT_STOPPED;
6213 cmdline_parse_token_string_t cmd_createbonded_device_create =
6214 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6216 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6217 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6219 cmdline_parse_token_string_t cmd_createbonded_device_device =
6220 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6222 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6223 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6225 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6226 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6229 cmdline_parse_inst_t cmd_create_bonded_device = {
6230 .f = cmd_create_bonded_device_parsed,
6231 .help_str = "create bonded device <mode> <socket>: "
6232 "Create a new bonded device with specific bonding mode and socket",
6235 (void *)&cmd_createbonded_device_create,
6236 (void *)&cmd_createbonded_device_bonded,
6237 (void *)&cmd_createbonded_device_device,
6238 (void *)&cmd_createbonded_device_mode,
6239 (void *)&cmd_createbonded_device_socket,
6244 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6245 struct cmd_set_bond_mac_addr_result {
6246 cmdline_fixed_string_t set;
6247 cmdline_fixed_string_t bonding;
6248 cmdline_fixed_string_t mac_addr;
6250 struct rte_ether_addr address;
6253 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6254 __attribute__((unused)) struct cmdline *cl,
6255 __attribute__((unused)) void *data)
6257 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6260 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6263 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6265 /* check the return value and print it if is < 0 */
6267 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6270 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6271 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6272 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6275 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6276 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6278 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6279 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6281 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6282 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6284 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6285 .f = cmd_set_bond_mac_addr_parsed,
6287 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6289 (void *)&cmd_set_bond_mac_addr_set,
6290 (void *)&cmd_set_bond_mac_addr_bonding,
6291 (void *)&cmd_set_bond_mac_addr_mac,
6292 (void *)&cmd_set_bond_mac_addr_portnum,
6293 (void *)&cmd_set_bond_mac_addr_addr,
6299 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6300 struct cmd_set_bond_mon_period_result {
6301 cmdline_fixed_string_t set;
6302 cmdline_fixed_string_t bonding;
6303 cmdline_fixed_string_t mon_period;
6308 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6309 __attribute__((unused)) struct cmdline *cl,
6310 __attribute__((unused)) void *data)
6312 struct cmd_set_bond_mon_period_result *res = parsed_result;
6315 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6317 /* check the return value and print it if is < 0 */
6319 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6322 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6323 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6325 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6326 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6327 bonding, "bonding");
6328 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6329 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6330 mon_period, "mon_period");
6331 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6332 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6334 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6335 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6338 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6339 .f = cmd_set_bond_mon_period_parsed,
6341 .help_str = "set bonding mon_period <port_id> <period_ms>",
6343 (void *)&cmd_set_bond_mon_period_set,
6344 (void *)&cmd_set_bond_mon_period_bonding,
6345 (void *)&cmd_set_bond_mon_period_mon_period,
6346 (void *)&cmd_set_bond_mon_period_portnum,
6347 (void *)&cmd_set_bond_mon_period_period_ms,
6354 struct cmd_set_bonding_agg_mode_policy_result {
6355 cmdline_fixed_string_t set;
6356 cmdline_fixed_string_t bonding;
6357 cmdline_fixed_string_t agg_mode;
6359 cmdline_fixed_string_t policy;
6364 cmd_set_bonding_agg_mode(void *parsed_result,
6365 __attribute__((unused)) struct cmdline *cl,
6366 __attribute__((unused)) void *data)
6368 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6369 uint8_t policy = AGG_BANDWIDTH;
6371 if (!strcmp(res->policy, "bandwidth"))
6372 policy = AGG_BANDWIDTH;
6373 else if (!strcmp(res->policy, "stable"))
6374 policy = AGG_STABLE;
6375 else if (!strcmp(res->policy, "count"))
6378 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6382 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6383 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6385 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6386 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6387 bonding, "bonding");
6389 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6390 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6391 agg_mode, "agg_mode");
6393 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6394 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6397 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6398 TOKEN_STRING_INITIALIZER(
6399 struct cmd_set_bonding_balance_xmit_policy_result,
6400 policy, "stable#bandwidth#count");
6402 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6403 .f = cmd_set_bonding_agg_mode,
6405 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6407 (void *)&cmd_set_bonding_agg_mode_set,
6408 (void *)&cmd_set_bonding_agg_mode_bonding,
6409 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6410 (void *)&cmd_set_bonding_agg_mode_portnum,
6411 (void *)&cmd_set_bonding_agg_mode_policy_string,
6417 #endif /* RTE_LIBRTE_PMD_BOND */
6419 /* *** SET FORWARDING MODE *** */
6420 struct cmd_set_fwd_mode_result {
6421 cmdline_fixed_string_t set;
6422 cmdline_fixed_string_t fwd;
6423 cmdline_fixed_string_t mode;
6426 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6427 __attribute__((unused)) struct cmdline *cl,
6428 __attribute__((unused)) void *data)
6430 struct cmd_set_fwd_mode_result *res = parsed_result;
6433 set_pkt_forwarding_mode(res->mode);
6436 cmdline_parse_token_string_t cmd_setfwd_set =
6437 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6438 cmdline_parse_token_string_t cmd_setfwd_fwd =
6439 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6440 cmdline_parse_token_string_t cmd_setfwd_mode =
6441 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6442 "" /* defined at init */);
6444 cmdline_parse_inst_t cmd_set_fwd_mode = {
6445 .f = cmd_set_fwd_mode_parsed,
6447 .help_str = NULL, /* defined at init */
6449 (void *)&cmd_setfwd_set,
6450 (void *)&cmd_setfwd_fwd,
6451 (void *)&cmd_setfwd_mode,
6456 static void cmd_set_fwd_mode_init(void)
6459 static char token[128];
6460 static char help[256];
6461 cmdline_parse_token_string_t *token_struct;
6463 modes = list_pkt_forwarding_modes();
6464 snprintf(help, sizeof(help), "set fwd %s: "
6465 "Set packet forwarding mode", modes);
6466 cmd_set_fwd_mode.help_str = help;
6468 /* string token separator is # */
6469 for (c = token; *modes != '\0'; modes++)
6474 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6475 token_struct->string_data.str = token;
6478 /* *** SET RETRY FORWARDING MODE *** */
6479 struct cmd_set_fwd_retry_mode_result {
6480 cmdline_fixed_string_t set;
6481 cmdline_fixed_string_t fwd;
6482 cmdline_fixed_string_t mode;
6483 cmdline_fixed_string_t retry;
6486 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6487 __attribute__((unused)) struct cmdline *cl,
6488 __attribute__((unused)) void *data)
6490 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6493 set_pkt_forwarding_mode(res->mode);
6496 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6497 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6499 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6502 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6505 "" /* defined at init */);
6506 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6507 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6510 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6511 .f = cmd_set_fwd_retry_mode_parsed,
6513 .help_str = NULL, /* defined at init */
6515 (void *)&cmd_setfwd_retry_set,
6516 (void *)&cmd_setfwd_retry_fwd,
6517 (void *)&cmd_setfwd_retry_mode,
6518 (void *)&cmd_setfwd_retry_retry,
6523 static void cmd_set_fwd_retry_mode_init(void)
6526 static char token[128];
6527 static char help[256];
6528 cmdline_parse_token_string_t *token_struct;
6530 modes = list_pkt_forwarding_retry_modes();
6531 snprintf(help, sizeof(help), "set fwd %s retry: "
6532 "Set packet forwarding mode with retry", modes);
6533 cmd_set_fwd_retry_mode.help_str = help;
6535 /* string token separator is # */
6536 for (c = token; *modes != '\0'; modes++)
6541 token_struct = (cmdline_parse_token_string_t *)
6542 cmd_set_fwd_retry_mode.tokens[2];
6543 token_struct->string_data.str = token;
6546 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6547 struct cmd_set_burst_tx_retry_result {
6548 cmdline_fixed_string_t set;
6549 cmdline_fixed_string_t burst;
6550 cmdline_fixed_string_t tx;
6551 cmdline_fixed_string_t delay;
6553 cmdline_fixed_string_t retry;
6557 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6558 __attribute__((unused)) struct cmdline *cl,
6559 __attribute__((unused)) void *data)
6561 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6563 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6564 && !strcmp(res->tx, "tx")) {
6565 if (!strcmp(res->delay, "delay"))
6566 burst_tx_delay_time = res->time;
6567 if (!strcmp(res->retry, "retry"))
6568 burst_tx_retry_num = res->retry_num;
6573 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6574 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6575 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6578 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6579 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6580 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6581 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6582 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6583 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6584 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6585 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6586 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6587 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6589 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6590 .f = cmd_set_burst_tx_retry_parsed,
6591 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6593 (void *)&cmd_set_burst_tx_retry_set,
6594 (void *)&cmd_set_burst_tx_retry_burst,
6595 (void *)&cmd_set_burst_tx_retry_tx,
6596 (void *)&cmd_set_burst_tx_retry_delay,
6597 (void *)&cmd_set_burst_tx_retry_time,
6598 (void *)&cmd_set_burst_tx_retry_retry,
6599 (void *)&cmd_set_burst_tx_retry_retry_num,
6604 /* *** SET PROMISC MODE *** */
6605 struct cmd_set_promisc_mode_result {
6606 cmdline_fixed_string_t set;
6607 cmdline_fixed_string_t promisc;
6608 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6609 uint16_t port_num; /* valid if "allports" argument == 0 */
6610 cmdline_fixed_string_t mode;
6613 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6614 __attribute__((unused)) struct cmdline *cl,
6617 struct cmd_set_promisc_mode_result *res = parsed_result;
6621 if (!strcmp(res->mode, "on"))
6628 RTE_ETH_FOREACH_DEV(i)
6629 eth_set_promisc_mode(i, enable);
6631 eth_set_promisc_mode(res->port_num, enable);
6635 cmdline_parse_token_string_t cmd_setpromisc_set =
6636 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6637 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6638 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6640 cmdline_parse_token_string_t cmd_setpromisc_portall =
6641 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6643 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6644 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6646 cmdline_parse_token_string_t cmd_setpromisc_mode =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6650 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6651 .f = cmd_set_promisc_mode_parsed,
6653 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6655 (void *)&cmd_setpromisc_set,
6656 (void *)&cmd_setpromisc_promisc,
6657 (void *)&cmd_setpromisc_portall,
6658 (void *)&cmd_setpromisc_mode,
6663 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6664 .f = cmd_set_promisc_mode_parsed,
6666 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6668 (void *)&cmd_setpromisc_set,
6669 (void *)&cmd_setpromisc_promisc,
6670 (void *)&cmd_setpromisc_portnum,
6671 (void *)&cmd_setpromisc_mode,
6676 /* *** SET ALLMULTI MODE *** */
6677 struct cmd_set_allmulti_mode_result {
6678 cmdline_fixed_string_t set;
6679 cmdline_fixed_string_t allmulti;
6680 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6681 uint16_t port_num; /* valid if "allports" argument == 0 */
6682 cmdline_fixed_string_t mode;
6685 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6686 __attribute__((unused)) struct cmdline *cl,
6689 struct cmd_set_allmulti_mode_result *res = parsed_result;
6693 if (!strcmp(res->mode, "on"))
6700 RTE_ETH_FOREACH_DEV(i) {
6701 eth_set_allmulticast_mode(i, enable);
6705 eth_set_allmulticast_mode(res->port_num, enable);
6709 cmdline_parse_token_string_t cmd_setallmulti_set =
6710 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6711 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6714 cmdline_parse_token_string_t cmd_setallmulti_portall =
6715 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6717 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6718 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6720 cmdline_parse_token_string_t cmd_setallmulti_mode =
6721 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6724 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6725 .f = cmd_set_allmulti_mode_parsed,
6727 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6729 (void *)&cmd_setallmulti_set,
6730 (void *)&cmd_setallmulti_allmulti,
6731 (void *)&cmd_setallmulti_portall,
6732 (void *)&cmd_setallmulti_mode,
6737 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6738 .f = cmd_set_allmulti_mode_parsed,
6740 .help_str = "set allmulti <port_id> on|off: "
6741 "Set allmulti mode on port_id",
6743 (void *)&cmd_setallmulti_set,
6744 (void *)&cmd_setallmulti_allmulti,
6745 (void *)&cmd_setallmulti_portnum,
6746 (void *)&cmd_setallmulti_mode,
6751 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6752 struct cmd_link_flow_ctrl_set_result {
6753 cmdline_fixed_string_t set;
6754 cmdline_fixed_string_t flow_ctrl;
6755 cmdline_fixed_string_t rx;
6756 cmdline_fixed_string_t rx_lfc_mode;
6757 cmdline_fixed_string_t tx;
6758 cmdline_fixed_string_t tx_lfc_mode;
6759 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6760 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6761 cmdline_fixed_string_t autoneg_str;
6762 cmdline_fixed_string_t autoneg;
6763 cmdline_fixed_string_t hw_str;
6764 uint32_t high_water;
6765 cmdline_fixed_string_t lw_str;
6767 cmdline_fixed_string_t pt_str;
6768 uint16_t pause_time;
6769 cmdline_fixed_string_t xon_str;
6774 cmdline_parse_token_string_t cmd_lfc_set_set =
6775 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6777 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6779 flow_ctrl, "flow_ctrl");
6780 cmdline_parse_token_string_t cmd_lfc_set_rx =
6781 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6783 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6784 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6785 rx_lfc_mode, "on#off");
6786 cmdline_parse_token_string_t cmd_lfc_set_tx =
6787 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6789 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6790 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6791 tx_lfc_mode, "on#off");
6792 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6793 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6794 hw_str, "high_water");
6795 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6796 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6797 high_water, UINT32);
6798 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6799 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6800 lw_str, "low_water");
6801 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6802 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6804 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6805 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6806 pt_str, "pause_time");
6807 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6808 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6809 pause_time, UINT16);
6810 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6811 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6812 xon_str, "send_xon");
6813 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6814 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6816 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6817 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6818 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6819 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6820 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6821 mac_ctrl_frame_fwd_mode, "on#off");
6822 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6823 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6824 autoneg_str, "autoneg");
6825 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6826 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6828 cmdline_parse_token_num_t cmd_lfc_set_portid =
6829 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6832 /* forward declaration */
6834 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6837 cmdline_parse_inst_t cmd_link_flow_control_set = {
6838 .f = cmd_link_flow_ctrl_set_parsed,
6840 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6841 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6842 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6844 (void *)&cmd_lfc_set_set,
6845 (void *)&cmd_lfc_set_flow_ctrl,
6846 (void *)&cmd_lfc_set_rx,
6847 (void *)&cmd_lfc_set_rx_mode,
6848 (void *)&cmd_lfc_set_tx,
6849 (void *)&cmd_lfc_set_tx_mode,
6850 (void *)&cmd_lfc_set_high_water,
6851 (void *)&cmd_lfc_set_low_water,
6852 (void *)&cmd_lfc_set_pause_time,
6853 (void *)&cmd_lfc_set_send_xon,
6854 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6855 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6856 (void *)&cmd_lfc_set_autoneg_str,
6857 (void *)&cmd_lfc_set_autoneg,
6858 (void *)&cmd_lfc_set_portid,
6863 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6864 .f = cmd_link_flow_ctrl_set_parsed,
6865 .data = (void *)&cmd_link_flow_control_set_rx,
6866 .help_str = "set flow_ctrl rx on|off <port_id>: "
6867 "Change rx flow control parameter",
6869 (void *)&cmd_lfc_set_set,
6870 (void *)&cmd_lfc_set_flow_ctrl,
6871 (void *)&cmd_lfc_set_rx,
6872 (void *)&cmd_lfc_set_rx_mode,
6873 (void *)&cmd_lfc_set_portid,
6878 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6879 .f = cmd_link_flow_ctrl_set_parsed,
6880 .data = (void *)&cmd_link_flow_control_set_tx,
6881 .help_str = "set flow_ctrl tx on|off <port_id>: "
6882 "Change tx flow control parameter",
6884 (void *)&cmd_lfc_set_set,
6885 (void *)&cmd_lfc_set_flow_ctrl,
6886 (void *)&cmd_lfc_set_tx,
6887 (void *)&cmd_lfc_set_tx_mode,
6888 (void *)&cmd_lfc_set_portid,
6893 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6894 .f = cmd_link_flow_ctrl_set_parsed,
6895 .data = (void *)&cmd_link_flow_control_set_hw,
6896 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6897 "Change high water flow control parameter",
6899 (void *)&cmd_lfc_set_set,
6900 (void *)&cmd_lfc_set_flow_ctrl,
6901 (void *)&cmd_lfc_set_high_water_str,
6902 (void *)&cmd_lfc_set_high_water,
6903 (void *)&cmd_lfc_set_portid,
6908 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6909 .f = cmd_link_flow_ctrl_set_parsed,
6910 .data = (void *)&cmd_link_flow_control_set_lw,
6911 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6912 "Change low water flow control parameter",
6914 (void *)&cmd_lfc_set_set,
6915 (void *)&cmd_lfc_set_flow_ctrl,
6916 (void *)&cmd_lfc_set_low_water_str,
6917 (void *)&cmd_lfc_set_low_water,
6918 (void *)&cmd_lfc_set_portid,
6923 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6924 .f = cmd_link_flow_ctrl_set_parsed,
6925 .data = (void *)&cmd_link_flow_control_set_pt,
6926 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6927 "Change pause time flow control parameter",
6929 (void *)&cmd_lfc_set_set,
6930 (void *)&cmd_lfc_set_flow_ctrl,
6931 (void *)&cmd_lfc_set_pause_time_str,
6932 (void *)&cmd_lfc_set_pause_time,
6933 (void *)&cmd_lfc_set_portid,
6938 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6939 .f = cmd_link_flow_ctrl_set_parsed,
6940 .data = (void *)&cmd_link_flow_control_set_xon,
6941 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6942 "Change send_xon flow control parameter",
6944 (void *)&cmd_lfc_set_set,
6945 (void *)&cmd_lfc_set_flow_ctrl,
6946 (void *)&cmd_lfc_set_send_xon_str,
6947 (void *)&cmd_lfc_set_send_xon,
6948 (void *)&cmd_lfc_set_portid,
6953 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6954 .f = cmd_link_flow_ctrl_set_parsed,
6955 .data = (void *)&cmd_link_flow_control_set_macfwd,
6956 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6957 "Change mac ctrl fwd flow control parameter",
6959 (void *)&cmd_lfc_set_set,
6960 (void *)&cmd_lfc_set_flow_ctrl,
6961 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6962 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6963 (void *)&cmd_lfc_set_portid,
6968 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6969 .f = cmd_link_flow_ctrl_set_parsed,
6970 .data = (void *)&cmd_link_flow_control_set_autoneg,
6971 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6972 "Change autoneg flow control parameter",
6974 (void *)&cmd_lfc_set_set,
6975 (void *)&cmd_lfc_set_flow_ctrl,
6976 (void *)&cmd_lfc_set_autoneg_str,
6977 (void *)&cmd_lfc_set_autoneg,
6978 (void *)&cmd_lfc_set_portid,
6984 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6985 __attribute__((unused)) struct cmdline *cl,
6988 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6989 cmdline_parse_inst_t *cmd = data;
6990 struct rte_eth_fc_conf fc_conf;
6996 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6997 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6998 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6999 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7001 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7002 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7005 /* Partial command line, retrieve current configuration */
7007 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7009 printf("cannot get current flow ctrl parameters, return"
7010 "code = %d\n", ret);
7014 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7015 (fc_conf.mode == RTE_FC_FULL))
7017 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7018 (fc_conf.mode == RTE_FC_FULL))
7022 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7023 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7025 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7026 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7028 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7030 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7031 fc_conf.high_water = res->high_water;
7033 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7034 fc_conf.low_water = res->low_water;
7036 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7037 fc_conf.pause_time = res->pause_time;
7039 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7040 fc_conf.send_xon = res->send_xon;
7042 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7043 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7044 fc_conf.mac_ctrl_frame_fwd = 1;
7046 fc_conf.mac_ctrl_frame_fwd = 0;
7049 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7050 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7052 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7054 printf("bad flow contrl parameter, return code = %d \n", ret);
7057 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7058 struct cmd_priority_flow_ctrl_set_result {
7059 cmdline_fixed_string_t set;
7060 cmdline_fixed_string_t pfc_ctrl;
7061 cmdline_fixed_string_t rx;
7062 cmdline_fixed_string_t rx_pfc_mode;
7063 cmdline_fixed_string_t tx;
7064 cmdline_fixed_string_t tx_pfc_mode;
7065 uint32_t high_water;
7067 uint16_t pause_time;
7073 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7074 __attribute__((unused)) struct cmdline *cl,
7075 __attribute__((unused)) void *data)
7077 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7078 struct rte_eth_pfc_conf pfc_conf;
7079 int rx_fc_enable, tx_fc_enable;
7083 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7084 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7085 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7086 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7088 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7089 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7092 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7093 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7094 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7095 pfc_conf.fc.high_water = res->high_water;
7096 pfc_conf.fc.low_water = res->low_water;
7097 pfc_conf.fc.pause_time = res->pause_time;
7098 pfc_conf.priority = res->priority;
7100 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7102 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7105 cmdline_parse_token_string_t cmd_pfc_set_set =
7106 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7108 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7109 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7110 pfc_ctrl, "pfc_ctrl");
7111 cmdline_parse_token_string_t cmd_pfc_set_rx =
7112 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7114 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7115 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7116 rx_pfc_mode, "on#off");
7117 cmdline_parse_token_string_t cmd_pfc_set_tx =
7118 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7120 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7121 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7122 tx_pfc_mode, "on#off");
7123 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7124 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7125 high_water, UINT32);
7126 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7127 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7129 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7130 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7131 pause_time, UINT16);
7132 cmdline_parse_token_num_t cmd_pfc_set_priority =
7133 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7135 cmdline_parse_token_num_t cmd_pfc_set_portid =
7136 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7139 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7140 .f = cmd_priority_flow_ctrl_set_parsed,
7142 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7143 "<pause_time> <priority> <port_id>: "
7144 "Configure the Ethernet priority flow control",
7146 (void *)&cmd_pfc_set_set,
7147 (void *)&cmd_pfc_set_flow_ctrl,
7148 (void *)&cmd_pfc_set_rx,
7149 (void *)&cmd_pfc_set_rx_mode,
7150 (void *)&cmd_pfc_set_tx,
7151 (void *)&cmd_pfc_set_tx_mode,
7152 (void *)&cmd_pfc_set_high_water,
7153 (void *)&cmd_pfc_set_low_water,
7154 (void *)&cmd_pfc_set_pause_time,
7155 (void *)&cmd_pfc_set_priority,
7156 (void *)&cmd_pfc_set_portid,
7161 /* *** RESET CONFIGURATION *** */
7162 struct cmd_reset_result {
7163 cmdline_fixed_string_t reset;
7164 cmdline_fixed_string_t def;
7167 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7169 __attribute__((unused)) void *data)
7171 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7172 set_def_fwd_config();
7175 cmdline_parse_token_string_t cmd_reset_set =
7176 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7177 cmdline_parse_token_string_t cmd_reset_def =
7178 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7181 cmdline_parse_inst_t cmd_reset = {
7182 .f = cmd_reset_parsed,
7184 .help_str = "set default: Reset default forwarding configuration",
7186 (void *)&cmd_reset_set,
7187 (void *)&cmd_reset_def,
7192 /* *** START FORWARDING *** */
7193 struct cmd_start_result {
7194 cmdline_fixed_string_t start;
7197 cmdline_parse_token_string_t cmd_start_start =
7198 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7200 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7201 __attribute__((unused)) struct cmdline *cl,
7202 __attribute__((unused)) void *data)
7204 start_packet_forwarding(0);
7207 cmdline_parse_inst_t cmd_start = {
7208 .f = cmd_start_parsed,
7210 .help_str = "start: Start packet forwarding",
7212 (void *)&cmd_start_start,
7217 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7218 struct cmd_start_tx_first_result {
7219 cmdline_fixed_string_t start;
7220 cmdline_fixed_string_t tx_first;
7224 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7225 __attribute__((unused)) struct cmdline *cl,
7226 __attribute__((unused)) void *data)
7228 start_packet_forwarding(1);
7231 cmdline_parse_token_string_t cmd_start_tx_first_start =
7232 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7234 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7235 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7236 tx_first, "tx_first");
7238 cmdline_parse_inst_t cmd_start_tx_first = {
7239 .f = cmd_start_tx_first_parsed,
7241 .help_str = "start tx_first: Start packet forwarding, "
7242 "after sending 1 burst of packets",
7244 (void *)&cmd_start_tx_first_start,
7245 (void *)&cmd_start_tx_first_tx_first,
7250 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7251 struct cmd_start_tx_first_n_result {
7252 cmdline_fixed_string_t start;
7253 cmdline_fixed_string_t tx_first;
7258 cmd_start_tx_first_n_parsed(void *parsed_result,
7259 __attribute__((unused)) struct cmdline *cl,
7260 __attribute__((unused)) void *data)
7262 struct cmd_start_tx_first_n_result *res = parsed_result;
7264 start_packet_forwarding(res->tx_num);
7267 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7268 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7270 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7271 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7272 tx_first, "tx_first");
7273 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7274 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7277 cmdline_parse_inst_t cmd_start_tx_first_n = {
7278 .f = cmd_start_tx_first_n_parsed,
7280 .help_str = "start tx_first <num>: "
7281 "packet forwarding, after sending <num> bursts of packets",
7283 (void *)&cmd_start_tx_first_n_start,
7284 (void *)&cmd_start_tx_first_n_tx_first,
7285 (void *)&cmd_start_tx_first_n_tx_num,
7290 /* *** SET LINK UP *** */
7291 struct cmd_set_link_up_result {
7292 cmdline_fixed_string_t set;
7293 cmdline_fixed_string_t link_up;
7294 cmdline_fixed_string_t port;
7298 cmdline_parse_token_string_t cmd_set_link_up_set =
7299 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7300 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7301 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7303 cmdline_parse_token_string_t cmd_set_link_up_port =
7304 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7305 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7306 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7308 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7309 __attribute__((unused)) struct cmdline *cl,
7310 __attribute__((unused)) void *data)
7312 struct cmd_set_link_up_result *res = parsed_result;
7313 dev_set_link_up(res->port_id);
7316 cmdline_parse_inst_t cmd_set_link_up = {
7317 .f = cmd_set_link_up_parsed,
7319 .help_str = "set link-up port <port id>",
7321 (void *)&cmd_set_link_up_set,
7322 (void *)&cmd_set_link_up_link_up,
7323 (void *)&cmd_set_link_up_port,
7324 (void *)&cmd_set_link_up_port_id,
7329 /* *** SET LINK DOWN *** */
7330 struct cmd_set_link_down_result {
7331 cmdline_fixed_string_t set;
7332 cmdline_fixed_string_t link_down;
7333 cmdline_fixed_string_t port;
7337 cmdline_parse_token_string_t cmd_set_link_down_set =
7338 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7339 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7340 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7342 cmdline_parse_token_string_t cmd_set_link_down_port =
7343 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7344 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7345 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7347 static void cmd_set_link_down_parsed(
7348 __attribute__((unused)) void *parsed_result,
7349 __attribute__((unused)) struct cmdline *cl,
7350 __attribute__((unused)) void *data)
7352 struct cmd_set_link_down_result *res = parsed_result;
7353 dev_set_link_down(res->port_id);
7356 cmdline_parse_inst_t cmd_set_link_down = {
7357 .f = cmd_set_link_down_parsed,
7359 .help_str = "set link-down port <port id>",
7361 (void *)&cmd_set_link_down_set,
7362 (void *)&cmd_set_link_down_link_down,
7363 (void *)&cmd_set_link_down_port,
7364 (void *)&cmd_set_link_down_port_id,
7369 /* *** SHOW CFG *** */
7370 struct cmd_showcfg_result {
7371 cmdline_fixed_string_t show;
7372 cmdline_fixed_string_t cfg;
7373 cmdline_fixed_string_t what;
7376 static void cmd_showcfg_parsed(void *parsed_result,
7377 __attribute__((unused)) struct cmdline *cl,
7378 __attribute__((unused)) void *data)
7380 struct cmd_showcfg_result *res = parsed_result;
7381 if (!strcmp(res->what, "rxtx"))
7382 rxtx_config_display();
7383 else if (!strcmp(res->what, "cores"))
7384 fwd_lcores_config_display();
7385 else if (!strcmp(res->what, "fwd"))
7386 pkt_fwd_config_display(&cur_fwd_config);
7387 else if (!strcmp(res->what, "txpkts"))
7388 show_tx_pkt_segments();
7391 cmdline_parse_token_string_t cmd_showcfg_show =
7392 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7393 cmdline_parse_token_string_t cmd_showcfg_port =
7394 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7395 cmdline_parse_token_string_t cmd_showcfg_what =
7396 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7397 "rxtx#cores#fwd#txpkts");
7399 cmdline_parse_inst_t cmd_showcfg = {
7400 .f = cmd_showcfg_parsed,
7402 .help_str = "show config rxtx|cores|fwd|txpkts",
7404 (void *)&cmd_showcfg_show,
7405 (void *)&cmd_showcfg_port,
7406 (void *)&cmd_showcfg_what,
7411 /* *** SHOW ALL PORT INFO *** */
7412 struct cmd_showportall_result {
7413 cmdline_fixed_string_t show;
7414 cmdline_fixed_string_t port;
7415 cmdline_fixed_string_t what;
7416 cmdline_fixed_string_t all;
7419 static void cmd_showportall_parsed(void *parsed_result,
7420 __attribute__((unused)) struct cmdline *cl,
7421 __attribute__((unused)) void *data)
7425 struct cmd_showportall_result *res = parsed_result;
7426 if (!strcmp(res->show, "clear")) {
7427 if (!strcmp(res->what, "stats"))
7428 RTE_ETH_FOREACH_DEV(i)
7430 else if (!strcmp(res->what, "xstats"))
7431 RTE_ETH_FOREACH_DEV(i)
7432 nic_xstats_clear(i);
7433 } else if (!strcmp(res->what, "info"))
7434 RTE_ETH_FOREACH_DEV(i)
7435 port_infos_display(i);
7436 else if (!strcmp(res->what, "summary")) {
7437 port_summary_header_display();
7438 RTE_ETH_FOREACH_DEV(i)
7439 port_summary_display(i);
7441 else if (!strcmp(res->what, "stats"))
7442 RTE_ETH_FOREACH_DEV(i)
7443 nic_stats_display(i);
7444 else if (!strcmp(res->what, "xstats"))
7445 RTE_ETH_FOREACH_DEV(i)
7446 nic_xstats_display(i);
7447 else if (!strcmp(res->what, "fdir"))
7448 RTE_ETH_FOREACH_DEV(i)
7450 else if (!strcmp(res->what, "stat_qmap"))
7451 RTE_ETH_FOREACH_DEV(i)
7452 nic_stats_mapping_display(i);
7453 else if (!strcmp(res->what, "dcb_tc"))
7454 RTE_ETH_FOREACH_DEV(i)
7455 port_dcb_info_display(i);
7456 else if (!strcmp(res->what, "cap"))
7457 RTE_ETH_FOREACH_DEV(i)
7458 port_offload_cap_display(i);
7461 cmdline_parse_token_string_t cmd_showportall_show =
7462 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7464 cmdline_parse_token_string_t cmd_showportall_port =
7465 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7466 cmdline_parse_token_string_t cmd_showportall_what =
7467 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7468 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7469 cmdline_parse_token_string_t cmd_showportall_all =
7470 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7471 cmdline_parse_inst_t cmd_showportall = {
7472 .f = cmd_showportall_parsed,
7474 .help_str = "show|clear port "
7475 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7477 (void *)&cmd_showportall_show,
7478 (void *)&cmd_showportall_port,
7479 (void *)&cmd_showportall_what,
7480 (void *)&cmd_showportall_all,
7485 /* *** SHOW PORT INFO *** */
7486 struct cmd_showport_result {
7487 cmdline_fixed_string_t show;
7488 cmdline_fixed_string_t port;
7489 cmdline_fixed_string_t what;
7493 static void cmd_showport_parsed(void *parsed_result,
7494 __attribute__((unused)) struct cmdline *cl,
7495 __attribute__((unused)) void *data)
7497 struct cmd_showport_result *res = parsed_result;
7498 if (!strcmp(res->show, "clear")) {
7499 if (!strcmp(res->what, "stats"))
7500 nic_stats_clear(res->portnum);
7501 else if (!strcmp(res->what, "xstats"))
7502 nic_xstats_clear(res->portnum);
7503 } else if (!strcmp(res->what, "info"))
7504 port_infos_display(res->portnum);
7505 else if (!strcmp(res->what, "summary")) {
7506 port_summary_header_display();
7507 port_summary_display(res->portnum);
7509 else if (!strcmp(res->what, "stats"))
7510 nic_stats_display(res->portnum);
7511 else if (!strcmp(res->what, "xstats"))
7512 nic_xstats_display(res->portnum);
7513 else if (!strcmp(res->what, "fdir"))
7514 fdir_get_infos(res->portnum);
7515 else if (!strcmp(res->what, "stat_qmap"))
7516 nic_stats_mapping_display(res->portnum);
7517 else if (!strcmp(res->what, "dcb_tc"))
7518 port_dcb_info_display(res->portnum);
7519 else if (!strcmp(res->what, "cap"))
7520 port_offload_cap_display(res->portnum);
7523 cmdline_parse_token_string_t cmd_showport_show =
7524 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7526 cmdline_parse_token_string_t cmd_showport_port =
7527 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7528 cmdline_parse_token_string_t cmd_showport_what =
7529 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7530 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7531 cmdline_parse_token_num_t cmd_showport_portnum =
7532 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7534 cmdline_parse_inst_t cmd_showport = {
7535 .f = cmd_showport_parsed,
7537 .help_str = "show|clear port "
7538 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7541 (void *)&cmd_showport_show,
7542 (void *)&cmd_showport_port,
7543 (void *)&cmd_showport_what,
7544 (void *)&cmd_showport_portnum,
7549 /* *** SHOW DEVICE INFO *** */
7550 struct cmd_showdevice_result {
7551 cmdline_fixed_string_t show;
7552 cmdline_fixed_string_t device;
7553 cmdline_fixed_string_t what;
7554 cmdline_fixed_string_t identifier;
7557 static void cmd_showdevice_parsed(void *parsed_result,
7558 __attribute__((unused)) struct cmdline *cl,
7559 __attribute__((unused)) void *data)
7561 struct cmd_showdevice_result *res = parsed_result;
7562 if (!strcmp(res->what, "info")) {
7563 if (!strcmp(res->identifier, "all"))
7564 device_infos_display(NULL);
7566 device_infos_display(res->identifier);
7570 cmdline_parse_token_string_t cmd_showdevice_show =
7571 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7573 cmdline_parse_token_string_t cmd_showdevice_device =
7574 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7575 cmdline_parse_token_string_t cmd_showdevice_what =
7576 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7578 cmdline_parse_token_string_t cmd_showdevice_identifier =
7579 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7582 cmdline_parse_inst_t cmd_showdevice = {
7583 .f = cmd_showdevice_parsed,
7585 .help_str = "show device info <identifier>|all",
7587 (void *)&cmd_showdevice_show,
7588 (void *)&cmd_showdevice_device,
7589 (void *)&cmd_showdevice_what,
7590 (void *)&cmd_showdevice_identifier,
7594 /* *** SHOW QUEUE INFO *** */
7595 struct cmd_showqueue_result {
7596 cmdline_fixed_string_t show;
7597 cmdline_fixed_string_t type;
7598 cmdline_fixed_string_t what;
7604 cmd_showqueue_parsed(void *parsed_result,
7605 __attribute__((unused)) struct cmdline *cl,
7606 __attribute__((unused)) void *data)
7608 struct cmd_showqueue_result *res = parsed_result;
7610 if (!strcmp(res->type, "rxq"))
7611 rx_queue_infos_display(res->portnum, res->queuenum);
7612 else if (!strcmp(res->type, "txq"))
7613 tx_queue_infos_display(res->portnum, res->queuenum);
7616 cmdline_parse_token_string_t cmd_showqueue_show =
7617 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7618 cmdline_parse_token_string_t cmd_showqueue_type =
7619 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7620 cmdline_parse_token_string_t cmd_showqueue_what =
7621 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7622 cmdline_parse_token_num_t cmd_showqueue_portnum =
7623 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7624 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7625 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7627 cmdline_parse_inst_t cmd_showqueue = {
7628 .f = cmd_showqueue_parsed,
7630 .help_str = "show rxq|txq info <port_id> <queue_id>",
7632 (void *)&cmd_showqueue_show,
7633 (void *)&cmd_showqueue_type,
7634 (void *)&cmd_showqueue_what,
7635 (void *)&cmd_showqueue_portnum,
7636 (void *)&cmd_showqueue_queuenum,
7641 /* show/clear fwd engine statistics */
7643 cmdline_fixed_string_t action;
7644 cmdline_fixed_string_t fwd;
7645 cmdline_fixed_string_t stats;
7646 cmdline_fixed_string_t all;
7649 cmdline_parse_token_string_t cmd_fwd_action =
7650 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7651 cmdline_parse_token_string_t cmd_fwd_fwd =
7652 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7653 cmdline_parse_token_string_t cmd_fwd_stats =
7654 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7655 cmdline_parse_token_string_t cmd_fwd_all =
7656 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7659 cmd_showfwdall_parsed(void *parsed_result,
7660 __rte_unused struct cmdline *cl,
7661 __rte_unused void *data)
7663 struct fwd_result *res = parsed_result;
7665 if (!strcmp(res->action, "show"))
7666 fwd_stats_display();
7671 static cmdline_parse_inst_t cmd_showfwdall = {
7672 .f = cmd_showfwdall_parsed,
7674 .help_str = "show|clear fwd stats all",
7676 (void *)&cmd_fwd_action,
7677 (void *)&cmd_fwd_fwd,
7678 (void *)&cmd_fwd_stats,
7679 (void *)&cmd_fwd_all,
7684 /* *** READ PORT REGISTER *** */
7685 struct cmd_read_reg_result {
7686 cmdline_fixed_string_t read;
7687 cmdline_fixed_string_t reg;
7693 cmd_read_reg_parsed(void *parsed_result,
7694 __attribute__((unused)) struct cmdline *cl,
7695 __attribute__((unused)) void *data)
7697 struct cmd_read_reg_result *res = parsed_result;
7698 port_reg_display(res->port_id, res->reg_off);
7701 cmdline_parse_token_string_t cmd_read_reg_read =
7702 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7703 cmdline_parse_token_string_t cmd_read_reg_reg =
7704 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7705 cmdline_parse_token_num_t cmd_read_reg_port_id =
7706 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7707 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7708 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7710 cmdline_parse_inst_t cmd_read_reg = {
7711 .f = cmd_read_reg_parsed,
7713 .help_str = "read reg <port_id> <reg_off>",
7715 (void *)&cmd_read_reg_read,
7716 (void *)&cmd_read_reg_reg,
7717 (void *)&cmd_read_reg_port_id,
7718 (void *)&cmd_read_reg_reg_off,
7723 /* *** READ PORT REGISTER BIT FIELD *** */
7724 struct cmd_read_reg_bit_field_result {
7725 cmdline_fixed_string_t read;
7726 cmdline_fixed_string_t regfield;
7734 cmd_read_reg_bit_field_parsed(void *parsed_result,
7735 __attribute__((unused)) struct cmdline *cl,
7736 __attribute__((unused)) void *data)
7738 struct cmd_read_reg_bit_field_result *res = parsed_result;
7739 port_reg_bit_field_display(res->port_id, res->reg_off,
7740 res->bit1_pos, res->bit2_pos);
7743 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7744 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7746 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7747 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7748 regfield, "regfield");
7749 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7750 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7752 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7753 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7755 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7756 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7758 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7759 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7762 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7763 .f = cmd_read_reg_bit_field_parsed,
7765 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7766 "Read register bit field between bit_x and bit_y included",
7768 (void *)&cmd_read_reg_bit_field_read,
7769 (void *)&cmd_read_reg_bit_field_regfield,
7770 (void *)&cmd_read_reg_bit_field_port_id,
7771 (void *)&cmd_read_reg_bit_field_reg_off,
7772 (void *)&cmd_read_reg_bit_field_bit1_pos,
7773 (void *)&cmd_read_reg_bit_field_bit2_pos,
7778 /* *** READ PORT REGISTER BIT *** */
7779 struct cmd_read_reg_bit_result {
7780 cmdline_fixed_string_t read;
7781 cmdline_fixed_string_t regbit;
7788 cmd_read_reg_bit_parsed(void *parsed_result,
7789 __attribute__((unused)) struct cmdline *cl,
7790 __attribute__((unused)) void *data)
7792 struct cmd_read_reg_bit_result *res = parsed_result;
7793 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7796 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7797 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7798 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7799 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7801 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7802 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7803 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7804 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7805 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7806 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7808 cmdline_parse_inst_t cmd_read_reg_bit = {
7809 .f = cmd_read_reg_bit_parsed,
7811 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7813 (void *)&cmd_read_reg_bit_read,
7814 (void *)&cmd_read_reg_bit_regbit,
7815 (void *)&cmd_read_reg_bit_port_id,
7816 (void *)&cmd_read_reg_bit_reg_off,
7817 (void *)&cmd_read_reg_bit_bit_pos,
7822 /* *** WRITE PORT REGISTER *** */
7823 struct cmd_write_reg_result {
7824 cmdline_fixed_string_t write;
7825 cmdline_fixed_string_t reg;
7832 cmd_write_reg_parsed(void *parsed_result,
7833 __attribute__((unused)) struct cmdline *cl,
7834 __attribute__((unused)) void *data)
7836 struct cmd_write_reg_result *res = parsed_result;
7837 port_reg_set(res->port_id, res->reg_off, res->value);
7840 cmdline_parse_token_string_t cmd_write_reg_write =
7841 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7842 cmdline_parse_token_string_t cmd_write_reg_reg =
7843 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7844 cmdline_parse_token_num_t cmd_write_reg_port_id =
7845 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7846 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7847 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7848 cmdline_parse_token_num_t cmd_write_reg_value =
7849 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7851 cmdline_parse_inst_t cmd_write_reg = {
7852 .f = cmd_write_reg_parsed,
7854 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7856 (void *)&cmd_write_reg_write,
7857 (void *)&cmd_write_reg_reg,
7858 (void *)&cmd_write_reg_port_id,
7859 (void *)&cmd_write_reg_reg_off,
7860 (void *)&cmd_write_reg_value,
7865 /* *** WRITE PORT REGISTER BIT FIELD *** */
7866 struct cmd_write_reg_bit_field_result {
7867 cmdline_fixed_string_t write;
7868 cmdline_fixed_string_t regfield;
7877 cmd_write_reg_bit_field_parsed(void *parsed_result,
7878 __attribute__((unused)) struct cmdline *cl,
7879 __attribute__((unused)) void *data)
7881 struct cmd_write_reg_bit_field_result *res = parsed_result;
7882 port_reg_bit_field_set(res->port_id, res->reg_off,
7883 res->bit1_pos, res->bit2_pos, res->value);
7886 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7887 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7889 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7890 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7891 regfield, "regfield");
7892 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7893 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7895 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7896 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7898 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7899 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7901 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7902 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7904 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7905 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7908 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7909 .f = cmd_write_reg_bit_field_parsed,
7911 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7913 "Set register bit field between bit_x and bit_y included",
7915 (void *)&cmd_write_reg_bit_field_write,
7916 (void *)&cmd_write_reg_bit_field_regfield,
7917 (void *)&cmd_write_reg_bit_field_port_id,
7918 (void *)&cmd_write_reg_bit_field_reg_off,
7919 (void *)&cmd_write_reg_bit_field_bit1_pos,
7920 (void *)&cmd_write_reg_bit_field_bit2_pos,
7921 (void *)&cmd_write_reg_bit_field_value,
7926 /* *** WRITE PORT REGISTER BIT *** */
7927 struct cmd_write_reg_bit_result {
7928 cmdline_fixed_string_t write;
7929 cmdline_fixed_string_t regbit;
7937 cmd_write_reg_bit_parsed(void *parsed_result,
7938 __attribute__((unused)) struct cmdline *cl,
7939 __attribute__((unused)) void *data)
7941 struct cmd_write_reg_bit_result *res = parsed_result;
7942 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7945 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7946 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7948 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7949 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7951 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7952 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7953 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7954 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7955 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7956 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7957 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7958 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7960 cmdline_parse_inst_t cmd_write_reg_bit = {
7961 .f = cmd_write_reg_bit_parsed,
7963 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7966 (void *)&cmd_write_reg_bit_write,
7967 (void *)&cmd_write_reg_bit_regbit,
7968 (void *)&cmd_write_reg_bit_port_id,
7969 (void *)&cmd_write_reg_bit_reg_off,
7970 (void *)&cmd_write_reg_bit_bit_pos,
7971 (void *)&cmd_write_reg_bit_value,
7976 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7977 struct cmd_read_rxd_txd_result {
7978 cmdline_fixed_string_t read;
7979 cmdline_fixed_string_t rxd_txd;
7986 cmd_read_rxd_txd_parsed(void *parsed_result,
7987 __attribute__((unused)) struct cmdline *cl,
7988 __attribute__((unused)) void *data)
7990 struct cmd_read_rxd_txd_result *res = parsed_result;
7992 if (!strcmp(res->rxd_txd, "rxd"))
7993 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7994 else if (!strcmp(res->rxd_txd, "txd"))
7995 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7998 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7999 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8000 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8001 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8003 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8004 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8005 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8006 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8007 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8008 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8010 cmdline_parse_inst_t cmd_read_rxd_txd = {
8011 .f = cmd_read_rxd_txd_parsed,
8013 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8015 (void *)&cmd_read_rxd_txd_read,
8016 (void *)&cmd_read_rxd_txd_rxd_txd,
8017 (void *)&cmd_read_rxd_txd_port_id,
8018 (void *)&cmd_read_rxd_txd_queue_id,
8019 (void *)&cmd_read_rxd_txd_desc_id,
8025 struct cmd_quit_result {
8026 cmdline_fixed_string_t quit;
8029 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
8031 __attribute__((unused)) void *data)
8036 cmdline_parse_token_string_t cmd_quit_quit =
8037 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8039 cmdline_parse_inst_t cmd_quit = {
8040 .f = cmd_quit_parsed,
8042 .help_str = "quit: Exit application",
8044 (void *)&cmd_quit_quit,
8049 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8050 struct cmd_mac_addr_result {
8051 cmdline_fixed_string_t mac_addr_cmd;
8052 cmdline_fixed_string_t what;
8054 struct rte_ether_addr address;
8057 static void cmd_mac_addr_parsed(void *parsed_result,
8058 __attribute__((unused)) struct cmdline *cl,
8059 __attribute__((unused)) void *data)
8061 struct cmd_mac_addr_result *res = parsed_result;
8064 if (strcmp(res->what, "add") == 0)
8065 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8066 else if (strcmp(res->what, "set") == 0)
8067 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8070 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8072 /* check the return value and print it if is < 0 */
8074 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8078 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8079 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8081 cmdline_parse_token_string_t cmd_mac_addr_what =
8082 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8084 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8085 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8087 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8088 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8090 cmdline_parse_inst_t cmd_mac_addr = {
8091 .f = cmd_mac_addr_parsed,
8093 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8094 "Add/Remove/Set MAC address on port_id",
8096 (void *)&cmd_mac_addr_cmd,
8097 (void *)&cmd_mac_addr_what,
8098 (void *)&cmd_mac_addr_portnum,
8099 (void *)&cmd_mac_addr_addr,
8104 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8105 struct cmd_eth_peer_result {
8106 cmdline_fixed_string_t set;
8107 cmdline_fixed_string_t eth_peer;
8109 cmdline_fixed_string_t peer_addr;
8112 static void cmd_set_eth_peer_parsed(void *parsed_result,
8113 __attribute__((unused)) struct cmdline *cl,
8114 __attribute__((unused)) void *data)
8116 struct cmd_eth_peer_result *res = parsed_result;
8118 if (test_done == 0) {
8119 printf("Please stop forwarding first\n");
8122 if (!strcmp(res->eth_peer, "eth-peer")) {
8123 set_fwd_eth_peer(res->port_id, res->peer_addr);
8127 cmdline_parse_token_string_t cmd_eth_peer_set =
8128 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8129 cmdline_parse_token_string_t cmd_eth_peer =
8130 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8131 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8132 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8133 cmdline_parse_token_string_t cmd_eth_peer_addr =
8134 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8136 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8137 .f = cmd_set_eth_peer_parsed,
8139 .help_str = "set eth-peer <port_id> <peer_mac>",
8141 (void *)&cmd_eth_peer_set,
8142 (void *)&cmd_eth_peer,
8143 (void *)&cmd_eth_peer_port_id,
8144 (void *)&cmd_eth_peer_addr,
8149 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8150 struct cmd_set_qmap_result {
8151 cmdline_fixed_string_t set;
8152 cmdline_fixed_string_t qmap;
8153 cmdline_fixed_string_t what;
8160 cmd_set_qmap_parsed(void *parsed_result,
8161 __attribute__((unused)) struct cmdline *cl,
8162 __attribute__((unused)) void *data)
8164 struct cmd_set_qmap_result *res = parsed_result;
8165 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8167 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8170 cmdline_parse_token_string_t cmd_setqmap_set =
8171 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8173 cmdline_parse_token_string_t cmd_setqmap_qmap =
8174 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8176 cmdline_parse_token_string_t cmd_setqmap_what =
8177 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8179 cmdline_parse_token_num_t cmd_setqmap_portid =
8180 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8182 cmdline_parse_token_num_t cmd_setqmap_queueid =
8183 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8185 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8186 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8189 cmdline_parse_inst_t cmd_set_qmap = {
8190 .f = cmd_set_qmap_parsed,
8192 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8193 "Set statistics mapping value on tx|rx queue_id of port_id",
8195 (void *)&cmd_setqmap_set,
8196 (void *)&cmd_setqmap_qmap,
8197 (void *)&cmd_setqmap_what,
8198 (void *)&cmd_setqmap_portid,
8199 (void *)&cmd_setqmap_queueid,
8200 (void *)&cmd_setqmap_mapvalue,
8205 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8206 struct cmd_set_xstats_hide_zero_result {
8207 cmdline_fixed_string_t keyword;
8208 cmdline_fixed_string_t name;
8209 cmdline_fixed_string_t on_off;
8213 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8214 __attribute__((unused)) struct cmdline *cl,
8215 __attribute__((unused)) void *data)
8217 struct cmd_set_xstats_hide_zero_result *res;
8218 uint16_t on_off = 0;
8220 res = parsed_result;
8221 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8222 set_xstats_hide_zero(on_off);
8225 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8226 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8228 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8229 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8230 name, "xstats-hide-zero");
8231 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8232 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8235 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8236 .f = cmd_set_xstats_hide_zero_parsed,
8238 .help_str = "set xstats-hide-zero on|off",
8240 (void *)&cmd_set_xstats_hide_zero_keyword,
8241 (void *)&cmd_set_xstats_hide_zero_name,
8242 (void *)&cmd_set_xstats_hide_zero_on_off,
8247 /* *** CONFIGURE UNICAST HASH TABLE *** */
8248 struct cmd_set_uc_hash_table {
8249 cmdline_fixed_string_t set;
8250 cmdline_fixed_string_t port;
8252 cmdline_fixed_string_t what;
8253 struct rte_ether_addr address;
8254 cmdline_fixed_string_t mode;
8258 cmd_set_uc_hash_parsed(void *parsed_result,
8259 __attribute__((unused)) struct cmdline *cl,
8260 __attribute__((unused)) void *data)
8263 struct cmd_set_uc_hash_table *res = parsed_result;
8265 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8267 if (strcmp(res->what, "uta") == 0)
8268 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8269 &res->address,(uint8_t)is_on);
8271 printf("bad unicast hash table parameter, return code = %d \n", ret);
8275 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8276 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8278 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8279 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8281 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8282 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8284 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8285 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8287 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8288 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8290 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8291 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8294 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8295 .f = cmd_set_uc_hash_parsed,
8297 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8299 (void *)&cmd_set_uc_hash_set,
8300 (void *)&cmd_set_uc_hash_port,
8301 (void *)&cmd_set_uc_hash_portid,
8302 (void *)&cmd_set_uc_hash_what,
8303 (void *)&cmd_set_uc_hash_mac,
8304 (void *)&cmd_set_uc_hash_mode,
8309 struct cmd_set_uc_all_hash_table {
8310 cmdline_fixed_string_t set;
8311 cmdline_fixed_string_t port;
8313 cmdline_fixed_string_t what;
8314 cmdline_fixed_string_t value;
8315 cmdline_fixed_string_t mode;
8319 cmd_set_uc_all_hash_parsed(void *parsed_result,
8320 __attribute__((unused)) struct cmdline *cl,
8321 __attribute__((unused)) void *data)
8324 struct cmd_set_uc_all_hash_table *res = parsed_result;
8326 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8328 if ((strcmp(res->what, "uta") == 0) &&
8329 (strcmp(res->value, "all") == 0))
8330 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8332 printf("bad unicast hash table parameter,"
8333 "return code = %d \n", ret);
8336 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8337 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8339 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8340 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8342 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8343 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8345 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8346 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8348 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8349 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8351 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8352 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8355 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8356 .f = cmd_set_uc_all_hash_parsed,
8358 .help_str = "set port <port_id> uta all on|off",
8360 (void *)&cmd_set_uc_all_hash_set,
8361 (void *)&cmd_set_uc_all_hash_port,
8362 (void *)&cmd_set_uc_all_hash_portid,
8363 (void *)&cmd_set_uc_all_hash_what,
8364 (void *)&cmd_set_uc_all_hash_value,
8365 (void *)&cmd_set_uc_all_hash_mode,
8370 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8371 struct cmd_set_vf_macvlan_filter {
8372 cmdline_fixed_string_t set;
8373 cmdline_fixed_string_t port;
8375 cmdline_fixed_string_t vf;
8377 struct rte_ether_addr address;
8378 cmdline_fixed_string_t filter_type;
8379 cmdline_fixed_string_t mode;
8383 cmd_set_vf_macvlan_parsed(void *parsed_result,
8384 __attribute__((unused)) struct cmdline *cl,
8385 __attribute__((unused)) void *data)
8388 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8389 struct rte_eth_mac_filter filter;
8391 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8393 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8395 /* set VF MAC filter */
8399 filter.dst_id = res->vf_id;
8401 if (!strcmp(res->filter_type, "exact-mac"))
8402 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8403 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8404 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8405 else if (!strcmp(res->filter_type, "hashmac"))
8406 filter.filter_type = RTE_MAC_HASH_MATCH;
8407 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8408 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8410 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8413 ret = rte_eth_dev_filter_ctrl(res->port_id,
8414 RTE_ETH_FILTER_MACVLAN,
8418 ret = rte_eth_dev_filter_ctrl(res->port_id,
8419 RTE_ETH_FILTER_MACVLAN,
8420 RTE_ETH_FILTER_DELETE,
8424 printf("bad set MAC hash parameter, return code = %d\n", ret);
8428 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8429 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8431 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8432 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8434 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8435 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8437 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8438 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8440 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8441 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8443 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8444 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8446 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8447 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8448 filter_type, "exact-mac#exact-mac-vlan"
8449 "#hashmac#hashmac-vlan");
8450 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8451 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8454 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8455 .f = cmd_set_vf_macvlan_parsed,
8457 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8458 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8459 "Exact match rule: exact match of MAC or MAC and VLAN; "
8460 "hash match rule: hash match of MAC and exact match of VLAN",
8462 (void *)&cmd_set_vf_macvlan_set,
8463 (void *)&cmd_set_vf_macvlan_port,
8464 (void *)&cmd_set_vf_macvlan_portid,
8465 (void *)&cmd_set_vf_macvlan_vf,
8466 (void *)&cmd_set_vf_macvlan_vf_id,
8467 (void *)&cmd_set_vf_macvlan_mac,
8468 (void *)&cmd_set_vf_macvlan_filter_type,
8469 (void *)&cmd_set_vf_macvlan_mode,
8474 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8475 struct cmd_set_vf_traffic {
8476 cmdline_fixed_string_t set;
8477 cmdline_fixed_string_t port;
8479 cmdline_fixed_string_t vf;
8481 cmdline_fixed_string_t what;
8482 cmdline_fixed_string_t mode;
8486 cmd_set_vf_traffic_parsed(void *parsed_result,
8487 __attribute__((unused)) struct cmdline *cl,
8488 __attribute__((unused)) void *data)
8490 struct cmd_set_vf_traffic *res = parsed_result;
8491 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8492 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8494 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8497 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8498 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8500 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8501 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8503 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8504 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8506 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8509 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8510 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8512 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8513 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8515 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8516 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8519 cmdline_parse_inst_t cmd_set_vf_traffic = {
8520 .f = cmd_set_vf_traffic_parsed,
8522 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8524 (void *)&cmd_setvf_traffic_set,
8525 (void *)&cmd_setvf_traffic_port,
8526 (void *)&cmd_setvf_traffic_portid,
8527 (void *)&cmd_setvf_traffic_vf,
8528 (void *)&cmd_setvf_traffic_vfid,
8529 (void *)&cmd_setvf_traffic_what,
8530 (void *)&cmd_setvf_traffic_mode,
8535 /* *** CONFIGURE VF RECEIVE MODE *** */
8536 struct cmd_set_vf_rxmode {
8537 cmdline_fixed_string_t set;
8538 cmdline_fixed_string_t port;
8540 cmdline_fixed_string_t vf;
8542 cmdline_fixed_string_t what;
8543 cmdline_fixed_string_t mode;
8544 cmdline_fixed_string_t on;
8548 cmd_set_vf_rxmode_parsed(void *parsed_result,
8549 __attribute__((unused)) struct cmdline *cl,
8550 __attribute__((unused)) void *data)
8553 uint16_t vf_rxmode = 0;
8554 struct cmd_set_vf_rxmode *res = parsed_result;
8556 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8557 if (!strcmp(res->what,"rxmode")) {
8558 if (!strcmp(res->mode, "AUPE"))
8559 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8560 else if (!strcmp(res->mode, "ROPE"))
8561 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8562 else if (!strcmp(res->mode, "BAM"))
8563 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8564 else if (!strncmp(res->mode, "MPE",3))
8565 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8568 RTE_SET_USED(is_on);
8570 #ifdef RTE_LIBRTE_IXGBE_PMD
8571 if (ret == -ENOTSUP)
8572 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8573 vf_rxmode, (uint8_t)is_on);
8575 #ifdef RTE_LIBRTE_BNXT_PMD
8576 if (ret == -ENOTSUP)
8577 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8578 vf_rxmode, (uint8_t)is_on);
8581 printf("bad VF receive mode parameter, return code = %d \n",
8585 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8586 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8588 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8589 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8591 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8592 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8594 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8595 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8597 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8598 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8600 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8601 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8603 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8605 mode, "AUPE#ROPE#BAM#MPE");
8606 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8610 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8611 .f = cmd_set_vf_rxmode_parsed,
8613 .help_str = "set port <port_id> vf <vf_id> rxmode "
8614 "AUPE|ROPE|BAM|MPE on|off",
8616 (void *)&cmd_set_vf_rxmode_set,
8617 (void *)&cmd_set_vf_rxmode_port,
8618 (void *)&cmd_set_vf_rxmode_portid,
8619 (void *)&cmd_set_vf_rxmode_vf,
8620 (void *)&cmd_set_vf_rxmode_vfid,
8621 (void *)&cmd_set_vf_rxmode_what,
8622 (void *)&cmd_set_vf_rxmode_mode,
8623 (void *)&cmd_set_vf_rxmode_on,
8628 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8629 struct cmd_vf_mac_addr_result {
8630 cmdline_fixed_string_t mac_addr_cmd;
8631 cmdline_fixed_string_t what;
8632 cmdline_fixed_string_t port;
8634 cmdline_fixed_string_t vf;
8636 struct rte_ether_addr address;
8639 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8640 __attribute__((unused)) struct cmdline *cl,
8641 __attribute__((unused)) void *data)
8643 struct cmd_vf_mac_addr_result *res = parsed_result;
8646 if (strcmp(res->what, "add") != 0)
8649 #ifdef RTE_LIBRTE_I40E_PMD
8650 if (ret == -ENOTSUP)
8651 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8654 #ifdef RTE_LIBRTE_BNXT_PMD
8655 if (ret == -ENOTSUP)
8656 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8661 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8665 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8666 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8667 mac_addr_cmd,"mac_addr");
8668 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8669 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8671 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8672 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8674 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8675 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8677 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8678 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8680 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8681 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8683 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8684 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8687 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8688 .f = cmd_vf_mac_addr_parsed,
8690 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8691 "Add MAC address filtering for a VF on port_id",
8693 (void *)&cmd_vf_mac_addr_cmd,
8694 (void *)&cmd_vf_mac_addr_what,
8695 (void *)&cmd_vf_mac_addr_port,
8696 (void *)&cmd_vf_mac_addr_portnum,
8697 (void *)&cmd_vf_mac_addr_vf,
8698 (void *)&cmd_vf_mac_addr_vfnum,
8699 (void *)&cmd_vf_mac_addr_addr,
8704 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8705 struct cmd_vf_rx_vlan_filter {
8706 cmdline_fixed_string_t rx_vlan;
8707 cmdline_fixed_string_t what;
8709 cmdline_fixed_string_t port;
8711 cmdline_fixed_string_t vf;
8716 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8717 __attribute__((unused)) struct cmdline *cl,
8718 __attribute__((unused)) void *data)
8720 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8723 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8725 #ifdef RTE_LIBRTE_IXGBE_PMD
8726 if (ret == -ENOTSUP)
8727 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8728 res->vlan_id, res->vf_mask, is_add);
8730 #ifdef RTE_LIBRTE_I40E_PMD
8731 if (ret == -ENOTSUP)
8732 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8733 res->vlan_id, res->vf_mask, is_add);
8735 #ifdef RTE_LIBRTE_BNXT_PMD
8736 if (ret == -ENOTSUP)
8737 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8738 res->vlan_id, res->vf_mask, is_add);
8745 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8746 res->vlan_id, res->vf_mask);
8749 printf("invalid port_id %d\n", res->port_id);
8752 printf("function not implemented or supported\n");
8755 printf("programming error: (%s)\n", strerror(-ret));
8759 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8760 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8761 rx_vlan, "rx_vlan");
8762 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8763 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8765 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8766 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8768 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8769 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8771 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8772 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8774 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8775 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8777 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8778 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8781 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8782 .f = cmd_vf_rx_vlan_filter_parsed,
8784 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8785 "(vf_mask = hexadecimal VF mask)",
8787 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8788 (void *)&cmd_vf_rx_vlan_filter_what,
8789 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8790 (void *)&cmd_vf_rx_vlan_filter_port,
8791 (void *)&cmd_vf_rx_vlan_filter_portid,
8792 (void *)&cmd_vf_rx_vlan_filter_vf,
8793 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8798 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8799 struct cmd_queue_rate_limit_result {
8800 cmdline_fixed_string_t set;
8801 cmdline_fixed_string_t port;
8803 cmdline_fixed_string_t queue;
8805 cmdline_fixed_string_t rate;
8809 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8810 __attribute__((unused)) struct cmdline *cl,
8811 __attribute__((unused)) void *data)
8813 struct cmd_queue_rate_limit_result *res = parsed_result;
8816 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8817 && (strcmp(res->queue, "queue") == 0)
8818 && (strcmp(res->rate, "rate") == 0))
8819 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8822 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8826 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8827 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8829 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8830 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8832 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8833 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8835 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8836 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8838 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8839 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8841 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8842 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8844 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8845 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8848 cmdline_parse_inst_t cmd_queue_rate_limit = {
8849 .f = cmd_queue_rate_limit_parsed,
8851 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8852 "Set rate limit for a queue on port_id",
8854 (void *)&cmd_queue_rate_limit_set,
8855 (void *)&cmd_queue_rate_limit_port,
8856 (void *)&cmd_queue_rate_limit_portnum,
8857 (void *)&cmd_queue_rate_limit_queue,
8858 (void *)&cmd_queue_rate_limit_queuenum,
8859 (void *)&cmd_queue_rate_limit_rate,
8860 (void *)&cmd_queue_rate_limit_ratenum,
8865 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8866 struct cmd_vf_rate_limit_result {
8867 cmdline_fixed_string_t set;
8868 cmdline_fixed_string_t port;
8870 cmdline_fixed_string_t vf;
8872 cmdline_fixed_string_t rate;
8874 cmdline_fixed_string_t q_msk;
8878 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8879 __attribute__((unused)) struct cmdline *cl,
8880 __attribute__((unused)) void *data)
8882 struct cmd_vf_rate_limit_result *res = parsed_result;
8885 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8886 && (strcmp(res->vf, "vf") == 0)
8887 && (strcmp(res->rate, "rate") == 0)
8888 && (strcmp(res->q_msk, "queue_mask") == 0))
8889 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8890 res->rate_num, res->q_msk_val);
8892 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8896 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8897 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8899 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8900 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8902 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8903 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8905 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8906 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8908 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8909 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8911 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8912 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8914 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8915 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8917 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8918 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8919 q_msk, "queue_mask");
8920 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8921 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8924 cmdline_parse_inst_t cmd_vf_rate_limit = {
8925 .f = cmd_vf_rate_limit_parsed,
8927 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8928 "queue_mask <queue_mask_value>: "
8929 "Set rate limit for queues of VF on port_id",
8931 (void *)&cmd_vf_rate_limit_set,
8932 (void *)&cmd_vf_rate_limit_port,
8933 (void *)&cmd_vf_rate_limit_portnum,
8934 (void *)&cmd_vf_rate_limit_vf,
8935 (void *)&cmd_vf_rate_limit_vfnum,
8936 (void *)&cmd_vf_rate_limit_rate,
8937 (void *)&cmd_vf_rate_limit_ratenum,
8938 (void *)&cmd_vf_rate_limit_q_msk,
8939 (void *)&cmd_vf_rate_limit_q_msk_val,
8944 /* *** ADD TUNNEL FILTER OF A PORT *** */
8945 struct cmd_tunnel_filter_result {
8946 cmdline_fixed_string_t cmd;
8947 cmdline_fixed_string_t what;
8949 struct rte_ether_addr outer_mac;
8950 struct rte_ether_addr inner_mac;
8951 cmdline_ipaddr_t ip_value;
8952 uint16_t inner_vlan;
8953 cmdline_fixed_string_t tunnel_type;
8954 cmdline_fixed_string_t filter_type;
8960 cmd_tunnel_filter_parsed(void *parsed_result,
8961 __attribute__((unused)) struct cmdline *cl,
8962 __attribute__((unused)) void *data)
8964 struct cmd_tunnel_filter_result *res = parsed_result;
8965 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8968 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8970 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8971 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8972 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8974 if (res->ip_value.family == AF_INET) {
8975 tunnel_filter_conf.ip_addr.ipv4_addr =
8976 res->ip_value.addr.ipv4.s_addr;
8977 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8979 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8980 &(res->ip_value.addr.ipv6),
8981 sizeof(struct in6_addr));
8982 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8985 if (!strcmp(res->filter_type, "imac-ivlan"))
8986 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8987 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8988 tunnel_filter_conf.filter_type =
8989 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8990 else if (!strcmp(res->filter_type, "imac-tenid"))
8991 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8992 else if (!strcmp(res->filter_type, "imac"))
8993 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8994 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8995 tunnel_filter_conf.filter_type =
8996 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8997 else if (!strcmp(res->filter_type, "oip"))
8998 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8999 else if (!strcmp(res->filter_type, "iip"))
9000 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9002 printf("The filter type is not supported");
9006 if (!strcmp(res->tunnel_type, "vxlan"))
9007 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9008 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9009 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9010 else if (!strcmp(res->tunnel_type, "nvgre"))
9011 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9012 else if (!strcmp(res->tunnel_type, "ipingre"))
9013 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9015 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9019 tunnel_filter_conf.tenant_id = res->tenant_id;
9020 tunnel_filter_conf.queue_id = res->queue_num;
9021 if (!strcmp(res->what, "add"))
9022 ret = rte_eth_dev_filter_ctrl(res->port_id,
9023 RTE_ETH_FILTER_TUNNEL,
9025 &tunnel_filter_conf);
9027 ret = rte_eth_dev_filter_ctrl(res->port_id,
9028 RTE_ETH_FILTER_TUNNEL,
9029 RTE_ETH_FILTER_DELETE,
9030 &tunnel_filter_conf);
9032 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9036 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9037 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9038 cmd, "tunnel_filter");
9039 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9040 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9042 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9043 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9045 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9046 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9048 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9049 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9051 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9052 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9053 inner_vlan, UINT16);
9054 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9055 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9057 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9058 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9059 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9061 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9062 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9063 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9064 "imac#omac-imac-tenid");
9065 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9066 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9068 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9069 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9072 cmdline_parse_inst_t cmd_tunnel_filter = {
9073 .f = cmd_tunnel_filter_parsed,
9075 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9076 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9077 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9078 "<queue_id>: Add/Rm tunnel filter of a port",
9080 (void *)&cmd_tunnel_filter_cmd,
9081 (void *)&cmd_tunnel_filter_what,
9082 (void *)&cmd_tunnel_filter_port_id,
9083 (void *)&cmd_tunnel_filter_outer_mac,
9084 (void *)&cmd_tunnel_filter_inner_mac,
9085 (void *)&cmd_tunnel_filter_ip_value,
9086 (void *)&cmd_tunnel_filter_innner_vlan,
9087 (void *)&cmd_tunnel_filter_tunnel_type,
9088 (void *)&cmd_tunnel_filter_filter_type,
9089 (void *)&cmd_tunnel_filter_tenant_id,
9090 (void *)&cmd_tunnel_filter_queue_num,
9095 /* *** CONFIGURE TUNNEL UDP PORT *** */
9096 struct cmd_tunnel_udp_config {
9097 cmdline_fixed_string_t cmd;
9098 cmdline_fixed_string_t what;
9104 cmd_tunnel_udp_config_parsed(void *parsed_result,
9105 __attribute__((unused)) struct cmdline *cl,
9106 __attribute__((unused)) void *data)
9108 struct cmd_tunnel_udp_config *res = parsed_result;
9109 struct rte_eth_udp_tunnel tunnel_udp;
9112 tunnel_udp.udp_port = res->udp_port;
9114 if (!strcmp(res->cmd, "rx_vxlan_port"))
9115 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9117 if (!strcmp(res->what, "add"))
9118 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9121 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9125 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9128 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9129 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9130 cmd, "rx_vxlan_port");
9131 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9132 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9134 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9135 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9137 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9138 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9141 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9142 .f = cmd_tunnel_udp_config_parsed,
9144 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9145 "Add/Remove a tunneling UDP port filter",
9147 (void *)&cmd_tunnel_udp_config_cmd,
9148 (void *)&cmd_tunnel_udp_config_what,
9149 (void *)&cmd_tunnel_udp_config_udp_port,
9150 (void *)&cmd_tunnel_udp_config_port_id,
9155 struct cmd_config_tunnel_udp_port {
9156 cmdline_fixed_string_t port;
9157 cmdline_fixed_string_t config;
9159 cmdline_fixed_string_t udp_tunnel_port;
9160 cmdline_fixed_string_t action;
9161 cmdline_fixed_string_t tunnel_type;
9166 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9167 __attribute__((unused)) struct cmdline *cl,
9168 __attribute__((unused)) void *data)
9170 struct cmd_config_tunnel_udp_port *res = parsed_result;
9171 struct rte_eth_udp_tunnel tunnel_udp;
9174 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9177 tunnel_udp.udp_port = res->udp_port;
9179 if (!strcmp(res->tunnel_type, "vxlan")) {
9180 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9181 } else if (!strcmp(res->tunnel_type, "geneve")) {
9182 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9183 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9184 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9186 printf("Invalid tunnel type\n");
9190 if (!strcmp(res->action, "add"))
9191 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9194 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9198 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9201 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9202 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9204 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9205 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9207 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9208 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9210 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9211 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9214 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9215 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9217 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9218 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9219 "vxlan#geneve#vxlan-gpe");
9220 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9221 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9224 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9225 .f = cmd_cfg_tunnel_udp_port_parsed,
9227 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9229 (void *)&cmd_config_tunnel_udp_port_port,
9230 (void *)&cmd_config_tunnel_udp_port_config,
9231 (void *)&cmd_config_tunnel_udp_port_port_id,
9232 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9233 (void *)&cmd_config_tunnel_udp_port_action,
9234 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9235 (void *)&cmd_config_tunnel_udp_port_value,
9240 /* *** GLOBAL CONFIG *** */
9241 struct cmd_global_config_result {
9242 cmdline_fixed_string_t cmd;
9244 cmdline_fixed_string_t cfg_type;
9249 cmd_global_config_parsed(void *parsed_result,
9250 __attribute__((unused)) struct cmdline *cl,
9251 __attribute__((unused)) void *data)
9253 struct cmd_global_config_result *res = parsed_result;
9254 struct rte_eth_global_cfg conf;
9257 memset(&conf, 0, sizeof(conf));
9258 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9259 conf.cfg.gre_key_len = res->len;
9260 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9261 RTE_ETH_FILTER_SET, &conf);
9263 printf("Global config error\n");
9266 cmdline_parse_token_string_t cmd_global_config_cmd =
9267 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9269 cmdline_parse_token_num_t cmd_global_config_port_id =
9270 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9272 cmdline_parse_token_string_t cmd_global_config_type =
9273 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9274 cfg_type, "gre-key-len");
9275 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9276 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9279 cmdline_parse_inst_t cmd_global_config = {
9280 .f = cmd_global_config_parsed,
9281 .data = (void *)NULL,
9282 .help_str = "global_config <port_id> gre-key-len <key_len>",
9284 (void *)&cmd_global_config_cmd,
9285 (void *)&cmd_global_config_port_id,
9286 (void *)&cmd_global_config_type,
9287 (void *)&cmd_global_config_gre_key_len,
9292 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9293 struct cmd_set_mirror_mask_result {
9294 cmdline_fixed_string_t set;
9295 cmdline_fixed_string_t port;
9297 cmdline_fixed_string_t mirror;
9299 cmdline_fixed_string_t what;
9300 cmdline_fixed_string_t value;
9301 cmdline_fixed_string_t dstpool;
9303 cmdline_fixed_string_t on;
9306 cmdline_parse_token_string_t cmd_mirror_mask_set =
9307 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9309 cmdline_parse_token_string_t cmd_mirror_mask_port =
9310 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9312 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9313 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9315 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9316 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9317 mirror, "mirror-rule");
9318 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9319 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9321 cmdline_parse_token_string_t cmd_mirror_mask_what =
9322 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9323 what, "pool-mirror-up#pool-mirror-down"
9325 cmdline_parse_token_string_t cmd_mirror_mask_value =
9326 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9328 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9330 dstpool, "dst-pool");
9331 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9332 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9334 cmdline_parse_token_string_t cmd_mirror_mask_on =
9335 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9339 cmd_set_mirror_mask_parsed(void *parsed_result,
9340 __attribute__((unused)) struct cmdline *cl,
9341 __attribute__((unused)) void *data)
9344 struct cmd_set_mirror_mask_result *res = parsed_result;
9345 struct rte_eth_mirror_conf mr_conf;
9347 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9349 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9351 mr_conf.dst_pool = res->dstpool_id;
9353 if (!strcmp(res->what, "pool-mirror-up")) {
9354 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9355 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9356 } else if (!strcmp(res->what, "pool-mirror-down")) {
9357 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9358 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9359 } else if (!strcmp(res->what, "vlan-mirror")) {
9360 mr_conf.rule_type = ETH_MIRROR_VLAN;
9361 nb_item = parse_item_list(res->value, "vlan",
9362 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9366 for (i = 0; i < nb_item; i++) {
9367 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9368 printf("Invalid vlan_id: must be < 4096\n");
9372 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9373 mr_conf.vlan.vlan_mask |= 1ULL << i;
9377 if (!strcmp(res->on, "on"))
9378 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9381 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9384 printf("mirror rule add error: (%s)\n", strerror(-ret));
9387 cmdline_parse_inst_t cmd_set_mirror_mask = {
9388 .f = cmd_set_mirror_mask_parsed,
9390 .help_str = "set port <port_id> mirror-rule <rule_id> "
9391 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9392 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9394 (void *)&cmd_mirror_mask_set,
9395 (void *)&cmd_mirror_mask_port,
9396 (void *)&cmd_mirror_mask_portid,
9397 (void *)&cmd_mirror_mask_mirror,
9398 (void *)&cmd_mirror_mask_ruleid,
9399 (void *)&cmd_mirror_mask_what,
9400 (void *)&cmd_mirror_mask_value,
9401 (void *)&cmd_mirror_mask_dstpool,
9402 (void *)&cmd_mirror_mask_poolid,
9403 (void *)&cmd_mirror_mask_on,
9408 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9409 struct cmd_set_mirror_link_result {
9410 cmdline_fixed_string_t set;
9411 cmdline_fixed_string_t port;
9413 cmdline_fixed_string_t mirror;
9415 cmdline_fixed_string_t what;
9416 cmdline_fixed_string_t dstpool;
9418 cmdline_fixed_string_t on;
9421 cmdline_parse_token_string_t cmd_mirror_link_set =
9422 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9424 cmdline_parse_token_string_t cmd_mirror_link_port =
9425 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9427 cmdline_parse_token_num_t cmd_mirror_link_portid =
9428 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9430 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9431 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9432 mirror, "mirror-rule");
9433 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9434 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9436 cmdline_parse_token_string_t cmd_mirror_link_what =
9437 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9438 what, "uplink-mirror#downlink-mirror");
9439 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9440 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9441 dstpool, "dst-pool");
9442 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9443 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9445 cmdline_parse_token_string_t cmd_mirror_link_on =
9446 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9450 cmd_set_mirror_link_parsed(void *parsed_result,
9451 __attribute__((unused)) struct cmdline *cl,
9452 __attribute__((unused)) void *data)
9455 struct cmd_set_mirror_link_result *res = parsed_result;
9456 struct rte_eth_mirror_conf mr_conf;
9458 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9459 if (!strcmp(res->what, "uplink-mirror"))
9460 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9462 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9464 mr_conf.dst_pool = res->dstpool_id;
9466 if (!strcmp(res->on, "on"))
9467 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9470 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9473 /* check the return value and print it if is < 0 */
9475 printf("mirror rule add error: (%s)\n", strerror(-ret));
9479 cmdline_parse_inst_t cmd_set_mirror_link = {
9480 .f = cmd_set_mirror_link_parsed,
9482 .help_str = "set port <port_id> mirror-rule <rule_id> "
9483 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9485 (void *)&cmd_mirror_link_set,
9486 (void *)&cmd_mirror_link_port,
9487 (void *)&cmd_mirror_link_portid,
9488 (void *)&cmd_mirror_link_mirror,
9489 (void *)&cmd_mirror_link_ruleid,
9490 (void *)&cmd_mirror_link_what,
9491 (void *)&cmd_mirror_link_dstpool,
9492 (void *)&cmd_mirror_link_poolid,
9493 (void *)&cmd_mirror_link_on,
9498 /* *** RESET VM MIRROR RULE *** */
9499 struct cmd_rm_mirror_rule_result {
9500 cmdline_fixed_string_t reset;
9501 cmdline_fixed_string_t port;
9503 cmdline_fixed_string_t mirror;
9507 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9508 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9510 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9511 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9513 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9514 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9516 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9517 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9518 mirror, "mirror-rule");
9519 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9520 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9524 cmd_reset_mirror_rule_parsed(void *parsed_result,
9525 __attribute__((unused)) struct cmdline *cl,
9526 __attribute__((unused)) void *data)
9529 struct cmd_set_mirror_link_result *res = parsed_result;
9531 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9533 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9536 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9537 .f = cmd_reset_mirror_rule_parsed,
9539 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9541 (void *)&cmd_rm_mirror_rule_reset,
9542 (void *)&cmd_rm_mirror_rule_port,
9543 (void *)&cmd_rm_mirror_rule_portid,
9544 (void *)&cmd_rm_mirror_rule_mirror,
9545 (void *)&cmd_rm_mirror_rule_ruleid,
9550 /* ******************************************************************************** */
9552 struct cmd_dump_result {
9553 cmdline_fixed_string_t dump;
9557 dump_struct_sizes(void)
9559 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9560 DUMP_SIZE(struct rte_mbuf);
9561 DUMP_SIZE(struct rte_mempool);
9562 DUMP_SIZE(struct rte_ring);
9566 static void cmd_dump_parsed(void *parsed_result,
9567 __attribute__((unused)) struct cmdline *cl,
9568 __attribute__((unused)) void *data)
9570 struct cmd_dump_result *res = parsed_result;
9572 if (!strcmp(res->dump, "dump_physmem"))
9573 rte_dump_physmem_layout(stdout);
9574 else if (!strcmp(res->dump, "dump_memzone"))
9575 rte_memzone_dump(stdout);
9576 else if (!strcmp(res->dump, "dump_struct_sizes"))
9577 dump_struct_sizes();
9578 else if (!strcmp(res->dump, "dump_ring"))
9579 rte_ring_list_dump(stdout);
9580 else if (!strcmp(res->dump, "dump_mempool"))
9581 rte_mempool_list_dump(stdout);
9582 else if (!strcmp(res->dump, "dump_devargs"))
9583 rte_devargs_dump(stdout);
9584 else if (!strcmp(res->dump, "dump_log_types"))
9585 rte_log_dump(stdout);
9588 cmdline_parse_token_string_t cmd_dump_dump =
9589 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9592 "dump_struct_sizes#"
9598 cmdline_parse_inst_t cmd_dump = {
9599 .f = cmd_dump_parsed, /* function to call */
9600 .data = NULL, /* 2nd arg of func */
9601 .help_str = "Dump status",
9602 .tokens = { /* token list, NULL terminated */
9603 (void *)&cmd_dump_dump,
9608 /* ******************************************************************************** */
9610 struct cmd_dump_one_result {
9611 cmdline_fixed_string_t dump;
9612 cmdline_fixed_string_t name;
9615 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9616 __attribute__((unused)) void *data)
9618 struct cmd_dump_one_result *res = parsed_result;
9620 if (!strcmp(res->dump, "dump_ring")) {
9622 r = rte_ring_lookup(res->name);
9624 cmdline_printf(cl, "Cannot find ring\n");
9627 rte_ring_dump(stdout, r);
9628 } else if (!strcmp(res->dump, "dump_mempool")) {
9629 struct rte_mempool *mp;
9630 mp = rte_mempool_lookup(res->name);
9632 cmdline_printf(cl, "Cannot find mempool\n");
9635 rte_mempool_dump(stdout, mp);
9639 cmdline_parse_token_string_t cmd_dump_one_dump =
9640 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9641 "dump_ring#dump_mempool");
9643 cmdline_parse_token_string_t cmd_dump_one_name =
9644 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9646 cmdline_parse_inst_t cmd_dump_one = {
9647 .f = cmd_dump_one_parsed, /* function to call */
9648 .data = NULL, /* 2nd arg of func */
9649 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9650 .tokens = { /* token list, NULL terminated */
9651 (void *)&cmd_dump_one_dump,
9652 (void *)&cmd_dump_one_name,
9657 /* *** Add/Del syn filter *** */
9658 struct cmd_syn_filter_result {
9659 cmdline_fixed_string_t filter;
9661 cmdline_fixed_string_t ops;
9662 cmdline_fixed_string_t priority;
9663 cmdline_fixed_string_t high;
9664 cmdline_fixed_string_t queue;
9669 cmd_syn_filter_parsed(void *parsed_result,
9670 __attribute__((unused)) struct cmdline *cl,
9671 __attribute__((unused)) void *data)
9673 struct cmd_syn_filter_result *res = parsed_result;
9674 struct rte_eth_syn_filter syn_filter;
9677 ret = rte_eth_dev_filter_supported(res->port_id,
9678 RTE_ETH_FILTER_SYN);
9680 printf("syn filter is not supported on port %u.\n",
9685 memset(&syn_filter, 0, sizeof(syn_filter));
9687 if (!strcmp(res->ops, "add")) {
9688 if (!strcmp(res->high, "high"))
9689 syn_filter.hig_pri = 1;
9691 syn_filter.hig_pri = 0;
9693 syn_filter.queue = res->queue_id;
9694 ret = rte_eth_dev_filter_ctrl(res->port_id,
9699 ret = rte_eth_dev_filter_ctrl(res->port_id,
9701 RTE_ETH_FILTER_DELETE,
9705 printf("syn filter programming error: (%s)\n",
9709 cmdline_parse_token_string_t cmd_syn_filter_filter =
9710 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9711 filter, "syn_filter");
9712 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9713 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9715 cmdline_parse_token_string_t cmd_syn_filter_ops =
9716 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9718 cmdline_parse_token_string_t cmd_syn_filter_priority =
9719 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9720 priority, "priority");
9721 cmdline_parse_token_string_t cmd_syn_filter_high =
9722 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9724 cmdline_parse_token_string_t cmd_syn_filter_queue =
9725 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9727 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9728 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9731 cmdline_parse_inst_t cmd_syn_filter = {
9732 .f = cmd_syn_filter_parsed,
9734 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9735 "<queue_id>: Add/Delete syn filter",
9737 (void *)&cmd_syn_filter_filter,
9738 (void *)&cmd_syn_filter_port_id,
9739 (void *)&cmd_syn_filter_ops,
9740 (void *)&cmd_syn_filter_priority,
9741 (void *)&cmd_syn_filter_high,
9742 (void *)&cmd_syn_filter_queue,
9743 (void *)&cmd_syn_filter_queue_id,
9748 /* *** queue region set *** */
9749 struct cmd_queue_region_result {
9750 cmdline_fixed_string_t set;
9751 cmdline_fixed_string_t port;
9753 cmdline_fixed_string_t cmd;
9754 cmdline_fixed_string_t region;
9756 cmdline_fixed_string_t queue_start_index;
9758 cmdline_fixed_string_t queue_num;
9759 uint8_t queue_num_value;
9763 cmd_queue_region_parsed(void *parsed_result,
9764 __attribute__((unused)) struct cmdline *cl,
9765 __attribute__((unused)) void *data)
9767 struct cmd_queue_region_result *res = parsed_result;
9769 #ifdef RTE_LIBRTE_I40E_PMD
9770 struct rte_pmd_i40e_queue_region_conf region_conf;
9771 enum rte_pmd_i40e_queue_region_op op_type;
9774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9777 #ifdef RTE_LIBRTE_I40E_PMD
9778 memset(®ion_conf, 0, sizeof(region_conf));
9779 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9780 region_conf.region_id = res->region_id;
9781 region_conf.queue_num = res->queue_num_value;
9782 region_conf.queue_start_index = res->queue_id;
9784 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9785 op_type, ®ion_conf);
9792 printf("function not implemented or supported\n");
9795 printf("queue region config error: (%s)\n", strerror(-ret));
9799 cmdline_parse_token_string_t cmd_queue_region_set =
9800 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9802 cmdline_parse_token_string_t cmd_queue_region_port =
9803 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9804 cmdline_parse_token_num_t cmd_queue_region_port_id =
9805 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9807 cmdline_parse_token_string_t cmd_queue_region_cmd =
9808 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9809 cmd, "queue-region");
9810 cmdline_parse_token_string_t cmd_queue_region_id =
9811 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9812 region, "region_id");
9813 cmdline_parse_token_num_t cmd_queue_region_index =
9814 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9816 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9817 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9818 queue_start_index, "queue_start_index");
9819 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9820 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9822 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9823 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9824 queue_num, "queue_num");
9825 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9826 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9827 queue_num_value, UINT8);
9829 cmdline_parse_inst_t cmd_queue_region = {
9830 .f = cmd_queue_region_parsed,
9832 .help_str = "set port <port_id> queue-region region_id <value> "
9833 "queue_start_index <value> queue_num <value>: Set a queue region",
9835 (void *)&cmd_queue_region_set,
9836 (void *)&cmd_queue_region_port,
9837 (void *)&cmd_queue_region_port_id,
9838 (void *)&cmd_queue_region_cmd,
9839 (void *)&cmd_queue_region_id,
9840 (void *)&cmd_queue_region_index,
9841 (void *)&cmd_queue_region_queue_start_index,
9842 (void *)&cmd_queue_region_queue_id,
9843 (void *)&cmd_queue_region_queue_num,
9844 (void *)&cmd_queue_region_queue_num_value,
9849 /* *** queue region and flowtype set *** */
9850 struct cmd_region_flowtype_result {
9851 cmdline_fixed_string_t set;
9852 cmdline_fixed_string_t port;
9854 cmdline_fixed_string_t cmd;
9855 cmdline_fixed_string_t region;
9857 cmdline_fixed_string_t flowtype;
9858 uint8_t flowtype_id;
9862 cmd_region_flowtype_parsed(void *parsed_result,
9863 __attribute__((unused)) struct cmdline *cl,
9864 __attribute__((unused)) void *data)
9866 struct cmd_region_flowtype_result *res = parsed_result;
9868 #ifdef RTE_LIBRTE_I40E_PMD
9869 struct rte_pmd_i40e_queue_region_conf region_conf;
9870 enum rte_pmd_i40e_queue_region_op op_type;
9873 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9876 #ifdef RTE_LIBRTE_I40E_PMD
9877 memset(®ion_conf, 0, sizeof(region_conf));
9879 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9880 region_conf.region_id = res->region_id;
9881 region_conf.hw_flowtype = res->flowtype_id;
9883 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9884 op_type, ®ion_conf);
9891 printf("function not implemented or supported\n");
9894 printf("region flowtype config error: (%s)\n", strerror(-ret));
9898 cmdline_parse_token_string_t cmd_region_flowtype_set =
9899 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9901 cmdline_parse_token_string_t cmd_region_flowtype_port =
9902 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9904 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9905 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9907 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9908 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9909 cmd, "queue-region");
9910 cmdline_parse_token_string_t cmd_region_flowtype_index =
9911 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9912 region, "region_id");
9913 cmdline_parse_token_num_t cmd_region_flowtype_id =
9914 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9916 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9917 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9918 flowtype, "flowtype");
9919 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9920 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9921 flowtype_id, UINT8);
9922 cmdline_parse_inst_t cmd_region_flowtype = {
9923 .f = cmd_region_flowtype_parsed,
9925 .help_str = "set port <port_id> queue-region region_id <value> "
9926 "flowtype <value>: Set a flowtype region index",
9928 (void *)&cmd_region_flowtype_set,
9929 (void *)&cmd_region_flowtype_port,
9930 (void *)&cmd_region_flowtype_port_index,
9931 (void *)&cmd_region_flowtype_cmd,
9932 (void *)&cmd_region_flowtype_index,
9933 (void *)&cmd_region_flowtype_id,
9934 (void *)&cmd_region_flowtype_flow_index,
9935 (void *)&cmd_region_flowtype_flow_id,
9940 /* *** User Priority (UP) to queue region (region_id) set *** */
9941 struct cmd_user_priority_region_result {
9942 cmdline_fixed_string_t set;
9943 cmdline_fixed_string_t port;
9945 cmdline_fixed_string_t cmd;
9946 cmdline_fixed_string_t user_priority;
9947 uint8_t user_priority_id;
9948 cmdline_fixed_string_t region;
9953 cmd_user_priority_region_parsed(void *parsed_result,
9954 __attribute__((unused)) struct cmdline *cl,
9955 __attribute__((unused)) void *data)
9957 struct cmd_user_priority_region_result *res = parsed_result;
9959 #ifdef RTE_LIBRTE_I40E_PMD
9960 struct rte_pmd_i40e_queue_region_conf region_conf;
9961 enum rte_pmd_i40e_queue_region_op op_type;
9964 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9967 #ifdef RTE_LIBRTE_I40E_PMD
9968 memset(®ion_conf, 0, sizeof(region_conf));
9969 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9970 region_conf.user_priority = res->user_priority_id;
9971 region_conf.region_id = res->region_id;
9973 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9974 op_type, ®ion_conf);
9981 printf("function not implemented or supported\n");
9984 printf("user_priority region config error: (%s)\n",
9989 cmdline_parse_token_string_t cmd_user_priority_region_set =
9990 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9992 cmdline_parse_token_string_t cmd_user_priority_region_port =
9993 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9995 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9996 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9998 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9999 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10000 cmd, "queue-region");
10001 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10002 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10003 user_priority, "UP");
10004 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10005 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10006 user_priority_id, UINT8);
10007 cmdline_parse_token_string_t cmd_user_priority_region_region =
10008 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10009 region, "region_id");
10010 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10011 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10014 cmdline_parse_inst_t cmd_user_priority_region = {
10015 .f = cmd_user_priority_region_parsed,
10017 .help_str = "set port <port_id> queue-region UP <value> "
10018 "region_id <value>: Set the mapping of User Priority (UP) "
10019 "to queue region (region_id) ",
10021 (void *)&cmd_user_priority_region_set,
10022 (void *)&cmd_user_priority_region_port,
10023 (void *)&cmd_user_priority_region_port_index,
10024 (void *)&cmd_user_priority_region_cmd,
10025 (void *)&cmd_user_priority_region_UP,
10026 (void *)&cmd_user_priority_region_UP_id,
10027 (void *)&cmd_user_priority_region_region,
10028 (void *)&cmd_user_priority_region_region_id,
10033 /* *** flush all queue region related configuration *** */
10034 struct cmd_flush_queue_region_result {
10035 cmdline_fixed_string_t set;
10036 cmdline_fixed_string_t port;
10038 cmdline_fixed_string_t cmd;
10039 cmdline_fixed_string_t flush;
10040 cmdline_fixed_string_t what;
10044 cmd_flush_queue_region_parsed(void *parsed_result,
10045 __attribute__((unused)) struct cmdline *cl,
10046 __attribute__((unused)) void *data)
10048 struct cmd_flush_queue_region_result *res = parsed_result;
10049 int ret = -ENOTSUP;
10050 #ifdef RTE_LIBRTE_I40E_PMD
10051 struct rte_pmd_i40e_queue_region_conf region_conf;
10052 enum rte_pmd_i40e_queue_region_op op_type;
10055 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10058 #ifdef RTE_LIBRTE_I40E_PMD
10059 memset(®ion_conf, 0, sizeof(region_conf));
10061 if (strcmp(res->what, "on") == 0)
10062 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10064 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10066 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10067 op_type, ®ion_conf);
10074 printf("function not implemented or supported\n");
10077 printf("queue region config flush error: (%s)\n",
10082 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10083 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10085 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10086 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10088 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10089 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10091 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10092 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10093 cmd, "queue-region");
10094 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10095 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10097 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10098 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10101 cmdline_parse_inst_t cmd_flush_queue_region = {
10102 .f = cmd_flush_queue_region_parsed,
10104 .help_str = "set port <port_id> queue-region flush on|off"
10105 ": flush all queue region related configuration",
10107 (void *)&cmd_flush_queue_region_set,
10108 (void *)&cmd_flush_queue_region_port,
10109 (void *)&cmd_flush_queue_region_port_index,
10110 (void *)&cmd_flush_queue_region_cmd,
10111 (void *)&cmd_flush_queue_region_flush,
10112 (void *)&cmd_flush_queue_region_what,
10117 /* *** get all queue region related configuration info *** */
10118 struct cmd_show_queue_region_info {
10119 cmdline_fixed_string_t show;
10120 cmdline_fixed_string_t port;
10122 cmdline_fixed_string_t cmd;
10126 cmd_show_queue_region_info_parsed(void *parsed_result,
10127 __attribute__((unused)) struct cmdline *cl,
10128 __attribute__((unused)) void *data)
10130 struct cmd_show_queue_region_info *res = parsed_result;
10131 int ret = -ENOTSUP;
10132 #ifdef RTE_LIBRTE_I40E_PMD
10133 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10134 enum rte_pmd_i40e_queue_region_op op_type;
10137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10140 #ifdef RTE_LIBRTE_I40E_PMD
10141 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10143 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10145 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10146 op_type, &rte_pmd_regions);
10148 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10155 printf("function not implemented or supported\n");
10158 printf("queue region config info show error: (%s)\n",
10163 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10164 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10166 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10167 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10169 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10170 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10172 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10173 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10174 cmd, "queue-region");
10176 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10177 .f = cmd_show_queue_region_info_parsed,
10179 .help_str = "show port <port_id> queue-region"
10180 ": show all queue region related configuration info",
10182 (void *)&cmd_show_queue_region_info_get,
10183 (void *)&cmd_show_queue_region_info_port,
10184 (void *)&cmd_show_queue_region_info_port_index,
10185 (void *)&cmd_show_queue_region_info_cmd,
10190 /* *** ADD/REMOVE A 2tuple FILTER *** */
10191 struct cmd_2tuple_filter_result {
10192 cmdline_fixed_string_t filter;
10194 cmdline_fixed_string_t ops;
10195 cmdline_fixed_string_t dst_port;
10196 uint16_t dst_port_value;
10197 cmdline_fixed_string_t protocol;
10198 uint8_t protocol_value;
10199 cmdline_fixed_string_t mask;
10200 uint8_t mask_value;
10201 cmdline_fixed_string_t tcp_flags;
10202 uint8_t tcp_flags_value;
10203 cmdline_fixed_string_t priority;
10204 uint8_t priority_value;
10205 cmdline_fixed_string_t queue;
10210 cmd_2tuple_filter_parsed(void *parsed_result,
10211 __attribute__((unused)) struct cmdline *cl,
10212 __attribute__((unused)) void *data)
10214 struct rte_eth_ntuple_filter filter;
10215 struct cmd_2tuple_filter_result *res = parsed_result;
10218 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10220 printf("ntuple filter is not supported on port %u.\n",
10225 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10227 filter.flags = RTE_2TUPLE_FLAGS;
10228 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10229 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10230 filter.proto = res->protocol_value;
10231 filter.priority = res->priority_value;
10232 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10233 printf("nonzero tcp_flags is only meaningful"
10234 " when protocol is TCP.\n");
10237 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10238 printf("invalid TCP flags.\n");
10242 if (res->tcp_flags_value != 0) {
10243 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10244 filter.tcp_flags = res->tcp_flags_value;
10247 /* need convert to big endian. */
10248 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10249 filter.queue = res->queue_id;
10251 if (!strcmp(res->ops, "add"))
10252 ret = rte_eth_dev_filter_ctrl(res->port_id,
10253 RTE_ETH_FILTER_NTUPLE,
10254 RTE_ETH_FILTER_ADD,
10257 ret = rte_eth_dev_filter_ctrl(res->port_id,
10258 RTE_ETH_FILTER_NTUPLE,
10259 RTE_ETH_FILTER_DELETE,
10262 printf("2tuple filter programming error: (%s)\n",
10267 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10268 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10269 filter, "2tuple_filter");
10270 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10271 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10273 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10274 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10276 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10277 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10278 dst_port, "dst_port");
10279 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10280 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10281 dst_port_value, UINT16);
10282 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10283 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10284 protocol, "protocol");
10285 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10286 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10287 protocol_value, UINT8);
10288 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10289 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10291 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10292 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10294 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10295 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10296 tcp_flags, "tcp_flags");
10297 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10298 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10299 tcp_flags_value, UINT8);
10300 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10301 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10302 priority, "priority");
10303 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10304 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10305 priority_value, UINT8);
10306 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10307 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10309 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10310 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10313 cmdline_parse_inst_t cmd_2tuple_filter = {
10314 .f = cmd_2tuple_filter_parsed,
10316 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10317 "<value> mask <value> tcp_flags <value> priority <value> queue "
10318 "<queue_id>: Add a 2tuple filter",
10320 (void *)&cmd_2tuple_filter_filter,
10321 (void *)&cmd_2tuple_filter_port_id,
10322 (void *)&cmd_2tuple_filter_ops,
10323 (void *)&cmd_2tuple_filter_dst_port,
10324 (void *)&cmd_2tuple_filter_dst_port_value,
10325 (void *)&cmd_2tuple_filter_protocol,
10326 (void *)&cmd_2tuple_filter_protocol_value,
10327 (void *)&cmd_2tuple_filter_mask,
10328 (void *)&cmd_2tuple_filter_mask_value,
10329 (void *)&cmd_2tuple_filter_tcp_flags,
10330 (void *)&cmd_2tuple_filter_tcp_flags_value,
10331 (void *)&cmd_2tuple_filter_priority,
10332 (void *)&cmd_2tuple_filter_priority_value,
10333 (void *)&cmd_2tuple_filter_queue,
10334 (void *)&cmd_2tuple_filter_queue_id,
10339 /* *** ADD/REMOVE A 5tuple FILTER *** */
10340 struct cmd_5tuple_filter_result {
10341 cmdline_fixed_string_t filter;
10343 cmdline_fixed_string_t ops;
10344 cmdline_fixed_string_t dst_ip;
10345 cmdline_ipaddr_t dst_ip_value;
10346 cmdline_fixed_string_t src_ip;
10347 cmdline_ipaddr_t src_ip_value;
10348 cmdline_fixed_string_t dst_port;
10349 uint16_t dst_port_value;
10350 cmdline_fixed_string_t src_port;
10351 uint16_t src_port_value;
10352 cmdline_fixed_string_t protocol;
10353 uint8_t protocol_value;
10354 cmdline_fixed_string_t mask;
10355 uint8_t mask_value;
10356 cmdline_fixed_string_t tcp_flags;
10357 uint8_t tcp_flags_value;
10358 cmdline_fixed_string_t priority;
10359 uint8_t priority_value;
10360 cmdline_fixed_string_t queue;
10365 cmd_5tuple_filter_parsed(void *parsed_result,
10366 __attribute__((unused)) struct cmdline *cl,
10367 __attribute__((unused)) void *data)
10369 struct rte_eth_ntuple_filter filter;
10370 struct cmd_5tuple_filter_result *res = parsed_result;
10373 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10375 printf("ntuple filter is not supported on port %u.\n",
10380 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10382 filter.flags = RTE_5TUPLE_FLAGS;
10383 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10384 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10385 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10386 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10387 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10388 filter.proto = res->protocol_value;
10389 filter.priority = res->priority_value;
10390 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10391 printf("nonzero tcp_flags is only meaningful"
10392 " when protocol is TCP.\n");
10395 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10396 printf("invalid TCP flags.\n");
10400 if (res->tcp_flags_value != 0) {
10401 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10402 filter.tcp_flags = res->tcp_flags_value;
10405 if (res->dst_ip_value.family == AF_INET)
10406 /* no need to convert, already big endian. */
10407 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10409 if (filter.dst_ip_mask == 0) {
10410 printf("can not support ipv6 involved compare.\n");
10416 if (res->src_ip_value.family == AF_INET)
10417 /* no need to convert, already big endian. */
10418 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10420 if (filter.src_ip_mask == 0) {
10421 printf("can not support ipv6 involved compare.\n");
10426 /* need convert to big endian. */
10427 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10428 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10429 filter.queue = res->queue_id;
10431 if (!strcmp(res->ops, "add"))
10432 ret = rte_eth_dev_filter_ctrl(res->port_id,
10433 RTE_ETH_FILTER_NTUPLE,
10434 RTE_ETH_FILTER_ADD,
10437 ret = rte_eth_dev_filter_ctrl(res->port_id,
10438 RTE_ETH_FILTER_NTUPLE,
10439 RTE_ETH_FILTER_DELETE,
10442 printf("5tuple filter programming error: (%s)\n",
10446 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10447 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10448 filter, "5tuple_filter");
10449 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10450 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10452 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10453 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10455 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10456 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10458 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10459 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10461 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10462 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10464 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10465 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10467 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10468 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10469 dst_port, "dst_port");
10470 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10471 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10472 dst_port_value, UINT16);
10473 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10474 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10475 src_port, "src_port");
10476 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10477 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10478 src_port_value, UINT16);
10479 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10480 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10481 protocol, "protocol");
10482 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10483 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10484 protocol_value, UINT8);
10485 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10486 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10488 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10489 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10491 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10492 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10493 tcp_flags, "tcp_flags");
10494 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10495 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10496 tcp_flags_value, UINT8);
10497 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10498 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10499 priority, "priority");
10500 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10501 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10502 priority_value, UINT8);
10503 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10504 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10506 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10507 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10510 cmdline_parse_inst_t cmd_5tuple_filter = {
10511 .f = cmd_5tuple_filter_parsed,
10513 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10514 "src_ip <value> dst_port <value> src_port <value> "
10515 "protocol <value> mask <value> tcp_flags <value> "
10516 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10518 (void *)&cmd_5tuple_filter_filter,
10519 (void *)&cmd_5tuple_filter_port_id,
10520 (void *)&cmd_5tuple_filter_ops,
10521 (void *)&cmd_5tuple_filter_dst_ip,
10522 (void *)&cmd_5tuple_filter_dst_ip_value,
10523 (void *)&cmd_5tuple_filter_src_ip,
10524 (void *)&cmd_5tuple_filter_src_ip_value,
10525 (void *)&cmd_5tuple_filter_dst_port,
10526 (void *)&cmd_5tuple_filter_dst_port_value,
10527 (void *)&cmd_5tuple_filter_src_port,
10528 (void *)&cmd_5tuple_filter_src_port_value,
10529 (void *)&cmd_5tuple_filter_protocol,
10530 (void *)&cmd_5tuple_filter_protocol_value,
10531 (void *)&cmd_5tuple_filter_mask,
10532 (void *)&cmd_5tuple_filter_mask_value,
10533 (void *)&cmd_5tuple_filter_tcp_flags,
10534 (void *)&cmd_5tuple_filter_tcp_flags_value,
10535 (void *)&cmd_5tuple_filter_priority,
10536 (void *)&cmd_5tuple_filter_priority_value,
10537 (void *)&cmd_5tuple_filter_queue,
10538 (void *)&cmd_5tuple_filter_queue_id,
10543 /* *** ADD/REMOVE A flex FILTER *** */
10544 struct cmd_flex_filter_result {
10545 cmdline_fixed_string_t filter;
10546 cmdline_fixed_string_t ops;
10548 cmdline_fixed_string_t len;
10550 cmdline_fixed_string_t bytes;
10551 cmdline_fixed_string_t bytes_value;
10552 cmdline_fixed_string_t mask;
10553 cmdline_fixed_string_t mask_value;
10554 cmdline_fixed_string_t priority;
10555 uint8_t priority_value;
10556 cmdline_fixed_string_t queue;
10560 static int xdigit2val(unsigned char c)
10565 else if (isupper(c))
10566 val = c - 'A' + 10;
10568 val = c - 'a' + 10;
10573 cmd_flex_filter_parsed(void *parsed_result,
10574 __attribute__((unused)) struct cmdline *cl,
10575 __attribute__((unused)) void *data)
10578 struct rte_eth_flex_filter filter;
10579 struct cmd_flex_filter_result *res = parsed_result;
10580 char *bytes_ptr, *mask_ptr;
10581 uint16_t len, i, j = 0;
10586 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10587 printf("the len exceed the max length 128\n");
10590 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10591 filter.len = res->len_value;
10592 filter.priority = res->priority_value;
10593 filter.queue = res->queue_id;
10594 bytes_ptr = res->bytes_value;
10595 mask_ptr = res->mask_value;
10597 /* translate bytes string to array. */
10598 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10599 (bytes_ptr[1] == 'X')))
10601 len = strnlen(bytes_ptr, res->len_value * 2);
10602 if (len == 0 || (len % 8 != 0)) {
10603 printf("please check len and bytes input\n");
10606 for (i = 0; i < len; i++) {
10608 if (isxdigit(c) == 0) {
10609 /* invalid characters. */
10610 printf("invalid input\n");
10613 val = xdigit2val(c);
10616 filter.bytes[j] = byte;
10617 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10624 /* translate mask string to uint8_t array. */
10625 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10626 (mask_ptr[1] == 'X')))
10628 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10630 printf("invalid input\n");
10635 for (i = 0; i < len; i++) {
10637 if (isxdigit(c) == 0) {
10638 /* invalid characters. */
10639 printf("invalid input\n");
10642 val = xdigit2val(c);
10645 filter.mask[j] = byte;
10646 printf("mask[%d]:%02x ", j, filter.mask[j]);
10654 if (!strcmp(res->ops, "add"))
10655 ret = rte_eth_dev_filter_ctrl(res->port_id,
10656 RTE_ETH_FILTER_FLEXIBLE,
10657 RTE_ETH_FILTER_ADD,
10660 ret = rte_eth_dev_filter_ctrl(res->port_id,
10661 RTE_ETH_FILTER_FLEXIBLE,
10662 RTE_ETH_FILTER_DELETE,
10666 printf("flex filter setting error: (%s)\n", strerror(-ret));
10669 cmdline_parse_token_string_t cmd_flex_filter_filter =
10670 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10671 filter, "flex_filter");
10672 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10673 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10675 cmdline_parse_token_string_t cmd_flex_filter_ops =
10676 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10678 cmdline_parse_token_string_t cmd_flex_filter_len =
10679 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10681 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10682 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10684 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10685 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10687 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10688 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10689 bytes_value, NULL);
10690 cmdline_parse_token_string_t cmd_flex_filter_mask =
10691 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10693 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10694 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10696 cmdline_parse_token_string_t cmd_flex_filter_priority =
10697 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10698 priority, "priority");
10699 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10700 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10701 priority_value, UINT8);
10702 cmdline_parse_token_string_t cmd_flex_filter_queue =
10703 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10705 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10706 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10708 cmdline_parse_inst_t cmd_flex_filter = {
10709 .f = cmd_flex_filter_parsed,
10711 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10712 "<value> mask <value> priority <value> queue <queue_id>: "
10713 "Add/Del a flex filter",
10715 (void *)&cmd_flex_filter_filter,
10716 (void *)&cmd_flex_filter_port_id,
10717 (void *)&cmd_flex_filter_ops,
10718 (void *)&cmd_flex_filter_len,
10719 (void *)&cmd_flex_filter_len_value,
10720 (void *)&cmd_flex_filter_bytes,
10721 (void *)&cmd_flex_filter_bytes_value,
10722 (void *)&cmd_flex_filter_mask,
10723 (void *)&cmd_flex_filter_mask_value,
10724 (void *)&cmd_flex_filter_priority,
10725 (void *)&cmd_flex_filter_priority_value,
10726 (void *)&cmd_flex_filter_queue,
10727 (void *)&cmd_flex_filter_queue_id,
10732 /* *** Filters Control *** */
10734 /* *** deal with ethertype filter *** */
10735 struct cmd_ethertype_filter_result {
10736 cmdline_fixed_string_t filter;
10738 cmdline_fixed_string_t ops;
10739 cmdline_fixed_string_t mac;
10740 struct rte_ether_addr mac_addr;
10741 cmdline_fixed_string_t ethertype;
10742 uint16_t ethertype_value;
10743 cmdline_fixed_string_t drop;
10744 cmdline_fixed_string_t queue;
10748 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10749 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10750 filter, "ethertype_filter");
10751 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10752 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10754 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10755 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10757 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10758 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10759 mac, "mac_addr#mac_ignr");
10760 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10761 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10763 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10764 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10765 ethertype, "ethertype");
10766 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10767 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10768 ethertype_value, UINT16);
10769 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10770 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10772 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10773 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10775 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10776 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10780 cmd_ethertype_filter_parsed(void *parsed_result,
10781 __attribute__((unused)) struct cmdline *cl,
10782 __attribute__((unused)) void *data)
10784 struct cmd_ethertype_filter_result *res = parsed_result;
10785 struct rte_eth_ethertype_filter filter;
10788 ret = rte_eth_dev_filter_supported(res->port_id,
10789 RTE_ETH_FILTER_ETHERTYPE);
10791 printf("ethertype filter is not supported on port %u.\n",
10796 memset(&filter, 0, sizeof(filter));
10797 if (!strcmp(res->mac, "mac_addr")) {
10798 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10799 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10800 sizeof(struct rte_ether_addr));
10802 if (!strcmp(res->drop, "drop"))
10803 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10804 filter.ether_type = res->ethertype_value;
10805 filter.queue = res->queue_id;
10807 if (!strcmp(res->ops, "add"))
10808 ret = rte_eth_dev_filter_ctrl(res->port_id,
10809 RTE_ETH_FILTER_ETHERTYPE,
10810 RTE_ETH_FILTER_ADD,
10813 ret = rte_eth_dev_filter_ctrl(res->port_id,
10814 RTE_ETH_FILTER_ETHERTYPE,
10815 RTE_ETH_FILTER_DELETE,
10818 printf("ethertype filter programming error: (%s)\n",
10822 cmdline_parse_inst_t cmd_ethertype_filter = {
10823 .f = cmd_ethertype_filter_parsed,
10825 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10826 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10827 "Add or delete an ethertype filter entry",
10829 (void *)&cmd_ethertype_filter_filter,
10830 (void *)&cmd_ethertype_filter_port_id,
10831 (void *)&cmd_ethertype_filter_ops,
10832 (void *)&cmd_ethertype_filter_mac,
10833 (void *)&cmd_ethertype_filter_mac_addr,
10834 (void *)&cmd_ethertype_filter_ethertype,
10835 (void *)&cmd_ethertype_filter_ethertype_value,
10836 (void *)&cmd_ethertype_filter_drop,
10837 (void *)&cmd_ethertype_filter_queue,
10838 (void *)&cmd_ethertype_filter_queue_id,
10843 /* *** deal with flow director filter *** */
10844 struct cmd_flow_director_result {
10845 cmdline_fixed_string_t flow_director_filter;
10847 cmdline_fixed_string_t mode;
10848 cmdline_fixed_string_t mode_value;
10849 cmdline_fixed_string_t ops;
10850 cmdline_fixed_string_t flow;
10851 cmdline_fixed_string_t flow_type;
10852 cmdline_fixed_string_t ether;
10853 uint16_t ether_type;
10854 cmdline_fixed_string_t src;
10855 cmdline_ipaddr_t ip_src;
10857 cmdline_fixed_string_t dst;
10858 cmdline_ipaddr_t ip_dst;
10860 cmdline_fixed_string_t verify_tag;
10861 uint32_t verify_tag_value;
10862 cmdline_fixed_string_t tos;
10864 cmdline_fixed_string_t proto;
10865 uint8_t proto_value;
10866 cmdline_fixed_string_t ttl;
10868 cmdline_fixed_string_t vlan;
10869 uint16_t vlan_value;
10870 cmdline_fixed_string_t flexbytes;
10871 cmdline_fixed_string_t flexbytes_value;
10872 cmdline_fixed_string_t pf_vf;
10873 cmdline_fixed_string_t drop;
10874 cmdline_fixed_string_t queue;
10876 cmdline_fixed_string_t fd_id;
10877 uint32_t fd_id_value;
10878 cmdline_fixed_string_t mac;
10879 struct rte_ether_addr mac_addr;
10880 cmdline_fixed_string_t tunnel;
10881 cmdline_fixed_string_t tunnel_type;
10882 cmdline_fixed_string_t tunnel_id;
10883 uint32_t tunnel_id_value;
10884 cmdline_fixed_string_t packet;
10889 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10892 const char *p, *p0 = q_arg;
10894 unsigned long int_fld;
10895 char *str_fld[max_num];
10900 p = strchr(p0, '(');
10904 p0 = strchr(p, ')');
10909 if (size >= sizeof(s))
10912 snprintf(s, sizeof(s), "%.*s", size, p);
10913 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10914 if (ret < 0 || ret > max_num)
10916 for (i = 0; i < ret; i++) {
10918 int_fld = strtoul(str_fld[i], &end, 0);
10919 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10921 flexbytes[i] = (uint8_t)int_fld;
10927 str2flowtype(char *string)
10930 static const struct {
10933 } flowtype_str[] = {
10934 {"raw", RTE_ETH_FLOW_RAW},
10935 {"ipv4", RTE_ETH_FLOW_IPV4},
10936 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10937 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10938 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10939 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10940 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10941 {"ipv6", RTE_ETH_FLOW_IPV6},
10942 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10943 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10944 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10945 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10946 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10947 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10950 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10951 if (!strcmp(flowtype_str[i].str, string))
10952 return flowtype_str[i].type;
10955 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10956 return (uint16_t)atoi(string);
10958 return RTE_ETH_FLOW_UNKNOWN;
10961 static enum rte_eth_fdir_tunnel_type
10962 str2fdir_tunneltype(char *string)
10966 static const struct {
10968 enum rte_eth_fdir_tunnel_type type;
10969 } tunneltype_str[] = {
10970 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10971 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10974 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10975 if (!strcmp(tunneltype_str[i].str, string))
10976 return tunneltype_str[i].type;
10978 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10981 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10983 if ((ip_addr).family == AF_INET) \
10984 (ip) = (ip_addr).addr.ipv4.s_addr; \
10986 printf("invalid parameter.\n"); \
10991 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10993 if ((ip_addr).family == AF_INET6) \
10994 rte_memcpy(&(ip), \
10995 &((ip_addr).addr.ipv6), \
10996 sizeof(struct in6_addr)); \
10998 printf("invalid parameter.\n"); \
11004 cmd_flow_director_filter_parsed(void *parsed_result,
11005 __attribute__((unused)) struct cmdline *cl,
11006 __attribute__((unused)) void *data)
11008 struct cmd_flow_director_result *res = parsed_result;
11009 struct rte_eth_fdir_filter entry;
11010 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11012 unsigned long vf_id;
11015 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11017 printf("flow director is not supported on port %u.\n",
11021 memset(flexbytes, 0, sizeof(flexbytes));
11022 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11024 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11025 if (strcmp(res->mode_value, "MAC-VLAN")) {
11026 printf("Please set mode to MAC-VLAN.\n");
11029 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11030 if (strcmp(res->mode_value, "Tunnel")) {
11031 printf("Please set mode to Tunnel.\n");
11035 if (!strcmp(res->mode_value, "raw")) {
11036 #ifdef RTE_LIBRTE_I40E_PMD
11037 struct rte_pmd_i40e_flow_type_mapping
11038 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11039 struct rte_pmd_i40e_pkt_template_conf conf;
11040 uint16_t flow_type = str2flowtype(res->flow_type);
11041 uint16_t i, port = res->port_id;
11044 memset(&conf, 0, sizeof(conf));
11046 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11047 printf("Invalid flow type specified.\n");
11050 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11054 if (mapping[flow_type].pctype == 0ULL) {
11055 printf("Invalid flow type specified.\n");
11058 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11059 if (mapping[flow_type].pctype & (1ULL << i)) {
11060 conf.input.pctype = i;
11065 conf.input.packet = open_file(res->filepath,
11066 &conf.input.length);
11067 if (!conf.input.packet)
11069 if (!strcmp(res->drop, "drop"))
11070 conf.action.behavior =
11071 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11073 conf.action.behavior =
11074 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11075 conf.action.report_status =
11076 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11077 conf.action.rx_queue = res->queue_id;
11078 conf.soft_id = res->fd_id_value;
11079 add = strcmp(res->ops, "del") ? 1 : 0;
11080 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11084 printf("flow director config error: (%s)\n",
11086 close_file(conf.input.packet);
11089 } else if (strcmp(res->mode_value, "IP")) {
11090 printf("Please set mode to IP or raw.\n");
11093 entry.input.flow_type = str2flowtype(res->flow_type);
11096 ret = parse_flexbytes(res->flexbytes_value,
11098 RTE_ETH_FDIR_MAX_FLEXLEN);
11100 printf("error: Cannot parse flexbytes input.\n");
11104 switch (entry.input.flow_type) {
11105 case RTE_ETH_FLOW_FRAG_IPV4:
11106 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11107 entry.input.flow.ip4_flow.proto = res->proto_value;
11109 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11110 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11111 IPV4_ADDR_TO_UINT(res->ip_dst,
11112 entry.input.flow.ip4_flow.dst_ip);
11113 IPV4_ADDR_TO_UINT(res->ip_src,
11114 entry.input.flow.ip4_flow.src_ip);
11115 entry.input.flow.ip4_flow.tos = res->tos_value;
11116 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11117 /* need convert to big endian. */
11118 entry.input.flow.udp4_flow.dst_port =
11119 rte_cpu_to_be_16(res->port_dst);
11120 entry.input.flow.udp4_flow.src_port =
11121 rte_cpu_to_be_16(res->port_src);
11123 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11124 IPV4_ADDR_TO_UINT(res->ip_dst,
11125 entry.input.flow.sctp4_flow.ip.dst_ip);
11126 IPV4_ADDR_TO_UINT(res->ip_src,
11127 entry.input.flow.sctp4_flow.ip.src_ip);
11128 entry.input.flow.ip4_flow.tos = res->tos_value;
11129 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11130 /* need convert to big endian. */
11131 entry.input.flow.sctp4_flow.dst_port =
11132 rte_cpu_to_be_16(res->port_dst);
11133 entry.input.flow.sctp4_flow.src_port =
11134 rte_cpu_to_be_16(res->port_src);
11135 entry.input.flow.sctp4_flow.verify_tag =
11136 rte_cpu_to_be_32(res->verify_tag_value);
11138 case RTE_ETH_FLOW_FRAG_IPV6:
11139 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11140 entry.input.flow.ipv6_flow.proto = res->proto_value;
11142 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11143 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11144 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11145 entry.input.flow.ipv6_flow.dst_ip);
11146 IPV6_ADDR_TO_ARRAY(res->ip_src,
11147 entry.input.flow.ipv6_flow.src_ip);
11148 entry.input.flow.ipv6_flow.tc = res->tos_value;
11149 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11150 /* need convert to big endian. */
11151 entry.input.flow.udp6_flow.dst_port =
11152 rte_cpu_to_be_16(res->port_dst);
11153 entry.input.flow.udp6_flow.src_port =
11154 rte_cpu_to_be_16(res->port_src);
11156 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11157 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11158 entry.input.flow.sctp6_flow.ip.dst_ip);
11159 IPV6_ADDR_TO_ARRAY(res->ip_src,
11160 entry.input.flow.sctp6_flow.ip.src_ip);
11161 entry.input.flow.ipv6_flow.tc = res->tos_value;
11162 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11163 /* need convert to big endian. */
11164 entry.input.flow.sctp6_flow.dst_port =
11165 rte_cpu_to_be_16(res->port_dst);
11166 entry.input.flow.sctp6_flow.src_port =
11167 rte_cpu_to_be_16(res->port_src);
11168 entry.input.flow.sctp6_flow.verify_tag =
11169 rte_cpu_to_be_32(res->verify_tag_value);
11171 case RTE_ETH_FLOW_L2_PAYLOAD:
11172 entry.input.flow.l2_flow.ether_type =
11173 rte_cpu_to_be_16(res->ether_type);
11179 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11180 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11182 sizeof(struct rte_ether_addr));
11184 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11185 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11187 sizeof(struct rte_ether_addr));
11188 entry.input.flow.tunnel_flow.tunnel_type =
11189 str2fdir_tunneltype(res->tunnel_type);
11190 entry.input.flow.tunnel_flow.tunnel_id =
11191 rte_cpu_to_be_32(res->tunnel_id_value);
11194 rte_memcpy(entry.input.flow_ext.flexbytes,
11196 RTE_ETH_FDIR_MAX_FLEXLEN);
11198 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11200 entry.action.flex_off = 0; /*use 0 by default */
11201 if (!strcmp(res->drop, "drop"))
11202 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11204 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11206 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11207 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11208 if (!strcmp(res->pf_vf, "pf"))
11209 entry.input.flow_ext.is_vf = 0;
11210 else if (!strncmp(res->pf_vf, "vf", 2)) {
11211 struct rte_eth_dev_info dev_info;
11213 ret = eth_dev_info_get_print_err(res->port_id,
11219 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11220 if (errno != 0 || *end != '\0' ||
11221 vf_id >= dev_info.max_vfs) {
11222 printf("invalid parameter %s.\n", res->pf_vf);
11225 entry.input.flow_ext.is_vf = 1;
11226 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11228 printf("invalid parameter %s.\n", res->pf_vf);
11233 /* set to report FD ID by default */
11234 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11235 entry.action.rx_queue = res->queue_id;
11236 entry.soft_id = res->fd_id_value;
11237 if (!strcmp(res->ops, "add"))
11238 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11239 RTE_ETH_FILTER_ADD, &entry);
11240 else if (!strcmp(res->ops, "del"))
11241 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11242 RTE_ETH_FILTER_DELETE, &entry);
11244 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11245 RTE_ETH_FILTER_UPDATE, &entry);
11247 printf("flow director programming error: (%s)\n",
11251 cmdline_parse_token_string_t cmd_flow_director_filter =
11252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11253 flow_director_filter, "flow_director_filter");
11254 cmdline_parse_token_num_t cmd_flow_director_port_id =
11255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11257 cmdline_parse_token_string_t cmd_flow_director_ops =
11258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11259 ops, "add#del#update");
11260 cmdline_parse_token_string_t cmd_flow_director_flow =
11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11263 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11266 cmdline_parse_token_string_t cmd_flow_director_ether =
11267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11269 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11270 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11271 ether_type, UINT16);
11272 cmdline_parse_token_string_t cmd_flow_director_src =
11273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11275 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11276 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11278 cmdline_parse_token_num_t cmd_flow_director_port_src =
11279 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11281 cmdline_parse_token_string_t cmd_flow_director_dst =
11282 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11284 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11285 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11287 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11288 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11290 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11292 verify_tag, "verify_tag");
11293 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11294 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11295 verify_tag_value, UINT32);
11296 cmdline_parse_token_string_t cmd_flow_director_tos =
11297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11299 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11300 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11302 cmdline_parse_token_string_t cmd_flow_director_proto =
11303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11305 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11306 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11307 proto_value, UINT8);
11308 cmdline_parse_token_string_t cmd_flow_director_ttl =
11309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11311 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11314 cmdline_parse_token_string_t cmd_flow_director_vlan =
11315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11317 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11318 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11319 vlan_value, UINT16);
11320 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11321 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11322 flexbytes, "flexbytes");
11323 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11324 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11325 flexbytes_value, NULL);
11326 cmdline_parse_token_string_t cmd_flow_director_drop =
11327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11329 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11330 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11332 cmdline_parse_token_string_t cmd_flow_director_queue =
11333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11335 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11336 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11338 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11341 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11342 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11343 fd_id_value, UINT32);
11345 cmdline_parse_token_string_t cmd_flow_director_mode =
11346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11348 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11351 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11353 mode_value, "MAC-VLAN");
11354 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11355 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11356 mode_value, "Tunnel");
11357 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11359 mode_value, "raw");
11360 cmdline_parse_token_string_t cmd_flow_director_mac =
11361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11363 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11364 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11366 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11369 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11371 tunnel_type, "NVGRE#VxLAN");
11372 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11374 tunnel_id, "tunnel-id");
11375 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11376 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11377 tunnel_id_value, UINT32);
11378 cmdline_parse_token_string_t cmd_flow_director_packet =
11379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11381 cmdline_parse_token_string_t cmd_flow_director_filepath =
11382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11385 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11386 .f = cmd_flow_director_filter_parsed,
11388 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11389 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11390 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11391 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11392 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11393 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11394 "fd_id <fd_id_value>: "
11395 "Add or delete an ip flow director entry on NIC",
11397 (void *)&cmd_flow_director_filter,
11398 (void *)&cmd_flow_director_port_id,
11399 (void *)&cmd_flow_director_mode,
11400 (void *)&cmd_flow_director_mode_ip,
11401 (void *)&cmd_flow_director_ops,
11402 (void *)&cmd_flow_director_flow,
11403 (void *)&cmd_flow_director_flow_type,
11404 (void *)&cmd_flow_director_src,
11405 (void *)&cmd_flow_director_ip_src,
11406 (void *)&cmd_flow_director_dst,
11407 (void *)&cmd_flow_director_ip_dst,
11408 (void *)&cmd_flow_director_tos,
11409 (void *)&cmd_flow_director_tos_value,
11410 (void *)&cmd_flow_director_proto,
11411 (void *)&cmd_flow_director_proto_value,
11412 (void *)&cmd_flow_director_ttl,
11413 (void *)&cmd_flow_director_ttl_value,
11414 (void *)&cmd_flow_director_vlan,
11415 (void *)&cmd_flow_director_vlan_value,
11416 (void *)&cmd_flow_director_flexbytes,
11417 (void *)&cmd_flow_director_flexbytes_value,
11418 (void *)&cmd_flow_director_drop,
11419 (void *)&cmd_flow_director_pf_vf,
11420 (void *)&cmd_flow_director_queue,
11421 (void *)&cmd_flow_director_queue_id,
11422 (void *)&cmd_flow_director_fd_id,
11423 (void *)&cmd_flow_director_fd_id_value,
11428 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11429 .f = cmd_flow_director_filter_parsed,
11431 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11432 "director entry on NIC",
11434 (void *)&cmd_flow_director_filter,
11435 (void *)&cmd_flow_director_port_id,
11436 (void *)&cmd_flow_director_mode,
11437 (void *)&cmd_flow_director_mode_ip,
11438 (void *)&cmd_flow_director_ops,
11439 (void *)&cmd_flow_director_flow,
11440 (void *)&cmd_flow_director_flow_type,
11441 (void *)&cmd_flow_director_src,
11442 (void *)&cmd_flow_director_ip_src,
11443 (void *)&cmd_flow_director_port_src,
11444 (void *)&cmd_flow_director_dst,
11445 (void *)&cmd_flow_director_ip_dst,
11446 (void *)&cmd_flow_director_port_dst,
11447 (void *)&cmd_flow_director_tos,
11448 (void *)&cmd_flow_director_tos_value,
11449 (void *)&cmd_flow_director_ttl,
11450 (void *)&cmd_flow_director_ttl_value,
11451 (void *)&cmd_flow_director_vlan,
11452 (void *)&cmd_flow_director_vlan_value,
11453 (void *)&cmd_flow_director_flexbytes,
11454 (void *)&cmd_flow_director_flexbytes_value,
11455 (void *)&cmd_flow_director_drop,
11456 (void *)&cmd_flow_director_pf_vf,
11457 (void *)&cmd_flow_director_queue,
11458 (void *)&cmd_flow_director_queue_id,
11459 (void *)&cmd_flow_director_fd_id,
11460 (void *)&cmd_flow_director_fd_id_value,
11465 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11466 .f = cmd_flow_director_filter_parsed,
11468 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11469 "director entry on NIC",
11471 (void *)&cmd_flow_director_filter,
11472 (void *)&cmd_flow_director_port_id,
11473 (void *)&cmd_flow_director_mode,
11474 (void *)&cmd_flow_director_mode_ip,
11475 (void *)&cmd_flow_director_ops,
11476 (void *)&cmd_flow_director_flow,
11477 (void *)&cmd_flow_director_flow_type,
11478 (void *)&cmd_flow_director_src,
11479 (void *)&cmd_flow_director_ip_src,
11480 (void *)&cmd_flow_director_port_src,
11481 (void *)&cmd_flow_director_dst,
11482 (void *)&cmd_flow_director_ip_dst,
11483 (void *)&cmd_flow_director_port_dst,
11484 (void *)&cmd_flow_director_verify_tag,
11485 (void *)&cmd_flow_director_verify_tag_value,
11486 (void *)&cmd_flow_director_tos,
11487 (void *)&cmd_flow_director_tos_value,
11488 (void *)&cmd_flow_director_ttl,
11489 (void *)&cmd_flow_director_ttl_value,
11490 (void *)&cmd_flow_director_vlan,
11491 (void *)&cmd_flow_director_vlan_value,
11492 (void *)&cmd_flow_director_flexbytes,
11493 (void *)&cmd_flow_director_flexbytes_value,
11494 (void *)&cmd_flow_director_drop,
11495 (void *)&cmd_flow_director_pf_vf,
11496 (void *)&cmd_flow_director_queue,
11497 (void *)&cmd_flow_director_queue_id,
11498 (void *)&cmd_flow_director_fd_id,
11499 (void *)&cmd_flow_director_fd_id_value,
11504 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11505 .f = cmd_flow_director_filter_parsed,
11507 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11508 "director entry on NIC",
11510 (void *)&cmd_flow_director_filter,
11511 (void *)&cmd_flow_director_port_id,
11512 (void *)&cmd_flow_director_mode,
11513 (void *)&cmd_flow_director_mode_ip,
11514 (void *)&cmd_flow_director_ops,
11515 (void *)&cmd_flow_director_flow,
11516 (void *)&cmd_flow_director_flow_type,
11517 (void *)&cmd_flow_director_ether,
11518 (void *)&cmd_flow_director_ether_type,
11519 (void *)&cmd_flow_director_flexbytes,
11520 (void *)&cmd_flow_director_flexbytes_value,
11521 (void *)&cmd_flow_director_drop,
11522 (void *)&cmd_flow_director_pf_vf,
11523 (void *)&cmd_flow_director_queue,
11524 (void *)&cmd_flow_director_queue_id,
11525 (void *)&cmd_flow_director_fd_id,
11526 (void *)&cmd_flow_director_fd_id_value,
11531 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11532 .f = cmd_flow_director_filter_parsed,
11534 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11535 "director entry on NIC",
11537 (void *)&cmd_flow_director_filter,
11538 (void *)&cmd_flow_director_port_id,
11539 (void *)&cmd_flow_director_mode,
11540 (void *)&cmd_flow_director_mode_mac_vlan,
11541 (void *)&cmd_flow_director_ops,
11542 (void *)&cmd_flow_director_mac,
11543 (void *)&cmd_flow_director_mac_addr,
11544 (void *)&cmd_flow_director_vlan,
11545 (void *)&cmd_flow_director_vlan_value,
11546 (void *)&cmd_flow_director_flexbytes,
11547 (void *)&cmd_flow_director_flexbytes_value,
11548 (void *)&cmd_flow_director_drop,
11549 (void *)&cmd_flow_director_queue,
11550 (void *)&cmd_flow_director_queue_id,
11551 (void *)&cmd_flow_director_fd_id,
11552 (void *)&cmd_flow_director_fd_id_value,
11557 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11558 .f = cmd_flow_director_filter_parsed,
11560 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11561 "director entry on NIC",
11563 (void *)&cmd_flow_director_filter,
11564 (void *)&cmd_flow_director_port_id,
11565 (void *)&cmd_flow_director_mode,
11566 (void *)&cmd_flow_director_mode_tunnel,
11567 (void *)&cmd_flow_director_ops,
11568 (void *)&cmd_flow_director_mac,
11569 (void *)&cmd_flow_director_mac_addr,
11570 (void *)&cmd_flow_director_vlan,
11571 (void *)&cmd_flow_director_vlan_value,
11572 (void *)&cmd_flow_director_tunnel,
11573 (void *)&cmd_flow_director_tunnel_type,
11574 (void *)&cmd_flow_director_tunnel_id,
11575 (void *)&cmd_flow_director_tunnel_id_value,
11576 (void *)&cmd_flow_director_flexbytes,
11577 (void *)&cmd_flow_director_flexbytes_value,
11578 (void *)&cmd_flow_director_drop,
11579 (void *)&cmd_flow_director_queue,
11580 (void *)&cmd_flow_director_queue_id,
11581 (void *)&cmd_flow_director_fd_id,
11582 (void *)&cmd_flow_director_fd_id_value,
11587 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11588 .f = cmd_flow_director_filter_parsed,
11590 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11591 "director entry on NIC",
11593 (void *)&cmd_flow_director_filter,
11594 (void *)&cmd_flow_director_port_id,
11595 (void *)&cmd_flow_director_mode,
11596 (void *)&cmd_flow_director_mode_raw,
11597 (void *)&cmd_flow_director_ops,
11598 (void *)&cmd_flow_director_flow,
11599 (void *)&cmd_flow_director_flow_type,
11600 (void *)&cmd_flow_director_drop,
11601 (void *)&cmd_flow_director_queue,
11602 (void *)&cmd_flow_director_queue_id,
11603 (void *)&cmd_flow_director_fd_id,
11604 (void *)&cmd_flow_director_fd_id_value,
11605 (void *)&cmd_flow_director_packet,
11606 (void *)&cmd_flow_director_filepath,
11611 struct cmd_flush_flow_director_result {
11612 cmdline_fixed_string_t flush_flow_director;
11616 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11617 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11618 flush_flow_director, "flush_flow_director");
11619 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11620 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11624 cmd_flush_flow_director_parsed(void *parsed_result,
11625 __attribute__((unused)) struct cmdline *cl,
11626 __attribute__((unused)) void *data)
11628 struct cmd_flow_director_result *res = parsed_result;
11631 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11633 printf("flow director is not supported on port %u.\n",
11638 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11639 RTE_ETH_FILTER_FLUSH, NULL);
11641 printf("flow director table flushing error: (%s)\n",
11645 cmdline_parse_inst_t cmd_flush_flow_director = {
11646 .f = cmd_flush_flow_director_parsed,
11648 .help_str = "flush_flow_director <port_id>: "
11649 "Flush all flow director entries of a device on NIC",
11651 (void *)&cmd_flush_flow_director_flush,
11652 (void *)&cmd_flush_flow_director_port_id,
11657 /* *** deal with flow director mask *** */
11658 struct cmd_flow_director_mask_result {
11659 cmdline_fixed_string_t flow_director_mask;
11661 cmdline_fixed_string_t mode;
11662 cmdline_fixed_string_t mode_value;
11663 cmdline_fixed_string_t vlan;
11664 uint16_t vlan_mask;
11665 cmdline_fixed_string_t src_mask;
11666 cmdline_ipaddr_t ipv4_src;
11667 cmdline_ipaddr_t ipv6_src;
11669 cmdline_fixed_string_t dst_mask;
11670 cmdline_ipaddr_t ipv4_dst;
11671 cmdline_ipaddr_t ipv6_dst;
11673 cmdline_fixed_string_t mac;
11674 uint8_t mac_addr_byte_mask;
11675 cmdline_fixed_string_t tunnel_id;
11676 uint32_t tunnel_id_mask;
11677 cmdline_fixed_string_t tunnel_type;
11678 uint8_t tunnel_type_mask;
11682 cmd_flow_director_mask_parsed(void *parsed_result,
11683 __attribute__((unused)) struct cmdline *cl,
11684 __attribute__((unused)) void *data)
11686 struct cmd_flow_director_mask_result *res = parsed_result;
11687 struct rte_eth_fdir_masks *mask;
11688 struct rte_port *port;
11690 port = &ports[res->port_id];
11691 /** Check if the port is not started **/
11692 if (port->port_status != RTE_PORT_STOPPED) {
11693 printf("Please stop port %d first\n", res->port_id);
11697 mask = &port->dev_conf.fdir_conf.mask;
11699 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11700 if (strcmp(res->mode_value, "MAC-VLAN")) {
11701 printf("Please set mode to MAC-VLAN.\n");
11705 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11706 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11707 if (strcmp(res->mode_value, "Tunnel")) {
11708 printf("Please set mode to Tunnel.\n");
11712 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11713 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11714 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11715 mask->tunnel_type_mask = res->tunnel_type_mask;
11717 if (strcmp(res->mode_value, "IP")) {
11718 printf("Please set mode to IP.\n");
11722 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11723 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11724 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11725 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11726 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11727 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11728 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11731 cmd_reconfig_device_queue(res->port_id, 1, 1);
11734 cmdline_parse_token_string_t cmd_flow_director_mask =
11735 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11736 flow_director_mask, "flow_director_mask");
11737 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11738 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11740 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11741 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11743 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11744 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11745 vlan_mask, UINT16);
11746 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11747 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11748 src_mask, "src_mask");
11749 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11750 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11752 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11753 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11755 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11756 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11758 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11759 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11760 dst_mask, "dst_mask");
11761 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11762 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11764 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11765 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11767 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11768 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11771 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11774 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11777 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11779 mode_value, "MAC-VLAN");
11780 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11782 mode_value, "Tunnel");
11783 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11786 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11787 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11788 mac_addr_byte_mask, UINT8);
11789 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11791 tunnel_type, "tunnel-type");
11792 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11793 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11794 tunnel_type_mask, UINT8);
11795 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11797 tunnel_id, "tunnel-id");
11798 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11799 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11800 tunnel_id_mask, UINT32);
11802 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11803 .f = cmd_flow_director_mask_parsed,
11805 .help_str = "flow_director_mask ... : "
11806 "Set IP mode flow director's mask on NIC",
11808 (void *)&cmd_flow_director_mask,
11809 (void *)&cmd_flow_director_mask_port_id,
11810 (void *)&cmd_flow_director_mask_mode,
11811 (void *)&cmd_flow_director_mask_mode_ip,
11812 (void *)&cmd_flow_director_mask_vlan,
11813 (void *)&cmd_flow_director_mask_vlan_value,
11814 (void *)&cmd_flow_director_mask_src,
11815 (void *)&cmd_flow_director_mask_ipv4_src,
11816 (void *)&cmd_flow_director_mask_ipv6_src,
11817 (void *)&cmd_flow_director_mask_port_src,
11818 (void *)&cmd_flow_director_mask_dst,
11819 (void *)&cmd_flow_director_mask_ipv4_dst,
11820 (void *)&cmd_flow_director_mask_ipv6_dst,
11821 (void *)&cmd_flow_director_mask_port_dst,
11826 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11827 .f = cmd_flow_director_mask_parsed,
11829 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11830 "flow director's mask on NIC",
11832 (void *)&cmd_flow_director_mask,
11833 (void *)&cmd_flow_director_mask_port_id,
11834 (void *)&cmd_flow_director_mask_mode,
11835 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11836 (void *)&cmd_flow_director_mask_vlan,
11837 (void *)&cmd_flow_director_mask_vlan_value,
11842 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11843 .f = cmd_flow_director_mask_parsed,
11845 .help_str = "flow_director_mask ... : Set tunnel mode "
11846 "flow director's mask on NIC",
11848 (void *)&cmd_flow_director_mask,
11849 (void *)&cmd_flow_director_mask_port_id,
11850 (void *)&cmd_flow_director_mask_mode,
11851 (void *)&cmd_flow_director_mask_mode_tunnel,
11852 (void *)&cmd_flow_director_mask_vlan,
11853 (void *)&cmd_flow_director_mask_vlan_value,
11854 (void *)&cmd_flow_director_mask_mac,
11855 (void *)&cmd_flow_director_mask_mac_value,
11856 (void *)&cmd_flow_director_mask_tunnel_type,
11857 (void *)&cmd_flow_director_mask_tunnel_type_value,
11858 (void *)&cmd_flow_director_mask_tunnel_id,
11859 (void *)&cmd_flow_director_mask_tunnel_id_value,
11864 /* *** deal with flow director mask on flexible payload *** */
11865 struct cmd_flow_director_flex_mask_result {
11866 cmdline_fixed_string_t flow_director_flexmask;
11868 cmdline_fixed_string_t flow;
11869 cmdline_fixed_string_t flow_type;
11870 cmdline_fixed_string_t mask;
11874 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11875 __attribute__((unused)) struct cmdline *cl,
11876 __attribute__((unused)) void *data)
11878 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11879 struct rte_eth_fdir_info fdir_info;
11880 struct rte_eth_fdir_flex_mask flex_mask;
11881 struct rte_port *port;
11882 uint64_t flow_type_mask;
11886 port = &ports[res->port_id];
11887 /** Check if the port is not started **/
11888 if (port->port_status != RTE_PORT_STOPPED) {
11889 printf("Please stop port %d first\n", res->port_id);
11893 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11894 ret = parse_flexbytes(res->mask,
11896 RTE_ETH_FDIR_MAX_FLEXLEN);
11898 printf("error: Cannot parse mask input.\n");
11902 memset(&fdir_info, 0, sizeof(fdir_info));
11903 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11904 RTE_ETH_FILTER_INFO, &fdir_info);
11906 printf("Cannot get FDir filter info\n");
11910 if (!strcmp(res->flow_type, "none")) {
11911 /* means don't specify the flow type */
11912 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11913 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11914 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11915 0, sizeof(struct rte_eth_fdir_flex_mask));
11916 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11917 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11919 sizeof(struct rte_eth_fdir_flex_mask));
11920 cmd_reconfig_device_queue(res->port_id, 1, 1);
11923 flow_type_mask = fdir_info.flow_types_mask[0];
11924 if (!strcmp(res->flow_type, "all")) {
11925 if (!flow_type_mask) {
11926 printf("No flow type supported\n");
11929 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11930 if (flow_type_mask & (1ULL << i)) {
11931 flex_mask.flow_type = i;
11932 fdir_set_flex_mask(res->port_id, &flex_mask);
11935 cmd_reconfig_device_queue(res->port_id, 1, 1);
11938 flex_mask.flow_type = str2flowtype(res->flow_type);
11939 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11940 printf("Flow type %s not supported on port %d\n",
11941 res->flow_type, res->port_id);
11944 fdir_set_flex_mask(res->port_id, &flex_mask);
11945 cmd_reconfig_device_queue(res->port_id, 1, 1);
11948 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11949 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11950 flow_director_flexmask,
11951 "flow_director_flex_mask");
11952 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11953 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11955 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11958 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11960 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11961 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11962 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11963 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11966 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11967 .f = cmd_flow_director_flex_mask_parsed,
11969 .help_str = "flow_director_flex_mask ... : "
11970 "Set flow director's flex mask on NIC",
11972 (void *)&cmd_flow_director_flexmask,
11973 (void *)&cmd_flow_director_flexmask_port_id,
11974 (void *)&cmd_flow_director_flexmask_flow,
11975 (void *)&cmd_flow_director_flexmask_flow_type,
11976 (void *)&cmd_flow_director_flexmask_mask,
11981 /* *** deal with flow director flexible payload configuration *** */
11982 struct cmd_flow_director_flexpayload_result {
11983 cmdline_fixed_string_t flow_director_flexpayload;
11985 cmdline_fixed_string_t payload_layer;
11986 cmdline_fixed_string_t payload_cfg;
11990 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11993 const char *p, *p0 = q_arg;
11995 unsigned long int_fld;
11996 char *str_fld[max_num];
12001 p = strchr(p0, '(');
12005 p0 = strchr(p, ')');
12010 if (size >= sizeof(s))
12013 snprintf(s, sizeof(s), "%.*s", size, p);
12014 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12015 if (ret < 0 || ret > max_num)
12017 for (i = 0; i < ret; i++) {
12019 int_fld = strtoul(str_fld[i], &end, 0);
12020 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12022 offsets[i] = (uint16_t)int_fld;
12028 cmd_flow_director_flxpld_parsed(void *parsed_result,
12029 __attribute__((unused)) struct cmdline *cl,
12030 __attribute__((unused)) void *data)
12032 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12033 struct rte_eth_flex_payload_cfg flex_cfg;
12034 struct rte_port *port;
12037 port = &ports[res->port_id];
12038 /** Check if the port is not started **/
12039 if (port->port_status != RTE_PORT_STOPPED) {
12040 printf("Please stop port %d first\n", res->port_id);
12044 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12046 if (!strcmp(res->payload_layer, "raw"))
12047 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12048 else if (!strcmp(res->payload_layer, "l2"))
12049 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12050 else if (!strcmp(res->payload_layer, "l3"))
12051 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12052 else if (!strcmp(res->payload_layer, "l4"))
12053 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12055 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12056 RTE_ETH_FDIR_MAX_FLEXLEN);
12058 printf("error: Cannot parse flex payload input.\n");
12062 fdir_set_flex_payload(res->port_id, &flex_cfg);
12063 cmd_reconfig_device_queue(res->port_id, 1, 1);
12066 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12067 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12068 flow_director_flexpayload,
12069 "flow_director_flex_payload");
12070 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12071 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12073 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12074 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12075 payload_layer, "raw#l2#l3#l4");
12076 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12077 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12078 payload_cfg, NULL);
12080 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12081 .f = cmd_flow_director_flxpld_parsed,
12083 .help_str = "flow_director_flexpayload ... : "
12084 "Set flow director's flex payload on NIC",
12086 (void *)&cmd_flow_director_flexpayload,
12087 (void *)&cmd_flow_director_flexpayload_port_id,
12088 (void *)&cmd_flow_director_flexpayload_payload_layer,
12089 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12094 /* Generic flow interface command. */
12095 extern cmdline_parse_inst_t cmd_flow;
12097 /* *** Classification Filters Control *** */
12098 /* *** Get symmetric hash enable per port *** */
12099 struct cmd_get_sym_hash_ena_per_port_result {
12100 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12105 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12106 __rte_unused struct cmdline *cl,
12107 __rte_unused void *data)
12109 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12110 struct rte_eth_hash_filter_info info;
12113 if (rte_eth_dev_filter_supported(res->port_id,
12114 RTE_ETH_FILTER_HASH) < 0) {
12115 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12120 memset(&info, 0, sizeof(info));
12121 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12122 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12123 RTE_ETH_FILTER_GET, &info);
12126 printf("Cannot get symmetric hash enable per port "
12127 "on port %u\n", res->port_id);
12131 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12132 "enabled" : "disabled", res->port_id);
12135 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12136 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12137 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12138 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12139 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12142 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12143 .f = cmd_get_sym_hash_per_port_parsed,
12145 .help_str = "get_sym_hash_ena_per_port <port_id>",
12147 (void *)&cmd_get_sym_hash_ena_per_port_all,
12148 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12153 /* *** Set symmetric hash enable per port *** */
12154 struct cmd_set_sym_hash_ena_per_port_result {
12155 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12156 cmdline_fixed_string_t enable;
12161 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12162 __rte_unused struct cmdline *cl,
12163 __rte_unused void *data)
12165 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12166 struct rte_eth_hash_filter_info info;
12169 if (rte_eth_dev_filter_supported(res->port_id,
12170 RTE_ETH_FILTER_HASH) < 0) {
12171 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12176 memset(&info, 0, sizeof(info));
12177 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12178 if (!strcmp(res->enable, "enable"))
12179 info.info.enable = 1;
12180 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12181 RTE_ETH_FILTER_SET, &info);
12183 printf("Cannot set symmetric hash enable per port on "
12184 "port %u\n", res->port_id);
12187 printf("Symmetric hash has been set to %s on port %u\n",
12188 res->enable, res->port_id);
12191 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12192 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12193 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12194 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12195 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12197 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12198 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12199 enable, "enable#disable");
12201 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12202 .f = cmd_set_sym_hash_per_port_parsed,
12204 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12206 (void *)&cmd_set_sym_hash_ena_per_port_all,
12207 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12208 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12213 /* Get global config of hash function */
12214 struct cmd_get_hash_global_config_result {
12215 cmdline_fixed_string_t get_hash_global_config;
12220 flowtype_to_str(uint16_t ftype)
12226 } ftype_table[] = {
12227 {"ipv4", RTE_ETH_FLOW_IPV4},
12228 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12229 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12230 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12231 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12232 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12233 {"ipv6", RTE_ETH_FLOW_IPV6},
12234 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12235 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12236 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12237 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12238 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12239 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12240 {"port", RTE_ETH_FLOW_PORT},
12241 {"vxlan", RTE_ETH_FLOW_VXLAN},
12242 {"geneve", RTE_ETH_FLOW_GENEVE},
12243 {"nvgre", RTE_ETH_FLOW_NVGRE},
12244 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12247 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12248 if (ftype_table[i].ftype == ftype)
12249 return ftype_table[i].str;
12256 cmd_get_hash_global_config_parsed(void *parsed_result,
12257 __rte_unused struct cmdline *cl,
12258 __rte_unused void *data)
12260 struct cmd_get_hash_global_config_result *res = parsed_result;
12261 struct rte_eth_hash_filter_info info;
12262 uint32_t idx, offset;
12267 if (rte_eth_dev_filter_supported(res->port_id,
12268 RTE_ETH_FILTER_HASH) < 0) {
12269 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12274 memset(&info, 0, sizeof(info));
12275 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12276 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12277 RTE_ETH_FILTER_GET, &info);
12279 printf("Cannot get hash global configurations by port %d\n",
12284 switch (info.info.global_conf.hash_func) {
12285 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12286 printf("Hash function is Toeplitz\n");
12288 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12289 printf("Hash function is Simple XOR\n");
12291 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12292 printf("Hash function is Symmetric Toeplitz\n");
12295 printf("Unknown hash function\n");
12299 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12300 idx = i / UINT64_BIT;
12301 offset = i % UINT64_BIT;
12302 if (!(info.info.global_conf.valid_bit_mask[idx] &
12305 str = flowtype_to_str(i);
12308 printf("Symmetric hash is %s globally for flow type %s "
12310 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12311 (1ULL << offset)) ? "enabled" : "disabled"), str,
12316 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12317 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12318 get_hash_global_config, "get_hash_global_config");
12319 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12320 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12323 cmdline_parse_inst_t cmd_get_hash_global_config = {
12324 .f = cmd_get_hash_global_config_parsed,
12326 .help_str = "get_hash_global_config <port_id>",
12328 (void *)&cmd_get_hash_global_config_all,
12329 (void *)&cmd_get_hash_global_config_port_id,
12334 /* Set global config of hash function */
12335 struct cmd_set_hash_global_config_result {
12336 cmdline_fixed_string_t set_hash_global_config;
12338 cmdline_fixed_string_t hash_func;
12339 cmdline_fixed_string_t flow_type;
12340 cmdline_fixed_string_t enable;
12344 cmd_set_hash_global_config_parsed(void *parsed_result,
12345 __rte_unused struct cmdline *cl,
12346 __rte_unused void *data)
12348 struct cmd_set_hash_global_config_result *res = parsed_result;
12349 struct rte_eth_hash_filter_info info;
12350 uint32_t ftype, idx, offset;
12353 if (rte_eth_dev_filter_supported(res->port_id,
12354 RTE_ETH_FILTER_HASH) < 0) {
12355 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12359 memset(&info, 0, sizeof(info));
12360 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12361 if (!strcmp(res->hash_func, "toeplitz"))
12362 info.info.global_conf.hash_func =
12363 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12364 else if (!strcmp(res->hash_func, "simple_xor"))
12365 info.info.global_conf.hash_func =
12366 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12367 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12368 info.info.global_conf.hash_func =
12369 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12370 else if (!strcmp(res->hash_func, "default"))
12371 info.info.global_conf.hash_func =
12372 RTE_ETH_HASH_FUNCTION_DEFAULT;
12374 ftype = str2flowtype(res->flow_type);
12375 idx = ftype / UINT64_BIT;
12376 offset = ftype % UINT64_BIT;
12377 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12378 if (!strcmp(res->enable, "enable"))
12379 info.info.global_conf.sym_hash_enable_mask[idx] |=
12381 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12382 RTE_ETH_FILTER_SET, &info);
12384 printf("Cannot set global hash configurations by port %d\n",
12387 printf("Global hash configurations have been set "
12388 "successfully by port %d\n", res->port_id);
12391 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12392 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12393 set_hash_global_config, "set_hash_global_config");
12394 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12395 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12397 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12399 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12400 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12401 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12403 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12404 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12405 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12406 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12407 enable, "enable#disable");
12409 cmdline_parse_inst_t cmd_set_hash_global_config = {
12410 .f = cmd_set_hash_global_config_parsed,
12412 .help_str = "set_hash_global_config <port_id> "
12413 "toeplitz|simple_xor|symmetric_toeplitz|default "
12414 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12415 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12416 "l2_payload enable|disable",
12418 (void *)&cmd_set_hash_global_config_all,
12419 (void *)&cmd_set_hash_global_config_port_id,
12420 (void *)&cmd_set_hash_global_config_hash_func,
12421 (void *)&cmd_set_hash_global_config_flow_type,
12422 (void *)&cmd_set_hash_global_config_enable,
12427 /* Set hash input set */
12428 struct cmd_set_hash_input_set_result {
12429 cmdline_fixed_string_t set_hash_input_set;
12431 cmdline_fixed_string_t flow_type;
12432 cmdline_fixed_string_t inset_field;
12433 cmdline_fixed_string_t select;
12436 static enum rte_eth_input_set_field
12437 str2inset(char *string)
12441 static const struct {
12443 enum rte_eth_input_set_field inset;
12444 } inset_table[] = {
12445 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12446 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12447 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12448 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12449 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12450 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12451 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12452 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12453 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12454 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12455 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12456 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12457 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12458 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12459 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12460 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12461 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12462 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12463 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12464 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12465 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12466 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12467 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12468 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12469 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12470 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12471 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12472 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12473 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12474 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12475 {"none", RTE_ETH_INPUT_SET_NONE},
12478 for (i = 0; i < RTE_DIM(inset_table); i++) {
12479 if (!strcmp(string, inset_table[i].str))
12480 return inset_table[i].inset;
12483 return RTE_ETH_INPUT_SET_UNKNOWN;
12487 cmd_set_hash_input_set_parsed(void *parsed_result,
12488 __rte_unused struct cmdline *cl,
12489 __rte_unused void *data)
12491 struct cmd_set_hash_input_set_result *res = parsed_result;
12492 struct rte_eth_hash_filter_info info;
12494 memset(&info, 0, sizeof(info));
12495 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12496 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12497 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12498 info.info.input_set_conf.inset_size = 1;
12499 if (!strcmp(res->select, "select"))
12500 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12501 else if (!strcmp(res->select, "add"))
12502 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12503 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12504 RTE_ETH_FILTER_SET, &info);
12507 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12508 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12509 set_hash_input_set, "set_hash_input_set");
12510 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12511 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12513 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12514 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12516 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12517 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12519 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12520 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12521 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12522 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12523 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12525 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12526 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12527 select, "select#add");
12529 cmdline_parse_inst_t cmd_set_hash_input_set = {
12530 .f = cmd_set_hash_input_set_parsed,
12532 .help_str = "set_hash_input_set <port_id> "
12533 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12534 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12535 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12536 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12537 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12538 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12539 "fld-7th|fld-8th|none select|add",
12541 (void *)&cmd_set_hash_input_set_cmd,
12542 (void *)&cmd_set_hash_input_set_port_id,
12543 (void *)&cmd_set_hash_input_set_flow_type,
12544 (void *)&cmd_set_hash_input_set_field,
12545 (void *)&cmd_set_hash_input_set_select,
12550 /* Set flow director input set */
12551 struct cmd_set_fdir_input_set_result {
12552 cmdline_fixed_string_t set_fdir_input_set;
12554 cmdline_fixed_string_t flow_type;
12555 cmdline_fixed_string_t inset_field;
12556 cmdline_fixed_string_t select;
12560 cmd_set_fdir_input_set_parsed(void *parsed_result,
12561 __rte_unused struct cmdline *cl,
12562 __rte_unused void *data)
12564 struct cmd_set_fdir_input_set_result *res = parsed_result;
12565 struct rte_eth_fdir_filter_info info;
12567 memset(&info, 0, sizeof(info));
12568 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12569 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12570 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12571 info.info.input_set_conf.inset_size = 1;
12572 if (!strcmp(res->select, "select"))
12573 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12574 else if (!strcmp(res->select, "add"))
12575 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12576 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12577 RTE_ETH_FILTER_SET, &info);
12580 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12581 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12582 set_fdir_input_set, "set_fdir_input_set");
12583 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12584 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12586 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12587 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12589 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12590 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12591 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12592 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12594 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12595 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12596 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12597 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12598 "sctp-veri-tag#none");
12599 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12600 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12601 select, "select#add");
12603 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12604 .f = cmd_set_fdir_input_set_parsed,
12606 .help_str = "set_fdir_input_set <port_id> "
12607 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12608 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12609 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12610 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12611 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12612 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12613 "sctp-veri-tag|none select|add",
12615 (void *)&cmd_set_fdir_input_set_cmd,
12616 (void *)&cmd_set_fdir_input_set_port_id,
12617 (void *)&cmd_set_fdir_input_set_flow_type,
12618 (void *)&cmd_set_fdir_input_set_field,
12619 (void *)&cmd_set_fdir_input_set_select,
12624 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12625 struct cmd_mcast_addr_result {
12626 cmdline_fixed_string_t mcast_addr_cmd;
12627 cmdline_fixed_string_t what;
12629 struct rte_ether_addr mc_addr;
12632 static void cmd_mcast_addr_parsed(void *parsed_result,
12633 __attribute__((unused)) struct cmdline *cl,
12634 __attribute__((unused)) void *data)
12636 struct cmd_mcast_addr_result *res = parsed_result;
12638 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12639 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12640 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12641 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12642 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12645 if (strcmp(res->what, "add") == 0)
12646 mcast_addr_add(res->port_num, &res->mc_addr);
12648 mcast_addr_remove(res->port_num, &res->mc_addr);
12651 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12652 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12653 mcast_addr_cmd, "mcast_addr");
12654 cmdline_parse_token_string_t cmd_mcast_addr_what =
12655 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12657 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12658 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12659 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12660 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12662 cmdline_parse_inst_t cmd_mcast_addr = {
12663 .f = cmd_mcast_addr_parsed,
12665 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12666 "Add/Remove multicast MAC address on port_id",
12668 (void *)&cmd_mcast_addr_cmd,
12669 (void *)&cmd_mcast_addr_what,
12670 (void *)&cmd_mcast_addr_portnum,
12671 (void *)&cmd_mcast_addr_addr,
12676 /* l2 tunnel config
12677 * only support E-tag now.
12680 /* Ether type config */
12681 struct cmd_config_l2_tunnel_eth_type_result {
12682 cmdline_fixed_string_t port;
12683 cmdline_fixed_string_t config;
12684 cmdline_fixed_string_t all;
12686 cmdline_fixed_string_t l2_tunnel;
12687 cmdline_fixed_string_t l2_tunnel_type;
12688 cmdline_fixed_string_t eth_type;
12689 uint16_t eth_type_val;
12692 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12693 TOKEN_STRING_INITIALIZER
12694 (struct cmd_config_l2_tunnel_eth_type_result,
12696 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12697 TOKEN_STRING_INITIALIZER
12698 (struct cmd_config_l2_tunnel_eth_type_result,
12700 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12701 TOKEN_STRING_INITIALIZER
12702 (struct cmd_config_l2_tunnel_eth_type_result,
12704 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12705 TOKEN_NUM_INITIALIZER
12706 (struct cmd_config_l2_tunnel_eth_type_result,
12708 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12709 TOKEN_STRING_INITIALIZER
12710 (struct cmd_config_l2_tunnel_eth_type_result,
12711 l2_tunnel, "l2-tunnel");
12712 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12713 TOKEN_STRING_INITIALIZER
12714 (struct cmd_config_l2_tunnel_eth_type_result,
12715 l2_tunnel_type, "E-tag");
12716 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12717 TOKEN_STRING_INITIALIZER
12718 (struct cmd_config_l2_tunnel_eth_type_result,
12719 eth_type, "ether-type");
12720 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12721 TOKEN_NUM_INITIALIZER
12722 (struct cmd_config_l2_tunnel_eth_type_result,
12723 eth_type_val, UINT16);
12725 static enum rte_eth_tunnel_type
12726 str2fdir_l2_tunnel_type(char *string)
12730 static const struct {
12732 enum rte_eth_tunnel_type type;
12733 } l2_tunnel_type_str[] = {
12734 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12737 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12738 if (!strcmp(l2_tunnel_type_str[i].str, string))
12739 return l2_tunnel_type_str[i].type;
12741 return RTE_TUNNEL_TYPE_NONE;
12744 /* ether type config for all ports */
12746 cmd_config_l2_tunnel_eth_type_all_parsed
12747 (void *parsed_result,
12748 __attribute__((unused)) struct cmdline *cl,
12749 __attribute__((unused)) void *data)
12751 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12752 struct rte_eth_l2_tunnel_conf entry;
12755 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12756 entry.ether_type = res->eth_type_val;
12758 RTE_ETH_FOREACH_DEV(pid) {
12759 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12763 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12764 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12766 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12768 (void *)&cmd_config_l2_tunnel_eth_type_port,
12769 (void *)&cmd_config_l2_tunnel_eth_type_config,
12770 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12771 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12772 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12773 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12774 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12779 /* ether type config for a specific port */
12781 cmd_config_l2_tunnel_eth_type_specific_parsed(
12782 void *parsed_result,
12783 __attribute__((unused)) struct cmdline *cl,
12784 __attribute__((unused)) void *data)
12786 struct cmd_config_l2_tunnel_eth_type_result *res =
12788 struct rte_eth_l2_tunnel_conf entry;
12790 if (port_id_is_invalid(res->id, ENABLED_WARN))
12793 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12794 entry.ether_type = res->eth_type_val;
12796 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12799 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12800 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12802 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12804 (void *)&cmd_config_l2_tunnel_eth_type_port,
12805 (void *)&cmd_config_l2_tunnel_eth_type_config,
12806 (void *)&cmd_config_l2_tunnel_eth_type_id,
12807 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12808 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12809 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12810 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12815 /* Enable/disable l2 tunnel */
12816 struct cmd_config_l2_tunnel_en_dis_result {
12817 cmdline_fixed_string_t port;
12818 cmdline_fixed_string_t config;
12819 cmdline_fixed_string_t all;
12821 cmdline_fixed_string_t l2_tunnel;
12822 cmdline_fixed_string_t l2_tunnel_type;
12823 cmdline_fixed_string_t en_dis;
12826 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12827 TOKEN_STRING_INITIALIZER
12828 (struct cmd_config_l2_tunnel_en_dis_result,
12830 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12831 TOKEN_STRING_INITIALIZER
12832 (struct cmd_config_l2_tunnel_en_dis_result,
12834 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12835 TOKEN_STRING_INITIALIZER
12836 (struct cmd_config_l2_tunnel_en_dis_result,
12838 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12839 TOKEN_NUM_INITIALIZER
12840 (struct cmd_config_l2_tunnel_en_dis_result,
12842 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12843 TOKEN_STRING_INITIALIZER
12844 (struct cmd_config_l2_tunnel_en_dis_result,
12845 l2_tunnel, "l2-tunnel");
12846 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12847 TOKEN_STRING_INITIALIZER
12848 (struct cmd_config_l2_tunnel_en_dis_result,
12849 l2_tunnel_type, "E-tag");
12850 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12851 TOKEN_STRING_INITIALIZER
12852 (struct cmd_config_l2_tunnel_en_dis_result,
12853 en_dis, "enable#disable");
12855 /* enable/disable l2 tunnel for all ports */
12857 cmd_config_l2_tunnel_en_dis_all_parsed(
12858 void *parsed_result,
12859 __attribute__((unused)) struct cmdline *cl,
12860 __attribute__((unused)) void *data)
12862 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12863 struct rte_eth_l2_tunnel_conf entry;
12867 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12869 if (!strcmp("enable", res->en_dis))
12874 RTE_ETH_FOREACH_DEV(pid) {
12875 rte_eth_dev_l2_tunnel_offload_set(pid,
12877 ETH_L2_TUNNEL_ENABLE_MASK,
12882 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12883 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12885 .help_str = "port config all l2-tunnel E-tag enable|disable",
12887 (void *)&cmd_config_l2_tunnel_en_dis_port,
12888 (void *)&cmd_config_l2_tunnel_en_dis_config,
12889 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12890 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12891 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12892 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12897 /* enable/disable l2 tunnel for a port */
12899 cmd_config_l2_tunnel_en_dis_specific_parsed(
12900 void *parsed_result,
12901 __attribute__((unused)) struct cmdline *cl,
12902 __attribute__((unused)) void *data)
12904 struct cmd_config_l2_tunnel_en_dis_result *res =
12906 struct rte_eth_l2_tunnel_conf entry;
12908 if (port_id_is_invalid(res->id, ENABLED_WARN))
12911 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12913 if (!strcmp("enable", res->en_dis))
12914 rte_eth_dev_l2_tunnel_offload_set(res->id,
12916 ETH_L2_TUNNEL_ENABLE_MASK,
12919 rte_eth_dev_l2_tunnel_offload_set(res->id,
12921 ETH_L2_TUNNEL_ENABLE_MASK,
12925 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12926 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12928 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12930 (void *)&cmd_config_l2_tunnel_en_dis_port,
12931 (void *)&cmd_config_l2_tunnel_en_dis_config,
12932 (void *)&cmd_config_l2_tunnel_en_dis_id,
12933 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12934 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12935 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12940 /* E-tag configuration */
12942 /* Common result structure for all E-tag configuration */
12943 struct cmd_config_e_tag_result {
12944 cmdline_fixed_string_t e_tag;
12945 cmdline_fixed_string_t set;
12946 cmdline_fixed_string_t insertion;
12947 cmdline_fixed_string_t stripping;
12948 cmdline_fixed_string_t forwarding;
12949 cmdline_fixed_string_t filter;
12950 cmdline_fixed_string_t add;
12951 cmdline_fixed_string_t del;
12952 cmdline_fixed_string_t on;
12953 cmdline_fixed_string_t off;
12954 cmdline_fixed_string_t on_off;
12955 cmdline_fixed_string_t port_tag_id;
12956 uint32_t port_tag_id_val;
12957 cmdline_fixed_string_t e_tag_id;
12958 uint16_t e_tag_id_val;
12959 cmdline_fixed_string_t dst_pool;
12960 uint8_t dst_pool_val;
12961 cmdline_fixed_string_t port;
12963 cmdline_fixed_string_t vf;
12967 /* Common CLI fields for all E-tag configuration */
12968 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12969 TOKEN_STRING_INITIALIZER
12970 (struct cmd_config_e_tag_result,
12972 cmdline_parse_token_string_t cmd_config_e_tag_set =
12973 TOKEN_STRING_INITIALIZER
12974 (struct cmd_config_e_tag_result,
12976 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12977 TOKEN_STRING_INITIALIZER
12978 (struct cmd_config_e_tag_result,
12979 insertion, "insertion");
12980 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12981 TOKEN_STRING_INITIALIZER
12982 (struct cmd_config_e_tag_result,
12983 stripping, "stripping");
12984 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12985 TOKEN_STRING_INITIALIZER
12986 (struct cmd_config_e_tag_result,
12987 forwarding, "forwarding");
12988 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12989 TOKEN_STRING_INITIALIZER
12990 (struct cmd_config_e_tag_result,
12992 cmdline_parse_token_string_t cmd_config_e_tag_add =
12993 TOKEN_STRING_INITIALIZER
12994 (struct cmd_config_e_tag_result,
12996 cmdline_parse_token_string_t cmd_config_e_tag_del =
12997 TOKEN_STRING_INITIALIZER
12998 (struct cmd_config_e_tag_result,
13000 cmdline_parse_token_string_t cmd_config_e_tag_on =
13001 TOKEN_STRING_INITIALIZER
13002 (struct cmd_config_e_tag_result,
13004 cmdline_parse_token_string_t cmd_config_e_tag_off =
13005 TOKEN_STRING_INITIALIZER
13006 (struct cmd_config_e_tag_result,
13008 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13009 TOKEN_STRING_INITIALIZER
13010 (struct cmd_config_e_tag_result,
13012 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13013 TOKEN_STRING_INITIALIZER
13014 (struct cmd_config_e_tag_result,
13015 port_tag_id, "port-tag-id");
13016 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13017 TOKEN_NUM_INITIALIZER
13018 (struct cmd_config_e_tag_result,
13019 port_tag_id_val, UINT32);
13020 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13021 TOKEN_STRING_INITIALIZER
13022 (struct cmd_config_e_tag_result,
13023 e_tag_id, "e-tag-id");
13024 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13025 TOKEN_NUM_INITIALIZER
13026 (struct cmd_config_e_tag_result,
13027 e_tag_id_val, UINT16);
13028 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13029 TOKEN_STRING_INITIALIZER
13030 (struct cmd_config_e_tag_result,
13031 dst_pool, "dst-pool");
13032 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13033 TOKEN_NUM_INITIALIZER
13034 (struct cmd_config_e_tag_result,
13035 dst_pool_val, UINT8);
13036 cmdline_parse_token_string_t cmd_config_e_tag_port =
13037 TOKEN_STRING_INITIALIZER
13038 (struct cmd_config_e_tag_result,
13040 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13041 TOKEN_NUM_INITIALIZER
13042 (struct cmd_config_e_tag_result,
13044 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13045 TOKEN_STRING_INITIALIZER
13046 (struct cmd_config_e_tag_result,
13048 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13049 TOKEN_NUM_INITIALIZER
13050 (struct cmd_config_e_tag_result,
13053 /* E-tag insertion configuration */
13055 cmd_config_e_tag_insertion_en_parsed(
13056 void *parsed_result,
13057 __attribute__((unused)) struct cmdline *cl,
13058 __attribute__((unused)) void *data)
13060 struct cmd_config_e_tag_result *res =
13062 struct rte_eth_l2_tunnel_conf entry;
13064 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13067 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13068 entry.tunnel_id = res->port_tag_id_val;
13069 entry.vf_id = res->vf_id;
13070 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13072 ETH_L2_TUNNEL_INSERTION_MASK,
13077 cmd_config_e_tag_insertion_dis_parsed(
13078 void *parsed_result,
13079 __attribute__((unused)) struct cmdline *cl,
13080 __attribute__((unused)) void *data)
13082 struct cmd_config_e_tag_result *res =
13084 struct rte_eth_l2_tunnel_conf entry;
13086 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13089 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13090 entry.vf_id = res->vf_id;
13092 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13094 ETH_L2_TUNNEL_INSERTION_MASK,
13098 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13099 .f = cmd_config_e_tag_insertion_en_parsed,
13101 .help_str = "E-tag ... : E-tag insertion enable",
13103 (void *)&cmd_config_e_tag_e_tag,
13104 (void *)&cmd_config_e_tag_set,
13105 (void *)&cmd_config_e_tag_insertion,
13106 (void *)&cmd_config_e_tag_on,
13107 (void *)&cmd_config_e_tag_port_tag_id,
13108 (void *)&cmd_config_e_tag_port_tag_id_val,
13109 (void *)&cmd_config_e_tag_port,
13110 (void *)&cmd_config_e_tag_port_id,
13111 (void *)&cmd_config_e_tag_vf,
13112 (void *)&cmd_config_e_tag_vf_id,
13117 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13118 .f = cmd_config_e_tag_insertion_dis_parsed,
13120 .help_str = "E-tag ... : E-tag insertion disable",
13122 (void *)&cmd_config_e_tag_e_tag,
13123 (void *)&cmd_config_e_tag_set,
13124 (void *)&cmd_config_e_tag_insertion,
13125 (void *)&cmd_config_e_tag_off,
13126 (void *)&cmd_config_e_tag_port,
13127 (void *)&cmd_config_e_tag_port_id,
13128 (void *)&cmd_config_e_tag_vf,
13129 (void *)&cmd_config_e_tag_vf_id,
13134 /* E-tag stripping configuration */
13136 cmd_config_e_tag_stripping_parsed(
13137 void *parsed_result,
13138 __attribute__((unused)) struct cmdline *cl,
13139 __attribute__((unused)) void *data)
13141 struct cmd_config_e_tag_result *res =
13143 struct rte_eth_l2_tunnel_conf entry;
13145 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13148 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13150 if (!strcmp(res->on_off, "on"))
13151 rte_eth_dev_l2_tunnel_offload_set
13154 ETH_L2_TUNNEL_STRIPPING_MASK,
13157 rte_eth_dev_l2_tunnel_offload_set
13160 ETH_L2_TUNNEL_STRIPPING_MASK,
13164 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13165 .f = cmd_config_e_tag_stripping_parsed,
13167 .help_str = "E-tag ... : E-tag stripping enable/disable",
13169 (void *)&cmd_config_e_tag_e_tag,
13170 (void *)&cmd_config_e_tag_set,
13171 (void *)&cmd_config_e_tag_stripping,
13172 (void *)&cmd_config_e_tag_on_off,
13173 (void *)&cmd_config_e_tag_port,
13174 (void *)&cmd_config_e_tag_port_id,
13179 /* E-tag forwarding configuration */
13181 cmd_config_e_tag_forwarding_parsed(
13182 void *parsed_result,
13183 __attribute__((unused)) struct cmdline *cl,
13184 __attribute__((unused)) void *data)
13186 struct cmd_config_e_tag_result *res = parsed_result;
13187 struct rte_eth_l2_tunnel_conf entry;
13189 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13192 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13194 if (!strcmp(res->on_off, "on"))
13195 rte_eth_dev_l2_tunnel_offload_set
13198 ETH_L2_TUNNEL_FORWARDING_MASK,
13201 rte_eth_dev_l2_tunnel_offload_set
13204 ETH_L2_TUNNEL_FORWARDING_MASK,
13208 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13209 .f = cmd_config_e_tag_forwarding_parsed,
13211 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13213 (void *)&cmd_config_e_tag_e_tag,
13214 (void *)&cmd_config_e_tag_set,
13215 (void *)&cmd_config_e_tag_forwarding,
13216 (void *)&cmd_config_e_tag_on_off,
13217 (void *)&cmd_config_e_tag_port,
13218 (void *)&cmd_config_e_tag_port_id,
13223 /* E-tag filter configuration */
13225 cmd_config_e_tag_filter_add_parsed(
13226 void *parsed_result,
13227 __attribute__((unused)) struct cmdline *cl,
13228 __attribute__((unused)) void *data)
13230 struct cmd_config_e_tag_result *res = parsed_result;
13231 struct rte_eth_l2_tunnel_conf entry;
13234 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13237 if (res->e_tag_id_val > 0x3fff) {
13238 printf("e-tag-id must be equal or less than 0x3fff.\n");
13242 ret = rte_eth_dev_filter_supported(res->port_id,
13243 RTE_ETH_FILTER_L2_TUNNEL);
13245 printf("E-tag filter is not supported on port %u.\n",
13250 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13251 entry.tunnel_id = res->e_tag_id_val;
13252 entry.pool = res->dst_pool_val;
13254 ret = rte_eth_dev_filter_ctrl(res->port_id,
13255 RTE_ETH_FILTER_L2_TUNNEL,
13256 RTE_ETH_FILTER_ADD,
13259 printf("E-tag filter programming error: (%s)\n",
13263 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13264 .f = cmd_config_e_tag_filter_add_parsed,
13266 .help_str = "E-tag ... : E-tag filter add",
13268 (void *)&cmd_config_e_tag_e_tag,
13269 (void *)&cmd_config_e_tag_set,
13270 (void *)&cmd_config_e_tag_filter,
13271 (void *)&cmd_config_e_tag_add,
13272 (void *)&cmd_config_e_tag_e_tag_id,
13273 (void *)&cmd_config_e_tag_e_tag_id_val,
13274 (void *)&cmd_config_e_tag_dst_pool,
13275 (void *)&cmd_config_e_tag_dst_pool_val,
13276 (void *)&cmd_config_e_tag_port,
13277 (void *)&cmd_config_e_tag_port_id,
13283 cmd_config_e_tag_filter_del_parsed(
13284 void *parsed_result,
13285 __attribute__((unused)) struct cmdline *cl,
13286 __attribute__((unused)) void *data)
13288 struct cmd_config_e_tag_result *res = parsed_result;
13289 struct rte_eth_l2_tunnel_conf entry;
13292 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13295 if (res->e_tag_id_val > 0x3fff) {
13296 printf("e-tag-id must be less than 0x3fff.\n");
13300 ret = rte_eth_dev_filter_supported(res->port_id,
13301 RTE_ETH_FILTER_L2_TUNNEL);
13303 printf("E-tag filter is not supported on port %u.\n",
13308 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13309 entry.tunnel_id = res->e_tag_id_val;
13311 ret = rte_eth_dev_filter_ctrl(res->port_id,
13312 RTE_ETH_FILTER_L2_TUNNEL,
13313 RTE_ETH_FILTER_DELETE,
13316 printf("E-tag filter programming error: (%s)\n",
13320 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13321 .f = cmd_config_e_tag_filter_del_parsed,
13323 .help_str = "E-tag ... : E-tag filter delete",
13325 (void *)&cmd_config_e_tag_e_tag,
13326 (void *)&cmd_config_e_tag_set,
13327 (void *)&cmd_config_e_tag_filter,
13328 (void *)&cmd_config_e_tag_del,
13329 (void *)&cmd_config_e_tag_e_tag_id,
13330 (void *)&cmd_config_e_tag_e_tag_id_val,
13331 (void *)&cmd_config_e_tag_port,
13332 (void *)&cmd_config_e_tag_port_id,
13337 /* vf vlan anti spoof configuration */
13339 /* Common result structure for vf vlan anti spoof */
13340 struct cmd_vf_vlan_anti_spoof_result {
13341 cmdline_fixed_string_t set;
13342 cmdline_fixed_string_t vf;
13343 cmdline_fixed_string_t vlan;
13344 cmdline_fixed_string_t antispoof;
13347 cmdline_fixed_string_t on_off;
13350 /* Common CLI fields for vf vlan anti spoof enable disable */
13351 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13352 TOKEN_STRING_INITIALIZER
13353 (struct cmd_vf_vlan_anti_spoof_result,
13355 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13356 TOKEN_STRING_INITIALIZER
13357 (struct cmd_vf_vlan_anti_spoof_result,
13359 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13360 TOKEN_STRING_INITIALIZER
13361 (struct cmd_vf_vlan_anti_spoof_result,
13363 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13364 TOKEN_STRING_INITIALIZER
13365 (struct cmd_vf_vlan_anti_spoof_result,
13366 antispoof, "antispoof");
13367 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13368 TOKEN_NUM_INITIALIZER
13369 (struct cmd_vf_vlan_anti_spoof_result,
13371 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13372 TOKEN_NUM_INITIALIZER
13373 (struct cmd_vf_vlan_anti_spoof_result,
13375 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13376 TOKEN_STRING_INITIALIZER
13377 (struct cmd_vf_vlan_anti_spoof_result,
13381 cmd_set_vf_vlan_anti_spoof_parsed(
13382 void *parsed_result,
13383 __attribute__((unused)) struct cmdline *cl,
13384 __attribute__((unused)) void *data)
13386 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13387 int ret = -ENOTSUP;
13389 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13391 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13394 #ifdef RTE_LIBRTE_IXGBE_PMD
13395 if (ret == -ENOTSUP)
13396 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13397 res->vf_id, is_on);
13399 #ifdef RTE_LIBRTE_I40E_PMD
13400 if (ret == -ENOTSUP)
13401 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13402 res->vf_id, is_on);
13404 #ifdef RTE_LIBRTE_BNXT_PMD
13405 if (ret == -ENOTSUP)
13406 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13407 res->vf_id, is_on);
13414 printf("invalid vf_id %d\n", res->vf_id);
13417 printf("invalid port_id %d\n", res->port_id);
13420 printf("function not implemented\n");
13423 printf("programming error: (%s)\n", strerror(-ret));
13427 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13428 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13430 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13432 (void *)&cmd_vf_vlan_anti_spoof_set,
13433 (void *)&cmd_vf_vlan_anti_spoof_vf,
13434 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13435 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13436 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13437 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13438 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13443 /* vf mac anti spoof configuration */
13445 /* Common result structure for vf mac anti spoof */
13446 struct cmd_vf_mac_anti_spoof_result {
13447 cmdline_fixed_string_t set;
13448 cmdline_fixed_string_t vf;
13449 cmdline_fixed_string_t mac;
13450 cmdline_fixed_string_t antispoof;
13453 cmdline_fixed_string_t on_off;
13456 /* Common CLI fields for vf mac anti spoof enable disable */
13457 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13458 TOKEN_STRING_INITIALIZER
13459 (struct cmd_vf_mac_anti_spoof_result,
13461 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13462 TOKEN_STRING_INITIALIZER
13463 (struct cmd_vf_mac_anti_spoof_result,
13465 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13466 TOKEN_STRING_INITIALIZER
13467 (struct cmd_vf_mac_anti_spoof_result,
13469 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13470 TOKEN_STRING_INITIALIZER
13471 (struct cmd_vf_mac_anti_spoof_result,
13472 antispoof, "antispoof");
13473 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13474 TOKEN_NUM_INITIALIZER
13475 (struct cmd_vf_mac_anti_spoof_result,
13477 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13478 TOKEN_NUM_INITIALIZER
13479 (struct cmd_vf_mac_anti_spoof_result,
13481 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13482 TOKEN_STRING_INITIALIZER
13483 (struct cmd_vf_mac_anti_spoof_result,
13487 cmd_set_vf_mac_anti_spoof_parsed(
13488 void *parsed_result,
13489 __attribute__((unused)) struct cmdline *cl,
13490 __attribute__((unused)) void *data)
13492 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13493 int ret = -ENOTSUP;
13495 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13497 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13500 #ifdef RTE_LIBRTE_IXGBE_PMD
13501 if (ret == -ENOTSUP)
13502 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13503 res->vf_id, is_on);
13505 #ifdef RTE_LIBRTE_I40E_PMD
13506 if (ret == -ENOTSUP)
13507 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13508 res->vf_id, is_on);
13510 #ifdef RTE_LIBRTE_BNXT_PMD
13511 if (ret == -ENOTSUP)
13512 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13513 res->vf_id, is_on);
13520 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13523 printf("invalid port_id %d\n", res->port_id);
13526 printf("function not implemented\n");
13529 printf("programming error: (%s)\n", strerror(-ret));
13533 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13534 .f = cmd_set_vf_mac_anti_spoof_parsed,
13536 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13538 (void *)&cmd_vf_mac_anti_spoof_set,
13539 (void *)&cmd_vf_mac_anti_spoof_vf,
13540 (void *)&cmd_vf_mac_anti_spoof_mac,
13541 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13542 (void *)&cmd_vf_mac_anti_spoof_port_id,
13543 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13544 (void *)&cmd_vf_mac_anti_spoof_on_off,
13549 /* vf vlan strip queue configuration */
13551 /* Common result structure for vf mac anti spoof */
13552 struct cmd_vf_vlan_stripq_result {
13553 cmdline_fixed_string_t set;
13554 cmdline_fixed_string_t vf;
13555 cmdline_fixed_string_t vlan;
13556 cmdline_fixed_string_t stripq;
13559 cmdline_fixed_string_t on_off;
13562 /* Common CLI fields for vf vlan strip enable disable */
13563 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13564 TOKEN_STRING_INITIALIZER
13565 (struct cmd_vf_vlan_stripq_result,
13567 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13568 TOKEN_STRING_INITIALIZER
13569 (struct cmd_vf_vlan_stripq_result,
13571 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13572 TOKEN_STRING_INITIALIZER
13573 (struct cmd_vf_vlan_stripq_result,
13575 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13576 TOKEN_STRING_INITIALIZER
13577 (struct cmd_vf_vlan_stripq_result,
13579 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13580 TOKEN_NUM_INITIALIZER
13581 (struct cmd_vf_vlan_stripq_result,
13583 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13584 TOKEN_NUM_INITIALIZER
13585 (struct cmd_vf_vlan_stripq_result,
13587 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13588 TOKEN_STRING_INITIALIZER
13589 (struct cmd_vf_vlan_stripq_result,
13593 cmd_set_vf_vlan_stripq_parsed(
13594 void *parsed_result,
13595 __attribute__((unused)) struct cmdline *cl,
13596 __attribute__((unused)) void *data)
13598 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13599 int ret = -ENOTSUP;
13601 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13603 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13606 #ifdef RTE_LIBRTE_IXGBE_PMD
13607 if (ret == -ENOTSUP)
13608 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13609 res->vf_id, is_on);
13611 #ifdef RTE_LIBRTE_I40E_PMD
13612 if (ret == -ENOTSUP)
13613 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13614 res->vf_id, is_on);
13616 #ifdef RTE_LIBRTE_BNXT_PMD
13617 if (ret == -ENOTSUP)
13618 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13619 res->vf_id, is_on);
13626 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13629 printf("invalid port_id %d\n", res->port_id);
13632 printf("function not implemented\n");
13635 printf("programming error: (%s)\n", strerror(-ret));
13639 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13640 .f = cmd_set_vf_vlan_stripq_parsed,
13642 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13644 (void *)&cmd_vf_vlan_stripq_set,
13645 (void *)&cmd_vf_vlan_stripq_vf,
13646 (void *)&cmd_vf_vlan_stripq_vlan,
13647 (void *)&cmd_vf_vlan_stripq_stripq,
13648 (void *)&cmd_vf_vlan_stripq_port_id,
13649 (void *)&cmd_vf_vlan_stripq_vf_id,
13650 (void *)&cmd_vf_vlan_stripq_on_off,
13655 /* vf vlan insert configuration */
13657 /* Common result structure for vf vlan insert */
13658 struct cmd_vf_vlan_insert_result {
13659 cmdline_fixed_string_t set;
13660 cmdline_fixed_string_t vf;
13661 cmdline_fixed_string_t vlan;
13662 cmdline_fixed_string_t insert;
13668 /* Common CLI fields for vf vlan insert enable disable */
13669 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13670 TOKEN_STRING_INITIALIZER
13671 (struct cmd_vf_vlan_insert_result,
13673 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13674 TOKEN_STRING_INITIALIZER
13675 (struct cmd_vf_vlan_insert_result,
13677 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13678 TOKEN_STRING_INITIALIZER
13679 (struct cmd_vf_vlan_insert_result,
13681 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13682 TOKEN_STRING_INITIALIZER
13683 (struct cmd_vf_vlan_insert_result,
13685 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13686 TOKEN_NUM_INITIALIZER
13687 (struct cmd_vf_vlan_insert_result,
13689 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13690 TOKEN_NUM_INITIALIZER
13691 (struct cmd_vf_vlan_insert_result,
13693 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13694 TOKEN_NUM_INITIALIZER
13695 (struct cmd_vf_vlan_insert_result,
13699 cmd_set_vf_vlan_insert_parsed(
13700 void *parsed_result,
13701 __attribute__((unused)) struct cmdline *cl,
13702 __attribute__((unused)) void *data)
13704 struct cmd_vf_vlan_insert_result *res = parsed_result;
13705 int ret = -ENOTSUP;
13707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13710 #ifdef RTE_LIBRTE_IXGBE_PMD
13711 if (ret == -ENOTSUP)
13712 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13715 #ifdef RTE_LIBRTE_I40E_PMD
13716 if (ret == -ENOTSUP)
13717 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13720 #ifdef RTE_LIBRTE_BNXT_PMD
13721 if (ret == -ENOTSUP)
13722 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13730 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13733 printf("invalid port_id %d\n", res->port_id);
13736 printf("function not implemented\n");
13739 printf("programming error: (%s)\n", strerror(-ret));
13743 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13744 .f = cmd_set_vf_vlan_insert_parsed,
13746 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13748 (void *)&cmd_vf_vlan_insert_set,
13749 (void *)&cmd_vf_vlan_insert_vf,
13750 (void *)&cmd_vf_vlan_insert_vlan,
13751 (void *)&cmd_vf_vlan_insert_insert,
13752 (void *)&cmd_vf_vlan_insert_port_id,
13753 (void *)&cmd_vf_vlan_insert_vf_id,
13754 (void *)&cmd_vf_vlan_insert_vlan_id,
13759 /* tx loopback configuration */
13761 /* Common result structure for tx loopback */
13762 struct cmd_tx_loopback_result {
13763 cmdline_fixed_string_t set;
13764 cmdline_fixed_string_t tx;
13765 cmdline_fixed_string_t loopback;
13767 cmdline_fixed_string_t on_off;
13770 /* Common CLI fields for tx loopback enable disable */
13771 cmdline_parse_token_string_t cmd_tx_loopback_set =
13772 TOKEN_STRING_INITIALIZER
13773 (struct cmd_tx_loopback_result,
13775 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13776 TOKEN_STRING_INITIALIZER
13777 (struct cmd_tx_loopback_result,
13779 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13780 TOKEN_STRING_INITIALIZER
13781 (struct cmd_tx_loopback_result,
13782 loopback, "loopback");
13783 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13784 TOKEN_NUM_INITIALIZER
13785 (struct cmd_tx_loopback_result,
13787 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13788 TOKEN_STRING_INITIALIZER
13789 (struct cmd_tx_loopback_result,
13793 cmd_set_tx_loopback_parsed(
13794 void *parsed_result,
13795 __attribute__((unused)) struct cmdline *cl,
13796 __attribute__((unused)) void *data)
13798 struct cmd_tx_loopback_result *res = parsed_result;
13799 int ret = -ENOTSUP;
13801 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13806 #ifdef RTE_LIBRTE_IXGBE_PMD
13807 if (ret == -ENOTSUP)
13808 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13810 #ifdef RTE_LIBRTE_I40E_PMD
13811 if (ret == -ENOTSUP)
13812 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13814 #ifdef RTE_LIBRTE_BNXT_PMD
13815 if (ret == -ENOTSUP)
13816 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13818 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13819 if (ret == -ENOTSUP)
13820 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13827 printf("invalid is_on %d\n", is_on);
13830 printf("invalid port_id %d\n", res->port_id);
13833 printf("function not implemented\n");
13836 printf("programming error: (%s)\n", strerror(-ret));
13840 cmdline_parse_inst_t cmd_set_tx_loopback = {
13841 .f = cmd_set_tx_loopback_parsed,
13843 .help_str = "set tx loopback <port_id> on|off",
13845 (void *)&cmd_tx_loopback_set,
13846 (void *)&cmd_tx_loopback_tx,
13847 (void *)&cmd_tx_loopback_loopback,
13848 (void *)&cmd_tx_loopback_port_id,
13849 (void *)&cmd_tx_loopback_on_off,
13854 /* all queues drop enable configuration */
13856 /* Common result structure for all queues drop enable */
13857 struct cmd_all_queues_drop_en_result {
13858 cmdline_fixed_string_t set;
13859 cmdline_fixed_string_t all;
13860 cmdline_fixed_string_t queues;
13861 cmdline_fixed_string_t drop;
13863 cmdline_fixed_string_t on_off;
13866 /* Common CLI fields for tx loopback enable disable */
13867 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13868 TOKEN_STRING_INITIALIZER
13869 (struct cmd_all_queues_drop_en_result,
13871 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13872 TOKEN_STRING_INITIALIZER
13873 (struct cmd_all_queues_drop_en_result,
13875 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13876 TOKEN_STRING_INITIALIZER
13877 (struct cmd_all_queues_drop_en_result,
13879 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13880 TOKEN_STRING_INITIALIZER
13881 (struct cmd_all_queues_drop_en_result,
13883 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13884 TOKEN_NUM_INITIALIZER
13885 (struct cmd_all_queues_drop_en_result,
13887 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13888 TOKEN_STRING_INITIALIZER
13889 (struct cmd_all_queues_drop_en_result,
13893 cmd_set_all_queues_drop_en_parsed(
13894 void *parsed_result,
13895 __attribute__((unused)) struct cmdline *cl,
13896 __attribute__((unused)) void *data)
13898 struct cmd_all_queues_drop_en_result *res = parsed_result;
13899 int ret = -ENOTSUP;
13900 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13902 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13905 #ifdef RTE_LIBRTE_IXGBE_PMD
13906 if (ret == -ENOTSUP)
13907 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13909 #ifdef RTE_LIBRTE_BNXT_PMD
13910 if (ret == -ENOTSUP)
13911 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13917 printf("invalid is_on %d\n", is_on);
13920 printf("invalid port_id %d\n", res->port_id);
13923 printf("function not implemented\n");
13926 printf("programming error: (%s)\n", strerror(-ret));
13930 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13931 .f = cmd_set_all_queues_drop_en_parsed,
13933 .help_str = "set all queues drop <port_id> on|off",
13935 (void *)&cmd_all_queues_drop_en_set,
13936 (void *)&cmd_all_queues_drop_en_all,
13937 (void *)&cmd_all_queues_drop_en_queues,
13938 (void *)&cmd_all_queues_drop_en_drop,
13939 (void *)&cmd_all_queues_drop_en_port_id,
13940 (void *)&cmd_all_queues_drop_en_on_off,
13945 /* vf split drop enable configuration */
13947 /* Common result structure for vf split drop enable */
13948 struct cmd_vf_split_drop_en_result {
13949 cmdline_fixed_string_t set;
13950 cmdline_fixed_string_t vf;
13951 cmdline_fixed_string_t split;
13952 cmdline_fixed_string_t drop;
13955 cmdline_fixed_string_t on_off;
13958 /* Common CLI fields for vf split drop enable disable */
13959 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13960 TOKEN_STRING_INITIALIZER
13961 (struct cmd_vf_split_drop_en_result,
13963 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13964 TOKEN_STRING_INITIALIZER
13965 (struct cmd_vf_split_drop_en_result,
13967 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13968 TOKEN_STRING_INITIALIZER
13969 (struct cmd_vf_split_drop_en_result,
13971 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13972 TOKEN_STRING_INITIALIZER
13973 (struct cmd_vf_split_drop_en_result,
13975 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13976 TOKEN_NUM_INITIALIZER
13977 (struct cmd_vf_split_drop_en_result,
13979 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13980 TOKEN_NUM_INITIALIZER
13981 (struct cmd_vf_split_drop_en_result,
13983 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13984 TOKEN_STRING_INITIALIZER
13985 (struct cmd_vf_split_drop_en_result,
13989 cmd_set_vf_split_drop_en_parsed(
13990 void *parsed_result,
13991 __attribute__((unused)) struct cmdline *cl,
13992 __attribute__((unused)) void *data)
13994 struct cmd_vf_split_drop_en_result *res = parsed_result;
13995 int ret = -ENOTSUP;
13996 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13998 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14001 #ifdef RTE_LIBRTE_IXGBE_PMD
14002 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14009 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14012 printf("invalid port_id %d\n", res->port_id);
14015 printf("not supported on port %d\n", res->port_id);
14018 printf("programming error: (%s)\n", strerror(-ret));
14022 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14023 .f = cmd_set_vf_split_drop_en_parsed,
14025 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14027 (void *)&cmd_vf_split_drop_en_set,
14028 (void *)&cmd_vf_split_drop_en_vf,
14029 (void *)&cmd_vf_split_drop_en_split,
14030 (void *)&cmd_vf_split_drop_en_drop,
14031 (void *)&cmd_vf_split_drop_en_port_id,
14032 (void *)&cmd_vf_split_drop_en_vf_id,
14033 (void *)&cmd_vf_split_drop_en_on_off,
14038 /* vf mac address configuration */
14040 /* Common result structure for vf mac address */
14041 struct cmd_set_vf_mac_addr_result {
14042 cmdline_fixed_string_t set;
14043 cmdline_fixed_string_t vf;
14044 cmdline_fixed_string_t mac;
14045 cmdline_fixed_string_t addr;
14048 struct rte_ether_addr mac_addr;
14052 /* Common CLI fields for vf split drop enable disable */
14053 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14054 TOKEN_STRING_INITIALIZER
14055 (struct cmd_set_vf_mac_addr_result,
14057 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14058 TOKEN_STRING_INITIALIZER
14059 (struct cmd_set_vf_mac_addr_result,
14061 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14062 TOKEN_STRING_INITIALIZER
14063 (struct cmd_set_vf_mac_addr_result,
14065 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14066 TOKEN_STRING_INITIALIZER
14067 (struct cmd_set_vf_mac_addr_result,
14069 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14070 TOKEN_NUM_INITIALIZER
14071 (struct cmd_set_vf_mac_addr_result,
14073 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14074 TOKEN_NUM_INITIALIZER
14075 (struct cmd_set_vf_mac_addr_result,
14077 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14078 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14082 cmd_set_vf_mac_addr_parsed(
14083 void *parsed_result,
14084 __attribute__((unused)) struct cmdline *cl,
14085 __attribute__((unused)) void *data)
14087 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14088 int ret = -ENOTSUP;
14090 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14093 #ifdef RTE_LIBRTE_IXGBE_PMD
14094 if (ret == -ENOTSUP)
14095 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14098 #ifdef RTE_LIBRTE_I40E_PMD
14099 if (ret == -ENOTSUP)
14100 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14103 #ifdef RTE_LIBRTE_BNXT_PMD
14104 if (ret == -ENOTSUP)
14105 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14113 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14116 printf("invalid port_id %d\n", res->port_id);
14119 printf("function not implemented\n");
14122 printf("programming error: (%s)\n", strerror(-ret));
14126 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14127 .f = cmd_set_vf_mac_addr_parsed,
14129 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14131 (void *)&cmd_set_vf_mac_addr_set,
14132 (void *)&cmd_set_vf_mac_addr_vf,
14133 (void *)&cmd_set_vf_mac_addr_mac,
14134 (void *)&cmd_set_vf_mac_addr_addr,
14135 (void *)&cmd_set_vf_mac_addr_port_id,
14136 (void *)&cmd_set_vf_mac_addr_vf_id,
14137 (void *)&cmd_set_vf_mac_addr_mac_addr,
14142 /* MACsec configuration */
14144 /* Common result structure for MACsec offload enable */
14145 struct cmd_macsec_offload_on_result {
14146 cmdline_fixed_string_t set;
14147 cmdline_fixed_string_t macsec;
14148 cmdline_fixed_string_t offload;
14150 cmdline_fixed_string_t on;
14151 cmdline_fixed_string_t encrypt;
14152 cmdline_fixed_string_t en_on_off;
14153 cmdline_fixed_string_t replay_protect;
14154 cmdline_fixed_string_t rp_on_off;
14157 /* Common CLI fields for MACsec offload disable */
14158 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14159 TOKEN_STRING_INITIALIZER
14160 (struct cmd_macsec_offload_on_result,
14162 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14163 TOKEN_STRING_INITIALIZER
14164 (struct cmd_macsec_offload_on_result,
14166 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14167 TOKEN_STRING_INITIALIZER
14168 (struct cmd_macsec_offload_on_result,
14169 offload, "offload");
14170 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14171 TOKEN_NUM_INITIALIZER
14172 (struct cmd_macsec_offload_on_result,
14174 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14175 TOKEN_STRING_INITIALIZER
14176 (struct cmd_macsec_offload_on_result,
14178 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14179 TOKEN_STRING_INITIALIZER
14180 (struct cmd_macsec_offload_on_result,
14181 encrypt, "encrypt");
14182 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14183 TOKEN_STRING_INITIALIZER
14184 (struct cmd_macsec_offload_on_result,
14185 en_on_off, "on#off");
14186 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14187 TOKEN_STRING_INITIALIZER
14188 (struct cmd_macsec_offload_on_result,
14189 replay_protect, "replay-protect");
14190 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14191 TOKEN_STRING_INITIALIZER
14192 (struct cmd_macsec_offload_on_result,
14193 rp_on_off, "on#off");
14196 cmd_set_macsec_offload_on_parsed(
14197 void *parsed_result,
14198 __attribute__((unused)) struct cmdline *cl,
14199 __attribute__((unused)) void *data)
14201 struct cmd_macsec_offload_on_result *res = parsed_result;
14202 int ret = -ENOTSUP;
14203 portid_t port_id = res->port_id;
14204 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14205 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14206 struct rte_eth_dev_info dev_info;
14208 if (port_id_is_invalid(port_id, ENABLED_WARN))
14210 if (!port_is_stopped(port_id)) {
14211 printf("Please stop port %d first\n", port_id);
14215 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14219 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14220 #ifdef RTE_LIBRTE_IXGBE_PMD
14221 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14229 ports[port_id].dev_conf.txmode.offloads |=
14230 DEV_TX_OFFLOAD_MACSEC_INSERT;
14231 cmd_reconfig_device_queue(port_id, 1, 1);
14234 printf("invalid port_id %d\n", port_id);
14237 printf("not supported on port %d\n", port_id);
14240 printf("programming error: (%s)\n", strerror(-ret));
14244 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14245 .f = cmd_set_macsec_offload_on_parsed,
14247 .help_str = "set macsec offload <port_id> on "
14248 "encrypt on|off replay-protect on|off",
14250 (void *)&cmd_macsec_offload_on_set,
14251 (void *)&cmd_macsec_offload_on_macsec,
14252 (void *)&cmd_macsec_offload_on_offload,
14253 (void *)&cmd_macsec_offload_on_port_id,
14254 (void *)&cmd_macsec_offload_on_on,
14255 (void *)&cmd_macsec_offload_on_encrypt,
14256 (void *)&cmd_macsec_offload_on_en_on_off,
14257 (void *)&cmd_macsec_offload_on_replay_protect,
14258 (void *)&cmd_macsec_offload_on_rp_on_off,
14263 /* Common result structure for MACsec offload disable */
14264 struct cmd_macsec_offload_off_result {
14265 cmdline_fixed_string_t set;
14266 cmdline_fixed_string_t macsec;
14267 cmdline_fixed_string_t offload;
14269 cmdline_fixed_string_t off;
14272 /* Common CLI fields for MACsec offload disable */
14273 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14274 TOKEN_STRING_INITIALIZER
14275 (struct cmd_macsec_offload_off_result,
14277 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14278 TOKEN_STRING_INITIALIZER
14279 (struct cmd_macsec_offload_off_result,
14281 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14282 TOKEN_STRING_INITIALIZER
14283 (struct cmd_macsec_offload_off_result,
14284 offload, "offload");
14285 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14286 TOKEN_NUM_INITIALIZER
14287 (struct cmd_macsec_offload_off_result,
14289 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14290 TOKEN_STRING_INITIALIZER
14291 (struct cmd_macsec_offload_off_result,
14295 cmd_set_macsec_offload_off_parsed(
14296 void *parsed_result,
14297 __attribute__((unused)) struct cmdline *cl,
14298 __attribute__((unused)) void *data)
14300 struct cmd_macsec_offload_off_result *res = parsed_result;
14301 int ret = -ENOTSUP;
14302 struct rte_eth_dev_info dev_info;
14303 portid_t port_id = res->port_id;
14305 if (port_id_is_invalid(port_id, ENABLED_WARN))
14307 if (!port_is_stopped(port_id)) {
14308 printf("Please stop port %d first\n", port_id);
14312 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14316 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14317 #ifdef RTE_LIBRTE_IXGBE_PMD
14318 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14323 ports[port_id].dev_conf.txmode.offloads &=
14324 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14325 cmd_reconfig_device_queue(port_id, 1, 1);
14328 printf("invalid port_id %d\n", port_id);
14331 printf("not supported on port %d\n", port_id);
14334 printf("programming error: (%s)\n", strerror(-ret));
14338 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14339 .f = cmd_set_macsec_offload_off_parsed,
14341 .help_str = "set macsec offload <port_id> off",
14343 (void *)&cmd_macsec_offload_off_set,
14344 (void *)&cmd_macsec_offload_off_macsec,
14345 (void *)&cmd_macsec_offload_off_offload,
14346 (void *)&cmd_macsec_offload_off_port_id,
14347 (void *)&cmd_macsec_offload_off_off,
14352 /* Common result structure for MACsec secure connection configure */
14353 struct cmd_macsec_sc_result {
14354 cmdline_fixed_string_t set;
14355 cmdline_fixed_string_t macsec;
14356 cmdline_fixed_string_t sc;
14357 cmdline_fixed_string_t tx_rx;
14359 struct rte_ether_addr mac;
14363 /* Common CLI fields for MACsec secure connection configure */
14364 cmdline_parse_token_string_t cmd_macsec_sc_set =
14365 TOKEN_STRING_INITIALIZER
14366 (struct cmd_macsec_sc_result,
14368 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14369 TOKEN_STRING_INITIALIZER
14370 (struct cmd_macsec_sc_result,
14372 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14373 TOKEN_STRING_INITIALIZER
14374 (struct cmd_macsec_sc_result,
14376 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14377 TOKEN_STRING_INITIALIZER
14378 (struct cmd_macsec_sc_result,
14380 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14381 TOKEN_NUM_INITIALIZER
14382 (struct cmd_macsec_sc_result,
14384 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14385 TOKEN_ETHERADDR_INITIALIZER
14386 (struct cmd_macsec_sc_result,
14388 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14389 TOKEN_NUM_INITIALIZER
14390 (struct cmd_macsec_sc_result,
14394 cmd_set_macsec_sc_parsed(
14395 void *parsed_result,
14396 __attribute__((unused)) struct cmdline *cl,
14397 __attribute__((unused)) void *data)
14399 struct cmd_macsec_sc_result *res = parsed_result;
14400 int ret = -ENOTSUP;
14401 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14403 #ifdef RTE_LIBRTE_IXGBE_PMD
14405 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14406 res->mac.addr_bytes) :
14407 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14408 res->mac.addr_bytes, res->pi);
14410 RTE_SET_USED(is_tx);
14416 printf("invalid port_id %d\n", res->port_id);
14419 printf("not supported on port %d\n", res->port_id);
14422 printf("programming error: (%s)\n", strerror(-ret));
14426 cmdline_parse_inst_t cmd_set_macsec_sc = {
14427 .f = cmd_set_macsec_sc_parsed,
14429 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14431 (void *)&cmd_macsec_sc_set,
14432 (void *)&cmd_macsec_sc_macsec,
14433 (void *)&cmd_macsec_sc_sc,
14434 (void *)&cmd_macsec_sc_tx_rx,
14435 (void *)&cmd_macsec_sc_port_id,
14436 (void *)&cmd_macsec_sc_mac,
14437 (void *)&cmd_macsec_sc_pi,
14442 /* Common result structure for MACsec secure connection configure */
14443 struct cmd_macsec_sa_result {
14444 cmdline_fixed_string_t set;
14445 cmdline_fixed_string_t macsec;
14446 cmdline_fixed_string_t sa;
14447 cmdline_fixed_string_t tx_rx;
14452 cmdline_fixed_string_t key;
14455 /* Common CLI fields for MACsec secure connection configure */
14456 cmdline_parse_token_string_t cmd_macsec_sa_set =
14457 TOKEN_STRING_INITIALIZER
14458 (struct cmd_macsec_sa_result,
14460 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14461 TOKEN_STRING_INITIALIZER
14462 (struct cmd_macsec_sa_result,
14464 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14465 TOKEN_STRING_INITIALIZER
14466 (struct cmd_macsec_sa_result,
14468 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14469 TOKEN_STRING_INITIALIZER
14470 (struct cmd_macsec_sa_result,
14472 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14473 TOKEN_NUM_INITIALIZER
14474 (struct cmd_macsec_sa_result,
14476 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14477 TOKEN_NUM_INITIALIZER
14478 (struct cmd_macsec_sa_result,
14480 cmdline_parse_token_num_t cmd_macsec_sa_an =
14481 TOKEN_NUM_INITIALIZER
14482 (struct cmd_macsec_sa_result,
14484 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14485 TOKEN_NUM_INITIALIZER
14486 (struct cmd_macsec_sa_result,
14488 cmdline_parse_token_string_t cmd_macsec_sa_key =
14489 TOKEN_STRING_INITIALIZER
14490 (struct cmd_macsec_sa_result,
14494 cmd_set_macsec_sa_parsed(
14495 void *parsed_result,
14496 __attribute__((unused)) struct cmdline *cl,
14497 __attribute__((unused)) void *data)
14499 struct cmd_macsec_sa_result *res = parsed_result;
14500 int ret = -ENOTSUP;
14501 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14502 uint8_t key[16] = { 0 };
14508 key_len = strlen(res->key) / 2;
14512 for (i = 0; i < key_len; i++) {
14513 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14516 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14519 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14522 #ifdef RTE_LIBRTE_IXGBE_PMD
14524 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14525 res->idx, res->an, res->pn, key) :
14526 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14527 res->idx, res->an, res->pn, key);
14529 RTE_SET_USED(is_tx);
14536 printf("invalid idx %d or an %d\n", res->idx, res->an);
14539 printf("invalid port_id %d\n", res->port_id);
14542 printf("not supported on port %d\n", res->port_id);
14545 printf("programming error: (%s)\n", strerror(-ret));
14549 cmdline_parse_inst_t cmd_set_macsec_sa = {
14550 .f = cmd_set_macsec_sa_parsed,
14552 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14554 (void *)&cmd_macsec_sa_set,
14555 (void *)&cmd_macsec_sa_macsec,
14556 (void *)&cmd_macsec_sa_sa,
14557 (void *)&cmd_macsec_sa_tx_rx,
14558 (void *)&cmd_macsec_sa_port_id,
14559 (void *)&cmd_macsec_sa_idx,
14560 (void *)&cmd_macsec_sa_an,
14561 (void *)&cmd_macsec_sa_pn,
14562 (void *)&cmd_macsec_sa_key,
14567 /* VF unicast promiscuous mode configuration */
14569 /* Common result structure for VF unicast promiscuous mode */
14570 struct cmd_vf_promisc_result {
14571 cmdline_fixed_string_t set;
14572 cmdline_fixed_string_t vf;
14573 cmdline_fixed_string_t promisc;
14576 cmdline_fixed_string_t on_off;
14579 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14580 cmdline_parse_token_string_t cmd_vf_promisc_set =
14581 TOKEN_STRING_INITIALIZER
14582 (struct cmd_vf_promisc_result,
14584 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14585 TOKEN_STRING_INITIALIZER
14586 (struct cmd_vf_promisc_result,
14588 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14589 TOKEN_STRING_INITIALIZER
14590 (struct cmd_vf_promisc_result,
14591 promisc, "promisc");
14592 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14593 TOKEN_NUM_INITIALIZER
14594 (struct cmd_vf_promisc_result,
14596 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14597 TOKEN_NUM_INITIALIZER
14598 (struct cmd_vf_promisc_result,
14600 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14601 TOKEN_STRING_INITIALIZER
14602 (struct cmd_vf_promisc_result,
14606 cmd_set_vf_promisc_parsed(
14607 void *parsed_result,
14608 __attribute__((unused)) struct cmdline *cl,
14609 __attribute__((unused)) void *data)
14611 struct cmd_vf_promisc_result *res = parsed_result;
14612 int ret = -ENOTSUP;
14614 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14619 #ifdef RTE_LIBRTE_I40E_PMD
14620 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14621 res->vf_id, is_on);
14628 printf("invalid vf_id %d\n", res->vf_id);
14631 printf("invalid port_id %d\n", res->port_id);
14634 printf("function not implemented\n");
14637 printf("programming error: (%s)\n", strerror(-ret));
14641 cmdline_parse_inst_t cmd_set_vf_promisc = {
14642 .f = cmd_set_vf_promisc_parsed,
14644 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14645 "Set unicast promiscuous mode for a VF from the PF",
14647 (void *)&cmd_vf_promisc_set,
14648 (void *)&cmd_vf_promisc_vf,
14649 (void *)&cmd_vf_promisc_promisc,
14650 (void *)&cmd_vf_promisc_port_id,
14651 (void *)&cmd_vf_promisc_vf_id,
14652 (void *)&cmd_vf_promisc_on_off,
14657 /* VF multicast promiscuous mode configuration */
14659 /* Common result structure for VF multicast promiscuous mode */
14660 struct cmd_vf_allmulti_result {
14661 cmdline_fixed_string_t set;
14662 cmdline_fixed_string_t vf;
14663 cmdline_fixed_string_t allmulti;
14666 cmdline_fixed_string_t on_off;
14669 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14670 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14671 TOKEN_STRING_INITIALIZER
14672 (struct cmd_vf_allmulti_result,
14674 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14675 TOKEN_STRING_INITIALIZER
14676 (struct cmd_vf_allmulti_result,
14678 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14679 TOKEN_STRING_INITIALIZER
14680 (struct cmd_vf_allmulti_result,
14681 allmulti, "allmulti");
14682 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14683 TOKEN_NUM_INITIALIZER
14684 (struct cmd_vf_allmulti_result,
14686 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14687 TOKEN_NUM_INITIALIZER
14688 (struct cmd_vf_allmulti_result,
14690 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14691 TOKEN_STRING_INITIALIZER
14692 (struct cmd_vf_allmulti_result,
14696 cmd_set_vf_allmulti_parsed(
14697 void *parsed_result,
14698 __attribute__((unused)) struct cmdline *cl,
14699 __attribute__((unused)) void *data)
14701 struct cmd_vf_allmulti_result *res = parsed_result;
14702 int ret = -ENOTSUP;
14704 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14706 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14709 #ifdef RTE_LIBRTE_I40E_PMD
14710 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14711 res->vf_id, is_on);
14718 printf("invalid vf_id %d\n", res->vf_id);
14721 printf("invalid port_id %d\n", res->port_id);
14724 printf("function not implemented\n");
14727 printf("programming error: (%s)\n", strerror(-ret));
14731 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14732 .f = cmd_set_vf_allmulti_parsed,
14734 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14735 "Set multicast promiscuous mode for a VF from the PF",
14737 (void *)&cmd_vf_allmulti_set,
14738 (void *)&cmd_vf_allmulti_vf,
14739 (void *)&cmd_vf_allmulti_allmulti,
14740 (void *)&cmd_vf_allmulti_port_id,
14741 (void *)&cmd_vf_allmulti_vf_id,
14742 (void *)&cmd_vf_allmulti_on_off,
14747 /* vf broadcast mode configuration */
14749 /* Common result structure for vf broadcast */
14750 struct cmd_set_vf_broadcast_result {
14751 cmdline_fixed_string_t set;
14752 cmdline_fixed_string_t vf;
14753 cmdline_fixed_string_t broadcast;
14756 cmdline_fixed_string_t on_off;
14759 /* Common CLI fields for vf broadcast enable disable */
14760 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14761 TOKEN_STRING_INITIALIZER
14762 (struct cmd_set_vf_broadcast_result,
14764 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14765 TOKEN_STRING_INITIALIZER
14766 (struct cmd_set_vf_broadcast_result,
14768 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14769 TOKEN_STRING_INITIALIZER
14770 (struct cmd_set_vf_broadcast_result,
14771 broadcast, "broadcast");
14772 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14773 TOKEN_NUM_INITIALIZER
14774 (struct cmd_set_vf_broadcast_result,
14776 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14777 TOKEN_NUM_INITIALIZER
14778 (struct cmd_set_vf_broadcast_result,
14780 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14781 TOKEN_STRING_INITIALIZER
14782 (struct cmd_set_vf_broadcast_result,
14786 cmd_set_vf_broadcast_parsed(
14787 void *parsed_result,
14788 __attribute__((unused)) struct cmdline *cl,
14789 __attribute__((unused)) void *data)
14791 struct cmd_set_vf_broadcast_result *res = parsed_result;
14792 int ret = -ENOTSUP;
14794 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14796 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14799 #ifdef RTE_LIBRTE_I40E_PMD
14800 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14801 res->vf_id, is_on);
14808 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14811 printf("invalid port_id %d\n", res->port_id);
14814 printf("function not implemented\n");
14817 printf("programming error: (%s)\n", strerror(-ret));
14821 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14822 .f = cmd_set_vf_broadcast_parsed,
14824 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14826 (void *)&cmd_set_vf_broadcast_set,
14827 (void *)&cmd_set_vf_broadcast_vf,
14828 (void *)&cmd_set_vf_broadcast_broadcast,
14829 (void *)&cmd_set_vf_broadcast_port_id,
14830 (void *)&cmd_set_vf_broadcast_vf_id,
14831 (void *)&cmd_set_vf_broadcast_on_off,
14836 /* vf vlan tag configuration */
14838 /* Common result structure for vf vlan tag */
14839 struct cmd_set_vf_vlan_tag_result {
14840 cmdline_fixed_string_t set;
14841 cmdline_fixed_string_t vf;
14842 cmdline_fixed_string_t vlan;
14843 cmdline_fixed_string_t tag;
14846 cmdline_fixed_string_t on_off;
14849 /* Common CLI fields for vf vlan tag enable disable */
14850 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14851 TOKEN_STRING_INITIALIZER
14852 (struct cmd_set_vf_vlan_tag_result,
14854 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14855 TOKEN_STRING_INITIALIZER
14856 (struct cmd_set_vf_vlan_tag_result,
14858 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14859 TOKEN_STRING_INITIALIZER
14860 (struct cmd_set_vf_vlan_tag_result,
14862 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14863 TOKEN_STRING_INITIALIZER
14864 (struct cmd_set_vf_vlan_tag_result,
14866 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14867 TOKEN_NUM_INITIALIZER
14868 (struct cmd_set_vf_vlan_tag_result,
14870 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14871 TOKEN_NUM_INITIALIZER
14872 (struct cmd_set_vf_vlan_tag_result,
14874 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14875 TOKEN_STRING_INITIALIZER
14876 (struct cmd_set_vf_vlan_tag_result,
14880 cmd_set_vf_vlan_tag_parsed(
14881 void *parsed_result,
14882 __attribute__((unused)) struct cmdline *cl,
14883 __attribute__((unused)) void *data)
14885 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14886 int ret = -ENOTSUP;
14888 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14893 #ifdef RTE_LIBRTE_I40E_PMD
14894 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14895 res->vf_id, is_on);
14902 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14905 printf("invalid port_id %d\n", res->port_id);
14908 printf("function not implemented\n");
14911 printf("programming error: (%s)\n", strerror(-ret));
14915 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14916 .f = cmd_set_vf_vlan_tag_parsed,
14918 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14920 (void *)&cmd_set_vf_vlan_tag_set,
14921 (void *)&cmd_set_vf_vlan_tag_vf,
14922 (void *)&cmd_set_vf_vlan_tag_vlan,
14923 (void *)&cmd_set_vf_vlan_tag_tag,
14924 (void *)&cmd_set_vf_vlan_tag_port_id,
14925 (void *)&cmd_set_vf_vlan_tag_vf_id,
14926 (void *)&cmd_set_vf_vlan_tag_on_off,
14931 /* Common definition of VF and TC TX bandwidth configuration */
14932 struct cmd_vf_tc_bw_result {
14933 cmdline_fixed_string_t set;
14934 cmdline_fixed_string_t vf;
14935 cmdline_fixed_string_t tc;
14936 cmdline_fixed_string_t tx;
14937 cmdline_fixed_string_t min_bw;
14938 cmdline_fixed_string_t max_bw;
14939 cmdline_fixed_string_t strict_link_prio;
14944 cmdline_fixed_string_t bw_list;
14948 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14949 TOKEN_STRING_INITIALIZER
14950 (struct cmd_vf_tc_bw_result,
14952 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14953 TOKEN_STRING_INITIALIZER
14954 (struct cmd_vf_tc_bw_result,
14956 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14957 TOKEN_STRING_INITIALIZER
14958 (struct cmd_vf_tc_bw_result,
14960 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14961 TOKEN_STRING_INITIALIZER
14962 (struct cmd_vf_tc_bw_result,
14964 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14965 TOKEN_STRING_INITIALIZER
14966 (struct cmd_vf_tc_bw_result,
14967 strict_link_prio, "strict-link-priority");
14968 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14969 TOKEN_STRING_INITIALIZER
14970 (struct cmd_vf_tc_bw_result,
14971 min_bw, "min-bandwidth");
14972 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14973 TOKEN_STRING_INITIALIZER
14974 (struct cmd_vf_tc_bw_result,
14975 max_bw, "max-bandwidth");
14976 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14977 TOKEN_NUM_INITIALIZER
14978 (struct cmd_vf_tc_bw_result,
14980 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14981 TOKEN_NUM_INITIALIZER
14982 (struct cmd_vf_tc_bw_result,
14984 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14985 TOKEN_NUM_INITIALIZER
14986 (struct cmd_vf_tc_bw_result,
14988 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14989 TOKEN_NUM_INITIALIZER
14990 (struct cmd_vf_tc_bw_result,
14992 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14993 TOKEN_STRING_INITIALIZER
14994 (struct cmd_vf_tc_bw_result,
14996 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14997 TOKEN_NUM_INITIALIZER
14998 (struct cmd_vf_tc_bw_result,
15001 /* VF max bandwidth setting */
15003 cmd_vf_max_bw_parsed(
15004 void *parsed_result,
15005 __attribute__((unused)) struct cmdline *cl,
15006 __attribute__((unused)) void *data)
15008 struct cmd_vf_tc_bw_result *res = parsed_result;
15009 int ret = -ENOTSUP;
15011 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15014 #ifdef RTE_LIBRTE_I40E_PMD
15015 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15016 res->vf_id, res->bw);
15023 printf("invalid vf_id %d or bandwidth %d\n",
15024 res->vf_id, res->bw);
15027 printf("invalid port_id %d\n", res->port_id);
15030 printf("function not implemented\n");
15033 printf("programming error: (%s)\n", strerror(-ret));
15037 cmdline_parse_inst_t cmd_vf_max_bw = {
15038 .f = cmd_vf_max_bw_parsed,
15040 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15042 (void *)&cmd_vf_tc_bw_set,
15043 (void *)&cmd_vf_tc_bw_vf,
15044 (void *)&cmd_vf_tc_bw_tx,
15045 (void *)&cmd_vf_tc_bw_max_bw,
15046 (void *)&cmd_vf_tc_bw_port_id,
15047 (void *)&cmd_vf_tc_bw_vf_id,
15048 (void *)&cmd_vf_tc_bw_bw,
15054 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15059 const char *p, *p0 = str;
15066 p = strchr(p0, '(');
15068 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15072 p0 = strchr(p, ')');
15074 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15078 if (size >= sizeof(s)) {
15079 printf("The string size exceeds the internal buffer size\n");
15082 snprintf(s, sizeof(s), "%.*s", size, p);
15083 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15085 printf("Failed to get the bandwidth list. ");
15089 for (i = 0; i < ret; i++)
15090 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15095 /* TC min bandwidth setting */
15097 cmd_vf_tc_min_bw_parsed(
15098 void *parsed_result,
15099 __attribute__((unused)) struct cmdline *cl,
15100 __attribute__((unused)) void *data)
15102 struct cmd_vf_tc_bw_result *res = parsed_result;
15105 int ret = -ENOTSUP;
15107 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15110 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15114 #ifdef RTE_LIBRTE_I40E_PMD
15115 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15123 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15126 printf("invalid port_id %d\n", res->port_id);
15129 printf("function not implemented\n");
15132 printf("programming error: (%s)\n", strerror(-ret));
15136 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15137 .f = cmd_vf_tc_min_bw_parsed,
15139 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15140 " <bw1, bw2, ...>",
15142 (void *)&cmd_vf_tc_bw_set,
15143 (void *)&cmd_vf_tc_bw_vf,
15144 (void *)&cmd_vf_tc_bw_tc,
15145 (void *)&cmd_vf_tc_bw_tx,
15146 (void *)&cmd_vf_tc_bw_min_bw,
15147 (void *)&cmd_vf_tc_bw_port_id,
15148 (void *)&cmd_vf_tc_bw_vf_id,
15149 (void *)&cmd_vf_tc_bw_bw_list,
15155 cmd_tc_min_bw_parsed(
15156 void *parsed_result,
15157 __attribute__((unused)) struct cmdline *cl,
15158 __attribute__((unused)) void *data)
15160 struct cmd_vf_tc_bw_result *res = parsed_result;
15161 struct rte_port *port;
15164 int ret = -ENOTSUP;
15166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15169 port = &ports[res->port_id];
15170 /** Check if the port is not started **/
15171 if (port->port_status != RTE_PORT_STOPPED) {
15172 printf("Please stop port %d first\n", res->port_id);
15176 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15180 #ifdef RTE_LIBRTE_IXGBE_PMD
15181 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15188 printf("invalid bandwidth\n");
15191 printf("invalid port_id %d\n", res->port_id);
15194 printf("function not implemented\n");
15197 printf("programming error: (%s)\n", strerror(-ret));
15201 cmdline_parse_inst_t cmd_tc_min_bw = {
15202 .f = cmd_tc_min_bw_parsed,
15204 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15206 (void *)&cmd_vf_tc_bw_set,
15207 (void *)&cmd_vf_tc_bw_tc,
15208 (void *)&cmd_vf_tc_bw_tx,
15209 (void *)&cmd_vf_tc_bw_min_bw,
15210 (void *)&cmd_vf_tc_bw_port_id,
15211 (void *)&cmd_vf_tc_bw_bw_list,
15216 /* TC max bandwidth setting */
15218 cmd_vf_tc_max_bw_parsed(
15219 void *parsed_result,
15220 __attribute__((unused)) struct cmdline *cl,
15221 __attribute__((unused)) void *data)
15223 struct cmd_vf_tc_bw_result *res = parsed_result;
15224 int ret = -ENOTSUP;
15226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15229 #ifdef RTE_LIBRTE_I40E_PMD
15230 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15231 res->tc_no, res->bw);
15238 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15239 res->vf_id, res->tc_no, res->bw);
15242 printf("invalid port_id %d\n", res->port_id);
15245 printf("function not implemented\n");
15248 printf("programming error: (%s)\n", strerror(-ret));
15252 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15253 .f = cmd_vf_tc_max_bw_parsed,
15255 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15258 (void *)&cmd_vf_tc_bw_set,
15259 (void *)&cmd_vf_tc_bw_vf,
15260 (void *)&cmd_vf_tc_bw_tc,
15261 (void *)&cmd_vf_tc_bw_tx,
15262 (void *)&cmd_vf_tc_bw_max_bw,
15263 (void *)&cmd_vf_tc_bw_port_id,
15264 (void *)&cmd_vf_tc_bw_vf_id,
15265 (void *)&cmd_vf_tc_bw_tc_no,
15266 (void *)&cmd_vf_tc_bw_bw,
15272 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15274 /* *** Set Port default Traffic Management Hierarchy *** */
15275 struct cmd_set_port_tm_hierarchy_default_result {
15276 cmdline_fixed_string_t set;
15277 cmdline_fixed_string_t port;
15278 cmdline_fixed_string_t tm;
15279 cmdline_fixed_string_t hierarchy;
15280 cmdline_fixed_string_t def;
15284 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15285 TOKEN_STRING_INITIALIZER(
15286 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15287 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15288 TOKEN_STRING_INITIALIZER(
15289 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15290 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15291 TOKEN_STRING_INITIALIZER(
15292 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15293 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15294 TOKEN_STRING_INITIALIZER(
15295 struct cmd_set_port_tm_hierarchy_default_result,
15296 hierarchy, "hierarchy");
15297 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15298 TOKEN_STRING_INITIALIZER(
15299 struct cmd_set_port_tm_hierarchy_default_result,
15301 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15302 TOKEN_NUM_INITIALIZER(
15303 struct cmd_set_port_tm_hierarchy_default_result,
15306 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15307 __attribute__((unused)) struct cmdline *cl,
15308 __attribute__((unused)) void *data)
15310 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15311 struct rte_port *p;
15312 portid_t port_id = res->port_id;
15314 if (port_id_is_invalid(port_id, ENABLED_WARN))
15317 p = &ports[port_id];
15319 /* Forward mode: tm */
15320 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15321 printf(" softnicfwd mode not enabled(error)\n");
15325 /* Set the default tm hierarchy */
15326 p->softport.default_tm_hierarchy_enable = 1;
15329 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15330 .f = cmd_set_port_tm_hierarchy_default_parsed,
15332 .help_str = "set port tm hierarchy default <port_id>",
15334 (void *)&cmd_set_port_tm_hierarchy_default_set,
15335 (void *)&cmd_set_port_tm_hierarchy_default_port,
15336 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15337 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15338 (void *)&cmd_set_port_tm_hierarchy_default_default,
15339 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15345 /** Set VXLAN encapsulation details */
15346 struct cmd_set_vxlan_result {
15347 cmdline_fixed_string_t set;
15348 cmdline_fixed_string_t vxlan;
15349 cmdline_fixed_string_t pos_token;
15350 cmdline_fixed_string_t ip_version;
15351 uint32_t vlan_present:1;
15355 cmdline_ipaddr_t ip_src;
15356 cmdline_ipaddr_t ip_dst;
15360 struct rte_ether_addr eth_src;
15361 struct rte_ether_addr eth_dst;
15364 cmdline_parse_token_string_t cmd_set_vxlan_set =
15365 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15366 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15367 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15368 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15369 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15371 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15372 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15373 "vxlan-with-vlan");
15374 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15375 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15377 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15378 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15380 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15381 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15383 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15384 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15385 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15386 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15388 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15389 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15390 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15391 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15393 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15394 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15395 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15396 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15398 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15399 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15400 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15401 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15403 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15404 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15405 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15406 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15408 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15409 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15410 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15411 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15413 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15414 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15415 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15416 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15418 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15419 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15420 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15421 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15423 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15424 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15425 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15426 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15428 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15429 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15431 static void cmd_set_vxlan_parsed(void *parsed_result,
15432 __attribute__((unused)) struct cmdline *cl,
15433 __attribute__((unused)) void *data)
15435 struct cmd_set_vxlan_result *res = parsed_result;
15440 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15443 vxlan_encap_conf.select_tos_ttl = 0;
15444 if (strcmp(res->vxlan, "vxlan") == 0)
15445 vxlan_encap_conf.select_vlan = 0;
15446 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15447 vxlan_encap_conf.select_vlan = 1;
15448 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15449 vxlan_encap_conf.select_vlan = 0;
15450 vxlan_encap_conf.select_tos_ttl = 1;
15452 if (strcmp(res->ip_version, "ipv4") == 0)
15453 vxlan_encap_conf.select_ipv4 = 1;
15454 else if (strcmp(res->ip_version, "ipv6") == 0)
15455 vxlan_encap_conf.select_ipv4 = 0;
15458 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15459 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15460 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15461 vxlan_encap_conf.ip_tos = res->tos;
15462 vxlan_encap_conf.ip_ttl = res->ttl;
15463 if (vxlan_encap_conf.select_ipv4) {
15464 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15465 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15467 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15468 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15470 if (vxlan_encap_conf.select_vlan)
15471 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15472 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15473 RTE_ETHER_ADDR_LEN);
15474 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15475 RTE_ETHER_ADDR_LEN);
15478 cmdline_parse_inst_t cmd_set_vxlan = {
15479 .f = cmd_set_vxlan_parsed,
15481 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15482 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15483 " eth-src <eth-src> eth-dst <eth-dst>",
15485 (void *)&cmd_set_vxlan_set,
15486 (void *)&cmd_set_vxlan_vxlan,
15487 (void *)&cmd_set_vxlan_ip_version,
15488 (void *)&cmd_set_vxlan_ip_version_value,
15489 (void *)&cmd_set_vxlan_vni,
15490 (void *)&cmd_set_vxlan_vni_value,
15491 (void *)&cmd_set_vxlan_udp_src,
15492 (void *)&cmd_set_vxlan_udp_src_value,
15493 (void *)&cmd_set_vxlan_udp_dst,
15494 (void *)&cmd_set_vxlan_udp_dst_value,
15495 (void *)&cmd_set_vxlan_ip_src,
15496 (void *)&cmd_set_vxlan_ip_src_value,
15497 (void *)&cmd_set_vxlan_ip_dst,
15498 (void *)&cmd_set_vxlan_ip_dst_value,
15499 (void *)&cmd_set_vxlan_eth_src,
15500 (void *)&cmd_set_vxlan_eth_src_value,
15501 (void *)&cmd_set_vxlan_eth_dst,
15502 (void *)&cmd_set_vxlan_eth_dst_value,
15507 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15508 .f = cmd_set_vxlan_parsed,
15510 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15511 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15512 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15513 " eth-dst <eth-dst>",
15515 (void *)&cmd_set_vxlan_set,
15516 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15517 (void *)&cmd_set_vxlan_ip_version,
15518 (void *)&cmd_set_vxlan_ip_version_value,
15519 (void *)&cmd_set_vxlan_vni,
15520 (void *)&cmd_set_vxlan_vni_value,
15521 (void *)&cmd_set_vxlan_udp_src,
15522 (void *)&cmd_set_vxlan_udp_src_value,
15523 (void *)&cmd_set_vxlan_udp_dst,
15524 (void *)&cmd_set_vxlan_udp_dst_value,
15525 (void *)&cmd_set_vxlan_ip_tos,
15526 (void *)&cmd_set_vxlan_ip_tos_value,
15527 (void *)&cmd_set_vxlan_ip_ttl,
15528 (void *)&cmd_set_vxlan_ip_ttl_value,
15529 (void *)&cmd_set_vxlan_ip_src,
15530 (void *)&cmd_set_vxlan_ip_src_value,
15531 (void *)&cmd_set_vxlan_ip_dst,
15532 (void *)&cmd_set_vxlan_ip_dst_value,
15533 (void *)&cmd_set_vxlan_eth_src,
15534 (void *)&cmd_set_vxlan_eth_src_value,
15535 (void *)&cmd_set_vxlan_eth_dst,
15536 (void *)&cmd_set_vxlan_eth_dst_value,
15541 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15542 .f = cmd_set_vxlan_parsed,
15544 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15545 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15546 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15549 (void *)&cmd_set_vxlan_set,
15550 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15551 (void *)&cmd_set_vxlan_ip_version,
15552 (void *)&cmd_set_vxlan_ip_version_value,
15553 (void *)&cmd_set_vxlan_vni,
15554 (void *)&cmd_set_vxlan_vni_value,
15555 (void *)&cmd_set_vxlan_udp_src,
15556 (void *)&cmd_set_vxlan_udp_src_value,
15557 (void *)&cmd_set_vxlan_udp_dst,
15558 (void *)&cmd_set_vxlan_udp_dst_value,
15559 (void *)&cmd_set_vxlan_ip_src,
15560 (void *)&cmd_set_vxlan_ip_src_value,
15561 (void *)&cmd_set_vxlan_ip_dst,
15562 (void *)&cmd_set_vxlan_ip_dst_value,
15563 (void *)&cmd_set_vxlan_vlan,
15564 (void *)&cmd_set_vxlan_vlan_value,
15565 (void *)&cmd_set_vxlan_eth_src,
15566 (void *)&cmd_set_vxlan_eth_src_value,
15567 (void *)&cmd_set_vxlan_eth_dst,
15568 (void *)&cmd_set_vxlan_eth_dst_value,
15573 /** Set NVGRE encapsulation details */
15574 struct cmd_set_nvgre_result {
15575 cmdline_fixed_string_t set;
15576 cmdline_fixed_string_t nvgre;
15577 cmdline_fixed_string_t pos_token;
15578 cmdline_fixed_string_t ip_version;
15580 cmdline_ipaddr_t ip_src;
15581 cmdline_ipaddr_t ip_dst;
15583 struct rte_ether_addr eth_src;
15584 struct rte_ether_addr eth_dst;
15587 cmdline_parse_token_string_t cmd_set_nvgre_set =
15588 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15589 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15590 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15591 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15592 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15593 "nvgre-with-vlan");
15594 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15595 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15597 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15598 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15600 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15601 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15603 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15604 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15605 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15606 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15608 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15609 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15610 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15611 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15613 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15614 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15615 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15616 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15618 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15619 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15620 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15621 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15623 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15624 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15625 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15626 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15628 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15629 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15631 static void cmd_set_nvgre_parsed(void *parsed_result,
15632 __attribute__((unused)) struct cmdline *cl,
15633 __attribute__((unused)) void *data)
15635 struct cmd_set_nvgre_result *res = parsed_result;
15637 uint32_t nvgre_tni;
15640 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15643 if (strcmp(res->nvgre, "nvgre") == 0)
15644 nvgre_encap_conf.select_vlan = 0;
15645 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15646 nvgre_encap_conf.select_vlan = 1;
15647 if (strcmp(res->ip_version, "ipv4") == 0)
15648 nvgre_encap_conf.select_ipv4 = 1;
15649 else if (strcmp(res->ip_version, "ipv6") == 0)
15650 nvgre_encap_conf.select_ipv4 = 0;
15653 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15654 if (nvgre_encap_conf.select_ipv4) {
15655 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15656 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15658 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15659 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15661 if (nvgre_encap_conf.select_vlan)
15662 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15663 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15664 RTE_ETHER_ADDR_LEN);
15665 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15666 RTE_ETHER_ADDR_LEN);
15669 cmdline_parse_inst_t cmd_set_nvgre = {
15670 .f = cmd_set_nvgre_parsed,
15672 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15673 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15674 " eth-dst <eth-dst>",
15676 (void *)&cmd_set_nvgre_set,
15677 (void *)&cmd_set_nvgre_nvgre,
15678 (void *)&cmd_set_nvgre_ip_version,
15679 (void *)&cmd_set_nvgre_ip_version_value,
15680 (void *)&cmd_set_nvgre_tni,
15681 (void *)&cmd_set_nvgre_tni_value,
15682 (void *)&cmd_set_nvgre_ip_src,
15683 (void *)&cmd_set_nvgre_ip_src_value,
15684 (void *)&cmd_set_nvgre_ip_dst,
15685 (void *)&cmd_set_nvgre_ip_dst_value,
15686 (void *)&cmd_set_nvgre_eth_src,
15687 (void *)&cmd_set_nvgre_eth_src_value,
15688 (void *)&cmd_set_nvgre_eth_dst,
15689 (void *)&cmd_set_nvgre_eth_dst_value,
15694 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15695 .f = cmd_set_nvgre_parsed,
15697 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15698 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15699 " eth-src <eth-src> eth-dst <eth-dst>",
15701 (void *)&cmd_set_nvgre_set,
15702 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15703 (void *)&cmd_set_nvgre_ip_version,
15704 (void *)&cmd_set_nvgre_ip_version_value,
15705 (void *)&cmd_set_nvgre_tni,
15706 (void *)&cmd_set_nvgre_tni_value,
15707 (void *)&cmd_set_nvgre_ip_src,
15708 (void *)&cmd_set_nvgre_ip_src_value,
15709 (void *)&cmd_set_nvgre_ip_dst,
15710 (void *)&cmd_set_nvgre_ip_dst_value,
15711 (void *)&cmd_set_nvgre_vlan,
15712 (void *)&cmd_set_nvgre_vlan_value,
15713 (void *)&cmd_set_nvgre_eth_src,
15714 (void *)&cmd_set_nvgre_eth_src_value,
15715 (void *)&cmd_set_nvgre_eth_dst,
15716 (void *)&cmd_set_nvgre_eth_dst_value,
15721 /** Set L2 encapsulation details */
15722 struct cmd_set_l2_encap_result {
15723 cmdline_fixed_string_t set;
15724 cmdline_fixed_string_t l2_encap;
15725 cmdline_fixed_string_t pos_token;
15726 cmdline_fixed_string_t ip_version;
15727 uint32_t vlan_present:1;
15729 struct rte_ether_addr eth_src;
15730 struct rte_ether_addr eth_dst;
15733 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15734 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15735 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15736 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15737 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15738 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15739 "l2_encap-with-vlan");
15740 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15741 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15743 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15744 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15746 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15747 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15749 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15750 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15751 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15752 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15754 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15755 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15756 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15757 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15759 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15760 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15762 static void cmd_set_l2_encap_parsed(void *parsed_result,
15763 __attribute__((unused)) struct cmdline *cl,
15764 __attribute__((unused)) void *data)
15766 struct cmd_set_l2_encap_result *res = parsed_result;
15768 if (strcmp(res->l2_encap, "l2_encap") == 0)
15769 l2_encap_conf.select_vlan = 0;
15770 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15771 l2_encap_conf.select_vlan = 1;
15772 if (strcmp(res->ip_version, "ipv4") == 0)
15773 l2_encap_conf.select_ipv4 = 1;
15774 else if (strcmp(res->ip_version, "ipv6") == 0)
15775 l2_encap_conf.select_ipv4 = 0;
15778 if (l2_encap_conf.select_vlan)
15779 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15780 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15781 RTE_ETHER_ADDR_LEN);
15782 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15783 RTE_ETHER_ADDR_LEN);
15786 cmdline_parse_inst_t cmd_set_l2_encap = {
15787 .f = cmd_set_l2_encap_parsed,
15789 .help_str = "set l2_encap ip-version ipv4|ipv6"
15790 " eth-src <eth-src> eth-dst <eth-dst>",
15792 (void *)&cmd_set_l2_encap_set,
15793 (void *)&cmd_set_l2_encap_l2_encap,
15794 (void *)&cmd_set_l2_encap_ip_version,
15795 (void *)&cmd_set_l2_encap_ip_version_value,
15796 (void *)&cmd_set_l2_encap_eth_src,
15797 (void *)&cmd_set_l2_encap_eth_src_value,
15798 (void *)&cmd_set_l2_encap_eth_dst,
15799 (void *)&cmd_set_l2_encap_eth_dst_value,
15804 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15805 .f = cmd_set_l2_encap_parsed,
15807 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15808 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15810 (void *)&cmd_set_l2_encap_set,
15811 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15812 (void *)&cmd_set_l2_encap_ip_version,
15813 (void *)&cmd_set_l2_encap_ip_version_value,
15814 (void *)&cmd_set_l2_encap_vlan,
15815 (void *)&cmd_set_l2_encap_vlan_value,
15816 (void *)&cmd_set_l2_encap_eth_src,
15817 (void *)&cmd_set_l2_encap_eth_src_value,
15818 (void *)&cmd_set_l2_encap_eth_dst,
15819 (void *)&cmd_set_l2_encap_eth_dst_value,
15824 /** Set L2 decapsulation details */
15825 struct cmd_set_l2_decap_result {
15826 cmdline_fixed_string_t set;
15827 cmdline_fixed_string_t l2_decap;
15828 cmdline_fixed_string_t pos_token;
15829 uint32_t vlan_present:1;
15832 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15833 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15834 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15835 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15837 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15838 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15839 "l2_decap-with-vlan");
15841 static void cmd_set_l2_decap_parsed(void *parsed_result,
15842 __attribute__((unused)) struct cmdline *cl,
15843 __attribute__((unused)) void *data)
15845 struct cmd_set_l2_decap_result *res = parsed_result;
15847 if (strcmp(res->l2_decap, "l2_decap") == 0)
15848 l2_decap_conf.select_vlan = 0;
15849 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15850 l2_decap_conf.select_vlan = 1;
15853 cmdline_parse_inst_t cmd_set_l2_decap = {
15854 .f = cmd_set_l2_decap_parsed,
15856 .help_str = "set l2_decap",
15858 (void *)&cmd_set_l2_decap_set,
15859 (void *)&cmd_set_l2_decap_l2_decap,
15864 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15865 .f = cmd_set_l2_decap_parsed,
15867 .help_str = "set l2_decap-with-vlan",
15869 (void *)&cmd_set_l2_decap_set,
15870 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15875 /** Set MPLSoGRE encapsulation details */
15876 struct cmd_set_mplsogre_encap_result {
15877 cmdline_fixed_string_t set;
15878 cmdline_fixed_string_t mplsogre;
15879 cmdline_fixed_string_t pos_token;
15880 cmdline_fixed_string_t ip_version;
15881 uint32_t vlan_present:1;
15883 cmdline_ipaddr_t ip_src;
15884 cmdline_ipaddr_t ip_dst;
15886 struct rte_ether_addr eth_src;
15887 struct rte_ether_addr eth_dst;
15890 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15891 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15893 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15894 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15896 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15897 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15898 mplsogre, "mplsogre_encap-with-vlan");
15899 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15900 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15901 pos_token, "ip-version");
15902 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15903 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15904 ip_version, "ipv4#ipv6");
15905 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15906 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15907 pos_token, "label");
15908 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15909 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15911 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15912 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15913 pos_token, "ip-src");
15914 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15915 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15916 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15917 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15918 pos_token, "ip-dst");
15919 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15920 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15921 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15922 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15923 pos_token, "vlan-tci");
15924 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15925 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15927 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15928 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15929 pos_token, "eth-src");
15930 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15931 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15933 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15934 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15935 pos_token, "eth-dst");
15936 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15937 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15940 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15941 __attribute__((unused)) struct cmdline *cl,
15942 __attribute__((unused)) void *data)
15944 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15946 uint32_t mplsogre_label;
15949 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15952 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15953 mplsogre_encap_conf.select_vlan = 0;
15954 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15955 mplsogre_encap_conf.select_vlan = 1;
15956 if (strcmp(res->ip_version, "ipv4") == 0)
15957 mplsogre_encap_conf.select_ipv4 = 1;
15958 else if (strcmp(res->ip_version, "ipv6") == 0)
15959 mplsogre_encap_conf.select_ipv4 = 0;
15962 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15963 if (mplsogre_encap_conf.select_ipv4) {
15964 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15965 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15967 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15968 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15970 if (mplsogre_encap_conf.select_vlan)
15971 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15972 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15973 RTE_ETHER_ADDR_LEN);
15974 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15975 RTE_ETHER_ADDR_LEN);
15978 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15979 .f = cmd_set_mplsogre_encap_parsed,
15981 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15982 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15983 " eth-dst <eth-dst>",
15985 (void *)&cmd_set_mplsogre_encap_set,
15986 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15987 (void *)&cmd_set_mplsogre_encap_ip_version,
15988 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15989 (void *)&cmd_set_mplsogre_encap_label,
15990 (void *)&cmd_set_mplsogre_encap_label_value,
15991 (void *)&cmd_set_mplsogre_encap_ip_src,
15992 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15993 (void *)&cmd_set_mplsogre_encap_ip_dst,
15994 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15995 (void *)&cmd_set_mplsogre_encap_eth_src,
15996 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15997 (void *)&cmd_set_mplsogre_encap_eth_dst,
15998 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16003 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16004 .f = cmd_set_mplsogre_encap_parsed,
16006 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16007 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16008 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16010 (void *)&cmd_set_mplsogre_encap_set,
16011 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16012 (void *)&cmd_set_mplsogre_encap_ip_version,
16013 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16014 (void *)&cmd_set_mplsogre_encap_label,
16015 (void *)&cmd_set_mplsogre_encap_label_value,
16016 (void *)&cmd_set_mplsogre_encap_ip_src,
16017 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16018 (void *)&cmd_set_mplsogre_encap_ip_dst,
16019 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16020 (void *)&cmd_set_mplsogre_encap_vlan,
16021 (void *)&cmd_set_mplsogre_encap_vlan_value,
16022 (void *)&cmd_set_mplsogre_encap_eth_src,
16023 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16024 (void *)&cmd_set_mplsogre_encap_eth_dst,
16025 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16030 /** Set MPLSoGRE decapsulation details */
16031 struct cmd_set_mplsogre_decap_result {
16032 cmdline_fixed_string_t set;
16033 cmdline_fixed_string_t mplsogre;
16034 cmdline_fixed_string_t pos_token;
16035 cmdline_fixed_string_t ip_version;
16036 uint32_t vlan_present:1;
16039 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16040 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16042 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16043 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16045 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16046 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16047 mplsogre, "mplsogre_decap-with-vlan");
16048 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16049 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16050 pos_token, "ip-version");
16051 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16052 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16053 ip_version, "ipv4#ipv6");
16055 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16056 __attribute__((unused)) struct cmdline *cl,
16057 __attribute__((unused)) void *data)
16059 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16061 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16062 mplsogre_decap_conf.select_vlan = 0;
16063 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16064 mplsogre_decap_conf.select_vlan = 1;
16065 if (strcmp(res->ip_version, "ipv4") == 0)
16066 mplsogre_decap_conf.select_ipv4 = 1;
16067 else if (strcmp(res->ip_version, "ipv6") == 0)
16068 mplsogre_decap_conf.select_ipv4 = 0;
16071 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16072 .f = cmd_set_mplsogre_decap_parsed,
16074 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16076 (void *)&cmd_set_mplsogre_decap_set,
16077 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16078 (void *)&cmd_set_mplsogre_decap_ip_version,
16079 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16084 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16085 .f = cmd_set_mplsogre_decap_parsed,
16087 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16089 (void *)&cmd_set_mplsogre_decap_set,
16090 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16091 (void *)&cmd_set_mplsogre_decap_ip_version,
16092 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16097 /** Set MPLSoUDP encapsulation details */
16098 struct cmd_set_mplsoudp_encap_result {
16099 cmdline_fixed_string_t set;
16100 cmdline_fixed_string_t mplsoudp;
16101 cmdline_fixed_string_t pos_token;
16102 cmdline_fixed_string_t ip_version;
16103 uint32_t vlan_present:1;
16107 cmdline_ipaddr_t ip_src;
16108 cmdline_ipaddr_t ip_dst;
16110 struct rte_ether_addr eth_src;
16111 struct rte_ether_addr eth_dst;
16114 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16115 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16117 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16118 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16120 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16121 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16122 mplsoudp, "mplsoudp_encap-with-vlan");
16123 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16124 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16125 pos_token, "ip-version");
16126 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16127 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16128 ip_version, "ipv4#ipv6");
16129 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16130 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16131 pos_token, "label");
16132 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16133 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16135 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16136 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16137 pos_token, "udp-src");
16138 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16139 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16141 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16142 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16143 pos_token, "udp-dst");
16144 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16145 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16147 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16148 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16149 pos_token, "ip-src");
16150 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16151 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16152 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16153 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16154 pos_token, "ip-dst");
16155 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16156 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16157 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16158 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16159 pos_token, "vlan-tci");
16160 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16161 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16163 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16164 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16165 pos_token, "eth-src");
16166 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16167 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16169 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16170 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16171 pos_token, "eth-dst");
16172 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16173 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16176 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16177 __attribute__((unused)) struct cmdline *cl,
16178 __attribute__((unused)) void *data)
16180 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16182 uint32_t mplsoudp_label;
16185 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16188 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16189 mplsoudp_encap_conf.select_vlan = 0;
16190 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16191 mplsoudp_encap_conf.select_vlan = 1;
16192 if (strcmp(res->ip_version, "ipv4") == 0)
16193 mplsoudp_encap_conf.select_ipv4 = 1;
16194 else if (strcmp(res->ip_version, "ipv6") == 0)
16195 mplsoudp_encap_conf.select_ipv4 = 0;
16198 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16199 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16200 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16201 if (mplsoudp_encap_conf.select_ipv4) {
16202 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16203 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16205 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16206 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16208 if (mplsoudp_encap_conf.select_vlan)
16209 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16210 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16211 RTE_ETHER_ADDR_LEN);
16212 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16213 RTE_ETHER_ADDR_LEN);
16216 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16217 .f = cmd_set_mplsoudp_encap_parsed,
16219 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16220 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16221 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16223 (void *)&cmd_set_mplsoudp_encap_set,
16224 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16225 (void *)&cmd_set_mplsoudp_encap_ip_version,
16226 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16227 (void *)&cmd_set_mplsoudp_encap_label,
16228 (void *)&cmd_set_mplsoudp_encap_label_value,
16229 (void *)&cmd_set_mplsoudp_encap_udp_src,
16230 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16231 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16232 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16233 (void *)&cmd_set_mplsoudp_encap_ip_src,
16234 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16235 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16236 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16237 (void *)&cmd_set_mplsoudp_encap_eth_src,
16238 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16239 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16240 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16245 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16246 .f = cmd_set_mplsoudp_encap_parsed,
16248 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16249 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16250 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16251 " eth-src <eth-src> eth-dst <eth-dst>",
16253 (void *)&cmd_set_mplsoudp_encap_set,
16254 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16255 (void *)&cmd_set_mplsoudp_encap_ip_version,
16256 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16257 (void *)&cmd_set_mplsoudp_encap_label,
16258 (void *)&cmd_set_mplsoudp_encap_label_value,
16259 (void *)&cmd_set_mplsoudp_encap_udp_src,
16260 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16261 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16262 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16263 (void *)&cmd_set_mplsoudp_encap_ip_src,
16264 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16265 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16266 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16267 (void *)&cmd_set_mplsoudp_encap_vlan,
16268 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16269 (void *)&cmd_set_mplsoudp_encap_eth_src,
16270 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16271 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16272 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16277 /** Set MPLSoUDP decapsulation details */
16278 struct cmd_set_mplsoudp_decap_result {
16279 cmdline_fixed_string_t set;
16280 cmdline_fixed_string_t mplsoudp;
16281 cmdline_fixed_string_t pos_token;
16282 cmdline_fixed_string_t ip_version;
16283 uint32_t vlan_present:1;
16286 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16287 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16289 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16290 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16292 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16293 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16294 mplsoudp, "mplsoudp_decap-with-vlan");
16295 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16296 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16297 pos_token, "ip-version");
16298 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16299 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16300 ip_version, "ipv4#ipv6");
16302 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16303 __attribute__((unused)) struct cmdline *cl,
16304 __attribute__((unused)) void *data)
16306 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16308 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16309 mplsoudp_decap_conf.select_vlan = 0;
16310 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16311 mplsoudp_decap_conf.select_vlan = 1;
16312 if (strcmp(res->ip_version, "ipv4") == 0)
16313 mplsoudp_decap_conf.select_ipv4 = 1;
16314 else if (strcmp(res->ip_version, "ipv6") == 0)
16315 mplsoudp_decap_conf.select_ipv4 = 0;
16318 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16319 .f = cmd_set_mplsoudp_decap_parsed,
16321 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16323 (void *)&cmd_set_mplsoudp_decap_set,
16324 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16325 (void *)&cmd_set_mplsoudp_decap_ip_version,
16326 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16331 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16332 .f = cmd_set_mplsoudp_decap_parsed,
16334 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16336 (void *)&cmd_set_mplsoudp_decap_set,
16337 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16338 (void *)&cmd_set_mplsoudp_decap_ip_version,
16339 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16344 /* Strict link priority scheduling mode setting */
16346 cmd_strict_link_prio_parsed(
16347 void *parsed_result,
16348 __attribute__((unused)) struct cmdline *cl,
16349 __attribute__((unused)) void *data)
16351 struct cmd_vf_tc_bw_result *res = parsed_result;
16352 int ret = -ENOTSUP;
16354 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16357 #ifdef RTE_LIBRTE_I40E_PMD
16358 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16365 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16368 printf("invalid port_id %d\n", res->port_id);
16371 printf("function not implemented\n");
16374 printf("programming error: (%s)\n", strerror(-ret));
16378 cmdline_parse_inst_t cmd_strict_link_prio = {
16379 .f = cmd_strict_link_prio_parsed,
16381 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16383 (void *)&cmd_vf_tc_bw_set,
16384 (void *)&cmd_vf_tc_bw_tx,
16385 (void *)&cmd_vf_tc_bw_strict_link_prio,
16386 (void *)&cmd_vf_tc_bw_port_id,
16387 (void *)&cmd_vf_tc_bw_tc_map,
16392 /* Load dynamic device personalization*/
16393 struct cmd_ddp_add_result {
16394 cmdline_fixed_string_t ddp;
16395 cmdline_fixed_string_t add;
16400 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16401 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16402 cmdline_parse_token_string_t cmd_ddp_add_add =
16403 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16404 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16405 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16406 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16407 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16410 cmd_ddp_add_parsed(
16411 void *parsed_result,
16412 __attribute__((unused)) struct cmdline *cl,
16413 __attribute__((unused)) void *data)
16415 struct cmd_ddp_add_result *res = parsed_result;
16421 int ret = -ENOTSUP;
16423 if (!all_ports_stopped()) {
16424 printf("Please stop all ports first\n");
16428 filepath = strdup(res->filepath);
16429 if (filepath == NULL) {
16430 printf("Failed to allocate memory\n");
16433 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16435 buff = open_file(file_fld[0], &size);
16437 free((void *)filepath);
16441 #ifdef RTE_LIBRTE_I40E_PMD
16442 if (ret == -ENOTSUP)
16443 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16445 RTE_PMD_I40E_PKG_OP_WR_ADD);
16448 if (ret == -EEXIST)
16449 printf("Profile has already existed.\n");
16451 printf("Failed to load profile.\n");
16452 else if (file_num == 2)
16453 save_file(file_fld[1], buff, size);
16456 free((void *)filepath);
16459 cmdline_parse_inst_t cmd_ddp_add = {
16460 .f = cmd_ddp_add_parsed,
16462 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16464 (void *)&cmd_ddp_add_ddp,
16465 (void *)&cmd_ddp_add_add,
16466 (void *)&cmd_ddp_add_port_id,
16467 (void *)&cmd_ddp_add_filepath,
16472 /* Delete dynamic device personalization*/
16473 struct cmd_ddp_del_result {
16474 cmdline_fixed_string_t ddp;
16475 cmdline_fixed_string_t del;
16480 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16481 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16482 cmdline_parse_token_string_t cmd_ddp_del_del =
16483 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16484 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16485 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16486 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16487 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16490 cmd_ddp_del_parsed(
16491 void *parsed_result,
16492 __attribute__((unused)) struct cmdline *cl,
16493 __attribute__((unused)) void *data)
16495 struct cmd_ddp_del_result *res = parsed_result;
16498 int ret = -ENOTSUP;
16500 if (!all_ports_stopped()) {
16501 printf("Please stop all ports first\n");
16505 buff = open_file(res->filepath, &size);
16509 #ifdef RTE_LIBRTE_I40E_PMD
16510 if (ret == -ENOTSUP)
16511 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16513 RTE_PMD_I40E_PKG_OP_WR_DEL);
16516 if (ret == -EACCES)
16517 printf("Profile does not exist.\n");
16519 printf("Failed to delete profile.\n");
16524 cmdline_parse_inst_t cmd_ddp_del = {
16525 .f = cmd_ddp_del_parsed,
16527 .help_str = "ddp del <port_id> <backup_profile_path>",
16529 (void *)&cmd_ddp_del_ddp,
16530 (void *)&cmd_ddp_del_del,
16531 (void *)&cmd_ddp_del_port_id,
16532 (void *)&cmd_ddp_del_filepath,
16537 /* Get dynamic device personalization profile info */
16538 struct cmd_ddp_info_result {
16539 cmdline_fixed_string_t ddp;
16540 cmdline_fixed_string_t get;
16541 cmdline_fixed_string_t info;
16545 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16546 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16547 cmdline_parse_token_string_t cmd_ddp_info_get =
16548 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16549 cmdline_parse_token_string_t cmd_ddp_info_info =
16550 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16551 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16552 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16555 cmd_ddp_info_parsed(
16556 void *parsed_result,
16557 __attribute__((unused)) struct cmdline *cl,
16558 __attribute__((unused)) void *data)
16560 struct cmd_ddp_info_result *res = parsed_result;
16563 int ret = -ENOTSUP;
16564 #ifdef RTE_LIBRTE_I40E_PMD
16567 uint32_t buff_size = 0;
16568 struct rte_pmd_i40e_profile_info info;
16569 uint32_t dev_num = 0;
16570 struct rte_pmd_i40e_ddp_device_id *devs;
16571 uint32_t proto_num = 0;
16572 struct rte_pmd_i40e_proto_info *proto = NULL;
16573 uint32_t pctype_num = 0;
16574 struct rte_pmd_i40e_ptype_info *pctype;
16575 uint32_t ptype_num = 0;
16576 struct rte_pmd_i40e_ptype_info *ptype;
16581 pkg = open_file(res->filepath, &pkg_size);
16585 #ifdef RTE_LIBRTE_I40E_PMD
16586 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16587 (uint8_t *)&info, sizeof(info),
16588 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16590 printf("Global Track id: 0x%x\n", info.track_id);
16591 printf("Global Version: %d.%d.%d.%d\n",
16592 info.version.major,
16593 info.version.minor,
16594 info.version.update,
16595 info.version.draft);
16596 printf("Global Package name: %s\n\n", info.name);
16599 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16600 (uint8_t *)&info, sizeof(info),
16601 RTE_PMD_I40E_PKG_INFO_HEADER);
16603 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16604 printf("i40e Profile Version: %d.%d.%d.%d\n",
16605 info.version.major,
16606 info.version.minor,
16607 info.version.update,
16608 info.version.draft);
16609 printf("i40e Profile name: %s\n\n", info.name);
16612 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16613 (uint8_t *)&buff_size, sizeof(buff_size),
16614 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16615 if (!ret && buff_size) {
16616 buff = (uint8_t *)malloc(buff_size);
16618 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16620 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16622 printf("Package Notes:\n%s\n\n", buff);
16627 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16628 (uint8_t *)&dev_num, sizeof(dev_num),
16629 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16630 if (!ret && dev_num) {
16631 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16632 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16634 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16635 (uint8_t *)devs, buff_size,
16636 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16638 printf("List of supported devices:\n");
16639 for (i = 0; i < dev_num; i++) {
16640 printf(" %04X:%04X %04X:%04X\n",
16641 devs[i].vendor_dev_id >> 16,
16642 devs[i].vendor_dev_id & 0xFFFF,
16643 devs[i].sub_vendor_dev_id >> 16,
16644 devs[i].sub_vendor_dev_id & 0xFFFF);
16652 /* get information about protocols and packet types */
16653 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16654 (uint8_t *)&proto_num, sizeof(proto_num),
16655 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16656 if (ret || !proto_num)
16657 goto no_print_return;
16659 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16660 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16662 goto no_print_return;
16664 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16666 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16668 printf("List of used protocols:\n");
16669 for (i = 0; i < proto_num; i++)
16670 printf(" %2u: %s\n", proto[i].proto_id,
16674 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16675 (uint8_t *)&pctype_num, sizeof(pctype_num),
16676 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16677 if (ret || !pctype_num)
16678 goto no_print_pctypes;
16680 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16681 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16683 goto no_print_pctypes;
16685 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16687 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16690 goto no_print_pctypes;
16693 printf("List of defined packet classification types:\n");
16694 for (i = 0; i < pctype_num; i++) {
16695 printf(" %2u:", pctype[i].ptype_id);
16696 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16697 proto_id = pctype[i].protocols[j];
16698 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16699 for (n = 0; n < proto_num; n++) {
16700 if (proto[n].proto_id == proto_id) {
16701 printf(" %s", proto[n].name);
16714 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16716 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16717 if (ret || !ptype_num)
16718 goto no_print_return;
16720 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16721 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16723 goto no_print_return;
16725 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16727 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16730 goto no_print_return;
16732 printf("List of defined packet types:\n");
16733 for (i = 0; i < ptype_num; i++) {
16734 printf(" %2u:", ptype[i].ptype_id);
16735 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16736 proto_id = ptype[i].protocols[j];
16737 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16738 for (n = 0; n < proto_num; n++) {
16739 if (proto[n].proto_id == proto_id) {
16740 printf(" %s", proto[n].name);
16756 if (ret == -ENOTSUP)
16757 printf("Function not supported in PMD driver\n");
16761 cmdline_parse_inst_t cmd_ddp_get_info = {
16762 .f = cmd_ddp_info_parsed,
16764 .help_str = "ddp get info <profile_path>",
16766 (void *)&cmd_ddp_info_ddp,
16767 (void *)&cmd_ddp_info_get,
16768 (void *)&cmd_ddp_info_info,
16769 (void *)&cmd_ddp_info_filepath,
16774 /* Get dynamic device personalization profile info list*/
16775 #define PROFILE_INFO_SIZE 48
16776 #define MAX_PROFILE_NUM 16
16778 struct cmd_ddp_get_list_result {
16779 cmdline_fixed_string_t ddp;
16780 cmdline_fixed_string_t get;
16781 cmdline_fixed_string_t list;
16785 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16786 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16787 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16788 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16789 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16790 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16791 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16792 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16795 cmd_ddp_get_list_parsed(
16796 __attribute__((unused)) void *parsed_result,
16797 __attribute__((unused)) struct cmdline *cl,
16798 __attribute__((unused)) void *data)
16800 #ifdef RTE_LIBRTE_I40E_PMD
16801 struct cmd_ddp_get_list_result *res = parsed_result;
16802 struct rte_pmd_i40e_profile_list *p_list;
16803 struct rte_pmd_i40e_profile_info *p_info;
16808 int ret = -ENOTSUP;
16810 #ifdef RTE_LIBRTE_I40E_PMD
16811 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16812 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16814 printf("%s: Failed to malloc buffer\n", __func__);
16816 if (ret == -ENOTSUP)
16817 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16818 (uint8_t *)p_list, size);
16821 p_num = p_list->p_count;
16822 printf("Profile number is: %d\n\n", p_num);
16824 for (i = 0; i < p_num; i++) {
16825 p_info = &p_list->p_info[i];
16826 printf("Profile %d:\n", i);
16827 printf("Track id: 0x%x\n", p_info->track_id);
16828 printf("Version: %d.%d.%d.%d\n",
16829 p_info->version.major,
16830 p_info->version.minor,
16831 p_info->version.update,
16832 p_info->version.draft);
16833 printf("Profile name: %s\n\n", p_info->name);
16841 printf("Failed to get ddp list\n");
16844 cmdline_parse_inst_t cmd_ddp_get_list = {
16845 .f = cmd_ddp_get_list_parsed,
16847 .help_str = "ddp get list <port_id>",
16849 (void *)&cmd_ddp_get_list_ddp,
16850 (void *)&cmd_ddp_get_list_get,
16851 (void *)&cmd_ddp_get_list_list,
16852 (void *)&cmd_ddp_get_list_port_id,
16857 /* Configure input set */
16858 struct cmd_cfg_input_set_result {
16859 cmdline_fixed_string_t port;
16860 cmdline_fixed_string_t cfg;
16862 cmdline_fixed_string_t pctype;
16864 cmdline_fixed_string_t inset_type;
16865 cmdline_fixed_string_t opt;
16866 cmdline_fixed_string_t field;
16871 cmd_cfg_input_set_parsed(
16872 __attribute__((unused)) void *parsed_result,
16873 __attribute__((unused)) struct cmdline *cl,
16874 __attribute__((unused)) void *data)
16876 #ifdef RTE_LIBRTE_I40E_PMD
16877 struct cmd_cfg_input_set_result *res = parsed_result;
16878 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16879 struct rte_pmd_i40e_inset inset;
16881 int ret = -ENOTSUP;
16883 if (!all_ports_stopped()) {
16884 printf("Please stop all ports first\n");
16888 #ifdef RTE_LIBRTE_I40E_PMD
16889 if (!strcmp(res->inset_type, "hash_inset"))
16890 inset_type = INSET_HASH;
16891 else if (!strcmp(res->inset_type, "fdir_inset"))
16892 inset_type = INSET_FDIR;
16893 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16894 inset_type = INSET_FDIR_FLX;
16895 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16896 &inset, inset_type);
16898 printf("Failed to get input set.\n");
16902 if (!strcmp(res->opt, "get")) {
16903 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16906 printf("Field index %d is enabled.\n", res->field_idx);
16908 printf("Field index %d is disabled.\n", res->field_idx);
16910 } else if (!strcmp(res->opt, "set"))
16911 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16913 else if (!strcmp(res->opt, "clear"))
16914 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16917 printf("Failed to configure input set field.\n");
16921 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16922 &inset, inset_type);
16924 printf("Failed to set input set.\n");
16929 if (ret == -ENOTSUP)
16930 printf("Function not supported\n");
16933 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16934 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16936 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16937 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16939 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16940 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16942 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16943 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16945 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16946 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16948 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16949 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16951 "hash_inset#fdir_inset#fdir_flx_inset");
16952 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16953 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16954 opt, "get#set#clear");
16955 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16956 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16958 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16959 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16962 cmdline_parse_inst_t cmd_cfg_input_set = {
16963 .f = cmd_cfg_input_set_parsed,
16965 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16966 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16968 (void *)&cmd_cfg_input_set_port,
16969 (void *)&cmd_cfg_input_set_cfg,
16970 (void *)&cmd_cfg_input_set_port_id,
16971 (void *)&cmd_cfg_input_set_pctype,
16972 (void *)&cmd_cfg_input_set_pctype_id,
16973 (void *)&cmd_cfg_input_set_inset_type,
16974 (void *)&cmd_cfg_input_set_opt,
16975 (void *)&cmd_cfg_input_set_field,
16976 (void *)&cmd_cfg_input_set_field_idx,
16981 /* Clear input set */
16982 struct cmd_clear_input_set_result {
16983 cmdline_fixed_string_t port;
16984 cmdline_fixed_string_t cfg;
16986 cmdline_fixed_string_t pctype;
16988 cmdline_fixed_string_t inset_type;
16989 cmdline_fixed_string_t clear;
16990 cmdline_fixed_string_t all;
16994 cmd_clear_input_set_parsed(
16995 __attribute__((unused)) void *parsed_result,
16996 __attribute__((unused)) struct cmdline *cl,
16997 __attribute__((unused)) void *data)
16999 #ifdef RTE_LIBRTE_I40E_PMD
17000 struct cmd_clear_input_set_result *res = parsed_result;
17001 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17002 struct rte_pmd_i40e_inset inset;
17004 int ret = -ENOTSUP;
17006 if (!all_ports_stopped()) {
17007 printf("Please stop all ports first\n");
17011 #ifdef RTE_LIBRTE_I40E_PMD
17012 if (!strcmp(res->inset_type, "hash_inset"))
17013 inset_type = INSET_HASH;
17014 else if (!strcmp(res->inset_type, "fdir_inset"))
17015 inset_type = INSET_FDIR;
17016 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17017 inset_type = INSET_FDIR_FLX;
17019 memset(&inset, 0, sizeof(inset));
17021 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17022 &inset, inset_type);
17024 printf("Failed to clear input set.\n");
17030 if (ret == -ENOTSUP)
17031 printf("Function not supported\n");
17034 cmdline_parse_token_string_t cmd_clear_input_set_port =
17035 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17037 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17038 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17040 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17041 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17043 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17044 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17046 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17047 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17049 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17050 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17052 "hash_inset#fdir_inset#fdir_flx_inset");
17053 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17054 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17056 cmdline_parse_token_string_t cmd_clear_input_set_all =
17057 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17060 cmdline_parse_inst_t cmd_clear_input_set = {
17061 .f = cmd_clear_input_set_parsed,
17063 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17064 "fdir_inset|fdir_flx_inset clear all",
17066 (void *)&cmd_clear_input_set_port,
17067 (void *)&cmd_clear_input_set_cfg,
17068 (void *)&cmd_clear_input_set_port_id,
17069 (void *)&cmd_clear_input_set_pctype,
17070 (void *)&cmd_clear_input_set_pctype_id,
17071 (void *)&cmd_clear_input_set_inset_type,
17072 (void *)&cmd_clear_input_set_clear,
17073 (void *)&cmd_clear_input_set_all,
17078 /* show vf stats */
17080 /* Common result structure for show vf stats */
17081 struct cmd_show_vf_stats_result {
17082 cmdline_fixed_string_t show;
17083 cmdline_fixed_string_t vf;
17084 cmdline_fixed_string_t stats;
17089 /* Common CLI fields show vf stats*/
17090 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17091 TOKEN_STRING_INITIALIZER
17092 (struct cmd_show_vf_stats_result,
17094 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17095 TOKEN_STRING_INITIALIZER
17096 (struct cmd_show_vf_stats_result,
17098 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17099 TOKEN_STRING_INITIALIZER
17100 (struct cmd_show_vf_stats_result,
17102 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17103 TOKEN_NUM_INITIALIZER
17104 (struct cmd_show_vf_stats_result,
17106 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17107 TOKEN_NUM_INITIALIZER
17108 (struct cmd_show_vf_stats_result,
17112 cmd_show_vf_stats_parsed(
17113 void *parsed_result,
17114 __attribute__((unused)) struct cmdline *cl,
17115 __attribute__((unused)) void *data)
17117 struct cmd_show_vf_stats_result *res = parsed_result;
17118 struct rte_eth_stats stats;
17119 int ret = -ENOTSUP;
17120 static const char *nic_stats_border = "########################";
17122 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17125 memset(&stats, 0, sizeof(stats));
17127 #ifdef RTE_LIBRTE_I40E_PMD
17128 if (ret == -ENOTSUP)
17129 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17133 #ifdef RTE_LIBRTE_BNXT_PMD
17134 if (ret == -ENOTSUP)
17135 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17144 printf("invalid vf_id %d\n", res->vf_id);
17147 printf("invalid port_id %d\n", res->port_id);
17150 printf("function not implemented\n");
17153 printf("programming error: (%s)\n", strerror(-ret));
17156 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17157 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17159 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17161 stats.ipackets, stats.imissed, stats.ibytes);
17162 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17163 printf(" RX-nombuf: %-10"PRIu64"\n",
17165 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17167 stats.opackets, stats.oerrors, stats.obytes);
17169 printf(" %s############################%s\n",
17170 nic_stats_border, nic_stats_border);
17173 cmdline_parse_inst_t cmd_show_vf_stats = {
17174 .f = cmd_show_vf_stats_parsed,
17176 .help_str = "show vf stats <port_id> <vf_id>",
17178 (void *)&cmd_show_vf_stats_show,
17179 (void *)&cmd_show_vf_stats_vf,
17180 (void *)&cmd_show_vf_stats_stats,
17181 (void *)&cmd_show_vf_stats_port_id,
17182 (void *)&cmd_show_vf_stats_vf_id,
17187 /* clear vf stats */
17189 /* Common result structure for clear vf stats */
17190 struct cmd_clear_vf_stats_result {
17191 cmdline_fixed_string_t clear;
17192 cmdline_fixed_string_t vf;
17193 cmdline_fixed_string_t stats;
17198 /* Common CLI fields clear vf stats*/
17199 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17200 TOKEN_STRING_INITIALIZER
17201 (struct cmd_clear_vf_stats_result,
17203 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17204 TOKEN_STRING_INITIALIZER
17205 (struct cmd_clear_vf_stats_result,
17207 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17208 TOKEN_STRING_INITIALIZER
17209 (struct cmd_clear_vf_stats_result,
17211 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17212 TOKEN_NUM_INITIALIZER
17213 (struct cmd_clear_vf_stats_result,
17215 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17216 TOKEN_NUM_INITIALIZER
17217 (struct cmd_clear_vf_stats_result,
17221 cmd_clear_vf_stats_parsed(
17222 void *parsed_result,
17223 __attribute__((unused)) struct cmdline *cl,
17224 __attribute__((unused)) void *data)
17226 struct cmd_clear_vf_stats_result *res = parsed_result;
17227 int ret = -ENOTSUP;
17229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17232 #ifdef RTE_LIBRTE_I40E_PMD
17233 if (ret == -ENOTSUP)
17234 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17237 #ifdef RTE_LIBRTE_BNXT_PMD
17238 if (ret == -ENOTSUP)
17239 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17247 printf("invalid vf_id %d\n", res->vf_id);
17250 printf("invalid port_id %d\n", res->port_id);
17253 printf("function not implemented\n");
17256 printf("programming error: (%s)\n", strerror(-ret));
17260 cmdline_parse_inst_t cmd_clear_vf_stats = {
17261 .f = cmd_clear_vf_stats_parsed,
17263 .help_str = "clear vf stats <port_id> <vf_id>",
17265 (void *)&cmd_clear_vf_stats_clear,
17266 (void *)&cmd_clear_vf_stats_vf,
17267 (void *)&cmd_clear_vf_stats_stats,
17268 (void *)&cmd_clear_vf_stats_port_id,
17269 (void *)&cmd_clear_vf_stats_vf_id,
17274 /* port config pctype mapping reset */
17276 /* Common result structure for port config pctype mapping reset */
17277 struct cmd_pctype_mapping_reset_result {
17278 cmdline_fixed_string_t port;
17279 cmdline_fixed_string_t config;
17281 cmdline_fixed_string_t pctype;
17282 cmdline_fixed_string_t mapping;
17283 cmdline_fixed_string_t reset;
17286 /* Common CLI fields for port config pctype mapping reset*/
17287 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17288 TOKEN_STRING_INITIALIZER
17289 (struct cmd_pctype_mapping_reset_result,
17291 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17292 TOKEN_STRING_INITIALIZER
17293 (struct cmd_pctype_mapping_reset_result,
17295 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17296 TOKEN_NUM_INITIALIZER
17297 (struct cmd_pctype_mapping_reset_result,
17299 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17300 TOKEN_STRING_INITIALIZER
17301 (struct cmd_pctype_mapping_reset_result,
17303 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17304 TOKEN_STRING_INITIALIZER
17305 (struct cmd_pctype_mapping_reset_result,
17306 mapping, "mapping");
17307 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17308 TOKEN_STRING_INITIALIZER
17309 (struct cmd_pctype_mapping_reset_result,
17313 cmd_pctype_mapping_reset_parsed(
17314 void *parsed_result,
17315 __attribute__((unused)) struct cmdline *cl,
17316 __attribute__((unused)) void *data)
17318 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17319 int ret = -ENOTSUP;
17321 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17324 #ifdef RTE_LIBRTE_I40E_PMD
17325 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17332 printf("invalid port_id %d\n", res->port_id);
17335 printf("function not implemented\n");
17338 printf("programming error: (%s)\n", strerror(-ret));
17342 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17343 .f = cmd_pctype_mapping_reset_parsed,
17345 .help_str = "port config <port_id> pctype mapping reset",
17347 (void *)&cmd_pctype_mapping_reset_port,
17348 (void *)&cmd_pctype_mapping_reset_config,
17349 (void *)&cmd_pctype_mapping_reset_port_id,
17350 (void *)&cmd_pctype_mapping_reset_pctype,
17351 (void *)&cmd_pctype_mapping_reset_mapping,
17352 (void *)&cmd_pctype_mapping_reset_reset,
17357 /* show port pctype mapping */
17359 /* Common result structure for show port pctype mapping */
17360 struct cmd_pctype_mapping_get_result {
17361 cmdline_fixed_string_t show;
17362 cmdline_fixed_string_t port;
17364 cmdline_fixed_string_t pctype;
17365 cmdline_fixed_string_t mapping;
17368 /* Common CLI fields for pctype mapping get */
17369 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17370 TOKEN_STRING_INITIALIZER
17371 (struct cmd_pctype_mapping_get_result,
17373 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17374 TOKEN_STRING_INITIALIZER
17375 (struct cmd_pctype_mapping_get_result,
17377 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17378 TOKEN_NUM_INITIALIZER
17379 (struct cmd_pctype_mapping_get_result,
17381 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17382 TOKEN_STRING_INITIALIZER
17383 (struct cmd_pctype_mapping_get_result,
17385 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17386 TOKEN_STRING_INITIALIZER
17387 (struct cmd_pctype_mapping_get_result,
17388 mapping, "mapping");
17391 cmd_pctype_mapping_get_parsed(
17392 void *parsed_result,
17393 __attribute__((unused)) struct cmdline *cl,
17394 __attribute__((unused)) void *data)
17396 struct cmd_pctype_mapping_get_result *res = parsed_result;
17397 int ret = -ENOTSUP;
17398 #ifdef RTE_LIBRTE_I40E_PMD
17399 struct rte_pmd_i40e_flow_type_mapping
17400 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17401 int i, j, first_pctype;
17404 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17407 #ifdef RTE_LIBRTE_I40E_PMD
17408 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17415 printf("invalid port_id %d\n", res->port_id);
17418 printf("function not implemented\n");
17421 printf("programming error: (%s)\n", strerror(-ret));
17425 #ifdef RTE_LIBRTE_I40E_PMD
17426 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17427 if (mapping[i].pctype != 0ULL) {
17430 printf("pctype: ");
17431 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17432 if (mapping[i].pctype & (1ULL << j)) {
17433 printf(first_pctype ?
17434 "%02d" : ",%02d", j);
17438 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17444 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17445 .f = cmd_pctype_mapping_get_parsed,
17447 .help_str = "show port <port_id> pctype mapping",
17449 (void *)&cmd_pctype_mapping_get_show,
17450 (void *)&cmd_pctype_mapping_get_port,
17451 (void *)&cmd_pctype_mapping_get_port_id,
17452 (void *)&cmd_pctype_mapping_get_pctype,
17453 (void *)&cmd_pctype_mapping_get_mapping,
17458 /* port config pctype mapping update */
17460 /* Common result structure for port config pctype mapping update */
17461 struct cmd_pctype_mapping_update_result {
17462 cmdline_fixed_string_t port;
17463 cmdline_fixed_string_t config;
17465 cmdline_fixed_string_t pctype;
17466 cmdline_fixed_string_t mapping;
17467 cmdline_fixed_string_t update;
17468 cmdline_fixed_string_t pctype_list;
17469 uint16_t flow_type;
17472 /* Common CLI fields for pctype mapping update*/
17473 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17474 TOKEN_STRING_INITIALIZER
17475 (struct cmd_pctype_mapping_update_result,
17477 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17478 TOKEN_STRING_INITIALIZER
17479 (struct cmd_pctype_mapping_update_result,
17481 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17482 TOKEN_NUM_INITIALIZER
17483 (struct cmd_pctype_mapping_update_result,
17485 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17486 TOKEN_STRING_INITIALIZER
17487 (struct cmd_pctype_mapping_update_result,
17489 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17490 TOKEN_STRING_INITIALIZER
17491 (struct cmd_pctype_mapping_update_result,
17492 mapping, "mapping");
17493 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17494 TOKEN_STRING_INITIALIZER
17495 (struct cmd_pctype_mapping_update_result,
17497 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17498 TOKEN_STRING_INITIALIZER
17499 (struct cmd_pctype_mapping_update_result,
17500 pctype_list, NULL);
17501 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17502 TOKEN_NUM_INITIALIZER
17503 (struct cmd_pctype_mapping_update_result,
17504 flow_type, UINT16);
17507 cmd_pctype_mapping_update_parsed(
17508 void *parsed_result,
17509 __attribute__((unused)) struct cmdline *cl,
17510 __attribute__((unused)) void *data)
17512 struct cmd_pctype_mapping_update_result *res = parsed_result;
17513 int ret = -ENOTSUP;
17514 #ifdef RTE_LIBRTE_I40E_PMD
17515 struct rte_pmd_i40e_flow_type_mapping mapping;
17517 unsigned int nb_item;
17518 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17521 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17524 #ifdef RTE_LIBRTE_I40E_PMD
17525 nb_item = parse_item_list(res->pctype_list, "pctypes",
17526 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17527 mapping.flow_type = res->flow_type;
17528 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17529 mapping.pctype |= (1ULL << pctype_list[i]);
17530 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17540 printf("invalid pctype or flow type\n");
17543 printf("invalid port_id %d\n", res->port_id);
17546 printf("function not implemented\n");
17549 printf("programming error: (%s)\n", strerror(-ret));
17553 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17554 .f = cmd_pctype_mapping_update_parsed,
17556 .help_str = "port config <port_id> pctype mapping update"
17557 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17559 (void *)&cmd_pctype_mapping_update_port,
17560 (void *)&cmd_pctype_mapping_update_config,
17561 (void *)&cmd_pctype_mapping_update_port_id,
17562 (void *)&cmd_pctype_mapping_update_pctype,
17563 (void *)&cmd_pctype_mapping_update_mapping,
17564 (void *)&cmd_pctype_mapping_update_update,
17565 (void *)&cmd_pctype_mapping_update_pc_type,
17566 (void *)&cmd_pctype_mapping_update_flow_type,
17571 /* ptype mapping get */
17573 /* Common result structure for ptype mapping get */
17574 struct cmd_ptype_mapping_get_result {
17575 cmdline_fixed_string_t ptype;
17576 cmdline_fixed_string_t mapping;
17577 cmdline_fixed_string_t get;
17579 uint8_t valid_only;
17582 /* Common CLI fields for ptype mapping get */
17583 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17584 TOKEN_STRING_INITIALIZER
17585 (struct cmd_ptype_mapping_get_result,
17587 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17588 TOKEN_STRING_INITIALIZER
17589 (struct cmd_ptype_mapping_get_result,
17590 mapping, "mapping");
17591 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17592 TOKEN_STRING_INITIALIZER
17593 (struct cmd_ptype_mapping_get_result,
17595 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17596 TOKEN_NUM_INITIALIZER
17597 (struct cmd_ptype_mapping_get_result,
17599 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17600 TOKEN_NUM_INITIALIZER
17601 (struct cmd_ptype_mapping_get_result,
17602 valid_only, UINT8);
17605 cmd_ptype_mapping_get_parsed(
17606 void *parsed_result,
17607 __attribute__((unused)) struct cmdline *cl,
17608 __attribute__((unused)) void *data)
17610 struct cmd_ptype_mapping_get_result *res = parsed_result;
17611 int ret = -ENOTSUP;
17612 #ifdef RTE_LIBRTE_I40E_PMD
17613 int max_ptype_num = 256;
17614 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17619 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17622 #ifdef RTE_LIBRTE_I40E_PMD
17623 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17634 printf("invalid port_id %d\n", res->port_id);
17637 printf("function not implemented\n");
17640 printf("programming error: (%s)\n", strerror(-ret));
17643 #ifdef RTE_LIBRTE_I40E_PMD
17645 for (i = 0; i < count; i++)
17646 printf("%3d\t0x%08x\n",
17647 mapping[i].hw_ptype, mapping[i].sw_ptype);
17652 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17653 .f = cmd_ptype_mapping_get_parsed,
17655 .help_str = "ptype mapping get <port_id> <valid_only>",
17657 (void *)&cmd_ptype_mapping_get_ptype,
17658 (void *)&cmd_ptype_mapping_get_mapping,
17659 (void *)&cmd_ptype_mapping_get_get,
17660 (void *)&cmd_ptype_mapping_get_port_id,
17661 (void *)&cmd_ptype_mapping_get_valid_only,
17666 /* ptype mapping replace */
17668 /* Common result structure for ptype mapping replace */
17669 struct cmd_ptype_mapping_replace_result {
17670 cmdline_fixed_string_t ptype;
17671 cmdline_fixed_string_t mapping;
17672 cmdline_fixed_string_t replace;
17679 /* Common CLI fields for ptype mapping replace */
17680 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17681 TOKEN_STRING_INITIALIZER
17682 (struct cmd_ptype_mapping_replace_result,
17684 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17685 TOKEN_STRING_INITIALIZER
17686 (struct cmd_ptype_mapping_replace_result,
17687 mapping, "mapping");
17688 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17689 TOKEN_STRING_INITIALIZER
17690 (struct cmd_ptype_mapping_replace_result,
17691 replace, "replace");
17692 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17693 TOKEN_NUM_INITIALIZER
17694 (struct cmd_ptype_mapping_replace_result,
17696 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17697 TOKEN_NUM_INITIALIZER
17698 (struct cmd_ptype_mapping_replace_result,
17700 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17701 TOKEN_NUM_INITIALIZER
17702 (struct cmd_ptype_mapping_replace_result,
17704 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17705 TOKEN_NUM_INITIALIZER
17706 (struct cmd_ptype_mapping_replace_result,
17710 cmd_ptype_mapping_replace_parsed(
17711 void *parsed_result,
17712 __attribute__((unused)) struct cmdline *cl,
17713 __attribute__((unused)) void *data)
17715 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17716 int ret = -ENOTSUP;
17718 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17721 #ifdef RTE_LIBRTE_I40E_PMD
17722 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17732 printf("invalid ptype 0x%8x or 0x%8x\n",
17733 res->target, res->pkt_type);
17736 printf("invalid port_id %d\n", res->port_id);
17739 printf("function not implemented\n");
17742 printf("programming error: (%s)\n", strerror(-ret));
17746 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17747 .f = cmd_ptype_mapping_replace_parsed,
17750 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17752 (void *)&cmd_ptype_mapping_replace_ptype,
17753 (void *)&cmd_ptype_mapping_replace_mapping,
17754 (void *)&cmd_ptype_mapping_replace_replace,
17755 (void *)&cmd_ptype_mapping_replace_port_id,
17756 (void *)&cmd_ptype_mapping_replace_target,
17757 (void *)&cmd_ptype_mapping_replace_mask,
17758 (void *)&cmd_ptype_mapping_replace_pkt_type,
17763 /* ptype mapping reset */
17765 /* Common result structure for ptype mapping reset */
17766 struct cmd_ptype_mapping_reset_result {
17767 cmdline_fixed_string_t ptype;
17768 cmdline_fixed_string_t mapping;
17769 cmdline_fixed_string_t reset;
17773 /* Common CLI fields for ptype mapping reset*/
17774 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17775 TOKEN_STRING_INITIALIZER
17776 (struct cmd_ptype_mapping_reset_result,
17778 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17779 TOKEN_STRING_INITIALIZER
17780 (struct cmd_ptype_mapping_reset_result,
17781 mapping, "mapping");
17782 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17783 TOKEN_STRING_INITIALIZER
17784 (struct cmd_ptype_mapping_reset_result,
17786 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17787 TOKEN_NUM_INITIALIZER
17788 (struct cmd_ptype_mapping_reset_result,
17792 cmd_ptype_mapping_reset_parsed(
17793 void *parsed_result,
17794 __attribute__((unused)) struct cmdline *cl,
17795 __attribute__((unused)) void *data)
17797 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17798 int ret = -ENOTSUP;
17800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17803 #ifdef RTE_LIBRTE_I40E_PMD
17804 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17811 printf("invalid port_id %d\n", res->port_id);
17814 printf("function not implemented\n");
17817 printf("programming error: (%s)\n", strerror(-ret));
17821 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17822 .f = cmd_ptype_mapping_reset_parsed,
17824 .help_str = "ptype mapping reset <port_id>",
17826 (void *)&cmd_ptype_mapping_reset_ptype,
17827 (void *)&cmd_ptype_mapping_reset_mapping,
17828 (void *)&cmd_ptype_mapping_reset_reset,
17829 (void *)&cmd_ptype_mapping_reset_port_id,
17834 /* ptype mapping update */
17836 /* Common result structure for ptype mapping update */
17837 struct cmd_ptype_mapping_update_result {
17838 cmdline_fixed_string_t ptype;
17839 cmdline_fixed_string_t mapping;
17840 cmdline_fixed_string_t reset;
17846 /* Common CLI fields for ptype mapping update*/
17847 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17848 TOKEN_STRING_INITIALIZER
17849 (struct cmd_ptype_mapping_update_result,
17851 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17852 TOKEN_STRING_INITIALIZER
17853 (struct cmd_ptype_mapping_update_result,
17854 mapping, "mapping");
17855 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17856 TOKEN_STRING_INITIALIZER
17857 (struct cmd_ptype_mapping_update_result,
17859 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17860 TOKEN_NUM_INITIALIZER
17861 (struct cmd_ptype_mapping_update_result,
17863 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17864 TOKEN_NUM_INITIALIZER
17865 (struct cmd_ptype_mapping_update_result,
17867 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17868 TOKEN_NUM_INITIALIZER
17869 (struct cmd_ptype_mapping_update_result,
17873 cmd_ptype_mapping_update_parsed(
17874 void *parsed_result,
17875 __attribute__((unused)) struct cmdline *cl,
17876 __attribute__((unused)) void *data)
17878 struct cmd_ptype_mapping_update_result *res = parsed_result;
17879 int ret = -ENOTSUP;
17880 #ifdef RTE_LIBRTE_I40E_PMD
17881 struct rte_pmd_i40e_ptype_mapping mapping;
17883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17886 #ifdef RTE_LIBRTE_I40E_PMD
17887 mapping.hw_ptype = res->hw_ptype;
17888 mapping.sw_ptype = res->sw_ptype;
17889 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17899 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17902 printf("invalid port_id %d\n", res->port_id);
17905 printf("function not implemented\n");
17908 printf("programming error: (%s)\n", strerror(-ret));
17912 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17913 .f = cmd_ptype_mapping_update_parsed,
17915 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17917 (void *)&cmd_ptype_mapping_update_ptype,
17918 (void *)&cmd_ptype_mapping_update_mapping,
17919 (void *)&cmd_ptype_mapping_update_update,
17920 (void *)&cmd_ptype_mapping_update_port_id,
17921 (void *)&cmd_ptype_mapping_update_hw_ptype,
17922 (void *)&cmd_ptype_mapping_update_sw_ptype,
17927 /* Common result structure for file commands */
17928 struct cmd_cmdfile_result {
17929 cmdline_fixed_string_t load;
17930 cmdline_fixed_string_t filename;
17933 /* Common CLI fields for file commands */
17934 cmdline_parse_token_string_t cmd_load_cmdfile =
17935 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17936 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17937 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17940 cmd_load_from_file_parsed(
17941 void *parsed_result,
17942 __attribute__((unused)) struct cmdline *cl,
17943 __attribute__((unused)) void *data)
17945 struct cmd_cmdfile_result *res = parsed_result;
17947 cmdline_read_from_file(res->filename);
17950 cmdline_parse_inst_t cmd_load_from_file = {
17951 .f = cmd_load_from_file_parsed,
17953 .help_str = "load <filename>",
17955 (void *)&cmd_load_cmdfile,
17956 (void *)&cmd_load_cmdfile_filename,
17961 /* Get Rx offloads capabilities */
17962 struct cmd_rx_offload_get_capa_result {
17963 cmdline_fixed_string_t show;
17964 cmdline_fixed_string_t port;
17966 cmdline_fixed_string_t rx_offload;
17967 cmdline_fixed_string_t capabilities;
17970 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17971 TOKEN_STRING_INITIALIZER
17972 (struct cmd_rx_offload_get_capa_result,
17974 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17975 TOKEN_STRING_INITIALIZER
17976 (struct cmd_rx_offload_get_capa_result,
17978 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17979 TOKEN_NUM_INITIALIZER
17980 (struct cmd_rx_offload_get_capa_result,
17982 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17983 TOKEN_STRING_INITIALIZER
17984 (struct cmd_rx_offload_get_capa_result,
17985 rx_offload, "rx_offload");
17986 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17987 TOKEN_STRING_INITIALIZER
17988 (struct cmd_rx_offload_get_capa_result,
17989 capabilities, "capabilities");
17992 print_rx_offloads(uint64_t offloads)
17994 uint64_t single_offload;
18002 begin = __builtin_ctzll(offloads);
18003 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18005 single_offload = 1ULL << begin;
18006 for (bit = begin; bit < end; bit++) {
18007 if (offloads & single_offload)
18009 rte_eth_dev_rx_offload_name(single_offload));
18010 single_offload <<= 1;
18015 cmd_rx_offload_get_capa_parsed(
18016 void *parsed_result,
18017 __attribute__((unused)) struct cmdline *cl,
18018 __attribute__((unused)) void *data)
18020 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18021 struct rte_eth_dev_info dev_info;
18022 portid_t port_id = res->port_id;
18023 uint64_t queue_offloads;
18024 uint64_t port_offloads;
18027 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18031 queue_offloads = dev_info.rx_queue_offload_capa;
18032 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18034 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18035 printf(" Per Queue :");
18036 print_rx_offloads(queue_offloads);
18039 printf(" Per Port :");
18040 print_rx_offloads(port_offloads);
18044 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18045 .f = cmd_rx_offload_get_capa_parsed,
18047 .help_str = "show port <port_id> rx_offload capabilities",
18049 (void *)&cmd_rx_offload_get_capa_show,
18050 (void *)&cmd_rx_offload_get_capa_port,
18051 (void *)&cmd_rx_offload_get_capa_port_id,
18052 (void *)&cmd_rx_offload_get_capa_rx_offload,
18053 (void *)&cmd_rx_offload_get_capa_capabilities,
18058 /* Get Rx offloads configuration */
18059 struct cmd_rx_offload_get_configuration_result {
18060 cmdline_fixed_string_t show;
18061 cmdline_fixed_string_t port;
18063 cmdline_fixed_string_t rx_offload;
18064 cmdline_fixed_string_t configuration;
18067 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18068 TOKEN_STRING_INITIALIZER
18069 (struct cmd_rx_offload_get_configuration_result,
18071 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18072 TOKEN_STRING_INITIALIZER
18073 (struct cmd_rx_offload_get_configuration_result,
18075 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18076 TOKEN_NUM_INITIALIZER
18077 (struct cmd_rx_offload_get_configuration_result,
18079 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18080 TOKEN_STRING_INITIALIZER
18081 (struct cmd_rx_offload_get_configuration_result,
18082 rx_offload, "rx_offload");
18083 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18084 TOKEN_STRING_INITIALIZER
18085 (struct cmd_rx_offload_get_configuration_result,
18086 configuration, "configuration");
18089 cmd_rx_offload_get_configuration_parsed(
18090 void *parsed_result,
18091 __attribute__((unused)) struct cmdline *cl,
18092 __attribute__((unused)) void *data)
18094 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18095 struct rte_eth_dev_info dev_info;
18096 portid_t port_id = res->port_id;
18097 struct rte_port *port = &ports[port_id];
18098 uint64_t port_offloads;
18099 uint64_t queue_offloads;
18100 uint16_t nb_rx_queues;
18104 printf("Rx Offloading Configuration of port %d :\n", port_id);
18106 port_offloads = port->dev_conf.rxmode.offloads;
18108 print_rx_offloads(port_offloads);
18111 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18115 nb_rx_queues = dev_info.nb_rx_queues;
18116 for (q = 0; q < nb_rx_queues; q++) {
18117 queue_offloads = port->rx_conf[q].offloads;
18118 printf(" Queue[%2d] :", q);
18119 print_rx_offloads(queue_offloads);
18125 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18126 .f = cmd_rx_offload_get_configuration_parsed,
18128 .help_str = "show port <port_id> rx_offload configuration",
18130 (void *)&cmd_rx_offload_get_configuration_show,
18131 (void *)&cmd_rx_offload_get_configuration_port,
18132 (void *)&cmd_rx_offload_get_configuration_port_id,
18133 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18134 (void *)&cmd_rx_offload_get_configuration_configuration,
18139 /* Enable/Disable a per port offloading */
18140 struct cmd_config_per_port_rx_offload_result {
18141 cmdline_fixed_string_t port;
18142 cmdline_fixed_string_t config;
18144 cmdline_fixed_string_t rx_offload;
18145 cmdline_fixed_string_t offload;
18146 cmdline_fixed_string_t on_off;
18149 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18150 TOKEN_STRING_INITIALIZER
18151 (struct cmd_config_per_port_rx_offload_result,
18153 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18154 TOKEN_STRING_INITIALIZER
18155 (struct cmd_config_per_port_rx_offload_result,
18157 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18158 TOKEN_NUM_INITIALIZER
18159 (struct cmd_config_per_port_rx_offload_result,
18161 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18162 TOKEN_STRING_INITIALIZER
18163 (struct cmd_config_per_port_rx_offload_result,
18164 rx_offload, "rx_offload");
18165 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18166 TOKEN_STRING_INITIALIZER
18167 (struct cmd_config_per_port_rx_offload_result,
18168 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18169 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18170 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18171 "scatter#timestamp#security#keep_crc#rss_hash");
18172 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18173 TOKEN_STRING_INITIALIZER
18174 (struct cmd_config_per_port_rx_offload_result,
18178 search_rx_offload(const char *name)
18180 uint64_t single_offload;
18181 const char *single_name;
18185 single_offload = 1;
18186 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18187 single_name = rte_eth_dev_rx_offload_name(single_offload);
18188 if (!strcasecmp(single_name, name)) {
18192 single_offload <<= 1;
18196 return single_offload;
18202 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18203 __attribute__((unused)) struct cmdline *cl,
18204 __attribute__((unused)) void *data)
18206 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18207 portid_t port_id = res->port_id;
18208 struct rte_eth_dev_info dev_info;
18209 struct rte_port *port = &ports[port_id];
18210 uint64_t single_offload;
18211 uint16_t nb_rx_queues;
18215 if (port->port_status != RTE_PORT_STOPPED) {
18216 printf("Error: Can't config offload when Port %d "
18217 "is not stopped\n", port_id);
18221 single_offload = search_rx_offload(res->offload);
18222 if (single_offload == 0) {
18223 printf("Unknown offload name: %s\n", res->offload);
18227 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18231 nb_rx_queues = dev_info.nb_rx_queues;
18232 if (!strcmp(res->on_off, "on")) {
18233 port->dev_conf.rxmode.offloads |= single_offload;
18234 for (q = 0; q < nb_rx_queues; q++)
18235 port->rx_conf[q].offloads |= single_offload;
18237 port->dev_conf.rxmode.offloads &= ~single_offload;
18238 for (q = 0; q < nb_rx_queues; q++)
18239 port->rx_conf[q].offloads &= ~single_offload;
18242 cmd_reconfig_device_queue(port_id, 1, 1);
18245 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18246 .f = cmd_config_per_port_rx_offload_parsed,
18248 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18249 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18250 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18251 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18254 (void *)&cmd_config_per_port_rx_offload_result_port,
18255 (void *)&cmd_config_per_port_rx_offload_result_config,
18256 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18257 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18258 (void *)&cmd_config_per_port_rx_offload_result_offload,
18259 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18264 /* Enable/Disable a per queue offloading */
18265 struct cmd_config_per_queue_rx_offload_result {
18266 cmdline_fixed_string_t port;
18268 cmdline_fixed_string_t rxq;
18270 cmdline_fixed_string_t rx_offload;
18271 cmdline_fixed_string_t offload;
18272 cmdline_fixed_string_t on_off;
18275 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18276 TOKEN_STRING_INITIALIZER
18277 (struct cmd_config_per_queue_rx_offload_result,
18279 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18280 TOKEN_NUM_INITIALIZER
18281 (struct cmd_config_per_queue_rx_offload_result,
18283 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18284 TOKEN_STRING_INITIALIZER
18285 (struct cmd_config_per_queue_rx_offload_result,
18287 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18288 TOKEN_NUM_INITIALIZER
18289 (struct cmd_config_per_queue_rx_offload_result,
18291 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18292 TOKEN_STRING_INITIALIZER
18293 (struct cmd_config_per_queue_rx_offload_result,
18294 rx_offload, "rx_offload");
18295 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18296 TOKEN_STRING_INITIALIZER
18297 (struct cmd_config_per_queue_rx_offload_result,
18298 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18299 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18300 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18301 "scatter#timestamp#security#keep_crc");
18302 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18303 TOKEN_STRING_INITIALIZER
18304 (struct cmd_config_per_queue_rx_offload_result,
18308 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18309 __attribute__((unused)) struct cmdline *cl,
18310 __attribute__((unused)) void *data)
18312 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18313 struct rte_eth_dev_info dev_info;
18314 portid_t port_id = res->port_id;
18315 uint16_t queue_id = res->queue_id;
18316 struct rte_port *port = &ports[port_id];
18317 uint64_t single_offload;
18320 if (port->port_status != RTE_PORT_STOPPED) {
18321 printf("Error: Can't config offload when Port %d "
18322 "is not stopped\n", port_id);
18326 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18330 if (queue_id >= dev_info.nb_rx_queues) {
18331 printf("Error: input queue_id should be 0 ... "
18332 "%d\n", dev_info.nb_rx_queues - 1);
18336 single_offload = search_rx_offload(res->offload);
18337 if (single_offload == 0) {
18338 printf("Unknown offload name: %s\n", res->offload);
18342 if (!strcmp(res->on_off, "on"))
18343 port->rx_conf[queue_id].offloads |= single_offload;
18345 port->rx_conf[queue_id].offloads &= ~single_offload;
18347 cmd_reconfig_device_queue(port_id, 1, 1);
18350 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18351 .f = cmd_config_per_queue_rx_offload_parsed,
18353 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18354 "vlan_strip|ipv4_cksum|"
18355 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18356 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18357 "jumbo_frame|scatter|timestamp|security|keep_crc "
18360 (void *)&cmd_config_per_queue_rx_offload_result_port,
18361 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18362 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18363 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18364 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18365 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18366 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18371 /* Get Tx offloads capabilities */
18372 struct cmd_tx_offload_get_capa_result {
18373 cmdline_fixed_string_t show;
18374 cmdline_fixed_string_t port;
18376 cmdline_fixed_string_t tx_offload;
18377 cmdline_fixed_string_t capabilities;
18380 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18381 TOKEN_STRING_INITIALIZER
18382 (struct cmd_tx_offload_get_capa_result,
18384 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18385 TOKEN_STRING_INITIALIZER
18386 (struct cmd_tx_offload_get_capa_result,
18388 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18389 TOKEN_NUM_INITIALIZER
18390 (struct cmd_tx_offload_get_capa_result,
18392 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18393 TOKEN_STRING_INITIALIZER
18394 (struct cmd_tx_offload_get_capa_result,
18395 tx_offload, "tx_offload");
18396 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18397 TOKEN_STRING_INITIALIZER
18398 (struct cmd_tx_offload_get_capa_result,
18399 capabilities, "capabilities");
18402 print_tx_offloads(uint64_t offloads)
18404 uint64_t single_offload;
18412 begin = __builtin_ctzll(offloads);
18413 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18415 single_offload = 1ULL << begin;
18416 for (bit = begin; bit < end; bit++) {
18417 if (offloads & single_offload)
18419 rte_eth_dev_tx_offload_name(single_offload));
18420 single_offload <<= 1;
18425 cmd_tx_offload_get_capa_parsed(
18426 void *parsed_result,
18427 __attribute__((unused)) struct cmdline *cl,
18428 __attribute__((unused)) void *data)
18430 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18431 struct rte_eth_dev_info dev_info;
18432 portid_t port_id = res->port_id;
18433 uint64_t queue_offloads;
18434 uint64_t port_offloads;
18437 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18441 queue_offloads = dev_info.tx_queue_offload_capa;
18442 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18444 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18445 printf(" Per Queue :");
18446 print_tx_offloads(queue_offloads);
18449 printf(" Per Port :");
18450 print_tx_offloads(port_offloads);
18454 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18455 .f = cmd_tx_offload_get_capa_parsed,
18457 .help_str = "show port <port_id> tx_offload capabilities",
18459 (void *)&cmd_tx_offload_get_capa_show,
18460 (void *)&cmd_tx_offload_get_capa_port,
18461 (void *)&cmd_tx_offload_get_capa_port_id,
18462 (void *)&cmd_tx_offload_get_capa_tx_offload,
18463 (void *)&cmd_tx_offload_get_capa_capabilities,
18468 /* Get Tx offloads configuration */
18469 struct cmd_tx_offload_get_configuration_result {
18470 cmdline_fixed_string_t show;
18471 cmdline_fixed_string_t port;
18473 cmdline_fixed_string_t tx_offload;
18474 cmdline_fixed_string_t configuration;
18477 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18478 TOKEN_STRING_INITIALIZER
18479 (struct cmd_tx_offload_get_configuration_result,
18481 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18482 TOKEN_STRING_INITIALIZER
18483 (struct cmd_tx_offload_get_configuration_result,
18485 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18486 TOKEN_NUM_INITIALIZER
18487 (struct cmd_tx_offload_get_configuration_result,
18489 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18490 TOKEN_STRING_INITIALIZER
18491 (struct cmd_tx_offload_get_configuration_result,
18492 tx_offload, "tx_offload");
18493 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18494 TOKEN_STRING_INITIALIZER
18495 (struct cmd_tx_offload_get_configuration_result,
18496 configuration, "configuration");
18499 cmd_tx_offload_get_configuration_parsed(
18500 void *parsed_result,
18501 __attribute__((unused)) struct cmdline *cl,
18502 __attribute__((unused)) void *data)
18504 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18505 struct rte_eth_dev_info dev_info;
18506 portid_t port_id = res->port_id;
18507 struct rte_port *port = &ports[port_id];
18508 uint64_t port_offloads;
18509 uint64_t queue_offloads;
18510 uint16_t nb_tx_queues;
18514 printf("Tx Offloading Configuration of port %d :\n", port_id);
18516 port_offloads = port->dev_conf.txmode.offloads;
18518 print_tx_offloads(port_offloads);
18521 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18525 nb_tx_queues = dev_info.nb_tx_queues;
18526 for (q = 0; q < nb_tx_queues; q++) {
18527 queue_offloads = port->tx_conf[q].offloads;
18528 printf(" Queue[%2d] :", q);
18529 print_tx_offloads(queue_offloads);
18535 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18536 .f = cmd_tx_offload_get_configuration_parsed,
18538 .help_str = "show port <port_id> tx_offload configuration",
18540 (void *)&cmd_tx_offload_get_configuration_show,
18541 (void *)&cmd_tx_offload_get_configuration_port,
18542 (void *)&cmd_tx_offload_get_configuration_port_id,
18543 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18544 (void *)&cmd_tx_offload_get_configuration_configuration,
18549 /* Enable/Disable a per port offloading */
18550 struct cmd_config_per_port_tx_offload_result {
18551 cmdline_fixed_string_t port;
18552 cmdline_fixed_string_t config;
18554 cmdline_fixed_string_t tx_offload;
18555 cmdline_fixed_string_t offload;
18556 cmdline_fixed_string_t on_off;
18559 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18560 TOKEN_STRING_INITIALIZER
18561 (struct cmd_config_per_port_tx_offload_result,
18563 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18564 TOKEN_STRING_INITIALIZER
18565 (struct cmd_config_per_port_tx_offload_result,
18567 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18568 TOKEN_NUM_INITIALIZER
18569 (struct cmd_config_per_port_tx_offload_result,
18571 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18572 TOKEN_STRING_INITIALIZER
18573 (struct cmd_config_per_port_tx_offload_result,
18574 tx_offload, "tx_offload");
18575 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18576 TOKEN_STRING_INITIALIZER
18577 (struct cmd_config_per_port_tx_offload_result,
18578 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18579 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18580 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18581 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18582 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18583 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18584 TOKEN_STRING_INITIALIZER
18585 (struct cmd_config_per_port_tx_offload_result,
18589 search_tx_offload(const char *name)
18591 uint64_t single_offload;
18592 const char *single_name;
18596 single_offload = 1;
18597 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18598 single_name = rte_eth_dev_tx_offload_name(single_offload);
18599 if (single_name == NULL)
18601 if (!strcasecmp(single_name, name)) {
18604 } else if (!strcasecmp(single_name, "UNKNOWN"))
18606 single_offload <<= 1;
18610 return single_offload;
18616 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18617 __attribute__((unused)) struct cmdline *cl,
18618 __attribute__((unused)) void *data)
18620 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18621 portid_t port_id = res->port_id;
18622 struct rte_eth_dev_info dev_info;
18623 struct rte_port *port = &ports[port_id];
18624 uint64_t single_offload;
18625 uint16_t nb_tx_queues;
18629 if (port->port_status != RTE_PORT_STOPPED) {
18630 printf("Error: Can't config offload when Port %d "
18631 "is not stopped\n", port_id);
18635 single_offload = search_tx_offload(res->offload);
18636 if (single_offload == 0) {
18637 printf("Unknown offload name: %s\n", res->offload);
18641 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18645 nb_tx_queues = dev_info.nb_tx_queues;
18646 if (!strcmp(res->on_off, "on")) {
18647 port->dev_conf.txmode.offloads |= single_offload;
18648 for (q = 0; q < nb_tx_queues; q++)
18649 port->tx_conf[q].offloads |= single_offload;
18651 port->dev_conf.txmode.offloads &= ~single_offload;
18652 for (q = 0; q < nb_tx_queues; q++)
18653 port->tx_conf[q].offloads &= ~single_offload;
18656 cmd_reconfig_device_queue(port_id, 1, 1);
18659 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18660 .f = cmd_config_per_port_tx_offload_parsed,
18662 .help_str = "port config <port_id> tx_offload "
18663 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18664 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18665 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18666 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18667 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18669 (void *)&cmd_config_per_port_tx_offload_result_port,
18670 (void *)&cmd_config_per_port_tx_offload_result_config,
18671 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18672 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18673 (void *)&cmd_config_per_port_tx_offload_result_offload,
18674 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18679 /* Enable/Disable a per queue offloading */
18680 struct cmd_config_per_queue_tx_offload_result {
18681 cmdline_fixed_string_t port;
18683 cmdline_fixed_string_t txq;
18685 cmdline_fixed_string_t tx_offload;
18686 cmdline_fixed_string_t offload;
18687 cmdline_fixed_string_t on_off;
18690 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18691 TOKEN_STRING_INITIALIZER
18692 (struct cmd_config_per_queue_tx_offload_result,
18694 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18695 TOKEN_NUM_INITIALIZER
18696 (struct cmd_config_per_queue_tx_offload_result,
18698 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18699 TOKEN_STRING_INITIALIZER
18700 (struct cmd_config_per_queue_tx_offload_result,
18702 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18703 TOKEN_NUM_INITIALIZER
18704 (struct cmd_config_per_queue_tx_offload_result,
18706 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18707 TOKEN_STRING_INITIALIZER
18708 (struct cmd_config_per_queue_tx_offload_result,
18709 tx_offload, "tx_offload");
18710 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18711 TOKEN_STRING_INITIALIZER
18712 (struct cmd_config_per_queue_tx_offload_result,
18713 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18714 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18715 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18716 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18717 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18718 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18719 TOKEN_STRING_INITIALIZER
18720 (struct cmd_config_per_queue_tx_offload_result,
18724 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18725 __attribute__((unused)) struct cmdline *cl,
18726 __attribute__((unused)) void *data)
18728 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18729 struct rte_eth_dev_info dev_info;
18730 portid_t port_id = res->port_id;
18731 uint16_t queue_id = res->queue_id;
18732 struct rte_port *port = &ports[port_id];
18733 uint64_t single_offload;
18736 if (port->port_status != RTE_PORT_STOPPED) {
18737 printf("Error: Can't config offload when Port %d "
18738 "is not stopped\n", port_id);
18742 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18746 if (queue_id >= dev_info.nb_tx_queues) {
18747 printf("Error: input queue_id should be 0 ... "
18748 "%d\n", dev_info.nb_tx_queues - 1);
18752 single_offload = search_tx_offload(res->offload);
18753 if (single_offload == 0) {
18754 printf("Unknown offload name: %s\n", res->offload);
18758 if (!strcmp(res->on_off, "on"))
18759 port->tx_conf[queue_id].offloads |= single_offload;
18761 port->tx_conf[queue_id].offloads &= ~single_offload;
18763 cmd_reconfig_device_queue(port_id, 1, 1);
18766 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18767 .f = cmd_config_per_queue_tx_offload_parsed,
18769 .help_str = "port <port_id> txq <queue_id> tx_offload "
18770 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18771 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18772 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18773 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18774 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18777 (void *)&cmd_config_per_queue_tx_offload_result_port,
18778 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18779 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18780 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18781 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18782 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18783 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18788 /* *** configure tx_metadata for specific port *** */
18789 struct cmd_config_tx_metadata_specific_result {
18790 cmdline_fixed_string_t port;
18791 cmdline_fixed_string_t keyword;
18793 cmdline_fixed_string_t item;
18798 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18799 __attribute__((unused)) struct cmdline *cl,
18800 __attribute__((unused)) void *data)
18802 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18804 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18806 ports[res->port_id].tx_metadata = res->value;
18807 /* Add/remove callback to insert valid metadata in every Tx packet. */
18808 if (ports[res->port_id].tx_metadata)
18809 add_tx_md_callback(res->port_id);
18811 remove_tx_md_callback(res->port_id);
18812 rte_flow_dynf_metadata_register();
18815 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18816 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18818 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18819 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18820 keyword, "config");
18821 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18822 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18824 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18825 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18826 item, "tx_metadata");
18827 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18828 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18831 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18832 .f = cmd_config_tx_metadata_specific_parsed,
18834 .help_str = "port config <port_id> tx_metadata <value>",
18836 (void *)&cmd_config_tx_metadata_specific_port,
18837 (void *)&cmd_config_tx_metadata_specific_keyword,
18838 (void *)&cmd_config_tx_metadata_specific_id,
18839 (void *)&cmd_config_tx_metadata_specific_item,
18840 (void *)&cmd_config_tx_metadata_specific_value,
18845 /* *** set dynf *** */
18846 struct cmd_config_tx_dynf_specific_result {
18847 cmdline_fixed_string_t port;
18848 cmdline_fixed_string_t keyword;
18850 cmdline_fixed_string_t item;
18851 cmdline_fixed_string_t name;
18852 cmdline_fixed_string_t value;
18856 cmd_config_dynf_specific_parsed(void *parsed_result,
18857 __attribute__((unused)) struct cmdline *cl,
18858 __attribute__((unused)) void *data)
18860 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18861 struct rte_mbuf_dynflag desc_flag;
18863 uint64_t old_port_flags;
18865 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18867 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18869 strcpy(desc_flag.name, res->name);
18870 desc_flag.flags = 0;
18871 flag = rte_mbuf_dynflag_register(&desc_flag);
18873 printf("Can't register flag\n");
18876 strcpy(dynf_names[flag], res->name);
18878 old_port_flags = ports[res->port_id].mbuf_dynf;
18879 if (!strcmp(res->value, "set")) {
18880 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18881 if (old_port_flags == 0)
18882 add_tx_dynf_callback(res->port_id);
18884 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18885 if (ports[res->port_id].mbuf_dynf == 0)
18886 remove_tx_dynf_callback(res->port_id);
18890 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18891 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18893 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18894 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18895 keyword, "config");
18896 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18897 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18899 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18900 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18902 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18903 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18905 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18906 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18907 value, "set#clear");
18909 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18910 .f = cmd_config_dynf_specific_parsed,
18912 .help_str = "port config <port id> dynf <name> set|clear",
18914 (void *)&cmd_config_tx_dynf_specific_port,
18915 (void *)&cmd_config_tx_dynf_specific_keyword,
18916 (void *)&cmd_config_tx_dynf_specific_port_id,
18917 (void *)&cmd_config_tx_dynf_specific_item,
18918 (void *)&cmd_config_tx_dynf_specific_name,
18919 (void *)&cmd_config_tx_dynf_specific_value,
18924 /* *** display tx_metadata per port configuration *** */
18925 struct cmd_show_tx_metadata_result {
18926 cmdline_fixed_string_t cmd_show;
18927 cmdline_fixed_string_t cmd_port;
18928 cmdline_fixed_string_t cmd_keyword;
18933 cmd_show_tx_metadata_parsed(void *parsed_result,
18934 __attribute__((unused)) struct cmdline *cl,
18935 __attribute__((unused)) void *data)
18937 struct cmd_show_tx_metadata_result *res = parsed_result;
18939 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18940 printf("invalid port id %u\n", res->cmd_pid);
18943 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18944 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18945 ports[res->cmd_pid].tx_metadata);
18949 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18950 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18952 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18953 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18955 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18956 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18958 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18959 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18960 cmd_keyword, "tx_metadata");
18962 cmdline_parse_inst_t cmd_show_tx_metadata = {
18963 .f = cmd_show_tx_metadata_parsed,
18965 .help_str = "show port <port_id> tx_metadata",
18967 (void *)&cmd_show_tx_metadata_show,
18968 (void *)&cmd_show_tx_metadata_port,
18969 (void *)&cmd_show_tx_metadata_pid,
18970 (void *)&cmd_show_tx_metadata_keyword,
18975 /* show port supported ptypes */
18977 /* Common result structure for show port ptypes */
18978 struct cmd_show_port_supported_ptypes_result {
18979 cmdline_fixed_string_t show;
18980 cmdline_fixed_string_t port;
18982 cmdline_fixed_string_t ptypes;
18985 /* Common CLI fields for show port ptypes */
18986 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18987 TOKEN_STRING_INITIALIZER
18988 (struct cmd_show_port_supported_ptypes_result,
18990 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18991 TOKEN_STRING_INITIALIZER
18992 (struct cmd_show_port_supported_ptypes_result,
18994 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18995 TOKEN_NUM_INITIALIZER
18996 (struct cmd_show_port_supported_ptypes_result,
18998 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18999 TOKEN_STRING_INITIALIZER
19000 (struct cmd_show_port_supported_ptypes_result,
19004 cmd_show_port_supported_ptypes_parsed(
19005 void *parsed_result,
19006 __attribute__((unused)) struct cmdline *cl,
19007 __attribute__((unused)) void *data)
19009 #define RSVD_PTYPE_MASK 0xf0000000
19010 #define MAX_PTYPES_PER_LAYER 16
19011 #define LTYPE_NAMESIZE 32
19012 #define PTYPE_NAMESIZE 256
19013 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19014 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19015 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19016 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19017 uint16_t port_id = res->port_id;
19020 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19024 while (ptype_mask != RSVD_PTYPE_MASK) {
19026 switch (ptype_mask) {
19027 case RTE_PTYPE_L2_MASK:
19028 strlcpy(ltype, "L2", sizeof(ltype));
19030 case RTE_PTYPE_L3_MASK:
19031 strlcpy(ltype, "L3", sizeof(ltype));
19033 case RTE_PTYPE_L4_MASK:
19034 strlcpy(ltype, "L4", sizeof(ltype));
19036 case RTE_PTYPE_TUNNEL_MASK:
19037 strlcpy(ltype, "Tunnel", sizeof(ltype));
19039 case RTE_PTYPE_INNER_L2_MASK:
19040 strlcpy(ltype, "Inner L2", sizeof(ltype));
19042 case RTE_PTYPE_INNER_L3_MASK:
19043 strlcpy(ltype, "Inner L3", sizeof(ltype));
19045 case RTE_PTYPE_INNER_L4_MASK:
19046 strlcpy(ltype, "Inner L4", sizeof(ltype));
19052 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19053 ptype_mask, ptypes,
19054 MAX_PTYPES_PER_LAYER);
19057 printf("Supported %s ptypes:\n", ltype);
19059 printf("%s ptypes unsupported\n", ltype);
19061 for (i = 0; i < ret; ++i) {
19062 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19063 printf("%s\n", buf);
19070 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19071 .f = cmd_show_port_supported_ptypes_parsed,
19073 .help_str = "show port <port_id> ptypes",
19075 (void *)&cmd_show_port_supported_ptypes_show,
19076 (void *)&cmd_show_port_supported_ptypes_port,
19077 (void *)&cmd_show_port_supported_ptypes_port_id,
19078 (void *)&cmd_show_port_supported_ptypes_ptypes,
19083 /* *** display rx/tx descriptor status *** */
19084 struct cmd_show_rx_tx_desc_status_result {
19085 cmdline_fixed_string_t cmd_show;
19086 cmdline_fixed_string_t cmd_port;
19087 cmdline_fixed_string_t cmd_keyword;
19088 cmdline_fixed_string_t cmd_desc;
19089 cmdline_fixed_string_t cmd_status;
19096 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19097 __attribute__((unused)) struct cmdline *cl,
19098 __attribute__((unused)) void *data)
19100 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19103 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19104 printf("invalid port id %u\n", res->cmd_pid);
19108 if (!strcmp(res->cmd_keyword, "rxq")) {
19109 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19112 printf("Invalid queueid = %d\n", res->cmd_qid);
19115 if (rc == RTE_ETH_RX_DESC_AVAIL)
19116 printf("Desc status = AVAILABLE\n");
19117 else if (rc == RTE_ETH_RX_DESC_DONE)
19118 printf("Desc status = DONE\n");
19120 printf("Desc status = UNAVAILABLE\n");
19121 } else if (!strcmp(res->cmd_keyword, "txq")) {
19122 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19125 printf("Invalid queueid = %d\n", res->cmd_qid);
19128 if (rc == RTE_ETH_TX_DESC_FULL)
19129 printf("Desc status = FULL\n");
19130 else if (rc == RTE_ETH_TX_DESC_DONE)
19131 printf("Desc status = DONE\n");
19133 printf("Desc status = UNAVAILABLE\n");
19137 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19138 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19140 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19141 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19143 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19144 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19146 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19147 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19148 cmd_keyword, "rxq#txq");
19149 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19150 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19152 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19153 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19155 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19156 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19158 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19159 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19160 cmd_status, "status");
19161 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19162 .f = cmd_show_rx_tx_desc_status_parsed,
19164 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19167 (void *)&cmd_show_rx_tx_desc_status_show,
19168 (void *)&cmd_show_rx_tx_desc_status_port,
19169 (void *)&cmd_show_rx_tx_desc_status_pid,
19170 (void *)&cmd_show_rx_tx_desc_status_keyword,
19171 (void *)&cmd_show_rx_tx_desc_status_qid,
19172 (void *)&cmd_show_rx_tx_desc_status_desc,
19173 (void *)&cmd_show_rx_tx_desc_status_did,
19174 (void *)&cmd_show_rx_tx_desc_status_status,
19179 /* Common result structure for set port ptypes */
19180 struct cmd_set_port_ptypes_result {
19181 cmdline_fixed_string_t set;
19182 cmdline_fixed_string_t port;
19184 cmdline_fixed_string_t ptype_mask;
19188 /* Common CLI fields for set port ptypes */
19189 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19190 TOKEN_STRING_INITIALIZER
19191 (struct cmd_set_port_ptypes_result,
19193 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19194 TOKEN_STRING_INITIALIZER
19195 (struct cmd_set_port_ptypes_result,
19197 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19198 TOKEN_NUM_INITIALIZER
19199 (struct cmd_set_port_ptypes_result,
19201 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19202 TOKEN_STRING_INITIALIZER
19203 (struct cmd_set_port_ptypes_result,
19204 ptype_mask, "ptype_mask");
19205 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19206 TOKEN_NUM_INITIALIZER
19207 (struct cmd_set_port_ptypes_result,
19211 cmd_set_port_ptypes_parsed(
19212 void *parsed_result,
19213 __attribute__((unused)) struct cmdline *cl,
19214 __attribute__((unused)) void *data)
19216 struct cmd_set_port_ptypes_result *res = parsed_result;
19217 #define PTYPE_NAMESIZE 256
19218 char ptype_name[PTYPE_NAMESIZE];
19219 uint16_t port_id = res->port_id;
19220 uint32_t ptype_mask = res->mask;
19223 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19226 printf("Port %d doesn't support any ptypes.\n", port_id);
19230 uint32_t ptypes[ret];
19232 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19234 printf("Unable to set requested ptypes for Port %d\n", port_id);
19238 printf("Successfully set following ptypes for Port %d\n", port_id);
19239 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19240 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19241 printf("%s\n", ptype_name);
19244 clear_ptypes = false;
19247 cmdline_parse_inst_t cmd_set_port_ptypes = {
19248 .f = cmd_set_port_ptypes_parsed,
19250 .help_str = "set port <port_id> ptype_mask <mask>",
19252 (void *)&cmd_set_port_ptypes_set,
19253 (void *)&cmd_set_port_ptypes_port,
19254 (void *)&cmd_set_port_ptypes_port_id,
19255 (void *)&cmd_set_port_ptypes_mask_str,
19256 (void *)&cmd_set_port_ptypes_mask_u32,
19261 /* *** display mac addresses added to a port *** */
19262 struct cmd_showport_macs_result {
19263 cmdline_fixed_string_t cmd_show;
19264 cmdline_fixed_string_t cmd_port;
19265 cmdline_fixed_string_t cmd_keyword;
19270 cmd_showport_macs_parsed(void *parsed_result,
19271 __attribute__((unused)) struct cmdline *cl,
19272 __attribute__((unused)) void *data)
19274 struct cmd_showport_macs_result *res = parsed_result;
19276 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19279 if (!strcmp(res->cmd_keyword, "macs"))
19280 show_macs(res->cmd_pid);
19281 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19282 show_mcast_macs(res->cmd_pid);
19285 cmdline_parse_token_string_t cmd_showport_macs_show =
19286 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19288 cmdline_parse_token_string_t cmd_showport_macs_port =
19289 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19291 cmdline_parse_token_num_t cmd_showport_macs_pid =
19292 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19294 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19295 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19296 cmd_keyword, "macs#mcast_macs");
19298 cmdline_parse_inst_t cmd_showport_macs = {
19299 .f = cmd_showport_macs_parsed,
19301 .help_str = "show port <port_id> macs|mcast_macs",
19303 (void *)&cmd_showport_macs_show,
19304 (void *)&cmd_showport_macs_port,
19305 (void *)&cmd_showport_macs_pid,
19306 (void *)&cmd_showport_macs_keyword,
19311 /* ******************************************************************************** */
19313 /* list of instructions */
19314 cmdline_parse_ctx_t main_ctx[] = {
19315 (cmdline_parse_inst_t *)&cmd_help_brief,
19316 (cmdline_parse_inst_t *)&cmd_help_long,
19317 (cmdline_parse_inst_t *)&cmd_quit,
19318 (cmdline_parse_inst_t *)&cmd_load_from_file,
19319 (cmdline_parse_inst_t *)&cmd_showport,
19320 (cmdline_parse_inst_t *)&cmd_showqueue,
19321 (cmdline_parse_inst_t *)&cmd_showportall,
19322 (cmdline_parse_inst_t *)&cmd_showdevice,
19323 (cmdline_parse_inst_t *)&cmd_showcfg,
19324 (cmdline_parse_inst_t *)&cmd_showfwdall,
19325 (cmdline_parse_inst_t *)&cmd_start,
19326 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19327 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19328 (cmdline_parse_inst_t *)&cmd_set_link_up,
19329 (cmdline_parse_inst_t *)&cmd_set_link_down,
19330 (cmdline_parse_inst_t *)&cmd_reset,
19331 (cmdline_parse_inst_t *)&cmd_set_numbers,
19332 (cmdline_parse_inst_t *)&cmd_set_log,
19333 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19334 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19335 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19336 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19337 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19338 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19339 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19340 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19341 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19342 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19343 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19344 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19345 (cmdline_parse_inst_t *)&cmd_set_link_check,
19346 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19347 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19348 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19349 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19350 #ifdef RTE_LIBRTE_PMD_BOND
19351 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19352 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19353 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19354 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19355 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19356 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19357 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19358 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19359 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19360 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19361 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19363 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19364 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19365 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19366 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19367 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19368 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19369 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19370 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19371 (cmdline_parse_inst_t *)&cmd_csum_set,
19372 (cmdline_parse_inst_t *)&cmd_csum_show,
19373 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19374 (cmdline_parse_inst_t *)&cmd_tso_set,
19375 (cmdline_parse_inst_t *)&cmd_tso_show,
19376 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19377 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19378 (cmdline_parse_inst_t *)&cmd_gro_enable,
19379 (cmdline_parse_inst_t *)&cmd_gro_flush,
19380 (cmdline_parse_inst_t *)&cmd_gro_show,
19381 (cmdline_parse_inst_t *)&cmd_gso_enable,
19382 (cmdline_parse_inst_t *)&cmd_gso_size,
19383 (cmdline_parse_inst_t *)&cmd_gso_show,
19384 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19385 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19386 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19387 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19388 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19389 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19390 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19391 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19392 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19393 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19394 (cmdline_parse_inst_t *)&cmd_config_dcb,
19395 (cmdline_parse_inst_t *)&cmd_read_reg,
19396 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19397 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19398 (cmdline_parse_inst_t *)&cmd_write_reg,
19399 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19400 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19401 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19402 (cmdline_parse_inst_t *)&cmd_stop,
19403 (cmdline_parse_inst_t *)&cmd_mac_addr,
19404 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19405 (cmdline_parse_inst_t *)&cmd_set_qmap,
19406 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19407 (cmdline_parse_inst_t *)&cmd_operate_port,
19408 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19409 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19410 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19411 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19412 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19413 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19414 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19415 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19416 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19417 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19418 (cmdline_parse_inst_t *)&cmd_config_mtu,
19419 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19420 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19421 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19422 (cmdline_parse_inst_t *)&cmd_config_rss,
19423 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19424 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19425 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19426 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19427 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19428 (cmdline_parse_inst_t *)&cmd_showport_reta,
19429 (cmdline_parse_inst_t *)&cmd_showport_macs,
19430 (cmdline_parse_inst_t *)&cmd_config_burst,
19431 (cmdline_parse_inst_t *)&cmd_config_thresh,
19432 (cmdline_parse_inst_t *)&cmd_config_threshold,
19433 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19434 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19435 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19436 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19437 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19438 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19439 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19440 (cmdline_parse_inst_t *)&cmd_global_config,
19441 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19442 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19443 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19444 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19445 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19446 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19447 (cmdline_parse_inst_t *)&cmd_dump,
19448 (cmdline_parse_inst_t *)&cmd_dump_one,
19449 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19450 (cmdline_parse_inst_t *)&cmd_syn_filter,
19451 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19452 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19453 (cmdline_parse_inst_t *)&cmd_flex_filter,
19454 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19455 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19456 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19457 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19458 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19459 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19460 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19461 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19462 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19463 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19464 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19465 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19466 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19467 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19468 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19469 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19470 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19471 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19472 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19473 (cmdline_parse_inst_t *)&cmd_flow,
19474 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19475 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19476 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19477 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19478 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19479 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19480 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19481 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19482 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19483 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19484 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19485 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19486 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19487 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19488 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19489 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19490 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19491 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19492 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19493 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19494 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19495 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19496 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19497 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19498 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19499 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19500 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19501 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19502 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19503 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19504 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19505 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19506 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19507 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19508 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19509 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19510 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19511 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19512 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19513 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19514 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19515 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19516 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19517 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19518 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19519 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19520 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19521 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19522 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19523 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19524 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19526 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19527 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19528 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19529 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19530 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19531 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19532 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19533 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19534 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19535 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19536 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19537 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19538 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19539 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19540 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19541 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19542 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19543 (cmdline_parse_inst_t *)&cmd_ddp_add,
19544 (cmdline_parse_inst_t *)&cmd_ddp_del,
19545 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19546 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19547 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19548 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19549 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19550 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19551 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19552 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19553 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19554 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19555 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19556 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19558 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19559 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19560 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19561 (cmdline_parse_inst_t *)&cmd_queue_region,
19562 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19563 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19564 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19565 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19566 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19567 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19568 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19569 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19570 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19571 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19572 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19573 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19574 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19575 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19576 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19577 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19578 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19579 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19580 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19581 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19582 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19583 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19584 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19585 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19586 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19587 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19588 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19589 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19590 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19591 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19592 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19593 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19594 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19595 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19596 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19597 #ifdef RTE_LIBRTE_BPF
19598 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19599 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19601 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19602 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19603 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19604 (cmdline_parse_inst_t *)&cmd_set_raw,
19605 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19606 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19607 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19611 /* read cmdline commands from file */
19613 cmdline_read_from_file(const char *filename)
19615 struct cmdline *cl;
19617 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19619 printf("Failed to create file based cmdline context: %s\n",
19624 cmdline_interact(cl);
19629 printf("Read CLI commands from %s\n", filename);
19632 /* prompt function, called from main on MASTER lcore */
19636 /* initialize non-constant commands */
19637 cmd_set_fwd_mode_init();
19638 cmd_set_fwd_retry_mode_init();
19640 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19641 if (testpmd_cl == NULL)
19643 cmdline_interact(testpmd_cl);
19644 cmdline_stdin_exit(testpmd_cl);
19650 if (testpmd_cl != NULL)
19651 cmdline_quit(testpmd_cl);
19655 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19657 if (id == (portid_t)RTE_PORT_ALL) {
19660 RTE_ETH_FOREACH_DEV(pid) {
19661 /* check if need_reconfig has been set to 1 */
19662 if (ports[pid].need_reconfig == 0)
19663 ports[pid].need_reconfig = dev;
19664 /* check if need_reconfig_queues has been set to 1 */
19665 if (ports[pid].need_reconfig_queues == 0)
19666 ports[pid].need_reconfig_queues = queue;
19668 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19669 /* check if need_reconfig has been set to 1 */
19670 if (ports[id].need_reconfig == 0)
19671 ports[id].need_reconfig = dev;
19672 /* check if need_reconfig_queues has been set to 1 */
19673 if (ports[id].need_reconfig_queues == 0)
19674 ports[id].need_reconfig_queues = queue;