1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
44 #include <cmdline_rdline.h>
45 #include <cmdline_parse.h>
46 #include <cmdline_parse_num.h>
47 #include <cmdline_parse_string.h>
48 #include <cmdline_parse_ipaddr.h>
49 #include <cmdline_parse_etheraddr.h>
50 #include <cmdline_socket.h>
52 #ifdef RTE_LIBRTE_PMD_BOND
53 #include <rte_eth_bond.h>
54 #include <rte_eth_bond_8023ad.h>
56 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
57 #include <rte_pmd_dpaa.h>
59 #ifdef RTE_LIBRTE_IXGBE_PMD
60 #include <rte_pmd_ixgbe.h>
62 #ifdef RTE_LIBRTE_I40E_PMD
63 #include <rte_pmd_i40e.h>
65 #ifdef RTE_LIBRTE_BNXT_PMD
66 #include <rte_pmd_bnxt.h>
69 #include "cmdline_mtr.h"
70 #include "cmdline_tm.h"
73 static struct cmdline *testpmd_cl;
75 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
77 /* *** Help command with introduction. *** */
78 struct cmd_help_brief_result {
79 cmdline_fixed_string_t help;
82 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
84 __attribute__((unused)) void *data)
89 "Help is available for the following sections:\n\n"
90 " help control : Start and stop forwarding.\n"
91 " help display : Displaying port, stats and config "
93 " help config : Configuration information.\n"
94 " help ports : Configuring ports.\n"
95 " help registers : Reading and setting port registers.\n"
96 " help filters : Filters configuration help.\n"
97 " help traffic_management : Traffic Management commmands.\n"
98 " help devices : Device related cmds.\n"
99 " help all : All of the above sections.\n\n"
104 cmdline_parse_token_string_t cmd_help_brief_help =
105 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 cmdline_parse_inst_t cmd_help_brief = {
108 .f = cmd_help_brief_parsed,
110 .help_str = "help: Show help",
112 (void *)&cmd_help_brief_help,
117 /* *** Help command with help sections. *** */
118 struct cmd_help_long_result {
119 cmdline_fixed_string_t help;
120 cmdline_fixed_string_t section;
123 static void cmd_help_long_parsed(void *parsed_result,
125 __attribute__((unused)) void *data)
128 struct cmd_help_long_result *res = parsed_result;
130 if (!strcmp(res->section, "all"))
133 if (show_all || !strcmp(res->section, "control")) {
138 "Control forwarding:\n"
139 "-------------------\n\n"
142 " Start packet forwarding with current configuration.\n\n"
145 " Start packet forwarding with current config"
146 " after sending one burst of packets.\n\n"
149 " Stop packet forwarding, and display accumulated"
153 " Quit to prompt.\n\n"
157 if (show_all || !strcmp(res->section, "display")) {
165 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
166 " Display information for port_id, or all.\n\n"
168 "show port X rss reta (size) (mask0,mask1,...)\n"
169 " Display the rss redirection table entry indicated"
170 " by masks on port X. size is used to indicate the"
171 " hardware supported reta size\n\n"
173 "show port (port_id) rss-hash [key]\n"
174 " Display the RSS hash functions and RSS hash key of port\n\n"
176 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
177 " Clear information for port_id, or all.\n\n"
179 "show (rxq|txq) info (port_id) (queue_id)\n"
180 " Display information for configured RX/TX queue.\n\n"
182 "show config (rxtx|cores|fwd|txpkts)\n"
183 " Display the given configuration.\n\n"
185 "read rxd (port_id) (queue_id) (rxd_id)\n"
186 " Display an RX descriptor of a port RX queue.\n\n"
188 "read txd (port_id) (queue_id) (txd_id)\n"
189 " Display a TX descriptor of a port TX queue.\n\n"
191 "ddp get list (port_id)\n"
192 " Get ddp profile info list\n\n"
194 "ddp get info (profile_path)\n"
195 " Get ddp profile information.\n\n"
197 "show vf stats (port_id) (vf_id)\n"
198 " Display a VF's statistics.\n\n"
200 "clear vf stats (port_id) (vf_id)\n"
201 " Reset a VF's statistics.\n\n"
203 "show port (port_id) pctype mapping\n"
204 " Get flow ptype to pctype mapping on a port\n\n"
206 "show port meter stats (port_id) (meter_id) (clear)\n"
207 " Get meter stats on a port\n\n"
209 "show fwd stats all\n"
210 " Display statistics for all fwd engines.\n\n"
212 "clear fwd stats all\n"
213 " Clear statistics for all fwd engines.\n\n"
215 "show port (port_id) rx_offload capabilities\n"
216 " List all per queue and per port Rx offloading"
217 " capabilities of a port\n\n"
219 "show port (port_id) rx_offload configuration\n"
220 " List port level and all queue level"
221 " Rx offloading configuration\n\n"
223 "show port (port_id) tx_offload capabilities\n"
224 " List all per queue and per port"
225 " Tx offloading capabilities of a port\n\n"
227 "show port (port_id) tx_offload configuration\n"
228 " List port level and all queue level"
229 " Tx offloading configuration\n\n"
231 "show port (port_id) tx_metadata\n"
232 " Show Tx metadata value set"
233 " for a specific port\n\n"
235 "show port (port_id) ptypes\n"
236 " Show port supported ptypes"
237 " for a specific port\n\n"
239 "show device info (<identifier>|all)"
240 " Show general information about devices probed.\n\n"
242 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
243 " Show status of rx|tx descriptor.\n\n"
247 if (show_all || !strcmp(res->section, "config")) {
253 "Configuration changes only become active when"
254 " forwarding is started/restarted.\n\n"
257 " Reset forwarding to the default configuration.\n\n"
259 "set verbose (level)\n"
260 " Set the debug verbosity level X.\n\n"
262 "set log global|(type) (level)\n"
263 " Set the log level.\n\n"
266 " Set number of ports.\n\n"
269 " Set number of cores.\n\n"
271 "set coremask (mask)\n"
272 " Set the forwarding cores hexadecimal mask.\n\n"
274 "set portmask (mask)\n"
275 " Set the forwarding ports hexadecimal mask.\n\n"
278 " Set number of packets per burst.\n\n"
280 "set burst tx delay (microseconds) retry (num)\n"
281 " Set the transmit delay time and number of retries,"
282 " effective when retry is enabled.\n\n"
284 "set txpkts (x[,y]*)\n"
285 " Set the length of each segment of TXONLY"
286 " and optionally CSUM packets.\n\n"
288 "set txsplit (off|on|rand)\n"
289 " Set the split policy for the TX packets."
290 " Right now only applicable for CSUM and TXONLY"
293 "set corelist (x[,y]*)\n"
294 " Set the list of forwarding cores.\n\n"
296 "set portlist (x[,y]*)\n"
297 " Set the list of forwarding ports.\n\n"
299 "set port setup on (iterator|event)\n"
300 " Select how attached port is retrieved for setup.\n\n"
302 "set tx loopback (port_id) (on|off)\n"
303 " Enable or disable tx loopback.\n\n"
305 "set all queues drop (port_id) (on|off)\n"
306 " Set drop enable bit for all queues.\n\n"
308 "set vf split drop (port_id) (vf_id) (on|off)\n"
309 " Set split drop enable bit for a VF from the PF.\n\n"
311 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
312 " Set MAC antispoof for a VF from the PF.\n\n"
314 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
315 " Enable MACsec offload.\n\n"
317 "set macsec offload (port_id) off\n"
318 " Disable MACsec offload.\n\n"
320 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
321 " Configure MACsec secure connection (SC).\n\n"
323 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
324 " Configure MACsec secure association (SA).\n\n"
326 "set vf broadcast (port_id) (vf_id) (on|off)\n"
327 " Set VF broadcast for a VF from the PF.\n\n"
329 "vlan set stripq (on|off) (port_id,queue_id)\n"
330 " Set the VLAN strip for a queue on a port.\n\n"
332 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
333 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
335 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
336 " Set VLAN insert for a VF from the PF.\n\n"
338 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
339 " Set VLAN antispoof for a VF from the PF.\n\n"
341 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
342 " Set VLAN tag for a VF from the PF.\n\n"
344 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
345 " Set a VF's max bandwidth(Mbps).\n\n"
347 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
348 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
350 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
351 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
353 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
354 " Set some TCs' strict link priority mode on a physical port.\n\n"
356 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
357 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
359 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
360 " Set the VLAN strip or filter or qinq strip or extend\n\n"
362 "vlan set (inner|outer) tpid (value) (port_id)\n"
363 " Set the VLAN TPID for Packet Filtering on"
366 "rx_vlan add (vlan_id|all) (port_id)\n"
367 " Add a vlan_id, or all identifiers, to the set"
368 " of VLAN identifiers filtered by port_id.\n\n"
370 "rx_vlan rm (vlan_id|all) (port_id)\n"
371 " Remove a vlan_id, or all identifiers, from the set"
372 " of VLAN identifiers filtered by port_id.\n\n"
374 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
375 " Add a vlan_id, to the set of VLAN identifiers"
376 "filtered for VF(s) from port_id.\n\n"
378 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
379 " Remove a vlan_id, to the set of VLAN identifiers"
380 "filtered for VF(s) from port_id.\n\n"
382 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
383 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
384 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
385 " add a tunnel filter of a port.\n\n"
387 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
388 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
389 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
390 " remove a tunnel filter of a port.\n\n"
392 "rx_vxlan_port add (udp_port) (port_id)\n"
393 " Add an UDP port for VXLAN packet filter on a port\n\n"
395 "rx_vxlan_port rm (udp_port) (port_id)\n"
396 " Remove an UDP port for VXLAN packet filter on a port\n\n"
398 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
399 " Set hardware insertion of VLAN IDs (single or double VLAN "
400 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
402 "tx_vlan set pvid port_id vlan_id (on|off)\n"
403 " Set port based TX VLAN insertion.\n\n"
405 "tx_vlan reset (port_id)\n"
406 " Disable hardware insertion of a VLAN header in"
407 " packets sent on a port.\n\n"
409 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
410 " Select hardware or software calculation of the"
411 " checksum when transmitting a packet using the"
412 " csum forward engine.\n"
413 " ip|udp|tcp|sctp always concern the inner layer.\n"
414 " outer-ip concerns the outer IP layer in"
415 " outer-udp concerns the outer UDP layer in"
416 " case the packet is recognized as a tunnel packet by"
417 " the forward engine (vxlan, gre and ipip are supported)\n"
418 " Please check the NIC datasheet for HW limits.\n\n"
420 "csum parse-tunnel (on|off) (tx_port_id)\n"
421 " If disabled, treat tunnel packets as non-tunneled"
422 " packets (treat inner headers as payload). The port\n"
423 " argument is the port used for TX in csum forward"
426 "csum show (port_id)\n"
427 " Display tx checksum offload configuration\n\n"
429 "tso set (segsize) (portid)\n"
430 " Enable TCP Segmentation Offload in csum forward"
432 " Please check the NIC datasheet for HW limits.\n\n"
435 " Display the status of TCP Segmentation Offload.\n\n"
437 "set port (port_id) gro on|off\n"
438 " Enable or disable Generic Receive Offload in"
439 " csum forwarding engine.\n\n"
441 "show port (port_id) gro\n"
442 " Display GRO configuration.\n\n"
444 "set gro flush (cycles)\n"
445 " Set the cycle to flush GROed packets from"
446 " reassembly tables.\n\n"
448 "set port (port_id) gso (on|off)"
449 " Enable or disable Generic Segmentation Offload in"
450 " csum forwarding engine.\n\n"
452 "set gso segsz (length)\n"
453 " Set max packet length for output GSO segments,"
454 " including packet header and payload.\n\n"
456 "show port (port_id) gso\n"
457 " Show GSO configuration.\n\n"
460 " Set packet forwarding mode.\n\n"
462 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
463 " Add a MAC address on port_id.\n\n"
465 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
466 " Remove a MAC address from port_id.\n\n"
468 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
469 " Set the default MAC address for port_id.\n\n"
471 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
472 " Add a MAC address for a VF on the port.\n\n"
474 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
475 " Set the MAC address for a VF from the PF.\n\n"
477 "set eth-peer (port_id) (peer_addr)\n"
478 " set the peer address for certain port.\n\n"
480 "set port (port_id) uta (mac_address|all) (on|off)\n"
481 " Add/Remove a or all unicast hash filter(s)"
484 "set promisc (port_id|all) (on|off)\n"
485 " Set the promiscuous mode on port_id, or all.\n\n"
487 "set allmulti (port_id|all) (on|off)\n"
488 " Set the allmulti mode on port_id, or all.\n\n"
490 "set vf promisc (port_id) (vf_id) (on|off)\n"
491 " Set unicast promiscuous mode for a VF from the PF.\n\n"
493 "set vf allmulti (port_id) (vf_id) (on|off)\n"
494 " Set multicast promiscuous mode for a VF from the PF.\n\n"
496 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
497 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
498 " (on|off) autoneg (on|off) (port_id)\n"
499 "set flow_ctrl rx (on|off) (portid)\n"
500 "set flow_ctrl tx (on|off) (portid)\n"
501 "set flow_ctrl high_water (high_water) (portid)\n"
502 "set flow_ctrl low_water (low_water) (portid)\n"
503 "set flow_ctrl pause_time (pause_time) (portid)\n"
504 "set flow_ctrl send_xon (send_xon) (portid)\n"
505 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
506 "set flow_ctrl autoneg (on|off) (port_id)\n"
507 " Set the link flow control parameter on a port.\n\n"
509 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
510 " (low_water) (pause_time) (priority) (port_id)\n"
511 " Set the priority flow control parameter on a"
514 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
515 " Set statistics mapping (qmapping 0..15) for RX/TX"
517 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
518 " on port 0 to mapping 5.\n\n"
520 "set xstats-hide-zero on|off\n"
521 " Set the option to hide the zero values"
522 " for xstats display.\n"
524 "set port (port_id) vf (vf_id) rx|tx on|off\n"
525 " Enable/Disable a VF receive/tranmit from a port\n\n"
527 "set port (port_id) vf (vf_id) (mac_addr)"
528 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
529 " Add/Remove unicast or multicast MAC addr filter"
532 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
534 " AUPE:accepts untagged VLAN;"
535 "ROPE:accept unicast hash\n\n"
536 " BAM:accepts broadcast packets;"
537 "MPE:accepts all multicast packets\n\n"
538 " Enable/Disable a VF receive mode of a port\n\n"
540 "set port (port_id) queue (queue_id) rate (rate_num)\n"
541 " Set rate limit for a queue of a port\n\n"
543 "set port (port_id) vf (vf_id) rate (rate_num) "
544 "queue_mask (queue_mask_value)\n"
545 " Set rate limit for queues in VF of a port\n\n"
547 "set port (port_id) mirror-rule (rule_id)"
548 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
549 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
550 " Set pool or vlan type mirror rule on a port.\n"
551 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
552 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
555 "set port (port_id) mirror-rule (rule_id)"
556 " (uplink-mirror|downlink-mirror) dst-pool"
557 " (pool_id) (on|off)\n"
558 " Set uplink or downlink type mirror rule on a port.\n"
559 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
560 " 0 on' enable mirror income traffic to pool 0.\n\n"
562 "reset port (port_id) mirror-rule (rule_id)\n"
563 " Reset a mirror rule.\n\n"
565 "set flush_rx (on|off)\n"
566 " Flush (default) or don't flush RX streams before"
567 " forwarding. Mainly used with PCAP drivers.\n\n"
569 "set bypass mode (normal|bypass|isolate) (port_id)\n"
570 " Set the bypass mode for the lowest port on bypass enabled"
573 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
574 "mode (normal|bypass|isolate) (port_id)\n"
575 " Set the event required to initiate specified bypass mode for"
576 " the lowest port on a bypass enabled NIC where:\n"
577 " timeout = enable bypass after watchdog timeout.\n"
578 " os_on = enable bypass when OS/board is powered on.\n"
579 " os_off = enable bypass when OS/board is powered off.\n"
580 " power_on = enable bypass when power supply is turned on.\n"
581 " power_off = enable bypass when power supply is turned off."
584 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
585 " Set the bypass watchdog timeout to 'n' seconds"
586 " where 0 = instant.\n\n"
588 "show bypass config (port_id)\n"
589 " Show the bypass configuration for a bypass enabled NIC"
590 " using the lowest port on the NIC.\n\n"
592 #ifdef RTE_LIBRTE_PMD_BOND
593 "create bonded device (mode) (socket)\n"
594 " Create a new bonded device with specific bonding mode and socket.\n\n"
596 "add bonding slave (slave_id) (port_id)\n"
597 " Add a slave device to a bonded device.\n\n"
599 "remove bonding slave (slave_id) (port_id)\n"
600 " Remove a slave device from a bonded device.\n\n"
602 "set bonding mode (value) (port_id)\n"
603 " Set the bonding mode on a bonded device.\n\n"
605 "set bonding primary (slave_id) (port_id)\n"
606 " Set the primary slave for a bonded device.\n\n"
608 "show bonding config (port_id)\n"
609 " Show the bonding config for port_id.\n\n"
611 "set bonding mac_addr (port_id) (address)\n"
612 " Set the MAC address of a bonded device.\n\n"
614 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
615 " Set Aggregation mode for IEEE802.3AD (mode 4)"
617 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
618 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
620 "set bonding mon_period (port_id) (value)\n"
621 " Set the bonding link status monitoring polling period in ms.\n\n"
623 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
624 " Enable/disable dedicated queues for LACP control traffic.\n\n"
627 "set link-up port (port_id)\n"
628 " Set link up for a port.\n\n"
630 "set link-down port (port_id)\n"
631 " Set link down for a port.\n\n"
633 "E-tag set insertion on port-tag-id (value)"
634 " port (port_id) vf (vf_id)\n"
635 " Enable E-tag insertion for a VF on a port\n\n"
637 "E-tag set insertion off port (port_id) vf (vf_id)\n"
638 " Disable E-tag insertion for a VF on a port\n\n"
640 "E-tag set stripping (on|off) port (port_id)\n"
641 " Enable/disable E-tag stripping on a port\n\n"
643 "E-tag set forwarding (on|off) port (port_id)\n"
644 " Enable/disable E-tag based forwarding"
647 "E-tag set filter add e-tag-id (value) dst-pool"
648 " (pool_id) port (port_id)\n"
649 " Add an E-tag forwarding filter on a port\n\n"
651 "E-tag set filter del e-tag-id (value) port (port_id)\n"
652 " Delete an E-tag forwarding filter on a port\n\n"
654 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
655 " Load a profile package on a port\n\n"
657 "ddp del (port_id) (backup_profile_path)\n"
658 " Delete a profile package from a port\n\n"
660 "ptype mapping get (port_id) (valid_only)\n"
661 " Get ptype mapping on a port\n\n"
663 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
664 " Replace target with the pkt_type in ptype mapping\n\n"
666 "ptype mapping reset (port_id)\n"
667 " Reset ptype mapping on a port\n\n"
669 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
670 " Update a ptype mapping item on a port\n\n"
672 "set port (port_id) ptype_mask (ptype_mask)\n"
673 " set packet types classification for a specific port\n\n"
675 "set port (port_id) queue-region region_id (value) "
676 "queue_start_index (value) queue_num (value)\n"
677 " Set a queue region on a port\n\n"
679 "set port (port_id) queue-region region_id (value) "
681 " Set a flowtype region index on a port\n\n"
683 "set port (port_id) queue-region UP (value) region_id (value)\n"
684 " Set the mapping of User Priority to "
685 "queue region on a port\n\n"
687 "set port (port_id) queue-region flush (on|off)\n"
688 " flush all queue region related configuration\n\n"
690 "show port meter cap (port_id)\n"
691 " Show port meter capability information\n\n"
693 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
694 " meter profile add - srtcm rfc 2697\n\n"
696 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
697 " meter profile add - trtcm rfc 2698\n\n"
699 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
700 " meter profile add - trtcm rfc 4115\n\n"
702 "del port meter profile (port_id) (profile_id)\n"
703 " meter profile delete\n\n"
705 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
706 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
707 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
708 "(dscp_tbl_entry63)]\n"
711 "enable port meter (port_id) (mtr_id)\n"
714 "disable port meter (port_id) (mtr_id)\n"
717 "del port meter (port_id) (mtr_id)\n"
720 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
721 " meter update meter profile\n\n"
723 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
724 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
725 " update meter dscp table entries\n\n"
727 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
728 "(action0) [(action1) (action2)]\n"
729 " meter update policer action\n\n"
731 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
732 " meter update stats\n\n"
734 "show port (port_id) queue-region\n"
735 " show all queue region related configuration info\n\n"
737 , list_pkt_forwarding_modes()
741 if (show_all || !strcmp(res->section, "ports")) {
747 "----------------\n\n"
749 "port start (port_id|all)\n"
750 " Start all ports or port_id.\n\n"
752 "port stop (port_id|all)\n"
753 " Stop all ports or port_id.\n\n"
755 "port close (port_id|all)\n"
756 " Close all ports or port_id.\n\n"
758 "port reset (port_id|all)\n"
759 " Reset all ports or port_id.\n\n"
761 "port attach (ident)\n"
762 " Attach physical or virtual dev by pci address or virtual device name\n\n"
764 "port detach (port_id)\n"
765 " Detach physical or virtual dev by port_id\n\n"
767 "port config (port_id|all)"
768 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
769 " duplex (half|full|auto)\n"
770 " Set speed and duplex for all ports or port_id\n\n"
772 "port config (port_id|all) loopback (mode)\n"
773 " Set loopback mode for all ports or port_id\n\n"
775 "port config all (rxq|txq|rxd|txd) (value)\n"
776 " Set number for rxq/txq/rxd/txd.\n\n"
778 "port config all max-pkt-len (value)\n"
779 " Set the max packet length.\n\n"
781 "port config all max-lro-pkt-size (value)\n"
782 " Set the max LRO aggregated packet size.\n\n"
784 "port config all drop-en (on|off)\n"
785 " Enable or disable packet drop on all RX queues of all ports when no "
786 "receive buffers available.\n\n"
788 "port config all rss (all|default|ip|tcp|udp|sctp|"
789 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
790 " Set the RSS mode.\n\n"
792 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
793 " Set the RSS redirection table.\n\n"
795 "port config (port_id) dcb vt (on|off) (traffic_class)"
797 " Set the DCB mode.\n\n"
799 "port config all burst (value)\n"
800 " Set the number of packets per burst.\n\n"
802 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
804 " Set the ring prefetch/host/writeback threshold"
805 " for tx/rx queue.\n\n"
807 "port config all (txfreet|txrst|rxfreet) (value)\n"
808 " Set free threshold for rx/tx, or set"
809 " tx rs bit threshold.\n\n"
810 "port config mtu X value\n"
811 " Set the MTU of port X to a given value\n\n"
813 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
814 " Set a rx/tx queue's ring size configuration, the new"
815 " value will take effect after command that (re-)start the port"
816 " or command that setup the specific queue\n\n"
818 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
819 " Start/stop a rx/tx queue of port X. Only take effect"
820 " when port X is started\n\n"
822 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
823 " Switch on/off a deferred start of port X rx/tx queue. Only"
824 " take effect when port X is stopped.\n\n"
826 "port (port_id) (rxq|txq) (queue_id) setup\n"
827 " Setup a rx/tx queue of port X.\n\n"
829 "port config (port_id|all) l2-tunnel E-tag ether-type"
831 " Set the value of E-tag ether-type.\n\n"
833 "port config (port_id|all) l2-tunnel E-tag"
834 " (enable|disable)\n"
835 " Enable/disable the E-tag support.\n\n"
837 "port config (port_id) pctype mapping reset\n"
838 " Reset flow type to pctype mapping on a port\n\n"
840 "port config (port_id) pctype mapping update"
841 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
842 " Update a flow type to pctype mapping item on a port\n\n"
844 "port config (port_id) pctype (pctype_id) hash_inset|"
845 "fdir_inset|fdir_flx_inset get|set|clear field\n"
847 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
849 "port config (port_id) pctype (pctype_id) hash_inset|"
850 "fdir_inset|fdir_flx_inset clear all"
851 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
853 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
854 " Add/remove UDP tunnel port for tunneling offload\n\n"
856 "port config <port_id> rx_offload vlan_strip|"
857 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
858 "outer_ipv4_cksum|macsec_strip|header_split|"
859 "vlan_filter|vlan_extend|jumbo_frame|"
860 "scatter|timestamp|security|keep_crc on|off\n"
861 " Enable or disable a per port Rx offloading"
862 " on all Rx queues of a port\n\n"
864 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
865 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
866 "outer_ipv4_cksum|macsec_strip|header_split|"
867 "vlan_filter|vlan_extend|jumbo_frame|"
868 "scatter|timestamp|security|keep_crc on|off\n"
869 " Enable or disable a per queue Rx offloading"
870 " only on a specific Rx queue\n\n"
872 "port config (port_id) tx_offload vlan_insert|"
873 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
874 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
875 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
876 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
878 " Enable or disable a per port Tx offloading"
879 " on all Tx queues of a port\n\n"
881 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
882 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
883 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
884 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
885 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
887 " Enable or disable a per queue Tx offloading"
888 " only on a specific Tx queue\n\n"
890 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
891 " Load an eBPF program as a callback"
892 " for particular RX/TX queue\n\n"
894 "bpf-unload rx|tx (port) (queue)\n"
895 " Unload previously loaded eBPF program"
896 " for particular RX/TX queue\n\n"
898 "port config (port_id) tx_metadata (value)\n"
899 " Set Tx metadata value per port. Testpmd will add this value"
900 " to any Tx packet sent from this port\n\n"
904 if (show_all || !strcmp(res->section, "registers")) {
912 "read reg (port_id) (address)\n"
913 " Display value of a port register.\n\n"
915 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
916 " Display a port register bit field.\n\n"
918 "read regbit (port_id) (address) (bit_x)\n"
919 " Display a single port register bit.\n\n"
921 "write reg (port_id) (address) (value)\n"
922 " Set value of a port register.\n\n"
924 "write regfield (port_id) (address) (bit_x) (bit_y)"
926 " Set bit field of a port register.\n\n"
928 "write regbit (port_id) (address) (bit_x) (value)\n"
929 " Set single bit value of a port register.\n\n"
932 if (show_all || !strcmp(res->section, "filters")) {
940 "ethertype_filter (port_id) (add|del)"
941 " (mac_addr|mac_ignr) (mac_address) ethertype"
942 " (ether_type) (drop|fwd) queue (queue_id)\n"
943 " Add/Del an ethertype filter.\n\n"
945 "2tuple_filter (port_id) (add|del)"
946 " dst_port (dst_port_value) protocol (protocol_value)"
947 " mask (mask_value) tcp_flags (tcp_flags_value)"
948 " priority (prio_value) queue (queue_id)\n"
949 " Add/Del a 2tuple filter.\n\n"
951 "5tuple_filter (port_id) (add|del)"
952 " dst_ip (dst_address) src_ip (src_address)"
953 " dst_port (dst_port_value) src_port (src_port_value)"
954 " protocol (protocol_value)"
955 " mask (mask_value) tcp_flags (tcp_flags_value)"
956 " priority (prio_value) queue (queue_id)\n"
957 " Add/Del a 5tuple filter.\n\n"
959 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
960 " Add/Del syn filter.\n\n"
962 "flex_filter (port_id) (add|del) len (len_value)"
963 " bytes (bytes_value) mask (mask_value)"
964 " priority (prio_value) queue (queue_id)\n"
965 " Add/Del a flex filter.\n\n"
967 "flow_director_filter (port_id) mode IP (add|del|update)"
968 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
969 " src (src_ip_address) dst (dst_ip_address)"
970 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
971 " vlan (vlan_value) flexbytes (flexbytes_value)"
972 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
973 " fd_id (fd_id_value)\n"
974 " Add/Del an IP type flow director filter.\n\n"
976 "flow_director_filter (port_id) mode IP (add|del|update)"
977 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
978 " src (src_ip_address) (src_port)"
979 " dst (dst_ip_address) (dst_port)"
980 " tos (tos_value) ttl (ttl_value)"
981 " vlan (vlan_value) flexbytes (flexbytes_value)"
982 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
983 " fd_id (fd_id_value)\n"
984 " Add/Del an UDP/TCP type flow director filter.\n\n"
986 "flow_director_filter (port_id) mode IP (add|del|update)"
987 " flow (ipv4-sctp|ipv6-sctp)"
988 " src (src_ip_address) (src_port)"
989 " dst (dst_ip_address) (dst_port)"
990 " tag (verification_tag) "
991 " tos (tos_value) ttl (ttl_value)"
993 " flexbytes (flexbytes_value) (drop|fwd)"
994 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
995 " Add/Del a SCTP type flow director filter.\n\n"
997 "flow_director_filter (port_id) mode IP (add|del|update)"
998 " flow l2_payload ether (ethertype)"
999 " flexbytes (flexbytes_value) (drop|fwd)"
1000 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1001 " Add/Del a l2 payload type flow director filter.\n\n"
1003 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1004 " mac (mac_address) vlan (vlan_value)"
1005 " flexbytes (flexbytes_value) (drop|fwd)"
1006 " queue (queue_id) fd_id (fd_id_value)\n"
1007 " Add/Del a MAC-VLAN flow director filter.\n\n"
1009 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1010 " mac (mac_address) vlan (vlan_value)"
1011 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1012 " flexbytes (flexbytes_value) (drop|fwd)"
1013 " queue (queue_id) fd_id (fd_id_value)\n"
1014 " Add/Del a Tunnel flow director filter.\n\n"
1016 "flow_director_filter (port_id) mode raw (add|del|update)"
1017 " flow (flow_id) (drop|fwd) queue (queue_id)"
1018 " fd_id (fd_id_value) packet (packet file name)\n"
1019 " Add/Del a raw type flow director filter.\n\n"
1021 "flush_flow_director (port_id)\n"
1022 " Flush all flow director entries of a device.\n\n"
1024 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1025 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1026 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1027 " Set flow director IP mask.\n\n"
1029 "flow_director_mask (port_id) mode MAC-VLAN"
1030 " vlan (vlan_value)\n"
1031 " Set flow director MAC-VLAN mask.\n\n"
1033 "flow_director_mask (port_id) mode Tunnel"
1034 " vlan (vlan_value) mac (mac_value)"
1035 " tunnel-type (tunnel_type_value)"
1036 " tunnel-id (tunnel_id_value)\n"
1037 " Set flow director Tunnel mask.\n\n"
1039 "flow_director_flex_mask (port_id)"
1040 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1041 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1043 " Configure mask of flex payload.\n\n"
1045 "flow_director_flex_payload (port_id)"
1046 " (raw|l2|l3|l4) (config)\n"
1047 " Configure flex payload selection.\n\n"
1049 "get_sym_hash_ena_per_port (port_id)\n"
1050 " get symmetric hash enable configuration per port.\n\n"
1052 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1053 " set symmetric hash enable configuration per port"
1054 " to enable or disable.\n\n"
1056 "get_hash_global_config (port_id)\n"
1057 " Get the global configurations of hash filters.\n\n"
1059 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1060 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1061 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1062 " (enable|disable)\n"
1063 " Set the global configurations of hash filters.\n\n"
1065 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1066 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1067 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1068 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1069 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1070 "ipv6-next-header|udp-src-port|udp-dst-port|"
1071 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1072 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1073 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1074 "fld-8th|none) (select|add)\n"
1075 " Set the input set for hash.\n\n"
1077 "set_fdir_input_set (port_id) "
1078 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1079 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1080 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1081 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1082 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1083 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1084 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1086 " Set the input set for FDir.\n\n"
1088 "flow validate {port_id}"
1089 " [group {group_id}] [priority {level}]"
1090 " [ingress] [egress]"
1091 " pattern {item} [/ {item} [...]] / end"
1092 " actions {action} [/ {action} [...]] / end\n"
1093 " Check whether a flow rule can be created.\n\n"
1095 "flow create {port_id}"
1096 " [group {group_id}] [priority {level}]"
1097 " [ingress] [egress]"
1098 " pattern {item} [/ {item} [...]] / end"
1099 " actions {action} [/ {action} [...]] / end\n"
1100 " Create a flow rule.\n\n"
1102 "flow destroy {port_id} rule {rule_id} [...]\n"
1103 " Destroy specific flow rules.\n\n"
1105 "flow flush {port_id}\n"
1106 " Destroy all flow rules.\n\n"
1108 "flow query {port_id} {rule_id} {action}\n"
1109 " Query an existing flow rule.\n\n"
1111 "flow list {port_id} [group {group_id}] [...]\n"
1112 " List existing flow rules sorted by priority,"
1113 " filtered by group identifiers.\n\n"
1115 "flow isolate {port_id} {boolean}\n"
1116 " Restrict ingress traffic to the defined"
1119 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1120 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1121 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1122 " Configure the VXLAN encapsulation for flows.\n\n"
1124 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1125 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1126 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1127 " eth-dst (eth-dst)\n"
1128 " Configure the VXLAN encapsulation for flows.\n\n"
1130 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1131 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1132 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1133 " eth-dst (eth-dst)\n"
1134 " Configure the VXLAN encapsulation for flows.\n\n"
1136 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1137 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1139 " Configure the NVGRE encapsulation for flows.\n\n"
1141 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1142 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1143 " eth-src (eth-src) eth-dst (eth-dst)\n"
1144 " Configure the NVGRE encapsulation for flows.\n\n"
1146 "set raw_encap {flow items}\n"
1147 " Configure the encapsulation with raw data.\n\n"
1149 "set raw_decap {flow items}\n"
1150 " Configure the decapsulation with raw data.\n\n"
1155 if (show_all || !strcmp(res->section, "traffic_management")) {
1159 "Traffic Management:\n"
1161 "show port tm cap (port_id)\n"
1162 " Display the port TM capability.\n\n"
1164 "show port tm level cap (port_id) (level_id)\n"
1165 " Display the port TM hierarchical level capability.\n\n"
1167 "show port tm node cap (port_id) (node_id)\n"
1168 " Display the port TM node capability.\n\n"
1170 "show port tm node type (port_id) (node_id)\n"
1171 " Display the port TM node type.\n\n"
1173 "show port tm node stats (port_id) (node_id) (clear)\n"
1174 " Display the port TM node stats.\n\n"
1176 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1177 "set port tm hierarchy default (port_id)\n"
1178 " Set default traffic Management hierarchy on a port\n\n"
1181 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1182 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1183 " (packet_length_adjust)\n"
1184 " Add port tm node private shaper profile.\n\n"
1186 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1187 " Delete port tm node private shaper profile.\n\n"
1189 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1190 " (shaper_profile_id)\n"
1191 " Add/update port tm node shared shaper.\n\n"
1193 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1194 " Delete port tm node shared shaper.\n\n"
1196 "set port tm node shaper profile (port_id) (node_id)"
1197 " (shaper_profile_id)\n"
1198 " Set port tm node shaper profile.\n\n"
1200 "add port tm node wred profile (port_id) (wred_profile_id)"
1201 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1202 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1203 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1204 " Add port tm node wred profile.\n\n"
1206 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1207 " Delete port tm node wred profile.\n\n"
1209 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1210 " (priority) (weight) (level_id) (shaper_profile_id)"
1211 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1212 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1213 " Add port tm nonleaf node.\n\n"
1215 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1216 " (priority) (weight) (level_id) (shaper_profile_id)"
1217 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1218 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1219 " Add port tm leaf node.\n\n"
1221 "del port tm node (port_id) (node_id)\n"
1222 " Delete port tm node.\n\n"
1224 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1225 " (priority) (weight)\n"
1226 " Set port tm node parent.\n\n"
1228 "suspend port tm node (port_id) (node_id)"
1229 " Suspend tm node.\n\n"
1231 "resume port tm node (port_id) (node_id)"
1232 " Resume tm node.\n\n"
1234 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1235 " Commit tm hierarchy.\n\n"
1237 "set port tm mark ip_ecn (port) (green) (yellow)"
1239 " Enables/Disables the traffic management marking"
1240 " for IP ECN (Explicit Congestion Notification)"
1241 " packets on a given port\n\n"
1243 "set port tm mark ip_dscp (port) (green) (yellow)"
1245 " Enables/Disables the traffic management marking"
1246 " on the port for IP dscp packets\n\n"
1248 "set port tm mark vlan_dei (port) (green) (yellow)"
1250 " Enables/Disables the traffic management marking"
1251 " on the port for VLAN packets with DEI enabled\n\n"
1255 if (show_all || !strcmp(res->section, "devices")) {
1259 "Device Operations:\n"
1261 "device detach (identifier)\n"
1262 " Detach device by identifier.\n\n"
1268 cmdline_parse_token_string_t cmd_help_long_help =
1269 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1271 cmdline_parse_token_string_t cmd_help_long_section =
1272 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1273 "all#control#display#config#"
1274 "ports#registers#filters#traffic_management#devices");
1276 cmdline_parse_inst_t cmd_help_long = {
1277 .f = cmd_help_long_parsed,
1279 .help_str = "help all|control|display|config|ports|register|"
1280 "filters|traffic_management|devices: "
1283 (void *)&cmd_help_long_help,
1284 (void *)&cmd_help_long_section,
1290 /* *** start/stop/close all ports *** */
1291 struct cmd_operate_port_result {
1292 cmdline_fixed_string_t keyword;
1293 cmdline_fixed_string_t name;
1294 cmdline_fixed_string_t value;
1297 static void cmd_operate_port_parsed(void *parsed_result,
1298 __attribute__((unused)) struct cmdline *cl,
1299 __attribute__((unused)) void *data)
1301 struct cmd_operate_port_result *res = parsed_result;
1303 if (!strcmp(res->name, "start"))
1304 start_port(RTE_PORT_ALL);
1305 else if (!strcmp(res->name, "stop"))
1306 stop_port(RTE_PORT_ALL);
1307 else if (!strcmp(res->name, "close"))
1308 close_port(RTE_PORT_ALL);
1309 else if (!strcmp(res->name, "reset"))
1310 reset_port(RTE_PORT_ALL);
1312 printf("Unknown parameter\n");
1315 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1316 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1318 cmdline_parse_token_string_t cmd_operate_port_all_port =
1319 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1320 "start#stop#close#reset");
1321 cmdline_parse_token_string_t cmd_operate_port_all_all =
1322 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1324 cmdline_parse_inst_t cmd_operate_port = {
1325 .f = cmd_operate_port_parsed,
1327 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1329 (void *)&cmd_operate_port_all_cmd,
1330 (void *)&cmd_operate_port_all_port,
1331 (void *)&cmd_operate_port_all_all,
1336 /* *** start/stop/close specific port *** */
1337 struct cmd_operate_specific_port_result {
1338 cmdline_fixed_string_t keyword;
1339 cmdline_fixed_string_t name;
1343 static void cmd_operate_specific_port_parsed(void *parsed_result,
1344 __attribute__((unused)) struct cmdline *cl,
1345 __attribute__((unused)) void *data)
1347 struct cmd_operate_specific_port_result *res = parsed_result;
1349 if (!strcmp(res->name, "start"))
1350 start_port(res->value);
1351 else if (!strcmp(res->name, "stop"))
1352 stop_port(res->value);
1353 else if (!strcmp(res->name, "close"))
1354 close_port(res->value);
1355 else if (!strcmp(res->name, "reset"))
1356 reset_port(res->value);
1358 printf("Unknown parameter\n");
1361 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1362 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1364 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1365 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1366 name, "start#stop#close#reset");
1367 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1368 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1371 cmdline_parse_inst_t cmd_operate_specific_port = {
1372 .f = cmd_operate_specific_port_parsed,
1374 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1376 (void *)&cmd_operate_specific_port_cmd,
1377 (void *)&cmd_operate_specific_port_port,
1378 (void *)&cmd_operate_specific_port_id,
1383 /* *** enable port setup (after attach) via iterator or event *** */
1384 struct cmd_set_port_setup_on_result {
1385 cmdline_fixed_string_t set;
1386 cmdline_fixed_string_t port;
1387 cmdline_fixed_string_t setup;
1388 cmdline_fixed_string_t on;
1389 cmdline_fixed_string_t mode;
1392 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1393 __attribute__((unused)) struct cmdline *cl,
1394 __attribute__((unused)) void *data)
1396 struct cmd_set_port_setup_on_result *res = parsed_result;
1398 if (strcmp(res->mode, "event") == 0)
1399 setup_on_probe_event = true;
1400 else if (strcmp(res->mode, "iterator") == 0)
1401 setup_on_probe_event = false;
1403 printf("Unknown mode\n");
1406 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1407 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1409 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1410 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1412 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1413 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1419 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1420 mode, "iterator#event");
1422 cmdline_parse_inst_t cmd_set_port_setup_on = {
1423 .f = cmd_set_port_setup_on_parsed,
1425 .help_str = "set port setup on iterator|event",
1427 (void *)&cmd_set_port_setup_on_set,
1428 (void *)&cmd_set_port_setup_on_port,
1429 (void *)&cmd_set_port_setup_on_setup,
1430 (void *)&cmd_set_port_setup_on_on,
1431 (void *)&cmd_set_port_setup_on_mode,
1436 /* *** attach a specified port *** */
1437 struct cmd_operate_attach_port_result {
1438 cmdline_fixed_string_t port;
1439 cmdline_fixed_string_t keyword;
1440 cmdline_fixed_string_t identifier;
1443 static void cmd_operate_attach_port_parsed(void *parsed_result,
1444 __attribute__((unused)) struct cmdline *cl,
1445 __attribute__((unused)) void *data)
1447 struct cmd_operate_attach_port_result *res = parsed_result;
1449 if (!strcmp(res->keyword, "attach"))
1450 attach_port(res->identifier);
1452 printf("Unknown parameter\n");
1455 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1456 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1458 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1459 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1461 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1462 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1465 cmdline_parse_inst_t cmd_operate_attach_port = {
1466 .f = cmd_operate_attach_port_parsed,
1468 .help_str = "port attach <identifier>: "
1469 "(identifier: pci address or virtual dev name)",
1471 (void *)&cmd_operate_attach_port_port,
1472 (void *)&cmd_operate_attach_port_keyword,
1473 (void *)&cmd_operate_attach_port_identifier,
1478 /* *** detach a specified port *** */
1479 struct cmd_operate_detach_port_result {
1480 cmdline_fixed_string_t port;
1481 cmdline_fixed_string_t keyword;
1485 static void cmd_operate_detach_port_parsed(void *parsed_result,
1486 __attribute__((unused)) struct cmdline *cl,
1487 __attribute__((unused)) void *data)
1489 struct cmd_operate_detach_port_result *res = parsed_result;
1491 if (!strcmp(res->keyword, "detach"))
1492 detach_port_device(res->port_id);
1494 printf("Unknown parameter\n");
1497 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1498 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1500 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1501 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1503 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1504 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1507 cmdline_parse_inst_t cmd_operate_detach_port = {
1508 .f = cmd_operate_detach_port_parsed,
1510 .help_str = "port detach <port_id>",
1512 (void *)&cmd_operate_detach_port_port,
1513 (void *)&cmd_operate_detach_port_keyword,
1514 (void *)&cmd_operate_detach_port_port_id,
1519 /* *** detach device by identifier *** */
1520 struct cmd_operate_detach_device_result {
1521 cmdline_fixed_string_t device;
1522 cmdline_fixed_string_t keyword;
1523 cmdline_fixed_string_t identifier;
1526 static void cmd_operate_detach_device_parsed(void *parsed_result,
1527 __attribute__((unused)) struct cmdline *cl,
1528 __attribute__((unused)) void *data)
1530 struct cmd_operate_detach_device_result *res = parsed_result;
1532 if (!strcmp(res->keyword, "detach"))
1533 detach_device(res->identifier);
1535 printf("Unknown parameter\n");
1538 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1539 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1541 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1542 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1544 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1545 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1548 cmdline_parse_inst_t cmd_operate_detach_device = {
1549 .f = cmd_operate_detach_device_parsed,
1551 .help_str = "device detach <identifier>:"
1552 "(identifier: pci address or virtual dev name)",
1554 (void *)&cmd_operate_detach_device_device,
1555 (void *)&cmd_operate_detach_device_keyword,
1556 (void *)&cmd_operate_detach_device_identifier,
1560 /* *** configure speed for all ports *** */
1561 struct cmd_config_speed_all {
1562 cmdline_fixed_string_t port;
1563 cmdline_fixed_string_t keyword;
1564 cmdline_fixed_string_t all;
1565 cmdline_fixed_string_t item1;
1566 cmdline_fixed_string_t item2;
1567 cmdline_fixed_string_t value1;
1568 cmdline_fixed_string_t value2;
1572 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1577 if (!strcmp(duplexstr, "half")) {
1578 duplex = ETH_LINK_HALF_DUPLEX;
1579 } else if (!strcmp(duplexstr, "full")) {
1580 duplex = ETH_LINK_FULL_DUPLEX;
1581 } else if (!strcmp(duplexstr, "auto")) {
1582 duplex = ETH_LINK_FULL_DUPLEX;
1584 printf("Unknown duplex parameter\n");
1588 if (!strcmp(speedstr, "10")) {
1589 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1590 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1591 } else if (!strcmp(speedstr, "100")) {
1592 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1593 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1595 if (duplex != ETH_LINK_FULL_DUPLEX) {
1596 printf("Invalid speed/duplex parameters\n");
1599 if (!strcmp(speedstr, "1000")) {
1600 *speed = ETH_LINK_SPEED_1G;
1601 } else if (!strcmp(speedstr, "10000")) {
1602 *speed = ETH_LINK_SPEED_10G;
1603 } else if (!strcmp(speedstr, "25000")) {
1604 *speed = ETH_LINK_SPEED_25G;
1605 } else if (!strcmp(speedstr, "40000")) {
1606 *speed = ETH_LINK_SPEED_40G;
1607 } else if (!strcmp(speedstr, "50000")) {
1608 *speed = ETH_LINK_SPEED_50G;
1609 } else if (!strcmp(speedstr, "100000")) {
1610 *speed = ETH_LINK_SPEED_100G;
1611 } else if (!strcmp(speedstr, "auto")) {
1612 *speed = ETH_LINK_SPEED_AUTONEG;
1614 printf("Unknown speed parameter\n");
1623 cmd_config_speed_all_parsed(void *parsed_result,
1624 __attribute__((unused)) struct cmdline *cl,
1625 __attribute__((unused)) void *data)
1627 struct cmd_config_speed_all *res = parsed_result;
1628 uint32_t link_speed;
1631 if (!all_ports_stopped()) {
1632 printf("Please stop all ports first\n");
1636 if (parse_and_check_speed_duplex(res->value1, res->value2,
1640 RTE_ETH_FOREACH_DEV(pid) {
1641 ports[pid].dev_conf.link_speeds = link_speed;
1644 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1647 cmdline_parse_token_string_t cmd_config_speed_all_port =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1649 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1652 cmdline_parse_token_string_t cmd_config_speed_all_all =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1654 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1656 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1658 "10#100#1000#10000#25000#40000#50000#100000#auto");
1659 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1661 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1665 cmdline_parse_inst_t cmd_config_speed_all = {
1666 .f = cmd_config_speed_all_parsed,
1668 .help_str = "port config all speed "
1669 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1672 (void *)&cmd_config_speed_all_port,
1673 (void *)&cmd_config_speed_all_keyword,
1674 (void *)&cmd_config_speed_all_all,
1675 (void *)&cmd_config_speed_all_item1,
1676 (void *)&cmd_config_speed_all_value1,
1677 (void *)&cmd_config_speed_all_item2,
1678 (void *)&cmd_config_speed_all_value2,
1683 /* *** configure speed for specific port *** */
1684 struct cmd_config_speed_specific {
1685 cmdline_fixed_string_t port;
1686 cmdline_fixed_string_t keyword;
1688 cmdline_fixed_string_t item1;
1689 cmdline_fixed_string_t item2;
1690 cmdline_fixed_string_t value1;
1691 cmdline_fixed_string_t value2;
1695 cmd_config_speed_specific_parsed(void *parsed_result,
1696 __attribute__((unused)) struct cmdline *cl,
1697 __attribute__((unused)) void *data)
1699 struct cmd_config_speed_specific *res = parsed_result;
1700 uint32_t link_speed;
1702 if (!all_ports_stopped()) {
1703 printf("Please stop all ports first\n");
1707 if (port_id_is_invalid(res->id, ENABLED_WARN))
1710 if (parse_and_check_speed_duplex(res->value1, res->value2,
1714 ports[res->id].dev_conf.link_speeds = link_speed;
1716 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1720 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1723 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1724 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1726 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1727 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1728 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1729 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1731 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1733 "10#100#1000#10000#25000#40000#50000#100000#auto");
1734 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1737 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1741 cmdline_parse_inst_t cmd_config_speed_specific = {
1742 .f = cmd_config_speed_specific_parsed,
1744 .help_str = "port config <port_id> speed "
1745 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1748 (void *)&cmd_config_speed_specific_port,
1749 (void *)&cmd_config_speed_specific_keyword,
1750 (void *)&cmd_config_speed_specific_id,
1751 (void *)&cmd_config_speed_specific_item1,
1752 (void *)&cmd_config_speed_specific_value1,
1753 (void *)&cmd_config_speed_specific_item2,
1754 (void *)&cmd_config_speed_specific_value2,
1759 /* *** configure loopback for all ports *** */
1760 struct cmd_config_loopback_all {
1761 cmdline_fixed_string_t port;
1762 cmdline_fixed_string_t keyword;
1763 cmdline_fixed_string_t all;
1764 cmdline_fixed_string_t item;
1769 cmd_config_loopback_all_parsed(void *parsed_result,
1770 __attribute__((unused)) struct cmdline *cl,
1771 __attribute__((unused)) void *data)
1773 struct cmd_config_loopback_all *res = parsed_result;
1776 if (!all_ports_stopped()) {
1777 printf("Please stop all ports first\n");
1781 RTE_ETH_FOREACH_DEV(pid) {
1782 ports[pid].dev_conf.lpbk_mode = res->mode;
1785 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1788 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1790 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1793 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1795 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1796 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1798 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1799 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1801 cmdline_parse_inst_t cmd_config_loopback_all = {
1802 .f = cmd_config_loopback_all_parsed,
1804 .help_str = "port config all loopback <mode>",
1806 (void *)&cmd_config_loopback_all_port,
1807 (void *)&cmd_config_loopback_all_keyword,
1808 (void *)&cmd_config_loopback_all_all,
1809 (void *)&cmd_config_loopback_all_item,
1810 (void *)&cmd_config_loopback_all_mode,
1815 /* *** configure loopback for specific port *** */
1816 struct cmd_config_loopback_specific {
1817 cmdline_fixed_string_t port;
1818 cmdline_fixed_string_t keyword;
1820 cmdline_fixed_string_t item;
1825 cmd_config_loopback_specific_parsed(void *parsed_result,
1826 __attribute__((unused)) struct cmdline *cl,
1827 __attribute__((unused)) void *data)
1829 struct cmd_config_loopback_specific *res = parsed_result;
1831 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1834 if (!port_is_stopped(res->port_id)) {
1835 printf("Please stop port %u first\n", res->port_id);
1839 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1841 cmd_reconfig_device_queue(res->port_id, 1, 1);
1845 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1848 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1851 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1852 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1854 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1857 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1858 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1861 cmdline_parse_inst_t cmd_config_loopback_specific = {
1862 .f = cmd_config_loopback_specific_parsed,
1864 .help_str = "port config <port_id> loopback <mode>",
1866 (void *)&cmd_config_loopback_specific_port,
1867 (void *)&cmd_config_loopback_specific_keyword,
1868 (void *)&cmd_config_loopback_specific_id,
1869 (void *)&cmd_config_loopback_specific_item,
1870 (void *)&cmd_config_loopback_specific_mode,
1875 /* *** configure txq/rxq, txd/rxd *** */
1876 struct cmd_config_rx_tx {
1877 cmdline_fixed_string_t port;
1878 cmdline_fixed_string_t keyword;
1879 cmdline_fixed_string_t all;
1880 cmdline_fixed_string_t name;
1885 cmd_config_rx_tx_parsed(void *parsed_result,
1886 __attribute__((unused)) struct cmdline *cl,
1887 __attribute__((unused)) void *data)
1889 struct cmd_config_rx_tx *res = parsed_result;
1891 if (!all_ports_stopped()) {
1892 printf("Please stop all ports first\n");
1895 if (!strcmp(res->name, "rxq")) {
1896 if (!res->value && !nb_txq) {
1897 printf("Warning: Either rx or tx queues should be non zero\n");
1900 if (check_nb_rxq(res->value) != 0)
1902 nb_rxq = res->value;
1904 else if (!strcmp(res->name, "txq")) {
1905 if (!res->value && !nb_rxq) {
1906 printf("Warning: Either rx or tx queues should be non zero\n");
1909 if (check_nb_txq(res->value) != 0)
1911 nb_txq = res->value;
1913 else if (!strcmp(res->name, "rxd")) {
1914 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1915 printf("rxd %d invalid - must be > 0 && <= %d\n",
1916 res->value, RTE_TEST_RX_DESC_MAX);
1919 nb_rxd = res->value;
1920 } else if (!strcmp(res->name, "txd")) {
1921 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1922 printf("txd %d invalid - must be > 0 && <= %d\n",
1923 res->value, RTE_TEST_TX_DESC_MAX);
1926 nb_txd = res->value;
1928 printf("Unknown parameter\n");
1936 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1939 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1941 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1943 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1944 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1945 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1946 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1948 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1949 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1951 cmdline_parse_inst_t cmd_config_rx_tx = {
1952 .f = cmd_config_rx_tx_parsed,
1954 .help_str = "port config all rxq|txq|rxd|txd <value>",
1956 (void *)&cmd_config_rx_tx_port,
1957 (void *)&cmd_config_rx_tx_keyword,
1958 (void *)&cmd_config_rx_tx_all,
1959 (void *)&cmd_config_rx_tx_name,
1960 (void *)&cmd_config_rx_tx_value,
1965 /* *** config max packet length *** */
1966 struct cmd_config_max_pkt_len_result {
1967 cmdline_fixed_string_t port;
1968 cmdline_fixed_string_t keyword;
1969 cmdline_fixed_string_t all;
1970 cmdline_fixed_string_t name;
1975 cmd_config_max_pkt_len_parsed(void *parsed_result,
1976 __attribute__((unused)) struct cmdline *cl,
1977 __attribute__((unused)) void *data)
1979 struct cmd_config_max_pkt_len_result *res = parsed_result;
1982 if (!all_ports_stopped()) {
1983 printf("Please stop all ports first\n");
1987 RTE_ETH_FOREACH_DEV(pid) {
1988 struct rte_port *port = &ports[pid];
1989 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1991 if (!strcmp(res->name, "max-pkt-len")) {
1992 if (res->value < RTE_ETHER_MIN_LEN) {
1993 printf("max-pkt-len can not be less than %d\n",
1997 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2000 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2001 if (res->value > RTE_ETHER_MAX_LEN)
2002 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2004 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2005 port->dev_conf.rxmode.offloads = rx_offloads;
2007 printf("Unknown parameter\n");
2014 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2017 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2018 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2020 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2021 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2023 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2024 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2026 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2029 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2030 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2033 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2034 .f = cmd_config_max_pkt_len_parsed,
2036 .help_str = "port config all max-pkt-len <value>",
2038 (void *)&cmd_config_max_pkt_len_port,
2039 (void *)&cmd_config_max_pkt_len_keyword,
2040 (void *)&cmd_config_max_pkt_len_all,
2041 (void *)&cmd_config_max_pkt_len_name,
2042 (void *)&cmd_config_max_pkt_len_value,
2047 /* *** config max LRO aggregated packet size *** */
2048 struct cmd_config_max_lro_pkt_size_result {
2049 cmdline_fixed_string_t port;
2050 cmdline_fixed_string_t keyword;
2051 cmdline_fixed_string_t all;
2052 cmdline_fixed_string_t name;
2057 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2058 __attribute__((unused)) struct cmdline *cl,
2059 __attribute__((unused)) void *data)
2061 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2064 if (!all_ports_stopped()) {
2065 printf("Please stop all ports first\n");
2069 RTE_ETH_FOREACH_DEV(pid) {
2070 struct rte_port *port = &ports[pid];
2072 if (!strcmp(res->name, "max-lro-pkt-size")) {
2074 port->dev_conf.rxmode.max_lro_pkt_size)
2077 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2079 printf("Unknown parameter\n");
2086 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2089 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2090 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2092 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2093 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2095 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2096 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2098 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2099 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2100 name, "max-lro-pkt-size");
2101 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2102 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2105 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2106 .f = cmd_config_max_lro_pkt_size_parsed,
2108 .help_str = "port config all max-lro-pkt-size <value>",
2110 (void *)&cmd_config_max_lro_pkt_size_port,
2111 (void *)&cmd_config_max_lro_pkt_size_keyword,
2112 (void *)&cmd_config_max_lro_pkt_size_all,
2113 (void *)&cmd_config_max_lro_pkt_size_name,
2114 (void *)&cmd_config_max_lro_pkt_size_value,
2119 /* *** configure port MTU *** */
2120 struct cmd_config_mtu_result {
2121 cmdline_fixed_string_t port;
2122 cmdline_fixed_string_t keyword;
2123 cmdline_fixed_string_t mtu;
2129 cmd_config_mtu_parsed(void *parsed_result,
2130 __attribute__((unused)) struct cmdline *cl,
2131 __attribute__((unused)) void *data)
2133 struct cmd_config_mtu_result *res = parsed_result;
2135 if (res->value < RTE_ETHER_MIN_LEN) {
2136 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2139 port_mtu_set(res->port_id, res->value);
2142 cmdline_parse_token_string_t cmd_config_mtu_port =
2143 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2145 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2146 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2148 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2151 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2152 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2153 cmdline_parse_token_num_t cmd_config_mtu_value =
2154 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2156 cmdline_parse_inst_t cmd_config_mtu = {
2157 .f = cmd_config_mtu_parsed,
2159 .help_str = "port config mtu <port_id> <value>",
2161 (void *)&cmd_config_mtu_port,
2162 (void *)&cmd_config_mtu_keyword,
2163 (void *)&cmd_config_mtu_mtu,
2164 (void *)&cmd_config_mtu_port_id,
2165 (void *)&cmd_config_mtu_value,
2170 /* *** configure rx mode *** */
2171 struct cmd_config_rx_mode_flag {
2172 cmdline_fixed_string_t port;
2173 cmdline_fixed_string_t keyword;
2174 cmdline_fixed_string_t all;
2175 cmdline_fixed_string_t name;
2176 cmdline_fixed_string_t value;
2180 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2181 __attribute__((unused)) struct cmdline *cl,
2182 __attribute__((unused)) void *data)
2184 struct cmd_config_rx_mode_flag *res = parsed_result;
2186 if (!all_ports_stopped()) {
2187 printf("Please stop all ports first\n");
2191 if (!strcmp(res->name, "drop-en")) {
2192 if (!strcmp(res->value, "on"))
2194 else if (!strcmp(res->value, "off"))
2197 printf("Unknown parameter\n");
2201 printf("Unknown parameter\n");
2207 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2210 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2211 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2212 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2213 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2215 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2216 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2217 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2218 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2220 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2221 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2224 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2225 .f = cmd_config_rx_mode_flag_parsed,
2227 .help_str = "port config all drop-en on|off",
2229 (void *)&cmd_config_rx_mode_flag_port,
2230 (void *)&cmd_config_rx_mode_flag_keyword,
2231 (void *)&cmd_config_rx_mode_flag_all,
2232 (void *)&cmd_config_rx_mode_flag_name,
2233 (void *)&cmd_config_rx_mode_flag_value,
2238 /* *** configure rss *** */
2239 struct cmd_config_rss {
2240 cmdline_fixed_string_t port;
2241 cmdline_fixed_string_t keyword;
2242 cmdline_fixed_string_t all;
2243 cmdline_fixed_string_t name;
2244 cmdline_fixed_string_t value;
2248 cmd_config_rss_parsed(void *parsed_result,
2249 __attribute__((unused)) struct cmdline *cl,
2250 __attribute__((unused)) void *data)
2252 struct cmd_config_rss *res = parsed_result;
2253 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2254 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2255 int use_default = 0;
2256 int all_updated = 1;
2261 if (!strcmp(res->value, "all"))
2262 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2263 ETH_RSS_UDP | ETH_RSS_SCTP |
2265 else if (!strcmp(res->value, "ip"))
2266 rss_conf.rss_hf = ETH_RSS_IP;
2267 else if (!strcmp(res->value, "udp"))
2268 rss_conf.rss_hf = ETH_RSS_UDP;
2269 else if (!strcmp(res->value, "tcp"))
2270 rss_conf.rss_hf = ETH_RSS_TCP;
2271 else if (!strcmp(res->value, "sctp"))
2272 rss_conf.rss_hf = ETH_RSS_SCTP;
2273 else if (!strcmp(res->value, "ether"))
2274 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2275 else if (!strcmp(res->value, "port"))
2276 rss_conf.rss_hf = ETH_RSS_PORT;
2277 else if (!strcmp(res->value, "vxlan"))
2278 rss_conf.rss_hf = ETH_RSS_VXLAN;
2279 else if (!strcmp(res->value, "geneve"))
2280 rss_conf.rss_hf = ETH_RSS_GENEVE;
2281 else if (!strcmp(res->value, "nvgre"))
2282 rss_conf.rss_hf = ETH_RSS_NVGRE;
2283 else if (!strcmp(res->value, "l3-src-only"))
2284 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2285 else if (!strcmp(res->value, "l3-dst-only"))
2286 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2287 else if (!strcmp(res->value, "l4-src-only"))
2288 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2289 else if (!strcmp(res->value, "l4-dst-only"))
2290 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2291 else if (!strcmp(res->value, "none"))
2292 rss_conf.rss_hf = 0;
2293 else if (!strcmp(res->value, "default"))
2295 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2296 atoi(res->value) < 64)
2297 rss_conf.rss_hf = 1ULL << atoi(res->value);
2299 printf("Unknown parameter\n");
2302 rss_conf.rss_key = NULL;
2303 /* Update global configuration for RSS types. */
2304 RTE_ETH_FOREACH_DEV(i) {
2305 struct rte_eth_rss_conf local_rss_conf;
2307 ret = eth_dev_info_get_print_err(i, &dev_info);
2312 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2314 local_rss_conf = rss_conf;
2315 local_rss_conf.rss_hf = rss_conf.rss_hf &
2316 dev_info.flow_type_rss_offloads;
2317 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2318 printf("Port %u modified RSS hash function based on hardware support,"
2319 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2320 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2322 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2325 printf("Configuration of RSS hash at ethernet port %d "
2326 "failed with error (%d): %s.\n",
2327 i, -diag, strerror(-diag));
2330 if (all_updated && !use_default)
2331 rss_hf = rss_conf.rss_hf;
2334 cmdline_parse_token_string_t cmd_config_rss_port =
2335 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2336 cmdline_parse_token_string_t cmd_config_rss_keyword =
2337 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2338 cmdline_parse_token_string_t cmd_config_rss_all =
2339 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2340 cmdline_parse_token_string_t cmd_config_rss_name =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2342 cmdline_parse_token_string_t cmd_config_rss_value =
2343 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2345 cmdline_parse_inst_t cmd_config_rss = {
2346 .f = cmd_config_rss_parsed,
2348 .help_str = "port config all rss "
2349 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2351 (void *)&cmd_config_rss_port,
2352 (void *)&cmd_config_rss_keyword,
2353 (void *)&cmd_config_rss_all,
2354 (void *)&cmd_config_rss_name,
2355 (void *)&cmd_config_rss_value,
2360 /* *** configure rss hash key *** */
2361 struct cmd_config_rss_hash_key {
2362 cmdline_fixed_string_t port;
2363 cmdline_fixed_string_t config;
2365 cmdline_fixed_string_t rss_hash_key;
2366 cmdline_fixed_string_t rss_type;
2367 cmdline_fixed_string_t key;
2371 hexa_digit_to_value(char hexa_digit)
2373 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2374 return (uint8_t) (hexa_digit - '0');
2375 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2376 return (uint8_t) ((hexa_digit - 'a') + 10);
2377 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2378 return (uint8_t) ((hexa_digit - 'A') + 10);
2379 /* Invalid hexa digit */
2384 parse_and_check_key_hexa_digit(char *key, int idx)
2388 hexa_v = hexa_digit_to_value(key[idx]);
2390 printf("invalid key: character %c at position %d is not a "
2391 "valid hexa digit\n", key[idx], idx);
2396 cmd_config_rss_hash_key_parsed(void *parsed_result,
2397 __attribute__((unused)) struct cmdline *cl,
2398 __attribute__((unused)) void *data)
2400 struct cmd_config_rss_hash_key *res = parsed_result;
2401 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2405 struct rte_eth_dev_info dev_info;
2406 uint8_t hash_key_size;
2410 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2414 if (dev_info.hash_key_size > 0 &&
2415 dev_info.hash_key_size <= sizeof(hash_key))
2416 hash_key_size = dev_info.hash_key_size;
2418 printf("dev_info did not provide a valid hash key size\n");
2421 /* Check the length of the RSS hash key */
2422 key_len = strlen(res->key);
2423 if (key_len != (hash_key_size * 2)) {
2424 printf("key length: %d invalid - key must be a string of %d"
2425 " hexa-decimal numbers\n",
2426 (int) key_len, hash_key_size * 2);
2429 /* Translate RSS hash key into binary representation */
2430 for (i = 0; i < hash_key_size; i++) {
2431 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2434 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2437 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2439 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2443 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2444 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2445 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2446 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2448 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2449 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2450 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2451 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2452 rss_hash_key, "rss-hash-key");
2453 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2454 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2455 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2456 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2457 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2458 "ipv6-tcp-ex#ipv6-udp-ex#"
2459 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2460 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2461 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2463 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2464 .f = cmd_config_rss_hash_key_parsed,
2466 .help_str = "port config <port_id> rss-hash-key "
2467 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2468 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2469 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2470 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2471 "<string of hex digits (variable length, NIC dependent)>",
2473 (void *)&cmd_config_rss_hash_key_port,
2474 (void *)&cmd_config_rss_hash_key_config,
2475 (void *)&cmd_config_rss_hash_key_port_id,
2476 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2477 (void *)&cmd_config_rss_hash_key_rss_type,
2478 (void *)&cmd_config_rss_hash_key_value,
2483 /* *** configure port rxq/txq ring size *** */
2484 struct cmd_config_rxtx_ring_size {
2485 cmdline_fixed_string_t port;
2486 cmdline_fixed_string_t config;
2488 cmdline_fixed_string_t rxtxq;
2490 cmdline_fixed_string_t rsize;
2495 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2496 __attribute__((unused)) struct cmdline *cl,
2497 __attribute__((unused)) void *data)
2499 struct cmd_config_rxtx_ring_size *res = parsed_result;
2500 struct rte_port *port;
2503 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2506 if (res->portid == (portid_t)RTE_PORT_ALL) {
2507 printf("Invalid port id\n");
2511 port = &ports[res->portid];
2513 if (!strcmp(res->rxtxq, "rxq"))
2515 else if (!strcmp(res->rxtxq, "txq"))
2518 printf("Unknown parameter\n");
2522 if (isrx && rx_queue_id_is_invalid(res->qid))
2524 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2527 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2528 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2534 port->nb_rx_desc[res->qid] = res->size;
2536 port->nb_tx_desc[res->qid] = res->size;
2538 cmd_reconfig_device_queue(res->portid, 0, 1);
2541 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2542 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2544 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2545 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2547 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2548 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2550 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2553 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2554 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2556 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2557 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2558 rsize, "ring_size");
2559 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2560 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2563 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2564 .f = cmd_config_rxtx_ring_size_parsed,
2566 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2568 (void *)&cmd_config_rxtx_ring_size_port,
2569 (void *)&cmd_config_rxtx_ring_size_config,
2570 (void *)&cmd_config_rxtx_ring_size_portid,
2571 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2572 (void *)&cmd_config_rxtx_ring_size_qid,
2573 (void *)&cmd_config_rxtx_ring_size_rsize,
2574 (void *)&cmd_config_rxtx_ring_size_size,
2579 /* *** configure port rxq/txq start/stop *** */
2580 struct cmd_config_rxtx_queue {
2581 cmdline_fixed_string_t port;
2583 cmdline_fixed_string_t rxtxq;
2585 cmdline_fixed_string_t opname;
2589 cmd_config_rxtx_queue_parsed(void *parsed_result,
2590 __attribute__((unused)) struct cmdline *cl,
2591 __attribute__((unused)) void *data)
2593 struct cmd_config_rxtx_queue *res = parsed_result;
2598 if (test_done == 0) {
2599 printf("Please stop forwarding first\n");
2603 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2606 if (port_is_started(res->portid) != 1) {
2607 printf("Please start port %u first\n", res->portid);
2611 if (!strcmp(res->rxtxq, "rxq"))
2613 else if (!strcmp(res->rxtxq, "txq"))
2616 printf("Unknown parameter\n");
2620 if (isrx && rx_queue_id_is_invalid(res->qid))
2622 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2625 if (!strcmp(res->opname, "start"))
2627 else if (!strcmp(res->opname, "stop"))
2630 printf("Unknown parameter\n");
2634 if (isstart && isrx)
2635 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2636 else if (!isstart && isrx)
2637 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2638 else if (isstart && !isrx)
2639 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2641 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2643 if (ret == -ENOTSUP)
2644 printf("Function not supported in PMD driver\n");
2647 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2648 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2649 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2650 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2651 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2652 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2653 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2654 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2655 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2656 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2659 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2660 .f = cmd_config_rxtx_queue_parsed,
2662 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2664 (void *)&cmd_config_rxtx_queue_port,
2665 (void *)&cmd_config_rxtx_queue_portid,
2666 (void *)&cmd_config_rxtx_queue_rxtxq,
2667 (void *)&cmd_config_rxtx_queue_qid,
2668 (void *)&cmd_config_rxtx_queue_opname,
2673 /* *** configure port rxq/txq deferred start on/off *** */
2674 struct cmd_config_deferred_start_rxtx_queue {
2675 cmdline_fixed_string_t port;
2677 cmdline_fixed_string_t rxtxq;
2679 cmdline_fixed_string_t opname;
2680 cmdline_fixed_string_t state;
2684 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2685 __attribute__((unused)) struct cmdline *cl,
2686 __attribute__((unused)) void *data)
2688 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2689 struct rte_port *port;
2692 uint8_t needreconfig = 0;
2694 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2697 if (port_is_started(res->port_id) != 0) {
2698 printf("Please stop port %u first\n", res->port_id);
2702 port = &ports[res->port_id];
2704 isrx = !strcmp(res->rxtxq, "rxq");
2706 if (isrx && rx_queue_id_is_invalid(res->qid))
2708 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2711 ison = !strcmp(res->state, "on");
2713 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2714 port->rx_conf[res->qid].rx_deferred_start = ison;
2716 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2717 port->tx_conf[res->qid].tx_deferred_start = ison;
2722 cmd_reconfig_device_queue(res->port_id, 0, 1);
2725 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2726 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2728 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2729 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2731 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2732 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2734 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2735 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2737 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2738 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2739 opname, "deferred_start");
2740 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2741 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2744 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2745 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2747 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2749 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2750 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2751 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2752 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2753 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2754 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2759 /* *** configure port rxq/txq setup *** */
2760 struct cmd_setup_rxtx_queue {
2761 cmdline_fixed_string_t port;
2763 cmdline_fixed_string_t rxtxq;
2765 cmdline_fixed_string_t setup;
2768 /* Common CLI fields for queue setup */
2769 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2770 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2771 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2772 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2773 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2774 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2775 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2776 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2777 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2778 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2781 cmd_setup_rxtx_queue_parsed(
2782 void *parsed_result,
2783 __attribute__((unused)) struct cmdline *cl,
2784 __attribute__((unused)) void *data)
2786 struct cmd_setup_rxtx_queue *res = parsed_result;
2787 struct rte_port *port;
2788 struct rte_mempool *mp;
2789 unsigned int socket_id;
2793 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2796 if (res->portid == (portid_t)RTE_PORT_ALL) {
2797 printf("Invalid port id\n");
2801 if (!strcmp(res->rxtxq, "rxq"))
2803 else if (!strcmp(res->rxtxq, "txq"))
2806 printf("Unknown parameter\n");
2810 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2811 printf("Invalid rx queue\n");
2813 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2814 printf("Invalid tx queue\n");
2818 port = &ports[res->portid];
2820 socket_id = rxring_numa[res->portid];
2821 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2822 socket_id = port->socket_id;
2824 mp = mbuf_pool_find(socket_id);
2826 printf("Failed to setup RX queue: "
2827 "No mempool allocation"
2828 " on the socket %d\n",
2829 rxring_numa[res->portid]);
2832 ret = rte_eth_rx_queue_setup(res->portid,
2834 port->nb_rx_desc[res->qid],
2836 &port->rx_conf[res->qid],
2839 printf("Failed to setup RX queue\n");
2841 socket_id = txring_numa[res->portid];
2842 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2843 socket_id = port->socket_id;
2845 ret = rte_eth_tx_queue_setup(res->portid,
2847 port->nb_tx_desc[res->qid],
2849 &port->tx_conf[res->qid]);
2851 printf("Failed to setup TX queue\n");
2855 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2856 .f = cmd_setup_rxtx_queue_parsed,
2858 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2860 (void *)&cmd_setup_rxtx_queue_port,
2861 (void *)&cmd_setup_rxtx_queue_portid,
2862 (void *)&cmd_setup_rxtx_queue_rxtxq,
2863 (void *)&cmd_setup_rxtx_queue_qid,
2864 (void *)&cmd_setup_rxtx_queue_setup,
2870 /* *** Configure RSS RETA *** */
2871 struct cmd_config_rss_reta {
2872 cmdline_fixed_string_t port;
2873 cmdline_fixed_string_t keyword;
2875 cmdline_fixed_string_t name;
2876 cmdline_fixed_string_t list_name;
2877 cmdline_fixed_string_t list_of_items;
2881 parse_reta_config(const char *str,
2882 struct rte_eth_rss_reta_entry64 *reta_conf,
2883 uint16_t nb_entries)
2887 uint16_t hash_index, idx, shift;
2890 const char *p, *p0 = str;
2897 unsigned long int_fld[_NUM_FLD];
2898 char *str_fld[_NUM_FLD];
2900 while ((p = strchr(p0,'(')) != NULL) {
2902 if((p0 = strchr(p,')')) == NULL)
2906 if(size >= sizeof(s))
2909 snprintf(s, sizeof(s), "%.*s", size, p);
2910 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2912 for (i = 0; i < _NUM_FLD; i++) {
2914 int_fld[i] = strtoul(str_fld[i], &end, 0);
2915 if (errno != 0 || end == str_fld[i] ||
2920 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2921 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2923 if (hash_index >= nb_entries) {
2924 printf("Invalid RETA hash index=%d\n", hash_index);
2928 idx = hash_index / RTE_RETA_GROUP_SIZE;
2929 shift = hash_index % RTE_RETA_GROUP_SIZE;
2930 reta_conf[idx].mask |= (1ULL << shift);
2931 reta_conf[idx].reta[shift] = nb_queue;
2938 cmd_set_rss_reta_parsed(void *parsed_result,
2939 __attribute__((unused)) struct cmdline *cl,
2940 __attribute__((unused)) void *data)
2943 struct rte_eth_dev_info dev_info;
2944 struct rte_eth_rss_reta_entry64 reta_conf[8];
2945 struct cmd_config_rss_reta *res = parsed_result;
2947 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2951 if (dev_info.reta_size == 0) {
2952 printf("Redirection table size is 0 which is "
2953 "invalid for RSS\n");
2956 printf("The reta size of port %d is %u\n",
2957 res->port_id, dev_info.reta_size);
2958 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2959 printf("Currently do not support more than %u entries of "
2960 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2964 memset(reta_conf, 0, sizeof(reta_conf));
2965 if (!strcmp(res->list_name, "reta")) {
2966 if (parse_reta_config(res->list_of_items, reta_conf,
2967 dev_info.reta_size)) {
2968 printf("Invalid RSS Redirection Table "
2969 "config entered\n");
2972 ret = rte_eth_dev_rss_reta_update(res->port_id,
2973 reta_conf, dev_info.reta_size);
2975 printf("Bad redirection table parameter, "
2976 "return code = %d \n", ret);
2980 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2981 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2982 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2983 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2984 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2985 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2986 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2987 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2988 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2989 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2990 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2991 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2993 cmdline_parse_inst_t cmd_config_rss_reta = {
2994 .f = cmd_set_rss_reta_parsed,
2996 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2998 (void *)&cmd_config_rss_reta_port,
2999 (void *)&cmd_config_rss_reta_keyword,
3000 (void *)&cmd_config_rss_reta_port_id,
3001 (void *)&cmd_config_rss_reta_name,
3002 (void *)&cmd_config_rss_reta_list_name,
3003 (void *)&cmd_config_rss_reta_list_of_items,
3008 /* *** SHOW PORT RETA INFO *** */
3009 struct cmd_showport_reta {
3010 cmdline_fixed_string_t show;
3011 cmdline_fixed_string_t port;
3013 cmdline_fixed_string_t rss;
3014 cmdline_fixed_string_t reta;
3016 cmdline_fixed_string_t list_of_items;
3020 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3021 uint16_t nb_entries,
3025 const char *p, *p0 = str;
3030 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3031 RTE_RETA_GROUP_SIZE;
3034 p = strchr(p0, '(');
3038 p0 = strchr(p, ')');
3042 if (size >= sizeof(s)) {
3043 printf("The string size exceeds the internal buffer size\n");
3046 snprintf(s, sizeof(s), "%.*s", size, p);
3047 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3048 if (ret <= 0 || ret != num) {
3049 printf("The bits of masks do not match the number of "
3050 "reta entries: %u\n", num);
3053 for (i = 0; i < ret; i++)
3054 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3060 cmd_showport_reta_parsed(void *parsed_result,
3061 __attribute__((unused)) struct cmdline *cl,
3062 __attribute__((unused)) void *data)
3064 struct cmd_showport_reta *res = parsed_result;
3065 struct rte_eth_rss_reta_entry64 reta_conf[8];
3066 struct rte_eth_dev_info dev_info;
3067 uint16_t max_reta_size;
3070 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3074 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3075 if (res->size == 0 || res->size > max_reta_size) {
3076 printf("Invalid redirection table size: %u (1-%u)\n",
3077 res->size, max_reta_size);
3081 memset(reta_conf, 0, sizeof(reta_conf));
3082 if (showport_parse_reta_config(reta_conf, res->size,
3083 res->list_of_items) < 0) {
3084 printf("Invalid string: %s for reta masks\n",
3085 res->list_of_items);
3088 port_rss_reta_info(res->port_id, reta_conf, res->size);
3091 cmdline_parse_token_string_t cmd_showport_reta_show =
3092 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3093 cmdline_parse_token_string_t cmd_showport_reta_port =
3094 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3095 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3096 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3097 cmdline_parse_token_string_t cmd_showport_reta_rss =
3098 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3099 cmdline_parse_token_string_t cmd_showport_reta_reta =
3100 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3101 cmdline_parse_token_num_t cmd_showport_reta_size =
3102 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3103 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3104 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3105 list_of_items, NULL);
3107 cmdline_parse_inst_t cmd_showport_reta = {
3108 .f = cmd_showport_reta_parsed,
3110 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3112 (void *)&cmd_showport_reta_show,
3113 (void *)&cmd_showport_reta_port,
3114 (void *)&cmd_showport_reta_port_id,
3115 (void *)&cmd_showport_reta_rss,
3116 (void *)&cmd_showport_reta_reta,
3117 (void *)&cmd_showport_reta_size,
3118 (void *)&cmd_showport_reta_list_of_items,
3123 /* *** Show RSS hash configuration *** */
3124 struct cmd_showport_rss_hash {
3125 cmdline_fixed_string_t show;
3126 cmdline_fixed_string_t port;
3128 cmdline_fixed_string_t rss_hash;
3129 cmdline_fixed_string_t rss_type;
3130 cmdline_fixed_string_t key; /* optional argument */
3133 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3134 __attribute__((unused)) struct cmdline *cl,
3137 struct cmd_showport_rss_hash *res = parsed_result;
3139 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3142 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3143 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3144 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3145 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3146 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3147 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3148 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3149 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3151 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3152 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3154 cmdline_parse_inst_t cmd_showport_rss_hash = {
3155 .f = cmd_showport_rss_hash_parsed,
3157 .help_str = "show port <port_id> rss-hash",
3159 (void *)&cmd_showport_rss_hash_show,
3160 (void *)&cmd_showport_rss_hash_port,
3161 (void *)&cmd_showport_rss_hash_port_id,
3162 (void *)&cmd_showport_rss_hash_rss_hash,
3167 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3168 .f = cmd_showport_rss_hash_parsed,
3170 .help_str = "show port <port_id> rss-hash key",
3172 (void *)&cmd_showport_rss_hash_show,
3173 (void *)&cmd_showport_rss_hash_port,
3174 (void *)&cmd_showport_rss_hash_port_id,
3175 (void *)&cmd_showport_rss_hash_rss_hash,
3176 (void *)&cmd_showport_rss_hash_rss_key,
3181 /* *** Configure DCB *** */
3182 struct cmd_config_dcb {
3183 cmdline_fixed_string_t port;
3184 cmdline_fixed_string_t config;
3186 cmdline_fixed_string_t dcb;
3187 cmdline_fixed_string_t vt;
3188 cmdline_fixed_string_t vt_en;
3190 cmdline_fixed_string_t pfc;
3191 cmdline_fixed_string_t pfc_en;
3195 cmd_config_dcb_parsed(void *parsed_result,
3196 __attribute__((unused)) struct cmdline *cl,
3197 __attribute__((unused)) void *data)
3199 struct cmd_config_dcb *res = parsed_result;
3200 portid_t port_id = res->port_id;
3201 struct rte_port *port;
3205 port = &ports[port_id];
3206 /** Check if the port is not started **/
3207 if (port->port_status != RTE_PORT_STOPPED) {
3208 printf("Please stop port %d first\n", port_id);
3212 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3213 printf("The invalid number of traffic class,"
3214 " only 4 or 8 allowed.\n");
3218 if (nb_fwd_lcores < res->num_tcs) {
3219 printf("nb_cores shouldn't be less than number of TCs.\n");
3222 if (!strncmp(res->pfc_en, "on", 2))
3227 /* DCB in VT mode */
3228 if (!strncmp(res->vt_en, "on", 2))
3229 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3230 (enum rte_eth_nb_tcs)res->num_tcs,
3233 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3234 (enum rte_eth_nb_tcs)res->num_tcs,
3239 printf("Cannot initialize network ports.\n");
3243 cmd_reconfig_device_queue(port_id, 1, 1);
3246 cmdline_parse_token_string_t cmd_config_dcb_port =
3247 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3248 cmdline_parse_token_string_t cmd_config_dcb_config =
3249 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3250 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3251 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3252 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3253 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3254 cmdline_parse_token_string_t cmd_config_dcb_vt =
3255 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3256 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3257 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3258 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3259 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3260 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3261 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3262 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3263 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3265 cmdline_parse_inst_t cmd_config_dcb = {
3266 .f = cmd_config_dcb_parsed,
3268 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3270 (void *)&cmd_config_dcb_port,
3271 (void *)&cmd_config_dcb_config,
3272 (void *)&cmd_config_dcb_port_id,
3273 (void *)&cmd_config_dcb_dcb,
3274 (void *)&cmd_config_dcb_vt,
3275 (void *)&cmd_config_dcb_vt_en,
3276 (void *)&cmd_config_dcb_num_tcs,
3277 (void *)&cmd_config_dcb_pfc,
3278 (void *)&cmd_config_dcb_pfc_en,
3283 /* *** configure number of packets per burst *** */
3284 struct cmd_config_burst {
3285 cmdline_fixed_string_t port;
3286 cmdline_fixed_string_t keyword;
3287 cmdline_fixed_string_t all;
3288 cmdline_fixed_string_t name;
3293 cmd_config_burst_parsed(void *parsed_result,
3294 __attribute__((unused)) struct cmdline *cl,
3295 __attribute__((unused)) void *data)
3297 struct cmd_config_burst *res = parsed_result;
3298 struct rte_eth_dev_info dev_info;
3299 uint16_t rec_nb_pkts;
3302 if (!all_ports_stopped()) {
3303 printf("Please stop all ports first\n");
3307 if (!strcmp(res->name, "burst")) {
3308 if (res->value == 0) {
3309 /* If user gives a value of zero, query the PMD for
3310 * its recommended Rx burst size. Testpmd uses a single
3311 * size for all ports, so assume all ports are the same
3312 * NIC model and use the values from Port 0.
3314 ret = eth_dev_info_get_print_err(0, &dev_info);
3318 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3320 if (rec_nb_pkts == 0) {
3321 printf("PMD does not recommend a burst size.\n"
3322 "User provided value must be between"
3323 " 1 and %d\n", MAX_PKT_BURST);
3325 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3326 printf("PMD recommended burst size of %d"
3327 " exceeds maximum value of %d\n",
3328 rec_nb_pkts, MAX_PKT_BURST);
3331 printf("Using PMD-provided burst value of %d\n",
3333 nb_pkt_per_burst = rec_nb_pkts;
3334 } else if (res->value > MAX_PKT_BURST) {
3335 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3338 nb_pkt_per_burst = res->value;
3340 printf("Unknown parameter\n");
3346 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3349 cmdline_parse_token_string_t cmd_config_burst_port =
3350 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3351 cmdline_parse_token_string_t cmd_config_burst_keyword =
3352 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3353 cmdline_parse_token_string_t cmd_config_burst_all =
3354 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3355 cmdline_parse_token_string_t cmd_config_burst_name =
3356 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3357 cmdline_parse_token_num_t cmd_config_burst_value =
3358 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3360 cmdline_parse_inst_t cmd_config_burst = {
3361 .f = cmd_config_burst_parsed,
3363 .help_str = "port config all burst <value>",
3365 (void *)&cmd_config_burst_port,
3366 (void *)&cmd_config_burst_keyword,
3367 (void *)&cmd_config_burst_all,
3368 (void *)&cmd_config_burst_name,
3369 (void *)&cmd_config_burst_value,
3374 /* *** configure rx/tx queues *** */
3375 struct cmd_config_thresh {
3376 cmdline_fixed_string_t port;
3377 cmdline_fixed_string_t keyword;
3378 cmdline_fixed_string_t all;
3379 cmdline_fixed_string_t name;
3384 cmd_config_thresh_parsed(void *parsed_result,
3385 __attribute__((unused)) struct cmdline *cl,
3386 __attribute__((unused)) void *data)
3388 struct cmd_config_thresh *res = parsed_result;
3390 if (!all_ports_stopped()) {
3391 printf("Please stop all ports first\n");
3395 if (!strcmp(res->name, "txpt"))
3396 tx_pthresh = res->value;
3397 else if(!strcmp(res->name, "txht"))
3398 tx_hthresh = res->value;
3399 else if(!strcmp(res->name, "txwt"))
3400 tx_wthresh = res->value;
3401 else if(!strcmp(res->name, "rxpt"))
3402 rx_pthresh = res->value;
3403 else if(!strcmp(res->name, "rxht"))
3404 rx_hthresh = res->value;
3405 else if(!strcmp(res->name, "rxwt"))
3406 rx_wthresh = res->value;
3408 printf("Unknown parameter\n");
3414 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3417 cmdline_parse_token_string_t cmd_config_thresh_port =
3418 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3419 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3420 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3421 cmdline_parse_token_string_t cmd_config_thresh_all =
3422 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3423 cmdline_parse_token_string_t cmd_config_thresh_name =
3424 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3425 "txpt#txht#txwt#rxpt#rxht#rxwt");
3426 cmdline_parse_token_num_t cmd_config_thresh_value =
3427 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3429 cmdline_parse_inst_t cmd_config_thresh = {
3430 .f = cmd_config_thresh_parsed,
3432 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3434 (void *)&cmd_config_thresh_port,
3435 (void *)&cmd_config_thresh_keyword,
3436 (void *)&cmd_config_thresh_all,
3437 (void *)&cmd_config_thresh_name,
3438 (void *)&cmd_config_thresh_value,
3443 /* *** configure free/rs threshold *** */
3444 struct cmd_config_threshold {
3445 cmdline_fixed_string_t port;
3446 cmdline_fixed_string_t keyword;
3447 cmdline_fixed_string_t all;
3448 cmdline_fixed_string_t name;
3453 cmd_config_threshold_parsed(void *parsed_result,
3454 __attribute__((unused)) struct cmdline *cl,
3455 __attribute__((unused)) void *data)
3457 struct cmd_config_threshold *res = parsed_result;
3459 if (!all_ports_stopped()) {
3460 printf("Please stop all ports first\n");
3464 if (!strcmp(res->name, "txfreet"))
3465 tx_free_thresh = res->value;
3466 else if (!strcmp(res->name, "txrst"))
3467 tx_rs_thresh = res->value;
3468 else if (!strcmp(res->name, "rxfreet"))
3469 rx_free_thresh = res->value;
3471 printf("Unknown parameter\n");
3477 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3480 cmdline_parse_token_string_t cmd_config_threshold_port =
3481 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3482 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3483 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3485 cmdline_parse_token_string_t cmd_config_threshold_all =
3486 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3487 cmdline_parse_token_string_t cmd_config_threshold_name =
3488 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3489 "txfreet#txrst#rxfreet");
3490 cmdline_parse_token_num_t cmd_config_threshold_value =
3491 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3493 cmdline_parse_inst_t cmd_config_threshold = {
3494 .f = cmd_config_threshold_parsed,
3496 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3498 (void *)&cmd_config_threshold_port,
3499 (void *)&cmd_config_threshold_keyword,
3500 (void *)&cmd_config_threshold_all,
3501 (void *)&cmd_config_threshold_name,
3502 (void *)&cmd_config_threshold_value,
3508 struct cmd_stop_result {
3509 cmdline_fixed_string_t stop;
3512 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3513 __attribute__((unused)) struct cmdline *cl,
3514 __attribute__((unused)) void *data)
3516 stop_packet_forwarding();
3519 cmdline_parse_token_string_t cmd_stop_stop =
3520 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3522 cmdline_parse_inst_t cmd_stop = {
3523 .f = cmd_stop_parsed,
3525 .help_str = "stop: Stop packet forwarding",
3527 (void *)&cmd_stop_stop,
3532 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3535 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3536 unsigned int *parsed_items, int check_unique_values)
3538 unsigned int nb_item;
3546 * First parse all items in the list and store their value.
3551 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3553 if ((c >= '0') && (c <= '9')) {
3554 value = (unsigned int) (value * 10 + (c - '0'));
3559 printf("character %c is not a decimal digit\n", c);
3563 printf("No valid value before comma\n");
3566 if (nb_item < max_items) {
3567 parsed_items[nb_item] = value;
3573 if (nb_item >= max_items) {
3574 printf("Number of %s = %u > %u (maximum items)\n",
3575 item_name, nb_item + 1, max_items);
3578 parsed_items[nb_item++] = value;
3579 if (! check_unique_values)
3583 * Then, check that all values in the list are differents.
3584 * No optimization here...
3586 for (i = 0; i < nb_item; i++) {
3587 for (j = i + 1; j < nb_item; j++) {
3588 if (parsed_items[j] == parsed_items[i]) {
3589 printf("duplicated %s %u at index %u and %u\n",
3590 item_name, parsed_items[i], i, j);
3598 struct cmd_set_list_result {
3599 cmdline_fixed_string_t cmd_keyword;
3600 cmdline_fixed_string_t list_name;
3601 cmdline_fixed_string_t list_of_items;
3604 static void cmd_set_list_parsed(void *parsed_result,
3605 __attribute__((unused)) struct cmdline *cl,
3606 __attribute__((unused)) void *data)
3608 struct cmd_set_list_result *res;
3610 unsigned int lcorelist[RTE_MAX_LCORE];
3611 unsigned int portlist[RTE_MAX_ETHPORTS];
3613 unsigned int nb_item;
3615 if (test_done == 0) {
3616 printf("Please stop forwarding first\n");
3620 res = parsed_result;
3621 if (!strcmp(res->list_name, "corelist")) {
3622 nb_item = parse_item_list(res->list_of_items, "core",
3624 parsed_items.lcorelist, 1);
3626 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3631 if (!strcmp(res->list_name, "portlist")) {
3632 nb_item = parse_item_list(res->list_of_items, "port",
3634 parsed_items.portlist, 1);
3636 set_fwd_ports_list(parsed_items.portlist, nb_item);
3642 cmdline_parse_token_string_t cmd_set_list_keyword =
3643 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3645 cmdline_parse_token_string_t cmd_set_list_name =
3646 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3647 "corelist#portlist");
3648 cmdline_parse_token_string_t cmd_set_list_of_items =
3649 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3652 cmdline_parse_inst_t cmd_set_fwd_list = {
3653 .f = cmd_set_list_parsed,
3655 .help_str = "set corelist|portlist <list0[,list1]*>",
3657 (void *)&cmd_set_list_keyword,
3658 (void *)&cmd_set_list_name,
3659 (void *)&cmd_set_list_of_items,
3664 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3666 struct cmd_setmask_result {
3667 cmdline_fixed_string_t set;
3668 cmdline_fixed_string_t mask;
3672 static void cmd_set_mask_parsed(void *parsed_result,
3673 __attribute__((unused)) struct cmdline *cl,
3674 __attribute__((unused)) void *data)
3676 struct cmd_setmask_result *res = parsed_result;
3678 if (test_done == 0) {
3679 printf("Please stop forwarding first\n");
3682 if (!strcmp(res->mask, "coremask")) {
3683 set_fwd_lcores_mask(res->hexavalue);
3685 } else if (!strcmp(res->mask, "portmask")) {
3686 set_fwd_ports_mask(res->hexavalue);
3691 cmdline_parse_token_string_t cmd_setmask_set =
3692 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3693 cmdline_parse_token_string_t cmd_setmask_mask =
3694 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3695 "coremask#portmask");
3696 cmdline_parse_token_num_t cmd_setmask_value =
3697 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3699 cmdline_parse_inst_t cmd_set_fwd_mask = {
3700 .f = cmd_set_mask_parsed,
3702 .help_str = "set coremask|portmask <hexadecimal value>",
3704 (void *)&cmd_setmask_set,
3705 (void *)&cmd_setmask_mask,
3706 (void *)&cmd_setmask_value,
3712 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3714 struct cmd_set_result {
3715 cmdline_fixed_string_t set;
3716 cmdline_fixed_string_t what;
3720 static void cmd_set_parsed(void *parsed_result,
3721 __attribute__((unused)) struct cmdline *cl,
3722 __attribute__((unused)) void *data)
3724 struct cmd_set_result *res = parsed_result;
3725 if (!strcmp(res->what, "nbport")) {
3726 set_fwd_ports_number(res->value);
3728 } else if (!strcmp(res->what, "nbcore")) {
3729 set_fwd_lcores_number(res->value);
3731 } else if (!strcmp(res->what, "burst"))
3732 set_nb_pkt_per_burst(res->value);
3733 else if (!strcmp(res->what, "verbose"))
3734 set_verbose_level(res->value);
3737 cmdline_parse_token_string_t cmd_set_set =
3738 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3739 cmdline_parse_token_string_t cmd_set_what =
3740 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3741 "nbport#nbcore#burst#verbose");
3742 cmdline_parse_token_num_t cmd_set_value =
3743 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3745 cmdline_parse_inst_t cmd_set_numbers = {
3746 .f = cmd_set_parsed,
3748 .help_str = "set nbport|nbcore|burst|verbose <value>",
3750 (void *)&cmd_set_set,
3751 (void *)&cmd_set_what,
3752 (void *)&cmd_set_value,
3757 /* *** SET LOG LEVEL CONFIGURATION *** */
3759 struct cmd_set_log_result {
3760 cmdline_fixed_string_t set;
3761 cmdline_fixed_string_t log;
3762 cmdline_fixed_string_t type;
3767 cmd_set_log_parsed(void *parsed_result,
3768 __attribute__((unused)) struct cmdline *cl,
3769 __attribute__((unused)) void *data)
3771 struct cmd_set_log_result *res;
3774 res = parsed_result;
3775 if (!strcmp(res->type, "global"))
3776 rte_log_set_global_level(res->level);
3778 ret = rte_log_set_level_regexp(res->type, res->level);
3780 printf("Unable to set log level\n");
3784 cmdline_parse_token_string_t cmd_set_log_set =
3785 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3786 cmdline_parse_token_string_t cmd_set_log_log =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3788 cmdline_parse_token_string_t cmd_set_log_type =
3789 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3790 cmdline_parse_token_num_t cmd_set_log_level =
3791 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3793 cmdline_parse_inst_t cmd_set_log = {
3794 .f = cmd_set_log_parsed,
3796 .help_str = "set log global|<type> <level>",
3798 (void *)&cmd_set_log_set,
3799 (void *)&cmd_set_log_log,
3800 (void *)&cmd_set_log_type,
3801 (void *)&cmd_set_log_level,
3806 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3808 struct cmd_set_txpkts_result {
3809 cmdline_fixed_string_t cmd_keyword;
3810 cmdline_fixed_string_t txpkts;
3811 cmdline_fixed_string_t seg_lengths;
3815 cmd_set_txpkts_parsed(void *parsed_result,
3816 __attribute__((unused)) struct cmdline *cl,
3817 __attribute__((unused)) void *data)
3819 struct cmd_set_txpkts_result *res;
3820 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3821 unsigned int nb_segs;
3823 res = parsed_result;
3824 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3825 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3827 set_tx_pkt_segments(seg_lengths, nb_segs);
3830 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3832 cmd_keyword, "set");
3833 cmdline_parse_token_string_t cmd_set_txpkts_name =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3836 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3837 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3840 cmdline_parse_inst_t cmd_set_txpkts = {
3841 .f = cmd_set_txpkts_parsed,
3843 .help_str = "set txpkts <len0[,len1]*>",
3845 (void *)&cmd_set_txpkts_keyword,
3846 (void *)&cmd_set_txpkts_name,
3847 (void *)&cmd_set_txpkts_lengths,
3852 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3854 struct cmd_set_txsplit_result {
3855 cmdline_fixed_string_t cmd_keyword;
3856 cmdline_fixed_string_t txsplit;
3857 cmdline_fixed_string_t mode;
3861 cmd_set_txsplit_parsed(void *parsed_result,
3862 __attribute__((unused)) struct cmdline *cl,
3863 __attribute__((unused)) void *data)
3865 struct cmd_set_txsplit_result *res;
3867 res = parsed_result;
3868 set_tx_pkt_split(res->mode);
3871 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3873 cmd_keyword, "set");
3874 cmdline_parse_token_string_t cmd_set_txsplit_name =
3875 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3876 txsplit, "txsplit");
3877 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3881 cmdline_parse_inst_t cmd_set_txsplit = {
3882 .f = cmd_set_txsplit_parsed,
3884 .help_str = "set txsplit on|off|rand",
3886 (void *)&cmd_set_txsplit_keyword,
3887 (void *)&cmd_set_txsplit_name,
3888 (void *)&cmd_set_txsplit_mode,
3893 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3894 struct cmd_rx_vlan_filter_all_result {
3895 cmdline_fixed_string_t rx_vlan;
3896 cmdline_fixed_string_t what;
3897 cmdline_fixed_string_t all;
3902 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3903 __attribute__((unused)) struct cmdline *cl,
3904 __attribute__((unused)) void *data)
3906 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3908 if (!strcmp(res->what, "add"))
3909 rx_vlan_all_filter_set(res->port_id, 1);
3911 rx_vlan_all_filter_set(res->port_id, 0);
3914 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3915 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3916 rx_vlan, "rx_vlan");
3917 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3918 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3920 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3921 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3923 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3924 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3927 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3928 .f = cmd_rx_vlan_filter_all_parsed,
3930 .help_str = "rx_vlan add|rm all <port_id>: "
3931 "Add/Remove all identifiers to/from the set of VLAN "
3932 "identifiers filtered by a port",
3934 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3935 (void *)&cmd_rx_vlan_filter_all_what,
3936 (void *)&cmd_rx_vlan_filter_all_all,
3937 (void *)&cmd_rx_vlan_filter_all_portid,
3942 /* *** VLAN OFFLOAD SET ON A PORT *** */
3943 struct cmd_vlan_offload_result {
3944 cmdline_fixed_string_t vlan;
3945 cmdline_fixed_string_t set;
3946 cmdline_fixed_string_t vlan_type;
3947 cmdline_fixed_string_t what;
3948 cmdline_fixed_string_t on;
3949 cmdline_fixed_string_t port_id;
3953 cmd_vlan_offload_parsed(void *parsed_result,
3954 __attribute__((unused)) struct cmdline *cl,
3955 __attribute__((unused)) void *data)
3958 struct cmd_vlan_offload_result *res = parsed_result;
3961 portid_t port_id = 0;
3965 len = strnlen(str, STR_TOKEN_SIZE);
3967 /* Get port_id first */
3975 tmp = strtoul(str, NULL, 0);
3976 /* If port_id greater that what portid_t can represent, return */
3977 if(tmp >= RTE_MAX_ETHPORTS)
3979 port_id = (portid_t)tmp;
3981 if (!strcmp(res->on, "on"))
3986 if (!strcmp(res->what, "strip"))
3987 rx_vlan_strip_set(port_id, on);
3988 else if(!strcmp(res->what, "stripq")){
3989 uint16_t queue_id = 0;
3991 /* No queue_id, return */
3993 printf("must specify (port,queue_id)\n");
3996 tmp = strtoul(str + i + 1, NULL, 0);
3997 /* If queue_id greater that what 16-bits can represent, return */
4001 queue_id = (uint16_t)tmp;
4002 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4004 else if (!strcmp(res->what, "filter"))
4005 rx_vlan_filter_set(port_id, on);
4006 else if (!strcmp(res->what, "qinq_strip"))
4007 rx_vlan_qinq_strip_set(port_id, on);
4009 vlan_extend_set(port_id, on);
4014 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4015 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4017 cmdline_parse_token_string_t cmd_vlan_offload_set =
4018 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4020 cmdline_parse_token_string_t cmd_vlan_offload_what =
4021 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4022 what, "strip#filter#qinq_strip#extend#stripq");
4023 cmdline_parse_token_string_t cmd_vlan_offload_on =
4024 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4026 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4027 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4030 cmdline_parse_inst_t cmd_vlan_offload = {
4031 .f = cmd_vlan_offload_parsed,
4033 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4034 "<port_id[,queue_id]>: "
4035 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4037 (void *)&cmd_vlan_offload_vlan,
4038 (void *)&cmd_vlan_offload_set,
4039 (void *)&cmd_vlan_offload_what,
4040 (void *)&cmd_vlan_offload_on,
4041 (void *)&cmd_vlan_offload_portid,
4046 /* *** VLAN TPID SET ON A PORT *** */
4047 struct cmd_vlan_tpid_result {
4048 cmdline_fixed_string_t vlan;
4049 cmdline_fixed_string_t set;
4050 cmdline_fixed_string_t vlan_type;
4051 cmdline_fixed_string_t what;
4057 cmd_vlan_tpid_parsed(void *parsed_result,
4058 __attribute__((unused)) struct cmdline *cl,
4059 __attribute__((unused)) void *data)
4061 struct cmd_vlan_tpid_result *res = parsed_result;
4062 enum rte_vlan_type vlan_type;
4064 if (!strcmp(res->vlan_type, "inner"))
4065 vlan_type = ETH_VLAN_TYPE_INNER;
4066 else if (!strcmp(res->vlan_type, "outer"))
4067 vlan_type = ETH_VLAN_TYPE_OUTER;
4069 printf("Unknown vlan type\n");
4072 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4075 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4076 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4078 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4079 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4081 cmdline_parse_token_string_t cmd_vlan_type =
4082 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4083 vlan_type, "inner#outer");
4084 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4085 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4087 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4088 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4090 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4091 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4094 cmdline_parse_inst_t cmd_vlan_tpid = {
4095 .f = cmd_vlan_tpid_parsed,
4097 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4098 "Set the VLAN Ether type",
4100 (void *)&cmd_vlan_tpid_vlan,
4101 (void *)&cmd_vlan_tpid_set,
4102 (void *)&cmd_vlan_type,
4103 (void *)&cmd_vlan_tpid_what,
4104 (void *)&cmd_vlan_tpid_tpid,
4105 (void *)&cmd_vlan_tpid_portid,
4110 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4111 struct cmd_rx_vlan_filter_result {
4112 cmdline_fixed_string_t rx_vlan;
4113 cmdline_fixed_string_t what;
4119 cmd_rx_vlan_filter_parsed(void *parsed_result,
4120 __attribute__((unused)) struct cmdline *cl,
4121 __attribute__((unused)) void *data)
4123 struct cmd_rx_vlan_filter_result *res = parsed_result;
4125 if (!strcmp(res->what, "add"))
4126 rx_vft_set(res->port_id, res->vlan_id, 1);
4128 rx_vft_set(res->port_id, res->vlan_id, 0);
4131 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4132 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4133 rx_vlan, "rx_vlan");
4134 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4135 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4137 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4138 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4140 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4141 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4144 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4145 .f = cmd_rx_vlan_filter_parsed,
4147 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4148 "Add/Remove a VLAN identifier to/from the set of VLAN "
4149 "identifiers filtered by a port",
4151 (void *)&cmd_rx_vlan_filter_rx_vlan,
4152 (void *)&cmd_rx_vlan_filter_what,
4153 (void *)&cmd_rx_vlan_filter_vlanid,
4154 (void *)&cmd_rx_vlan_filter_portid,
4159 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4160 struct cmd_tx_vlan_set_result {
4161 cmdline_fixed_string_t tx_vlan;
4162 cmdline_fixed_string_t set;
4168 cmd_tx_vlan_set_parsed(void *parsed_result,
4169 __attribute__((unused)) struct cmdline *cl,
4170 __attribute__((unused)) void *data)
4172 struct cmd_tx_vlan_set_result *res = parsed_result;
4174 if (!port_is_stopped(res->port_id)) {
4175 printf("Please stop port %d first\n", res->port_id);
4179 tx_vlan_set(res->port_id, res->vlan_id);
4181 cmd_reconfig_device_queue(res->port_id, 1, 1);
4184 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4185 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4186 tx_vlan, "tx_vlan");
4187 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4188 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4190 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4191 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4193 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4194 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4197 cmdline_parse_inst_t cmd_tx_vlan_set = {
4198 .f = cmd_tx_vlan_set_parsed,
4200 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4201 "Enable hardware insertion of a single VLAN header "
4202 "with a given TAG Identifier in packets sent on a port",
4204 (void *)&cmd_tx_vlan_set_tx_vlan,
4205 (void *)&cmd_tx_vlan_set_set,
4206 (void *)&cmd_tx_vlan_set_portid,
4207 (void *)&cmd_tx_vlan_set_vlanid,
4212 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4213 struct cmd_tx_vlan_set_qinq_result {
4214 cmdline_fixed_string_t tx_vlan;
4215 cmdline_fixed_string_t set;
4218 uint16_t vlan_id_outer;
4222 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4223 __attribute__((unused)) struct cmdline *cl,
4224 __attribute__((unused)) void *data)
4226 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4228 if (!port_is_stopped(res->port_id)) {
4229 printf("Please stop port %d first\n", res->port_id);
4233 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4235 cmd_reconfig_device_queue(res->port_id, 1, 1);
4238 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4239 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4240 tx_vlan, "tx_vlan");
4241 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4242 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4244 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4245 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4247 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4248 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4250 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4251 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4252 vlan_id_outer, UINT16);
4254 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4255 .f = cmd_tx_vlan_set_qinq_parsed,
4257 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4258 "Enable hardware insertion of double VLAN header "
4259 "with given TAG Identifiers in packets sent on a port",
4261 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4262 (void *)&cmd_tx_vlan_set_qinq_set,
4263 (void *)&cmd_tx_vlan_set_qinq_portid,
4264 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4265 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4270 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4271 struct cmd_tx_vlan_set_pvid_result {
4272 cmdline_fixed_string_t tx_vlan;
4273 cmdline_fixed_string_t set;
4274 cmdline_fixed_string_t pvid;
4277 cmdline_fixed_string_t mode;
4281 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4282 __attribute__((unused)) struct cmdline *cl,
4283 __attribute__((unused)) void *data)
4285 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4287 if (strcmp(res->mode, "on") == 0)
4288 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4290 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4293 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4294 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4295 tx_vlan, "tx_vlan");
4296 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4297 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4299 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4300 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4302 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4303 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4305 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4306 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4308 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4309 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4312 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4313 .f = cmd_tx_vlan_set_pvid_parsed,
4315 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4317 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4318 (void *)&cmd_tx_vlan_set_pvid_set,
4319 (void *)&cmd_tx_vlan_set_pvid_pvid,
4320 (void *)&cmd_tx_vlan_set_pvid_port_id,
4321 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4322 (void *)&cmd_tx_vlan_set_pvid_mode,
4327 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4328 struct cmd_tx_vlan_reset_result {
4329 cmdline_fixed_string_t tx_vlan;
4330 cmdline_fixed_string_t reset;
4335 cmd_tx_vlan_reset_parsed(void *parsed_result,
4336 __attribute__((unused)) struct cmdline *cl,
4337 __attribute__((unused)) void *data)
4339 struct cmd_tx_vlan_reset_result *res = parsed_result;
4341 if (!port_is_stopped(res->port_id)) {
4342 printf("Please stop port %d first\n", res->port_id);
4346 tx_vlan_reset(res->port_id);
4348 cmd_reconfig_device_queue(res->port_id, 1, 1);
4351 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4352 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4353 tx_vlan, "tx_vlan");
4354 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4355 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4357 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4358 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4361 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4362 .f = cmd_tx_vlan_reset_parsed,
4364 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4365 "VLAN header in packets sent on a port",
4367 (void *)&cmd_tx_vlan_reset_tx_vlan,
4368 (void *)&cmd_tx_vlan_reset_reset,
4369 (void *)&cmd_tx_vlan_reset_portid,
4375 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4376 struct cmd_csum_result {
4377 cmdline_fixed_string_t csum;
4378 cmdline_fixed_string_t mode;
4379 cmdline_fixed_string_t proto;
4380 cmdline_fixed_string_t hwsw;
4385 csum_show(int port_id)
4387 struct rte_eth_dev_info dev_info;
4388 uint64_t tx_offloads;
4391 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4392 printf("Parse tunnel is %s\n",
4393 (ports[port_id].parse_tunnel) ? "on" : "off");
4394 printf("IP checksum offload is %s\n",
4395 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4396 printf("UDP checksum offload is %s\n",
4397 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4398 printf("TCP checksum offload is %s\n",
4399 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4400 printf("SCTP checksum offload is %s\n",
4401 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4402 printf("Outer-Ip checksum offload is %s\n",
4403 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4404 printf("Outer-Udp checksum offload is %s\n",
4405 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4407 /* display warnings if configuration is not supported by the NIC */
4408 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4412 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4413 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4414 printf("Warning: hardware IP checksum enabled but not "
4415 "supported by port %d\n", port_id);
4417 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4418 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4419 printf("Warning: hardware UDP checksum enabled but not "
4420 "supported by port %d\n", port_id);
4422 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4423 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4424 printf("Warning: hardware TCP checksum enabled but not "
4425 "supported by port %d\n", port_id);
4427 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4428 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4429 printf("Warning: hardware SCTP checksum enabled but not "
4430 "supported by port %d\n", port_id);
4432 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4433 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4434 printf("Warning: hardware outer IP checksum enabled but not "
4435 "supported by port %d\n", port_id);
4437 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4438 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4440 printf("Warning: hardware outer UDP checksum enabled but not "
4441 "supported by port %d\n", port_id);
4446 cmd_config_queue_tx_offloads(struct rte_port *port)
4450 /* Apply queue tx offloads configuration */
4451 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4452 port->tx_conf[k].offloads =
4453 port->dev_conf.txmode.offloads;
4457 cmd_csum_parsed(void *parsed_result,
4458 __attribute__((unused)) struct cmdline *cl,
4459 __attribute__((unused)) void *data)
4461 struct cmd_csum_result *res = parsed_result;
4463 uint64_t csum_offloads = 0;
4464 struct rte_eth_dev_info dev_info;
4467 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4468 printf("invalid port %d\n", res->port_id);
4471 if (!port_is_stopped(res->port_id)) {
4472 printf("Please stop port %d first\n", res->port_id);
4476 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4480 if (!strcmp(res->mode, "set")) {
4482 if (!strcmp(res->hwsw, "hw"))
4485 if (!strcmp(res->proto, "ip")) {
4486 if (hw == 0 || (dev_info.tx_offload_capa &
4487 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4488 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4490 printf("IP checksum offload is not supported "
4491 "by port %u\n", res->port_id);
4493 } else if (!strcmp(res->proto, "udp")) {
4494 if (hw == 0 || (dev_info.tx_offload_capa &
4495 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4496 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4498 printf("UDP checksum offload is not supported "
4499 "by port %u\n", res->port_id);
4501 } else if (!strcmp(res->proto, "tcp")) {
4502 if (hw == 0 || (dev_info.tx_offload_capa &
4503 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4504 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4506 printf("TCP checksum offload is not supported "
4507 "by port %u\n", res->port_id);
4509 } else if (!strcmp(res->proto, "sctp")) {
4510 if (hw == 0 || (dev_info.tx_offload_capa &
4511 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4512 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4514 printf("SCTP checksum offload is not supported "
4515 "by port %u\n", res->port_id);
4517 } else if (!strcmp(res->proto, "outer-ip")) {
4518 if (hw == 0 || (dev_info.tx_offload_capa &
4519 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4521 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4523 printf("Outer IP checksum offload is not "
4524 "supported by port %u\n", res->port_id);
4526 } else if (!strcmp(res->proto, "outer-udp")) {
4527 if (hw == 0 || (dev_info.tx_offload_capa &
4528 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4530 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4532 printf("Outer UDP checksum offload is not "
4533 "supported by port %u\n", res->port_id);
4538 ports[res->port_id].dev_conf.txmode.offloads |=
4541 ports[res->port_id].dev_conf.txmode.offloads &=
4544 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4546 csum_show(res->port_id);
4548 cmd_reconfig_device_queue(res->port_id, 1, 1);
4551 cmdline_parse_token_string_t cmd_csum_csum =
4552 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4554 cmdline_parse_token_string_t cmd_csum_mode =
4555 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4557 cmdline_parse_token_string_t cmd_csum_proto =
4558 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4559 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4560 cmdline_parse_token_string_t cmd_csum_hwsw =
4561 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4563 cmdline_parse_token_num_t cmd_csum_portid =
4564 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4567 cmdline_parse_inst_t cmd_csum_set = {
4568 .f = cmd_csum_parsed,
4570 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4571 "Enable/Disable hardware calculation of L3/L4 checksum when "
4572 "using csum forward engine",
4574 (void *)&cmd_csum_csum,
4575 (void *)&cmd_csum_mode,
4576 (void *)&cmd_csum_proto,
4577 (void *)&cmd_csum_hwsw,
4578 (void *)&cmd_csum_portid,
4583 cmdline_parse_token_string_t cmd_csum_mode_show =
4584 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4587 cmdline_parse_inst_t cmd_csum_show = {
4588 .f = cmd_csum_parsed,
4590 .help_str = "csum show <port_id>: Show checksum offload configuration",
4592 (void *)&cmd_csum_csum,
4593 (void *)&cmd_csum_mode_show,
4594 (void *)&cmd_csum_portid,
4599 /* Enable/disable tunnel parsing */
4600 struct cmd_csum_tunnel_result {
4601 cmdline_fixed_string_t csum;
4602 cmdline_fixed_string_t parse;
4603 cmdline_fixed_string_t onoff;
4608 cmd_csum_tunnel_parsed(void *parsed_result,
4609 __attribute__((unused)) struct cmdline *cl,
4610 __attribute__((unused)) void *data)
4612 struct cmd_csum_tunnel_result *res = parsed_result;
4614 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4617 if (!strcmp(res->onoff, "on"))
4618 ports[res->port_id].parse_tunnel = 1;
4620 ports[res->port_id].parse_tunnel = 0;
4622 csum_show(res->port_id);
4625 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4626 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4628 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4629 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4630 parse, "parse-tunnel");
4631 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4632 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4634 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4635 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4638 cmdline_parse_inst_t cmd_csum_tunnel = {
4639 .f = cmd_csum_tunnel_parsed,
4641 .help_str = "csum parse-tunnel on|off <port_id>: "
4642 "Enable/Disable parsing of tunnels for csum engine",
4644 (void *)&cmd_csum_tunnel_csum,
4645 (void *)&cmd_csum_tunnel_parse,
4646 (void *)&cmd_csum_tunnel_onoff,
4647 (void *)&cmd_csum_tunnel_portid,
4652 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4653 struct cmd_tso_set_result {
4654 cmdline_fixed_string_t tso;
4655 cmdline_fixed_string_t mode;
4661 cmd_tso_set_parsed(void *parsed_result,
4662 __attribute__((unused)) struct cmdline *cl,
4663 __attribute__((unused)) void *data)
4665 struct cmd_tso_set_result *res = parsed_result;
4666 struct rte_eth_dev_info dev_info;
4669 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4671 if (!port_is_stopped(res->port_id)) {
4672 printf("Please stop port %d first\n", res->port_id);
4676 if (!strcmp(res->mode, "set"))
4677 ports[res->port_id].tso_segsz = res->tso_segsz;
4679 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4683 if ((ports[res->port_id].tso_segsz != 0) &&
4684 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4685 printf("Error: TSO is not supported by port %d\n",
4690 if (ports[res->port_id].tso_segsz == 0) {
4691 ports[res->port_id].dev_conf.txmode.offloads &=
4692 ~DEV_TX_OFFLOAD_TCP_TSO;
4693 printf("TSO for non-tunneled packets is disabled\n");
4695 ports[res->port_id].dev_conf.txmode.offloads |=
4696 DEV_TX_OFFLOAD_TCP_TSO;
4697 printf("TSO segment size for non-tunneled packets is %d\n",
4698 ports[res->port_id].tso_segsz);
4700 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4702 /* display warnings if configuration is not supported by the NIC */
4703 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4707 if ((ports[res->port_id].tso_segsz != 0) &&
4708 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4709 printf("Warning: TSO enabled but not "
4710 "supported by port %d\n", res->port_id);
4713 cmd_reconfig_device_queue(res->port_id, 1, 1);
4716 cmdline_parse_token_string_t cmd_tso_set_tso =
4717 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4719 cmdline_parse_token_string_t cmd_tso_set_mode =
4720 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4722 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4723 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4725 cmdline_parse_token_num_t cmd_tso_set_portid =
4726 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4729 cmdline_parse_inst_t cmd_tso_set = {
4730 .f = cmd_tso_set_parsed,
4732 .help_str = "tso set <tso_segsz> <port_id>: "
4733 "Set TSO segment size of non-tunneled packets for csum engine "
4736 (void *)&cmd_tso_set_tso,
4737 (void *)&cmd_tso_set_mode,
4738 (void *)&cmd_tso_set_tso_segsz,
4739 (void *)&cmd_tso_set_portid,
4744 cmdline_parse_token_string_t cmd_tso_show_mode =
4745 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4749 cmdline_parse_inst_t cmd_tso_show = {
4750 .f = cmd_tso_set_parsed,
4752 .help_str = "tso show <port_id>: "
4753 "Show TSO segment size of non-tunneled packets for csum engine",
4755 (void *)&cmd_tso_set_tso,
4756 (void *)&cmd_tso_show_mode,
4757 (void *)&cmd_tso_set_portid,
4762 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4763 struct cmd_tunnel_tso_set_result {
4764 cmdline_fixed_string_t tso;
4765 cmdline_fixed_string_t mode;
4770 static struct rte_eth_dev_info
4771 check_tunnel_tso_nic_support(portid_t port_id)
4773 struct rte_eth_dev_info dev_info;
4775 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4778 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4779 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4780 "not enabled for port %d\n", port_id);
4781 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4782 printf("Warning: GRE TUNNEL TSO not supported therefore "
4783 "not enabled for port %d\n", port_id);
4784 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4785 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4786 "not enabled for port %d\n", port_id);
4787 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4788 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4789 "not enabled for port %d\n", port_id);
4790 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4791 printf("Warning: IP TUNNEL TSO not supported therefore "
4792 "not enabled for port %d\n", port_id);
4793 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4794 printf("Warning: UDP TUNNEL TSO not supported therefore "
4795 "not enabled for port %d\n", port_id);
4800 cmd_tunnel_tso_set_parsed(void *parsed_result,
4801 __attribute__((unused)) struct cmdline *cl,
4802 __attribute__((unused)) void *data)
4804 struct cmd_tunnel_tso_set_result *res = parsed_result;
4805 struct rte_eth_dev_info dev_info;
4807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4809 if (!port_is_stopped(res->port_id)) {
4810 printf("Please stop port %d first\n", res->port_id);
4814 if (!strcmp(res->mode, "set"))
4815 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4817 dev_info = check_tunnel_tso_nic_support(res->port_id);
4818 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4819 ports[res->port_id].dev_conf.txmode.offloads &=
4820 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4821 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4822 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4823 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4824 DEV_TX_OFFLOAD_IP_TNL_TSO |
4825 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4826 printf("TSO for tunneled packets is disabled\n");
4828 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4829 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4830 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4831 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4832 DEV_TX_OFFLOAD_IP_TNL_TSO |
4833 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4835 ports[res->port_id].dev_conf.txmode.offloads |=
4836 (tso_offloads & dev_info.tx_offload_capa);
4837 printf("TSO segment size for tunneled packets is %d\n",
4838 ports[res->port_id].tunnel_tso_segsz);
4840 /* Below conditions are needed to make it work:
4841 * (1) tunnel TSO is supported by the NIC;
4842 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4844 * (3) for tunneled pkts with outer L3 of IPv4,
4845 * "csum set outer-ip" must be set to hw, because after tso,
4846 * total_len of outer IP header is changed, and the checksum
4847 * of outer IP header calculated by sw should be wrong; that
4848 * is not necessary for IPv6 tunneled pkts because there's no
4849 * checksum in IP header anymore.
4852 if (!ports[res->port_id].parse_tunnel)
4853 printf("Warning: csum parse_tunnel must be set "
4854 "so that tunneled packets are recognized\n");
4855 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4856 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4857 printf("Warning: csum set outer-ip must be set to hw "
4858 "if outer L3 is IPv4; not necessary for IPv6\n");
4861 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4862 cmd_reconfig_device_queue(res->port_id, 1, 1);
4865 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4866 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4868 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4869 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4871 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4872 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4874 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4875 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4878 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4879 .f = cmd_tunnel_tso_set_parsed,
4881 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4882 "Set TSO segment size of tunneled packets for csum engine "
4885 (void *)&cmd_tunnel_tso_set_tso,
4886 (void *)&cmd_tunnel_tso_set_mode,
4887 (void *)&cmd_tunnel_tso_set_tso_segsz,
4888 (void *)&cmd_tunnel_tso_set_portid,
4893 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4894 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4898 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4899 .f = cmd_tunnel_tso_set_parsed,
4901 .help_str = "tunnel_tso show <port_id> "
4902 "Show TSO segment size of tunneled packets for csum engine",
4904 (void *)&cmd_tunnel_tso_set_tso,
4905 (void *)&cmd_tunnel_tso_show_mode,
4906 (void *)&cmd_tunnel_tso_set_portid,
4911 /* *** SET GRO FOR A PORT *** */
4912 struct cmd_gro_enable_result {
4913 cmdline_fixed_string_t cmd_set;
4914 cmdline_fixed_string_t cmd_port;
4915 cmdline_fixed_string_t cmd_keyword;
4916 cmdline_fixed_string_t cmd_onoff;
4921 cmd_gro_enable_parsed(void *parsed_result,
4922 __attribute__((unused)) struct cmdline *cl,
4923 __attribute__((unused)) void *data)
4925 struct cmd_gro_enable_result *res;
4927 res = parsed_result;
4928 if (!strcmp(res->cmd_keyword, "gro"))
4929 setup_gro(res->cmd_onoff, res->cmd_pid);
4932 cmdline_parse_token_string_t cmd_gro_enable_set =
4933 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4935 cmdline_parse_token_string_t cmd_gro_enable_port =
4936 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4937 cmd_keyword, "port");
4938 cmdline_parse_token_num_t cmd_gro_enable_pid =
4939 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4941 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4942 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4943 cmd_keyword, "gro");
4944 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4945 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4946 cmd_onoff, "on#off");
4948 cmdline_parse_inst_t cmd_gro_enable = {
4949 .f = cmd_gro_enable_parsed,
4951 .help_str = "set port <port_id> gro on|off",
4953 (void *)&cmd_gro_enable_set,
4954 (void *)&cmd_gro_enable_port,
4955 (void *)&cmd_gro_enable_pid,
4956 (void *)&cmd_gro_enable_keyword,
4957 (void *)&cmd_gro_enable_onoff,
4962 /* *** DISPLAY GRO CONFIGURATION *** */
4963 struct cmd_gro_show_result {
4964 cmdline_fixed_string_t cmd_show;
4965 cmdline_fixed_string_t cmd_port;
4966 cmdline_fixed_string_t cmd_keyword;
4971 cmd_gro_show_parsed(void *parsed_result,
4972 __attribute__((unused)) struct cmdline *cl,
4973 __attribute__((unused)) void *data)
4975 struct cmd_gro_show_result *res;
4977 res = parsed_result;
4978 if (!strcmp(res->cmd_keyword, "gro"))
4979 show_gro(res->cmd_pid);
4982 cmdline_parse_token_string_t cmd_gro_show_show =
4983 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4985 cmdline_parse_token_string_t cmd_gro_show_port =
4986 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4988 cmdline_parse_token_num_t cmd_gro_show_pid =
4989 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4991 cmdline_parse_token_string_t cmd_gro_show_keyword =
4992 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4993 cmd_keyword, "gro");
4995 cmdline_parse_inst_t cmd_gro_show = {
4996 .f = cmd_gro_show_parsed,
4998 .help_str = "show port <port_id> gro",
5000 (void *)&cmd_gro_show_show,
5001 (void *)&cmd_gro_show_port,
5002 (void *)&cmd_gro_show_pid,
5003 (void *)&cmd_gro_show_keyword,
5008 /* *** SET FLUSH CYCLES FOR GRO *** */
5009 struct cmd_gro_flush_result {
5010 cmdline_fixed_string_t cmd_set;
5011 cmdline_fixed_string_t cmd_keyword;
5012 cmdline_fixed_string_t cmd_flush;
5017 cmd_gro_flush_parsed(void *parsed_result,
5018 __attribute__((unused)) struct cmdline *cl,
5019 __attribute__((unused)) void *data)
5021 struct cmd_gro_flush_result *res;
5023 res = parsed_result;
5024 if ((!strcmp(res->cmd_keyword, "gro")) &&
5025 (!strcmp(res->cmd_flush, "flush")))
5026 setup_gro_flush_cycles(res->cmd_cycles);
5029 cmdline_parse_token_string_t cmd_gro_flush_set =
5030 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5032 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5033 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5034 cmd_keyword, "gro");
5035 cmdline_parse_token_string_t cmd_gro_flush_flush =
5036 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5037 cmd_flush, "flush");
5038 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5039 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5042 cmdline_parse_inst_t cmd_gro_flush = {
5043 .f = cmd_gro_flush_parsed,
5045 .help_str = "set gro flush <cycles>",
5047 (void *)&cmd_gro_flush_set,
5048 (void *)&cmd_gro_flush_keyword,
5049 (void *)&cmd_gro_flush_flush,
5050 (void *)&cmd_gro_flush_cycles,
5055 /* *** ENABLE/DISABLE GSO *** */
5056 struct cmd_gso_enable_result {
5057 cmdline_fixed_string_t cmd_set;
5058 cmdline_fixed_string_t cmd_port;
5059 cmdline_fixed_string_t cmd_keyword;
5060 cmdline_fixed_string_t cmd_mode;
5065 cmd_gso_enable_parsed(void *parsed_result,
5066 __attribute__((unused)) struct cmdline *cl,
5067 __attribute__((unused)) void *data)
5069 struct cmd_gso_enable_result *res;
5071 res = parsed_result;
5072 if (!strcmp(res->cmd_keyword, "gso"))
5073 setup_gso(res->cmd_mode, res->cmd_pid);
5076 cmdline_parse_token_string_t cmd_gso_enable_set =
5077 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5079 cmdline_parse_token_string_t cmd_gso_enable_port =
5080 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5082 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5083 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5084 cmd_keyword, "gso");
5085 cmdline_parse_token_string_t cmd_gso_enable_mode =
5086 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5087 cmd_mode, "on#off");
5088 cmdline_parse_token_num_t cmd_gso_enable_pid =
5089 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5092 cmdline_parse_inst_t cmd_gso_enable = {
5093 .f = cmd_gso_enable_parsed,
5095 .help_str = "set port <port_id> gso on|off",
5097 (void *)&cmd_gso_enable_set,
5098 (void *)&cmd_gso_enable_port,
5099 (void *)&cmd_gso_enable_pid,
5100 (void *)&cmd_gso_enable_keyword,
5101 (void *)&cmd_gso_enable_mode,
5106 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5107 struct cmd_gso_size_result {
5108 cmdline_fixed_string_t cmd_set;
5109 cmdline_fixed_string_t cmd_keyword;
5110 cmdline_fixed_string_t cmd_segsz;
5115 cmd_gso_size_parsed(void *parsed_result,
5116 __attribute__((unused)) struct cmdline *cl,
5117 __attribute__((unused)) void *data)
5119 struct cmd_gso_size_result *res = parsed_result;
5121 if (test_done == 0) {
5122 printf("Before setting GSO segsz, please first"
5123 " stop fowarding\n");
5127 if (!strcmp(res->cmd_keyword, "gso") &&
5128 !strcmp(res->cmd_segsz, "segsz")) {
5129 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5130 printf("gso_size should be larger than %zu."
5131 " Please input a legal value\n",
5132 RTE_GSO_SEG_SIZE_MIN);
5134 gso_max_segment_size = res->cmd_size;
5138 cmdline_parse_token_string_t cmd_gso_size_set =
5139 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5141 cmdline_parse_token_string_t cmd_gso_size_keyword =
5142 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5143 cmd_keyword, "gso");
5144 cmdline_parse_token_string_t cmd_gso_size_segsz =
5145 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5146 cmd_segsz, "segsz");
5147 cmdline_parse_token_num_t cmd_gso_size_size =
5148 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5151 cmdline_parse_inst_t cmd_gso_size = {
5152 .f = cmd_gso_size_parsed,
5154 .help_str = "set gso segsz <length>",
5156 (void *)&cmd_gso_size_set,
5157 (void *)&cmd_gso_size_keyword,
5158 (void *)&cmd_gso_size_segsz,
5159 (void *)&cmd_gso_size_size,
5164 /* *** SHOW GSO CONFIGURATION *** */
5165 struct cmd_gso_show_result {
5166 cmdline_fixed_string_t cmd_show;
5167 cmdline_fixed_string_t cmd_port;
5168 cmdline_fixed_string_t cmd_keyword;
5173 cmd_gso_show_parsed(void *parsed_result,
5174 __attribute__((unused)) struct cmdline *cl,
5175 __attribute__((unused)) void *data)
5177 struct cmd_gso_show_result *res = parsed_result;
5179 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5180 printf("invalid port id %u\n", res->cmd_pid);
5183 if (!strcmp(res->cmd_keyword, "gso")) {
5184 if (gso_ports[res->cmd_pid].enable) {
5185 printf("Max GSO'd packet size: %uB\n"
5186 "Supported GSO types: TCP/IPv4, "
5187 "UDP/IPv4, VxLAN with inner "
5188 "TCP/IPv4 packet, GRE with inner "
5189 "TCP/IPv4 packet\n",
5190 gso_max_segment_size);
5192 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5196 cmdline_parse_token_string_t cmd_gso_show_show =
5197 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5199 cmdline_parse_token_string_t cmd_gso_show_port =
5200 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5202 cmdline_parse_token_string_t cmd_gso_show_keyword =
5203 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5204 cmd_keyword, "gso");
5205 cmdline_parse_token_num_t cmd_gso_show_pid =
5206 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5209 cmdline_parse_inst_t cmd_gso_show = {
5210 .f = cmd_gso_show_parsed,
5212 .help_str = "show port <port_id> gso",
5214 (void *)&cmd_gso_show_show,
5215 (void *)&cmd_gso_show_port,
5216 (void *)&cmd_gso_show_pid,
5217 (void *)&cmd_gso_show_keyword,
5222 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5223 struct cmd_set_flush_rx {
5224 cmdline_fixed_string_t set;
5225 cmdline_fixed_string_t flush_rx;
5226 cmdline_fixed_string_t mode;
5230 cmd_set_flush_rx_parsed(void *parsed_result,
5231 __attribute__((unused)) struct cmdline *cl,
5232 __attribute__((unused)) void *data)
5234 struct cmd_set_flush_rx *res = parsed_result;
5235 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5238 cmdline_parse_token_string_t cmd_setflushrx_set =
5239 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5241 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5242 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5243 flush_rx, "flush_rx");
5244 cmdline_parse_token_string_t cmd_setflushrx_mode =
5245 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5249 cmdline_parse_inst_t cmd_set_flush_rx = {
5250 .f = cmd_set_flush_rx_parsed,
5251 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5254 (void *)&cmd_setflushrx_set,
5255 (void *)&cmd_setflushrx_flush_rx,
5256 (void *)&cmd_setflushrx_mode,
5261 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5262 struct cmd_set_link_check {
5263 cmdline_fixed_string_t set;
5264 cmdline_fixed_string_t link_check;
5265 cmdline_fixed_string_t mode;
5269 cmd_set_link_check_parsed(void *parsed_result,
5270 __attribute__((unused)) struct cmdline *cl,
5271 __attribute__((unused)) void *data)
5273 struct cmd_set_link_check *res = parsed_result;
5274 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5277 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5278 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5280 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5281 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5282 link_check, "link_check");
5283 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5284 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5288 cmdline_parse_inst_t cmd_set_link_check = {
5289 .f = cmd_set_link_check_parsed,
5290 .help_str = "set link_check on|off: Enable/Disable link status check "
5291 "when starting/stopping a port",
5294 (void *)&cmd_setlinkcheck_set,
5295 (void *)&cmd_setlinkcheck_link_check,
5296 (void *)&cmd_setlinkcheck_mode,
5301 /* *** SET NIC BYPASS MODE *** */
5302 struct cmd_set_bypass_mode_result {
5303 cmdline_fixed_string_t set;
5304 cmdline_fixed_string_t bypass;
5305 cmdline_fixed_string_t mode;
5306 cmdline_fixed_string_t value;
5311 cmd_set_bypass_mode_parsed(void *parsed_result,
5312 __attribute__((unused)) struct cmdline *cl,
5313 __attribute__((unused)) void *data)
5315 struct cmd_set_bypass_mode_result *res = parsed_result;
5316 portid_t port_id = res->port_id;
5317 int32_t rc = -EINVAL;
5319 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5320 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5322 if (!strcmp(res->value, "bypass"))
5323 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5324 else if (!strcmp(res->value, "isolate"))
5325 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5327 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5329 /* Set the bypass mode for the relevant port. */
5330 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5333 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5336 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5337 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5339 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5340 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5342 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5343 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5345 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5346 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5347 value, "normal#bypass#isolate");
5348 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5349 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5352 cmdline_parse_inst_t cmd_set_bypass_mode = {
5353 .f = cmd_set_bypass_mode_parsed,
5354 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5355 "Set the NIC bypass mode for port_id",
5358 (void *)&cmd_setbypass_mode_set,
5359 (void *)&cmd_setbypass_mode_bypass,
5360 (void *)&cmd_setbypass_mode_mode,
5361 (void *)&cmd_setbypass_mode_value,
5362 (void *)&cmd_setbypass_mode_port,
5367 /* *** SET NIC BYPASS EVENT *** */
5368 struct cmd_set_bypass_event_result {
5369 cmdline_fixed_string_t set;
5370 cmdline_fixed_string_t bypass;
5371 cmdline_fixed_string_t event;
5372 cmdline_fixed_string_t event_value;
5373 cmdline_fixed_string_t mode;
5374 cmdline_fixed_string_t mode_value;
5379 cmd_set_bypass_event_parsed(void *parsed_result,
5380 __attribute__((unused)) struct cmdline *cl,
5381 __attribute__((unused)) void *data)
5383 int32_t rc = -EINVAL;
5384 struct cmd_set_bypass_event_result *res = parsed_result;
5385 portid_t port_id = res->port_id;
5387 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5388 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5389 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5391 if (!strcmp(res->event_value, "timeout"))
5392 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5393 else if (!strcmp(res->event_value, "os_on"))
5394 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5395 else if (!strcmp(res->event_value, "os_off"))
5396 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5397 else if (!strcmp(res->event_value, "power_on"))
5398 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5399 else if (!strcmp(res->event_value, "power_off"))
5400 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5402 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5404 if (!strcmp(res->mode_value, "bypass"))
5405 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5406 else if (!strcmp(res->mode_value, "isolate"))
5407 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5409 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5411 /* Set the watchdog timeout. */
5412 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5415 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5416 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5420 printf("Failed to set timeout value %u "
5421 "for port %d, errto code: %d.\n",
5422 bypass_timeout, port_id, rc);
5426 /* Set the bypass event to transition to bypass mode. */
5427 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5432 printf("\t Failed to set bypass event for port = %d.\n",
5436 cmdline_parse_token_string_t cmd_setbypass_event_set =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5439 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5442 cmdline_parse_token_string_t cmd_setbypass_event_event =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5445 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5447 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5448 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5451 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5453 mode_value, "normal#bypass#isolate");
5454 cmdline_parse_token_num_t cmd_setbypass_event_port =
5455 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5458 cmdline_parse_inst_t cmd_set_bypass_event = {
5459 .f = cmd_set_bypass_event_parsed,
5460 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5461 "power_off mode normal|bypass|isolate <port_id>: "
5462 "Set the NIC bypass event mode for port_id",
5465 (void *)&cmd_setbypass_event_set,
5466 (void *)&cmd_setbypass_event_bypass,
5467 (void *)&cmd_setbypass_event_event,
5468 (void *)&cmd_setbypass_event_event_value,
5469 (void *)&cmd_setbypass_event_mode,
5470 (void *)&cmd_setbypass_event_mode_value,
5471 (void *)&cmd_setbypass_event_port,
5477 /* *** SET NIC BYPASS TIMEOUT *** */
5478 struct cmd_set_bypass_timeout_result {
5479 cmdline_fixed_string_t set;
5480 cmdline_fixed_string_t bypass;
5481 cmdline_fixed_string_t timeout;
5482 cmdline_fixed_string_t value;
5486 cmd_set_bypass_timeout_parsed(void *parsed_result,
5487 __attribute__((unused)) struct cmdline *cl,
5488 __attribute__((unused)) void *data)
5490 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5492 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5493 if (!strcmp(res->value, "1.5"))
5494 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5495 else if (!strcmp(res->value, "2"))
5496 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5497 else if (!strcmp(res->value, "3"))
5498 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5499 else if (!strcmp(res->value, "4"))
5500 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5501 else if (!strcmp(res->value, "8"))
5502 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5503 else if (!strcmp(res->value, "16"))
5504 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5505 else if (!strcmp(res->value, "32"))
5506 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5508 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5512 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5513 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5515 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5516 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5518 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5519 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5520 timeout, "timeout");
5521 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5522 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5523 value, "0#1.5#2#3#4#8#16#32");
5525 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5526 .f = cmd_set_bypass_timeout_parsed,
5527 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5528 "Set the NIC bypass watchdog timeout in seconds",
5531 (void *)&cmd_setbypass_timeout_set,
5532 (void *)&cmd_setbypass_timeout_bypass,
5533 (void *)&cmd_setbypass_timeout_timeout,
5534 (void *)&cmd_setbypass_timeout_value,
5539 /* *** SHOW NIC BYPASS MODE *** */
5540 struct cmd_show_bypass_config_result {
5541 cmdline_fixed_string_t show;
5542 cmdline_fixed_string_t bypass;
5543 cmdline_fixed_string_t config;
5548 cmd_show_bypass_config_parsed(void *parsed_result,
5549 __attribute__((unused)) struct cmdline *cl,
5550 __attribute__((unused)) void *data)
5552 struct cmd_show_bypass_config_result *res = parsed_result;
5553 portid_t port_id = res->port_id;
5555 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5556 uint32_t event_mode;
5557 uint32_t bypass_mode;
5558 uint32_t timeout = bypass_timeout;
5561 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5562 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5563 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5564 {"UNKNOWN", "normal", "bypass", "isolate"};
5565 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5572 int num_events = (sizeof events) / (sizeof events[0]);
5574 /* Display the bypass mode.*/
5575 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5576 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5580 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5581 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5583 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5586 /* Display the bypass timeout.*/
5587 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5588 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5590 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5592 /* Display the bypass events and associated modes. */
5593 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5595 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5596 printf("\tFailed to get bypass mode for event = %s\n",
5599 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5600 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5602 printf("\tbypass event: %-16s = %s\n", events[i],
5608 printf("\tFailed to get bypass configuration for port = %d\n",
5612 cmdline_parse_token_string_t cmd_showbypass_config_show =
5613 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5615 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5616 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5618 cmdline_parse_token_string_t cmd_showbypass_config_config =
5619 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5621 cmdline_parse_token_num_t cmd_showbypass_config_port =
5622 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5625 cmdline_parse_inst_t cmd_show_bypass_config = {
5626 .f = cmd_show_bypass_config_parsed,
5627 .help_str = "show bypass config <port_id>: "
5628 "Show the NIC bypass config for port_id",
5631 (void *)&cmd_showbypass_config_show,
5632 (void *)&cmd_showbypass_config_bypass,
5633 (void *)&cmd_showbypass_config_config,
5634 (void *)&cmd_showbypass_config_port,
5639 #ifdef RTE_LIBRTE_PMD_BOND
5640 /* *** SET BONDING MODE *** */
5641 struct cmd_set_bonding_mode_result {
5642 cmdline_fixed_string_t set;
5643 cmdline_fixed_string_t bonding;
5644 cmdline_fixed_string_t mode;
5649 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5650 __attribute__((unused)) struct cmdline *cl,
5651 __attribute__((unused)) void *data)
5653 struct cmd_set_bonding_mode_result *res = parsed_result;
5654 portid_t port_id = res->port_id;
5656 /* Set the bonding mode for the relevant port. */
5657 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5658 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5661 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5662 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5664 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5665 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5666 bonding, "bonding");
5667 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5668 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5670 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5671 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5673 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5674 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5677 cmdline_parse_inst_t cmd_set_bonding_mode = {
5678 .f = cmd_set_bonding_mode_parsed,
5679 .help_str = "set bonding mode <mode_value> <port_id>: "
5680 "Set the bonding mode for port_id",
5683 (void *) &cmd_setbonding_mode_set,
5684 (void *) &cmd_setbonding_mode_bonding,
5685 (void *) &cmd_setbonding_mode_mode,
5686 (void *) &cmd_setbonding_mode_value,
5687 (void *) &cmd_setbonding_mode_port,
5692 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5693 struct cmd_set_bonding_lacp_dedicated_queues_result {
5694 cmdline_fixed_string_t set;
5695 cmdline_fixed_string_t bonding;
5696 cmdline_fixed_string_t lacp;
5697 cmdline_fixed_string_t dedicated_queues;
5699 cmdline_fixed_string_t mode;
5702 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5703 __attribute__((unused)) struct cmdline *cl,
5704 __attribute__((unused)) void *data)
5706 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5707 portid_t port_id = res->port_id;
5708 struct rte_port *port;
5710 port = &ports[port_id];
5712 /** Check if the port is not started **/
5713 if (port->port_status != RTE_PORT_STOPPED) {
5714 printf("Please stop port %d first\n", port_id);
5718 if (!strcmp(res->mode, "enable")) {
5719 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5720 printf("Dedicate queues for LACP control packets"
5723 printf("Enabling dedicate queues for LACP control "
5724 "packets on port %d failed\n", port_id);
5725 } else if (!strcmp(res->mode, "disable")) {
5726 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5727 printf("Dedicated queues for LACP control packets "
5730 printf("Disabling dedicated queues for LACP control "
5731 "traffic on port %d failed\n", port_id);
5735 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5736 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5738 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5739 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5740 bonding, "bonding");
5741 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5742 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5744 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5746 dedicated_queues, "dedicated_queues");
5747 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5748 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5750 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5752 mode, "enable#disable");
5754 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5755 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5756 .help_str = "set bonding lacp dedicated_queues <port_id> "
5758 "Enable/disable dedicated queues for LACP control traffic for port_id",
5761 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5762 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5763 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5764 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5765 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5766 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5771 /* *** SET BALANCE XMIT POLICY *** */
5772 struct cmd_set_bonding_balance_xmit_policy_result {
5773 cmdline_fixed_string_t set;
5774 cmdline_fixed_string_t bonding;
5775 cmdline_fixed_string_t balance_xmit_policy;
5777 cmdline_fixed_string_t policy;
5780 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5781 __attribute__((unused)) struct cmdline *cl,
5782 __attribute__((unused)) void *data)
5784 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5785 portid_t port_id = res->port_id;
5788 if (!strcmp(res->policy, "l2")) {
5789 policy = BALANCE_XMIT_POLICY_LAYER2;
5790 } else if (!strcmp(res->policy, "l23")) {
5791 policy = BALANCE_XMIT_POLICY_LAYER23;
5792 } else if (!strcmp(res->policy, "l34")) {
5793 policy = BALANCE_XMIT_POLICY_LAYER34;
5795 printf("\t Invalid xmit policy selection");
5799 /* Set the bonding mode for the relevant port. */
5800 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5801 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5806 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5807 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5809 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5810 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5811 bonding, "bonding");
5812 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5813 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5814 balance_xmit_policy, "balance_xmit_policy");
5815 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5816 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5818 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5819 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5820 policy, "l2#l23#l34");
5822 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5823 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5824 .help_str = "set bonding balance_xmit_policy <port_id> "
5826 "Set the bonding balance_xmit_policy for port_id",
5829 (void *)&cmd_setbonding_balance_xmit_policy_set,
5830 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5831 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5832 (void *)&cmd_setbonding_balance_xmit_policy_port,
5833 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5838 /* *** SHOW NIC BONDING CONFIGURATION *** */
5839 struct cmd_show_bonding_config_result {
5840 cmdline_fixed_string_t show;
5841 cmdline_fixed_string_t bonding;
5842 cmdline_fixed_string_t config;
5846 static void cmd_show_bonding_config_parsed(void *parsed_result,
5847 __attribute__((unused)) struct cmdline *cl,
5848 __attribute__((unused)) void *data)
5850 struct cmd_show_bonding_config_result *res = parsed_result;
5851 int bonding_mode, agg_mode;
5852 portid_t slaves[RTE_MAX_ETHPORTS];
5853 int num_slaves, num_active_slaves;
5856 portid_t port_id = res->port_id;
5858 /* Display the bonding mode.*/
5859 bonding_mode = rte_eth_bond_mode_get(port_id);
5860 if (bonding_mode < 0) {
5861 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5864 printf("\tBonding mode: %d\n", bonding_mode);
5866 if (bonding_mode == BONDING_MODE_BALANCE) {
5867 int balance_xmit_policy;
5869 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5870 if (balance_xmit_policy < 0) {
5871 printf("\tFailed to get balance xmit policy for port = %d\n",
5875 printf("\tBalance Xmit Policy: ");
5877 switch (balance_xmit_policy) {
5878 case BALANCE_XMIT_POLICY_LAYER2:
5879 printf("BALANCE_XMIT_POLICY_LAYER2");
5881 case BALANCE_XMIT_POLICY_LAYER23:
5882 printf("BALANCE_XMIT_POLICY_LAYER23");
5884 case BALANCE_XMIT_POLICY_LAYER34:
5885 printf("BALANCE_XMIT_POLICY_LAYER34");
5892 if (bonding_mode == BONDING_MODE_8023AD) {
5893 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5894 printf("\tIEEE802.3AD Aggregator Mode: ");
5897 printf("bandwidth");
5909 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5911 if (num_slaves < 0) {
5912 printf("\tFailed to get slave list for port = %d\n", port_id);
5915 if (num_slaves > 0) {
5916 printf("\tSlaves (%d): [", num_slaves);
5917 for (i = 0; i < num_slaves - 1; i++)
5918 printf("%d ", slaves[i]);
5920 printf("%d]\n", slaves[num_slaves - 1]);
5922 printf("\tSlaves: []\n");
5926 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5929 if (num_active_slaves < 0) {
5930 printf("\tFailed to get active slave list for port = %d\n", port_id);
5933 if (num_active_slaves > 0) {
5934 printf("\tActive Slaves (%d): [", num_active_slaves);
5935 for (i = 0; i < num_active_slaves - 1; i++)
5936 printf("%d ", slaves[i]);
5938 printf("%d]\n", slaves[num_active_slaves - 1]);
5941 printf("\tActive Slaves: []\n");
5945 primary_id = rte_eth_bond_primary_get(port_id);
5946 if (primary_id < 0) {
5947 printf("\tFailed to get primary slave for port = %d\n", port_id);
5950 printf("\tPrimary: [%d]\n", primary_id);
5954 cmdline_parse_token_string_t cmd_showbonding_config_show =
5955 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5957 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5958 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5959 bonding, "bonding");
5960 cmdline_parse_token_string_t cmd_showbonding_config_config =
5961 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5963 cmdline_parse_token_num_t cmd_showbonding_config_port =
5964 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5967 cmdline_parse_inst_t cmd_show_bonding_config = {
5968 .f = cmd_show_bonding_config_parsed,
5969 .help_str = "show bonding config <port_id>: "
5970 "Show the bonding config for port_id",
5973 (void *)&cmd_showbonding_config_show,
5974 (void *)&cmd_showbonding_config_bonding,
5975 (void *)&cmd_showbonding_config_config,
5976 (void *)&cmd_showbonding_config_port,
5981 /* *** SET BONDING PRIMARY *** */
5982 struct cmd_set_bonding_primary_result {
5983 cmdline_fixed_string_t set;
5984 cmdline_fixed_string_t bonding;
5985 cmdline_fixed_string_t primary;
5990 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5991 __attribute__((unused)) struct cmdline *cl,
5992 __attribute__((unused)) void *data)
5994 struct cmd_set_bonding_primary_result *res = parsed_result;
5995 portid_t master_port_id = res->port_id;
5996 portid_t slave_port_id = res->slave_id;
5998 /* Set the primary slave for a bonded device. */
5999 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6000 printf("\t Failed to set primary slave for port = %d.\n",
6007 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6008 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6010 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6011 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6012 bonding, "bonding");
6013 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6014 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6015 primary, "primary");
6016 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6017 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6019 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6020 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6023 cmdline_parse_inst_t cmd_set_bonding_primary = {
6024 .f = cmd_set_bonding_primary_parsed,
6025 .help_str = "set bonding primary <slave_id> <port_id>: "
6026 "Set the primary slave for port_id",
6029 (void *)&cmd_setbonding_primary_set,
6030 (void *)&cmd_setbonding_primary_bonding,
6031 (void *)&cmd_setbonding_primary_primary,
6032 (void *)&cmd_setbonding_primary_slave,
6033 (void *)&cmd_setbonding_primary_port,
6038 /* *** ADD SLAVE *** */
6039 struct cmd_add_bonding_slave_result {
6040 cmdline_fixed_string_t add;
6041 cmdline_fixed_string_t bonding;
6042 cmdline_fixed_string_t slave;
6047 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6048 __attribute__((unused)) struct cmdline *cl,
6049 __attribute__((unused)) void *data)
6051 struct cmd_add_bonding_slave_result *res = parsed_result;
6052 portid_t master_port_id = res->port_id;
6053 portid_t slave_port_id = res->slave_id;
6055 /* add the slave for a bonded device. */
6056 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6057 printf("\t Failed to add slave %d to master port = %d.\n",
6058 slave_port_id, master_port_id);
6062 set_port_slave_flag(slave_port_id);
6065 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6066 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6068 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6069 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6070 bonding, "bonding");
6071 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6072 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6074 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6075 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6077 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6078 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6081 cmdline_parse_inst_t cmd_add_bonding_slave = {
6082 .f = cmd_add_bonding_slave_parsed,
6083 .help_str = "add bonding slave <slave_id> <port_id>: "
6084 "Add a slave device to a bonded device",
6087 (void *)&cmd_addbonding_slave_add,
6088 (void *)&cmd_addbonding_slave_bonding,
6089 (void *)&cmd_addbonding_slave_slave,
6090 (void *)&cmd_addbonding_slave_slaveid,
6091 (void *)&cmd_addbonding_slave_port,
6096 /* *** REMOVE SLAVE *** */
6097 struct cmd_remove_bonding_slave_result {
6098 cmdline_fixed_string_t remove;
6099 cmdline_fixed_string_t bonding;
6100 cmdline_fixed_string_t slave;
6105 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6106 __attribute__((unused)) struct cmdline *cl,
6107 __attribute__((unused)) void *data)
6109 struct cmd_remove_bonding_slave_result *res = parsed_result;
6110 portid_t master_port_id = res->port_id;
6111 portid_t slave_port_id = res->slave_id;
6113 /* remove the slave from a bonded device. */
6114 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6115 printf("\t Failed to remove slave %d from master port = %d.\n",
6116 slave_port_id, master_port_id);
6120 clear_port_slave_flag(slave_port_id);
6123 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6124 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6126 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6127 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6128 bonding, "bonding");
6129 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6130 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6132 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6133 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6135 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6136 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6139 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6140 .f = cmd_remove_bonding_slave_parsed,
6141 .help_str = "remove bonding slave <slave_id> <port_id>: "
6142 "Remove a slave device from a bonded device",
6145 (void *)&cmd_removebonding_slave_remove,
6146 (void *)&cmd_removebonding_slave_bonding,
6147 (void *)&cmd_removebonding_slave_slave,
6148 (void *)&cmd_removebonding_slave_slaveid,
6149 (void *)&cmd_removebonding_slave_port,
6154 /* *** CREATE BONDED DEVICE *** */
6155 struct cmd_create_bonded_device_result {
6156 cmdline_fixed_string_t create;
6157 cmdline_fixed_string_t bonded;
6158 cmdline_fixed_string_t device;
6163 static int bond_dev_num = 0;
6165 static void cmd_create_bonded_device_parsed(void *parsed_result,
6166 __attribute__((unused)) struct cmdline *cl,
6167 __attribute__((unused)) void *data)
6169 struct cmd_create_bonded_device_result *res = parsed_result;
6170 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6174 if (test_done == 0) {
6175 printf("Please stop forwarding first\n");
6179 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6182 /* Create a new bonded device. */
6183 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6185 printf("\t Failed to create bonded device.\n");
6188 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6191 /* Update number of ports */
6192 nb_ports = rte_eth_dev_count_avail();
6193 reconfig(port_id, res->socket);
6194 ret = rte_eth_promiscuous_enable(port_id);
6196 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6197 port_id, rte_strerror(-ret));
6199 ports[port_id].need_setup = 0;
6200 ports[port_id].port_status = RTE_PORT_STOPPED;
6205 cmdline_parse_token_string_t cmd_createbonded_device_create =
6206 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6208 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6209 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6211 cmdline_parse_token_string_t cmd_createbonded_device_device =
6212 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6214 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6215 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6217 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6218 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6221 cmdline_parse_inst_t cmd_create_bonded_device = {
6222 .f = cmd_create_bonded_device_parsed,
6223 .help_str = "create bonded device <mode> <socket>: "
6224 "Create a new bonded device with specific bonding mode and socket",
6227 (void *)&cmd_createbonded_device_create,
6228 (void *)&cmd_createbonded_device_bonded,
6229 (void *)&cmd_createbonded_device_device,
6230 (void *)&cmd_createbonded_device_mode,
6231 (void *)&cmd_createbonded_device_socket,
6236 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6237 struct cmd_set_bond_mac_addr_result {
6238 cmdline_fixed_string_t set;
6239 cmdline_fixed_string_t bonding;
6240 cmdline_fixed_string_t mac_addr;
6242 struct rte_ether_addr address;
6245 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6246 __attribute__((unused)) struct cmdline *cl,
6247 __attribute__((unused)) void *data)
6249 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6252 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6255 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6257 /* check the return value and print it if is < 0 */
6259 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6262 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6263 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6264 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6265 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6267 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6268 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6270 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6271 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6273 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6274 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6276 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6277 .f = cmd_set_bond_mac_addr_parsed,
6279 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6281 (void *)&cmd_set_bond_mac_addr_set,
6282 (void *)&cmd_set_bond_mac_addr_bonding,
6283 (void *)&cmd_set_bond_mac_addr_mac,
6284 (void *)&cmd_set_bond_mac_addr_portnum,
6285 (void *)&cmd_set_bond_mac_addr_addr,
6291 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6292 struct cmd_set_bond_mon_period_result {
6293 cmdline_fixed_string_t set;
6294 cmdline_fixed_string_t bonding;
6295 cmdline_fixed_string_t mon_period;
6300 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6301 __attribute__((unused)) struct cmdline *cl,
6302 __attribute__((unused)) void *data)
6304 struct cmd_set_bond_mon_period_result *res = parsed_result;
6307 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6309 /* check the return value and print it if is < 0 */
6311 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6314 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6315 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6317 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6318 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6319 bonding, "bonding");
6320 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6321 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6322 mon_period, "mon_period");
6323 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6324 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6326 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6327 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6330 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6331 .f = cmd_set_bond_mon_period_parsed,
6333 .help_str = "set bonding mon_period <port_id> <period_ms>",
6335 (void *)&cmd_set_bond_mon_period_set,
6336 (void *)&cmd_set_bond_mon_period_bonding,
6337 (void *)&cmd_set_bond_mon_period_mon_period,
6338 (void *)&cmd_set_bond_mon_period_portnum,
6339 (void *)&cmd_set_bond_mon_period_period_ms,
6346 struct cmd_set_bonding_agg_mode_policy_result {
6347 cmdline_fixed_string_t set;
6348 cmdline_fixed_string_t bonding;
6349 cmdline_fixed_string_t agg_mode;
6351 cmdline_fixed_string_t policy;
6356 cmd_set_bonding_agg_mode(void *parsed_result,
6357 __attribute__((unused)) struct cmdline *cl,
6358 __attribute__((unused)) void *data)
6360 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6361 uint8_t policy = AGG_BANDWIDTH;
6363 if (!strcmp(res->policy, "bandwidth"))
6364 policy = AGG_BANDWIDTH;
6365 else if (!strcmp(res->policy, "stable"))
6366 policy = AGG_STABLE;
6367 else if (!strcmp(res->policy, "count"))
6370 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6374 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6375 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6377 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6378 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6379 bonding, "bonding");
6381 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6382 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6383 agg_mode, "agg_mode");
6385 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6386 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6389 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6390 TOKEN_STRING_INITIALIZER(
6391 struct cmd_set_bonding_balance_xmit_policy_result,
6392 policy, "stable#bandwidth#count");
6394 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6395 .f = cmd_set_bonding_agg_mode,
6397 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6399 (void *)&cmd_set_bonding_agg_mode_set,
6400 (void *)&cmd_set_bonding_agg_mode_bonding,
6401 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6402 (void *)&cmd_set_bonding_agg_mode_portnum,
6403 (void *)&cmd_set_bonding_agg_mode_policy_string,
6409 #endif /* RTE_LIBRTE_PMD_BOND */
6411 /* *** SET FORWARDING MODE *** */
6412 struct cmd_set_fwd_mode_result {
6413 cmdline_fixed_string_t set;
6414 cmdline_fixed_string_t fwd;
6415 cmdline_fixed_string_t mode;
6418 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6419 __attribute__((unused)) struct cmdline *cl,
6420 __attribute__((unused)) void *data)
6422 struct cmd_set_fwd_mode_result *res = parsed_result;
6425 set_pkt_forwarding_mode(res->mode);
6428 cmdline_parse_token_string_t cmd_setfwd_set =
6429 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6430 cmdline_parse_token_string_t cmd_setfwd_fwd =
6431 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6432 cmdline_parse_token_string_t cmd_setfwd_mode =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6434 "" /* defined at init */);
6436 cmdline_parse_inst_t cmd_set_fwd_mode = {
6437 .f = cmd_set_fwd_mode_parsed,
6439 .help_str = NULL, /* defined at init */
6441 (void *)&cmd_setfwd_set,
6442 (void *)&cmd_setfwd_fwd,
6443 (void *)&cmd_setfwd_mode,
6448 static void cmd_set_fwd_mode_init(void)
6451 static char token[128];
6452 static char help[256];
6453 cmdline_parse_token_string_t *token_struct;
6455 modes = list_pkt_forwarding_modes();
6456 snprintf(help, sizeof(help), "set fwd %s: "
6457 "Set packet forwarding mode", modes);
6458 cmd_set_fwd_mode.help_str = help;
6460 /* string token separator is # */
6461 for (c = token; *modes != '\0'; modes++)
6466 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6467 token_struct->string_data.str = token;
6470 /* *** SET RETRY FORWARDING MODE *** */
6471 struct cmd_set_fwd_retry_mode_result {
6472 cmdline_fixed_string_t set;
6473 cmdline_fixed_string_t fwd;
6474 cmdline_fixed_string_t mode;
6475 cmdline_fixed_string_t retry;
6478 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6479 __attribute__((unused)) struct cmdline *cl,
6480 __attribute__((unused)) void *data)
6482 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6485 set_pkt_forwarding_mode(res->mode);
6488 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6491 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6492 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6494 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6495 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6497 "" /* defined at init */);
6498 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6499 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6502 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6503 .f = cmd_set_fwd_retry_mode_parsed,
6505 .help_str = NULL, /* defined at init */
6507 (void *)&cmd_setfwd_retry_set,
6508 (void *)&cmd_setfwd_retry_fwd,
6509 (void *)&cmd_setfwd_retry_mode,
6510 (void *)&cmd_setfwd_retry_retry,
6515 static void cmd_set_fwd_retry_mode_init(void)
6518 static char token[128];
6519 static char help[256];
6520 cmdline_parse_token_string_t *token_struct;
6522 modes = list_pkt_forwarding_retry_modes();
6523 snprintf(help, sizeof(help), "set fwd %s retry: "
6524 "Set packet forwarding mode with retry", modes);
6525 cmd_set_fwd_retry_mode.help_str = help;
6527 /* string token separator is # */
6528 for (c = token; *modes != '\0'; modes++)
6533 token_struct = (cmdline_parse_token_string_t *)
6534 cmd_set_fwd_retry_mode.tokens[2];
6535 token_struct->string_data.str = token;
6538 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6539 struct cmd_set_burst_tx_retry_result {
6540 cmdline_fixed_string_t set;
6541 cmdline_fixed_string_t burst;
6542 cmdline_fixed_string_t tx;
6543 cmdline_fixed_string_t delay;
6545 cmdline_fixed_string_t retry;
6549 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6550 __attribute__((unused)) struct cmdline *cl,
6551 __attribute__((unused)) void *data)
6553 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6555 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6556 && !strcmp(res->tx, "tx")) {
6557 if (!strcmp(res->delay, "delay"))
6558 burst_tx_delay_time = res->time;
6559 if (!strcmp(res->retry, "retry"))
6560 burst_tx_retry_num = res->retry_num;
6565 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6566 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6567 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6568 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6570 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6571 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6572 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6574 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6575 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6576 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6577 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6578 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6579 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6581 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6582 .f = cmd_set_burst_tx_retry_parsed,
6583 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6585 (void *)&cmd_set_burst_tx_retry_set,
6586 (void *)&cmd_set_burst_tx_retry_burst,
6587 (void *)&cmd_set_burst_tx_retry_tx,
6588 (void *)&cmd_set_burst_tx_retry_delay,
6589 (void *)&cmd_set_burst_tx_retry_time,
6590 (void *)&cmd_set_burst_tx_retry_retry,
6591 (void *)&cmd_set_burst_tx_retry_retry_num,
6596 /* *** SET PROMISC MODE *** */
6597 struct cmd_set_promisc_mode_result {
6598 cmdline_fixed_string_t set;
6599 cmdline_fixed_string_t promisc;
6600 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6601 uint16_t port_num; /* valid if "allports" argument == 0 */
6602 cmdline_fixed_string_t mode;
6605 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6606 __attribute__((unused)) struct cmdline *cl,
6609 struct cmd_set_promisc_mode_result *res = parsed_result;
6613 if (!strcmp(res->mode, "on"))
6620 RTE_ETH_FOREACH_DEV(i)
6621 eth_set_promisc_mode(i, enable);
6623 eth_set_promisc_mode(res->port_num, enable);
6627 cmdline_parse_token_string_t cmd_setpromisc_set =
6628 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6629 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6630 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6632 cmdline_parse_token_string_t cmd_setpromisc_portall =
6633 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6635 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6636 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6638 cmdline_parse_token_string_t cmd_setpromisc_mode =
6639 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6642 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6643 .f = cmd_set_promisc_mode_parsed,
6645 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6647 (void *)&cmd_setpromisc_set,
6648 (void *)&cmd_setpromisc_promisc,
6649 (void *)&cmd_setpromisc_portall,
6650 (void *)&cmd_setpromisc_mode,
6655 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6656 .f = cmd_set_promisc_mode_parsed,
6658 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6660 (void *)&cmd_setpromisc_set,
6661 (void *)&cmd_setpromisc_promisc,
6662 (void *)&cmd_setpromisc_portnum,
6663 (void *)&cmd_setpromisc_mode,
6668 /* *** SET ALLMULTI MODE *** */
6669 struct cmd_set_allmulti_mode_result {
6670 cmdline_fixed_string_t set;
6671 cmdline_fixed_string_t allmulti;
6672 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6673 uint16_t port_num; /* valid if "allports" argument == 0 */
6674 cmdline_fixed_string_t mode;
6677 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6678 __attribute__((unused)) struct cmdline *cl,
6681 struct cmd_set_allmulti_mode_result *res = parsed_result;
6685 if (!strcmp(res->mode, "on"))
6692 RTE_ETH_FOREACH_DEV(i) {
6693 eth_set_allmulticast_mode(i, enable);
6697 eth_set_allmulticast_mode(res->port_num, enable);
6701 cmdline_parse_token_string_t cmd_setallmulti_set =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6703 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6704 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6706 cmdline_parse_token_string_t cmd_setallmulti_portall =
6707 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6709 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6710 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6712 cmdline_parse_token_string_t cmd_setallmulti_mode =
6713 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6716 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6717 .f = cmd_set_allmulti_mode_parsed,
6719 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6721 (void *)&cmd_setallmulti_set,
6722 (void *)&cmd_setallmulti_allmulti,
6723 (void *)&cmd_setallmulti_portall,
6724 (void *)&cmd_setallmulti_mode,
6729 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6730 .f = cmd_set_allmulti_mode_parsed,
6732 .help_str = "set allmulti <port_id> on|off: "
6733 "Set allmulti mode on port_id",
6735 (void *)&cmd_setallmulti_set,
6736 (void *)&cmd_setallmulti_allmulti,
6737 (void *)&cmd_setallmulti_portnum,
6738 (void *)&cmd_setallmulti_mode,
6743 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6744 struct cmd_link_flow_ctrl_set_result {
6745 cmdline_fixed_string_t set;
6746 cmdline_fixed_string_t flow_ctrl;
6747 cmdline_fixed_string_t rx;
6748 cmdline_fixed_string_t rx_lfc_mode;
6749 cmdline_fixed_string_t tx;
6750 cmdline_fixed_string_t tx_lfc_mode;
6751 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6752 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6753 cmdline_fixed_string_t autoneg_str;
6754 cmdline_fixed_string_t autoneg;
6755 cmdline_fixed_string_t hw_str;
6756 uint32_t high_water;
6757 cmdline_fixed_string_t lw_str;
6759 cmdline_fixed_string_t pt_str;
6760 uint16_t pause_time;
6761 cmdline_fixed_string_t xon_str;
6766 cmdline_parse_token_string_t cmd_lfc_set_set =
6767 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6769 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6770 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6771 flow_ctrl, "flow_ctrl");
6772 cmdline_parse_token_string_t cmd_lfc_set_rx =
6773 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6775 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6776 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6777 rx_lfc_mode, "on#off");
6778 cmdline_parse_token_string_t cmd_lfc_set_tx =
6779 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6781 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6782 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6783 tx_lfc_mode, "on#off");
6784 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6785 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6786 hw_str, "high_water");
6787 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6788 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6789 high_water, UINT32);
6790 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6791 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6792 lw_str, "low_water");
6793 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6794 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6796 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6797 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6798 pt_str, "pause_time");
6799 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6800 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6801 pause_time, UINT16);
6802 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6803 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6804 xon_str, "send_xon");
6805 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6806 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6808 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6809 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6810 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6811 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6812 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6813 mac_ctrl_frame_fwd_mode, "on#off");
6814 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6815 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6816 autoneg_str, "autoneg");
6817 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6818 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6820 cmdline_parse_token_num_t cmd_lfc_set_portid =
6821 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6824 /* forward declaration */
6826 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6829 cmdline_parse_inst_t cmd_link_flow_control_set = {
6830 .f = cmd_link_flow_ctrl_set_parsed,
6832 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6833 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6834 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6836 (void *)&cmd_lfc_set_set,
6837 (void *)&cmd_lfc_set_flow_ctrl,
6838 (void *)&cmd_lfc_set_rx,
6839 (void *)&cmd_lfc_set_rx_mode,
6840 (void *)&cmd_lfc_set_tx,
6841 (void *)&cmd_lfc_set_tx_mode,
6842 (void *)&cmd_lfc_set_high_water,
6843 (void *)&cmd_lfc_set_low_water,
6844 (void *)&cmd_lfc_set_pause_time,
6845 (void *)&cmd_lfc_set_send_xon,
6846 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6847 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6848 (void *)&cmd_lfc_set_autoneg_str,
6849 (void *)&cmd_lfc_set_autoneg,
6850 (void *)&cmd_lfc_set_portid,
6855 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6856 .f = cmd_link_flow_ctrl_set_parsed,
6857 .data = (void *)&cmd_link_flow_control_set_rx,
6858 .help_str = "set flow_ctrl rx on|off <port_id>: "
6859 "Change rx flow control parameter",
6861 (void *)&cmd_lfc_set_set,
6862 (void *)&cmd_lfc_set_flow_ctrl,
6863 (void *)&cmd_lfc_set_rx,
6864 (void *)&cmd_lfc_set_rx_mode,
6865 (void *)&cmd_lfc_set_portid,
6870 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6871 .f = cmd_link_flow_ctrl_set_parsed,
6872 .data = (void *)&cmd_link_flow_control_set_tx,
6873 .help_str = "set flow_ctrl tx on|off <port_id>: "
6874 "Change tx flow control parameter",
6876 (void *)&cmd_lfc_set_set,
6877 (void *)&cmd_lfc_set_flow_ctrl,
6878 (void *)&cmd_lfc_set_tx,
6879 (void *)&cmd_lfc_set_tx_mode,
6880 (void *)&cmd_lfc_set_portid,
6885 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6886 .f = cmd_link_flow_ctrl_set_parsed,
6887 .data = (void *)&cmd_link_flow_control_set_hw,
6888 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6889 "Change high water flow control parameter",
6891 (void *)&cmd_lfc_set_set,
6892 (void *)&cmd_lfc_set_flow_ctrl,
6893 (void *)&cmd_lfc_set_high_water_str,
6894 (void *)&cmd_lfc_set_high_water,
6895 (void *)&cmd_lfc_set_portid,
6900 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6901 .f = cmd_link_flow_ctrl_set_parsed,
6902 .data = (void *)&cmd_link_flow_control_set_lw,
6903 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6904 "Change low water flow control parameter",
6906 (void *)&cmd_lfc_set_set,
6907 (void *)&cmd_lfc_set_flow_ctrl,
6908 (void *)&cmd_lfc_set_low_water_str,
6909 (void *)&cmd_lfc_set_low_water,
6910 (void *)&cmd_lfc_set_portid,
6915 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6916 .f = cmd_link_flow_ctrl_set_parsed,
6917 .data = (void *)&cmd_link_flow_control_set_pt,
6918 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6919 "Change pause time flow control parameter",
6921 (void *)&cmd_lfc_set_set,
6922 (void *)&cmd_lfc_set_flow_ctrl,
6923 (void *)&cmd_lfc_set_pause_time_str,
6924 (void *)&cmd_lfc_set_pause_time,
6925 (void *)&cmd_lfc_set_portid,
6930 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6931 .f = cmd_link_flow_ctrl_set_parsed,
6932 .data = (void *)&cmd_link_flow_control_set_xon,
6933 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6934 "Change send_xon flow control parameter",
6936 (void *)&cmd_lfc_set_set,
6937 (void *)&cmd_lfc_set_flow_ctrl,
6938 (void *)&cmd_lfc_set_send_xon_str,
6939 (void *)&cmd_lfc_set_send_xon,
6940 (void *)&cmd_lfc_set_portid,
6945 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6946 .f = cmd_link_flow_ctrl_set_parsed,
6947 .data = (void *)&cmd_link_flow_control_set_macfwd,
6948 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6949 "Change mac ctrl fwd flow control parameter",
6951 (void *)&cmd_lfc_set_set,
6952 (void *)&cmd_lfc_set_flow_ctrl,
6953 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6954 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6955 (void *)&cmd_lfc_set_portid,
6960 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6961 .f = cmd_link_flow_ctrl_set_parsed,
6962 .data = (void *)&cmd_link_flow_control_set_autoneg,
6963 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6964 "Change autoneg flow control parameter",
6966 (void *)&cmd_lfc_set_set,
6967 (void *)&cmd_lfc_set_flow_ctrl,
6968 (void *)&cmd_lfc_set_autoneg_str,
6969 (void *)&cmd_lfc_set_autoneg,
6970 (void *)&cmd_lfc_set_portid,
6976 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6977 __attribute__((unused)) struct cmdline *cl,
6980 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6981 cmdline_parse_inst_t *cmd = data;
6982 struct rte_eth_fc_conf fc_conf;
6988 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6989 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6990 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6991 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6993 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6994 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6997 /* Partial command line, retrieve current configuration */
6999 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7001 printf("cannot get current flow ctrl parameters, return"
7002 "code = %d\n", ret);
7006 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7007 (fc_conf.mode == RTE_FC_FULL))
7009 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7010 (fc_conf.mode == RTE_FC_FULL))
7014 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7015 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7017 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7018 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7020 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7022 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7023 fc_conf.high_water = res->high_water;
7025 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7026 fc_conf.low_water = res->low_water;
7028 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7029 fc_conf.pause_time = res->pause_time;
7031 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7032 fc_conf.send_xon = res->send_xon;
7034 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7035 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7036 fc_conf.mac_ctrl_frame_fwd = 1;
7038 fc_conf.mac_ctrl_frame_fwd = 0;
7041 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7042 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7044 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7046 printf("bad flow contrl parameter, return code = %d \n", ret);
7049 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7050 struct cmd_priority_flow_ctrl_set_result {
7051 cmdline_fixed_string_t set;
7052 cmdline_fixed_string_t pfc_ctrl;
7053 cmdline_fixed_string_t rx;
7054 cmdline_fixed_string_t rx_pfc_mode;
7055 cmdline_fixed_string_t tx;
7056 cmdline_fixed_string_t tx_pfc_mode;
7057 uint32_t high_water;
7059 uint16_t pause_time;
7065 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7066 __attribute__((unused)) struct cmdline *cl,
7067 __attribute__((unused)) void *data)
7069 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7070 struct rte_eth_pfc_conf pfc_conf;
7071 int rx_fc_enable, tx_fc_enable;
7075 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7076 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7077 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7078 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7080 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7081 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7084 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7085 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7086 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7087 pfc_conf.fc.high_water = res->high_water;
7088 pfc_conf.fc.low_water = res->low_water;
7089 pfc_conf.fc.pause_time = res->pause_time;
7090 pfc_conf.priority = res->priority;
7092 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7094 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7097 cmdline_parse_token_string_t cmd_pfc_set_set =
7098 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7100 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7101 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7102 pfc_ctrl, "pfc_ctrl");
7103 cmdline_parse_token_string_t cmd_pfc_set_rx =
7104 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7106 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7107 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7108 rx_pfc_mode, "on#off");
7109 cmdline_parse_token_string_t cmd_pfc_set_tx =
7110 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7112 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7113 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7114 tx_pfc_mode, "on#off");
7115 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7116 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7117 high_water, UINT32);
7118 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7119 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7121 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7122 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7123 pause_time, UINT16);
7124 cmdline_parse_token_num_t cmd_pfc_set_priority =
7125 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7127 cmdline_parse_token_num_t cmd_pfc_set_portid =
7128 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7131 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7132 .f = cmd_priority_flow_ctrl_set_parsed,
7134 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7135 "<pause_time> <priority> <port_id>: "
7136 "Configure the Ethernet priority flow control",
7138 (void *)&cmd_pfc_set_set,
7139 (void *)&cmd_pfc_set_flow_ctrl,
7140 (void *)&cmd_pfc_set_rx,
7141 (void *)&cmd_pfc_set_rx_mode,
7142 (void *)&cmd_pfc_set_tx,
7143 (void *)&cmd_pfc_set_tx_mode,
7144 (void *)&cmd_pfc_set_high_water,
7145 (void *)&cmd_pfc_set_low_water,
7146 (void *)&cmd_pfc_set_pause_time,
7147 (void *)&cmd_pfc_set_priority,
7148 (void *)&cmd_pfc_set_portid,
7153 /* *** RESET CONFIGURATION *** */
7154 struct cmd_reset_result {
7155 cmdline_fixed_string_t reset;
7156 cmdline_fixed_string_t def;
7159 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7161 __attribute__((unused)) void *data)
7163 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7164 set_def_fwd_config();
7167 cmdline_parse_token_string_t cmd_reset_set =
7168 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7169 cmdline_parse_token_string_t cmd_reset_def =
7170 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7173 cmdline_parse_inst_t cmd_reset = {
7174 .f = cmd_reset_parsed,
7176 .help_str = "set default: Reset default forwarding configuration",
7178 (void *)&cmd_reset_set,
7179 (void *)&cmd_reset_def,
7184 /* *** START FORWARDING *** */
7185 struct cmd_start_result {
7186 cmdline_fixed_string_t start;
7189 cmdline_parse_token_string_t cmd_start_start =
7190 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7192 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7193 __attribute__((unused)) struct cmdline *cl,
7194 __attribute__((unused)) void *data)
7196 start_packet_forwarding(0);
7199 cmdline_parse_inst_t cmd_start = {
7200 .f = cmd_start_parsed,
7202 .help_str = "start: Start packet forwarding",
7204 (void *)&cmd_start_start,
7209 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7210 struct cmd_start_tx_first_result {
7211 cmdline_fixed_string_t start;
7212 cmdline_fixed_string_t tx_first;
7216 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7217 __attribute__((unused)) struct cmdline *cl,
7218 __attribute__((unused)) void *data)
7220 start_packet_forwarding(1);
7223 cmdline_parse_token_string_t cmd_start_tx_first_start =
7224 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7226 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7227 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7228 tx_first, "tx_first");
7230 cmdline_parse_inst_t cmd_start_tx_first = {
7231 .f = cmd_start_tx_first_parsed,
7233 .help_str = "start tx_first: Start packet forwarding, "
7234 "after sending 1 burst of packets",
7236 (void *)&cmd_start_tx_first_start,
7237 (void *)&cmd_start_tx_first_tx_first,
7242 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7243 struct cmd_start_tx_first_n_result {
7244 cmdline_fixed_string_t start;
7245 cmdline_fixed_string_t tx_first;
7250 cmd_start_tx_first_n_parsed(void *parsed_result,
7251 __attribute__((unused)) struct cmdline *cl,
7252 __attribute__((unused)) void *data)
7254 struct cmd_start_tx_first_n_result *res = parsed_result;
7256 start_packet_forwarding(res->tx_num);
7259 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7260 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7262 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7263 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7264 tx_first, "tx_first");
7265 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7266 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7269 cmdline_parse_inst_t cmd_start_tx_first_n = {
7270 .f = cmd_start_tx_first_n_parsed,
7272 .help_str = "start tx_first <num>: "
7273 "packet forwarding, after sending <num> bursts of packets",
7275 (void *)&cmd_start_tx_first_n_start,
7276 (void *)&cmd_start_tx_first_n_tx_first,
7277 (void *)&cmd_start_tx_first_n_tx_num,
7282 /* *** SET LINK UP *** */
7283 struct cmd_set_link_up_result {
7284 cmdline_fixed_string_t set;
7285 cmdline_fixed_string_t link_up;
7286 cmdline_fixed_string_t port;
7290 cmdline_parse_token_string_t cmd_set_link_up_set =
7291 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7292 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7293 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7295 cmdline_parse_token_string_t cmd_set_link_up_port =
7296 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7297 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7298 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7300 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7301 __attribute__((unused)) struct cmdline *cl,
7302 __attribute__((unused)) void *data)
7304 struct cmd_set_link_up_result *res = parsed_result;
7305 dev_set_link_up(res->port_id);
7308 cmdline_parse_inst_t cmd_set_link_up = {
7309 .f = cmd_set_link_up_parsed,
7311 .help_str = "set link-up port <port id>",
7313 (void *)&cmd_set_link_up_set,
7314 (void *)&cmd_set_link_up_link_up,
7315 (void *)&cmd_set_link_up_port,
7316 (void *)&cmd_set_link_up_port_id,
7321 /* *** SET LINK DOWN *** */
7322 struct cmd_set_link_down_result {
7323 cmdline_fixed_string_t set;
7324 cmdline_fixed_string_t link_down;
7325 cmdline_fixed_string_t port;
7329 cmdline_parse_token_string_t cmd_set_link_down_set =
7330 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7331 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7332 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7334 cmdline_parse_token_string_t cmd_set_link_down_port =
7335 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7336 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7337 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7339 static void cmd_set_link_down_parsed(
7340 __attribute__((unused)) void *parsed_result,
7341 __attribute__((unused)) struct cmdline *cl,
7342 __attribute__((unused)) void *data)
7344 struct cmd_set_link_down_result *res = parsed_result;
7345 dev_set_link_down(res->port_id);
7348 cmdline_parse_inst_t cmd_set_link_down = {
7349 .f = cmd_set_link_down_parsed,
7351 .help_str = "set link-down port <port id>",
7353 (void *)&cmd_set_link_down_set,
7354 (void *)&cmd_set_link_down_link_down,
7355 (void *)&cmd_set_link_down_port,
7356 (void *)&cmd_set_link_down_port_id,
7361 /* *** SHOW CFG *** */
7362 struct cmd_showcfg_result {
7363 cmdline_fixed_string_t show;
7364 cmdline_fixed_string_t cfg;
7365 cmdline_fixed_string_t what;
7368 static void cmd_showcfg_parsed(void *parsed_result,
7369 __attribute__((unused)) struct cmdline *cl,
7370 __attribute__((unused)) void *data)
7372 struct cmd_showcfg_result *res = parsed_result;
7373 if (!strcmp(res->what, "rxtx"))
7374 rxtx_config_display();
7375 else if (!strcmp(res->what, "cores"))
7376 fwd_lcores_config_display();
7377 else if (!strcmp(res->what, "fwd"))
7378 pkt_fwd_config_display(&cur_fwd_config);
7379 else if (!strcmp(res->what, "txpkts"))
7380 show_tx_pkt_segments();
7383 cmdline_parse_token_string_t cmd_showcfg_show =
7384 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7385 cmdline_parse_token_string_t cmd_showcfg_port =
7386 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7387 cmdline_parse_token_string_t cmd_showcfg_what =
7388 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7389 "rxtx#cores#fwd#txpkts");
7391 cmdline_parse_inst_t cmd_showcfg = {
7392 .f = cmd_showcfg_parsed,
7394 .help_str = "show config rxtx|cores|fwd|txpkts",
7396 (void *)&cmd_showcfg_show,
7397 (void *)&cmd_showcfg_port,
7398 (void *)&cmd_showcfg_what,
7403 /* *** SHOW ALL PORT INFO *** */
7404 struct cmd_showportall_result {
7405 cmdline_fixed_string_t show;
7406 cmdline_fixed_string_t port;
7407 cmdline_fixed_string_t what;
7408 cmdline_fixed_string_t all;
7411 static void cmd_showportall_parsed(void *parsed_result,
7412 __attribute__((unused)) struct cmdline *cl,
7413 __attribute__((unused)) void *data)
7417 struct cmd_showportall_result *res = parsed_result;
7418 if (!strcmp(res->show, "clear")) {
7419 if (!strcmp(res->what, "stats"))
7420 RTE_ETH_FOREACH_DEV(i)
7422 else if (!strcmp(res->what, "xstats"))
7423 RTE_ETH_FOREACH_DEV(i)
7424 nic_xstats_clear(i);
7425 } else if (!strcmp(res->what, "info"))
7426 RTE_ETH_FOREACH_DEV(i)
7427 port_infos_display(i);
7428 else if (!strcmp(res->what, "summary")) {
7429 port_summary_header_display();
7430 RTE_ETH_FOREACH_DEV(i)
7431 port_summary_display(i);
7433 else if (!strcmp(res->what, "stats"))
7434 RTE_ETH_FOREACH_DEV(i)
7435 nic_stats_display(i);
7436 else if (!strcmp(res->what, "xstats"))
7437 RTE_ETH_FOREACH_DEV(i)
7438 nic_xstats_display(i);
7439 else if (!strcmp(res->what, "fdir"))
7440 RTE_ETH_FOREACH_DEV(i)
7442 else if (!strcmp(res->what, "stat_qmap"))
7443 RTE_ETH_FOREACH_DEV(i)
7444 nic_stats_mapping_display(i);
7445 else if (!strcmp(res->what, "dcb_tc"))
7446 RTE_ETH_FOREACH_DEV(i)
7447 port_dcb_info_display(i);
7448 else if (!strcmp(res->what, "cap"))
7449 RTE_ETH_FOREACH_DEV(i)
7450 port_offload_cap_display(i);
7453 cmdline_parse_token_string_t cmd_showportall_show =
7454 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7456 cmdline_parse_token_string_t cmd_showportall_port =
7457 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7458 cmdline_parse_token_string_t cmd_showportall_what =
7459 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7460 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7461 cmdline_parse_token_string_t cmd_showportall_all =
7462 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7463 cmdline_parse_inst_t cmd_showportall = {
7464 .f = cmd_showportall_parsed,
7466 .help_str = "show|clear port "
7467 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7469 (void *)&cmd_showportall_show,
7470 (void *)&cmd_showportall_port,
7471 (void *)&cmd_showportall_what,
7472 (void *)&cmd_showportall_all,
7477 /* *** SHOW PORT INFO *** */
7478 struct cmd_showport_result {
7479 cmdline_fixed_string_t show;
7480 cmdline_fixed_string_t port;
7481 cmdline_fixed_string_t what;
7485 static void cmd_showport_parsed(void *parsed_result,
7486 __attribute__((unused)) struct cmdline *cl,
7487 __attribute__((unused)) void *data)
7489 struct cmd_showport_result *res = parsed_result;
7490 if (!strcmp(res->show, "clear")) {
7491 if (!strcmp(res->what, "stats"))
7492 nic_stats_clear(res->portnum);
7493 else if (!strcmp(res->what, "xstats"))
7494 nic_xstats_clear(res->portnum);
7495 } else if (!strcmp(res->what, "info"))
7496 port_infos_display(res->portnum);
7497 else if (!strcmp(res->what, "summary")) {
7498 port_summary_header_display();
7499 port_summary_display(res->portnum);
7501 else if (!strcmp(res->what, "stats"))
7502 nic_stats_display(res->portnum);
7503 else if (!strcmp(res->what, "xstats"))
7504 nic_xstats_display(res->portnum);
7505 else if (!strcmp(res->what, "fdir"))
7506 fdir_get_infos(res->portnum);
7507 else if (!strcmp(res->what, "stat_qmap"))
7508 nic_stats_mapping_display(res->portnum);
7509 else if (!strcmp(res->what, "dcb_tc"))
7510 port_dcb_info_display(res->portnum);
7511 else if (!strcmp(res->what, "cap"))
7512 port_offload_cap_display(res->portnum);
7515 cmdline_parse_token_string_t cmd_showport_show =
7516 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7518 cmdline_parse_token_string_t cmd_showport_port =
7519 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7520 cmdline_parse_token_string_t cmd_showport_what =
7521 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7522 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7523 cmdline_parse_token_num_t cmd_showport_portnum =
7524 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7526 cmdline_parse_inst_t cmd_showport = {
7527 .f = cmd_showport_parsed,
7529 .help_str = "show|clear port "
7530 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7533 (void *)&cmd_showport_show,
7534 (void *)&cmd_showport_port,
7535 (void *)&cmd_showport_what,
7536 (void *)&cmd_showport_portnum,
7541 /* *** SHOW DEVICE INFO *** */
7542 struct cmd_showdevice_result {
7543 cmdline_fixed_string_t show;
7544 cmdline_fixed_string_t device;
7545 cmdline_fixed_string_t what;
7546 cmdline_fixed_string_t identifier;
7549 static void cmd_showdevice_parsed(void *parsed_result,
7550 __attribute__((unused)) struct cmdline *cl,
7551 __attribute__((unused)) void *data)
7553 struct cmd_showdevice_result *res = parsed_result;
7554 if (!strcmp(res->what, "info")) {
7555 if (!strcmp(res->identifier, "all"))
7556 device_infos_display(NULL);
7558 device_infos_display(res->identifier);
7562 cmdline_parse_token_string_t cmd_showdevice_show =
7563 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7565 cmdline_parse_token_string_t cmd_showdevice_device =
7566 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7567 cmdline_parse_token_string_t cmd_showdevice_what =
7568 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7570 cmdline_parse_token_string_t cmd_showdevice_identifier =
7571 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7574 cmdline_parse_inst_t cmd_showdevice = {
7575 .f = cmd_showdevice_parsed,
7577 .help_str = "show device info <identifier>|all",
7579 (void *)&cmd_showdevice_show,
7580 (void *)&cmd_showdevice_device,
7581 (void *)&cmd_showdevice_what,
7582 (void *)&cmd_showdevice_identifier,
7586 /* *** SHOW QUEUE INFO *** */
7587 struct cmd_showqueue_result {
7588 cmdline_fixed_string_t show;
7589 cmdline_fixed_string_t type;
7590 cmdline_fixed_string_t what;
7596 cmd_showqueue_parsed(void *parsed_result,
7597 __attribute__((unused)) struct cmdline *cl,
7598 __attribute__((unused)) void *data)
7600 struct cmd_showqueue_result *res = parsed_result;
7602 if (!strcmp(res->type, "rxq"))
7603 rx_queue_infos_display(res->portnum, res->queuenum);
7604 else if (!strcmp(res->type, "txq"))
7605 tx_queue_infos_display(res->portnum, res->queuenum);
7608 cmdline_parse_token_string_t cmd_showqueue_show =
7609 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7610 cmdline_parse_token_string_t cmd_showqueue_type =
7611 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7612 cmdline_parse_token_string_t cmd_showqueue_what =
7613 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7614 cmdline_parse_token_num_t cmd_showqueue_portnum =
7615 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7616 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7617 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7619 cmdline_parse_inst_t cmd_showqueue = {
7620 .f = cmd_showqueue_parsed,
7622 .help_str = "show rxq|txq info <port_id> <queue_id>",
7624 (void *)&cmd_showqueue_show,
7625 (void *)&cmd_showqueue_type,
7626 (void *)&cmd_showqueue_what,
7627 (void *)&cmd_showqueue_portnum,
7628 (void *)&cmd_showqueue_queuenum,
7633 /* show/clear fwd engine statistics */
7635 cmdline_fixed_string_t action;
7636 cmdline_fixed_string_t fwd;
7637 cmdline_fixed_string_t stats;
7638 cmdline_fixed_string_t all;
7641 cmdline_parse_token_string_t cmd_fwd_action =
7642 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7643 cmdline_parse_token_string_t cmd_fwd_fwd =
7644 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7645 cmdline_parse_token_string_t cmd_fwd_stats =
7646 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7647 cmdline_parse_token_string_t cmd_fwd_all =
7648 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7651 cmd_showfwdall_parsed(void *parsed_result,
7652 __rte_unused struct cmdline *cl,
7653 __rte_unused void *data)
7655 struct fwd_result *res = parsed_result;
7657 if (!strcmp(res->action, "show"))
7658 fwd_stats_display();
7663 static cmdline_parse_inst_t cmd_showfwdall = {
7664 .f = cmd_showfwdall_parsed,
7666 .help_str = "show|clear fwd stats all",
7668 (void *)&cmd_fwd_action,
7669 (void *)&cmd_fwd_fwd,
7670 (void *)&cmd_fwd_stats,
7671 (void *)&cmd_fwd_all,
7676 /* *** READ PORT REGISTER *** */
7677 struct cmd_read_reg_result {
7678 cmdline_fixed_string_t read;
7679 cmdline_fixed_string_t reg;
7685 cmd_read_reg_parsed(void *parsed_result,
7686 __attribute__((unused)) struct cmdline *cl,
7687 __attribute__((unused)) void *data)
7689 struct cmd_read_reg_result *res = parsed_result;
7690 port_reg_display(res->port_id, res->reg_off);
7693 cmdline_parse_token_string_t cmd_read_reg_read =
7694 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7695 cmdline_parse_token_string_t cmd_read_reg_reg =
7696 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7697 cmdline_parse_token_num_t cmd_read_reg_port_id =
7698 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7699 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7700 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7702 cmdline_parse_inst_t cmd_read_reg = {
7703 .f = cmd_read_reg_parsed,
7705 .help_str = "read reg <port_id> <reg_off>",
7707 (void *)&cmd_read_reg_read,
7708 (void *)&cmd_read_reg_reg,
7709 (void *)&cmd_read_reg_port_id,
7710 (void *)&cmd_read_reg_reg_off,
7715 /* *** READ PORT REGISTER BIT FIELD *** */
7716 struct cmd_read_reg_bit_field_result {
7717 cmdline_fixed_string_t read;
7718 cmdline_fixed_string_t regfield;
7726 cmd_read_reg_bit_field_parsed(void *parsed_result,
7727 __attribute__((unused)) struct cmdline *cl,
7728 __attribute__((unused)) void *data)
7730 struct cmd_read_reg_bit_field_result *res = parsed_result;
7731 port_reg_bit_field_display(res->port_id, res->reg_off,
7732 res->bit1_pos, res->bit2_pos);
7735 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7736 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7738 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7739 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7740 regfield, "regfield");
7741 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7742 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7744 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7745 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7747 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7748 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7750 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7751 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7754 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7755 .f = cmd_read_reg_bit_field_parsed,
7757 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7758 "Read register bit field between bit_x and bit_y included",
7760 (void *)&cmd_read_reg_bit_field_read,
7761 (void *)&cmd_read_reg_bit_field_regfield,
7762 (void *)&cmd_read_reg_bit_field_port_id,
7763 (void *)&cmd_read_reg_bit_field_reg_off,
7764 (void *)&cmd_read_reg_bit_field_bit1_pos,
7765 (void *)&cmd_read_reg_bit_field_bit2_pos,
7770 /* *** READ PORT REGISTER BIT *** */
7771 struct cmd_read_reg_bit_result {
7772 cmdline_fixed_string_t read;
7773 cmdline_fixed_string_t regbit;
7780 cmd_read_reg_bit_parsed(void *parsed_result,
7781 __attribute__((unused)) struct cmdline *cl,
7782 __attribute__((unused)) void *data)
7784 struct cmd_read_reg_bit_result *res = parsed_result;
7785 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7788 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7789 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7790 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7791 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7793 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7794 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7795 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7796 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7797 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7798 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7800 cmdline_parse_inst_t cmd_read_reg_bit = {
7801 .f = cmd_read_reg_bit_parsed,
7803 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7805 (void *)&cmd_read_reg_bit_read,
7806 (void *)&cmd_read_reg_bit_regbit,
7807 (void *)&cmd_read_reg_bit_port_id,
7808 (void *)&cmd_read_reg_bit_reg_off,
7809 (void *)&cmd_read_reg_bit_bit_pos,
7814 /* *** WRITE PORT REGISTER *** */
7815 struct cmd_write_reg_result {
7816 cmdline_fixed_string_t write;
7817 cmdline_fixed_string_t reg;
7824 cmd_write_reg_parsed(void *parsed_result,
7825 __attribute__((unused)) struct cmdline *cl,
7826 __attribute__((unused)) void *data)
7828 struct cmd_write_reg_result *res = parsed_result;
7829 port_reg_set(res->port_id, res->reg_off, res->value);
7832 cmdline_parse_token_string_t cmd_write_reg_write =
7833 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7834 cmdline_parse_token_string_t cmd_write_reg_reg =
7835 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7836 cmdline_parse_token_num_t cmd_write_reg_port_id =
7837 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7838 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7839 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7840 cmdline_parse_token_num_t cmd_write_reg_value =
7841 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7843 cmdline_parse_inst_t cmd_write_reg = {
7844 .f = cmd_write_reg_parsed,
7846 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7848 (void *)&cmd_write_reg_write,
7849 (void *)&cmd_write_reg_reg,
7850 (void *)&cmd_write_reg_port_id,
7851 (void *)&cmd_write_reg_reg_off,
7852 (void *)&cmd_write_reg_value,
7857 /* *** WRITE PORT REGISTER BIT FIELD *** */
7858 struct cmd_write_reg_bit_field_result {
7859 cmdline_fixed_string_t write;
7860 cmdline_fixed_string_t regfield;
7869 cmd_write_reg_bit_field_parsed(void *parsed_result,
7870 __attribute__((unused)) struct cmdline *cl,
7871 __attribute__((unused)) void *data)
7873 struct cmd_write_reg_bit_field_result *res = parsed_result;
7874 port_reg_bit_field_set(res->port_id, res->reg_off,
7875 res->bit1_pos, res->bit2_pos, res->value);
7878 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7879 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7881 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7882 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7883 regfield, "regfield");
7884 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7885 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7887 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7888 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7890 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7891 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7893 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7894 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7896 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7897 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7900 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7901 .f = cmd_write_reg_bit_field_parsed,
7903 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7905 "Set register bit field between bit_x and bit_y included",
7907 (void *)&cmd_write_reg_bit_field_write,
7908 (void *)&cmd_write_reg_bit_field_regfield,
7909 (void *)&cmd_write_reg_bit_field_port_id,
7910 (void *)&cmd_write_reg_bit_field_reg_off,
7911 (void *)&cmd_write_reg_bit_field_bit1_pos,
7912 (void *)&cmd_write_reg_bit_field_bit2_pos,
7913 (void *)&cmd_write_reg_bit_field_value,
7918 /* *** WRITE PORT REGISTER BIT *** */
7919 struct cmd_write_reg_bit_result {
7920 cmdline_fixed_string_t write;
7921 cmdline_fixed_string_t regbit;
7929 cmd_write_reg_bit_parsed(void *parsed_result,
7930 __attribute__((unused)) struct cmdline *cl,
7931 __attribute__((unused)) void *data)
7933 struct cmd_write_reg_bit_result *res = parsed_result;
7934 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7937 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7938 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7940 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7941 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7943 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7944 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7945 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7946 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7947 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7948 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7949 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7950 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7952 cmdline_parse_inst_t cmd_write_reg_bit = {
7953 .f = cmd_write_reg_bit_parsed,
7955 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7958 (void *)&cmd_write_reg_bit_write,
7959 (void *)&cmd_write_reg_bit_regbit,
7960 (void *)&cmd_write_reg_bit_port_id,
7961 (void *)&cmd_write_reg_bit_reg_off,
7962 (void *)&cmd_write_reg_bit_bit_pos,
7963 (void *)&cmd_write_reg_bit_value,
7968 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7969 struct cmd_read_rxd_txd_result {
7970 cmdline_fixed_string_t read;
7971 cmdline_fixed_string_t rxd_txd;
7978 cmd_read_rxd_txd_parsed(void *parsed_result,
7979 __attribute__((unused)) struct cmdline *cl,
7980 __attribute__((unused)) void *data)
7982 struct cmd_read_rxd_txd_result *res = parsed_result;
7984 if (!strcmp(res->rxd_txd, "rxd"))
7985 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7986 else if (!strcmp(res->rxd_txd, "txd"))
7987 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7990 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7991 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7992 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7993 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7995 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7996 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7997 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7998 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7999 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8000 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8002 cmdline_parse_inst_t cmd_read_rxd_txd = {
8003 .f = cmd_read_rxd_txd_parsed,
8005 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8007 (void *)&cmd_read_rxd_txd_read,
8008 (void *)&cmd_read_rxd_txd_rxd_txd,
8009 (void *)&cmd_read_rxd_txd_port_id,
8010 (void *)&cmd_read_rxd_txd_queue_id,
8011 (void *)&cmd_read_rxd_txd_desc_id,
8017 struct cmd_quit_result {
8018 cmdline_fixed_string_t quit;
8021 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
8023 __attribute__((unused)) void *data)
8028 cmdline_parse_token_string_t cmd_quit_quit =
8029 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8031 cmdline_parse_inst_t cmd_quit = {
8032 .f = cmd_quit_parsed,
8034 .help_str = "quit: Exit application",
8036 (void *)&cmd_quit_quit,
8041 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8042 struct cmd_mac_addr_result {
8043 cmdline_fixed_string_t mac_addr_cmd;
8044 cmdline_fixed_string_t what;
8046 struct rte_ether_addr address;
8049 static void cmd_mac_addr_parsed(void *parsed_result,
8050 __attribute__((unused)) struct cmdline *cl,
8051 __attribute__((unused)) void *data)
8053 struct cmd_mac_addr_result *res = parsed_result;
8056 if (strcmp(res->what, "add") == 0)
8057 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8058 else if (strcmp(res->what, "set") == 0)
8059 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8062 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8064 /* check the return value and print it if is < 0 */
8066 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8070 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8071 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8073 cmdline_parse_token_string_t cmd_mac_addr_what =
8074 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8076 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8077 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8079 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8080 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8082 cmdline_parse_inst_t cmd_mac_addr = {
8083 .f = cmd_mac_addr_parsed,
8085 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8086 "Add/Remove/Set MAC address on port_id",
8088 (void *)&cmd_mac_addr_cmd,
8089 (void *)&cmd_mac_addr_what,
8090 (void *)&cmd_mac_addr_portnum,
8091 (void *)&cmd_mac_addr_addr,
8096 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8097 struct cmd_eth_peer_result {
8098 cmdline_fixed_string_t set;
8099 cmdline_fixed_string_t eth_peer;
8101 cmdline_fixed_string_t peer_addr;
8104 static void cmd_set_eth_peer_parsed(void *parsed_result,
8105 __attribute__((unused)) struct cmdline *cl,
8106 __attribute__((unused)) void *data)
8108 struct cmd_eth_peer_result *res = parsed_result;
8110 if (test_done == 0) {
8111 printf("Please stop forwarding first\n");
8114 if (!strcmp(res->eth_peer, "eth-peer")) {
8115 set_fwd_eth_peer(res->port_id, res->peer_addr);
8119 cmdline_parse_token_string_t cmd_eth_peer_set =
8120 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8121 cmdline_parse_token_string_t cmd_eth_peer =
8122 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8123 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8124 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8125 cmdline_parse_token_string_t cmd_eth_peer_addr =
8126 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8128 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8129 .f = cmd_set_eth_peer_parsed,
8131 .help_str = "set eth-peer <port_id> <peer_mac>",
8133 (void *)&cmd_eth_peer_set,
8134 (void *)&cmd_eth_peer,
8135 (void *)&cmd_eth_peer_port_id,
8136 (void *)&cmd_eth_peer_addr,
8141 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8142 struct cmd_set_qmap_result {
8143 cmdline_fixed_string_t set;
8144 cmdline_fixed_string_t qmap;
8145 cmdline_fixed_string_t what;
8152 cmd_set_qmap_parsed(void *parsed_result,
8153 __attribute__((unused)) struct cmdline *cl,
8154 __attribute__((unused)) void *data)
8156 struct cmd_set_qmap_result *res = parsed_result;
8157 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8159 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8162 cmdline_parse_token_string_t cmd_setqmap_set =
8163 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8165 cmdline_parse_token_string_t cmd_setqmap_qmap =
8166 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8168 cmdline_parse_token_string_t cmd_setqmap_what =
8169 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8171 cmdline_parse_token_num_t cmd_setqmap_portid =
8172 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8174 cmdline_parse_token_num_t cmd_setqmap_queueid =
8175 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8177 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8178 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8181 cmdline_parse_inst_t cmd_set_qmap = {
8182 .f = cmd_set_qmap_parsed,
8184 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8185 "Set statistics mapping value on tx|rx queue_id of port_id",
8187 (void *)&cmd_setqmap_set,
8188 (void *)&cmd_setqmap_qmap,
8189 (void *)&cmd_setqmap_what,
8190 (void *)&cmd_setqmap_portid,
8191 (void *)&cmd_setqmap_queueid,
8192 (void *)&cmd_setqmap_mapvalue,
8197 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8198 struct cmd_set_xstats_hide_zero_result {
8199 cmdline_fixed_string_t keyword;
8200 cmdline_fixed_string_t name;
8201 cmdline_fixed_string_t on_off;
8205 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8206 __attribute__((unused)) struct cmdline *cl,
8207 __attribute__((unused)) void *data)
8209 struct cmd_set_xstats_hide_zero_result *res;
8210 uint16_t on_off = 0;
8212 res = parsed_result;
8213 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8214 set_xstats_hide_zero(on_off);
8217 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8220 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8222 name, "xstats-hide-zero");
8223 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8224 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8227 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8228 .f = cmd_set_xstats_hide_zero_parsed,
8230 .help_str = "set xstats-hide-zero on|off",
8232 (void *)&cmd_set_xstats_hide_zero_keyword,
8233 (void *)&cmd_set_xstats_hide_zero_name,
8234 (void *)&cmd_set_xstats_hide_zero_on_off,
8239 /* *** CONFIGURE UNICAST HASH TABLE *** */
8240 struct cmd_set_uc_hash_table {
8241 cmdline_fixed_string_t set;
8242 cmdline_fixed_string_t port;
8244 cmdline_fixed_string_t what;
8245 struct rte_ether_addr address;
8246 cmdline_fixed_string_t mode;
8250 cmd_set_uc_hash_parsed(void *parsed_result,
8251 __attribute__((unused)) struct cmdline *cl,
8252 __attribute__((unused)) void *data)
8255 struct cmd_set_uc_hash_table *res = parsed_result;
8257 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8259 if (strcmp(res->what, "uta") == 0)
8260 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8261 &res->address,(uint8_t)is_on);
8263 printf("bad unicast hash table parameter, return code = %d \n", ret);
8267 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8268 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8270 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8271 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8273 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8274 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8276 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8277 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8279 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8280 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8282 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8283 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8286 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8287 .f = cmd_set_uc_hash_parsed,
8289 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8291 (void *)&cmd_set_uc_hash_set,
8292 (void *)&cmd_set_uc_hash_port,
8293 (void *)&cmd_set_uc_hash_portid,
8294 (void *)&cmd_set_uc_hash_what,
8295 (void *)&cmd_set_uc_hash_mac,
8296 (void *)&cmd_set_uc_hash_mode,
8301 struct cmd_set_uc_all_hash_table {
8302 cmdline_fixed_string_t set;
8303 cmdline_fixed_string_t port;
8305 cmdline_fixed_string_t what;
8306 cmdline_fixed_string_t value;
8307 cmdline_fixed_string_t mode;
8311 cmd_set_uc_all_hash_parsed(void *parsed_result,
8312 __attribute__((unused)) struct cmdline *cl,
8313 __attribute__((unused)) void *data)
8316 struct cmd_set_uc_all_hash_table *res = parsed_result;
8318 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8320 if ((strcmp(res->what, "uta") == 0) &&
8321 (strcmp(res->value, "all") == 0))
8322 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8324 printf("bad unicast hash table parameter,"
8325 "return code = %d \n", ret);
8328 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8329 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8331 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8334 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8335 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8337 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8338 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8340 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8341 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8343 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8344 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8347 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8348 .f = cmd_set_uc_all_hash_parsed,
8350 .help_str = "set port <port_id> uta all on|off",
8352 (void *)&cmd_set_uc_all_hash_set,
8353 (void *)&cmd_set_uc_all_hash_port,
8354 (void *)&cmd_set_uc_all_hash_portid,
8355 (void *)&cmd_set_uc_all_hash_what,
8356 (void *)&cmd_set_uc_all_hash_value,
8357 (void *)&cmd_set_uc_all_hash_mode,
8362 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8363 struct cmd_set_vf_macvlan_filter {
8364 cmdline_fixed_string_t set;
8365 cmdline_fixed_string_t port;
8367 cmdline_fixed_string_t vf;
8369 struct rte_ether_addr address;
8370 cmdline_fixed_string_t filter_type;
8371 cmdline_fixed_string_t mode;
8375 cmd_set_vf_macvlan_parsed(void *parsed_result,
8376 __attribute__((unused)) struct cmdline *cl,
8377 __attribute__((unused)) void *data)
8380 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8381 struct rte_eth_mac_filter filter;
8383 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8385 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8387 /* set VF MAC filter */
8391 filter.dst_id = res->vf_id;
8393 if (!strcmp(res->filter_type, "exact-mac"))
8394 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8395 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8396 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8397 else if (!strcmp(res->filter_type, "hashmac"))
8398 filter.filter_type = RTE_MAC_HASH_MATCH;
8399 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8400 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8402 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8405 ret = rte_eth_dev_filter_ctrl(res->port_id,
8406 RTE_ETH_FILTER_MACVLAN,
8410 ret = rte_eth_dev_filter_ctrl(res->port_id,
8411 RTE_ETH_FILTER_MACVLAN,
8412 RTE_ETH_FILTER_DELETE,
8416 printf("bad set MAC hash parameter, return code = %d\n", ret);
8420 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8421 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8423 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8424 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8426 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8427 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8429 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8432 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8433 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8435 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8436 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8438 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8439 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8440 filter_type, "exact-mac#exact-mac-vlan"
8441 "#hashmac#hashmac-vlan");
8442 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8443 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8446 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8447 .f = cmd_set_vf_macvlan_parsed,
8449 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8450 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8451 "Exact match rule: exact match of MAC or MAC and VLAN; "
8452 "hash match rule: hash match of MAC and exact match of VLAN",
8454 (void *)&cmd_set_vf_macvlan_set,
8455 (void *)&cmd_set_vf_macvlan_port,
8456 (void *)&cmd_set_vf_macvlan_portid,
8457 (void *)&cmd_set_vf_macvlan_vf,
8458 (void *)&cmd_set_vf_macvlan_vf_id,
8459 (void *)&cmd_set_vf_macvlan_mac,
8460 (void *)&cmd_set_vf_macvlan_filter_type,
8461 (void *)&cmd_set_vf_macvlan_mode,
8466 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8467 struct cmd_set_vf_traffic {
8468 cmdline_fixed_string_t set;
8469 cmdline_fixed_string_t port;
8471 cmdline_fixed_string_t vf;
8473 cmdline_fixed_string_t what;
8474 cmdline_fixed_string_t mode;
8478 cmd_set_vf_traffic_parsed(void *parsed_result,
8479 __attribute__((unused)) struct cmdline *cl,
8480 __attribute__((unused)) void *data)
8482 struct cmd_set_vf_traffic *res = parsed_result;
8483 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8484 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8486 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8489 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8490 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8492 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8493 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8495 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8496 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8498 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8499 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8501 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8502 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8504 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8505 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8507 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8511 cmdline_parse_inst_t cmd_set_vf_traffic = {
8512 .f = cmd_set_vf_traffic_parsed,
8514 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8516 (void *)&cmd_setvf_traffic_set,
8517 (void *)&cmd_setvf_traffic_port,
8518 (void *)&cmd_setvf_traffic_portid,
8519 (void *)&cmd_setvf_traffic_vf,
8520 (void *)&cmd_setvf_traffic_vfid,
8521 (void *)&cmd_setvf_traffic_what,
8522 (void *)&cmd_setvf_traffic_mode,
8527 /* *** CONFIGURE VF RECEIVE MODE *** */
8528 struct cmd_set_vf_rxmode {
8529 cmdline_fixed_string_t set;
8530 cmdline_fixed_string_t port;
8532 cmdline_fixed_string_t vf;
8534 cmdline_fixed_string_t what;
8535 cmdline_fixed_string_t mode;
8536 cmdline_fixed_string_t on;
8540 cmd_set_vf_rxmode_parsed(void *parsed_result,
8541 __attribute__((unused)) struct cmdline *cl,
8542 __attribute__((unused)) void *data)
8545 uint16_t vf_rxmode = 0;
8546 struct cmd_set_vf_rxmode *res = parsed_result;
8548 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8549 if (!strcmp(res->what,"rxmode")) {
8550 if (!strcmp(res->mode, "AUPE"))
8551 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8552 else if (!strcmp(res->mode, "ROPE"))
8553 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8554 else if (!strcmp(res->mode, "BAM"))
8555 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8556 else if (!strncmp(res->mode, "MPE",3))
8557 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8560 RTE_SET_USED(is_on);
8562 #ifdef RTE_LIBRTE_IXGBE_PMD
8563 if (ret == -ENOTSUP)
8564 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8565 vf_rxmode, (uint8_t)is_on);
8567 #ifdef RTE_LIBRTE_BNXT_PMD
8568 if (ret == -ENOTSUP)
8569 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8570 vf_rxmode, (uint8_t)is_on);
8573 printf("bad VF receive mode parameter, return code = %d \n",
8577 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8578 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8580 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8581 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8583 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8584 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8586 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8587 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8589 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8590 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8592 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8593 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8595 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8596 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8597 mode, "AUPE#ROPE#BAM#MPE");
8598 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8599 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8602 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8603 .f = cmd_set_vf_rxmode_parsed,
8605 .help_str = "set port <port_id> vf <vf_id> rxmode "
8606 "AUPE|ROPE|BAM|MPE on|off",
8608 (void *)&cmd_set_vf_rxmode_set,
8609 (void *)&cmd_set_vf_rxmode_port,
8610 (void *)&cmd_set_vf_rxmode_portid,
8611 (void *)&cmd_set_vf_rxmode_vf,
8612 (void *)&cmd_set_vf_rxmode_vfid,
8613 (void *)&cmd_set_vf_rxmode_what,
8614 (void *)&cmd_set_vf_rxmode_mode,
8615 (void *)&cmd_set_vf_rxmode_on,
8620 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8621 struct cmd_vf_mac_addr_result {
8622 cmdline_fixed_string_t mac_addr_cmd;
8623 cmdline_fixed_string_t what;
8624 cmdline_fixed_string_t port;
8626 cmdline_fixed_string_t vf;
8628 struct rte_ether_addr address;
8631 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8632 __attribute__((unused)) struct cmdline *cl,
8633 __attribute__((unused)) void *data)
8635 struct cmd_vf_mac_addr_result *res = parsed_result;
8638 if (strcmp(res->what, "add") != 0)
8641 #ifdef RTE_LIBRTE_I40E_PMD
8642 if (ret == -ENOTSUP)
8643 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8646 #ifdef RTE_LIBRTE_BNXT_PMD
8647 if (ret == -ENOTSUP)
8648 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8653 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8657 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8658 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8659 mac_addr_cmd,"mac_addr");
8660 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8661 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8663 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8664 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8666 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8667 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8669 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8670 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8672 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8673 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8675 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8676 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8679 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8680 .f = cmd_vf_mac_addr_parsed,
8682 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8683 "Add MAC address filtering for a VF on port_id",
8685 (void *)&cmd_vf_mac_addr_cmd,
8686 (void *)&cmd_vf_mac_addr_what,
8687 (void *)&cmd_vf_mac_addr_port,
8688 (void *)&cmd_vf_mac_addr_portnum,
8689 (void *)&cmd_vf_mac_addr_vf,
8690 (void *)&cmd_vf_mac_addr_vfnum,
8691 (void *)&cmd_vf_mac_addr_addr,
8696 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8697 struct cmd_vf_rx_vlan_filter {
8698 cmdline_fixed_string_t rx_vlan;
8699 cmdline_fixed_string_t what;
8701 cmdline_fixed_string_t port;
8703 cmdline_fixed_string_t vf;
8708 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8709 __attribute__((unused)) struct cmdline *cl,
8710 __attribute__((unused)) void *data)
8712 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8715 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8717 #ifdef RTE_LIBRTE_IXGBE_PMD
8718 if (ret == -ENOTSUP)
8719 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8720 res->vlan_id, res->vf_mask, is_add);
8722 #ifdef RTE_LIBRTE_I40E_PMD
8723 if (ret == -ENOTSUP)
8724 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8725 res->vlan_id, res->vf_mask, is_add);
8727 #ifdef RTE_LIBRTE_BNXT_PMD
8728 if (ret == -ENOTSUP)
8729 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8730 res->vlan_id, res->vf_mask, is_add);
8737 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8738 res->vlan_id, res->vf_mask);
8741 printf("invalid port_id %d\n", res->port_id);
8744 printf("function not implemented or supported\n");
8747 printf("programming error: (%s)\n", strerror(-ret));
8751 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8752 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8753 rx_vlan, "rx_vlan");
8754 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8755 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8757 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8758 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8760 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8761 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8763 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8764 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8766 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8767 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8769 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8770 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8773 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8774 .f = cmd_vf_rx_vlan_filter_parsed,
8776 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8777 "(vf_mask = hexadecimal VF mask)",
8779 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8780 (void *)&cmd_vf_rx_vlan_filter_what,
8781 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8782 (void *)&cmd_vf_rx_vlan_filter_port,
8783 (void *)&cmd_vf_rx_vlan_filter_portid,
8784 (void *)&cmd_vf_rx_vlan_filter_vf,
8785 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8790 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8791 struct cmd_queue_rate_limit_result {
8792 cmdline_fixed_string_t set;
8793 cmdline_fixed_string_t port;
8795 cmdline_fixed_string_t queue;
8797 cmdline_fixed_string_t rate;
8801 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8802 __attribute__((unused)) struct cmdline *cl,
8803 __attribute__((unused)) void *data)
8805 struct cmd_queue_rate_limit_result *res = parsed_result;
8808 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8809 && (strcmp(res->queue, "queue") == 0)
8810 && (strcmp(res->rate, "rate") == 0))
8811 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8814 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8818 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8819 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8821 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8822 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8824 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8825 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8827 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8828 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8830 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8831 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8833 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8834 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8836 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8837 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8840 cmdline_parse_inst_t cmd_queue_rate_limit = {
8841 .f = cmd_queue_rate_limit_parsed,
8843 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8844 "Set rate limit for a queue on port_id",
8846 (void *)&cmd_queue_rate_limit_set,
8847 (void *)&cmd_queue_rate_limit_port,
8848 (void *)&cmd_queue_rate_limit_portnum,
8849 (void *)&cmd_queue_rate_limit_queue,
8850 (void *)&cmd_queue_rate_limit_queuenum,
8851 (void *)&cmd_queue_rate_limit_rate,
8852 (void *)&cmd_queue_rate_limit_ratenum,
8857 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8858 struct cmd_vf_rate_limit_result {
8859 cmdline_fixed_string_t set;
8860 cmdline_fixed_string_t port;
8862 cmdline_fixed_string_t vf;
8864 cmdline_fixed_string_t rate;
8866 cmdline_fixed_string_t q_msk;
8870 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8871 __attribute__((unused)) struct cmdline *cl,
8872 __attribute__((unused)) void *data)
8874 struct cmd_vf_rate_limit_result *res = parsed_result;
8877 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8878 && (strcmp(res->vf, "vf") == 0)
8879 && (strcmp(res->rate, "rate") == 0)
8880 && (strcmp(res->q_msk, "queue_mask") == 0))
8881 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8882 res->rate_num, res->q_msk_val);
8884 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8888 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8889 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8891 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8892 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8894 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8895 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8897 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8898 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8900 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8901 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8903 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8904 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8906 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8907 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8909 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8910 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8911 q_msk, "queue_mask");
8912 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8913 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8916 cmdline_parse_inst_t cmd_vf_rate_limit = {
8917 .f = cmd_vf_rate_limit_parsed,
8919 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8920 "queue_mask <queue_mask_value>: "
8921 "Set rate limit for queues of VF on port_id",
8923 (void *)&cmd_vf_rate_limit_set,
8924 (void *)&cmd_vf_rate_limit_port,
8925 (void *)&cmd_vf_rate_limit_portnum,
8926 (void *)&cmd_vf_rate_limit_vf,
8927 (void *)&cmd_vf_rate_limit_vfnum,
8928 (void *)&cmd_vf_rate_limit_rate,
8929 (void *)&cmd_vf_rate_limit_ratenum,
8930 (void *)&cmd_vf_rate_limit_q_msk,
8931 (void *)&cmd_vf_rate_limit_q_msk_val,
8936 /* *** ADD TUNNEL FILTER OF A PORT *** */
8937 struct cmd_tunnel_filter_result {
8938 cmdline_fixed_string_t cmd;
8939 cmdline_fixed_string_t what;
8941 struct rte_ether_addr outer_mac;
8942 struct rte_ether_addr inner_mac;
8943 cmdline_ipaddr_t ip_value;
8944 uint16_t inner_vlan;
8945 cmdline_fixed_string_t tunnel_type;
8946 cmdline_fixed_string_t filter_type;
8952 cmd_tunnel_filter_parsed(void *parsed_result,
8953 __attribute__((unused)) struct cmdline *cl,
8954 __attribute__((unused)) void *data)
8956 struct cmd_tunnel_filter_result *res = parsed_result;
8957 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8960 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8962 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8963 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8964 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8966 if (res->ip_value.family == AF_INET) {
8967 tunnel_filter_conf.ip_addr.ipv4_addr =
8968 res->ip_value.addr.ipv4.s_addr;
8969 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8971 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8972 &(res->ip_value.addr.ipv6),
8973 sizeof(struct in6_addr));
8974 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8977 if (!strcmp(res->filter_type, "imac-ivlan"))
8978 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8979 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8980 tunnel_filter_conf.filter_type =
8981 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8982 else if (!strcmp(res->filter_type, "imac-tenid"))
8983 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8984 else if (!strcmp(res->filter_type, "imac"))
8985 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8986 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8987 tunnel_filter_conf.filter_type =
8988 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8989 else if (!strcmp(res->filter_type, "oip"))
8990 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8991 else if (!strcmp(res->filter_type, "iip"))
8992 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8994 printf("The filter type is not supported");
8998 if (!strcmp(res->tunnel_type, "vxlan"))
8999 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9000 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9001 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9002 else if (!strcmp(res->tunnel_type, "nvgre"))
9003 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9004 else if (!strcmp(res->tunnel_type, "ipingre"))
9005 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9007 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9011 tunnel_filter_conf.tenant_id = res->tenant_id;
9012 tunnel_filter_conf.queue_id = res->queue_num;
9013 if (!strcmp(res->what, "add"))
9014 ret = rte_eth_dev_filter_ctrl(res->port_id,
9015 RTE_ETH_FILTER_TUNNEL,
9017 &tunnel_filter_conf);
9019 ret = rte_eth_dev_filter_ctrl(res->port_id,
9020 RTE_ETH_FILTER_TUNNEL,
9021 RTE_ETH_FILTER_DELETE,
9022 &tunnel_filter_conf);
9024 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9028 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9029 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9030 cmd, "tunnel_filter");
9031 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9032 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9034 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9035 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9037 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9038 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9040 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9041 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9043 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9044 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9045 inner_vlan, UINT16);
9046 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9047 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9049 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9050 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9051 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9053 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9054 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9055 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9056 "imac#omac-imac-tenid");
9057 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9058 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9060 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9061 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9064 cmdline_parse_inst_t cmd_tunnel_filter = {
9065 .f = cmd_tunnel_filter_parsed,
9067 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9068 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9069 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9070 "<queue_id>: Add/Rm tunnel filter of a port",
9072 (void *)&cmd_tunnel_filter_cmd,
9073 (void *)&cmd_tunnel_filter_what,
9074 (void *)&cmd_tunnel_filter_port_id,
9075 (void *)&cmd_tunnel_filter_outer_mac,
9076 (void *)&cmd_tunnel_filter_inner_mac,
9077 (void *)&cmd_tunnel_filter_ip_value,
9078 (void *)&cmd_tunnel_filter_innner_vlan,
9079 (void *)&cmd_tunnel_filter_tunnel_type,
9080 (void *)&cmd_tunnel_filter_filter_type,
9081 (void *)&cmd_tunnel_filter_tenant_id,
9082 (void *)&cmd_tunnel_filter_queue_num,
9087 /* *** CONFIGURE TUNNEL UDP PORT *** */
9088 struct cmd_tunnel_udp_config {
9089 cmdline_fixed_string_t cmd;
9090 cmdline_fixed_string_t what;
9096 cmd_tunnel_udp_config_parsed(void *parsed_result,
9097 __attribute__((unused)) struct cmdline *cl,
9098 __attribute__((unused)) void *data)
9100 struct cmd_tunnel_udp_config *res = parsed_result;
9101 struct rte_eth_udp_tunnel tunnel_udp;
9104 tunnel_udp.udp_port = res->udp_port;
9106 if (!strcmp(res->cmd, "rx_vxlan_port"))
9107 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9109 if (!strcmp(res->what, "add"))
9110 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9113 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9117 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9120 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9121 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9122 cmd, "rx_vxlan_port");
9123 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9126 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9127 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9129 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9133 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9134 .f = cmd_tunnel_udp_config_parsed,
9136 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9137 "Add/Remove a tunneling UDP port filter",
9139 (void *)&cmd_tunnel_udp_config_cmd,
9140 (void *)&cmd_tunnel_udp_config_what,
9141 (void *)&cmd_tunnel_udp_config_udp_port,
9142 (void *)&cmd_tunnel_udp_config_port_id,
9147 struct cmd_config_tunnel_udp_port {
9148 cmdline_fixed_string_t port;
9149 cmdline_fixed_string_t config;
9151 cmdline_fixed_string_t udp_tunnel_port;
9152 cmdline_fixed_string_t action;
9153 cmdline_fixed_string_t tunnel_type;
9158 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9159 __attribute__((unused)) struct cmdline *cl,
9160 __attribute__((unused)) void *data)
9162 struct cmd_config_tunnel_udp_port *res = parsed_result;
9163 struct rte_eth_udp_tunnel tunnel_udp;
9166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9169 tunnel_udp.udp_port = res->udp_port;
9171 if (!strcmp(res->tunnel_type, "vxlan")) {
9172 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9173 } else if (!strcmp(res->tunnel_type, "geneve")) {
9174 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9175 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9176 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9178 printf("Invalid tunnel type\n");
9182 if (!strcmp(res->action, "add"))
9183 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9186 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9190 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9193 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9194 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9196 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9197 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9199 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9200 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9202 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9203 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9206 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9207 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9209 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9210 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9211 "vxlan#geneve#vxlan-gpe");
9212 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9213 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9216 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9217 .f = cmd_cfg_tunnel_udp_port_parsed,
9219 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9221 (void *)&cmd_config_tunnel_udp_port_port,
9222 (void *)&cmd_config_tunnel_udp_port_config,
9223 (void *)&cmd_config_tunnel_udp_port_port_id,
9224 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9225 (void *)&cmd_config_tunnel_udp_port_action,
9226 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9227 (void *)&cmd_config_tunnel_udp_port_value,
9232 /* *** GLOBAL CONFIG *** */
9233 struct cmd_global_config_result {
9234 cmdline_fixed_string_t cmd;
9236 cmdline_fixed_string_t cfg_type;
9241 cmd_global_config_parsed(void *parsed_result,
9242 __attribute__((unused)) struct cmdline *cl,
9243 __attribute__((unused)) void *data)
9245 struct cmd_global_config_result *res = parsed_result;
9246 struct rte_eth_global_cfg conf;
9249 memset(&conf, 0, sizeof(conf));
9250 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9251 conf.cfg.gre_key_len = res->len;
9252 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9253 RTE_ETH_FILTER_SET, &conf);
9255 printf("Global config error\n");
9258 cmdline_parse_token_string_t cmd_global_config_cmd =
9259 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9261 cmdline_parse_token_num_t cmd_global_config_port_id =
9262 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9264 cmdline_parse_token_string_t cmd_global_config_type =
9265 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9266 cfg_type, "gre-key-len");
9267 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9268 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9271 cmdline_parse_inst_t cmd_global_config = {
9272 .f = cmd_global_config_parsed,
9273 .data = (void *)NULL,
9274 .help_str = "global_config <port_id> gre-key-len <key_len>",
9276 (void *)&cmd_global_config_cmd,
9277 (void *)&cmd_global_config_port_id,
9278 (void *)&cmd_global_config_type,
9279 (void *)&cmd_global_config_gre_key_len,
9284 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9285 struct cmd_set_mirror_mask_result {
9286 cmdline_fixed_string_t set;
9287 cmdline_fixed_string_t port;
9289 cmdline_fixed_string_t mirror;
9291 cmdline_fixed_string_t what;
9292 cmdline_fixed_string_t value;
9293 cmdline_fixed_string_t dstpool;
9295 cmdline_fixed_string_t on;
9298 cmdline_parse_token_string_t cmd_mirror_mask_set =
9299 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9301 cmdline_parse_token_string_t cmd_mirror_mask_port =
9302 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9304 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9305 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9307 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9308 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9309 mirror, "mirror-rule");
9310 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9311 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9313 cmdline_parse_token_string_t cmd_mirror_mask_what =
9314 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9315 what, "pool-mirror-up#pool-mirror-down"
9317 cmdline_parse_token_string_t cmd_mirror_mask_value =
9318 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9320 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9322 dstpool, "dst-pool");
9323 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9324 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9326 cmdline_parse_token_string_t cmd_mirror_mask_on =
9327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9331 cmd_set_mirror_mask_parsed(void *parsed_result,
9332 __attribute__((unused)) struct cmdline *cl,
9333 __attribute__((unused)) void *data)
9336 struct cmd_set_mirror_mask_result *res = parsed_result;
9337 struct rte_eth_mirror_conf mr_conf;
9339 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9341 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9343 mr_conf.dst_pool = res->dstpool_id;
9345 if (!strcmp(res->what, "pool-mirror-up")) {
9346 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9347 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9348 } else if (!strcmp(res->what, "pool-mirror-down")) {
9349 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9350 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9351 } else if (!strcmp(res->what, "vlan-mirror")) {
9352 mr_conf.rule_type = ETH_MIRROR_VLAN;
9353 nb_item = parse_item_list(res->value, "vlan",
9354 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9358 for (i = 0; i < nb_item; i++) {
9359 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9360 printf("Invalid vlan_id: must be < 4096\n");
9364 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9365 mr_conf.vlan.vlan_mask |= 1ULL << i;
9369 if (!strcmp(res->on, "on"))
9370 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9373 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9376 printf("mirror rule add error: (%s)\n", strerror(-ret));
9379 cmdline_parse_inst_t cmd_set_mirror_mask = {
9380 .f = cmd_set_mirror_mask_parsed,
9382 .help_str = "set port <port_id> mirror-rule <rule_id> "
9383 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9384 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9386 (void *)&cmd_mirror_mask_set,
9387 (void *)&cmd_mirror_mask_port,
9388 (void *)&cmd_mirror_mask_portid,
9389 (void *)&cmd_mirror_mask_mirror,
9390 (void *)&cmd_mirror_mask_ruleid,
9391 (void *)&cmd_mirror_mask_what,
9392 (void *)&cmd_mirror_mask_value,
9393 (void *)&cmd_mirror_mask_dstpool,
9394 (void *)&cmd_mirror_mask_poolid,
9395 (void *)&cmd_mirror_mask_on,
9400 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9401 struct cmd_set_mirror_link_result {
9402 cmdline_fixed_string_t set;
9403 cmdline_fixed_string_t port;
9405 cmdline_fixed_string_t mirror;
9407 cmdline_fixed_string_t what;
9408 cmdline_fixed_string_t dstpool;
9410 cmdline_fixed_string_t on;
9413 cmdline_parse_token_string_t cmd_mirror_link_set =
9414 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9416 cmdline_parse_token_string_t cmd_mirror_link_port =
9417 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9419 cmdline_parse_token_num_t cmd_mirror_link_portid =
9420 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9422 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9423 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9424 mirror, "mirror-rule");
9425 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9426 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9428 cmdline_parse_token_string_t cmd_mirror_link_what =
9429 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9430 what, "uplink-mirror#downlink-mirror");
9431 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9433 dstpool, "dst-pool");
9434 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9435 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9437 cmdline_parse_token_string_t cmd_mirror_link_on =
9438 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9442 cmd_set_mirror_link_parsed(void *parsed_result,
9443 __attribute__((unused)) struct cmdline *cl,
9444 __attribute__((unused)) void *data)
9447 struct cmd_set_mirror_link_result *res = parsed_result;
9448 struct rte_eth_mirror_conf mr_conf;
9450 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9451 if (!strcmp(res->what, "uplink-mirror"))
9452 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9454 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9456 mr_conf.dst_pool = res->dstpool_id;
9458 if (!strcmp(res->on, "on"))
9459 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9462 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9465 /* check the return value and print it if is < 0 */
9467 printf("mirror rule add error: (%s)\n", strerror(-ret));
9471 cmdline_parse_inst_t cmd_set_mirror_link = {
9472 .f = cmd_set_mirror_link_parsed,
9474 .help_str = "set port <port_id> mirror-rule <rule_id> "
9475 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9477 (void *)&cmd_mirror_link_set,
9478 (void *)&cmd_mirror_link_port,
9479 (void *)&cmd_mirror_link_portid,
9480 (void *)&cmd_mirror_link_mirror,
9481 (void *)&cmd_mirror_link_ruleid,
9482 (void *)&cmd_mirror_link_what,
9483 (void *)&cmd_mirror_link_dstpool,
9484 (void *)&cmd_mirror_link_poolid,
9485 (void *)&cmd_mirror_link_on,
9490 /* *** RESET VM MIRROR RULE *** */
9491 struct cmd_rm_mirror_rule_result {
9492 cmdline_fixed_string_t reset;
9493 cmdline_fixed_string_t port;
9495 cmdline_fixed_string_t mirror;
9499 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9500 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9502 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9503 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9505 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9506 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9508 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9509 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9510 mirror, "mirror-rule");
9511 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9512 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9516 cmd_reset_mirror_rule_parsed(void *parsed_result,
9517 __attribute__((unused)) struct cmdline *cl,
9518 __attribute__((unused)) void *data)
9521 struct cmd_set_mirror_link_result *res = parsed_result;
9523 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9525 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9528 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9529 .f = cmd_reset_mirror_rule_parsed,
9531 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9533 (void *)&cmd_rm_mirror_rule_reset,
9534 (void *)&cmd_rm_mirror_rule_port,
9535 (void *)&cmd_rm_mirror_rule_portid,
9536 (void *)&cmd_rm_mirror_rule_mirror,
9537 (void *)&cmd_rm_mirror_rule_ruleid,
9542 /* ******************************************************************************** */
9544 struct cmd_dump_result {
9545 cmdline_fixed_string_t dump;
9549 dump_struct_sizes(void)
9551 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9552 DUMP_SIZE(struct rte_mbuf);
9553 DUMP_SIZE(struct rte_mempool);
9554 DUMP_SIZE(struct rte_ring);
9558 static void cmd_dump_parsed(void *parsed_result,
9559 __attribute__((unused)) struct cmdline *cl,
9560 __attribute__((unused)) void *data)
9562 struct cmd_dump_result *res = parsed_result;
9564 if (!strcmp(res->dump, "dump_physmem"))
9565 rte_dump_physmem_layout(stdout);
9566 else if (!strcmp(res->dump, "dump_memzone"))
9567 rte_memzone_dump(stdout);
9568 else if (!strcmp(res->dump, "dump_struct_sizes"))
9569 dump_struct_sizes();
9570 else if (!strcmp(res->dump, "dump_ring"))
9571 rte_ring_list_dump(stdout);
9572 else if (!strcmp(res->dump, "dump_mempool"))
9573 rte_mempool_list_dump(stdout);
9574 else if (!strcmp(res->dump, "dump_devargs"))
9575 rte_devargs_dump(stdout);
9576 else if (!strcmp(res->dump, "dump_log_types"))
9577 rte_log_dump(stdout);
9580 cmdline_parse_token_string_t cmd_dump_dump =
9581 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9584 "dump_struct_sizes#"
9590 cmdline_parse_inst_t cmd_dump = {
9591 .f = cmd_dump_parsed, /* function to call */
9592 .data = NULL, /* 2nd arg of func */
9593 .help_str = "Dump status",
9594 .tokens = { /* token list, NULL terminated */
9595 (void *)&cmd_dump_dump,
9600 /* ******************************************************************************** */
9602 struct cmd_dump_one_result {
9603 cmdline_fixed_string_t dump;
9604 cmdline_fixed_string_t name;
9607 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9608 __attribute__((unused)) void *data)
9610 struct cmd_dump_one_result *res = parsed_result;
9612 if (!strcmp(res->dump, "dump_ring")) {
9614 r = rte_ring_lookup(res->name);
9616 cmdline_printf(cl, "Cannot find ring\n");
9619 rte_ring_dump(stdout, r);
9620 } else if (!strcmp(res->dump, "dump_mempool")) {
9621 struct rte_mempool *mp;
9622 mp = rte_mempool_lookup(res->name);
9624 cmdline_printf(cl, "Cannot find mempool\n");
9627 rte_mempool_dump(stdout, mp);
9631 cmdline_parse_token_string_t cmd_dump_one_dump =
9632 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9633 "dump_ring#dump_mempool");
9635 cmdline_parse_token_string_t cmd_dump_one_name =
9636 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9638 cmdline_parse_inst_t cmd_dump_one = {
9639 .f = cmd_dump_one_parsed, /* function to call */
9640 .data = NULL, /* 2nd arg of func */
9641 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9642 .tokens = { /* token list, NULL terminated */
9643 (void *)&cmd_dump_one_dump,
9644 (void *)&cmd_dump_one_name,
9649 /* *** Add/Del syn filter *** */
9650 struct cmd_syn_filter_result {
9651 cmdline_fixed_string_t filter;
9653 cmdline_fixed_string_t ops;
9654 cmdline_fixed_string_t priority;
9655 cmdline_fixed_string_t high;
9656 cmdline_fixed_string_t queue;
9661 cmd_syn_filter_parsed(void *parsed_result,
9662 __attribute__((unused)) struct cmdline *cl,
9663 __attribute__((unused)) void *data)
9665 struct cmd_syn_filter_result *res = parsed_result;
9666 struct rte_eth_syn_filter syn_filter;
9669 ret = rte_eth_dev_filter_supported(res->port_id,
9670 RTE_ETH_FILTER_SYN);
9672 printf("syn filter is not supported on port %u.\n",
9677 memset(&syn_filter, 0, sizeof(syn_filter));
9679 if (!strcmp(res->ops, "add")) {
9680 if (!strcmp(res->high, "high"))
9681 syn_filter.hig_pri = 1;
9683 syn_filter.hig_pri = 0;
9685 syn_filter.queue = res->queue_id;
9686 ret = rte_eth_dev_filter_ctrl(res->port_id,
9691 ret = rte_eth_dev_filter_ctrl(res->port_id,
9693 RTE_ETH_FILTER_DELETE,
9697 printf("syn filter programming error: (%s)\n",
9701 cmdline_parse_token_string_t cmd_syn_filter_filter =
9702 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9703 filter, "syn_filter");
9704 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9705 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9707 cmdline_parse_token_string_t cmd_syn_filter_ops =
9708 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9710 cmdline_parse_token_string_t cmd_syn_filter_priority =
9711 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9712 priority, "priority");
9713 cmdline_parse_token_string_t cmd_syn_filter_high =
9714 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9716 cmdline_parse_token_string_t cmd_syn_filter_queue =
9717 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9719 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9720 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9723 cmdline_parse_inst_t cmd_syn_filter = {
9724 .f = cmd_syn_filter_parsed,
9726 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9727 "<queue_id>: Add/Delete syn filter",
9729 (void *)&cmd_syn_filter_filter,
9730 (void *)&cmd_syn_filter_port_id,
9731 (void *)&cmd_syn_filter_ops,
9732 (void *)&cmd_syn_filter_priority,
9733 (void *)&cmd_syn_filter_high,
9734 (void *)&cmd_syn_filter_queue,
9735 (void *)&cmd_syn_filter_queue_id,
9740 /* *** queue region set *** */
9741 struct cmd_queue_region_result {
9742 cmdline_fixed_string_t set;
9743 cmdline_fixed_string_t port;
9745 cmdline_fixed_string_t cmd;
9746 cmdline_fixed_string_t region;
9748 cmdline_fixed_string_t queue_start_index;
9750 cmdline_fixed_string_t queue_num;
9751 uint8_t queue_num_value;
9755 cmd_queue_region_parsed(void *parsed_result,
9756 __attribute__((unused)) struct cmdline *cl,
9757 __attribute__((unused)) void *data)
9759 struct cmd_queue_region_result *res = parsed_result;
9761 #ifdef RTE_LIBRTE_I40E_PMD
9762 struct rte_pmd_i40e_queue_region_conf region_conf;
9763 enum rte_pmd_i40e_queue_region_op op_type;
9766 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9769 #ifdef RTE_LIBRTE_I40E_PMD
9770 memset(®ion_conf, 0, sizeof(region_conf));
9771 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9772 region_conf.region_id = res->region_id;
9773 region_conf.queue_num = res->queue_num_value;
9774 region_conf.queue_start_index = res->queue_id;
9776 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9777 op_type, ®ion_conf);
9784 printf("function not implemented or supported\n");
9787 printf("queue region config error: (%s)\n", strerror(-ret));
9791 cmdline_parse_token_string_t cmd_queue_region_set =
9792 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9794 cmdline_parse_token_string_t cmd_queue_region_port =
9795 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9796 cmdline_parse_token_num_t cmd_queue_region_port_id =
9797 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9799 cmdline_parse_token_string_t cmd_queue_region_cmd =
9800 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9801 cmd, "queue-region");
9802 cmdline_parse_token_string_t cmd_queue_region_id =
9803 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9804 region, "region_id");
9805 cmdline_parse_token_num_t cmd_queue_region_index =
9806 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9808 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9809 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9810 queue_start_index, "queue_start_index");
9811 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9812 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9814 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9815 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9816 queue_num, "queue_num");
9817 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9818 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9819 queue_num_value, UINT8);
9821 cmdline_parse_inst_t cmd_queue_region = {
9822 .f = cmd_queue_region_parsed,
9824 .help_str = "set port <port_id> queue-region region_id <value> "
9825 "queue_start_index <value> queue_num <value>: Set a queue region",
9827 (void *)&cmd_queue_region_set,
9828 (void *)&cmd_queue_region_port,
9829 (void *)&cmd_queue_region_port_id,
9830 (void *)&cmd_queue_region_cmd,
9831 (void *)&cmd_queue_region_id,
9832 (void *)&cmd_queue_region_index,
9833 (void *)&cmd_queue_region_queue_start_index,
9834 (void *)&cmd_queue_region_queue_id,
9835 (void *)&cmd_queue_region_queue_num,
9836 (void *)&cmd_queue_region_queue_num_value,
9841 /* *** queue region and flowtype set *** */
9842 struct cmd_region_flowtype_result {
9843 cmdline_fixed_string_t set;
9844 cmdline_fixed_string_t port;
9846 cmdline_fixed_string_t cmd;
9847 cmdline_fixed_string_t region;
9849 cmdline_fixed_string_t flowtype;
9850 uint8_t flowtype_id;
9854 cmd_region_flowtype_parsed(void *parsed_result,
9855 __attribute__((unused)) struct cmdline *cl,
9856 __attribute__((unused)) void *data)
9858 struct cmd_region_flowtype_result *res = parsed_result;
9860 #ifdef RTE_LIBRTE_I40E_PMD
9861 struct rte_pmd_i40e_queue_region_conf region_conf;
9862 enum rte_pmd_i40e_queue_region_op op_type;
9865 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9868 #ifdef RTE_LIBRTE_I40E_PMD
9869 memset(®ion_conf, 0, sizeof(region_conf));
9871 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9872 region_conf.region_id = res->region_id;
9873 region_conf.hw_flowtype = res->flowtype_id;
9875 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9876 op_type, ®ion_conf);
9883 printf("function not implemented or supported\n");
9886 printf("region flowtype config error: (%s)\n", strerror(-ret));
9890 cmdline_parse_token_string_t cmd_region_flowtype_set =
9891 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9893 cmdline_parse_token_string_t cmd_region_flowtype_port =
9894 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9896 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9897 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9899 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9900 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9901 cmd, "queue-region");
9902 cmdline_parse_token_string_t cmd_region_flowtype_index =
9903 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9904 region, "region_id");
9905 cmdline_parse_token_num_t cmd_region_flowtype_id =
9906 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9908 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9909 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9910 flowtype, "flowtype");
9911 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9912 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9913 flowtype_id, UINT8);
9914 cmdline_parse_inst_t cmd_region_flowtype = {
9915 .f = cmd_region_flowtype_parsed,
9917 .help_str = "set port <port_id> queue-region region_id <value> "
9918 "flowtype <value>: Set a flowtype region index",
9920 (void *)&cmd_region_flowtype_set,
9921 (void *)&cmd_region_flowtype_port,
9922 (void *)&cmd_region_flowtype_port_index,
9923 (void *)&cmd_region_flowtype_cmd,
9924 (void *)&cmd_region_flowtype_index,
9925 (void *)&cmd_region_flowtype_id,
9926 (void *)&cmd_region_flowtype_flow_index,
9927 (void *)&cmd_region_flowtype_flow_id,
9932 /* *** User Priority (UP) to queue region (region_id) set *** */
9933 struct cmd_user_priority_region_result {
9934 cmdline_fixed_string_t set;
9935 cmdline_fixed_string_t port;
9937 cmdline_fixed_string_t cmd;
9938 cmdline_fixed_string_t user_priority;
9939 uint8_t user_priority_id;
9940 cmdline_fixed_string_t region;
9945 cmd_user_priority_region_parsed(void *parsed_result,
9946 __attribute__((unused)) struct cmdline *cl,
9947 __attribute__((unused)) void *data)
9949 struct cmd_user_priority_region_result *res = parsed_result;
9951 #ifdef RTE_LIBRTE_I40E_PMD
9952 struct rte_pmd_i40e_queue_region_conf region_conf;
9953 enum rte_pmd_i40e_queue_region_op op_type;
9956 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9959 #ifdef RTE_LIBRTE_I40E_PMD
9960 memset(®ion_conf, 0, sizeof(region_conf));
9961 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9962 region_conf.user_priority = res->user_priority_id;
9963 region_conf.region_id = res->region_id;
9965 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9966 op_type, ®ion_conf);
9973 printf("function not implemented or supported\n");
9976 printf("user_priority region config error: (%s)\n",
9981 cmdline_parse_token_string_t cmd_user_priority_region_set =
9982 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9984 cmdline_parse_token_string_t cmd_user_priority_region_port =
9985 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9987 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9988 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9990 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9991 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9992 cmd, "queue-region");
9993 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9994 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9995 user_priority, "UP");
9996 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9997 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9998 user_priority_id, UINT8);
9999 cmdline_parse_token_string_t cmd_user_priority_region_region =
10000 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10001 region, "region_id");
10002 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10003 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10006 cmdline_parse_inst_t cmd_user_priority_region = {
10007 .f = cmd_user_priority_region_parsed,
10009 .help_str = "set port <port_id> queue-region UP <value> "
10010 "region_id <value>: Set the mapping of User Priority (UP) "
10011 "to queue region (region_id) ",
10013 (void *)&cmd_user_priority_region_set,
10014 (void *)&cmd_user_priority_region_port,
10015 (void *)&cmd_user_priority_region_port_index,
10016 (void *)&cmd_user_priority_region_cmd,
10017 (void *)&cmd_user_priority_region_UP,
10018 (void *)&cmd_user_priority_region_UP_id,
10019 (void *)&cmd_user_priority_region_region,
10020 (void *)&cmd_user_priority_region_region_id,
10025 /* *** flush all queue region related configuration *** */
10026 struct cmd_flush_queue_region_result {
10027 cmdline_fixed_string_t set;
10028 cmdline_fixed_string_t port;
10030 cmdline_fixed_string_t cmd;
10031 cmdline_fixed_string_t flush;
10032 cmdline_fixed_string_t what;
10036 cmd_flush_queue_region_parsed(void *parsed_result,
10037 __attribute__((unused)) struct cmdline *cl,
10038 __attribute__((unused)) void *data)
10040 struct cmd_flush_queue_region_result *res = parsed_result;
10041 int ret = -ENOTSUP;
10042 #ifdef RTE_LIBRTE_I40E_PMD
10043 struct rte_pmd_i40e_queue_region_conf region_conf;
10044 enum rte_pmd_i40e_queue_region_op op_type;
10047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10050 #ifdef RTE_LIBRTE_I40E_PMD
10051 memset(®ion_conf, 0, sizeof(region_conf));
10053 if (strcmp(res->what, "on") == 0)
10054 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10056 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10058 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10059 op_type, ®ion_conf);
10066 printf("function not implemented or supported\n");
10069 printf("queue region config flush error: (%s)\n",
10074 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10075 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10077 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10078 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10080 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10081 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10083 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10084 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10085 cmd, "queue-region");
10086 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10087 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10089 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10090 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10093 cmdline_parse_inst_t cmd_flush_queue_region = {
10094 .f = cmd_flush_queue_region_parsed,
10096 .help_str = "set port <port_id> queue-region flush on|off"
10097 ": flush all queue region related configuration",
10099 (void *)&cmd_flush_queue_region_set,
10100 (void *)&cmd_flush_queue_region_port,
10101 (void *)&cmd_flush_queue_region_port_index,
10102 (void *)&cmd_flush_queue_region_cmd,
10103 (void *)&cmd_flush_queue_region_flush,
10104 (void *)&cmd_flush_queue_region_what,
10109 /* *** get all queue region related configuration info *** */
10110 struct cmd_show_queue_region_info {
10111 cmdline_fixed_string_t show;
10112 cmdline_fixed_string_t port;
10114 cmdline_fixed_string_t cmd;
10118 cmd_show_queue_region_info_parsed(void *parsed_result,
10119 __attribute__((unused)) struct cmdline *cl,
10120 __attribute__((unused)) void *data)
10122 struct cmd_show_queue_region_info *res = parsed_result;
10123 int ret = -ENOTSUP;
10124 #ifdef RTE_LIBRTE_I40E_PMD
10125 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10126 enum rte_pmd_i40e_queue_region_op op_type;
10129 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10132 #ifdef RTE_LIBRTE_I40E_PMD
10133 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10135 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10137 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10138 op_type, &rte_pmd_regions);
10140 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10147 printf("function not implemented or supported\n");
10150 printf("queue region config info show error: (%s)\n",
10155 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10156 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10158 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10159 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10161 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10162 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10164 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10165 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10166 cmd, "queue-region");
10168 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10169 .f = cmd_show_queue_region_info_parsed,
10171 .help_str = "show port <port_id> queue-region"
10172 ": show all queue region related configuration info",
10174 (void *)&cmd_show_queue_region_info_get,
10175 (void *)&cmd_show_queue_region_info_port,
10176 (void *)&cmd_show_queue_region_info_port_index,
10177 (void *)&cmd_show_queue_region_info_cmd,
10182 /* *** ADD/REMOVE A 2tuple FILTER *** */
10183 struct cmd_2tuple_filter_result {
10184 cmdline_fixed_string_t filter;
10186 cmdline_fixed_string_t ops;
10187 cmdline_fixed_string_t dst_port;
10188 uint16_t dst_port_value;
10189 cmdline_fixed_string_t protocol;
10190 uint8_t protocol_value;
10191 cmdline_fixed_string_t mask;
10192 uint8_t mask_value;
10193 cmdline_fixed_string_t tcp_flags;
10194 uint8_t tcp_flags_value;
10195 cmdline_fixed_string_t priority;
10196 uint8_t priority_value;
10197 cmdline_fixed_string_t queue;
10202 cmd_2tuple_filter_parsed(void *parsed_result,
10203 __attribute__((unused)) struct cmdline *cl,
10204 __attribute__((unused)) void *data)
10206 struct rte_eth_ntuple_filter filter;
10207 struct cmd_2tuple_filter_result *res = parsed_result;
10210 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10212 printf("ntuple filter is not supported on port %u.\n",
10217 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10219 filter.flags = RTE_2TUPLE_FLAGS;
10220 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10221 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10222 filter.proto = res->protocol_value;
10223 filter.priority = res->priority_value;
10224 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10225 printf("nonzero tcp_flags is only meaningful"
10226 " when protocol is TCP.\n");
10229 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10230 printf("invalid TCP flags.\n");
10234 if (res->tcp_flags_value != 0) {
10235 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10236 filter.tcp_flags = res->tcp_flags_value;
10239 /* need convert to big endian. */
10240 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10241 filter.queue = res->queue_id;
10243 if (!strcmp(res->ops, "add"))
10244 ret = rte_eth_dev_filter_ctrl(res->port_id,
10245 RTE_ETH_FILTER_NTUPLE,
10246 RTE_ETH_FILTER_ADD,
10249 ret = rte_eth_dev_filter_ctrl(res->port_id,
10250 RTE_ETH_FILTER_NTUPLE,
10251 RTE_ETH_FILTER_DELETE,
10254 printf("2tuple filter programming error: (%s)\n",
10259 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10260 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10261 filter, "2tuple_filter");
10262 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10263 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10265 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10266 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10268 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10269 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10270 dst_port, "dst_port");
10271 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10272 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10273 dst_port_value, UINT16);
10274 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10275 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10276 protocol, "protocol");
10277 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10278 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10279 protocol_value, UINT8);
10280 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10281 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10283 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10284 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10286 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10287 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10288 tcp_flags, "tcp_flags");
10289 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10290 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10291 tcp_flags_value, UINT8);
10292 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10293 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10294 priority, "priority");
10295 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10296 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10297 priority_value, UINT8);
10298 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10299 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10301 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10302 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10305 cmdline_parse_inst_t cmd_2tuple_filter = {
10306 .f = cmd_2tuple_filter_parsed,
10308 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10309 "<value> mask <value> tcp_flags <value> priority <value> queue "
10310 "<queue_id>: Add a 2tuple filter",
10312 (void *)&cmd_2tuple_filter_filter,
10313 (void *)&cmd_2tuple_filter_port_id,
10314 (void *)&cmd_2tuple_filter_ops,
10315 (void *)&cmd_2tuple_filter_dst_port,
10316 (void *)&cmd_2tuple_filter_dst_port_value,
10317 (void *)&cmd_2tuple_filter_protocol,
10318 (void *)&cmd_2tuple_filter_protocol_value,
10319 (void *)&cmd_2tuple_filter_mask,
10320 (void *)&cmd_2tuple_filter_mask_value,
10321 (void *)&cmd_2tuple_filter_tcp_flags,
10322 (void *)&cmd_2tuple_filter_tcp_flags_value,
10323 (void *)&cmd_2tuple_filter_priority,
10324 (void *)&cmd_2tuple_filter_priority_value,
10325 (void *)&cmd_2tuple_filter_queue,
10326 (void *)&cmd_2tuple_filter_queue_id,
10331 /* *** ADD/REMOVE A 5tuple FILTER *** */
10332 struct cmd_5tuple_filter_result {
10333 cmdline_fixed_string_t filter;
10335 cmdline_fixed_string_t ops;
10336 cmdline_fixed_string_t dst_ip;
10337 cmdline_ipaddr_t dst_ip_value;
10338 cmdline_fixed_string_t src_ip;
10339 cmdline_ipaddr_t src_ip_value;
10340 cmdline_fixed_string_t dst_port;
10341 uint16_t dst_port_value;
10342 cmdline_fixed_string_t src_port;
10343 uint16_t src_port_value;
10344 cmdline_fixed_string_t protocol;
10345 uint8_t protocol_value;
10346 cmdline_fixed_string_t mask;
10347 uint8_t mask_value;
10348 cmdline_fixed_string_t tcp_flags;
10349 uint8_t tcp_flags_value;
10350 cmdline_fixed_string_t priority;
10351 uint8_t priority_value;
10352 cmdline_fixed_string_t queue;
10357 cmd_5tuple_filter_parsed(void *parsed_result,
10358 __attribute__((unused)) struct cmdline *cl,
10359 __attribute__((unused)) void *data)
10361 struct rte_eth_ntuple_filter filter;
10362 struct cmd_5tuple_filter_result *res = parsed_result;
10365 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10367 printf("ntuple filter is not supported on port %u.\n",
10372 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10374 filter.flags = RTE_5TUPLE_FLAGS;
10375 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10376 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10377 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10378 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10379 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10380 filter.proto = res->protocol_value;
10381 filter.priority = res->priority_value;
10382 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10383 printf("nonzero tcp_flags is only meaningful"
10384 " when protocol is TCP.\n");
10387 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10388 printf("invalid TCP flags.\n");
10392 if (res->tcp_flags_value != 0) {
10393 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10394 filter.tcp_flags = res->tcp_flags_value;
10397 if (res->dst_ip_value.family == AF_INET)
10398 /* no need to convert, already big endian. */
10399 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10401 if (filter.dst_ip_mask == 0) {
10402 printf("can not support ipv6 involved compare.\n");
10408 if (res->src_ip_value.family == AF_INET)
10409 /* no need to convert, already big endian. */
10410 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10412 if (filter.src_ip_mask == 0) {
10413 printf("can not support ipv6 involved compare.\n");
10418 /* need convert to big endian. */
10419 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10420 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10421 filter.queue = res->queue_id;
10423 if (!strcmp(res->ops, "add"))
10424 ret = rte_eth_dev_filter_ctrl(res->port_id,
10425 RTE_ETH_FILTER_NTUPLE,
10426 RTE_ETH_FILTER_ADD,
10429 ret = rte_eth_dev_filter_ctrl(res->port_id,
10430 RTE_ETH_FILTER_NTUPLE,
10431 RTE_ETH_FILTER_DELETE,
10434 printf("5tuple filter programming error: (%s)\n",
10438 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10439 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10440 filter, "5tuple_filter");
10441 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10442 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10444 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10445 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10447 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10448 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10450 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10451 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10453 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10454 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10456 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10457 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10459 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10460 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10461 dst_port, "dst_port");
10462 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10463 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10464 dst_port_value, UINT16);
10465 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10466 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10467 src_port, "src_port");
10468 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10469 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10470 src_port_value, UINT16);
10471 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10472 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10473 protocol, "protocol");
10474 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10475 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10476 protocol_value, UINT8);
10477 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10478 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10480 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10481 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10483 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10484 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10485 tcp_flags, "tcp_flags");
10486 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10487 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10488 tcp_flags_value, UINT8);
10489 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10490 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10491 priority, "priority");
10492 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10493 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10494 priority_value, UINT8);
10495 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10496 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10498 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10499 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10502 cmdline_parse_inst_t cmd_5tuple_filter = {
10503 .f = cmd_5tuple_filter_parsed,
10505 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10506 "src_ip <value> dst_port <value> src_port <value> "
10507 "protocol <value> mask <value> tcp_flags <value> "
10508 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10510 (void *)&cmd_5tuple_filter_filter,
10511 (void *)&cmd_5tuple_filter_port_id,
10512 (void *)&cmd_5tuple_filter_ops,
10513 (void *)&cmd_5tuple_filter_dst_ip,
10514 (void *)&cmd_5tuple_filter_dst_ip_value,
10515 (void *)&cmd_5tuple_filter_src_ip,
10516 (void *)&cmd_5tuple_filter_src_ip_value,
10517 (void *)&cmd_5tuple_filter_dst_port,
10518 (void *)&cmd_5tuple_filter_dst_port_value,
10519 (void *)&cmd_5tuple_filter_src_port,
10520 (void *)&cmd_5tuple_filter_src_port_value,
10521 (void *)&cmd_5tuple_filter_protocol,
10522 (void *)&cmd_5tuple_filter_protocol_value,
10523 (void *)&cmd_5tuple_filter_mask,
10524 (void *)&cmd_5tuple_filter_mask_value,
10525 (void *)&cmd_5tuple_filter_tcp_flags,
10526 (void *)&cmd_5tuple_filter_tcp_flags_value,
10527 (void *)&cmd_5tuple_filter_priority,
10528 (void *)&cmd_5tuple_filter_priority_value,
10529 (void *)&cmd_5tuple_filter_queue,
10530 (void *)&cmd_5tuple_filter_queue_id,
10535 /* *** ADD/REMOVE A flex FILTER *** */
10536 struct cmd_flex_filter_result {
10537 cmdline_fixed_string_t filter;
10538 cmdline_fixed_string_t ops;
10540 cmdline_fixed_string_t len;
10542 cmdline_fixed_string_t bytes;
10543 cmdline_fixed_string_t bytes_value;
10544 cmdline_fixed_string_t mask;
10545 cmdline_fixed_string_t mask_value;
10546 cmdline_fixed_string_t priority;
10547 uint8_t priority_value;
10548 cmdline_fixed_string_t queue;
10552 static int xdigit2val(unsigned char c)
10557 else if (isupper(c))
10558 val = c - 'A' + 10;
10560 val = c - 'a' + 10;
10565 cmd_flex_filter_parsed(void *parsed_result,
10566 __attribute__((unused)) struct cmdline *cl,
10567 __attribute__((unused)) void *data)
10570 struct rte_eth_flex_filter filter;
10571 struct cmd_flex_filter_result *res = parsed_result;
10572 char *bytes_ptr, *mask_ptr;
10573 uint16_t len, i, j = 0;
10578 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10579 printf("the len exceed the max length 128\n");
10582 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10583 filter.len = res->len_value;
10584 filter.priority = res->priority_value;
10585 filter.queue = res->queue_id;
10586 bytes_ptr = res->bytes_value;
10587 mask_ptr = res->mask_value;
10589 /* translate bytes string to array. */
10590 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10591 (bytes_ptr[1] == 'X')))
10593 len = strnlen(bytes_ptr, res->len_value * 2);
10594 if (len == 0 || (len % 8 != 0)) {
10595 printf("please check len and bytes input\n");
10598 for (i = 0; i < len; i++) {
10600 if (isxdigit(c) == 0) {
10601 /* invalid characters. */
10602 printf("invalid input\n");
10605 val = xdigit2val(c);
10608 filter.bytes[j] = byte;
10609 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10616 /* translate mask string to uint8_t array. */
10617 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10618 (mask_ptr[1] == 'X')))
10620 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10622 printf("invalid input\n");
10627 for (i = 0; i < len; i++) {
10629 if (isxdigit(c) == 0) {
10630 /* invalid characters. */
10631 printf("invalid input\n");
10634 val = xdigit2val(c);
10637 filter.mask[j] = byte;
10638 printf("mask[%d]:%02x ", j, filter.mask[j]);
10646 if (!strcmp(res->ops, "add"))
10647 ret = rte_eth_dev_filter_ctrl(res->port_id,
10648 RTE_ETH_FILTER_FLEXIBLE,
10649 RTE_ETH_FILTER_ADD,
10652 ret = rte_eth_dev_filter_ctrl(res->port_id,
10653 RTE_ETH_FILTER_FLEXIBLE,
10654 RTE_ETH_FILTER_DELETE,
10658 printf("flex filter setting error: (%s)\n", strerror(-ret));
10661 cmdline_parse_token_string_t cmd_flex_filter_filter =
10662 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10663 filter, "flex_filter");
10664 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10665 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10667 cmdline_parse_token_string_t cmd_flex_filter_ops =
10668 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10670 cmdline_parse_token_string_t cmd_flex_filter_len =
10671 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10673 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10674 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10676 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10677 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10679 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10680 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10681 bytes_value, NULL);
10682 cmdline_parse_token_string_t cmd_flex_filter_mask =
10683 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10685 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10686 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10688 cmdline_parse_token_string_t cmd_flex_filter_priority =
10689 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10690 priority, "priority");
10691 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10692 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10693 priority_value, UINT8);
10694 cmdline_parse_token_string_t cmd_flex_filter_queue =
10695 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10697 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10698 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10700 cmdline_parse_inst_t cmd_flex_filter = {
10701 .f = cmd_flex_filter_parsed,
10703 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10704 "<value> mask <value> priority <value> queue <queue_id>: "
10705 "Add/Del a flex filter",
10707 (void *)&cmd_flex_filter_filter,
10708 (void *)&cmd_flex_filter_port_id,
10709 (void *)&cmd_flex_filter_ops,
10710 (void *)&cmd_flex_filter_len,
10711 (void *)&cmd_flex_filter_len_value,
10712 (void *)&cmd_flex_filter_bytes,
10713 (void *)&cmd_flex_filter_bytes_value,
10714 (void *)&cmd_flex_filter_mask,
10715 (void *)&cmd_flex_filter_mask_value,
10716 (void *)&cmd_flex_filter_priority,
10717 (void *)&cmd_flex_filter_priority_value,
10718 (void *)&cmd_flex_filter_queue,
10719 (void *)&cmd_flex_filter_queue_id,
10724 /* *** Filters Control *** */
10726 /* *** deal with ethertype filter *** */
10727 struct cmd_ethertype_filter_result {
10728 cmdline_fixed_string_t filter;
10730 cmdline_fixed_string_t ops;
10731 cmdline_fixed_string_t mac;
10732 struct rte_ether_addr mac_addr;
10733 cmdline_fixed_string_t ethertype;
10734 uint16_t ethertype_value;
10735 cmdline_fixed_string_t drop;
10736 cmdline_fixed_string_t queue;
10740 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10741 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10742 filter, "ethertype_filter");
10743 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10744 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10746 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10747 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10749 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10750 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10751 mac, "mac_addr#mac_ignr");
10752 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10753 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10755 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10756 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10757 ethertype, "ethertype");
10758 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10759 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10760 ethertype_value, UINT16);
10761 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10762 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10764 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10765 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10767 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10768 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10772 cmd_ethertype_filter_parsed(void *parsed_result,
10773 __attribute__((unused)) struct cmdline *cl,
10774 __attribute__((unused)) void *data)
10776 struct cmd_ethertype_filter_result *res = parsed_result;
10777 struct rte_eth_ethertype_filter filter;
10780 ret = rte_eth_dev_filter_supported(res->port_id,
10781 RTE_ETH_FILTER_ETHERTYPE);
10783 printf("ethertype filter is not supported on port %u.\n",
10788 memset(&filter, 0, sizeof(filter));
10789 if (!strcmp(res->mac, "mac_addr")) {
10790 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10791 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10792 sizeof(struct rte_ether_addr));
10794 if (!strcmp(res->drop, "drop"))
10795 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10796 filter.ether_type = res->ethertype_value;
10797 filter.queue = res->queue_id;
10799 if (!strcmp(res->ops, "add"))
10800 ret = rte_eth_dev_filter_ctrl(res->port_id,
10801 RTE_ETH_FILTER_ETHERTYPE,
10802 RTE_ETH_FILTER_ADD,
10805 ret = rte_eth_dev_filter_ctrl(res->port_id,
10806 RTE_ETH_FILTER_ETHERTYPE,
10807 RTE_ETH_FILTER_DELETE,
10810 printf("ethertype filter programming error: (%s)\n",
10814 cmdline_parse_inst_t cmd_ethertype_filter = {
10815 .f = cmd_ethertype_filter_parsed,
10817 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10818 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10819 "Add or delete an ethertype filter entry",
10821 (void *)&cmd_ethertype_filter_filter,
10822 (void *)&cmd_ethertype_filter_port_id,
10823 (void *)&cmd_ethertype_filter_ops,
10824 (void *)&cmd_ethertype_filter_mac,
10825 (void *)&cmd_ethertype_filter_mac_addr,
10826 (void *)&cmd_ethertype_filter_ethertype,
10827 (void *)&cmd_ethertype_filter_ethertype_value,
10828 (void *)&cmd_ethertype_filter_drop,
10829 (void *)&cmd_ethertype_filter_queue,
10830 (void *)&cmd_ethertype_filter_queue_id,
10835 /* *** deal with flow director filter *** */
10836 struct cmd_flow_director_result {
10837 cmdline_fixed_string_t flow_director_filter;
10839 cmdline_fixed_string_t mode;
10840 cmdline_fixed_string_t mode_value;
10841 cmdline_fixed_string_t ops;
10842 cmdline_fixed_string_t flow;
10843 cmdline_fixed_string_t flow_type;
10844 cmdline_fixed_string_t ether;
10845 uint16_t ether_type;
10846 cmdline_fixed_string_t src;
10847 cmdline_ipaddr_t ip_src;
10849 cmdline_fixed_string_t dst;
10850 cmdline_ipaddr_t ip_dst;
10852 cmdline_fixed_string_t verify_tag;
10853 uint32_t verify_tag_value;
10854 cmdline_fixed_string_t tos;
10856 cmdline_fixed_string_t proto;
10857 uint8_t proto_value;
10858 cmdline_fixed_string_t ttl;
10860 cmdline_fixed_string_t vlan;
10861 uint16_t vlan_value;
10862 cmdline_fixed_string_t flexbytes;
10863 cmdline_fixed_string_t flexbytes_value;
10864 cmdline_fixed_string_t pf_vf;
10865 cmdline_fixed_string_t drop;
10866 cmdline_fixed_string_t queue;
10868 cmdline_fixed_string_t fd_id;
10869 uint32_t fd_id_value;
10870 cmdline_fixed_string_t mac;
10871 struct rte_ether_addr mac_addr;
10872 cmdline_fixed_string_t tunnel;
10873 cmdline_fixed_string_t tunnel_type;
10874 cmdline_fixed_string_t tunnel_id;
10875 uint32_t tunnel_id_value;
10876 cmdline_fixed_string_t packet;
10881 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10884 const char *p, *p0 = q_arg;
10886 unsigned long int_fld;
10887 char *str_fld[max_num];
10892 p = strchr(p0, '(');
10896 p0 = strchr(p, ')');
10901 if (size >= sizeof(s))
10904 snprintf(s, sizeof(s), "%.*s", size, p);
10905 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10906 if (ret < 0 || ret > max_num)
10908 for (i = 0; i < ret; i++) {
10910 int_fld = strtoul(str_fld[i], &end, 0);
10911 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10913 flexbytes[i] = (uint8_t)int_fld;
10919 str2flowtype(char *string)
10922 static const struct {
10925 } flowtype_str[] = {
10926 {"raw", RTE_ETH_FLOW_RAW},
10927 {"ipv4", RTE_ETH_FLOW_IPV4},
10928 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10929 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10930 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10931 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10932 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10933 {"ipv6", RTE_ETH_FLOW_IPV6},
10934 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10935 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10936 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10937 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10938 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10939 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10942 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10943 if (!strcmp(flowtype_str[i].str, string))
10944 return flowtype_str[i].type;
10947 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10948 return (uint16_t)atoi(string);
10950 return RTE_ETH_FLOW_UNKNOWN;
10953 static enum rte_eth_fdir_tunnel_type
10954 str2fdir_tunneltype(char *string)
10958 static const struct {
10960 enum rte_eth_fdir_tunnel_type type;
10961 } tunneltype_str[] = {
10962 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10963 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10966 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10967 if (!strcmp(tunneltype_str[i].str, string))
10968 return tunneltype_str[i].type;
10970 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10973 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10975 if ((ip_addr).family == AF_INET) \
10976 (ip) = (ip_addr).addr.ipv4.s_addr; \
10978 printf("invalid parameter.\n"); \
10983 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10985 if ((ip_addr).family == AF_INET6) \
10986 rte_memcpy(&(ip), \
10987 &((ip_addr).addr.ipv6), \
10988 sizeof(struct in6_addr)); \
10990 printf("invalid parameter.\n"); \
10996 cmd_flow_director_filter_parsed(void *parsed_result,
10997 __attribute__((unused)) struct cmdline *cl,
10998 __attribute__((unused)) void *data)
11000 struct cmd_flow_director_result *res = parsed_result;
11001 struct rte_eth_fdir_filter entry;
11002 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11004 unsigned long vf_id;
11007 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11009 printf("flow director is not supported on port %u.\n",
11013 memset(flexbytes, 0, sizeof(flexbytes));
11014 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11016 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11017 if (strcmp(res->mode_value, "MAC-VLAN")) {
11018 printf("Please set mode to MAC-VLAN.\n");
11021 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11022 if (strcmp(res->mode_value, "Tunnel")) {
11023 printf("Please set mode to Tunnel.\n");
11027 if (!strcmp(res->mode_value, "raw")) {
11028 #ifdef RTE_LIBRTE_I40E_PMD
11029 struct rte_pmd_i40e_flow_type_mapping
11030 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11031 struct rte_pmd_i40e_pkt_template_conf conf;
11032 uint16_t flow_type = str2flowtype(res->flow_type);
11033 uint16_t i, port = res->port_id;
11036 memset(&conf, 0, sizeof(conf));
11038 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11039 printf("Invalid flow type specified.\n");
11042 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11046 if (mapping[flow_type].pctype == 0ULL) {
11047 printf("Invalid flow type specified.\n");
11050 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11051 if (mapping[flow_type].pctype & (1ULL << i)) {
11052 conf.input.pctype = i;
11057 conf.input.packet = open_file(res->filepath,
11058 &conf.input.length);
11059 if (!conf.input.packet)
11061 if (!strcmp(res->drop, "drop"))
11062 conf.action.behavior =
11063 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11065 conf.action.behavior =
11066 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11067 conf.action.report_status =
11068 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11069 conf.action.rx_queue = res->queue_id;
11070 conf.soft_id = res->fd_id_value;
11071 add = strcmp(res->ops, "del") ? 1 : 0;
11072 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11076 printf("flow director config error: (%s)\n",
11078 close_file(conf.input.packet);
11081 } else if (strcmp(res->mode_value, "IP")) {
11082 printf("Please set mode to IP or raw.\n");
11085 entry.input.flow_type = str2flowtype(res->flow_type);
11088 ret = parse_flexbytes(res->flexbytes_value,
11090 RTE_ETH_FDIR_MAX_FLEXLEN);
11092 printf("error: Cannot parse flexbytes input.\n");
11096 switch (entry.input.flow_type) {
11097 case RTE_ETH_FLOW_FRAG_IPV4:
11098 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11099 entry.input.flow.ip4_flow.proto = res->proto_value;
11101 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11102 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11103 IPV4_ADDR_TO_UINT(res->ip_dst,
11104 entry.input.flow.ip4_flow.dst_ip);
11105 IPV4_ADDR_TO_UINT(res->ip_src,
11106 entry.input.flow.ip4_flow.src_ip);
11107 entry.input.flow.ip4_flow.tos = res->tos_value;
11108 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11109 /* need convert to big endian. */
11110 entry.input.flow.udp4_flow.dst_port =
11111 rte_cpu_to_be_16(res->port_dst);
11112 entry.input.flow.udp4_flow.src_port =
11113 rte_cpu_to_be_16(res->port_src);
11115 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11116 IPV4_ADDR_TO_UINT(res->ip_dst,
11117 entry.input.flow.sctp4_flow.ip.dst_ip);
11118 IPV4_ADDR_TO_UINT(res->ip_src,
11119 entry.input.flow.sctp4_flow.ip.src_ip);
11120 entry.input.flow.ip4_flow.tos = res->tos_value;
11121 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11122 /* need convert to big endian. */
11123 entry.input.flow.sctp4_flow.dst_port =
11124 rte_cpu_to_be_16(res->port_dst);
11125 entry.input.flow.sctp4_flow.src_port =
11126 rte_cpu_to_be_16(res->port_src);
11127 entry.input.flow.sctp4_flow.verify_tag =
11128 rte_cpu_to_be_32(res->verify_tag_value);
11130 case RTE_ETH_FLOW_FRAG_IPV6:
11131 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11132 entry.input.flow.ipv6_flow.proto = res->proto_value;
11134 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11135 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11136 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11137 entry.input.flow.ipv6_flow.dst_ip);
11138 IPV6_ADDR_TO_ARRAY(res->ip_src,
11139 entry.input.flow.ipv6_flow.src_ip);
11140 entry.input.flow.ipv6_flow.tc = res->tos_value;
11141 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11142 /* need convert to big endian. */
11143 entry.input.flow.udp6_flow.dst_port =
11144 rte_cpu_to_be_16(res->port_dst);
11145 entry.input.flow.udp6_flow.src_port =
11146 rte_cpu_to_be_16(res->port_src);
11148 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11149 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11150 entry.input.flow.sctp6_flow.ip.dst_ip);
11151 IPV6_ADDR_TO_ARRAY(res->ip_src,
11152 entry.input.flow.sctp6_flow.ip.src_ip);
11153 entry.input.flow.ipv6_flow.tc = res->tos_value;
11154 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11155 /* need convert to big endian. */
11156 entry.input.flow.sctp6_flow.dst_port =
11157 rte_cpu_to_be_16(res->port_dst);
11158 entry.input.flow.sctp6_flow.src_port =
11159 rte_cpu_to_be_16(res->port_src);
11160 entry.input.flow.sctp6_flow.verify_tag =
11161 rte_cpu_to_be_32(res->verify_tag_value);
11163 case RTE_ETH_FLOW_L2_PAYLOAD:
11164 entry.input.flow.l2_flow.ether_type =
11165 rte_cpu_to_be_16(res->ether_type);
11171 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11172 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11174 sizeof(struct rte_ether_addr));
11176 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11177 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11179 sizeof(struct rte_ether_addr));
11180 entry.input.flow.tunnel_flow.tunnel_type =
11181 str2fdir_tunneltype(res->tunnel_type);
11182 entry.input.flow.tunnel_flow.tunnel_id =
11183 rte_cpu_to_be_32(res->tunnel_id_value);
11186 rte_memcpy(entry.input.flow_ext.flexbytes,
11188 RTE_ETH_FDIR_MAX_FLEXLEN);
11190 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11192 entry.action.flex_off = 0; /*use 0 by default */
11193 if (!strcmp(res->drop, "drop"))
11194 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11196 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11198 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11199 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11200 if (!strcmp(res->pf_vf, "pf"))
11201 entry.input.flow_ext.is_vf = 0;
11202 else if (!strncmp(res->pf_vf, "vf", 2)) {
11203 struct rte_eth_dev_info dev_info;
11205 ret = eth_dev_info_get_print_err(res->port_id,
11211 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11212 if (errno != 0 || *end != '\0' ||
11213 vf_id >= dev_info.max_vfs) {
11214 printf("invalid parameter %s.\n", res->pf_vf);
11217 entry.input.flow_ext.is_vf = 1;
11218 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11220 printf("invalid parameter %s.\n", res->pf_vf);
11225 /* set to report FD ID by default */
11226 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11227 entry.action.rx_queue = res->queue_id;
11228 entry.soft_id = res->fd_id_value;
11229 if (!strcmp(res->ops, "add"))
11230 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11231 RTE_ETH_FILTER_ADD, &entry);
11232 else if (!strcmp(res->ops, "del"))
11233 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11234 RTE_ETH_FILTER_DELETE, &entry);
11236 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11237 RTE_ETH_FILTER_UPDATE, &entry);
11239 printf("flow director programming error: (%s)\n",
11243 cmdline_parse_token_string_t cmd_flow_director_filter =
11244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11245 flow_director_filter, "flow_director_filter");
11246 cmdline_parse_token_num_t cmd_flow_director_port_id =
11247 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11249 cmdline_parse_token_string_t cmd_flow_director_ops =
11250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11251 ops, "add#del#update");
11252 cmdline_parse_token_string_t cmd_flow_director_flow =
11253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11255 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11258 cmdline_parse_token_string_t cmd_flow_director_ether =
11259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11261 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11262 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11263 ether_type, UINT16);
11264 cmdline_parse_token_string_t cmd_flow_director_src =
11265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11267 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11268 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11270 cmdline_parse_token_num_t cmd_flow_director_port_src =
11271 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11273 cmdline_parse_token_string_t cmd_flow_director_dst =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11276 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11277 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11279 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11282 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11284 verify_tag, "verify_tag");
11285 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11286 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11287 verify_tag_value, UINT32);
11288 cmdline_parse_token_string_t cmd_flow_director_tos =
11289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11291 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11294 cmdline_parse_token_string_t cmd_flow_director_proto =
11295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11297 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11298 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11299 proto_value, UINT8);
11300 cmdline_parse_token_string_t cmd_flow_director_ttl =
11301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11303 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11304 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11306 cmdline_parse_token_string_t cmd_flow_director_vlan =
11307 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11309 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11310 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11311 vlan_value, UINT16);
11312 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11313 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11314 flexbytes, "flexbytes");
11315 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11316 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11317 flexbytes_value, NULL);
11318 cmdline_parse_token_string_t cmd_flow_director_drop =
11319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11321 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11324 cmdline_parse_token_string_t cmd_flow_director_queue =
11325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11327 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11328 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11330 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11333 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11334 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11335 fd_id_value, UINT32);
11337 cmdline_parse_token_string_t cmd_flow_director_mode =
11338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11340 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11343 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11345 mode_value, "MAC-VLAN");
11346 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11348 mode_value, "Tunnel");
11349 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11351 mode_value, "raw");
11352 cmdline_parse_token_string_t cmd_flow_director_mac =
11353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11355 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11356 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11358 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11361 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11363 tunnel_type, "NVGRE#VxLAN");
11364 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11366 tunnel_id, "tunnel-id");
11367 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11368 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11369 tunnel_id_value, UINT32);
11370 cmdline_parse_token_string_t cmd_flow_director_packet =
11371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11373 cmdline_parse_token_string_t cmd_flow_director_filepath =
11374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11377 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11378 .f = cmd_flow_director_filter_parsed,
11380 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11381 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11382 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11383 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11384 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11385 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11386 "fd_id <fd_id_value>: "
11387 "Add or delete an ip flow director entry on NIC",
11389 (void *)&cmd_flow_director_filter,
11390 (void *)&cmd_flow_director_port_id,
11391 (void *)&cmd_flow_director_mode,
11392 (void *)&cmd_flow_director_mode_ip,
11393 (void *)&cmd_flow_director_ops,
11394 (void *)&cmd_flow_director_flow,
11395 (void *)&cmd_flow_director_flow_type,
11396 (void *)&cmd_flow_director_src,
11397 (void *)&cmd_flow_director_ip_src,
11398 (void *)&cmd_flow_director_dst,
11399 (void *)&cmd_flow_director_ip_dst,
11400 (void *)&cmd_flow_director_tos,
11401 (void *)&cmd_flow_director_tos_value,
11402 (void *)&cmd_flow_director_proto,
11403 (void *)&cmd_flow_director_proto_value,
11404 (void *)&cmd_flow_director_ttl,
11405 (void *)&cmd_flow_director_ttl_value,
11406 (void *)&cmd_flow_director_vlan,
11407 (void *)&cmd_flow_director_vlan_value,
11408 (void *)&cmd_flow_director_flexbytes,
11409 (void *)&cmd_flow_director_flexbytes_value,
11410 (void *)&cmd_flow_director_drop,
11411 (void *)&cmd_flow_director_pf_vf,
11412 (void *)&cmd_flow_director_queue,
11413 (void *)&cmd_flow_director_queue_id,
11414 (void *)&cmd_flow_director_fd_id,
11415 (void *)&cmd_flow_director_fd_id_value,
11420 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11421 .f = cmd_flow_director_filter_parsed,
11423 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11424 "director entry on NIC",
11426 (void *)&cmd_flow_director_filter,
11427 (void *)&cmd_flow_director_port_id,
11428 (void *)&cmd_flow_director_mode,
11429 (void *)&cmd_flow_director_mode_ip,
11430 (void *)&cmd_flow_director_ops,
11431 (void *)&cmd_flow_director_flow,
11432 (void *)&cmd_flow_director_flow_type,
11433 (void *)&cmd_flow_director_src,
11434 (void *)&cmd_flow_director_ip_src,
11435 (void *)&cmd_flow_director_port_src,
11436 (void *)&cmd_flow_director_dst,
11437 (void *)&cmd_flow_director_ip_dst,
11438 (void *)&cmd_flow_director_port_dst,
11439 (void *)&cmd_flow_director_tos,
11440 (void *)&cmd_flow_director_tos_value,
11441 (void *)&cmd_flow_director_ttl,
11442 (void *)&cmd_flow_director_ttl_value,
11443 (void *)&cmd_flow_director_vlan,
11444 (void *)&cmd_flow_director_vlan_value,
11445 (void *)&cmd_flow_director_flexbytes,
11446 (void *)&cmd_flow_director_flexbytes_value,
11447 (void *)&cmd_flow_director_drop,
11448 (void *)&cmd_flow_director_pf_vf,
11449 (void *)&cmd_flow_director_queue,
11450 (void *)&cmd_flow_director_queue_id,
11451 (void *)&cmd_flow_director_fd_id,
11452 (void *)&cmd_flow_director_fd_id_value,
11457 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11458 .f = cmd_flow_director_filter_parsed,
11460 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11461 "director entry on NIC",
11463 (void *)&cmd_flow_director_filter,
11464 (void *)&cmd_flow_director_port_id,
11465 (void *)&cmd_flow_director_mode,
11466 (void *)&cmd_flow_director_mode_ip,
11467 (void *)&cmd_flow_director_ops,
11468 (void *)&cmd_flow_director_flow,
11469 (void *)&cmd_flow_director_flow_type,
11470 (void *)&cmd_flow_director_src,
11471 (void *)&cmd_flow_director_ip_src,
11472 (void *)&cmd_flow_director_port_src,
11473 (void *)&cmd_flow_director_dst,
11474 (void *)&cmd_flow_director_ip_dst,
11475 (void *)&cmd_flow_director_port_dst,
11476 (void *)&cmd_flow_director_verify_tag,
11477 (void *)&cmd_flow_director_verify_tag_value,
11478 (void *)&cmd_flow_director_tos,
11479 (void *)&cmd_flow_director_tos_value,
11480 (void *)&cmd_flow_director_ttl,
11481 (void *)&cmd_flow_director_ttl_value,
11482 (void *)&cmd_flow_director_vlan,
11483 (void *)&cmd_flow_director_vlan_value,
11484 (void *)&cmd_flow_director_flexbytes,
11485 (void *)&cmd_flow_director_flexbytes_value,
11486 (void *)&cmd_flow_director_drop,
11487 (void *)&cmd_flow_director_pf_vf,
11488 (void *)&cmd_flow_director_queue,
11489 (void *)&cmd_flow_director_queue_id,
11490 (void *)&cmd_flow_director_fd_id,
11491 (void *)&cmd_flow_director_fd_id_value,
11496 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11497 .f = cmd_flow_director_filter_parsed,
11499 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11500 "director entry on NIC",
11502 (void *)&cmd_flow_director_filter,
11503 (void *)&cmd_flow_director_port_id,
11504 (void *)&cmd_flow_director_mode,
11505 (void *)&cmd_flow_director_mode_ip,
11506 (void *)&cmd_flow_director_ops,
11507 (void *)&cmd_flow_director_flow,
11508 (void *)&cmd_flow_director_flow_type,
11509 (void *)&cmd_flow_director_ether,
11510 (void *)&cmd_flow_director_ether_type,
11511 (void *)&cmd_flow_director_flexbytes,
11512 (void *)&cmd_flow_director_flexbytes_value,
11513 (void *)&cmd_flow_director_drop,
11514 (void *)&cmd_flow_director_pf_vf,
11515 (void *)&cmd_flow_director_queue,
11516 (void *)&cmd_flow_director_queue_id,
11517 (void *)&cmd_flow_director_fd_id,
11518 (void *)&cmd_flow_director_fd_id_value,
11523 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11524 .f = cmd_flow_director_filter_parsed,
11526 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11527 "director entry on NIC",
11529 (void *)&cmd_flow_director_filter,
11530 (void *)&cmd_flow_director_port_id,
11531 (void *)&cmd_flow_director_mode,
11532 (void *)&cmd_flow_director_mode_mac_vlan,
11533 (void *)&cmd_flow_director_ops,
11534 (void *)&cmd_flow_director_mac,
11535 (void *)&cmd_flow_director_mac_addr,
11536 (void *)&cmd_flow_director_vlan,
11537 (void *)&cmd_flow_director_vlan_value,
11538 (void *)&cmd_flow_director_flexbytes,
11539 (void *)&cmd_flow_director_flexbytes_value,
11540 (void *)&cmd_flow_director_drop,
11541 (void *)&cmd_flow_director_queue,
11542 (void *)&cmd_flow_director_queue_id,
11543 (void *)&cmd_flow_director_fd_id,
11544 (void *)&cmd_flow_director_fd_id_value,
11549 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11550 .f = cmd_flow_director_filter_parsed,
11552 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11553 "director entry on NIC",
11555 (void *)&cmd_flow_director_filter,
11556 (void *)&cmd_flow_director_port_id,
11557 (void *)&cmd_flow_director_mode,
11558 (void *)&cmd_flow_director_mode_tunnel,
11559 (void *)&cmd_flow_director_ops,
11560 (void *)&cmd_flow_director_mac,
11561 (void *)&cmd_flow_director_mac_addr,
11562 (void *)&cmd_flow_director_vlan,
11563 (void *)&cmd_flow_director_vlan_value,
11564 (void *)&cmd_flow_director_tunnel,
11565 (void *)&cmd_flow_director_tunnel_type,
11566 (void *)&cmd_flow_director_tunnel_id,
11567 (void *)&cmd_flow_director_tunnel_id_value,
11568 (void *)&cmd_flow_director_flexbytes,
11569 (void *)&cmd_flow_director_flexbytes_value,
11570 (void *)&cmd_flow_director_drop,
11571 (void *)&cmd_flow_director_queue,
11572 (void *)&cmd_flow_director_queue_id,
11573 (void *)&cmd_flow_director_fd_id,
11574 (void *)&cmd_flow_director_fd_id_value,
11579 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11580 .f = cmd_flow_director_filter_parsed,
11582 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11583 "director entry on NIC",
11585 (void *)&cmd_flow_director_filter,
11586 (void *)&cmd_flow_director_port_id,
11587 (void *)&cmd_flow_director_mode,
11588 (void *)&cmd_flow_director_mode_raw,
11589 (void *)&cmd_flow_director_ops,
11590 (void *)&cmd_flow_director_flow,
11591 (void *)&cmd_flow_director_flow_type,
11592 (void *)&cmd_flow_director_drop,
11593 (void *)&cmd_flow_director_queue,
11594 (void *)&cmd_flow_director_queue_id,
11595 (void *)&cmd_flow_director_fd_id,
11596 (void *)&cmd_flow_director_fd_id_value,
11597 (void *)&cmd_flow_director_packet,
11598 (void *)&cmd_flow_director_filepath,
11603 struct cmd_flush_flow_director_result {
11604 cmdline_fixed_string_t flush_flow_director;
11608 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11609 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11610 flush_flow_director, "flush_flow_director");
11611 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11612 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11616 cmd_flush_flow_director_parsed(void *parsed_result,
11617 __attribute__((unused)) struct cmdline *cl,
11618 __attribute__((unused)) void *data)
11620 struct cmd_flow_director_result *res = parsed_result;
11623 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11625 printf("flow director is not supported on port %u.\n",
11630 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11631 RTE_ETH_FILTER_FLUSH, NULL);
11633 printf("flow director table flushing error: (%s)\n",
11637 cmdline_parse_inst_t cmd_flush_flow_director = {
11638 .f = cmd_flush_flow_director_parsed,
11640 .help_str = "flush_flow_director <port_id>: "
11641 "Flush all flow director entries of a device on NIC",
11643 (void *)&cmd_flush_flow_director_flush,
11644 (void *)&cmd_flush_flow_director_port_id,
11649 /* *** deal with flow director mask *** */
11650 struct cmd_flow_director_mask_result {
11651 cmdline_fixed_string_t flow_director_mask;
11653 cmdline_fixed_string_t mode;
11654 cmdline_fixed_string_t mode_value;
11655 cmdline_fixed_string_t vlan;
11656 uint16_t vlan_mask;
11657 cmdline_fixed_string_t src_mask;
11658 cmdline_ipaddr_t ipv4_src;
11659 cmdline_ipaddr_t ipv6_src;
11661 cmdline_fixed_string_t dst_mask;
11662 cmdline_ipaddr_t ipv4_dst;
11663 cmdline_ipaddr_t ipv6_dst;
11665 cmdline_fixed_string_t mac;
11666 uint8_t mac_addr_byte_mask;
11667 cmdline_fixed_string_t tunnel_id;
11668 uint32_t tunnel_id_mask;
11669 cmdline_fixed_string_t tunnel_type;
11670 uint8_t tunnel_type_mask;
11674 cmd_flow_director_mask_parsed(void *parsed_result,
11675 __attribute__((unused)) struct cmdline *cl,
11676 __attribute__((unused)) void *data)
11678 struct cmd_flow_director_mask_result *res = parsed_result;
11679 struct rte_eth_fdir_masks *mask;
11680 struct rte_port *port;
11682 port = &ports[res->port_id];
11683 /** Check if the port is not started **/
11684 if (port->port_status != RTE_PORT_STOPPED) {
11685 printf("Please stop port %d first\n", res->port_id);
11689 mask = &port->dev_conf.fdir_conf.mask;
11691 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11692 if (strcmp(res->mode_value, "MAC-VLAN")) {
11693 printf("Please set mode to MAC-VLAN.\n");
11697 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11698 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11699 if (strcmp(res->mode_value, "Tunnel")) {
11700 printf("Please set mode to Tunnel.\n");
11704 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11705 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11706 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11707 mask->tunnel_type_mask = res->tunnel_type_mask;
11709 if (strcmp(res->mode_value, "IP")) {
11710 printf("Please set mode to IP.\n");
11714 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11715 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11716 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11717 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11718 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11719 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11720 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11723 cmd_reconfig_device_queue(res->port_id, 1, 1);
11726 cmdline_parse_token_string_t cmd_flow_director_mask =
11727 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11728 flow_director_mask, "flow_director_mask");
11729 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11730 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11732 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11735 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11736 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11737 vlan_mask, UINT16);
11738 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11739 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11740 src_mask, "src_mask");
11741 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11742 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11744 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11745 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11747 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11748 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11750 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11752 dst_mask, "dst_mask");
11753 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11754 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11756 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11757 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11759 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11760 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11763 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11764 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11766 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11769 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11770 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11771 mode_value, "MAC-VLAN");
11772 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11774 mode_value, "Tunnel");
11775 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11778 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11779 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11780 mac_addr_byte_mask, UINT8);
11781 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11783 tunnel_type, "tunnel-type");
11784 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11785 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11786 tunnel_type_mask, UINT8);
11787 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11788 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11789 tunnel_id, "tunnel-id");
11790 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11791 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11792 tunnel_id_mask, UINT32);
11794 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11795 .f = cmd_flow_director_mask_parsed,
11797 .help_str = "flow_director_mask ... : "
11798 "Set IP mode flow director's mask on NIC",
11800 (void *)&cmd_flow_director_mask,
11801 (void *)&cmd_flow_director_mask_port_id,
11802 (void *)&cmd_flow_director_mask_mode,
11803 (void *)&cmd_flow_director_mask_mode_ip,
11804 (void *)&cmd_flow_director_mask_vlan,
11805 (void *)&cmd_flow_director_mask_vlan_value,
11806 (void *)&cmd_flow_director_mask_src,
11807 (void *)&cmd_flow_director_mask_ipv4_src,
11808 (void *)&cmd_flow_director_mask_ipv6_src,
11809 (void *)&cmd_flow_director_mask_port_src,
11810 (void *)&cmd_flow_director_mask_dst,
11811 (void *)&cmd_flow_director_mask_ipv4_dst,
11812 (void *)&cmd_flow_director_mask_ipv6_dst,
11813 (void *)&cmd_flow_director_mask_port_dst,
11818 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11819 .f = cmd_flow_director_mask_parsed,
11821 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11822 "flow director's mask on NIC",
11824 (void *)&cmd_flow_director_mask,
11825 (void *)&cmd_flow_director_mask_port_id,
11826 (void *)&cmd_flow_director_mask_mode,
11827 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11828 (void *)&cmd_flow_director_mask_vlan,
11829 (void *)&cmd_flow_director_mask_vlan_value,
11834 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11835 .f = cmd_flow_director_mask_parsed,
11837 .help_str = "flow_director_mask ... : Set tunnel mode "
11838 "flow director's mask on NIC",
11840 (void *)&cmd_flow_director_mask,
11841 (void *)&cmd_flow_director_mask_port_id,
11842 (void *)&cmd_flow_director_mask_mode,
11843 (void *)&cmd_flow_director_mask_mode_tunnel,
11844 (void *)&cmd_flow_director_mask_vlan,
11845 (void *)&cmd_flow_director_mask_vlan_value,
11846 (void *)&cmd_flow_director_mask_mac,
11847 (void *)&cmd_flow_director_mask_mac_value,
11848 (void *)&cmd_flow_director_mask_tunnel_type,
11849 (void *)&cmd_flow_director_mask_tunnel_type_value,
11850 (void *)&cmd_flow_director_mask_tunnel_id,
11851 (void *)&cmd_flow_director_mask_tunnel_id_value,
11856 /* *** deal with flow director mask on flexible payload *** */
11857 struct cmd_flow_director_flex_mask_result {
11858 cmdline_fixed_string_t flow_director_flexmask;
11860 cmdline_fixed_string_t flow;
11861 cmdline_fixed_string_t flow_type;
11862 cmdline_fixed_string_t mask;
11866 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11867 __attribute__((unused)) struct cmdline *cl,
11868 __attribute__((unused)) void *data)
11870 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11871 struct rte_eth_fdir_info fdir_info;
11872 struct rte_eth_fdir_flex_mask flex_mask;
11873 struct rte_port *port;
11874 uint64_t flow_type_mask;
11878 port = &ports[res->port_id];
11879 /** Check if the port is not started **/
11880 if (port->port_status != RTE_PORT_STOPPED) {
11881 printf("Please stop port %d first\n", res->port_id);
11885 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11886 ret = parse_flexbytes(res->mask,
11888 RTE_ETH_FDIR_MAX_FLEXLEN);
11890 printf("error: Cannot parse mask input.\n");
11894 memset(&fdir_info, 0, sizeof(fdir_info));
11895 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11896 RTE_ETH_FILTER_INFO, &fdir_info);
11898 printf("Cannot get FDir filter info\n");
11902 if (!strcmp(res->flow_type, "none")) {
11903 /* means don't specify the flow type */
11904 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11905 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11906 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11907 0, sizeof(struct rte_eth_fdir_flex_mask));
11908 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11909 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11911 sizeof(struct rte_eth_fdir_flex_mask));
11912 cmd_reconfig_device_queue(res->port_id, 1, 1);
11915 flow_type_mask = fdir_info.flow_types_mask[0];
11916 if (!strcmp(res->flow_type, "all")) {
11917 if (!flow_type_mask) {
11918 printf("No flow type supported\n");
11921 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11922 if (flow_type_mask & (1ULL << i)) {
11923 flex_mask.flow_type = i;
11924 fdir_set_flex_mask(res->port_id, &flex_mask);
11927 cmd_reconfig_device_queue(res->port_id, 1, 1);
11930 flex_mask.flow_type = str2flowtype(res->flow_type);
11931 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11932 printf("Flow type %s not supported on port %d\n",
11933 res->flow_type, res->port_id);
11936 fdir_set_flex_mask(res->port_id, &flex_mask);
11937 cmd_reconfig_device_queue(res->port_id, 1, 1);
11940 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11942 flow_director_flexmask,
11943 "flow_director_flex_mask");
11944 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11945 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11947 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11948 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11950 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11951 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11952 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11953 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11954 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11958 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11959 .f = cmd_flow_director_flex_mask_parsed,
11961 .help_str = "flow_director_flex_mask ... : "
11962 "Set flow director's flex mask on NIC",
11964 (void *)&cmd_flow_director_flexmask,
11965 (void *)&cmd_flow_director_flexmask_port_id,
11966 (void *)&cmd_flow_director_flexmask_flow,
11967 (void *)&cmd_flow_director_flexmask_flow_type,
11968 (void *)&cmd_flow_director_flexmask_mask,
11973 /* *** deal with flow director flexible payload configuration *** */
11974 struct cmd_flow_director_flexpayload_result {
11975 cmdline_fixed_string_t flow_director_flexpayload;
11977 cmdline_fixed_string_t payload_layer;
11978 cmdline_fixed_string_t payload_cfg;
11982 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11985 const char *p, *p0 = q_arg;
11987 unsigned long int_fld;
11988 char *str_fld[max_num];
11993 p = strchr(p0, '(');
11997 p0 = strchr(p, ')');
12002 if (size >= sizeof(s))
12005 snprintf(s, sizeof(s), "%.*s", size, p);
12006 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12007 if (ret < 0 || ret > max_num)
12009 for (i = 0; i < ret; i++) {
12011 int_fld = strtoul(str_fld[i], &end, 0);
12012 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12014 offsets[i] = (uint16_t)int_fld;
12020 cmd_flow_director_flxpld_parsed(void *parsed_result,
12021 __attribute__((unused)) struct cmdline *cl,
12022 __attribute__((unused)) void *data)
12024 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12025 struct rte_eth_flex_payload_cfg flex_cfg;
12026 struct rte_port *port;
12029 port = &ports[res->port_id];
12030 /** Check if the port is not started **/
12031 if (port->port_status != RTE_PORT_STOPPED) {
12032 printf("Please stop port %d first\n", res->port_id);
12036 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12038 if (!strcmp(res->payload_layer, "raw"))
12039 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12040 else if (!strcmp(res->payload_layer, "l2"))
12041 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12042 else if (!strcmp(res->payload_layer, "l3"))
12043 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12044 else if (!strcmp(res->payload_layer, "l4"))
12045 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12047 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12048 RTE_ETH_FDIR_MAX_FLEXLEN);
12050 printf("error: Cannot parse flex payload input.\n");
12054 fdir_set_flex_payload(res->port_id, &flex_cfg);
12055 cmd_reconfig_device_queue(res->port_id, 1, 1);
12058 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12059 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12060 flow_director_flexpayload,
12061 "flow_director_flex_payload");
12062 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12063 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12065 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12066 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12067 payload_layer, "raw#l2#l3#l4");
12068 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12069 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12070 payload_cfg, NULL);
12072 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12073 .f = cmd_flow_director_flxpld_parsed,
12075 .help_str = "flow_director_flexpayload ... : "
12076 "Set flow director's flex payload on NIC",
12078 (void *)&cmd_flow_director_flexpayload,
12079 (void *)&cmd_flow_director_flexpayload_port_id,
12080 (void *)&cmd_flow_director_flexpayload_payload_layer,
12081 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12086 /* Generic flow interface command. */
12087 extern cmdline_parse_inst_t cmd_flow;
12089 /* *** Classification Filters Control *** */
12090 /* *** Get symmetric hash enable per port *** */
12091 struct cmd_get_sym_hash_ena_per_port_result {
12092 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12097 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12098 __rte_unused struct cmdline *cl,
12099 __rte_unused void *data)
12101 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12102 struct rte_eth_hash_filter_info info;
12105 if (rte_eth_dev_filter_supported(res->port_id,
12106 RTE_ETH_FILTER_HASH) < 0) {
12107 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12112 memset(&info, 0, sizeof(info));
12113 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12114 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12115 RTE_ETH_FILTER_GET, &info);
12118 printf("Cannot get symmetric hash enable per port "
12119 "on port %u\n", res->port_id);
12123 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12124 "enabled" : "disabled", res->port_id);
12127 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12128 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12129 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12130 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12131 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12134 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12135 .f = cmd_get_sym_hash_per_port_parsed,
12137 .help_str = "get_sym_hash_ena_per_port <port_id>",
12139 (void *)&cmd_get_sym_hash_ena_per_port_all,
12140 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12145 /* *** Set symmetric hash enable per port *** */
12146 struct cmd_set_sym_hash_ena_per_port_result {
12147 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12148 cmdline_fixed_string_t enable;
12153 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12154 __rte_unused struct cmdline *cl,
12155 __rte_unused void *data)
12157 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12158 struct rte_eth_hash_filter_info info;
12161 if (rte_eth_dev_filter_supported(res->port_id,
12162 RTE_ETH_FILTER_HASH) < 0) {
12163 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12168 memset(&info, 0, sizeof(info));
12169 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12170 if (!strcmp(res->enable, "enable"))
12171 info.info.enable = 1;
12172 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12173 RTE_ETH_FILTER_SET, &info);
12175 printf("Cannot set symmetric hash enable per port on "
12176 "port %u\n", res->port_id);
12179 printf("Symmetric hash has been set to %s on port %u\n",
12180 res->enable, res->port_id);
12183 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12184 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12185 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12186 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12187 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12189 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12190 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12191 enable, "enable#disable");
12193 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12194 .f = cmd_set_sym_hash_per_port_parsed,
12196 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12198 (void *)&cmd_set_sym_hash_ena_per_port_all,
12199 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12200 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12205 /* Get global config of hash function */
12206 struct cmd_get_hash_global_config_result {
12207 cmdline_fixed_string_t get_hash_global_config;
12212 flowtype_to_str(uint16_t ftype)
12218 } ftype_table[] = {
12219 {"ipv4", RTE_ETH_FLOW_IPV4},
12220 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12221 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12222 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12223 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12224 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12225 {"ipv6", RTE_ETH_FLOW_IPV6},
12226 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12227 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12228 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12229 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12230 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12231 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12232 {"port", RTE_ETH_FLOW_PORT},
12233 {"vxlan", RTE_ETH_FLOW_VXLAN},
12234 {"geneve", RTE_ETH_FLOW_GENEVE},
12235 {"nvgre", RTE_ETH_FLOW_NVGRE},
12236 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12239 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12240 if (ftype_table[i].ftype == ftype)
12241 return ftype_table[i].str;
12248 cmd_get_hash_global_config_parsed(void *parsed_result,
12249 __rte_unused struct cmdline *cl,
12250 __rte_unused void *data)
12252 struct cmd_get_hash_global_config_result *res = parsed_result;
12253 struct rte_eth_hash_filter_info info;
12254 uint32_t idx, offset;
12259 if (rte_eth_dev_filter_supported(res->port_id,
12260 RTE_ETH_FILTER_HASH) < 0) {
12261 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12266 memset(&info, 0, sizeof(info));
12267 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12268 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12269 RTE_ETH_FILTER_GET, &info);
12271 printf("Cannot get hash global configurations by port %d\n",
12276 switch (info.info.global_conf.hash_func) {
12277 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12278 printf("Hash function is Toeplitz\n");
12280 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12281 printf("Hash function is Simple XOR\n");
12283 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12284 printf("Hash function is Symmetric Toeplitz\n");
12287 printf("Unknown hash function\n");
12291 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12292 idx = i / UINT64_BIT;
12293 offset = i % UINT64_BIT;
12294 if (!(info.info.global_conf.valid_bit_mask[idx] &
12297 str = flowtype_to_str(i);
12300 printf("Symmetric hash is %s globally for flow type %s "
12302 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12303 (1ULL << offset)) ? "enabled" : "disabled"), str,
12308 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12309 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12310 get_hash_global_config, "get_hash_global_config");
12311 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12312 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12315 cmdline_parse_inst_t cmd_get_hash_global_config = {
12316 .f = cmd_get_hash_global_config_parsed,
12318 .help_str = "get_hash_global_config <port_id>",
12320 (void *)&cmd_get_hash_global_config_all,
12321 (void *)&cmd_get_hash_global_config_port_id,
12326 /* Set global config of hash function */
12327 struct cmd_set_hash_global_config_result {
12328 cmdline_fixed_string_t set_hash_global_config;
12330 cmdline_fixed_string_t hash_func;
12331 cmdline_fixed_string_t flow_type;
12332 cmdline_fixed_string_t enable;
12336 cmd_set_hash_global_config_parsed(void *parsed_result,
12337 __rte_unused struct cmdline *cl,
12338 __rte_unused void *data)
12340 struct cmd_set_hash_global_config_result *res = parsed_result;
12341 struct rte_eth_hash_filter_info info;
12342 uint32_t ftype, idx, offset;
12345 if (rte_eth_dev_filter_supported(res->port_id,
12346 RTE_ETH_FILTER_HASH) < 0) {
12347 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12351 memset(&info, 0, sizeof(info));
12352 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12353 if (!strcmp(res->hash_func, "toeplitz"))
12354 info.info.global_conf.hash_func =
12355 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12356 else if (!strcmp(res->hash_func, "simple_xor"))
12357 info.info.global_conf.hash_func =
12358 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12359 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12360 info.info.global_conf.hash_func =
12361 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12362 else if (!strcmp(res->hash_func, "default"))
12363 info.info.global_conf.hash_func =
12364 RTE_ETH_HASH_FUNCTION_DEFAULT;
12366 ftype = str2flowtype(res->flow_type);
12367 idx = ftype / UINT64_BIT;
12368 offset = ftype % UINT64_BIT;
12369 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12370 if (!strcmp(res->enable, "enable"))
12371 info.info.global_conf.sym_hash_enable_mask[idx] |=
12373 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12374 RTE_ETH_FILTER_SET, &info);
12376 printf("Cannot set global hash configurations by port %d\n",
12379 printf("Global hash configurations have been set "
12380 "successfully by port %d\n", res->port_id);
12383 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12384 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12385 set_hash_global_config, "set_hash_global_config");
12386 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12387 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12389 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12390 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12391 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12392 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12393 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12395 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12396 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12397 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12399 enable, "enable#disable");
12401 cmdline_parse_inst_t cmd_set_hash_global_config = {
12402 .f = cmd_set_hash_global_config_parsed,
12404 .help_str = "set_hash_global_config <port_id> "
12405 "toeplitz|simple_xor|symmetric_toeplitz|default "
12406 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12407 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12408 "l2_payload enable|disable",
12410 (void *)&cmd_set_hash_global_config_all,
12411 (void *)&cmd_set_hash_global_config_port_id,
12412 (void *)&cmd_set_hash_global_config_hash_func,
12413 (void *)&cmd_set_hash_global_config_flow_type,
12414 (void *)&cmd_set_hash_global_config_enable,
12419 /* Set hash input set */
12420 struct cmd_set_hash_input_set_result {
12421 cmdline_fixed_string_t set_hash_input_set;
12423 cmdline_fixed_string_t flow_type;
12424 cmdline_fixed_string_t inset_field;
12425 cmdline_fixed_string_t select;
12428 static enum rte_eth_input_set_field
12429 str2inset(char *string)
12433 static const struct {
12435 enum rte_eth_input_set_field inset;
12436 } inset_table[] = {
12437 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12438 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12439 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12440 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12441 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12442 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12443 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12444 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12445 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12446 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12447 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12448 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12449 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12450 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12451 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12452 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12453 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12454 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12455 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12456 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12457 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12458 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12459 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12460 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12461 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12462 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12463 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12464 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12465 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12466 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12467 {"none", RTE_ETH_INPUT_SET_NONE},
12470 for (i = 0; i < RTE_DIM(inset_table); i++) {
12471 if (!strcmp(string, inset_table[i].str))
12472 return inset_table[i].inset;
12475 return RTE_ETH_INPUT_SET_UNKNOWN;
12479 cmd_set_hash_input_set_parsed(void *parsed_result,
12480 __rte_unused struct cmdline *cl,
12481 __rte_unused void *data)
12483 struct cmd_set_hash_input_set_result *res = parsed_result;
12484 struct rte_eth_hash_filter_info info;
12486 memset(&info, 0, sizeof(info));
12487 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12488 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12489 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12490 info.info.input_set_conf.inset_size = 1;
12491 if (!strcmp(res->select, "select"))
12492 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12493 else if (!strcmp(res->select, "add"))
12494 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12495 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12496 RTE_ETH_FILTER_SET, &info);
12499 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12500 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12501 set_hash_input_set, "set_hash_input_set");
12502 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12503 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12505 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12506 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12508 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12509 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12511 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12512 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12513 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12514 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12515 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12517 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12518 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12519 select, "select#add");
12521 cmdline_parse_inst_t cmd_set_hash_input_set = {
12522 .f = cmd_set_hash_input_set_parsed,
12524 .help_str = "set_hash_input_set <port_id> "
12525 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12526 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12527 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12528 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12529 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12530 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12531 "fld-7th|fld-8th|none select|add",
12533 (void *)&cmd_set_hash_input_set_cmd,
12534 (void *)&cmd_set_hash_input_set_port_id,
12535 (void *)&cmd_set_hash_input_set_flow_type,
12536 (void *)&cmd_set_hash_input_set_field,
12537 (void *)&cmd_set_hash_input_set_select,
12542 /* Set flow director input set */
12543 struct cmd_set_fdir_input_set_result {
12544 cmdline_fixed_string_t set_fdir_input_set;
12546 cmdline_fixed_string_t flow_type;
12547 cmdline_fixed_string_t inset_field;
12548 cmdline_fixed_string_t select;
12552 cmd_set_fdir_input_set_parsed(void *parsed_result,
12553 __rte_unused struct cmdline *cl,
12554 __rte_unused void *data)
12556 struct cmd_set_fdir_input_set_result *res = parsed_result;
12557 struct rte_eth_fdir_filter_info info;
12559 memset(&info, 0, sizeof(info));
12560 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12561 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12562 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12563 info.info.input_set_conf.inset_size = 1;
12564 if (!strcmp(res->select, "select"))
12565 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12566 else if (!strcmp(res->select, "add"))
12567 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12568 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12569 RTE_ETH_FILTER_SET, &info);
12572 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12573 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12574 set_fdir_input_set, "set_fdir_input_set");
12575 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12576 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12578 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12579 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12581 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12582 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12583 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12584 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12586 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12587 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12588 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12589 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12590 "sctp-veri-tag#none");
12591 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12592 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12593 select, "select#add");
12595 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12596 .f = cmd_set_fdir_input_set_parsed,
12598 .help_str = "set_fdir_input_set <port_id> "
12599 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12600 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12601 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12602 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12603 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12604 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12605 "sctp-veri-tag|none select|add",
12607 (void *)&cmd_set_fdir_input_set_cmd,
12608 (void *)&cmd_set_fdir_input_set_port_id,
12609 (void *)&cmd_set_fdir_input_set_flow_type,
12610 (void *)&cmd_set_fdir_input_set_field,
12611 (void *)&cmd_set_fdir_input_set_select,
12616 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12617 struct cmd_mcast_addr_result {
12618 cmdline_fixed_string_t mcast_addr_cmd;
12619 cmdline_fixed_string_t what;
12621 struct rte_ether_addr mc_addr;
12624 static void cmd_mcast_addr_parsed(void *parsed_result,
12625 __attribute__((unused)) struct cmdline *cl,
12626 __attribute__((unused)) void *data)
12628 struct cmd_mcast_addr_result *res = parsed_result;
12630 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12631 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12632 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12633 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12634 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12637 if (strcmp(res->what, "add") == 0)
12638 mcast_addr_add(res->port_num, &res->mc_addr);
12640 mcast_addr_remove(res->port_num, &res->mc_addr);
12643 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12644 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12645 mcast_addr_cmd, "mcast_addr");
12646 cmdline_parse_token_string_t cmd_mcast_addr_what =
12647 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12649 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12650 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12651 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12652 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12654 cmdline_parse_inst_t cmd_mcast_addr = {
12655 .f = cmd_mcast_addr_parsed,
12657 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12658 "Add/Remove multicast MAC address on port_id",
12660 (void *)&cmd_mcast_addr_cmd,
12661 (void *)&cmd_mcast_addr_what,
12662 (void *)&cmd_mcast_addr_portnum,
12663 (void *)&cmd_mcast_addr_addr,
12668 /* l2 tunnel config
12669 * only support E-tag now.
12672 /* Ether type config */
12673 struct cmd_config_l2_tunnel_eth_type_result {
12674 cmdline_fixed_string_t port;
12675 cmdline_fixed_string_t config;
12676 cmdline_fixed_string_t all;
12678 cmdline_fixed_string_t l2_tunnel;
12679 cmdline_fixed_string_t l2_tunnel_type;
12680 cmdline_fixed_string_t eth_type;
12681 uint16_t eth_type_val;
12684 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12685 TOKEN_STRING_INITIALIZER
12686 (struct cmd_config_l2_tunnel_eth_type_result,
12688 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12689 TOKEN_STRING_INITIALIZER
12690 (struct cmd_config_l2_tunnel_eth_type_result,
12692 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12693 TOKEN_STRING_INITIALIZER
12694 (struct cmd_config_l2_tunnel_eth_type_result,
12696 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12697 TOKEN_NUM_INITIALIZER
12698 (struct cmd_config_l2_tunnel_eth_type_result,
12700 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12701 TOKEN_STRING_INITIALIZER
12702 (struct cmd_config_l2_tunnel_eth_type_result,
12703 l2_tunnel, "l2-tunnel");
12704 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12705 TOKEN_STRING_INITIALIZER
12706 (struct cmd_config_l2_tunnel_eth_type_result,
12707 l2_tunnel_type, "E-tag");
12708 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12709 TOKEN_STRING_INITIALIZER
12710 (struct cmd_config_l2_tunnel_eth_type_result,
12711 eth_type, "ether-type");
12712 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12713 TOKEN_NUM_INITIALIZER
12714 (struct cmd_config_l2_tunnel_eth_type_result,
12715 eth_type_val, UINT16);
12717 static enum rte_eth_tunnel_type
12718 str2fdir_l2_tunnel_type(char *string)
12722 static const struct {
12724 enum rte_eth_tunnel_type type;
12725 } l2_tunnel_type_str[] = {
12726 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12729 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12730 if (!strcmp(l2_tunnel_type_str[i].str, string))
12731 return l2_tunnel_type_str[i].type;
12733 return RTE_TUNNEL_TYPE_NONE;
12736 /* ether type config for all ports */
12738 cmd_config_l2_tunnel_eth_type_all_parsed
12739 (void *parsed_result,
12740 __attribute__((unused)) struct cmdline *cl,
12741 __attribute__((unused)) void *data)
12743 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12744 struct rte_eth_l2_tunnel_conf entry;
12747 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12748 entry.ether_type = res->eth_type_val;
12750 RTE_ETH_FOREACH_DEV(pid) {
12751 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12755 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12756 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12758 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12760 (void *)&cmd_config_l2_tunnel_eth_type_port,
12761 (void *)&cmd_config_l2_tunnel_eth_type_config,
12762 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12763 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12764 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12765 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12766 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12771 /* ether type config for a specific port */
12773 cmd_config_l2_tunnel_eth_type_specific_parsed(
12774 void *parsed_result,
12775 __attribute__((unused)) struct cmdline *cl,
12776 __attribute__((unused)) void *data)
12778 struct cmd_config_l2_tunnel_eth_type_result *res =
12780 struct rte_eth_l2_tunnel_conf entry;
12782 if (port_id_is_invalid(res->id, ENABLED_WARN))
12785 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12786 entry.ether_type = res->eth_type_val;
12788 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12791 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12792 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12794 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12796 (void *)&cmd_config_l2_tunnel_eth_type_port,
12797 (void *)&cmd_config_l2_tunnel_eth_type_config,
12798 (void *)&cmd_config_l2_tunnel_eth_type_id,
12799 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12800 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12801 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12802 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12807 /* Enable/disable l2 tunnel */
12808 struct cmd_config_l2_tunnel_en_dis_result {
12809 cmdline_fixed_string_t port;
12810 cmdline_fixed_string_t config;
12811 cmdline_fixed_string_t all;
12813 cmdline_fixed_string_t l2_tunnel;
12814 cmdline_fixed_string_t l2_tunnel_type;
12815 cmdline_fixed_string_t en_dis;
12818 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12819 TOKEN_STRING_INITIALIZER
12820 (struct cmd_config_l2_tunnel_en_dis_result,
12822 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12823 TOKEN_STRING_INITIALIZER
12824 (struct cmd_config_l2_tunnel_en_dis_result,
12826 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12827 TOKEN_STRING_INITIALIZER
12828 (struct cmd_config_l2_tunnel_en_dis_result,
12830 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12831 TOKEN_NUM_INITIALIZER
12832 (struct cmd_config_l2_tunnel_en_dis_result,
12834 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12835 TOKEN_STRING_INITIALIZER
12836 (struct cmd_config_l2_tunnel_en_dis_result,
12837 l2_tunnel, "l2-tunnel");
12838 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12839 TOKEN_STRING_INITIALIZER
12840 (struct cmd_config_l2_tunnel_en_dis_result,
12841 l2_tunnel_type, "E-tag");
12842 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12843 TOKEN_STRING_INITIALIZER
12844 (struct cmd_config_l2_tunnel_en_dis_result,
12845 en_dis, "enable#disable");
12847 /* enable/disable l2 tunnel for all ports */
12849 cmd_config_l2_tunnel_en_dis_all_parsed(
12850 void *parsed_result,
12851 __attribute__((unused)) struct cmdline *cl,
12852 __attribute__((unused)) void *data)
12854 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12855 struct rte_eth_l2_tunnel_conf entry;
12859 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12861 if (!strcmp("enable", res->en_dis))
12866 RTE_ETH_FOREACH_DEV(pid) {
12867 rte_eth_dev_l2_tunnel_offload_set(pid,
12869 ETH_L2_TUNNEL_ENABLE_MASK,
12874 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12875 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12877 .help_str = "port config all l2-tunnel E-tag enable|disable",
12879 (void *)&cmd_config_l2_tunnel_en_dis_port,
12880 (void *)&cmd_config_l2_tunnel_en_dis_config,
12881 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12882 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12883 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12884 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12889 /* enable/disable l2 tunnel for a port */
12891 cmd_config_l2_tunnel_en_dis_specific_parsed(
12892 void *parsed_result,
12893 __attribute__((unused)) struct cmdline *cl,
12894 __attribute__((unused)) void *data)
12896 struct cmd_config_l2_tunnel_en_dis_result *res =
12898 struct rte_eth_l2_tunnel_conf entry;
12900 if (port_id_is_invalid(res->id, ENABLED_WARN))
12903 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12905 if (!strcmp("enable", res->en_dis))
12906 rte_eth_dev_l2_tunnel_offload_set(res->id,
12908 ETH_L2_TUNNEL_ENABLE_MASK,
12911 rte_eth_dev_l2_tunnel_offload_set(res->id,
12913 ETH_L2_TUNNEL_ENABLE_MASK,
12917 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12918 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12920 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12922 (void *)&cmd_config_l2_tunnel_en_dis_port,
12923 (void *)&cmd_config_l2_tunnel_en_dis_config,
12924 (void *)&cmd_config_l2_tunnel_en_dis_id,
12925 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12926 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12927 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12932 /* E-tag configuration */
12934 /* Common result structure for all E-tag configuration */
12935 struct cmd_config_e_tag_result {
12936 cmdline_fixed_string_t e_tag;
12937 cmdline_fixed_string_t set;
12938 cmdline_fixed_string_t insertion;
12939 cmdline_fixed_string_t stripping;
12940 cmdline_fixed_string_t forwarding;
12941 cmdline_fixed_string_t filter;
12942 cmdline_fixed_string_t add;
12943 cmdline_fixed_string_t del;
12944 cmdline_fixed_string_t on;
12945 cmdline_fixed_string_t off;
12946 cmdline_fixed_string_t on_off;
12947 cmdline_fixed_string_t port_tag_id;
12948 uint32_t port_tag_id_val;
12949 cmdline_fixed_string_t e_tag_id;
12950 uint16_t e_tag_id_val;
12951 cmdline_fixed_string_t dst_pool;
12952 uint8_t dst_pool_val;
12953 cmdline_fixed_string_t port;
12955 cmdline_fixed_string_t vf;
12959 /* Common CLI fields for all E-tag configuration */
12960 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12961 TOKEN_STRING_INITIALIZER
12962 (struct cmd_config_e_tag_result,
12964 cmdline_parse_token_string_t cmd_config_e_tag_set =
12965 TOKEN_STRING_INITIALIZER
12966 (struct cmd_config_e_tag_result,
12968 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12969 TOKEN_STRING_INITIALIZER
12970 (struct cmd_config_e_tag_result,
12971 insertion, "insertion");
12972 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12973 TOKEN_STRING_INITIALIZER
12974 (struct cmd_config_e_tag_result,
12975 stripping, "stripping");
12976 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12977 TOKEN_STRING_INITIALIZER
12978 (struct cmd_config_e_tag_result,
12979 forwarding, "forwarding");
12980 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12981 TOKEN_STRING_INITIALIZER
12982 (struct cmd_config_e_tag_result,
12984 cmdline_parse_token_string_t cmd_config_e_tag_add =
12985 TOKEN_STRING_INITIALIZER
12986 (struct cmd_config_e_tag_result,
12988 cmdline_parse_token_string_t cmd_config_e_tag_del =
12989 TOKEN_STRING_INITIALIZER
12990 (struct cmd_config_e_tag_result,
12992 cmdline_parse_token_string_t cmd_config_e_tag_on =
12993 TOKEN_STRING_INITIALIZER
12994 (struct cmd_config_e_tag_result,
12996 cmdline_parse_token_string_t cmd_config_e_tag_off =
12997 TOKEN_STRING_INITIALIZER
12998 (struct cmd_config_e_tag_result,
13000 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13001 TOKEN_STRING_INITIALIZER
13002 (struct cmd_config_e_tag_result,
13004 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13005 TOKEN_STRING_INITIALIZER
13006 (struct cmd_config_e_tag_result,
13007 port_tag_id, "port-tag-id");
13008 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13009 TOKEN_NUM_INITIALIZER
13010 (struct cmd_config_e_tag_result,
13011 port_tag_id_val, UINT32);
13012 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13013 TOKEN_STRING_INITIALIZER
13014 (struct cmd_config_e_tag_result,
13015 e_tag_id, "e-tag-id");
13016 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13017 TOKEN_NUM_INITIALIZER
13018 (struct cmd_config_e_tag_result,
13019 e_tag_id_val, UINT16);
13020 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13021 TOKEN_STRING_INITIALIZER
13022 (struct cmd_config_e_tag_result,
13023 dst_pool, "dst-pool");
13024 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13025 TOKEN_NUM_INITIALIZER
13026 (struct cmd_config_e_tag_result,
13027 dst_pool_val, UINT8);
13028 cmdline_parse_token_string_t cmd_config_e_tag_port =
13029 TOKEN_STRING_INITIALIZER
13030 (struct cmd_config_e_tag_result,
13032 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13033 TOKEN_NUM_INITIALIZER
13034 (struct cmd_config_e_tag_result,
13036 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13037 TOKEN_STRING_INITIALIZER
13038 (struct cmd_config_e_tag_result,
13040 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13041 TOKEN_NUM_INITIALIZER
13042 (struct cmd_config_e_tag_result,
13045 /* E-tag insertion configuration */
13047 cmd_config_e_tag_insertion_en_parsed(
13048 void *parsed_result,
13049 __attribute__((unused)) struct cmdline *cl,
13050 __attribute__((unused)) void *data)
13052 struct cmd_config_e_tag_result *res =
13054 struct rte_eth_l2_tunnel_conf entry;
13056 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13059 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13060 entry.tunnel_id = res->port_tag_id_val;
13061 entry.vf_id = res->vf_id;
13062 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13064 ETH_L2_TUNNEL_INSERTION_MASK,
13069 cmd_config_e_tag_insertion_dis_parsed(
13070 void *parsed_result,
13071 __attribute__((unused)) struct cmdline *cl,
13072 __attribute__((unused)) void *data)
13074 struct cmd_config_e_tag_result *res =
13076 struct rte_eth_l2_tunnel_conf entry;
13078 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13081 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13082 entry.vf_id = res->vf_id;
13084 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13086 ETH_L2_TUNNEL_INSERTION_MASK,
13090 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13091 .f = cmd_config_e_tag_insertion_en_parsed,
13093 .help_str = "E-tag ... : E-tag insertion enable",
13095 (void *)&cmd_config_e_tag_e_tag,
13096 (void *)&cmd_config_e_tag_set,
13097 (void *)&cmd_config_e_tag_insertion,
13098 (void *)&cmd_config_e_tag_on,
13099 (void *)&cmd_config_e_tag_port_tag_id,
13100 (void *)&cmd_config_e_tag_port_tag_id_val,
13101 (void *)&cmd_config_e_tag_port,
13102 (void *)&cmd_config_e_tag_port_id,
13103 (void *)&cmd_config_e_tag_vf,
13104 (void *)&cmd_config_e_tag_vf_id,
13109 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13110 .f = cmd_config_e_tag_insertion_dis_parsed,
13112 .help_str = "E-tag ... : E-tag insertion disable",
13114 (void *)&cmd_config_e_tag_e_tag,
13115 (void *)&cmd_config_e_tag_set,
13116 (void *)&cmd_config_e_tag_insertion,
13117 (void *)&cmd_config_e_tag_off,
13118 (void *)&cmd_config_e_tag_port,
13119 (void *)&cmd_config_e_tag_port_id,
13120 (void *)&cmd_config_e_tag_vf,
13121 (void *)&cmd_config_e_tag_vf_id,
13126 /* E-tag stripping configuration */
13128 cmd_config_e_tag_stripping_parsed(
13129 void *parsed_result,
13130 __attribute__((unused)) struct cmdline *cl,
13131 __attribute__((unused)) void *data)
13133 struct cmd_config_e_tag_result *res =
13135 struct rte_eth_l2_tunnel_conf entry;
13137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13140 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13142 if (!strcmp(res->on_off, "on"))
13143 rte_eth_dev_l2_tunnel_offload_set
13146 ETH_L2_TUNNEL_STRIPPING_MASK,
13149 rte_eth_dev_l2_tunnel_offload_set
13152 ETH_L2_TUNNEL_STRIPPING_MASK,
13156 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13157 .f = cmd_config_e_tag_stripping_parsed,
13159 .help_str = "E-tag ... : E-tag stripping enable/disable",
13161 (void *)&cmd_config_e_tag_e_tag,
13162 (void *)&cmd_config_e_tag_set,
13163 (void *)&cmd_config_e_tag_stripping,
13164 (void *)&cmd_config_e_tag_on_off,
13165 (void *)&cmd_config_e_tag_port,
13166 (void *)&cmd_config_e_tag_port_id,
13171 /* E-tag forwarding configuration */
13173 cmd_config_e_tag_forwarding_parsed(
13174 void *parsed_result,
13175 __attribute__((unused)) struct cmdline *cl,
13176 __attribute__((unused)) void *data)
13178 struct cmd_config_e_tag_result *res = parsed_result;
13179 struct rte_eth_l2_tunnel_conf entry;
13181 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13184 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13186 if (!strcmp(res->on_off, "on"))
13187 rte_eth_dev_l2_tunnel_offload_set
13190 ETH_L2_TUNNEL_FORWARDING_MASK,
13193 rte_eth_dev_l2_tunnel_offload_set
13196 ETH_L2_TUNNEL_FORWARDING_MASK,
13200 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13201 .f = cmd_config_e_tag_forwarding_parsed,
13203 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13205 (void *)&cmd_config_e_tag_e_tag,
13206 (void *)&cmd_config_e_tag_set,
13207 (void *)&cmd_config_e_tag_forwarding,
13208 (void *)&cmd_config_e_tag_on_off,
13209 (void *)&cmd_config_e_tag_port,
13210 (void *)&cmd_config_e_tag_port_id,
13215 /* E-tag filter configuration */
13217 cmd_config_e_tag_filter_add_parsed(
13218 void *parsed_result,
13219 __attribute__((unused)) struct cmdline *cl,
13220 __attribute__((unused)) void *data)
13222 struct cmd_config_e_tag_result *res = parsed_result;
13223 struct rte_eth_l2_tunnel_conf entry;
13226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13229 if (res->e_tag_id_val > 0x3fff) {
13230 printf("e-tag-id must be equal or less than 0x3fff.\n");
13234 ret = rte_eth_dev_filter_supported(res->port_id,
13235 RTE_ETH_FILTER_L2_TUNNEL);
13237 printf("E-tag filter is not supported on port %u.\n",
13242 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13243 entry.tunnel_id = res->e_tag_id_val;
13244 entry.pool = res->dst_pool_val;
13246 ret = rte_eth_dev_filter_ctrl(res->port_id,
13247 RTE_ETH_FILTER_L2_TUNNEL,
13248 RTE_ETH_FILTER_ADD,
13251 printf("E-tag filter programming error: (%s)\n",
13255 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13256 .f = cmd_config_e_tag_filter_add_parsed,
13258 .help_str = "E-tag ... : E-tag filter add",
13260 (void *)&cmd_config_e_tag_e_tag,
13261 (void *)&cmd_config_e_tag_set,
13262 (void *)&cmd_config_e_tag_filter,
13263 (void *)&cmd_config_e_tag_add,
13264 (void *)&cmd_config_e_tag_e_tag_id,
13265 (void *)&cmd_config_e_tag_e_tag_id_val,
13266 (void *)&cmd_config_e_tag_dst_pool,
13267 (void *)&cmd_config_e_tag_dst_pool_val,
13268 (void *)&cmd_config_e_tag_port,
13269 (void *)&cmd_config_e_tag_port_id,
13275 cmd_config_e_tag_filter_del_parsed(
13276 void *parsed_result,
13277 __attribute__((unused)) struct cmdline *cl,
13278 __attribute__((unused)) void *data)
13280 struct cmd_config_e_tag_result *res = parsed_result;
13281 struct rte_eth_l2_tunnel_conf entry;
13284 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13287 if (res->e_tag_id_val > 0x3fff) {
13288 printf("e-tag-id must be less than 0x3fff.\n");
13292 ret = rte_eth_dev_filter_supported(res->port_id,
13293 RTE_ETH_FILTER_L2_TUNNEL);
13295 printf("E-tag filter is not supported on port %u.\n",
13300 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13301 entry.tunnel_id = res->e_tag_id_val;
13303 ret = rte_eth_dev_filter_ctrl(res->port_id,
13304 RTE_ETH_FILTER_L2_TUNNEL,
13305 RTE_ETH_FILTER_DELETE,
13308 printf("E-tag filter programming error: (%s)\n",
13312 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13313 .f = cmd_config_e_tag_filter_del_parsed,
13315 .help_str = "E-tag ... : E-tag filter delete",
13317 (void *)&cmd_config_e_tag_e_tag,
13318 (void *)&cmd_config_e_tag_set,
13319 (void *)&cmd_config_e_tag_filter,
13320 (void *)&cmd_config_e_tag_del,
13321 (void *)&cmd_config_e_tag_e_tag_id,
13322 (void *)&cmd_config_e_tag_e_tag_id_val,
13323 (void *)&cmd_config_e_tag_port,
13324 (void *)&cmd_config_e_tag_port_id,
13329 /* vf vlan anti spoof configuration */
13331 /* Common result structure for vf vlan anti spoof */
13332 struct cmd_vf_vlan_anti_spoof_result {
13333 cmdline_fixed_string_t set;
13334 cmdline_fixed_string_t vf;
13335 cmdline_fixed_string_t vlan;
13336 cmdline_fixed_string_t antispoof;
13339 cmdline_fixed_string_t on_off;
13342 /* Common CLI fields for vf vlan anti spoof enable disable */
13343 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13344 TOKEN_STRING_INITIALIZER
13345 (struct cmd_vf_vlan_anti_spoof_result,
13347 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13348 TOKEN_STRING_INITIALIZER
13349 (struct cmd_vf_vlan_anti_spoof_result,
13351 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13352 TOKEN_STRING_INITIALIZER
13353 (struct cmd_vf_vlan_anti_spoof_result,
13355 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13356 TOKEN_STRING_INITIALIZER
13357 (struct cmd_vf_vlan_anti_spoof_result,
13358 antispoof, "antispoof");
13359 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13360 TOKEN_NUM_INITIALIZER
13361 (struct cmd_vf_vlan_anti_spoof_result,
13363 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13364 TOKEN_NUM_INITIALIZER
13365 (struct cmd_vf_vlan_anti_spoof_result,
13367 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13368 TOKEN_STRING_INITIALIZER
13369 (struct cmd_vf_vlan_anti_spoof_result,
13373 cmd_set_vf_vlan_anti_spoof_parsed(
13374 void *parsed_result,
13375 __attribute__((unused)) struct cmdline *cl,
13376 __attribute__((unused)) void *data)
13378 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13379 int ret = -ENOTSUP;
13381 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13383 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13386 #ifdef RTE_LIBRTE_IXGBE_PMD
13387 if (ret == -ENOTSUP)
13388 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13389 res->vf_id, is_on);
13391 #ifdef RTE_LIBRTE_I40E_PMD
13392 if (ret == -ENOTSUP)
13393 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13394 res->vf_id, is_on);
13396 #ifdef RTE_LIBRTE_BNXT_PMD
13397 if (ret == -ENOTSUP)
13398 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13399 res->vf_id, is_on);
13406 printf("invalid vf_id %d\n", res->vf_id);
13409 printf("invalid port_id %d\n", res->port_id);
13412 printf("function not implemented\n");
13415 printf("programming error: (%s)\n", strerror(-ret));
13419 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13420 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13422 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13424 (void *)&cmd_vf_vlan_anti_spoof_set,
13425 (void *)&cmd_vf_vlan_anti_spoof_vf,
13426 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13427 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13428 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13429 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13430 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13435 /* vf mac anti spoof configuration */
13437 /* Common result structure for vf mac anti spoof */
13438 struct cmd_vf_mac_anti_spoof_result {
13439 cmdline_fixed_string_t set;
13440 cmdline_fixed_string_t vf;
13441 cmdline_fixed_string_t mac;
13442 cmdline_fixed_string_t antispoof;
13445 cmdline_fixed_string_t on_off;
13448 /* Common CLI fields for vf mac anti spoof enable disable */
13449 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13450 TOKEN_STRING_INITIALIZER
13451 (struct cmd_vf_mac_anti_spoof_result,
13453 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13454 TOKEN_STRING_INITIALIZER
13455 (struct cmd_vf_mac_anti_spoof_result,
13457 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13458 TOKEN_STRING_INITIALIZER
13459 (struct cmd_vf_mac_anti_spoof_result,
13461 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13462 TOKEN_STRING_INITIALIZER
13463 (struct cmd_vf_mac_anti_spoof_result,
13464 antispoof, "antispoof");
13465 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13466 TOKEN_NUM_INITIALIZER
13467 (struct cmd_vf_mac_anti_spoof_result,
13469 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13470 TOKEN_NUM_INITIALIZER
13471 (struct cmd_vf_mac_anti_spoof_result,
13473 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13474 TOKEN_STRING_INITIALIZER
13475 (struct cmd_vf_mac_anti_spoof_result,
13479 cmd_set_vf_mac_anti_spoof_parsed(
13480 void *parsed_result,
13481 __attribute__((unused)) struct cmdline *cl,
13482 __attribute__((unused)) void *data)
13484 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13485 int ret = -ENOTSUP;
13487 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13489 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13492 #ifdef RTE_LIBRTE_IXGBE_PMD
13493 if (ret == -ENOTSUP)
13494 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13495 res->vf_id, is_on);
13497 #ifdef RTE_LIBRTE_I40E_PMD
13498 if (ret == -ENOTSUP)
13499 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13500 res->vf_id, is_on);
13502 #ifdef RTE_LIBRTE_BNXT_PMD
13503 if (ret == -ENOTSUP)
13504 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13505 res->vf_id, is_on);
13512 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13515 printf("invalid port_id %d\n", res->port_id);
13518 printf("function not implemented\n");
13521 printf("programming error: (%s)\n", strerror(-ret));
13525 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13526 .f = cmd_set_vf_mac_anti_spoof_parsed,
13528 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13530 (void *)&cmd_vf_mac_anti_spoof_set,
13531 (void *)&cmd_vf_mac_anti_spoof_vf,
13532 (void *)&cmd_vf_mac_anti_spoof_mac,
13533 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13534 (void *)&cmd_vf_mac_anti_spoof_port_id,
13535 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13536 (void *)&cmd_vf_mac_anti_spoof_on_off,
13541 /* vf vlan strip queue configuration */
13543 /* Common result structure for vf mac anti spoof */
13544 struct cmd_vf_vlan_stripq_result {
13545 cmdline_fixed_string_t set;
13546 cmdline_fixed_string_t vf;
13547 cmdline_fixed_string_t vlan;
13548 cmdline_fixed_string_t stripq;
13551 cmdline_fixed_string_t on_off;
13554 /* Common CLI fields for vf vlan strip enable disable */
13555 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13556 TOKEN_STRING_INITIALIZER
13557 (struct cmd_vf_vlan_stripq_result,
13559 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13560 TOKEN_STRING_INITIALIZER
13561 (struct cmd_vf_vlan_stripq_result,
13563 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13564 TOKEN_STRING_INITIALIZER
13565 (struct cmd_vf_vlan_stripq_result,
13567 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13568 TOKEN_STRING_INITIALIZER
13569 (struct cmd_vf_vlan_stripq_result,
13571 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13572 TOKEN_NUM_INITIALIZER
13573 (struct cmd_vf_vlan_stripq_result,
13575 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13576 TOKEN_NUM_INITIALIZER
13577 (struct cmd_vf_vlan_stripq_result,
13579 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13580 TOKEN_STRING_INITIALIZER
13581 (struct cmd_vf_vlan_stripq_result,
13585 cmd_set_vf_vlan_stripq_parsed(
13586 void *parsed_result,
13587 __attribute__((unused)) struct cmdline *cl,
13588 __attribute__((unused)) void *data)
13590 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13591 int ret = -ENOTSUP;
13593 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13598 #ifdef RTE_LIBRTE_IXGBE_PMD
13599 if (ret == -ENOTSUP)
13600 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13601 res->vf_id, is_on);
13603 #ifdef RTE_LIBRTE_I40E_PMD
13604 if (ret == -ENOTSUP)
13605 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13606 res->vf_id, is_on);
13608 #ifdef RTE_LIBRTE_BNXT_PMD
13609 if (ret == -ENOTSUP)
13610 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13611 res->vf_id, is_on);
13618 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13621 printf("invalid port_id %d\n", res->port_id);
13624 printf("function not implemented\n");
13627 printf("programming error: (%s)\n", strerror(-ret));
13631 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13632 .f = cmd_set_vf_vlan_stripq_parsed,
13634 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13636 (void *)&cmd_vf_vlan_stripq_set,
13637 (void *)&cmd_vf_vlan_stripq_vf,
13638 (void *)&cmd_vf_vlan_stripq_vlan,
13639 (void *)&cmd_vf_vlan_stripq_stripq,
13640 (void *)&cmd_vf_vlan_stripq_port_id,
13641 (void *)&cmd_vf_vlan_stripq_vf_id,
13642 (void *)&cmd_vf_vlan_stripq_on_off,
13647 /* vf vlan insert configuration */
13649 /* Common result structure for vf vlan insert */
13650 struct cmd_vf_vlan_insert_result {
13651 cmdline_fixed_string_t set;
13652 cmdline_fixed_string_t vf;
13653 cmdline_fixed_string_t vlan;
13654 cmdline_fixed_string_t insert;
13660 /* Common CLI fields for vf vlan insert enable disable */
13661 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13662 TOKEN_STRING_INITIALIZER
13663 (struct cmd_vf_vlan_insert_result,
13665 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13666 TOKEN_STRING_INITIALIZER
13667 (struct cmd_vf_vlan_insert_result,
13669 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13670 TOKEN_STRING_INITIALIZER
13671 (struct cmd_vf_vlan_insert_result,
13673 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13674 TOKEN_STRING_INITIALIZER
13675 (struct cmd_vf_vlan_insert_result,
13677 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13678 TOKEN_NUM_INITIALIZER
13679 (struct cmd_vf_vlan_insert_result,
13681 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13682 TOKEN_NUM_INITIALIZER
13683 (struct cmd_vf_vlan_insert_result,
13685 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13686 TOKEN_NUM_INITIALIZER
13687 (struct cmd_vf_vlan_insert_result,
13691 cmd_set_vf_vlan_insert_parsed(
13692 void *parsed_result,
13693 __attribute__((unused)) struct cmdline *cl,
13694 __attribute__((unused)) void *data)
13696 struct cmd_vf_vlan_insert_result *res = parsed_result;
13697 int ret = -ENOTSUP;
13699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13702 #ifdef RTE_LIBRTE_IXGBE_PMD
13703 if (ret == -ENOTSUP)
13704 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13707 #ifdef RTE_LIBRTE_I40E_PMD
13708 if (ret == -ENOTSUP)
13709 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13712 #ifdef RTE_LIBRTE_BNXT_PMD
13713 if (ret == -ENOTSUP)
13714 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13722 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13725 printf("invalid port_id %d\n", res->port_id);
13728 printf("function not implemented\n");
13731 printf("programming error: (%s)\n", strerror(-ret));
13735 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13736 .f = cmd_set_vf_vlan_insert_parsed,
13738 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13740 (void *)&cmd_vf_vlan_insert_set,
13741 (void *)&cmd_vf_vlan_insert_vf,
13742 (void *)&cmd_vf_vlan_insert_vlan,
13743 (void *)&cmd_vf_vlan_insert_insert,
13744 (void *)&cmd_vf_vlan_insert_port_id,
13745 (void *)&cmd_vf_vlan_insert_vf_id,
13746 (void *)&cmd_vf_vlan_insert_vlan_id,
13751 /* tx loopback configuration */
13753 /* Common result structure for tx loopback */
13754 struct cmd_tx_loopback_result {
13755 cmdline_fixed_string_t set;
13756 cmdline_fixed_string_t tx;
13757 cmdline_fixed_string_t loopback;
13759 cmdline_fixed_string_t on_off;
13762 /* Common CLI fields for tx loopback enable disable */
13763 cmdline_parse_token_string_t cmd_tx_loopback_set =
13764 TOKEN_STRING_INITIALIZER
13765 (struct cmd_tx_loopback_result,
13767 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13768 TOKEN_STRING_INITIALIZER
13769 (struct cmd_tx_loopback_result,
13771 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13772 TOKEN_STRING_INITIALIZER
13773 (struct cmd_tx_loopback_result,
13774 loopback, "loopback");
13775 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13776 TOKEN_NUM_INITIALIZER
13777 (struct cmd_tx_loopback_result,
13779 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13780 TOKEN_STRING_INITIALIZER
13781 (struct cmd_tx_loopback_result,
13785 cmd_set_tx_loopback_parsed(
13786 void *parsed_result,
13787 __attribute__((unused)) struct cmdline *cl,
13788 __attribute__((unused)) void *data)
13790 struct cmd_tx_loopback_result *res = parsed_result;
13791 int ret = -ENOTSUP;
13793 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13795 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13798 #ifdef RTE_LIBRTE_IXGBE_PMD
13799 if (ret == -ENOTSUP)
13800 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13802 #ifdef RTE_LIBRTE_I40E_PMD
13803 if (ret == -ENOTSUP)
13804 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13806 #ifdef RTE_LIBRTE_BNXT_PMD
13807 if (ret == -ENOTSUP)
13808 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13810 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13811 if (ret == -ENOTSUP)
13812 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13819 printf("invalid is_on %d\n", is_on);
13822 printf("invalid port_id %d\n", res->port_id);
13825 printf("function not implemented\n");
13828 printf("programming error: (%s)\n", strerror(-ret));
13832 cmdline_parse_inst_t cmd_set_tx_loopback = {
13833 .f = cmd_set_tx_loopback_parsed,
13835 .help_str = "set tx loopback <port_id> on|off",
13837 (void *)&cmd_tx_loopback_set,
13838 (void *)&cmd_tx_loopback_tx,
13839 (void *)&cmd_tx_loopback_loopback,
13840 (void *)&cmd_tx_loopback_port_id,
13841 (void *)&cmd_tx_loopback_on_off,
13846 /* all queues drop enable configuration */
13848 /* Common result structure for all queues drop enable */
13849 struct cmd_all_queues_drop_en_result {
13850 cmdline_fixed_string_t set;
13851 cmdline_fixed_string_t all;
13852 cmdline_fixed_string_t queues;
13853 cmdline_fixed_string_t drop;
13855 cmdline_fixed_string_t on_off;
13858 /* Common CLI fields for tx loopback enable disable */
13859 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13860 TOKEN_STRING_INITIALIZER
13861 (struct cmd_all_queues_drop_en_result,
13863 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13864 TOKEN_STRING_INITIALIZER
13865 (struct cmd_all_queues_drop_en_result,
13867 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13868 TOKEN_STRING_INITIALIZER
13869 (struct cmd_all_queues_drop_en_result,
13871 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13872 TOKEN_STRING_INITIALIZER
13873 (struct cmd_all_queues_drop_en_result,
13875 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13876 TOKEN_NUM_INITIALIZER
13877 (struct cmd_all_queues_drop_en_result,
13879 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13880 TOKEN_STRING_INITIALIZER
13881 (struct cmd_all_queues_drop_en_result,
13885 cmd_set_all_queues_drop_en_parsed(
13886 void *parsed_result,
13887 __attribute__((unused)) struct cmdline *cl,
13888 __attribute__((unused)) void *data)
13890 struct cmd_all_queues_drop_en_result *res = parsed_result;
13891 int ret = -ENOTSUP;
13892 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13894 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13897 #ifdef RTE_LIBRTE_IXGBE_PMD
13898 if (ret == -ENOTSUP)
13899 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13901 #ifdef RTE_LIBRTE_BNXT_PMD
13902 if (ret == -ENOTSUP)
13903 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13909 printf("invalid is_on %d\n", is_on);
13912 printf("invalid port_id %d\n", res->port_id);
13915 printf("function not implemented\n");
13918 printf("programming error: (%s)\n", strerror(-ret));
13922 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13923 .f = cmd_set_all_queues_drop_en_parsed,
13925 .help_str = "set all queues drop <port_id> on|off",
13927 (void *)&cmd_all_queues_drop_en_set,
13928 (void *)&cmd_all_queues_drop_en_all,
13929 (void *)&cmd_all_queues_drop_en_queues,
13930 (void *)&cmd_all_queues_drop_en_drop,
13931 (void *)&cmd_all_queues_drop_en_port_id,
13932 (void *)&cmd_all_queues_drop_en_on_off,
13937 /* vf split drop enable configuration */
13939 /* Common result structure for vf split drop enable */
13940 struct cmd_vf_split_drop_en_result {
13941 cmdline_fixed_string_t set;
13942 cmdline_fixed_string_t vf;
13943 cmdline_fixed_string_t split;
13944 cmdline_fixed_string_t drop;
13947 cmdline_fixed_string_t on_off;
13950 /* Common CLI fields for vf split drop enable disable */
13951 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13952 TOKEN_STRING_INITIALIZER
13953 (struct cmd_vf_split_drop_en_result,
13955 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13956 TOKEN_STRING_INITIALIZER
13957 (struct cmd_vf_split_drop_en_result,
13959 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13960 TOKEN_STRING_INITIALIZER
13961 (struct cmd_vf_split_drop_en_result,
13963 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13964 TOKEN_STRING_INITIALIZER
13965 (struct cmd_vf_split_drop_en_result,
13967 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13968 TOKEN_NUM_INITIALIZER
13969 (struct cmd_vf_split_drop_en_result,
13971 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13972 TOKEN_NUM_INITIALIZER
13973 (struct cmd_vf_split_drop_en_result,
13975 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13976 TOKEN_STRING_INITIALIZER
13977 (struct cmd_vf_split_drop_en_result,
13981 cmd_set_vf_split_drop_en_parsed(
13982 void *parsed_result,
13983 __attribute__((unused)) struct cmdline *cl,
13984 __attribute__((unused)) void *data)
13986 struct cmd_vf_split_drop_en_result *res = parsed_result;
13987 int ret = -ENOTSUP;
13988 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13990 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13993 #ifdef RTE_LIBRTE_IXGBE_PMD
13994 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14001 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14004 printf("invalid port_id %d\n", res->port_id);
14007 printf("not supported on port %d\n", res->port_id);
14010 printf("programming error: (%s)\n", strerror(-ret));
14014 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14015 .f = cmd_set_vf_split_drop_en_parsed,
14017 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14019 (void *)&cmd_vf_split_drop_en_set,
14020 (void *)&cmd_vf_split_drop_en_vf,
14021 (void *)&cmd_vf_split_drop_en_split,
14022 (void *)&cmd_vf_split_drop_en_drop,
14023 (void *)&cmd_vf_split_drop_en_port_id,
14024 (void *)&cmd_vf_split_drop_en_vf_id,
14025 (void *)&cmd_vf_split_drop_en_on_off,
14030 /* vf mac address configuration */
14032 /* Common result structure for vf mac address */
14033 struct cmd_set_vf_mac_addr_result {
14034 cmdline_fixed_string_t set;
14035 cmdline_fixed_string_t vf;
14036 cmdline_fixed_string_t mac;
14037 cmdline_fixed_string_t addr;
14040 struct rte_ether_addr mac_addr;
14044 /* Common CLI fields for vf split drop enable disable */
14045 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14046 TOKEN_STRING_INITIALIZER
14047 (struct cmd_set_vf_mac_addr_result,
14049 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14050 TOKEN_STRING_INITIALIZER
14051 (struct cmd_set_vf_mac_addr_result,
14053 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14054 TOKEN_STRING_INITIALIZER
14055 (struct cmd_set_vf_mac_addr_result,
14057 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14058 TOKEN_STRING_INITIALIZER
14059 (struct cmd_set_vf_mac_addr_result,
14061 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14062 TOKEN_NUM_INITIALIZER
14063 (struct cmd_set_vf_mac_addr_result,
14065 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14066 TOKEN_NUM_INITIALIZER
14067 (struct cmd_set_vf_mac_addr_result,
14069 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14070 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14074 cmd_set_vf_mac_addr_parsed(
14075 void *parsed_result,
14076 __attribute__((unused)) struct cmdline *cl,
14077 __attribute__((unused)) void *data)
14079 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14080 int ret = -ENOTSUP;
14082 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14085 #ifdef RTE_LIBRTE_IXGBE_PMD
14086 if (ret == -ENOTSUP)
14087 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14090 #ifdef RTE_LIBRTE_I40E_PMD
14091 if (ret == -ENOTSUP)
14092 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14095 #ifdef RTE_LIBRTE_BNXT_PMD
14096 if (ret == -ENOTSUP)
14097 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14105 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14108 printf("invalid port_id %d\n", res->port_id);
14111 printf("function not implemented\n");
14114 printf("programming error: (%s)\n", strerror(-ret));
14118 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14119 .f = cmd_set_vf_mac_addr_parsed,
14121 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14123 (void *)&cmd_set_vf_mac_addr_set,
14124 (void *)&cmd_set_vf_mac_addr_vf,
14125 (void *)&cmd_set_vf_mac_addr_mac,
14126 (void *)&cmd_set_vf_mac_addr_addr,
14127 (void *)&cmd_set_vf_mac_addr_port_id,
14128 (void *)&cmd_set_vf_mac_addr_vf_id,
14129 (void *)&cmd_set_vf_mac_addr_mac_addr,
14134 /* MACsec configuration */
14136 /* Common result structure for MACsec offload enable */
14137 struct cmd_macsec_offload_on_result {
14138 cmdline_fixed_string_t set;
14139 cmdline_fixed_string_t macsec;
14140 cmdline_fixed_string_t offload;
14142 cmdline_fixed_string_t on;
14143 cmdline_fixed_string_t encrypt;
14144 cmdline_fixed_string_t en_on_off;
14145 cmdline_fixed_string_t replay_protect;
14146 cmdline_fixed_string_t rp_on_off;
14149 /* Common CLI fields for MACsec offload disable */
14150 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14151 TOKEN_STRING_INITIALIZER
14152 (struct cmd_macsec_offload_on_result,
14154 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14155 TOKEN_STRING_INITIALIZER
14156 (struct cmd_macsec_offload_on_result,
14158 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14159 TOKEN_STRING_INITIALIZER
14160 (struct cmd_macsec_offload_on_result,
14161 offload, "offload");
14162 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14163 TOKEN_NUM_INITIALIZER
14164 (struct cmd_macsec_offload_on_result,
14166 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14167 TOKEN_STRING_INITIALIZER
14168 (struct cmd_macsec_offload_on_result,
14170 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14171 TOKEN_STRING_INITIALIZER
14172 (struct cmd_macsec_offload_on_result,
14173 encrypt, "encrypt");
14174 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14175 TOKEN_STRING_INITIALIZER
14176 (struct cmd_macsec_offload_on_result,
14177 en_on_off, "on#off");
14178 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14179 TOKEN_STRING_INITIALIZER
14180 (struct cmd_macsec_offload_on_result,
14181 replay_protect, "replay-protect");
14182 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14183 TOKEN_STRING_INITIALIZER
14184 (struct cmd_macsec_offload_on_result,
14185 rp_on_off, "on#off");
14188 cmd_set_macsec_offload_on_parsed(
14189 void *parsed_result,
14190 __attribute__((unused)) struct cmdline *cl,
14191 __attribute__((unused)) void *data)
14193 struct cmd_macsec_offload_on_result *res = parsed_result;
14194 int ret = -ENOTSUP;
14195 portid_t port_id = res->port_id;
14196 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14197 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14198 struct rte_eth_dev_info dev_info;
14200 if (port_id_is_invalid(port_id, ENABLED_WARN))
14202 if (!port_is_stopped(port_id)) {
14203 printf("Please stop port %d first\n", port_id);
14207 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14211 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14212 #ifdef RTE_LIBRTE_IXGBE_PMD
14213 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14221 ports[port_id].dev_conf.txmode.offloads |=
14222 DEV_TX_OFFLOAD_MACSEC_INSERT;
14223 cmd_reconfig_device_queue(port_id, 1, 1);
14226 printf("invalid port_id %d\n", port_id);
14229 printf("not supported on port %d\n", port_id);
14232 printf("programming error: (%s)\n", strerror(-ret));
14236 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14237 .f = cmd_set_macsec_offload_on_parsed,
14239 .help_str = "set macsec offload <port_id> on "
14240 "encrypt on|off replay-protect on|off",
14242 (void *)&cmd_macsec_offload_on_set,
14243 (void *)&cmd_macsec_offload_on_macsec,
14244 (void *)&cmd_macsec_offload_on_offload,
14245 (void *)&cmd_macsec_offload_on_port_id,
14246 (void *)&cmd_macsec_offload_on_on,
14247 (void *)&cmd_macsec_offload_on_encrypt,
14248 (void *)&cmd_macsec_offload_on_en_on_off,
14249 (void *)&cmd_macsec_offload_on_replay_protect,
14250 (void *)&cmd_macsec_offload_on_rp_on_off,
14255 /* Common result structure for MACsec offload disable */
14256 struct cmd_macsec_offload_off_result {
14257 cmdline_fixed_string_t set;
14258 cmdline_fixed_string_t macsec;
14259 cmdline_fixed_string_t offload;
14261 cmdline_fixed_string_t off;
14264 /* Common CLI fields for MACsec offload disable */
14265 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14266 TOKEN_STRING_INITIALIZER
14267 (struct cmd_macsec_offload_off_result,
14269 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14270 TOKEN_STRING_INITIALIZER
14271 (struct cmd_macsec_offload_off_result,
14273 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14274 TOKEN_STRING_INITIALIZER
14275 (struct cmd_macsec_offload_off_result,
14276 offload, "offload");
14277 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14278 TOKEN_NUM_INITIALIZER
14279 (struct cmd_macsec_offload_off_result,
14281 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14282 TOKEN_STRING_INITIALIZER
14283 (struct cmd_macsec_offload_off_result,
14287 cmd_set_macsec_offload_off_parsed(
14288 void *parsed_result,
14289 __attribute__((unused)) struct cmdline *cl,
14290 __attribute__((unused)) void *data)
14292 struct cmd_macsec_offload_off_result *res = parsed_result;
14293 int ret = -ENOTSUP;
14294 struct rte_eth_dev_info dev_info;
14295 portid_t port_id = res->port_id;
14297 if (port_id_is_invalid(port_id, ENABLED_WARN))
14299 if (!port_is_stopped(port_id)) {
14300 printf("Please stop port %d first\n", port_id);
14304 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14308 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14309 #ifdef RTE_LIBRTE_IXGBE_PMD
14310 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14315 ports[port_id].dev_conf.txmode.offloads &=
14316 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14317 cmd_reconfig_device_queue(port_id, 1, 1);
14320 printf("invalid port_id %d\n", port_id);
14323 printf("not supported on port %d\n", port_id);
14326 printf("programming error: (%s)\n", strerror(-ret));
14330 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14331 .f = cmd_set_macsec_offload_off_parsed,
14333 .help_str = "set macsec offload <port_id> off",
14335 (void *)&cmd_macsec_offload_off_set,
14336 (void *)&cmd_macsec_offload_off_macsec,
14337 (void *)&cmd_macsec_offload_off_offload,
14338 (void *)&cmd_macsec_offload_off_port_id,
14339 (void *)&cmd_macsec_offload_off_off,
14344 /* Common result structure for MACsec secure connection configure */
14345 struct cmd_macsec_sc_result {
14346 cmdline_fixed_string_t set;
14347 cmdline_fixed_string_t macsec;
14348 cmdline_fixed_string_t sc;
14349 cmdline_fixed_string_t tx_rx;
14351 struct rte_ether_addr mac;
14355 /* Common CLI fields for MACsec secure connection configure */
14356 cmdline_parse_token_string_t cmd_macsec_sc_set =
14357 TOKEN_STRING_INITIALIZER
14358 (struct cmd_macsec_sc_result,
14360 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14361 TOKEN_STRING_INITIALIZER
14362 (struct cmd_macsec_sc_result,
14364 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14365 TOKEN_STRING_INITIALIZER
14366 (struct cmd_macsec_sc_result,
14368 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14369 TOKEN_STRING_INITIALIZER
14370 (struct cmd_macsec_sc_result,
14372 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14373 TOKEN_NUM_INITIALIZER
14374 (struct cmd_macsec_sc_result,
14376 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14377 TOKEN_ETHERADDR_INITIALIZER
14378 (struct cmd_macsec_sc_result,
14380 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14381 TOKEN_NUM_INITIALIZER
14382 (struct cmd_macsec_sc_result,
14386 cmd_set_macsec_sc_parsed(
14387 void *parsed_result,
14388 __attribute__((unused)) struct cmdline *cl,
14389 __attribute__((unused)) void *data)
14391 struct cmd_macsec_sc_result *res = parsed_result;
14392 int ret = -ENOTSUP;
14393 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14395 #ifdef RTE_LIBRTE_IXGBE_PMD
14397 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14398 res->mac.addr_bytes) :
14399 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14400 res->mac.addr_bytes, res->pi);
14402 RTE_SET_USED(is_tx);
14408 printf("invalid port_id %d\n", res->port_id);
14411 printf("not supported on port %d\n", res->port_id);
14414 printf("programming error: (%s)\n", strerror(-ret));
14418 cmdline_parse_inst_t cmd_set_macsec_sc = {
14419 .f = cmd_set_macsec_sc_parsed,
14421 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14423 (void *)&cmd_macsec_sc_set,
14424 (void *)&cmd_macsec_sc_macsec,
14425 (void *)&cmd_macsec_sc_sc,
14426 (void *)&cmd_macsec_sc_tx_rx,
14427 (void *)&cmd_macsec_sc_port_id,
14428 (void *)&cmd_macsec_sc_mac,
14429 (void *)&cmd_macsec_sc_pi,
14434 /* Common result structure for MACsec secure connection configure */
14435 struct cmd_macsec_sa_result {
14436 cmdline_fixed_string_t set;
14437 cmdline_fixed_string_t macsec;
14438 cmdline_fixed_string_t sa;
14439 cmdline_fixed_string_t tx_rx;
14444 cmdline_fixed_string_t key;
14447 /* Common CLI fields for MACsec secure connection configure */
14448 cmdline_parse_token_string_t cmd_macsec_sa_set =
14449 TOKEN_STRING_INITIALIZER
14450 (struct cmd_macsec_sa_result,
14452 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14453 TOKEN_STRING_INITIALIZER
14454 (struct cmd_macsec_sa_result,
14456 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14457 TOKEN_STRING_INITIALIZER
14458 (struct cmd_macsec_sa_result,
14460 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14461 TOKEN_STRING_INITIALIZER
14462 (struct cmd_macsec_sa_result,
14464 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14465 TOKEN_NUM_INITIALIZER
14466 (struct cmd_macsec_sa_result,
14468 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14469 TOKEN_NUM_INITIALIZER
14470 (struct cmd_macsec_sa_result,
14472 cmdline_parse_token_num_t cmd_macsec_sa_an =
14473 TOKEN_NUM_INITIALIZER
14474 (struct cmd_macsec_sa_result,
14476 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14477 TOKEN_NUM_INITIALIZER
14478 (struct cmd_macsec_sa_result,
14480 cmdline_parse_token_string_t cmd_macsec_sa_key =
14481 TOKEN_STRING_INITIALIZER
14482 (struct cmd_macsec_sa_result,
14486 cmd_set_macsec_sa_parsed(
14487 void *parsed_result,
14488 __attribute__((unused)) struct cmdline *cl,
14489 __attribute__((unused)) void *data)
14491 struct cmd_macsec_sa_result *res = parsed_result;
14492 int ret = -ENOTSUP;
14493 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14494 uint8_t key[16] = { 0 };
14500 key_len = strlen(res->key) / 2;
14504 for (i = 0; i < key_len; i++) {
14505 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14508 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14511 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14514 #ifdef RTE_LIBRTE_IXGBE_PMD
14516 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14517 res->idx, res->an, res->pn, key) :
14518 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14519 res->idx, res->an, res->pn, key);
14521 RTE_SET_USED(is_tx);
14528 printf("invalid idx %d or an %d\n", res->idx, res->an);
14531 printf("invalid port_id %d\n", res->port_id);
14534 printf("not supported on port %d\n", res->port_id);
14537 printf("programming error: (%s)\n", strerror(-ret));
14541 cmdline_parse_inst_t cmd_set_macsec_sa = {
14542 .f = cmd_set_macsec_sa_parsed,
14544 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14546 (void *)&cmd_macsec_sa_set,
14547 (void *)&cmd_macsec_sa_macsec,
14548 (void *)&cmd_macsec_sa_sa,
14549 (void *)&cmd_macsec_sa_tx_rx,
14550 (void *)&cmd_macsec_sa_port_id,
14551 (void *)&cmd_macsec_sa_idx,
14552 (void *)&cmd_macsec_sa_an,
14553 (void *)&cmd_macsec_sa_pn,
14554 (void *)&cmd_macsec_sa_key,
14559 /* VF unicast promiscuous mode configuration */
14561 /* Common result structure for VF unicast promiscuous mode */
14562 struct cmd_vf_promisc_result {
14563 cmdline_fixed_string_t set;
14564 cmdline_fixed_string_t vf;
14565 cmdline_fixed_string_t promisc;
14568 cmdline_fixed_string_t on_off;
14571 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14572 cmdline_parse_token_string_t cmd_vf_promisc_set =
14573 TOKEN_STRING_INITIALIZER
14574 (struct cmd_vf_promisc_result,
14576 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14577 TOKEN_STRING_INITIALIZER
14578 (struct cmd_vf_promisc_result,
14580 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14581 TOKEN_STRING_INITIALIZER
14582 (struct cmd_vf_promisc_result,
14583 promisc, "promisc");
14584 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14585 TOKEN_NUM_INITIALIZER
14586 (struct cmd_vf_promisc_result,
14588 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14589 TOKEN_NUM_INITIALIZER
14590 (struct cmd_vf_promisc_result,
14592 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14593 TOKEN_STRING_INITIALIZER
14594 (struct cmd_vf_promisc_result,
14598 cmd_set_vf_promisc_parsed(
14599 void *parsed_result,
14600 __attribute__((unused)) struct cmdline *cl,
14601 __attribute__((unused)) void *data)
14603 struct cmd_vf_promisc_result *res = parsed_result;
14604 int ret = -ENOTSUP;
14606 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14608 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14611 #ifdef RTE_LIBRTE_I40E_PMD
14612 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14613 res->vf_id, is_on);
14620 printf("invalid vf_id %d\n", res->vf_id);
14623 printf("invalid port_id %d\n", res->port_id);
14626 printf("function not implemented\n");
14629 printf("programming error: (%s)\n", strerror(-ret));
14633 cmdline_parse_inst_t cmd_set_vf_promisc = {
14634 .f = cmd_set_vf_promisc_parsed,
14636 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14637 "Set unicast promiscuous mode for a VF from the PF",
14639 (void *)&cmd_vf_promisc_set,
14640 (void *)&cmd_vf_promisc_vf,
14641 (void *)&cmd_vf_promisc_promisc,
14642 (void *)&cmd_vf_promisc_port_id,
14643 (void *)&cmd_vf_promisc_vf_id,
14644 (void *)&cmd_vf_promisc_on_off,
14649 /* VF multicast promiscuous mode configuration */
14651 /* Common result structure for VF multicast promiscuous mode */
14652 struct cmd_vf_allmulti_result {
14653 cmdline_fixed_string_t set;
14654 cmdline_fixed_string_t vf;
14655 cmdline_fixed_string_t allmulti;
14658 cmdline_fixed_string_t on_off;
14661 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14662 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14663 TOKEN_STRING_INITIALIZER
14664 (struct cmd_vf_allmulti_result,
14666 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14667 TOKEN_STRING_INITIALIZER
14668 (struct cmd_vf_allmulti_result,
14670 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14671 TOKEN_STRING_INITIALIZER
14672 (struct cmd_vf_allmulti_result,
14673 allmulti, "allmulti");
14674 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14675 TOKEN_NUM_INITIALIZER
14676 (struct cmd_vf_allmulti_result,
14678 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14679 TOKEN_NUM_INITIALIZER
14680 (struct cmd_vf_allmulti_result,
14682 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14683 TOKEN_STRING_INITIALIZER
14684 (struct cmd_vf_allmulti_result,
14688 cmd_set_vf_allmulti_parsed(
14689 void *parsed_result,
14690 __attribute__((unused)) struct cmdline *cl,
14691 __attribute__((unused)) void *data)
14693 struct cmd_vf_allmulti_result *res = parsed_result;
14694 int ret = -ENOTSUP;
14696 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14698 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14701 #ifdef RTE_LIBRTE_I40E_PMD
14702 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14703 res->vf_id, is_on);
14710 printf("invalid vf_id %d\n", res->vf_id);
14713 printf("invalid port_id %d\n", res->port_id);
14716 printf("function not implemented\n");
14719 printf("programming error: (%s)\n", strerror(-ret));
14723 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14724 .f = cmd_set_vf_allmulti_parsed,
14726 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14727 "Set multicast promiscuous mode for a VF from the PF",
14729 (void *)&cmd_vf_allmulti_set,
14730 (void *)&cmd_vf_allmulti_vf,
14731 (void *)&cmd_vf_allmulti_allmulti,
14732 (void *)&cmd_vf_allmulti_port_id,
14733 (void *)&cmd_vf_allmulti_vf_id,
14734 (void *)&cmd_vf_allmulti_on_off,
14739 /* vf broadcast mode configuration */
14741 /* Common result structure for vf broadcast */
14742 struct cmd_set_vf_broadcast_result {
14743 cmdline_fixed_string_t set;
14744 cmdline_fixed_string_t vf;
14745 cmdline_fixed_string_t broadcast;
14748 cmdline_fixed_string_t on_off;
14751 /* Common CLI fields for vf broadcast enable disable */
14752 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14753 TOKEN_STRING_INITIALIZER
14754 (struct cmd_set_vf_broadcast_result,
14756 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14757 TOKEN_STRING_INITIALIZER
14758 (struct cmd_set_vf_broadcast_result,
14760 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14761 TOKEN_STRING_INITIALIZER
14762 (struct cmd_set_vf_broadcast_result,
14763 broadcast, "broadcast");
14764 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14765 TOKEN_NUM_INITIALIZER
14766 (struct cmd_set_vf_broadcast_result,
14768 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14769 TOKEN_NUM_INITIALIZER
14770 (struct cmd_set_vf_broadcast_result,
14772 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14773 TOKEN_STRING_INITIALIZER
14774 (struct cmd_set_vf_broadcast_result,
14778 cmd_set_vf_broadcast_parsed(
14779 void *parsed_result,
14780 __attribute__((unused)) struct cmdline *cl,
14781 __attribute__((unused)) void *data)
14783 struct cmd_set_vf_broadcast_result *res = parsed_result;
14784 int ret = -ENOTSUP;
14786 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14791 #ifdef RTE_LIBRTE_I40E_PMD
14792 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14793 res->vf_id, is_on);
14800 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14803 printf("invalid port_id %d\n", res->port_id);
14806 printf("function not implemented\n");
14809 printf("programming error: (%s)\n", strerror(-ret));
14813 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14814 .f = cmd_set_vf_broadcast_parsed,
14816 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14818 (void *)&cmd_set_vf_broadcast_set,
14819 (void *)&cmd_set_vf_broadcast_vf,
14820 (void *)&cmd_set_vf_broadcast_broadcast,
14821 (void *)&cmd_set_vf_broadcast_port_id,
14822 (void *)&cmd_set_vf_broadcast_vf_id,
14823 (void *)&cmd_set_vf_broadcast_on_off,
14828 /* vf vlan tag configuration */
14830 /* Common result structure for vf vlan tag */
14831 struct cmd_set_vf_vlan_tag_result {
14832 cmdline_fixed_string_t set;
14833 cmdline_fixed_string_t vf;
14834 cmdline_fixed_string_t vlan;
14835 cmdline_fixed_string_t tag;
14838 cmdline_fixed_string_t on_off;
14841 /* Common CLI fields for vf vlan tag enable disable */
14842 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14843 TOKEN_STRING_INITIALIZER
14844 (struct cmd_set_vf_vlan_tag_result,
14846 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14847 TOKEN_STRING_INITIALIZER
14848 (struct cmd_set_vf_vlan_tag_result,
14850 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14851 TOKEN_STRING_INITIALIZER
14852 (struct cmd_set_vf_vlan_tag_result,
14854 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14855 TOKEN_STRING_INITIALIZER
14856 (struct cmd_set_vf_vlan_tag_result,
14858 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14859 TOKEN_NUM_INITIALIZER
14860 (struct cmd_set_vf_vlan_tag_result,
14862 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14863 TOKEN_NUM_INITIALIZER
14864 (struct cmd_set_vf_vlan_tag_result,
14866 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14867 TOKEN_STRING_INITIALIZER
14868 (struct cmd_set_vf_vlan_tag_result,
14872 cmd_set_vf_vlan_tag_parsed(
14873 void *parsed_result,
14874 __attribute__((unused)) struct cmdline *cl,
14875 __attribute__((unused)) void *data)
14877 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14878 int ret = -ENOTSUP;
14880 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14882 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14885 #ifdef RTE_LIBRTE_I40E_PMD
14886 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14887 res->vf_id, is_on);
14894 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14897 printf("invalid port_id %d\n", res->port_id);
14900 printf("function not implemented\n");
14903 printf("programming error: (%s)\n", strerror(-ret));
14907 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14908 .f = cmd_set_vf_vlan_tag_parsed,
14910 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14912 (void *)&cmd_set_vf_vlan_tag_set,
14913 (void *)&cmd_set_vf_vlan_tag_vf,
14914 (void *)&cmd_set_vf_vlan_tag_vlan,
14915 (void *)&cmd_set_vf_vlan_tag_tag,
14916 (void *)&cmd_set_vf_vlan_tag_port_id,
14917 (void *)&cmd_set_vf_vlan_tag_vf_id,
14918 (void *)&cmd_set_vf_vlan_tag_on_off,
14923 /* Common definition of VF and TC TX bandwidth configuration */
14924 struct cmd_vf_tc_bw_result {
14925 cmdline_fixed_string_t set;
14926 cmdline_fixed_string_t vf;
14927 cmdline_fixed_string_t tc;
14928 cmdline_fixed_string_t tx;
14929 cmdline_fixed_string_t min_bw;
14930 cmdline_fixed_string_t max_bw;
14931 cmdline_fixed_string_t strict_link_prio;
14936 cmdline_fixed_string_t bw_list;
14940 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14941 TOKEN_STRING_INITIALIZER
14942 (struct cmd_vf_tc_bw_result,
14944 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14945 TOKEN_STRING_INITIALIZER
14946 (struct cmd_vf_tc_bw_result,
14948 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14949 TOKEN_STRING_INITIALIZER
14950 (struct cmd_vf_tc_bw_result,
14952 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14953 TOKEN_STRING_INITIALIZER
14954 (struct cmd_vf_tc_bw_result,
14956 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14957 TOKEN_STRING_INITIALIZER
14958 (struct cmd_vf_tc_bw_result,
14959 strict_link_prio, "strict-link-priority");
14960 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14961 TOKEN_STRING_INITIALIZER
14962 (struct cmd_vf_tc_bw_result,
14963 min_bw, "min-bandwidth");
14964 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14965 TOKEN_STRING_INITIALIZER
14966 (struct cmd_vf_tc_bw_result,
14967 max_bw, "max-bandwidth");
14968 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14969 TOKEN_NUM_INITIALIZER
14970 (struct cmd_vf_tc_bw_result,
14972 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14973 TOKEN_NUM_INITIALIZER
14974 (struct cmd_vf_tc_bw_result,
14976 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14977 TOKEN_NUM_INITIALIZER
14978 (struct cmd_vf_tc_bw_result,
14980 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14981 TOKEN_NUM_INITIALIZER
14982 (struct cmd_vf_tc_bw_result,
14984 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14985 TOKEN_STRING_INITIALIZER
14986 (struct cmd_vf_tc_bw_result,
14988 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14989 TOKEN_NUM_INITIALIZER
14990 (struct cmd_vf_tc_bw_result,
14993 /* VF max bandwidth setting */
14995 cmd_vf_max_bw_parsed(
14996 void *parsed_result,
14997 __attribute__((unused)) struct cmdline *cl,
14998 __attribute__((unused)) void *data)
15000 struct cmd_vf_tc_bw_result *res = parsed_result;
15001 int ret = -ENOTSUP;
15003 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15006 #ifdef RTE_LIBRTE_I40E_PMD
15007 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15008 res->vf_id, res->bw);
15015 printf("invalid vf_id %d or bandwidth %d\n",
15016 res->vf_id, res->bw);
15019 printf("invalid port_id %d\n", res->port_id);
15022 printf("function not implemented\n");
15025 printf("programming error: (%s)\n", strerror(-ret));
15029 cmdline_parse_inst_t cmd_vf_max_bw = {
15030 .f = cmd_vf_max_bw_parsed,
15032 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15034 (void *)&cmd_vf_tc_bw_set,
15035 (void *)&cmd_vf_tc_bw_vf,
15036 (void *)&cmd_vf_tc_bw_tx,
15037 (void *)&cmd_vf_tc_bw_max_bw,
15038 (void *)&cmd_vf_tc_bw_port_id,
15039 (void *)&cmd_vf_tc_bw_vf_id,
15040 (void *)&cmd_vf_tc_bw_bw,
15046 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15051 const char *p, *p0 = str;
15058 p = strchr(p0, '(');
15060 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15064 p0 = strchr(p, ')');
15066 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15070 if (size >= sizeof(s)) {
15071 printf("The string size exceeds the internal buffer size\n");
15074 snprintf(s, sizeof(s), "%.*s", size, p);
15075 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15077 printf("Failed to get the bandwidth list. ");
15081 for (i = 0; i < ret; i++)
15082 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15087 /* TC min bandwidth setting */
15089 cmd_vf_tc_min_bw_parsed(
15090 void *parsed_result,
15091 __attribute__((unused)) struct cmdline *cl,
15092 __attribute__((unused)) void *data)
15094 struct cmd_vf_tc_bw_result *res = parsed_result;
15097 int ret = -ENOTSUP;
15099 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15102 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15106 #ifdef RTE_LIBRTE_I40E_PMD
15107 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15115 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15118 printf("invalid port_id %d\n", res->port_id);
15121 printf("function not implemented\n");
15124 printf("programming error: (%s)\n", strerror(-ret));
15128 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15129 .f = cmd_vf_tc_min_bw_parsed,
15131 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15132 " <bw1, bw2, ...>",
15134 (void *)&cmd_vf_tc_bw_set,
15135 (void *)&cmd_vf_tc_bw_vf,
15136 (void *)&cmd_vf_tc_bw_tc,
15137 (void *)&cmd_vf_tc_bw_tx,
15138 (void *)&cmd_vf_tc_bw_min_bw,
15139 (void *)&cmd_vf_tc_bw_port_id,
15140 (void *)&cmd_vf_tc_bw_vf_id,
15141 (void *)&cmd_vf_tc_bw_bw_list,
15147 cmd_tc_min_bw_parsed(
15148 void *parsed_result,
15149 __attribute__((unused)) struct cmdline *cl,
15150 __attribute__((unused)) void *data)
15152 struct cmd_vf_tc_bw_result *res = parsed_result;
15153 struct rte_port *port;
15156 int ret = -ENOTSUP;
15158 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15161 port = &ports[res->port_id];
15162 /** Check if the port is not started **/
15163 if (port->port_status != RTE_PORT_STOPPED) {
15164 printf("Please stop port %d first\n", res->port_id);
15168 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15172 #ifdef RTE_LIBRTE_IXGBE_PMD
15173 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15180 printf("invalid bandwidth\n");
15183 printf("invalid port_id %d\n", res->port_id);
15186 printf("function not implemented\n");
15189 printf("programming error: (%s)\n", strerror(-ret));
15193 cmdline_parse_inst_t cmd_tc_min_bw = {
15194 .f = cmd_tc_min_bw_parsed,
15196 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15198 (void *)&cmd_vf_tc_bw_set,
15199 (void *)&cmd_vf_tc_bw_tc,
15200 (void *)&cmd_vf_tc_bw_tx,
15201 (void *)&cmd_vf_tc_bw_min_bw,
15202 (void *)&cmd_vf_tc_bw_port_id,
15203 (void *)&cmd_vf_tc_bw_bw_list,
15208 /* TC max bandwidth setting */
15210 cmd_vf_tc_max_bw_parsed(
15211 void *parsed_result,
15212 __attribute__((unused)) struct cmdline *cl,
15213 __attribute__((unused)) void *data)
15215 struct cmd_vf_tc_bw_result *res = parsed_result;
15216 int ret = -ENOTSUP;
15218 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15221 #ifdef RTE_LIBRTE_I40E_PMD
15222 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15223 res->tc_no, res->bw);
15230 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15231 res->vf_id, res->tc_no, res->bw);
15234 printf("invalid port_id %d\n", res->port_id);
15237 printf("function not implemented\n");
15240 printf("programming error: (%s)\n", strerror(-ret));
15244 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15245 .f = cmd_vf_tc_max_bw_parsed,
15247 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15250 (void *)&cmd_vf_tc_bw_set,
15251 (void *)&cmd_vf_tc_bw_vf,
15252 (void *)&cmd_vf_tc_bw_tc,
15253 (void *)&cmd_vf_tc_bw_tx,
15254 (void *)&cmd_vf_tc_bw_max_bw,
15255 (void *)&cmd_vf_tc_bw_port_id,
15256 (void *)&cmd_vf_tc_bw_vf_id,
15257 (void *)&cmd_vf_tc_bw_tc_no,
15258 (void *)&cmd_vf_tc_bw_bw,
15264 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15266 /* *** Set Port default Traffic Management Hierarchy *** */
15267 struct cmd_set_port_tm_hierarchy_default_result {
15268 cmdline_fixed_string_t set;
15269 cmdline_fixed_string_t port;
15270 cmdline_fixed_string_t tm;
15271 cmdline_fixed_string_t hierarchy;
15272 cmdline_fixed_string_t def;
15276 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15277 TOKEN_STRING_INITIALIZER(
15278 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15279 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15280 TOKEN_STRING_INITIALIZER(
15281 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15282 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15283 TOKEN_STRING_INITIALIZER(
15284 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15285 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15286 TOKEN_STRING_INITIALIZER(
15287 struct cmd_set_port_tm_hierarchy_default_result,
15288 hierarchy, "hierarchy");
15289 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15290 TOKEN_STRING_INITIALIZER(
15291 struct cmd_set_port_tm_hierarchy_default_result,
15293 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15294 TOKEN_NUM_INITIALIZER(
15295 struct cmd_set_port_tm_hierarchy_default_result,
15298 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15299 __attribute__((unused)) struct cmdline *cl,
15300 __attribute__((unused)) void *data)
15302 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15303 struct rte_port *p;
15304 portid_t port_id = res->port_id;
15306 if (port_id_is_invalid(port_id, ENABLED_WARN))
15309 p = &ports[port_id];
15311 /* Forward mode: tm */
15312 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15313 printf(" softnicfwd mode not enabled(error)\n");
15317 /* Set the default tm hierarchy */
15318 p->softport.default_tm_hierarchy_enable = 1;
15321 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15322 .f = cmd_set_port_tm_hierarchy_default_parsed,
15324 .help_str = "set port tm hierarchy default <port_id>",
15326 (void *)&cmd_set_port_tm_hierarchy_default_set,
15327 (void *)&cmd_set_port_tm_hierarchy_default_port,
15328 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15329 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15330 (void *)&cmd_set_port_tm_hierarchy_default_default,
15331 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15337 /** Set VXLAN encapsulation details */
15338 struct cmd_set_vxlan_result {
15339 cmdline_fixed_string_t set;
15340 cmdline_fixed_string_t vxlan;
15341 cmdline_fixed_string_t pos_token;
15342 cmdline_fixed_string_t ip_version;
15343 uint32_t vlan_present:1;
15347 cmdline_ipaddr_t ip_src;
15348 cmdline_ipaddr_t ip_dst;
15352 struct rte_ether_addr eth_src;
15353 struct rte_ether_addr eth_dst;
15356 cmdline_parse_token_string_t cmd_set_vxlan_set =
15357 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15358 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15359 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15360 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15361 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15363 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15364 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15365 "vxlan-with-vlan");
15366 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15367 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15369 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15370 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15372 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15373 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15375 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15376 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15377 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15378 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15380 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15381 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15382 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15383 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15385 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15386 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15387 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15388 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15390 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15391 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15392 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15393 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15395 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15396 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15397 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15398 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15400 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15401 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15402 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15403 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15405 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15406 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15407 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15408 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15410 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15411 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15412 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15413 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15415 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15416 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15417 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15418 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15420 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15421 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15423 static void cmd_set_vxlan_parsed(void *parsed_result,
15424 __attribute__((unused)) struct cmdline *cl,
15425 __attribute__((unused)) void *data)
15427 struct cmd_set_vxlan_result *res = parsed_result;
15432 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15435 vxlan_encap_conf.select_tos_ttl = 0;
15436 if (strcmp(res->vxlan, "vxlan") == 0)
15437 vxlan_encap_conf.select_vlan = 0;
15438 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15439 vxlan_encap_conf.select_vlan = 1;
15440 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15441 vxlan_encap_conf.select_vlan = 0;
15442 vxlan_encap_conf.select_tos_ttl = 1;
15444 if (strcmp(res->ip_version, "ipv4") == 0)
15445 vxlan_encap_conf.select_ipv4 = 1;
15446 else if (strcmp(res->ip_version, "ipv6") == 0)
15447 vxlan_encap_conf.select_ipv4 = 0;
15450 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15451 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15452 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15453 vxlan_encap_conf.ip_tos = res->tos;
15454 vxlan_encap_conf.ip_ttl = res->ttl;
15455 if (vxlan_encap_conf.select_ipv4) {
15456 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15457 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15459 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15460 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15462 if (vxlan_encap_conf.select_vlan)
15463 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15464 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15465 RTE_ETHER_ADDR_LEN);
15466 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15467 RTE_ETHER_ADDR_LEN);
15470 cmdline_parse_inst_t cmd_set_vxlan = {
15471 .f = cmd_set_vxlan_parsed,
15473 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15474 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15475 " eth-src <eth-src> eth-dst <eth-dst>",
15477 (void *)&cmd_set_vxlan_set,
15478 (void *)&cmd_set_vxlan_vxlan,
15479 (void *)&cmd_set_vxlan_ip_version,
15480 (void *)&cmd_set_vxlan_ip_version_value,
15481 (void *)&cmd_set_vxlan_vni,
15482 (void *)&cmd_set_vxlan_vni_value,
15483 (void *)&cmd_set_vxlan_udp_src,
15484 (void *)&cmd_set_vxlan_udp_src_value,
15485 (void *)&cmd_set_vxlan_udp_dst,
15486 (void *)&cmd_set_vxlan_udp_dst_value,
15487 (void *)&cmd_set_vxlan_ip_src,
15488 (void *)&cmd_set_vxlan_ip_src_value,
15489 (void *)&cmd_set_vxlan_ip_dst,
15490 (void *)&cmd_set_vxlan_ip_dst_value,
15491 (void *)&cmd_set_vxlan_eth_src,
15492 (void *)&cmd_set_vxlan_eth_src_value,
15493 (void *)&cmd_set_vxlan_eth_dst,
15494 (void *)&cmd_set_vxlan_eth_dst_value,
15499 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15500 .f = cmd_set_vxlan_parsed,
15502 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15503 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15504 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15505 " eth-dst <eth-dst>",
15507 (void *)&cmd_set_vxlan_set,
15508 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15509 (void *)&cmd_set_vxlan_ip_version,
15510 (void *)&cmd_set_vxlan_ip_version_value,
15511 (void *)&cmd_set_vxlan_vni,
15512 (void *)&cmd_set_vxlan_vni_value,
15513 (void *)&cmd_set_vxlan_udp_src,
15514 (void *)&cmd_set_vxlan_udp_src_value,
15515 (void *)&cmd_set_vxlan_udp_dst,
15516 (void *)&cmd_set_vxlan_udp_dst_value,
15517 (void *)&cmd_set_vxlan_ip_tos,
15518 (void *)&cmd_set_vxlan_ip_tos_value,
15519 (void *)&cmd_set_vxlan_ip_ttl,
15520 (void *)&cmd_set_vxlan_ip_ttl_value,
15521 (void *)&cmd_set_vxlan_ip_src,
15522 (void *)&cmd_set_vxlan_ip_src_value,
15523 (void *)&cmd_set_vxlan_ip_dst,
15524 (void *)&cmd_set_vxlan_ip_dst_value,
15525 (void *)&cmd_set_vxlan_eth_src,
15526 (void *)&cmd_set_vxlan_eth_src_value,
15527 (void *)&cmd_set_vxlan_eth_dst,
15528 (void *)&cmd_set_vxlan_eth_dst_value,
15533 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15534 .f = cmd_set_vxlan_parsed,
15536 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15537 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15538 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15541 (void *)&cmd_set_vxlan_set,
15542 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15543 (void *)&cmd_set_vxlan_ip_version,
15544 (void *)&cmd_set_vxlan_ip_version_value,
15545 (void *)&cmd_set_vxlan_vni,
15546 (void *)&cmd_set_vxlan_vni_value,
15547 (void *)&cmd_set_vxlan_udp_src,
15548 (void *)&cmd_set_vxlan_udp_src_value,
15549 (void *)&cmd_set_vxlan_udp_dst,
15550 (void *)&cmd_set_vxlan_udp_dst_value,
15551 (void *)&cmd_set_vxlan_ip_src,
15552 (void *)&cmd_set_vxlan_ip_src_value,
15553 (void *)&cmd_set_vxlan_ip_dst,
15554 (void *)&cmd_set_vxlan_ip_dst_value,
15555 (void *)&cmd_set_vxlan_vlan,
15556 (void *)&cmd_set_vxlan_vlan_value,
15557 (void *)&cmd_set_vxlan_eth_src,
15558 (void *)&cmd_set_vxlan_eth_src_value,
15559 (void *)&cmd_set_vxlan_eth_dst,
15560 (void *)&cmd_set_vxlan_eth_dst_value,
15565 /** Set NVGRE encapsulation details */
15566 struct cmd_set_nvgre_result {
15567 cmdline_fixed_string_t set;
15568 cmdline_fixed_string_t nvgre;
15569 cmdline_fixed_string_t pos_token;
15570 cmdline_fixed_string_t ip_version;
15572 cmdline_ipaddr_t ip_src;
15573 cmdline_ipaddr_t ip_dst;
15575 struct rte_ether_addr eth_src;
15576 struct rte_ether_addr eth_dst;
15579 cmdline_parse_token_string_t cmd_set_nvgre_set =
15580 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15581 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15582 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15583 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15584 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15585 "nvgre-with-vlan");
15586 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15587 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15589 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15590 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15592 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15593 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15595 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15596 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15597 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15598 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15600 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15601 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15602 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15603 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15605 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15606 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15607 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15608 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15610 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15611 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15612 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15613 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15615 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15616 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15617 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15618 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15620 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15621 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15623 static void cmd_set_nvgre_parsed(void *parsed_result,
15624 __attribute__((unused)) struct cmdline *cl,
15625 __attribute__((unused)) void *data)
15627 struct cmd_set_nvgre_result *res = parsed_result;
15629 uint32_t nvgre_tni;
15632 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15635 if (strcmp(res->nvgre, "nvgre") == 0)
15636 nvgre_encap_conf.select_vlan = 0;
15637 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15638 nvgre_encap_conf.select_vlan = 1;
15639 if (strcmp(res->ip_version, "ipv4") == 0)
15640 nvgre_encap_conf.select_ipv4 = 1;
15641 else if (strcmp(res->ip_version, "ipv6") == 0)
15642 nvgre_encap_conf.select_ipv4 = 0;
15645 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15646 if (nvgre_encap_conf.select_ipv4) {
15647 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15648 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15650 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15651 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15653 if (nvgre_encap_conf.select_vlan)
15654 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15655 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15656 RTE_ETHER_ADDR_LEN);
15657 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15658 RTE_ETHER_ADDR_LEN);
15661 cmdline_parse_inst_t cmd_set_nvgre = {
15662 .f = cmd_set_nvgre_parsed,
15664 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15665 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15666 " eth-dst <eth-dst>",
15668 (void *)&cmd_set_nvgre_set,
15669 (void *)&cmd_set_nvgre_nvgre,
15670 (void *)&cmd_set_nvgre_ip_version,
15671 (void *)&cmd_set_nvgre_ip_version_value,
15672 (void *)&cmd_set_nvgre_tni,
15673 (void *)&cmd_set_nvgre_tni_value,
15674 (void *)&cmd_set_nvgre_ip_src,
15675 (void *)&cmd_set_nvgre_ip_src_value,
15676 (void *)&cmd_set_nvgre_ip_dst,
15677 (void *)&cmd_set_nvgre_ip_dst_value,
15678 (void *)&cmd_set_nvgre_eth_src,
15679 (void *)&cmd_set_nvgre_eth_src_value,
15680 (void *)&cmd_set_nvgre_eth_dst,
15681 (void *)&cmd_set_nvgre_eth_dst_value,
15686 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15687 .f = cmd_set_nvgre_parsed,
15689 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15690 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15691 " eth-src <eth-src> eth-dst <eth-dst>",
15693 (void *)&cmd_set_nvgre_set,
15694 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15695 (void *)&cmd_set_nvgre_ip_version,
15696 (void *)&cmd_set_nvgre_ip_version_value,
15697 (void *)&cmd_set_nvgre_tni,
15698 (void *)&cmd_set_nvgre_tni_value,
15699 (void *)&cmd_set_nvgre_ip_src,
15700 (void *)&cmd_set_nvgre_ip_src_value,
15701 (void *)&cmd_set_nvgre_ip_dst,
15702 (void *)&cmd_set_nvgre_ip_dst_value,
15703 (void *)&cmd_set_nvgre_vlan,
15704 (void *)&cmd_set_nvgre_vlan_value,
15705 (void *)&cmd_set_nvgre_eth_src,
15706 (void *)&cmd_set_nvgre_eth_src_value,
15707 (void *)&cmd_set_nvgre_eth_dst,
15708 (void *)&cmd_set_nvgre_eth_dst_value,
15713 /** Set L2 encapsulation details */
15714 struct cmd_set_l2_encap_result {
15715 cmdline_fixed_string_t set;
15716 cmdline_fixed_string_t l2_encap;
15717 cmdline_fixed_string_t pos_token;
15718 cmdline_fixed_string_t ip_version;
15719 uint32_t vlan_present:1;
15721 struct rte_ether_addr eth_src;
15722 struct rte_ether_addr eth_dst;
15725 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15726 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15727 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15728 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15729 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15730 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15731 "l2_encap-with-vlan");
15732 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15733 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15735 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15736 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15738 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15739 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15741 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15742 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15743 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15744 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15746 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15747 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15748 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15749 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15751 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15752 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15754 static void cmd_set_l2_encap_parsed(void *parsed_result,
15755 __attribute__((unused)) struct cmdline *cl,
15756 __attribute__((unused)) void *data)
15758 struct cmd_set_l2_encap_result *res = parsed_result;
15760 if (strcmp(res->l2_encap, "l2_encap") == 0)
15761 l2_encap_conf.select_vlan = 0;
15762 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15763 l2_encap_conf.select_vlan = 1;
15764 if (strcmp(res->ip_version, "ipv4") == 0)
15765 l2_encap_conf.select_ipv4 = 1;
15766 else if (strcmp(res->ip_version, "ipv6") == 0)
15767 l2_encap_conf.select_ipv4 = 0;
15770 if (l2_encap_conf.select_vlan)
15771 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15772 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15773 RTE_ETHER_ADDR_LEN);
15774 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15775 RTE_ETHER_ADDR_LEN);
15778 cmdline_parse_inst_t cmd_set_l2_encap = {
15779 .f = cmd_set_l2_encap_parsed,
15781 .help_str = "set l2_encap ip-version ipv4|ipv6"
15782 " eth-src <eth-src> eth-dst <eth-dst>",
15784 (void *)&cmd_set_l2_encap_set,
15785 (void *)&cmd_set_l2_encap_l2_encap,
15786 (void *)&cmd_set_l2_encap_ip_version,
15787 (void *)&cmd_set_l2_encap_ip_version_value,
15788 (void *)&cmd_set_l2_encap_eth_src,
15789 (void *)&cmd_set_l2_encap_eth_src_value,
15790 (void *)&cmd_set_l2_encap_eth_dst,
15791 (void *)&cmd_set_l2_encap_eth_dst_value,
15796 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15797 .f = cmd_set_l2_encap_parsed,
15799 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15800 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15802 (void *)&cmd_set_l2_encap_set,
15803 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15804 (void *)&cmd_set_l2_encap_ip_version,
15805 (void *)&cmd_set_l2_encap_ip_version_value,
15806 (void *)&cmd_set_l2_encap_vlan,
15807 (void *)&cmd_set_l2_encap_vlan_value,
15808 (void *)&cmd_set_l2_encap_eth_src,
15809 (void *)&cmd_set_l2_encap_eth_src_value,
15810 (void *)&cmd_set_l2_encap_eth_dst,
15811 (void *)&cmd_set_l2_encap_eth_dst_value,
15816 /** Set L2 decapsulation details */
15817 struct cmd_set_l2_decap_result {
15818 cmdline_fixed_string_t set;
15819 cmdline_fixed_string_t l2_decap;
15820 cmdline_fixed_string_t pos_token;
15821 uint32_t vlan_present:1;
15824 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15825 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15826 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15827 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15829 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15830 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15831 "l2_decap-with-vlan");
15833 static void cmd_set_l2_decap_parsed(void *parsed_result,
15834 __attribute__((unused)) struct cmdline *cl,
15835 __attribute__((unused)) void *data)
15837 struct cmd_set_l2_decap_result *res = parsed_result;
15839 if (strcmp(res->l2_decap, "l2_decap") == 0)
15840 l2_decap_conf.select_vlan = 0;
15841 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15842 l2_decap_conf.select_vlan = 1;
15845 cmdline_parse_inst_t cmd_set_l2_decap = {
15846 .f = cmd_set_l2_decap_parsed,
15848 .help_str = "set l2_decap",
15850 (void *)&cmd_set_l2_decap_set,
15851 (void *)&cmd_set_l2_decap_l2_decap,
15856 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15857 .f = cmd_set_l2_decap_parsed,
15859 .help_str = "set l2_decap-with-vlan",
15861 (void *)&cmd_set_l2_decap_set,
15862 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15867 /** Set MPLSoGRE encapsulation details */
15868 struct cmd_set_mplsogre_encap_result {
15869 cmdline_fixed_string_t set;
15870 cmdline_fixed_string_t mplsogre;
15871 cmdline_fixed_string_t pos_token;
15872 cmdline_fixed_string_t ip_version;
15873 uint32_t vlan_present:1;
15875 cmdline_ipaddr_t ip_src;
15876 cmdline_ipaddr_t ip_dst;
15878 struct rte_ether_addr eth_src;
15879 struct rte_ether_addr eth_dst;
15882 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15883 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15885 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15888 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15889 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15890 mplsogre, "mplsogre_encap-with-vlan");
15891 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15893 pos_token, "ip-version");
15894 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15895 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15896 ip_version, "ipv4#ipv6");
15897 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15898 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15899 pos_token, "label");
15900 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15901 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15903 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15904 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15905 pos_token, "ip-src");
15906 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15907 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15908 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15909 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15910 pos_token, "ip-dst");
15911 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15912 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15913 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15914 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15915 pos_token, "vlan-tci");
15916 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15917 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15919 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15920 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15921 pos_token, "eth-src");
15922 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15923 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15925 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15926 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15927 pos_token, "eth-dst");
15928 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15929 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15932 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15933 __attribute__((unused)) struct cmdline *cl,
15934 __attribute__((unused)) void *data)
15936 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15938 uint32_t mplsogre_label;
15941 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15944 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15945 mplsogre_encap_conf.select_vlan = 0;
15946 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15947 mplsogre_encap_conf.select_vlan = 1;
15948 if (strcmp(res->ip_version, "ipv4") == 0)
15949 mplsogre_encap_conf.select_ipv4 = 1;
15950 else if (strcmp(res->ip_version, "ipv6") == 0)
15951 mplsogre_encap_conf.select_ipv4 = 0;
15954 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15955 if (mplsogre_encap_conf.select_ipv4) {
15956 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15957 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15959 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15960 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15962 if (mplsogre_encap_conf.select_vlan)
15963 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15964 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15965 RTE_ETHER_ADDR_LEN);
15966 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15967 RTE_ETHER_ADDR_LEN);
15970 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15971 .f = cmd_set_mplsogre_encap_parsed,
15973 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15974 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15975 " eth-dst <eth-dst>",
15977 (void *)&cmd_set_mplsogre_encap_set,
15978 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15979 (void *)&cmd_set_mplsogre_encap_ip_version,
15980 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15981 (void *)&cmd_set_mplsogre_encap_label,
15982 (void *)&cmd_set_mplsogre_encap_label_value,
15983 (void *)&cmd_set_mplsogre_encap_ip_src,
15984 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15985 (void *)&cmd_set_mplsogre_encap_ip_dst,
15986 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15987 (void *)&cmd_set_mplsogre_encap_eth_src,
15988 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15989 (void *)&cmd_set_mplsogre_encap_eth_dst,
15990 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15995 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15996 .f = cmd_set_mplsogre_encap_parsed,
15998 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15999 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16000 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16002 (void *)&cmd_set_mplsogre_encap_set,
16003 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16004 (void *)&cmd_set_mplsogre_encap_ip_version,
16005 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16006 (void *)&cmd_set_mplsogre_encap_label,
16007 (void *)&cmd_set_mplsogre_encap_label_value,
16008 (void *)&cmd_set_mplsogre_encap_ip_src,
16009 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16010 (void *)&cmd_set_mplsogre_encap_ip_dst,
16011 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16012 (void *)&cmd_set_mplsogre_encap_vlan,
16013 (void *)&cmd_set_mplsogre_encap_vlan_value,
16014 (void *)&cmd_set_mplsogre_encap_eth_src,
16015 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16016 (void *)&cmd_set_mplsogre_encap_eth_dst,
16017 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16022 /** Set MPLSoGRE decapsulation details */
16023 struct cmd_set_mplsogre_decap_result {
16024 cmdline_fixed_string_t set;
16025 cmdline_fixed_string_t mplsogre;
16026 cmdline_fixed_string_t pos_token;
16027 cmdline_fixed_string_t ip_version;
16028 uint32_t vlan_present:1;
16031 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16032 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16034 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16035 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16037 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16038 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16039 mplsogre, "mplsogre_decap-with-vlan");
16040 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16041 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16042 pos_token, "ip-version");
16043 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16044 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16045 ip_version, "ipv4#ipv6");
16047 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16048 __attribute__((unused)) struct cmdline *cl,
16049 __attribute__((unused)) void *data)
16051 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16053 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16054 mplsogre_decap_conf.select_vlan = 0;
16055 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16056 mplsogre_decap_conf.select_vlan = 1;
16057 if (strcmp(res->ip_version, "ipv4") == 0)
16058 mplsogre_decap_conf.select_ipv4 = 1;
16059 else if (strcmp(res->ip_version, "ipv6") == 0)
16060 mplsogre_decap_conf.select_ipv4 = 0;
16063 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16064 .f = cmd_set_mplsogre_decap_parsed,
16066 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16068 (void *)&cmd_set_mplsogre_decap_set,
16069 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16070 (void *)&cmd_set_mplsogre_decap_ip_version,
16071 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16076 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16077 .f = cmd_set_mplsogre_decap_parsed,
16079 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16081 (void *)&cmd_set_mplsogre_decap_set,
16082 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16083 (void *)&cmd_set_mplsogre_decap_ip_version,
16084 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16089 /** Set MPLSoUDP encapsulation details */
16090 struct cmd_set_mplsoudp_encap_result {
16091 cmdline_fixed_string_t set;
16092 cmdline_fixed_string_t mplsoudp;
16093 cmdline_fixed_string_t pos_token;
16094 cmdline_fixed_string_t ip_version;
16095 uint32_t vlan_present:1;
16099 cmdline_ipaddr_t ip_src;
16100 cmdline_ipaddr_t ip_dst;
16102 struct rte_ether_addr eth_src;
16103 struct rte_ether_addr eth_dst;
16106 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16107 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16109 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16110 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16112 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16113 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16114 mplsoudp, "mplsoudp_encap-with-vlan");
16115 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16116 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16117 pos_token, "ip-version");
16118 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16119 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16120 ip_version, "ipv4#ipv6");
16121 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16122 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16123 pos_token, "label");
16124 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16125 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16127 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16128 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16129 pos_token, "udp-src");
16130 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16131 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16133 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16134 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16135 pos_token, "udp-dst");
16136 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16137 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16139 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16140 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16141 pos_token, "ip-src");
16142 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16143 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16144 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16145 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16146 pos_token, "ip-dst");
16147 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16148 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16149 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16150 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16151 pos_token, "vlan-tci");
16152 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16153 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16155 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16156 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16157 pos_token, "eth-src");
16158 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16159 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16161 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16163 pos_token, "eth-dst");
16164 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16165 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16168 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16169 __attribute__((unused)) struct cmdline *cl,
16170 __attribute__((unused)) void *data)
16172 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16174 uint32_t mplsoudp_label;
16177 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16180 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16181 mplsoudp_encap_conf.select_vlan = 0;
16182 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16183 mplsoudp_encap_conf.select_vlan = 1;
16184 if (strcmp(res->ip_version, "ipv4") == 0)
16185 mplsoudp_encap_conf.select_ipv4 = 1;
16186 else if (strcmp(res->ip_version, "ipv6") == 0)
16187 mplsoudp_encap_conf.select_ipv4 = 0;
16190 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16191 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16192 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16193 if (mplsoudp_encap_conf.select_ipv4) {
16194 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16195 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16197 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16198 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16200 if (mplsoudp_encap_conf.select_vlan)
16201 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16202 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16203 RTE_ETHER_ADDR_LEN);
16204 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16205 RTE_ETHER_ADDR_LEN);
16208 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16209 .f = cmd_set_mplsoudp_encap_parsed,
16211 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16212 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16213 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16215 (void *)&cmd_set_mplsoudp_encap_set,
16216 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16217 (void *)&cmd_set_mplsoudp_encap_ip_version,
16218 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16219 (void *)&cmd_set_mplsoudp_encap_label,
16220 (void *)&cmd_set_mplsoudp_encap_label_value,
16221 (void *)&cmd_set_mplsoudp_encap_udp_src,
16222 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16223 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16224 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16225 (void *)&cmd_set_mplsoudp_encap_ip_src,
16226 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16227 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16228 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16229 (void *)&cmd_set_mplsoudp_encap_eth_src,
16230 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16231 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16232 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16237 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16238 .f = cmd_set_mplsoudp_encap_parsed,
16240 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16241 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16242 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16243 " eth-src <eth-src> eth-dst <eth-dst>",
16245 (void *)&cmd_set_mplsoudp_encap_set,
16246 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16247 (void *)&cmd_set_mplsoudp_encap_ip_version,
16248 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16249 (void *)&cmd_set_mplsoudp_encap_label,
16250 (void *)&cmd_set_mplsoudp_encap_label_value,
16251 (void *)&cmd_set_mplsoudp_encap_udp_src,
16252 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16253 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16254 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16255 (void *)&cmd_set_mplsoudp_encap_ip_src,
16256 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16257 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16258 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16259 (void *)&cmd_set_mplsoudp_encap_vlan,
16260 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16261 (void *)&cmd_set_mplsoudp_encap_eth_src,
16262 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16263 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16264 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16269 /** Set MPLSoUDP decapsulation details */
16270 struct cmd_set_mplsoudp_decap_result {
16271 cmdline_fixed_string_t set;
16272 cmdline_fixed_string_t mplsoudp;
16273 cmdline_fixed_string_t pos_token;
16274 cmdline_fixed_string_t ip_version;
16275 uint32_t vlan_present:1;
16278 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16279 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16281 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16282 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16284 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16285 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16286 mplsoudp, "mplsoudp_decap-with-vlan");
16287 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16288 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16289 pos_token, "ip-version");
16290 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16291 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16292 ip_version, "ipv4#ipv6");
16294 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16295 __attribute__((unused)) struct cmdline *cl,
16296 __attribute__((unused)) void *data)
16298 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16300 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16301 mplsoudp_decap_conf.select_vlan = 0;
16302 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16303 mplsoudp_decap_conf.select_vlan = 1;
16304 if (strcmp(res->ip_version, "ipv4") == 0)
16305 mplsoudp_decap_conf.select_ipv4 = 1;
16306 else if (strcmp(res->ip_version, "ipv6") == 0)
16307 mplsoudp_decap_conf.select_ipv4 = 0;
16310 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16311 .f = cmd_set_mplsoudp_decap_parsed,
16313 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16315 (void *)&cmd_set_mplsoudp_decap_set,
16316 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16317 (void *)&cmd_set_mplsoudp_decap_ip_version,
16318 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16323 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16324 .f = cmd_set_mplsoudp_decap_parsed,
16326 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16328 (void *)&cmd_set_mplsoudp_decap_set,
16329 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16330 (void *)&cmd_set_mplsoudp_decap_ip_version,
16331 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16336 /* Strict link priority scheduling mode setting */
16338 cmd_strict_link_prio_parsed(
16339 void *parsed_result,
16340 __attribute__((unused)) struct cmdline *cl,
16341 __attribute__((unused)) void *data)
16343 struct cmd_vf_tc_bw_result *res = parsed_result;
16344 int ret = -ENOTSUP;
16346 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16349 #ifdef RTE_LIBRTE_I40E_PMD
16350 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16357 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16360 printf("invalid port_id %d\n", res->port_id);
16363 printf("function not implemented\n");
16366 printf("programming error: (%s)\n", strerror(-ret));
16370 cmdline_parse_inst_t cmd_strict_link_prio = {
16371 .f = cmd_strict_link_prio_parsed,
16373 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16375 (void *)&cmd_vf_tc_bw_set,
16376 (void *)&cmd_vf_tc_bw_tx,
16377 (void *)&cmd_vf_tc_bw_strict_link_prio,
16378 (void *)&cmd_vf_tc_bw_port_id,
16379 (void *)&cmd_vf_tc_bw_tc_map,
16384 /* Load dynamic device personalization*/
16385 struct cmd_ddp_add_result {
16386 cmdline_fixed_string_t ddp;
16387 cmdline_fixed_string_t add;
16392 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16393 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16394 cmdline_parse_token_string_t cmd_ddp_add_add =
16395 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16396 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16397 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16398 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16399 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16402 cmd_ddp_add_parsed(
16403 void *parsed_result,
16404 __attribute__((unused)) struct cmdline *cl,
16405 __attribute__((unused)) void *data)
16407 struct cmd_ddp_add_result *res = parsed_result;
16413 int ret = -ENOTSUP;
16415 if (!all_ports_stopped()) {
16416 printf("Please stop all ports first\n");
16420 filepath = strdup(res->filepath);
16421 if (filepath == NULL) {
16422 printf("Failed to allocate memory\n");
16425 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16427 buff = open_file(file_fld[0], &size);
16429 free((void *)filepath);
16433 #ifdef RTE_LIBRTE_I40E_PMD
16434 if (ret == -ENOTSUP)
16435 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16437 RTE_PMD_I40E_PKG_OP_WR_ADD);
16440 if (ret == -EEXIST)
16441 printf("Profile has already existed.\n");
16443 printf("Failed to load profile.\n");
16444 else if (file_num == 2)
16445 save_file(file_fld[1], buff, size);
16448 free((void *)filepath);
16451 cmdline_parse_inst_t cmd_ddp_add = {
16452 .f = cmd_ddp_add_parsed,
16454 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16456 (void *)&cmd_ddp_add_ddp,
16457 (void *)&cmd_ddp_add_add,
16458 (void *)&cmd_ddp_add_port_id,
16459 (void *)&cmd_ddp_add_filepath,
16464 /* Delete dynamic device personalization*/
16465 struct cmd_ddp_del_result {
16466 cmdline_fixed_string_t ddp;
16467 cmdline_fixed_string_t del;
16472 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16473 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16474 cmdline_parse_token_string_t cmd_ddp_del_del =
16475 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16476 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16477 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16478 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16479 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16482 cmd_ddp_del_parsed(
16483 void *parsed_result,
16484 __attribute__((unused)) struct cmdline *cl,
16485 __attribute__((unused)) void *data)
16487 struct cmd_ddp_del_result *res = parsed_result;
16490 int ret = -ENOTSUP;
16492 if (!all_ports_stopped()) {
16493 printf("Please stop all ports first\n");
16497 buff = open_file(res->filepath, &size);
16501 #ifdef RTE_LIBRTE_I40E_PMD
16502 if (ret == -ENOTSUP)
16503 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16505 RTE_PMD_I40E_PKG_OP_WR_DEL);
16508 if (ret == -EACCES)
16509 printf("Profile does not exist.\n");
16511 printf("Failed to delete profile.\n");
16516 cmdline_parse_inst_t cmd_ddp_del = {
16517 .f = cmd_ddp_del_parsed,
16519 .help_str = "ddp del <port_id> <backup_profile_path>",
16521 (void *)&cmd_ddp_del_ddp,
16522 (void *)&cmd_ddp_del_del,
16523 (void *)&cmd_ddp_del_port_id,
16524 (void *)&cmd_ddp_del_filepath,
16529 /* Get dynamic device personalization profile info */
16530 struct cmd_ddp_info_result {
16531 cmdline_fixed_string_t ddp;
16532 cmdline_fixed_string_t get;
16533 cmdline_fixed_string_t info;
16537 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16538 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16539 cmdline_parse_token_string_t cmd_ddp_info_get =
16540 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16541 cmdline_parse_token_string_t cmd_ddp_info_info =
16542 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16543 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16544 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16547 cmd_ddp_info_parsed(
16548 void *parsed_result,
16549 __attribute__((unused)) struct cmdline *cl,
16550 __attribute__((unused)) void *data)
16552 struct cmd_ddp_info_result *res = parsed_result;
16555 int ret = -ENOTSUP;
16556 #ifdef RTE_LIBRTE_I40E_PMD
16559 uint32_t buff_size = 0;
16560 struct rte_pmd_i40e_profile_info info;
16561 uint32_t dev_num = 0;
16562 struct rte_pmd_i40e_ddp_device_id *devs;
16563 uint32_t proto_num = 0;
16564 struct rte_pmd_i40e_proto_info *proto = NULL;
16565 uint32_t pctype_num = 0;
16566 struct rte_pmd_i40e_ptype_info *pctype;
16567 uint32_t ptype_num = 0;
16568 struct rte_pmd_i40e_ptype_info *ptype;
16573 pkg = open_file(res->filepath, &pkg_size);
16577 #ifdef RTE_LIBRTE_I40E_PMD
16578 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16579 (uint8_t *)&info, sizeof(info),
16580 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16582 printf("Global Track id: 0x%x\n", info.track_id);
16583 printf("Global Version: %d.%d.%d.%d\n",
16584 info.version.major,
16585 info.version.minor,
16586 info.version.update,
16587 info.version.draft);
16588 printf("Global Package name: %s\n\n", info.name);
16591 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16592 (uint8_t *)&info, sizeof(info),
16593 RTE_PMD_I40E_PKG_INFO_HEADER);
16595 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16596 printf("i40e Profile Version: %d.%d.%d.%d\n",
16597 info.version.major,
16598 info.version.minor,
16599 info.version.update,
16600 info.version.draft);
16601 printf("i40e Profile name: %s\n\n", info.name);
16604 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16605 (uint8_t *)&buff_size, sizeof(buff_size),
16606 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16607 if (!ret && buff_size) {
16608 buff = (uint8_t *)malloc(buff_size);
16610 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16612 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16614 printf("Package Notes:\n%s\n\n", buff);
16619 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16620 (uint8_t *)&dev_num, sizeof(dev_num),
16621 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16622 if (!ret && dev_num) {
16623 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16624 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16626 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16627 (uint8_t *)devs, buff_size,
16628 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16630 printf("List of supported devices:\n");
16631 for (i = 0; i < dev_num; i++) {
16632 printf(" %04X:%04X %04X:%04X\n",
16633 devs[i].vendor_dev_id >> 16,
16634 devs[i].vendor_dev_id & 0xFFFF,
16635 devs[i].sub_vendor_dev_id >> 16,
16636 devs[i].sub_vendor_dev_id & 0xFFFF);
16644 /* get information about protocols and packet types */
16645 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16646 (uint8_t *)&proto_num, sizeof(proto_num),
16647 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16648 if (ret || !proto_num)
16649 goto no_print_return;
16651 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16652 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16654 goto no_print_return;
16656 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16658 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16660 printf("List of used protocols:\n");
16661 for (i = 0; i < proto_num; i++)
16662 printf(" %2u: %s\n", proto[i].proto_id,
16666 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16667 (uint8_t *)&pctype_num, sizeof(pctype_num),
16668 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16669 if (ret || !pctype_num)
16670 goto no_print_pctypes;
16672 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16673 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16675 goto no_print_pctypes;
16677 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16679 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16682 goto no_print_pctypes;
16685 printf("List of defined packet classification types:\n");
16686 for (i = 0; i < pctype_num; i++) {
16687 printf(" %2u:", pctype[i].ptype_id);
16688 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16689 proto_id = pctype[i].protocols[j];
16690 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16691 for (n = 0; n < proto_num; n++) {
16692 if (proto[n].proto_id == proto_id) {
16693 printf(" %s", proto[n].name);
16706 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16708 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16709 if (ret || !ptype_num)
16710 goto no_print_return;
16712 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16713 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16715 goto no_print_return;
16717 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16719 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16722 goto no_print_return;
16724 printf("List of defined packet types:\n");
16725 for (i = 0; i < ptype_num; i++) {
16726 printf(" %2u:", ptype[i].ptype_id);
16727 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16728 proto_id = ptype[i].protocols[j];
16729 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16730 for (n = 0; n < proto_num; n++) {
16731 if (proto[n].proto_id == proto_id) {
16732 printf(" %s", proto[n].name);
16748 if (ret == -ENOTSUP)
16749 printf("Function not supported in PMD driver\n");
16753 cmdline_parse_inst_t cmd_ddp_get_info = {
16754 .f = cmd_ddp_info_parsed,
16756 .help_str = "ddp get info <profile_path>",
16758 (void *)&cmd_ddp_info_ddp,
16759 (void *)&cmd_ddp_info_get,
16760 (void *)&cmd_ddp_info_info,
16761 (void *)&cmd_ddp_info_filepath,
16766 /* Get dynamic device personalization profile info list*/
16767 #define PROFILE_INFO_SIZE 48
16768 #define MAX_PROFILE_NUM 16
16770 struct cmd_ddp_get_list_result {
16771 cmdline_fixed_string_t ddp;
16772 cmdline_fixed_string_t get;
16773 cmdline_fixed_string_t list;
16777 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16778 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16779 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16780 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16781 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16782 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16783 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16784 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16787 cmd_ddp_get_list_parsed(
16788 __attribute__((unused)) void *parsed_result,
16789 __attribute__((unused)) struct cmdline *cl,
16790 __attribute__((unused)) void *data)
16792 #ifdef RTE_LIBRTE_I40E_PMD
16793 struct cmd_ddp_get_list_result *res = parsed_result;
16794 struct rte_pmd_i40e_profile_list *p_list;
16795 struct rte_pmd_i40e_profile_info *p_info;
16800 int ret = -ENOTSUP;
16802 #ifdef RTE_LIBRTE_I40E_PMD
16803 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16804 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16806 printf("%s: Failed to malloc buffer\n", __func__);
16808 if (ret == -ENOTSUP)
16809 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16810 (uint8_t *)p_list, size);
16813 p_num = p_list->p_count;
16814 printf("Profile number is: %d\n\n", p_num);
16816 for (i = 0; i < p_num; i++) {
16817 p_info = &p_list->p_info[i];
16818 printf("Profile %d:\n", i);
16819 printf("Track id: 0x%x\n", p_info->track_id);
16820 printf("Version: %d.%d.%d.%d\n",
16821 p_info->version.major,
16822 p_info->version.minor,
16823 p_info->version.update,
16824 p_info->version.draft);
16825 printf("Profile name: %s\n\n", p_info->name);
16833 printf("Failed to get ddp list\n");
16836 cmdline_parse_inst_t cmd_ddp_get_list = {
16837 .f = cmd_ddp_get_list_parsed,
16839 .help_str = "ddp get list <port_id>",
16841 (void *)&cmd_ddp_get_list_ddp,
16842 (void *)&cmd_ddp_get_list_get,
16843 (void *)&cmd_ddp_get_list_list,
16844 (void *)&cmd_ddp_get_list_port_id,
16849 /* Configure input set */
16850 struct cmd_cfg_input_set_result {
16851 cmdline_fixed_string_t port;
16852 cmdline_fixed_string_t cfg;
16854 cmdline_fixed_string_t pctype;
16856 cmdline_fixed_string_t inset_type;
16857 cmdline_fixed_string_t opt;
16858 cmdline_fixed_string_t field;
16863 cmd_cfg_input_set_parsed(
16864 __attribute__((unused)) void *parsed_result,
16865 __attribute__((unused)) struct cmdline *cl,
16866 __attribute__((unused)) void *data)
16868 #ifdef RTE_LIBRTE_I40E_PMD
16869 struct cmd_cfg_input_set_result *res = parsed_result;
16870 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16871 struct rte_pmd_i40e_inset inset;
16873 int ret = -ENOTSUP;
16875 if (!all_ports_stopped()) {
16876 printf("Please stop all ports first\n");
16880 #ifdef RTE_LIBRTE_I40E_PMD
16881 if (!strcmp(res->inset_type, "hash_inset"))
16882 inset_type = INSET_HASH;
16883 else if (!strcmp(res->inset_type, "fdir_inset"))
16884 inset_type = INSET_FDIR;
16885 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16886 inset_type = INSET_FDIR_FLX;
16887 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16888 &inset, inset_type);
16890 printf("Failed to get input set.\n");
16894 if (!strcmp(res->opt, "get")) {
16895 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16898 printf("Field index %d is enabled.\n", res->field_idx);
16900 printf("Field index %d is disabled.\n", res->field_idx);
16902 } else if (!strcmp(res->opt, "set"))
16903 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16905 else if (!strcmp(res->opt, "clear"))
16906 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16909 printf("Failed to configure input set field.\n");
16913 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16914 &inset, inset_type);
16916 printf("Failed to set input set.\n");
16921 if (ret == -ENOTSUP)
16922 printf("Function not supported\n");
16925 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16926 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16928 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16929 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16931 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16932 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16934 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16935 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16937 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16938 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16940 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16941 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16943 "hash_inset#fdir_inset#fdir_flx_inset");
16944 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16945 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16946 opt, "get#set#clear");
16947 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16948 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16950 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16951 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16954 cmdline_parse_inst_t cmd_cfg_input_set = {
16955 .f = cmd_cfg_input_set_parsed,
16957 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16958 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16960 (void *)&cmd_cfg_input_set_port,
16961 (void *)&cmd_cfg_input_set_cfg,
16962 (void *)&cmd_cfg_input_set_port_id,
16963 (void *)&cmd_cfg_input_set_pctype,
16964 (void *)&cmd_cfg_input_set_pctype_id,
16965 (void *)&cmd_cfg_input_set_inset_type,
16966 (void *)&cmd_cfg_input_set_opt,
16967 (void *)&cmd_cfg_input_set_field,
16968 (void *)&cmd_cfg_input_set_field_idx,
16973 /* Clear input set */
16974 struct cmd_clear_input_set_result {
16975 cmdline_fixed_string_t port;
16976 cmdline_fixed_string_t cfg;
16978 cmdline_fixed_string_t pctype;
16980 cmdline_fixed_string_t inset_type;
16981 cmdline_fixed_string_t clear;
16982 cmdline_fixed_string_t all;
16986 cmd_clear_input_set_parsed(
16987 __attribute__((unused)) void *parsed_result,
16988 __attribute__((unused)) struct cmdline *cl,
16989 __attribute__((unused)) void *data)
16991 #ifdef RTE_LIBRTE_I40E_PMD
16992 struct cmd_clear_input_set_result *res = parsed_result;
16993 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16994 struct rte_pmd_i40e_inset inset;
16996 int ret = -ENOTSUP;
16998 if (!all_ports_stopped()) {
16999 printf("Please stop all ports first\n");
17003 #ifdef RTE_LIBRTE_I40E_PMD
17004 if (!strcmp(res->inset_type, "hash_inset"))
17005 inset_type = INSET_HASH;
17006 else if (!strcmp(res->inset_type, "fdir_inset"))
17007 inset_type = INSET_FDIR;
17008 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17009 inset_type = INSET_FDIR_FLX;
17011 memset(&inset, 0, sizeof(inset));
17013 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17014 &inset, inset_type);
17016 printf("Failed to clear input set.\n");
17022 if (ret == -ENOTSUP)
17023 printf("Function not supported\n");
17026 cmdline_parse_token_string_t cmd_clear_input_set_port =
17027 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17029 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17030 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17032 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17033 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17035 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17036 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17038 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17039 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17041 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17042 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17044 "hash_inset#fdir_inset#fdir_flx_inset");
17045 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17046 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17048 cmdline_parse_token_string_t cmd_clear_input_set_all =
17049 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17052 cmdline_parse_inst_t cmd_clear_input_set = {
17053 .f = cmd_clear_input_set_parsed,
17055 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17056 "fdir_inset|fdir_flx_inset clear all",
17058 (void *)&cmd_clear_input_set_port,
17059 (void *)&cmd_clear_input_set_cfg,
17060 (void *)&cmd_clear_input_set_port_id,
17061 (void *)&cmd_clear_input_set_pctype,
17062 (void *)&cmd_clear_input_set_pctype_id,
17063 (void *)&cmd_clear_input_set_inset_type,
17064 (void *)&cmd_clear_input_set_clear,
17065 (void *)&cmd_clear_input_set_all,
17070 /* show vf stats */
17072 /* Common result structure for show vf stats */
17073 struct cmd_show_vf_stats_result {
17074 cmdline_fixed_string_t show;
17075 cmdline_fixed_string_t vf;
17076 cmdline_fixed_string_t stats;
17081 /* Common CLI fields show vf stats*/
17082 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17083 TOKEN_STRING_INITIALIZER
17084 (struct cmd_show_vf_stats_result,
17086 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17087 TOKEN_STRING_INITIALIZER
17088 (struct cmd_show_vf_stats_result,
17090 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17091 TOKEN_STRING_INITIALIZER
17092 (struct cmd_show_vf_stats_result,
17094 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17095 TOKEN_NUM_INITIALIZER
17096 (struct cmd_show_vf_stats_result,
17098 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17099 TOKEN_NUM_INITIALIZER
17100 (struct cmd_show_vf_stats_result,
17104 cmd_show_vf_stats_parsed(
17105 void *parsed_result,
17106 __attribute__((unused)) struct cmdline *cl,
17107 __attribute__((unused)) void *data)
17109 struct cmd_show_vf_stats_result *res = parsed_result;
17110 struct rte_eth_stats stats;
17111 int ret = -ENOTSUP;
17112 static const char *nic_stats_border = "########################";
17114 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17117 memset(&stats, 0, sizeof(stats));
17119 #ifdef RTE_LIBRTE_I40E_PMD
17120 if (ret == -ENOTSUP)
17121 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17125 #ifdef RTE_LIBRTE_BNXT_PMD
17126 if (ret == -ENOTSUP)
17127 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17136 printf("invalid vf_id %d\n", res->vf_id);
17139 printf("invalid port_id %d\n", res->port_id);
17142 printf("function not implemented\n");
17145 printf("programming error: (%s)\n", strerror(-ret));
17148 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17149 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17151 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17153 stats.ipackets, stats.imissed, stats.ibytes);
17154 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17155 printf(" RX-nombuf: %-10"PRIu64"\n",
17157 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17159 stats.opackets, stats.oerrors, stats.obytes);
17161 printf(" %s############################%s\n",
17162 nic_stats_border, nic_stats_border);
17165 cmdline_parse_inst_t cmd_show_vf_stats = {
17166 .f = cmd_show_vf_stats_parsed,
17168 .help_str = "show vf stats <port_id> <vf_id>",
17170 (void *)&cmd_show_vf_stats_show,
17171 (void *)&cmd_show_vf_stats_vf,
17172 (void *)&cmd_show_vf_stats_stats,
17173 (void *)&cmd_show_vf_stats_port_id,
17174 (void *)&cmd_show_vf_stats_vf_id,
17179 /* clear vf stats */
17181 /* Common result structure for clear vf stats */
17182 struct cmd_clear_vf_stats_result {
17183 cmdline_fixed_string_t clear;
17184 cmdline_fixed_string_t vf;
17185 cmdline_fixed_string_t stats;
17190 /* Common CLI fields clear vf stats*/
17191 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17192 TOKEN_STRING_INITIALIZER
17193 (struct cmd_clear_vf_stats_result,
17195 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17196 TOKEN_STRING_INITIALIZER
17197 (struct cmd_clear_vf_stats_result,
17199 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17200 TOKEN_STRING_INITIALIZER
17201 (struct cmd_clear_vf_stats_result,
17203 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17204 TOKEN_NUM_INITIALIZER
17205 (struct cmd_clear_vf_stats_result,
17207 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17208 TOKEN_NUM_INITIALIZER
17209 (struct cmd_clear_vf_stats_result,
17213 cmd_clear_vf_stats_parsed(
17214 void *parsed_result,
17215 __attribute__((unused)) struct cmdline *cl,
17216 __attribute__((unused)) void *data)
17218 struct cmd_clear_vf_stats_result *res = parsed_result;
17219 int ret = -ENOTSUP;
17221 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17224 #ifdef RTE_LIBRTE_I40E_PMD
17225 if (ret == -ENOTSUP)
17226 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17229 #ifdef RTE_LIBRTE_BNXT_PMD
17230 if (ret == -ENOTSUP)
17231 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17239 printf("invalid vf_id %d\n", res->vf_id);
17242 printf("invalid port_id %d\n", res->port_id);
17245 printf("function not implemented\n");
17248 printf("programming error: (%s)\n", strerror(-ret));
17252 cmdline_parse_inst_t cmd_clear_vf_stats = {
17253 .f = cmd_clear_vf_stats_parsed,
17255 .help_str = "clear vf stats <port_id> <vf_id>",
17257 (void *)&cmd_clear_vf_stats_clear,
17258 (void *)&cmd_clear_vf_stats_vf,
17259 (void *)&cmd_clear_vf_stats_stats,
17260 (void *)&cmd_clear_vf_stats_port_id,
17261 (void *)&cmd_clear_vf_stats_vf_id,
17266 /* port config pctype mapping reset */
17268 /* Common result structure for port config pctype mapping reset */
17269 struct cmd_pctype_mapping_reset_result {
17270 cmdline_fixed_string_t port;
17271 cmdline_fixed_string_t config;
17273 cmdline_fixed_string_t pctype;
17274 cmdline_fixed_string_t mapping;
17275 cmdline_fixed_string_t reset;
17278 /* Common CLI fields for port config pctype mapping reset*/
17279 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17280 TOKEN_STRING_INITIALIZER
17281 (struct cmd_pctype_mapping_reset_result,
17283 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17284 TOKEN_STRING_INITIALIZER
17285 (struct cmd_pctype_mapping_reset_result,
17287 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17288 TOKEN_NUM_INITIALIZER
17289 (struct cmd_pctype_mapping_reset_result,
17291 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17292 TOKEN_STRING_INITIALIZER
17293 (struct cmd_pctype_mapping_reset_result,
17295 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17296 TOKEN_STRING_INITIALIZER
17297 (struct cmd_pctype_mapping_reset_result,
17298 mapping, "mapping");
17299 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17300 TOKEN_STRING_INITIALIZER
17301 (struct cmd_pctype_mapping_reset_result,
17305 cmd_pctype_mapping_reset_parsed(
17306 void *parsed_result,
17307 __attribute__((unused)) struct cmdline *cl,
17308 __attribute__((unused)) void *data)
17310 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17311 int ret = -ENOTSUP;
17313 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17316 #ifdef RTE_LIBRTE_I40E_PMD
17317 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17324 printf("invalid port_id %d\n", res->port_id);
17327 printf("function not implemented\n");
17330 printf("programming error: (%s)\n", strerror(-ret));
17334 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17335 .f = cmd_pctype_mapping_reset_parsed,
17337 .help_str = "port config <port_id> pctype mapping reset",
17339 (void *)&cmd_pctype_mapping_reset_port,
17340 (void *)&cmd_pctype_mapping_reset_config,
17341 (void *)&cmd_pctype_mapping_reset_port_id,
17342 (void *)&cmd_pctype_mapping_reset_pctype,
17343 (void *)&cmd_pctype_mapping_reset_mapping,
17344 (void *)&cmd_pctype_mapping_reset_reset,
17349 /* show port pctype mapping */
17351 /* Common result structure for show port pctype mapping */
17352 struct cmd_pctype_mapping_get_result {
17353 cmdline_fixed_string_t show;
17354 cmdline_fixed_string_t port;
17356 cmdline_fixed_string_t pctype;
17357 cmdline_fixed_string_t mapping;
17360 /* Common CLI fields for pctype mapping get */
17361 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17362 TOKEN_STRING_INITIALIZER
17363 (struct cmd_pctype_mapping_get_result,
17365 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17366 TOKEN_STRING_INITIALIZER
17367 (struct cmd_pctype_mapping_get_result,
17369 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17370 TOKEN_NUM_INITIALIZER
17371 (struct cmd_pctype_mapping_get_result,
17373 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17374 TOKEN_STRING_INITIALIZER
17375 (struct cmd_pctype_mapping_get_result,
17377 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17378 TOKEN_STRING_INITIALIZER
17379 (struct cmd_pctype_mapping_get_result,
17380 mapping, "mapping");
17383 cmd_pctype_mapping_get_parsed(
17384 void *parsed_result,
17385 __attribute__((unused)) struct cmdline *cl,
17386 __attribute__((unused)) void *data)
17388 struct cmd_pctype_mapping_get_result *res = parsed_result;
17389 int ret = -ENOTSUP;
17390 #ifdef RTE_LIBRTE_I40E_PMD
17391 struct rte_pmd_i40e_flow_type_mapping
17392 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17393 int i, j, first_pctype;
17396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17399 #ifdef RTE_LIBRTE_I40E_PMD
17400 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17407 printf("invalid port_id %d\n", res->port_id);
17410 printf("function not implemented\n");
17413 printf("programming error: (%s)\n", strerror(-ret));
17417 #ifdef RTE_LIBRTE_I40E_PMD
17418 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17419 if (mapping[i].pctype != 0ULL) {
17422 printf("pctype: ");
17423 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17424 if (mapping[i].pctype & (1ULL << j)) {
17425 printf(first_pctype ?
17426 "%02d" : ",%02d", j);
17430 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17436 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17437 .f = cmd_pctype_mapping_get_parsed,
17439 .help_str = "show port <port_id> pctype mapping",
17441 (void *)&cmd_pctype_mapping_get_show,
17442 (void *)&cmd_pctype_mapping_get_port,
17443 (void *)&cmd_pctype_mapping_get_port_id,
17444 (void *)&cmd_pctype_mapping_get_pctype,
17445 (void *)&cmd_pctype_mapping_get_mapping,
17450 /* port config pctype mapping update */
17452 /* Common result structure for port config pctype mapping update */
17453 struct cmd_pctype_mapping_update_result {
17454 cmdline_fixed_string_t port;
17455 cmdline_fixed_string_t config;
17457 cmdline_fixed_string_t pctype;
17458 cmdline_fixed_string_t mapping;
17459 cmdline_fixed_string_t update;
17460 cmdline_fixed_string_t pctype_list;
17461 uint16_t flow_type;
17464 /* Common CLI fields for pctype mapping update*/
17465 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17466 TOKEN_STRING_INITIALIZER
17467 (struct cmd_pctype_mapping_update_result,
17469 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17470 TOKEN_STRING_INITIALIZER
17471 (struct cmd_pctype_mapping_update_result,
17473 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17474 TOKEN_NUM_INITIALIZER
17475 (struct cmd_pctype_mapping_update_result,
17477 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17478 TOKEN_STRING_INITIALIZER
17479 (struct cmd_pctype_mapping_update_result,
17481 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17482 TOKEN_STRING_INITIALIZER
17483 (struct cmd_pctype_mapping_update_result,
17484 mapping, "mapping");
17485 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17486 TOKEN_STRING_INITIALIZER
17487 (struct cmd_pctype_mapping_update_result,
17489 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17490 TOKEN_STRING_INITIALIZER
17491 (struct cmd_pctype_mapping_update_result,
17492 pctype_list, NULL);
17493 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17494 TOKEN_NUM_INITIALIZER
17495 (struct cmd_pctype_mapping_update_result,
17496 flow_type, UINT16);
17499 cmd_pctype_mapping_update_parsed(
17500 void *parsed_result,
17501 __attribute__((unused)) struct cmdline *cl,
17502 __attribute__((unused)) void *data)
17504 struct cmd_pctype_mapping_update_result *res = parsed_result;
17505 int ret = -ENOTSUP;
17506 #ifdef RTE_LIBRTE_I40E_PMD
17507 struct rte_pmd_i40e_flow_type_mapping mapping;
17509 unsigned int nb_item;
17510 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17513 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17516 #ifdef RTE_LIBRTE_I40E_PMD
17517 nb_item = parse_item_list(res->pctype_list, "pctypes",
17518 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17519 mapping.flow_type = res->flow_type;
17520 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17521 mapping.pctype |= (1ULL << pctype_list[i]);
17522 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17532 printf("invalid pctype or flow type\n");
17535 printf("invalid port_id %d\n", res->port_id);
17538 printf("function not implemented\n");
17541 printf("programming error: (%s)\n", strerror(-ret));
17545 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17546 .f = cmd_pctype_mapping_update_parsed,
17548 .help_str = "port config <port_id> pctype mapping update"
17549 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17551 (void *)&cmd_pctype_mapping_update_port,
17552 (void *)&cmd_pctype_mapping_update_config,
17553 (void *)&cmd_pctype_mapping_update_port_id,
17554 (void *)&cmd_pctype_mapping_update_pctype,
17555 (void *)&cmd_pctype_mapping_update_mapping,
17556 (void *)&cmd_pctype_mapping_update_update,
17557 (void *)&cmd_pctype_mapping_update_pc_type,
17558 (void *)&cmd_pctype_mapping_update_flow_type,
17563 /* ptype mapping get */
17565 /* Common result structure for ptype mapping get */
17566 struct cmd_ptype_mapping_get_result {
17567 cmdline_fixed_string_t ptype;
17568 cmdline_fixed_string_t mapping;
17569 cmdline_fixed_string_t get;
17571 uint8_t valid_only;
17574 /* Common CLI fields for ptype mapping get */
17575 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17576 TOKEN_STRING_INITIALIZER
17577 (struct cmd_ptype_mapping_get_result,
17579 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17580 TOKEN_STRING_INITIALIZER
17581 (struct cmd_ptype_mapping_get_result,
17582 mapping, "mapping");
17583 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17584 TOKEN_STRING_INITIALIZER
17585 (struct cmd_ptype_mapping_get_result,
17587 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17588 TOKEN_NUM_INITIALIZER
17589 (struct cmd_ptype_mapping_get_result,
17591 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17592 TOKEN_NUM_INITIALIZER
17593 (struct cmd_ptype_mapping_get_result,
17594 valid_only, UINT8);
17597 cmd_ptype_mapping_get_parsed(
17598 void *parsed_result,
17599 __attribute__((unused)) struct cmdline *cl,
17600 __attribute__((unused)) void *data)
17602 struct cmd_ptype_mapping_get_result *res = parsed_result;
17603 int ret = -ENOTSUP;
17604 #ifdef RTE_LIBRTE_I40E_PMD
17605 int max_ptype_num = 256;
17606 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17611 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17614 #ifdef RTE_LIBRTE_I40E_PMD
17615 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17626 printf("invalid port_id %d\n", res->port_id);
17629 printf("function not implemented\n");
17632 printf("programming error: (%s)\n", strerror(-ret));
17635 #ifdef RTE_LIBRTE_I40E_PMD
17637 for (i = 0; i < count; i++)
17638 printf("%3d\t0x%08x\n",
17639 mapping[i].hw_ptype, mapping[i].sw_ptype);
17644 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17645 .f = cmd_ptype_mapping_get_parsed,
17647 .help_str = "ptype mapping get <port_id> <valid_only>",
17649 (void *)&cmd_ptype_mapping_get_ptype,
17650 (void *)&cmd_ptype_mapping_get_mapping,
17651 (void *)&cmd_ptype_mapping_get_get,
17652 (void *)&cmd_ptype_mapping_get_port_id,
17653 (void *)&cmd_ptype_mapping_get_valid_only,
17658 /* ptype mapping replace */
17660 /* Common result structure for ptype mapping replace */
17661 struct cmd_ptype_mapping_replace_result {
17662 cmdline_fixed_string_t ptype;
17663 cmdline_fixed_string_t mapping;
17664 cmdline_fixed_string_t replace;
17671 /* Common CLI fields for ptype mapping replace */
17672 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17673 TOKEN_STRING_INITIALIZER
17674 (struct cmd_ptype_mapping_replace_result,
17676 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17677 TOKEN_STRING_INITIALIZER
17678 (struct cmd_ptype_mapping_replace_result,
17679 mapping, "mapping");
17680 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17681 TOKEN_STRING_INITIALIZER
17682 (struct cmd_ptype_mapping_replace_result,
17683 replace, "replace");
17684 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17685 TOKEN_NUM_INITIALIZER
17686 (struct cmd_ptype_mapping_replace_result,
17688 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17689 TOKEN_NUM_INITIALIZER
17690 (struct cmd_ptype_mapping_replace_result,
17692 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17693 TOKEN_NUM_INITIALIZER
17694 (struct cmd_ptype_mapping_replace_result,
17696 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17697 TOKEN_NUM_INITIALIZER
17698 (struct cmd_ptype_mapping_replace_result,
17702 cmd_ptype_mapping_replace_parsed(
17703 void *parsed_result,
17704 __attribute__((unused)) struct cmdline *cl,
17705 __attribute__((unused)) void *data)
17707 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17708 int ret = -ENOTSUP;
17710 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17713 #ifdef RTE_LIBRTE_I40E_PMD
17714 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17724 printf("invalid ptype 0x%8x or 0x%8x\n",
17725 res->target, res->pkt_type);
17728 printf("invalid port_id %d\n", res->port_id);
17731 printf("function not implemented\n");
17734 printf("programming error: (%s)\n", strerror(-ret));
17738 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17739 .f = cmd_ptype_mapping_replace_parsed,
17742 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17744 (void *)&cmd_ptype_mapping_replace_ptype,
17745 (void *)&cmd_ptype_mapping_replace_mapping,
17746 (void *)&cmd_ptype_mapping_replace_replace,
17747 (void *)&cmd_ptype_mapping_replace_port_id,
17748 (void *)&cmd_ptype_mapping_replace_target,
17749 (void *)&cmd_ptype_mapping_replace_mask,
17750 (void *)&cmd_ptype_mapping_replace_pkt_type,
17755 /* ptype mapping reset */
17757 /* Common result structure for ptype mapping reset */
17758 struct cmd_ptype_mapping_reset_result {
17759 cmdline_fixed_string_t ptype;
17760 cmdline_fixed_string_t mapping;
17761 cmdline_fixed_string_t reset;
17765 /* Common CLI fields for ptype mapping reset*/
17766 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17767 TOKEN_STRING_INITIALIZER
17768 (struct cmd_ptype_mapping_reset_result,
17770 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17771 TOKEN_STRING_INITIALIZER
17772 (struct cmd_ptype_mapping_reset_result,
17773 mapping, "mapping");
17774 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17775 TOKEN_STRING_INITIALIZER
17776 (struct cmd_ptype_mapping_reset_result,
17778 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17779 TOKEN_NUM_INITIALIZER
17780 (struct cmd_ptype_mapping_reset_result,
17784 cmd_ptype_mapping_reset_parsed(
17785 void *parsed_result,
17786 __attribute__((unused)) struct cmdline *cl,
17787 __attribute__((unused)) void *data)
17789 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17790 int ret = -ENOTSUP;
17792 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17795 #ifdef RTE_LIBRTE_I40E_PMD
17796 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17803 printf("invalid port_id %d\n", res->port_id);
17806 printf("function not implemented\n");
17809 printf("programming error: (%s)\n", strerror(-ret));
17813 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17814 .f = cmd_ptype_mapping_reset_parsed,
17816 .help_str = "ptype mapping reset <port_id>",
17818 (void *)&cmd_ptype_mapping_reset_ptype,
17819 (void *)&cmd_ptype_mapping_reset_mapping,
17820 (void *)&cmd_ptype_mapping_reset_reset,
17821 (void *)&cmd_ptype_mapping_reset_port_id,
17826 /* ptype mapping update */
17828 /* Common result structure for ptype mapping update */
17829 struct cmd_ptype_mapping_update_result {
17830 cmdline_fixed_string_t ptype;
17831 cmdline_fixed_string_t mapping;
17832 cmdline_fixed_string_t reset;
17838 /* Common CLI fields for ptype mapping update*/
17839 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17840 TOKEN_STRING_INITIALIZER
17841 (struct cmd_ptype_mapping_update_result,
17843 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17844 TOKEN_STRING_INITIALIZER
17845 (struct cmd_ptype_mapping_update_result,
17846 mapping, "mapping");
17847 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17848 TOKEN_STRING_INITIALIZER
17849 (struct cmd_ptype_mapping_update_result,
17851 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17852 TOKEN_NUM_INITIALIZER
17853 (struct cmd_ptype_mapping_update_result,
17855 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17856 TOKEN_NUM_INITIALIZER
17857 (struct cmd_ptype_mapping_update_result,
17859 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17860 TOKEN_NUM_INITIALIZER
17861 (struct cmd_ptype_mapping_update_result,
17865 cmd_ptype_mapping_update_parsed(
17866 void *parsed_result,
17867 __attribute__((unused)) struct cmdline *cl,
17868 __attribute__((unused)) void *data)
17870 struct cmd_ptype_mapping_update_result *res = parsed_result;
17871 int ret = -ENOTSUP;
17872 #ifdef RTE_LIBRTE_I40E_PMD
17873 struct rte_pmd_i40e_ptype_mapping mapping;
17875 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17878 #ifdef RTE_LIBRTE_I40E_PMD
17879 mapping.hw_ptype = res->hw_ptype;
17880 mapping.sw_ptype = res->sw_ptype;
17881 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17891 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17894 printf("invalid port_id %d\n", res->port_id);
17897 printf("function not implemented\n");
17900 printf("programming error: (%s)\n", strerror(-ret));
17904 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17905 .f = cmd_ptype_mapping_update_parsed,
17907 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17909 (void *)&cmd_ptype_mapping_update_ptype,
17910 (void *)&cmd_ptype_mapping_update_mapping,
17911 (void *)&cmd_ptype_mapping_update_update,
17912 (void *)&cmd_ptype_mapping_update_port_id,
17913 (void *)&cmd_ptype_mapping_update_hw_ptype,
17914 (void *)&cmd_ptype_mapping_update_sw_ptype,
17919 /* Common result structure for file commands */
17920 struct cmd_cmdfile_result {
17921 cmdline_fixed_string_t load;
17922 cmdline_fixed_string_t filename;
17925 /* Common CLI fields for file commands */
17926 cmdline_parse_token_string_t cmd_load_cmdfile =
17927 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17928 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17929 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17932 cmd_load_from_file_parsed(
17933 void *parsed_result,
17934 __attribute__((unused)) struct cmdline *cl,
17935 __attribute__((unused)) void *data)
17937 struct cmd_cmdfile_result *res = parsed_result;
17939 cmdline_read_from_file(res->filename);
17942 cmdline_parse_inst_t cmd_load_from_file = {
17943 .f = cmd_load_from_file_parsed,
17945 .help_str = "load <filename>",
17947 (void *)&cmd_load_cmdfile,
17948 (void *)&cmd_load_cmdfile_filename,
17953 /* Get Rx offloads capabilities */
17954 struct cmd_rx_offload_get_capa_result {
17955 cmdline_fixed_string_t show;
17956 cmdline_fixed_string_t port;
17958 cmdline_fixed_string_t rx_offload;
17959 cmdline_fixed_string_t capabilities;
17962 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17963 TOKEN_STRING_INITIALIZER
17964 (struct cmd_rx_offload_get_capa_result,
17966 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17967 TOKEN_STRING_INITIALIZER
17968 (struct cmd_rx_offload_get_capa_result,
17970 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17971 TOKEN_NUM_INITIALIZER
17972 (struct cmd_rx_offload_get_capa_result,
17974 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17975 TOKEN_STRING_INITIALIZER
17976 (struct cmd_rx_offload_get_capa_result,
17977 rx_offload, "rx_offload");
17978 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17979 TOKEN_STRING_INITIALIZER
17980 (struct cmd_rx_offload_get_capa_result,
17981 capabilities, "capabilities");
17984 print_rx_offloads(uint64_t offloads)
17986 uint64_t single_offload;
17994 begin = __builtin_ctzll(offloads);
17995 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17997 single_offload = 1ULL << begin;
17998 for (bit = begin; bit < end; bit++) {
17999 if (offloads & single_offload)
18001 rte_eth_dev_rx_offload_name(single_offload));
18002 single_offload <<= 1;
18007 cmd_rx_offload_get_capa_parsed(
18008 void *parsed_result,
18009 __attribute__((unused)) struct cmdline *cl,
18010 __attribute__((unused)) void *data)
18012 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18013 struct rte_eth_dev_info dev_info;
18014 portid_t port_id = res->port_id;
18015 uint64_t queue_offloads;
18016 uint64_t port_offloads;
18019 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18023 queue_offloads = dev_info.rx_queue_offload_capa;
18024 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18026 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18027 printf(" Per Queue :");
18028 print_rx_offloads(queue_offloads);
18031 printf(" Per Port :");
18032 print_rx_offloads(port_offloads);
18036 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18037 .f = cmd_rx_offload_get_capa_parsed,
18039 .help_str = "show port <port_id> rx_offload capabilities",
18041 (void *)&cmd_rx_offload_get_capa_show,
18042 (void *)&cmd_rx_offload_get_capa_port,
18043 (void *)&cmd_rx_offload_get_capa_port_id,
18044 (void *)&cmd_rx_offload_get_capa_rx_offload,
18045 (void *)&cmd_rx_offload_get_capa_capabilities,
18050 /* Get Rx offloads configuration */
18051 struct cmd_rx_offload_get_configuration_result {
18052 cmdline_fixed_string_t show;
18053 cmdline_fixed_string_t port;
18055 cmdline_fixed_string_t rx_offload;
18056 cmdline_fixed_string_t configuration;
18059 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18060 TOKEN_STRING_INITIALIZER
18061 (struct cmd_rx_offload_get_configuration_result,
18063 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18064 TOKEN_STRING_INITIALIZER
18065 (struct cmd_rx_offload_get_configuration_result,
18067 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18068 TOKEN_NUM_INITIALIZER
18069 (struct cmd_rx_offload_get_configuration_result,
18071 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18072 TOKEN_STRING_INITIALIZER
18073 (struct cmd_rx_offload_get_configuration_result,
18074 rx_offload, "rx_offload");
18075 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18076 TOKEN_STRING_INITIALIZER
18077 (struct cmd_rx_offload_get_configuration_result,
18078 configuration, "configuration");
18081 cmd_rx_offload_get_configuration_parsed(
18082 void *parsed_result,
18083 __attribute__((unused)) struct cmdline *cl,
18084 __attribute__((unused)) void *data)
18086 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18087 struct rte_eth_dev_info dev_info;
18088 portid_t port_id = res->port_id;
18089 struct rte_port *port = &ports[port_id];
18090 uint64_t port_offloads;
18091 uint64_t queue_offloads;
18092 uint16_t nb_rx_queues;
18096 printf("Rx Offloading Configuration of port %d :\n", port_id);
18098 port_offloads = port->dev_conf.rxmode.offloads;
18100 print_rx_offloads(port_offloads);
18103 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18107 nb_rx_queues = dev_info.nb_rx_queues;
18108 for (q = 0; q < nb_rx_queues; q++) {
18109 queue_offloads = port->rx_conf[q].offloads;
18110 printf(" Queue[%2d] :", q);
18111 print_rx_offloads(queue_offloads);
18117 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18118 .f = cmd_rx_offload_get_configuration_parsed,
18120 .help_str = "show port <port_id> rx_offload configuration",
18122 (void *)&cmd_rx_offload_get_configuration_show,
18123 (void *)&cmd_rx_offload_get_configuration_port,
18124 (void *)&cmd_rx_offload_get_configuration_port_id,
18125 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18126 (void *)&cmd_rx_offload_get_configuration_configuration,
18131 /* Enable/Disable a per port offloading */
18132 struct cmd_config_per_port_rx_offload_result {
18133 cmdline_fixed_string_t port;
18134 cmdline_fixed_string_t config;
18136 cmdline_fixed_string_t rx_offload;
18137 cmdline_fixed_string_t offload;
18138 cmdline_fixed_string_t on_off;
18141 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18142 TOKEN_STRING_INITIALIZER
18143 (struct cmd_config_per_port_rx_offload_result,
18145 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18146 TOKEN_STRING_INITIALIZER
18147 (struct cmd_config_per_port_rx_offload_result,
18149 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18150 TOKEN_NUM_INITIALIZER
18151 (struct cmd_config_per_port_rx_offload_result,
18153 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18154 TOKEN_STRING_INITIALIZER
18155 (struct cmd_config_per_port_rx_offload_result,
18156 rx_offload, "rx_offload");
18157 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18158 TOKEN_STRING_INITIALIZER
18159 (struct cmd_config_per_port_rx_offload_result,
18160 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18161 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18162 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18163 "scatter#timestamp#security#keep_crc#rss_hash");
18164 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18165 TOKEN_STRING_INITIALIZER
18166 (struct cmd_config_per_port_rx_offload_result,
18170 search_rx_offload(const char *name)
18172 uint64_t single_offload;
18173 const char *single_name;
18177 single_offload = 1;
18178 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18179 single_name = rte_eth_dev_rx_offload_name(single_offload);
18180 if (!strcasecmp(single_name, name)) {
18184 single_offload <<= 1;
18188 return single_offload;
18194 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18195 __attribute__((unused)) struct cmdline *cl,
18196 __attribute__((unused)) void *data)
18198 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18199 portid_t port_id = res->port_id;
18200 struct rte_eth_dev_info dev_info;
18201 struct rte_port *port = &ports[port_id];
18202 uint64_t single_offload;
18203 uint16_t nb_rx_queues;
18207 if (port->port_status != RTE_PORT_STOPPED) {
18208 printf("Error: Can't config offload when Port %d "
18209 "is not stopped\n", port_id);
18213 single_offload = search_rx_offload(res->offload);
18214 if (single_offload == 0) {
18215 printf("Unknown offload name: %s\n", res->offload);
18219 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18223 nb_rx_queues = dev_info.nb_rx_queues;
18224 if (!strcmp(res->on_off, "on")) {
18225 port->dev_conf.rxmode.offloads |= single_offload;
18226 for (q = 0; q < nb_rx_queues; q++)
18227 port->rx_conf[q].offloads |= single_offload;
18229 port->dev_conf.rxmode.offloads &= ~single_offload;
18230 for (q = 0; q < nb_rx_queues; q++)
18231 port->rx_conf[q].offloads &= ~single_offload;
18234 cmd_reconfig_device_queue(port_id, 1, 1);
18237 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18238 .f = cmd_config_per_port_rx_offload_parsed,
18240 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18241 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18242 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18243 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18246 (void *)&cmd_config_per_port_rx_offload_result_port,
18247 (void *)&cmd_config_per_port_rx_offload_result_config,
18248 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18249 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18250 (void *)&cmd_config_per_port_rx_offload_result_offload,
18251 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18256 /* Enable/Disable a per queue offloading */
18257 struct cmd_config_per_queue_rx_offload_result {
18258 cmdline_fixed_string_t port;
18260 cmdline_fixed_string_t rxq;
18262 cmdline_fixed_string_t rx_offload;
18263 cmdline_fixed_string_t offload;
18264 cmdline_fixed_string_t on_off;
18267 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18268 TOKEN_STRING_INITIALIZER
18269 (struct cmd_config_per_queue_rx_offload_result,
18271 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18272 TOKEN_NUM_INITIALIZER
18273 (struct cmd_config_per_queue_rx_offload_result,
18275 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
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_queue_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_rxoffload =
18284 TOKEN_STRING_INITIALIZER
18285 (struct cmd_config_per_queue_rx_offload_result,
18286 rx_offload, "rx_offload");
18287 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18288 TOKEN_STRING_INITIALIZER
18289 (struct cmd_config_per_queue_rx_offload_result,
18290 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18291 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18292 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18293 "scatter#timestamp#security#keep_crc");
18294 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18295 TOKEN_STRING_INITIALIZER
18296 (struct cmd_config_per_queue_rx_offload_result,
18300 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18301 __attribute__((unused)) struct cmdline *cl,
18302 __attribute__((unused)) void *data)
18304 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18305 struct rte_eth_dev_info dev_info;
18306 portid_t port_id = res->port_id;
18307 uint16_t queue_id = res->queue_id;
18308 struct rte_port *port = &ports[port_id];
18309 uint64_t single_offload;
18312 if (port->port_status != RTE_PORT_STOPPED) {
18313 printf("Error: Can't config offload when Port %d "
18314 "is not stopped\n", port_id);
18318 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18322 if (queue_id >= dev_info.nb_rx_queues) {
18323 printf("Error: input queue_id should be 0 ... "
18324 "%d\n", dev_info.nb_rx_queues - 1);
18328 single_offload = search_rx_offload(res->offload);
18329 if (single_offload == 0) {
18330 printf("Unknown offload name: %s\n", res->offload);
18334 if (!strcmp(res->on_off, "on"))
18335 port->rx_conf[queue_id].offloads |= single_offload;
18337 port->rx_conf[queue_id].offloads &= ~single_offload;
18339 cmd_reconfig_device_queue(port_id, 1, 1);
18342 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18343 .f = cmd_config_per_queue_rx_offload_parsed,
18345 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18346 "vlan_strip|ipv4_cksum|"
18347 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18348 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18349 "jumbo_frame|scatter|timestamp|security|keep_crc "
18352 (void *)&cmd_config_per_queue_rx_offload_result_port,
18353 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18354 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18355 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18356 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18357 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18358 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18363 /* Get Tx offloads capabilities */
18364 struct cmd_tx_offload_get_capa_result {
18365 cmdline_fixed_string_t show;
18366 cmdline_fixed_string_t port;
18368 cmdline_fixed_string_t tx_offload;
18369 cmdline_fixed_string_t capabilities;
18372 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18373 TOKEN_STRING_INITIALIZER
18374 (struct cmd_tx_offload_get_capa_result,
18376 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18377 TOKEN_STRING_INITIALIZER
18378 (struct cmd_tx_offload_get_capa_result,
18380 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18381 TOKEN_NUM_INITIALIZER
18382 (struct cmd_tx_offload_get_capa_result,
18384 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18385 TOKEN_STRING_INITIALIZER
18386 (struct cmd_tx_offload_get_capa_result,
18387 tx_offload, "tx_offload");
18388 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18389 TOKEN_STRING_INITIALIZER
18390 (struct cmd_tx_offload_get_capa_result,
18391 capabilities, "capabilities");
18394 print_tx_offloads(uint64_t offloads)
18396 uint64_t single_offload;
18404 begin = __builtin_ctzll(offloads);
18405 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18407 single_offload = 1ULL << begin;
18408 for (bit = begin; bit < end; bit++) {
18409 if (offloads & single_offload)
18411 rte_eth_dev_tx_offload_name(single_offload));
18412 single_offload <<= 1;
18417 cmd_tx_offload_get_capa_parsed(
18418 void *parsed_result,
18419 __attribute__((unused)) struct cmdline *cl,
18420 __attribute__((unused)) void *data)
18422 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18423 struct rte_eth_dev_info dev_info;
18424 portid_t port_id = res->port_id;
18425 uint64_t queue_offloads;
18426 uint64_t port_offloads;
18429 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18433 queue_offloads = dev_info.tx_queue_offload_capa;
18434 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18436 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18437 printf(" Per Queue :");
18438 print_tx_offloads(queue_offloads);
18441 printf(" Per Port :");
18442 print_tx_offloads(port_offloads);
18446 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18447 .f = cmd_tx_offload_get_capa_parsed,
18449 .help_str = "show port <port_id> tx_offload capabilities",
18451 (void *)&cmd_tx_offload_get_capa_show,
18452 (void *)&cmd_tx_offload_get_capa_port,
18453 (void *)&cmd_tx_offload_get_capa_port_id,
18454 (void *)&cmd_tx_offload_get_capa_tx_offload,
18455 (void *)&cmd_tx_offload_get_capa_capabilities,
18460 /* Get Tx offloads configuration */
18461 struct cmd_tx_offload_get_configuration_result {
18462 cmdline_fixed_string_t show;
18463 cmdline_fixed_string_t port;
18465 cmdline_fixed_string_t tx_offload;
18466 cmdline_fixed_string_t configuration;
18469 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18470 TOKEN_STRING_INITIALIZER
18471 (struct cmd_tx_offload_get_configuration_result,
18473 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18474 TOKEN_STRING_INITIALIZER
18475 (struct cmd_tx_offload_get_configuration_result,
18477 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18478 TOKEN_NUM_INITIALIZER
18479 (struct cmd_tx_offload_get_configuration_result,
18481 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18482 TOKEN_STRING_INITIALIZER
18483 (struct cmd_tx_offload_get_configuration_result,
18484 tx_offload, "tx_offload");
18485 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18486 TOKEN_STRING_INITIALIZER
18487 (struct cmd_tx_offload_get_configuration_result,
18488 configuration, "configuration");
18491 cmd_tx_offload_get_configuration_parsed(
18492 void *parsed_result,
18493 __attribute__((unused)) struct cmdline *cl,
18494 __attribute__((unused)) void *data)
18496 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18497 struct rte_eth_dev_info dev_info;
18498 portid_t port_id = res->port_id;
18499 struct rte_port *port = &ports[port_id];
18500 uint64_t port_offloads;
18501 uint64_t queue_offloads;
18502 uint16_t nb_tx_queues;
18506 printf("Tx Offloading Configuration of port %d :\n", port_id);
18508 port_offloads = port->dev_conf.txmode.offloads;
18510 print_tx_offloads(port_offloads);
18513 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18517 nb_tx_queues = dev_info.nb_tx_queues;
18518 for (q = 0; q < nb_tx_queues; q++) {
18519 queue_offloads = port->tx_conf[q].offloads;
18520 printf(" Queue[%2d] :", q);
18521 print_tx_offloads(queue_offloads);
18527 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18528 .f = cmd_tx_offload_get_configuration_parsed,
18530 .help_str = "show port <port_id> tx_offload configuration",
18532 (void *)&cmd_tx_offload_get_configuration_show,
18533 (void *)&cmd_tx_offload_get_configuration_port,
18534 (void *)&cmd_tx_offload_get_configuration_port_id,
18535 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18536 (void *)&cmd_tx_offload_get_configuration_configuration,
18541 /* Enable/Disable a per port offloading */
18542 struct cmd_config_per_port_tx_offload_result {
18543 cmdline_fixed_string_t port;
18544 cmdline_fixed_string_t config;
18546 cmdline_fixed_string_t tx_offload;
18547 cmdline_fixed_string_t offload;
18548 cmdline_fixed_string_t on_off;
18551 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18552 TOKEN_STRING_INITIALIZER
18553 (struct cmd_config_per_port_tx_offload_result,
18555 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18556 TOKEN_STRING_INITIALIZER
18557 (struct cmd_config_per_port_tx_offload_result,
18559 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18560 TOKEN_NUM_INITIALIZER
18561 (struct cmd_config_per_port_tx_offload_result,
18563 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18564 TOKEN_STRING_INITIALIZER
18565 (struct cmd_config_per_port_tx_offload_result,
18566 tx_offload, "tx_offload");
18567 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18568 TOKEN_STRING_INITIALIZER
18569 (struct cmd_config_per_port_tx_offload_result,
18570 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18571 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18572 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18573 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18574 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18575 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18576 TOKEN_STRING_INITIALIZER
18577 (struct cmd_config_per_port_tx_offload_result,
18581 search_tx_offload(const char *name)
18583 uint64_t single_offload;
18584 const char *single_name;
18588 single_offload = 1;
18589 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18590 single_name = rte_eth_dev_tx_offload_name(single_offload);
18591 if (single_name == NULL)
18593 if (!strcasecmp(single_name, name)) {
18596 } else if (!strcasecmp(single_name, "UNKNOWN"))
18598 single_offload <<= 1;
18602 return single_offload;
18608 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18609 __attribute__((unused)) struct cmdline *cl,
18610 __attribute__((unused)) void *data)
18612 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18613 portid_t port_id = res->port_id;
18614 struct rte_eth_dev_info dev_info;
18615 struct rte_port *port = &ports[port_id];
18616 uint64_t single_offload;
18617 uint16_t nb_tx_queues;
18621 if (port->port_status != RTE_PORT_STOPPED) {
18622 printf("Error: Can't config offload when Port %d "
18623 "is not stopped\n", port_id);
18627 single_offload = search_tx_offload(res->offload);
18628 if (single_offload == 0) {
18629 printf("Unknown offload name: %s\n", res->offload);
18633 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18637 nb_tx_queues = dev_info.nb_tx_queues;
18638 if (!strcmp(res->on_off, "on")) {
18639 port->dev_conf.txmode.offloads |= single_offload;
18640 for (q = 0; q < nb_tx_queues; q++)
18641 port->tx_conf[q].offloads |= single_offload;
18643 port->dev_conf.txmode.offloads &= ~single_offload;
18644 for (q = 0; q < nb_tx_queues; q++)
18645 port->tx_conf[q].offloads &= ~single_offload;
18648 cmd_reconfig_device_queue(port_id, 1, 1);
18651 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18652 .f = cmd_config_per_port_tx_offload_parsed,
18654 .help_str = "port config <port_id> tx_offload "
18655 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18656 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18657 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18658 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18659 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18661 (void *)&cmd_config_per_port_tx_offload_result_port,
18662 (void *)&cmd_config_per_port_tx_offload_result_config,
18663 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18664 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18665 (void *)&cmd_config_per_port_tx_offload_result_offload,
18666 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18671 /* Enable/Disable a per queue offloading */
18672 struct cmd_config_per_queue_tx_offload_result {
18673 cmdline_fixed_string_t port;
18675 cmdline_fixed_string_t txq;
18677 cmdline_fixed_string_t tx_offload;
18678 cmdline_fixed_string_t offload;
18679 cmdline_fixed_string_t on_off;
18682 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18683 TOKEN_STRING_INITIALIZER
18684 (struct cmd_config_per_queue_tx_offload_result,
18686 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18687 TOKEN_NUM_INITIALIZER
18688 (struct cmd_config_per_queue_tx_offload_result,
18690 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
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_queue_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_txoffload =
18699 TOKEN_STRING_INITIALIZER
18700 (struct cmd_config_per_queue_tx_offload_result,
18701 tx_offload, "tx_offload");
18702 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18703 TOKEN_STRING_INITIALIZER
18704 (struct cmd_config_per_queue_tx_offload_result,
18705 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18706 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18707 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18708 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18709 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18710 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18711 TOKEN_STRING_INITIALIZER
18712 (struct cmd_config_per_queue_tx_offload_result,
18716 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18717 __attribute__((unused)) struct cmdline *cl,
18718 __attribute__((unused)) void *data)
18720 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18721 struct rte_eth_dev_info dev_info;
18722 portid_t port_id = res->port_id;
18723 uint16_t queue_id = res->queue_id;
18724 struct rte_port *port = &ports[port_id];
18725 uint64_t single_offload;
18728 if (port->port_status != RTE_PORT_STOPPED) {
18729 printf("Error: Can't config offload when Port %d "
18730 "is not stopped\n", port_id);
18734 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18738 if (queue_id >= dev_info.nb_tx_queues) {
18739 printf("Error: input queue_id should be 0 ... "
18740 "%d\n", dev_info.nb_tx_queues - 1);
18744 single_offload = search_tx_offload(res->offload);
18745 if (single_offload == 0) {
18746 printf("Unknown offload name: %s\n", res->offload);
18750 if (!strcmp(res->on_off, "on"))
18751 port->tx_conf[queue_id].offloads |= single_offload;
18753 port->tx_conf[queue_id].offloads &= ~single_offload;
18755 cmd_reconfig_device_queue(port_id, 1, 1);
18758 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18759 .f = cmd_config_per_queue_tx_offload_parsed,
18761 .help_str = "port <port_id> txq <queue_id> tx_offload "
18762 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18763 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18764 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18765 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18766 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18769 (void *)&cmd_config_per_queue_tx_offload_result_port,
18770 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18771 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18772 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18773 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18774 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18775 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18780 /* *** configure tx_metadata for specific port *** */
18781 struct cmd_config_tx_metadata_specific_result {
18782 cmdline_fixed_string_t port;
18783 cmdline_fixed_string_t keyword;
18785 cmdline_fixed_string_t item;
18790 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18791 __attribute__((unused)) struct cmdline *cl,
18792 __attribute__((unused)) void *data)
18794 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18796 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18798 ports[res->port_id].tx_metadata = res->value;
18799 /* Add/remove callback to insert valid metadata in every Tx packet. */
18800 if (ports[res->port_id].tx_metadata)
18801 add_tx_md_callback(res->port_id);
18803 remove_tx_md_callback(res->port_id);
18804 rte_flow_dynf_metadata_register();
18807 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18808 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18810 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18811 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18812 keyword, "config");
18813 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18814 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18816 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18817 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18818 item, "tx_metadata");
18819 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18820 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18823 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18824 .f = cmd_config_tx_metadata_specific_parsed,
18826 .help_str = "port config <port_id> tx_metadata <value>",
18828 (void *)&cmd_config_tx_metadata_specific_port,
18829 (void *)&cmd_config_tx_metadata_specific_keyword,
18830 (void *)&cmd_config_tx_metadata_specific_id,
18831 (void *)&cmd_config_tx_metadata_specific_item,
18832 (void *)&cmd_config_tx_metadata_specific_value,
18837 /* *** display tx_metadata per port configuration *** */
18838 struct cmd_show_tx_metadata_result {
18839 cmdline_fixed_string_t cmd_show;
18840 cmdline_fixed_string_t cmd_port;
18841 cmdline_fixed_string_t cmd_keyword;
18846 cmd_show_tx_metadata_parsed(void *parsed_result,
18847 __attribute__((unused)) struct cmdline *cl,
18848 __attribute__((unused)) void *data)
18850 struct cmd_show_tx_metadata_result *res = parsed_result;
18852 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18853 printf("invalid port id %u\n", res->cmd_pid);
18856 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18857 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18858 ports[res->cmd_pid].tx_metadata);
18862 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18863 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18865 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18866 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18868 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18869 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18871 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18872 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18873 cmd_keyword, "tx_metadata");
18875 cmdline_parse_inst_t cmd_show_tx_metadata = {
18876 .f = cmd_show_tx_metadata_parsed,
18878 .help_str = "show port <port_id> tx_metadata",
18880 (void *)&cmd_show_tx_metadata_show,
18881 (void *)&cmd_show_tx_metadata_port,
18882 (void *)&cmd_show_tx_metadata_pid,
18883 (void *)&cmd_show_tx_metadata_keyword,
18888 /* show port supported ptypes */
18890 /* Common result structure for show port ptypes */
18891 struct cmd_show_port_supported_ptypes_result {
18892 cmdline_fixed_string_t show;
18893 cmdline_fixed_string_t port;
18895 cmdline_fixed_string_t ptypes;
18898 /* Common CLI fields for show port ptypes */
18899 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18900 TOKEN_STRING_INITIALIZER
18901 (struct cmd_show_port_supported_ptypes_result,
18903 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18904 TOKEN_STRING_INITIALIZER
18905 (struct cmd_show_port_supported_ptypes_result,
18907 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18908 TOKEN_NUM_INITIALIZER
18909 (struct cmd_show_port_supported_ptypes_result,
18911 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18912 TOKEN_STRING_INITIALIZER
18913 (struct cmd_show_port_supported_ptypes_result,
18917 cmd_show_port_supported_ptypes_parsed(
18918 void *parsed_result,
18919 __attribute__((unused)) struct cmdline *cl,
18920 __attribute__((unused)) void *data)
18922 #define RSVD_PTYPE_MASK 0xf0000000
18923 #define MAX_PTYPES_PER_LAYER 16
18924 #define LTYPE_NAMESIZE 32
18925 #define PTYPE_NAMESIZE 256
18926 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18927 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18928 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18929 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18930 uint16_t port_id = res->port_id;
18933 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18937 while (ptype_mask != RSVD_PTYPE_MASK) {
18939 switch (ptype_mask) {
18940 case RTE_PTYPE_L2_MASK:
18941 strlcpy(ltype, "L2", sizeof(ltype));
18943 case RTE_PTYPE_L3_MASK:
18944 strlcpy(ltype, "L3", sizeof(ltype));
18946 case RTE_PTYPE_L4_MASK:
18947 strlcpy(ltype, "L4", sizeof(ltype));
18949 case RTE_PTYPE_TUNNEL_MASK:
18950 strlcpy(ltype, "Tunnel", sizeof(ltype));
18952 case RTE_PTYPE_INNER_L2_MASK:
18953 strlcpy(ltype, "Inner L2", sizeof(ltype));
18955 case RTE_PTYPE_INNER_L3_MASK:
18956 strlcpy(ltype, "Inner L3", sizeof(ltype));
18958 case RTE_PTYPE_INNER_L4_MASK:
18959 strlcpy(ltype, "Inner L4", sizeof(ltype));
18965 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18966 ptype_mask, ptypes,
18967 MAX_PTYPES_PER_LAYER);
18970 printf("Supported %s ptypes:\n", ltype);
18972 printf("%s ptypes unsupported\n", ltype);
18974 for (i = 0; i < ret; ++i) {
18975 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18976 printf("%s\n", buf);
18983 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18984 .f = cmd_show_port_supported_ptypes_parsed,
18986 .help_str = "show port <port_id> ptypes",
18988 (void *)&cmd_show_port_supported_ptypes_show,
18989 (void *)&cmd_show_port_supported_ptypes_port,
18990 (void *)&cmd_show_port_supported_ptypes_port_id,
18991 (void *)&cmd_show_port_supported_ptypes_ptypes,
18996 /* *** display rx/tx descriptor status *** */
18997 struct cmd_show_rx_tx_desc_status_result {
18998 cmdline_fixed_string_t cmd_show;
18999 cmdline_fixed_string_t cmd_port;
19000 cmdline_fixed_string_t cmd_keyword;
19001 cmdline_fixed_string_t cmd_desc;
19002 cmdline_fixed_string_t cmd_status;
19009 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19010 __attribute__((unused)) struct cmdline *cl,
19011 __attribute__((unused)) void *data)
19013 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19016 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19017 printf("invalid port id %u\n", res->cmd_pid);
19021 if (!strcmp(res->cmd_keyword, "rxq")) {
19022 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19025 printf("Invalid queueid = %d\n", res->cmd_qid);
19028 if (rc == RTE_ETH_RX_DESC_AVAIL)
19029 printf("Desc status = AVAILABLE\n");
19030 else if (rc == RTE_ETH_RX_DESC_DONE)
19031 printf("Desc status = DONE\n");
19033 printf("Desc status = UNAVAILABLE\n");
19034 } else if (!strcmp(res->cmd_keyword, "txq")) {
19035 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19038 printf("Invalid queueid = %d\n", res->cmd_qid);
19041 if (rc == RTE_ETH_TX_DESC_FULL)
19042 printf("Desc status = FULL\n");
19043 else if (rc == RTE_ETH_TX_DESC_DONE)
19044 printf("Desc status = DONE\n");
19046 printf("Desc status = UNAVAILABLE\n");
19050 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19051 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19053 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19054 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19056 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19057 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19059 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19060 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19061 cmd_keyword, "rxq#txq");
19062 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19063 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19065 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19066 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19068 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19069 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19071 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19072 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19073 cmd_status, "status");
19074 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19075 .f = cmd_show_rx_tx_desc_status_parsed,
19077 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19080 (void *)&cmd_show_rx_tx_desc_status_show,
19081 (void *)&cmd_show_rx_tx_desc_status_port,
19082 (void *)&cmd_show_rx_tx_desc_status_pid,
19083 (void *)&cmd_show_rx_tx_desc_status_keyword,
19084 (void *)&cmd_show_rx_tx_desc_status_qid,
19085 (void *)&cmd_show_rx_tx_desc_status_desc,
19086 (void *)&cmd_show_rx_tx_desc_status_did,
19087 (void *)&cmd_show_rx_tx_desc_status_status,
19092 /* Common result structure for set port ptypes */
19093 struct cmd_set_port_ptypes_result {
19094 cmdline_fixed_string_t set;
19095 cmdline_fixed_string_t port;
19097 cmdline_fixed_string_t ptype_mask;
19101 /* Common CLI fields for set port ptypes */
19102 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19103 TOKEN_STRING_INITIALIZER
19104 (struct cmd_set_port_ptypes_result,
19106 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19107 TOKEN_STRING_INITIALIZER
19108 (struct cmd_set_port_ptypes_result,
19110 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19111 TOKEN_NUM_INITIALIZER
19112 (struct cmd_set_port_ptypes_result,
19114 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19115 TOKEN_STRING_INITIALIZER
19116 (struct cmd_set_port_ptypes_result,
19117 ptype_mask, "ptype_mask");
19118 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19119 TOKEN_NUM_INITIALIZER
19120 (struct cmd_set_port_ptypes_result,
19124 cmd_set_port_ptypes_parsed(
19125 void *parsed_result,
19126 __attribute__((unused)) struct cmdline *cl,
19127 __attribute__((unused)) void *data)
19129 struct cmd_set_port_ptypes_result *res = parsed_result;
19130 #define PTYPE_NAMESIZE 256
19131 char ptype_name[PTYPE_NAMESIZE];
19132 uint16_t port_id = res->port_id;
19133 uint32_t ptype_mask = res->mask;
19136 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19139 printf("Port %d doesn't support any ptypes.\n", port_id);
19143 uint32_t ptypes[ret];
19145 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19147 printf("Unable to set requested ptypes for Port %d\n", port_id);
19151 printf("Successfully set following ptypes for Port %d\n", port_id);
19152 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19153 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19154 printf("%s\n", ptype_name);
19157 clear_ptypes = false;
19160 cmdline_parse_inst_t cmd_set_port_ptypes = {
19161 .f = cmd_set_port_ptypes_parsed,
19163 .help_str = "set port <port_id> ptype_mask <mask>",
19165 (void *)&cmd_set_port_ptypes_set,
19166 (void *)&cmd_set_port_ptypes_port,
19167 (void *)&cmd_set_port_ptypes_port_id,
19168 (void *)&cmd_set_port_ptypes_mask_str,
19169 (void *)&cmd_set_port_ptypes_mask_u32,
19174 /* ******************************************************************************** */
19176 /* list of instructions */
19177 cmdline_parse_ctx_t main_ctx[] = {
19178 (cmdline_parse_inst_t *)&cmd_help_brief,
19179 (cmdline_parse_inst_t *)&cmd_help_long,
19180 (cmdline_parse_inst_t *)&cmd_quit,
19181 (cmdline_parse_inst_t *)&cmd_load_from_file,
19182 (cmdline_parse_inst_t *)&cmd_showport,
19183 (cmdline_parse_inst_t *)&cmd_showqueue,
19184 (cmdline_parse_inst_t *)&cmd_showportall,
19185 (cmdline_parse_inst_t *)&cmd_showdevice,
19186 (cmdline_parse_inst_t *)&cmd_showcfg,
19187 (cmdline_parse_inst_t *)&cmd_showfwdall,
19188 (cmdline_parse_inst_t *)&cmd_start,
19189 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19190 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19191 (cmdline_parse_inst_t *)&cmd_set_link_up,
19192 (cmdline_parse_inst_t *)&cmd_set_link_down,
19193 (cmdline_parse_inst_t *)&cmd_reset,
19194 (cmdline_parse_inst_t *)&cmd_set_numbers,
19195 (cmdline_parse_inst_t *)&cmd_set_log,
19196 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19197 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19198 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19199 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19200 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19201 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19202 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19203 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19204 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19205 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19206 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19207 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19208 (cmdline_parse_inst_t *)&cmd_set_link_check,
19209 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19210 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19211 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19212 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19213 #ifdef RTE_LIBRTE_PMD_BOND
19214 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19215 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19216 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19217 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19218 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19219 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19220 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19221 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19222 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19223 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19224 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19226 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19227 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19228 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19229 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19230 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19231 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19232 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19233 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19234 (cmdline_parse_inst_t *)&cmd_csum_set,
19235 (cmdline_parse_inst_t *)&cmd_csum_show,
19236 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19237 (cmdline_parse_inst_t *)&cmd_tso_set,
19238 (cmdline_parse_inst_t *)&cmd_tso_show,
19239 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19240 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19241 (cmdline_parse_inst_t *)&cmd_gro_enable,
19242 (cmdline_parse_inst_t *)&cmd_gro_flush,
19243 (cmdline_parse_inst_t *)&cmd_gro_show,
19244 (cmdline_parse_inst_t *)&cmd_gso_enable,
19245 (cmdline_parse_inst_t *)&cmd_gso_size,
19246 (cmdline_parse_inst_t *)&cmd_gso_show,
19247 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19248 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19249 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19250 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19251 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19252 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19253 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19254 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19255 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19256 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19257 (cmdline_parse_inst_t *)&cmd_config_dcb,
19258 (cmdline_parse_inst_t *)&cmd_read_reg,
19259 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19260 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19261 (cmdline_parse_inst_t *)&cmd_write_reg,
19262 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19263 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19264 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19265 (cmdline_parse_inst_t *)&cmd_stop,
19266 (cmdline_parse_inst_t *)&cmd_mac_addr,
19267 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19268 (cmdline_parse_inst_t *)&cmd_set_qmap,
19269 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19270 (cmdline_parse_inst_t *)&cmd_operate_port,
19271 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19272 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19273 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19274 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19275 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19276 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19277 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19278 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19279 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19280 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19281 (cmdline_parse_inst_t *)&cmd_config_mtu,
19282 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19283 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19284 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19285 (cmdline_parse_inst_t *)&cmd_config_rss,
19286 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19287 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19288 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19289 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19290 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19291 (cmdline_parse_inst_t *)&cmd_showport_reta,
19292 (cmdline_parse_inst_t *)&cmd_config_burst,
19293 (cmdline_parse_inst_t *)&cmd_config_thresh,
19294 (cmdline_parse_inst_t *)&cmd_config_threshold,
19295 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19296 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19297 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19298 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19299 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19300 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19301 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19302 (cmdline_parse_inst_t *)&cmd_global_config,
19303 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19304 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19305 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19306 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19307 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19308 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19309 (cmdline_parse_inst_t *)&cmd_dump,
19310 (cmdline_parse_inst_t *)&cmd_dump_one,
19311 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19312 (cmdline_parse_inst_t *)&cmd_syn_filter,
19313 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19314 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19315 (cmdline_parse_inst_t *)&cmd_flex_filter,
19316 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19317 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19318 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19319 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19320 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19321 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19322 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19323 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19324 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19325 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19326 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19327 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19328 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19329 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19330 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19331 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19332 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19333 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19334 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19335 (cmdline_parse_inst_t *)&cmd_flow,
19336 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19337 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19338 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19339 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19340 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19341 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19342 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19343 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19344 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19345 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19346 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19347 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19348 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19349 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19350 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19351 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19352 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19353 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19354 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19355 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19356 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19357 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19358 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19359 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19360 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19361 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19362 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19363 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19364 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19365 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19366 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19367 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19368 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19369 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19370 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19371 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19372 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19373 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19374 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19375 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19376 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19377 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19378 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19379 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19380 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19381 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19382 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19383 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19384 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19385 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19386 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19388 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19389 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19390 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19391 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19392 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19393 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19394 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19395 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19396 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19397 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19398 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19399 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19400 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19401 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19402 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19403 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19404 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19405 (cmdline_parse_inst_t *)&cmd_ddp_add,
19406 (cmdline_parse_inst_t *)&cmd_ddp_del,
19407 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19408 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19409 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19410 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19411 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19412 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19413 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19414 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19415 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19416 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19417 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19418 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19420 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19421 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19422 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19423 (cmdline_parse_inst_t *)&cmd_queue_region,
19424 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19425 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19426 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19427 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19428 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19429 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19430 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19431 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19432 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19433 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19434 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19435 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19436 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19437 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19438 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19439 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19440 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19441 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19442 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19443 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19444 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19445 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19446 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19447 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19448 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19449 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19450 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19451 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19452 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19453 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19454 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19455 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19456 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19457 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19458 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19459 #ifdef RTE_LIBRTE_BPF
19460 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19461 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19463 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19464 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19465 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19466 (cmdline_parse_inst_t *)&cmd_set_raw,
19467 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19468 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19472 /* read cmdline commands from file */
19474 cmdline_read_from_file(const char *filename)
19476 struct cmdline *cl;
19478 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19480 printf("Failed to create file based cmdline context: %s\n",
19485 cmdline_interact(cl);
19490 printf("Read CLI commands from %s\n", filename);
19493 /* prompt function, called from main on MASTER lcore */
19497 /* initialize non-constant commands */
19498 cmd_set_fwd_mode_init();
19499 cmd_set_fwd_retry_mode_init();
19501 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19502 if (testpmd_cl == NULL)
19504 cmdline_interact(testpmd_cl);
19505 cmdline_stdin_exit(testpmd_cl);
19511 if (testpmd_cl != NULL)
19512 cmdline_quit(testpmd_cl);
19516 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19518 if (id == (portid_t)RTE_PORT_ALL) {
19521 RTE_ETH_FOREACH_DEV(pid) {
19522 /* check if need_reconfig has been set to 1 */
19523 if (ports[pid].need_reconfig == 0)
19524 ports[pid].need_reconfig = dev;
19525 /* check if need_reconfig_queues has been set to 1 */
19526 if (ports[pid].need_reconfig_queues == 0)
19527 ports[pid].need_reconfig_queues = queue;
19529 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19530 /* check if need_reconfig has been set to 1 */
19531 if (ports[id].need_reconfig == 0)
19532 ports[id].need_reconfig = dev;
19533 /* check if need_reconfig_queues has been set to 1 */
19534 if (ports[id].need_reconfig_queues == 0)
19535 ports[id].need_reconfig_queues = queue;