1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
50 #include <cmdline_rdline.h>
51 #include <cmdline_parse.h>
52 #include <cmdline_parse_num.h>
53 #include <cmdline_parse_string.h>
54 #include <cmdline_parse_ipaddr.h>
55 #include <cmdline_parse_etheraddr.h>
56 #include <cmdline_socket.h>
58 #ifdef RTE_LIBRTE_PMD_BOND
59 #include <rte_eth_bond.h>
60 #include <rte_eth_bond_8023ad.h>
62 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
63 #include <rte_pmd_dpaa.h>
65 #ifdef RTE_LIBRTE_IXGBE_PMD
66 #include <rte_pmd_ixgbe.h>
68 #ifdef RTE_LIBRTE_I40E_PMD
69 #include <rte_pmd_i40e.h>
71 #ifdef RTE_LIBRTE_BNXT_PMD
72 #include <rte_pmd_bnxt.h>
75 #include "cmdline_mtr.h"
76 #include "cmdline_tm.h"
79 static struct cmdline *testpmd_cl;
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 cmdline_fixed_string_t help;
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
90 __attribute__((unused)) void *data)
95 "Help is available for the following sections:\n\n"
96 " help control : Start and stop forwarding.\n"
97 " help display : Displaying port, stats and config "
99 " help config : Configuration information.\n"
100 " help ports : Configuring ports.\n"
101 " help registers : Reading and setting port registers.\n"
102 " help filters : Filters configuration help.\n"
103 " help traffic_management : Traffic Management commmands.\n"
104 " help devices : Device related cmds.\n"
105 " help all : All of the above sections.\n\n"
110 cmdline_parse_token_string_t cmd_help_brief_help =
111 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
113 cmdline_parse_inst_t cmd_help_brief = {
114 .f = cmd_help_brief_parsed,
116 .help_str = "help: Show help",
118 (void *)&cmd_help_brief_help,
123 /* *** Help command with help sections. *** */
124 struct cmd_help_long_result {
125 cmdline_fixed_string_t help;
126 cmdline_fixed_string_t section;
129 static void cmd_help_long_parsed(void *parsed_result,
131 __attribute__((unused)) void *data)
134 struct cmd_help_long_result *res = parsed_result;
136 if (!strcmp(res->section, "all"))
139 if (show_all || !strcmp(res->section, "control")) {
144 "Control forwarding:\n"
145 "-------------------\n\n"
148 " Start packet forwarding with current configuration.\n\n"
151 " Start packet forwarding with current config"
152 " after sending one burst of packets.\n\n"
155 " Stop packet forwarding, and display accumulated"
159 " Quit to prompt.\n\n"
163 if (show_all || !strcmp(res->section, "display")) {
171 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
172 " Display information for port_id, or all.\n\n"
174 "show port X rss reta (size) (mask0,mask1,...)\n"
175 " Display the rss redirection table entry indicated"
176 " by masks on port X. size is used to indicate the"
177 " hardware supported reta size\n\n"
179 "show port (port_id) rss-hash [key]\n"
180 " Display the RSS hash functions and RSS hash key of port\n\n"
182 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
183 " Clear information for port_id, or all.\n\n"
185 "show (rxq|txq) info (port_id) (queue_id)\n"
186 " Display information for configured RX/TX queue.\n\n"
188 "show config (rxtx|cores|fwd|txpkts)\n"
189 " Display the given configuration.\n\n"
191 "read rxd (port_id) (queue_id) (rxd_id)\n"
192 " Display an RX descriptor of a port RX queue.\n\n"
194 "read txd (port_id) (queue_id) (txd_id)\n"
195 " Display a TX descriptor of a port TX queue.\n\n"
197 "ddp get list (port_id)\n"
198 " Get ddp profile info list\n\n"
200 "ddp get info (profile_path)\n"
201 " Get ddp profile information.\n\n"
203 "show vf stats (port_id) (vf_id)\n"
204 " Display a VF's statistics.\n\n"
206 "clear vf stats (port_id) (vf_id)\n"
207 " Reset a VF's statistics.\n\n"
209 "show port (port_id) pctype mapping\n"
210 " Get flow ptype to pctype mapping on a port\n\n"
212 "show port meter stats (port_id) (meter_id) (clear)\n"
213 " Get meter stats on a port\n\n"
215 "show fwd stats all\n"
216 " Display statistics for all fwd engines.\n\n"
218 "clear fwd stats all\n"
219 " Clear statistics for all fwd engines.\n\n"
221 "show port (port_id) rx_offload capabilities\n"
222 " List all per queue and per port Rx offloading"
223 " capabilities of a port\n\n"
225 "show port (port_id) rx_offload configuration\n"
226 " List port level and all queue level"
227 " Rx offloading configuration\n\n"
229 "show port (port_id) tx_offload capabilities\n"
230 " List all per queue and per port"
231 " Tx offloading capabilities of a port\n\n"
233 "show port (port_id) tx_offload configuration\n"
234 " List port level and all queue level"
235 " Tx offloading configuration\n\n"
237 "show port (port_id) tx_metadata\n"
238 " Show Tx metadata value set"
239 " for a specific port\n\n"
241 "show device info (<identifier>|all)"
242 " Show general information about devices probed.\n\n"
246 if (show_all || !strcmp(res->section, "config")) {
252 "Configuration changes only become active when"
253 " forwarding is started/restarted.\n\n"
256 " Reset forwarding to the default configuration.\n\n"
258 "set verbose (level)\n"
259 " Set the debug verbosity level X.\n\n"
261 "set log global|(type) (level)\n"
262 " Set the log level.\n\n"
265 " Set number of ports.\n\n"
268 " Set number of cores.\n\n"
270 "set coremask (mask)\n"
271 " Set the forwarding cores hexadecimal mask.\n\n"
273 "set portmask (mask)\n"
274 " Set the forwarding ports hexadecimal mask.\n\n"
277 " Set number of packets per burst.\n\n"
279 "set burst tx delay (microseconds) retry (num)\n"
280 " Set the transmit delay time and number of retries,"
281 " effective when retry is enabled.\n\n"
283 "set txpkts (x[,y]*)\n"
284 " Set the length of each segment of TXONLY"
285 " and optionally CSUM packets.\n\n"
287 "set txsplit (off|on|rand)\n"
288 " Set the split policy for the TX packets."
289 " Right now only applicable for CSUM and TXONLY"
292 "set corelist (x[,y]*)\n"
293 " Set the list of forwarding cores.\n\n"
295 "set portlist (x[,y]*)\n"
296 " Set the list of forwarding ports.\n\n"
298 "set port setup on (iterator|event)\n"
299 " Select how attached port is retrieved for setup.\n\n"
301 "set tx loopback (port_id) (on|off)\n"
302 " Enable or disable tx loopback.\n\n"
304 "set all queues drop (port_id) (on|off)\n"
305 " Set drop enable bit for all queues.\n\n"
307 "set vf split drop (port_id) (vf_id) (on|off)\n"
308 " Set split drop enable bit for a VF from the PF.\n\n"
310 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
311 " Set MAC antispoof for a VF from the PF.\n\n"
313 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
314 " Enable MACsec offload.\n\n"
316 "set macsec offload (port_id) off\n"
317 " Disable MACsec offload.\n\n"
319 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
320 " Configure MACsec secure connection (SC).\n\n"
322 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
323 " Configure MACsec secure association (SA).\n\n"
325 "set vf broadcast (port_id) (vf_id) (on|off)\n"
326 " Set VF broadcast for a VF from the PF.\n\n"
328 "vlan set strip (on|off) (port_id)\n"
329 " Set the VLAN strip on a port.\n\n"
331 "vlan set stripq (on|off) (port_id,queue_id)\n"
332 " Set the VLAN strip for a queue on a port.\n\n"
334 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
335 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
337 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
338 " Set VLAN insert for a VF from the PF.\n\n"
340 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
341 " Set VLAN antispoof for a VF from the PF.\n\n"
343 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
344 " Set VLAN tag for a VF from the PF.\n\n"
346 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
347 " Set a VF's max bandwidth(Mbps).\n\n"
349 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
350 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
352 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
353 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
355 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
356 " Set some TCs' strict link priority mode on a physical port.\n\n"
358 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
359 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
361 "vlan set filter (on|off) (port_id)\n"
362 " Set the VLAN filter on a port.\n\n"
364 "vlan set qinq (on|off) (port_id)\n"
365 " Set the VLAN QinQ (extended queue in queue)"
368 "vlan set (inner|outer) tpid (value) (port_id)\n"
369 " Set the VLAN TPID for Packet Filtering on"
372 "rx_vlan add (vlan_id|all) (port_id)\n"
373 " Add a vlan_id, or all identifiers, to the set"
374 " of VLAN identifiers filtered by port_id.\n\n"
376 "rx_vlan rm (vlan_id|all) (port_id)\n"
377 " Remove a vlan_id, or all identifiers, from the set"
378 " of VLAN identifiers filtered by port_id.\n\n"
380 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
381 " Add a vlan_id, to the set of VLAN identifiers"
382 "filtered for VF(s) from port_id.\n\n"
384 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
385 " Remove a vlan_id, to the set of VLAN identifiers"
386 "filtered for VF(s) from port_id.\n\n"
388 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
389 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
390 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
391 " add a tunnel filter of a port.\n\n"
393 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
394 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
395 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
396 " remove a tunnel filter of a port.\n\n"
398 "rx_vxlan_port add (udp_port) (port_id)\n"
399 " Add an UDP port for VXLAN packet filter on a port\n\n"
401 "rx_vxlan_port rm (udp_port) (port_id)\n"
402 " Remove an UDP port for VXLAN packet filter on a port\n\n"
404 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
405 " Set hardware insertion of VLAN IDs (single or double VLAN "
406 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
408 "tx_vlan set pvid port_id vlan_id (on|off)\n"
409 " Set port based TX VLAN insertion.\n\n"
411 "tx_vlan reset (port_id)\n"
412 " Disable hardware insertion of a VLAN header in"
413 " packets sent on a port.\n\n"
415 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
416 " Select hardware or software calculation of the"
417 " checksum when transmitting a packet using the"
418 " csum forward engine.\n"
419 " ip|udp|tcp|sctp always concern the inner layer.\n"
420 " outer-ip concerns the outer IP layer in"
421 " outer-udp concerns the outer UDP layer in"
422 " case the packet is recognized as a tunnel packet by"
423 " the forward engine (vxlan, gre and ipip are supported)\n"
424 " Please check the NIC datasheet for HW limits.\n\n"
426 "csum parse-tunnel (on|off) (tx_port_id)\n"
427 " If disabled, treat tunnel packets as non-tunneled"
428 " packets (treat inner headers as payload). The port\n"
429 " argument is the port used for TX in csum forward"
432 "csum show (port_id)\n"
433 " Display tx checksum offload configuration\n\n"
435 "tso set (segsize) (portid)\n"
436 " Enable TCP Segmentation Offload in csum forward"
438 " Please check the NIC datasheet for HW limits.\n\n"
441 " Display the status of TCP Segmentation Offload.\n\n"
443 "set port (port_id) gro on|off\n"
444 " Enable or disable Generic Receive Offload in"
445 " csum forwarding engine.\n\n"
447 "show port (port_id) gro\n"
448 " Display GRO configuration.\n\n"
450 "set gro flush (cycles)\n"
451 " Set the cycle to flush GROed packets from"
452 " reassembly tables.\n\n"
454 "set port (port_id) gso (on|off)"
455 " Enable or disable Generic Segmentation Offload in"
456 " csum forwarding engine.\n\n"
458 "set gso segsz (length)\n"
459 " Set max packet length for output GSO segments,"
460 " including packet header and payload.\n\n"
462 "show port (port_id) gso\n"
463 " Show GSO configuration.\n\n"
466 " Set packet forwarding mode.\n\n"
468 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
469 " Add a MAC address on port_id.\n\n"
471 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
472 " Remove a MAC address from port_id.\n\n"
474 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 " Set the default MAC address for port_id.\n\n"
477 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
478 " Add a MAC address for a VF on the port.\n\n"
480 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Set the MAC address for a VF from the PF.\n\n"
483 "set eth-peer (port_id) (peer_addr)\n"
484 " set the peer address for certain port.\n\n"
486 "set port (port_id) uta (mac_address|all) (on|off)\n"
487 " Add/Remove a or all unicast hash filter(s)"
490 "set promisc (port_id|all) (on|off)\n"
491 " Set the promiscuous mode on port_id, or all.\n\n"
493 "set allmulti (port_id|all) (on|off)\n"
494 " Set the allmulti mode on port_id, or all.\n\n"
496 "set vf promisc (port_id) (vf_id) (on|off)\n"
497 " Set unicast promiscuous mode for a VF from the PF.\n\n"
499 "set vf allmulti (port_id) (vf_id) (on|off)\n"
500 " Set multicast promiscuous mode for a VF from the PF.\n\n"
502 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
503 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
504 " (on|off) autoneg (on|off) (port_id)\n"
505 "set flow_ctrl rx (on|off) (portid)\n"
506 "set flow_ctrl tx (on|off) (portid)\n"
507 "set flow_ctrl high_water (high_water) (portid)\n"
508 "set flow_ctrl low_water (low_water) (portid)\n"
509 "set flow_ctrl pause_time (pause_time) (portid)\n"
510 "set flow_ctrl send_xon (send_xon) (portid)\n"
511 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
512 "set flow_ctrl autoneg (on|off) (port_id)\n"
513 " Set the link flow control parameter on a port.\n\n"
515 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
516 " (low_water) (pause_time) (priority) (port_id)\n"
517 " Set the priority flow control parameter on a"
520 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
521 " Set statistics mapping (qmapping 0..15) for RX/TX"
523 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
524 " on port 0 to mapping 5.\n\n"
526 "set xstats-hide-zero on|off\n"
527 " Set the option to hide the zero values"
528 " for xstats display.\n"
530 "set port (port_id) vf (vf_id) rx|tx on|off\n"
531 " Enable/Disable a VF receive/tranmit from a port\n\n"
533 "set port (port_id) vf (vf_id) (mac_addr)"
534 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
535 " Add/Remove unicast or multicast MAC addr filter"
538 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
540 " AUPE:accepts untagged VLAN;"
541 "ROPE:accept unicast hash\n\n"
542 " BAM:accepts broadcast packets;"
543 "MPE:accepts all multicast packets\n\n"
544 " Enable/Disable a VF receive mode of a port\n\n"
546 "set port (port_id) queue (queue_id) rate (rate_num)\n"
547 " Set rate limit for a queue of a port\n\n"
549 "set port (port_id) vf (vf_id) rate (rate_num) "
550 "queue_mask (queue_mask_value)\n"
551 " Set rate limit for queues in VF of a port\n\n"
553 "set port (port_id) mirror-rule (rule_id)"
554 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
555 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
556 " Set pool or vlan type mirror rule on a port.\n"
557 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
558 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
561 "set port (port_id) mirror-rule (rule_id)"
562 " (uplink-mirror|downlink-mirror) dst-pool"
563 " (pool_id) (on|off)\n"
564 " Set uplink or downlink type mirror rule on a port.\n"
565 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
566 " 0 on' enable mirror income traffic to pool 0.\n\n"
568 "reset port (port_id) mirror-rule (rule_id)\n"
569 " Reset a mirror rule.\n\n"
571 "set flush_rx (on|off)\n"
572 " Flush (default) or don't flush RX streams before"
573 " forwarding. Mainly used with PCAP drivers.\n\n"
575 "set bypass mode (normal|bypass|isolate) (port_id)\n"
576 " Set the bypass mode for the lowest port on bypass enabled"
579 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
580 "mode (normal|bypass|isolate) (port_id)\n"
581 " Set the event required to initiate specified bypass mode for"
582 " the lowest port on a bypass enabled NIC where:\n"
583 " timeout = enable bypass after watchdog timeout.\n"
584 " os_on = enable bypass when OS/board is powered on.\n"
585 " os_off = enable bypass when OS/board is powered off.\n"
586 " power_on = enable bypass when power supply is turned on.\n"
587 " power_off = enable bypass when power supply is turned off."
590 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
591 " Set the bypass watchdog timeout to 'n' seconds"
592 " where 0 = instant.\n\n"
594 "show bypass config (port_id)\n"
595 " Show the bypass configuration for a bypass enabled NIC"
596 " using the lowest port on the NIC.\n\n"
598 #ifdef RTE_LIBRTE_PMD_BOND
599 "create bonded device (mode) (socket)\n"
600 " Create a new bonded device with specific bonding mode and socket.\n\n"
602 "add bonding slave (slave_id) (port_id)\n"
603 " Add a slave device to a bonded device.\n\n"
605 "remove bonding slave (slave_id) (port_id)\n"
606 " Remove a slave device from a bonded device.\n\n"
608 "set bonding mode (value) (port_id)\n"
609 " Set the bonding mode on a bonded device.\n\n"
611 "set bonding primary (slave_id) (port_id)\n"
612 " Set the primary slave for a bonded device.\n\n"
614 "show bonding config (port_id)\n"
615 " Show the bonding config for port_id.\n\n"
617 "set bonding mac_addr (port_id) (address)\n"
618 " Set the MAC address of a bonded device.\n\n"
620 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
621 " Set Aggregation mode for IEEE802.3AD (mode 4)"
623 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
624 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
626 "set bonding mon_period (port_id) (value)\n"
627 " Set the bonding link status monitoring polling period in ms.\n\n"
629 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
630 " Enable/disable dedicated queues for LACP control traffic.\n\n"
633 "set link-up port (port_id)\n"
634 " Set link up for a port.\n\n"
636 "set link-down port (port_id)\n"
637 " Set link down for a port.\n\n"
639 "E-tag set insertion on port-tag-id (value)"
640 " port (port_id) vf (vf_id)\n"
641 " Enable E-tag insertion for a VF on a port\n\n"
643 "E-tag set insertion off port (port_id) vf (vf_id)\n"
644 " Disable E-tag insertion for a VF on a port\n\n"
646 "E-tag set stripping (on|off) port (port_id)\n"
647 " Enable/disable E-tag stripping on a port\n\n"
649 "E-tag set forwarding (on|off) port (port_id)\n"
650 " Enable/disable E-tag based forwarding"
653 "E-tag set filter add e-tag-id (value) dst-pool"
654 " (pool_id) port (port_id)\n"
655 " Add an E-tag forwarding filter on a port\n\n"
657 "E-tag set filter del e-tag-id (value) port (port_id)\n"
658 " Delete an E-tag forwarding filter on a port\n\n"
660 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
661 " Load a profile package on a port\n\n"
663 "ddp del (port_id) (backup_profile_path)\n"
664 " Delete a profile package from a port\n\n"
666 "ptype mapping get (port_id) (valid_only)\n"
667 " Get ptype mapping on a port\n\n"
669 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
670 " Replace target with the pkt_type in ptype mapping\n\n"
672 "ptype mapping reset (port_id)\n"
673 " Reset ptype mapping on a port\n\n"
675 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
676 " Update a ptype mapping item on a port\n\n"
678 "set port (port_id) queue-region region_id (value) "
679 "queue_start_index (value) queue_num (value)\n"
680 " Set a queue region on a port\n\n"
682 "set port (port_id) queue-region region_id (value) "
684 " Set a flowtype region index on a port\n\n"
686 "set port (port_id) queue-region UP (value) region_id (value)\n"
687 " Set the mapping of User Priority to "
688 "queue region on a port\n\n"
690 "set port (port_id) queue-region flush (on|off)\n"
691 " flush all queue region related configuration\n\n"
693 "show port meter cap (port_id)\n"
694 " Show port meter capability information\n\n"
696 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
697 " meter profile add - srtcm rfc 2697\n\n"
699 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
700 " meter profile add - trtcm rfc 2698\n\n"
702 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
703 " meter profile add - trtcm rfc 4115\n\n"
705 "del port meter profile (port_id) (profile_id)\n"
706 " meter profile delete\n\n"
708 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
709 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
710 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
711 "(dscp_tbl_entry63)]\n"
714 "enable port meter (port_id) (mtr_id)\n"
717 "disable port meter (port_id) (mtr_id)\n"
720 "del port meter (port_id) (mtr_id)\n"
723 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
724 " meter update meter profile\n\n"
726 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
727 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
728 " update meter dscp table entries\n\n"
730 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
731 "(action0) [(action1) (action2)]\n"
732 " meter update policer action\n\n"
734 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
735 " meter update stats\n\n"
737 "show port (port_id) queue-region\n"
738 " show all queue region related configuration info\n\n"
740 , list_pkt_forwarding_modes()
744 if (show_all || !strcmp(res->section, "ports")) {
750 "----------------\n\n"
752 "port start (port_id|all)\n"
753 " Start all ports or port_id.\n\n"
755 "port stop (port_id|all)\n"
756 " Stop all ports or port_id.\n\n"
758 "port close (port_id|all)\n"
759 " Close all ports or port_id.\n\n"
761 "port 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 (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
782 "hw-vlan-strip|hw-vlan-extend|drop-en)"
784 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
787 "port config all rss (all|default|ip|tcp|udp|sctp|"
788 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
789 " Set the RSS mode.\n\n"
791 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
792 " Set the RSS redirection table.\n\n"
794 "port config (port_id) dcb vt (on|off) (traffic_class)"
796 " Set the DCB mode.\n\n"
798 "port config all burst (value)\n"
799 " Set the number of packets per burst.\n\n"
801 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
803 " Set the ring prefetch/host/writeback threshold"
804 " for tx/rx queue.\n\n"
806 "port config all (txfreet|txrst|rxfreet) (value)\n"
807 " Set free threshold for rx/tx, or set"
808 " tx rs bit threshold.\n\n"
809 "port config mtu X value\n"
810 " Set the MTU of port X to a given value\n\n"
812 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
813 " Set a rx/tx queue's ring size configuration, the new"
814 " value will take effect after command that (re-)start the port"
815 " or command that setup the specific queue\n\n"
817 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
818 " Start/stop a rx/tx queue of port X. Only take effect"
819 " when port X is started\n\n"
821 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
822 " Switch on/off a deferred start of port X rx/tx queue. Only"
823 " take effect when port X is stopped.\n\n"
825 "port (port_id) (rxq|txq) (queue_id) setup\n"
826 " Setup a rx/tx queue of port X.\n\n"
828 "port config (port_id|all) l2-tunnel E-tag ether-type"
830 " Set the value of E-tag ether-type.\n\n"
832 "port config (port_id|all) l2-tunnel E-tag"
833 " (enable|disable)\n"
834 " Enable/disable the E-tag support.\n\n"
836 "port config (port_id) pctype mapping reset\n"
837 " Reset flow type to pctype mapping on a port\n\n"
839 "port config (port_id) pctype mapping update"
840 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
841 " Update a flow type to pctype mapping item on a port\n\n"
843 "port config (port_id) pctype (pctype_id) hash_inset|"
844 "fdir_inset|fdir_flx_inset get|set|clear field\n"
846 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset clear all"
850 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
852 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
853 " Add/remove UDP tunnel port for tunneling offload\n\n"
855 "port config <port_id> rx_offload vlan_strip|"
856 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
857 "outer_ipv4_cksum|macsec_strip|header_split|"
858 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
859 "scatter|timestamp|security|keep_crc on|off\n"
860 " Enable or disable a per port Rx offloading"
861 " on all Rx queues of a port\n\n"
863 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
864 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
865 "outer_ipv4_cksum|macsec_strip|header_split|"
866 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
867 "scatter|timestamp|security|keep_crc on|off\n"
868 " Enable or disable a per queue Rx offloading"
869 " only on a specific Rx queue\n\n"
871 "port config (port_id) tx_offload vlan_insert|"
872 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
873 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
874 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
875 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
876 "security|match_metadata on|off\n"
877 " Enable or disable a per port Tx offloading"
878 " on all Tx queues of a port\n\n"
880 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
881 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
882 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
883 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
884 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
886 " Enable or disable a per queue Tx offloading"
887 " only on a specific Tx queue\n\n"
889 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
890 " Load an eBPF program as a callback"
891 " for particular RX/TX queue\n\n"
893 "bpf-unload rx|tx (port) (queue)\n"
894 " Unload previously loaded eBPF program"
895 " for particular RX/TX queue\n\n"
897 "port config (port_id) tx_metadata (value)\n"
898 " Set Tx metadata value per port. Testpmd will add this value"
899 " to any Tx packet sent from this port\n\n"
903 if (show_all || !strcmp(res->section, "registers")) {
911 "read reg (port_id) (address)\n"
912 " Display value of a port register.\n\n"
914 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
915 " Display a port register bit field.\n\n"
917 "read regbit (port_id) (address) (bit_x)\n"
918 " Display a single port register bit.\n\n"
920 "write reg (port_id) (address) (value)\n"
921 " Set value of a port register.\n\n"
923 "write regfield (port_id) (address) (bit_x) (bit_y)"
925 " Set bit field of a port register.\n\n"
927 "write regbit (port_id) (address) (bit_x) (value)\n"
928 " Set single bit value of a port register.\n\n"
931 if (show_all || !strcmp(res->section, "filters")) {
939 "ethertype_filter (port_id) (add|del)"
940 " (mac_addr|mac_ignr) (mac_address) ethertype"
941 " (ether_type) (drop|fwd) queue (queue_id)\n"
942 " Add/Del an ethertype filter.\n\n"
944 "2tuple_filter (port_id) (add|del)"
945 " dst_port (dst_port_value) protocol (protocol_value)"
946 " mask (mask_value) tcp_flags (tcp_flags_value)"
947 " priority (prio_value) queue (queue_id)\n"
948 " Add/Del a 2tuple filter.\n\n"
950 "5tuple_filter (port_id) (add|del)"
951 " dst_ip (dst_address) src_ip (src_address)"
952 " dst_port (dst_port_value) src_port (src_port_value)"
953 " protocol (protocol_value)"
954 " mask (mask_value) tcp_flags (tcp_flags_value)"
955 " priority (prio_value) queue (queue_id)\n"
956 " Add/Del a 5tuple filter.\n\n"
958 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
959 " Add/Del syn filter.\n\n"
961 "flex_filter (port_id) (add|del) len (len_value)"
962 " bytes (bytes_value) mask (mask_value)"
963 " priority (prio_value) queue (queue_id)\n"
964 " Add/Del a flex filter.\n\n"
966 "flow_director_filter (port_id) mode IP (add|del|update)"
967 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
968 " src (src_ip_address) dst (dst_ip_address)"
969 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
970 " vlan (vlan_value) flexbytes (flexbytes_value)"
971 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
972 " fd_id (fd_id_value)\n"
973 " Add/Del an IP type flow director filter.\n\n"
975 "flow_director_filter (port_id) mode IP (add|del|update)"
976 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
977 " src (src_ip_address) (src_port)"
978 " dst (dst_ip_address) (dst_port)"
979 " tos (tos_value) ttl (ttl_value)"
980 " vlan (vlan_value) flexbytes (flexbytes_value)"
981 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 " fd_id (fd_id_value)\n"
983 " Add/Del an UDP/TCP type flow director filter.\n\n"
985 "flow_director_filter (port_id) mode IP (add|del|update)"
986 " flow (ipv4-sctp|ipv6-sctp)"
987 " src (src_ip_address) (src_port)"
988 " dst (dst_ip_address) (dst_port)"
989 " tag (verification_tag) "
990 " tos (tos_value) ttl (ttl_value)"
992 " flexbytes (flexbytes_value) (drop|fwd)"
993 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
994 " Add/Del a SCTP type flow director filter.\n\n"
996 "flow_director_filter (port_id) mode IP (add|del|update)"
997 " flow l2_payload ether (ethertype)"
998 " flexbytes (flexbytes_value) (drop|fwd)"
999 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1000 " Add/Del a l2 payload type flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1003 " mac (mac_address) vlan (vlan_value)"
1004 " flexbytes (flexbytes_value) (drop|fwd)"
1005 " queue (queue_id) fd_id (fd_id_value)\n"
1006 " Add/Del a MAC-VLAN flow director filter.\n\n"
1008 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1009 " mac (mac_address) vlan (vlan_value)"
1010 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1011 " flexbytes (flexbytes_value) (drop|fwd)"
1012 " queue (queue_id) fd_id (fd_id_value)\n"
1013 " Add/Del a Tunnel flow director filter.\n\n"
1015 "flow_director_filter (port_id) mode raw (add|del|update)"
1016 " flow (flow_id) (drop|fwd) queue (queue_id)"
1017 " fd_id (fd_id_value) packet (packet file name)\n"
1018 " Add/Del a raw type flow director filter.\n\n"
1020 "flush_flow_director (port_id)\n"
1021 " Flush all flow director entries of a device.\n\n"
1023 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1024 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1025 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1026 " Set flow director IP mask.\n\n"
1028 "flow_director_mask (port_id) mode MAC-VLAN"
1029 " vlan (vlan_value)\n"
1030 " Set flow director MAC-VLAN mask.\n\n"
1032 "flow_director_mask (port_id) mode Tunnel"
1033 " vlan (vlan_value) mac (mac_value)"
1034 " tunnel-type (tunnel_type_value)"
1035 " tunnel-id (tunnel_id_value)\n"
1036 " Set flow director Tunnel mask.\n\n"
1038 "flow_director_flex_mask (port_id)"
1039 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1040 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1042 " Configure mask of flex payload.\n\n"
1044 "flow_director_flex_payload (port_id)"
1045 " (raw|l2|l3|l4) (config)\n"
1046 " Configure flex payload selection.\n\n"
1048 "get_sym_hash_ena_per_port (port_id)\n"
1049 " get symmetric hash enable configuration per port.\n\n"
1051 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1052 " set symmetric hash enable configuration per port"
1053 " to enable or disable.\n\n"
1055 "get_hash_global_config (port_id)\n"
1056 " Get the global configurations of hash filters.\n\n"
1058 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1059 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1060 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1061 " (enable|disable)\n"
1062 " Set the global configurations of hash filters.\n\n"
1064 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1065 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1066 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1067 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1068 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1069 "ipv6-next-header|udp-src-port|udp-dst-port|"
1070 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1071 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1072 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1073 "fld-8th|none) (select|add)\n"
1074 " Set the input set for hash.\n\n"
1076 "set_fdir_input_set (port_id) "
1077 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1078 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1079 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1080 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1081 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1082 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1083 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1085 " Set the input set for FDir.\n\n"
1087 "flow validate {port_id}"
1088 " [group {group_id}] [priority {level}]"
1089 " [ingress] [egress]"
1090 " pattern {item} [/ {item} [...]] / end"
1091 " actions {action} [/ {action} [...]] / end\n"
1092 " Check whether a flow rule can be created.\n\n"
1094 "flow create {port_id}"
1095 " [group {group_id}] [priority {level}]"
1096 " [ingress] [egress]"
1097 " pattern {item} [/ {item} [...]] / end"
1098 " actions {action} [/ {action} [...]] / end\n"
1099 " Create a flow rule.\n\n"
1101 "flow destroy {port_id} rule {rule_id} [...]\n"
1102 " Destroy specific flow rules.\n\n"
1104 "flow flush {port_id}\n"
1105 " Destroy all flow rules.\n\n"
1107 "flow query {port_id} {rule_id} {action}\n"
1108 " Query an existing flow rule.\n\n"
1110 "flow list {port_id} [group {group_id}] [...]\n"
1111 " List existing flow rules sorted by priority,"
1112 " filtered by group identifiers.\n\n"
1114 "flow isolate {port_id} {boolean}\n"
1115 " Restrict ingress traffic to the defined"
1118 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1119 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1120 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1121 " Configure the VXLAN encapsulation for flows.\n\n"
1123 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1124 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1125 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1126 " eth-dst (eth-dst)\n"
1127 " Configure the VXLAN encapsulation for flows.\n\n"
1129 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1130 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1131 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1132 " eth-dst (eth-dst)\n"
1133 " Configure the VXLAN encapsulation for flows.\n\n"
1135 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1136 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1138 " Configure the NVGRE encapsulation for flows.\n\n"
1140 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1141 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1142 " eth-src (eth-src) eth-dst (eth-dst)\n"
1143 " Configure the NVGRE encapsulation for flows.\n\n"
1145 "set raw_encap {flow items}\n"
1146 " Configure the encapsulation with raw data.\n\n"
1148 "set raw_decap {flow items}\n"
1149 " Configure the decapsulation with raw data.\n\n"
1154 if (show_all || !strcmp(res->section, "traffic_management")) {
1158 "Traffic Management:\n"
1160 "show port tm cap (port_id)\n"
1161 " Display the port TM capability.\n\n"
1163 "show port tm level cap (port_id) (level_id)\n"
1164 " Display the port TM hierarchical level capability.\n\n"
1166 "show port tm node cap (port_id) (node_id)\n"
1167 " Display the port TM node capability.\n\n"
1169 "show port tm node type (port_id) (node_id)\n"
1170 " Display the port TM node type.\n\n"
1172 "show port tm node stats (port_id) (node_id) (clear)\n"
1173 " Display the port TM node stats.\n\n"
1175 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1176 "set port tm hierarchy default (port_id)\n"
1177 " Set default traffic Management hierarchy on a port\n\n"
1180 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1181 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1182 " (packet_length_adjust)\n"
1183 " Add port tm node private shaper profile.\n\n"
1185 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1186 " Delete port tm node private shaper profile.\n\n"
1188 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1189 " (shaper_profile_id)\n"
1190 " Add/update port tm node shared shaper.\n\n"
1192 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1193 " Delete port tm node shared shaper.\n\n"
1195 "set port tm node shaper profile (port_id) (node_id)"
1196 " (shaper_profile_id)\n"
1197 " Set port tm node shaper profile.\n\n"
1199 "add port tm node wred profile (port_id) (wred_profile_id)"
1200 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1201 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1202 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1203 " Add port tm node wred profile.\n\n"
1205 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1206 " Delete port tm node wred profile.\n\n"
1208 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1209 " (priority) (weight) (level_id) (shaper_profile_id)"
1210 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1211 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1212 " Add port tm nonleaf node.\n\n"
1214 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1215 " (priority) (weight) (level_id) (shaper_profile_id)"
1216 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1217 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1218 " Add port tm leaf node.\n\n"
1220 "del port tm node (port_id) (node_id)\n"
1221 " Delete port tm node.\n\n"
1223 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1224 " (priority) (weight)\n"
1225 " Set port tm node parent.\n\n"
1227 "suspend port tm node (port_id) (node_id)"
1228 " Suspend tm node.\n\n"
1230 "resume port tm node (port_id) (node_id)"
1231 " Resume tm node.\n\n"
1233 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1234 " Commit tm hierarchy.\n\n"
1236 "set port tm mark ip_ecn (port) (green) (yellow)"
1238 " Enables/Disables the traffic management marking"
1239 " for IP ECN (Explicit Congestion Notification)"
1240 " packets on a given port\n\n"
1242 "set port tm mark ip_dscp (port) (green) (yellow)"
1244 " Enables/Disables the traffic management marking"
1245 " on the port for IP dscp packets\n\n"
1247 "set port tm mark vlan_dei (port) (green) (yellow)"
1249 " Enables/Disables the traffic management marking"
1250 " on the port for VLAN packets with DEI enabled\n\n"
1254 if (show_all || !strcmp(res->section, "devices")) {
1258 "Device Operations:\n"
1260 "device detach (identifier)\n"
1261 " Detach device by identifier.\n\n"
1267 cmdline_parse_token_string_t cmd_help_long_help =
1268 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1270 cmdline_parse_token_string_t cmd_help_long_section =
1271 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1272 "all#control#display#config#"
1273 "ports#registers#filters#traffic_management#devices");
1275 cmdline_parse_inst_t cmd_help_long = {
1276 .f = cmd_help_long_parsed,
1278 .help_str = "help all|control|display|config|ports|register|"
1279 "filters|traffic_management|devices: "
1282 (void *)&cmd_help_long_help,
1283 (void *)&cmd_help_long_section,
1289 /* *** start/stop/close all ports *** */
1290 struct cmd_operate_port_result {
1291 cmdline_fixed_string_t keyword;
1292 cmdline_fixed_string_t name;
1293 cmdline_fixed_string_t value;
1296 static void cmd_operate_port_parsed(void *parsed_result,
1297 __attribute__((unused)) struct cmdline *cl,
1298 __attribute__((unused)) void *data)
1300 struct cmd_operate_port_result *res = parsed_result;
1302 if (!strcmp(res->name, "start"))
1303 start_port(RTE_PORT_ALL);
1304 else if (!strcmp(res->name, "stop"))
1305 stop_port(RTE_PORT_ALL);
1306 else if (!strcmp(res->name, "close"))
1307 close_port(RTE_PORT_ALL);
1308 else if (!strcmp(res->name, "reset"))
1309 reset_port(RTE_PORT_ALL);
1311 printf("Unknown parameter\n");
1314 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1317 cmdline_parse_token_string_t cmd_operate_port_all_port =
1318 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1319 "start#stop#close#reset");
1320 cmdline_parse_token_string_t cmd_operate_port_all_all =
1321 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1323 cmdline_parse_inst_t cmd_operate_port = {
1324 .f = cmd_operate_port_parsed,
1326 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1328 (void *)&cmd_operate_port_all_cmd,
1329 (void *)&cmd_operate_port_all_port,
1330 (void *)&cmd_operate_port_all_all,
1335 /* *** start/stop/close specific port *** */
1336 struct cmd_operate_specific_port_result {
1337 cmdline_fixed_string_t keyword;
1338 cmdline_fixed_string_t name;
1342 static void cmd_operate_specific_port_parsed(void *parsed_result,
1343 __attribute__((unused)) struct cmdline *cl,
1344 __attribute__((unused)) void *data)
1346 struct cmd_operate_specific_port_result *res = parsed_result;
1348 if (!strcmp(res->name, "start"))
1349 start_port(res->value);
1350 else if (!strcmp(res->name, "stop"))
1351 stop_port(res->value);
1352 else if (!strcmp(res->name, "close"))
1353 close_port(res->value);
1354 else if (!strcmp(res->name, "reset"))
1355 reset_port(res->value);
1357 printf("Unknown parameter\n");
1360 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1361 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1363 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1364 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1365 name, "start#stop#close#reset");
1366 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1367 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1370 cmdline_parse_inst_t cmd_operate_specific_port = {
1371 .f = cmd_operate_specific_port_parsed,
1373 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1375 (void *)&cmd_operate_specific_port_cmd,
1376 (void *)&cmd_operate_specific_port_port,
1377 (void *)&cmd_operate_specific_port_id,
1382 /* *** enable port setup (after attach) via iterator or event *** */
1383 struct cmd_set_port_setup_on_result {
1384 cmdline_fixed_string_t set;
1385 cmdline_fixed_string_t port;
1386 cmdline_fixed_string_t setup;
1387 cmdline_fixed_string_t on;
1388 cmdline_fixed_string_t mode;
1391 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1392 __attribute__((unused)) struct cmdline *cl,
1393 __attribute__((unused)) void *data)
1395 struct cmd_set_port_setup_on_result *res = parsed_result;
1397 if (strcmp(res->mode, "event") == 0)
1398 setup_on_probe_event = true;
1399 else if (strcmp(res->mode, "iterator") == 0)
1400 setup_on_probe_event = false;
1402 printf("Unknown mode\n");
1405 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1406 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1408 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1411 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1412 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1414 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1415 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1417 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1418 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1419 mode, "iterator#event");
1421 cmdline_parse_inst_t cmd_set_port_setup_on = {
1422 .f = cmd_set_port_setup_on_parsed,
1424 .help_str = "set port setup on iterator|event",
1426 (void *)&cmd_set_port_setup_on_set,
1427 (void *)&cmd_set_port_setup_on_port,
1428 (void *)&cmd_set_port_setup_on_setup,
1429 (void *)&cmd_set_port_setup_on_on,
1430 (void *)&cmd_set_port_setup_on_mode,
1435 /* *** attach a specified port *** */
1436 struct cmd_operate_attach_port_result {
1437 cmdline_fixed_string_t port;
1438 cmdline_fixed_string_t keyword;
1439 cmdline_fixed_string_t identifier;
1442 static void cmd_operate_attach_port_parsed(void *parsed_result,
1443 __attribute__((unused)) struct cmdline *cl,
1444 __attribute__((unused)) void *data)
1446 struct cmd_operate_attach_port_result *res = parsed_result;
1448 if (!strcmp(res->keyword, "attach"))
1449 attach_port(res->identifier);
1451 printf("Unknown parameter\n");
1454 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1457 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1460 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1461 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1464 cmdline_parse_inst_t cmd_operate_attach_port = {
1465 .f = cmd_operate_attach_port_parsed,
1467 .help_str = "port attach <identifier>: "
1468 "(identifier: pci address or virtual dev name)",
1470 (void *)&cmd_operate_attach_port_port,
1471 (void *)&cmd_operate_attach_port_keyword,
1472 (void *)&cmd_operate_attach_port_identifier,
1477 /* *** detach a specified port *** */
1478 struct cmd_operate_detach_port_result {
1479 cmdline_fixed_string_t port;
1480 cmdline_fixed_string_t keyword;
1484 static void cmd_operate_detach_port_parsed(void *parsed_result,
1485 __attribute__((unused)) struct cmdline *cl,
1486 __attribute__((unused)) void *data)
1488 struct cmd_operate_detach_port_result *res = parsed_result;
1490 if (!strcmp(res->keyword, "detach"))
1491 detach_port_device(res->port_id);
1493 printf("Unknown parameter\n");
1496 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1497 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1499 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1500 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1502 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1503 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1506 cmdline_parse_inst_t cmd_operate_detach_port = {
1507 .f = cmd_operate_detach_port_parsed,
1509 .help_str = "port detach <port_id>",
1511 (void *)&cmd_operate_detach_port_port,
1512 (void *)&cmd_operate_detach_port_keyword,
1513 (void *)&cmd_operate_detach_port_port_id,
1518 /* *** detach device by identifier *** */
1519 struct cmd_operate_detach_device_result {
1520 cmdline_fixed_string_t device;
1521 cmdline_fixed_string_t keyword;
1522 cmdline_fixed_string_t identifier;
1525 static void cmd_operate_detach_device_parsed(void *parsed_result,
1526 __attribute__((unused)) struct cmdline *cl,
1527 __attribute__((unused)) void *data)
1529 struct cmd_operate_detach_device_result *res = parsed_result;
1531 if (!strcmp(res->keyword, "detach"))
1532 detach_device(res->identifier);
1534 printf("Unknown parameter\n");
1537 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1538 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1540 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1541 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1543 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1544 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1547 cmdline_parse_inst_t cmd_operate_detach_device = {
1548 .f = cmd_operate_detach_device_parsed,
1550 .help_str = "device detach <identifier>:"
1551 "(identifier: pci address or virtual dev name)",
1553 (void *)&cmd_operate_detach_device_device,
1554 (void *)&cmd_operate_detach_device_keyword,
1555 (void *)&cmd_operate_detach_device_identifier,
1559 /* *** configure speed for all ports *** */
1560 struct cmd_config_speed_all {
1561 cmdline_fixed_string_t port;
1562 cmdline_fixed_string_t keyword;
1563 cmdline_fixed_string_t all;
1564 cmdline_fixed_string_t item1;
1565 cmdline_fixed_string_t item2;
1566 cmdline_fixed_string_t value1;
1567 cmdline_fixed_string_t value2;
1571 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1576 if (!strcmp(duplexstr, "half")) {
1577 duplex = ETH_LINK_HALF_DUPLEX;
1578 } else if (!strcmp(duplexstr, "full")) {
1579 duplex = ETH_LINK_FULL_DUPLEX;
1580 } else if (!strcmp(duplexstr, "auto")) {
1581 duplex = ETH_LINK_FULL_DUPLEX;
1583 printf("Unknown duplex parameter\n");
1587 if (!strcmp(speedstr, "10")) {
1588 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1589 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1590 } else if (!strcmp(speedstr, "100")) {
1591 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1592 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1594 if (duplex != ETH_LINK_FULL_DUPLEX) {
1595 printf("Invalid speed/duplex parameters\n");
1598 if (!strcmp(speedstr, "1000")) {
1599 *speed = ETH_LINK_SPEED_1G;
1600 } else if (!strcmp(speedstr, "10000")) {
1601 *speed = ETH_LINK_SPEED_10G;
1602 } else if (!strcmp(speedstr, "25000")) {
1603 *speed = ETH_LINK_SPEED_25G;
1604 } else if (!strcmp(speedstr, "40000")) {
1605 *speed = ETH_LINK_SPEED_40G;
1606 } else if (!strcmp(speedstr, "50000")) {
1607 *speed = ETH_LINK_SPEED_50G;
1608 } else if (!strcmp(speedstr, "100000")) {
1609 *speed = ETH_LINK_SPEED_100G;
1610 } else if (!strcmp(speedstr, "auto")) {
1611 *speed = ETH_LINK_SPEED_AUTONEG;
1613 printf("Unknown speed parameter\n");
1622 cmd_config_speed_all_parsed(void *parsed_result,
1623 __attribute__((unused)) struct cmdline *cl,
1624 __attribute__((unused)) void *data)
1626 struct cmd_config_speed_all *res = parsed_result;
1627 uint32_t link_speed;
1630 if (!all_ports_stopped()) {
1631 printf("Please stop all ports first\n");
1635 if (parse_and_check_speed_duplex(res->value1, res->value2,
1639 RTE_ETH_FOREACH_DEV(pid) {
1640 ports[pid].dev_conf.link_speeds = link_speed;
1643 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1646 cmdline_parse_token_string_t cmd_config_speed_all_port =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1648 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1651 cmdline_parse_token_string_t cmd_config_speed_all_all =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1653 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1654 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1655 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1657 "10#100#1000#10000#25000#40000#50000#100000#auto");
1658 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1660 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1664 cmdline_parse_inst_t cmd_config_speed_all = {
1665 .f = cmd_config_speed_all_parsed,
1667 .help_str = "port config all speed "
1668 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1671 (void *)&cmd_config_speed_all_port,
1672 (void *)&cmd_config_speed_all_keyword,
1673 (void *)&cmd_config_speed_all_all,
1674 (void *)&cmd_config_speed_all_item1,
1675 (void *)&cmd_config_speed_all_value1,
1676 (void *)&cmd_config_speed_all_item2,
1677 (void *)&cmd_config_speed_all_value2,
1682 /* *** configure speed for specific port *** */
1683 struct cmd_config_speed_specific {
1684 cmdline_fixed_string_t port;
1685 cmdline_fixed_string_t keyword;
1687 cmdline_fixed_string_t item1;
1688 cmdline_fixed_string_t item2;
1689 cmdline_fixed_string_t value1;
1690 cmdline_fixed_string_t value2;
1694 cmd_config_speed_specific_parsed(void *parsed_result,
1695 __attribute__((unused)) struct cmdline *cl,
1696 __attribute__((unused)) void *data)
1698 struct cmd_config_speed_specific *res = parsed_result;
1699 uint32_t link_speed;
1701 if (!all_ports_stopped()) {
1702 printf("Please stop all ports first\n");
1706 if (port_id_is_invalid(res->id, ENABLED_WARN))
1709 if (parse_and_check_speed_duplex(res->value1, res->value2,
1713 ports[res->id].dev_conf.link_speeds = link_speed;
1715 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1719 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1722 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1725 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1726 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1727 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1730 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1732 "10#100#1000#10000#25000#40000#50000#100000#auto");
1733 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1736 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1740 cmdline_parse_inst_t cmd_config_speed_specific = {
1741 .f = cmd_config_speed_specific_parsed,
1743 .help_str = "port config <port_id> speed "
1744 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1747 (void *)&cmd_config_speed_specific_port,
1748 (void *)&cmd_config_speed_specific_keyword,
1749 (void *)&cmd_config_speed_specific_id,
1750 (void *)&cmd_config_speed_specific_item1,
1751 (void *)&cmd_config_speed_specific_value1,
1752 (void *)&cmd_config_speed_specific_item2,
1753 (void *)&cmd_config_speed_specific_value2,
1758 /* *** configure loopback for all ports *** */
1759 struct cmd_config_loopback_all {
1760 cmdline_fixed_string_t port;
1761 cmdline_fixed_string_t keyword;
1762 cmdline_fixed_string_t all;
1763 cmdline_fixed_string_t item;
1768 cmd_config_loopback_all_parsed(void *parsed_result,
1769 __attribute__((unused)) struct cmdline *cl,
1770 __attribute__((unused)) void *data)
1772 struct cmd_config_loopback_all *res = parsed_result;
1775 if (!all_ports_stopped()) {
1776 printf("Please stop all ports first\n");
1780 RTE_ETH_FOREACH_DEV(pid) {
1781 ports[pid].dev_conf.lpbk_mode = res->mode;
1784 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1787 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1789 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1792 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1794 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1795 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1797 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1798 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1800 cmdline_parse_inst_t cmd_config_loopback_all = {
1801 .f = cmd_config_loopback_all_parsed,
1803 .help_str = "port config all loopback <mode>",
1805 (void *)&cmd_config_loopback_all_port,
1806 (void *)&cmd_config_loopback_all_keyword,
1807 (void *)&cmd_config_loopback_all_all,
1808 (void *)&cmd_config_loopback_all_item,
1809 (void *)&cmd_config_loopback_all_mode,
1814 /* *** configure loopback for specific port *** */
1815 struct cmd_config_loopback_specific {
1816 cmdline_fixed_string_t port;
1817 cmdline_fixed_string_t keyword;
1819 cmdline_fixed_string_t item;
1824 cmd_config_loopback_specific_parsed(void *parsed_result,
1825 __attribute__((unused)) struct cmdline *cl,
1826 __attribute__((unused)) void *data)
1828 struct cmd_config_loopback_specific *res = parsed_result;
1830 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1833 if (!port_is_stopped(res->port_id)) {
1834 printf("Please stop port %u first\n", res->port_id);
1838 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1840 cmd_reconfig_device_queue(res->port_id, 1, 1);
1844 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1847 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1850 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1851 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1853 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1854 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1856 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1857 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1860 cmdline_parse_inst_t cmd_config_loopback_specific = {
1861 .f = cmd_config_loopback_specific_parsed,
1863 .help_str = "port config <port_id> loopback <mode>",
1865 (void *)&cmd_config_loopback_specific_port,
1866 (void *)&cmd_config_loopback_specific_keyword,
1867 (void *)&cmd_config_loopback_specific_id,
1868 (void *)&cmd_config_loopback_specific_item,
1869 (void *)&cmd_config_loopback_specific_mode,
1874 /* *** configure txq/rxq, txd/rxd *** */
1875 struct cmd_config_rx_tx {
1876 cmdline_fixed_string_t port;
1877 cmdline_fixed_string_t keyword;
1878 cmdline_fixed_string_t all;
1879 cmdline_fixed_string_t name;
1884 cmd_config_rx_tx_parsed(void *parsed_result,
1885 __attribute__((unused)) struct cmdline *cl,
1886 __attribute__((unused)) void *data)
1888 struct cmd_config_rx_tx *res = parsed_result;
1890 if (!all_ports_stopped()) {
1891 printf("Please stop all ports first\n");
1894 if (!strcmp(res->name, "rxq")) {
1895 if (!res->value && !nb_txq) {
1896 printf("Warning: Either rx or tx queues should be non zero\n");
1899 if (check_nb_rxq(res->value) != 0)
1901 nb_rxq = res->value;
1903 else if (!strcmp(res->name, "txq")) {
1904 if (!res->value && !nb_rxq) {
1905 printf("Warning: Either rx or tx queues should be non zero\n");
1908 if (check_nb_txq(res->value) != 0)
1910 nb_txq = res->value;
1912 else if (!strcmp(res->name, "rxd")) {
1913 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1914 printf("rxd %d invalid - must be > 0 && <= %d\n",
1915 res->value, RTE_TEST_RX_DESC_MAX);
1918 nb_rxd = res->value;
1919 } else if (!strcmp(res->name, "txd")) {
1920 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1921 printf("txd %d invalid - must be > 0 && <= %d\n",
1922 res->value, RTE_TEST_TX_DESC_MAX);
1925 nb_txd = res->value;
1927 printf("Unknown parameter\n");
1935 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1938 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1940 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1941 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1942 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1943 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1944 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1947 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1948 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1950 cmdline_parse_inst_t cmd_config_rx_tx = {
1951 .f = cmd_config_rx_tx_parsed,
1953 .help_str = "port config all rxq|txq|rxd|txd <value>",
1955 (void *)&cmd_config_rx_tx_port,
1956 (void *)&cmd_config_rx_tx_keyword,
1957 (void *)&cmd_config_rx_tx_all,
1958 (void *)&cmd_config_rx_tx_name,
1959 (void *)&cmd_config_rx_tx_value,
1964 /* *** config max packet length *** */
1965 struct cmd_config_max_pkt_len_result {
1966 cmdline_fixed_string_t port;
1967 cmdline_fixed_string_t keyword;
1968 cmdline_fixed_string_t all;
1969 cmdline_fixed_string_t name;
1974 cmd_config_max_pkt_len_parsed(void *parsed_result,
1975 __attribute__((unused)) struct cmdline *cl,
1976 __attribute__((unused)) void *data)
1978 struct cmd_config_max_pkt_len_result *res = parsed_result;
1981 if (!all_ports_stopped()) {
1982 printf("Please stop all ports first\n");
1986 RTE_ETH_FOREACH_DEV(pid) {
1987 struct rte_port *port = &ports[pid];
1988 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1990 if (!strcmp(res->name, "max-pkt-len")) {
1991 if (res->value < RTE_ETHER_MIN_LEN) {
1992 printf("max-pkt-len can not be less than %d\n",
1996 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1999 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2000 if (res->value > RTE_ETHER_MAX_LEN)
2001 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2003 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2004 port->dev_conf.rxmode.offloads = rx_offloads;
2006 printf("Unknown parameter\n");
2013 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2016 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2022 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2025 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2028 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2029 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2032 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2033 .f = cmd_config_max_pkt_len_parsed,
2035 .help_str = "port config all max-pkt-len <value>",
2037 (void *)&cmd_config_max_pkt_len_port,
2038 (void *)&cmd_config_max_pkt_len_keyword,
2039 (void *)&cmd_config_max_pkt_len_all,
2040 (void *)&cmd_config_max_pkt_len_name,
2041 (void *)&cmd_config_max_pkt_len_value,
2046 /* *** configure port MTU *** */
2047 struct cmd_config_mtu_result {
2048 cmdline_fixed_string_t port;
2049 cmdline_fixed_string_t keyword;
2050 cmdline_fixed_string_t mtu;
2056 cmd_config_mtu_parsed(void *parsed_result,
2057 __attribute__((unused)) struct cmdline *cl,
2058 __attribute__((unused)) void *data)
2060 struct cmd_config_mtu_result *res = parsed_result;
2062 if (res->value < RTE_ETHER_MIN_LEN) {
2063 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2066 port_mtu_set(res->port_id, res->value);
2069 cmdline_parse_token_string_t cmd_config_mtu_port =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2072 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2075 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2076 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2078 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2079 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2080 cmdline_parse_token_num_t cmd_config_mtu_value =
2081 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2083 cmdline_parse_inst_t cmd_config_mtu = {
2084 .f = cmd_config_mtu_parsed,
2086 .help_str = "port config mtu <port_id> <value>",
2088 (void *)&cmd_config_mtu_port,
2089 (void *)&cmd_config_mtu_keyword,
2090 (void *)&cmd_config_mtu_mtu,
2091 (void *)&cmd_config_mtu_port_id,
2092 (void *)&cmd_config_mtu_value,
2097 /* *** configure rx mode *** */
2098 struct cmd_config_rx_mode_flag {
2099 cmdline_fixed_string_t port;
2100 cmdline_fixed_string_t keyword;
2101 cmdline_fixed_string_t all;
2102 cmdline_fixed_string_t name;
2103 cmdline_fixed_string_t value;
2107 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2108 __attribute__((unused)) struct cmdline *cl,
2109 __attribute__((unused)) void *data)
2111 struct cmd_config_rx_mode_flag *res = parsed_result;
2115 if (!all_ports_stopped()) {
2116 printf("Please stop all ports first\n");
2120 RTE_ETH_FOREACH_DEV(pid) {
2121 struct rte_port *port;
2122 uint64_t rx_offloads;
2125 rx_offloads = port->dev_conf.rxmode.offloads;
2126 if (!strcmp(res->name, "crc-strip")) {
2127 if (!strcmp(res->value, "on")) {
2128 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
2129 } else if (!strcmp(res->value, "off")) {
2130 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
2132 printf("Unknown parameter\n");
2135 } else if (!strcmp(res->name, "scatter")) {
2136 if (!strcmp(res->value, "on")) {
2137 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
2138 } else if (!strcmp(res->value, "off")) {
2139 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
2141 printf("Unknown parameter\n");
2144 } else if (!strcmp(res->name, "rx-cksum")) {
2145 if (!strcmp(res->value, "on"))
2146 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
2147 else if (!strcmp(res->value, "off"))
2148 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
2150 printf("Unknown parameter\n");
2153 } else if (!strcmp(res->name, "rx-timestamp")) {
2154 if (!strcmp(res->value, "on"))
2155 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
2156 else if (!strcmp(res->value, "off"))
2157 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
2159 printf("Unknown parameter\n");
2162 } else if (!strcmp(res->name, "hw-vlan")) {
2163 if (!strcmp(res->value, "on")) {
2164 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2165 DEV_RX_OFFLOAD_VLAN_STRIP);
2166 } else if (!strcmp(res->value, "off")) {
2167 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2168 DEV_RX_OFFLOAD_VLAN_STRIP);
2170 printf("Unknown parameter\n");
2173 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2174 if (!strcmp(res->value, "on"))
2175 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2176 else if (!strcmp(res->value, "off"))
2177 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2179 printf("Unknown parameter\n");
2182 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2183 if (!strcmp(res->value, "on"))
2184 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2185 else if (!strcmp(res->value, "off"))
2186 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2188 printf("Unknown parameter\n");
2191 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2192 if (!strcmp(res->value, "on"))
2193 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2194 else if (!strcmp(res->value, "off"))
2195 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2197 printf("Unknown parameter\n");
2200 } else if (!strcmp(res->name, "drop-en")) {
2201 if (!strcmp(res->value, "on"))
2203 else if (!strcmp(res->value, "off"))
2206 printf("Unknown parameter\n");
2210 printf("Unknown parameter\n");
2213 port->dev_conf.rxmode.offloads = rx_offloads;
2214 /* Apply Rx offloads configuration */
2215 for (k = 0; k < port->dev_info.max_rx_queues; k++)
2216 port->rx_conf[k].offloads =
2217 port->dev_conf.rxmode.offloads;
2222 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2225 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2226 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2227 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2228 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2230 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2231 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2232 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2233 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2234 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2235 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2236 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2237 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2240 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2241 .f = cmd_config_rx_mode_flag_parsed,
2243 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2244 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2246 (void *)&cmd_config_rx_mode_flag_port,
2247 (void *)&cmd_config_rx_mode_flag_keyword,
2248 (void *)&cmd_config_rx_mode_flag_all,
2249 (void *)&cmd_config_rx_mode_flag_name,
2250 (void *)&cmd_config_rx_mode_flag_value,
2255 /* *** configure rss *** */
2256 struct cmd_config_rss {
2257 cmdline_fixed_string_t port;
2258 cmdline_fixed_string_t keyword;
2259 cmdline_fixed_string_t all;
2260 cmdline_fixed_string_t name;
2261 cmdline_fixed_string_t value;
2265 cmd_config_rss_parsed(void *parsed_result,
2266 __attribute__((unused)) struct cmdline *cl,
2267 __attribute__((unused)) void *data)
2269 struct cmd_config_rss *res = parsed_result;
2270 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2271 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2272 int use_default = 0;
2273 int all_updated = 1;
2277 if (!strcmp(res->value, "all"))
2278 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2279 ETH_RSS_UDP | ETH_RSS_SCTP |
2281 else if (!strcmp(res->value, "ip"))
2282 rss_conf.rss_hf = ETH_RSS_IP;
2283 else if (!strcmp(res->value, "udp"))
2284 rss_conf.rss_hf = ETH_RSS_UDP;
2285 else if (!strcmp(res->value, "tcp"))
2286 rss_conf.rss_hf = ETH_RSS_TCP;
2287 else if (!strcmp(res->value, "sctp"))
2288 rss_conf.rss_hf = ETH_RSS_SCTP;
2289 else if (!strcmp(res->value, "ether"))
2290 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2291 else if (!strcmp(res->value, "port"))
2292 rss_conf.rss_hf = ETH_RSS_PORT;
2293 else if (!strcmp(res->value, "vxlan"))
2294 rss_conf.rss_hf = ETH_RSS_VXLAN;
2295 else if (!strcmp(res->value, "geneve"))
2296 rss_conf.rss_hf = ETH_RSS_GENEVE;
2297 else if (!strcmp(res->value, "nvgre"))
2298 rss_conf.rss_hf = ETH_RSS_NVGRE;
2299 else if (!strcmp(res->value, "none"))
2300 rss_conf.rss_hf = 0;
2301 else if (!strcmp(res->value, "default"))
2303 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2304 atoi(res->value) < 64)
2305 rss_conf.rss_hf = 1ULL << atoi(res->value);
2307 printf("Unknown parameter\n");
2310 rss_conf.rss_key = NULL;
2311 /* Update global configuration for RSS types. */
2312 RTE_ETH_FOREACH_DEV(i) {
2313 struct rte_eth_rss_conf local_rss_conf;
2315 rte_eth_dev_info_get(i, &dev_info);
2317 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2319 local_rss_conf = rss_conf;
2320 local_rss_conf.rss_hf = rss_conf.rss_hf &
2321 dev_info.flow_type_rss_offloads;
2322 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2323 printf("Port %u modified RSS hash function based on hardware support,"
2324 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2325 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2327 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2330 printf("Configuration of RSS hash at ethernet port %d "
2331 "failed with error (%d): %s.\n",
2332 i, -diag, strerror(-diag));
2335 if (all_updated && !use_default)
2336 rss_hf = rss_conf.rss_hf;
2339 cmdline_parse_token_string_t cmd_config_rss_port =
2340 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2341 cmdline_parse_token_string_t cmd_config_rss_keyword =
2342 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2343 cmdline_parse_token_string_t cmd_config_rss_all =
2344 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2345 cmdline_parse_token_string_t cmd_config_rss_name =
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2347 cmdline_parse_token_string_t cmd_config_rss_value =
2348 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2350 cmdline_parse_inst_t cmd_config_rss = {
2351 .f = cmd_config_rss_parsed,
2353 .help_str = "port config all rss "
2354 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2356 (void *)&cmd_config_rss_port,
2357 (void *)&cmd_config_rss_keyword,
2358 (void *)&cmd_config_rss_all,
2359 (void *)&cmd_config_rss_name,
2360 (void *)&cmd_config_rss_value,
2365 /* *** configure rss hash key *** */
2366 struct cmd_config_rss_hash_key {
2367 cmdline_fixed_string_t port;
2368 cmdline_fixed_string_t config;
2370 cmdline_fixed_string_t rss_hash_key;
2371 cmdline_fixed_string_t rss_type;
2372 cmdline_fixed_string_t key;
2376 hexa_digit_to_value(char hexa_digit)
2378 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2379 return (uint8_t) (hexa_digit - '0');
2380 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2381 return (uint8_t) ((hexa_digit - 'a') + 10);
2382 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2383 return (uint8_t) ((hexa_digit - 'A') + 10);
2384 /* Invalid hexa digit */
2389 parse_and_check_key_hexa_digit(char *key, int idx)
2393 hexa_v = hexa_digit_to_value(key[idx]);
2395 printf("invalid key: character %c at position %d is not a "
2396 "valid hexa digit\n", key[idx], idx);
2401 cmd_config_rss_hash_key_parsed(void *parsed_result,
2402 __attribute__((unused)) struct cmdline *cl,
2403 __attribute__((unused)) void *data)
2405 struct cmd_config_rss_hash_key *res = parsed_result;
2406 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2410 struct rte_eth_dev_info dev_info;
2411 uint8_t hash_key_size;
2414 memset(&dev_info, 0, sizeof(dev_info));
2415 rte_eth_dev_info_get(res->port_id, &dev_info);
2416 if (dev_info.hash_key_size > 0 &&
2417 dev_info.hash_key_size <= sizeof(hash_key))
2418 hash_key_size = dev_info.hash_key_size;
2420 printf("dev_info did not provide a valid hash key size\n");
2423 /* Check the length of the RSS hash key */
2424 key_len = strlen(res->key);
2425 if (key_len != (hash_key_size * 2)) {
2426 printf("key length: %d invalid - key must be a string of %d"
2427 " hexa-decimal numbers\n",
2428 (int) key_len, hash_key_size * 2);
2431 /* Translate RSS hash key into binary representation */
2432 for (i = 0; i < hash_key_size; i++) {
2433 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2436 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2439 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2441 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2445 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2446 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2447 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2448 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2450 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2451 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2452 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2454 rss_hash_key, "rss-hash-key");
2455 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2456 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2457 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2458 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2459 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2460 "ipv6-tcp-ex#ipv6-udp-ex");
2461 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2462 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2464 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2465 .f = cmd_config_rss_hash_key_parsed,
2467 .help_str = "port config <port_id> rss-hash-key "
2468 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2469 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2470 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
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 memset(&dev_info, 0, sizeof(dev_info));
2948 rte_eth_dev_info_get(res->port_id, &dev_info);
2949 if (dev_info.reta_size == 0) {
2950 printf("Redirection table size is 0 which is "
2951 "invalid for RSS\n");
2954 printf("The reta size of port %d is %u\n",
2955 res->port_id, dev_info.reta_size);
2956 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2957 printf("Currently do not support more than %u entries of "
2958 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2962 memset(reta_conf, 0, sizeof(reta_conf));
2963 if (!strcmp(res->list_name, "reta")) {
2964 if (parse_reta_config(res->list_of_items, reta_conf,
2965 dev_info.reta_size)) {
2966 printf("Invalid RSS Redirection Table "
2967 "config entered\n");
2970 ret = rte_eth_dev_rss_reta_update(res->port_id,
2971 reta_conf, dev_info.reta_size);
2973 printf("Bad redirection table parameter, "
2974 "return code = %d \n", ret);
2978 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2979 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2980 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2981 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2982 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2983 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2984 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2985 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2986 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2987 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2988 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2989 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2991 cmdline_parse_inst_t cmd_config_rss_reta = {
2992 .f = cmd_set_rss_reta_parsed,
2994 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2996 (void *)&cmd_config_rss_reta_port,
2997 (void *)&cmd_config_rss_reta_keyword,
2998 (void *)&cmd_config_rss_reta_port_id,
2999 (void *)&cmd_config_rss_reta_name,
3000 (void *)&cmd_config_rss_reta_list_name,
3001 (void *)&cmd_config_rss_reta_list_of_items,
3006 /* *** SHOW PORT RETA INFO *** */
3007 struct cmd_showport_reta {
3008 cmdline_fixed_string_t show;
3009 cmdline_fixed_string_t port;
3011 cmdline_fixed_string_t rss;
3012 cmdline_fixed_string_t reta;
3014 cmdline_fixed_string_t list_of_items;
3018 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3019 uint16_t nb_entries,
3023 const char *p, *p0 = str;
3028 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3029 RTE_RETA_GROUP_SIZE;
3032 p = strchr(p0, '(');
3036 p0 = strchr(p, ')');
3040 if (size >= sizeof(s)) {
3041 printf("The string size exceeds the internal buffer size\n");
3044 snprintf(s, sizeof(s), "%.*s", size, p);
3045 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3046 if (ret <= 0 || ret != num) {
3047 printf("The bits of masks do not match the number of "
3048 "reta entries: %u\n", num);
3051 for (i = 0; i < ret; i++)
3052 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3058 cmd_showport_reta_parsed(void *parsed_result,
3059 __attribute__((unused)) struct cmdline *cl,
3060 __attribute__((unused)) void *data)
3062 struct cmd_showport_reta *res = parsed_result;
3063 struct rte_eth_rss_reta_entry64 reta_conf[8];
3064 struct rte_eth_dev_info dev_info;
3065 uint16_t max_reta_size;
3067 memset(&dev_info, 0, sizeof(dev_info));
3068 rte_eth_dev_info_get(res->port_id, &dev_info);
3069 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3070 if (res->size == 0 || res->size > max_reta_size) {
3071 printf("Invalid redirection table size: %u (1-%u)\n",
3072 res->size, max_reta_size);
3076 memset(reta_conf, 0, sizeof(reta_conf));
3077 if (showport_parse_reta_config(reta_conf, res->size,
3078 res->list_of_items) < 0) {
3079 printf("Invalid string: %s for reta masks\n",
3080 res->list_of_items);
3083 port_rss_reta_info(res->port_id, reta_conf, res->size);
3086 cmdline_parse_token_string_t cmd_showport_reta_show =
3087 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3088 cmdline_parse_token_string_t cmd_showport_reta_port =
3089 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3090 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3091 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3092 cmdline_parse_token_string_t cmd_showport_reta_rss =
3093 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3094 cmdline_parse_token_string_t cmd_showport_reta_reta =
3095 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3096 cmdline_parse_token_num_t cmd_showport_reta_size =
3097 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3098 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3099 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3100 list_of_items, NULL);
3102 cmdline_parse_inst_t cmd_showport_reta = {
3103 .f = cmd_showport_reta_parsed,
3105 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3107 (void *)&cmd_showport_reta_show,
3108 (void *)&cmd_showport_reta_port,
3109 (void *)&cmd_showport_reta_port_id,
3110 (void *)&cmd_showport_reta_rss,
3111 (void *)&cmd_showport_reta_reta,
3112 (void *)&cmd_showport_reta_size,
3113 (void *)&cmd_showport_reta_list_of_items,
3118 /* *** Show RSS hash configuration *** */
3119 struct cmd_showport_rss_hash {
3120 cmdline_fixed_string_t show;
3121 cmdline_fixed_string_t port;
3123 cmdline_fixed_string_t rss_hash;
3124 cmdline_fixed_string_t rss_type;
3125 cmdline_fixed_string_t key; /* optional argument */
3128 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3129 __attribute__((unused)) struct cmdline *cl,
3132 struct cmd_showport_rss_hash *res = parsed_result;
3134 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3137 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3138 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3139 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3140 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3141 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3142 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3143 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3144 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3146 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3147 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3149 cmdline_parse_inst_t cmd_showport_rss_hash = {
3150 .f = cmd_showport_rss_hash_parsed,
3152 .help_str = "show port <port_id> rss-hash",
3154 (void *)&cmd_showport_rss_hash_show,
3155 (void *)&cmd_showport_rss_hash_port,
3156 (void *)&cmd_showport_rss_hash_port_id,
3157 (void *)&cmd_showport_rss_hash_rss_hash,
3162 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3163 .f = cmd_showport_rss_hash_parsed,
3165 .help_str = "show port <port_id> rss-hash key",
3167 (void *)&cmd_showport_rss_hash_show,
3168 (void *)&cmd_showport_rss_hash_port,
3169 (void *)&cmd_showport_rss_hash_port_id,
3170 (void *)&cmd_showport_rss_hash_rss_hash,
3171 (void *)&cmd_showport_rss_hash_rss_key,
3176 /* *** Configure DCB *** */
3177 struct cmd_config_dcb {
3178 cmdline_fixed_string_t port;
3179 cmdline_fixed_string_t config;
3181 cmdline_fixed_string_t dcb;
3182 cmdline_fixed_string_t vt;
3183 cmdline_fixed_string_t vt_en;
3185 cmdline_fixed_string_t pfc;
3186 cmdline_fixed_string_t pfc_en;
3190 cmd_config_dcb_parsed(void *parsed_result,
3191 __attribute__((unused)) struct cmdline *cl,
3192 __attribute__((unused)) void *data)
3194 struct cmd_config_dcb *res = parsed_result;
3195 portid_t port_id = res->port_id;
3196 struct rte_port *port;
3200 port = &ports[port_id];
3201 /** Check if the port is not started **/
3202 if (port->port_status != RTE_PORT_STOPPED) {
3203 printf("Please stop port %d first\n", port_id);
3207 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3208 printf("The invalid number of traffic class,"
3209 " only 4 or 8 allowed.\n");
3213 if (nb_fwd_lcores < res->num_tcs) {
3214 printf("nb_cores shouldn't be less than number of TCs.\n");
3217 if (!strncmp(res->pfc_en, "on", 2))
3222 /* DCB in VT mode */
3223 if (!strncmp(res->vt_en, "on", 2))
3224 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3225 (enum rte_eth_nb_tcs)res->num_tcs,
3228 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3229 (enum rte_eth_nb_tcs)res->num_tcs,
3234 printf("Cannot initialize network ports.\n");
3238 cmd_reconfig_device_queue(port_id, 1, 1);
3241 cmdline_parse_token_string_t cmd_config_dcb_port =
3242 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3243 cmdline_parse_token_string_t cmd_config_dcb_config =
3244 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3245 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3246 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3247 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3248 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3249 cmdline_parse_token_string_t cmd_config_dcb_vt =
3250 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3251 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3252 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3253 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3254 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3255 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3256 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3257 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3258 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3260 cmdline_parse_inst_t cmd_config_dcb = {
3261 .f = cmd_config_dcb_parsed,
3263 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3265 (void *)&cmd_config_dcb_port,
3266 (void *)&cmd_config_dcb_config,
3267 (void *)&cmd_config_dcb_port_id,
3268 (void *)&cmd_config_dcb_dcb,
3269 (void *)&cmd_config_dcb_vt,
3270 (void *)&cmd_config_dcb_vt_en,
3271 (void *)&cmd_config_dcb_num_tcs,
3272 (void *)&cmd_config_dcb_pfc,
3273 (void *)&cmd_config_dcb_pfc_en,
3278 /* *** configure number of packets per burst *** */
3279 struct cmd_config_burst {
3280 cmdline_fixed_string_t port;
3281 cmdline_fixed_string_t keyword;
3282 cmdline_fixed_string_t all;
3283 cmdline_fixed_string_t name;
3288 cmd_config_burst_parsed(void *parsed_result,
3289 __attribute__((unused)) struct cmdline *cl,
3290 __attribute__((unused)) void *data)
3292 struct cmd_config_burst *res = parsed_result;
3293 struct rte_eth_dev_info dev_info;
3294 uint16_t rec_nb_pkts;
3296 if (!all_ports_stopped()) {
3297 printf("Please stop all ports first\n");
3301 if (!strcmp(res->name, "burst")) {
3302 if (res->value == 0) {
3303 /* If user gives a value of zero, query the PMD for
3304 * its recommended Rx burst size. Testpmd uses a single
3305 * size for all ports, so assume all ports are the same
3306 * NIC model and use the values from Port 0.
3308 rte_eth_dev_info_get(0, &dev_info);
3309 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3311 if (rec_nb_pkts == 0) {
3312 printf("PMD does not recommend a burst size.\n"
3313 "User provided value must be between"
3314 " 1 and %d\n", MAX_PKT_BURST);
3316 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3317 printf("PMD recommended burst size of %d"
3318 " exceeds maximum value of %d\n",
3319 rec_nb_pkts, MAX_PKT_BURST);
3322 printf("Using PMD-provided burst value of %d\n",
3324 nb_pkt_per_burst = rec_nb_pkts;
3325 } else if (res->value > MAX_PKT_BURST) {
3326 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3329 nb_pkt_per_burst = res->value;
3331 printf("Unknown parameter\n");
3337 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3340 cmdline_parse_token_string_t cmd_config_burst_port =
3341 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3342 cmdline_parse_token_string_t cmd_config_burst_keyword =
3343 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3344 cmdline_parse_token_string_t cmd_config_burst_all =
3345 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3346 cmdline_parse_token_string_t cmd_config_burst_name =
3347 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3348 cmdline_parse_token_num_t cmd_config_burst_value =
3349 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3351 cmdline_parse_inst_t cmd_config_burst = {
3352 .f = cmd_config_burst_parsed,
3354 .help_str = "port config all burst <value>",
3356 (void *)&cmd_config_burst_port,
3357 (void *)&cmd_config_burst_keyword,
3358 (void *)&cmd_config_burst_all,
3359 (void *)&cmd_config_burst_name,
3360 (void *)&cmd_config_burst_value,
3365 /* *** configure rx/tx queues *** */
3366 struct cmd_config_thresh {
3367 cmdline_fixed_string_t port;
3368 cmdline_fixed_string_t keyword;
3369 cmdline_fixed_string_t all;
3370 cmdline_fixed_string_t name;
3375 cmd_config_thresh_parsed(void *parsed_result,
3376 __attribute__((unused)) struct cmdline *cl,
3377 __attribute__((unused)) void *data)
3379 struct cmd_config_thresh *res = parsed_result;
3381 if (!all_ports_stopped()) {
3382 printf("Please stop all ports first\n");
3386 if (!strcmp(res->name, "txpt"))
3387 tx_pthresh = res->value;
3388 else if(!strcmp(res->name, "txht"))
3389 tx_hthresh = res->value;
3390 else if(!strcmp(res->name, "txwt"))
3391 tx_wthresh = res->value;
3392 else if(!strcmp(res->name, "rxpt"))
3393 rx_pthresh = res->value;
3394 else if(!strcmp(res->name, "rxht"))
3395 rx_hthresh = res->value;
3396 else if(!strcmp(res->name, "rxwt"))
3397 rx_wthresh = res->value;
3399 printf("Unknown parameter\n");
3405 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3408 cmdline_parse_token_string_t cmd_config_thresh_port =
3409 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3410 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3411 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3412 cmdline_parse_token_string_t cmd_config_thresh_all =
3413 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3414 cmdline_parse_token_string_t cmd_config_thresh_name =
3415 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3416 "txpt#txht#txwt#rxpt#rxht#rxwt");
3417 cmdline_parse_token_num_t cmd_config_thresh_value =
3418 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3420 cmdline_parse_inst_t cmd_config_thresh = {
3421 .f = cmd_config_thresh_parsed,
3423 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3425 (void *)&cmd_config_thresh_port,
3426 (void *)&cmd_config_thresh_keyword,
3427 (void *)&cmd_config_thresh_all,
3428 (void *)&cmd_config_thresh_name,
3429 (void *)&cmd_config_thresh_value,
3434 /* *** configure free/rs threshold *** */
3435 struct cmd_config_threshold {
3436 cmdline_fixed_string_t port;
3437 cmdline_fixed_string_t keyword;
3438 cmdline_fixed_string_t all;
3439 cmdline_fixed_string_t name;
3444 cmd_config_threshold_parsed(void *parsed_result,
3445 __attribute__((unused)) struct cmdline *cl,
3446 __attribute__((unused)) void *data)
3448 struct cmd_config_threshold *res = parsed_result;
3450 if (!all_ports_stopped()) {
3451 printf("Please stop all ports first\n");
3455 if (!strcmp(res->name, "txfreet"))
3456 tx_free_thresh = res->value;
3457 else if (!strcmp(res->name, "txrst"))
3458 tx_rs_thresh = res->value;
3459 else if (!strcmp(res->name, "rxfreet"))
3460 rx_free_thresh = res->value;
3462 printf("Unknown parameter\n");
3468 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3471 cmdline_parse_token_string_t cmd_config_threshold_port =
3472 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3473 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3474 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3476 cmdline_parse_token_string_t cmd_config_threshold_all =
3477 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3478 cmdline_parse_token_string_t cmd_config_threshold_name =
3479 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3480 "txfreet#txrst#rxfreet");
3481 cmdline_parse_token_num_t cmd_config_threshold_value =
3482 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3484 cmdline_parse_inst_t cmd_config_threshold = {
3485 .f = cmd_config_threshold_parsed,
3487 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3489 (void *)&cmd_config_threshold_port,
3490 (void *)&cmd_config_threshold_keyword,
3491 (void *)&cmd_config_threshold_all,
3492 (void *)&cmd_config_threshold_name,
3493 (void *)&cmd_config_threshold_value,
3499 struct cmd_stop_result {
3500 cmdline_fixed_string_t stop;
3503 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3504 __attribute__((unused)) struct cmdline *cl,
3505 __attribute__((unused)) void *data)
3507 stop_packet_forwarding();
3510 cmdline_parse_token_string_t cmd_stop_stop =
3511 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3513 cmdline_parse_inst_t cmd_stop = {
3514 .f = cmd_stop_parsed,
3516 .help_str = "stop: Stop packet forwarding",
3518 (void *)&cmd_stop_stop,
3523 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3526 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3527 unsigned int *parsed_items, int check_unique_values)
3529 unsigned int nb_item;
3537 * First parse all items in the list and store their value.
3542 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3544 if ((c >= '0') && (c <= '9')) {
3545 value = (unsigned int) (value * 10 + (c - '0'));
3550 printf("character %c is not a decimal digit\n", c);
3554 printf("No valid value before comma\n");
3557 if (nb_item < max_items) {
3558 parsed_items[nb_item] = value;
3564 if (nb_item >= max_items) {
3565 printf("Number of %s = %u > %u (maximum items)\n",
3566 item_name, nb_item + 1, max_items);
3569 parsed_items[nb_item++] = value;
3570 if (! check_unique_values)
3574 * Then, check that all values in the list are differents.
3575 * No optimization here...
3577 for (i = 0; i < nb_item; i++) {
3578 for (j = i + 1; j < nb_item; j++) {
3579 if (parsed_items[j] == parsed_items[i]) {
3580 printf("duplicated %s %u at index %u and %u\n",
3581 item_name, parsed_items[i], i, j);
3589 struct cmd_set_list_result {
3590 cmdline_fixed_string_t cmd_keyword;
3591 cmdline_fixed_string_t list_name;
3592 cmdline_fixed_string_t list_of_items;
3595 static void cmd_set_list_parsed(void *parsed_result,
3596 __attribute__((unused)) struct cmdline *cl,
3597 __attribute__((unused)) void *data)
3599 struct cmd_set_list_result *res;
3601 unsigned int lcorelist[RTE_MAX_LCORE];
3602 unsigned int portlist[RTE_MAX_ETHPORTS];
3604 unsigned int nb_item;
3606 if (test_done == 0) {
3607 printf("Please stop forwarding first\n");
3611 res = parsed_result;
3612 if (!strcmp(res->list_name, "corelist")) {
3613 nb_item = parse_item_list(res->list_of_items, "core",
3615 parsed_items.lcorelist, 1);
3617 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3622 if (!strcmp(res->list_name, "portlist")) {
3623 nb_item = parse_item_list(res->list_of_items, "port",
3625 parsed_items.portlist, 1);
3627 set_fwd_ports_list(parsed_items.portlist, nb_item);
3633 cmdline_parse_token_string_t cmd_set_list_keyword =
3634 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3636 cmdline_parse_token_string_t cmd_set_list_name =
3637 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3638 "corelist#portlist");
3639 cmdline_parse_token_string_t cmd_set_list_of_items =
3640 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3643 cmdline_parse_inst_t cmd_set_fwd_list = {
3644 .f = cmd_set_list_parsed,
3646 .help_str = "set corelist|portlist <list0[,list1]*>",
3648 (void *)&cmd_set_list_keyword,
3649 (void *)&cmd_set_list_name,
3650 (void *)&cmd_set_list_of_items,
3655 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3657 struct cmd_setmask_result {
3658 cmdline_fixed_string_t set;
3659 cmdline_fixed_string_t mask;
3663 static void cmd_set_mask_parsed(void *parsed_result,
3664 __attribute__((unused)) struct cmdline *cl,
3665 __attribute__((unused)) void *data)
3667 struct cmd_setmask_result *res = parsed_result;
3669 if (test_done == 0) {
3670 printf("Please stop forwarding first\n");
3673 if (!strcmp(res->mask, "coremask")) {
3674 set_fwd_lcores_mask(res->hexavalue);
3676 } else if (!strcmp(res->mask, "portmask")) {
3677 set_fwd_ports_mask(res->hexavalue);
3682 cmdline_parse_token_string_t cmd_setmask_set =
3683 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3684 cmdline_parse_token_string_t cmd_setmask_mask =
3685 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3686 "coremask#portmask");
3687 cmdline_parse_token_num_t cmd_setmask_value =
3688 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3690 cmdline_parse_inst_t cmd_set_fwd_mask = {
3691 .f = cmd_set_mask_parsed,
3693 .help_str = "set coremask|portmask <hexadecimal value>",
3695 (void *)&cmd_setmask_set,
3696 (void *)&cmd_setmask_mask,
3697 (void *)&cmd_setmask_value,
3703 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3705 struct cmd_set_result {
3706 cmdline_fixed_string_t set;
3707 cmdline_fixed_string_t what;
3711 static void cmd_set_parsed(void *parsed_result,
3712 __attribute__((unused)) struct cmdline *cl,
3713 __attribute__((unused)) void *data)
3715 struct cmd_set_result *res = parsed_result;
3716 if (!strcmp(res->what, "nbport")) {
3717 set_fwd_ports_number(res->value);
3719 } else if (!strcmp(res->what, "nbcore")) {
3720 set_fwd_lcores_number(res->value);
3722 } else if (!strcmp(res->what, "burst"))
3723 set_nb_pkt_per_burst(res->value);
3724 else if (!strcmp(res->what, "verbose"))
3725 set_verbose_level(res->value);
3728 cmdline_parse_token_string_t cmd_set_set =
3729 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3730 cmdline_parse_token_string_t cmd_set_what =
3731 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3732 "nbport#nbcore#burst#verbose");
3733 cmdline_parse_token_num_t cmd_set_value =
3734 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3736 cmdline_parse_inst_t cmd_set_numbers = {
3737 .f = cmd_set_parsed,
3739 .help_str = "set nbport|nbcore|burst|verbose <value>",
3741 (void *)&cmd_set_set,
3742 (void *)&cmd_set_what,
3743 (void *)&cmd_set_value,
3748 /* *** SET LOG LEVEL CONFIGURATION *** */
3750 struct cmd_set_log_result {
3751 cmdline_fixed_string_t set;
3752 cmdline_fixed_string_t log;
3753 cmdline_fixed_string_t type;
3758 cmd_set_log_parsed(void *parsed_result,
3759 __attribute__((unused)) struct cmdline *cl,
3760 __attribute__((unused)) void *data)
3762 struct cmd_set_log_result *res;
3765 res = parsed_result;
3766 if (!strcmp(res->type, "global"))
3767 rte_log_set_global_level(res->level);
3769 ret = rte_log_set_level_regexp(res->type, res->level);
3771 printf("Unable to set log level\n");
3775 cmdline_parse_token_string_t cmd_set_log_set =
3776 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3777 cmdline_parse_token_string_t cmd_set_log_log =
3778 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3779 cmdline_parse_token_string_t cmd_set_log_type =
3780 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3781 cmdline_parse_token_num_t cmd_set_log_level =
3782 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3784 cmdline_parse_inst_t cmd_set_log = {
3785 .f = cmd_set_log_parsed,
3787 .help_str = "set log global|<type> <level>",
3789 (void *)&cmd_set_log_set,
3790 (void *)&cmd_set_log_log,
3791 (void *)&cmd_set_log_type,
3792 (void *)&cmd_set_log_level,
3797 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3799 struct cmd_set_txpkts_result {
3800 cmdline_fixed_string_t cmd_keyword;
3801 cmdline_fixed_string_t txpkts;
3802 cmdline_fixed_string_t seg_lengths;
3806 cmd_set_txpkts_parsed(void *parsed_result,
3807 __attribute__((unused)) struct cmdline *cl,
3808 __attribute__((unused)) void *data)
3810 struct cmd_set_txpkts_result *res;
3811 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3812 unsigned int nb_segs;
3814 res = parsed_result;
3815 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3816 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3818 set_tx_pkt_segments(seg_lengths, nb_segs);
3821 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3822 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3823 cmd_keyword, "set");
3824 cmdline_parse_token_string_t cmd_set_txpkts_name =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3827 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3828 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3831 cmdline_parse_inst_t cmd_set_txpkts = {
3832 .f = cmd_set_txpkts_parsed,
3834 .help_str = "set txpkts <len0[,len1]*>",
3836 (void *)&cmd_set_txpkts_keyword,
3837 (void *)&cmd_set_txpkts_name,
3838 (void *)&cmd_set_txpkts_lengths,
3843 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3845 struct cmd_set_txsplit_result {
3846 cmdline_fixed_string_t cmd_keyword;
3847 cmdline_fixed_string_t txsplit;
3848 cmdline_fixed_string_t mode;
3852 cmd_set_txsplit_parsed(void *parsed_result,
3853 __attribute__((unused)) struct cmdline *cl,
3854 __attribute__((unused)) void *data)
3856 struct cmd_set_txsplit_result *res;
3858 res = parsed_result;
3859 set_tx_pkt_split(res->mode);
3862 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3863 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3864 cmd_keyword, "set");
3865 cmdline_parse_token_string_t cmd_set_txsplit_name =
3866 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3867 txsplit, "txsplit");
3868 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3869 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3872 cmdline_parse_inst_t cmd_set_txsplit = {
3873 .f = cmd_set_txsplit_parsed,
3875 .help_str = "set txsplit on|off|rand",
3877 (void *)&cmd_set_txsplit_keyword,
3878 (void *)&cmd_set_txsplit_name,
3879 (void *)&cmd_set_txsplit_mode,
3884 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3885 struct cmd_rx_vlan_filter_all_result {
3886 cmdline_fixed_string_t rx_vlan;
3887 cmdline_fixed_string_t what;
3888 cmdline_fixed_string_t all;
3893 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3894 __attribute__((unused)) struct cmdline *cl,
3895 __attribute__((unused)) void *data)
3897 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3899 if (!strcmp(res->what, "add"))
3900 rx_vlan_all_filter_set(res->port_id, 1);
3902 rx_vlan_all_filter_set(res->port_id, 0);
3905 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3906 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3907 rx_vlan, "rx_vlan");
3908 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3909 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3911 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3912 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3914 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3915 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3918 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3919 .f = cmd_rx_vlan_filter_all_parsed,
3921 .help_str = "rx_vlan add|rm all <port_id>: "
3922 "Add/Remove all identifiers to/from the set of VLAN "
3923 "identifiers filtered by a port",
3925 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3926 (void *)&cmd_rx_vlan_filter_all_what,
3927 (void *)&cmd_rx_vlan_filter_all_all,
3928 (void *)&cmd_rx_vlan_filter_all_portid,
3933 /* *** VLAN OFFLOAD SET ON A PORT *** */
3934 struct cmd_vlan_offload_result {
3935 cmdline_fixed_string_t vlan;
3936 cmdline_fixed_string_t set;
3937 cmdline_fixed_string_t vlan_type;
3938 cmdline_fixed_string_t what;
3939 cmdline_fixed_string_t on;
3940 cmdline_fixed_string_t port_id;
3944 cmd_vlan_offload_parsed(void *parsed_result,
3945 __attribute__((unused)) struct cmdline *cl,
3946 __attribute__((unused)) void *data)
3949 struct cmd_vlan_offload_result *res = parsed_result;
3952 portid_t port_id = 0;
3956 len = strnlen(str, STR_TOKEN_SIZE);
3958 /* Get port_id first */
3966 tmp = strtoul(str, NULL, 0);
3967 /* If port_id greater that what portid_t can represent, return */
3968 if(tmp >= RTE_MAX_ETHPORTS)
3970 port_id = (portid_t)tmp;
3972 if (!strcmp(res->on, "on"))
3977 if (!strcmp(res->what, "strip"))
3978 rx_vlan_strip_set(port_id, on);
3979 else if(!strcmp(res->what, "stripq")){
3980 uint16_t queue_id = 0;
3982 /* No queue_id, return */
3984 printf("must specify (port,queue_id)\n");
3987 tmp = strtoul(str + i + 1, NULL, 0);
3988 /* If queue_id greater that what 16-bits can represent, return */
3992 queue_id = (uint16_t)tmp;
3993 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3995 else if (!strcmp(res->what, "filter"))
3996 rx_vlan_filter_set(port_id, on);
3998 vlan_extend_set(port_id, on);
4003 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4004 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4006 cmdline_parse_token_string_t cmd_vlan_offload_set =
4007 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4009 cmdline_parse_token_string_t cmd_vlan_offload_what =
4010 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4011 what, "strip#filter#qinq#stripq");
4012 cmdline_parse_token_string_t cmd_vlan_offload_on =
4013 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4015 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4016 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4019 cmdline_parse_inst_t cmd_vlan_offload = {
4020 .f = cmd_vlan_offload_parsed,
4022 .help_str = "vlan set strip|filter|qinq|stripq on|off "
4023 "<port_id[,queue_id]>: "
4024 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
4026 (void *)&cmd_vlan_offload_vlan,
4027 (void *)&cmd_vlan_offload_set,
4028 (void *)&cmd_vlan_offload_what,
4029 (void *)&cmd_vlan_offload_on,
4030 (void *)&cmd_vlan_offload_portid,
4035 /* *** VLAN TPID SET ON A PORT *** */
4036 struct cmd_vlan_tpid_result {
4037 cmdline_fixed_string_t vlan;
4038 cmdline_fixed_string_t set;
4039 cmdline_fixed_string_t vlan_type;
4040 cmdline_fixed_string_t what;
4046 cmd_vlan_tpid_parsed(void *parsed_result,
4047 __attribute__((unused)) struct cmdline *cl,
4048 __attribute__((unused)) void *data)
4050 struct cmd_vlan_tpid_result *res = parsed_result;
4051 enum rte_vlan_type vlan_type;
4053 if (!strcmp(res->vlan_type, "inner"))
4054 vlan_type = ETH_VLAN_TYPE_INNER;
4055 else if (!strcmp(res->vlan_type, "outer"))
4056 vlan_type = ETH_VLAN_TYPE_OUTER;
4058 printf("Unknown vlan type\n");
4061 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4064 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4065 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4067 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4068 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4070 cmdline_parse_token_string_t cmd_vlan_type =
4071 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4072 vlan_type, "inner#outer");
4073 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4074 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4076 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4077 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4079 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4080 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4083 cmdline_parse_inst_t cmd_vlan_tpid = {
4084 .f = cmd_vlan_tpid_parsed,
4086 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4087 "Set the VLAN Ether type",
4089 (void *)&cmd_vlan_tpid_vlan,
4090 (void *)&cmd_vlan_tpid_set,
4091 (void *)&cmd_vlan_type,
4092 (void *)&cmd_vlan_tpid_what,
4093 (void *)&cmd_vlan_tpid_tpid,
4094 (void *)&cmd_vlan_tpid_portid,
4099 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4100 struct cmd_rx_vlan_filter_result {
4101 cmdline_fixed_string_t rx_vlan;
4102 cmdline_fixed_string_t what;
4108 cmd_rx_vlan_filter_parsed(void *parsed_result,
4109 __attribute__((unused)) struct cmdline *cl,
4110 __attribute__((unused)) void *data)
4112 struct cmd_rx_vlan_filter_result *res = parsed_result;
4114 if (!strcmp(res->what, "add"))
4115 rx_vft_set(res->port_id, res->vlan_id, 1);
4117 rx_vft_set(res->port_id, res->vlan_id, 0);
4120 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4121 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4122 rx_vlan, "rx_vlan");
4123 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4124 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4126 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4127 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4129 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4130 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4133 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4134 .f = cmd_rx_vlan_filter_parsed,
4136 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4137 "Add/Remove a VLAN identifier to/from the set of VLAN "
4138 "identifiers filtered by a port",
4140 (void *)&cmd_rx_vlan_filter_rx_vlan,
4141 (void *)&cmd_rx_vlan_filter_what,
4142 (void *)&cmd_rx_vlan_filter_vlanid,
4143 (void *)&cmd_rx_vlan_filter_portid,
4148 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4149 struct cmd_tx_vlan_set_result {
4150 cmdline_fixed_string_t tx_vlan;
4151 cmdline_fixed_string_t set;
4157 cmd_tx_vlan_set_parsed(void *parsed_result,
4158 __attribute__((unused)) struct cmdline *cl,
4159 __attribute__((unused)) void *data)
4161 struct cmd_tx_vlan_set_result *res = parsed_result;
4163 if (!port_is_stopped(res->port_id)) {
4164 printf("Please stop port %d first\n", res->port_id);
4168 tx_vlan_set(res->port_id, res->vlan_id);
4170 cmd_reconfig_device_queue(res->port_id, 1, 1);
4173 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4174 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4175 tx_vlan, "tx_vlan");
4176 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4177 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4179 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4180 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4182 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4183 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4186 cmdline_parse_inst_t cmd_tx_vlan_set = {
4187 .f = cmd_tx_vlan_set_parsed,
4189 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4190 "Enable hardware insertion of a single VLAN header "
4191 "with a given TAG Identifier in packets sent on a port",
4193 (void *)&cmd_tx_vlan_set_tx_vlan,
4194 (void *)&cmd_tx_vlan_set_set,
4195 (void *)&cmd_tx_vlan_set_portid,
4196 (void *)&cmd_tx_vlan_set_vlanid,
4201 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4202 struct cmd_tx_vlan_set_qinq_result {
4203 cmdline_fixed_string_t tx_vlan;
4204 cmdline_fixed_string_t set;
4207 uint16_t vlan_id_outer;
4211 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4212 __attribute__((unused)) struct cmdline *cl,
4213 __attribute__((unused)) void *data)
4215 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4217 if (!port_is_stopped(res->port_id)) {
4218 printf("Please stop port %d first\n", res->port_id);
4222 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4224 cmd_reconfig_device_queue(res->port_id, 1, 1);
4227 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4228 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4229 tx_vlan, "tx_vlan");
4230 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4231 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4233 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4234 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4236 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4237 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4239 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4240 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4241 vlan_id_outer, UINT16);
4243 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4244 .f = cmd_tx_vlan_set_qinq_parsed,
4246 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4247 "Enable hardware insertion of double VLAN header "
4248 "with given TAG Identifiers in packets sent on a port",
4250 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4251 (void *)&cmd_tx_vlan_set_qinq_set,
4252 (void *)&cmd_tx_vlan_set_qinq_portid,
4253 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4254 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4259 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4260 struct cmd_tx_vlan_set_pvid_result {
4261 cmdline_fixed_string_t tx_vlan;
4262 cmdline_fixed_string_t set;
4263 cmdline_fixed_string_t pvid;
4266 cmdline_fixed_string_t mode;
4270 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4271 __attribute__((unused)) struct cmdline *cl,
4272 __attribute__((unused)) void *data)
4274 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4276 if (strcmp(res->mode, "on") == 0)
4277 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4279 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4282 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4283 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4284 tx_vlan, "tx_vlan");
4285 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4286 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4288 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4289 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4291 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4292 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4294 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4295 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4297 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4298 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4301 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4302 .f = cmd_tx_vlan_set_pvid_parsed,
4304 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4306 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4307 (void *)&cmd_tx_vlan_set_pvid_set,
4308 (void *)&cmd_tx_vlan_set_pvid_pvid,
4309 (void *)&cmd_tx_vlan_set_pvid_port_id,
4310 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4311 (void *)&cmd_tx_vlan_set_pvid_mode,
4316 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4317 struct cmd_tx_vlan_reset_result {
4318 cmdline_fixed_string_t tx_vlan;
4319 cmdline_fixed_string_t reset;
4324 cmd_tx_vlan_reset_parsed(void *parsed_result,
4325 __attribute__((unused)) struct cmdline *cl,
4326 __attribute__((unused)) void *data)
4328 struct cmd_tx_vlan_reset_result *res = parsed_result;
4330 if (!port_is_stopped(res->port_id)) {
4331 printf("Please stop port %d first\n", res->port_id);
4335 tx_vlan_reset(res->port_id);
4337 cmd_reconfig_device_queue(res->port_id, 1, 1);
4340 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4341 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4342 tx_vlan, "tx_vlan");
4343 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4344 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4346 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4347 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4350 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4351 .f = cmd_tx_vlan_reset_parsed,
4353 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4354 "VLAN header in packets sent on a port",
4356 (void *)&cmd_tx_vlan_reset_tx_vlan,
4357 (void *)&cmd_tx_vlan_reset_reset,
4358 (void *)&cmd_tx_vlan_reset_portid,
4364 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4365 struct cmd_csum_result {
4366 cmdline_fixed_string_t csum;
4367 cmdline_fixed_string_t mode;
4368 cmdline_fixed_string_t proto;
4369 cmdline_fixed_string_t hwsw;
4374 csum_show(int port_id)
4376 struct rte_eth_dev_info dev_info;
4377 uint64_t tx_offloads;
4379 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4380 printf("Parse tunnel is %s\n",
4381 (ports[port_id].parse_tunnel) ? "on" : "off");
4382 printf("IP checksum offload is %s\n",
4383 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4384 printf("UDP checksum offload is %s\n",
4385 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4386 printf("TCP checksum offload is %s\n",
4387 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4388 printf("SCTP checksum offload is %s\n",
4389 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4390 printf("Outer-Ip checksum offload is %s\n",
4391 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4392 printf("Outer-Udp checksum offload is %s\n",
4393 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4395 /* display warnings if configuration is not supported by the NIC */
4396 rte_eth_dev_info_get(port_id, &dev_info);
4397 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4398 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4399 printf("Warning: hardware IP checksum enabled but not "
4400 "supported by port %d\n", port_id);
4402 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4403 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4404 printf("Warning: hardware UDP checksum enabled but not "
4405 "supported by port %d\n", port_id);
4407 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4408 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4409 printf("Warning: hardware TCP checksum enabled but not "
4410 "supported by port %d\n", port_id);
4412 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4413 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4414 printf("Warning: hardware SCTP checksum enabled but not "
4415 "supported by port %d\n", port_id);
4417 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4418 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4419 printf("Warning: hardware outer IP checksum enabled but not "
4420 "supported by port %d\n", port_id);
4422 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4423 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4425 printf("Warning: hardware outer UDP checksum enabled but not "
4426 "supported by port %d\n", port_id);
4431 cmd_config_queue_tx_offloads(struct rte_port *port)
4435 /* Apply queue tx offloads configuration */
4436 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4437 port->tx_conf[k].offloads =
4438 port->dev_conf.txmode.offloads;
4442 cmd_csum_parsed(void *parsed_result,
4443 __attribute__((unused)) struct cmdline *cl,
4444 __attribute__((unused)) void *data)
4446 struct cmd_csum_result *res = parsed_result;
4448 uint64_t csum_offloads = 0;
4449 struct rte_eth_dev_info dev_info;
4451 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4452 printf("invalid port %d\n", res->port_id);
4455 if (!port_is_stopped(res->port_id)) {
4456 printf("Please stop port %d first\n", res->port_id);
4460 rte_eth_dev_info_get(res->port_id, &dev_info);
4461 if (!strcmp(res->mode, "set")) {
4463 if (!strcmp(res->hwsw, "hw"))
4466 if (!strcmp(res->proto, "ip")) {
4467 if (hw == 0 || (dev_info.tx_offload_capa &
4468 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4469 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4471 printf("IP checksum offload is not supported "
4472 "by port %u\n", res->port_id);
4474 } else if (!strcmp(res->proto, "udp")) {
4475 if (hw == 0 || (dev_info.tx_offload_capa &
4476 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4477 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4479 printf("UDP checksum offload is not supported "
4480 "by port %u\n", res->port_id);
4482 } else if (!strcmp(res->proto, "tcp")) {
4483 if (hw == 0 || (dev_info.tx_offload_capa &
4484 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4485 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4487 printf("TCP checksum offload is not supported "
4488 "by port %u\n", res->port_id);
4490 } else if (!strcmp(res->proto, "sctp")) {
4491 if (hw == 0 || (dev_info.tx_offload_capa &
4492 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4493 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4495 printf("SCTP checksum offload is not supported "
4496 "by port %u\n", res->port_id);
4498 } else if (!strcmp(res->proto, "outer-ip")) {
4499 if (hw == 0 || (dev_info.tx_offload_capa &
4500 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4502 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4504 printf("Outer IP checksum offload is not "
4505 "supported by port %u\n", res->port_id);
4507 } else if (!strcmp(res->proto, "outer-udp")) {
4508 if (hw == 0 || (dev_info.tx_offload_capa &
4509 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4511 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4513 printf("Outer UDP checksum offload is not "
4514 "supported by port %u\n", res->port_id);
4519 ports[res->port_id].dev_conf.txmode.offloads |=
4522 ports[res->port_id].dev_conf.txmode.offloads &=
4525 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4527 csum_show(res->port_id);
4529 cmd_reconfig_device_queue(res->port_id, 1, 1);
4532 cmdline_parse_token_string_t cmd_csum_csum =
4533 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4535 cmdline_parse_token_string_t cmd_csum_mode =
4536 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4538 cmdline_parse_token_string_t cmd_csum_proto =
4539 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4540 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4541 cmdline_parse_token_string_t cmd_csum_hwsw =
4542 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4544 cmdline_parse_token_num_t cmd_csum_portid =
4545 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4548 cmdline_parse_inst_t cmd_csum_set = {
4549 .f = cmd_csum_parsed,
4551 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4552 "Enable/Disable hardware calculation of L3/L4 checksum when "
4553 "using csum forward engine",
4555 (void *)&cmd_csum_csum,
4556 (void *)&cmd_csum_mode,
4557 (void *)&cmd_csum_proto,
4558 (void *)&cmd_csum_hwsw,
4559 (void *)&cmd_csum_portid,
4564 cmdline_parse_token_string_t cmd_csum_mode_show =
4565 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4568 cmdline_parse_inst_t cmd_csum_show = {
4569 .f = cmd_csum_parsed,
4571 .help_str = "csum show <port_id>: Show checksum offload configuration",
4573 (void *)&cmd_csum_csum,
4574 (void *)&cmd_csum_mode_show,
4575 (void *)&cmd_csum_portid,
4580 /* Enable/disable tunnel parsing */
4581 struct cmd_csum_tunnel_result {
4582 cmdline_fixed_string_t csum;
4583 cmdline_fixed_string_t parse;
4584 cmdline_fixed_string_t onoff;
4589 cmd_csum_tunnel_parsed(void *parsed_result,
4590 __attribute__((unused)) struct cmdline *cl,
4591 __attribute__((unused)) void *data)
4593 struct cmd_csum_tunnel_result *res = parsed_result;
4595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4598 if (!strcmp(res->onoff, "on"))
4599 ports[res->port_id].parse_tunnel = 1;
4601 ports[res->port_id].parse_tunnel = 0;
4603 csum_show(res->port_id);
4606 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4607 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4609 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4610 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4611 parse, "parse-tunnel");
4612 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4613 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4615 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4616 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4619 cmdline_parse_inst_t cmd_csum_tunnel = {
4620 .f = cmd_csum_tunnel_parsed,
4622 .help_str = "csum parse-tunnel on|off <port_id>: "
4623 "Enable/Disable parsing of tunnels for csum engine",
4625 (void *)&cmd_csum_tunnel_csum,
4626 (void *)&cmd_csum_tunnel_parse,
4627 (void *)&cmd_csum_tunnel_onoff,
4628 (void *)&cmd_csum_tunnel_portid,
4633 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4634 struct cmd_tso_set_result {
4635 cmdline_fixed_string_t tso;
4636 cmdline_fixed_string_t mode;
4642 cmd_tso_set_parsed(void *parsed_result,
4643 __attribute__((unused)) struct cmdline *cl,
4644 __attribute__((unused)) void *data)
4646 struct cmd_tso_set_result *res = parsed_result;
4647 struct rte_eth_dev_info dev_info;
4649 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4651 if (!port_is_stopped(res->port_id)) {
4652 printf("Please stop port %d first\n", res->port_id);
4656 if (!strcmp(res->mode, "set"))
4657 ports[res->port_id].tso_segsz = res->tso_segsz;
4659 rte_eth_dev_info_get(res->port_id, &dev_info);
4660 if ((ports[res->port_id].tso_segsz != 0) &&
4661 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4662 printf("Error: TSO is not supported by port %d\n",
4667 if (ports[res->port_id].tso_segsz == 0) {
4668 ports[res->port_id].dev_conf.txmode.offloads &=
4669 ~DEV_TX_OFFLOAD_TCP_TSO;
4670 printf("TSO for non-tunneled packets is disabled\n");
4672 ports[res->port_id].dev_conf.txmode.offloads |=
4673 DEV_TX_OFFLOAD_TCP_TSO;
4674 printf("TSO segment size for non-tunneled packets is %d\n",
4675 ports[res->port_id].tso_segsz);
4677 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4679 /* display warnings if configuration is not supported by the NIC */
4680 rte_eth_dev_info_get(res->port_id, &dev_info);
4681 if ((ports[res->port_id].tso_segsz != 0) &&
4682 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4683 printf("Warning: TSO enabled but not "
4684 "supported by port %d\n", res->port_id);
4687 cmd_reconfig_device_queue(res->port_id, 1, 1);
4690 cmdline_parse_token_string_t cmd_tso_set_tso =
4691 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4693 cmdline_parse_token_string_t cmd_tso_set_mode =
4694 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4696 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4697 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4699 cmdline_parse_token_num_t cmd_tso_set_portid =
4700 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4703 cmdline_parse_inst_t cmd_tso_set = {
4704 .f = cmd_tso_set_parsed,
4706 .help_str = "tso set <tso_segsz> <port_id>: "
4707 "Set TSO segment size of non-tunneled packets for csum engine "
4710 (void *)&cmd_tso_set_tso,
4711 (void *)&cmd_tso_set_mode,
4712 (void *)&cmd_tso_set_tso_segsz,
4713 (void *)&cmd_tso_set_portid,
4718 cmdline_parse_token_string_t cmd_tso_show_mode =
4719 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4723 cmdline_parse_inst_t cmd_tso_show = {
4724 .f = cmd_tso_set_parsed,
4726 .help_str = "tso show <port_id>: "
4727 "Show TSO segment size of non-tunneled packets for csum engine",
4729 (void *)&cmd_tso_set_tso,
4730 (void *)&cmd_tso_show_mode,
4731 (void *)&cmd_tso_set_portid,
4736 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4737 struct cmd_tunnel_tso_set_result {
4738 cmdline_fixed_string_t tso;
4739 cmdline_fixed_string_t mode;
4744 static struct rte_eth_dev_info
4745 check_tunnel_tso_nic_support(portid_t port_id)
4747 struct rte_eth_dev_info dev_info;
4749 rte_eth_dev_info_get(port_id, &dev_info);
4750 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4751 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4752 "not enabled for port %d\n", port_id);
4753 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4754 printf("Warning: GRE TUNNEL TSO not supported therefore "
4755 "not enabled for port %d\n", port_id);
4756 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4757 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4758 "not enabled for port %d\n", port_id);
4759 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4760 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4761 "not enabled for port %d\n", port_id);
4762 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4763 printf("Warning: IP TUNNEL TSO not supported therefore "
4764 "not enabled for port %d\n", port_id);
4765 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4766 printf("Warning: UDP TUNNEL TSO not supported therefore "
4767 "not enabled for port %d\n", port_id);
4772 cmd_tunnel_tso_set_parsed(void *parsed_result,
4773 __attribute__((unused)) struct cmdline *cl,
4774 __attribute__((unused)) void *data)
4776 struct cmd_tunnel_tso_set_result *res = parsed_result;
4777 struct rte_eth_dev_info dev_info;
4779 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4781 if (!port_is_stopped(res->port_id)) {
4782 printf("Please stop port %d first\n", res->port_id);
4786 if (!strcmp(res->mode, "set"))
4787 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4789 dev_info = check_tunnel_tso_nic_support(res->port_id);
4790 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4791 ports[res->port_id].dev_conf.txmode.offloads &=
4792 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4793 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4794 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4795 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4796 DEV_TX_OFFLOAD_IP_TNL_TSO |
4797 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4798 printf("TSO for tunneled packets is disabled\n");
4800 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4801 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4802 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4803 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4804 DEV_TX_OFFLOAD_IP_TNL_TSO |
4805 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4807 ports[res->port_id].dev_conf.txmode.offloads |=
4808 (tso_offloads & dev_info.tx_offload_capa);
4809 printf("TSO segment size for tunneled packets is %d\n",
4810 ports[res->port_id].tunnel_tso_segsz);
4812 /* Below conditions are needed to make it work:
4813 * (1) tunnel TSO is supported by the NIC;
4814 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4816 * (3) for tunneled pkts with outer L3 of IPv4,
4817 * "csum set outer-ip" must be set to hw, because after tso,
4818 * total_len of outer IP header is changed, and the checksum
4819 * of outer IP header calculated by sw should be wrong; that
4820 * is not necessary for IPv6 tunneled pkts because there's no
4821 * checksum in IP header anymore.
4824 if (!ports[res->port_id].parse_tunnel)
4825 printf("Warning: csum parse_tunnel must be set "
4826 "so that tunneled packets are recognized\n");
4827 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4828 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4829 printf("Warning: csum set outer-ip must be set to hw "
4830 "if outer L3 is IPv4; not necessary for IPv6\n");
4833 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4834 cmd_reconfig_device_queue(res->port_id, 1, 1);
4837 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4838 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4840 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4841 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4843 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4844 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4846 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4847 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4850 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4851 .f = cmd_tunnel_tso_set_parsed,
4853 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4854 "Set TSO segment size of tunneled packets for csum engine "
4857 (void *)&cmd_tunnel_tso_set_tso,
4858 (void *)&cmd_tunnel_tso_set_mode,
4859 (void *)&cmd_tunnel_tso_set_tso_segsz,
4860 (void *)&cmd_tunnel_tso_set_portid,
4865 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4866 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4870 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4871 .f = cmd_tunnel_tso_set_parsed,
4873 .help_str = "tunnel_tso show <port_id> "
4874 "Show TSO segment size of tunneled packets for csum engine",
4876 (void *)&cmd_tunnel_tso_set_tso,
4877 (void *)&cmd_tunnel_tso_show_mode,
4878 (void *)&cmd_tunnel_tso_set_portid,
4883 /* *** SET GRO FOR A PORT *** */
4884 struct cmd_gro_enable_result {
4885 cmdline_fixed_string_t cmd_set;
4886 cmdline_fixed_string_t cmd_port;
4887 cmdline_fixed_string_t cmd_keyword;
4888 cmdline_fixed_string_t cmd_onoff;
4893 cmd_gro_enable_parsed(void *parsed_result,
4894 __attribute__((unused)) struct cmdline *cl,
4895 __attribute__((unused)) void *data)
4897 struct cmd_gro_enable_result *res;
4899 res = parsed_result;
4900 if (!strcmp(res->cmd_keyword, "gro"))
4901 setup_gro(res->cmd_onoff, res->cmd_pid);
4904 cmdline_parse_token_string_t cmd_gro_enable_set =
4905 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4907 cmdline_parse_token_string_t cmd_gro_enable_port =
4908 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4909 cmd_keyword, "port");
4910 cmdline_parse_token_num_t cmd_gro_enable_pid =
4911 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4913 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4914 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4915 cmd_keyword, "gro");
4916 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4917 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4918 cmd_onoff, "on#off");
4920 cmdline_parse_inst_t cmd_gro_enable = {
4921 .f = cmd_gro_enable_parsed,
4923 .help_str = "set port <port_id> gro on|off",
4925 (void *)&cmd_gro_enable_set,
4926 (void *)&cmd_gro_enable_port,
4927 (void *)&cmd_gro_enable_pid,
4928 (void *)&cmd_gro_enable_keyword,
4929 (void *)&cmd_gro_enable_onoff,
4934 /* *** DISPLAY GRO CONFIGURATION *** */
4935 struct cmd_gro_show_result {
4936 cmdline_fixed_string_t cmd_show;
4937 cmdline_fixed_string_t cmd_port;
4938 cmdline_fixed_string_t cmd_keyword;
4943 cmd_gro_show_parsed(void *parsed_result,
4944 __attribute__((unused)) struct cmdline *cl,
4945 __attribute__((unused)) void *data)
4947 struct cmd_gro_show_result *res;
4949 res = parsed_result;
4950 if (!strcmp(res->cmd_keyword, "gro"))
4951 show_gro(res->cmd_pid);
4954 cmdline_parse_token_string_t cmd_gro_show_show =
4955 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4957 cmdline_parse_token_string_t cmd_gro_show_port =
4958 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4960 cmdline_parse_token_num_t cmd_gro_show_pid =
4961 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4963 cmdline_parse_token_string_t cmd_gro_show_keyword =
4964 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4965 cmd_keyword, "gro");
4967 cmdline_parse_inst_t cmd_gro_show = {
4968 .f = cmd_gro_show_parsed,
4970 .help_str = "show port <port_id> gro",
4972 (void *)&cmd_gro_show_show,
4973 (void *)&cmd_gro_show_port,
4974 (void *)&cmd_gro_show_pid,
4975 (void *)&cmd_gro_show_keyword,
4980 /* *** SET FLUSH CYCLES FOR GRO *** */
4981 struct cmd_gro_flush_result {
4982 cmdline_fixed_string_t cmd_set;
4983 cmdline_fixed_string_t cmd_keyword;
4984 cmdline_fixed_string_t cmd_flush;
4989 cmd_gro_flush_parsed(void *parsed_result,
4990 __attribute__((unused)) struct cmdline *cl,
4991 __attribute__((unused)) void *data)
4993 struct cmd_gro_flush_result *res;
4995 res = parsed_result;
4996 if ((!strcmp(res->cmd_keyword, "gro")) &&
4997 (!strcmp(res->cmd_flush, "flush")))
4998 setup_gro_flush_cycles(res->cmd_cycles);
5001 cmdline_parse_token_string_t cmd_gro_flush_set =
5002 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5004 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5005 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5006 cmd_keyword, "gro");
5007 cmdline_parse_token_string_t cmd_gro_flush_flush =
5008 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5009 cmd_flush, "flush");
5010 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5011 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5014 cmdline_parse_inst_t cmd_gro_flush = {
5015 .f = cmd_gro_flush_parsed,
5017 .help_str = "set gro flush <cycles>",
5019 (void *)&cmd_gro_flush_set,
5020 (void *)&cmd_gro_flush_keyword,
5021 (void *)&cmd_gro_flush_flush,
5022 (void *)&cmd_gro_flush_cycles,
5027 /* *** ENABLE/DISABLE GSO *** */
5028 struct cmd_gso_enable_result {
5029 cmdline_fixed_string_t cmd_set;
5030 cmdline_fixed_string_t cmd_port;
5031 cmdline_fixed_string_t cmd_keyword;
5032 cmdline_fixed_string_t cmd_mode;
5037 cmd_gso_enable_parsed(void *parsed_result,
5038 __attribute__((unused)) struct cmdline *cl,
5039 __attribute__((unused)) void *data)
5041 struct cmd_gso_enable_result *res;
5043 res = parsed_result;
5044 if (!strcmp(res->cmd_keyword, "gso"))
5045 setup_gso(res->cmd_mode, res->cmd_pid);
5048 cmdline_parse_token_string_t cmd_gso_enable_set =
5049 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5051 cmdline_parse_token_string_t cmd_gso_enable_port =
5052 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5054 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5055 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5056 cmd_keyword, "gso");
5057 cmdline_parse_token_string_t cmd_gso_enable_mode =
5058 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5059 cmd_mode, "on#off");
5060 cmdline_parse_token_num_t cmd_gso_enable_pid =
5061 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5064 cmdline_parse_inst_t cmd_gso_enable = {
5065 .f = cmd_gso_enable_parsed,
5067 .help_str = "set port <port_id> gso on|off",
5069 (void *)&cmd_gso_enable_set,
5070 (void *)&cmd_gso_enable_port,
5071 (void *)&cmd_gso_enable_pid,
5072 (void *)&cmd_gso_enable_keyword,
5073 (void *)&cmd_gso_enable_mode,
5078 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5079 struct cmd_gso_size_result {
5080 cmdline_fixed_string_t cmd_set;
5081 cmdline_fixed_string_t cmd_keyword;
5082 cmdline_fixed_string_t cmd_segsz;
5087 cmd_gso_size_parsed(void *parsed_result,
5088 __attribute__((unused)) struct cmdline *cl,
5089 __attribute__((unused)) void *data)
5091 struct cmd_gso_size_result *res = parsed_result;
5093 if (test_done == 0) {
5094 printf("Before setting GSO segsz, please first"
5095 " stop fowarding\n");
5099 if (!strcmp(res->cmd_keyword, "gso") &&
5100 !strcmp(res->cmd_segsz, "segsz")) {
5101 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5102 printf("gso_size should be larger than %zu."
5103 " Please input a legal value\n",
5104 RTE_GSO_SEG_SIZE_MIN);
5106 gso_max_segment_size = res->cmd_size;
5110 cmdline_parse_token_string_t cmd_gso_size_set =
5111 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5113 cmdline_parse_token_string_t cmd_gso_size_keyword =
5114 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5115 cmd_keyword, "gso");
5116 cmdline_parse_token_string_t cmd_gso_size_segsz =
5117 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5118 cmd_segsz, "segsz");
5119 cmdline_parse_token_num_t cmd_gso_size_size =
5120 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5123 cmdline_parse_inst_t cmd_gso_size = {
5124 .f = cmd_gso_size_parsed,
5126 .help_str = "set gso segsz <length>",
5128 (void *)&cmd_gso_size_set,
5129 (void *)&cmd_gso_size_keyword,
5130 (void *)&cmd_gso_size_segsz,
5131 (void *)&cmd_gso_size_size,
5136 /* *** SHOW GSO CONFIGURATION *** */
5137 struct cmd_gso_show_result {
5138 cmdline_fixed_string_t cmd_show;
5139 cmdline_fixed_string_t cmd_port;
5140 cmdline_fixed_string_t cmd_keyword;
5145 cmd_gso_show_parsed(void *parsed_result,
5146 __attribute__((unused)) struct cmdline *cl,
5147 __attribute__((unused)) void *data)
5149 struct cmd_gso_show_result *res = parsed_result;
5151 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5152 printf("invalid port id %u\n", res->cmd_pid);
5155 if (!strcmp(res->cmd_keyword, "gso")) {
5156 if (gso_ports[res->cmd_pid].enable) {
5157 printf("Max GSO'd packet size: %uB\n"
5158 "Supported GSO types: TCP/IPv4, "
5159 "UDP/IPv4, VxLAN with inner "
5160 "TCP/IPv4 packet, GRE with inner "
5161 "TCP/IPv4 packet\n",
5162 gso_max_segment_size);
5164 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5168 cmdline_parse_token_string_t cmd_gso_show_show =
5169 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5171 cmdline_parse_token_string_t cmd_gso_show_port =
5172 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5174 cmdline_parse_token_string_t cmd_gso_show_keyword =
5175 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5176 cmd_keyword, "gso");
5177 cmdline_parse_token_num_t cmd_gso_show_pid =
5178 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5181 cmdline_parse_inst_t cmd_gso_show = {
5182 .f = cmd_gso_show_parsed,
5184 .help_str = "show port <port_id> gso",
5186 (void *)&cmd_gso_show_show,
5187 (void *)&cmd_gso_show_port,
5188 (void *)&cmd_gso_show_pid,
5189 (void *)&cmd_gso_show_keyword,
5194 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5195 struct cmd_set_flush_rx {
5196 cmdline_fixed_string_t set;
5197 cmdline_fixed_string_t flush_rx;
5198 cmdline_fixed_string_t mode;
5202 cmd_set_flush_rx_parsed(void *parsed_result,
5203 __attribute__((unused)) struct cmdline *cl,
5204 __attribute__((unused)) void *data)
5206 struct cmd_set_flush_rx *res = parsed_result;
5207 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5210 cmdline_parse_token_string_t cmd_setflushrx_set =
5211 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5213 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5214 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5215 flush_rx, "flush_rx");
5216 cmdline_parse_token_string_t cmd_setflushrx_mode =
5217 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5221 cmdline_parse_inst_t cmd_set_flush_rx = {
5222 .f = cmd_set_flush_rx_parsed,
5223 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5226 (void *)&cmd_setflushrx_set,
5227 (void *)&cmd_setflushrx_flush_rx,
5228 (void *)&cmd_setflushrx_mode,
5233 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5234 struct cmd_set_link_check {
5235 cmdline_fixed_string_t set;
5236 cmdline_fixed_string_t link_check;
5237 cmdline_fixed_string_t mode;
5241 cmd_set_link_check_parsed(void *parsed_result,
5242 __attribute__((unused)) struct cmdline *cl,
5243 __attribute__((unused)) void *data)
5245 struct cmd_set_link_check *res = parsed_result;
5246 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5249 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5250 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5252 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5253 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5254 link_check, "link_check");
5255 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5256 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5260 cmdline_parse_inst_t cmd_set_link_check = {
5261 .f = cmd_set_link_check_parsed,
5262 .help_str = "set link_check on|off: Enable/Disable link status check "
5263 "when starting/stopping a port",
5266 (void *)&cmd_setlinkcheck_set,
5267 (void *)&cmd_setlinkcheck_link_check,
5268 (void *)&cmd_setlinkcheck_mode,
5273 /* *** SET NIC BYPASS MODE *** */
5274 struct cmd_set_bypass_mode_result {
5275 cmdline_fixed_string_t set;
5276 cmdline_fixed_string_t bypass;
5277 cmdline_fixed_string_t mode;
5278 cmdline_fixed_string_t value;
5283 cmd_set_bypass_mode_parsed(void *parsed_result,
5284 __attribute__((unused)) struct cmdline *cl,
5285 __attribute__((unused)) void *data)
5287 struct cmd_set_bypass_mode_result *res = parsed_result;
5288 portid_t port_id = res->port_id;
5289 int32_t rc = -EINVAL;
5291 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5292 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5294 if (!strcmp(res->value, "bypass"))
5295 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5296 else if (!strcmp(res->value, "isolate"))
5297 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5299 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5301 /* Set the bypass mode for the relevant port. */
5302 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5305 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5308 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5309 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5311 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5312 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5314 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5315 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5317 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5318 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5319 value, "normal#bypass#isolate");
5320 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5321 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5324 cmdline_parse_inst_t cmd_set_bypass_mode = {
5325 .f = cmd_set_bypass_mode_parsed,
5326 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5327 "Set the NIC bypass mode for port_id",
5330 (void *)&cmd_setbypass_mode_set,
5331 (void *)&cmd_setbypass_mode_bypass,
5332 (void *)&cmd_setbypass_mode_mode,
5333 (void *)&cmd_setbypass_mode_value,
5334 (void *)&cmd_setbypass_mode_port,
5339 /* *** SET NIC BYPASS EVENT *** */
5340 struct cmd_set_bypass_event_result {
5341 cmdline_fixed_string_t set;
5342 cmdline_fixed_string_t bypass;
5343 cmdline_fixed_string_t event;
5344 cmdline_fixed_string_t event_value;
5345 cmdline_fixed_string_t mode;
5346 cmdline_fixed_string_t mode_value;
5351 cmd_set_bypass_event_parsed(void *parsed_result,
5352 __attribute__((unused)) struct cmdline *cl,
5353 __attribute__((unused)) void *data)
5355 int32_t rc = -EINVAL;
5356 struct cmd_set_bypass_event_result *res = parsed_result;
5357 portid_t port_id = res->port_id;
5359 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5360 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5361 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5363 if (!strcmp(res->event_value, "timeout"))
5364 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5365 else if (!strcmp(res->event_value, "os_on"))
5366 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5367 else if (!strcmp(res->event_value, "os_off"))
5368 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5369 else if (!strcmp(res->event_value, "power_on"))
5370 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5371 else if (!strcmp(res->event_value, "power_off"))
5372 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5374 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5376 if (!strcmp(res->mode_value, "bypass"))
5377 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5378 else if (!strcmp(res->mode_value, "isolate"))
5379 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5381 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5383 /* Set the watchdog timeout. */
5384 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5387 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5388 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5392 printf("Failed to set timeout value %u "
5393 "for port %d, errto code: %d.\n",
5394 bypass_timeout, port_id, rc);
5398 /* Set the bypass event to transition to bypass mode. */
5399 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5404 printf("\t Failed to set bypass event for port = %d.\n",
5408 cmdline_parse_token_string_t cmd_setbypass_event_set =
5409 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5411 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5412 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5414 cmdline_parse_token_string_t cmd_setbypass_event_event =
5415 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5417 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5418 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5419 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5420 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5421 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5423 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5424 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5425 mode_value, "normal#bypass#isolate");
5426 cmdline_parse_token_num_t cmd_setbypass_event_port =
5427 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5430 cmdline_parse_inst_t cmd_set_bypass_event = {
5431 .f = cmd_set_bypass_event_parsed,
5432 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5433 "power_off mode normal|bypass|isolate <port_id>: "
5434 "Set the NIC bypass event mode for port_id",
5437 (void *)&cmd_setbypass_event_set,
5438 (void *)&cmd_setbypass_event_bypass,
5439 (void *)&cmd_setbypass_event_event,
5440 (void *)&cmd_setbypass_event_event_value,
5441 (void *)&cmd_setbypass_event_mode,
5442 (void *)&cmd_setbypass_event_mode_value,
5443 (void *)&cmd_setbypass_event_port,
5449 /* *** SET NIC BYPASS TIMEOUT *** */
5450 struct cmd_set_bypass_timeout_result {
5451 cmdline_fixed_string_t set;
5452 cmdline_fixed_string_t bypass;
5453 cmdline_fixed_string_t timeout;
5454 cmdline_fixed_string_t value;
5458 cmd_set_bypass_timeout_parsed(void *parsed_result,
5459 __attribute__((unused)) struct cmdline *cl,
5460 __attribute__((unused)) void *data)
5462 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5464 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5465 if (!strcmp(res->value, "1.5"))
5466 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5467 else if (!strcmp(res->value, "2"))
5468 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5469 else if (!strcmp(res->value, "3"))
5470 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5471 else if (!strcmp(res->value, "4"))
5472 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5473 else if (!strcmp(res->value, "8"))
5474 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5475 else if (!strcmp(res->value, "16"))
5476 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5477 else if (!strcmp(res->value, "32"))
5478 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5480 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5484 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5485 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5487 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5488 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5490 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5491 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5492 timeout, "timeout");
5493 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5494 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5495 value, "0#1.5#2#3#4#8#16#32");
5497 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5498 .f = cmd_set_bypass_timeout_parsed,
5499 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5500 "Set the NIC bypass watchdog timeout in seconds",
5503 (void *)&cmd_setbypass_timeout_set,
5504 (void *)&cmd_setbypass_timeout_bypass,
5505 (void *)&cmd_setbypass_timeout_timeout,
5506 (void *)&cmd_setbypass_timeout_value,
5511 /* *** SHOW NIC BYPASS MODE *** */
5512 struct cmd_show_bypass_config_result {
5513 cmdline_fixed_string_t show;
5514 cmdline_fixed_string_t bypass;
5515 cmdline_fixed_string_t config;
5520 cmd_show_bypass_config_parsed(void *parsed_result,
5521 __attribute__((unused)) struct cmdline *cl,
5522 __attribute__((unused)) void *data)
5524 struct cmd_show_bypass_config_result *res = parsed_result;
5525 portid_t port_id = res->port_id;
5527 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5528 uint32_t event_mode;
5529 uint32_t bypass_mode;
5530 uint32_t timeout = bypass_timeout;
5533 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5534 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5535 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5536 {"UNKNOWN", "normal", "bypass", "isolate"};
5537 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5544 int num_events = (sizeof events) / (sizeof events[0]);
5546 /* Display the bypass mode.*/
5547 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5548 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5552 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5553 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5555 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5558 /* Display the bypass timeout.*/
5559 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5560 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5562 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5564 /* Display the bypass events and associated modes. */
5565 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5567 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5568 printf("\tFailed to get bypass mode for event = %s\n",
5571 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5572 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5574 printf("\tbypass event: %-16s = %s\n", events[i],
5580 printf("\tFailed to get bypass configuration for port = %d\n",
5584 cmdline_parse_token_string_t cmd_showbypass_config_show =
5585 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5587 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5588 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5590 cmdline_parse_token_string_t cmd_showbypass_config_config =
5591 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5593 cmdline_parse_token_num_t cmd_showbypass_config_port =
5594 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5597 cmdline_parse_inst_t cmd_show_bypass_config = {
5598 .f = cmd_show_bypass_config_parsed,
5599 .help_str = "show bypass config <port_id>: "
5600 "Show the NIC bypass config for port_id",
5603 (void *)&cmd_showbypass_config_show,
5604 (void *)&cmd_showbypass_config_bypass,
5605 (void *)&cmd_showbypass_config_config,
5606 (void *)&cmd_showbypass_config_port,
5611 #ifdef RTE_LIBRTE_PMD_BOND
5612 /* *** SET BONDING MODE *** */
5613 struct cmd_set_bonding_mode_result {
5614 cmdline_fixed_string_t set;
5615 cmdline_fixed_string_t bonding;
5616 cmdline_fixed_string_t mode;
5621 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5622 __attribute__((unused)) struct cmdline *cl,
5623 __attribute__((unused)) void *data)
5625 struct cmd_set_bonding_mode_result *res = parsed_result;
5626 portid_t port_id = res->port_id;
5628 /* Set the bonding mode for the relevant port. */
5629 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5630 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5633 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5634 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5636 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5637 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5638 bonding, "bonding");
5639 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5640 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5642 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5643 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5645 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5646 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5649 cmdline_parse_inst_t cmd_set_bonding_mode = {
5650 .f = cmd_set_bonding_mode_parsed,
5651 .help_str = "set bonding mode <mode_value> <port_id>: "
5652 "Set the bonding mode for port_id",
5655 (void *) &cmd_setbonding_mode_set,
5656 (void *) &cmd_setbonding_mode_bonding,
5657 (void *) &cmd_setbonding_mode_mode,
5658 (void *) &cmd_setbonding_mode_value,
5659 (void *) &cmd_setbonding_mode_port,
5664 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5665 struct cmd_set_bonding_lacp_dedicated_queues_result {
5666 cmdline_fixed_string_t set;
5667 cmdline_fixed_string_t bonding;
5668 cmdline_fixed_string_t lacp;
5669 cmdline_fixed_string_t dedicated_queues;
5671 cmdline_fixed_string_t mode;
5674 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5675 __attribute__((unused)) struct cmdline *cl,
5676 __attribute__((unused)) void *data)
5678 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5679 portid_t port_id = res->port_id;
5680 struct rte_port *port;
5682 port = &ports[port_id];
5684 /** Check if the port is not started **/
5685 if (port->port_status != RTE_PORT_STOPPED) {
5686 printf("Please stop port %d first\n", port_id);
5690 if (!strcmp(res->mode, "enable")) {
5691 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5692 printf("Dedicate queues for LACP control packets"
5695 printf("Enabling dedicate queues for LACP control "
5696 "packets on port %d failed\n", port_id);
5697 } else if (!strcmp(res->mode, "disable")) {
5698 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5699 printf("Dedicated queues for LACP control packets "
5702 printf("Disabling dedicated queues for LACP control "
5703 "traffic on port %d failed\n", port_id);
5707 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5708 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5710 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5711 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5712 bonding, "bonding");
5713 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5714 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5716 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5717 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5718 dedicated_queues, "dedicated_queues");
5719 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5720 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5722 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5724 mode, "enable#disable");
5726 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5727 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5728 .help_str = "set bonding lacp dedicated_queues <port_id> "
5730 "Enable/disable dedicated queues for LACP control traffic for port_id",
5733 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5734 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5735 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5736 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5737 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5738 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5743 /* *** SET BALANCE XMIT POLICY *** */
5744 struct cmd_set_bonding_balance_xmit_policy_result {
5745 cmdline_fixed_string_t set;
5746 cmdline_fixed_string_t bonding;
5747 cmdline_fixed_string_t balance_xmit_policy;
5749 cmdline_fixed_string_t policy;
5752 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5753 __attribute__((unused)) struct cmdline *cl,
5754 __attribute__((unused)) void *data)
5756 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5757 portid_t port_id = res->port_id;
5760 if (!strcmp(res->policy, "l2")) {
5761 policy = BALANCE_XMIT_POLICY_LAYER2;
5762 } else if (!strcmp(res->policy, "l23")) {
5763 policy = BALANCE_XMIT_POLICY_LAYER23;
5764 } else if (!strcmp(res->policy, "l34")) {
5765 policy = BALANCE_XMIT_POLICY_LAYER34;
5767 printf("\t Invalid xmit policy selection");
5771 /* Set the bonding mode for the relevant port. */
5772 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5773 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5778 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5781 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5783 bonding, "bonding");
5784 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5786 balance_xmit_policy, "balance_xmit_policy");
5787 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5788 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5790 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5791 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5792 policy, "l2#l23#l34");
5794 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5795 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5796 .help_str = "set bonding balance_xmit_policy <port_id> "
5798 "Set the bonding balance_xmit_policy for port_id",
5801 (void *)&cmd_setbonding_balance_xmit_policy_set,
5802 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5803 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5804 (void *)&cmd_setbonding_balance_xmit_policy_port,
5805 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5810 /* *** SHOW NIC BONDING CONFIGURATION *** */
5811 struct cmd_show_bonding_config_result {
5812 cmdline_fixed_string_t show;
5813 cmdline_fixed_string_t bonding;
5814 cmdline_fixed_string_t config;
5818 static void cmd_show_bonding_config_parsed(void *parsed_result,
5819 __attribute__((unused)) struct cmdline *cl,
5820 __attribute__((unused)) void *data)
5822 struct cmd_show_bonding_config_result *res = parsed_result;
5823 int bonding_mode, agg_mode;
5824 portid_t slaves[RTE_MAX_ETHPORTS];
5825 int num_slaves, num_active_slaves;
5828 portid_t port_id = res->port_id;
5830 /* Display the bonding mode.*/
5831 bonding_mode = rte_eth_bond_mode_get(port_id);
5832 if (bonding_mode < 0) {
5833 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5836 printf("\tBonding mode: %d\n", bonding_mode);
5838 if (bonding_mode == BONDING_MODE_BALANCE) {
5839 int balance_xmit_policy;
5841 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5842 if (balance_xmit_policy < 0) {
5843 printf("\tFailed to get balance xmit policy for port = %d\n",
5847 printf("\tBalance Xmit Policy: ");
5849 switch (balance_xmit_policy) {
5850 case BALANCE_XMIT_POLICY_LAYER2:
5851 printf("BALANCE_XMIT_POLICY_LAYER2");
5853 case BALANCE_XMIT_POLICY_LAYER23:
5854 printf("BALANCE_XMIT_POLICY_LAYER23");
5856 case BALANCE_XMIT_POLICY_LAYER34:
5857 printf("BALANCE_XMIT_POLICY_LAYER34");
5864 if (bonding_mode == BONDING_MODE_8023AD) {
5865 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5866 printf("\tIEEE802.3AD Aggregator Mode: ");
5869 printf("bandwidth");
5881 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5883 if (num_slaves < 0) {
5884 printf("\tFailed to get slave list for port = %d\n", port_id);
5887 if (num_slaves > 0) {
5888 printf("\tSlaves (%d): [", num_slaves);
5889 for (i = 0; i < num_slaves - 1; i++)
5890 printf("%d ", slaves[i]);
5892 printf("%d]\n", slaves[num_slaves - 1]);
5894 printf("\tSlaves: []\n");
5898 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5901 if (num_active_slaves < 0) {
5902 printf("\tFailed to get active slave list for port = %d\n", port_id);
5905 if (num_active_slaves > 0) {
5906 printf("\tActive Slaves (%d): [", num_active_slaves);
5907 for (i = 0; i < num_active_slaves - 1; i++)
5908 printf("%d ", slaves[i]);
5910 printf("%d]\n", slaves[num_active_slaves - 1]);
5913 printf("\tActive Slaves: []\n");
5917 primary_id = rte_eth_bond_primary_get(port_id);
5918 if (primary_id < 0) {
5919 printf("\tFailed to get primary slave for port = %d\n", port_id);
5922 printf("\tPrimary: [%d]\n", primary_id);
5926 cmdline_parse_token_string_t cmd_showbonding_config_show =
5927 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5929 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5930 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5931 bonding, "bonding");
5932 cmdline_parse_token_string_t cmd_showbonding_config_config =
5933 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5935 cmdline_parse_token_num_t cmd_showbonding_config_port =
5936 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5939 cmdline_parse_inst_t cmd_show_bonding_config = {
5940 .f = cmd_show_bonding_config_parsed,
5941 .help_str = "show bonding config <port_id>: "
5942 "Show the bonding config for port_id",
5945 (void *)&cmd_showbonding_config_show,
5946 (void *)&cmd_showbonding_config_bonding,
5947 (void *)&cmd_showbonding_config_config,
5948 (void *)&cmd_showbonding_config_port,
5953 /* *** SET BONDING PRIMARY *** */
5954 struct cmd_set_bonding_primary_result {
5955 cmdline_fixed_string_t set;
5956 cmdline_fixed_string_t bonding;
5957 cmdline_fixed_string_t primary;
5962 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5963 __attribute__((unused)) struct cmdline *cl,
5964 __attribute__((unused)) void *data)
5966 struct cmd_set_bonding_primary_result *res = parsed_result;
5967 portid_t master_port_id = res->port_id;
5968 portid_t slave_port_id = res->slave_id;
5970 /* Set the primary slave for a bonded device. */
5971 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5972 printf("\t Failed to set primary slave for port = %d.\n",
5979 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5980 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5982 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5983 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5984 bonding, "bonding");
5985 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5986 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5987 primary, "primary");
5988 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5989 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5991 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5992 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5995 cmdline_parse_inst_t cmd_set_bonding_primary = {
5996 .f = cmd_set_bonding_primary_parsed,
5997 .help_str = "set bonding primary <slave_id> <port_id>: "
5998 "Set the primary slave for port_id",
6001 (void *)&cmd_setbonding_primary_set,
6002 (void *)&cmd_setbonding_primary_bonding,
6003 (void *)&cmd_setbonding_primary_primary,
6004 (void *)&cmd_setbonding_primary_slave,
6005 (void *)&cmd_setbonding_primary_port,
6010 /* *** ADD SLAVE *** */
6011 struct cmd_add_bonding_slave_result {
6012 cmdline_fixed_string_t add;
6013 cmdline_fixed_string_t bonding;
6014 cmdline_fixed_string_t slave;
6019 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6020 __attribute__((unused)) struct cmdline *cl,
6021 __attribute__((unused)) void *data)
6023 struct cmd_add_bonding_slave_result *res = parsed_result;
6024 portid_t master_port_id = res->port_id;
6025 portid_t slave_port_id = res->slave_id;
6027 /* add the slave for a bonded device. */
6028 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6029 printf("\t Failed to add slave %d to master port = %d.\n",
6030 slave_port_id, master_port_id);
6034 set_port_slave_flag(slave_port_id);
6037 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6038 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6040 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6041 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6042 bonding, "bonding");
6043 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6044 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6046 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6047 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6049 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6050 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6053 cmdline_parse_inst_t cmd_add_bonding_slave = {
6054 .f = cmd_add_bonding_slave_parsed,
6055 .help_str = "add bonding slave <slave_id> <port_id>: "
6056 "Add a slave device to a bonded device",
6059 (void *)&cmd_addbonding_slave_add,
6060 (void *)&cmd_addbonding_slave_bonding,
6061 (void *)&cmd_addbonding_slave_slave,
6062 (void *)&cmd_addbonding_slave_slaveid,
6063 (void *)&cmd_addbonding_slave_port,
6068 /* *** REMOVE SLAVE *** */
6069 struct cmd_remove_bonding_slave_result {
6070 cmdline_fixed_string_t remove;
6071 cmdline_fixed_string_t bonding;
6072 cmdline_fixed_string_t slave;
6077 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6078 __attribute__((unused)) struct cmdline *cl,
6079 __attribute__((unused)) void *data)
6081 struct cmd_remove_bonding_slave_result *res = parsed_result;
6082 portid_t master_port_id = res->port_id;
6083 portid_t slave_port_id = res->slave_id;
6085 /* remove the slave from a bonded device. */
6086 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6087 printf("\t Failed to remove slave %d from master port = %d.\n",
6088 slave_port_id, master_port_id);
6092 clear_port_slave_flag(slave_port_id);
6095 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6096 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6098 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6099 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6100 bonding, "bonding");
6101 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6102 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6104 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6105 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6107 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6108 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6111 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6112 .f = cmd_remove_bonding_slave_parsed,
6113 .help_str = "remove bonding slave <slave_id> <port_id>: "
6114 "Remove a slave device from a bonded device",
6117 (void *)&cmd_removebonding_slave_remove,
6118 (void *)&cmd_removebonding_slave_bonding,
6119 (void *)&cmd_removebonding_slave_slave,
6120 (void *)&cmd_removebonding_slave_slaveid,
6121 (void *)&cmd_removebonding_slave_port,
6126 /* *** CREATE BONDED DEVICE *** */
6127 struct cmd_create_bonded_device_result {
6128 cmdline_fixed_string_t create;
6129 cmdline_fixed_string_t bonded;
6130 cmdline_fixed_string_t device;
6135 static int bond_dev_num = 0;
6137 static void cmd_create_bonded_device_parsed(void *parsed_result,
6138 __attribute__((unused)) struct cmdline *cl,
6139 __attribute__((unused)) void *data)
6141 struct cmd_create_bonded_device_result *res = parsed_result;
6142 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6145 if (test_done == 0) {
6146 printf("Please stop forwarding first\n");
6150 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6153 /* Create a new bonded device. */
6154 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6156 printf("\t Failed to create bonded device.\n");
6159 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6162 /* Update number of ports */
6163 nb_ports = rte_eth_dev_count_avail();
6164 reconfig(port_id, res->socket);
6165 rte_eth_promiscuous_enable(port_id);
6166 ports[port_id].need_setup = 0;
6167 ports[port_id].port_status = RTE_PORT_STOPPED;
6172 cmdline_parse_token_string_t cmd_createbonded_device_create =
6173 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6175 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6176 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6178 cmdline_parse_token_string_t cmd_createbonded_device_device =
6179 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6181 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6182 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6184 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6185 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6188 cmdline_parse_inst_t cmd_create_bonded_device = {
6189 .f = cmd_create_bonded_device_parsed,
6190 .help_str = "create bonded device <mode> <socket>: "
6191 "Create a new bonded device with specific bonding mode and socket",
6194 (void *)&cmd_createbonded_device_create,
6195 (void *)&cmd_createbonded_device_bonded,
6196 (void *)&cmd_createbonded_device_device,
6197 (void *)&cmd_createbonded_device_mode,
6198 (void *)&cmd_createbonded_device_socket,
6203 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6204 struct cmd_set_bond_mac_addr_result {
6205 cmdline_fixed_string_t set;
6206 cmdline_fixed_string_t bonding;
6207 cmdline_fixed_string_t mac_addr;
6209 struct rte_ether_addr address;
6212 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6213 __attribute__((unused)) struct cmdline *cl,
6214 __attribute__((unused)) void *data)
6216 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6219 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6222 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6224 /* check the return value and print it if is < 0 */
6226 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6229 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6230 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6231 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6234 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6235 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6237 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6238 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6240 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6241 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6243 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6244 .f = cmd_set_bond_mac_addr_parsed,
6246 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6248 (void *)&cmd_set_bond_mac_addr_set,
6249 (void *)&cmd_set_bond_mac_addr_bonding,
6250 (void *)&cmd_set_bond_mac_addr_mac,
6251 (void *)&cmd_set_bond_mac_addr_portnum,
6252 (void *)&cmd_set_bond_mac_addr_addr,
6258 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6259 struct cmd_set_bond_mon_period_result {
6260 cmdline_fixed_string_t set;
6261 cmdline_fixed_string_t bonding;
6262 cmdline_fixed_string_t mon_period;
6267 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6268 __attribute__((unused)) struct cmdline *cl,
6269 __attribute__((unused)) void *data)
6271 struct cmd_set_bond_mon_period_result *res = parsed_result;
6274 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6276 /* check the return value and print it if is < 0 */
6278 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6281 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6282 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6284 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6285 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6286 bonding, "bonding");
6287 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6288 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6289 mon_period, "mon_period");
6290 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6291 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6293 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6294 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6297 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6298 .f = cmd_set_bond_mon_period_parsed,
6300 .help_str = "set bonding mon_period <port_id> <period_ms>",
6302 (void *)&cmd_set_bond_mon_period_set,
6303 (void *)&cmd_set_bond_mon_period_bonding,
6304 (void *)&cmd_set_bond_mon_period_mon_period,
6305 (void *)&cmd_set_bond_mon_period_portnum,
6306 (void *)&cmd_set_bond_mon_period_period_ms,
6313 struct cmd_set_bonding_agg_mode_policy_result {
6314 cmdline_fixed_string_t set;
6315 cmdline_fixed_string_t bonding;
6316 cmdline_fixed_string_t agg_mode;
6318 cmdline_fixed_string_t policy;
6323 cmd_set_bonding_agg_mode(void *parsed_result,
6324 __attribute__((unused)) struct cmdline *cl,
6325 __attribute__((unused)) void *data)
6327 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6328 uint8_t policy = AGG_BANDWIDTH;
6330 if (!strcmp(res->policy, "bandwidth"))
6331 policy = AGG_BANDWIDTH;
6332 else if (!strcmp(res->policy, "stable"))
6333 policy = AGG_STABLE;
6334 else if (!strcmp(res->policy, "count"))
6337 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6341 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6344 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6346 bonding, "bonding");
6348 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6349 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6350 agg_mode, "agg_mode");
6352 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6353 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6356 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6357 TOKEN_STRING_INITIALIZER(
6358 struct cmd_set_bonding_balance_xmit_policy_result,
6359 policy, "stable#bandwidth#count");
6361 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6362 .f = cmd_set_bonding_agg_mode,
6364 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6366 (void *)&cmd_set_bonding_agg_mode_set,
6367 (void *)&cmd_set_bonding_agg_mode_bonding,
6368 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6369 (void *)&cmd_set_bonding_agg_mode_portnum,
6370 (void *)&cmd_set_bonding_agg_mode_policy_string,
6376 #endif /* RTE_LIBRTE_PMD_BOND */
6378 /* *** SET FORWARDING MODE *** */
6379 struct cmd_set_fwd_mode_result {
6380 cmdline_fixed_string_t set;
6381 cmdline_fixed_string_t fwd;
6382 cmdline_fixed_string_t mode;
6385 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6386 __attribute__((unused)) struct cmdline *cl,
6387 __attribute__((unused)) void *data)
6389 struct cmd_set_fwd_mode_result *res = parsed_result;
6392 set_pkt_forwarding_mode(res->mode);
6395 cmdline_parse_token_string_t cmd_setfwd_set =
6396 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6397 cmdline_parse_token_string_t cmd_setfwd_fwd =
6398 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6399 cmdline_parse_token_string_t cmd_setfwd_mode =
6400 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6401 "" /* defined at init */);
6403 cmdline_parse_inst_t cmd_set_fwd_mode = {
6404 .f = cmd_set_fwd_mode_parsed,
6406 .help_str = NULL, /* defined at init */
6408 (void *)&cmd_setfwd_set,
6409 (void *)&cmd_setfwd_fwd,
6410 (void *)&cmd_setfwd_mode,
6415 static void cmd_set_fwd_mode_init(void)
6418 static char token[128];
6419 static char help[256];
6420 cmdline_parse_token_string_t *token_struct;
6422 modes = list_pkt_forwarding_modes();
6423 snprintf(help, sizeof(help), "set fwd %s: "
6424 "Set packet forwarding mode", modes);
6425 cmd_set_fwd_mode.help_str = help;
6427 /* string token separator is # */
6428 for (c = token; *modes != '\0'; modes++)
6433 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6434 token_struct->string_data.str = token;
6437 /* *** SET RETRY FORWARDING MODE *** */
6438 struct cmd_set_fwd_retry_mode_result {
6439 cmdline_fixed_string_t set;
6440 cmdline_fixed_string_t fwd;
6441 cmdline_fixed_string_t mode;
6442 cmdline_fixed_string_t retry;
6445 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6446 __attribute__((unused)) struct cmdline *cl,
6447 __attribute__((unused)) void *data)
6449 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6452 set_pkt_forwarding_mode(res->mode);
6455 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6456 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6458 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6459 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6461 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6462 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6464 "" /* defined at init */);
6465 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6469 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6470 .f = cmd_set_fwd_retry_mode_parsed,
6472 .help_str = NULL, /* defined at init */
6474 (void *)&cmd_setfwd_retry_set,
6475 (void *)&cmd_setfwd_retry_fwd,
6476 (void *)&cmd_setfwd_retry_mode,
6477 (void *)&cmd_setfwd_retry_retry,
6482 static void cmd_set_fwd_retry_mode_init(void)
6485 static char token[128];
6486 static char help[256];
6487 cmdline_parse_token_string_t *token_struct;
6489 modes = list_pkt_forwarding_retry_modes();
6490 snprintf(help, sizeof(help), "set fwd %s retry: "
6491 "Set packet forwarding mode with retry", modes);
6492 cmd_set_fwd_retry_mode.help_str = help;
6494 /* string token separator is # */
6495 for (c = token; *modes != '\0'; modes++)
6500 token_struct = (cmdline_parse_token_string_t *)
6501 cmd_set_fwd_retry_mode.tokens[2];
6502 token_struct->string_data.str = token;
6505 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6506 struct cmd_set_burst_tx_retry_result {
6507 cmdline_fixed_string_t set;
6508 cmdline_fixed_string_t burst;
6509 cmdline_fixed_string_t tx;
6510 cmdline_fixed_string_t delay;
6512 cmdline_fixed_string_t retry;
6516 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6517 __attribute__((unused)) struct cmdline *cl,
6518 __attribute__((unused)) void *data)
6520 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6522 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6523 && !strcmp(res->tx, "tx")) {
6524 if (!strcmp(res->delay, "delay"))
6525 burst_tx_delay_time = res->time;
6526 if (!strcmp(res->retry, "retry"))
6527 burst_tx_retry_num = res->retry_num;
6532 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6533 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6534 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6535 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6537 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6538 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6539 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6541 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6542 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6543 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6544 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6545 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6546 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6548 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6549 .f = cmd_set_burst_tx_retry_parsed,
6550 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6552 (void *)&cmd_set_burst_tx_retry_set,
6553 (void *)&cmd_set_burst_tx_retry_burst,
6554 (void *)&cmd_set_burst_tx_retry_tx,
6555 (void *)&cmd_set_burst_tx_retry_delay,
6556 (void *)&cmd_set_burst_tx_retry_time,
6557 (void *)&cmd_set_burst_tx_retry_retry,
6558 (void *)&cmd_set_burst_tx_retry_retry_num,
6563 /* *** SET PROMISC MODE *** */
6564 struct cmd_set_promisc_mode_result {
6565 cmdline_fixed_string_t set;
6566 cmdline_fixed_string_t promisc;
6567 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6568 uint16_t port_num; /* valid if "allports" argument == 0 */
6569 cmdline_fixed_string_t mode;
6572 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6573 __attribute__((unused)) struct cmdline *cl,
6576 struct cmd_set_promisc_mode_result *res = parsed_result;
6580 if (!strcmp(res->mode, "on"))
6587 RTE_ETH_FOREACH_DEV(i) {
6589 rte_eth_promiscuous_enable(i);
6591 rte_eth_promiscuous_disable(i);
6596 rte_eth_promiscuous_enable(res->port_num);
6598 rte_eth_promiscuous_disable(res->port_num);
6602 cmdline_parse_token_string_t cmd_setpromisc_set =
6603 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6604 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6605 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6607 cmdline_parse_token_string_t cmd_setpromisc_portall =
6608 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6610 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6611 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6613 cmdline_parse_token_string_t cmd_setpromisc_mode =
6614 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6617 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6618 .f = cmd_set_promisc_mode_parsed,
6620 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6622 (void *)&cmd_setpromisc_set,
6623 (void *)&cmd_setpromisc_promisc,
6624 (void *)&cmd_setpromisc_portall,
6625 (void *)&cmd_setpromisc_mode,
6630 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6631 .f = cmd_set_promisc_mode_parsed,
6633 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6635 (void *)&cmd_setpromisc_set,
6636 (void *)&cmd_setpromisc_promisc,
6637 (void *)&cmd_setpromisc_portnum,
6638 (void *)&cmd_setpromisc_mode,
6643 /* *** SET ALLMULTI MODE *** */
6644 struct cmd_set_allmulti_mode_result {
6645 cmdline_fixed_string_t set;
6646 cmdline_fixed_string_t allmulti;
6647 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6648 uint16_t port_num; /* valid if "allports" argument == 0 */
6649 cmdline_fixed_string_t mode;
6652 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6653 __attribute__((unused)) struct cmdline *cl,
6656 struct cmd_set_allmulti_mode_result *res = parsed_result;
6660 if (!strcmp(res->mode, "on"))
6667 RTE_ETH_FOREACH_DEV(i) {
6669 rte_eth_allmulticast_enable(i);
6671 rte_eth_allmulticast_disable(i);
6676 rte_eth_allmulticast_enable(res->port_num);
6678 rte_eth_allmulticast_disable(res->port_num);
6682 cmdline_parse_token_string_t cmd_setallmulti_set =
6683 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6684 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6687 cmdline_parse_token_string_t cmd_setallmulti_portall =
6688 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6690 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6691 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6693 cmdline_parse_token_string_t cmd_setallmulti_mode =
6694 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6697 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6698 .f = cmd_set_allmulti_mode_parsed,
6700 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6702 (void *)&cmd_setallmulti_set,
6703 (void *)&cmd_setallmulti_allmulti,
6704 (void *)&cmd_setallmulti_portall,
6705 (void *)&cmd_setallmulti_mode,
6710 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6711 .f = cmd_set_allmulti_mode_parsed,
6713 .help_str = "set allmulti <port_id> on|off: "
6714 "Set allmulti mode on port_id",
6716 (void *)&cmd_setallmulti_set,
6717 (void *)&cmd_setallmulti_allmulti,
6718 (void *)&cmd_setallmulti_portnum,
6719 (void *)&cmd_setallmulti_mode,
6724 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6725 struct cmd_link_flow_ctrl_set_result {
6726 cmdline_fixed_string_t set;
6727 cmdline_fixed_string_t flow_ctrl;
6728 cmdline_fixed_string_t rx;
6729 cmdline_fixed_string_t rx_lfc_mode;
6730 cmdline_fixed_string_t tx;
6731 cmdline_fixed_string_t tx_lfc_mode;
6732 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6733 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6734 cmdline_fixed_string_t autoneg_str;
6735 cmdline_fixed_string_t autoneg;
6736 cmdline_fixed_string_t hw_str;
6737 uint32_t high_water;
6738 cmdline_fixed_string_t lw_str;
6740 cmdline_fixed_string_t pt_str;
6741 uint16_t pause_time;
6742 cmdline_fixed_string_t xon_str;
6747 cmdline_parse_token_string_t cmd_lfc_set_set =
6748 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6750 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6751 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6752 flow_ctrl, "flow_ctrl");
6753 cmdline_parse_token_string_t cmd_lfc_set_rx =
6754 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6756 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6757 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6758 rx_lfc_mode, "on#off");
6759 cmdline_parse_token_string_t cmd_lfc_set_tx =
6760 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6762 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6763 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6764 tx_lfc_mode, "on#off");
6765 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6766 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6767 hw_str, "high_water");
6768 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6769 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6770 high_water, UINT32);
6771 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6772 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6773 lw_str, "low_water");
6774 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6775 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6777 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6779 pt_str, "pause_time");
6780 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6781 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6782 pause_time, UINT16);
6783 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6784 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6785 xon_str, "send_xon");
6786 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6787 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6789 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6790 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6791 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6792 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6793 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6794 mac_ctrl_frame_fwd_mode, "on#off");
6795 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6796 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6797 autoneg_str, "autoneg");
6798 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6799 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6801 cmdline_parse_token_num_t cmd_lfc_set_portid =
6802 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6805 /* forward declaration */
6807 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6810 cmdline_parse_inst_t cmd_link_flow_control_set = {
6811 .f = cmd_link_flow_ctrl_set_parsed,
6813 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6814 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6815 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6817 (void *)&cmd_lfc_set_set,
6818 (void *)&cmd_lfc_set_flow_ctrl,
6819 (void *)&cmd_lfc_set_rx,
6820 (void *)&cmd_lfc_set_rx_mode,
6821 (void *)&cmd_lfc_set_tx,
6822 (void *)&cmd_lfc_set_tx_mode,
6823 (void *)&cmd_lfc_set_high_water,
6824 (void *)&cmd_lfc_set_low_water,
6825 (void *)&cmd_lfc_set_pause_time,
6826 (void *)&cmd_lfc_set_send_xon,
6827 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6828 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6829 (void *)&cmd_lfc_set_autoneg_str,
6830 (void *)&cmd_lfc_set_autoneg,
6831 (void *)&cmd_lfc_set_portid,
6836 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6837 .f = cmd_link_flow_ctrl_set_parsed,
6838 .data = (void *)&cmd_link_flow_control_set_rx,
6839 .help_str = "set flow_ctrl rx on|off <port_id>: "
6840 "Change rx flow control parameter",
6842 (void *)&cmd_lfc_set_set,
6843 (void *)&cmd_lfc_set_flow_ctrl,
6844 (void *)&cmd_lfc_set_rx,
6845 (void *)&cmd_lfc_set_rx_mode,
6846 (void *)&cmd_lfc_set_portid,
6851 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6852 .f = cmd_link_flow_ctrl_set_parsed,
6853 .data = (void *)&cmd_link_flow_control_set_tx,
6854 .help_str = "set flow_ctrl tx on|off <port_id>: "
6855 "Change tx flow control parameter",
6857 (void *)&cmd_lfc_set_set,
6858 (void *)&cmd_lfc_set_flow_ctrl,
6859 (void *)&cmd_lfc_set_tx,
6860 (void *)&cmd_lfc_set_tx_mode,
6861 (void *)&cmd_lfc_set_portid,
6866 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6867 .f = cmd_link_flow_ctrl_set_parsed,
6868 .data = (void *)&cmd_link_flow_control_set_hw,
6869 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6870 "Change high water flow control parameter",
6872 (void *)&cmd_lfc_set_set,
6873 (void *)&cmd_lfc_set_flow_ctrl,
6874 (void *)&cmd_lfc_set_high_water_str,
6875 (void *)&cmd_lfc_set_high_water,
6876 (void *)&cmd_lfc_set_portid,
6881 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6882 .f = cmd_link_flow_ctrl_set_parsed,
6883 .data = (void *)&cmd_link_flow_control_set_lw,
6884 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6885 "Change low water flow control parameter",
6887 (void *)&cmd_lfc_set_set,
6888 (void *)&cmd_lfc_set_flow_ctrl,
6889 (void *)&cmd_lfc_set_low_water_str,
6890 (void *)&cmd_lfc_set_low_water,
6891 (void *)&cmd_lfc_set_portid,
6896 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6897 .f = cmd_link_flow_ctrl_set_parsed,
6898 .data = (void *)&cmd_link_flow_control_set_pt,
6899 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6900 "Change pause time flow control parameter",
6902 (void *)&cmd_lfc_set_set,
6903 (void *)&cmd_lfc_set_flow_ctrl,
6904 (void *)&cmd_lfc_set_pause_time_str,
6905 (void *)&cmd_lfc_set_pause_time,
6906 (void *)&cmd_lfc_set_portid,
6911 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6912 .f = cmd_link_flow_ctrl_set_parsed,
6913 .data = (void *)&cmd_link_flow_control_set_xon,
6914 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6915 "Change send_xon flow control parameter",
6917 (void *)&cmd_lfc_set_set,
6918 (void *)&cmd_lfc_set_flow_ctrl,
6919 (void *)&cmd_lfc_set_send_xon_str,
6920 (void *)&cmd_lfc_set_send_xon,
6921 (void *)&cmd_lfc_set_portid,
6926 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6927 .f = cmd_link_flow_ctrl_set_parsed,
6928 .data = (void *)&cmd_link_flow_control_set_macfwd,
6929 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6930 "Change mac ctrl fwd flow control parameter",
6932 (void *)&cmd_lfc_set_set,
6933 (void *)&cmd_lfc_set_flow_ctrl,
6934 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6935 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6936 (void *)&cmd_lfc_set_portid,
6941 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6942 .f = cmd_link_flow_ctrl_set_parsed,
6943 .data = (void *)&cmd_link_flow_control_set_autoneg,
6944 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6945 "Change autoneg flow control parameter",
6947 (void *)&cmd_lfc_set_set,
6948 (void *)&cmd_lfc_set_flow_ctrl,
6949 (void *)&cmd_lfc_set_autoneg_str,
6950 (void *)&cmd_lfc_set_autoneg,
6951 (void *)&cmd_lfc_set_portid,
6957 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6958 __attribute__((unused)) struct cmdline *cl,
6961 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6962 cmdline_parse_inst_t *cmd = data;
6963 struct rte_eth_fc_conf fc_conf;
6969 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6970 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6971 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6972 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6974 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6975 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6978 /* Partial command line, retrieve current configuration */
6980 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6982 printf("cannot get current flow ctrl parameters, return"
6983 "code = %d\n", ret);
6987 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6988 (fc_conf.mode == RTE_FC_FULL))
6990 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6991 (fc_conf.mode == RTE_FC_FULL))
6995 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6996 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6998 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6999 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7001 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7003 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7004 fc_conf.high_water = res->high_water;
7006 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7007 fc_conf.low_water = res->low_water;
7009 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7010 fc_conf.pause_time = res->pause_time;
7012 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7013 fc_conf.send_xon = res->send_xon;
7015 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7016 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7017 fc_conf.mac_ctrl_frame_fwd = 1;
7019 fc_conf.mac_ctrl_frame_fwd = 0;
7022 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7023 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7025 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7027 printf("bad flow contrl parameter, return code = %d \n", ret);
7030 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7031 struct cmd_priority_flow_ctrl_set_result {
7032 cmdline_fixed_string_t set;
7033 cmdline_fixed_string_t pfc_ctrl;
7034 cmdline_fixed_string_t rx;
7035 cmdline_fixed_string_t rx_pfc_mode;
7036 cmdline_fixed_string_t tx;
7037 cmdline_fixed_string_t tx_pfc_mode;
7038 uint32_t high_water;
7040 uint16_t pause_time;
7046 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7047 __attribute__((unused)) struct cmdline *cl,
7048 __attribute__((unused)) void *data)
7050 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7051 struct rte_eth_pfc_conf pfc_conf;
7052 int rx_fc_enable, tx_fc_enable;
7056 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7057 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7058 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7059 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7061 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7062 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7065 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7066 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7067 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7068 pfc_conf.fc.high_water = res->high_water;
7069 pfc_conf.fc.low_water = res->low_water;
7070 pfc_conf.fc.pause_time = res->pause_time;
7071 pfc_conf.priority = res->priority;
7073 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7075 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7078 cmdline_parse_token_string_t cmd_pfc_set_set =
7079 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7081 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7082 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7083 pfc_ctrl, "pfc_ctrl");
7084 cmdline_parse_token_string_t cmd_pfc_set_rx =
7085 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7087 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7088 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7089 rx_pfc_mode, "on#off");
7090 cmdline_parse_token_string_t cmd_pfc_set_tx =
7091 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7093 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7094 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7095 tx_pfc_mode, "on#off");
7096 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7097 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7098 high_water, UINT32);
7099 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7100 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7102 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7103 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7104 pause_time, UINT16);
7105 cmdline_parse_token_num_t cmd_pfc_set_priority =
7106 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7108 cmdline_parse_token_num_t cmd_pfc_set_portid =
7109 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7112 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7113 .f = cmd_priority_flow_ctrl_set_parsed,
7115 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7116 "<pause_time> <priority> <port_id>: "
7117 "Configure the Ethernet priority flow control",
7119 (void *)&cmd_pfc_set_set,
7120 (void *)&cmd_pfc_set_flow_ctrl,
7121 (void *)&cmd_pfc_set_rx,
7122 (void *)&cmd_pfc_set_rx_mode,
7123 (void *)&cmd_pfc_set_tx,
7124 (void *)&cmd_pfc_set_tx_mode,
7125 (void *)&cmd_pfc_set_high_water,
7126 (void *)&cmd_pfc_set_low_water,
7127 (void *)&cmd_pfc_set_pause_time,
7128 (void *)&cmd_pfc_set_priority,
7129 (void *)&cmd_pfc_set_portid,
7134 /* *** RESET CONFIGURATION *** */
7135 struct cmd_reset_result {
7136 cmdline_fixed_string_t reset;
7137 cmdline_fixed_string_t def;
7140 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7142 __attribute__((unused)) void *data)
7144 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7145 set_def_fwd_config();
7148 cmdline_parse_token_string_t cmd_reset_set =
7149 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7150 cmdline_parse_token_string_t cmd_reset_def =
7151 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7154 cmdline_parse_inst_t cmd_reset = {
7155 .f = cmd_reset_parsed,
7157 .help_str = "set default: Reset default forwarding configuration",
7159 (void *)&cmd_reset_set,
7160 (void *)&cmd_reset_def,
7165 /* *** START FORWARDING *** */
7166 struct cmd_start_result {
7167 cmdline_fixed_string_t start;
7170 cmdline_parse_token_string_t cmd_start_start =
7171 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7173 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7174 __attribute__((unused)) struct cmdline *cl,
7175 __attribute__((unused)) void *data)
7177 start_packet_forwarding(0);
7180 cmdline_parse_inst_t cmd_start = {
7181 .f = cmd_start_parsed,
7183 .help_str = "start: Start packet forwarding",
7185 (void *)&cmd_start_start,
7190 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7191 struct cmd_start_tx_first_result {
7192 cmdline_fixed_string_t start;
7193 cmdline_fixed_string_t tx_first;
7197 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7198 __attribute__((unused)) struct cmdline *cl,
7199 __attribute__((unused)) void *data)
7201 start_packet_forwarding(1);
7204 cmdline_parse_token_string_t cmd_start_tx_first_start =
7205 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7207 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7208 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7209 tx_first, "tx_first");
7211 cmdline_parse_inst_t cmd_start_tx_first = {
7212 .f = cmd_start_tx_first_parsed,
7214 .help_str = "start tx_first: Start packet forwarding, "
7215 "after sending 1 burst of packets",
7217 (void *)&cmd_start_tx_first_start,
7218 (void *)&cmd_start_tx_first_tx_first,
7223 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7224 struct cmd_start_tx_first_n_result {
7225 cmdline_fixed_string_t start;
7226 cmdline_fixed_string_t tx_first;
7231 cmd_start_tx_first_n_parsed(void *parsed_result,
7232 __attribute__((unused)) struct cmdline *cl,
7233 __attribute__((unused)) void *data)
7235 struct cmd_start_tx_first_n_result *res = parsed_result;
7237 start_packet_forwarding(res->tx_num);
7240 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7241 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7243 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7244 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7245 tx_first, "tx_first");
7246 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7247 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7250 cmdline_parse_inst_t cmd_start_tx_first_n = {
7251 .f = cmd_start_tx_first_n_parsed,
7253 .help_str = "start tx_first <num>: "
7254 "packet forwarding, after sending <num> bursts of packets",
7256 (void *)&cmd_start_tx_first_n_start,
7257 (void *)&cmd_start_tx_first_n_tx_first,
7258 (void *)&cmd_start_tx_first_n_tx_num,
7263 /* *** SET LINK UP *** */
7264 struct cmd_set_link_up_result {
7265 cmdline_fixed_string_t set;
7266 cmdline_fixed_string_t link_up;
7267 cmdline_fixed_string_t port;
7271 cmdline_parse_token_string_t cmd_set_link_up_set =
7272 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7273 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7274 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7276 cmdline_parse_token_string_t cmd_set_link_up_port =
7277 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7278 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7279 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7281 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7282 __attribute__((unused)) struct cmdline *cl,
7283 __attribute__((unused)) void *data)
7285 struct cmd_set_link_up_result *res = parsed_result;
7286 dev_set_link_up(res->port_id);
7289 cmdline_parse_inst_t cmd_set_link_up = {
7290 .f = cmd_set_link_up_parsed,
7292 .help_str = "set link-up port <port id>",
7294 (void *)&cmd_set_link_up_set,
7295 (void *)&cmd_set_link_up_link_up,
7296 (void *)&cmd_set_link_up_port,
7297 (void *)&cmd_set_link_up_port_id,
7302 /* *** SET LINK DOWN *** */
7303 struct cmd_set_link_down_result {
7304 cmdline_fixed_string_t set;
7305 cmdline_fixed_string_t link_down;
7306 cmdline_fixed_string_t port;
7310 cmdline_parse_token_string_t cmd_set_link_down_set =
7311 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7312 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7313 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7315 cmdline_parse_token_string_t cmd_set_link_down_port =
7316 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7317 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7318 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7320 static void cmd_set_link_down_parsed(
7321 __attribute__((unused)) void *parsed_result,
7322 __attribute__((unused)) struct cmdline *cl,
7323 __attribute__((unused)) void *data)
7325 struct cmd_set_link_down_result *res = parsed_result;
7326 dev_set_link_down(res->port_id);
7329 cmdline_parse_inst_t cmd_set_link_down = {
7330 .f = cmd_set_link_down_parsed,
7332 .help_str = "set link-down port <port id>",
7334 (void *)&cmd_set_link_down_set,
7335 (void *)&cmd_set_link_down_link_down,
7336 (void *)&cmd_set_link_down_port,
7337 (void *)&cmd_set_link_down_port_id,
7342 /* *** SHOW CFG *** */
7343 struct cmd_showcfg_result {
7344 cmdline_fixed_string_t show;
7345 cmdline_fixed_string_t cfg;
7346 cmdline_fixed_string_t what;
7349 static void cmd_showcfg_parsed(void *parsed_result,
7350 __attribute__((unused)) struct cmdline *cl,
7351 __attribute__((unused)) void *data)
7353 struct cmd_showcfg_result *res = parsed_result;
7354 if (!strcmp(res->what, "rxtx"))
7355 rxtx_config_display();
7356 else if (!strcmp(res->what, "cores"))
7357 fwd_lcores_config_display();
7358 else if (!strcmp(res->what, "fwd"))
7359 pkt_fwd_config_display(&cur_fwd_config);
7360 else if (!strcmp(res->what, "txpkts"))
7361 show_tx_pkt_segments();
7364 cmdline_parse_token_string_t cmd_showcfg_show =
7365 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7366 cmdline_parse_token_string_t cmd_showcfg_port =
7367 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7368 cmdline_parse_token_string_t cmd_showcfg_what =
7369 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7370 "rxtx#cores#fwd#txpkts");
7372 cmdline_parse_inst_t cmd_showcfg = {
7373 .f = cmd_showcfg_parsed,
7375 .help_str = "show config rxtx|cores|fwd|txpkts",
7377 (void *)&cmd_showcfg_show,
7378 (void *)&cmd_showcfg_port,
7379 (void *)&cmd_showcfg_what,
7384 /* *** SHOW ALL PORT INFO *** */
7385 struct cmd_showportall_result {
7386 cmdline_fixed_string_t show;
7387 cmdline_fixed_string_t port;
7388 cmdline_fixed_string_t what;
7389 cmdline_fixed_string_t all;
7392 static void cmd_showportall_parsed(void *parsed_result,
7393 __attribute__((unused)) struct cmdline *cl,
7394 __attribute__((unused)) void *data)
7398 struct cmd_showportall_result *res = parsed_result;
7399 if (!strcmp(res->show, "clear")) {
7400 if (!strcmp(res->what, "stats"))
7401 RTE_ETH_FOREACH_DEV(i)
7403 else if (!strcmp(res->what, "xstats"))
7404 RTE_ETH_FOREACH_DEV(i)
7405 nic_xstats_clear(i);
7406 } else if (!strcmp(res->what, "info"))
7407 RTE_ETH_FOREACH_DEV(i)
7408 port_infos_display(i);
7409 else if (!strcmp(res->what, "summary")) {
7410 port_summary_header_display();
7411 RTE_ETH_FOREACH_DEV(i)
7412 port_summary_display(i);
7414 else if (!strcmp(res->what, "stats"))
7415 RTE_ETH_FOREACH_DEV(i)
7416 nic_stats_display(i);
7417 else if (!strcmp(res->what, "xstats"))
7418 RTE_ETH_FOREACH_DEV(i)
7419 nic_xstats_display(i);
7420 else if (!strcmp(res->what, "fdir"))
7421 RTE_ETH_FOREACH_DEV(i)
7423 else if (!strcmp(res->what, "stat_qmap"))
7424 RTE_ETH_FOREACH_DEV(i)
7425 nic_stats_mapping_display(i);
7426 else if (!strcmp(res->what, "dcb_tc"))
7427 RTE_ETH_FOREACH_DEV(i)
7428 port_dcb_info_display(i);
7429 else if (!strcmp(res->what, "cap"))
7430 RTE_ETH_FOREACH_DEV(i)
7431 port_offload_cap_display(i);
7434 cmdline_parse_token_string_t cmd_showportall_show =
7435 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7437 cmdline_parse_token_string_t cmd_showportall_port =
7438 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7439 cmdline_parse_token_string_t cmd_showportall_what =
7440 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7441 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7442 cmdline_parse_token_string_t cmd_showportall_all =
7443 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7444 cmdline_parse_inst_t cmd_showportall = {
7445 .f = cmd_showportall_parsed,
7447 .help_str = "show|clear port "
7448 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7450 (void *)&cmd_showportall_show,
7451 (void *)&cmd_showportall_port,
7452 (void *)&cmd_showportall_what,
7453 (void *)&cmd_showportall_all,
7458 /* *** SHOW PORT INFO *** */
7459 struct cmd_showport_result {
7460 cmdline_fixed_string_t show;
7461 cmdline_fixed_string_t port;
7462 cmdline_fixed_string_t what;
7466 static void cmd_showport_parsed(void *parsed_result,
7467 __attribute__((unused)) struct cmdline *cl,
7468 __attribute__((unused)) void *data)
7470 struct cmd_showport_result *res = parsed_result;
7471 if (!strcmp(res->show, "clear")) {
7472 if (!strcmp(res->what, "stats"))
7473 nic_stats_clear(res->portnum);
7474 else if (!strcmp(res->what, "xstats"))
7475 nic_xstats_clear(res->portnum);
7476 } else if (!strcmp(res->what, "info"))
7477 port_infos_display(res->portnum);
7478 else if (!strcmp(res->what, "summary")) {
7479 port_summary_header_display();
7480 port_summary_display(res->portnum);
7482 else if (!strcmp(res->what, "stats"))
7483 nic_stats_display(res->portnum);
7484 else if (!strcmp(res->what, "xstats"))
7485 nic_xstats_display(res->portnum);
7486 else if (!strcmp(res->what, "fdir"))
7487 fdir_get_infos(res->portnum);
7488 else if (!strcmp(res->what, "stat_qmap"))
7489 nic_stats_mapping_display(res->portnum);
7490 else if (!strcmp(res->what, "dcb_tc"))
7491 port_dcb_info_display(res->portnum);
7492 else if (!strcmp(res->what, "cap"))
7493 port_offload_cap_display(res->portnum);
7496 cmdline_parse_token_string_t cmd_showport_show =
7497 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7499 cmdline_parse_token_string_t cmd_showport_port =
7500 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7501 cmdline_parse_token_string_t cmd_showport_what =
7502 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7503 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7504 cmdline_parse_token_num_t cmd_showport_portnum =
7505 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7507 cmdline_parse_inst_t cmd_showport = {
7508 .f = cmd_showport_parsed,
7510 .help_str = "show|clear port "
7511 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7514 (void *)&cmd_showport_show,
7515 (void *)&cmd_showport_port,
7516 (void *)&cmd_showport_what,
7517 (void *)&cmd_showport_portnum,
7522 /* *** SHOW DEVICE INFO *** */
7523 struct cmd_showdevice_result {
7524 cmdline_fixed_string_t show;
7525 cmdline_fixed_string_t device;
7526 cmdline_fixed_string_t what;
7527 cmdline_fixed_string_t identifier;
7530 static void cmd_showdevice_parsed(void *parsed_result,
7531 __attribute__((unused)) struct cmdline *cl,
7532 __attribute__((unused)) void *data)
7534 struct cmd_showdevice_result *res = parsed_result;
7535 if (!strcmp(res->what, "info")) {
7536 if (!strcmp(res->identifier, "all"))
7537 device_infos_display(NULL);
7539 device_infos_display(res->identifier);
7543 cmdline_parse_token_string_t cmd_showdevice_show =
7544 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7546 cmdline_parse_token_string_t cmd_showdevice_device =
7547 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7548 cmdline_parse_token_string_t cmd_showdevice_what =
7549 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7551 cmdline_parse_token_string_t cmd_showdevice_identifier =
7552 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7555 cmdline_parse_inst_t cmd_showdevice = {
7556 .f = cmd_showdevice_parsed,
7558 .help_str = "show device info <identifier>|all",
7560 (void *)&cmd_showdevice_show,
7561 (void *)&cmd_showdevice_device,
7562 (void *)&cmd_showdevice_what,
7563 (void *)&cmd_showdevice_identifier,
7567 /* *** SHOW QUEUE INFO *** */
7568 struct cmd_showqueue_result {
7569 cmdline_fixed_string_t show;
7570 cmdline_fixed_string_t type;
7571 cmdline_fixed_string_t what;
7577 cmd_showqueue_parsed(void *parsed_result,
7578 __attribute__((unused)) struct cmdline *cl,
7579 __attribute__((unused)) void *data)
7581 struct cmd_showqueue_result *res = parsed_result;
7583 if (!strcmp(res->type, "rxq"))
7584 rx_queue_infos_display(res->portnum, res->queuenum);
7585 else if (!strcmp(res->type, "txq"))
7586 tx_queue_infos_display(res->portnum, res->queuenum);
7589 cmdline_parse_token_string_t cmd_showqueue_show =
7590 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7591 cmdline_parse_token_string_t cmd_showqueue_type =
7592 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7593 cmdline_parse_token_string_t cmd_showqueue_what =
7594 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7595 cmdline_parse_token_num_t cmd_showqueue_portnum =
7596 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7597 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7598 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7600 cmdline_parse_inst_t cmd_showqueue = {
7601 .f = cmd_showqueue_parsed,
7603 .help_str = "show rxq|txq info <port_id> <queue_id>",
7605 (void *)&cmd_showqueue_show,
7606 (void *)&cmd_showqueue_type,
7607 (void *)&cmd_showqueue_what,
7608 (void *)&cmd_showqueue_portnum,
7609 (void *)&cmd_showqueue_queuenum,
7614 /* show/clear fwd engine statistics */
7616 cmdline_fixed_string_t action;
7617 cmdline_fixed_string_t fwd;
7618 cmdline_fixed_string_t stats;
7619 cmdline_fixed_string_t all;
7622 cmdline_parse_token_string_t cmd_fwd_action =
7623 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7624 cmdline_parse_token_string_t cmd_fwd_fwd =
7625 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7626 cmdline_parse_token_string_t cmd_fwd_stats =
7627 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7628 cmdline_parse_token_string_t cmd_fwd_all =
7629 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7632 cmd_showfwdall_parsed(void *parsed_result,
7633 __rte_unused struct cmdline *cl,
7634 __rte_unused void *data)
7636 struct fwd_result *res = parsed_result;
7638 if (!strcmp(res->action, "show"))
7639 fwd_stats_display();
7644 static cmdline_parse_inst_t cmd_showfwdall = {
7645 .f = cmd_showfwdall_parsed,
7647 .help_str = "show|clear fwd stats all",
7649 (void *)&cmd_fwd_action,
7650 (void *)&cmd_fwd_fwd,
7651 (void *)&cmd_fwd_stats,
7652 (void *)&cmd_fwd_all,
7657 /* *** READ PORT REGISTER *** */
7658 struct cmd_read_reg_result {
7659 cmdline_fixed_string_t read;
7660 cmdline_fixed_string_t reg;
7666 cmd_read_reg_parsed(void *parsed_result,
7667 __attribute__((unused)) struct cmdline *cl,
7668 __attribute__((unused)) void *data)
7670 struct cmd_read_reg_result *res = parsed_result;
7671 port_reg_display(res->port_id, res->reg_off);
7674 cmdline_parse_token_string_t cmd_read_reg_read =
7675 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7676 cmdline_parse_token_string_t cmd_read_reg_reg =
7677 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7678 cmdline_parse_token_num_t cmd_read_reg_port_id =
7679 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7680 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7681 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7683 cmdline_parse_inst_t cmd_read_reg = {
7684 .f = cmd_read_reg_parsed,
7686 .help_str = "read reg <port_id> <reg_off>",
7688 (void *)&cmd_read_reg_read,
7689 (void *)&cmd_read_reg_reg,
7690 (void *)&cmd_read_reg_port_id,
7691 (void *)&cmd_read_reg_reg_off,
7696 /* *** READ PORT REGISTER BIT FIELD *** */
7697 struct cmd_read_reg_bit_field_result {
7698 cmdline_fixed_string_t read;
7699 cmdline_fixed_string_t regfield;
7707 cmd_read_reg_bit_field_parsed(void *parsed_result,
7708 __attribute__((unused)) struct cmdline *cl,
7709 __attribute__((unused)) void *data)
7711 struct cmd_read_reg_bit_field_result *res = parsed_result;
7712 port_reg_bit_field_display(res->port_id, res->reg_off,
7713 res->bit1_pos, res->bit2_pos);
7716 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7717 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7719 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7720 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7721 regfield, "regfield");
7722 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7723 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7725 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7726 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7728 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7729 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7731 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7732 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7735 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7736 .f = cmd_read_reg_bit_field_parsed,
7738 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7739 "Read register bit field between bit_x and bit_y included",
7741 (void *)&cmd_read_reg_bit_field_read,
7742 (void *)&cmd_read_reg_bit_field_regfield,
7743 (void *)&cmd_read_reg_bit_field_port_id,
7744 (void *)&cmd_read_reg_bit_field_reg_off,
7745 (void *)&cmd_read_reg_bit_field_bit1_pos,
7746 (void *)&cmd_read_reg_bit_field_bit2_pos,
7751 /* *** READ PORT REGISTER BIT *** */
7752 struct cmd_read_reg_bit_result {
7753 cmdline_fixed_string_t read;
7754 cmdline_fixed_string_t regbit;
7761 cmd_read_reg_bit_parsed(void *parsed_result,
7762 __attribute__((unused)) struct cmdline *cl,
7763 __attribute__((unused)) void *data)
7765 struct cmd_read_reg_bit_result *res = parsed_result;
7766 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7769 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7770 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7771 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7772 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7774 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7775 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7776 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7777 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7778 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7779 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7781 cmdline_parse_inst_t cmd_read_reg_bit = {
7782 .f = cmd_read_reg_bit_parsed,
7784 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7786 (void *)&cmd_read_reg_bit_read,
7787 (void *)&cmd_read_reg_bit_regbit,
7788 (void *)&cmd_read_reg_bit_port_id,
7789 (void *)&cmd_read_reg_bit_reg_off,
7790 (void *)&cmd_read_reg_bit_bit_pos,
7795 /* *** WRITE PORT REGISTER *** */
7796 struct cmd_write_reg_result {
7797 cmdline_fixed_string_t write;
7798 cmdline_fixed_string_t reg;
7805 cmd_write_reg_parsed(void *parsed_result,
7806 __attribute__((unused)) struct cmdline *cl,
7807 __attribute__((unused)) void *data)
7809 struct cmd_write_reg_result *res = parsed_result;
7810 port_reg_set(res->port_id, res->reg_off, res->value);
7813 cmdline_parse_token_string_t cmd_write_reg_write =
7814 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7815 cmdline_parse_token_string_t cmd_write_reg_reg =
7816 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7817 cmdline_parse_token_num_t cmd_write_reg_port_id =
7818 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7819 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7820 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7821 cmdline_parse_token_num_t cmd_write_reg_value =
7822 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7824 cmdline_parse_inst_t cmd_write_reg = {
7825 .f = cmd_write_reg_parsed,
7827 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7829 (void *)&cmd_write_reg_write,
7830 (void *)&cmd_write_reg_reg,
7831 (void *)&cmd_write_reg_port_id,
7832 (void *)&cmd_write_reg_reg_off,
7833 (void *)&cmd_write_reg_value,
7838 /* *** WRITE PORT REGISTER BIT FIELD *** */
7839 struct cmd_write_reg_bit_field_result {
7840 cmdline_fixed_string_t write;
7841 cmdline_fixed_string_t regfield;
7850 cmd_write_reg_bit_field_parsed(void *parsed_result,
7851 __attribute__((unused)) struct cmdline *cl,
7852 __attribute__((unused)) void *data)
7854 struct cmd_write_reg_bit_field_result *res = parsed_result;
7855 port_reg_bit_field_set(res->port_id, res->reg_off,
7856 res->bit1_pos, res->bit2_pos, res->value);
7859 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7860 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7862 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7863 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7864 regfield, "regfield");
7865 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7866 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7868 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7869 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7871 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7872 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7874 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7875 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7877 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7878 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7881 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7882 .f = cmd_write_reg_bit_field_parsed,
7884 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7886 "Set register bit field between bit_x and bit_y included",
7888 (void *)&cmd_write_reg_bit_field_write,
7889 (void *)&cmd_write_reg_bit_field_regfield,
7890 (void *)&cmd_write_reg_bit_field_port_id,
7891 (void *)&cmd_write_reg_bit_field_reg_off,
7892 (void *)&cmd_write_reg_bit_field_bit1_pos,
7893 (void *)&cmd_write_reg_bit_field_bit2_pos,
7894 (void *)&cmd_write_reg_bit_field_value,
7899 /* *** WRITE PORT REGISTER BIT *** */
7900 struct cmd_write_reg_bit_result {
7901 cmdline_fixed_string_t write;
7902 cmdline_fixed_string_t regbit;
7910 cmd_write_reg_bit_parsed(void *parsed_result,
7911 __attribute__((unused)) struct cmdline *cl,
7912 __attribute__((unused)) void *data)
7914 struct cmd_write_reg_bit_result *res = parsed_result;
7915 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7918 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7919 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7921 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7922 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7924 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7925 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7926 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7927 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7928 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7929 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7930 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7931 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7933 cmdline_parse_inst_t cmd_write_reg_bit = {
7934 .f = cmd_write_reg_bit_parsed,
7936 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7939 (void *)&cmd_write_reg_bit_write,
7940 (void *)&cmd_write_reg_bit_regbit,
7941 (void *)&cmd_write_reg_bit_port_id,
7942 (void *)&cmd_write_reg_bit_reg_off,
7943 (void *)&cmd_write_reg_bit_bit_pos,
7944 (void *)&cmd_write_reg_bit_value,
7949 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7950 struct cmd_read_rxd_txd_result {
7951 cmdline_fixed_string_t read;
7952 cmdline_fixed_string_t rxd_txd;
7959 cmd_read_rxd_txd_parsed(void *parsed_result,
7960 __attribute__((unused)) struct cmdline *cl,
7961 __attribute__((unused)) void *data)
7963 struct cmd_read_rxd_txd_result *res = parsed_result;
7965 if (!strcmp(res->rxd_txd, "rxd"))
7966 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7967 else if (!strcmp(res->rxd_txd, "txd"))
7968 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7971 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7972 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7973 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7974 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7976 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7977 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7978 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7979 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7980 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7981 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7983 cmdline_parse_inst_t cmd_read_rxd_txd = {
7984 .f = cmd_read_rxd_txd_parsed,
7986 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7988 (void *)&cmd_read_rxd_txd_read,
7989 (void *)&cmd_read_rxd_txd_rxd_txd,
7990 (void *)&cmd_read_rxd_txd_port_id,
7991 (void *)&cmd_read_rxd_txd_queue_id,
7992 (void *)&cmd_read_rxd_txd_desc_id,
7998 struct cmd_quit_result {
7999 cmdline_fixed_string_t quit;
8002 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
8004 __attribute__((unused)) void *data)
8009 cmdline_parse_token_string_t cmd_quit_quit =
8010 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8012 cmdline_parse_inst_t cmd_quit = {
8013 .f = cmd_quit_parsed,
8015 .help_str = "quit: Exit application",
8017 (void *)&cmd_quit_quit,
8022 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8023 struct cmd_mac_addr_result {
8024 cmdline_fixed_string_t mac_addr_cmd;
8025 cmdline_fixed_string_t what;
8027 struct rte_ether_addr address;
8030 static void cmd_mac_addr_parsed(void *parsed_result,
8031 __attribute__((unused)) struct cmdline *cl,
8032 __attribute__((unused)) void *data)
8034 struct cmd_mac_addr_result *res = parsed_result;
8037 if (strcmp(res->what, "add") == 0)
8038 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8039 else if (strcmp(res->what, "set") == 0)
8040 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8043 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8045 /* check the return value and print it if is < 0 */
8047 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8051 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8052 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8054 cmdline_parse_token_string_t cmd_mac_addr_what =
8055 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8057 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8058 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8060 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8061 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8063 cmdline_parse_inst_t cmd_mac_addr = {
8064 .f = cmd_mac_addr_parsed,
8066 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8067 "Add/Remove/Set MAC address on port_id",
8069 (void *)&cmd_mac_addr_cmd,
8070 (void *)&cmd_mac_addr_what,
8071 (void *)&cmd_mac_addr_portnum,
8072 (void *)&cmd_mac_addr_addr,
8077 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8078 struct cmd_eth_peer_result {
8079 cmdline_fixed_string_t set;
8080 cmdline_fixed_string_t eth_peer;
8082 cmdline_fixed_string_t peer_addr;
8085 static void cmd_set_eth_peer_parsed(void *parsed_result,
8086 __attribute__((unused)) struct cmdline *cl,
8087 __attribute__((unused)) void *data)
8089 struct cmd_eth_peer_result *res = parsed_result;
8091 if (test_done == 0) {
8092 printf("Please stop forwarding first\n");
8095 if (!strcmp(res->eth_peer, "eth-peer")) {
8096 set_fwd_eth_peer(res->port_id, res->peer_addr);
8100 cmdline_parse_token_string_t cmd_eth_peer_set =
8101 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8102 cmdline_parse_token_string_t cmd_eth_peer =
8103 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8104 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8105 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8106 cmdline_parse_token_string_t cmd_eth_peer_addr =
8107 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8109 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8110 .f = cmd_set_eth_peer_parsed,
8112 .help_str = "set eth-peer <port_id> <peer_mac>",
8114 (void *)&cmd_eth_peer_set,
8115 (void *)&cmd_eth_peer,
8116 (void *)&cmd_eth_peer_port_id,
8117 (void *)&cmd_eth_peer_addr,
8122 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8123 struct cmd_set_qmap_result {
8124 cmdline_fixed_string_t set;
8125 cmdline_fixed_string_t qmap;
8126 cmdline_fixed_string_t what;
8133 cmd_set_qmap_parsed(void *parsed_result,
8134 __attribute__((unused)) struct cmdline *cl,
8135 __attribute__((unused)) void *data)
8137 struct cmd_set_qmap_result *res = parsed_result;
8138 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8140 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8143 cmdline_parse_token_string_t cmd_setqmap_set =
8144 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8146 cmdline_parse_token_string_t cmd_setqmap_qmap =
8147 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8149 cmdline_parse_token_string_t cmd_setqmap_what =
8150 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8152 cmdline_parse_token_num_t cmd_setqmap_portid =
8153 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8155 cmdline_parse_token_num_t cmd_setqmap_queueid =
8156 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8158 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8159 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8162 cmdline_parse_inst_t cmd_set_qmap = {
8163 .f = cmd_set_qmap_parsed,
8165 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8166 "Set statistics mapping value on tx|rx queue_id of port_id",
8168 (void *)&cmd_setqmap_set,
8169 (void *)&cmd_setqmap_qmap,
8170 (void *)&cmd_setqmap_what,
8171 (void *)&cmd_setqmap_portid,
8172 (void *)&cmd_setqmap_queueid,
8173 (void *)&cmd_setqmap_mapvalue,
8178 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8179 struct cmd_set_xstats_hide_zero_result {
8180 cmdline_fixed_string_t keyword;
8181 cmdline_fixed_string_t name;
8182 cmdline_fixed_string_t on_off;
8186 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8187 __attribute__((unused)) struct cmdline *cl,
8188 __attribute__((unused)) void *data)
8190 struct cmd_set_xstats_hide_zero_result *res;
8191 uint16_t on_off = 0;
8193 res = parsed_result;
8194 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8195 set_xstats_hide_zero(on_off);
8198 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8199 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8201 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8202 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8203 name, "xstats-hide-zero");
8204 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8205 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8208 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8209 .f = cmd_set_xstats_hide_zero_parsed,
8211 .help_str = "set xstats-hide-zero on|off",
8213 (void *)&cmd_set_xstats_hide_zero_keyword,
8214 (void *)&cmd_set_xstats_hide_zero_name,
8215 (void *)&cmd_set_xstats_hide_zero_on_off,
8220 /* *** CONFIGURE UNICAST HASH TABLE *** */
8221 struct cmd_set_uc_hash_table {
8222 cmdline_fixed_string_t set;
8223 cmdline_fixed_string_t port;
8225 cmdline_fixed_string_t what;
8226 struct rte_ether_addr address;
8227 cmdline_fixed_string_t mode;
8231 cmd_set_uc_hash_parsed(void *parsed_result,
8232 __attribute__((unused)) struct cmdline *cl,
8233 __attribute__((unused)) void *data)
8236 struct cmd_set_uc_hash_table *res = parsed_result;
8238 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8240 if (strcmp(res->what, "uta") == 0)
8241 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8242 &res->address,(uint8_t)is_on);
8244 printf("bad unicast hash table parameter, return code = %d \n", ret);
8248 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8249 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8251 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8252 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8254 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8255 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8257 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8258 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8260 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8261 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8263 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8264 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8267 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8268 .f = cmd_set_uc_hash_parsed,
8270 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8272 (void *)&cmd_set_uc_hash_set,
8273 (void *)&cmd_set_uc_hash_port,
8274 (void *)&cmd_set_uc_hash_portid,
8275 (void *)&cmd_set_uc_hash_what,
8276 (void *)&cmd_set_uc_hash_mac,
8277 (void *)&cmd_set_uc_hash_mode,
8282 struct cmd_set_uc_all_hash_table {
8283 cmdline_fixed_string_t set;
8284 cmdline_fixed_string_t port;
8286 cmdline_fixed_string_t what;
8287 cmdline_fixed_string_t value;
8288 cmdline_fixed_string_t mode;
8292 cmd_set_uc_all_hash_parsed(void *parsed_result,
8293 __attribute__((unused)) struct cmdline *cl,
8294 __attribute__((unused)) void *data)
8297 struct cmd_set_uc_all_hash_table *res = parsed_result;
8299 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8301 if ((strcmp(res->what, "uta") == 0) &&
8302 (strcmp(res->value, "all") == 0))
8303 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8305 printf("bad unicast hash table parameter,"
8306 "return code = %d \n", ret);
8309 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8310 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8312 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8313 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8315 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8316 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8318 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8319 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8321 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8322 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8324 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8325 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8328 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8329 .f = cmd_set_uc_all_hash_parsed,
8331 .help_str = "set port <port_id> uta all on|off",
8333 (void *)&cmd_set_uc_all_hash_set,
8334 (void *)&cmd_set_uc_all_hash_port,
8335 (void *)&cmd_set_uc_all_hash_portid,
8336 (void *)&cmd_set_uc_all_hash_what,
8337 (void *)&cmd_set_uc_all_hash_value,
8338 (void *)&cmd_set_uc_all_hash_mode,
8343 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8344 struct cmd_set_vf_macvlan_filter {
8345 cmdline_fixed_string_t set;
8346 cmdline_fixed_string_t port;
8348 cmdline_fixed_string_t vf;
8350 struct rte_ether_addr address;
8351 cmdline_fixed_string_t filter_type;
8352 cmdline_fixed_string_t mode;
8356 cmd_set_vf_macvlan_parsed(void *parsed_result,
8357 __attribute__((unused)) struct cmdline *cl,
8358 __attribute__((unused)) void *data)
8361 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8362 struct rte_eth_mac_filter filter;
8364 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8366 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8368 /* set VF MAC filter */
8372 filter.dst_id = res->vf_id;
8374 if (!strcmp(res->filter_type, "exact-mac"))
8375 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8376 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8377 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8378 else if (!strcmp(res->filter_type, "hashmac"))
8379 filter.filter_type = RTE_MAC_HASH_MATCH;
8380 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8381 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8383 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8386 ret = rte_eth_dev_filter_ctrl(res->port_id,
8387 RTE_ETH_FILTER_MACVLAN,
8391 ret = rte_eth_dev_filter_ctrl(res->port_id,
8392 RTE_ETH_FILTER_MACVLAN,
8393 RTE_ETH_FILTER_DELETE,
8397 printf("bad set MAC hash parameter, return code = %d\n", ret);
8401 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8402 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8404 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8405 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8407 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8408 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8410 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8411 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8413 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8414 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8416 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8417 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8419 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8420 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8421 filter_type, "exact-mac#exact-mac-vlan"
8422 "#hashmac#hashmac-vlan");
8423 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8424 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8427 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8428 .f = cmd_set_vf_macvlan_parsed,
8430 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8431 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8432 "Exact match rule: exact match of MAC or MAC and VLAN; "
8433 "hash match rule: hash match of MAC and exact match of VLAN",
8435 (void *)&cmd_set_vf_macvlan_set,
8436 (void *)&cmd_set_vf_macvlan_port,
8437 (void *)&cmd_set_vf_macvlan_portid,
8438 (void *)&cmd_set_vf_macvlan_vf,
8439 (void *)&cmd_set_vf_macvlan_vf_id,
8440 (void *)&cmd_set_vf_macvlan_mac,
8441 (void *)&cmd_set_vf_macvlan_filter_type,
8442 (void *)&cmd_set_vf_macvlan_mode,
8447 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8448 struct cmd_set_vf_traffic {
8449 cmdline_fixed_string_t set;
8450 cmdline_fixed_string_t port;
8452 cmdline_fixed_string_t vf;
8454 cmdline_fixed_string_t what;
8455 cmdline_fixed_string_t mode;
8459 cmd_set_vf_traffic_parsed(void *parsed_result,
8460 __attribute__((unused)) struct cmdline *cl,
8461 __attribute__((unused)) void *data)
8463 struct cmd_set_vf_traffic *res = parsed_result;
8464 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8465 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8467 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8470 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8471 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8473 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8474 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8476 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8477 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8479 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8480 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8482 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8483 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8485 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8486 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8488 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8489 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8492 cmdline_parse_inst_t cmd_set_vf_traffic = {
8493 .f = cmd_set_vf_traffic_parsed,
8495 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8497 (void *)&cmd_setvf_traffic_set,
8498 (void *)&cmd_setvf_traffic_port,
8499 (void *)&cmd_setvf_traffic_portid,
8500 (void *)&cmd_setvf_traffic_vf,
8501 (void *)&cmd_setvf_traffic_vfid,
8502 (void *)&cmd_setvf_traffic_what,
8503 (void *)&cmd_setvf_traffic_mode,
8508 /* *** CONFIGURE VF RECEIVE MODE *** */
8509 struct cmd_set_vf_rxmode {
8510 cmdline_fixed_string_t set;
8511 cmdline_fixed_string_t port;
8513 cmdline_fixed_string_t vf;
8515 cmdline_fixed_string_t what;
8516 cmdline_fixed_string_t mode;
8517 cmdline_fixed_string_t on;
8521 cmd_set_vf_rxmode_parsed(void *parsed_result,
8522 __attribute__((unused)) struct cmdline *cl,
8523 __attribute__((unused)) void *data)
8526 uint16_t rx_mode = 0;
8527 struct cmd_set_vf_rxmode *res = parsed_result;
8529 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8530 if (!strcmp(res->what,"rxmode")) {
8531 if (!strcmp(res->mode, "AUPE"))
8532 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8533 else if (!strcmp(res->mode, "ROPE"))
8534 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8535 else if (!strcmp(res->mode, "BAM"))
8536 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8537 else if (!strncmp(res->mode, "MPE",3))
8538 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8541 RTE_SET_USED(is_on);
8543 #ifdef RTE_LIBRTE_IXGBE_PMD
8544 if (ret == -ENOTSUP)
8545 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8546 rx_mode, (uint8_t)is_on);
8548 #ifdef RTE_LIBRTE_BNXT_PMD
8549 if (ret == -ENOTSUP)
8550 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8551 rx_mode, (uint8_t)is_on);
8554 printf("bad VF receive mode parameter, return code = %d \n",
8558 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8559 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8561 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8562 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8564 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8565 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8567 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8568 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8570 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8571 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8573 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8574 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8576 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8577 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8578 mode, "AUPE#ROPE#BAM#MPE");
8579 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8580 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8583 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8584 .f = cmd_set_vf_rxmode_parsed,
8586 .help_str = "set port <port_id> vf <vf_id> rxmode "
8587 "AUPE|ROPE|BAM|MPE on|off",
8589 (void *)&cmd_set_vf_rxmode_set,
8590 (void *)&cmd_set_vf_rxmode_port,
8591 (void *)&cmd_set_vf_rxmode_portid,
8592 (void *)&cmd_set_vf_rxmode_vf,
8593 (void *)&cmd_set_vf_rxmode_vfid,
8594 (void *)&cmd_set_vf_rxmode_what,
8595 (void *)&cmd_set_vf_rxmode_mode,
8596 (void *)&cmd_set_vf_rxmode_on,
8601 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8602 struct cmd_vf_mac_addr_result {
8603 cmdline_fixed_string_t mac_addr_cmd;
8604 cmdline_fixed_string_t what;
8605 cmdline_fixed_string_t port;
8607 cmdline_fixed_string_t vf;
8609 struct rte_ether_addr address;
8612 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8613 __attribute__((unused)) struct cmdline *cl,
8614 __attribute__((unused)) void *data)
8616 struct cmd_vf_mac_addr_result *res = parsed_result;
8619 if (strcmp(res->what, "add") != 0)
8622 #ifdef RTE_LIBRTE_I40E_PMD
8623 if (ret == -ENOTSUP)
8624 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8627 #ifdef RTE_LIBRTE_BNXT_PMD
8628 if (ret == -ENOTSUP)
8629 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8634 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8638 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8639 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8640 mac_addr_cmd,"mac_addr");
8641 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8642 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8644 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8645 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8647 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8648 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8650 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8651 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8653 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8654 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8656 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8657 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8660 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8661 .f = cmd_vf_mac_addr_parsed,
8663 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8664 "Add MAC address filtering for a VF on port_id",
8666 (void *)&cmd_vf_mac_addr_cmd,
8667 (void *)&cmd_vf_mac_addr_what,
8668 (void *)&cmd_vf_mac_addr_port,
8669 (void *)&cmd_vf_mac_addr_portnum,
8670 (void *)&cmd_vf_mac_addr_vf,
8671 (void *)&cmd_vf_mac_addr_vfnum,
8672 (void *)&cmd_vf_mac_addr_addr,
8677 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8678 struct cmd_vf_rx_vlan_filter {
8679 cmdline_fixed_string_t rx_vlan;
8680 cmdline_fixed_string_t what;
8682 cmdline_fixed_string_t port;
8684 cmdline_fixed_string_t vf;
8689 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8690 __attribute__((unused)) struct cmdline *cl,
8691 __attribute__((unused)) void *data)
8693 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8696 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8698 #ifdef RTE_LIBRTE_IXGBE_PMD
8699 if (ret == -ENOTSUP)
8700 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8701 res->vlan_id, res->vf_mask, is_add);
8703 #ifdef RTE_LIBRTE_I40E_PMD
8704 if (ret == -ENOTSUP)
8705 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8706 res->vlan_id, res->vf_mask, is_add);
8708 #ifdef RTE_LIBRTE_BNXT_PMD
8709 if (ret == -ENOTSUP)
8710 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8711 res->vlan_id, res->vf_mask, is_add);
8718 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8719 res->vlan_id, res->vf_mask);
8722 printf("invalid port_id %d\n", res->port_id);
8725 printf("function not implemented or supported\n");
8728 printf("programming error: (%s)\n", strerror(-ret));
8732 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8733 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8734 rx_vlan, "rx_vlan");
8735 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8736 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8738 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8739 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8741 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8742 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8744 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8745 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8747 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8748 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8750 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8751 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8754 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8755 .f = cmd_vf_rx_vlan_filter_parsed,
8757 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8758 "(vf_mask = hexadecimal VF mask)",
8760 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8761 (void *)&cmd_vf_rx_vlan_filter_what,
8762 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8763 (void *)&cmd_vf_rx_vlan_filter_port,
8764 (void *)&cmd_vf_rx_vlan_filter_portid,
8765 (void *)&cmd_vf_rx_vlan_filter_vf,
8766 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8771 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8772 struct cmd_queue_rate_limit_result {
8773 cmdline_fixed_string_t set;
8774 cmdline_fixed_string_t port;
8776 cmdline_fixed_string_t queue;
8778 cmdline_fixed_string_t rate;
8782 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8783 __attribute__((unused)) struct cmdline *cl,
8784 __attribute__((unused)) void *data)
8786 struct cmd_queue_rate_limit_result *res = parsed_result;
8789 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8790 && (strcmp(res->queue, "queue") == 0)
8791 && (strcmp(res->rate, "rate") == 0))
8792 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8795 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8799 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8800 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8802 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8803 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8805 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8806 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8808 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8809 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8811 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8812 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8814 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8815 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8817 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8818 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8821 cmdline_parse_inst_t cmd_queue_rate_limit = {
8822 .f = cmd_queue_rate_limit_parsed,
8824 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8825 "Set rate limit for a queue on port_id",
8827 (void *)&cmd_queue_rate_limit_set,
8828 (void *)&cmd_queue_rate_limit_port,
8829 (void *)&cmd_queue_rate_limit_portnum,
8830 (void *)&cmd_queue_rate_limit_queue,
8831 (void *)&cmd_queue_rate_limit_queuenum,
8832 (void *)&cmd_queue_rate_limit_rate,
8833 (void *)&cmd_queue_rate_limit_ratenum,
8838 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8839 struct cmd_vf_rate_limit_result {
8840 cmdline_fixed_string_t set;
8841 cmdline_fixed_string_t port;
8843 cmdline_fixed_string_t vf;
8845 cmdline_fixed_string_t rate;
8847 cmdline_fixed_string_t q_msk;
8851 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8852 __attribute__((unused)) struct cmdline *cl,
8853 __attribute__((unused)) void *data)
8855 struct cmd_vf_rate_limit_result *res = parsed_result;
8858 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8859 && (strcmp(res->vf, "vf") == 0)
8860 && (strcmp(res->rate, "rate") == 0)
8861 && (strcmp(res->q_msk, "queue_mask") == 0))
8862 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8863 res->rate_num, res->q_msk_val);
8865 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8869 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8870 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8872 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8873 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8875 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8876 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8878 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8879 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8881 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8882 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8884 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8885 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8887 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8888 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8890 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8891 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8892 q_msk, "queue_mask");
8893 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8894 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8897 cmdline_parse_inst_t cmd_vf_rate_limit = {
8898 .f = cmd_vf_rate_limit_parsed,
8900 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8901 "queue_mask <queue_mask_value>: "
8902 "Set rate limit for queues of VF on port_id",
8904 (void *)&cmd_vf_rate_limit_set,
8905 (void *)&cmd_vf_rate_limit_port,
8906 (void *)&cmd_vf_rate_limit_portnum,
8907 (void *)&cmd_vf_rate_limit_vf,
8908 (void *)&cmd_vf_rate_limit_vfnum,
8909 (void *)&cmd_vf_rate_limit_rate,
8910 (void *)&cmd_vf_rate_limit_ratenum,
8911 (void *)&cmd_vf_rate_limit_q_msk,
8912 (void *)&cmd_vf_rate_limit_q_msk_val,
8917 /* *** ADD TUNNEL FILTER OF A PORT *** */
8918 struct cmd_tunnel_filter_result {
8919 cmdline_fixed_string_t cmd;
8920 cmdline_fixed_string_t what;
8922 struct rte_ether_addr outer_mac;
8923 struct rte_ether_addr inner_mac;
8924 cmdline_ipaddr_t ip_value;
8925 uint16_t inner_vlan;
8926 cmdline_fixed_string_t tunnel_type;
8927 cmdline_fixed_string_t filter_type;
8933 cmd_tunnel_filter_parsed(void *parsed_result,
8934 __attribute__((unused)) struct cmdline *cl,
8935 __attribute__((unused)) void *data)
8937 struct cmd_tunnel_filter_result *res = parsed_result;
8938 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8941 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8943 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8944 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8945 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8947 if (res->ip_value.family == AF_INET) {
8948 tunnel_filter_conf.ip_addr.ipv4_addr =
8949 res->ip_value.addr.ipv4.s_addr;
8950 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8952 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8953 &(res->ip_value.addr.ipv6),
8954 sizeof(struct in6_addr));
8955 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8958 if (!strcmp(res->filter_type, "imac-ivlan"))
8959 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8960 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8961 tunnel_filter_conf.filter_type =
8962 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8963 else if (!strcmp(res->filter_type, "imac-tenid"))
8964 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8965 else if (!strcmp(res->filter_type, "imac"))
8966 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8967 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8968 tunnel_filter_conf.filter_type =
8969 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8970 else if (!strcmp(res->filter_type, "oip"))
8971 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8972 else if (!strcmp(res->filter_type, "iip"))
8973 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8975 printf("The filter type is not supported");
8979 if (!strcmp(res->tunnel_type, "vxlan"))
8980 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8981 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8982 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8983 else if (!strcmp(res->tunnel_type, "nvgre"))
8984 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8985 else if (!strcmp(res->tunnel_type, "ipingre"))
8986 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8988 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8992 tunnel_filter_conf.tenant_id = res->tenant_id;
8993 tunnel_filter_conf.queue_id = res->queue_num;
8994 if (!strcmp(res->what, "add"))
8995 ret = rte_eth_dev_filter_ctrl(res->port_id,
8996 RTE_ETH_FILTER_TUNNEL,
8998 &tunnel_filter_conf);
9000 ret = rte_eth_dev_filter_ctrl(res->port_id,
9001 RTE_ETH_FILTER_TUNNEL,
9002 RTE_ETH_FILTER_DELETE,
9003 &tunnel_filter_conf);
9005 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9009 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9010 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9011 cmd, "tunnel_filter");
9012 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9013 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9015 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9016 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9018 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9019 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9021 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9022 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9024 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9025 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9026 inner_vlan, UINT16);
9027 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9028 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9030 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9031 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9032 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9034 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9036 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9037 "imac#omac-imac-tenid");
9038 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9039 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9041 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9042 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9045 cmdline_parse_inst_t cmd_tunnel_filter = {
9046 .f = cmd_tunnel_filter_parsed,
9048 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9049 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9050 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9051 "<queue_id>: Add/Rm tunnel filter of a port",
9053 (void *)&cmd_tunnel_filter_cmd,
9054 (void *)&cmd_tunnel_filter_what,
9055 (void *)&cmd_tunnel_filter_port_id,
9056 (void *)&cmd_tunnel_filter_outer_mac,
9057 (void *)&cmd_tunnel_filter_inner_mac,
9058 (void *)&cmd_tunnel_filter_ip_value,
9059 (void *)&cmd_tunnel_filter_innner_vlan,
9060 (void *)&cmd_tunnel_filter_tunnel_type,
9061 (void *)&cmd_tunnel_filter_filter_type,
9062 (void *)&cmd_tunnel_filter_tenant_id,
9063 (void *)&cmd_tunnel_filter_queue_num,
9068 /* *** CONFIGURE TUNNEL UDP PORT *** */
9069 struct cmd_tunnel_udp_config {
9070 cmdline_fixed_string_t cmd;
9071 cmdline_fixed_string_t what;
9077 cmd_tunnel_udp_config_parsed(void *parsed_result,
9078 __attribute__((unused)) struct cmdline *cl,
9079 __attribute__((unused)) void *data)
9081 struct cmd_tunnel_udp_config *res = parsed_result;
9082 struct rte_eth_udp_tunnel tunnel_udp;
9085 tunnel_udp.udp_port = res->udp_port;
9087 if (!strcmp(res->cmd, "rx_vxlan_port"))
9088 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9090 if (!strcmp(res->what, "add"))
9091 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9094 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9098 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9101 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9102 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9103 cmd, "rx_vxlan_port");
9104 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9105 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9107 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9108 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9110 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9111 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9114 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9115 .f = cmd_tunnel_udp_config_parsed,
9117 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9118 "Add/Remove a tunneling UDP port filter",
9120 (void *)&cmd_tunnel_udp_config_cmd,
9121 (void *)&cmd_tunnel_udp_config_what,
9122 (void *)&cmd_tunnel_udp_config_udp_port,
9123 (void *)&cmd_tunnel_udp_config_port_id,
9128 struct cmd_config_tunnel_udp_port {
9129 cmdline_fixed_string_t port;
9130 cmdline_fixed_string_t config;
9132 cmdline_fixed_string_t udp_tunnel_port;
9133 cmdline_fixed_string_t action;
9134 cmdline_fixed_string_t tunnel_type;
9139 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9140 __attribute__((unused)) struct cmdline *cl,
9141 __attribute__((unused)) void *data)
9143 struct cmd_config_tunnel_udp_port *res = parsed_result;
9144 struct rte_eth_udp_tunnel tunnel_udp;
9147 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9150 tunnel_udp.udp_port = res->udp_port;
9152 if (!strcmp(res->tunnel_type, "vxlan")) {
9153 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9154 } else if (!strcmp(res->tunnel_type, "geneve")) {
9155 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9156 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9157 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9159 printf("Invalid tunnel type\n");
9163 if (!strcmp(res->action, "add"))
9164 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9167 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9171 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9174 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9175 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9177 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9178 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9180 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9181 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9183 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9184 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9187 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9188 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9190 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9191 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9192 "vxlan#geneve#vxlan-gpe");
9193 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9194 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9197 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9198 .f = cmd_cfg_tunnel_udp_port_parsed,
9200 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9202 (void *)&cmd_config_tunnel_udp_port_port,
9203 (void *)&cmd_config_tunnel_udp_port_config,
9204 (void *)&cmd_config_tunnel_udp_port_port_id,
9205 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9206 (void *)&cmd_config_tunnel_udp_port_action,
9207 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9208 (void *)&cmd_config_tunnel_udp_port_value,
9213 /* *** GLOBAL CONFIG *** */
9214 struct cmd_global_config_result {
9215 cmdline_fixed_string_t cmd;
9217 cmdline_fixed_string_t cfg_type;
9222 cmd_global_config_parsed(void *parsed_result,
9223 __attribute__((unused)) struct cmdline *cl,
9224 __attribute__((unused)) void *data)
9226 struct cmd_global_config_result *res = parsed_result;
9227 struct rte_eth_global_cfg conf;
9230 memset(&conf, 0, sizeof(conf));
9231 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9232 conf.cfg.gre_key_len = res->len;
9233 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9234 RTE_ETH_FILTER_SET, &conf);
9236 printf("Global config error\n");
9239 cmdline_parse_token_string_t cmd_global_config_cmd =
9240 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9242 cmdline_parse_token_num_t cmd_global_config_port_id =
9243 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9245 cmdline_parse_token_string_t cmd_global_config_type =
9246 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9247 cfg_type, "gre-key-len");
9248 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9249 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9252 cmdline_parse_inst_t cmd_global_config = {
9253 .f = cmd_global_config_parsed,
9254 .data = (void *)NULL,
9255 .help_str = "global_config <port_id> gre-key-len <key_len>",
9257 (void *)&cmd_global_config_cmd,
9258 (void *)&cmd_global_config_port_id,
9259 (void *)&cmd_global_config_type,
9260 (void *)&cmd_global_config_gre_key_len,
9265 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9266 struct cmd_set_mirror_mask_result {
9267 cmdline_fixed_string_t set;
9268 cmdline_fixed_string_t port;
9270 cmdline_fixed_string_t mirror;
9272 cmdline_fixed_string_t what;
9273 cmdline_fixed_string_t value;
9274 cmdline_fixed_string_t dstpool;
9276 cmdline_fixed_string_t on;
9279 cmdline_parse_token_string_t cmd_mirror_mask_set =
9280 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9282 cmdline_parse_token_string_t cmd_mirror_mask_port =
9283 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9285 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9286 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9288 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9289 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9290 mirror, "mirror-rule");
9291 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9292 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9294 cmdline_parse_token_string_t cmd_mirror_mask_what =
9295 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9296 what, "pool-mirror-up#pool-mirror-down"
9298 cmdline_parse_token_string_t cmd_mirror_mask_value =
9299 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9301 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9302 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9303 dstpool, "dst-pool");
9304 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9305 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9307 cmdline_parse_token_string_t cmd_mirror_mask_on =
9308 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9312 cmd_set_mirror_mask_parsed(void *parsed_result,
9313 __attribute__((unused)) struct cmdline *cl,
9314 __attribute__((unused)) void *data)
9317 struct cmd_set_mirror_mask_result *res = parsed_result;
9318 struct rte_eth_mirror_conf mr_conf;
9320 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9322 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9324 mr_conf.dst_pool = res->dstpool_id;
9326 if (!strcmp(res->what, "pool-mirror-up")) {
9327 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9328 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9329 } else if (!strcmp(res->what, "pool-mirror-down")) {
9330 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9331 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9332 } else if (!strcmp(res->what, "vlan-mirror")) {
9333 mr_conf.rule_type = ETH_MIRROR_VLAN;
9334 nb_item = parse_item_list(res->value, "vlan",
9335 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9339 for (i = 0; i < nb_item; i++) {
9340 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9341 printf("Invalid vlan_id: must be < 4096\n");
9345 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9346 mr_conf.vlan.vlan_mask |= 1ULL << i;
9350 if (!strcmp(res->on, "on"))
9351 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9354 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9357 printf("mirror rule add error: (%s)\n", strerror(-ret));
9360 cmdline_parse_inst_t cmd_set_mirror_mask = {
9361 .f = cmd_set_mirror_mask_parsed,
9363 .help_str = "set port <port_id> mirror-rule <rule_id> "
9364 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9365 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9367 (void *)&cmd_mirror_mask_set,
9368 (void *)&cmd_mirror_mask_port,
9369 (void *)&cmd_mirror_mask_portid,
9370 (void *)&cmd_mirror_mask_mirror,
9371 (void *)&cmd_mirror_mask_ruleid,
9372 (void *)&cmd_mirror_mask_what,
9373 (void *)&cmd_mirror_mask_value,
9374 (void *)&cmd_mirror_mask_dstpool,
9375 (void *)&cmd_mirror_mask_poolid,
9376 (void *)&cmd_mirror_mask_on,
9381 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9382 struct cmd_set_mirror_link_result {
9383 cmdline_fixed_string_t set;
9384 cmdline_fixed_string_t port;
9386 cmdline_fixed_string_t mirror;
9388 cmdline_fixed_string_t what;
9389 cmdline_fixed_string_t dstpool;
9391 cmdline_fixed_string_t on;
9394 cmdline_parse_token_string_t cmd_mirror_link_set =
9395 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9397 cmdline_parse_token_string_t cmd_mirror_link_port =
9398 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9400 cmdline_parse_token_num_t cmd_mirror_link_portid =
9401 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9403 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9404 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9405 mirror, "mirror-rule");
9406 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9407 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9409 cmdline_parse_token_string_t cmd_mirror_link_what =
9410 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9411 what, "uplink-mirror#downlink-mirror");
9412 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9413 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9414 dstpool, "dst-pool");
9415 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9416 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9418 cmdline_parse_token_string_t cmd_mirror_link_on =
9419 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9423 cmd_set_mirror_link_parsed(void *parsed_result,
9424 __attribute__((unused)) struct cmdline *cl,
9425 __attribute__((unused)) void *data)
9428 struct cmd_set_mirror_link_result *res = parsed_result;
9429 struct rte_eth_mirror_conf mr_conf;
9431 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9432 if (!strcmp(res->what, "uplink-mirror"))
9433 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9435 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9437 mr_conf.dst_pool = res->dstpool_id;
9439 if (!strcmp(res->on, "on"))
9440 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9443 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9446 /* check the return value and print it if is < 0 */
9448 printf("mirror rule add error: (%s)\n", strerror(-ret));
9452 cmdline_parse_inst_t cmd_set_mirror_link = {
9453 .f = cmd_set_mirror_link_parsed,
9455 .help_str = "set port <port_id> mirror-rule <rule_id> "
9456 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9458 (void *)&cmd_mirror_link_set,
9459 (void *)&cmd_mirror_link_port,
9460 (void *)&cmd_mirror_link_portid,
9461 (void *)&cmd_mirror_link_mirror,
9462 (void *)&cmd_mirror_link_ruleid,
9463 (void *)&cmd_mirror_link_what,
9464 (void *)&cmd_mirror_link_dstpool,
9465 (void *)&cmd_mirror_link_poolid,
9466 (void *)&cmd_mirror_link_on,
9471 /* *** RESET VM MIRROR RULE *** */
9472 struct cmd_rm_mirror_rule_result {
9473 cmdline_fixed_string_t reset;
9474 cmdline_fixed_string_t port;
9476 cmdline_fixed_string_t mirror;
9480 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9481 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9483 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9484 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9486 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9487 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9489 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9490 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9491 mirror, "mirror-rule");
9492 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9493 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9497 cmd_reset_mirror_rule_parsed(void *parsed_result,
9498 __attribute__((unused)) struct cmdline *cl,
9499 __attribute__((unused)) void *data)
9502 struct cmd_set_mirror_link_result *res = parsed_result;
9504 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9506 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9509 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9510 .f = cmd_reset_mirror_rule_parsed,
9512 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9514 (void *)&cmd_rm_mirror_rule_reset,
9515 (void *)&cmd_rm_mirror_rule_port,
9516 (void *)&cmd_rm_mirror_rule_portid,
9517 (void *)&cmd_rm_mirror_rule_mirror,
9518 (void *)&cmd_rm_mirror_rule_ruleid,
9523 /* ******************************************************************************** */
9525 struct cmd_dump_result {
9526 cmdline_fixed_string_t dump;
9530 dump_struct_sizes(void)
9532 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9533 DUMP_SIZE(struct rte_mbuf);
9534 DUMP_SIZE(struct rte_mempool);
9535 DUMP_SIZE(struct rte_ring);
9539 static void cmd_dump_parsed(void *parsed_result,
9540 __attribute__((unused)) struct cmdline *cl,
9541 __attribute__((unused)) void *data)
9543 struct cmd_dump_result *res = parsed_result;
9545 if (!strcmp(res->dump, "dump_physmem"))
9546 rte_dump_physmem_layout(stdout);
9547 else if (!strcmp(res->dump, "dump_memzone"))
9548 rte_memzone_dump(stdout);
9549 else if (!strcmp(res->dump, "dump_struct_sizes"))
9550 dump_struct_sizes();
9551 else if (!strcmp(res->dump, "dump_ring"))
9552 rte_ring_list_dump(stdout);
9553 else if (!strcmp(res->dump, "dump_mempool"))
9554 rte_mempool_list_dump(stdout);
9555 else if (!strcmp(res->dump, "dump_devargs"))
9556 rte_devargs_dump(stdout);
9557 else if (!strcmp(res->dump, "dump_log_types"))
9558 rte_log_dump(stdout);
9561 cmdline_parse_token_string_t cmd_dump_dump =
9562 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9565 "dump_struct_sizes#"
9571 cmdline_parse_inst_t cmd_dump = {
9572 .f = cmd_dump_parsed, /* function to call */
9573 .data = NULL, /* 2nd arg of func */
9574 .help_str = "Dump status",
9575 .tokens = { /* token list, NULL terminated */
9576 (void *)&cmd_dump_dump,
9581 /* ******************************************************************************** */
9583 struct cmd_dump_one_result {
9584 cmdline_fixed_string_t dump;
9585 cmdline_fixed_string_t name;
9588 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9589 __attribute__((unused)) void *data)
9591 struct cmd_dump_one_result *res = parsed_result;
9593 if (!strcmp(res->dump, "dump_ring")) {
9595 r = rte_ring_lookup(res->name);
9597 cmdline_printf(cl, "Cannot find ring\n");
9600 rte_ring_dump(stdout, r);
9601 } else if (!strcmp(res->dump, "dump_mempool")) {
9602 struct rte_mempool *mp;
9603 mp = rte_mempool_lookup(res->name);
9605 cmdline_printf(cl, "Cannot find mempool\n");
9608 rte_mempool_dump(stdout, mp);
9612 cmdline_parse_token_string_t cmd_dump_one_dump =
9613 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9614 "dump_ring#dump_mempool");
9616 cmdline_parse_token_string_t cmd_dump_one_name =
9617 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9619 cmdline_parse_inst_t cmd_dump_one = {
9620 .f = cmd_dump_one_parsed, /* function to call */
9621 .data = NULL, /* 2nd arg of func */
9622 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9623 .tokens = { /* token list, NULL terminated */
9624 (void *)&cmd_dump_one_dump,
9625 (void *)&cmd_dump_one_name,
9630 /* *** Add/Del syn filter *** */
9631 struct cmd_syn_filter_result {
9632 cmdline_fixed_string_t filter;
9634 cmdline_fixed_string_t ops;
9635 cmdline_fixed_string_t priority;
9636 cmdline_fixed_string_t high;
9637 cmdline_fixed_string_t queue;
9642 cmd_syn_filter_parsed(void *parsed_result,
9643 __attribute__((unused)) struct cmdline *cl,
9644 __attribute__((unused)) void *data)
9646 struct cmd_syn_filter_result *res = parsed_result;
9647 struct rte_eth_syn_filter syn_filter;
9650 ret = rte_eth_dev_filter_supported(res->port_id,
9651 RTE_ETH_FILTER_SYN);
9653 printf("syn filter is not supported on port %u.\n",
9658 memset(&syn_filter, 0, sizeof(syn_filter));
9660 if (!strcmp(res->ops, "add")) {
9661 if (!strcmp(res->high, "high"))
9662 syn_filter.hig_pri = 1;
9664 syn_filter.hig_pri = 0;
9666 syn_filter.queue = res->queue_id;
9667 ret = rte_eth_dev_filter_ctrl(res->port_id,
9672 ret = rte_eth_dev_filter_ctrl(res->port_id,
9674 RTE_ETH_FILTER_DELETE,
9678 printf("syn filter programming error: (%s)\n",
9682 cmdline_parse_token_string_t cmd_syn_filter_filter =
9683 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9684 filter, "syn_filter");
9685 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9686 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9688 cmdline_parse_token_string_t cmd_syn_filter_ops =
9689 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9691 cmdline_parse_token_string_t cmd_syn_filter_priority =
9692 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9693 priority, "priority");
9694 cmdline_parse_token_string_t cmd_syn_filter_high =
9695 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9697 cmdline_parse_token_string_t cmd_syn_filter_queue =
9698 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9700 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9701 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9704 cmdline_parse_inst_t cmd_syn_filter = {
9705 .f = cmd_syn_filter_parsed,
9707 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9708 "<queue_id>: Add/Delete syn filter",
9710 (void *)&cmd_syn_filter_filter,
9711 (void *)&cmd_syn_filter_port_id,
9712 (void *)&cmd_syn_filter_ops,
9713 (void *)&cmd_syn_filter_priority,
9714 (void *)&cmd_syn_filter_high,
9715 (void *)&cmd_syn_filter_queue,
9716 (void *)&cmd_syn_filter_queue_id,
9721 /* *** queue region set *** */
9722 struct cmd_queue_region_result {
9723 cmdline_fixed_string_t set;
9724 cmdline_fixed_string_t port;
9726 cmdline_fixed_string_t cmd;
9727 cmdline_fixed_string_t region;
9729 cmdline_fixed_string_t queue_start_index;
9731 cmdline_fixed_string_t queue_num;
9732 uint8_t queue_num_value;
9736 cmd_queue_region_parsed(void *parsed_result,
9737 __attribute__((unused)) struct cmdline *cl,
9738 __attribute__((unused)) void *data)
9740 struct cmd_queue_region_result *res = parsed_result;
9742 #ifdef RTE_LIBRTE_I40E_PMD
9743 struct rte_pmd_i40e_queue_region_conf region_conf;
9744 enum rte_pmd_i40e_queue_region_op op_type;
9747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9750 #ifdef RTE_LIBRTE_I40E_PMD
9751 memset(®ion_conf, 0, sizeof(region_conf));
9752 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9753 region_conf.region_id = res->region_id;
9754 region_conf.queue_num = res->queue_num_value;
9755 region_conf.queue_start_index = res->queue_id;
9757 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9758 op_type, ®ion_conf);
9765 printf("function not implemented or supported\n");
9768 printf("queue region config error: (%s)\n", strerror(-ret));
9772 cmdline_parse_token_string_t cmd_queue_region_set =
9773 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9775 cmdline_parse_token_string_t cmd_queue_region_port =
9776 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9777 cmdline_parse_token_num_t cmd_queue_region_port_id =
9778 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9780 cmdline_parse_token_string_t cmd_queue_region_cmd =
9781 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9782 cmd, "queue-region");
9783 cmdline_parse_token_string_t cmd_queue_region_id =
9784 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9785 region, "region_id");
9786 cmdline_parse_token_num_t cmd_queue_region_index =
9787 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9789 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9790 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9791 queue_start_index, "queue_start_index");
9792 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9793 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9795 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9796 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9797 queue_num, "queue_num");
9798 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9799 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9800 queue_num_value, UINT8);
9802 cmdline_parse_inst_t cmd_queue_region = {
9803 .f = cmd_queue_region_parsed,
9805 .help_str = "set port <port_id> queue-region region_id <value> "
9806 "queue_start_index <value> queue_num <value>: Set a queue region",
9808 (void *)&cmd_queue_region_set,
9809 (void *)&cmd_queue_region_port,
9810 (void *)&cmd_queue_region_port_id,
9811 (void *)&cmd_queue_region_cmd,
9812 (void *)&cmd_queue_region_id,
9813 (void *)&cmd_queue_region_index,
9814 (void *)&cmd_queue_region_queue_start_index,
9815 (void *)&cmd_queue_region_queue_id,
9816 (void *)&cmd_queue_region_queue_num,
9817 (void *)&cmd_queue_region_queue_num_value,
9822 /* *** queue region and flowtype set *** */
9823 struct cmd_region_flowtype_result {
9824 cmdline_fixed_string_t set;
9825 cmdline_fixed_string_t port;
9827 cmdline_fixed_string_t cmd;
9828 cmdline_fixed_string_t region;
9830 cmdline_fixed_string_t flowtype;
9831 uint8_t flowtype_id;
9835 cmd_region_flowtype_parsed(void *parsed_result,
9836 __attribute__((unused)) struct cmdline *cl,
9837 __attribute__((unused)) void *data)
9839 struct cmd_region_flowtype_result *res = parsed_result;
9841 #ifdef RTE_LIBRTE_I40E_PMD
9842 struct rte_pmd_i40e_queue_region_conf region_conf;
9843 enum rte_pmd_i40e_queue_region_op op_type;
9846 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9849 #ifdef RTE_LIBRTE_I40E_PMD
9850 memset(®ion_conf, 0, sizeof(region_conf));
9852 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9853 region_conf.region_id = res->region_id;
9854 region_conf.hw_flowtype = res->flowtype_id;
9856 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9857 op_type, ®ion_conf);
9864 printf("function not implemented or supported\n");
9867 printf("region flowtype config error: (%s)\n", strerror(-ret));
9871 cmdline_parse_token_string_t cmd_region_flowtype_set =
9872 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9874 cmdline_parse_token_string_t cmd_region_flowtype_port =
9875 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9877 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9878 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9880 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9881 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9882 cmd, "queue-region");
9883 cmdline_parse_token_string_t cmd_region_flowtype_index =
9884 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9885 region, "region_id");
9886 cmdline_parse_token_num_t cmd_region_flowtype_id =
9887 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9889 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9890 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9891 flowtype, "flowtype");
9892 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9893 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9894 flowtype_id, UINT8);
9895 cmdline_parse_inst_t cmd_region_flowtype = {
9896 .f = cmd_region_flowtype_parsed,
9898 .help_str = "set port <port_id> queue-region region_id <value> "
9899 "flowtype <value>: Set a flowtype region index",
9901 (void *)&cmd_region_flowtype_set,
9902 (void *)&cmd_region_flowtype_port,
9903 (void *)&cmd_region_flowtype_port_index,
9904 (void *)&cmd_region_flowtype_cmd,
9905 (void *)&cmd_region_flowtype_index,
9906 (void *)&cmd_region_flowtype_id,
9907 (void *)&cmd_region_flowtype_flow_index,
9908 (void *)&cmd_region_flowtype_flow_id,
9913 /* *** User Priority (UP) to queue region (region_id) set *** */
9914 struct cmd_user_priority_region_result {
9915 cmdline_fixed_string_t set;
9916 cmdline_fixed_string_t port;
9918 cmdline_fixed_string_t cmd;
9919 cmdline_fixed_string_t user_priority;
9920 uint8_t user_priority_id;
9921 cmdline_fixed_string_t region;
9926 cmd_user_priority_region_parsed(void *parsed_result,
9927 __attribute__((unused)) struct cmdline *cl,
9928 __attribute__((unused)) void *data)
9930 struct cmd_user_priority_region_result *res = parsed_result;
9932 #ifdef RTE_LIBRTE_I40E_PMD
9933 struct rte_pmd_i40e_queue_region_conf region_conf;
9934 enum rte_pmd_i40e_queue_region_op op_type;
9937 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9940 #ifdef RTE_LIBRTE_I40E_PMD
9941 memset(®ion_conf, 0, sizeof(region_conf));
9942 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9943 region_conf.user_priority = res->user_priority_id;
9944 region_conf.region_id = res->region_id;
9946 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9947 op_type, ®ion_conf);
9954 printf("function not implemented or supported\n");
9957 printf("user_priority region config error: (%s)\n",
9962 cmdline_parse_token_string_t cmd_user_priority_region_set =
9963 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9965 cmdline_parse_token_string_t cmd_user_priority_region_port =
9966 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9968 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9969 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9971 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9972 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9973 cmd, "queue-region");
9974 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9975 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9976 user_priority, "UP");
9977 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9978 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9979 user_priority_id, UINT8);
9980 cmdline_parse_token_string_t cmd_user_priority_region_region =
9981 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9982 region, "region_id");
9983 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9984 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9987 cmdline_parse_inst_t cmd_user_priority_region = {
9988 .f = cmd_user_priority_region_parsed,
9990 .help_str = "set port <port_id> queue-region UP <value> "
9991 "region_id <value>: Set the mapping of User Priority (UP) "
9992 "to queue region (region_id) ",
9994 (void *)&cmd_user_priority_region_set,
9995 (void *)&cmd_user_priority_region_port,
9996 (void *)&cmd_user_priority_region_port_index,
9997 (void *)&cmd_user_priority_region_cmd,
9998 (void *)&cmd_user_priority_region_UP,
9999 (void *)&cmd_user_priority_region_UP_id,
10000 (void *)&cmd_user_priority_region_region,
10001 (void *)&cmd_user_priority_region_region_id,
10006 /* *** flush all queue region related configuration *** */
10007 struct cmd_flush_queue_region_result {
10008 cmdline_fixed_string_t set;
10009 cmdline_fixed_string_t port;
10011 cmdline_fixed_string_t cmd;
10012 cmdline_fixed_string_t flush;
10013 cmdline_fixed_string_t what;
10017 cmd_flush_queue_region_parsed(void *parsed_result,
10018 __attribute__((unused)) struct cmdline *cl,
10019 __attribute__((unused)) void *data)
10021 struct cmd_flush_queue_region_result *res = parsed_result;
10022 int ret = -ENOTSUP;
10023 #ifdef RTE_LIBRTE_I40E_PMD
10024 struct rte_pmd_i40e_queue_region_conf region_conf;
10025 enum rte_pmd_i40e_queue_region_op op_type;
10028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10031 #ifdef RTE_LIBRTE_I40E_PMD
10032 memset(®ion_conf, 0, sizeof(region_conf));
10034 if (strcmp(res->what, "on") == 0)
10035 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10037 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10039 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10040 op_type, ®ion_conf);
10047 printf("function not implemented or supported\n");
10050 printf("queue region config flush error: (%s)\n",
10055 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10056 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10058 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10059 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10061 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10062 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10064 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10065 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10066 cmd, "queue-region");
10067 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10068 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10070 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10071 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10074 cmdline_parse_inst_t cmd_flush_queue_region = {
10075 .f = cmd_flush_queue_region_parsed,
10077 .help_str = "set port <port_id> queue-region flush on|off"
10078 ": flush all queue region related configuration",
10080 (void *)&cmd_flush_queue_region_set,
10081 (void *)&cmd_flush_queue_region_port,
10082 (void *)&cmd_flush_queue_region_port_index,
10083 (void *)&cmd_flush_queue_region_cmd,
10084 (void *)&cmd_flush_queue_region_flush,
10085 (void *)&cmd_flush_queue_region_what,
10090 /* *** get all queue region related configuration info *** */
10091 struct cmd_show_queue_region_info {
10092 cmdline_fixed_string_t show;
10093 cmdline_fixed_string_t port;
10095 cmdline_fixed_string_t cmd;
10099 cmd_show_queue_region_info_parsed(void *parsed_result,
10100 __attribute__((unused)) struct cmdline *cl,
10101 __attribute__((unused)) void *data)
10103 struct cmd_show_queue_region_info *res = parsed_result;
10104 int ret = -ENOTSUP;
10105 #ifdef RTE_LIBRTE_I40E_PMD
10106 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10107 enum rte_pmd_i40e_queue_region_op op_type;
10110 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10113 #ifdef RTE_LIBRTE_I40E_PMD
10114 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10116 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10118 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10119 op_type, &rte_pmd_regions);
10121 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10128 printf("function not implemented or supported\n");
10131 printf("queue region config info show error: (%s)\n",
10136 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10137 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10139 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10140 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10142 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10143 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10145 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10146 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10147 cmd, "queue-region");
10149 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10150 .f = cmd_show_queue_region_info_parsed,
10152 .help_str = "show port <port_id> queue-region"
10153 ": show all queue region related configuration info",
10155 (void *)&cmd_show_queue_region_info_get,
10156 (void *)&cmd_show_queue_region_info_port,
10157 (void *)&cmd_show_queue_region_info_port_index,
10158 (void *)&cmd_show_queue_region_info_cmd,
10163 /* *** ADD/REMOVE A 2tuple FILTER *** */
10164 struct cmd_2tuple_filter_result {
10165 cmdline_fixed_string_t filter;
10167 cmdline_fixed_string_t ops;
10168 cmdline_fixed_string_t dst_port;
10169 uint16_t dst_port_value;
10170 cmdline_fixed_string_t protocol;
10171 uint8_t protocol_value;
10172 cmdline_fixed_string_t mask;
10173 uint8_t mask_value;
10174 cmdline_fixed_string_t tcp_flags;
10175 uint8_t tcp_flags_value;
10176 cmdline_fixed_string_t priority;
10177 uint8_t priority_value;
10178 cmdline_fixed_string_t queue;
10183 cmd_2tuple_filter_parsed(void *parsed_result,
10184 __attribute__((unused)) struct cmdline *cl,
10185 __attribute__((unused)) void *data)
10187 struct rte_eth_ntuple_filter filter;
10188 struct cmd_2tuple_filter_result *res = parsed_result;
10191 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10193 printf("ntuple filter is not supported on port %u.\n",
10198 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10200 filter.flags = RTE_2TUPLE_FLAGS;
10201 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10202 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10203 filter.proto = res->protocol_value;
10204 filter.priority = res->priority_value;
10205 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10206 printf("nonzero tcp_flags is only meaningful"
10207 " when protocol is TCP.\n");
10210 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10211 printf("invalid TCP flags.\n");
10215 if (res->tcp_flags_value != 0) {
10216 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10217 filter.tcp_flags = res->tcp_flags_value;
10220 /* need convert to big endian. */
10221 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10222 filter.queue = res->queue_id;
10224 if (!strcmp(res->ops, "add"))
10225 ret = rte_eth_dev_filter_ctrl(res->port_id,
10226 RTE_ETH_FILTER_NTUPLE,
10227 RTE_ETH_FILTER_ADD,
10230 ret = rte_eth_dev_filter_ctrl(res->port_id,
10231 RTE_ETH_FILTER_NTUPLE,
10232 RTE_ETH_FILTER_DELETE,
10235 printf("2tuple filter programming error: (%s)\n",
10240 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10241 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10242 filter, "2tuple_filter");
10243 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10244 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10246 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10247 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10249 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10250 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10251 dst_port, "dst_port");
10252 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10253 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10254 dst_port_value, UINT16);
10255 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10256 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10257 protocol, "protocol");
10258 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10259 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10260 protocol_value, UINT8);
10261 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10262 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10264 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10265 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10267 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10268 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10269 tcp_flags, "tcp_flags");
10270 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10271 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10272 tcp_flags_value, UINT8);
10273 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10274 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10275 priority, "priority");
10276 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10277 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10278 priority_value, UINT8);
10279 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10280 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10282 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10283 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10286 cmdline_parse_inst_t cmd_2tuple_filter = {
10287 .f = cmd_2tuple_filter_parsed,
10289 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10290 "<value> mask <value> tcp_flags <value> priority <value> queue "
10291 "<queue_id>: Add a 2tuple filter",
10293 (void *)&cmd_2tuple_filter_filter,
10294 (void *)&cmd_2tuple_filter_port_id,
10295 (void *)&cmd_2tuple_filter_ops,
10296 (void *)&cmd_2tuple_filter_dst_port,
10297 (void *)&cmd_2tuple_filter_dst_port_value,
10298 (void *)&cmd_2tuple_filter_protocol,
10299 (void *)&cmd_2tuple_filter_protocol_value,
10300 (void *)&cmd_2tuple_filter_mask,
10301 (void *)&cmd_2tuple_filter_mask_value,
10302 (void *)&cmd_2tuple_filter_tcp_flags,
10303 (void *)&cmd_2tuple_filter_tcp_flags_value,
10304 (void *)&cmd_2tuple_filter_priority,
10305 (void *)&cmd_2tuple_filter_priority_value,
10306 (void *)&cmd_2tuple_filter_queue,
10307 (void *)&cmd_2tuple_filter_queue_id,
10312 /* *** ADD/REMOVE A 5tuple FILTER *** */
10313 struct cmd_5tuple_filter_result {
10314 cmdline_fixed_string_t filter;
10316 cmdline_fixed_string_t ops;
10317 cmdline_fixed_string_t dst_ip;
10318 cmdline_ipaddr_t dst_ip_value;
10319 cmdline_fixed_string_t src_ip;
10320 cmdline_ipaddr_t src_ip_value;
10321 cmdline_fixed_string_t dst_port;
10322 uint16_t dst_port_value;
10323 cmdline_fixed_string_t src_port;
10324 uint16_t src_port_value;
10325 cmdline_fixed_string_t protocol;
10326 uint8_t protocol_value;
10327 cmdline_fixed_string_t mask;
10328 uint8_t mask_value;
10329 cmdline_fixed_string_t tcp_flags;
10330 uint8_t tcp_flags_value;
10331 cmdline_fixed_string_t priority;
10332 uint8_t priority_value;
10333 cmdline_fixed_string_t queue;
10338 cmd_5tuple_filter_parsed(void *parsed_result,
10339 __attribute__((unused)) struct cmdline *cl,
10340 __attribute__((unused)) void *data)
10342 struct rte_eth_ntuple_filter filter;
10343 struct cmd_5tuple_filter_result *res = parsed_result;
10346 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10348 printf("ntuple filter is not supported on port %u.\n",
10353 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10355 filter.flags = RTE_5TUPLE_FLAGS;
10356 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10357 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10358 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10359 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10360 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10361 filter.proto = res->protocol_value;
10362 filter.priority = res->priority_value;
10363 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10364 printf("nonzero tcp_flags is only meaningful"
10365 " when protocol is TCP.\n");
10368 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10369 printf("invalid TCP flags.\n");
10373 if (res->tcp_flags_value != 0) {
10374 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10375 filter.tcp_flags = res->tcp_flags_value;
10378 if (res->dst_ip_value.family == AF_INET)
10379 /* no need to convert, already big endian. */
10380 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10382 if (filter.dst_ip_mask == 0) {
10383 printf("can not support ipv6 involved compare.\n");
10389 if (res->src_ip_value.family == AF_INET)
10390 /* no need to convert, already big endian. */
10391 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10393 if (filter.src_ip_mask == 0) {
10394 printf("can not support ipv6 involved compare.\n");
10399 /* need convert to big endian. */
10400 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10401 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10402 filter.queue = res->queue_id;
10404 if (!strcmp(res->ops, "add"))
10405 ret = rte_eth_dev_filter_ctrl(res->port_id,
10406 RTE_ETH_FILTER_NTUPLE,
10407 RTE_ETH_FILTER_ADD,
10410 ret = rte_eth_dev_filter_ctrl(res->port_id,
10411 RTE_ETH_FILTER_NTUPLE,
10412 RTE_ETH_FILTER_DELETE,
10415 printf("5tuple filter programming error: (%s)\n",
10419 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10420 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10421 filter, "5tuple_filter");
10422 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10423 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10425 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10426 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10428 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10429 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10431 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10432 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10434 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10435 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10437 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10438 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10440 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10441 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10442 dst_port, "dst_port");
10443 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10444 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10445 dst_port_value, UINT16);
10446 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10447 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10448 src_port, "src_port");
10449 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10450 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10451 src_port_value, UINT16);
10452 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10453 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10454 protocol, "protocol");
10455 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10456 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10457 protocol_value, UINT8);
10458 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10459 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10461 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10462 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10464 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10465 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10466 tcp_flags, "tcp_flags");
10467 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10468 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10469 tcp_flags_value, UINT8);
10470 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10471 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10472 priority, "priority");
10473 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10474 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10475 priority_value, UINT8);
10476 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10477 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10479 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10480 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10483 cmdline_parse_inst_t cmd_5tuple_filter = {
10484 .f = cmd_5tuple_filter_parsed,
10486 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10487 "src_ip <value> dst_port <value> src_port <value> "
10488 "protocol <value> mask <value> tcp_flags <value> "
10489 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10491 (void *)&cmd_5tuple_filter_filter,
10492 (void *)&cmd_5tuple_filter_port_id,
10493 (void *)&cmd_5tuple_filter_ops,
10494 (void *)&cmd_5tuple_filter_dst_ip,
10495 (void *)&cmd_5tuple_filter_dst_ip_value,
10496 (void *)&cmd_5tuple_filter_src_ip,
10497 (void *)&cmd_5tuple_filter_src_ip_value,
10498 (void *)&cmd_5tuple_filter_dst_port,
10499 (void *)&cmd_5tuple_filter_dst_port_value,
10500 (void *)&cmd_5tuple_filter_src_port,
10501 (void *)&cmd_5tuple_filter_src_port_value,
10502 (void *)&cmd_5tuple_filter_protocol,
10503 (void *)&cmd_5tuple_filter_protocol_value,
10504 (void *)&cmd_5tuple_filter_mask,
10505 (void *)&cmd_5tuple_filter_mask_value,
10506 (void *)&cmd_5tuple_filter_tcp_flags,
10507 (void *)&cmd_5tuple_filter_tcp_flags_value,
10508 (void *)&cmd_5tuple_filter_priority,
10509 (void *)&cmd_5tuple_filter_priority_value,
10510 (void *)&cmd_5tuple_filter_queue,
10511 (void *)&cmd_5tuple_filter_queue_id,
10516 /* *** ADD/REMOVE A flex FILTER *** */
10517 struct cmd_flex_filter_result {
10518 cmdline_fixed_string_t filter;
10519 cmdline_fixed_string_t ops;
10521 cmdline_fixed_string_t len;
10523 cmdline_fixed_string_t bytes;
10524 cmdline_fixed_string_t bytes_value;
10525 cmdline_fixed_string_t mask;
10526 cmdline_fixed_string_t mask_value;
10527 cmdline_fixed_string_t priority;
10528 uint8_t priority_value;
10529 cmdline_fixed_string_t queue;
10533 static int xdigit2val(unsigned char c)
10538 else if (isupper(c))
10539 val = c - 'A' + 10;
10541 val = c - 'a' + 10;
10546 cmd_flex_filter_parsed(void *parsed_result,
10547 __attribute__((unused)) struct cmdline *cl,
10548 __attribute__((unused)) void *data)
10551 struct rte_eth_flex_filter filter;
10552 struct cmd_flex_filter_result *res = parsed_result;
10553 char *bytes_ptr, *mask_ptr;
10554 uint16_t len, i, j = 0;
10559 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10560 printf("the len exceed the max length 128\n");
10563 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10564 filter.len = res->len_value;
10565 filter.priority = res->priority_value;
10566 filter.queue = res->queue_id;
10567 bytes_ptr = res->bytes_value;
10568 mask_ptr = res->mask_value;
10570 /* translate bytes string to array. */
10571 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10572 (bytes_ptr[1] == 'X')))
10574 len = strnlen(bytes_ptr, res->len_value * 2);
10575 if (len == 0 || (len % 8 != 0)) {
10576 printf("please check len and bytes input\n");
10579 for (i = 0; i < len; i++) {
10581 if (isxdigit(c) == 0) {
10582 /* invalid characters. */
10583 printf("invalid input\n");
10586 val = xdigit2val(c);
10589 filter.bytes[j] = byte;
10590 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10597 /* translate mask string to uint8_t array. */
10598 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10599 (mask_ptr[1] == 'X')))
10601 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10603 printf("invalid input\n");
10608 for (i = 0; i < len; i++) {
10610 if (isxdigit(c) == 0) {
10611 /* invalid characters. */
10612 printf("invalid input\n");
10615 val = xdigit2val(c);
10618 filter.mask[j] = byte;
10619 printf("mask[%d]:%02x ", j, filter.mask[j]);
10627 if (!strcmp(res->ops, "add"))
10628 ret = rte_eth_dev_filter_ctrl(res->port_id,
10629 RTE_ETH_FILTER_FLEXIBLE,
10630 RTE_ETH_FILTER_ADD,
10633 ret = rte_eth_dev_filter_ctrl(res->port_id,
10634 RTE_ETH_FILTER_FLEXIBLE,
10635 RTE_ETH_FILTER_DELETE,
10639 printf("flex filter setting error: (%s)\n", strerror(-ret));
10642 cmdline_parse_token_string_t cmd_flex_filter_filter =
10643 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10644 filter, "flex_filter");
10645 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10646 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10648 cmdline_parse_token_string_t cmd_flex_filter_ops =
10649 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10651 cmdline_parse_token_string_t cmd_flex_filter_len =
10652 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10654 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10655 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10657 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10658 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10660 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10661 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10662 bytes_value, NULL);
10663 cmdline_parse_token_string_t cmd_flex_filter_mask =
10664 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10666 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10667 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10669 cmdline_parse_token_string_t cmd_flex_filter_priority =
10670 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10671 priority, "priority");
10672 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10673 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10674 priority_value, UINT8);
10675 cmdline_parse_token_string_t cmd_flex_filter_queue =
10676 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10678 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10679 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10681 cmdline_parse_inst_t cmd_flex_filter = {
10682 .f = cmd_flex_filter_parsed,
10684 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10685 "<value> mask <value> priority <value> queue <queue_id>: "
10686 "Add/Del a flex filter",
10688 (void *)&cmd_flex_filter_filter,
10689 (void *)&cmd_flex_filter_port_id,
10690 (void *)&cmd_flex_filter_ops,
10691 (void *)&cmd_flex_filter_len,
10692 (void *)&cmd_flex_filter_len_value,
10693 (void *)&cmd_flex_filter_bytes,
10694 (void *)&cmd_flex_filter_bytes_value,
10695 (void *)&cmd_flex_filter_mask,
10696 (void *)&cmd_flex_filter_mask_value,
10697 (void *)&cmd_flex_filter_priority,
10698 (void *)&cmd_flex_filter_priority_value,
10699 (void *)&cmd_flex_filter_queue,
10700 (void *)&cmd_flex_filter_queue_id,
10705 /* *** Filters Control *** */
10707 /* *** deal with ethertype filter *** */
10708 struct cmd_ethertype_filter_result {
10709 cmdline_fixed_string_t filter;
10711 cmdline_fixed_string_t ops;
10712 cmdline_fixed_string_t mac;
10713 struct rte_ether_addr mac_addr;
10714 cmdline_fixed_string_t ethertype;
10715 uint16_t ethertype_value;
10716 cmdline_fixed_string_t drop;
10717 cmdline_fixed_string_t queue;
10721 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10722 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10723 filter, "ethertype_filter");
10724 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10725 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10727 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10728 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10730 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10731 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10732 mac, "mac_addr#mac_ignr");
10733 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10734 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10736 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10737 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10738 ethertype, "ethertype");
10739 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10740 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10741 ethertype_value, UINT16);
10742 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10743 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10745 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10746 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10748 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10749 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10753 cmd_ethertype_filter_parsed(void *parsed_result,
10754 __attribute__((unused)) struct cmdline *cl,
10755 __attribute__((unused)) void *data)
10757 struct cmd_ethertype_filter_result *res = parsed_result;
10758 struct rte_eth_ethertype_filter filter;
10761 ret = rte_eth_dev_filter_supported(res->port_id,
10762 RTE_ETH_FILTER_ETHERTYPE);
10764 printf("ethertype filter is not supported on port %u.\n",
10769 memset(&filter, 0, sizeof(filter));
10770 if (!strcmp(res->mac, "mac_addr")) {
10771 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10772 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10773 sizeof(struct rte_ether_addr));
10775 if (!strcmp(res->drop, "drop"))
10776 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10777 filter.ether_type = res->ethertype_value;
10778 filter.queue = res->queue_id;
10780 if (!strcmp(res->ops, "add"))
10781 ret = rte_eth_dev_filter_ctrl(res->port_id,
10782 RTE_ETH_FILTER_ETHERTYPE,
10783 RTE_ETH_FILTER_ADD,
10786 ret = rte_eth_dev_filter_ctrl(res->port_id,
10787 RTE_ETH_FILTER_ETHERTYPE,
10788 RTE_ETH_FILTER_DELETE,
10791 printf("ethertype filter programming error: (%s)\n",
10795 cmdline_parse_inst_t cmd_ethertype_filter = {
10796 .f = cmd_ethertype_filter_parsed,
10798 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10799 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10800 "Add or delete an ethertype filter entry",
10802 (void *)&cmd_ethertype_filter_filter,
10803 (void *)&cmd_ethertype_filter_port_id,
10804 (void *)&cmd_ethertype_filter_ops,
10805 (void *)&cmd_ethertype_filter_mac,
10806 (void *)&cmd_ethertype_filter_mac_addr,
10807 (void *)&cmd_ethertype_filter_ethertype,
10808 (void *)&cmd_ethertype_filter_ethertype_value,
10809 (void *)&cmd_ethertype_filter_drop,
10810 (void *)&cmd_ethertype_filter_queue,
10811 (void *)&cmd_ethertype_filter_queue_id,
10816 /* *** deal with flow director filter *** */
10817 struct cmd_flow_director_result {
10818 cmdline_fixed_string_t flow_director_filter;
10820 cmdline_fixed_string_t mode;
10821 cmdline_fixed_string_t mode_value;
10822 cmdline_fixed_string_t ops;
10823 cmdline_fixed_string_t flow;
10824 cmdline_fixed_string_t flow_type;
10825 cmdline_fixed_string_t ether;
10826 uint16_t ether_type;
10827 cmdline_fixed_string_t src;
10828 cmdline_ipaddr_t ip_src;
10830 cmdline_fixed_string_t dst;
10831 cmdline_ipaddr_t ip_dst;
10833 cmdline_fixed_string_t verify_tag;
10834 uint32_t verify_tag_value;
10835 cmdline_fixed_string_t tos;
10837 cmdline_fixed_string_t proto;
10838 uint8_t proto_value;
10839 cmdline_fixed_string_t ttl;
10841 cmdline_fixed_string_t vlan;
10842 uint16_t vlan_value;
10843 cmdline_fixed_string_t flexbytes;
10844 cmdline_fixed_string_t flexbytes_value;
10845 cmdline_fixed_string_t pf_vf;
10846 cmdline_fixed_string_t drop;
10847 cmdline_fixed_string_t queue;
10849 cmdline_fixed_string_t fd_id;
10850 uint32_t fd_id_value;
10851 cmdline_fixed_string_t mac;
10852 struct rte_ether_addr mac_addr;
10853 cmdline_fixed_string_t tunnel;
10854 cmdline_fixed_string_t tunnel_type;
10855 cmdline_fixed_string_t tunnel_id;
10856 uint32_t tunnel_id_value;
10857 cmdline_fixed_string_t packet;
10862 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10865 const char *p, *p0 = q_arg;
10867 unsigned long int_fld;
10868 char *str_fld[max_num];
10873 p = strchr(p0, '(');
10877 p0 = strchr(p, ')');
10882 if (size >= sizeof(s))
10885 snprintf(s, sizeof(s), "%.*s", size, p);
10886 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10887 if (ret < 0 || ret > max_num)
10889 for (i = 0; i < ret; i++) {
10891 int_fld = strtoul(str_fld[i], &end, 0);
10892 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10894 flexbytes[i] = (uint8_t)int_fld;
10900 str2flowtype(char *string)
10903 static const struct {
10906 } flowtype_str[] = {
10907 {"raw", RTE_ETH_FLOW_RAW},
10908 {"ipv4", RTE_ETH_FLOW_IPV4},
10909 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10910 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10911 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10912 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10913 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10914 {"ipv6", RTE_ETH_FLOW_IPV6},
10915 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10916 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10917 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10918 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10919 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10920 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10923 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10924 if (!strcmp(flowtype_str[i].str, string))
10925 return flowtype_str[i].type;
10928 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10929 return (uint16_t)atoi(string);
10931 return RTE_ETH_FLOW_UNKNOWN;
10934 static enum rte_eth_fdir_tunnel_type
10935 str2fdir_tunneltype(char *string)
10939 static const struct {
10941 enum rte_eth_fdir_tunnel_type type;
10942 } tunneltype_str[] = {
10943 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10944 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10947 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10948 if (!strcmp(tunneltype_str[i].str, string))
10949 return tunneltype_str[i].type;
10951 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10954 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10956 if ((ip_addr).family == AF_INET) \
10957 (ip) = (ip_addr).addr.ipv4.s_addr; \
10959 printf("invalid parameter.\n"); \
10964 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10966 if ((ip_addr).family == AF_INET6) \
10967 rte_memcpy(&(ip), \
10968 &((ip_addr).addr.ipv6), \
10969 sizeof(struct in6_addr)); \
10971 printf("invalid parameter.\n"); \
10977 cmd_flow_director_filter_parsed(void *parsed_result,
10978 __attribute__((unused)) struct cmdline *cl,
10979 __attribute__((unused)) void *data)
10981 struct cmd_flow_director_result *res = parsed_result;
10982 struct rte_eth_fdir_filter entry;
10983 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10985 unsigned long vf_id;
10988 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10990 printf("flow director is not supported on port %u.\n",
10994 memset(flexbytes, 0, sizeof(flexbytes));
10995 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10997 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10998 if (strcmp(res->mode_value, "MAC-VLAN")) {
10999 printf("Please set mode to MAC-VLAN.\n");
11002 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11003 if (strcmp(res->mode_value, "Tunnel")) {
11004 printf("Please set mode to Tunnel.\n");
11008 if (!strcmp(res->mode_value, "raw")) {
11009 #ifdef RTE_LIBRTE_I40E_PMD
11010 struct rte_pmd_i40e_flow_type_mapping
11011 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11012 struct rte_pmd_i40e_pkt_template_conf conf;
11013 uint16_t flow_type = str2flowtype(res->flow_type);
11014 uint16_t i, port = res->port_id;
11017 memset(&conf, 0, sizeof(conf));
11019 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11020 printf("Invalid flow type specified.\n");
11023 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11027 if (mapping[flow_type].pctype == 0ULL) {
11028 printf("Invalid flow type specified.\n");
11031 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11032 if (mapping[flow_type].pctype & (1ULL << i)) {
11033 conf.input.pctype = i;
11038 conf.input.packet = open_file(res->filepath,
11039 &conf.input.length);
11040 if (!conf.input.packet)
11042 if (!strcmp(res->drop, "drop"))
11043 conf.action.behavior =
11044 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11046 conf.action.behavior =
11047 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11048 conf.action.report_status =
11049 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11050 conf.action.rx_queue = res->queue_id;
11051 conf.soft_id = res->fd_id_value;
11052 add = strcmp(res->ops, "del") ? 1 : 0;
11053 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11057 printf("flow director config error: (%s)\n",
11059 close_file(conf.input.packet);
11062 } else if (strcmp(res->mode_value, "IP")) {
11063 printf("Please set mode to IP or raw.\n");
11066 entry.input.flow_type = str2flowtype(res->flow_type);
11069 ret = parse_flexbytes(res->flexbytes_value,
11071 RTE_ETH_FDIR_MAX_FLEXLEN);
11073 printf("error: Cannot parse flexbytes input.\n");
11077 switch (entry.input.flow_type) {
11078 case RTE_ETH_FLOW_FRAG_IPV4:
11079 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11080 entry.input.flow.ip4_flow.proto = res->proto_value;
11082 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11083 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11084 IPV4_ADDR_TO_UINT(res->ip_dst,
11085 entry.input.flow.ip4_flow.dst_ip);
11086 IPV4_ADDR_TO_UINT(res->ip_src,
11087 entry.input.flow.ip4_flow.src_ip);
11088 entry.input.flow.ip4_flow.tos = res->tos_value;
11089 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11090 /* need convert to big endian. */
11091 entry.input.flow.udp4_flow.dst_port =
11092 rte_cpu_to_be_16(res->port_dst);
11093 entry.input.flow.udp4_flow.src_port =
11094 rte_cpu_to_be_16(res->port_src);
11096 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11097 IPV4_ADDR_TO_UINT(res->ip_dst,
11098 entry.input.flow.sctp4_flow.ip.dst_ip);
11099 IPV4_ADDR_TO_UINT(res->ip_src,
11100 entry.input.flow.sctp4_flow.ip.src_ip);
11101 entry.input.flow.ip4_flow.tos = res->tos_value;
11102 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11103 /* need convert to big endian. */
11104 entry.input.flow.sctp4_flow.dst_port =
11105 rte_cpu_to_be_16(res->port_dst);
11106 entry.input.flow.sctp4_flow.src_port =
11107 rte_cpu_to_be_16(res->port_src);
11108 entry.input.flow.sctp4_flow.verify_tag =
11109 rte_cpu_to_be_32(res->verify_tag_value);
11111 case RTE_ETH_FLOW_FRAG_IPV6:
11112 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11113 entry.input.flow.ipv6_flow.proto = res->proto_value;
11115 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11116 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11117 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11118 entry.input.flow.ipv6_flow.dst_ip);
11119 IPV6_ADDR_TO_ARRAY(res->ip_src,
11120 entry.input.flow.ipv6_flow.src_ip);
11121 entry.input.flow.ipv6_flow.tc = res->tos_value;
11122 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11123 /* need convert to big endian. */
11124 entry.input.flow.udp6_flow.dst_port =
11125 rte_cpu_to_be_16(res->port_dst);
11126 entry.input.flow.udp6_flow.src_port =
11127 rte_cpu_to_be_16(res->port_src);
11129 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11130 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11131 entry.input.flow.sctp6_flow.ip.dst_ip);
11132 IPV6_ADDR_TO_ARRAY(res->ip_src,
11133 entry.input.flow.sctp6_flow.ip.src_ip);
11134 entry.input.flow.ipv6_flow.tc = res->tos_value;
11135 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11136 /* need convert to big endian. */
11137 entry.input.flow.sctp6_flow.dst_port =
11138 rte_cpu_to_be_16(res->port_dst);
11139 entry.input.flow.sctp6_flow.src_port =
11140 rte_cpu_to_be_16(res->port_src);
11141 entry.input.flow.sctp6_flow.verify_tag =
11142 rte_cpu_to_be_32(res->verify_tag_value);
11144 case RTE_ETH_FLOW_L2_PAYLOAD:
11145 entry.input.flow.l2_flow.ether_type =
11146 rte_cpu_to_be_16(res->ether_type);
11152 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11153 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11155 sizeof(struct rte_ether_addr));
11157 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11158 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11160 sizeof(struct rte_ether_addr));
11161 entry.input.flow.tunnel_flow.tunnel_type =
11162 str2fdir_tunneltype(res->tunnel_type);
11163 entry.input.flow.tunnel_flow.tunnel_id =
11164 rte_cpu_to_be_32(res->tunnel_id_value);
11167 rte_memcpy(entry.input.flow_ext.flexbytes,
11169 RTE_ETH_FDIR_MAX_FLEXLEN);
11171 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11173 entry.action.flex_off = 0; /*use 0 by default */
11174 if (!strcmp(res->drop, "drop"))
11175 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11177 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11179 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11180 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11181 if (!strcmp(res->pf_vf, "pf"))
11182 entry.input.flow_ext.is_vf = 0;
11183 else if (!strncmp(res->pf_vf, "vf", 2)) {
11184 struct rte_eth_dev_info dev_info;
11186 memset(&dev_info, 0, sizeof(dev_info));
11187 rte_eth_dev_info_get(res->port_id, &dev_info);
11189 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11190 if (errno != 0 || *end != '\0' ||
11191 vf_id >= dev_info.max_vfs) {
11192 printf("invalid parameter %s.\n", res->pf_vf);
11195 entry.input.flow_ext.is_vf = 1;
11196 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11198 printf("invalid parameter %s.\n", res->pf_vf);
11203 /* set to report FD ID by default */
11204 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11205 entry.action.rx_queue = res->queue_id;
11206 entry.soft_id = res->fd_id_value;
11207 if (!strcmp(res->ops, "add"))
11208 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11209 RTE_ETH_FILTER_ADD, &entry);
11210 else if (!strcmp(res->ops, "del"))
11211 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11212 RTE_ETH_FILTER_DELETE, &entry);
11214 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11215 RTE_ETH_FILTER_UPDATE, &entry);
11217 printf("flow director programming error: (%s)\n",
11221 cmdline_parse_token_string_t cmd_flow_director_filter =
11222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11223 flow_director_filter, "flow_director_filter");
11224 cmdline_parse_token_num_t cmd_flow_director_port_id =
11225 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11227 cmdline_parse_token_string_t cmd_flow_director_ops =
11228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11229 ops, "add#del#update");
11230 cmdline_parse_token_string_t cmd_flow_director_flow =
11231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11233 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11236 cmdline_parse_token_string_t cmd_flow_director_ether =
11237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11239 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11240 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11241 ether_type, UINT16);
11242 cmdline_parse_token_string_t cmd_flow_director_src =
11243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11245 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11246 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11248 cmdline_parse_token_num_t cmd_flow_director_port_src =
11249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11251 cmdline_parse_token_string_t cmd_flow_director_dst =
11252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11254 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11255 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11257 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11258 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11260 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11262 verify_tag, "verify_tag");
11263 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11264 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11265 verify_tag_value, UINT32);
11266 cmdline_parse_token_string_t cmd_flow_director_tos =
11267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11269 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11270 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11272 cmdline_parse_token_string_t cmd_flow_director_proto =
11273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11275 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11276 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11277 proto_value, UINT8);
11278 cmdline_parse_token_string_t cmd_flow_director_ttl =
11279 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11281 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11282 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11284 cmdline_parse_token_string_t cmd_flow_director_vlan =
11285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11287 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11288 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11289 vlan_value, UINT16);
11290 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11292 flexbytes, "flexbytes");
11293 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11295 flexbytes_value, NULL);
11296 cmdline_parse_token_string_t cmd_flow_director_drop =
11297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11299 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11300 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11302 cmdline_parse_token_string_t cmd_flow_director_queue =
11303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11305 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11306 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11308 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11311 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11313 fd_id_value, UINT32);
11315 cmdline_parse_token_string_t cmd_flow_director_mode =
11316 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11318 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11321 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11323 mode_value, "MAC-VLAN");
11324 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11326 mode_value, "Tunnel");
11327 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11329 mode_value, "raw");
11330 cmdline_parse_token_string_t cmd_flow_director_mac =
11331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11333 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11334 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11336 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11337 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11339 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11341 tunnel_type, "NVGRE#VxLAN");
11342 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11343 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11344 tunnel_id, "tunnel-id");
11345 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11346 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11347 tunnel_id_value, UINT32);
11348 cmdline_parse_token_string_t cmd_flow_director_packet =
11349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11351 cmdline_parse_token_string_t cmd_flow_director_filepath =
11352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11355 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11356 .f = cmd_flow_director_filter_parsed,
11358 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11359 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11360 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11361 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11362 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11363 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11364 "fd_id <fd_id_value>: "
11365 "Add or delete an ip flow director entry on NIC",
11367 (void *)&cmd_flow_director_filter,
11368 (void *)&cmd_flow_director_port_id,
11369 (void *)&cmd_flow_director_mode,
11370 (void *)&cmd_flow_director_mode_ip,
11371 (void *)&cmd_flow_director_ops,
11372 (void *)&cmd_flow_director_flow,
11373 (void *)&cmd_flow_director_flow_type,
11374 (void *)&cmd_flow_director_src,
11375 (void *)&cmd_flow_director_ip_src,
11376 (void *)&cmd_flow_director_dst,
11377 (void *)&cmd_flow_director_ip_dst,
11378 (void *)&cmd_flow_director_tos,
11379 (void *)&cmd_flow_director_tos_value,
11380 (void *)&cmd_flow_director_proto,
11381 (void *)&cmd_flow_director_proto_value,
11382 (void *)&cmd_flow_director_ttl,
11383 (void *)&cmd_flow_director_ttl_value,
11384 (void *)&cmd_flow_director_vlan,
11385 (void *)&cmd_flow_director_vlan_value,
11386 (void *)&cmd_flow_director_flexbytes,
11387 (void *)&cmd_flow_director_flexbytes_value,
11388 (void *)&cmd_flow_director_drop,
11389 (void *)&cmd_flow_director_pf_vf,
11390 (void *)&cmd_flow_director_queue,
11391 (void *)&cmd_flow_director_queue_id,
11392 (void *)&cmd_flow_director_fd_id,
11393 (void *)&cmd_flow_director_fd_id_value,
11398 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11399 .f = cmd_flow_director_filter_parsed,
11401 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11402 "director entry on NIC",
11404 (void *)&cmd_flow_director_filter,
11405 (void *)&cmd_flow_director_port_id,
11406 (void *)&cmd_flow_director_mode,
11407 (void *)&cmd_flow_director_mode_ip,
11408 (void *)&cmd_flow_director_ops,
11409 (void *)&cmd_flow_director_flow,
11410 (void *)&cmd_flow_director_flow_type,
11411 (void *)&cmd_flow_director_src,
11412 (void *)&cmd_flow_director_ip_src,
11413 (void *)&cmd_flow_director_port_src,
11414 (void *)&cmd_flow_director_dst,
11415 (void *)&cmd_flow_director_ip_dst,
11416 (void *)&cmd_flow_director_port_dst,
11417 (void *)&cmd_flow_director_tos,
11418 (void *)&cmd_flow_director_tos_value,
11419 (void *)&cmd_flow_director_ttl,
11420 (void *)&cmd_flow_director_ttl_value,
11421 (void *)&cmd_flow_director_vlan,
11422 (void *)&cmd_flow_director_vlan_value,
11423 (void *)&cmd_flow_director_flexbytes,
11424 (void *)&cmd_flow_director_flexbytes_value,
11425 (void *)&cmd_flow_director_drop,
11426 (void *)&cmd_flow_director_pf_vf,
11427 (void *)&cmd_flow_director_queue,
11428 (void *)&cmd_flow_director_queue_id,
11429 (void *)&cmd_flow_director_fd_id,
11430 (void *)&cmd_flow_director_fd_id_value,
11435 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11436 .f = cmd_flow_director_filter_parsed,
11438 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11439 "director entry on NIC",
11441 (void *)&cmd_flow_director_filter,
11442 (void *)&cmd_flow_director_port_id,
11443 (void *)&cmd_flow_director_mode,
11444 (void *)&cmd_flow_director_mode_ip,
11445 (void *)&cmd_flow_director_ops,
11446 (void *)&cmd_flow_director_flow,
11447 (void *)&cmd_flow_director_flow_type,
11448 (void *)&cmd_flow_director_src,
11449 (void *)&cmd_flow_director_ip_src,
11450 (void *)&cmd_flow_director_port_src,
11451 (void *)&cmd_flow_director_dst,
11452 (void *)&cmd_flow_director_ip_dst,
11453 (void *)&cmd_flow_director_port_dst,
11454 (void *)&cmd_flow_director_verify_tag,
11455 (void *)&cmd_flow_director_verify_tag_value,
11456 (void *)&cmd_flow_director_tos,
11457 (void *)&cmd_flow_director_tos_value,
11458 (void *)&cmd_flow_director_ttl,
11459 (void *)&cmd_flow_director_ttl_value,
11460 (void *)&cmd_flow_director_vlan,
11461 (void *)&cmd_flow_director_vlan_value,
11462 (void *)&cmd_flow_director_flexbytes,
11463 (void *)&cmd_flow_director_flexbytes_value,
11464 (void *)&cmd_flow_director_drop,
11465 (void *)&cmd_flow_director_pf_vf,
11466 (void *)&cmd_flow_director_queue,
11467 (void *)&cmd_flow_director_queue_id,
11468 (void *)&cmd_flow_director_fd_id,
11469 (void *)&cmd_flow_director_fd_id_value,
11474 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11475 .f = cmd_flow_director_filter_parsed,
11477 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11478 "director entry on NIC",
11480 (void *)&cmd_flow_director_filter,
11481 (void *)&cmd_flow_director_port_id,
11482 (void *)&cmd_flow_director_mode,
11483 (void *)&cmd_flow_director_mode_ip,
11484 (void *)&cmd_flow_director_ops,
11485 (void *)&cmd_flow_director_flow,
11486 (void *)&cmd_flow_director_flow_type,
11487 (void *)&cmd_flow_director_ether,
11488 (void *)&cmd_flow_director_ether_type,
11489 (void *)&cmd_flow_director_flexbytes,
11490 (void *)&cmd_flow_director_flexbytes_value,
11491 (void *)&cmd_flow_director_drop,
11492 (void *)&cmd_flow_director_pf_vf,
11493 (void *)&cmd_flow_director_queue,
11494 (void *)&cmd_flow_director_queue_id,
11495 (void *)&cmd_flow_director_fd_id,
11496 (void *)&cmd_flow_director_fd_id_value,
11501 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11502 .f = cmd_flow_director_filter_parsed,
11504 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11505 "director entry on NIC",
11507 (void *)&cmd_flow_director_filter,
11508 (void *)&cmd_flow_director_port_id,
11509 (void *)&cmd_flow_director_mode,
11510 (void *)&cmd_flow_director_mode_mac_vlan,
11511 (void *)&cmd_flow_director_ops,
11512 (void *)&cmd_flow_director_mac,
11513 (void *)&cmd_flow_director_mac_addr,
11514 (void *)&cmd_flow_director_vlan,
11515 (void *)&cmd_flow_director_vlan_value,
11516 (void *)&cmd_flow_director_flexbytes,
11517 (void *)&cmd_flow_director_flexbytes_value,
11518 (void *)&cmd_flow_director_drop,
11519 (void *)&cmd_flow_director_queue,
11520 (void *)&cmd_flow_director_queue_id,
11521 (void *)&cmd_flow_director_fd_id,
11522 (void *)&cmd_flow_director_fd_id_value,
11527 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11528 .f = cmd_flow_director_filter_parsed,
11530 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11531 "director entry on NIC",
11533 (void *)&cmd_flow_director_filter,
11534 (void *)&cmd_flow_director_port_id,
11535 (void *)&cmd_flow_director_mode,
11536 (void *)&cmd_flow_director_mode_tunnel,
11537 (void *)&cmd_flow_director_ops,
11538 (void *)&cmd_flow_director_mac,
11539 (void *)&cmd_flow_director_mac_addr,
11540 (void *)&cmd_flow_director_vlan,
11541 (void *)&cmd_flow_director_vlan_value,
11542 (void *)&cmd_flow_director_tunnel,
11543 (void *)&cmd_flow_director_tunnel_type,
11544 (void *)&cmd_flow_director_tunnel_id,
11545 (void *)&cmd_flow_director_tunnel_id_value,
11546 (void *)&cmd_flow_director_flexbytes,
11547 (void *)&cmd_flow_director_flexbytes_value,
11548 (void *)&cmd_flow_director_drop,
11549 (void *)&cmd_flow_director_queue,
11550 (void *)&cmd_flow_director_queue_id,
11551 (void *)&cmd_flow_director_fd_id,
11552 (void *)&cmd_flow_director_fd_id_value,
11557 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11558 .f = cmd_flow_director_filter_parsed,
11560 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11561 "director entry on NIC",
11563 (void *)&cmd_flow_director_filter,
11564 (void *)&cmd_flow_director_port_id,
11565 (void *)&cmd_flow_director_mode,
11566 (void *)&cmd_flow_director_mode_raw,
11567 (void *)&cmd_flow_director_ops,
11568 (void *)&cmd_flow_director_flow,
11569 (void *)&cmd_flow_director_flow_type,
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,
11575 (void *)&cmd_flow_director_packet,
11576 (void *)&cmd_flow_director_filepath,
11581 struct cmd_flush_flow_director_result {
11582 cmdline_fixed_string_t flush_flow_director;
11586 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11587 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11588 flush_flow_director, "flush_flow_director");
11589 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11590 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11594 cmd_flush_flow_director_parsed(void *parsed_result,
11595 __attribute__((unused)) struct cmdline *cl,
11596 __attribute__((unused)) void *data)
11598 struct cmd_flow_director_result *res = parsed_result;
11601 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11603 printf("flow director is not supported on port %u.\n",
11608 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11609 RTE_ETH_FILTER_FLUSH, NULL);
11611 printf("flow director table flushing error: (%s)\n",
11615 cmdline_parse_inst_t cmd_flush_flow_director = {
11616 .f = cmd_flush_flow_director_parsed,
11618 .help_str = "flush_flow_director <port_id>: "
11619 "Flush all flow director entries of a device on NIC",
11621 (void *)&cmd_flush_flow_director_flush,
11622 (void *)&cmd_flush_flow_director_port_id,
11627 /* *** deal with flow director mask *** */
11628 struct cmd_flow_director_mask_result {
11629 cmdline_fixed_string_t flow_director_mask;
11631 cmdline_fixed_string_t mode;
11632 cmdline_fixed_string_t mode_value;
11633 cmdline_fixed_string_t vlan;
11634 uint16_t vlan_mask;
11635 cmdline_fixed_string_t src_mask;
11636 cmdline_ipaddr_t ipv4_src;
11637 cmdline_ipaddr_t ipv6_src;
11639 cmdline_fixed_string_t dst_mask;
11640 cmdline_ipaddr_t ipv4_dst;
11641 cmdline_ipaddr_t ipv6_dst;
11643 cmdline_fixed_string_t mac;
11644 uint8_t mac_addr_byte_mask;
11645 cmdline_fixed_string_t tunnel_id;
11646 uint32_t tunnel_id_mask;
11647 cmdline_fixed_string_t tunnel_type;
11648 uint8_t tunnel_type_mask;
11652 cmd_flow_director_mask_parsed(void *parsed_result,
11653 __attribute__((unused)) struct cmdline *cl,
11654 __attribute__((unused)) void *data)
11656 struct cmd_flow_director_mask_result *res = parsed_result;
11657 struct rte_eth_fdir_masks *mask;
11658 struct rte_port *port;
11660 port = &ports[res->port_id];
11661 /** Check if the port is not started **/
11662 if (port->port_status != RTE_PORT_STOPPED) {
11663 printf("Please stop port %d first\n", res->port_id);
11667 mask = &port->dev_conf.fdir_conf.mask;
11669 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11670 if (strcmp(res->mode_value, "MAC-VLAN")) {
11671 printf("Please set mode to MAC-VLAN.\n");
11675 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11676 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11677 if (strcmp(res->mode_value, "Tunnel")) {
11678 printf("Please set mode to Tunnel.\n");
11682 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11683 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11684 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11685 mask->tunnel_type_mask = res->tunnel_type_mask;
11687 if (strcmp(res->mode_value, "IP")) {
11688 printf("Please set mode to IP.\n");
11692 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11693 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11694 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11695 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11696 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11697 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11698 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11701 cmd_reconfig_device_queue(res->port_id, 1, 1);
11704 cmdline_parse_token_string_t cmd_flow_director_mask =
11705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11706 flow_director_mask, "flow_director_mask");
11707 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11708 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11710 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11713 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11715 vlan_mask, UINT16);
11716 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11718 src_mask, "src_mask");
11719 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11720 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11722 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11723 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11725 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11726 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11728 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11730 dst_mask, "dst_mask");
11731 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11732 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11734 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11735 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11737 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11738 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11741 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11744 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11747 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11749 mode_value, "MAC-VLAN");
11750 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11752 mode_value, "Tunnel");
11753 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11756 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11758 mac_addr_byte_mask, UINT8);
11759 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11761 tunnel_type, "tunnel-type");
11762 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11764 tunnel_type_mask, UINT8);
11765 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11767 tunnel_id, "tunnel-id");
11768 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11770 tunnel_id_mask, UINT32);
11772 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11773 .f = cmd_flow_director_mask_parsed,
11775 .help_str = "flow_director_mask ... : "
11776 "Set IP mode flow director's mask on NIC",
11778 (void *)&cmd_flow_director_mask,
11779 (void *)&cmd_flow_director_mask_port_id,
11780 (void *)&cmd_flow_director_mask_mode,
11781 (void *)&cmd_flow_director_mask_mode_ip,
11782 (void *)&cmd_flow_director_mask_vlan,
11783 (void *)&cmd_flow_director_mask_vlan_value,
11784 (void *)&cmd_flow_director_mask_src,
11785 (void *)&cmd_flow_director_mask_ipv4_src,
11786 (void *)&cmd_flow_director_mask_ipv6_src,
11787 (void *)&cmd_flow_director_mask_port_src,
11788 (void *)&cmd_flow_director_mask_dst,
11789 (void *)&cmd_flow_director_mask_ipv4_dst,
11790 (void *)&cmd_flow_director_mask_ipv6_dst,
11791 (void *)&cmd_flow_director_mask_port_dst,
11796 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11797 .f = cmd_flow_director_mask_parsed,
11799 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11800 "flow director's mask on NIC",
11802 (void *)&cmd_flow_director_mask,
11803 (void *)&cmd_flow_director_mask_port_id,
11804 (void *)&cmd_flow_director_mask_mode,
11805 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11806 (void *)&cmd_flow_director_mask_vlan,
11807 (void *)&cmd_flow_director_mask_vlan_value,
11812 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11813 .f = cmd_flow_director_mask_parsed,
11815 .help_str = "flow_director_mask ... : Set tunnel mode "
11816 "flow director's mask on NIC",
11818 (void *)&cmd_flow_director_mask,
11819 (void *)&cmd_flow_director_mask_port_id,
11820 (void *)&cmd_flow_director_mask_mode,
11821 (void *)&cmd_flow_director_mask_mode_tunnel,
11822 (void *)&cmd_flow_director_mask_vlan,
11823 (void *)&cmd_flow_director_mask_vlan_value,
11824 (void *)&cmd_flow_director_mask_mac,
11825 (void *)&cmd_flow_director_mask_mac_value,
11826 (void *)&cmd_flow_director_mask_tunnel_type,
11827 (void *)&cmd_flow_director_mask_tunnel_type_value,
11828 (void *)&cmd_flow_director_mask_tunnel_id,
11829 (void *)&cmd_flow_director_mask_tunnel_id_value,
11834 /* *** deal with flow director mask on flexible payload *** */
11835 struct cmd_flow_director_flex_mask_result {
11836 cmdline_fixed_string_t flow_director_flexmask;
11838 cmdline_fixed_string_t flow;
11839 cmdline_fixed_string_t flow_type;
11840 cmdline_fixed_string_t mask;
11844 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11845 __attribute__((unused)) struct cmdline *cl,
11846 __attribute__((unused)) void *data)
11848 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11849 struct rte_eth_fdir_info fdir_info;
11850 struct rte_eth_fdir_flex_mask flex_mask;
11851 struct rte_port *port;
11852 uint64_t flow_type_mask;
11856 port = &ports[res->port_id];
11857 /** Check if the port is not started **/
11858 if (port->port_status != RTE_PORT_STOPPED) {
11859 printf("Please stop port %d first\n", res->port_id);
11863 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11864 ret = parse_flexbytes(res->mask,
11866 RTE_ETH_FDIR_MAX_FLEXLEN);
11868 printf("error: Cannot parse mask input.\n");
11872 memset(&fdir_info, 0, sizeof(fdir_info));
11873 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11874 RTE_ETH_FILTER_INFO, &fdir_info);
11876 printf("Cannot get FDir filter info\n");
11880 if (!strcmp(res->flow_type, "none")) {
11881 /* means don't specify the flow type */
11882 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11883 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11884 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11885 0, sizeof(struct rte_eth_fdir_flex_mask));
11886 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11887 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11889 sizeof(struct rte_eth_fdir_flex_mask));
11890 cmd_reconfig_device_queue(res->port_id, 1, 1);
11893 flow_type_mask = fdir_info.flow_types_mask[0];
11894 if (!strcmp(res->flow_type, "all")) {
11895 if (!flow_type_mask) {
11896 printf("No flow type supported\n");
11899 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11900 if (flow_type_mask & (1ULL << i)) {
11901 flex_mask.flow_type = i;
11902 fdir_set_flex_mask(res->port_id, &flex_mask);
11905 cmd_reconfig_device_queue(res->port_id, 1, 1);
11908 flex_mask.flow_type = str2flowtype(res->flow_type);
11909 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11910 printf("Flow type %s not supported on port %d\n",
11911 res->flow_type, res->port_id);
11914 fdir_set_flex_mask(res->port_id, &flex_mask);
11915 cmd_reconfig_device_queue(res->port_id, 1, 1);
11918 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11920 flow_director_flexmask,
11921 "flow_director_flex_mask");
11922 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11923 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11925 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11926 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11928 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11929 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11930 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11931 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11932 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11933 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11936 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11937 .f = cmd_flow_director_flex_mask_parsed,
11939 .help_str = "flow_director_flex_mask ... : "
11940 "Set flow director's flex mask on NIC",
11942 (void *)&cmd_flow_director_flexmask,
11943 (void *)&cmd_flow_director_flexmask_port_id,
11944 (void *)&cmd_flow_director_flexmask_flow,
11945 (void *)&cmd_flow_director_flexmask_flow_type,
11946 (void *)&cmd_flow_director_flexmask_mask,
11951 /* *** deal with flow director flexible payload configuration *** */
11952 struct cmd_flow_director_flexpayload_result {
11953 cmdline_fixed_string_t flow_director_flexpayload;
11955 cmdline_fixed_string_t payload_layer;
11956 cmdline_fixed_string_t payload_cfg;
11960 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11963 const char *p, *p0 = q_arg;
11965 unsigned long int_fld;
11966 char *str_fld[max_num];
11971 p = strchr(p0, '(');
11975 p0 = strchr(p, ')');
11980 if (size >= sizeof(s))
11983 snprintf(s, sizeof(s), "%.*s", size, p);
11984 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11985 if (ret < 0 || ret > max_num)
11987 for (i = 0; i < ret; i++) {
11989 int_fld = strtoul(str_fld[i], &end, 0);
11990 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11992 offsets[i] = (uint16_t)int_fld;
11998 cmd_flow_director_flxpld_parsed(void *parsed_result,
11999 __attribute__((unused)) struct cmdline *cl,
12000 __attribute__((unused)) void *data)
12002 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12003 struct rte_eth_flex_payload_cfg flex_cfg;
12004 struct rte_port *port;
12007 port = &ports[res->port_id];
12008 /** Check if the port is not started **/
12009 if (port->port_status != RTE_PORT_STOPPED) {
12010 printf("Please stop port %d first\n", res->port_id);
12014 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12016 if (!strcmp(res->payload_layer, "raw"))
12017 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12018 else if (!strcmp(res->payload_layer, "l2"))
12019 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12020 else if (!strcmp(res->payload_layer, "l3"))
12021 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12022 else if (!strcmp(res->payload_layer, "l4"))
12023 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12025 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12026 RTE_ETH_FDIR_MAX_FLEXLEN);
12028 printf("error: Cannot parse flex payload input.\n");
12032 fdir_set_flex_payload(res->port_id, &flex_cfg);
12033 cmd_reconfig_device_queue(res->port_id, 1, 1);
12036 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12037 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12038 flow_director_flexpayload,
12039 "flow_director_flex_payload");
12040 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12041 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12043 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12045 payload_layer, "raw#l2#l3#l4");
12046 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12048 payload_cfg, NULL);
12050 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12051 .f = cmd_flow_director_flxpld_parsed,
12053 .help_str = "flow_director_flexpayload ... : "
12054 "Set flow director's flex payload on NIC",
12056 (void *)&cmd_flow_director_flexpayload,
12057 (void *)&cmd_flow_director_flexpayload_port_id,
12058 (void *)&cmd_flow_director_flexpayload_payload_layer,
12059 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12064 /* Generic flow interface command. */
12065 extern cmdline_parse_inst_t cmd_flow;
12067 /* *** Classification Filters Control *** */
12068 /* *** Get symmetric hash enable per port *** */
12069 struct cmd_get_sym_hash_ena_per_port_result {
12070 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12075 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12076 __rte_unused struct cmdline *cl,
12077 __rte_unused void *data)
12079 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12080 struct rte_eth_hash_filter_info info;
12083 if (rte_eth_dev_filter_supported(res->port_id,
12084 RTE_ETH_FILTER_HASH) < 0) {
12085 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12090 memset(&info, 0, sizeof(info));
12091 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12092 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12093 RTE_ETH_FILTER_GET, &info);
12096 printf("Cannot get symmetric hash enable per port "
12097 "on port %u\n", res->port_id);
12101 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12102 "enabled" : "disabled", res->port_id);
12105 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12106 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12107 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12108 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12109 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12112 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12113 .f = cmd_get_sym_hash_per_port_parsed,
12115 .help_str = "get_sym_hash_ena_per_port <port_id>",
12117 (void *)&cmd_get_sym_hash_ena_per_port_all,
12118 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12123 /* *** Set symmetric hash enable per port *** */
12124 struct cmd_set_sym_hash_ena_per_port_result {
12125 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12126 cmdline_fixed_string_t enable;
12131 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12132 __rte_unused struct cmdline *cl,
12133 __rte_unused void *data)
12135 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12136 struct rte_eth_hash_filter_info info;
12139 if (rte_eth_dev_filter_supported(res->port_id,
12140 RTE_ETH_FILTER_HASH) < 0) {
12141 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12146 memset(&info, 0, sizeof(info));
12147 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12148 if (!strcmp(res->enable, "enable"))
12149 info.info.enable = 1;
12150 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12151 RTE_ETH_FILTER_SET, &info);
12153 printf("Cannot set symmetric hash enable per port on "
12154 "port %u\n", res->port_id);
12157 printf("Symmetric hash has been set to %s on port %u\n",
12158 res->enable, res->port_id);
12161 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12162 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12163 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12164 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12165 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12167 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12168 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12169 enable, "enable#disable");
12171 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12172 .f = cmd_set_sym_hash_per_port_parsed,
12174 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12176 (void *)&cmd_set_sym_hash_ena_per_port_all,
12177 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12178 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12183 /* Get global config of hash function */
12184 struct cmd_get_hash_global_config_result {
12185 cmdline_fixed_string_t get_hash_global_config;
12190 flowtype_to_str(uint16_t ftype)
12196 } ftype_table[] = {
12197 {"ipv4", RTE_ETH_FLOW_IPV4},
12198 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12199 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12200 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12201 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12202 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12203 {"ipv6", RTE_ETH_FLOW_IPV6},
12204 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12205 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12206 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12207 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12208 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12209 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12210 {"port", RTE_ETH_FLOW_PORT},
12211 {"vxlan", RTE_ETH_FLOW_VXLAN},
12212 {"geneve", RTE_ETH_FLOW_GENEVE},
12213 {"nvgre", RTE_ETH_FLOW_NVGRE},
12214 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12217 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12218 if (ftype_table[i].ftype == ftype)
12219 return ftype_table[i].str;
12226 cmd_get_hash_global_config_parsed(void *parsed_result,
12227 __rte_unused struct cmdline *cl,
12228 __rte_unused void *data)
12230 struct cmd_get_hash_global_config_result *res = parsed_result;
12231 struct rte_eth_hash_filter_info info;
12232 uint32_t idx, offset;
12237 if (rte_eth_dev_filter_supported(res->port_id,
12238 RTE_ETH_FILTER_HASH) < 0) {
12239 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12244 memset(&info, 0, sizeof(info));
12245 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12246 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12247 RTE_ETH_FILTER_GET, &info);
12249 printf("Cannot get hash global configurations by port %d\n",
12254 switch (info.info.global_conf.hash_func) {
12255 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12256 printf("Hash function is Toeplitz\n");
12258 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12259 printf("Hash function is Simple XOR\n");
12262 printf("Unknown hash function\n");
12266 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12267 idx = i / UINT64_BIT;
12268 offset = i % UINT64_BIT;
12269 if (!(info.info.global_conf.valid_bit_mask[idx] &
12272 str = flowtype_to_str(i);
12275 printf("Symmetric hash is %s globally for flow type %s "
12277 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12278 (1ULL << offset)) ? "enabled" : "disabled"), str,
12283 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12284 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12285 get_hash_global_config, "get_hash_global_config");
12286 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12287 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12290 cmdline_parse_inst_t cmd_get_hash_global_config = {
12291 .f = cmd_get_hash_global_config_parsed,
12293 .help_str = "get_hash_global_config <port_id>",
12295 (void *)&cmd_get_hash_global_config_all,
12296 (void *)&cmd_get_hash_global_config_port_id,
12301 /* Set global config of hash function */
12302 struct cmd_set_hash_global_config_result {
12303 cmdline_fixed_string_t set_hash_global_config;
12305 cmdline_fixed_string_t hash_func;
12306 cmdline_fixed_string_t flow_type;
12307 cmdline_fixed_string_t enable;
12311 cmd_set_hash_global_config_parsed(void *parsed_result,
12312 __rte_unused struct cmdline *cl,
12313 __rte_unused void *data)
12315 struct cmd_set_hash_global_config_result *res = parsed_result;
12316 struct rte_eth_hash_filter_info info;
12317 uint32_t ftype, idx, offset;
12320 if (rte_eth_dev_filter_supported(res->port_id,
12321 RTE_ETH_FILTER_HASH) < 0) {
12322 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12326 memset(&info, 0, sizeof(info));
12327 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12328 if (!strcmp(res->hash_func, "toeplitz"))
12329 info.info.global_conf.hash_func =
12330 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12331 else if (!strcmp(res->hash_func, "simple_xor"))
12332 info.info.global_conf.hash_func =
12333 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12334 else if (!strcmp(res->hash_func, "default"))
12335 info.info.global_conf.hash_func =
12336 RTE_ETH_HASH_FUNCTION_DEFAULT;
12338 ftype = str2flowtype(res->flow_type);
12339 idx = ftype / UINT64_BIT;
12340 offset = ftype % UINT64_BIT;
12341 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12342 if (!strcmp(res->enable, "enable"))
12343 info.info.global_conf.sym_hash_enable_mask[idx] |=
12345 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12346 RTE_ETH_FILTER_SET, &info);
12348 printf("Cannot set global hash configurations by port %d\n",
12351 printf("Global hash configurations have been set "
12352 "successfully by port %d\n", res->port_id);
12355 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12356 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12357 set_hash_global_config, "set_hash_global_config");
12358 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12359 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12361 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12362 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12363 hash_func, "toeplitz#simple_xor#default");
12364 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12365 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12367 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12368 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12369 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12370 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12371 enable, "enable#disable");
12373 cmdline_parse_inst_t cmd_set_hash_global_config = {
12374 .f = cmd_set_hash_global_config_parsed,
12376 .help_str = "set_hash_global_config <port_id> "
12377 "toeplitz|simple_xor|default "
12378 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12379 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12380 "l2_payload enable|disable",
12382 (void *)&cmd_set_hash_global_config_all,
12383 (void *)&cmd_set_hash_global_config_port_id,
12384 (void *)&cmd_set_hash_global_config_hash_func,
12385 (void *)&cmd_set_hash_global_config_flow_type,
12386 (void *)&cmd_set_hash_global_config_enable,
12391 /* Set hash input set */
12392 struct cmd_set_hash_input_set_result {
12393 cmdline_fixed_string_t set_hash_input_set;
12395 cmdline_fixed_string_t flow_type;
12396 cmdline_fixed_string_t inset_field;
12397 cmdline_fixed_string_t select;
12400 static enum rte_eth_input_set_field
12401 str2inset(char *string)
12405 static const struct {
12407 enum rte_eth_input_set_field inset;
12408 } inset_table[] = {
12409 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12410 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12411 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12412 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12413 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12414 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12415 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12416 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12417 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12418 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12419 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12420 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12421 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12422 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12423 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12424 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12425 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12426 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12427 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12428 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12429 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12430 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12431 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12432 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12433 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12434 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12435 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12436 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12437 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12438 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12439 {"none", RTE_ETH_INPUT_SET_NONE},
12442 for (i = 0; i < RTE_DIM(inset_table); i++) {
12443 if (!strcmp(string, inset_table[i].str))
12444 return inset_table[i].inset;
12447 return RTE_ETH_INPUT_SET_UNKNOWN;
12451 cmd_set_hash_input_set_parsed(void *parsed_result,
12452 __rte_unused struct cmdline *cl,
12453 __rte_unused void *data)
12455 struct cmd_set_hash_input_set_result *res = parsed_result;
12456 struct rte_eth_hash_filter_info info;
12458 memset(&info, 0, sizeof(info));
12459 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12460 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12461 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12462 info.info.input_set_conf.inset_size = 1;
12463 if (!strcmp(res->select, "select"))
12464 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12465 else if (!strcmp(res->select, "add"))
12466 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12467 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12468 RTE_ETH_FILTER_SET, &info);
12471 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12472 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12473 set_hash_input_set, "set_hash_input_set");
12474 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12475 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12477 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12478 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12480 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12481 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12483 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12484 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12485 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12486 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12487 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12489 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12490 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12491 select, "select#add");
12493 cmdline_parse_inst_t cmd_set_hash_input_set = {
12494 .f = cmd_set_hash_input_set_parsed,
12496 .help_str = "set_hash_input_set <port_id> "
12497 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12498 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12499 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12500 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12501 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12502 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12503 "fld-7th|fld-8th|none select|add",
12505 (void *)&cmd_set_hash_input_set_cmd,
12506 (void *)&cmd_set_hash_input_set_port_id,
12507 (void *)&cmd_set_hash_input_set_flow_type,
12508 (void *)&cmd_set_hash_input_set_field,
12509 (void *)&cmd_set_hash_input_set_select,
12514 /* Set flow director input set */
12515 struct cmd_set_fdir_input_set_result {
12516 cmdline_fixed_string_t set_fdir_input_set;
12518 cmdline_fixed_string_t flow_type;
12519 cmdline_fixed_string_t inset_field;
12520 cmdline_fixed_string_t select;
12524 cmd_set_fdir_input_set_parsed(void *parsed_result,
12525 __rte_unused struct cmdline *cl,
12526 __rte_unused void *data)
12528 struct cmd_set_fdir_input_set_result *res = parsed_result;
12529 struct rte_eth_fdir_filter_info info;
12531 memset(&info, 0, sizeof(info));
12532 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12533 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12534 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12535 info.info.input_set_conf.inset_size = 1;
12536 if (!strcmp(res->select, "select"))
12537 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12538 else if (!strcmp(res->select, "add"))
12539 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12540 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12541 RTE_ETH_FILTER_SET, &info);
12544 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12545 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12546 set_fdir_input_set, "set_fdir_input_set");
12547 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12548 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12550 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12551 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12553 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12554 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12555 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12556 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12558 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12559 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12560 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12561 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12562 "sctp-veri-tag#none");
12563 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12564 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12565 select, "select#add");
12567 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12568 .f = cmd_set_fdir_input_set_parsed,
12570 .help_str = "set_fdir_input_set <port_id> "
12571 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12572 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12573 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12574 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12575 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12576 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12577 "sctp-veri-tag|none select|add",
12579 (void *)&cmd_set_fdir_input_set_cmd,
12580 (void *)&cmd_set_fdir_input_set_port_id,
12581 (void *)&cmd_set_fdir_input_set_flow_type,
12582 (void *)&cmd_set_fdir_input_set_field,
12583 (void *)&cmd_set_fdir_input_set_select,
12588 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12589 struct cmd_mcast_addr_result {
12590 cmdline_fixed_string_t mcast_addr_cmd;
12591 cmdline_fixed_string_t what;
12593 struct rte_ether_addr mc_addr;
12596 static void cmd_mcast_addr_parsed(void *parsed_result,
12597 __attribute__((unused)) struct cmdline *cl,
12598 __attribute__((unused)) void *data)
12600 struct cmd_mcast_addr_result *res = parsed_result;
12602 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12603 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12604 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12605 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12606 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12609 if (strcmp(res->what, "add") == 0)
12610 mcast_addr_add(res->port_num, &res->mc_addr);
12612 mcast_addr_remove(res->port_num, &res->mc_addr);
12615 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12616 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12617 mcast_addr_cmd, "mcast_addr");
12618 cmdline_parse_token_string_t cmd_mcast_addr_what =
12619 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12621 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12622 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12623 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12624 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12626 cmdline_parse_inst_t cmd_mcast_addr = {
12627 .f = cmd_mcast_addr_parsed,
12629 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12630 "Add/Remove multicast MAC address on port_id",
12632 (void *)&cmd_mcast_addr_cmd,
12633 (void *)&cmd_mcast_addr_what,
12634 (void *)&cmd_mcast_addr_portnum,
12635 (void *)&cmd_mcast_addr_addr,
12640 /* l2 tunnel config
12641 * only support E-tag now.
12644 /* Ether type config */
12645 struct cmd_config_l2_tunnel_eth_type_result {
12646 cmdline_fixed_string_t port;
12647 cmdline_fixed_string_t config;
12648 cmdline_fixed_string_t all;
12650 cmdline_fixed_string_t l2_tunnel;
12651 cmdline_fixed_string_t l2_tunnel_type;
12652 cmdline_fixed_string_t eth_type;
12653 uint16_t eth_type_val;
12656 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12657 TOKEN_STRING_INITIALIZER
12658 (struct cmd_config_l2_tunnel_eth_type_result,
12660 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12661 TOKEN_STRING_INITIALIZER
12662 (struct cmd_config_l2_tunnel_eth_type_result,
12664 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12665 TOKEN_STRING_INITIALIZER
12666 (struct cmd_config_l2_tunnel_eth_type_result,
12668 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12669 TOKEN_NUM_INITIALIZER
12670 (struct cmd_config_l2_tunnel_eth_type_result,
12672 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12673 TOKEN_STRING_INITIALIZER
12674 (struct cmd_config_l2_tunnel_eth_type_result,
12675 l2_tunnel, "l2-tunnel");
12676 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12677 TOKEN_STRING_INITIALIZER
12678 (struct cmd_config_l2_tunnel_eth_type_result,
12679 l2_tunnel_type, "E-tag");
12680 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12681 TOKEN_STRING_INITIALIZER
12682 (struct cmd_config_l2_tunnel_eth_type_result,
12683 eth_type, "ether-type");
12684 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12685 TOKEN_NUM_INITIALIZER
12686 (struct cmd_config_l2_tunnel_eth_type_result,
12687 eth_type_val, UINT16);
12689 static enum rte_eth_tunnel_type
12690 str2fdir_l2_tunnel_type(char *string)
12694 static const struct {
12696 enum rte_eth_tunnel_type type;
12697 } l2_tunnel_type_str[] = {
12698 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12701 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12702 if (!strcmp(l2_tunnel_type_str[i].str, string))
12703 return l2_tunnel_type_str[i].type;
12705 return RTE_TUNNEL_TYPE_NONE;
12708 /* ether type config for all ports */
12710 cmd_config_l2_tunnel_eth_type_all_parsed
12711 (void *parsed_result,
12712 __attribute__((unused)) struct cmdline *cl,
12713 __attribute__((unused)) void *data)
12715 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12716 struct rte_eth_l2_tunnel_conf entry;
12719 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12720 entry.ether_type = res->eth_type_val;
12722 RTE_ETH_FOREACH_DEV(pid) {
12723 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12727 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12728 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12730 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12732 (void *)&cmd_config_l2_tunnel_eth_type_port,
12733 (void *)&cmd_config_l2_tunnel_eth_type_config,
12734 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12735 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12736 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12737 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12738 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12743 /* ether type config for a specific port */
12745 cmd_config_l2_tunnel_eth_type_specific_parsed(
12746 void *parsed_result,
12747 __attribute__((unused)) struct cmdline *cl,
12748 __attribute__((unused)) void *data)
12750 struct cmd_config_l2_tunnel_eth_type_result *res =
12752 struct rte_eth_l2_tunnel_conf entry;
12754 if (port_id_is_invalid(res->id, ENABLED_WARN))
12757 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12758 entry.ether_type = res->eth_type_val;
12760 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12763 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12764 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12766 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12768 (void *)&cmd_config_l2_tunnel_eth_type_port,
12769 (void *)&cmd_config_l2_tunnel_eth_type_config,
12770 (void *)&cmd_config_l2_tunnel_eth_type_id,
12771 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12772 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12773 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12774 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12779 /* Enable/disable l2 tunnel */
12780 struct cmd_config_l2_tunnel_en_dis_result {
12781 cmdline_fixed_string_t port;
12782 cmdline_fixed_string_t config;
12783 cmdline_fixed_string_t all;
12785 cmdline_fixed_string_t l2_tunnel;
12786 cmdline_fixed_string_t l2_tunnel_type;
12787 cmdline_fixed_string_t en_dis;
12790 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12791 TOKEN_STRING_INITIALIZER
12792 (struct cmd_config_l2_tunnel_en_dis_result,
12794 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12795 TOKEN_STRING_INITIALIZER
12796 (struct cmd_config_l2_tunnel_en_dis_result,
12798 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12799 TOKEN_STRING_INITIALIZER
12800 (struct cmd_config_l2_tunnel_en_dis_result,
12802 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12803 TOKEN_NUM_INITIALIZER
12804 (struct cmd_config_l2_tunnel_en_dis_result,
12806 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12807 TOKEN_STRING_INITIALIZER
12808 (struct cmd_config_l2_tunnel_en_dis_result,
12809 l2_tunnel, "l2-tunnel");
12810 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12811 TOKEN_STRING_INITIALIZER
12812 (struct cmd_config_l2_tunnel_en_dis_result,
12813 l2_tunnel_type, "E-tag");
12814 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12815 TOKEN_STRING_INITIALIZER
12816 (struct cmd_config_l2_tunnel_en_dis_result,
12817 en_dis, "enable#disable");
12819 /* enable/disable l2 tunnel for all ports */
12821 cmd_config_l2_tunnel_en_dis_all_parsed(
12822 void *parsed_result,
12823 __attribute__((unused)) struct cmdline *cl,
12824 __attribute__((unused)) void *data)
12826 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12827 struct rte_eth_l2_tunnel_conf entry;
12831 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12833 if (!strcmp("enable", res->en_dis))
12838 RTE_ETH_FOREACH_DEV(pid) {
12839 rte_eth_dev_l2_tunnel_offload_set(pid,
12841 ETH_L2_TUNNEL_ENABLE_MASK,
12846 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12847 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12849 .help_str = "port config all l2-tunnel E-tag enable|disable",
12851 (void *)&cmd_config_l2_tunnel_en_dis_port,
12852 (void *)&cmd_config_l2_tunnel_en_dis_config,
12853 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12854 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12855 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12856 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12861 /* enable/disable l2 tunnel for a port */
12863 cmd_config_l2_tunnel_en_dis_specific_parsed(
12864 void *parsed_result,
12865 __attribute__((unused)) struct cmdline *cl,
12866 __attribute__((unused)) void *data)
12868 struct cmd_config_l2_tunnel_en_dis_result *res =
12870 struct rte_eth_l2_tunnel_conf entry;
12872 if (port_id_is_invalid(res->id, ENABLED_WARN))
12875 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12877 if (!strcmp("enable", res->en_dis))
12878 rte_eth_dev_l2_tunnel_offload_set(res->id,
12880 ETH_L2_TUNNEL_ENABLE_MASK,
12883 rte_eth_dev_l2_tunnel_offload_set(res->id,
12885 ETH_L2_TUNNEL_ENABLE_MASK,
12889 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12890 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12892 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12894 (void *)&cmd_config_l2_tunnel_en_dis_port,
12895 (void *)&cmd_config_l2_tunnel_en_dis_config,
12896 (void *)&cmd_config_l2_tunnel_en_dis_id,
12897 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12898 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12899 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12904 /* E-tag configuration */
12906 /* Common result structure for all E-tag configuration */
12907 struct cmd_config_e_tag_result {
12908 cmdline_fixed_string_t e_tag;
12909 cmdline_fixed_string_t set;
12910 cmdline_fixed_string_t insertion;
12911 cmdline_fixed_string_t stripping;
12912 cmdline_fixed_string_t forwarding;
12913 cmdline_fixed_string_t filter;
12914 cmdline_fixed_string_t add;
12915 cmdline_fixed_string_t del;
12916 cmdline_fixed_string_t on;
12917 cmdline_fixed_string_t off;
12918 cmdline_fixed_string_t on_off;
12919 cmdline_fixed_string_t port_tag_id;
12920 uint32_t port_tag_id_val;
12921 cmdline_fixed_string_t e_tag_id;
12922 uint16_t e_tag_id_val;
12923 cmdline_fixed_string_t dst_pool;
12924 uint8_t dst_pool_val;
12925 cmdline_fixed_string_t port;
12927 cmdline_fixed_string_t vf;
12931 /* Common CLI fields for all E-tag configuration */
12932 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12933 TOKEN_STRING_INITIALIZER
12934 (struct cmd_config_e_tag_result,
12936 cmdline_parse_token_string_t cmd_config_e_tag_set =
12937 TOKEN_STRING_INITIALIZER
12938 (struct cmd_config_e_tag_result,
12940 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12941 TOKEN_STRING_INITIALIZER
12942 (struct cmd_config_e_tag_result,
12943 insertion, "insertion");
12944 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12945 TOKEN_STRING_INITIALIZER
12946 (struct cmd_config_e_tag_result,
12947 stripping, "stripping");
12948 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12949 TOKEN_STRING_INITIALIZER
12950 (struct cmd_config_e_tag_result,
12951 forwarding, "forwarding");
12952 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12953 TOKEN_STRING_INITIALIZER
12954 (struct cmd_config_e_tag_result,
12956 cmdline_parse_token_string_t cmd_config_e_tag_add =
12957 TOKEN_STRING_INITIALIZER
12958 (struct cmd_config_e_tag_result,
12960 cmdline_parse_token_string_t cmd_config_e_tag_del =
12961 TOKEN_STRING_INITIALIZER
12962 (struct cmd_config_e_tag_result,
12964 cmdline_parse_token_string_t cmd_config_e_tag_on =
12965 TOKEN_STRING_INITIALIZER
12966 (struct cmd_config_e_tag_result,
12968 cmdline_parse_token_string_t cmd_config_e_tag_off =
12969 TOKEN_STRING_INITIALIZER
12970 (struct cmd_config_e_tag_result,
12972 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12973 TOKEN_STRING_INITIALIZER
12974 (struct cmd_config_e_tag_result,
12976 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12977 TOKEN_STRING_INITIALIZER
12978 (struct cmd_config_e_tag_result,
12979 port_tag_id, "port-tag-id");
12980 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12981 TOKEN_NUM_INITIALIZER
12982 (struct cmd_config_e_tag_result,
12983 port_tag_id_val, UINT32);
12984 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12985 TOKEN_STRING_INITIALIZER
12986 (struct cmd_config_e_tag_result,
12987 e_tag_id, "e-tag-id");
12988 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12989 TOKEN_NUM_INITIALIZER
12990 (struct cmd_config_e_tag_result,
12991 e_tag_id_val, UINT16);
12992 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12993 TOKEN_STRING_INITIALIZER
12994 (struct cmd_config_e_tag_result,
12995 dst_pool, "dst-pool");
12996 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12997 TOKEN_NUM_INITIALIZER
12998 (struct cmd_config_e_tag_result,
12999 dst_pool_val, UINT8);
13000 cmdline_parse_token_string_t cmd_config_e_tag_port =
13001 TOKEN_STRING_INITIALIZER
13002 (struct cmd_config_e_tag_result,
13004 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13005 TOKEN_NUM_INITIALIZER
13006 (struct cmd_config_e_tag_result,
13008 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13009 TOKEN_STRING_INITIALIZER
13010 (struct cmd_config_e_tag_result,
13012 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13013 TOKEN_NUM_INITIALIZER
13014 (struct cmd_config_e_tag_result,
13017 /* E-tag insertion configuration */
13019 cmd_config_e_tag_insertion_en_parsed(
13020 void *parsed_result,
13021 __attribute__((unused)) struct cmdline *cl,
13022 __attribute__((unused)) void *data)
13024 struct cmd_config_e_tag_result *res =
13026 struct rte_eth_l2_tunnel_conf entry;
13028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13031 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13032 entry.tunnel_id = res->port_tag_id_val;
13033 entry.vf_id = res->vf_id;
13034 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13036 ETH_L2_TUNNEL_INSERTION_MASK,
13041 cmd_config_e_tag_insertion_dis_parsed(
13042 void *parsed_result,
13043 __attribute__((unused)) struct cmdline *cl,
13044 __attribute__((unused)) void *data)
13046 struct cmd_config_e_tag_result *res =
13048 struct rte_eth_l2_tunnel_conf entry;
13050 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13053 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13054 entry.vf_id = res->vf_id;
13056 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13058 ETH_L2_TUNNEL_INSERTION_MASK,
13062 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13063 .f = cmd_config_e_tag_insertion_en_parsed,
13065 .help_str = "E-tag ... : E-tag insertion enable",
13067 (void *)&cmd_config_e_tag_e_tag,
13068 (void *)&cmd_config_e_tag_set,
13069 (void *)&cmd_config_e_tag_insertion,
13070 (void *)&cmd_config_e_tag_on,
13071 (void *)&cmd_config_e_tag_port_tag_id,
13072 (void *)&cmd_config_e_tag_port_tag_id_val,
13073 (void *)&cmd_config_e_tag_port,
13074 (void *)&cmd_config_e_tag_port_id,
13075 (void *)&cmd_config_e_tag_vf,
13076 (void *)&cmd_config_e_tag_vf_id,
13081 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13082 .f = cmd_config_e_tag_insertion_dis_parsed,
13084 .help_str = "E-tag ... : E-tag insertion disable",
13086 (void *)&cmd_config_e_tag_e_tag,
13087 (void *)&cmd_config_e_tag_set,
13088 (void *)&cmd_config_e_tag_insertion,
13089 (void *)&cmd_config_e_tag_off,
13090 (void *)&cmd_config_e_tag_port,
13091 (void *)&cmd_config_e_tag_port_id,
13092 (void *)&cmd_config_e_tag_vf,
13093 (void *)&cmd_config_e_tag_vf_id,
13098 /* E-tag stripping configuration */
13100 cmd_config_e_tag_stripping_parsed(
13101 void *parsed_result,
13102 __attribute__((unused)) struct cmdline *cl,
13103 __attribute__((unused)) void *data)
13105 struct cmd_config_e_tag_result *res =
13107 struct rte_eth_l2_tunnel_conf entry;
13109 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13112 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13114 if (!strcmp(res->on_off, "on"))
13115 rte_eth_dev_l2_tunnel_offload_set
13118 ETH_L2_TUNNEL_STRIPPING_MASK,
13121 rte_eth_dev_l2_tunnel_offload_set
13124 ETH_L2_TUNNEL_STRIPPING_MASK,
13128 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13129 .f = cmd_config_e_tag_stripping_parsed,
13131 .help_str = "E-tag ... : E-tag stripping enable/disable",
13133 (void *)&cmd_config_e_tag_e_tag,
13134 (void *)&cmd_config_e_tag_set,
13135 (void *)&cmd_config_e_tag_stripping,
13136 (void *)&cmd_config_e_tag_on_off,
13137 (void *)&cmd_config_e_tag_port,
13138 (void *)&cmd_config_e_tag_port_id,
13143 /* E-tag forwarding configuration */
13145 cmd_config_e_tag_forwarding_parsed(
13146 void *parsed_result,
13147 __attribute__((unused)) struct cmdline *cl,
13148 __attribute__((unused)) void *data)
13150 struct cmd_config_e_tag_result *res = parsed_result;
13151 struct rte_eth_l2_tunnel_conf entry;
13153 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13156 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13158 if (!strcmp(res->on_off, "on"))
13159 rte_eth_dev_l2_tunnel_offload_set
13162 ETH_L2_TUNNEL_FORWARDING_MASK,
13165 rte_eth_dev_l2_tunnel_offload_set
13168 ETH_L2_TUNNEL_FORWARDING_MASK,
13172 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13173 .f = cmd_config_e_tag_forwarding_parsed,
13175 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13177 (void *)&cmd_config_e_tag_e_tag,
13178 (void *)&cmd_config_e_tag_set,
13179 (void *)&cmd_config_e_tag_forwarding,
13180 (void *)&cmd_config_e_tag_on_off,
13181 (void *)&cmd_config_e_tag_port,
13182 (void *)&cmd_config_e_tag_port_id,
13187 /* E-tag filter configuration */
13189 cmd_config_e_tag_filter_add_parsed(
13190 void *parsed_result,
13191 __attribute__((unused)) struct cmdline *cl,
13192 __attribute__((unused)) void *data)
13194 struct cmd_config_e_tag_result *res = parsed_result;
13195 struct rte_eth_l2_tunnel_conf entry;
13198 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13201 if (res->e_tag_id_val > 0x3fff) {
13202 printf("e-tag-id must be equal or less than 0x3fff.\n");
13206 ret = rte_eth_dev_filter_supported(res->port_id,
13207 RTE_ETH_FILTER_L2_TUNNEL);
13209 printf("E-tag filter is not supported on port %u.\n",
13214 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13215 entry.tunnel_id = res->e_tag_id_val;
13216 entry.pool = res->dst_pool_val;
13218 ret = rte_eth_dev_filter_ctrl(res->port_id,
13219 RTE_ETH_FILTER_L2_TUNNEL,
13220 RTE_ETH_FILTER_ADD,
13223 printf("E-tag filter programming error: (%s)\n",
13227 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13228 .f = cmd_config_e_tag_filter_add_parsed,
13230 .help_str = "E-tag ... : E-tag filter add",
13232 (void *)&cmd_config_e_tag_e_tag,
13233 (void *)&cmd_config_e_tag_set,
13234 (void *)&cmd_config_e_tag_filter,
13235 (void *)&cmd_config_e_tag_add,
13236 (void *)&cmd_config_e_tag_e_tag_id,
13237 (void *)&cmd_config_e_tag_e_tag_id_val,
13238 (void *)&cmd_config_e_tag_dst_pool,
13239 (void *)&cmd_config_e_tag_dst_pool_val,
13240 (void *)&cmd_config_e_tag_port,
13241 (void *)&cmd_config_e_tag_port_id,
13247 cmd_config_e_tag_filter_del_parsed(
13248 void *parsed_result,
13249 __attribute__((unused)) struct cmdline *cl,
13250 __attribute__((unused)) void *data)
13252 struct cmd_config_e_tag_result *res = parsed_result;
13253 struct rte_eth_l2_tunnel_conf entry;
13256 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13259 if (res->e_tag_id_val > 0x3fff) {
13260 printf("e-tag-id must be less than 0x3fff.\n");
13264 ret = rte_eth_dev_filter_supported(res->port_id,
13265 RTE_ETH_FILTER_L2_TUNNEL);
13267 printf("E-tag filter is not supported on port %u.\n",
13272 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13273 entry.tunnel_id = res->e_tag_id_val;
13275 ret = rte_eth_dev_filter_ctrl(res->port_id,
13276 RTE_ETH_FILTER_L2_TUNNEL,
13277 RTE_ETH_FILTER_DELETE,
13280 printf("E-tag filter programming error: (%s)\n",
13284 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13285 .f = cmd_config_e_tag_filter_del_parsed,
13287 .help_str = "E-tag ... : E-tag filter delete",
13289 (void *)&cmd_config_e_tag_e_tag,
13290 (void *)&cmd_config_e_tag_set,
13291 (void *)&cmd_config_e_tag_filter,
13292 (void *)&cmd_config_e_tag_del,
13293 (void *)&cmd_config_e_tag_e_tag_id,
13294 (void *)&cmd_config_e_tag_e_tag_id_val,
13295 (void *)&cmd_config_e_tag_port,
13296 (void *)&cmd_config_e_tag_port_id,
13301 /* vf vlan anti spoof configuration */
13303 /* Common result structure for vf vlan anti spoof */
13304 struct cmd_vf_vlan_anti_spoof_result {
13305 cmdline_fixed_string_t set;
13306 cmdline_fixed_string_t vf;
13307 cmdline_fixed_string_t vlan;
13308 cmdline_fixed_string_t antispoof;
13311 cmdline_fixed_string_t on_off;
13314 /* Common CLI fields for vf vlan anti spoof enable disable */
13315 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13316 TOKEN_STRING_INITIALIZER
13317 (struct cmd_vf_vlan_anti_spoof_result,
13319 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13320 TOKEN_STRING_INITIALIZER
13321 (struct cmd_vf_vlan_anti_spoof_result,
13323 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13324 TOKEN_STRING_INITIALIZER
13325 (struct cmd_vf_vlan_anti_spoof_result,
13327 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13328 TOKEN_STRING_INITIALIZER
13329 (struct cmd_vf_vlan_anti_spoof_result,
13330 antispoof, "antispoof");
13331 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13332 TOKEN_NUM_INITIALIZER
13333 (struct cmd_vf_vlan_anti_spoof_result,
13335 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13336 TOKEN_NUM_INITIALIZER
13337 (struct cmd_vf_vlan_anti_spoof_result,
13339 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13340 TOKEN_STRING_INITIALIZER
13341 (struct cmd_vf_vlan_anti_spoof_result,
13345 cmd_set_vf_vlan_anti_spoof_parsed(
13346 void *parsed_result,
13347 __attribute__((unused)) struct cmdline *cl,
13348 __attribute__((unused)) void *data)
13350 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13351 int ret = -ENOTSUP;
13353 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13355 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13358 #ifdef RTE_LIBRTE_IXGBE_PMD
13359 if (ret == -ENOTSUP)
13360 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13361 res->vf_id, is_on);
13363 #ifdef RTE_LIBRTE_I40E_PMD
13364 if (ret == -ENOTSUP)
13365 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13366 res->vf_id, is_on);
13368 #ifdef RTE_LIBRTE_BNXT_PMD
13369 if (ret == -ENOTSUP)
13370 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13371 res->vf_id, is_on);
13378 printf("invalid vf_id %d\n", res->vf_id);
13381 printf("invalid port_id %d\n", res->port_id);
13384 printf("function not implemented\n");
13387 printf("programming error: (%s)\n", strerror(-ret));
13391 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13392 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13394 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13396 (void *)&cmd_vf_vlan_anti_spoof_set,
13397 (void *)&cmd_vf_vlan_anti_spoof_vf,
13398 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13399 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13400 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13401 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13402 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13407 /* vf mac anti spoof configuration */
13409 /* Common result structure for vf mac anti spoof */
13410 struct cmd_vf_mac_anti_spoof_result {
13411 cmdline_fixed_string_t set;
13412 cmdline_fixed_string_t vf;
13413 cmdline_fixed_string_t mac;
13414 cmdline_fixed_string_t antispoof;
13417 cmdline_fixed_string_t on_off;
13420 /* Common CLI fields for vf mac anti spoof enable disable */
13421 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13422 TOKEN_STRING_INITIALIZER
13423 (struct cmd_vf_mac_anti_spoof_result,
13425 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13426 TOKEN_STRING_INITIALIZER
13427 (struct cmd_vf_mac_anti_spoof_result,
13429 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13430 TOKEN_STRING_INITIALIZER
13431 (struct cmd_vf_mac_anti_spoof_result,
13433 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13434 TOKEN_STRING_INITIALIZER
13435 (struct cmd_vf_mac_anti_spoof_result,
13436 antispoof, "antispoof");
13437 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13438 TOKEN_NUM_INITIALIZER
13439 (struct cmd_vf_mac_anti_spoof_result,
13441 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13442 TOKEN_NUM_INITIALIZER
13443 (struct cmd_vf_mac_anti_spoof_result,
13445 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13446 TOKEN_STRING_INITIALIZER
13447 (struct cmd_vf_mac_anti_spoof_result,
13451 cmd_set_vf_mac_anti_spoof_parsed(
13452 void *parsed_result,
13453 __attribute__((unused)) struct cmdline *cl,
13454 __attribute__((unused)) void *data)
13456 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13457 int ret = -ENOTSUP;
13459 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13461 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13464 #ifdef RTE_LIBRTE_IXGBE_PMD
13465 if (ret == -ENOTSUP)
13466 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13467 res->vf_id, is_on);
13469 #ifdef RTE_LIBRTE_I40E_PMD
13470 if (ret == -ENOTSUP)
13471 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13472 res->vf_id, is_on);
13474 #ifdef RTE_LIBRTE_BNXT_PMD
13475 if (ret == -ENOTSUP)
13476 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13477 res->vf_id, is_on);
13484 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13487 printf("invalid port_id %d\n", res->port_id);
13490 printf("function not implemented\n");
13493 printf("programming error: (%s)\n", strerror(-ret));
13497 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13498 .f = cmd_set_vf_mac_anti_spoof_parsed,
13500 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13502 (void *)&cmd_vf_mac_anti_spoof_set,
13503 (void *)&cmd_vf_mac_anti_spoof_vf,
13504 (void *)&cmd_vf_mac_anti_spoof_mac,
13505 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13506 (void *)&cmd_vf_mac_anti_spoof_port_id,
13507 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13508 (void *)&cmd_vf_mac_anti_spoof_on_off,
13513 /* vf vlan strip queue configuration */
13515 /* Common result structure for vf mac anti spoof */
13516 struct cmd_vf_vlan_stripq_result {
13517 cmdline_fixed_string_t set;
13518 cmdline_fixed_string_t vf;
13519 cmdline_fixed_string_t vlan;
13520 cmdline_fixed_string_t stripq;
13523 cmdline_fixed_string_t on_off;
13526 /* Common CLI fields for vf vlan strip enable disable */
13527 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13528 TOKEN_STRING_INITIALIZER
13529 (struct cmd_vf_vlan_stripq_result,
13531 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13532 TOKEN_STRING_INITIALIZER
13533 (struct cmd_vf_vlan_stripq_result,
13535 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13536 TOKEN_STRING_INITIALIZER
13537 (struct cmd_vf_vlan_stripq_result,
13539 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13540 TOKEN_STRING_INITIALIZER
13541 (struct cmd_vf_vlan_stripq_result,
13543 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13544 TOKEN_NUM_INITIALIZER
13545 (struct cmd_vf_vlan_stripq_result,
13547 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13548 TOKEN_NUM_INITIALIZER
13549 (struct cmd_vf_vlan_stripq_result,
13551 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13552 TOKEN_STRING_INITIALIZER
13553 (struct cmd_vf_vlan_stripq_result,
13557 cmd_set_vf_vlan_stripq_parsed(
13558 void *parsed_result,
13559 __attribute__((unused)) struct cmdline *cl,
13560 __attribute__((unused)) void *data)
13562 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13563 int ret = -ENOTSUP;
13565 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13567 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13570 #ifdef RTE_LIBRTE_IXGBE_PMD
13571 if (ret == -ENOTSUP)
13572 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13573 res->vf_id, is_on);
13575 #ifdef RTE_LIBRTE_I40E_PMD
13576 if (ret == -ENOTSUP)
13577 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13578 res->vf_id, is_on);
13580 #ifdef RTE_LIBRTE_BNXT_PMD
13581 if (ret == -ENOTSUP)
13582 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13583 res->vf_id, is_on);
13590 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13593 printf("invalid port_id %d\n", res->port_id);
13596 printf("function not implemented\n");
13599 printf("programming error: (%s)\n", strerror(-ret));
13603 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13604 .f = cmd_set_vf_vlan_stripq_parsed,
13606 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13608 (void *)&cmd_vf_vlan_stripq_set,
13609 (void *)&cmd_vf_vlan_stripq_vf,
13610 (void *)&cmd_vf_vlan_stripq_vlan,
13611 (void *)&cmd_vf_vlan_stripq_stripq,
13612 (void *)&cmd_vf_vlan_stripq_port_id,
13613 (void *)&cmd_vf_vlan_stripq_vf_id,
13614 (void *)&cmd_vf_vlan_stripq_on_off,
13619 /* vf vlan insert configuration */
13621 /* Common result structure for vf vlan insert */
13622 struct cmd_vf_vlan_insert_result {
13623 cmdline_fixed_string_t set;
13624 cmdline_fixed_string_t vf;
13625 cmdline_fixed_string_t vlan;
13626 cmdline_fixed_string_t insert;
13632 /* Common CLI fields for vf vlan insert enable disable */
13633 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13634 TOKEN_STRING_INITIALIZER
13635 (struct cmd_vf_vlan_insert_result,
13637 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13638 TOKEN_STRING_INITIALIZER
13639 (struct cmd_vf_vlan_insert_result,
13641 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13642 TOKEN_STRING_INITIALIZER
13643 (struct cmd_vf_vlan_insert_result,
13645 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13646 TOKEN_STRING_INITIALIZER
13647 (struct cmd_vf_vlan_insert_result,
13649 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13650 TOKEN_NUM_INITIALIZER
13651 (struct cmd_vf_vlan_insert_result,
13653 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13654 TOKEN_NUM_INITIALIZER
13655 (struct cmd_vf_vlan_insert_result,
13657 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13658 TOKEN_NUM_INITIALIZER
13659 (struct cmd_vf_vlan_insert_result,
13663 cmd_set_vf_vlan_insert_parsed(
13664 void *parsed_result,
13665 __attribute__((unused)) struct cmdline *cl,
13666 __attribute__((unused)) void *data)
13668 struct cmd_vf_vlan_insert_result *res = parsed_result;
13669 int ret = -ENOTSUP;
13671 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13674 #ifdef RTE_LIBRTE_IXGBE_PMD
13675 if (ret == -ENOTSUP)
13676 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13679 #ifdef RTE_LIBRTE_I40E_PMD
13680 if (ret == -ENOTSUP)
13681 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13684 #ifdef RTE_LIBRTE_BNXT_PMD
13685 if (ret == -ENOTSUP)
13686 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13694 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13697 printf("invalid port_id %d\n", res->port_id);
13700 printf("function not implemented\n");
13703 printf("programming error: (%s)\n", strerror(-ret));
13707 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13708 .f = cmd_set_vf_vlan_insert_parsed,
13710 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13712 (void *)&cmd_vf_vlan_insert_set,
13713 (void *)&cmd_vf_vlan_insert_vf,
13714 (void *)&cmd_vf_vlan_insert_vlan,
13715 (void *)&cmd_vf_vlan_insert_insert,
13716 (void *)&cmd_vf_vlan_insert_port_id,
13717 (void *)&cmd_vf_vlan_insert_vf_id,
13718 (void *)&cmd_vf_vlan_insert_vlan_id,
13723 /* tx loopback configuration */
13725 /* Common result structure for tx loopback */
13726 struct cmd_tx_loopback_result {
13727 cmdline_fixed_string_t set;
13728 cmdline_fixed_string_t tx;
13729 cmdline_fixed_string_t loopback;
13731 cmdline_fixed_string_t on_off;
13734 /* Common CLI fields for tx loopback enable disable */
13735 cmdline_parse_token_string_t cmd_tx_loopback_set =
13736 TOKEN_STRING_INITIALIZER
13737 (struct cmd_tx_loopback_result,
13739 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13740 TOKEN_STRING_INITIALIZER
13741 (struct cmd_tx_loopback_result,
13743 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_tx_loopback_result,
13746 loopback, "loopback");
13747 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13748 TOKEN_NUM_INITIALIZER
13749 (struct cmd_tx_loopback_result,
13751 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13752 TOKEN_STRING_INITIALIZER
13753 (struct cmd_tx_loopback_result,
13757 cmd_set_tx_loopback_parsed(
13758 void *parsed_result,
13759 __attribute__((unused)) struct cmdline *cl,
13760 __attribute__((unused)) void *data)
13762 struct cmd_tx_loopback_result *res = parsed_result;
13763 int ret = -ENOTSUP;
13765 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13767 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13770 #ifdef RTE_LIBRTE_IXGBE_PMD
13771 if (ret == -ENOTSUP)
13772 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13774 #ifdef RTE_LIBRTE_I40E_PMD
13775 if (ret == -ENOTSUP)
13776 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13778 #ifdef RTE_LIBRTE_BNXT_PMD
13779 if (ret == -ENOTSUP)
13780 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13782 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13783 if (ret == -ENOTSUP)
13784 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13791 printf("invalid is_on %d\n", is_on);
13794 printf("invalid port_id %d\n", res->port_id);
13797 printf("function not implemented\n");
13800 printf("programming error: (%s)\n", strerror(-ret));
13804 cmdline_parse_inst_t cmd_set_tx_loopback = {
13805 .f = cmd_set_tx_loopback_parsed,
13807 .help_str = "set tx loopback <port_id> on|off",
13809 (void *)&cmd_tx_loopback_set,
13810 (void *)&cmd_tx_loopback_tx,
13811 (void *)&cmd_tx_loopback_loopback,
13812 (void *)&cmd_tx_loopback_port_id,
13813 (void *)&cmd_tx_loopback_on_off,
13818 /* all queues drop enable configuration */
13820 /* Common result structure for all queues drop enable */
13821 struct cmd_all_queues_drop_en_result {
13822 cmdline_fixed_string_t set;
13823 cmdline_fixed_string_t all;
13824 cmdline_fixed_string_t queues;
13825 cmdline_fixed_string_t drop;
13827 cmdline_fixed_string_t on_off;
13830 /* Common CLI fields for tx loopback enable disable */
13831 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13832 TOKEN_STRING_INITIALIZER
13833 (struct cmd_all_queues_drop_en_result,
13835 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13836 TOKEN_STRING_INITIALIZER
13837 (struct cmd_all_queues_drop_en_result,
13839 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13840 TOKEN_STRING_INITIALIZER
13841 (struct cmd_all_queues_drop_en_result,
13843 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13844 TOKEN_STRING_INITIALIZER
13845 (struct cmd_all_queues_drop_en_result,
13847 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13848 TOKEN_NUM_INITIALIZER
13849 (struct cmd_all_queues_drop_en_result,
13851 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13852 TOKEN_STRING_INITIALIZER
13853 (struct cmd_all_queues_drop_en_result,
13857 cmd_set_all_queues_drop_en_parsed(
13858 void *parsed_result,
13859 __attribute__((unused)) struct cmdline *cl,
13860 __attribute__((unused)) void *data)
13862 struct cmd_all_queues_drop_en_result *res = parsed_result;
13863 int ret = -ENOTSUP;
13864 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13869 #ifdef RTE_LIBRTE_IXGBE_PMD
13870 if (ret == -ENOTSUP)
13871 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13873 #ifdef RTE_LIBRTE_BNXT_PMD
13874 if (ret == -ENOTSUP)
13875 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13881 printf("invalid is_on %d\n", is_on);
13884 printf("invalid port_id %d\n", res->port_id);
13887 printf("function not implemented\n");
13890 printf("programming error: (%s)\n", strerror(-ret));
13894 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13895 .f = cmd_set_all_queues_drop_en_parsed,
13897 .help_str = "set all queues drop <port_id> on|off",
13899 (void *)&cmd_all_queues_drop_en_set,
13900 (void *)&cmd_all_queues_drop_en_all,
13901 (void *)&cmd_all_queues_drop_en_queues,
13902 (void *)&cmd_all_queues_drop_en_drop,
13903 (void *)&cmd_all_queues_drop_en_port_id,
13904 (void *)&cmd_all_queues_drop_en_on_off,
13909 /* vf split drop enable configuration */
13911 /* Common result structure for vf split drop enable */
13912 struct cmd_vf_split_drop_en_result {
13913 cmdline_fixed_string_t set;
13914 cmdline_fixed_string_t vf;
13915 cmdline_fixed_string_t split;
13916 cmdline_fixed_string_t drop;
13919 cmdline_fixed_string_t on_off;
13922 /* Common CLI fields for vf split drop enable disable */
13923 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13924 TOKEN_STRING_INITIALIZER
13925 (struct cmd_vf_split_drop_en_result,
13927 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13928 TOKEN_STRING_INITIALIZER
13929 (struct cmd_vf_split_drop_en_result,
13931 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13932 TOKEN_STRING_INITIALIZER
13933 (struct cmd_vf_split_drop_en_result,
13935 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13936 TOKEN_STRING_INITIALIZER
13937 (struct cmd_vf_split_drop_en_result,
13939 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13940 TOKEN_NUM_INITIALIZER
13941 (struct cmd_vf_split_drop_en_result,
13943 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13944 TOKEN_NUM_INITIALIZER
13945 (struct cmd_vf_split_drop_en_result,
13947 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13948 TOKEN_STRING_INITIALIZER
13949 (struct cmd_vf_split_drop_en_result,
13953 cmd_set_vf_split_drop_en_parsed(
13954 void *parsed_result,
13955 __attribute__((unused)) struct cmdline *cl,
13956 __attribute__((unused)) void *data)
13958 struct cmd_vf_split_drop_en_result *res = parsed_result;
13959 int ret = -ENOTSUP;
13960 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13962 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13965 #ifdef RTE_LIBRTE_IXGBE_PMD
13966 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13973 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13976 printf("invalid port_id %d\n", res->port_id);
13979 printf("not supported on port %d\n", res->port_id);
13982 printf("programming error: (%s)\n", strerror(-ret));
13986 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13987 .f = cmd_set_vf_split_drop_en_parsed,
13989 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13991 (void *)&cmd_vf_split_drop_en_set,
13992 (void *)&cmd_vf_split_drop_en_vf,
13993 (void *)&cmd_vf_split_drop_en_split,
13994 (void *)&cmd_vf_split_drop_en_drop,
13995 (void *)&cmd_vf_split_drop_en_port_id,
13996 (void *)&cmd_vf_split_drop_en_vf_id,
13997 (void *)&cmd_vf_split_drop_en_on_off,
14002 /* vf mac address configuration */
14004 /* Common result structure for vf mac address */
14005 struct cmd_set_vf_mac_addr_result {
14006 cmdline_fixed_string_t set;
14007 cmdline_fixed_string_t vf;
14008 cmdline_fixed_string_t mac;
14009 cmdline_fixed_string_t addr;
14012 struct rte_ether_addr mac_addr;
14016 /* Common CLI fields for vf split drop enable disable */
14017 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14018 TOKEN_STRING_INITIALIZER
14019 (struct cmd_set_vf_mac_addr_result,
14021 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14022 TOKEN_STRING_INITIALIZER
14023 (struct cmd_set_vf_mac_addr_result,
14025 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14026 TOKEN_STRING_INITIALIZER
14027 (struct cmd_set_vf_mac_addr_result,
14029 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14030 TOKEN_STRING_INITIALIZER
14031 (struct cmd_set_vf_mac_addr_result,
14033 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14034 TOKEN_NUM_INITIALIZER
14035 (struct cmd_set_vf_mac_addr_result,
14037 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14038 TOKEN_NUM_INITIALIZER
14039 (struct cmd_set_vf_mac_addr_result,
14041 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14042 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14046 cmd_set_vf_mac_addr_parsed(
14047 void *parsed_result,
14048 __attribute__((unused)) struct cmdline *cl,
14049 __attribute__((unused)) void *data)
14051 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14052 int ret = -ENOTSUP;
14054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14057 #ifdef RTE_LIBRTE_IXGBE_PMD
14058 if (ret == -ENOTSUP)
14059 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14062 #ifdef RTE_LIBRTE_I40E_PMD
14063 if (ret == -ENOTSUP)
14064 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14067 #ifdef RTE_LIBRTE_BNXT_PMD
14068 if (ret == -ENOTSUP)
14069 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14077 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14080 printf("invalid port_id %d\n", res->port_id);
14083 printf("function not implemented\n");
14086 printf("programming error: (%s)\n", strerror(-ret));
14090 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14091 .f = cmd_set_vf_mac_addr_parsed,
14093 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14095 (void *)&cmd_set_vf_mac_addr_set,
14096 (void *)&cmd_set_vf_mac_addr_vf,
14097 (void *)&cmd_set_vf_mac_addr_mac,
14098 (void *)&cmd_set_vf_mac_addr_addr,
14099 (void *)&cmd_set_vf_mac_addr_port_id,
14100 (void *)&cmd_set_vf_mac_addr_vf_id,
14101 (void *)&cmd_set_vf_mac_addr_mac_addr,
14106 /* MACsec configuration */
14108 /* Common result structure for MACsec offload enable */
14109 struct cmd_macsec_offload_on_result {
14110 cmdline_fixed_string_t set;
14111 cmdline_fixed_string_t macsec;
14112 cmdline_fixed_string_t offload;
14114 cmdline_fixed_string_t on;
14115 cmdline_fixed_string_t encrypt;
14116 cmdline_fixed_string_t en_on_off;
14117 cmdline_fixed_string_t replay_protect;
14118 cmdline_fixed_string_t rp_on_off;
14121 /* Common CLI fields for MACsec offload disable */
14122 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14123 TOKEN_STRING_INITIALIZER
14124 (struct cmd_macsec_offload_on_result,
14126 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14127 TOKEN_STRING_INITIALIZER
14128 (struct cmd_macsec_offload_on_result,
14130 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14131 TOKEN_STRING_INITIALIZER
14132 (struct cmd_macsec_offload_on_result,
14133 offload, "offload");
14134 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14135 TOKEN_NUM_INITIALIZER
14136 (struct cmd_macsec_offload_on_result,
14138 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14139 TOKEN_STRING_INITIALIZER
14140 (struct cmd_macsec_offload_on_result,
14142 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14143 TOKEN_STRING_INITIALIZER
14144 (struct cmd_macsec_offload_on_result,
14145 encrypt, "encrypt");
14146 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14147 TOKEN_STRING_INITIALIZER
14148 (struct cmd_macsec_offload_on_result,
14149 en_on_off, "on#off");
14150 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14151 TOKEN_STRING_INITIALIZER
14152 (struct cmd_macsec_offload_on_result,
14153 replay_protect, "replay-protect");
14154 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14155 TOKEN_STRING_INITIALIZER
14156 (struct cmd_macsec_offload_on_result,
14157 rp_on_off, "on#off");
14160 cmd_set_macsec_offload_on_parsed(
14161 void *parsed_result,
14162 __attribute__((unused)) struct cmdline *cl,
14163 __attribute__((unused)) void *data)
14165 struct cmd_macsec_offload_on_result *res = parsed_result;
14166 int ret = -ENOTSUP;
14167 portid_t port_id = res->port_id;
14168 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14169 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14170 struct rte_eth_dev_info dev_info;
14172 if (port_id_is_invalid(port_id, ENABLED_WARN))
14174 if (!port_is_stopped(port_id)) {
14175 printf("Please stop port %d first\n", port_id);
14179 rte_eth_dev_info_get(port_id, &dev_info);
14180 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14181 #ifdef RTE_LIBRTE_IXGBE_PMD
14182 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14190 ports[port_id].dev_conf.txmode.offloads |=
14191 DEV_TX_OFFLOAD_MACSEC_INSERT;
14192 cmd_reconfig_device_queue(port_id, 1, 1);
14195 printf("invalid port_id %d\n", port_id);
14198 printf("not supported on port %d\n", port_id);
14201 printf("programming error: (%s)\n", strerror(-ret));
14205 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14206 .f = cmd_set_macsec_offload_on_parsed,
14208 .help_str = "set macsec offload <port_id> on "
14209 "encrypt on|off replay-protect on|off",
14211 (void *)&cmd_macsec_offload_on_set,
14212 (void *)&cmd_macsec_offload_on_macsec,
14213 (void *)&cmd_macsec_offload_on_offload,
14214 (void *)&cmd_macsec_offload_on_port_id,
14215 (void *)&cmd_macsec_offload_on_on,
14216 (void *)&cmd_macsec_offload_on_encrypt,
14217 (void *)&cmd_macsec_offload_on_en_on_off,
14218 (void *)&cmd_macsec_offload_on_replay_protect,
14219 (void *)&cmd_macsec_offload_on_rp_on_off,
14224 /* Common result structure for MACsec offload disable */
14225 struct cmd_macsec_offload_off_result {
14226 cmdline_fixed_string_t set;
14227 cmdline_fixed_string_t macsec;
14228 cmdline_fixed_string_t offload;
14230 cmdline_fixed_string_t off;
14233 /* Common CLI fields for MACsec offload disable */
14234 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14235 TOKEN_STRING_INITIALIZER
14236 (struct cmd_macsec_offload_off_result,
14238 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14239 TOKEN_STRING_INITIALIZER
14240 (struct cmd_macsec_offload_off_result,
14242 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14243 TOKEN_STRING_INITIALIZER
14244 (struct cmd_macsec_offload_off_result,
14245 offload, "offload");
14246 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14247 TOKEN_NUM_INITIALIZER
14248 (struct cmd_macsec_offload_off_result,
14250 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14251 TOKEN_STRING_INITIALIZER
14252 (struct cmd_macsec_offload_off_result,
14256 cmd_set_macsec_offload_off_parsed(
14257 void *parsed_result,
14258 __attribute__((unused)) struct cmdline *cl,
14259 __attribute__((unused)) void *data)
14261 struct cmd_macsec_offload_off_result *res = parsed_result;
14262 int ret = -ENOTSUP;
14263 struct rte_eth_dev_info dev_info;
14264 portid_t port_id = res->port_id;
14266 if (port_id_is_invalid(port_id, ENABLED_WARN))
14268 if (!port_is_stopped(port_id)) {
14269 printf("Please stop port %d first\n", port_id);
14273 rte_eth_dev_info_get(port_id, &dev_info);
14274 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14275 #ifdef RTE_LIBRTE_IXGBE_PMD
14276 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14281 ports[port_id].dev_conf.txmode.offloads &=
14282 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14283 cmd_reconfig_device_queue(port_id, 1, 1);
14286 printf("invalid port_id %d\n", port_id);
14289 printf("not supported on port %d\n", port_id);
14292 printf("programming error: (%s)\n", strerror(-ret));
14296 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14297 .f = cmd_set_macsec_offload_off_parsed,
14299 .help_str = "set macsec offload <port_id> off",
14301 (void *)&cmd_macsec_offload_off_set,
14302 (void *)&cmd_macsec_offload_off_macsec,
14303 (void *)&cmd_macsec_offload_off_offload,
14304 (void *)&cmd_macsec_offload_off_port_id,
14305 (void *)&cmd_macsec_offload_off_off,
14310 /* Common result structure for MACsec secure connection configure */
14311 struct cmd_macsec_sc_result {
14312 cmdline_fixed_string_t set;
14313 cmdline_fixed_string_t macsec;
14314 cmdline_fixed_string_t sc;
14315 cmdline_fixed_string_t tx_rx;
14317 struct rte_ether_addr mac;
14321 /* Common CLI fields for MACsec secure connection configure */
14322 cmdline_parse_token_string_t cmd_macsec_sc_set =
14323 TOKEN_STRING_INITIALIZER
14324 (struct cmd_macsec_sc_result,
14326 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14327 TOKEN_STRING_INITIALIZER
14328 (struct cmd_macsec_sc_result,
14330 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14331 TOKEN_STRING_INITIALIZER
14332 (struct cmd_macsec_sc_result,
14334 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14335 TOKEN_STRING_INITIALIZER
14336 (struct cmd_macsec_sc_result,
14338 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14339 TOKEN_NUM_INITIALIZER
14340 (struct cmd_macsec_sc_result,
14342 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14343 TOKEN_ETHERADDR_INITIALIZER
14344 (struct cmd_macsec_sc_result,
14346 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14347 TOKEN_NUM_INITIALIZER
14348 (struct cmd_macsec_sc_result,
14352 cmd_set_macsec_sc_parsed(
14353 void *parsed_result,
14354 __attribute__((unused)) struct cmdline *cl,
14355 __attribute__((unused)) void *data)
14357 struct cmd_macsec_sc_result *res = parsed_result;
14358 int ret = -ENOTSUP;
14359 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14361 #ifdef RTE_LIBRTE_IXGBE_PMD
14363 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14364 res->mac.addr_bytes) :
14365 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14366 res->mac.addr_bytes, res->pi);
14368 RTE_SET_USED(is_tx);
14374 printf("invalid port_id %d\n", res->port_id);
14377 printf("not supported on port %d\n", res->port_id);
14380 printf("programming error: (%s)\n", strerror(-ret));
14384 cmdline_parse_inst_t cmd_set_macsec_sc = {
14385 .f = cmd_set_macsec_sc_parsed,
14387 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14389 (void *)&cmd_macsec_sc_set,
14390 (void *)&cmd_macsec_sc_macsec,
14391 (void *)&cmd_macsec_sc_sc,
14392 (void *)&cmd_macsec_sc_tx_rx,
14393 (void *)&cmd_macsec_sc_port_id,
14394 (void *)&cmd_macsec_sc_mac,
14395 (void *)&cmd_macsec_sc_pi,
14400 /* Common result structure for MACsec secure connection configure */
14401 struct cmd_macsec_sa_result {
14402 cmdline_fixed_string_t set;
14403 cmdline_fixed_string_t macsec;
14404 cmdline_fixed_string_t sa;
14405 cmdline_fixed_string_t tx_rx;
14410 cmdline_fixed_string_t key;
14413 /* Common CLI fields for MACsec secure connection configure */
14414 cmdline_parse_token_string_t cmd_macsec_sa_set =
14415 TOKEN_STRING_INITIALIZER
14416 (struct cmd_macsec_sa_result,
14418 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14419 TOKEN_STRING_INITIALIZER
14420 (struct cmd_macsec_sa_result,
14422 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14423 TOKEN_STRING_INITIALIZER
14424 (struct cmd_macsec_sa_result,
14426 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14427 TOKEN_STRING_INITIALIZER
14428 (struct cmd_macsec_sa_result,
14430 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14431 TOKEN_NUM_INITIALIZER
14432 (struct cmd_macsec_sa_result,
14434 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14435 TOKEN_NUM_INITIALIZER
14436 (struct cmd_macsec_sa_result,
14438 cmdline_parse_token_num_t cmd_macsec_sa_an =
14439 TOKEN_NUM_INITIALIZER
14440 (struct cmd_macsec_sa_result,
14442 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14443 TOKEN_NUM_INITIALIZER
14444 (struct cmd_macsec_sa_result,
14446 cmdline_parse_token_string_t cmd_macsec_sa_key =
14447 TOKEN_STRING_INITIALIZER
14448 (struct cmd_macsec_sa_result,
14452 cmd_set_macsec_sa_parsed(
14453 void *parsed_result,
14454 __attribute__((unused)) struct cmdline *cl,
14455 __attribute__((unused)) void *data)
14457 struct cmd_macsec_sa_result *res = parsed_result;
14458 int ret = -ENOTSUP;
14459 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14460 uint8_t key[16] = { 0 };
14466 key_len = strlen(res->key) / 2;
14470 for (i = 0; i < key_len; i++) {
14471 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14474 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14477 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14480 #ifdef RTE_LIBRTE_IXGBE_PMD
14482 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14483 res->idx, res->an, res->pn, key) :
14484 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14485 res->idx, res->an, res->pn, key);
14487 RTE_SET_USED(is_tx);
14494 printf("invalid idx %d or an %d\n", res->idx, res->an);
14497 printf("invalid port_id %d\n", res->port_id);
14500 printf("not supported on port %d\n", res->port_id);
14503 printf("programming error: (%s)\n", strerror(-ret));
14507 cmdline_parse_inst_t cmd_set_macsec_sa = {
14508 .f = cmd_set_macsec_sa_parsed,
14510 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14512 (void *)&cmd_macsec_sa_set,
14513 (void *)&cmd_macsec_sa_macsec,
14514 (void *)&cmd_macsec_sa_sa,
14515 (void *)&cmd_macsec_sa_tx_rx,
14516 (void *)&cmd_macsec_sa_port_id,
14517 (void *)&cmd_macsec_sa_idx,
14518 (void *)&cmd_macsec_sa_an,
14519 (void *)&cmd_macsec_sa_pn,
14520 (void *)&cmd_macsec_sa_key,
14525 /* VF unicast promiscuous mode configuration */
14527 /* Common result structure for VF unicast promiscuous mode */
14528 struct cmd_vf_promisc_result {
14529 cmdline_fixed_string_t set;
14530 cmdline_fixed_string_t vf;
14531 cmdline_fixed_string_t promisc;
14534 cmdline_fixed_string_t on_off;
14537 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14538 cmdline_parse_token_string_t cmd_vf_promisc_set =
14539 TOKEN_STRING_INITIALIZER
14540 (struct cmd_vf_promisc_result,
14542 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14543 TOKEN_STRING_INITIALIZER
14544 (struct cmd_vf_promisc_result,
14546 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14547 TOKEN_STRING_INITIALIZER
14548 (struct cmd_vf_promisc_result,
14549 promisc, "promisc");
14550 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14551 TOKEN_NUM_INITIALIZER
14552 (struct cmd_vf_promisc_result,
14554 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14555 TOKEN_NUM_INITIALIZER
14556 (struct cmd_vf_promisc_result,
14558 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14559 TOKEN_STRING_INITIALIZER
14560 (struct cmd_vf_promisc_result,
14564 cmd_set_vf_promisc_parsed(
14565 void *parsed_result,
14566 __attribute__((unused)) struct cmdline *cl,
14567 __attribute__((unused)) void *data)
14569 struct cmd_vf_promisc_result *res = parsed_result;
14570 int ret = -ENOTSUP;
14572 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14577 #ifdef RTE_LIBRTE_I40E_PMD
14578 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14579 res->vf_id, is_on);
14586 printf("invalid vf_id %d\n", res->vf_id);
14589 printf("invalid port_id %d\n", res->port_id);
14592 printf("function not implemented\n");
14595 printf("programming error: (%s)\n", strerror(-ret));
14599 cmdline_parse_inst_t cmd_set_vf_promisc = {
14600 .f = cmd_set_vf_promisc_parsed,
14602 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14603 "Set unicast promiscuous mode for a VF from the PF",
14605 (void *)&cmd_vf_promisc_set,
14606 (void *)&cmd_vf_promisc_vf,
14607 (void *)&cmd_vf_promisc_promisc,
14608 (void *)&cmd_vf_promisc_port_id,
14609 (void *)&cmd_vf_promisc_vf_id,
14610 (void *)&cmd_vf_promisc_on_off,
14615 /* VF multicast promiscuous mode configuration */
14617 /* Common result structure for VF multicast promiscuous mode */
14618 struct cmd_vf_allmulti_result {
14619 cmdline_fixed_string_t set;
14620 cmdline_fixed_string_t vf;
14621 cmdline_fixed_string_t allmulti;
14624 cmdline_fixed_string_t on_off;
14627 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14628 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14629 TOKEN_STRING_INITIALIZER
14630 (struct cmd_vf_allmulti_result,
14632 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14633 TOKEN_STRING_INITIALIZER
14634 (struct cmd_vf_allmulti_result,
14636 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14637 TOKEN_STRING_INITIALIZER
14638 (struct cmd_vf_allmulti_result,
14639 allmulti, "allmulti");
14640 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14641 TOKEN_NUM_INITIALIZER
14642 (struct cmd_vf_allmulti_result,
14644 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14645 TOKEN_NUM_INITIALIZER
14646 (struct cmd_vf_allmulti_result,
14648 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14649 TOKEN_STRING_INITIALIZER
14650 (struct cmd_vf_allmulti_result,
14654 cmd_set_vf_allmulti_parsed(
14655 void *parsed_result,
14656 __attribute__((unused)) struct cmdline *cl,
14657 __attribute__((unused)) void *data)
14659 struct cmd_vf_allmulti_result *res = parsed_result;
14660 int ret = -ENOTSUP;
14662 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14664 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14667 #ifdef RTE_LIBRTE_I40E_PMD
14668 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14669 res->vf_id, is_on);
14676 printf("invalid vf_id %d\n", res->vf_id);
14679 printf("invalid port_id %d\n", res->port_id);
14682 printf("function not implemented\n");
14685 printf("programming error: (%s)\n", strerror(-ret));
14689 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14690 .f = cmd_set_vf_allmulti_parsed,
14692 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14693 "Set multicast promiscuous mode for a VF from the PF",
14695 (void *)&cmd_vf_allmulti_set,
14696 (void *)&cmd_vf_allmulti_vf,
14697 (void *)&cmd_vf_allmulti_allmulti,
14698 (void *)&cmd_vf_allmulti_port_id,
14699 (void *)&cmd_vf_allmulti_vf_id,
14700 (void *)&cmd_vf_allmulti_on_off,
14705 /* vf broadcast mode configuration */
14707 /* Common result structure for vf broadcast */
14708 struct cmd_set_vf_broadcast_result {
14709 cmdline_fixed_string_t set;
14710 cmdline_fixed_string_t vf;
14711 cmdline_fixed_string_t broadcast;
14714 cmdline_fixed_string_t on_off;
14717 /* Common CLI fields for vf broadcast enable disable */
14718 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14719 TOKEN_STRING_INITIALIZER
14720 (struct cmd_set_vf_broadcast_result,
14722 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14723 TOKEN_STRING_INITIALIZER
14724 (struct cmd_set_vf_broadcast_result,
14726 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14727 TOKEN_STRING_INITIALIZER
14728 (struct cmd_set_vf_broadcast_result,
14729 broadcast, "broadcast");
14730 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14731 TOKEN_NUM_INITIALIZER
14732 (struct cmd_set_vf_broadcast_result,
14734 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14735 TOKEN_NUM_INITIALIZER
14736 (struct cmd_set_vf_broadcast_result,
14738 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14739 TOKEN_STRING_INITIALIZER
14740 (struct cmd_set_vf_broadcast_result,
14744 cmd_set_vf_broadcast_parsed(
14745 void *parsed_result,
14746 __attribute__((unused)) struct cmdline *cl,
14747 __attribute__((unused)) void *data)
14749 struct cmd_set_vf_broadcast_result *res = parsed_result;
14750 int ret = -ENOTSUP;
14752 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14754 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14757 #ifdef RTE_LIBRTE_I40E_PMD
14758 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14759 res->vf_id, is_on);
14766 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14769 printf("invalid port_id %d\n", res->port_id);
14772 printf("function not implemented\n");
14775 printf("programming error: (%s)\n", strerror(-ret));
14779 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14780 .f = cmd_set_vf_broadcast_parsed,
14782 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14784 (void *)&cmd_set_vf_broadcast_set,
14785 (void *)&cmd_set_vf_broadcast_vf,
14786 (void *)&cmd_set_vf_broadcast_broadcast,
14787 (void *)&cmd_set_vf_broadcast_port_id,
14788 (void *)&cmd_set_vf_broadcast_vf_id,
14789 (void *)&cmd_set_vf_broadcast_on_off,
14794 /* vf vlan tag configuration */
14796 /* Common result structure for vf vlan tag */
14797 struct cmd_set_vf_vlan_tag_result {
14798 cmdline_fixed_string_t set;
14799 cmdline_fixed_string_t vf;
14800 cmdline_fixed_string_t vlan;
14801 cmdline_fixed_string_t tag;
14804 cmdline_fixed_string_t on_off;
14807 /* Common CLI fields for vf vlan tag enable disable */
14808 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14809 TOKEN_STRING_INITIALIZER
14810 (struct cmd_set_vf_vlan_tag_result,
14812 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14813 TOKEN_STRING_INITIALIZER
14814 (struct cmd_set_vf_vlan_tag_result,
14816 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14817 TOKEN_STRING_INITIALIZER
14818 (struct cmd_set_vf_vlan_tag_result,
14820 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14821 TOKEN_STRING_INITIALIZER
14822 (struct cmd_set_vf_vlan_tag_result,
14824 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14825 TOKEN_NUM_INITIALIZER
14826 (struct cmd_set_vf_vlan_tag_result,
14828 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14829 TOKEN_NUM_INITIALIZER
14830 (struct cmd_set_vf_vlan_tag_result,
14832 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14833 TOKEN_STRING_INITIALIZER
14834 (struct cmd_set_vf_vlan_tag_result,
14838 cmd_set_vf_vlan_tag_parsed(
14839 void *parsed_result,
14840 __attribute__((unused)) struct cmdline *cl,
14841 __attribute__((unused)) void *data)
14843 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14844 int ret = -ENOTSUP;
14846 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14848 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14851 #ifdef RTE_LIBRTE_I40E_PMD
14852 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14853 res->vf_id, is_on);
14860 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14863 printf("invalid port_id %d\n", res->port_id);
14866 printf("function not implemented\n");
14869 printf("programming error: (%s)\n", strerror(-ret));
14873 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14874 .f = cmd_set_vf_vlan_tag_parsed,
14876 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14878 (void *)&cmd_set_vf_vlan_tag_set,
14879 (void *)&cmd_set_vf_vlan_tag_vf,
14880 (void *)&cmd_set_vf_vlan_tag_vlan,
14881 (void *)&cmd_set_vf_vlan_tag_tag,
14882 (void *)&cmd_set_vf_vlan_tag_port_id,
14883 (void *)&cmd_set_vf_vlan_tag_vf_id,
14884 (void *)&cmd_set_vf_vlan_tag_on_off,
14889 /* Common definition of VF and TC TX bandwidth configuration */
14890 struct cmd_vf_tc_bw_result {
14891 cmdline_fixed_string_t set;
14892 cmdline_fixed_string_t vf;
14893 cmdline_fixed_string_t tc;
14894 cmdline_fixed_string_t tx;
14895 cmdline_fixed_string_t min_bw;
14896 cmdline_fixed_string_t max_bw;
14897 cmdline_fixed_string_t strict_link_prio;
14902 cmdline_fixed_string_t bw_list;
14906 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14907 TOKEN_STRING_INITIALIZER
14908 (struct cmd_vf_tc_bw_result,
14910 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14911 TOKEN_STRING_INITIALIZER
14912 (struct cmd_vf_tc_bw_result,
14914 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14915 TOKEN_STRING_INITIALIZER
14916 (struct cmd_vf_tc_bw_result,
14918 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14919 TOKEN_STRING_INITIALIZER
14920 (struct cmd_vf_tc_bw_result,
14922 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14923 TOKEN_STRING_INITIALIZER
14924 (struct cmd_vf_tc_bw_result,
14925 strict_link_prio, "strict-link-priority");
14926 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14927 TOKEN_STRING_INITIALIZER
14928 (struct cmd_vf_tc_bw_result,
14929 min_bw, "min-bandwidth");
14930 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14931 TOKEN_STRING_INITIALIZER
14932 (struct cmd_vf_tc_bw_result,
14933 max_bw, "max-bandwidth");
14934 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14935 TOKEN_NUM_INITIALIZER
14936 (struct cmd_vf_tc_bw_result,
14938 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14939 TOKEN_NUM_INITIALIZER
14940 (struct cmd_vf_tc_bw_result,
14942 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14943 TOKEN_NUM_INITIALIZER
14944 (struct cmd_vf_tc_bw_result,
14946 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14947 TOKEN_NUM_INITIALIZER
14948 (struct cmd_vf_tc_bw_result,
14950 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14951 TOKEN_STRING_INITIALIZER
14952 (struct cmd_vf_tc_bw_result,
14954 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14955 TOKEN_NUM_INITIALIZER
14956 (struct cmd_vf_tc_bw_result,
14959 /* VF max bandwidth setting */
14961 cmd_vf_max_bw_parsed(
14962 void *parsed_result,
14963 __attribute__((unused)) struct cmdline *cl,
14964 __attribute__((unused)) void *data)
14966 struct cmd_vf_tc_bw_result *res = parsed_result;
14967 int ret = -ENOTSUP;
14969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14972 #ifdef RTE_LIBRTE_I40E_PMD
14973 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14974 res->vf_id, res->bw);
14981 printf("invalid vf_id %d or bandwidth %d\n",
14982 res->vf_id, res->bw);
14985 printf("invalid port_id %d\n", res->port_id);
14988 printf("function not implemented\n");
14991 printf("programming error: (%s)\n", strerror(-ret));
14995 cmdline_parse_inst_t cmd_vf_max_bw = {
14996 .f = cmd_vf_max_bw_parsed,
14998 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15000 (void *)&cmd_vf_tc_bw_set,
15001 (void *)&cmd_vf_tc_bw_vf,
15002 (void *)&cmd_vf_tc_bw_tx,
15003 (void *)&cmd_vf_tc_bw_max_bw,
15004 (void *)&cmd_vf_tc_bw_port_id,
15005 (void *)&cmd_vf_tc_bw_vf_id,
15006 (void *)&cmd_vf_tc_bw_bw,
15012 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15017 const char *p, *p0 = str;
15024 p = strchr(p0, '(');
15026 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15030 p0 = strchr(p, ')');
15032 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15036 if (size >= sizeof(s)) {
15037 printf("The string size exceeds the internal buffer size\n");
15040 snprintf(s, sizeof(s), "%.*s", size, p);
15041 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15043 printf("Failed to get the bandwidth list. ");
15047 for (i = 0; i < ret; i++)
15048 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15053 /* TC min bandwidth setting */
15055 cmd_vf_tc_min_bw_parsed(
15056 void *parsed_result,
15057 __attribute__((unused)) struct cmdline *cl,
15058 __attribute__((unused)) void *data)
15060 struct cmd_vf_tc_bw_result *res = parsed_result;
15063 int ret = -ENOTSUP;
15065 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15068 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15072 #ifdef RTE_LIBRTE_I40E_PMD
15073 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15081 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15084 printf("invalid port_id %d\n", res->port_id);
15087 printf("function not implemented\n");
15090 printf("programming error: (%s)\n", strerror(-ret));
15094 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15095 .f = cmd_vf_tc_min_bw_parsed,
15097 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15098 " <bw1, bw2, ...>",
15100 (void *)&cmd_vf_tc_bw_set,
15101 (void *)&cmd_vf_tc_bw_vf,
15102 (void *)&cmd_vf_tc_bw_tc,
15103 (void *)&cmd_vf_tc_bw_tx,
15104 (void *)&cmd_vf_tc_bw_min_bw,
15105 (void *)&cmd_vf_tc_bw_port_id,
15106 (void *)&cmd_vf_tc_bw_vf_id,
15107 (void *)&cmd_vf_tc_bw_bw_list,
15113 cmd_tc_min_bw_parsed(
15114 void *parsed_result,
15115 __attribute__((unused)) struct cmdline *cl,
15116 __attribute__((unused)) void *data)
15118 struct cmd_vf_tc_bw_result *res = parsed_result;
15119 struct rte_port *port;
15122 int ret = -ENOTSUP;
15124 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15127 port = &ports[res->port_id];
15128 /** Check if the port is not started **/
15129 if (port->port_status != RTE_PORT_STOPPED) {
15130 printf("Please stop port %d first\n", res->port_id);
15134 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15138 #ifdef RTE_LIBRTE_IXGBE_PMD
15139 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15146 printf("invalid bandwidth\n");
15149 printf("invalid port_id %d\n", res->port_id);
15152 printf("function not implemented\n");
15155 printf("programming error: (%s)\n", strerror(-ret));
15159 cmdline_parse_inst_t cmd_tc_min_bw = {
15160 .f = cmd_tc_min_bw_parsed,
15162 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15164 (void *)&cmd_vf_tc_bw_set,
15165 (void *)&cmd_vf_tc_bw_tc,
15166 (void *)&cmd_vf_tc_bw_tx,
15167 (void *)&cmd_vf_tc_bw_min_bw,
15168 (void *)&cmd_vf_tc_bw_port_id,
15169 (void *)&cmd_vf_tc_bw_bw_list,
15174 /* TC max bandwidth setting */
15176 cmd_vf_tc_max_bw_parsed(
15177 void *parsed_result,
15178 __attribute__((unused)) struct cmdline *cl,
15179 __attribute__((unused)) void *data)
15181 struct cmd_vf_tc_bw_result *res = parsed_result;
15182 int ret = -ENOTSUP;
15184 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15187 #ifdef RTE_LIBRTE_I40E_PMD
15188 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15189 res->tc_no, res->bw);
15196 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15197 res->vf_id, res->tc_no, res->bw);
15200 printf("invalid port_id %d\n", res->port_id);
15203 printf("function not implemented\n");
15206 printf("programming error: (%s)\n", strerror(-ret));
15210 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15211 .f = cmd_vf_tc_max_bw_parsed,
15213 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15216 (void *)&cmd_vf_tc_bw_set,
15217 (void *)&cmd_vf_tc_bw_vf,
15218 (void *)&cmd_vf_tc_bw_tc,
15219 (void *)&cmd_vf_tc_bw_tx,
15220 (void *)&cmd_vf_tc_bw_max_bw,
15221 (void *)&cmd_vf_tc_bw_port_id,
15222 (void *)&cmd_vf_tc_bw_vf_id,
15223 (void *)&cmd_vf_tc_bw_tc_no,
15224 (void *)&cmd_vf_tc_bw_bw,
15230 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15232 /* *** Set Port default Traffic Management Hierarchy *** */
15233 struct cmd_set_port_tm_hierarchy_default_result {
15234 cmdline_fixed_string_t set;
15235 cmdline_fixed_string_t port;
15236 cmdline_fixed_string_t tm;
15237 cmdline_fixed_string_t hierarchy;
15238 cmdline_fixed_string_t def;
15242 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15243 TOKEN_STRING_INITIALIZER(
15244 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15245 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15246 TOKEN_STRING_INITIALIZER(
15247 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15248 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15249 TOKEN_STRING_INITIALIZER(
15250 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15251 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15252 TOKEN_STRING_INITIALIZER(
15253 struct cmd_set_port_tm_hierarchy_default_result,
15254 hierarchy, "hierarchy");
15255 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15256 TOKEN_STRING_INITIALIZER(
15257 struct cmd_set_port_tm_hierarchy_default_result,
15259 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15260 TOKEN_NUM_INITIALIZER(
15261 struct cmd_set_port_tm_hierarchy_default_result,
15264 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15265 __attribute__((unused)) struct cmdline *cl,
15266 __attribute__((unused)) void *data)
15268 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15269 struct rte_port *p;
15270 portid_t port_id = res->port_id;
15272 if (port_id_is_invalid(port_id, ENABLED_WARN))
15275 p = &ports[port_id];
15277 /* Forward mode: tm */
15278 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15279 printf(" softnicfwd mode not enabled(error)\n");
15283 /* Set the default tm hierarchy */
15284 p->softport.default_tm_hierarchy_enable = 1;
15287 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15288 .f = cmd_set_port_tm_hierarchy_default_parsed,
15290 .help_str = "set port tm hierarchy default <port_id>",
15292 (void *)&cmd_set_port_tm_hierarchy_default_set,
15293 (void *)&cmd_set_port_tm_hierarchy_default_port,
15294 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15295 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15296 (void *)&cmd_set_port_tm_hierarchy_default_default,
15297 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15303 /** Set VXLAN encapsulation details */
15304 struct cmd_set_vxlan_result {
15305 cmdline_fixed_string_t set;
15306 cmdline_fixed_string_t vxlan;
15307 cmdline_fixed_string_t pos_token;
15308 cmdline_fixed_string_t ip_version;
15309 uint32_t vlan_present:1;
15313 cmdline_ipaddr_t ip_src;
15314 cmdline_ipaddr_t ip_dst;
15318 struct rte_ether_addr eth_src;
15319 struct rte_ether_addr eth_dst;
15322 cmdline_parse_token_string_t cmd_set_vxlan_set =
15323 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15324 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15325 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15326 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15327 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15329 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15330 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15331 "vxlan-with-vlan");
15332 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15333 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15335 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15336 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15338 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15339 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15341 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15342 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15343 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15344 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15346 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15347 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15348 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15349 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15351 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15352 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15353 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15354 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15356 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15357 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15358 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15359 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15361 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15362 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15363 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15364 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15366 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15367 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15368 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15369 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15371 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15372 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15373 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15374 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15376 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15377 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15378 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15379 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15381 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15382 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15383 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15384 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15386 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15387 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15389 static void cmd_set_vxlan_parsed(void *parsed_result,
15390 __attribute__((unused)) struct cmdline *cl,
15391 __attribute__((unused)) void *data)
15393 struct cmd_set_vxlan_result *res = parsed_result;
15398 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15401 vxlan_encap_conf.select_tos_ttl = 0;
15402 if (strcmp(res->vxlan, "vxlan") == 0)
15403 vxlan_encap_conf.select_vlan = 0;
15404 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15405 vxlan_encap_conf.select_vlan = 1;
15406 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15407 vxlan_encap_conf.select_vlan = 0;
15408 vxlan_encap_conf.select_tos_ttl = 1;
15410 if (strcmp(res->ip_version, "ipv4") == 0)
15411 vxlan_encap_conf.select_ipv4 = 1;
15412 else if (strcmp(res->ip_version, "ipv6") == 0)
15413 vxlan_encap_conf.select_ipv4 = 0;
15416 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15417 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15418 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15419 vxlan_encap_conf.ip_tos = res->tos;
15420 vxlan_encap_conf.ip_ttl = res->ttl;
15421 if (vxlan_encap_conf.select_ipv4) {
15422 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15423 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15425 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15426 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15428 if (vxlan_encap_conf.select_vlan)
15429 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15430 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15431 RTE_ETHER_ADDR_LEN);
15432 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15433 RTE_ETHER_ADDR_LEN);
15436 cmdline_parse_inst_t cmd_set_vxlan = {
15437 .f = cmd_set_vxlan_parsed,
15439 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15440 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15441 " eth-src <eth-src> eth-dst <eth-dst>",
15443 (void *)&cmd_set_vxlan_set,
15444 (void *)&cmd_set_vxlan_vxlan,
15445 (void *)&cmd_set_vxlan_ip_version,
15446 (void *)&cmd_set_vxlan_ip_version_value,
15447 (void *)&cmd_set_vxlan_vni,
15448 (void *)&cmd_set_vxlan_vni_value,
15449 (void *)&cmd_set_vxlan_udp_src,
15450 (void *)&cmd_set_vxlan_udp_src_value,
15451 (void *)&cmd_set_vxlan_udp_dst,
15452 (void *)&cmd_set_vxlan_udp_dst_value,
15453 (void *)&cmd_set_vxlan_ip_src,
15454 (void *)&cmd_set_vxlan_ip_src_value,
15455 (void *)&cmd_set_vxlan_ip_dst,
15456 (void *)&cmd_set_vxlan_ip_dst_value,
15457 (void *)&cmd_set_vxlan_eth_src,
15458 (void *)&cmd_set_vxlan_eth_src_value,
15459 (void *)&cmd_set_vxlan_eth_dst,
15460 (void *)&cmd_set_vxlan_eth_dst_value,
15465 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15466 .f = cmd_set_vxlan_parsed,
15468 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15469 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15470 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15471 " eth-dst <eth-dst>",
15473 (void *)&cmd_set_vxlan_set,
15474 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15475 (void *)&cmd_set_vxlan_ip_version,
15476 (void *)&cmd_set_vxlan_ip_version_value,
15477 (void *)&cmd_set_vxlan_vni,
15478 (void *)&cmd_set_vxlan_vni_value,
15479 (void *)&cmd_set_vxlan_udp_src,
15480 (void *)&cmd_set_vxlan_udp_src_value,
15481 (void *)&cmd_set_vxlan_udp_dst,
15482 (void *)&cmd_set_vxlan_udp_dst_value,
15483 (void *)&cmd_set_vxlan_ip_tos,
15484 (void *)&cmd_set_vxlan_ip_tos_value,
15485 (void *)&cmd_set_vxlan_ip_ttl,
15486 (void *)&cmd_set_vxlan_ip_ttl_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_with_vlan = {
15500 .f = cmd_set_vxlan_parsed,
15502 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15503 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15504 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15507 (void *)&cmd_set_vxlan_set,
15508 (void *)&cmd_set_vxlan_vxlan_with_vlan,
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_src,
15518 (void *)&cmd_set_vxlan_ip_src_value,
15519 (void *)&cmd_set_vxlan_ip_dst,
15520 (void *)&cmd_set_vxlan_ip_dst_value,
15521 (void *)&cmd_set_vxlan_vlan,
15522 (void *)&cmd_set_vxlan_vlan_value,
15523 (void *)&cmd_set_vxlan_eth_src,
15524 (void *)&cmd_set_vxlan_eth_src_value,
15525 (void *)&cmd_set_vxlan_eth_dst,
15526 (void *)&cmd_set_vxlan_eth_dst_value,
15531 /** Set NVGRE encapsulation details */
15532 struct cmd_set_nvgre_result {
15533 cmdline_fixed_string_t set;
15534 cmdline_fixed_string_t nvgre;
15535 cmdline_fixed_string_t pos_token;
15536 cmdline_fixed_string_t ip_version;
15538 cmdline_ipaddr_t ip_src;
15539 cmdline_ipaddr_t ip_dst;
15541 struct rte_ether_addr eth_src;
15542 struct rte_ether_addr eth_dst;
15545 cmdline_parse_token_string_t cmd_set_nvgre_set =
15546 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15547 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15548 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15549 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15550 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15551 "nvgre-with-vlan");
15552 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15553 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15555 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15556 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15558 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15559 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15561 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15562 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15563 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15564 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15566 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15567 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15568 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15569 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15571 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15572 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15573 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15574 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15576 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15577 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15578 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15579 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15581 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15582 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15583 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15584 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15586 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15587 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15589 static void cmd_set_nvgre_parsed(void *parsed_result,
15590 __attribute__((unused)) struct cmdline *cl,
15591 __attribute__((unused)) void *data)
15593 struct cmd_set_nvgre_result *res = parsed_result;
15595 uint32_t nvgre_tni;
15598 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15601 if (strcmp(res->nvgre, "nvgre") == 0)
15602 nvgre_encap_conf.select_vlan = 0;
15603 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15604 nvgre_encap_conf.select_vlan = 1;
15605 if (strcmp(res->ip_version, "ipv4") == 0)
15606 nvgre_encap_conf.select_ipv4 = 1;
15607 else if (strcmp(res->ip_version, "ipv6") == 0)
15608 nvgre_encap_conf.select_ipv4 = 0;
15611 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15612 if (nvgre_encap_conf.select_ipv4) {
15613 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15614 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15616 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15617 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15619 if (nvgre_encap_conf.select_vlan)
15620 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15621 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15622 RTE_ETHER_ADDR_LEN);
15623 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15624 RTE_ETHER_ADDR_LEN);
15627 cmdline_parse_inst_t cmd_set_nvgre = {
15628 .f = cmd_set_nvgre_parsed,
15630 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15631 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15632 " eth-dst <eth-dst>",
15634 (void *)&cmd_set_nvgre_set,
15635 (void *)&cmd_set_nvgre_nvgre,
15636 (void *)&cmd_set_nvgre_ip_version,
15637 (void *)&cmd_set_nvgre_ip_version_value,
15638 (void *)&cmd_set_nvgre_tni,
15639 (void *)&cmd_set_nvgre_tni_value,
15640 (void *)&cmd_set_nvgre_ip_src,
15641 (void *)&cmd_set_nvgre_ip_src_value,
15642 (void *)&cmd_set_nvgre_ip_dst,
15643 (void *)&cmd_set_nvgre_ip_dst_value,
15644 (void *)&cmd_set_nvgre_eth_src,
15645 (void *)&cmd_set_nvgre_eth_src_value,
15646 (void *)&cmd_set_nvgre_eth_dst,
15647 (void *)&cmd_set_nvgre_eth_dst_value,
15652 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15653 .f = cmd_set_nvgre_parsed,
15655 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15656 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15657 " eth-src <eth-src> eth-dst <eth-dst>",
15659 (void *)&cmd_set_nvgre_set,
15660 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15661 (void *)&cmd_set_nvgre_ip_version,
15662 (void *)&cmd_set_nvgre_ip_version_value,
15663 (void *)&cmd_set_nvgre_tni,
15664 (void *)&cmd_set_nvgre_tni_value,
15665 (void *)&cmd_set_nvgre_ip_src,
15666 (void *)&cmd_set_nvgre_ip_src_value,
15667 (void *)&cmd_set_nvgre_ip_dst,
15668 (void *)&cmd_set_nvgre_ip_dst_value,
15669 (void *)&cmd_set_nvgre_vlan,
15670 (void *)&cmd_set_nvgre_vlan_value,
15671 (void *)&cmd_set_nvgre_eth_src,
15672 (void *)&cmd_set_nvgre_eth_src_value,
15673 (void *)&cmd_set_nvgre_eth_dst,
15674 (void *)&cmd_set_nvgre_eth_dst_value,
15679 /** Set L2 encapsulation details */
15680 struct cmd_set_l2_encap_result {
15681 cmdline_fixed_string_t set;
15682 cmdline_fixed_string_t l2_encap;
15683 cmdline_fixed_string_t pos_token;
15684 cmdline_fixed_string_t ip_version;
15685 uint32_t vlan_present:1;
15687 struct rte_ether_addr eth_src;
15688 struct rte_ether_addr eth_dst;
15691 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15692 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15693 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15694 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15695 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15696 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15697 "l2_encap-with-vlan");
15698 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15699 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15701 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15702 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15704 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15705 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15707 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15708 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15709 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15710 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15712 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15713 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15714 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15715 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15717 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15718 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15720 static void cmd_set_l2_encap_parsed(void *parsed_result,
15721 __attribute__((unused)) struct cmdline *cl,
15722 __attribute__((unused)) void *data)
15724 struct cmd_set_l2_encap_result *res = parsed_result;
15726 if (strcmp(res->l2_encap, "l2_encap") == 0)
15727 l2_encap_conf.select_vlan = 0;
15728 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15729 l2_encap_conf.select_vlan = 1;
15730 if (strcmp(res->ip_version, "ipv4") == 0)
15731 l2_encap_conf.select_ipv4 = 1;
15732 else if (strcmp(res->ip_version, "ipv6") == 0)
15733 l2_encap_conf.select_ipv4 = 0;
15736 if (l2_encap_conf.select_vlan)
15737 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15738 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15739 RTE_ETHER_ADDR_LEN);
15740 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15741 RTE_ETHER_ADDR_LEN);
15744 cmdline_parse_inst_t cmd_set_l2_encap = {
15745 .f = cmd_set_l2_encap_parsed,
15747 .help_str = "set l2_encap ip-version ipv4|ipv6"
15748 " eth-src <eth-src> eth-dst <eth-dst>",
15750 (void *)&cmd_set_l2_encap_set,
15751 (void *)&cmd_set_l2_encap_l2_encap,
15752 (void *)&cmd_set_l2_encap_ip_version,
15753 (void *)&cmd_set_l2_encap_ip_version_value,
15754 (void *)&cmd_set_l2_encap_eth_src,
15755 (void *)&cmd_set_l2_encap_eth_src_value,
15756 (void *)&cmd_set_l2_encap_eth_dst,
15757 (void *)&cmd_set_l2_encap_eth_dst_value,
15762 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15763 .f = cmd_set_l2_encap_parsed,
15765 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15766 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15768 (void *)&cmd_set_l2_encap_set,
15769 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15770 (void *)&cmd_set_l2_encap_ip_version,
15771 (void *)&cmd_set_l2_encap_ip_version_value,
15772 (void *)&cmd_set_l2_encap_vlan,
15773 (void *)&cmd_set_l2_encap_vlan_value,
15774 (void *)&cmd_set_l2_encap_eth_src,
15775 (void *)&cmd_set_l2_encap_eth_src_value,
15776 (void *)&cmd_set_l2_encap_eth_dst,
15777 (void *)&cmd_set_l2_encap_eth_dst_value,
15782 /** Set L2 decapsulation details */
15783 struct cmd_set_l2_decap_result {
15784 cmdline_fixed_string_t set;
15785 cmdline_fixed_string_t l2_decap;
15786 cmdline_fixed_string_t pos_token;
15787 uint32_t vlan_present:1;
15790 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15791 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15792 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15793 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15795 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15796 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15797 "l2_decap-with-vlan");
15799 static void cmd_set_l2_decap_parsed(void *parsed_result,
15800 __attribute__((unused)) struct cmdline *cl,
15801 __attribute__((unused)) void *data)
15803 struct cmd_set_l2_decap_result *res = parsed_result;
15805 if (strcmp(res->l2_decap, "l2_decap") == 0)
15806 l2_decap_conf.select_vlan = 0;
15807 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15808 l2_decap_conf.select_vlan = 1;
15811 cmdline_parse_inst_t cmd_set_l2_decap = {
15812 .f = cmd_set_l2_decap_parsed,
15814 .help_str = "set l2_decap",
15816 (void *)&cmd_set_l2_decap_set,
15817 (void *)&cmd_set_l2_decap_l2_decap,
15822 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15823 .f = cmd_set_l2_decap_parsed,
15825 .help_str = "set l2_decap-with-vlan",
15827 (void *)&cmd_set_l2_decap_set,
15828 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15833 /** Set MPLSoGRE encapsulation details */
15834 struct cmd_set_mplsogre_encap_result {
15835 cmdline_fixed_string_t set;
15836 cmdline_fixed_string_t mplsogre;
15837 cmdline_fixed_string_t pos_token;
15838 cmdline_fixed_string_t ip_version;
15839 uint32_t vlan_present:1;
15841 cmdline_ipaddr_t ip_src;
15842 cmdline_ipaddr_t ip_dst;
15844 struct rte_ether_addr eth_src;
15845 struct rte_ether_addr eth_dst;
15848 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15849 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15851 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15852 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15854 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15855 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15856 mplsogre, "mplsogre_encap-with-vlan");
15857 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15858 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15859 pos_token, "ip-version");
15860 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15861 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15862 ip_version, "ipv4#ipv6");
15863 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15864 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15865 pos_token, "label");
15866 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15867 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15869 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15870 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15871 pos_token, "ip-src");
15872 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15873 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15874 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15875 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15876 pos_token, "ip-dst");
15877 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15878 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15879 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15880 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15881 pos_token, "vlan-tci");
15882 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15883 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15885 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15887 pos_token, "eth-src");
15888 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15889 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15891 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15893 pos_token, "eth-dst");
15894 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15895 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15898 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15899 __attribute__((unused)) struct cmdline *cl,
15900 __attribute__((unused)) void *data)
15902 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15904 uint32_t mplsogre_label;
15907 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15910 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15911 mplsogre_encap_conf.select_vlan = 0;
15912 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15913 mplsogre_encap_conf.select_vlan = 1;
15914 if (strcmp(res->ip_version, "ipv4") == 0)
15915 mplsogre_encap_conf.select_ipv4 = 1;
15916 else if (strcmp(res->ip_version, "ipv6") == 0)
15917 mplsogre_encap_conf.select_ipv4 = 0;
15920 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15921 if (mplsogre_encap_conf.select_ipv4) {
15922 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15923 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15925 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15926 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15928 if (mplsogre_encap_conf.select_vlan)
15929 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15930 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15931 RTE_ETHER_ADDR_LEN);
15932 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15933 RTE_ETHER_ADDR_LEN);
15936 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15937 .f = cmd_set_mplsogre_encap_parsed,
15939 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15940 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15941 " eth-dst <eth-dst>",
15943 (void *)&cmd_set_mplsogre_encap_set,
15944 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15945 (void *)&cmd_set_mplsogre_encap_ip_version,
15946 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15947 (void *)&cmd_set_mplsogre_encap_label,
15948 (void *)&cmd_set_mplsogre_encap_label_value,
15949 (void *)&cmd_set_mplsogre_encap_ip_src,
15950 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15951 (void *)&cmd_set_mplsogre_encap_ip_dst,
15952 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15953 (void *)&cmd_set_mplsogre_encap_eth_src,
15954 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15955 (void *)&cmd_set_mplsogre_encap_eth_dst,
15956 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15961 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15962 .f = cmd_set_mplsogre_encap_parsed,
15964 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15965 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15966 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15968 (void *)&cmd_set_mplsogre_encap_set,
15969 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15970 (void *)&cmd_set_mplsogre_encap_ip_version,
15971 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15972 (void *)&cmd_set_mplsogre_encap_label,
15973 (void *)&cmd_set_mplsogre_encap_label_value,
15974 (void *)&cmd_set_mplsogre_encap_ip_src,
15975 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15976 (void *)&cmd_set_mplsogre_encap_ip_dst,
15977 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15978 (void *)&cmd_set_mplsogre_encap_vlan,
15979 (void *)&cmd_set_mplsogre_encap_vlan_value,
15980 (void *)&cmd_set_mplsogre_encap_eth_src,
15981 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15982 (void *)&cmd_set_mplsogre_encap_eth_dst,
15983 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15988 /** Set MPLSoGRE decapsulation details */
15989 struct cmd_set_mplsogre_decap_result {
15990 cmdline_fixed_string_t set;
15991 cmdline_fixed_string_t mplsogre;
15992 cmdline_fixed_string_t pos_token;
15993 cmdline_fixed_string_t ip_version;
15994 uint32_t vlan_present:1;
15997 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15998 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16000 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16001 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16003 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16004 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16005 mplsogre, "mplsogre_decap-with-vlan");
16006 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16007 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16008 pos_token, "ip-version");
16009 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16010 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16011 ip_version, "ipv4#ipv6");
16013 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16014 __attribute__((unused)) struct cmdline *cl,
16015 __attribute__((unused)) void *data)
16017 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16019 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16020 mplsogre_decap_conf.select_vlan = 0;
16021 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16022 mplsogre_decap_conf.select_vlan = 1;
16023 if (strcmp(res->ip_version, "ipv4") == 0)
16024 mplsogre_decap_conf.select_ipv4 = 1;
16025 else if (strcmp(res->ip_version, "ipv6") == 0)
16026 mplsogre_decap_conf.select_ipv4 = 0;
16029 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16030 .f = cmd_set_mplsogre_decap_parsed,
16032 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16034 (void *)&cmd_set_mplsogre_decap_set,
16035 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16036 (void *)&cmd_set_mplsogre_decap_ip_version,
16037 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16042 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16043 .f = cmd_set_mplsogre_decap_parsed,
16045 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16047 (void *)&cmd_set_mplsogre_decap_set,
16048 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16049 (void *)&cmd_set_mplsogre_decap_ip_version,
16050 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16055 /** Set MPLSoUDP encapsulation details */
16056 struct cmd_set_mplsoudp_encap_result {
16057 cmdline_fixed_string_t set;
16058 cmdline_fixed_string_t mplsoudp;
16059 cmdline_fixed_string_t pos_token;
16060 cmdline_fixed_string_t ip_version;
16061 uint32_t vlan_present:1;
16065 cmdline_ipaddr_t ip_src;
16066 cmdline_ipaddr_t ip_dst;
16068 struct rte_ether_addr eth_src;
16069 struct rte_ether_addr eth_dst;
16072 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16073 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16075 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16076 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16078 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16079 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16080 mplsoudp, "mplsoudp_encap-with-vlan");
16081 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16082 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16083 pos_token, "ip-version");
16084 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16085 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16086 ip_version, "ipv4#ipv6");
16087 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16088 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16089 pos_token, "label");
16090 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16091 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16093 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16094 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16095 pos_token, "udp-src");
16096 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16097 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16099 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16100 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16101 pos_token, "udp-dst");
16102 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16103 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16105 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16106 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16107 pos_token, "ip-src");
16108 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16109 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16110 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16111 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16112 pos_token, "ip-dst");
16113 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16114 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16115 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16116 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16117 pos_token, "vlan-tci");
16118 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16119 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16121 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16122 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16123 pos_token, "eth-src");
16124 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16125 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16127 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16128 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16129 pos_token, "eth-dst");
16130 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16131 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16134 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16135 __attribute__((unused)) struct cmdline *cl,
16136 __attribute__((unused)) void *data)
16138 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16140 uint32_t mplsoudp_label;
16143 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16146 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16147 mplsoudp_encap_conf.select_vlan = 0;
16148 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16149 mplsoudp_encap_conf.select_vlan = 1;
16150 if (strcmp(res->ip_version, "ipv4") == 0)
16151 mplsoudp_encap_conf.select_ipv4 = 1;
16152 else if (strcmp(res->ip_version, "ipv6") == 0)
16153 mplsoudp_encap_conf.select_ipv4 = 0;
16156 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16157 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16158 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16159 if (mplsoudp_encap_conf.select_ipv4) {
16160 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16161 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16163 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16164 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16166 if (mplsoudp_encap_conf.select_vlan)
16167 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16168 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16169 RTE_ETHER_ADDR_LEN);
16170 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16171 RTE_ETHER_ADDR_LEN);
16174 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16175 .f = cmd_set_mplsoudp_encap_parsed,
16177 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16178 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16179 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16181 (void *)&cmd_set_mplsoudp_encap_set,
16182 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16183 (void *)&cmd_set_mplsoudp_encap_ip_version,
16184 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16185 (void *)&cmd_set_mplsoudp_encap_label,
16186 (void *)&cmd_set_mplsoudp_encap_label_value,
16187 (void *)&cmd_set_mplsoudp_encap_udp_src,
16188 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16189 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16190 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16191 (void *)&cmd_set_mplsoudp_encap_ip_src,
16192 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16193 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16194 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16195 (void *)&cmd_set_mplsoudp_encap_eth_src,
16196 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16197 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16198 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16203 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16204 .f = cmd_set_mplsoudp_encap_parsed,
16206 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16207 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16208 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16209 " eth-src <eth-src> eth-dst <eth-dst>",
16211 (void *)&cmd_set_mplsoudp_encap_set,
16212 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16213 (void *)&cmd_set_mplsoudp_encap_ip_version,
16214 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16215 (void *)&cmd_set_mplsoudp_encap_label,
16216 (void *)&cmd_set_mplsoudp_encap_label_value,
16217 (void *)&cmd_set_mplsoudp_encap_udp_src,
16218 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16219 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16220 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16221 (void *)&cmd_set_mplsoudp_encap_ip_src,
16222 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16223 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16224 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16225 (void *)&cmd_set_mplsoudp_encap_vlan,
16226 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16227 (void *)&cmd_set_mplsoudp_encap_eth_src,
16228 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16229 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16230 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16235 /** Set MPLSoUDP decapsulation details */
16236 struct cmd_set_mplsoudp_decap_result {
16237 cmdline_fixed_string_t set;
16238 cmdline_fixed_string_t mplsoudp;
16239 cmdline_fixed_string_t pos_token;
16240 cmdline_fixed_string_t ip_version;
16241 uint32_t vlan_present:1;
16244 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16245 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16247 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16248 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16250 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16251 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16252 mplsoudp, "mplsoudp_decap-with-vlan");
16253 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16254 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16255 pos_token, "ip-version");
16256 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16257 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16258 ip_version, "ipv4#ipv6");
16260 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16261 __attribute__((unused)) struct cmdline *cl,
16262 __attribute__((unused)) void *data)
16264 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16266 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16267 mplsoudp_decap_conf.select_vlan = 0;
16268 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16269 mplsoudp_decap_conf.select_vlan = 1;
16270 if (strcmp(res->ip_version, "ipv4") == 0)
16271 mplsoudp_decap_conf.select_ipv4 = 1;
16272 else if (strcmp(res->ip_version, "ipv6") == 0)
16273 mplsoudp_decap_conf.select_ipv4 = 0;
16276 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16277 .f = cmd_set_mplsoudp_decap_parsed,
16279 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16281 (void *)&cmd_set_mplsoudp_decap_set,
16282 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16283 (void *)&cmd_set_mplsoudp_decap_ip_version,
16284 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16289 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16290 .f = cmd_set_mplsoudp_decap_parsed,
16292 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16294 (void *)&cmd_set_mplsoudp_decap_set,
16295 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16296 (void *)&cmd_set_mplsoudp_decap_ip_version,
16297 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16302 /* Strict link priority scheduling mode setting */
16304 cmd_strict_link_prio_parsed(
16305 void *parsed_result,
16306 __attribute__((unused)) struct cmdline *cl,
16307 __attribute__((unused)) void *data)
16309 struct cmd_vf_tc_bw_result *res = parsed_result;
16310 int ret = -ENOTSUP;
16312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16315 #ifdef RTE_LIBRTE_I40E_PMD
16316 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16323 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16326 printf("invalid port_id %d\n", res->port_id);
16329 printf("function not implemented\n");
16332 printf("programming error: (%s)\n", strerror(-ret));
16336 cmdline_parse_inst_t cmd_strict_link_prio = {
16337 .f = cmd_strict_link_prio_parsed,
16339 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16341 (void *)&cmd_vf_tc_bw_set,
16342 (void *)&cmd_vf_tc_bw_tx,
16343 (void *)&cmd_vf_tc_bw_strict_link_prio,
16344 (void *)&cmd_vf_tc_bw_port_id,
16345 (void *)&cmd_vf_tc_bw_tc_map,
16350 /* Load dynamic device personalization*/
16351 struct cmd_ddp_add_result {
16352 cmdline_fixed_string_t ddp;
16353 cmdline_fixed_string_t add;
16358 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16359 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16360 cmdline_parse_token_string_t cmd_ddp_add_add =
16361 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16362 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16363 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16364 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16365 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16368 cmd_ddp_add_parsed(
16369 void *parsed_result,
16370 __attribute__((unused)) struct cmdline *cl,
16371 __attribute__((unused)) void *data)
16373 struct cmd_ddp_add_result *res = parsed_result;
16379 int ret = -ENOTSUP;
16381 if (!all_ports_stopped()) {
16382 printf("Please stop all ports first\n");
16386 filepath = strdup(res->filepath);
16387 if (filepath == NULL) {
16388 printf("Failed to allocate memory\n");
16391 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16393 buff = open_file(file_fld[0], &size);
16395 free((void *)filepath);
16399 #ifdef RTE_LIBRTE_I40E_PMD
16400 if (ret == -ENOTSUP)
16401 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16403 RTE_PMD_I40E_PKG_OP_WR_ADD);
16406 if (ret == -EEXIST)
16407 printf("Profile has already existed.\n");
16409 printf("Failed to load profile.\n");
16410 else if (file_num == 2)
16411 save_file(file_fld[1], buff, size);
16414 free((void *)filepath);
16417 cmdline_parse_inst_t cmd_ddp_add = {
16418 .f = cmd_ddp_add_parsed,
16420 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16422 (void *)&cmd_ddp_add_ddp,
16423 (void *)&cmd_ddp_add_add,
16424 (void *)&cmd_ddp_add_port_id,
16425 (void *)&cmd_ddp_add_filepath,
16430 /* Delete dynamic device personalization*/
16431 struct cmd_ddp_del_result {
16432 cmdline_fixed_string_t ddp;
16433 cmdline_fixed_string_t del;
16438 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16439 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16440 cmdline_parse_token_string_t cmd_ddp_del_del =
16441 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16442 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16443 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16444 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16445 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16448 cmd_ddp_del_parsed(
16449 void *parsed_result,
16450 __attribute__((unused)) struct cmdline *cl,
16451 __attribute__((unused)) void *data)
16453 struct cmd_ddp_del_result *res = parsed_result;
16456 int ret = -ENOTSUP;
16458 if (!all_ports_stopped()) {
16459 printf("Please stop all ports first\n");
16463 buff = open_file(res->filepath, &size);
16467 #ifdef RTE_LIBRTE_I40E_PMD
16468 if (ret == -ENOTSUP)
16469 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16471 RTE_PMD_I40E_PKG_OP_WR_DEL);
16474 if (ret == -EACCES)
16475 printf("Profile does not exist.\n");
16477 printf("Failed to delete profile.\n");
16482 cmdline_parse_inst_t cmd_ddp_del = {
16483 .f = cmd_ddp_del_parsed,
16485 .help_str = "ddp del <port_id> <backup_profile_path>",
16487 (void *)&cmd_ddp_del_ddp,
16488 (void *)&cmd_ddp_del_del,
16489 (void *)&cmd_ddp_del_port_id,
16490 (void *)&cmd_ddp_del_filepath,
16495 /* Get dynamic device personalization profile info */
16496 struct cmd_ddp_info_result {
16497 cmdline_fixed_string_t ddp;
16498 cmdline_fixed_string_t get;
16499 cmdline_fixed_string_t info;
16503 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16504 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16505 cmdline_parse_token_string_t cmd_ddp_info_get =
16506 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16507 cmdline_parse_token_string_t cmd_ddp_info_info =
16508 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16509 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16510 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16513 cmd_ddp_info_parsed(
16514 void *parsed_result,
16515 __attribute__((unused)) struct cmdline *cl,
16516 __attribute__((unused)) void *data)
16518 struct cmd_ddp_info_result *res = parsed_result;
16521 int ret = -ENOTSUP;
16522 #ifdef RTE_LIBRTE_I40E_PMD
16525 uint32_t buff_size = 0;
16526 struct rte_pmd_i40e_profile_info info;
16527 uint32_t dev_num = 0;
16528 struct rte_pmd_i40e_ddp_device_id *devs;
16529 uint32_t proto_num = 0;
16530 struct rte_pmd_i40e_proto_info *proto = NULL;
16531 uint32_t pctype_num = 0;
16532 struct rte_pmd_i40e_ptype_info *pctype;
16533 uint32_t ptype_num = 0;
16534 struct rte_pmd_i40e_ptype_info *ptype;
16539 pkg = open_file(res->filepath, &pkg_size);
16543 #ifdef RTE_LIBRTE_I40E_PMD
16544 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16545 (uint8_t *)&info, sizeof(info),
16546 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16548 printf("Global Track id: 0x%x\n", info.track_id);
16549 printf("Global Version: %d.%d.%d.%d\n",
16550 info.version.major,
16551 info.version.minor,
16552 info.version.update,
16553 info.version.draft);
16554 printf("Global Package name: %s\n\n", info.name);
16557 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16558 (uint8_t *)&info, sizeof(info),
16559 RTE_PMD_I40E_PKG_INFO_HEADER);
16561 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16562 printf("i40e Profile Version: %d.%d.%d.%d\n",
16563 info.version.major,
16564 info.version.minor,
16565 info.version.update,
16566 info.version.draft);
16567 printf("i40e Profile name: %s\n\n", info.name);
16570 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16571 (uint8_t *)&buff_size, sizeof(buff_size),
16572 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16573 if (!ret && buff_size) {
16574 buff = (uint8_t *)malloc(buff_size);
16576 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16578 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16580 printf("Package Notes:\n%s\n\n", buff);
16585 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16586 (uint8_t *)&dev_num, sizeof(dev_num),
16587 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16588 if (!ret && dev_num) {
16589 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16590 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16592 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16593 (uint8_t *)devs, buff_size,
16594 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16596 printf("List of supported devices:\n");
16597 for (i = 0; i < dev_num; i++) {
16598 printf(" %04X:%04X %04X:%04X\n",
16599 devs[i].vendor_dev_id >> 16,
16600 devs[i].vendor_dev_id & 0xFFFF,
16601 devs[i].sub_vendor_dev_id >> 16,
16602 devs[i].sub_vendor_dev_id & 0xFFFF);
16610 /* get information about protocols and packet types */
16611 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16612 (uint8_t *)&proto_num, sizeof(proto_num),
16613 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16614 if (ret || !proto_num)
16615 goto no_print_return;
16617 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16618 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16620 goto no_print_return;
16622 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16624 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16626 printf("List of used protocols:\n");
16627 for (i = 0; i < proto_num; i++)
16628 printf(" %2u: %s\n", proto[i].proto_id,
16632 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16633 (uint8_t *)&pctype_num, sizeof(pctype_num),
16634 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16635 if (ret || !pctype_num)
16636 goto no_print_pctypes;
16638 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16639 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16641 goto no_print_pctypes;
16643 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16645 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16648 goto no_print_pctypes;
16651 printf("List of defined packet classification types:\n");
16652 for (i = 0; i < pctype_num; i++) {
16653 printf(" %2u:", pctype[i].ptype_id);
16654 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16655 proto_id = pctype[i].protocols[j];
16656 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16657 for (n = 0; n < proto_num; n++) {
16658 if (proto[n].proto_id == proto_id) {
16659 printf(" %s", proto[n].name);
16672 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16674 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16675 if (ret || !ptype_num)
16676 goto no_print_return;
16678 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16679 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16681 goto no_print_return;
16683 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16685 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16688 goto no_print_return;
16690 printf("List of defined packet types:\n");
16691 for (i = 0; i < ptype_num; i++) {
16692 printf(" %2u:", ptype[i].ptype_id);
16693 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16694 proto_id = ptype[i].protocols[j];
16695 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16696 for (n = 0; n < proto_num; n++) {
16697 if (proto[n].proto_id == proto_id) {
16698 printf(" %s", proto[n].name);
16714 if (ret == -ENOTSUP)
16715 printf("Function not supported in PMD driver\n");
16719 cmdline_parse_inst_t cmd_ddp_get_info = {
16720 .f = cmd_ddp_info_parsed,
16722 .help_str = "ddp get info <profile_path>",
16724 (void *)&cmd_ddp_info_ddp,
16725 (void *)&cmd_ddp_info_get,
16726 (void *)&cmd_ddp_info_info,
16727 (void *)&cmd_ddp_info_filepath,
16732 /* Get dynamic device personalization profile info list*/
16733 #define PROFILE_INFO_SIZE 48
16734 #define MAX_PROFILE_NUM 16
16736 struct cmd_ddp_get_list_result {
16737 cmdline_fixed_string_t ddp;
16738 cmdline_fixed_string_t get;
16739 cmdline_fixed_string_t list;
16743 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16744 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16745 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16746 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16747 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16748 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16749 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16750 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16753 cmd_ddp_get_list_parsed(
16754 __attribute__((unused)) void *parsed_result,
16755 __attribute__((unused)) struct cmdline *cl,
16756 __attribute__((unused)) void *data)
16758 #ifdef RTE_LIBRTE_I40E_PMD
16759 struct cmd_ddp_get_list_result *res = parsed_result;
16760 struct rte_pmd_i40e_profile_list *p_list;
16761 struct rte_pmd_i40e_profile_info *p_info;
16766 int ret = -ENOTSUP;
16768 #ifdef RTE_LIBRTE_I40E_PMD
16769 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16770 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16772 printf("%s: Failed to malloc buffer\n", __func__);
16774 if (ret == -ENOTSUP)
16775 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16776 (uint8_t *)p_list, size);
16779 p_num = p_list->p_count;
16780 printf("Profile number is: %d\n\n", p_num);
16782 for (i = 0; i < p_num; i++) {
16783 p_info = &p_list->p_info[i];
16784 printf("Profile %d:\n", i);
16785 printf("Track id: 0x%x\n", p_info->track_id);
16786 printf("Version: %d.%d.%d.%d\n",
16787 p_info->version.major,
16788 p_info->version.minor,
16789 p_info->version.update,
16790 p_info->version.draft);
16791 printf("Profile name: %s\n\n", p_info->name);
16799 printf("Failed to get ddp list\n");
16802 cmdline_parse_inst_t cmd_ddp_get_list = {
16803 .f = cmd_ddp_get_list_parsed,
16805 .help_str = "ddp get list <port_id>",
16807 (void *)&cmd_ddp_get_list_ddp,
16808 (void *)&cmd_ddp_get_list_get,
16809 (void *)&cmd_ddp_get_list_list,
16810 (void *)&cmd_ddp_get_list_port_id,
16815 /* Configure input set */
16816 struct cmd_cfg_input_set_result {
16817 cmdline_fixed_string_t port;
16818 cmdline_fixed_string_t cfg;
16820 cmdline_fixed_string_t pctype;
16822 cmdline_fixed_string_t inset_type;
16823 cmdline_fixed_string_t opt;
16824 cmdline_fixed_string_t field;
16829 cmd_cfg_input_set_parsed(
16830 __attribute__((unused)) void *parsed_result,
16831 __attribute__((unused)) struct cmdline *cl,
16832 __attribute__((unused)) void *data)
16834 #ifdef RTE_LIBRTE_I40E_PMD
16835 struct cmd_cfg_input_set_result *res = parsed_result;
16836 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16837 struct rte_pmd_i40e_inset inset;
16839 int ret = -ENOTSUP;
16841 if (!all_ports_stopped()) {
16842 printf("Please stop all ports first\n");
16846 #ifdef RTE_LIBRTE_I40E_PMD
16847 if (!strcmp(res->inset_type, "hash_inset"))
16848 inset_type = INSET_HASH;
16849 else if (!strcmp(res->inset_type, "fdir_inset"))
16850 inset_type = INSET_FDIR;
16851 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16852 inset_type = INSET_FDIR_FLX;
16853 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16854 &inset, inset_type);
16856 printf("Failed to get input set.\n");
16860 if (!strcmp(res->opt, "get")) {
16861 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16864 printf("Field index %d is enabled.\n", res->field_idx);
16866 printf("Field index %d is disabled.\n", res->field_idx);
16868 } else if (!strcmp(res->opt, "set"))
16869 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16871 else if (!strcmp(res->opt, "clear"))
16872 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16875 printf("Failed to configure input set field.\n");
16879 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16880 &inset, inset_type);
16882 printf("Failed to set input set.\n");
16887 if (ret == -ENOTSUP)
16888 printf("Function not supported\n");
16891 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16892 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16894 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16895 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16897 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16898 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16900 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16901 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16903 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16904 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16906 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16907 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16909 "hash_inset#fdir_inset#fdir_flx_inset");
16910 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16911 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16912 opt, "get#set#clear");
16913 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16914 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16916 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16917 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16920 cmdline_parse_inst_t cmd_cfg_input_set = {
16921 .f = cmd_cfg_input_set_parsed,
16923 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16924 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16926 (void *)&cmd_cfg_input_set_port,
16927 (void *)&cmd_cfg_input_set_cfg,
16928 (void *)&cmd_cfg_input_set_port_id,
16929 (void *)&cmd_cfg_input_set_pctype,
16930 (void *)&cmd_cfg_input_set_pctype_id,
16931 (void *)&cmd_cfg_input_set_inset_type,
16932 (void *)&cmd_cfg_input_set_opt,
16933 (void *)&cmd_cfg_input_set_field,
16934 (void *)&cmd_cfg_input_set_field_idx,
16939 /* Clear input set */
16940 struct cmd_clear_input_set_result {
16941 cmdline_fixed_string_t port;
16942 cmdline_fixed_string_t cfg;
16944 cmdline_fixed_string_t pctype;
16946 cmdline_fixed_string_t inset_type;
16947 cmdline_fixed_string_t clear;
16948 cmdline_fixed_string_t all;
16952 cmd_clear_input_set_parsed(
16953 __attribute__((unused)) void *parsed_result,
16954 __attribute__((unused)) struct cmdline *cl,
16955 __attribute__((unused)) void *data)
16957 #ifdef RTE_LIBRTE_I40E_PMD
16958 struct cmd_clear_input_set_result *res = parsed_result;
16959 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16960 struct rte_pmd_i40e_inset inset;
16962 int ret = -ENOTSUP;
16964 if (!all_ports_stopped()) {
16965 printf("Please stop all ports first\n");
16969 #ifdef RTE_LIBRTE_I40E_PMD
16970 if (!strcmp(res->inset_type, "hash_inset"))
16971 inset_type = INSET_HASH;
16972 else if (!strcmp(res->inset_type, "fdir_inset"))
16973 inset_type = INSET_FDIR;
16974 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16975 inset_type = INSET_FDIR_FLX;
16977 memset(&inset, 0, sizeof(inset));
16979 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16980 &inset, inset_type);
16982 printf("Failed to clear input set.\n");
16988 if (ret == -ENOTSUP)
16989 printf("Function not supported\n");
16992 cmdline_parse_token_string_t cmd_clear_input_set_port =
16993 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16995 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16996 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16998 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16999 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17001 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17002 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17004 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17005 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17007 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17008 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17010 "hash_inset#fdir_inset#fdir_flx_inset");
17011 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17012 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17014 cmdline_parse_token_string_t cmd_clear_input_set_all =
17015 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17018 cmdline_parse_inst_t cmd_clear_input_set = {
17019 .f = cmd_clear_input_set_parsed,
17021 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17022 "fdir_inset|fdir_flx_inset clear all",
17024 (void *)&cmd_clear_input_set_port,
17025 (void *)&cmd_clear_input_set_cfg,
17026 (void *)&cmd_clear_input_set_port_id,
17027 (void *)&cmd_clear_input_set_pctype,
17028 (void *)&cmd_clear_input_set_pctype_id,
17029 (void *)&cmd_clear_input_set_inset_type,
17030 (void *)&cmd_clear_input_set_clear,
17031 (void *)&cmd_clear_input_set_all,
17036 /* show vf stats */
17038 /* Common result structure for show vf stats */
17039 struct cmd_show_vf_stats_result {
17040 cmdline_fixed_string_t show;
17041 cmdline_fixed_string_t vf;
17042 cmdline_fixed_string_t stats;
17047 /* Common CLI fields show vf stats*/
17048 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17049 TOKEN_STRING_INITIALIZER
17050 (struct cmd_show_vf_stats_result,
17052 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17053 TOKEN_STRING_INITIALIZER
17054 (struct cmd_show_vf_stats_result,
17056 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17057 TOKEN_STRING_INITIALIZER
17058 (struct cmd_show_vf_stats_result,
17060 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17061 TOKEN_NUM_INITIALIZER
17062 (struct cmd_show_vf_stats_result,
17064 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17065 TOKEN_NUM_INITIALIZER
17066 (struct cmd_show_vf_stats_result,
17070 cmd_show_vf_stats_parsed(
17071 void *parsed_result,
17072 __attribute__((unused)) struct cmdline *cl,
17073 __attribute__((unused)) void *data)
17075 struct cmd_show_vf_stats_result *res = parsed_result;
17076 struct rte_eth_stats stats;
17077 int ret = -ENOTSUP;
17078 static const char *nic_stats_border = "########################";
17080 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17083 memset(&stats, 0, sizeof(stats));
17085 #ifdef RTE_LIBRTE_I40E_PMD
17086 if (ret == -ENOTSUP)
17087 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17091 #ifdef RTE_LIBRTE_BNXT_PMD
17092 if (ret == -ENOTSUP)
17093 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17102 printf("invalid vf_id %d\n", res->vf_id);
17105 printf("invalid port_id %d\n", res->port_id);
17108 printf("function not implemented\n");
17111 printf("programming error: (%s)\n", strerror(-ret));
17114 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17115 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17117 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17119 stats.ipackets, stats.imissed, stats.ibytes);
17120 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17121 printf(" RX-nombuf: %-10"PRIu64"\n",
17123 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17125 stats.opackets, stats.oerrors, stats.obytes);
17127 printf(" %s############################%s\n",
17128 nic_stats_border, nic_stats_border);
17131 cmdline_parse_inst_t cmd_show_vf_stats = {
17132 .f = cmd_show_vf_stats_parsed,
17134 .help_str = "show vf stats <port_id> <vf_id>",
17136 (void *)&cmd_show_vf_stats_show,
17137 (void *)&cmd_show_vf_stats_vf,
17138 (void *)&cmd_show_vf_stats_stats,
17139 (void *)&cmd_show_vf_stats_port_id,
17140 (void *)&cmd_show_vf_stats_vf_id,
17145 /* clear vf stats */
17147 /* Common result structure for clear vf stats */
17148 struct cmd_clear_vf_stats_result {
17149 cmdline_fixed_string_t clear;
17150 cmdline_fixed_string_t vf;
17151 cmdline_fixed_string_t stats;
17156 /* Common CLI fields clear vf stats*/
17157 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17158 TOKEN_STRING_INITIALIZER
17159 (struct cmd_clear_vf_stats_result,
17161 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17162 TOKEN_STRING_INITIALIZER
17163 (struct cmd_clear_vf_stats_result,
17165 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17166 TOKEN_STRING_INITIALIZER
17167 (struct cmd_clear_vf_stats_result,
17169 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17170 TOKEN_NUM_INITIALIZER
17171 (struct cmd_clear_vf_stats_result,
17173 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17174 TOKEN_NUM_INITIALIZER
17175 (struct cmd_clear_vf_stats_result,
17179 cmd_clear_vf_stats_parsed(
17180 void *parsed_result,
17181 __attribute__((unused)) struct cmdline *cl,
17182 __attribute__((unused)) void *data)
17184 struct cmd_clear_vf_stats_result *res = parsed_result;
17185 int ret = -ENOTSUP;
17187 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17190 #ifdef RTE_LIBRTE_I40E_PMD
17191 if (ret == -ENOTSUP)
17192 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17195 #ifdef RTE_LIBRTE_BNXT_PMD
17196 if (ret == -ENOTSUP)
17197 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17205 printf("invalid vf_id %d\n", res->vf_id);
17208 printf("invalid port_id %d\n", res->port_id);
17211 printf("function not implemented\n");
17214 printf("programming error: (%s)\n", strerror(-ret));
17218 cmdline_parse_inst_t cmd_clear_vf_stats = {
17219 .f = cmd_clear_vf_stats_parsed,
17221 .help_str = "clear vf stats <port_id> <vf_id>",
17223 (void *)&cmd_clear_vf_stats_clear,
17224 (void *)&cmd_clear_vf_stats_vf,
17225 (void *)&cmd_clear_vf_stats_stats,
17226 (void *)&cmd_clear_vf_stats_port_id,
17227 (void *)&cmd_clear_vf_stats_vf_id,
17232 /* port config pctype mapping reset */
17234 /* Common result structure for port config pctype mapping reset */
17235 struct cmd_pctype_mapping_reset_result {
17236 cmdline_fixed_string_t port;
17237 cmdline_fixed_string_t config;
17239 cmdline_fixed_string_t pctype;
17240 cmdline_fixed_string_t mapping;
17241 cmdline_fixed_string_t reset;
17244 /* Common CLI fields for port config pctype mapping reset*/
17245 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17246 TOKEN_STRING_INITIALIZER
17247 (struct cmd_pctype_mapping_reset_result,
17249 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17250 TOKEN_STRING_INITIALIZER
17251 (struct cmd_pctype_mapping_reset_result,
17253 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17254 TOKEN_NUM_INITIALIZER
17255 (struct cmd_pctype_mapping_reset_result,
17257 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17258 TOKEN_STRING_INITIALIZER
17259 (struct cmd_pctype_mapping_reset_result,
17261 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17262 TOKEN_STRING_INITIALIZER
17263 (struct cmd_pctype_mapping_reset_result,
17264 mapping, "mapping");
17265 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17266 TOKEN_STRING_INITIALIZER
17267 (struct cmd_pctype_mapping_reset_result,
17271 cmd_pctype_mapping_reset_parsed(
17272 void *parsed_result,
17273 __attribute__((unused)) struct cmdline *cl,
17274 __attribute__((unused)) void *data)
17276 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17277 int ret = -ENOTSUP;
17279 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17282 #ifdef RTE_LIBRTE_I40E_PMD
17283 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17290 printf("invalid port_id %d\n", res->port_id);
17293 printf("function not implemented\n");
17296 printf("programming error: (%s)\n", strerror(-ret));
17300 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17301 .f = cmd_pctype_mapping_reset_parsed,
17303 .help_str = "port config <port_id> pctype mapping reset",
17305 (void *)&cmd_pctype_mapping_reset_port,
17306 (void *)&cmd_pctype_mapping_reset_config,
17307 (void *)&cmd_pctype_mapping_reset_port_id,
17308 (void *)&cmd_pctype_mapping_reset_pctype,
17309 (void *)&cmd_pctype_mapping_reset_mapping,
17310 (void *)&cmd_pctype_mapping_reset_reset,
17315 /* show port pctype mapping */
17317 /* Common result structure for show port pctype mapping */
17318 struct cmd_pctype_mapping_get_result {
17319 cmdline_fixed_string_t show;
17320 cmdline_fixed_string_t port;
17322 cmdline_fixed_string_t pctype;
17323 cmdline_fixed_string_t mapping;
17326 /* Common CLI fields for pctype mapping get */
17327 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17328 TOKEN_STRING_INITIALIZER
17329 (struct cmd_pctype_mapping_get_result,
17331 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17332 TOKEN_STRING_INITIALIZER
17333 (struct cmd_pctype_mapping_get_result,
17335 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17336 TOKEN_NUM_INITIALIZER
17337 (struct cmd_pctype_mapping_get_result,
17339 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17340 TOKEN_STRING_INITIALIZER
17341 (struct cmd_pctype_mapping_get_result,
17343 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17344 TOKEN_STRING_INITIALIZER
17345 (struct cmd_pctype_mapping_get_result,
17346 mapping, "mapping");
17349 cmd_pctype_mapping_get_parsed(
17350 void *parsed_result,
17351 __attribute__((unused)) struct cmdline *cl,
17352 __attribute__((unused)) void *data)
17354 struct cmd_pctype_mapping_get_result *res = parsed_result;
17355 int ret = -ENOTSUP;
17356 #ifdef RTE_LIBRTE_I40E_PMD
17357 struct rte_pmd_i40e_flow_type_mapping
17358 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17359 int i, j, first_pctype;
17362 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17365 #ifdef RTE_LIBRTE_I40E_PMD
17366 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17373 printf("invalid port_id %d\n", res->port_id);
17376 printf("function not implemented\n");
17379 printf("programming error: (%s)\n", strerror(-ret));
17383 #ifdef RTE_LIBRTE_I40E_PMD
17384 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17385 if (mapping[i].pctype != 0ULL) {
17388 printf("pctype: ");
17389 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17390 if (mapping[i].pctype & (1ULL << j)) {
17391 printf(first_pctype ?
17392 "%02d" : ",%02d", j);
17396 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17402 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17403 .f = cmd_pctype_mapping_get_parsed,
17405 .help_str = "show port <port_id> pctype mapping",
17407 (void *)&cmd_pctype_mapping_get_show,
17408 (void *)&cmd_pctype_mapping_get_port,
17409 (void *)&cmd_pctype_mapping_get_port_id,
17410 (void *)&cmd_pctype_mapping_get_pctype,
17411 (void *)&cmd_pctype_mapping_get_mapping,
17416 /* port config pctype mapping update */
17418 /* Common result structure for port config pctype mapping update */
17419 struct cmd_pctype_mapping_update_result {
17420 cmdline_fixed_string_t port;
17421 cmdline_fixed_string_t config;
17423 cmdline_fixed_string_t pctype;
17424 cmdline_fixed_string_t mapping;
17425 cmdline_fixed_string_t update;
17426 cmdline_fixed_string_t pctype_list;
17427 uint16_t flow_type;
17430 /* Common CLI fields for pctype mapping update*/
17431 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17432 TOKEN_STRING_INITIALIZER
17433 (struct cmd_pctype_mapping_update_result,
17435 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17436 TOKEN_STRING_INITIALIZER
17437 (struct cmd_pctype_mapping_update_result,
17439 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17440 TOKEN_NUM_INITIALIZER
17441 (struct cmd_pctype_mapping_update_result,
17443 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17444 TOKEN_STRING_INITIALIZER
17445 (struct cmd_pctype_mapping_update_result,
17447 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17448 TOKEN_STRING_INITIALIZER
17449 (struct cmd_pctype_mapping_update_result,
17450 mapping, "mapping");
17451 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17452 TOKEN_STRING_INITIALIZER
17453 (struct cmd_pctype_mapping_update_result,
17455 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17456 TOKEN_STRING_INITIALIZER
17457 (struct cmd_pctype_mapping_update_result,
17458 pctype_list, NULL);
17459 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17460 TOKEN_NUM_INITIALIZER
17461 (struct cmd_pctype_mapping_update_result,
17462 flow_type, UINT16);
17465 cmd_pctype_mapping_update_parsed(
17466 void *parsed_result,
17467 __attribute__((unused)) struct cmdline *cl,
17468 __attribute__((unused)) void *data)
17470 struct cmd_pctype_mapping_update_result *res = parsed_result;
17471 int ret = -ENOTSUP;
17472 #ifdef RTE_LIBRTE_I40E_PMD
17473 struct rte_pmd_i40e_flow_type_mapping mapping;
17475 unsigned int nb_item;
17476 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17479 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17482 #ifdef RTE_LIBRTE_I40E_PMD
17483 nb_item = parse_item_list(res->pctype_list, "pctypes",
17484 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17485 mapping.flow_type = res->flow_type;
17486 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17487 mapping.pctype |= (1ULL << pctype_list[i]);
17488 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17498 printf("invalid pctype or flow type\n");
17501 printf("invalid port_id %d\n", res->port_id);
17504 printf("function not implemented\n");
17507 printf("programming error: (%s)\n", strerror(-ret));
17511 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17512 .f = cmd_pctype_mapping_update_parsed,
17514 .help_str = "port config <port_id> pctype mapping update"
17515 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17517 (void *)&cmd_pctype_mapping_update_port,
17518 (void *)&cmd_pctype_mapping_update_config,
17519 (void *)&cmd_pctype_mapping_update_port_id,
17520 (void *)&cmd_pctype_mapping_update_pctype,
17521 (void *)&cmd_pctype_mapping_update_mapping,
17522 (void *)&cmd_pctype_mapping_update_update,
17523 (void *)&cmd_pctype_mapping_update_pc_type,
17524 (void *)&cmd_pctype_mapping_update_flow_type,
17529 /* ptype mapping get */
17531 /* Common result structure for ptype mapping get */
17532 struct cmd_ptype_mapping_get_result {
17533 cmdline_fixed_string_t ptype;
17534 cmdline_fixed_string_t mapping;
17535 cmdline_fixed_string_t get;
17537 uint8_t valid_only;
17540 /* Common CLI fields for ptype mapping get */
17541 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17542 TOKEN_STRING_INITIALIZER
17543 (struct cmd_ptype_mapping_get_result,
17545 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17546 TOKEN_STRING_INITIALIZER
17547 (struct cmd_ptype_mapping_get_result,
17548 mapping, "mapping");
17549 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17550 TOKEN_STRING_INITIALIZER
17551 (struct cmd_ptype_mapping_get_result,
17553 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17554 TOKEN_NUM_INITIALIZER
17555 (struct cmd_ptype_mapping_get_result,
17557 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17558 TOKEN_NUM_INITIALIZER
17559 (struct cmd_ptype_mapping_get_result,
17560 valid_only, UINT8);
17563 cmd_ptype_mapping_get_parsed(
17564 void *parsed_result,
17565 __attribute__((unused)) struct cmdline *cl,
17566 __attribute__((unused)) void *data)
17568 struct cmd_ptype_mapping_get_result *res = parsed_result;
17569 int ret = -ENOTSUP;
17570 #ifdef RTE_LIBRTE_I40E_PMD
17571 int max_ptype_num = 256;
17572 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17577 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17580 #ifdef RTE_LIBRTE_I40E_PMD
17581 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17592 printf("invalid port_id %d\n", res->port_id);
17595 printf("function not implemented\n");
17598 printf("programming error: (%s)\n", strerror(-ret));
17601 #ifdef RTE_LIBRTE_I40E_PMD
17603 for (i = 0; i < count; i++)
17604 printf("%3d\t0x%08x\n",
17605 mapping[i].hw_ptype, mapping[i].sw_ptype);
17610 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17611 .f = cmd_ptype_mapping_get_parsed,
17613 .help_str = "ptype mapping get <port_id> <valid_only>",
17615 (void *)&cmd_ptype_mapping_get_ptype,
17616 (void *)&cmd_ptype_mapping_get_mapping,
17617 (void *)&cmd_ptype_mapping_get_get,
17618 (void *)&cmd_ptype_mapping_get_port_id,
17619 (void *)&cmd_ptype_mapping_get_valid_only,
17624 /* ptype mapping replace */
17626 /* Common result structure for ptype mapping replace */
17627 struct cmd_ptype_mapping_replace_result {
17628 cmdline_fixed_string_t ptype;
17629 cmdline_fixed_string_t mapping;
17630 cmdline_fixed_string_t replace;
17637 /* Common CLI fields for ptype mapping replace */
17638 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17639 TOKEN_STRING_INITIALIZER
17640 (struct cmd_ptype_mapping_replace_result,
17642 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17643 TOKEN_STRING_INITIALIZER
17644 (struct cmd_ptype_mapping_replace_result,
17645 mapping, "mapping");
17646 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17647 TOKEN_STRING_INITIALIZER
17648 (struct cmd_ptype_mapping_replace_result,
17649 replace, "replace");
17650 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17651 TOKEN_NUM_INITIALIZER
17652 (struct cmd_ptype_mapping_replace_result,
17654 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17655 TOKEN_NUM_INITIALIZER
17656 (struct cmd_ptype_mapping_replace_result,
17658 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17659 TOKEN_NUM_INITIALIZER
17660 (struct cmd_ptype_mapping_replace_result,
17662 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17663 TOKEN_NUM_INITIALIZER
17664 (struct cmd_ptype_mapping_replace_result,
17668 cmd_ptype_mapping_replace_parsed(
17669 void *parsed_result,
17670 __attribute__((unused)) struct cmdline *cl,
17671 __attribute__((unused)) void *data)
17673 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17674 int ret = -ENOTSUP;
17676 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17679 #ifdef RTE_LIBRTE_I40E_PMD
17680 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17690 printf("invalid ptype 0x%8x or 0x%8x\n",
17691 res->target, res->pkt_type);
17694 printf("invalid port_id %d\n", res->port_id);
17697 printf("function not implemented\n");
17700 printf("programming error: (%s)\n", strerror(-ret));
17704 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17705 .f = cmd_ptype_mapping_replace_parsed,
17708 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17710 (void *)&cmd_ptype_mapping_replace_ptype,
17711 (void *)&cmd_ptype_mapping_replace_mapping,
17712 (void *)&cmd_ptype_mapping_replace_replace,
17713 (void *)&cmd_ptype_mapping_replace_port_id,
17714 (void *)&cmd_ptype_mapping_replace_target,
17715 (void *)&cmd_ptype_mapping_replace_mask,
17716 (void *)&cmd_ptype_mapping_replace_pkt_type,
17721 /* ptype mapping reset */
17723 /* Common result structure for ptype mapping reset */
17724 struct cmd_ptype_mapping_reset_result {
17725 cmdline_fixed_string_t ptype;
17726 cmdline_fixed_string_t mapping;
17727 cmdline_fixed_string_t reset;
17731 /* Common CLI fields for ptype mapping reset*/
17732 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17733 TOKEN_STRING_INITIALIZER
17734 (struct cmd_ptype_mapping_reset_result,
17736 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17737 TOKEN_STRING_INITIALIZER
17738 (struct cmd_ptype_mapping_reset_result,
17739 mapping, "mapping");
17740 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17741 TOKEN_STRING_INITIALIZER
17742 (struct cmd_ptype_mapping_reset_result,
17744 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17745 TOKEN_NUM_INITIALIZER
17746 (struct cmd_ptype_mapping_reset_result,
17750 cmd_ptype_mapping_reset_parsed(
17751 void *parsed_result,
17752 __attribute__((unused)) struct cmdline *cl,
17753 __attribute__((unused)) void *data)
17755 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17756 int ret = -ENOTSUP;
17758 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17761 #ifdef RTE_LIBRTE_I40E_PMD
17762 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17769 printf("invalid port_id %d\n", res->port_id);
17772 printf("function not implemented\n");
17775 printf("programming error: (%s)\n", strerror(-ret));
17779 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17780 .f = cmd_ptype_mapping_reset_parsed,
17782 .help_str = "ptype mapping reset <port_id>",
17784 (void *)&cmd_ptype_mapping_reset_ptype,
17785 (void *)&cmd_ptype_mapping_reset_mapping,
17786 (void *)&cmd_ptype_mapping_reset_reset,
17787 (void *)&cmd_ptype_mapping_reset_port_id,
17792 /* ptype mapping update */
17794 /* Common result structure for ptype mapping update */
17795 struct cmd_ptype_mapping_update_result {
17796 cmdline_fixed_string_t ptype;
17797 cmdline_fixed_string_t mapping;
17798 cmdline_fixed_string_t reset;
17804 /* Common CLI fields for ptype mapping update*/
17805 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17806 TOKEN_STRING_INITIALIZER
17807 (struct cmd_ptype_mapping_update_result,
17809 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17810 TOKEN_STRING_INITIALIZER
17811 (struct cmd_ptype_mapping_update_result,
17812 mapping, "mapping");
17813 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17814 TOKEN_STRING_INITIALIZER
17815 (struct cmd_ptype_mapping_update_result,
17817 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17818 TOKEN_NUM_INITIALIZER
17819 (struct cmd_ptype_mapping_update_result,
17821 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17822 TOKEN_NUM_INITIALIZER
17823 (struct cmd_ptype_mapping_update_result,
17825 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17826 TOKEN_NUM_INITIALIZER
17827 (struct cmd_ptype_mapping_update_result,
17831 cmd_ptype_mapping_update_parsed(
17832 void *parsed_result,
17833 __attribute__((unused)) struct cmdline *cl,
17834 __attribute__((unused)) void *data)
17836 struct cmd_ptype_mapping_update_result *res = parsed_result;
17837 int ret = -ENOTSUP;
17838 #ifdef RTE_LIBRTE_I40E_PMD
17839 struct rte_pmd_i40e_ptype_mapping mapping;
17841 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17844 #ifdef RTE_LIBRTE_I40E_PMD
17845 mapping.hw_ptype = res->hw_ptype;
17846 mapping.sw_ptype = res->sw_ptype;
17847 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17857 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17860 printf("invalid port_id %d\n", res->port_id);
17863 printf("function not implemented\n");
17866 printf("programming error: (%s)\n", strerror(-ret));
17870 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17871 .f = cmd_ptype_mapping_update_parsed,
17873 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17875 (void *)&cmd_ptype_mapping_update_ptype,
17876 (void *)&cmd_ptype_mapping_update_mapping,
17877 (void *)&cmd_ptype_mapping_update_update,
17878 (void *)&cmd_ptype_mapping_update_port_id,
17879 (void *)&cmd_ptype_mapping_update_hw_ptype,
17880 (void *)&cmd_ptype_mapping_update_sw_ptype,
17885 /* Common result structure for file commands */
17886 struct cmd_cmdfile_result {
17887 cmdline_fixed_string_t load;
17888 cmdline_fixed_string_t filename;
17891 /* Common CLI fields for file commands */
17892 cmdline_parse_token_string_t cmd_load_cmdfile =
17893 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17894 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17895 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17898 cmd_load_from_file_parsed(
17899 void *parsed_result,
17900 __attribute__((unused)) struct cmdline *cl,
17901 __attribute__((unused)) void *data)
17903 struct cmd_cmdfile_result *res = parsed_result;
17905 cmdline_read_from_file(res->filename);
17908 cmdline_parse_inst_t cmd_load_from_file = {
17909 .f = cmd_load_from_file_parsed,
17911 .help_str = "load <filename>",
17913 (void *)&cmd_load_cmdfile,
17914 (void *)&cmd_load_cmdfile_filename,
17919 /* Get Rx offloads capabilities */
17920 struct cmd_rx_offload_get_capa_result {
17921 cmdline_fixed_string_t show;
17922 cmdline_fixed_string_t port;
17924 cmdline_fixed_string_t rx_offload;
17925 cmdline_fixed_string_t capabilities;
17928 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17929 TOKEN_STRING_INITIALIZER
17930 (struct cmd_rx_offload_get_capa_result,
17932 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17933 TOKEN_STRING_INITIALIZER
17934 (struct cmd_rx_offload_get_capa_result,
17936 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17937 TOKEN_NUM_INITIALIZER
17938 (struct cmd_rx_offload_get_capa_result,
17940 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17941 TOKEN_STRING_INITIALIZER
17942 (struct cmd_rx_offload_get_capa_result,
17943 rx_offload, "rx_offload");
17944 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17945 TOKEN_STRING_INITIALIZER
17946 (struct cmd_rx_offload_get_capa_result,
17947 capabilities, "capabilities");
17950 print_rx_offloads(uint64_t offloads)
17952 uint64_t single_offload;
17960 begin = __builtin_ctzll(offloads);
17961 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17963 single_offload = 1ULL << begin;
17964 for (bit = begin; bit < end; bit++) {
17965 if (offloads & single_offload)
17967 rte_eth_dev_rx_offload_name(single_offload));
17968 single_offload <<= 1;
17973 cmd_rx_offload_get_capa_parsed(
17974 void *parsed_result,
17975 __attribute__((unused)) struct cmdline *cl,
17976 __attribute__((unused)) void *data)
17978 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17979 struct rte_eth_dev_info dev_info;
17980 portid_t port_id = res->port_id;
17981 uint64_t queue_offloads;
17982 uint64_t port_offloads;
17984 rte_eth_dev_info_get(port_id, &dev_info);
17985 queue_offloads = dev_info.rx_queue_offload_capa;
17986 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17988 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17989 printf(" Per Queue :");
17990 print_rx_offloads(queue_offloads);
17993 printf(" Per Port :");
17994 print_rx_offloads(port_offloads);
17998 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17999 .f = cmd_rx_offload_get_capa_parsed,
18001 .help_str = "show port <port_id> rx_offload capabilities",
18003 (void *)&cmd_rx_offload_get_capa_show,
18004 (void *)&cmd_rx_offload_get_capa_port,
18005 (void *)&cmd_rx_offload_get_capa_port_id,
18006 (void *)&cmd_rx_offload_get_capa_rx_offload,
18007 (void *)&cmd_rx_offload_get_capa_capabilities,
18012 /* Get Rx offloads configuration */
18013 struct cmd_rx_offload_get_configuration_result {
18014 cmdline_fixed_string_t show;
18015 cmdline_fixed_string_t port;
18017 cmdline_fixed_string_t rx_offload;
18018 cmdline_fixed_string_t configuration;
18021 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18022 TOKEN_STRING_INITIALIZER
18023 (struct cmd_rx_offload_get_configuration_result,
18025 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18026 TOKEN_STRING_INITIALIZER
18027 (struct cmd_rx_offload_get_configuration_result,
18029 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18030 TOKEN_NUM_INITIALIZER
18031 (struct cmd_rx_offload_get_configuration_result,
18033 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18034 TOKEN_STRING_INITIALIZER
18035 (struct cmd_rx_offload_get_configuration_result,
18036 rx_offload, "rx_offload");
18037 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18038 TOKEN_STRING_INITIALIZER
18039 (struct cmd_rx_offload_get_configuration_result,
18040 configuration, "configuration");
18043 cmd_rx_offload_get_configuration_parsed(
18044 void *parsed_result,
18045 __attribute__((unused)) struct cmdline *cl,
18046 __attribute__((unused)) void *data)
18048 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18049 struct rte_eth_dev_info dev_info;
18050 portid_t port_id = res->port_id;
18051 struct rte_port *port = &ports[port_id];
18052 uint64_t port_offloads;
18053 uint64_t queue_offloads;
18054 uint16_t nb_rx_queues;
18057 printf("Rx Offloading Configuration of port %d :\n", port_id);
18059 port_offloads = port->dev_conf.rxmode.offloads;
18061 print_rx_offloads(port_offloads);
18064 rte_eth_dev_info_get(port_id, &dev_info);
18065 nb_rx_queues = dev_info.nb_rx_queues;
18066 for (q = 0; q < nb_rx_queues; q++) {
18067 queue_offloads = port->rx_conf[q].offloads;
18068 printf(" Queue[%2d] :", q);
18069 print_rx_offloads(queue_offloads);
18075 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18076 .f = cmd_rx_offload_get_configuration_parsed,
18078 .help_str = "show port <port_id> rx_offload configuration",
18080 (void *)&cmd_rx_offload_get_configuration_show,
18081 (void *)&cmd_rx_offload_get_configuration_port,
18082 (void *)&cmd_rx_offload_get_configuration_port_id,
18083 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18084 (void *)&cmd_rx_offload_get_configuration_configuration,
18089 /* Enable/Disable a per port offloading */
18090 struct cmd_config_per_port_rx_offload_result {
18091 cmdline_fixed_string_t port;
18092 cmdline_fixed_string_t config;
18094 cmdline_fixed_string_t rx_offload;
18095 cmdline_fixed_string_t offload;
18096 cmdline_fixed_string_t on_off;
18099 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18100 TOKEN_STRING_INITIALIZER
18101 (struct cmd_config_per_port_rx_offload_result,
18103 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18104 TOKEN_STRING_INITIALIZER
18105 (struct cmd_config_per_port_rx_offload_result,
18107 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18108 TOKEN_NUM_INITIALIZER
18109 (struct cmd_config_per_port_rx_offload_result,
18111 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18112 TOKEN_STRING_INITIALIZER
18113 (struct cmd_config_per_port_rx_offload_result,
18114 rx_offload, "rx_offload");
18115 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18116 TOKEN_STRING_INITIALIZER
18117 (struct cmd_config_per_port_rx_offload_result,
18118 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18119 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18120 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18121 "crc_strip#scatter#timestamp#security#keep_crc");
18122 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18123 TOKEN_STRING_INITIALIZER
18124 (struct cmd_config_per_port_rx_offload_result,
18128 search_rx_offload(const char *name)
18130 uint64_t single_offload;
18131 const char *single_name;
18135 single_offload = 1;
18136 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18137 single_name = rte_eth_dev_rx_offload_name(single_offload);
18138 if (!strcasecmp(single_name, name)) {
18142 single_offload <<= 1;
18146 return single_offload;
18152 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18153 __attribute__((unused)) struct cmdline *cl,
18154 __attribute__((unused)) void *data)
18156 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18157 portid_t port_id = res->port_id;
18158 struct rte_eth_dev_info dev_info;
18159 struct rte_port *port = &ports[port_id];
18160 uint64_t single_offload;
18161 uint16_t nb_rx_queues;
18164 if (port->port_status != RTE_PORT_STOPPED) {
18165 printf("Error: Can't config offload when Port %d "
18166 "is not stopped\n", port_id);
18170 single_offload = search_rx_offload(res->offload);
18171 if (single_offload == 0) {
18172 printf("Unknown offload name: %s\n", res->offload);
18176 rte_eth_dev_info_get(port_id, &dev_info);
18177 nb_rx_queues = dev_info.nb_rx_queues;
18178 if (!strcmp(res->on_off, "on")) {
18179 port->dev_conf.rxmode.offloads |= single_offload;
18180 for (q = 0; q < nb_rx_queues; q++)
18181 port->rx_conf[q].offloads |= single_offload;
18183 port->dev_conf.rxmode.offloads &= ~single_offload;
18184 for (q = 0; q < nb_rx_queues; q++)
18185 port->rx_conf[q].offloads &= ~single_offload;
18188 cmd_reconfig_device_queue(port_id, 1, 1);
18191 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18192 .f = cmd_config_per_port_rx_offload_parsed,
18194 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18195 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18196 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18197 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18200 (void *)&cmd_config_per_port_rx_offload_result_port,
18201 (void *)&cmd_config_per_port_rx_offload_result_config,
18202 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18203 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18204 (void *)&cmd_config_per_port_rx_offload_result_offload,
18205 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18210 /* Enable/Disable a per queue offloading */
18211 struct cmd_config_per_queue_rx_offload_result {
18212 cmdline_fixed_string_t port;
18214 cmdline_fixed_string_t rxq;
18216 cmdline_fixed_string_t rx_offload;
18217 cmdline_fixed_string_t offload;
18218 cmdline_fixed_string_t on_off;
18221 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18222 TOKEN_STRING_INITIALIZER
18223 (struct cmd_config_per_queue_rx_offload_result,
18225 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18226 TOKEN_NUM_INITIALIZER
18227 (struct cmd_config_per_queue_rx_offload_result,
18229 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18230 TOKEN_STRING_INITIALIZER
18231 (struct cmd_config_per_queue_rx_offload_result,
18233 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18234 TOKEN_NUM_INITIALIZER
18235 (struct cmd_config_per_queue_rx_offload_result,
18237 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18238 TOKEN_STRING_INITIALIZER
18239 (struct cmd_config_per_queue_rx_offload_result,
18240 rx_offload, "rx_offload");
18241 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18242 TOKEN_STRING_INITIALIZER
18243 (struct cmd_config_per_queue_rx_offload_result,
18244 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18245 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18246 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18247 "crc_strip#scatter#timestamp#security#keep_crc");
18248 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18249 TOKEN_STRING_INITIALIZER
18250 (struct cmd_config_per_queue_rx_offload_result,
18254 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18255 __attribute__((unused)) struct cmdline *cl,
18256 __attribute__((unused)) void *data)
18258 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18259 struct rte_eth_dev_info dev_info;
18260 portid_t port_id = res->port_id;
18261 uint16_t queue_id = res->queue_id;
18262 struct rte_port *port = &ports[port_id];
18263 uint64_t single_offload;
18265 if (port->port_status != RTE_PORT_STOPPED) {
18266 printf("Error: Can't config offload when Port %d "
18267 "is not stopped\n", port_id);
18271 rte_eth_dev_info_get(port_id, &dev_info);
18272 if (queue_id >= dev_info.nb_rx_queues) {
18273 printf("Error: input queue_id should be 0 ... "
18274 "%d\n", dev_info.nb_rx_queues - 1);
18278 single_offload = search_rx_offload(res->offload);
18279 if (single_offload == 0) {
18280 printf("Unknown offload name: %s\n", res->offload);
18284 if (!strcmp(res->on_off, "on"))
18285 port->rx_conf[queue_id].offloads |= single_offload;
18287 port->rx_conf[queue_id].offloads &= ~single_offload;
18289 cmd_reconfig_device_queue(port_id, 1, 1);
18292 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18293 .f = cmd_config_per_queue_rx_offload_parsed,
18295 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18296 "vlan_strip|ipv4_cksum|"
18297 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18298 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18299 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18302 (void *)&cmd_config_per_queue_rx_offload_result_port,
18303 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18304 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18305 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18306 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18307 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18308 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18313 /* Get Tx offloads capabilities */
18314 struct cmd_tx_offload_get_capa_result {
18315 cmdline_fixed_string_t show;
18316 cmdline_fixed_string_t port;
18318 cmdline_fixed_string_t tx_offload;
18319 cmdline_fixed_string_t capabilities;
18322 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18323 TOKEN_STRING_INITIALIZER
18324 (struct cmd_tx_offload_get_capa_result,
18326 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18327 TOKEN_STRING_INITIALIZER
18328 (struct cmd_tx_offload_get_capa_result,
18330 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18331 TOKEN_NUM_INITIALIZER
18332 (struct cmd_tx_offload_get_capa_result,
18334 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18335 TOKEN_STRING_INITIALIZER
18336 (struct cmd_tx_offload_get_capa_result,
18337 tx_offload, "tx_offload");
18338 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18339 TOKEN_STRING_INITIALIZER
18340 (struct cmd_tx_offload_get_capa_result,
18341 capabilities, "capabilities");
18344 print_tx_offloads(uint64_t offloads)
18346 uint64_t single_offload;
18354 begin = __builtin_ctzll(offloads);
18355 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18357 single_offload = 1ULL << begin;
18358 for (bit = begin; bit < end; bit++) {
18359 if (offloads & single_offload)
18361 rte_eth_dev_tx_offload_name(single_offload));
18362 single_offload <<= 1;
18367 cmd_tx_offload_get_capa_parsed(
18368 void *parsed_result,
18369 __attribute__((unused)) struct cmdline *cl,
18370 __attribute__((unused)) void *data)
18372 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18373 struct rte_eth_dev_info dev_info;
18374 portid_t port_id = res->port_id;
18375 uint64_t queue_offloads;
18376 uint64_t port_offloads;
18378 rte_eth_dev_info_get(port_id, &dev_info);
18379 queue_offloads = dev_info.tx_queue_offload_capa;
18380 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18382 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18383 printf(" Per Queue :");
18384 print_tx_offloads(queue_offloads);
18387 printf(" Per Port :");
18388 print_tx_offloads(port_offloads);
18392 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18393 .f = cmd_tx_offload_get_capa_parsed,
18395 .help_str = "show port <port_id> tx_offload capabilities",
18397 (void *)&cmd_tx_offload_get_capa_show,
18398 (void *)&cmd_tx_offload_get_capa_port,
18399 (void *)&cmd_tx_offload_get_capa_port_id,
18400 (void *)&cmd_tx_offload_get_capa_tx_offload,
18401 (void *)&cmd_tx_offload_get_capa_capabilities,
18406 /* Get Tx offloads configuration */
18407 struct cmd_tx_offload_get_configuration_result {
18408 cmdline_fixed_string_t show;
18409 cmdline_fixed_string_t port;
18411 cmdline_fixed_string_t tx_offload;
18412 cmdline_fixed_string_t configuration;
18415 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18416 TOKEN_STRING_INITIALIZER
18417 (struct cmd_tx_offload_get_configuration_result,
18419 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18420 TOKEN_STRING_INITIALIZER
18421 (struct cmd_tx_offload_get_configuration_result,
18423 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18424 TOKEN_NUM_INITIALIZER
18425 (struct cmd_tx_offload_get_configuration_result,
18427 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18428 TOKEN_STRING_INITIALIZER
18429 (struct cmd_tx_offload_get_configuration_result,
18430 tx_offload, "tx_offload");
18431 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18432 TOKEN_STRING_INITIALIZER
18433 (struct cmd_tx_offload_get_configuration_result,
18434 configuration, "configuration");
18437 cmd_tx_offload_get_configuration_parsed(
18438 void *parsed_result,
18439 __attribute__((unused)) struct cmdline *cl,
18440 __attribute__((unused)) void *data)
18442 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18443 struct rte_eth_dev_info dev_info;
18444 portid_t port_id = res->port_id;
18445 struct rte_port *port = &ports[port_id];
18446 uint64_t port_offloads;
18447 uint64_t queue_offloads;
18448 uint16_t nb_tx_queues;
18451 printf("Tx Offloading Configuration of port %d :\n", port_id);
18453 port_offloads = port->dev_conf.txmode.offloads;
18455 print_tx_offloads(port_offloads);
18458 rte_eth_dev_info_get(port_id, &dev_info);
18459 nb_tx_queues = dev_info.nb_tx_queues;
18460 for (q = 0; q < nb_tx_queues; q++) {
18461 queue_offloads = port->tx_conf[q].offloads;
18462 printf(" Queue[%2d] :", q);
18463 print_tx_offloads(queue_offloads);
18469 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18470 .f = cmd_tx_offload_get_configuration_parsed,
18472 .help_str = "show port <port_id> tx_offload configuration",
18474 (void *)&cmd_tx_offload_get_configuration_show,
18475 (void *)&cmd_tx_offload_get_configuration_port,
18476 (void *)&cmd_tx_offload_get_configuration_port_id,
18477 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18478 (void *)&cmd_tx_offload_get_configuration_configuration,
18483 /* Enable/Disable a per port offloading */
18484 struct cmd_config_per_port_tx_offload_result {
18485 cmdline_fixed_string_t port;
18486 cmdline_fixed_string_t config;
18488 cmdline_fixed_string_t tx_offload;
18489 cmdline_fixed_string_t offload;
18490 cmdline_fixed_string_t on_off;
18493 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18494 TOKEN_STRING_INITIALIZER
18495 (struct cmd_config_per_port_tx_offload_result,
18497 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18498 TOKEN_STRING_INITIALIZER
18499 (struct cmd_config_per_port_tx_offload_result,
18501 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18502 TOKEN_NUM_INITIALIZER
18503 (struct cmd_config_per_port_tx_offload_result,
18505 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18506 TOKEN_STRING_INITIALIZER
18507 (struct cmd_config_per_port_tx_offload_result,
18508 tx_offload, "tx_offload");
18509 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18510 TOKEN_STRING_INITIALIZER
18511 (struct cmd_config_per_port_tx_offload_result,
18512 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18513 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18514 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18515 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18516 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18518 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18519 TOKEN_STRING_INITIALIZER
18520 (struct cmd_config_per_port_tx_offload_result,
18524 search_tx_offload(const char *name)
18526 uint64_t single_offload;
18527 const char *single_name;
18531 single_offload = 1;
18532 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18533 single_name = rte_eth_dev_tx_offload_name(single_offload);
18534 if (single_name == NULL)
18536 if (!strcasecmp(single_name, name)) {
18539 } else if (!strcasecmp(single_name, "UNKNOWN"))
18541 single_offload <<= 1;
18545 return single_offload;
18551 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18552 __attribute__((unused)) struct cmdline *cl,
18553 __attribute__((unused)) void *data)
18555 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18556 portid_t port_id = res->port_id;
18557 struct rte_eth_dev_info dev_info;
18558 struct rte_port *port = &ports[port_id];
18559 uint64_t single_offload;
18560 uint16_t nb_tx_queues;
18563 if (port->port_status != RTE_PORT_STOPPED) {
18564 printf("Error: Can't config offload when Port %d "
18565 "is not stopped\n", port_id);
18569 single_offload = search_tx_offload(res->offload);
18570 if (single_offload == 0) {
18571 printf("Unknown offload name: %s\n", res->offload);
18575 rte_eth_dev_info_get(port_id, &dev_info);
18576 nb_tx_queues = dev_info.nb_tx_queues;
18577 if (!strcmp(res->on_off, "on")) {
18578 port->dev_conf.txmode.offloads |= single_offload;
18579 for (q = 0; q < nb_tx_queues; q++)
18580 port->tx_conf[q].offloads |= single_offload;
18582 port->dev_conf.txmode.offloads &= ~single_offload;
18583 for (q = 0; q < nb_tx_queues; q++)
18584 port->tx_conf[q].offloads &= ~single_offload;
18587 cmd_reconfig_device_queue(port_id, 1, 1);
18590 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18591 .f = cmd_config_per_port_tx_offload_parsed,
18593 .help_str = "port config <port_id> tx_offload "
18594 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18595 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18596 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18597 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18598 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18599 "match_metadata on|off",
18601 (void *)&cmd_config_per_port_tx_offload_result_port,
18602 (void *)&cmd_config_per_port_tx_offload_result_config,
18603 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18604 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18605 (void *)&cmd_config_per_port_tx_offload_result_offload,
18606 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18611 /* Enable/Disable a per queue offloading */
18612 struct cmd_config_per_queue_tx_offload_result {
18613 cmdline_fixed_string_t port;
18615 cmdline_fixed_string_t txq;
18617 cmdline_fixed_string_t tx_offload;
18618 cmdline_fixed_string_t offload;
18619 cmdline_fixed_string_t on_off;
18622 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18623 TOKEN_STRING_INITIALIZER
18624 (struct cmd_config_per_queue_tx_offload_result,
18626 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18627 TOKEN_NUM_INITIALIZER
18628 (struct cmd_config_per_queue_tx_offload_result,
18630 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18631 TOKEN_STRING_INITIALIZER
18632 (struct cmd_config_per_queue_tx_offload_result,
18634 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18635 TOKEN_NUM_INITIALIZER
18636 (struct cmd_config_per_queue_tx_offload_result,
18638 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18639 TOKEN_STRING_INITIALIZER
18640 (struct cmd_config_per_queue_tx_offload_result,
18641 tx_offload, "tx_offload");
18642 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18643 TOKEN_STRING_INITIALIZER
18644 (struct cmd_config_per_queue_tx_offload_result,
18645 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18646 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18647 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18648 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18649 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18650 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18651 TOKEN_STRING_INITIALIZER
18652 (struct cmd_config_per_queue_tx_offload_result,
18656 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18657 __attribute__((unused)) struct cmdline *cl,
18658 __attribute__((unused)) void *data)
18660 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18661 struct rte_eth_dev_info dev_info;
18662 portid_t port_id = res->port_id;
18663 uint16_t queue_id = res->queue_id;
18664 struct rte_port *port = &ports[port_id];
18665 uint64_t single_offload;
18667 if (port->port_status != RTE_PORT_STOPPED) {
18668 printf("Error: Can't config offload when Port %d "
18669 "is not stopped\n", port_id);
18673 rte_eth_dev_info_get(port_id, &dev_info);
18674 if (queue_id >= dev_info.nb_tx_queues) {
18675 printf("Error: input queue_id should be 0 ... "
18676 "%d\n", dev_info.nb_tx_queues - 1);
18680 single_offload = search_tx_offload(res->offload);
18681 if (single_offload == 0) {
18682 printf("Unknown offload name: %s\n", res->offload);
18686 if (!strcmp(res->on_off, "on"))
18687 port->tx_conf[queue_id].offloads |= single_offload;
18689 port->tx_conf[queue_id].offloads &= ~single_offload;
18691 cmd_reconfig_device_queue(port_id, 1, 1);
18694 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18695 .f = cmd_config_per_queue_tx_offload_parsed,
18697 .help_str = "port <port_id> txq <queue_id> tx_offload "
18698 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18699 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18700 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18701 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18702 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18705 (void *)&cmd_config_per_queue_tx_offload_result_port,
18706 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18707 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18708 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18709 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18710 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18711 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18716 /* *** configure tx_metadata for specific port *** */
18717 struct cmd_config_tx_metadata_specific_result {
18718 cmdline_fixed_string_t port;
18719 cmdline_fixed_string_t keyword;
18721 cmdline_fixed_string_t item;
18726 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18727 __attribute__((unused)) struct cmdline *cl,
18728 __attribute__((unused)) void *data)
18730 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18732 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18734 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18735 /* Add/remove callback to insert valid metadata in every Tx packet. */
18736 if (ports[res->port_id].tx_metadata)
18737 add_tx_md_callback(res->port_id);
18739 remove_tx_md_callback(res->port_id);
18742 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18743 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18745 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18746 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18747 keyword, "config");
18748 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18749 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18751 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18752 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18753 item, "tx_metadata");
18754 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18755 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18758 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18759 .f = cmd_config_tx_metadata_specific_parsed,
18761 .help_str = "port config <port_id> tx_metadata <value>",
18763 (void *)&cmd_config_tx_metadata_specific_port,
18764 (void *)&cmd_config_tx_metadata_specific_keyword,
18765 (void *)&cmd_config_tx_metadata_specific_id,
18766 (void *)&cmd_config_tx_metadata_specific_item,
18767 (void *)&cmd_config_tx_metadata_specific_value,
18772 /* *** display tx_metadata per port configuration *** */
18773 struct cmd_show_tx_metadata_result {
18774 cmdline_fixed_string_t cmd_show;
18775 cmdline_fixed_string_t cmd_port;
18776 cmdline_fixed_string_t cmd_keyword;
18781 cmd_show_tx_metadata_parsed(void *parsed_result,
18782 __attribute__((unused)) struct cmdline *cl,
18783 __attribute__((unused)) void *data)
18785 struct cmd_show_tx_metadata_result *res = parsed_result;
18787 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18788 printf("invalid port id %u\n", res->cmd_pid);
18791 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18792 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18793 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18797 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18798 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18800 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18801 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18803 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18804 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18806 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18807 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18808 cmd_keyword, "tx_metadata");
18810 cmdline_parse_inst_t cmd_show_tx_metadata = {
18811 .f = cmd_show_tx_metadata_parsed,
18813 .help_str = "show port <port_id> tx_metadata",
18815 (void *)&cmd_show_tx_metadata_show,
18816 (void *)&cmd_show_tx_metadata_port,
18817 (void *)&cmd_show_tx_metadata_pid,
18818 (void *)&cmd_show_tx_metadata_keyword,
18823 /* ******************************************************************************** */
18825 /* list of instructions */
18826 cmdline_parse_ctx_t main_ctx[] = {
18827 (cmdline_parse_inst_t *)&cmd_help_brief,
18828 (cmdline_parse_inst_t *)&cmd_help_long,
18829 (cmdline_parse_inst_t *)&cmd_quit,
18830 (cmdline_parse_inst_t *)&cmd_load_from_file,
18831 (cmdline_parse_inst_t *)&cmd_showport,
18832 (cmdline_parse_inst_t *)&cmd_showqueue,
18833 (cmdline_parse_inst_t *)&cmd_showportall,
18834 (cmdline_parse_inst_t *)&cmd_showdevice,
18835 (cmdline_parse_inst_t *)&cmd_showcfg,
18836 (cmdline_parse_inst_t *)&cmd_showfwdall,
18837 (cmdline_parse_inst_t *)&cmd_start,
18838 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18839 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18840 (cmdline_parse_inst_t *)&cmd_set_link_up,
18841 (cmdline_parse_inst_t *)&cmd_set_link_down,
18842 (cmdline_parse_inst_t *)&cmd_reset,
18843 (cmdline_parse_inst_t *)&cmd_set_numbers,
18844 (cmdline_parse_inst_t *)&cmd_set_log,
18845 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18846 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18847 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18848 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18849 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18850 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18851 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18852 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18853 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18854 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18855 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18856 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18857 (cmdline_parse_inst_t *)&cmd_set_link_check,
18858 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18859 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18860 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18861 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18862 #ifdef RTE_LIBRTE_PMD_BOND
18863 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18864 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18865 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18866 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18867 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18868 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18869 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18870 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18871 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18872 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18873 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18875 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18876 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18877 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18878 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18879 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18880 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18881 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18882 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18883 (cmdline_parse_inst_t *)&cmd_csum_set,
18884 (cmdline_parse_inst_t *)&cmd_csum_show,
18885 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18886 (cmdline_parse_inst_t *)&cmd_tso_set,
18887 (cmdline_parse_inst_t *)&cmd_tso_show,
18888 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18889 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18890 (cmdline_parse_inst_t *)&cmd_gro_enable,
18891 (cmdline_parse_inst_t *)&cmd_gro_flush,
18892 (cmdline_parse_inst_t *)&cmd_gro_show,
18893 (cmdline_parse_inst_t *)&cmd_gso_enable,
18894 (cmdline_parse_inst_t *)&cmd_gso_size,
18895 (cmdline_parse_inst_t *)&cmd_gso_show,
18896 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18897 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18898 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18899 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18900 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18901 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18902 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18903 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18904 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18905 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18906 (cmdline_parse_inst_t *)&cmd_config_dcb,
18907 (cmdline_parse_inst_t *)&cmd_read_reg,
18908 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18909 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18910 (cmdline_parse_inst_t *)&cmd_write_reg,
18911 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18912 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18913 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18914 (cmdline_parse_inst_t *)&cmd_stop,
18915 (cmdline_parse_inst_t *)&cmd_mac_addr,
18916 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18917 (cmdline_parse_inst_t *)&cmd_set_qmap,
18918 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18919 (cmdline_parse_inst_t *)&cmd_operate_port,
18920 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18921 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18922 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18923 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18924 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18925 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18926 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18927 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18928 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18929 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18930 (cmdline_parse_inst_t *)&cmd_config_mtu,
18931 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18932 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18933 (cmdline_parse_inst_t *)&cmd_config_rss,
18934 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18935 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18936 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18937 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18938 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18939 (cmdline_parse_inst_t *)&cmd_showport_reta,
18940 (cmdline_parse_inst_t *)&cmd_config_burst,
18941 (cmdline_parse_inst_t *)&cmd_config_thresh,
18942 (cmdline_parse_inst_t *)&cmd_config_threshold,
18943 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18944 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18945 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18946 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18947 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18948 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18949 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18950 (cmdline_parse_inst_t *)&cmd_global_config,
18951 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18952 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18953 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18954 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18955 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18956 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18957 (cmdline_parse_inst_t *)&cmd_dump,
18958 (cmdline_parse_inst_t *)&cmd_dump_one,
18959 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18960 (cmdline_parse_inst_t *)&cmd_syn_filter,
18961 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18962 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18963 (cmdline_parse_inst_t *)&cmd_flex_filter,
18964 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18965 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18966 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18967 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18968 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18969 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18970 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18971 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18972 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18973 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18974 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18975 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18976 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18977 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18978 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18979 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18980 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18981 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18982 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18983 (cmdline_parse_inst_t *)&cmd_flow,
18984 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18985 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18986 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18987 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18988 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18989 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18990 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18991 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18992 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18993 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18994 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18995 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18996 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18997 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18998 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18999 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19000 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19001 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19002 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19003 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19004 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19005 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19006 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19007 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19008 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19009 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19010 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19011 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19012 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19013 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19014 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19015 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19016 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19017 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19018 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19019 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19020 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19021 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19022 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19023 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19024 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19025 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19026 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19027 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19028 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19029 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19030 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19031 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19032 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19033 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19034 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19036 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19037 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19038 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19039 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19040 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19041 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19042 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19043 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19044 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19045 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19046 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19047 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19048 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19049 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19050 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19051 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19052 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19053 (cmdline_parse_inst_t *)&cmd_ddp_add,
19054 (cmdline_parse_inst_t *)&cmd_ddp_del,
19055 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19056 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19057 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19058 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19059 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19060 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19061 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19062 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19063 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19064 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19066 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19067 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19068 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19069 (cmdline_parse_inst_t *)&cmd_queue_region,
19070 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19071 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19072 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19073 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19074 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19075 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19076 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19077 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19078 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19079 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19080 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19081 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19082 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19083 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19084 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19085 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19086 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19087 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19088 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19089 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19090 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19091 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19092 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19093 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19094 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19095 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19096 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19097 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19098 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19099 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19100 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19101 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19102 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19103 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19104 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19105 #ifdef RTE_LIBRTE_BPF
19106 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19107 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19109 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19110 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19111 (cmdline_parse_inst_t *)&cmd_set_raw,
19115 /* read cmdline commands from file */
19117 cmdline_read_from_file(const char *filename)
19119 struct cmdline *cl;
19121 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19123 printf("Failed to create file based cmdline context: %s\n",
19128 cmdline_interact(cl);
19133 printf("Read CLI commands from %s\n", filename);
19136 /* prompt function, called from main on MASTER lcore */
19140 /* initialize non-constant commands */
19141 cmd_set_fwd_mode_init();
19142 cmd_set_fwd_retry_mode_init();
19144 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19145 if (testpmd_cl == NULL)
19147 cmdline_interact(testpmd_cl);
19148 cmdline_stdin_exit(testpmd_cl);
19154 if (testpmd_cl != NULL)
19155 cmdline_quit(testpmd_cl);
19159 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19161 if (id == (portid_t)RTE_PORT_ALL) {
19164 RTE_ETH_FOREACH_DEV(pid) {
19165 /* check if need_reconfig has been set to 1 */
19166 if (ports[pid].need_reconfig == 0)
19167 ports[pid].need_reconfig = dev;
19168 /* check if need_reconfig_queues has been set to 1 */
19169 if (ports[pid].need_reconfig_queues == 0)
19170 ports[pid].need_reconfig_queues = queue;
19172 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19173 /* check if need_reconfig has been set to 1 */
19174 if (ports[id].need_reconfig == 0)
19175 ports[id].need_reconfig = dev;
19176 /* check if need_reconfig_queues has been set to 1 */
19177 if (ports[id].need_reconfig_queues == 0)
19178 ports[id].need_reconfig_queues = queue;