4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_malloc.h>
62 #include <rte_launch.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <rte_devargs.h>
76 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
90 #include <rte_eth_bond_8023ad.h>
92 #ifdef RTE_LIBRTE_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
103 static struct cmdline *testpmd_cl;
105 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
107 /* *** Help command with introduction. *** */
108 struct cmd_help_brief_result {
109 cmdline_fixed_string_t help;
112 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
114 __attribute__((unused)) void *data)
119 "Help is available for the following sections:\n\n"
120 " help control : Start and stop forwarding.\n"
121 " help display : Displaying port, stats and config "
123 " help config : Configuration information.\n"
124 " help ports : Configuring ports.\n"
125 " help registers : Reading and setting port registers.\n"
126 " help filters : Filters configuration help.\n"
127 " help all : All of the above sections.\n\n"
132 cmdline_parse_token_string_t cmd_help_brief_help =
133 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
135 cmdline_parse_inst_t cmd_help_brief = {
136 .f = cmd_help_brief_parsed,
138 .help_str = "help: Show help",
140 (void *)&cmd_help_brief_help,
145 /* *** Help command with help sections. *** */
146 struct cmd_help_long_result {
147 cmdline_fixed_string_t help;
148 cmdline_fixed_string_t section;
151 static void cmd_help_long_parsed(void *parsed_result,
153 __attribute__((unused)) void *data)
156 struct cmd_help_long_result *res = parsed_result;
158 if (!strcmp(res->section, "all"))
161 if (show_all || !strcmp(res->section, "control")) {
166 "Control forwarding:\n"
167 "-------------------\n\n"
170 " Start packet forwarding with current configuration.\n\n"
173 " Start packet forwarding with current config"
174 " after sending one burst of packets.\n\n"
177 " Stop packet forwarding, and display accumulated"
181 " Quit to prompt.\n\n"
185 if (show_all || !strcmp(res->section, "display")) {
193 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
194 " Display information for port_id, or all.\n\n"
196 "show port X rss reta (size) (mask0,mask1,...)\n"
197 " Display the rss redirection table entry indicated"
198 " by masks on port X. size is used to indicate the"
199 " hardware supported reta size\n\n"
201 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
202 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
203 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
204 " Display the RSS hash functions and RSS hash key"
207 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
208 " Clear information for port_id, or all.\n\n"
210 "show (rxq|txq) info (port_id) (queue_id)\n"
211 " Display information for configured RX/TX queue.\n\n"
213 "show config (rxtx|cores|fwd|txpkts)\n"
214 " Display the given configuration.\n\n"
216 "read rxd (port_id) (queue_id) (rxd_id)\n"
217 " Display an RX descriptor of a port RX queue.\n\n"
219 "read txd (port_id) (queue_id) (txd_id)\n"
220 " Display a TX descriptor of a port TX queue.\n\n"
222 "ddp get list (port_id)\n"
223 " Get ddp profile info list\n\n"
225 "ddp get info (profile_path)\n"
226 " Get ddp profile information.\n\n"
228 "show vf stats (port_id) (vf_id)\n"
229 " Display a VF's statistics.\n\n"
231 "clear vf stats (port_id) (vf_id)\n"
232 " Reset a VF's statistics.\n\n"
234 "show port (port_id) pctype mapping\n"
235 " Get flow ptype to pctype mapping on a port\n\n"
240 if (show_all || !strcmp(res->section, "config")) {
246 "Configuration changes only become active when"
247 " forwarding is started/restarted.\n\n"
250 " Reset forwarding to the default configuration.\n\n"
252 "set verbose (level)\n"
253 " Set the debug verbosity level X.\n\n"
256 " Set number of ports.\n\n"
259 " Set number of cores.\n\n"
261 "set coremask (mask)\n"
262 " Set the forwarding cores hexadecimal mask.\n\n"
264 "set portmask (mask)\n"
265 " Set the forwarding ports hexadecimal mask.\n\n"
268 " Set number of packets per burst.\n\n"
270 "set burst tx delay (microseconds) retry (num)\n"
271 " Set the transmit delay time and number of retries,"
272 " effective when retry is enabled.\n\n"
274 "set txpkts (x[,y]*)\n"
275 " Set the length of each segment of TXONLY"
276 " and optionally CSUM packets.\n\n"
278 "set txsplit (off|on|rand)\n"
279 " Set the split policy for the TX packets."
280 " Right now only applicable for CSUM and TXONLY"
283 "set corelist (x[,y]*)\n"
284 " Set the list of forwarding cores.\n\n"
286 "set portlist (x[,y]*)\n"
287 " Set the list of forwarding ports.\n\n"
289 "set tx loopback (port_id) (on|off)\n"
290 " Enable or disable tx loopback.\n\n"
292 "set all queues drop (port_id) (on|off)\n"
293 " Set drop enable bit for all queues.\n\n"
295 "set vf split drop (port_id) (vf_id) (on|off)\n"
296 " Set split drop enable bit for a VF from the PF.\n\n"
298 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
299 " Set MAC antispoof for a VF from the PF.\n\n"
301 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
302 " Enable MACsec offload.\n\n"
304 "set macsec offload (port_id) off\n"
305 " Disable MACsec offload.\n\n"
307 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
308 " Configure MACsec secure connection (SC).\n\n"
310 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
311 " Configure MACsec secure association (SA).\n\n"
313 "set vf broadcast (port_id) (vf_id) (on|off)\n"
314 " Set VF broadcast for a VF from the PF.\n\n"
316 "vlan set strip (on|off) (port_id)\n"
317 " Set the VLAN strip on a port.\n\n"
319 "vlan set stripq (on|off) (port_id,queue_id)\n"
320 " Set the VLAN strip for a queue on a port.\n\n"
322 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
323 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
325 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
326 " Set VLAN insert for a VF from the PF.\n\n"
328 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
329 " Set VLAN antispoof for a VF from the PF.\n\n"
331 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
332 " Set VLAN tag for a VF from the PF.\n\n"
334 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
335 " Set a VF's max bandwidth(Mbps).\n\n"
337 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
338 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
340 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
341 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
343 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
344 " Set some TCs' strict link priority mode on a physical port.\n\n"
346 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
347 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
349 "vlan set filter (on|off) (port_id)\n"
350 " Set the VLAN filter on a port.\n\n"
352 "vlan set qinq (on|off) (port_id)\n"
353 " Set the VLAN QinQ (extended queue in queue)"
356 "vlan set (inner|outer) tpid (value) (port_id)\n"
357 " Set the VLAN TPID for Packet Filtering on"
360 "rx_vlan add (vlan_id|all) (port_id)\n"
361 " Add a vlan_id, or all identifiers, to the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan rm (vlan_id|all) (port_id)\n"
365 " Remove a vlan_id, or all identifiers, from the set"
366 " of VLAN identifiers filtered by port_id.\n\n"
368 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Add a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
373 " Remove a vlan_id, to the set of VLAN identifiers"
374 "filtered for VF(s) from port_id.\n\n"
376 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
377 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
378 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
379 " add a tunnel filter of a port.\n\n"
381 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
382 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
383 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
384 " remove a tunnel filter of a port.\n\n"
386 "rx_vxlan_port add (udp_port) (port_id)\n"
387 " Add an UDP port for VXLAN packet filter on a port\n\n"
389 "rx_vxlan_port rm (udp_port) (port_id)\n"
390 " Remove an UDP port for VXLAN packet filter on a port\n\n"
392 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
393 " Set hardware insertion of VLAN IDs (single or double VLAN "
394 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
396 "tx_vlan set pvid port_id vlan_id (on|off)\n"
397 " Set port based TX VLAN insertion.\n\n"
399 "tx_vlan reset (port_id)\n"
400 " Disable hardware insertion of a VLAN header in"
401 " packets sent on a port.\n\n"
403 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
404 " Select hardware or software calculation of the"
405 " checksum when transmitting a packet using the"
406 " csum forward engine.\n"
407 " ip|udp|tcp|sctp always concern the inner layer.\n"
408 " outer-ip concerns the outer IP layer in"
409 " case the packet is recognized as a tunnel packet by"
410 " the forward engine (vxlan, gre and ipip are supported)\n"
411 " Please check the NIC datasheet for HW limits.\n\n"
413 "csum parse-tunnel (on|off) (tx_port_id)\n"
414 " If disabled, treat tunnel packets as non-tunneled"
415 " packets (treat inner headers as payload). The port\n"
416 " argument is the port used for TX in csum forward"
419 "csum show (port_id)\n"
420 " Display tx checksum offload configuration\n\n"
422 "tso set (segsize) (portid)\n"
423 " Enable TCP Segmentation Offload in csum forward"
425 " Please check the NIC datasheet for HW limits.\n\n"
428 " Display the status of TCP Segmentation Offload.\n\n"
430 "set port (port_id) gro on|off\n"
431 " Enable or disable Generic Receive Offload in"
432 " csum forwarding engine.\n\n"
434 "show port (port_id) gro\n"
435 " Display GRO configuration.\n\n"
437 "set gro flush (cycles)\n"
438 " Set the cycle to flush GROed packets from"
439 " reassembly tables.\n\n"
441 "set port (port_id) gso (on|off)"
442 " Enable or disable Generic Segmentation Offload in"
443 " csum forwarding engine.\n\n"
445 "set gso segsz (length)\n"
446 " Set max packet length for output GSO segments,"
447 " including packet header and payload.\n\n"
449 "show port (port_id) gso\n"
450 " Show GSO configuration.\n\n"
453 " Set packet forwarding mode.\n\n"
455 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
456 " Add a MAC address on port_id.\n\n"
458 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
459 " Remove a MAC address from port_id.\n\n"
461 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
462 " Set the default MAC address for port_id.\n\n"
464 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
465 " Add a MAC address for a VF on the port.\n\n"
467 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
468 " Set the MAC address for a VF from the PF.\n\n"
470 "set port (port_id) uta (mac_address|all) (on|off)\n"
471 " Add/Remove a or all unicast hash filter(s)"
474 "set promisc (port_id|all) (on|off)\n"
475 " Set the promiscuous mode on port_id, or all.\n\n"
477 "set allmulti (port_id|all) (on|off)\n"
478 " Set the allmulti mode on port_id, or all.\n\n"
480 "set vf promisc (port_id) (vf_id) (on|off)\n"
481 " Set unicast promiscuous mode for a VF from the PF.\n\n"
483 "set vf allmulti (port_id) (vf_id) (on|off)\n"
484 " Set multicast promiscuous mode for a VF from the PF.\n\n"
486 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
487 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
488 " (on|off) autoneg (on|off) (port_id)\n"
489 "set flow_ctrl rx (on|off) (portid)\n"
490 "set flow_ctrl tx (on|off) (portid)\n"
491 "set flow_ctrl high_water (high_water) (portid)\n"
492 "set flow_ctrl low_water (low_water) (portid)\n"
493 "set flow_ctrl pause_time (pause_time) (portid)\n"
494 "set flow_ctrl send_xon (send_xon) (portid)\n"
495 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
496 "set flow_ctrl autoneg (on|off) (port_id)\n"
497 " Set the link flow control parameter on a port.\n\n"
499 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
500 " (low_water) (pause_time) (priority) (port_id)\n"
501 " Set the priority flow control parameter on a"
504 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
505 " Set statistics mapping (qmapping 0..15) for RX/TX"
507 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
508 " on port 0 to mapping 5.\n\n"
510 "set port (port_id) vf (vf_id) rx|tx on|off\n"
511 " Enable/Disable a VF receive/tranmit from a port\n\n"
513 "set port (port_id) vf (vf_id) (mac_addr)"
514 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
515 " Add/Remove unicast or multicast MAC addr filter"
518 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
520 " AUPE:accepts untagged VLAN;"
521 "ROPE:accept unicast hash\n\n"
522 " BAM:accepts broadcast packets;"
523 "MPE:accepts all multicast packets\n\n"
524 " Enable/Disable a VF receive mode of a port\n\n"
526 "set port (port_id) queue (queue_id) rate (rate_num)\n"
527 " Set rate limit for a queue of a port\n\n"
529 "set port (port_id) vf (vf_id) rate (rate_num) "
530 "queue_mask (queue_mask_value)\n"
531 " Set rate limit for queues in VF of a port\n\n"
533 "set port (port_id) mirror-rule (rule_id)"
534 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
535 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
536 " Set pool or vlan type mirror rule on a port.\n"
537 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
538 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
541 "set port (port_id) mirror-rule (rule_id)"
542 " (uplink-mirror|downlink-mirror) dst-pool"
543 " (pool_id) (on|off)\n"
544 " Set uplink or downlink type mirror rule on a port.\n"
545 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
546 " 0 on' enable mirror income traffic to pool 0.\n\n"
548 "reset port (port_id) mirror-rule (rule_id)\n"
549 " Reset a mirror rule.\n\n"
551 "set flush_rx (on|off)\n"
552 " Flush (default) or don't flush RX streams before"
553 " forwarding. Mainly used with PCAP drivers.\n\n"
555 "set bypass mode (normal|bypass|isolate) (port_id)\n"
556 " Set the bypass mode for the lowest port on bypass enabled"
559 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
560 "mode (normal|bypass|isolate) (port_id)\n"
561 " Set the event required to initiate specified bypass mode for"
562 " the lowest port on a bypass enabled NIC where:\n"
563 " timeout = enable bypass after watchdog timeout.\n"
564 " os_on = enable bypass when OS/board is powered on.\n"
565 " os_off = enable bypass when OS/board is powered off.\n"
566 " power_on = enable bypass when power supply is turned on.\n"
567 " power_off = enable bypass when power supply is turned off."
570 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
571 " Set the bypass watchdog timeout to 'n' seconds"
572 " where 0 = instant.\n\n"
574 "show bypass config (port_id)\n"
575 " Show the bypass configuration for a bypass enabled NIC"
576 " using the lowest port on the NIC.\n\n"
578 #ifdef RTE_LIBRTE_PMD_BOND
579 "create bonded device (mode) (socket)\n"
580 " Create a new bonded device with specific bonding mode and socket.\n\n"
582 "add bonding slave (slave_id) (port_id)\n"
583 " Add a slave device to a bonded device.\n\n"
585 "remove bonding slave (slave_id) (port_id)\n"
586 " Remove a slave device from a bonded device.\n\n"
588 "set bonding mode (value) (port_id)\n"
589 " Set the bonding mode on a bonded device.\n\n"
591 "set bonding primary (slave_id) (port_id)\n"
592 " Set the primary slave for a bonded device.\n\n"
594 "show bonding config (port_id)\n"
595 " Show the bonding config for port_id.\n\n"
597 "set bonding mac_addr (port_id) (address)\n"
598 " Set the MAC address of a bonded device.\n\n"
600 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
601 " Set Aggregation mode for IEEE802.3AD (mode 4)"
603 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
604 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
606 "set bonding mon_period (port_id) (value)\n"
607 " Set the bonding link status monitoring polling period in ms.\n\n"
609 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
610 " Enable/disable dedicated queues for LACP control traffic.\n\n"
613 "set link-up port (port_id)\n"
614 " Set link up for a port.\n\n"
616 "set link-down port (port_id)\n"
617 " Set link down for a port.\n\n"
619 "E-tag set insertion on port-tag-id (value)"
620 " port (port_id) vf (vf_id)\n"
621 " Enable E-tag insertion for a VF on a port\n\n"
623 "E-tag set insertion off port (port_id) vf (vf_id)\n"
624 " Disable E-tag insertion for a VF on a port\n\n"
626 "E-tag set stripping (on|off) port (port_id)\n"
627 " Enable/disable E-tag stripping on a port\n\n"
629 "E-tag set forwarding (on|off) port (port_id)\n"
630 " Enable/disable E-tag based forwarding"
633 "E-tag set filter add e-tag-id (value) dst-pool"
634 " (pool_id) port (port_id)\n"
635 " Add an E-tag forwarding filter on a port\n\n"
637 "E-tag set filter del e-tag-id (value) port (port_id)\n"
638 " Delete an E-tag forwarding filter on a port\n\n"
640 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
641 "set port tm hierarchy default (port_id)\n"
642 " Set default traffic Management hierarchy on a port\n\n"
645 "ddp add (port_id) (profile_path[,output_path])\n"
646 " Load a profile package on a port\n\n"
648 "ddp del (port_id) (profile_path)\n"
649 " Delete a profile package from a port\n\n"
651 "ptype mapping get (port_id) (valid_only)\n"
652 " Get ptype mapping on a port\n\n"
654 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
655 " Replace target with the pkt_type in ptype mapping\n\n"
657 "ptype mapping reset (port_id)\n"
658 " Reset ptype mapping on a port\n\n"
660 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
661 " Update a ptype mapping item on a port\n\n"
663 , list_pkt_forwarding_modes()
667 if (show_all || !strcmp(res->section, "ports")) {
673 "----------------\n\n"
675 "port start (port_id|all)\n"
676 " Start all ports or port_id.\n\n"
678 "port stop (port_id|all)\n"
679 " Stop all ports or port_id.\n\n"
681 "port close (port_id|all)\n"
682 " Close all ports or port_id.\n\n"
684 "port attach (ident)\n"
685 " Attach physical or virtual dev by pci address or virtual device name\n\n"
687 "port detach (port_id)\n"
688 " Detach physical or virtual dev by port_id\n\n"
690 "port config (port_id|all)"
691 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
692 " duplex (half|full|auto)\n"
693 " Set speed and duplex for all ports or port_id\n\n"
695 "port config all (rxq|txq|rxd|txd) (value)\n"
696 " Set number for rxq/txq/rxd/txd.\n\n"
698 "port config all max-pkt-len (value)\n"
699 " Set the max packet length.\n\n"
701 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
702 "hw-vlan-strip|hw-vlan-extend|drop-en)"
704 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
707 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
708 "geneve|nvgre|none|<flowtype_id>)\n"
709 " Set the RSS mode.\n\n"
711 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
712 " Set the RSS redirection table.\n\n"
714 "port config (port_id) dcb vt (on|off) (traffic_class)"
716 " Set the DCB mode.\n\n"
718 "port config all burst (value)\n"
719 " Set the number of packets per burst.\n\n"
721 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
723 " Set the ring prefetch/host/writeback threshold"
724 " for tx/rx queue.\n\n"
726 "port config all (txfreet|txrst|rxfreet) (value)\n"
727 " Set free threshold for rx/tx, or set"
728 " tx rs bit threshold.\n\n"
729 "port config mtu X value\n"
730 " Set the MTU of port X to a given value\n\n"
732 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
733 " Start/stop a rx/tx queue of port X. Only take effect"
734 " when port X is started\n\n"
736 "port config (port_id|all) l2-tunnel E-tag ether-type"
738 " Set the value of E-tag ether-type.\n\n"
740 "port config (port_id|all) l2-tunnel E-tag"
741 " (enable|disable)\n"
742 " Enable/disable the E-tag support.\n\n"
744 "port config (port_id) pctype mapping reset\n"
745 " Reset flow type to pctype mapping on a port\n\n"
747 "port config (port_id) pctype mapping update"
748 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
749 " Update a flow type to pctype mapping item on a port\n\n"
753 if (show_all || !strcmp(res->section, "registers")) {
761 "read reg (port_id) (address)\n"
762 " Display value of a port register.\n\n"
764 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
765 " Display a port register bit field.\n\n"
767 "read regbit (port_id) (address) (bit_x)\n"
768 " Display a single port register bit.\n\n"
770 "write reg (port_id) (address) (value)\n"
771 " Set value of a port register.\n\n"
773 "write regfield (port_id) (address) (bit_x) (bit_y)"
775 " Set bit field of a port register.\n\n"
777 "write regbit (port_id) (address) (bit_x) (value)\n"
778 " Set single bit value of a port register.\n\n"
781 if (show_all || !strcmp(res->section, "filters")) {
789 "ethertype_filter (port_id) (add|del)"
790 " (mac_addr|mac_ignr) (mac_address) ethertype"
791 " (ether_type) (drop|fwd) queue (queue_id)\n"
792 " Add/Del an ethertype filter.\n\n"
794 "2tuple_filter (port_id) (add|del)"
795 " dst_port (dst_port_value) protocol (protocol_value)"
796 " mask (mask_value) tcp_flags (tcp_flags_value)"
797 " priority (prio_value) queue (queue_id)\n"
798 " Add/Del a 2tuple filter.\n\n"
800 "5tuple_filter (port_id) (add|del)"
801 " dst_ip (dst_address) src_ip (src_address)"
802 " dst_port (dst_port_value) src_port (src_port_value)"
803 " protocol (protocol_value)"
804 " mask (mask_value) tcp_flags (tcp_flags_value)"
805 " priority (prio_value) queue (queue_id)\n"
806 " Add/Del a 5tuple filter.\n\n"
808 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
809 " Add/Del syn filter.\n\n"
811 "flex_filter (port_id) (add|del) len (len_value)"
812 " bytes (bytes_value) mask (mask_value)"
813 " priority (prio_value) queue (queue_id)\n"
814 " Add/Del a flex filter.\n\n"
816 "flow_director_filter (port_id) mode IP (add|del|update)"
817 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
818 " src (src_ip_address) dst (dst_ip_address)"
819 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
820 " vlan (vlan_value) flexbytes (flexbytes_value)"
821 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
822 " fd_id (fd_id_value)\n"
823 " Add/Del an IP type flow director filter.\n\n"
825 "flow_director_filter (port_id) mode IP (add|del|update)"
826 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
827 " src (src_ip_address) (src_port)"
828 " dst (dst_ip_address) (dst_port)"
829 " tos (tos_value) ttl (ttl_value)"
830 " vlan (vlan_value) flexbytes (flexbytes_value)"
831 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
832 " fd_id (fd_id_value)\n"
833 " Add/Del an UDP/TCP type flow director filter.\n\n"
835 "flow_director_filter (port_id) mode IP (add|del|update)"
836 " flow (ipv4-sctp|ipv6-sctp)"
837 " src (src_ip_address) (src_port)"
838 " dst (dst_ip_address) (dst_port)"
839 " tag (verification_tag) "
840 " tos (tos_value) ttl (ttl_value)"
842 " flexbytes (flexbytes_value) (drop|fwd)"
843 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
844 " Add/Del a SCTP type flow director filter.\n\n"
846 "flow_director_filter (port_id) mode IP (add|del|update)"
847 " flow l2_payload ether (ethertype)"
848 " flexbytes (flexbytes_value) (drop|fwd)"
849 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
850 " Add/Del a l2 payload type flow director filter.\n\n"
852 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
853 " mac (mac_address) vlan (vlan_value)"
854 " flexbytes (flexbytes_value) (drop|fwd)"
855 " queue (queue_id) fd_id (fd_id_value)\n"
856 " Add/Del a MAC-VLAN flow director filter.\n\n"
858 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
859 " mac (mac_address) vlan (vlan_value)"
860 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
861 " flexbytes (flexbytes_value) (drop|fwd)"
862 " queue (queue_id) fd_id (fd_id_value)\n"
863 " Add/Del a Tunnel flow director filter.\n\n"
865 "flush_flow_director (port_id)\n"
866 " Flush all flow director entries of a device.\n\n"
868 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
869 " src_mask (ipv4_src) (ipv6_src) (src_port)"
870 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
871 " Set flow director IP mask.\n\n"
873 "flow_director_mask (port_id) mode MAC-VLAN"
874 " vlan (vlan_value)\n"
875 " Set flow director MAC-VLAN mask.\n\n"
877 "flow_director_mask (port_id) mode Tunnel"
878 " vlan (vlan_value) mac (mac_value)"
879 " tunnel-type (tunnel_type_value)"
880 " tunnel-id (tunnel_id_value)\n"
881 " Set flow director Tunnel mask.\n\n"
883 "flow_director_flex_mask (port_id)"
884 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
885 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
887 " Configure mask of flex payload.\n\n"
889 "flow_director_flex_payload (port_id)"
890 " (raw|l2|l3|l4) (config)\n"
891 " Configure flex payload selection.\n\n"
893 "get_sym_hash_ena_per_port (port_id)\n"
894 " get symmetric hash enable configuration per port.\n\n"
896 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
897 " set symmetric hash enable configuration per port"
898 " to enable or disable.\n\n"
900 "get_hash_global_config (port_id)\n"
901 " Get the global configurations of hash filters.\n\n"
903 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
904 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
905 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
906 " (enable|disable)\n"
907 " Set the global configurations of hash filters.\n\n"
909 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
910 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
911 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
912 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
913 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
914 "ipv6-next-header|udp-src-port|udp-dst-port|"
915 "tcp-src-port|tcp-dst-port|sctp-src-port|"
916 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
917 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
918 "fld-8th|none) (select|add)\n"
919 " Set the input set for hash.\n\n"
921 "set_fdir_input_set (port_id) "
922 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
923 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
924 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
925 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
926 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
927 "udp-dst-port|tcp-src-port|tcp-dst-port|"
928 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
930 " Set the input set for FDir.\n\n"
932 "flow validate {port_id}"
933 " [group {group_id}] [priority {level}]"
934 " [ingress] [egress]"
935 " pattern {item} [/ {item} [...]] / end"
936 " actions {action} [/ {action} [...]] / end\n"
937 " Check whether a flow rule can be created.\n\n"
939 "flow create {port_id}"
940 " [group {group_id}] [priority {level}]"
941 " [ingress] [egress]"
942 " pattern {item} [/ {item} [...]] / end"
943 " actions {action} [/ {action} [...]] / end\n"
944 " Create a flow rule.\n\n"
946 "flow destroy {port_id} rule {rule_id} [...]\n"
947 " Destroy specific flow rules.\n\n"
949 "flow flush {port_id}\n"
950 " Destroy all flow rules.\n\n"
952 "flow query {port_id} {rule_id} {action}\n"
953 " Query an existing flow rule.\n\n"
955 "flow list {port_id} [group {group_id}] [...]\n"
956 " List existing flow rules sorted by priority,"
957 " filtered by group identifiers.\n\n"
959 "flow isolate {port_id} {boolean}\n"
960 " Restrict ingress traffic to the defined"
966 cmdline_parse_token_string_t cmd_help_long_help =
967 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
969 cmdline_parse_token_string_t cmd_help_long_section =
970 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
971 "all#control#display#config#"
972 "ports#registers#filters");
974 cmdline_parse_inst_t cmd_help_long = {
975 .f = cmd_help_long_parsed,
977 .help_str = "help all|control|display|config|ports|register|filters: "
980 (void *)&cmd_help_long_help,
981 (void *)&cmd_help_long_section,
987 /* *** start/stop/close all ports *** */
988 struct cmd_operate_port_result {
989 cmdline_fixed_string_t keyword;
990 cmdline_fixed_string_t name;
991 cmdline_fixed_string_t value;
994 static void cmd_operate_port_parsed(void *parsed_result,
995 __attribute__((unused)) struct cmdline *cl,
996 __attribute__((unused)) void *data)
998 struct cmd_operate_port_result *res = parsed_result;
1000 if (!strcmp(res->name, "start"))
1001 start_port(RTE_PORT_ALL);
1002 else if (!strcmp(res->name, "stop"))
1003 stop_port(RTE_PORT_ALL);
1004 else if (!strcmp(res->name, "close"))
1005 close_port(RTE_PORT_ALL);
1006 else if (!strcmp(res->name, "reset"))
1007 reset_port(RTE_PORT_ALL);
1009 printf("Unknown parameter\n");
1012 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1013 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1015 cmdline_parse_token_string_t cmd_operate_port_all_port =
1016 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1017 "start#stop#close#reset");
1018 cmdline_parse_token_string_t cmd_operate_port_all_all =
1019 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1021 cmdline_parse_inst_t cmd_operate_port = {
1022 .f = cmd_operate_port_parsed,
1024 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1026 (void *)&cmd_operate_port_all_cmd,
1027 (void *)&cmd_operate_port_all_port,
1028 (void *)&cmd_operate_port_all_all,
1033 /* *** start/stop/close specific port *** */
1034 struct cmd_operate_specific_port_result {
1035 cmdline_fixed_string_t keyword;
1036 cmdline_fixed_string_t name;
1040 static void cmd_operate_specific_port_parsed(void *parsed_result,
1041 __attribute__((unused)) struct cmdline *cl,
1042 __attribute__((unused)) void *data)
1044 struct cmd_operate_specific_port_result *res = parsed_result;
1046 if (!strcmp(res->name, "start"))
1047 start_port(res->value);
1048 else if (!strcmp(res->name, "stop"))
1049 stop_port(res->value);
1050 else if (!strcmp(res->name, "close"))
1051 close_port(res->value);
1052 else if (!strcmp(res->name, "reset"))
1053 reset_port(res->value);
1055 printf("Unknown parameter\n");
1058 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1059 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1061 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1062 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1063 name, "start#stop#close#reset");
1064 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1065 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1068 cmdline_parse_inst_t cmd_operate_specific_port = {
1069 .f = cmd_operate_specific_port_parsed,
1071 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1073 (void *)&cmd_operate_specific_port_cmd,
1074 (void *)&cmd_operate_specific_port_port,
1075 (void *)&cmd_operate_specific_port_id,
1080 /* *** attach a specified port *** */
1081 struct cmd_operate_attach_port_result {
1082 cmdline_fixed_string_t port;
1083 cmdline_fixed_string_t keyword;
1084 cmdline_fixed_string_t identifier;
1087 static void cmd_operate_attach_port_parsed(void *parsed_result,
1088 __attribute__((unused)) struct cmdline *cl,
1089 __attribute__((unused)) void *data)
1091 struct cmd_operate_attach_port_result *res = parsed_result;
1093 if (!strcmp(res->keyword, "attach"))
1094 attach_port(res->identifier);
1096 printf("Unknown parameter\n");
1099 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1100 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1102 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1103 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1105 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1106 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1109 cmdline_parse_inst_t cmd_operate_attach_port = {
1110 .f = cmd_operate_attach_port_parsed,
1112 .help_str = "port attach <identifier>: "
1113 "(identifier: pci address or virtual dev name)",
1115 (void *)&cmd_operate_attach_port_port,
1116 (void *)&cmd_operate_attach_port_keyword,
1117 (void *)&cmd_operate_attach_port_identifier,
1122 /* *** detach a specified port *** */
1123 struct cmd_operate_detach_port_result {
1124 cmdline_fixed_string_t port;
1125 cmdline_fixed_string_t keyword;
1129 static void cmd_operate_detach_port_parsed(void *parsed_result,
1130 __attribute__((unused)) struct cmdline *cl,
1131 __attribute__((unused)) void *data)
1133 struct cmd_operate_detach_port_result *res = parsed_result;
1135 if (!strcmp(res->keyword, "detach"))
1136 detach_port(res->port_id);
1138 printf("Unknown parameter\n");
1141 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1142 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1144 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1145 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1147 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1148 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1151 cmdline_parse_inst_t cmd_operate_detach_port = {
1152 .f = cmd_operate_detach_port_parsed,
1154 .help_str = "port detach <port_id>",
1156 (void *)&cmd_operate_detach_port_port,
1157 (void *)&cmd_operate_detach_port_keyword,
1158 (void *)&cmd_operate_detach_port_port_id,
1163 /* *** configure speed for all ports *** */
1164 struct cmd_config_speed_all {
1165 cmdline_fixed_string_t port;
1166 cmdline_fixed_string_t keyword;
1167 cmdline_fixed_string_t all;
1168 cmdline_fixed_string_t item1;
1169 cmdline_fixed_string_t item2;
1170 cmdline_fixed_string_t value1;
1171 cmdline_fixed_string_t value2;
1175 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1180 if (!strcmp(duplexstr, "half")) {
1181 duplex = ETH_LINK_HALF_DUPLEX;
1182 } else if (!strcmp(duplexstr, "full")) {
1183 duplex = ETH_LINK_FULL_DUPLEX;
1184 } else if (!strcmp(duplexstr, "auto")) {
1185 duplex = ETH_LINK_FULL_DUPLEX;
1187 printf("Unknown duplex parameter\n");
1191 if (!strcmp(speedstr, "10")) {
1192 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1193 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1194 } else if (!strcmp(speedstr, "100")) {
1195 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1196 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1198 if (duplex != ETH_LINK_FULL_DUPLEX) {
1199 printf("Invalid speed/duplex parameters\n");
1202 if (!strcmp(speedstr, "1000")) {
1203 *speed = ETH_LINK_SPEED_1G;
1204 } else if (!strcmp(speedstr, "10000")) {
1205 *speed = ETH_LINK_SPEED_10G;
1206 } else if (!strcmp(speedstr, "25000")) {
1207 *speed = ETH_LINK_SPEED_25G;
1208 } else if (!strcmp(speedstr, "40000")) {
1209 *speed = ETH_LINK_SPEED_40G;
1210 } else if (!strcmp(speedstr, "50000")) {
1211 *speed = ETH_LINK_SPEED_50G;
1212 } else if (!strcmp(speedstr, "100000")) {
1213 *speed = ETH_LINK_SPEED_100G;
1214 } else if (!strcmp(speedstr, "auto")) {
1215 *speed = ETH_LINK_SPEED_AUTONEG;
1217 printf("Unknown speed parameter\n");
1226 cmd_config_speed_all_parsed(void *parsed_result,
1227 __attribute__((unused)) struct cmdline *cl,
1228 __attribute__((unused)) void *data)
1230 struct cmd_config_speed_all *res = parsed_result;
1231 uint32_t link_speed;
1234 if (!all_ports_stopped()) {
1235 printf("Please stop all ports first\n");
1239 if (parse_and_check_speed_duplex(res->value1, res->value2,
1243 RTE_ETH_FOREACH_DEV(pid) {
1244 ports[pid].dev_conf.link_speeds = link_speed;
1247 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1250 cmdline_parse_token_string_t cmd_config_speed_all_port =
1251 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1252 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1253 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1255 cmdline_parse_token_string_t cmd_config_speed_all_all =
1256 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1257 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1258 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1259 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1260 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1261 "10#100#1000#10000#25000#40000#50000#100000#auto");
1262 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1263 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1264 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1265 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1268 cmdline_parse_inst_t cmd_config_speed_all = {
1269 .f = cmd_config_speed_all_parsed,
1271 .help_str = "port config all speed "
1272 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1275 (void *)&cmd_config_speed_all_port,
1276 (void *)&cmd_config_speed_all_keyword,
1277 (void *)&cmd_config_speed_all_all,
1278 (void *)&cmd_config_speed_all_item1,
1279 (void *)&cmd_config_speed_all_value1,
1280 (void *)&cmd_config_speed_all_item2,
1281 (void *)&cmd_config_speed_all_value2,
1286 /* *** configure speed for specific port *** */
1287 struct cmd_config_speed_specific {
1288 cmdline_fixed_string_t port;
1289 cmdline_fixed_string_t keyword;
1291 cmdline_fixed_string_t item1;
1292 cmdline_fixed_string_t item2;
1293 cmdline_fixed_string_t value1;
1294 cmdline_fixed_string_t value2;
1298 cmd_config_speed_specific_parsed(void *parsed_result,
1299 __attribute__((unused)) struct cmdline *cl,
1300 __attribute__((unused)) void *data)
1302 struct cmd_config_speed_specific *res = parsed_result;
1303 uint32_t link_speed;
1305 if (!all_ports_stopped()) {
1306 printf("Please stop all ports first\n");
1310 if (port_id_is_invalid(res->id, ENABLED_WARN))
1313 if (parse_and_check_speed_duplex(res->value1, res->value2,
1317 ports[res->id].dev_conf.link_speeds = link_speed;
1319 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1323 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1324 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1326 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1327 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1329 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1330 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1331 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1332 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1334 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1335 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1336 "10#100#1000#10000#25000#40000#50000#100000#auto");
1337 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1338 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1340 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1341 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1344 cmdline_parse_inst_t cmd_config_speed_specific = {
1345 .f = cmd_config_speed_specific_parsed,
1347 .help_str = "port config <port_id> speed "
1348 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1351 (void *)&cmd_config_speed_specific_port,
1352 (void *)&cmd_config_speed_specific_keyword,
1353 (void *)&cmd_config_speed_specific_id,
1354 (void *)&cmd_config_speed_specific_item1,
1355 (void *)&cmd_config_speed_specific_value1,
1356 (void *)&cmd_config_speed_specific_item2,
1357 (void *)&cmd_config_speed_specific_value2,
1362 /* *** configure txq/rxq, txd/rxd *** */
1363 struct cmd_config_rx_tx {
1364 cmdline_fixed_string_t port;
1365 cmdline_fixed_string_t keyword;
1366 cmdline_fixed_string_t all;
1367 cmdline_fixed_string_t name;
1372 cmd_config_rx_tx_parsed(void *parsed_result,
1373 __attribute__((unused)) struct cmdline *cl,
1374 __attribute__((unused)) void *data)
1376 struct cmd_config_rx_tx *res = parsed_result;
1378 if (!all_ports_stopped()) {
1379 printf("Please stop all ports first\n");
1382 if (!strcmp(res->name, "rxq")) {
1383 if (!res->value && !nb_txq) {
1384 printf("Warning: Either rx or tx queues should be non zero\n");
1387 nb_rxq = res->value;
1389 else if (!strcmp(res->name, "txq")) {
1390 if (!res->value && !nb_rxq) {
1391 printf("Warning: Either rx or tx queues should be non zero\n");
1394 nb_txq = res->value;
1396 else if (!strcmp(res->name, "rxd")) {
1397 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1398 printf("rxd %d invalid - must be > 0 && <= %d\n",
1399 res->value, RTE_TEST_RX_DESC_MAX);
1402 nb_rxd = res->value;
1403 } else if (!strcmp(res->name, "txd")) {
1404 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1405 printf("txd %d invalid - must be > 0 && <= %d\n",
1406 res->value, RTE_TEST_TX_DESC_MAX);
1409 nb_txd = res->value;
1411 printf("Unknown parameter\n");
1419 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1422 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1424 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1425 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1426 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1427 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1428 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1429 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1431 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1432 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1434 cmdline_parse_inst_t cmd_config_rx_tx = {
1435 .f = cmd_config_rx_tx_parsed,
1437 .help_str = "port config all rxq|txq|rxd|txd <value>",
1439 (void *)&cmd_config_rx_tx_port,
1440 (void *)&cmd_config_rx_tx_keyword,
1441 (void *)&cmd_config_rx_tx_all,
1442 (void *)&cmd_config_rx_tx_name,
1443 (void *)&cmd_config_rx_tx_value,
1448 /* *** config max packet length *** */
1449 struct cmd_config_max_pkt_len_result {
1450 cmdline_fixed_string_t port;
1451 cmdline_fixed_string_t keyword;
1452 cmdline_fixed_string_t all;
1453 cmdline_fixed_string_t name;
1458 cmd_config_max_pkt_len_parsed(void *parsed_result,
1459 __attribute__((unused)) struct cmdline *cl,
1460 __attribute__((unused)) void *data)
1462 struct cmd_config_max_pkt_len_result *res = parsed_result;
1464 if (!all_ports_stopped()) {
1465 printf("Please stop all ports first\n");
1469 if (!strcmp(res->name, "max-pkt-len")) {
1470 if (res->value < ETHER_MIN_LEN) {
1471 printf("max-pkt-len can not be less than %d\n",
1475 if (res->value == rx_mode.max_rx_pkt_len)
1478 rx_mode.max_rx_pkt_len = res->value;
1479 if (res->value > ETHER_MAX_LEN)
1480 rx_mode.jumbo_frame = 1;
1482 rx_mode.jumbo_frame = 0;
1484 printf("Unknown parameter\n");
1490 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1493 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1496 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1497 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1499 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1502 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1503 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1505 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1506 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1509 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1510 .f = cmd_config_max_pkt_len_parsed,
1512 .help_str = "port config all max-pkt-len <value>",
1514 (void *)&cmd_config_max_pkt_len_port,
1515 (void *)&cmd_config_max_pkt_len_keyword,
1516 (void *)&cmd_config_max_pkt_len_all,
1517 (void *)&cmd_config_max_pkt_len_name,
1518 (void *)&cmd_config_max_pkt_len_value,
1523 /* *** configure port MTU *** */
1524 struct cmd_config_mtu_result {
1525 cmdline_fixed_string_t port;
1526 cmdline_fixed_string_t keyword;
1527 cmdline_fixed_string_t mtu;
1533 cmd_config_mtu_parsed(void *parsed_result,
1534 __attribute__((unused)) struct cmdline *cl,
1535 __attribute__((unused)) void *data)
1537 struct cmd_config_mtu_result *res = parsed_result;
1539 if (res->value < ETHER_MIN_LEN) {
1540 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1543 port_mtu_set(res->port_id, res->value);
1546 cmdline_parse_token_string_t cmd_config_mtu_port =
1547 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1549 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1550 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1552 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1553 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1555 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1556 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1557 cmdline_parse_token_num_t cmd_config_mtu_value =
1558 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1560 cmdline_parse_inst_t cmd_config_mtu = {
1561 .f = cmd_config_mtu_parsed,
1563 .help_str = "port config mtu <port_id> <value>",
1565 (void *)&cmd_config_mtu_port,
1566 (void *)&cmd_config_mtu_keyword,
1567 (void *)&cmd_config_mtu_mtu,
1568 (void *)&cmd_config_mtu_port_id,
1569 (void *)&cmd_config_mtu_value,
1574 /* *** configure rx mode *** */
1575 struct cmd_config_rx_mode_flag {
1576 cmdline_fixed_string_t port;
1577 cmdline_fixed_string_t keyword;
1578 cmdline_fixed_string_t all;
1579 cmdline_fixed_string_t name;
1580 cmdline_fixed_string_t value;
1584 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1585 __attribute__((unused)) struct cmdline *cl,
1586 __attribute__((unused)) void *data)
1588 struct cmd_config_rx_mode_flag *res = parsed_result;
1590 if (!all_ports_stopped()) {
1591 printf("Please stop all ports first\n");
1595 if (!strcmp(res->name, "crc-strip")) {
1596 if (!strcmp(res->value, "on"))
1597 rx_mode.hw_strip_crc = 1;
1598 else if (!strcmp(res->value, "off"))
1599 rx_mode.hw_strip_crc = 0;
1601 printf("Unknown parameter\n");
1604 } else if (!strcmp(res->name, "scatter")) {
1605 if (!strcmp(res->value, "on"))
1606 rx_mode.enable_scatter = 1;
1607 else if (!strcmp(res->value, "off"))
1608 rx_mode.enable_scatter = 0;
1610 printf("Unknown parameter\n");
1613 } else if (!strcmp(res->name, "rx-cksum")) {
1614 if (!strcmp(res->value, "on"))
1615 rx_mode.hw_ip_checksum = 1;
1616 else if (!strcmp(res->value, "off"))
1617 rx_mode.hw_ip_checksum = 0;
1619 printf("Unknown parameter\n");
1622 } else if (!strcmp(res->name, "hw-vlan")) {
1623 if (!strcmp(res->value, "on")) {
1624 rx_mode.hw_vlan_filter = 1;
1625 rx_mode.hw_vlan_strip = 1;
1627 else if (!strcmp(res->value, "off")) {
1628 rx_mode.hw_vlan_filter = 0;
1629 rx_mode.hw_vlan_strip = 0;
1632 printf("Unknown parameter\n");
1635 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1636 if (!strcmp(res->value, "on"))
1637 rx_mode.hw_vlan_filter = 1;
1638 else if (!strcmp(res->value, "off"))
1639 rx_mode.hw_vlan_filter = 0;
1641 printf("Unknown parameter\n");
1644 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1645 if (!strcmp(res->value, "on"))
1646 rx_mode.hw_vlan_strip = 1;
1647 else if (!strcmp(res->value, "off"))
1648 rx_mode.hw_vlan_strip = 0;
1650 printf("Unknown parameter\n");
1653 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1654 if (!strcmp(res->value, "on"))
1655 rx_mode.hw_vlan_extend = 1;
1656 else if (!strcmp(res->value, "off"))
1657 rx_mode.hw_vlan_extend = 0;
1659 printf("Unknown parameter\n");
1662 } else if (!strcmp(res->name, "drop-en")) {
1663 if (!strcmp(res->value, "on"))
1665 else if (!strcmp(res->value, "off"))
1668 printf("Unknown parameter\n");
1672 printf("Unknown parameter\n");
1678 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1681 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1683 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1686 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1688 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1689 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1690 "crc-strip#scatter#rx-cksum#hw-vlan#"
1691 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1692 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1693 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1696 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1697 .f = cmd_config_rx_mode_flag_parsed,
1699 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1700 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1702 (void *)&cmd_config_rx_mode_flag_port,
1703 (void *)&cmd_config_rx_mode_flag_keyword,
1704 (void *)&cmd_config_rx_mode_flag_all,
1705 (void *)&cmd_config_rx_mode_flag_name,
1706 (void *)&cmd_config_rx_mode_flag_value,
1711 /* *** configure rss *** */
1712 struct cmd_config_rss {
1713 cmdline_fixed_string_t port;
1714 cmdline_fixed_string_t keyword;
1715 cmdline_fixed_string_t all;
1716 cmdline_fixed_string_t name;
1717 cmdline_fixed_string_t value;
1721 cmd_config_rss_parsed(void *parsed_result,
1722 __attribute__((unused)) struct cmdline *cl,
1723 __attribute__((unused)) void *data)
1725 struct cmd_config_rss *res = parsed_result;
1726 struct rte_eth_rss_conf rss_conf;
1730 if (!strcmp(res->value, "all"))
1731 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1732 ETH_RSS_UDP | ETH_RSS_SCTP |
1734 else if (!strcmp(res->value, "ip"))
1735 rss_conf.rss_hf = ETH_RSS_IP;
1736 else if (!strcmp(res->value, "udp"))
1737 rss_conf.rss_hf = ETH_RSS_UDP;
1738 else if (!strcmp(res->value, "tcp"))
1739 rss_conf.rss_hf = ETH_RSS_TCP;
1740 else if (!strcmp(res->value, "sctp"))
1741 rss_conf.rss_hf = ETH_RSS_SCTP;
1742 else if (!strcmp(res->value, "ether"))
1743 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1744 else if (!strcmp(res->value, "port"))
1745 rss_conf.rss_hf = ETH_RSS_PORT;
1746 else if (!strcmp(res->value, "vxlan"))
1747 rss_conf.rss_hf = ETH_RSS_VXLAN;
1748 else if (!strcmp(res->value, "geneve"))
1749 rss_conf.rss_hf = ETH_RSS_GENEVE;
1750 else if (!strcmp(res->value, "nvgre"))
1751 rss_conf.rss_hf = ETH_RSS_NVGRE;
1752 else if (!strcmp(res->value, "none"))
1753 rss_conf.rss_hf = 0;
1754 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1755 atoi(res->value) < 64)
1756 rss_conf.rss_hf = 1ULL << atoi(res->value);
1758 printf("Unknown parameter\n");
1761 rss_conf.rss_key = NULL;
1762 for (i = 0; i < rte_eth_dev_count(); i++) {
1763 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1765 printf("Configuration of RSS hash at ethernet port %d "
1766 "failed with error (%d): %s.\n",
1767 i, -diag, strerror(-diag));
1771 cmdline_parse_token_string_t cmd_config_rss_port =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1773 cmdline_parse_token_string_t cmd_config_rss_keyword =
1774 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1775 cmdline_parse_token_string_t cmd_config_rss_all =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1777 cmdline_parse_token_string_t cmd_config_rss_name =
1778 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1779 cmdline_parse_token_string_t cmd_config_rss_value =
1780 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1782 cmdline_parse_inst_t cmd_config_rss = {
1783 .f = cmd_config_rss_parsed,
1785 .help_str = "port config all rss "
1786 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1788 (void *)&cmd_config_rss_port,
1789 (void *)&cmd_config_rss_keyword,
1790 (void *)&cmd_config_rss_all,
1791 (void *)&cmd_config_rss_name,
1792 (void *)&cmd_config_rss_value,
1797 /* *** configure rss hash key *** */
1798 struct cmd_config_rss_hash_key {
1799 cmdline_fixed_string_t port;
1800 cmdline_fixed_string_t config;
1802 cmdline_fixed_string_t rss_hash_key;
1803 cmdline_fixed_string_t rss_type;
1804 cmdline_fixed_string_t key;
1808 hexa_digit_to_value(char hexa_digit)
1810 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1811 return (uint8_t) (hexa_digit - '0');
1812 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1813 return (uint8_t) ((hexa_digit - 'a') + 10);
1814 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1815 return (uint8_t) ((hexa_digit - 'A') + 10);
1816 /* Invalid hexa digit */
1821 parse_and_check_key_hexa_digit(char *key, int idx)
1825 hexa_v = hexa_digit_to_value(key[idx]);
1827 printf("invalid key: character %c at position %d is not a "
1828 "valid hexa digit\n", key[idx], idx);
1833 cmd_config_rss_hash_key_parsed(void *parsed_result,
1834 __attribute__((unused)) struct cmdline *cl,
1835 __attribute__((unused)) void *data)
1837 struct cmd_config_rss_hash_key *res = parsed_result;
1838 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1842 struct rte_eth_dev_info dev_info;
1843 uint8_t hash_key_size;
1846 memset(&dev_info, 0, sizeof(dev_info));
1847 rte_eth_dev_info_get(res->port_id, &dev_info);
1848 if (dev_info.hash_key_size > 0 &&
1849 dev_info.hash_key_size <= sizeof(hash_key))
1850 hash_key_size = dev_info.hash_key_size;
1852 printf("dev_info did not provide a valid hash key size\n");
1855 /* Check the length of the RSS hash key */
1856 key_len = strlen(res->key);
1857 if (key_len != (hash_key_size * 2)) {
1858 printf("key length: %d invalid - key must be a string of %d"
1859 " hexa-decimal numbers\n",
1860 (int) key_len, hash_key_size * 2);
1863 /* Translate RSS hash key into binary representation */
1864 for (i = 0; i < hash_key_size; i++) {
1865 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1868 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1871 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1873 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1877 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1878 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1879 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1880 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1882 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1883 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1884 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1885 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1886 rss_hash_key, "rss-hash-key");
1887 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1888 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1889 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1890 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1891 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1892 "ipv6-tcp-ex#ipv6-udp-ex");
1893 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1894 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1896 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1897 .f = cmd_config_rss_hash_key_parsed,
1899 .help_str = "port config <port_id> rss-hash-key "
1900 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1901 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1902 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1903 "<string of hex digits (variable length, NIC dependent)>",
1905 (void *)&cmd_config_rss_hash_key_port,
1906 (void *)&cmd_config_rss_hash_key_config,
1907 (void *)&cmd_config_rss_hash_key_port_id,
1908 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1909 (void *)&cmd_config_rss_hash_key_rss_type,
1910 (void *)&cmd_config_rss_hash_key_value,
1915 /* *** configure port rxq/txq start/stop *** */
1916 struct cmd_config_rxtx_queue {
1917 cmdline_fixed_string_t port;
1919 cmdline_fixed_string_t rxtxq;
1921 cmdline_fixed_string_t opname;
1925 cmd_config_rxtx_queue_parsed(void *parsed_result,
1926 __attribute__((unused)) struct cmdline *cl,
1927 __attribute__((unused)) void *data)
1929 struct cmd_config_rxtx_queue *res = parsed_result;
1934 if (test_done == 0) {
1935 printf("Please stop forwarding first\n");
1939 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1942 if (port_is_started(res->portid) != 1) {
1943 printf("Please start port %u first\n", res->portid);
1947 if (!strcmp(res->rxtxq, "rxq"))
1949 else if (!strcmp(res->rxtxq, "txq"))
1952 printf("Unknown parameter\n");
1956 if (isrx && rx_queue_id_is_invalid(res->qid))
1958 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1961 if (!strcmp(res->opname, "start"))
1963 else if (!strcmp(res->opname, "stop"))
1966 printf("Unknown parameter\n");
1970 if (isstart && isrx)
1971 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1972 else if (!isstart && isrx)
1973 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1974 else if (isstart && !isrx)
1975 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1977 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1979 if (ret == -ENOTSUP)
1980 printf("Function not supported in PMD driver\n");
1983 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1984 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1985 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1986 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1987 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1988 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1989 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1990 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1991 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1992 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1995 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1996 .f = cmd_config_rxtx_queue_parsed,
1998 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2000 (void *)&cmd_config_speed_all_port,
2001 (void *)&cmd_config_rxtx_queue_portid,
2002 (void *)&cmd_config_rxtx_queue_rxtxq,
2003 (void *)&cmd_config_rxtx_queue_qid,
2004 (void *)&cmd_config_rxtx_queue_opname,
2009 /* *** Configure RSS RETA *** */
2010 struct cmd_config_rss_reta {
2011 cmdline_fixed_string_t port;
2012 cmdline_fixed_string_t keyword;
2014 cmdline_fixed_string_t name;
2015 cmdline_fixed_string_t list_name;
2016 cmdline_fixed_string_t list_of_items;
2020 parse_reta_config(const char *str,
2021 struct rte_eth_rss_reta_entry64 *reta_conf,
2022 uint16_t nb_entries)
2026 uint16_t hash_index, idx, shift;
2029 const char *p, *p0 = str;
2036 unsigned long int_fld[_NUM_FLD];
2037 char *str_fld[_NUM_FLD];
2039 while ((p = strchr(p0,'(')) != NULL) {
2041 if((p0 = strchr(p,')')) == NULL)
2045 if(size >= sizeof(s))
2048 snprintf(s, sizeof(s), "%.*s", size, p);
2049 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2051 for (i = 0; i < _NUM_FLD; i++) {
2053 int_fld[i] = strtoul(str_fld[i], &end, 0);
2054 if (errno != 0 || end == str_fld[i] ||
2059 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2060 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2062 if (hash_index >= nb_entries) {
2063 printf("Invalid RETA hash index=%d\n", hash_index);
2067 idx = hash_index / RTE_RETA_GROUP_SIZE;
2068 shift = hash_index % RTE_RETA_GROUP_SIZE;
2069 reta_conf[idx].mask |= (1ULL << shift);
2070 reta_conf[idx].reta[shift] = nb_queue;
2077 cmd_set_rss_reta_parsed(void *parsed_result,
2078 __attribute__((unused)) struct cmdline *cl,
2079 __attribute__((unused)) void *data)
2082 struct rte_eth_dev_info dev_info;
2083 struct rte_eth_rss_reta_entry64 reta_conf[8];
2084 struct cmd_config_rss_reta *res = parsed_result;
2086 memset(&dev_info, 0, sizeof(dev_info));
2087 rte_eth_dev_info_get(res->port_id, &dev_info);
2088 if (dev_info.reta_size == 0) {
2089 printf("Redirection table size is 0 which is "
2090 "invalid for RSS\n");
2093 printf("The reta size of port %d is %u\n",
2094 res->port_id, dev_info.reta_size);
2095 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2096 printf("Currently do not support more than %u entries of "
2097 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2101 memset(reta_conf, 0, sizeof(reta_conf));
2102 if (!strcmp(res->list_name, "reta")) {
2103 if (parse_reta_config(res->list_of_items, reta_conf,
2104 dev_info.reta_size)) {
2105 printf("Invalid RSS Redirection Table "
2106 "config entered\n");
2109 ret = rte_eth_dev_rss_reta_update(res->port_id,
2110 reta_conf, dev_info.reta_size);
2112 printf("Bad redirection table parameter, "
2113 "return code = %d \n", ret);
2117 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2119 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2121 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2122 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2123 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2124 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2125 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2126 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2127 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2128 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2130 cmdline_parse_inst_t cmd_config_rss_reta = {
2131 .f = cmd_set_rss_reta_parsed,
2133 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2135 (void *)&cmd_config_rss_reta_port,
2136 (void *)&cmd_config_rss_reta_keyword,
2137 (void *)&cmd_config_rss_reta_port_id,
2138 (void *)&cmd_config_rss_reta_name,
2139 (void *)&cmd_config_rss_reta_list_name,
2140 (void *)&cmd_config_rss_reta_list_of_items,
2145 /* *** SHOW PORT RETA INFO *** */
2146 struct cmd_showport_reta {
2147 cmdline_fixed_string_t show;
2148 cmdline_fixed_string_t port;
2150 cmdline_fixed_string_t rss;
2151 cmdline_fixed_string_t reta;
2153 cmdline_fixed_string_t list_of_items;
2157 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2158 uint16_t nb_entries,
2162 const char *p, *p0 = str;
2167 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2168 RTE_RETA_GROUP_SIZE;
2171 p = strchr(p0, '(');
2175 p0 = strchr(p, ')');
2179 if (size >= sizeof(s)) {
2180 printf("The string size exceeds the internal buffer size\n");
2183 snprintf(s, sizeof(s), "%.*s", size, p);
2184 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2185 if (ret <= 0 || ret != num) {
2186 printf("The bits of masks do not match the number of "
2187 "reta entries: %u\n", num);
2190 for (i = 0; i < ret; i++)
2191 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2197 cmd_showport_reta_parsed(void *parsed_result,
2198 __attribute__((unused)) struct cmdline *cl,
2199 __attribute__((unused)) void *data)
2201 struct cmd_showport_reta *res = parsed_result;
2202 struct rte_eth_rss_reta_entry64 reta_conf[8];
2203 struct rte_eth_dev_info dev_info;
2204 uint16_t max_reta_size;
2206 memset(&dev_info, 0, sizeof(dev_info));
2207 rte_eth_dev_info_get(res->port_id, &dev_info);
2208 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2209 if (res->size == 0 || res->size > max_reta_size) {
2210 printf("Invalid redirection table size: %u (1-%u)\n",
2211 res->size, max_reta_size);
2215 memset(reta_conf, 0, sizeof(reta_conf));
2216 if (showport_parse_reta_config(reta_conf, res->size,
2217 res->list_of_items) < 0) {
2218 printf("Invalid string: %s for reta masks\n",
2219 res->list_of_items);
2222 port_rss_reta_info(res->port_id, reta_conf, res->size);
2225 cmdline_parse_token_string_t cmd_showport_reta_show =
2226 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2227 cmdline_parse_token_string_t cmd_showport_reta_port =
2228 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2229 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2230 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2231 cmdline_parse_token_string_t cmd_showport_reta_rss =
2232 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2233 cmdline_parse_token_string_t cmd_showport_reta_reta =
2234 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2235 cmdline_parse_token_num_t cmd_showport_reta_size =
2236 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2237 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2238 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2239 list_of_items, NULL);
2241 cmdline_parse_inst_t cmd_showport_reta = {
2242 .f = cmd_showport_reta_parsed,
2244 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2246 (void *)&cmd_showport_reta_show,
2247 (void *)&cmd_showport_reta_port,
2248 (void *)&cmd_showport_reta_port_id,
2249 (void *)&cmd_showport_reta_rss,
2250 (void *)&cmd_showport_reta_reta,
2251 (void *)&cmd_showport_reta_size,
2252 (void *)&cmd_showport_reta_list_of_items,
2257 /* *** Show RSS hash configuration *** */
2258 struct cmd_showport_rss_hash {
2259 cmdline_fixed_string_t show;
2260 cmdline_fixed_string_t port;
2262 cmdline_fixed_string_t rss_hash;
2263 cmdline_fixed_string_t rss_type;
2264 cmdline_fixed_string_t key; /* optional argument */
2267 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2268 __attribute__((unused)) struct cmdline *cl,
2271 struct cmd_showport_rss_hash *res = parsed_result;
2273 port_rss_hash_conf_show(res->port_id, res->rss_type,
2274 show_rss_key != NULL);
2277 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2278 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2279 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2280 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2281 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2282 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2283 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2284 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2286 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2287 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2288 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2289 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2290 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2291 "ipv6-tcp-ex#ipv6-udp-ex");
2292 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2293 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2295 cmdline_parse_inst_t cmd_showport_rss_hash = {
2296 .f = cmd_showport_rss_hash_parsed,
2298 .help_str = "show port <port_id> rss-hash "
2299 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2300 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2301 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2303 (void *)&cmd_showport_rss_hash_show,
2304 (void *)&cmd_showport_rss_hash_port,
2305 (void *)&cmd_showport_rss_hash_port_id,
2306 (void *)&cmd_showport_rss_hash_rss_hash,
2307 (void *)&cmd_showport_rss_hash_rss_hash_info,
2312 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2313 .f = cmd_showport_rss_hash_parsed,
2315 .help_str = "show port <port_id> rss-hash "
2316 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2317 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2318 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2320 (void *)&cmd_showport_rss_hash_show,
2321 (void *)&cmd_showport_rss_hash_port,
2322 (void *)&cmd_showport_rss_hash_port_id,
2323 (void *)&cmd_showport_rss_hash_rss_hash,
2324 (void *)&cmd_showport_rss_hash_rss_hash_info,
2325 (void *)&cmd_showport_rss_hash_rss_key,
2330 /* *** Configure DCB *** */
2331 struct cmd_config_dcb {
2332 cmdline_fixed_string_t port;
2333 cmdline_fixed_string_t config;
2335 cmdline_fixed_string_t dcb;
2336 cmdline_fixed_string_t vt;
2337 cmdline_fixed_string_t vt_en;
2339 cmdline_fixed_string_t pfc;
2340 cmdline_fixed_string_t pfc_en;
2344 cmd_config_dcb_parsed(void *parsed_result,
2345 __attribute__((unused)) struct cmdline *cl,
2346 __attribute__((unused)) void *data)
2348 struct cmd_config_dcb *res = parsed_result;
2349 portid_t port_id = res->port_id;
2350 struct rte_port *port;
2354 port = &ports[port_id];
2355 /** Check if the port is not started **/
2356 if (port->port_status != RTE_PORT_STOPPED) {
2357 printf("Please stop port %d first\n", port_id);
2361 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2362 printf("The invalid number of traffic class,"
2363 " only 4 or 8 allowed.\n");
2367 if (nb_fwd_lcores < res->num_tcs) {
2368 printf("nb_cores shouldn't be less than number of TCs.\n");
2371 if (!strncmp(res->pfc_en, "on", 2))
2376 /* DCB in VT mode */
2377 if (!strncmp(res->vt_en, "on", 2))
2378 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2379 (enum rte_eth_nb_tcs)res->num_tcs,
2382 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2383 (enum rte_eth_nb_tcs)res->num_tcs,
2388 printf("Cannot initialize network ports.\n");
2392 cmd_reconfig_device_queue(port_id, 1, 1);
2395 cmdline_parse_token_string_t cmd_config_dcb_port =
2396 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2397 cmdline_parse_token_string_t cmd_config_dcb_config =
2398 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2399 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2400 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2401 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2402 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2403 cmdline_parse_token_string_t cmd_config_dcb_vt =
2404 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2405 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2406 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2407 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2408 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2409 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2410 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2411 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2414 cmdline_parse_inst_t cmd_config_dcb = {
2415 .f = cmd_config_dcb_parsed,
2417 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2419 (void *)&cmd_config_dcb_port,
2420 (void *)&cmd_config_dcb_config,
2421 (void *)&cmd_config_dcb_port_id,
2422 (void *)&cmd_config_dcb_dcb,
2423 (void *)&cmd_config_dcb_vt,
2424 (void *)&cmd_config_dcb_vt_en,
2425 (void *)&cmd_config_dcb_num_tcs,
2426 (void *)&cmd_config_dcb_pfc,
2427 (void *)&cmd_config_dcb_pfc_en,
2432 /* *** configure number of packets per burst *** */
2433 struct cmd_config_burst {
2434 cmdline_fixed_string_t port;
2435 cmdline_fixed_string_t keyword;
2436 cmdline_fixed_string_t all;
2437 cmdline_fixed_string_t name;
2442 cmd_config_burst_parsed(void *parsed_result,
2443 __attribute__((unused)) struct cmdline *cl,
2444 __attribute__((unused)) void *data)
2446 struct cmd_config_burst *res = parsed_result;
2448 if (!all_ports_stopped()) {
2449 printf("Please stop all ports first\n");
2453 if (!strcmp(res->name, "burst")) {
2454 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2455 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2458 nb_pkt_per_burst = res->value;
2460 printf("Unknown parameter\n");
2466 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2469 cmdline_parse_token_string_t cmd_config_burst_port =
2470 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2471 cmdline_parse_token_string_t cmd_config_burst_keyword =
2472 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2473 cmdline_parse_token_string_t cmd_config_burst_all =
2474 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2475 cmdline_parse_token_string_t cmd_config_burst_name =
2476 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2477 cmdline_parse_token_num_t cmd_config_burst_value =
2478 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2480 cmdline_parse_inst_t cmd_config_burst = {
2481 .f = cmd_config_burst_parsed,
2483 .help_str = "port config all burst <value>",
2485 (void *)&cmd_config_burst_port,
2486 (void *)&cmd_config_burst_keyword,
2487 (void *)&cmd_config_burst_all,
2488 (void *)&cmd_config_burst_name,
2489 (void *)&cmd_config_burst_value,
2494 /* *** configure rx/tx queues *** */
2495 struct cmd_config_thresh {
2496 cmdline_fixed_string_t port;
2497 cmdline_fixed_string_t keyword;
2498 cmdline_fixed_string_t all;
2499 cmdline_fixed_string_t name;
2504 cmd_config_thresh_parsed(void *parsed_result,
2505 __attribute__((unused)) struct cmdline *cl,
2506 __attribute__((unused)) void *data)
2508 struct cmd_config_thresh *res = parsed_result;
2510 if (!all_ports_stopped()) {
2511 printf("Please stop all ports first\n");
2515 if (!strcmp(res->name, "txpt"))
2516 tx_pthresh = res->value;
2517 else if(!strcmp(res->name, "txht"))
2518 tx_hthresh = res->value;
2519 else if(!strcmp(res->name, "txwt"))
2520 tx_wthresh = res->value;
2521 else if(!strcmp(res->name, "rxpt"))
2522 rx_pthresh = res->value;
2523 else if(!strcmp(res->name, "rxht"))
2524 rx_hthresh = res->value;
2525 else if(!strcmp(res->name, "rxwt"))
2526 rx_wthresh = res->value;
2528 printf("Unknown parameter\n");
2534 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2537 cmdline_parse_token_string_t cmd_config_thresh_port =
2538 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2539 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2540 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2541 cmdline_parse_token_string_t cmd_config_thresh_all =
2542 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2543 cmdline_parse_token_string_t cmd_config_thresh_name =
2544 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2545 "txpt#txht#txwt#rxpt#rxht#rxwt");
2546 cmdline_parse_token_num_t cmd_config_thresh_value =
2547 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2549 cmdline_parse_inst_t cmd_config_thresh = {
2550 .f = cmd_config_thresh_parsed,
2552 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2554 (void *)&cmd_config_thresh_port,
2555 (void *)&cmd_config_thresh_keyword,
2556 (void *)&cmd_config_thresh_all,
2557 (void *)&cmd_config_thresh_name,
2558 (void *)&cmd_config_thresh_value,
2563 /* *** configure free/rs threshold *** */
2564 struct cmd_config_threshold {
2565 cmdline_fixed_string_t port;
2566 cmdline_fixed_string_t keyword;
2567 cmdline_fixed_string_t all;
2568 cmdline_fixed_string_t name;
2573 cmd_config_threshold_parsed(void *parsed_result,
2574 __attribute__((unused)) struct cmdline *cl,
2575 __attribute__((unused)) void *data)
2577 struct cmd_config_threshold *res = parsed_result;
2579 if (!all_ports_stopped()) {
2580 printf("Please stop all ports first\n");
2584 if (!strcmp(res->name, "txfreet"))
2585 tx_free_thresh = res->value;
2586 else if (!strcmp(res->name, "txrst"))
2587 tx_rs_thresh = res->value;
2588 else if (!strcmp(res->name, "rxfreet"))
2589 rx_free_thresh = res->value;
2591 printf("Unknown parameter\n");
2597 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2600 cmdline_parse_token_string_t cmd_config_threshold_port =
2601 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2602 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2603 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2605 cmdline_parse_token_string_t cmd_config_threshold_all =
2606 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2607 cmdline_parse_token_string_t cmd_config_threshold_name =
2608 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2609 "txfreet#txrst#rxfreet");
2610 cmdline_parse_token_num_t cmd_config_threshold_value =
2611 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2613 cmdline_parse_inst_t cmd_config_threshold = {
2614 .f = cmd_config_threshold_parsed,
2616 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2618 (void *)&cmd_config_threshold_port,
2619 (void *)&cmd_config_threshold_keyword,
2620 (void *)&cmd_config_threshold_all,
2621 (void *)&cmd_config_threshold_name,
2622 (void *)&cmd_config_threshold_value,
2628 struct cmd_stop_result {
2629 cmdline_fixed_string_t stop;
2632 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2633 __attribute__((unused)) struct cmdline *cl,
2634 __attribute__((unused)) void *data)
2636 stop_packet_forwarding();
2639 cmdline_parse_token_string_t cmd_stop_stop =
2640 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2642 cmdline_parse_inst_t cmd_stop = {
2643 .f = cmd_stop_parsed,
2645 .help_str = "stop: Stop packet forwarding",
2647 (void *)&cmd_stop_stop,
2652 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2655 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2656 unsigned int *parsed_items, int check_unique_values)
2658 unsigned int nb_item;
2666 * First parse all items in the list and store their value.
2671 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2673 if ((c >= '0') && (c <= '9')) {
2674 value = (unsigned int) (value * 10 + (c - '0'));
2679 printf("character %c is not a decimal digit\n", c);
2683 printf("No valid value before comma\n");
2686 if (nb_item < max_items) {
2687 parsed_items[nb_item] = value;
2693 if (nb_item >= max_items) {
2694 printf("Number of %s = %u > %u (maximum items)\n",
2695 item_name, nb_item + 1, max_items);
2698 parsed_items[nb_item++] = value;
2699 if (! check_unique_values)
2703 * Then, check that all values in the list are differents.
2704 * No optimization here...
2706 for (i = 0; i < nb_item; i++) {
2707 for (j = i + 1; j < nb_item; j++) {
2708 if (parsed_items[j] == parsed_items[i]) {
2709 printf("duplicated %s %u at index %u and %u\n",
2710 item_name, parsed_items[i], i, j);
2718 struct cmd_set_list_result {
2719 cmdline_fixed_string_t cmd_keyword;
2720 cmdline_fixed_string_t list_name;
2721 cmdline_fixed_string_t list_of_items;
2724 static void cmd_set_list_parsed(void *parsed_result,
2725 __attribute__((unused)) struct cmdline *cl,
2726 __attribute__((unused)) void *data)
2728 struct cmd_set_list_result *res;
2730 unsigned int lcorelist[RTE_MAX_LCORE];
2731 unsigned int portlist[RTE_MAX_ETHPORTS];
2733 unsigned int nb_item;
2735 if (test_done == 0) {
2736 printf("Please stop forwarding first\n");
2740 res = parsed_result;
2741 if (!strcmp(res->list_name, "corelist")) {
2742 nb_item = parse_item_list(res->list_of_items, "core",
2744 parsed_items.lcorelist, 1);
2746 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2751 if (!strcmp(res->list_name, "portlist")) {
2752 nb_item = parse_item_list(res->list_of_items, "port",
2754 parsed_items.portlist, 1);
2756 set_fwd_ports_list(parsed_items.portlist, nb_item);
2762 cmdline_parse_token_string_t cmd_set_list_keyword =
2763 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2765 cmdline_parse_token_string_t cmd_set_list_name =
2766 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2767 "corelist#portlist");
2768 cmdline_parse_token_string_t cmd_set_list_of_items =
2769 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2772 cmdline_parse_inst_t cmd_set_fwd_list = {
2773 .f = cmd_set_list_parsed,
2775 .help_str = "set corelist|portlist <list0[,list1]*>",
2777 (void *)&cmd_set_list_keyword,
2778 (void *)&cmd_set_list_name,
2779 (void *)&cmd_set_list_of_items,
2784 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2786 struct cmd_setmask_result {
2787 cmdline_fixed_string_t set;
2788 cmdline_fixed_string_t mask;
2792 static void cmd_set_mask_parsed(void *parsed_result,
2793 __attribute__((unused)) struct cmdline *cl,
2794 __attribute__((unused)) void *data)
2796 struct cmd_setmask_result *res = parsed_result;
2798 if (test_done == 0) {
2799 printf("Please stop forwarding first\n");
2802 if (!strcmp(res->mask, "coremask")) {
2803 set_fwd_lcores_mask(res->hexavalue);
2805 } else if (!strcmp(res->mask, "portmask")) {
2806 set_fwd_ports_mask(res->hexavalue);
2811 cmdline_parse_token_string_t cmd_setmask_set =
2812 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2813 cmdline_parse_token_string_t cmd_setmask_mask =
2814 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2815 "coremask#portmask");
2816 cmdline_parse_token_num_t cmd_setmask_value =
2817 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2819 cmdline_parse_inst_t cmd_set_fwd_mask = {
2820 .f = cmd_set_mask_parsed,
2822 .help_str = "set coremask|portmask <hexadecimal value>",
2824 (void *)&cmd_setmask_set,
2825 (void *)&cmd_setmask_mask,
2826 (void *)&cmd_setmask_value,
2832 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2834 struct cmd_set_result {
2835 cmdline_fixed_string_t set;
2836 cmdline_fixed_string_t what;
2840 static void cmd_set_parsed(void *parsed_result,
2841 __attribute__((unused)) struct cmdline *cl,
2842 __attribute__((unused)) void *data)
2844 struct cmd_set_result *res = parsed_result;
2845 if (!strcmp(res->what, "nbport")) {
2846 set_fwd_ports_number(res->value);
2848 } else if (!strcmp(res->what, "nbcore")) {
2849 set_fwd_lcores_number(res->value);
2851 } else if (!strcmp(res->what, "burst"))
2852 set_nb_pkt_per_burst(res->value);
2853 else if (!strcmp(res->what, "verbose"))
2854 set_verbose_level(res->value);
2857 cmdline_parse_token_string_t cmd_set_set =
2858 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2859 cmdline_parse_token_string_t cmd_set_what =
2860 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2861 "nbport#nbcore#burst#verbose");
2862 cmdline_parse_token_num_t cmd_set_value =
2863 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2865 cmdline_parse_inst_t cmd_set_numbers = {
2866 .f = cmd_set_parsed,
2868 .help_str = "set nbport|nbcore|burst|verbose <value>",
2870 (void *)&cmd_set_set,
2871 (void *)&cmd_set_what,
2872 (void *)&cmd_set_value,
2877 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2879 struct cmd_set_txpkts_result {
2880 cmdline_fixed_string_t cmd_keyword;
2881 cmdline_fixed_string_t txpkts;
2882 cmdline_fixed_string_t seg_lengths;
2886 cmd_set_txpkts_parsed(void *parsed_result,
2887 __attribute__((unused)) struct cmdline *cl,
2888 __attribute__((unused)) void *data)
2890 struct cmd_set_txpkts_result *res;
2891 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2892 unsigned int nb_segs;
2894 res = parsed_result;
2895 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2896 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2898 set_tx_pkt_segments(seg_lengths, nb_segs);
2901 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2902 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2903 cmd_keyword, "set");
2904 cmdline_parse_token_string_t cmd_set_txpkts_name =
2905 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2907 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2908 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2911 cmdline_parse_inst_t cmd_set_txpkts = {
2912 .f = cmd_set_txpkts_parsed,
2914 .help_str = "set txpkts <len0[,len1]*>",
2916 (void *)&cmd_set_txpkts_keyword,
2917 (void *)&cmd_set_txpkts_name,
2918 (void *)&cmd_set_txpkts_lengths,
2923 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2925 struct cmd_set_txsplit_result {
2926 cmdline_fixed_string_t cmd_keyword;
2927 cmdline_fixed_string_t txsplit;
2928 cmdline_fixed_string_t mode;
2932 cmd_set_txsplit_parsed(void *parsed_result,
2933 __attribute__((unused)) struct cmdline *cl,
2934 __attribute__((unused)) void *data)
2936 struct cmd_set_txsplit_result *res;
2938 res = parsed_result;
2939 set_tx_pkt_split(res->mode);
2942 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2943 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2944 cmd_keyword, "set");
2945 cmdline_parse_token_string_t cmd_set_txsplit_name =
2946 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2947 txsplit, "txsplit");
2948 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2949 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2952 cmdline_parse_inst_t cmd_set_txsplit = {
2953 .f = cmd_set_txsplit_parsed,
2955 .help_str = "set txsplit on|off|rand",
2957 (void *)&cmd_set_txsplit_keyword,
2958 (void *)&cmd_set_txsplit_name,
2959 (void *)&cmd_set_txsplit_mode,
2964 /* *** CONFIG TX QUEUE FLAGS *** */
2966 struct cmd_config_txqflags_result {
2967 cmdline_fixed_string_t port;
2968 cmdline_fixed_string_t config;
2969 cmdline_fixed_string_t all;
2970 cmdline_fixed_string_t what;
2974 static void cmd_config_txqflags_parsed(void *parsed_result,
2975 __attribute__((unused)) struct cmdline *cl,
2976 __attribute__((unused)) void *data)
2978 struct cmd_config_txqflags_result *res = parsed_result;
2980 if (!all_ports_stopped()) {
2981 printf("Please stop all ports first\n");
2985 if (strcmp(res->what, "txqflags")) {
2986 printf("Unknown parameter\n");
2990 if (res->hexvalue >= 0) {
2991 txq_flags = res->hexvalue;
2993 printf("txqflags must be >= 0\n");
2999 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3002 cmdline_parse_token_string_t cmd_config_txqflags_port =
3003 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3005 cmdline_parse_token_string_t cmd_config_txqflags_config =
3006 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3008 cmdline_parse_token_string_t cmd_config_txqflags_all =
3009 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3011 cmdline_parse_token_string_t cmd_config_txqflags_what =
3012 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3014 cmdline_parse_token_num_t cmd_config_txqflags_value =
3015 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3018 cmdline_parse_inst_t cmd_config_txqflags = {
3019 .f = cmd_config_txqflags_parsed,
3021 .help_str = "port config all txqflags <value>",
3023 (void *)&cmd_config_txqflags_port,
3024 (void *)&cmd_config_txqflags_config,
3025 (void *)&cmd_config_txqflags_all,
3026 (void *)&cmd_config_txqflags_what,
3027 (void *)&cmd_config_txqflags_value,
3032 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3033 struct cmd_rx_vlan_filter_all_result {
3034 cmdline_fixed_string_t rx_vlan;
3035 cmdline_fixed_string_t what;
3036 cmdline_fixed_string_t all;
3041 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3042 __attribute__((unused)) struct cmdline *cl,
3043 __attribute__((unused)) void *data)
3045 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3047 if (!strcmp(res->what, "add"))
3048 rx_vlan_all_filter_set(res->port_id, 1);
3050 rx_vlan_all_filter_set(res->port_id, 0);
3053 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3054 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3055 rx_vlan, "rx_vlan");
3056 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3057 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3059 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3060 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3062 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3063 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3066 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3067 .f = cmd_rx_vlan_filter_all_parsed,
3069 .help_str = "rx_vlan add|rm all <port_id>: "
3070 "Add/Remove all identifiers to/from the set of VLAN "
3071 "identifiers filtered by a port",
3073 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3074 (void *)&cmd_rx_vlan_filter_all_what,
3075 (void *)&cmd_rx_vlan_filter_all_all,
3076 (void *)&cmd_rx_vlan_filter_all_portid,
3081 /* *** VLAN OFFLOAD SET ON A PORT *** */
3082 struct cmd_vlan_offload_result {
3083 cmdline_fixed_string_t vlan;
3084 cmdline_fixed_string_t set;
3085 cmdline_fixed_string_t vlan_type;
3086 cmdline_fixed_string_t what;
3087 cmdline_fixed_string_t on;
3088 cmdline_fixed_string_t port_id;
3092 cmd_vlan_offload_parsed(void *parsed_result,
3093 __attribute__((unused)) struct cmdline *cl,
3094 __attribute__((unused)) void *data)
3097 struct cmd_vlan_offload_result *res = parsed_result;
3100 portid_t port_id = 0;
3104 len = strnlen(str, STR_TOKEN_SIZE);
3106 /* Get port_id first */
3114 tmp = strtoul(str, NULL, 0);
3115 /* If port_id greater that what portid_t can represent, return */
3116 if(tmp >= RTE_MAX_ETHPORTS)
3118 port_id = (portid_t)tmp;
3120 if (!strcmp(res->on, "on"))
3125 if (!strcmp(res->what, "strip"))
3126 rx_vlan_strip_set(port_id, on);
3127 else if(!strcmp(res->what, "stripq")){
3128 uint16_t queue_id = 0;
3130 /* No queue_id, return */
3132 printf("must specify (port,queue_id)\n");
3135 tmp = strtoul(str + i + 1, NULL, 0);
3136 /* If queue_id greater that what 16-bits can represent, return */
3140 queue_id = (uint16_t)tmp;
3141 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3143 else if (!strcmp(res->what, "filter"))
3144 rx_vlan_filter_set(port_id, on);
3146 vlan_extend_set(port_id, on);
3151 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3152 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3154 cmdline_parse_token_string_t cmd_vlan_offload_set =
3155 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3157 cmdline_parse_token_string_t cmd_vlan_offload_what =
3158 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3159 what, "strip#filter#qinq#stripq");
3160 cmdline_parse_token_string_t cmd_vlan_offload_on =
3161 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3163 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3164 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3167 cmdline_parse_inst_t cmd_vlan_offload = {
3168 .f = cmd_vlan_offload_parsed,
3170 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3171 "<port_id[,queue_id]>: "
3172 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3174 (void *)&cmd_vlan_offload_vlan,
3175 (void *)&cmd_vlan_offload_set,
3176 (void *)&cmd_vlan_offload_what,
3177 (void *)&cmd_vlan_offload_on,
3178 (void *)&cmd_vlan_offload_portid,
3183 /* *** VLAN TPID SET ON A PORT *** */
3184 struct cmd_vlan_tpid_result {
3185 cmdline_fixed_string_t vlan;
3186 cmdline_fixed_string_t set;
3187 cmdline_fixed_string_t vlan_type;
3188 cmdline_fixed_string_t what;
3194 cmd_vlan_tpid_parsed(void *parsed_result,
3195 __attribute__((unused)) struct cmdline *cl,
3196 __attribute__((unused)) void *data)
3198 struct cmd_vlan_tpid_result *res = parsed_result;
3199 enum rte_vlan_type vlan_type;
3201 if (!strcmp(res->vlan_type, "inner"))
3202 vlan_type = ETH_VLAN_TYPE_INNER;
3203 else if (!strcmp(res->vlan_type, "outer"))
3204 vlan_type = ETH_VLAN_TYPE_OUTER;
3206 printf("Unknown vlan type\n");
3209 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3212 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3213 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3215 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3216 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3218 cmdline_parse_token_string_t cmd_vlan_type =
3219 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3220 vlan_type, "inner#outer");
3221 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3222 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3224 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3225 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3227 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3228 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3231 cmdline_parse_inst_t cmd_vlan_tpid = {
3232 .f = cmd_vlan_tpid_parsed,
3234 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3235 "Set the VLAN Ether type",
3237 (void *)&cmd_vlan_tpid_vlan,
3238 (void *)&cmd_vlan_tpid_set,
3239 (void *)&cmd_vlan_type,
3240 (void *)&cmd_vlan_tpid_what,
3241 (void *)&cmd_vlan_tpid_tpid,
3242 (void *)&cmd_vlan_tpid_portid,
3247 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3248 struct cmd_rx_vlan_filter_result {
3249 cmdline_fixed_string_t rx_vlan;
3250 cmdline_fixed_string_t what;
3256 cmd_rx_vlan_filter_parsed(void *parsed_result,
3257 __attribute__((unused)) struct cmdline *cl,
3258 __attribute__((unused)) void *data)
3260 struct cmd_rx_vlan_filter_result *res = parsed_result;
3262 if (!strcmp(res->what, "add"))
3263 rx_vft_set(res->port_id, res->vlan_id, 1);
3265 rx_vft_set(res->port_id, res->vlan_id, 0);
3268 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3269 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3270 rx_vlan, "rx_vlan");
3271 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3272 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3274 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3275 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3277 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3278 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3281 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3282 .f = cmd_rx_vlan_filter_parsed,
3284 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3285 "Add/Remove a VLAN identifier to/from the set of VLAN "
3286 "identifiers filtered by a port",
3288 (void *)&cmd_rx_vlan_filter_rx_vlan,
3289 (void *)&cmd_rx_vlan_filter_what,
3290 (void *)&cmd_rx_vlan_filter_vlanid,
3291 (void *)&cmd_rx_vlan_filter_portid,
3296 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3297 struct cmd_tx_vlan_set_result {
3298 cmdline_fixed_string_t tx_vlan;
3299 cmdline_fixed_string_t set;
3305 cmd_tx_vlan_set_parsed(void *parsed_result,
3306 __attribute__((unused)) struct cmdline *cl,
3307 __attribute__((unused)) void *data)
3309 struct cmd_tx_vlan_set_result *res = parsed_result;
3311 tx_vlan_set(res->port_id, res->vlan_id);
3314 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3315 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3316 tx_vlan, "tx_vlan");
3317 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3318 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3320 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3321 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3323 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3324 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3327 cmdline_parse_inst_t cmd_tx_vlan_set = {
3328 .f = cmd_tx_vlan_set_parsed,
3330 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3331 "Enable hardware insertion of a single VLAN header "
3332 "with a given TAG Identifier in packets sent on a port",
3334 (void *)&cmd_tx_vlan_set_tx_vlan,
3335 (void *)&cmd_tx_vlan_set_set,
3336 (void *)&cmd_tx_vlan_set_portid,
3337 (void *)&cmd_tx_vlan_set_vlanid,
3342 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3343 struct cmd_tx_vlan_set_qinq_result {
3344 cmdline_fixed_string_t tx_vlan;
3345 cmdline_fixed_string_t set;
3348 uint16_t vlan_id_outer;
3352 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3353 __attribute__((unused)) struct cmdline *cl,
3354 __attribute__((unused)) void *data)
3356 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3358 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3361 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3362 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3363 tx_vlan, "tx_vlan");
3364 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3365 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3367 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3368 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3370 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3371 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3373 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3374 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3375 vlan_id_outer, UINT16);
3377 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3378 .f = cmd_tx_vlan_set_qinq_parsed,
3380 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3381 "Enable hardware insertion of double VLAN header "
3382 "with given TAG Identifiers in packets sent on a port",
3384 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3385 (void *)&cmd_tx_vlan_set_qinq_set,
3386 (void *)&cmd_tx_vlan_set_qinq_portid,
3387 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3388 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3393 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3394 struct cmd_tx_vlan_set_pvid_result {
3395 cmdline_fixed_string_t tx_vlan;
3396 cmdline_fixed_string_t set;
3397 cmdline_fixed_string_t pvid;
3400 cmdline_fixed_string_t mode;
3404 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3405 __attribute__((unused)) struct cmdline *cl,
3406 __attribute__((unused)) void *data)
3408 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3410 if (strcmp(res->mode, "on") == 0)
3411 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3413 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3416 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3417 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3418 tx_vlan, "tx_vlan");
3419 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3420 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3422 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3423 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3425 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3426 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3428 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3429 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3431 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3432 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3435 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3436 .f = cmd_tx_vlan_set_pvid_parsed,
3438 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3440 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3441 (void *)&cmd_tx_vlan_set_pvid_set,
3442 (void *)&cmd_tx_vlan_set_pvid_pvid,
3443 (void *)&cmd_tx_vlan_set_pvid_port_id,
3444 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3445 (void *)&cmd_tx_vlan_set_pvid_mode,
3450 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3451 struct cmd_tx_vlan_reset_result {
3452 cmdline_fixed_string_t tx_vlan;
3453 cmdline_fixed_string_t reset;
3458 cmd_tx_vlan_reset_parsed(void *parsed_result,
3459 __attribute__((unused)) struct cmdline *cl,
3460 __attribute__((unused)) void *data)
3462 struct cmd_tx_vlan_reset_result *res = parsed_result;
3464 tx_vlan_reset(res->port_id);
3467 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3468 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3469 tx_vlan, "tx_vlan");
3470 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3471 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3473 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3474 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3477 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3478 .f = cmd_tx_vlan_reset_parsed,
3480 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3481 "VLAN header in packets sent on a port",
3483 (void *)&cmd_tx_vlan_reset_tx_vlan,
3484 (void *)&cmd_tx_vlan_reset_reset,
3485 (void *)&cmd_tx_vlan_reset_portid,
3491 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3492 struct cmd_csum_result {
3493 cmdline_fixed_string_t csum;
3494 cmdline_fixed_string_t mode;
3495 cmdline_fixed_string_t proto;
3496 cmdline_fixed_string_t hwsw;
3501 csum_show(int port_id)
3503 struct rte_eth_dev_info dev_info;
3506 ol_flags = ports[port_id].tx_ol_flags;
3507 printf("Parse tunnel is %s\n",
3508 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3509 printf("IP checksum offload is %s\n",
3510 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3511 printf("UDP checksum offload is %s\n",
3512 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3513 printf("TCP checksum offload is %s\n",
3514 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3515 printf("SCTP checksum offload is %s\n",
3516 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3517 printf("Outer-Ip checksum offload is %s\n",
3518 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3520 /* display warnings if configuration is not supported by the NIC */
3521 rte_eth_dev_info_get(port_id, &dev_info);
3522 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3523 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3524 printf("Warning: hardware IP checksum enabled but not "
3525 "supported by port %d\n", port_id);
3527 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3528 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3529 printf("Warning: hardware UDP checksum enabled but not "
3530 "supported by port %d\n", port_id);
3532 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3533 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3534 printf("Warning: hardware TCP checksum enabled but not "
3535 "supported by port %d\n", port_id);
3537 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3538 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3539 printf("Warning: hardware SCTP checksum enabled but not "
3540 "supported by port %d\n", port_id);
3542 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3543 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3544 printf("Warning: hardware outer IP checksum enabled but not "
3545 "supported by port %d\n", port_id);
3550 cmd_csum_parsed(void *parsed_result,
3551 __attribute__((unused)) struct cmdline *cl,
3552 __attribute__((unused)) void *data)
3554 struct cmd_csum_result *res = parsed_result;
3558 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3559 printf("invalid port %d\n", res->port_id);
3563 if (!strcmp(res->mode, "set")) {
3565 if (!strcmp(res->hwsw, "hw"))
3568 if (!strcmp(res->proto, "ip")) {
3569 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3570 } else if (!strcmp(res->proto, "udp")) {
3571 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3572 } else if (!strcmp(res->proto, "tcp")) {
3573 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3574 } else if (!strcmp(res->proto, "sctp")) {
3575 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3576 } else if (!strcmp(res->proto, "outer-ip")) {
3577 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3581 ports[res->port_id].tx_ol_flags |= mask;
3583 ports[res->port_id].tx_ol_flags &= (~mask);
3585 csum_show(res->port_id);
3588 cmdline_parse_token_string_t cmd_csum_csum =
3589 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3591 cmdline_parse_token_string_t cmd_csum_mode =
3592 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3594 cmdline_parse_token_string_t cmd_csum_proto =
3595 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3596 proto, "ip#tcp#udp#sctp#outer-ip");
3597 cmdline_parse_token_string_t cmd_csum_hwsw =
3598 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3600 cmdline_parse_token_num_t cmd_csum_portid =
3601 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3604 cmdline_parse_inst_t cmd_csum_set = {
3605 .f = cmd_csum_parsed,
3607 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3608 "Enable/Disable hardware calculation of L3/L4 checksum when "
3609 "using csum forward engine",
3611 (void *)&cmd_csum_csum,
3612 (void *)&cmd_csum_mode,
3613 (void *)&cmd_csum_proto,
3614 (void *)&cmd_csum_hwsw,
3615 (void *)&cmd_csum_portid,
3620 cmdline_parse_token_string_t cmd_csum_mode_show =
3621 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3624 cmdline_parse_inst_t cmd_csum_show = {
3625 .f = cmd_csum_parsed,
3627 .help_str = "csum show <port_id>: Show checksum offload configuration",
3629 (void *)&cmd_csum_csum,
3630 (void *)&cmd_csum_mode_show,
3631 (void *)&cmd_csum_portid,
3636 /* Enable/disable tunnel parsing */
3637 struct cmd_csum_tunnel_result {
3638 cmdline_fixed_string_t csum;
3639 cmdline_fixed_string_t parse;
3640 cmdline_fixed_string_t onoff;
3645 cmd_csum_tunnel_parsed(void *parsed_result,
3646 __attribute__((unused)) struct cmdline *cl,
3647 __attribute__((unused)) void *data)
3649 struct cmd_csum_tunnel_result *res = parsed_result;
3651 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3654 if (!strcmp(res->onoff, "on"))
3655 ports[res->port_id].tx_ol_flags |=
3656 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3658 ports[res->port_id].tx_ol_flags &=
3659 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3661 csum_show(res->port_id);
3664 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3665 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3667 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3668 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3669 parse, "parse_tunnel");
3670 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3671 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3673 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3674 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3677 cmdline_parse_inst_t cmd_csum_tunnel = {
3678 .f = cmd_csum_tunnel_parsed,
3680 .help_str = "csum parse_tunnel on|off <port_id>: "
3681 "Enable/Disable parsing of tunnels for csum engine",
3683 (void *)&cmd_csum_tunnel_csum,
3684 (void *)&cmd_csum_tunnel_parse,
3685 (void *)&cmd_csum_tunnel_onoff,
3686 (void *)&cmd_csum_tunnel_portid,
3691 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3692 struct cmd_tso_set_result {
3693 cmdline_fixed_string_t tso;
3694 cmdline_fixed_string_t mode;
3700 cmd_tso_set_parsed(void *parsed_result,
3701 __attribute__((unused)) struct cmdline *cl,
3702 __attribute__((unused)) void *data)
3704 struct cmd_tso_set_result *res = parsed_result;
3705 struct rte_eth_dev_info dev_info;
3707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3710 if (!strcmp(res->mode, "set"))
3711 ports[res->port_id].tso_segsz = res->tso_segsz;
3713 if (ports[res->port_id].tso_segsz == 0)
3714 printf("TSO for non-tunneled packets is disabled\n");
3716 printf("TSO segment size for non-tunneled packets is %d\n",
3717 ports[res->port_id].tso_segsz);
3719 /* display warnings if configuration is not supported by the NIC */
3720 rte_eth_dev_info_get(res->port_id, &dev_info);
3721 if ((ports[res->port_id].tso_segsz != 0) &&
3722 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3723 printf("Warning: TSO enabled but not "
3724 "supported by port %d\n", res->port_id);
3728 cmdline_parse_token_string_t cmd_tso_set_tso =
3729 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3731 cmdline_parse_token_string_t cmd_tso_set_mode =
3732 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3734 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3735 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3737 cmdline_parse_token_num_t cmd_tso_set_portid =
3738 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3741 cmdline_parse_inst_t cmd_tso_set = {
3742 .f = cmd_tso_set_parsed,
3744 .help_str = "tso set <tso_segsz> <port_id>: "
3745 "Set TSO segment size of non-tunneled packets for csum engine "
3748 (void *)&cmd_tso_set_tso,
3749 (void *)&cmd_tso_set_mode,
3750 (void *)&cmd_tso_set_tso_segsz,
3751 (void *)&cmd_tso_set_portid,
3756 cmdline_parse_token_string_t cmd_tso_show_mode =
3757 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3761 cmdline_parse_inst_t cmd_tso_show = {
3762 .f = cmd_tso_set_parsed,
3764 .help_str = "tso show <port_id>: "
3765 "Show TSO segment size of non-tunneled packets for csum engine",
3767 (void *)&cmd_tso_set_tso,
3768 (void *)&cmd_tso_show_mode,
3769 (void *)&cmd_tso_set_portid,
3774 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3775 struct cmd_tunnel_tso_set_result {
3776 cmdline_fixed_string_t tso;
3777 cmdline_fixed_string_t mode;
3783 check_tunnel_tso_nic_support(uint8_t port_id)
3785 struct rte_eth_dev_info dev_info;
3787 rte_eth_dev_info_get(port_id, &dev_info);
3788 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3789 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3790 "supported by port %d\n", port_id);
3791 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3792 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3793 "supported by port %d\n", port_id);
3794 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3795 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3796 "supported by port %d\n", port_id);
3797 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3798 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3799 "supported by port %d\n", port_id);
3803 cmd_tunnel_tso_set_parsed(void *parsed_result,
3804 __attribute__((unused)) struct cmdline *cl,
3805 __attribute__((unused)) void *data)
3807 struct cmd_tunnel_tso_set_result *res = parsed_result;
3809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3812 if (!strcmp(res->mode, "set"))
3813 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3815 if (ports[res->port_id].tunnel_tso_segsz == 0)
3816 printf("TSO for tunneled packets is disabled\n");
3818 printf("TSO segment size for tunneled packets is %d\n",
3819 ports[res->port_id].tunnel_tso_segsz);
3821 /* Below conditions are needed to make it work:
3822 * (1) tunnel TSO is supported by the NIC;
3823 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3825 * (3) for tunneled pkts with outer L3 of IPv4,
3826 * "csum set outer-ip" must be set to hw, because after tso,
3827 * total_len of outer IP header is changed, and the checksum
3828 * of outer IP header calculated by sw should be wrong; that
3829 * is not necessary for IPv6 tunneled pkts because there's no
3830 * checksum in IP header anymore.
3832 check_tunnel_tso_nic_support(res->port_id);
3834 if (!(ports[res->port_id].tx_ol_flags &
3835 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3836 printf("Warning: csum parse_tunnel must be set "
3837 "so that tunneled packets are recognized\n");
3838 if (!(ports[res->port_id].tx_ol_flags &
3839 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3840 printf("Warning: csum set outer-ip must be set to hw "
3841 "if outer L3 is IPv4; not necessary for IPv6\n");
3845 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3846 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3848 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3849 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3851 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3852 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3854 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3855 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3858 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3859 .f = cmd_tunnel_tso_set_parsed,
3861 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3862 "Set TSO segment size of tunneled packets for csum engine "
3865 (void *)&cmd_tunnel_tso_set_tso,
3866 (void *)&cmd_tunnel_tso_set_mode,
3867 (void *)&cmd_tunnel_tso_set_tso_segsz,
3868 (void *)&cmd_tunnel_tso_set_portid,
3873 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3874 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3878 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3879 .f = cmd_tunnel_tso_set_parsed,
3881 .help_str = "tunnel_tso show <port_id> "
3882 "Show TSO segment size of tunneled packets for csum engine",
3884 (void *)&cmd_tunnel_tso_set_tso,
3885 (void *)&cmd_tunnel_tso_show_mode,
3886 (void *)&cmd_tunnel_tso_set_portid,
3891 /* *** SET GRO FOR A PORT *** */
3892 struct cmd_gro_enable_result {
3893 cmdline_fixed_string_t cmd_set;
3894 cmdline_fixed_string_t cmd_port;
3895 cmdline_fixed_string_t cmd_keyword;
3896 cmdline_fixed_string_t cmd_onoff;
3901 cmd_gro_enable_parsed(void *parsed_result,
3902 __attribute__((unused)) struct cmdline *cl,
3903 __attribute__((unused)) void *data)
3905 struct cmd_gro_enable_result *res;
3907 res = parsed_result;
3908 if (!strcmp(res->cmd_keyword, "gro"))
3909 setup_gro(res->cmd_onoff, res->cmd_pid);
3912 cmdline_parse_token_string_t cmd_gro_enable_set =
3913 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3915 cmdline_parse_token_string_t cmd_gro_enable_port =
3916 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3917 cmd_keyword, "port");
3918 cmdline_parse_token_num_t cmd_gro_enable_pid =
3919 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
3921 cmdline_parse_token_string_t cmd_gro_enable_keyword =
3922 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3923 cmd_keyword, "gro");
3924 cmdline_parse_token_string_t cmd_gro_enable_onoff =
3925 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3926 cmd_onoff, "on#off");
3928 cmdline_parse_inst_t cmd_gro_enable = {
3929 .f = cmd_gro_enable_parsed,
3931 .help_str = "set port <port_id> gro on|off",
3933 (void *)&cmd_gro_enable_set,
3934 (void *)&cmd_gro_enable_port,
3935 (void *)&cmd_gro_enable_pid,
3936 (void *)&cmd_gro_enable_keyword,
3937 (void *)&cmd_gro_enable_onoff,
3942 /* *** DISPLAY GRO CONFIGURATION *** */
3943 struct cmd_gro_show_result {
3944 cmdline_fixed_string_t cmd_show;
3945 cmdline_fixed_string_t cmd_port;
3946 cmdline_fixed_string_t cmd_keyword;
3951 cmd_gro_show_parsed(void *parsed_result,
3952 __attribute__((unused)) struct cmdline *cl,
3953 __attribute__((unused)) void *data)
3955 struct cmd_gro_show_result *res;
3957 res = parsed_result;
3958 if (!strcmp(res->cmd_keyword, "gro"))
3959 show_gro(res->cmd_pid);
3962 cmdline_parse_token_string_t cmd_gro_show_show =
3963 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3965 cmdline_parse_token_string_t cmd_gro_show_port =
3966 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3968 cmdline_parse_token_num_t cmd_gro_show_pid =
3969 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
3971 cmdline_parse_token_string_t cmd_gro_show_keyword =
3972 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3973 cmd_keyword, "gro");
3975 cmdline_parse_inst_t cmd_gro_show = {
3976 .f = cmd_gro_show_parsed,
3978 .help_str = "show port <port_id> gro",
3980 (void *)&cmd_gro_show_show,
3981 (void *)&cmd_gro_show_port,
3982 (void *)&cmd_gro_show_pid,
3983 (void *)&cmd_gro_show_keyword,
3988 /* *** SET FLUSH CYCLES FOR GRO *** */
3989 struct cmd_gro_flush_result {
3990 cmdline_fixed_string_t cmd_set;
3991 cmdline_fixed_string_t cmd_keyword;
3992 cmdline_fixed_string_t cmd_flush;
3997 cmd_gro_flush_parsed(void *parsed_result,
3998 __attribute__((unused)) struct cmdline *cl,
3999 __attribute__((unused)) void *data)
4001 struct cmd_gro_flush_result *res;
4003 res = parsed_result;
4004 if ((!strcmp(res->cmd_keyword, "gro")) &&
4005 (!strcmp(res->cmd_flush, "flush")))
4006 setup_gro_flush_cycles(res->cmd_cycles);
4009 cmdline_parse_token_string_t cmd_gro_flush_set =
4010 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4012 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4013 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4014 cmd_keyword, "gro");
4015 cmdline_parse_token_string_t cmd_gro_flush_flush =
4016 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4017 cmd_flush, "flush");
4018 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4019 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4022 cmdline_parse_inst_t cmd_gro_flush = {
4023 .f = cmd_gro_flush_parsed,
4025 .help_str = "set gro flush <cycles>",
4027 (void *)&cmd_gro_flush_set,
4028 (void *)&cmd_gro_flush_keyword,
4029 (void *)&cmd_gro_flush_flush,
4030 (void *)&cmd_gro_flush_cycles,
4035 /* *** ENABLE/DISABLE GSO *** */
4036 struct cmd_gso_enable_result {
4037 cmdline_fixed_string_t cmd_set;
4038 cmdline_fixed_string_t cmd_port;
4039 cmdline_fixed_string_t cmd_keyword;
4040 cmdline_fixed_string_t cmd_mode;
4045 cmd_gso_enable_parsed(void *parsed_result,
4046 __attribute__((unused)) struct cmdline *cl,
4047 __attribute__((unused)) void *data)
4049 struct cmd_gso_enable_result *res;
4051 res = parsed_result;
4052 if (!strcmp(res->cmd_keyword, "gso"))
4053 setup_gso(res->cmd_mode, res->cmd_pid);
4056 cmdline_parse_token_string_t cmd_gso_enable_set =
4057 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4059 cmdline_parse_token_string_t cmd_gso_enable_port =
4060 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4062 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4063 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4064 cmd_keyword, "gso");
4065 cmdline_parse_token_string_t cmd_gso_enable_mode =
4066 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4067 cmd_mode, "on#off");
4068 cmdline_parse_token_num_t cmd_gso_enable_pid =
4069 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4072 cmdline_parse_inst_t cmd_gso_enable = {
4073 .f = cmd_gso_enable_parsed,
4075 .help_str = "set port <port_id> gso on|off",
4077 (void *)&cmd_gso_enable_set,
4078 (void *)&cmd_gso_enable_port,
4079 (void *)&cmd_gso_enable_pid,
4080 (void *)&cmd_gso_enable_keyword,
4081 (void *)&cmd_gso_enable_mode,
4086 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4087 struct cmd_gso_size_result {
4088 cmdline_fixed_string_t cmd_set;
4089 cmdline_fixed_string_t cmd_keyword;
4090 cmdline_fixed_string_t cmd_segsz;
4095 cmd_gso_size_parsed(void *parsed_result,
4096 __attribute__((unused)) struct cmdline *cl,
4097 __attribute__((unused)) void *data)
4099 struct cmd_gso_size_result *res = parsed_result;
4101 if (test_done == 0) {
4102 printf("Before setting GSO segsz, please first"
4103 " stop fowarding\n");
4107 if (!strcmp(res->cmd_keyword, "gso") &&
4108 !strcmp(res->cmd_segsz, "segsz")) {
4109 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4110 printf("gso_size should be larger than %zu."
4111 " Please input a legal value\n",
4112 RTE_GSO_SEG_SIZE_MIN);
4114 gso_max_segment_size = res->cmd_size;
4118 cmdline_parse_token_string_t cmd_gso_size_set =
4119 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4121 cmdline_parse_token_string_t cmd_gso_size_keyword =
4122 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4123 cmd_keyword, "gso");
4124 cmdline_parse_token_string_t cmd_gso_size_segsz =
4125 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4126 cmd_segsz, "segsz");
4127 cmdline_parse_token_num_t cmd_gso_size_size =
4128 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4131 cmdline_parse_inst_t cmd_gso_size = {
4132 .f = cmd_gso_size_parsed,
4134 .help_str = "set gso segsz <length>",
4136 (void *)&cmd_gso_size_set,
4137 (void *)&cmd_gso_size_keyword,
4138 (void *)&cmd_gso_size_segsz,
4139 (void *)&cmd_gso_size_size,
4144 /* *** SHOW GSO CONFIGURATION *** */
4145 struct cmd_gso_show_result {
4146 cmdline_fixed_string_t cmd_show;
4147 cmdline_fixed_string_t cmd_port;
4148 cmdline_fixed_string_t cmd_keyword;
4153 cmd_gso_show_parsed(void *parsed_result,
4154 __attribute__((unused)) struct cmdline *cl,
4155 __attribute__((unused)) void *data)
4157 struct cmd_gso_show_result *res = parsed_result;
4159 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4160 printf("invalid port id %u\n", res->cmd_pid);
4163 if (!strcmp(res->cmd_keyword, "gso")) {
4164 if (gso_ports[res->cmd_pid].enable) {
4165 printf("Max GSO'd packet size: %uB\n"
4166 "Supported GSO types: TCP/IPv4, "
4167 "VxLAN with inner TCP/IPv4 packet, "
4168 "GRE with inner TCP/IPv4 packet\n",
4169 gso_max_segment_size);
4171 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4175 cmdline_parse_token_string_t cmd_gso_show_show =
4176 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4178 cmdline_parse_token_string_t cmd_gso_show_port =
4179 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4181 cmdline_parse_token_string_t cmd_gso_show_keyword =
4182 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4183 cmd_keyword, "gso");
4184 cmdline_parse_token_num_t cmd_gso_show_pid =
4185 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4188 cmdline_parse_inst_t cmd_gso_show = {
4189 .f = cmd_gso_show_parsed,
4191 .help_str = "show port <port_id> gso",
4193 (void *)&cmd_gso_show_show,
4194 (void *)&cmd_gso_show_port,
4195 (void *)&cmd_gso_show_pid,
4196 (void *)&cmd_gso_show_keyword,
4201 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4202 struct cmd_set_flush_rx {
4203 cmdline_fixed_string_t set;
4204 cmdline_fixed_string_t flush_rx;
4205 cmdline_fixed_string_t mode;
4209 cmd_set_flush_rx_parsed(void *parsed_result,
4210 __attribute__((unused)) struct cmdline *cl,
4211 __attribute__((unused)) void *data)
4213 struct cmd_set_flush_rx *res = parsed_result;
4214 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4217 cmdline_parse_token_string_t cmd_setflushrx_set =
4218 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4220 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4221 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4222 flush_rx, "flush_rx");
4223 cmdline_parse_token_string_t cmd_setflushrx_mode =
4224 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4228 cmdline_parse_inst_t cmd_set_flush_rx = {
4229 .f = cmd_set_flush_rx_parsed,
4230 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4233 (void *)&cmd_setflushrx_set,
4234 (void *)&cmd_setflushrx_flush_rx,
4235 (void *)&cmd_setflushrx_mode,
4240 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4241 struct cmd_set_link_check {
4242 cmdline_fixed_string_t set;
4243 cmdline_fixed_string_t link_check;
4244 cmdline_fixed_string_t mode;
4248 cmd_set_link_check_parsed(void *parsed_result,
4249 __attribute__((unused)) struct cmdline *cl,
4250 __attribute__((unused)) void *data)
4252 struct cmd_set_link_check *res = parsed_result;
4253 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4256 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4257 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4259 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4260 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4261 link_check, "link_check");
4262 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4263 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4267 cmdline_parse_inst_t cmd_set_link_check = {
4268 .f = cmd_set_link_check_parsed,
4269 .help_str = "set link_check on|off: Enable/Disable link status check "
4270 "when starting/stopping a port",
4273 (void *)&cmd_setlinkcheck_set,
4274 (void *)&cmd_setlinkcheck_link_check,
4275 (void *)&cmd_setlinkcheck_mode,
4280 /* *** SET NIC BYPASS MODE *** */
4281 struct cmd_set_bypass_mode_result {
4282 cmdline_fixed_string_t set;
4283 cmdline_fixed_string_t bypass;
4284 cmdline_fixed_string_t mode;
4285 cmdline_fixed_string_t value;
4290 cmd_set_bypass_mode_parsed(void *parsed_result,
4291 __attribute__((unused)) struct cmdline *cl,
4292 __attribute__((unused)) void *data)
4294 struct cmd_set_bypass_mode_result *res = parsed_result;
4295 portid_t port_id = res->port_id;
4296 int32_t rc = -EINVAL;
4298 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4299 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4301 if (!strcmp(res->value, "bypass"))
4302 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4303 else if (!strcmp(res->value, "isolate"))
4304 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4306 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4308 /* Set the bypass mode for the relevant port. */
4309 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4312 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4315 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4316 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4318 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4319 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4321 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4322 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4324 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4325 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4326 value, "normal#bypass#isolate");
4327 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4328 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4331 cmdline_parse_inst_t cmd_set_bypass_mode = {
4332 .f = cmd_set_bypass_mode_parsed,
4333 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4334 "Set the NIC bypass mode for port_id",
4337 (void *)&cmd_setbypass_mode_set,
4338 (void *)&cmd_setbypass_mode_bypass,
4339 (void *)&cmd_setbypass_mode_mode,
4340 (void *)&cmd_setbypass_mode_value,
4341 (void *)&cmd_setbypass_mode_port,
4346 /* *** SET NIC BYPASS EVENT *** */
4347 struct cmd_set_bypass_event_result {
4348 cmdline_fixed_string_t set;
4349 cmdline_fixed_string_t bypass;
4350 cmdline_fixed_string_t event;
4351 cmdline_fixed_string_t event_value;
4352 cmdline_fixed_string_t mode;
4353 cmdline_fixed_string_t mode_value;
4358 cmd_set_bypass_event_parsed(void *parsed_result,
4359 __attribute__((unused)) struct cmdline *cl,
4360 __attribute__((unused)) void *data)
4362 int32_t rc = -EINVAL;
4363 struct cmd_set_bypass_event_result *res = parsed_result;
4364 portid_t port_id = res->port_id;
4366 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4367 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4368 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4370 if (!strcmp(res->event_value, "timeout"))
4371 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4372 else if (!strcmp(res->event_value, "os_on"))
4373 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4374 else if (!strcmp(res->event_value, "os_off"))
4375 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4376 else if (!strcmp(res->event_value, "power_on"))
4377 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4378 else if (!strcmp(res->event_value, "power_off"))
4379 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4381 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4383 if (!strcmp(res->mode_value, "bypass"))
4384 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4385 else if (!strcmp(res->mode_value, "isolate"))
4386 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4388 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4390 /* Set the watchdog timeout. */
4391 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4394 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4395 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4399 printf("Failed to set timeout value %u "
4400 "for port %d, errto code: %d.\n",
4401 bypass_timeout, port_id, rc);
4405 /* Set the bypass event to transition to bypass mode. */
4406 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4411 printf("\t Failed to set bypass event for port = %d.\n",
4415 cmdline_parse_token_string_t cmd_setbypass_event_set =
4416 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4418 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4419 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4421 cmdline_parse_token_string_t cmd_setbypass_event_event =
4422 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4424 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4425 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4426 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4427 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4428 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4430 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4431 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4432 mode_value, "normal#bypass#isolate");
4433 cmdline_parse_token_num_t cmd_setbypass_event_port =
4434 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4437 cmdline_parse_inst_t cmd_set_bypass_event = {
4438 .f = cmd_set_bypass_event_parsed,
4439 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4440 "power_off mode normal|bypass|isolate <port_id>: "
4441 "Set the NIC bypass event mode for port_id",
4444 (void *)&cmd_setbypass_event_set,
4445 (void *)&cmd_setbypass_event_bypass,
4446 (void *)&cmd_setbypass_event_event,
4447 (void *)&cmd_setbypass_event_event_value,
4448 (void *)&cmd_setbypass_event_mode,
4449 (void *)&cmd_setbypass_event_mode_value,
4450 (void *)&cmd_setbypass_event_port,
4456 /* *** SET NIC BYPASS TIMEOUT *** */
4457 struct cmd_set_bypass_timeout_result {
4458 cmdline_fixed_string_t set;
4459 cmdline_fixed_string_t bypass;
4460 cmdline_fixed_string_t timeout;
4461 cmdline_fixed_string_t value;
4465 cmd_set_bypass_timeout_parsed(void *parsed_result,
4466 __attribute__((unused)) struct cmdline *cl,
4467 __attribute__((unused)) void *data)
4469 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4471 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4472 if (!strcmp(res->value, "1.5"))
4473 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4474 else if (!strcmp(res->value, "2"))
4475 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4476 else if (!strcmp(res->value, "3"))
4477 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4478 else if (!strcmp(res->value, "4"))
4479 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4480 else if (!strcmp(res->value, "8"))
4481 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4482 else if (!strcmp(res->value, "16"))
4483 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4484 else if (!strcmp(res->value, "32"))
4485 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4487 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4491 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4492 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4494 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4495 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4497 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4498 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4499 timeout, "timeout");
4500 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4501 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4502 value, "0#1.5#2#3#4#8#16#32");
4504 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4505 .f = cmd_set_bypass_timeout_parsed,
4506 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4507 "Set the NIC bypass watchdog timeout in seconds",
4510 (void *)&cmd_setbypass_timeout_set,
4511 (void *)&cmd_setbypass_timeout_bypass,
4512 (void *)&cmd_setbypass_timeout_timeout,
4513 (void *)&cmd_setbypass_timeout_value,
4518 /* *** SHOW NIC BYPASS MODE *** */
4519 struct cmd_show_bypass_config_result {
4520 cmdline_fixed_string_t show;
4521 cmdline_fixed_string_t bypass;
4522 cmdline_fixed_string_t config;
4527 cmd_show_bypass_config_parsed(void *parsed_result,
4528 __attribute__((unused)) struct cmdline *cl,
4529 __attribute__((unused)) void *data)
4531 struct cmd_show_bypass_config_result *res = parsed_result;
4532 portid_t port_id = res->port_id;
4534 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4535 uint32_t event_mode;
4536 uint32_t bypass_mode;
4537 uint32_t timeout = bypass_timeout;
4540 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4541 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4542 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4543 {"UNKNOWN", "normal", "bypass", "isolate"};
4544 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4551 int num_events = (sizeof events) / (sizeof events[0]);
4553 /* Display the bypass mode.*/
4554 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4555 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4559 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4560 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4562 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4565 /* Display the bypass timeout.*/
4566 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4567 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4569 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4571 /* Display the bypass events and associated modes. */
4572 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4574 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4575 printf("\tFailed to get bypass mode for event = %s\n",
4578 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4579 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4581 printf("\tbypass event: %-16s = %s\n", events[i],
4587 printf("\tFailed to get bypass configuration for port = %d\n",
4591 cmdline_parse_token_string_t cmd_showbypass_config_show =
4592 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4594 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4595 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4597 cmdline_parse_token_string_t cmd_showbypass_config_config =
4598 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4600 cmdline_parse_token_num_t cmd_showbypass_config_port =
4601 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4604 cmdline_parse_inst_t cmd_show_bypass_config = {
4605 .f = cmd_show_bypass_config_parsed,
4606 .help_str = "show bypass config <port_id>: "
4607 "Show the NIC bypass config for port_id",
4610 (void *)&cmd_showbypass_config_show,
4611 (void *)&cmd_showbypass_config_bypass,
4612 (void *)&cmd_showbypass_config_config,
4613 (void *)&cmd_showbypass_config_port,
4618 #ifdef RTE_LIBRTE_PMD_BOND
4619 /* *** SET BONDING MODE *** */
4620 struct cmd_set_bonding_mode_result {
4621 cmdline_fixed_string_t set;
4622 cmdline_fixed_string_t bonding;
4623 cmdline_fixed_string_t mode;
4628 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4629 __attribute__((unused)) struct cmdline *cl,
4630 __attribute__((unused)) void *data)
4632 struct cmd_set_bonding_mode_result *res = parsed_result;
4633 portid_t port_id = res->port_id;
4635 /* Set the bonding mode for the relevant port. */
4636 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4637 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4640 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4641 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4643 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4644 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4645 bonding, "bonding");
4646 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4647 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4649 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4650 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4652 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4653 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4656 cmdline_parse_inst_t cmd_set_bonding_mode = {
4657 .f = cmd_set_bonding_mode_parsed,
4658 .help_str = "set bonding mode <mode_value> <port_id>: "
4659 "Set the bonding mode for port_id",
4662 (void *) &cmd_setbonding_mode_set,
4663 (void *) &cmd_setbonding_mode_bonding,
4664 (void *) &cmd_setbonding_mode_mode,
4665 (void *) &cmd_setbonding_mode_value,
4666 (void *) &cmd_setbonding_mode_port,
4671 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4672 struct cmd_set_bonding_lacp_dedicated_queues_result {
4673 cmdline_fixed_string_t set;
4674 cmdline_fixed_string_t bonding;
4675 cmdline_fixed_string_t lacp;
4676 cmdline_fixed_string_t dedicated_queues;
4678 cmdline_fixed_string_t mode;
4681 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4682 __attribute__((unused)) struct cmdline *cl,
4683 __attribute__((unused)) void *data)
4685 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4686 portid_t port_id = res->port_id;
4687 struct rte_port *port;
4689 port = &ports[port_id];
4691 /** Check if the port is not started **/
4692 if (port->port_status != RTE_PORT_STOPPED) {
4693 printf("Please stop port %d first\n", port_id);
4697 if (!strcmp(res->mode, "enable")) {
4698 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4699 printf("Dedicate queues for LACP control packets"
4702 printf("Enabling dedicate queues for LACP control "
4703 "packets on port %d failed\n", port_id);
4704 } else if (!strcmp(res->mode, "disable")) {
4705 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4706 printf("Dedicated queues for LACP control packets "
4709 printf("Disabling dedicated queues for LACP control "
4710 "traffic on port %d failed\n", port_id);
4714 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4715 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4717 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4718 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4719 bonding, "bonding");
4720 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4721 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4723 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4724 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4725 dedicated_queues, "dedicated_queues");
4726 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4727 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4729 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4730 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4731 mode, "enable#disable");
4733 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4734 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4735 .help_str = "set bonding lacp dedicated_queues <port_id> "
4737 "Enable/disable dedicated queues for LACP control traffic for port_id",
4740 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4741 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4742 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4743 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4744 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4745 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4750 /* *** SET BALANCE XMIT POLICY *** */
4751 struct cmd_set_bonding_balance_xmit_policy_result {
4752 cmdline_fixed_string_t set;
4753 cmdline_fixed_string_t bonding;
4754 cmdline_fixed_string_t balance_xmit_policy;
4756 cmdline_fixed_string_t policy;
4759 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4760 __attribute__((unused)) struct cmdline *cl,
4761 __attribute__((unused)) void *data)
4763 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4764 portid_t port_id = res->port_id;
4767 if (!strcmp(res->policy, "l2")) {
4768 policy = BALANCE_XMIT_POLICY_LAYER2;
4769 } else if (!strcmp(res->policy, "l23")) {
4770 policy = BALANCE_XMIT_POLICY_LAYER23;
4771 } else if (!strcmp(res->policy, "l34")) {
4772 policy = BALANCE_XMIT_POLICY_LAYER34;
4774 printf("\t Invalid xmit policy selection");
4778 /* Set the bonding mode for the relevant port. */
4779 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4780 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4785 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4786 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4788 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4789 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4790 bonding, "bonding");
4791 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4792 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4793 balance_xmit_policy, "balance_xmit_policy");
4794 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4795 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4797 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4798 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4799 policy, "l2#l23#l34");
4801 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4802 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4803 .help_str = "set bonding balance_xmit_policy <port_id> "
4805 "Set the bonding balance_xmit_policy for port_id",
4808 (void *)&cmd_setbonding_balance_xmit_policy_set,
4809 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4810 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4811 (void *)&cmd_setbonding_balance_xmit_policy_port,
4812 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4817 /* *** SHOW NIC BONDING CONFIGURATION *** */
4818 struct cmd_show_bonding_config_result {
4819 cmdline_fixed_string_t show;
4820 cmdline_fixed_string_t bonding;
4821 cmdline_fixed_string_t config;
4825 static void cmd_show_bonding_config_parsed(void *parsed_result,
4826 __attribute__((unused)) struct cmdline *cl,
4827 __attribute__((unused)) void *data)
4829 struct cmd_show_bonding_config_result *res = parsed_result;
4830 int bonding_mode, agg_mode;
4831 portid_t slaves[RTE_MAX_ETHPORTS];
4832 int num_slaves, num_active_slaves;
4835 portid_t port_id = res->port_id;
4837 /* Display the bonding mode.*/
4838 bonding_mode = rte_eth_bond_mode_get(port_id);
4839 if (bonding_mode < 0) {
4840 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4843 printf("\tBonding mode: %d\n", bonding_mode);
4845 if (bonding_mode == BONDING_MODE_BALANCE) {
4846 int balance_xmit_policy;
4848 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4849 if (balance_xmit_policy < 0) {
4850 printf("\tFailed to get balance xmit policy for port = %d\n",
4854 printf("\tBalance Xmit Policy: ");
4856 switch (balance_xmit_policy) {
4857 case BALANCE_XMIT_POLICY_LAYER2:
4858 printf("BALANCE_XMIT_POLICY_LAYER2");
4860 case BALANCE_XMIT_POLICY_LAYER23:
4861 printf("BALANCE_XMIT_POLICY_LAYER23");
4863 case BALANCE_XMIT_POLICY_LAYER34:
4864 printf("BALANCE_XMIT_POLICY_LAYER34");
4871 if (bonding_mode == BONDING_MODE_8023AD) {
4872 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4873 printf("\tIEEE802.3AD Aggregator Mode: ");
4876 printf("bandwidth");
4888 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4890 if (num_slaves < 0) {
4891 printf("\tFailed to get slave list for port = %d\n", port_id);
4894 if (num_slaves > 0) {
4895 printf("\tSlaves (%d): [", num_slaves);
4896 for (i = 0; i < num_slaves - 1; i++)
4897 printf("%d ", slaves[i]);
4899 printf("%d]\n", slaves[num_slaves - 1]);
4901 printf("\tSlaves: []\n");
4905 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4908 if (num_active_slaves < 0) {
4909 printf("\tFailed to get active slave list for port = %d\n", port_id);
4912 if (num_active_slaves > 0) {
4913 printf("\tActive Slaves (%d): [", num_active_slaves);
4914 for (i = 0; i < num_active_slaves - 1; i++)
4915 printf("%d ", slaves[i]);
4917 printf("%d]\n", slaves[num_active_slaves - 1]);
4920 printf("\tActive Slaves: []\n");
4924 primary_id = rte_eth_bond_primary_get(port_id);
4925 if (primary_id < 0) {
4926 printf("\tFailed to get primary slave for port = %d\n", port_id);
4929 printf("\tPrimary: [%d]\n", primary_id);
4933 cmdline_parse_token_string_t cmd_showbonding_config_show =
4934 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4936 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4937 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4938 bonding, "bonding");
4939 cmdline_parse_token_string_t cmd_showbonding_config_config =
4940 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4942 cmdline_parse_token_num_t cmd_showbonding_config_port =
4943 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4946 cmdline_parse_inst_t cmd_show_bonding_config = {
4947 .f = cmd_show_bonding_config_parsed,
4948 .help_str = "show bonding config <port_id>: "
4949 "Show the bonding config for port_id",
4952 (void *)&cmd_showbonding_config_show,
4953 (void *)&cmd_showbonding_config_bonding,
4954 (void *)&cmd_showbonding_config_config,
4955 (void *)&cmd_showbonding_config_port,
4960 /* *** SET BONDING PRIMARY *** */
4961 struct cmd_set_bonding_primary_result {
4962 cmdline_fixed_string_t set;
4963 cmdline_fixed_string_t bonding;
4964 cmdline_fixed_string_t primary;
4969 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4970 __attribute__((unused)) struct cmdline *cl,
4971 __attribute__((unused)) void *data)
4973 struct cmd_set_bonding_primary_result *res = parsed_result;
4974 portid_t master_port_id = res->port_id;
4975 portid_t slave_port_id = res->slave_id;
4977 /* Set the primary slave for a bonded device. */
4978 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4979 printf("\t Failed to set primary slave for port = %d.\n",
4986 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4987 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4989 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4990 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4991 bonding, "bonding");
4992 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4993 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4994 primary, "primary");
4995 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4996 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4998 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4999 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5002 cmdline_parse_inst_t cmd_set_bonding_primary = {
5003 .f = cmd_set_bonding_primary_parsed,
5004 .help_str = "set bonding primary <slave_id> <port_id>: "
5005 "Set the primary slave for port_id",
5008 (void *)&cmd_setbonding_primary_set,
5009 (void *)&cmd_setbonding_primary_bonding,
5010 (void *)&cmd_setbonding_primary_primary,
5011 (void *)&cmd_setbonding_primary_slave,
5012 (void *)&cmd_setbonding_primary_port,
5017 /* *** ADD SLAVE *** */
5018 struct cmd_add_bonding_slave_result {
5019 cmdline_fixed_string_t add;
5020 cmdline_fixed_string_t bonding;
5021 cmdline_fixed_string_t slave;
5026 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5027 __attribute__((unused)) struct cmdline *cl,
5028 __attribute__((unused)) void *data)
5030 struct cmd_add_bonding_slave_result *res = parsed_result;
5031 portid_t master_port_id = res->port_id;
5032 portid_t slave_port_id = res->slave_id;
5034 /* add the slave for a bonded device. */
5035 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5036 printf("\t Failed to add slave %d to master port = %d.\n",
5037 slave_port_id, master_port_id);
5041 set_port_slave_flag(slave_port_id);
5044 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5045 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5047 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5048 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5049 bonding, "bonding");
5050 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5051 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5053 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5054 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5056 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5057 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5060 cmdline_parse_inst_t cmd_add_bonding_slave = {
5061 .f = cmd_add_bonding_slave_parsed,
5062 .help_str = "add bonding slave <slave_id> <port_id>: "
5063 "Add a slave device to a bonded device",
5066 (void *)&cmd_addbonding_slave_add,
5067 (void *)&cmd_addbonding_slave_bonding,
5068 (void *)&cmd_addbonding_slave_slave,
5069 (void *)&cmd_addbonding_slave_slaveid,
5070 (void *)&cmd_addbonding_slave_port,
5075 /* *** REMOVE SLAVE *** */
5076 struct cmd_remove_bonding_slave_result {
5077 cmdline_fixed_string_t remove;
5078 cmdline_fixed_string_t bonding;
5079 cmdline_fixed_string_t slave;
5084 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5085 __attribute__((unused)) struct cmdline *cl,
5086 __attribute__((unused)) void *data)
5088 struct cmd_remove_bonding_slave_result *res = parsed_result;
5089 portid_t master_port_id = res->port_id;
5090 portid_t slave_port_id = res->slave_id;
5092 /* remove the slave from a bonded device. */
5093 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5094 printf("\t Failed to remove slave %d from master port = %d.\n",
5095 slave_port_id, master_port_id);
5099 clear_port_slave_flag(slave_port_id);
5102 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5103 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5105 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5106 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5107 bonding, "bonding");
5108 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5109 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5111 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5112 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5114 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5115 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5118 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5119 .f = cmd_remove_bonding_slave_parsed,
5120 .help_str = "remove bonding slave <slave_id> <port_id>: "
5121 "Remove a slave device from a bonded device",
5124 (void *)&cmd_removebonding_slave_remove,
5125 (void *)&cmd_removebonding_slave_bonding,
5126 (void *)&cmd_removebonding_slave_slave,
5127 (void *)&cmd_removebonding_slave_slaveid,
5128 (void *)&cmd_removebonding_slave_port,
5133 /* *** CREATE BONDED DEVICE *** */
5134 struct cmd_create_bonded_device_result {
5135 cmdline_fixed_string_t create;
5136 cmdline_fixed_string_t bonded;
5137 cmdline_fixed_string_t device;
5142 static int bond_dev_num = 0;
5144 static void cmd_create_bonded_device_parsed(void *parsed_result,
5145 __attribute__((unused)) struct cmdline *cl,
5146 __attribute__((unused)) void *data)
5148 struct cmd_create_bonded_device_result *res = parsed_result;
5149 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5152 if (test_done == 0) {
5153 printf("Please stop forwarding first\n");
5157 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5160 /* Create a new bonded device. */
5161 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5163 printf("\t Failed to create bonded device.\n");
5166 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5169 /* Update number of ports */
5170 nb_ports = rte_eth_dev_count();
5171 reconfig(port_id, res->socket);
5172 rte_eth_promiscuous_enable(port_id);
5177 cmdline_parse_token_string_t cmd_createbonded_device_create =
5178 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5180 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5181 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5183 cmdline_parse_token_string_t cmd_createbonded_device_device =
5184 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5186 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5187 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5189 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5190 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5193 cmdline_parse_inst_t cmd_create_bonded_device = {
5194 .f = cmd_create_bonded_device_parsed,
5195 .help_str = "create bonded device <mode> <socket>: "
5196 "Create a new bonded device with specific bonding mode and socket",
5199 (void *)&cmd_createbonded_device_create,
5200 (void *)&cmd_createbonded_device_bonded,
5201 (void *)&cmd_createbonded_device_device,
5202 (void *)&cmd_createbonded_device_mode,
5203 (void *)&cmd_createbonded_device_socket,
5208 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5209 struct cmd_set_bond_mac_addr_result {
5210 cmdline_fixed_string_t set;
5211 cmdline_fixed_string_t bonding;
5212 cmdline_fixed_string_t mac_addr;
5214 struct ether_addr address;
5217 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5218 __attribute__((unused)) struct cmdline *cl,
5219 __attribute__((unused)) void *data)
5221 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5224 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5227 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5229 /* check the return value and print it if is < 0 */
5231 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5234 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5235 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5236 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5237 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5239 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5240 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5242 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5243 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
5244 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5245 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5247 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5248 .f = cmd_set_bond_mac_addr_parsed,
5250 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5252 (void *)&cmd_set_bond_mac_addr_set,
5253 (void *)&cmd_set_bond_mac_addr_bonding,
5254 (void *)&cmd_set_bond_mac_addr_mac,
5255 (void *)&cmd_set_bond_mac_addr_portnum,
5256 (void *)&cmd_set_bond_mac_addr_addr,
5262 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5263 struct cmd_set_bond_mon_period_result {
5264 cmdline_fixed_string_t set;
5265 cmdline_fixed_string_t bonding;
5266 cmdline_fixed_string_t mon_period;
5271 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5272 __attribute__((unused)) struct cmdline *cl,
5273 __attribute__((unused)) void *data)
5275 struct cmd_set_bond_mon_period_result *res = parsed_result;
5278 if (res->port_num >= nb_ports) {
5279 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5283 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5285 /* check the return value and print it if is < 0 */
5287 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5290 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5291 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5293 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5294 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5295 bonding, "bonding");
5296 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5297 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5298 mon_period, "mon_period");
5299 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5300 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5302 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5303 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5306 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5307 .f = cmd_set_bond_mon_period_parsed,
5309 .help_str = "set bonding mon_period <port_id> <period_ms>",
5311 (void *)&cmd_set_bond_mon_period_set,
5312 (void *)&cmd_set_bond_mon_period_bonding,
5313 (void *)&cmd_set_bond_mon_period_mon_period,
5314 (void *)&cmd_set_bond_mon_period_portnum,
5315 (void *)&cmd_set_bond_mon_period_period_ms,
5322 struct cmd_set_bonding_agg_mode_policy_result {
5323 cmdline_fixed_string_t set;
5324 cmdline_fixed_string_t bonding;
5325 cmdline_fixed_string_t agg_mode;
5327 cmdline_fixed_string_t policy;
5332 cmd_set_bonding_agg_mode(void *parsed_result,
5333 __attribute__((unused)) struct cmdline *cl,
5334 __attribute__((unused)) void *data)
5336 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5337 uint8_t policy = AGG_BANDWIDTH;
5339 if (res->port_num >= nb_ports) {
5340 printf("Port id %d must be less than %d\n",
5341 res->port_num, nb_ports);
5345 if (!strcmp(res->policy, "bandwidth"))
5346 policy = AGG_BANDWIDTH;
5347 else if (!strcmp(res->policy, "stable"))
5348 policy = AGG_STABLE;
5349 else if (!strcmp(res->policy, "count"))
5352 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5356 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5357 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5359 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5360 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5361 bonding, "bonding");
5363 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5364 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5365 agg_mode, "agg_mode");
5367 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5368 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5371 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5372 TOKEN_STRING_INITIALIZER(
5373 struct cmd_set_bonding_balance_xmit_policy_result,
5374 policy, "stable#bandwidth#count");
5376 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5377 .f = cmd_set_bonding_agg_mode,
5379 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5381 (void *)&cmd_set_bonding_agg_mode_set,
5382 (void *)&cmd_set_bonding_agg_mode_bonding,
5383 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5384 (void *)&cmd_set_bonding_agg_mode_portnum,
5385 (void *)&cmd_set_bonding_agg_mode_policy_string,
5391 #endif /* RTE_LIBRTE_PMD_BOND */
5393 /* *** SET FORWARDING MODE *** */
5394 struct cmd_set_fwd_mode_result {
5395 cmdline_fixed_string_t set;
5396 cmdline_fixed_string_t fwd;
5397 cmdline_fixed_string_t mode;
5400 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5401 __attribute__((unused)) struct cmdline *cl,
5402 __attribute__((unused)) void *data)
5404 struct cmd_set_fwd_mode_result *res = parsed_result;
5407 set_pkt_forwarding_mode(res->mode);
5410 cmdline_parse_token_string_t cmd_setfwd_set =
5411 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5412 cmdline_parse_token_string_t cmd_setfwd_fwd =
5413 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5414 cmdline_parse_token_string_t cmd_setfwd_mode =
5415 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5416 "" /* defined at init */);
5418 cmdline_parse_inst_t cmd_set_fwd_mode = {
5419 .f = cmd_set_fwd_mode_parsed,
5421 .help_str = NULL, /* defined at init */
5423 (void *)&cmd_setfwd_set,
5424 (void *)&cmd_setfwd_fwd,
5425 (void *)&cmd_setfwd_mode,
5430 static void cmd_set_fwd_mode_init(void)
5433 static char token[128];
5434 static char help[256];
5435 cmdline_parse_token_string_t *token_struct;
5437 modes = list_pkt_forwarding_modes();
5438 snprintf(help, sizeof(help), "set fwd %s: "
5439 "Set packet forwarding mode", modes);
5440 cmd_set_fwd_mode.help_str = help;
5442 /* string token separator is # */
5443 for (c = token; *modes != '\0'; modes++)
5448 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5449 token_struct->string_data.str = token;
5452 /* *** SET RETRY FORWARDING MODE *** */
5453 struct cmd_set_fwd_retry_mode_result {
5454 cmdline_fixed_string_t set;
5455 cmdline_fixed_string_t fwd;
5456 cmdline_fixed_string_t mode;
5457 cmdline_fixed_string_t retry;
5460 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5461 __attribute__((unused)) struct cmdline *cl,
5462 __attribute__((unused)) void *data)
5464 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5467 set_pkt_forwarding_mode(res->mode);
5470 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5471 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5473 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5474 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5476 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5477 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5479 "" /* defined at init */);
5480 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5481 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5484 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5485 .f = cmd_set_fwd_retry_mode_parsed,
5487 .help_str = NULL, /* defined at init */
5489 (void *)&cmd_setfwd_retry_set,
5490 (void *)&cmd_setfwd_retry_fwd,
5491 (void *)&cmd_setfwd_retry_mode,
5492 (void *)&cmd_setfwd_retry_retry,
5497 static void cmd_set_fwd_retry_mode_init(void)
5500 static char token[128];
5501 static char help[256];
5502 cmdline_parse_token_string_t *token_struct;
5504 modes = list_pkt_forwarding_retry_modes();
5505 snprintf(help, sizeof(help), "set fwd %s retry: "
5506 "Set packet forwarding mode with retry", modes);
5507 cmd_set_fwd_retry_mode.help_str = help;
5509 /* string token separator is # */
5510 for (c = token; *modes != '\0'; modes++)
5515 token_struct = (cmdline_parse_token_string_t *)
5516 cmd_set_fwd_retry_mode.tokens[2];
5517 token_struct->string_data.str = token;
5520 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5521 struct cmd_set_burst_tx_retry_result {
5522 cmdline_fixed_string_t set;
5523 cmdline_fixed_string_t burst;
5524 cmdline_fixed_string_t tx;
5525 cmdline_fixed_string_t delay;
5527 cmdline_fixed_string_t retry;
5531 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5532 __attribute__((unused)) struct cmdline *cl,
5533 __attribute__((unused)) void *data)
5535 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5537 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5538 && !strcmp(res->tx, "tx")) {
5539 if (!strcmp(res->delay, "delay"))
5540 burst_tx_delay_time = res->time;
5541 if (!strcmp(res->retry, "retry"))
5542 burst_tx_retry_num = res->retry_num;
5547 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5549 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5550 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5552 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5553 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5554 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5556 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5557 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5558 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5560 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5561 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5563 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5564 .f = cmd_set_burst_tx_retry_parsed,
5565 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5567 (void *)&cmd_set_burst_tx_retry_set,
5568 (void *)&cmd_set_burst_tx_retry_burst,
5569 (void *)&cmd_set_burst_tx_retry_tx,
5570 (void *)&cmd_set_burst_tx_retry_delay,
5571 (void *)&cmd_set_burst_tx_retry_time,
5572 (void *)&cmd_set_burst_tx_retry_retry,
5573 (void *)&cmd_set_burst_tx_retry_retry_num,
5578 /* *** SET PROMISC MODE *** */
5579 struct cmd_set_promisc_mode_result {
5580 cmdline_fixed_string_t set;
5581 cmdline_fixed_string_t promisc;
5582 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5583 uint8_t port_num; /* valid if "allports" argument == 0 */
5584 cmdline_fixed_string_t mode;
5587 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5588 __attribute__((unused)) struct cmdline *cl,
5591 struct cmd_set_promisc_mode_result *res = parsed_result;
5595 if (!strcmp(res->mode, "on"))
5602 RTE_ETH_FOREACH_DEV(i) {
5604 rte_eth_promiscuous_enable(i);
5606 rte_eth_promiscuous_disable(i);
5611 rte_eth_promiscuous_enable(res->port_num);
5613 rte_eth_promiscuous_disable(res->port_num);
5617 cmdline_parse_token_string_t cmd_setpromisc_set =
5618 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5619 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5622 cmdline_parse_token_string_t cmd_setpromisc_portall =
5623 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5625 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5626 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5628 cmdline_parse_token_string_t cmd_setpromisc_mode =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5632 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5633 .f = cmd_set_promisc_mode_parsed,
5635 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5637 (void *)&cmd_setpromisc_set,
5638 (void *)&cmd_setpromisc_promisc,
5639 (void *)&cmd_setpromisc_portall,
5640 (void *)&cmd_setpromisc_mode,
5645 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5646 .f = cmd_set_promisc_mode_parsed,
5648 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5650 (void *)&cmd_setpromisc_set,
5651 (void *)&cmd_setpromisc_promisc,
5652 (void *)&cmd_setpromisc_portnum,
5653 (void *)&cmd_setpromisc_mode,
5658 /* *** SET ALLMULTI MODE *** */
5659 struct cmd_set_allmulti_mode_result {
5660 cmdline_fixed_string_t set;
5661 cmdline_fixed_string_t allmulti;
5662 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5663 uint8_t port_num; /* valid if "allports" argument == 0 */
5664 cmdline_fixed_string_t mode;
5667 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5668 __attribute__((unused)) struct cmdline *cl,
5671 struct cmd_set_allmulti_mode_result *res = parsed_result;
5675 if (!strcmp(res->mode, "on"))
5682 RTE_ETH_FOREACH_DEV(i) {
5684 rte_eth_allmulticast_enable(i);
5686 rte_eth_allmulticast_disable(i);
5691 rte_eth_allmulticast_enable(res->port_num);
5693 rte_eth_allmulticast_disable(res->port_num);
5697 cmdline_parse_token_string_t cmd_setallmulti_set =
5698 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5699 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5700 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5702 cmdline_parse_token_string_t cmd_setallmulti_portall =
5703 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5705 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5706 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5708 cmdline_parse_token_string_t cmd_setallmulti_mode =
5709 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5712 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5713 .f = cmd_set_allmulti_mode_parsed,
5715 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5717 (void *)&cmd_setallmulti_set,
5718 (void *)&cmd_setallmulti_allmulti,
5719 (void *)&cmd_setallmulti_portall,
5720 (void *)&cmd_setallmulti_mode,
5725 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5726 .f = cmd_set_allmulti_mode_parsed,
5728 .help_str = "set allmulti <port_id> on|off: "
5729 "Set allmulti mode on port_id",
5731 (void *)&cmd_setallmulti_set,
5732 (void *)&cmd_setallmulti_allmulti,
5733 (void *)&cmd_setallmulti_portnum,
5734 (void *)&cmd_setallmulti_mode,
5739 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5740 struct cmd_link_flow_ctrl_set_result {
5741 cmdline_fixed_string_t set;
5742 cmdline_fixed_string_t flow_ctrl;
5743 cmdline_fixed_string_t rx;
5744 cmdline_fixed_string_t rx_lfc_mode;
5745 cmdline_fixed_string_t tx;
5746 cmdline_fixed_string_t tx_lfc_mode;
5747 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5748 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5749 cmdline_fixed_string_t autoneg_str;
5750 cmdline_fixed_string_t autoneg;
5751 cmdline_fixed_string_t hw_str;
5752 uint32_t high_water;
5753 cmdline_fixed_string_t lw_str;
5755 cmdline_fixed_string_t pt_str;
5756 uint16_t pause_time;
5757 cmdline_fixed_string_t xon_str;
5762 cmdline_parse_token_string_t cmd_lfc_set_set =
5763 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5765 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5766 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5767 flow_ctrl, "flow_ctrl");
5768 cmdline_parse_token_string_t cmd_lfc_set_rx =
5769 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5771 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5772 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5773 rx_lfc_mode, "on#off");
5774 cmdline_parse_token_string_t cmd_lfc_set_tx =
5775 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5777 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5779 tx_lfc_mode, "on#off");
5780 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5781 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5782 hw_str, "high_water");
5783 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5784 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5785 high_water, UINT32);
5786 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5787 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5788 lw_str, "low_water");
5789 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5790 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5792 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5793 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5794 pt_str, "pause_time");
5795 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5796 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5797 pause_time, UINT16);
5798 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5799 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5800 xon_str, "send_xon");
5801 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5802 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5804 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5805 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5806 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5807 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5808 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5809 mac_ctrl_frame_fwd_mode, "on#off");
5810 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5811 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5812 autoneg_str, "autoneg");
5813 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5814 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5816 cmdline_parse_token_num_t cmd_lfc_set_portid =
5817 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5820 /* forward declaration */
5822 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5825 cmdline_parse_inst_t cmd_link_flow_control_set = {
5826 .f = cmd_link_flow_ctrl_set_parsed,
5828 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5829 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5830 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5832 (void *)&cmd_lfc_set_set,
5833 (void *)&cmd_lfc_set_flow_ctrl,
5834 (void *)&cmd_lfc_set_rx,
5835 (void *)&cmd_lfc_set_rx_mode,
5836 (void *)&cmd_lfc_set_tx,
5837 (void *)&cmd_lfc_set_tx_mode,
5838 (void *)&cmd_lfc_set_high_water,
5839 (void *)&cmd_lfc_set_low_water,
5840 (void *)&cmd_lfc_set_pause_time,
5841 (void *)&cmd_lfc_set_send_xon,
5842 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5843 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5844 (void *)&cmd_lfc_set_autoneg_str,
5845 (void *)&cmd_lfc_set_autoneg,
5846 (void *)&cmd_lfc_set_portid,
5851 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5852 .f = cmd_link_flow_ctrl_set_parsed,
5853 .data = (void *)&cmd_link_flow_control_set_rx,
5854 .help_str = "set flow_ctrl rx on|off <port_id>: "
5855 "Change rx flow control parameter",
5857 (void *)&cmd_lfc_set_set,
5858 (void *)&cmd_lfc_set_flow_ctrl,
5859 (void *)&cmd_lfc_set_rx,
5860 (void *)&cmd_lfc_set_rx_mode,
5861 (void *)&cmd_lfc_set_portid,
5866 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5867 .f = cmd_link_flow_ctrl_set_parsed,
5868 .data = (void *)&cmd_link_flow_control_set_tx,
5869 .help_str = "set flow_ctrl tx on|off <port_id>: "
5870 "Change tx flow control parameter",
5872 (void *)&cmd_lfc_set_set,
5873 (void *)&cmd_lfc_set_flow_ctrl,
5874 (void *)&cmd_lfc_set_tx,
5875 (void *)&cmd_lfc_set_tx_mode,
5876 (void *)&cmd_lfc_set_portid,
5881 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5882 .f = cmd_link_flow_ctrl_set_parsed,
5883 .data = (void *)&cmd_link_flow_control_set_hw,
5884 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5885 "Change high water flow control parameter",
5887 (void *)&cmd_lfc_set_set,
5888 (void *)&cmd_lfc_set_flow_ctrl,
5889 (void *)&cmd_lfc_set_high_water_str,
5890 (void *)&cmd_lfc_set_high_water,
5891 (void *)&cmd_lfc_set_portid,
5896 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5897 .f = cmd_link_flow_ctrl_set_parsed,
5898 .data = (void *)&cmd_link_flow_control_set_lw,
5899 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5900 "Change low water flow control parameter",
5902 (void *)&cmd_lfc_set_set,
5903 (void *)&cmd_lfc_set_flow_ctrl,
5904 (void *)&cmd_lfc_set_low_water_str,
5905 (void *)&cmd_lfc_set_low_water,
5906 (void *)&cmd_lfc_set_portid,
5911 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5912 .f = cmd_link_flow_ctrl_set_parsed,
5913 .data = (void *)&cmd_link_flow_control_set_pt,
5914 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5915 "Change pause time flow control parameter",
5917 (void *)&cmd_lfc_set_set,
5918 (void *)&cmd_lfc_set_flow_ctrl,
5919 (void *)&cmd_lfc_set_pause_time_str,
5920 (void *)&cmd_lfc_set_pause_time,
5921 (void *)&cmd_lfc_set_portid,
5926 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5927 .f = cmd_link_flow_ctrl_set_parsed,
5928 .data = (void *)&cmd_link_flow_control_set_xon,
5929 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5930 "Change send_xon flow control parameter",
5932 (void *)&cmd_lfc_set_set,
5933 (void *)&cmd_lfc_set_flow_ctrl,
5934 (void *)&cmd_lfc_set_send_xon_str,
5935 (void *)&cmd_lfc_set_send_xon,
5936 (void *)&cmd_lfc_set_portid,
5941 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5942 .f = cmd_link_flow_ctrl_set_parsed,
5943 .data = (void *)&cmd_link_flow_control_set_macfwd,
5944 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5945 "Change mac ctrl fwd flow control parameter",
5947 (void *)&cmd_lfc_set_set,
5948 (void *)&cmd_lfc_set_flow_ctrl,
5949 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5950 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5951 (void *)&cmd_lfc_set_portid,
5956 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5957 .f = cmd_link_flow_ctrl_set_parsed,
5958 .data = (void *)&cmd_link_flow_control_set_autoneg,
5959 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5960 "Change autoneg flow control parameter",
5962 (void *)&cmd_lfc_set_set,
5963 (void *)&cmd_lfc_set_flow_ctrl,
5964 (void *)&cmd_lfc_set_autoneg_str,
5965 (void *)&cmd_lfc_set_autoneg,
5966 (void *)&cmd_lfc_set_portid,
5972 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5973 __attribute__((unused)) struct cmdline *cl,
5976 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5977 cmdline_parse_inst_t *cmd = data;
5978 struct rte_eth_fc_conf fc_conf;
5984 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5985 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5986 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5987 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5989 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5990 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5993 /* Partial command line, retrieve current configuration */
5995 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5997 printf("cannot get current flow ctrl parameters, return"
5998 "code = %d\n", ret);
6002 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6003 (fc_conf.mode == RTE_FC_FULL))
6005 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6006 (fc_conf.mode == RTE_FC_FULL))
6010 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6011 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6013 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6014 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6016 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6018 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6019 fc_conf.high_water = res->high_water;
6021 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6022 fc_conf.low_water = res->low_water;
6024 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6025 fc_conf.pause_time = res->pause_time;
6027 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6028 fc_conf.send_xon = res->send_xon;
6030 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6031 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6032 fc_conf.mac_ctrl_frame_fwd = 1;
6034 fc_conf.mac_ctrl_frame_fwd = 0;
6037 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6038 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6040 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6042 printf("bad flow contrl parameter, return code = %d \n", ret);
6045 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6046 struct cmd_priority_flow_ctrl_set_result {
6047 cmdline_fixed_string_t set;
6048 cmdline_fixed_string_t pfc_ctrl;
6049 cmdline_fixed_string_t rx;
6050 cmdline_fixed_string_t rx_pfc_mode;
6051 cmdline_fixed_string_t tx;
6052 cmdline_fixed_string_t tx_pfc_mode;
6053 uint32_t high_water;
6055 uint16_t pause_time;
6061 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6062 __attribute__((unused)) struct cmdline *cl,
6063 __attribute__((unused)) void *data)
6065 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6066 struct rte_eth_pfc_conf pfc_conf;
6067 int rx_fc_enable, tx_fc_enable;
6071 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6072 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6073 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6074 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6076 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6077 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6080 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6081 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6082 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6083 pfc_conf.fc.high_water = res->high_water;
6084 pfc_conf.fc.low_water = res->low_water;
6085 pfc_conf.fc.pause_time = res->pause_time;
6086 pfc_conf.priority = res->priority;
6088 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6090 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6093 cmdline_parse_token_string_t cmd_pfc_set_set =
6094 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6096 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6097 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6098 pfc_ctrl, "pfc_ctrl");
6099 cmdline_parse_token_string_t cmd_pfc_set_rx =
6100 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6102 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6103 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6104 rx_pfc_mode, "on#off");
6105 cmdline_parse_token_string_t cmd_pfc_set_tx =
6106 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6108 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6109 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6110 tx_pfc_mode, "on#off");
6111 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6112 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6113 high_water, UINT32);
6114 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6115 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6117 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6118 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6119 pause_time, UINT16);
6120 cmdline_parse_token_num_t cmd_pfc_set_priority =
6121 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6123 cmdline_parse_token_num_t cmd_pfc_set_portid =
6124 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6127 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6128 .f = cmd_priority_flow_ctrl_set_parsed,
6130 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6131 "<pause_time> <priority> <port_id>: "
6132 "Configure the Ethernet priority flow control",
6134 (void *)&cmd_pfc_set_set,
6135 (void *)&cmd_pfc_set_flow_ctrl,
6136 (void *)&cmd_pfc_set_rx,
6137 (void *)&cmd_pfc_set_rx_mode,
6138 (void *)&cmd_pfc_set_tx,
6139 (void *)&cmd_pfc_set_tx_mode,
6140 (void *)&cmd_pfc_set_high_water,
6141 (void *)&cmd_pfc_set_low_water,
6142 (void *)&cmd_pfc_set_pause_time,
6143 (void *)&cmd_pfc_set_priority,
6144 (void *)&cmd_pfc_set_portid,
6149 /* *** RESET CONFIGURATION *** */
6150 struct cmd_reset_result {
6151 cmdline_fixed_string_t reset;
6152 cmdline_fixed_string_t def;
6155 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6157 __attribute__((unused)) void *data)
6159 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6160 set_def_fwd_config();
6163 cmdline_parse_token_string_t cmd_reset_set =
6164 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6165 cmdline_parse_token_string_t cmd_reset_def =
6166 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6169 cmdline_parse_inst_t cmd_reset = {
6170 .f = cmd_reset_parsed,
6172 .help_str = "set default: Reset default forwarding configuration",
6174 (void *)&cmd_reset_set,
6175 (void *)&cmd_reset_def,
6180 /* *** START FORWARDING *** */
6181 struct cmd_start_result {
6182 cmdline_fixed_string_t start;
6185 cmdline_parse_token_string_t cmd_start_start =
6186 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6188 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6189 __attribute__((unused)) struct cmdline *cl,
6190 __attribute__((unused)) void *data)
6192 start_packet_forwarding(0);
6195 cmdline_parse_inst_t cmd_start = {
6196 .f = cmd_start_parsed,
6198 .help_str = "start: Start packet forwarding",
6200 (void *)&cmd_start_start,
6205 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6206 struct cmd_start_tx_first_result {
6207 cmdline_fixed_string_t start;
6208 cmdline_fixed_string_t tx_first;
6212 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6213 __attribute__((unused)) struct cmdline *cl,
6214 __attribute__((unused)) void *data)
6216 start_packet_forwarding(1);
6219 cmdline_parse_token_string_t cmd_start_tx_first_start =
6220 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6222 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6223 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6224 tx_first, "tx_first");
6226 cmdline_parse_inst_t cmd_start_tx_first = {
6227 .f = cmd_start_tx_first_parsed,
6229 .help_str = "start tx_first: Start packet forwarding, "
6230 "after sending 1 burst of packets",
6232 (void *)&cmd_start_tx_first_start,
6233 (void *)&cmd_start_tx_first_tx_first,
6238 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6239 struct cmd_start_tx_first_n_result {
6240 cmdline_fixed_string_t start;
6241 cmdline_fixed_string_t tx_first;
6246 cmd_start_tx_first_n_parsed(void *parsed_result,
6247 __attribute__((unused)) struct cmdline *cl,
6248 __attribute__((unused)) void *data)
6250 struct cmd_start_tx_first_n_result *res = parsed_result;
6252 start_packet_forwarding(res->tx_num);
6255 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6256 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6258 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6259 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6260 tx_first, "tx_first");
6261 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6262 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6265 cmdline_parse_inst_t cmd_start_tx_first_n = {
6266 .f = cmd_start_tx_first_n_parsed,
6268 .help_str = "start tx_first <num>: "
6269 "packet forwarding, after sending <num> bursts of packets",
6271 (void *)&cmd_start_tx_first_n_start,
6272 (void *)&cmd_start_tx_first_n_tx_first,
6273 (void *)&cmd_start_tx_first_n_tx_num,
6278 /* *** SET LINK UP *** */
6279 struct cmd_set_link_up_result {
6280 cmdline_fixed_string_t set;
6281 cmdline_fixed_string_t link_up;
6282 cmdline_fixed_string_t port;
6286 cmdline_parse_token_string_t cmd_set_link_up_set =
6287 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6288 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6289 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6291 cmdline_parse_token_string_t cmd_set_link_up_port =
6292 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6293 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6294 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
6296 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6297 __attribute__((unused)) struct cmdline *cl,
6298 __attribute__((unused)) void *data)
6300 struct cmd_set_link_up_result *res = parsed_result;
6301 dev_set_link_up(res->port_id);
6304 cmdline_parse_inst_t cmd_set_link_up = {
6305 .f = cmd_set_link_up_parsed,
6307 .help_str = "set link-up port <port id>",
6309 (void *)&cmd_set_link_up_set,
6310 (void *)&cmd_set_link_up_link_up,
6311 (void *)&cmd_set_link_up_port,
6312 (void *)&cmd_set_link_up_port_id,
6317 /* *** SET LINK DOWN *** */
6318 struct cmd_set_link_down_result {
6319 cmdline_fixed_string_t set;
6320 cmdline_fixed_string_t link_down;
6321 cmdline_fixed_string_t port;
6325 cmdline_parse_token_string_t cmd_set_link_down_set =
6326 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6327 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6328 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6330 cmdline_parse_token_string_t cmd_set_link_down_port =
6331 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6332 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6333 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
6335 static void cmd_set_link_down_parsed(
6336 __attribute__((unused)) void *parsed_result,
6337 __attribute__((unused)) struct cmdline *cl,
6338 __attribute__((unused)) void *data)
6340 struct cmd_set_link_down_result *res = parsed_result;
6341 dev_set_link_down(res->port_id);
6344 cmdline_parse_inst_t cmd_set_link_down = {
6345 .f = cmd_set_link_down_parsed,
6347 .help_str = "set link-down port <port id>",
6349 (void *)&cmd_set_link_down_set,
6350 (void *)&cmd_set_link_down_link_down,
6351 (void *)&cmd_set_link_down_port,
6352 (void *)&cmd_set_link_down_port_id,
6357 /* *** SHOW CFG *** */
6358 struct cmd_showcfg_result {
6359 cmdline_fixed_string_t show;
6360 cmdline_fixed_string_t cfg;
6361 cmdline_fixed_string_t what;
6364 static void cmd_showcfg_parsed(void *parsed_result,
6365 __attribute__((unused)) struct cmdline *cl,
6366 __attribute__((unused)) void *data)
6368 struct cmd_showcfg_result *res = parsed_result;
6369 if (!strcmp(res->what, "rxtx"))
6370 rxtx_config_display();
6371 else if (!strcmp(res->what, "cores"))
6372 fwd_lcores_config_display();
6373 else if (!strcmp(res->what, "fwd"))
6374 pkt_fwd_config_display(&cur_fwd_config);
6375 else if (!strcmp(res->what, "txpkts"))
6376 show_tx_pkt_segments();
6379 cmdline_parse_token_string_t cmd_showcfg_show =
6380 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6381 cmdline_parse_token_string_t cmd_showcfg_port =
6382 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6383 cmdline_parse_token_string_t cmd_showcfg_what =
6384 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6385 "rxtx#cores#fwd#txpkts");
6387 cmdline_parse_inst_t cmd_showcfg = {
6388 .f = cmd_showcfg_parsed,
6390 .help_str = "show config rxtx|cores|fwd|txpkts",
6392 (void *)&cmd_showcfg_show,
6393 (void *)&cmd_showcfg_port,
6394 (void *)&cmd_showcfg_what,
6399 /* *** SHOW ALL PORT INFO *** */
6400 struct cmd_showportall_result {
6401 cmdline_fixed_string_t show;
6402 cmdline_fixed_string_t port;
6403 cmdline_fixed_string_t what;
6404 cmdline_fixed_string_t all;
6407 static void cmd_showportall_parsed(void *parsed_result,
6408 __attribute__((unused)) struct cmdline *cl,
6409 __attribute__((unused)) void *data)
6413 struct cmd_showportall_result *res = parsed_result;
6414 if (!strcmp(res->show, "clear")) {
6415 if (!strcmp(res->what, "stats"))
6416 RTE_ETH_FOREACH_DEV(i)
6418 else if (!strcmp(res->what, "xstats"))
6419 RTE_ETH_FOREACH_DEV(i)
6420 nic_xstats_clear(i);
6421 } else if (!strcmp(res->what, "info"))
6422 RTE_ETH_FOREACH_DEV(i)
6423 port_infos_display(i);
6424 else if (!strcmp(res->what, "stats"))
6425 RTE_ETH_FOREACH_DEV(i)
6426 nic_stats_display(i);
6427 else if (!strcmp(res->what, "xstats"))
6428 RTE_ETH_FOREACH_DEV(i)
6429 nic_xstats_display(i);
6430 else if (!strcmp(res->what, "fdir"))
6431 RTE_ETH_FOREACH_DEV(i)
6433 else if (!strcmp(res->what, "stat_qmap"))
6434 RTE_ETH_FOREACH_DEV(i)
6435 nic_stats_mapping_display(i);
6436 else if (!strcmp(res->what, "dcb_tc"))
6437 RTE_ETH_FOREACH_DEV(i)
6438 port_dcb_info_display(i);
6439 else if (!strcmp(res->what, "cap"))
6440 RTE_ETH_FOREACH_DEV(i)
6441 port_offload_cap_display(i);
6444 cmdline_parse_token_string_t cmd_showportall_show =
6445 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6447 cmdline_parse_token_string_t cmd_showportall_port =
6448 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6449 cmdline_parse_token_string_t cmd_showportall_what =
6450 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6451 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6452 cmdline_parse_token_string_t cmd_showportall_all =
6453 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6454 cmdline_parse_inst_t cmd_showportall = {
6455 .f = cmd_showportall_parsed,
6457 .help_str = "show|clear port "
6458 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6460 (void *)&cmd_showportall_show,
6461 (void *)&cmd_showportall_port,
6462 (void *)&cmd_showportall_what,
6463 (void *)&cmd_showportall_all,
6468 /* *** SHOW PORT INFO *** */
6469 struct cmd_showport_result {
6470 cmdline_fixed_string_t show;
6471 cmdline_fixed_string_t port;
6472 cmdline_fixed_string_t what;
6476 static void cmd_showport_parsed(void *parsed_result,
6477 __attribute__((unused)) struct cmdline *cl,
6478 __attribute__((unused)) void *data)
6480 struct cmd_showport_result *res = parsed_result;
6481 if (!strcmp(res->show, "clear")) {
6482 if (!strcmp(res->what, "stats"))
6483 nic_stats_clear(res->portnum);
6484 else if (!strcmp(res->what, "xstats"))
6485 nic_xstats_clear(res->portnum);
6486 } else if (!strcmp(res->what, "info"))
6487 port_infos_display(res->portnum);
6488 else if (!strcmp(res->what, "stats"))
6489 nic_stats_display(res->portnum);
6490 else if (!strcmp(res->what, "xstats"))
6491 nic_xstats_display(res->portnum);
6492 else if (!strcmp(res->what, "fdir"))
6493 fdir_get_infos(res->portnum);
6494 else if (!strcmp(res->what, "stat_qmap"))
6495 nic_stats_mapping_display(res->portnum);
6496 else if (!strcmp(res->what, "dcb_tc"))
6497 port_dcb_info_display(res->portnum);
6498 else if (!strcmp(res->what, "cap"))
6499 port_offload_cap_display(res->portnum);
6502 cmdline_parse_token_string_t cmd_showport_show =
6503 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6505 cmdline_parse_token_string_t cmd_showport_port =
6506 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6507 cmdline_parse_token_string_t cmd_showport_what =
6508 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6509 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6510 cmdline_parse_token_num_t cmd_showport_portnum =
6511 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6513 cmdline_parse_inst_t cmd_showport = {
6514 .f = cmd_showport_parsed,
6516 .help_str = "show|clear port "
6517 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6520 (void *)&cmd_showport_show,
6521 (void *)&cmd_showport_port,
6522 (void *)&cmd_showport_what,
6523 (void *)&cmd_showport_portnum,
6528 /* *** SHOW QUEUE INFO *** */
6529 struct cmd_showqueue_result {
6530 cmdline_fixed_string_t show;
6531 cmdline_fixed_string_t type;
6532 cmdline_fixed_string_t what;
6538 cmd_showqueue_parsed(void *parsed_result,
6539 __attribute__((unused)) struct cmdline *cl,
6540 __attribute__((unused)) void *data)
6542 struct cmd_showqueue_result *res = parsed_result;
6544 if (!strcmp(res->type, "rxq"))
6545 rx_queue_infos_display(res->portnum, res->queuenum);
6546 else if (!strcmp(res->type, "txq"))
6547 tx_queue_infos_display(res->portnum, res->queuenum);
6550 cmdline_parse_token_string_t cmd_showqueue_show =
6551 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6552 cmdline_parse_token_string_t cmd_showqueue_type =
6553 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6554 cmdline_parse_token_string_t cmd_showqueue_what =
6555 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6556 cmdline_parse_token_num_t cmd_showqueue_portnum =
6557 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6558 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6559 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6561 cmdline_parse_inst_t cmd_showqueue = {
6562 .f = cmd_showqueue_parsed,
6564 .help_str = "show rxq|txq info <port_id> <queue_id>",
6566 (void *)&cmd_showqueue_show,
6567 (void *)&cmd_showqueue_type,
6568 (void *)&cmd_showqueue_what,
6569 (void *)&cmd_showqueue_portnum,
6570 (void *)&cmd_showqueue_queuenum,
6575 /* *** READ PORT REGISTER *** */
6576 struct cmd_read_reg_result {
6577 cmdline_fixed_string_t read;
6578 cmdline_fixed_string_t reg;
6584 cmd_read_reg_parsed(void *parsed_result,
6585 __attribute__((unused)) struct cmdline *cl,
6586 __attribute__((unused)) void *data)
6588 struct cmd_read_reg_result *res = parsed_result;
6589 port_reg_display(res->port_id, res->reg_off);
6592 cmdline_parse_token_string_t cmd_read_reg_read =
6593 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6594 cmdline_parse_token_string_t cmd_read_reg_reg =
6595 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6596 cmdline_parse_token_num_t cmd_read_reg_port_id =
6597 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6598 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6599 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6601 cmdline_parse_inst_t cmd_read_reg = {
6602 .f = cmd_read_reg_parsed,
6604 .help_str = "read reg <port_id> <reg_off>",
6606 (void *)&cmd_read_reg_read,
6607 (void *)&cmd_read_reg_reg,
6608 (void *)&cmd_read_reg_port_id,
6609 (void *)&cmd_read_reg_reg_off,
6614 /* *** READ PORT REGISTER BIT FIELD *** */
6615 struct cmd_read_reg_bit_field_result {
6616 cmdline_fixed_string_t read;
6617 cmdline_fixed_string_t regfield;
6625 cmd_read_reg_bit_field_parsed(void *parsed_result,
6626 __attribute__((unused)) struct cmdline *cl,
6627 __attribute__((unused)) void *data)
6629 struct cmd_read_reg_bit_field_result *res = parsed_result;
6630 port_reg_bit_field_display(res->port_id, res->reg_off,
6631 res->bit1_pos, res->bit2_pos);
6634 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6635 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6637 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6638 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6639 regfield, "regfield");
6640 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6641 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6643 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6644 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6646 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6647 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6649 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6650 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6653 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6654 .f = cmd_read_reg_bit_field_parsed,
6656 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6657 "Read register bit field between bit_x and bit_y included",
6659 (void *)&cmd_read_reg_bit_field_read,
6660 (void *)&cmd_read_reg_bit_field_regfield,
6661 (void *)&cmd_read_reg_bit_field_port_id,
6662 (void *)&cmd_read_reg_bit_field_reg_off,
6663 (void *)&cmd_read_reg_bit_field_bit1_pos,
6664 (void *)&cmd_read_reg_bit_field_bit2_pos,
6669 /* *** READ PORT REGISTER BIT *** */
6670 struct cmd_read_reg_bit_result {
6671 cmdline_fixed_string_t read;
6672 cmdline_fixed_string_t regbit;
6679 cmd_read_reg_bit_parsed(void *parsed_result,
6680 __attribute__((unused)) struct cmdline *cl,
6681 __attribute__((unused)) void *data)
6683 struct cmd_read_reg_bit_result *res = parsed_result;
6684 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6687 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6688 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6689 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6690 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6692 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6693 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6694 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6695 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6696 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6697 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6699 cmdline_parse_inst_t cmd_read_reg_bit = {
6700 .f = cmd_read_reg_bit_parsed,
6702 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6704 (void *)&cmd_read_reg_bit_read,
6705 (void *)&cmd_read_reg_bit_regbit,
6706 (void *)&cmd_read_reg_bit_port_id,
6707 (void *)&cmd_read_reg_bit_reg_off,
6708 (void *)&cmd_read_reg_bit_bit_pos,
6713 /* *** WRITE PORT REGISTER *** */
6714 struct cmd_write_reg_result {
6715 cmdline_fixed_string_t write;
6716 cmdline_fixed_string_t reg;
6723 cmd_write_reg_parsed(void *parsed_result,
6724 __attribute__((unused)) struct cmdline *cl,
6725 __attribute__((unused)) void *data)
6727 struct cmd_write_reg_result *res = parsed_result;
6728 port_reg_set(res->port_id, res->reg_off, res->value);
6731 cmdline_parse_token_string_t cmd_write_reg_write =
6732 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6733 cmdline_parse_token_string_t cmd_write_reg_reg =
6734 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6735 cmdline_parse_token_num_t cmd_write_reg_port_id =
6736 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6737 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6738 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6739 cmdline_parse_token_num_t cmd_write_reg_value =
6740 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6742 cmdline_parse_inst_t cmd_write_reg = {
6743 .f = cmd_write_reg_parsed,
6745 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6747 (void *)&cmd_write_reg_write,
6748 (void *)&cmd_write_reg_reg,
6749 (void *)&cmd_write_reg_port_id,
6750 (void *)&cmd_write_reg_reg_off,
6751 (void *)&cmd_write_reg_value,
6756 /* *** WRITE PORT REGISTER BIT FIELD *** */
6757 struct cmd_write_reg_bit_field_result {
6758 cmdline_fixed_string_t write;
6759 cmdline_fixed_string_t regfield;
6768 cmd_write_reg_bit_field_parsed(void *parsed_result,
6769 __attribute__((unused)) struct cmdline *cl,
6770 __attribute__((unused)) void *data)
6772 struct cmd_write_reg_bit_field_result *res = parsed_result;
6773 port_reg_bit_field_set(res->port_id, res->reg_off,
6774 res->bit1_pos, res->bit2_pos, res->value);
6777 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6778 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6780 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6781 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6782 regfield, "regfield");
6783 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6784 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6786 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6787 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6789 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6790 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6792 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6793 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6795 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6796 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6799 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6800 .f = cmd_write_reg_bit_field_parsed,
6802 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6804 "Set register bit field between bit_x and bit_y included",
6806 (void *)&cmd_write_reg_bit_field_write,
6807 (void *)&cmd_write_reg_bit_field_regfield,
6808 (void *)&cmd_write_reg_bit_field_port_id,
6809 (void *)&cmd_write_reg_bit_field_reg_off,
6810 (void *)&cmd_write_reg_bit_field_bit1_pos,
6811 (void *)&cmd_write_reg_bit_field_bit2_pos,
6812 (void *)&cmd_write_reg_bit_field_value,
6817 /* *** WRITE PORT REGISTER BIT *** */
6818 struct cmd_write_reg_bit_result {
6819 cmdline_fixed_string_t write;
6820 cmdline_fixed_string_t regbit;
6828 cmd_write_reg_bit_parsed(void *parsed_result,
6829 __attribute__((unused)) struct cmdline *cl,
6830 __attribute__((unused)) void *data)
6832 struct cmd_write_reg_bit_result *res = parsed_result;
6833 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6836 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6837 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6839 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6840 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6842 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6843 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6844 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6845 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6846 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6847 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6848 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6849 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6851 cmdline_parse_inst_t cmd_write_reg_bit = {
6852 .f = cmd_write_reg_bit_parsed,
6854 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6857 (void *)&cmd_write_reg_bit_write,
6858 (void *)&cmd_write_reg_bit_regbit,
6859 (void *)&cmd_write_reg_bit_port_id,
6860 (void *)&cmd_write_reg_bit_reg_off,
6861 (void *)&cmd_write_reg_bit_bit_pos,
6862 (void *)&cmd_write_reg_bit_value,
6867 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6868 struct cmd_read_rxd_txd_result {
6869 cmdline_fixed_string_t read;
6870 cmdline_fixed_string_t rxd_txd;
6877 cmd_read_rxd_txd_parsed(void *parsed_result,
6878 __attribute__((unused)) struct cmdline *cl,
6879 __attribute__((unused)) void *data)
6881 struct cmd_read_rxd_txd_result *res = parsed_result;
6883 if (!strcmp(res->rxd_txd, "rxd"))
6884 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6885 else if (!strcmp(res->rxd_txd, "txd"))
6886 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6889 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6890 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6891 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6892 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6894 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6895 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6896 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6897 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6898 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6899 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6901 cmdline_parse_inst_t cmd_read_rxd_txd = {
6902 .f = cmd_read_rxd_txd_parsed,
6904 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6906 (void *)&cmd_read_rxd_txd_read,
6907 (void *)&cmd_read_rxd_txd_rxd_txd,
6908 (void *)&cmd_read_rxd_txd_port_id,
6909 (void *)&cmd_read_rxd_txd_queue_id,
6910 (void *)&cmd_read_rxd_txd_desc_id,
6916 struct cmd_quit_result {
6917 cmdline_fixed_string_t quit;
6920 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6922 __attribute__((unused)) void *data)
6928 cmdline_parse_token_string_t cmd_quit_quit =
6929 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6931 cmdline_parse_inst_t cmd_quit = {
6932 .f = cmd_quit_parsed,
6934 .help_str = "quit: Exit application",
6936 (void *)&cmd_quit_quit,
6941 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6942 struct cmd_mac_addr_result {
6943 cmdline_fixed_string_t mac_addr_cmd;
6944 cmdline_fixed_string_t what;
6946 struct ether_addr address;
6949 static void cmd_mac_addr_parsed(void *parsed_result,
6950 __attribute__((unused)) struct cmdline *cl,
6951 __attribute__((unused)) void *data)
6953 struct cmd_mac_addr_result *res = parsed_result;
6956 if (strcmp(res->what, "add") == 0)
6957 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6958 else if (strcmp(res->what, "set") == 0)
6959 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6962 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6964 /* check the return value and print it if is < 0 */
6966 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6970 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6971 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6973 cmdline_parse_token_string_t cmd_mac_addr_what =
6974 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6976 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6977 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6978 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6979 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6981 cmdline_parse_inst_t cmd_mac_addr = {
6982 .f = cmd_mac_addr_parsed,
6984 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6985 "Add/Remove/Set MAC address on port_id",
6987 (void *)&cmd_mac_addr_cmd,
6988 (void *)&cmd_mac_addr_what,
6989 (void *)&cmd_mac_addr_portnum,
6990 (void *)&cmd_mac_addr_addr,
6996 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6997 struct cmd_set_qmap_result {
6998 cmdline_fixed_string_t set;
6999 cmdline_fixed_string_t qmap;
7000 cmdline_fixed_string_t what;
7007 cmd_set_qmap_parsed(void *parsed_result,
7008 __attribute__((unused)) struct cmdline *cl,
7009 __attribute__((unused)) void *data)
7011 struct cmd_set_qmap_result *res = parsed_result;
7012 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7014 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7017 cmdline_parse_token_string_t cmd_setqmap_set =
7018 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7020 cmdline_parse_token_string_t cmd_setqmap_qmap =
7021 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7023 cmdline_parse_token_string_t cmd_setqmap_what =
7024 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7026 cmdline_parse_token_num_t cmd_setqmap_portid =
7027 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7029 cmdline_parse_token_num_t cmd_setqmap_queueid =
7030 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7032 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7033 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7036 cmdline_parse_inst_t cmd_set_qmap = {
7037 .f = cmd_set_qmap_parsed,
7039 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7040 "Set statistics mapping value on tx|rx queue_id of port_id",
7042 (void *)&cmd_setqmap_set,
7043 (void *)&cmd_setqmap_qmap,
7044 (void *)&cmd_setqmap_what,
7045 (void *)&cmd_setqmap_portid,
7046 (void *)&cmd_setqmap_queueid,
7047 (void *)&cmd_setqmap_mapvalue,
7052 /* *** CONFIGURE UNICAST HASH TABLE *** */
7053 struct cmd_set_uc_hash_table {
7054 cmdline_fixed_string_t set;
7055 cmdline_fixed_string_t port;
7057 cmdline_fixed_string_t what;
7058 struct ether_addr address;
7059 cmdline_fixed_string_t mode;
7063 cmd_set_uc_hash_parsed(void *parsed_result,
7064 __attribute__((unused)) struct cmdline *cl,
7065 __attribute__((unused)) void *data)
7068 struct cmd_set_uc_hash_table *res = parsed_result;
7070 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7072 if (strcmp(res->what, "uta") == 0)
7073 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7074 &res->address,(uint8_t)is_on);
7076 printf("bad unicast hash table parameter, return code = %d \n", ret);
7080 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7081 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7083 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7084 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7086 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7087 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7089 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7090 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7092 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7093 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7095 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7096 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7099 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7100 .f = cmd_set_uc_hash_parsed,
7102 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7104 (void *)&cmd_set_uc_hash_set,
7105 (void *)&cmd_set_uc_hash_port,
7106 (void *)&cmd_set_uc_hash_portid,
7107 (void *)&cmd_set_uc_hash_what,
7108 (void *)&cmd_set_uc_hash_mac,
7109 (void *)&cmd_set_uc_hash_mode,
7114 struct cmd_set_uc_all_hash_table {
7115 cmdline_fixed_string_t set;
7116 cmdline_fixed_string_t port;
7118 cmdline_fixed_string_t what;
7119 cmdline_fixed_string_t value;
7120 cmdline_fixed_string_t mode;
7124 cmd_set_uc_all_hash_parsed(void *parsed_result,
7125 __attribute__((unused)) struct cmdline *cl,
7126 __attribute__((unused)) void *data)
7129 struct cmd_set_uc_all_hash_table *res = parsed_result;
7131 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7133 if ((strcmp(res->what, "uta") == 0) &&
7134 (strcmp(res->value, "all") == 0))
7135 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7137 printf("bad unicast hash table parameter,"
7138 "return code = %d \n", ret);
7141 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7142 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7144 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7145 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7147 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7148 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7150 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7151 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7153 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7154 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7156 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7160 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7161 .f = cmd_set_uc_all_hash_parsed,
7163 .help_str = "set port <port_id> uta all on|off",
7165 (void *)&cmd_set_uc_all_hash_set,
7166 (void *)&cmd_set_uc_all_hash_port,
7167 (void *)&cmd_set_uc_all_hash_portid,
7168 (void *)&cmd_set_uc_all_hash_what,
7169 (void *)&cmd_set_uc_all_hash_value,
7170 (void *)&cmd_set_uc_all_hash_mode,
7175 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7176 struct cmd_set_vf_macvlan_filter {
7177 cmdline_fixed_string_t set;
7178 cmdline_fixed_string_t port;
7180 cmdline_fixed_string_t vf;
7182 struct ether_addr address;
7183 cmdline_fixed_string_t filter_type;
7184 cmdline_fixed_string_t mode;
7188 cmd_set_vf_macvlan_parsed(void *parsed_result,
7189 __attribute__((unused)) struct cmdline *cl,
7190 __attribute__((unused)) void *data)
7193 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7194 struct rte_eth_mac_filter filter;
7196 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7198 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7200 /* set VF MAC filter */
7204 filter.dst_id = res->vf_id;
7206 if (!strcmp(res->filter_type, "exact-mac"))
7207 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7208 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7209 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7210 else if (!strcmp(res->filter_type, "hashmac"))
7211 filter.filter_type = RTE_MAC_HASH_MATCH;
7212 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7213 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7215 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7218 ret = rte_eth_dev_filter_ctrl(res->port_id,
7219 RTE_ETH_FILTER_MACVLAN,
7223 ret = rte_eth_dev_filter_ctrl(res->port_id,
7224 RTE_ETH_FILTER_MACVLAN,
7225 RTE_ETH_FILTER_DELETE,
7229 printf("bad set MAC hash parameter, return code = %d\n", ret);
7233 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7234 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7236 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7237 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7239 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7240 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7242 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7243 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7245 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7246 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7248 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7249 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7251 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7252 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7253 filter_type, "exact-mac#exact-mac-vlan"
7254 "#hashmac#hashmac-vlan");
7255 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7256 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7259 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7260 .f = cmd_set_vf_macvlan_parsed,
7262 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7263 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7264 "Exact match rule: exact match of MAC or MAC and VLAN; "
7265 "hash match rule: hash match of MAC and exact match of VLAN",
7267 (void *)&cmd_set_vf_macvlan_set,
7268 (void *)&cmd_set_vf_macvlan_port,
7269 (void *)&cmd_set_vf_macvlan_portid,
7270 (void *)&cmd_set_vf_macvlan_vf,
7271 (void *)&cmd_set_vf_macvlan_vf_id,
7272 (void *)&cmd_set_vf_macvlan_mac,
7273 (void *)&cmd_set_vf_macvlan_filter_type,
7274 (void *)&cmd_set_vf_macvlan_mode,
7279 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7280 struct cmd_set_vf_traffic {
7281 cmdline_fixed_string_t set;
7282 cmdline_fixed_string_t port;
7284 cmdline_fixed_string_t vf;
7286 cmdline_fixed_string_t what;
7287 cmdline_fixed_string_t mode;
7291 cmd_set_vf_traffic_parsed(void *parsed_result,
7292 __attribute__((unused)) struct cmdline *cl,
7293 __attribute__((unused)) void *data)
7295 struct cmd_set_vf_traffic *res = parsed_result;
7296 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7297 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7299 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7302 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7303 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7305 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7306 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7308 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7309 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7311 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7312 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7314 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7315 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7317 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7318 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7320 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7321 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7324 cmdline_parse_inst_t cmd_set_vf_traffic = {
7325 .f = cmd_set_vf_traffic_parsed,
7327 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7329 (void *)&cmd_setvf_traffic_set,
7330 (void *)&cmd_setvf_traffic_port,
7331 (void *)&cmd_setvf_traffic_portid,
7332 (void *)&cmd_setvf_traffic_vf,
7333 (void *)&cmd_setvf_traffic_vfid,
7334 (void *)&cmd_setvf_traffic_what,
7335 (void *)&cmd_setvf_traffic_mode,
7340 /* *** CONFIGURE VF RECEIVE MODE *** */
7341 struct cmd_set_vf_rxmode {
7342 cmdline_fixed_string_t set;
7343 cmdline_fixed_string_t port;
7345 cmdline_fixed_string_t vf;
7347 cmdline_fixed_string_t what;
7348 cmdline_fixed_string_t mode;
7349 cmdline_fixed_string_t on;
7353 cmd_set_vf_rxmode_parsed(void *parsed_result,
7354 __attribute__((unused)) struct cmdline *cl,
7355 __attribute__((unused)) void *data)
7358 uint16_t rx_mode = 0;
7359 struct cmd_set_vf_rxmode *res = parsed_result;
7361 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7362 if (!strcmp(res->what,"rxmode")) {
7363 if (!strcmp(res->mode, "AUPE"))
7364 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7365 else if (!strcmp(res->mode, "ROPE"))
7366 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7367 else if (!strcmp(res->mode, "BAM"))
7368 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7369 else if (!strncmp(res->mode, "MPE",3))
7370 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7373 #ifdef RTE_LIBRTE_IXGBE_PMD
7374 if (ret == -ENOTSUP)
7375 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7376 rx_mode, (uint8_t)is_on);
7378 #ifdef RTE_LIBRTE_BNXT_PMD
7379 if (ret == -ENOTSUP)
7380 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7381 rx_mode, (uint8_t)is_on);
7384 printf("bad VF receive mode parameter, return code = %d \n",
7388 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7389 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7391 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7392 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7394 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7395 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7397 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7398 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7400 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7401 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7403 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7404 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7406 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7407 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7408 mode, "AUPE#ROPE#BAM#MPE");
7409 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7410 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7413 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7414 .f = cmd_set_vf_rxmode_parsed,
7416 .help_str = "set port <port_id> vf <vf_id> rxmode "
7417 "AUPE|ROPE|BAM|MPE on|off",
7419 (void *)&cmd_set_vf_rxmode_set,
7420 (void *)&cmd_set_vf_rxmode_port,
7421 (void *)&cmd_set_vf_rxmode_portid,
7422 (void *)&cmd_set_vf_rxmode_vf,
7423 (void *)&cmd_set_vf_rxmode_vfid,
7424 (void *)&cmd_set_vf_rxmode_what,
7425 (void *)&cmd_set_vf_rxmode_mode,
7426 (void *)&cmd_set_vf_rxmode_on,
7431 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7432 struct cmd_vf_mac_addr_result {
7433 cmdline_fixed_string_t mac_addr_cmd;
7434 cmdline_fixed_string_t what;
7435 cmdline_fixed_string_t port;
7437 cmdline_fixed_string_t vf;
7439 struct ether_addr address;
7442 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7443 __attribute__((unused)) struct cmdline *cl,
7444 __attribute__((unused)) void *data)
7446 struct cmd_vf_mac_addr_result *res = parsed_result;
7449 if (strcmp(res->what, "add") != 0)
7452 #ifdef RTE_LIBRTE_I40E_PMD
7453 if (ret == -ENOTSUP)
7454 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7457 #ifdef RTE_LIBRTE_BNXT_PMD
7458 if (ret == -ENOTSUP)
7459 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7464 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7468 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7469 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7470 mac_addr_cmd,"mac_addr");
7471 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7472 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7474 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7475 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7477 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7478 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7480 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7481 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7483 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7484 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7486 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7487 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7490 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7491 .f = cmd_vf_mac_addr_parsed,
7493 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7494 "Add MAC address filtering for a VF on port_id",
7496 (void *)&cmd_vf_mac_addr_cmd,
7497 (void *)&cmd_vf_mac_addr_what,
7498 (void *)&cmd_vf_mac_addr_port,
7499 (void *)&cmd_vf_mac_addr_portnum,
7500 (void *)&cmd_vf_mac_addr_vf,
7501 (void *)&cmd_vf_mac_addr_vfnum,
7502 (void *)&cmd_vf_mac_addr_addr,
7507 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7508 struct cmd_vf_rx_vlan_filter {
7509 cmdline_fixed_string_t rx_vlan;
7510 cmdline_fixed_string_t what;
7512 cmdline_fixed_string_t port;
7514 cmdline_fixed_string_t vf;
7519 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7520 __attribute__((unused)) struct cmdline *cl,
7521 __attribute__((unused)) void *data)
7523 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7526 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7528 #ifdef RTE_LIBRTE_IXGBE_PMD
7529 if (ret == -ENOTSUP)
7530 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7531 res->vlan_id, res->vf_mask, is_add);
7533 #ifdef RTE_LIBRTE_I40E_PMD
7534 if (ret == -ENOTSUP)
7535 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7536 res->vlan_id, res->vf_mask, is_add);
7538 #ifdef RTE_LIBRTE_BNXT_PMD
7539 if (ret == -ENOTSUP)
7540 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7541 res->vlan_id, res->vf_mask, is_add);
7548 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7549 res->vlan_id, res->vf_mask);
7552 printf("invalid port_id %d\n", res->port_id);
7555 printf("function not implemented or supported\n");
7558 printf("programming error: (%s)\n", strerror(-ret));
7562 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7563 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7564 rx_vlan, "rx_vlan");
7565 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7566 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7568 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7569 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7571 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7572 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7574 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7575 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7577 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7578 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7580 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7581 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7584 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7585 .f = cmd_vf_rx_vlan_filter_parsed,
7587 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7588 "(vf_mask = hexadecimal VF mask)",
7590 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7591 (void *)&cmd_vf_rx_vlan_filter_what,
7592 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7593 (void *)&cmd_vf_rx_vlan_filter_port,
7594 (void *)&cmd_vf_rx_vlan_filter_portid,
7595 (void *)&cmd_vf_rx_vlan_filter_vf,
7596 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7601 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7602 struct cmd_queue_rate_limit_result {
7603 cmdline_fixed_string_t set;
7604 cmdline_fixed_string_t port;
7606 cmdline_fixed_string_t queue;
7608 cmdline_fixed_string_t rate;
7612 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7613 __attribute__((unused)) struct cmdline *cl,
7614 __attribute__((unused)) void *data)
7616 struct cmd_queue_rate_limit_result *res = parsed_result;
7619 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7620 && (strcmp(res->queue, "queue") == 0)
7621 && (strcmp(res->rate, "rate") == 0))
7622 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7625 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7629 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7630 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7632 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7633 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7635 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7636 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7638 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7639 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7641 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7642 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7644 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7645 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7647 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7648 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7651 cmdline_parse_inst_t cmd_queue_rate_limit = {
7652 .f = cmd_queue_rate_limit_parsed,
7654 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7655 "Set rate limit for a queue on port_id",
7657 (void *)&cmd_queue_rate_limit_set,
7658 (void *)&cmd_queue_rate_limit_port,
7659 (void *)&cmd_queue_rate_limit_portnum,
7660 (void *)&cmd_queue_rate_limit_queue,
7661 (void *)&cmd_queue_rate_limit_queuenum,
7662 (void *)&cmd_queue_rate_limit_rate,
7663 (void *)&cmd_queue_rate_limit_ratenum,
7668 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7669 struct cmd_vf_rate_limit_result {
7670 cmdline_fixed_string_t set;
7671 cmdline_fixed_string_t port;
7673 cmdline_fixed_string_t vf;
7675 cmdline_fixed_string_t rate;
7677 cmdline_fixed_string_t q_msk;
7681 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7682 __attribute__((unused)) struct cmdline *cl,
7683 __attribute__((unused)) void *data)
7685 struct cmd_vf_rate_limit_result *res = parsed_result;
7688 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7689 && (strcmp(res->vf, "vf") == 0)
7690 && (strcmp(res->rate, "rate") == 0)
7691 && (strcmp(res->q_msk, "queue_mask") == 0))
7692 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7693 res->rate_num, res->q_msk_val);
7695 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7699 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7700 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7702 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7703 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7705 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7706 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7708 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7709 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7711 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7712 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7714 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7715 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7717 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7718 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7720 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7721 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7722 q_msk, "queue_mask");
7723 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7724 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7727 cmdline_parse_inst_t cmd_vf_rate_limit = {
7728 .f = cmd_vf_rate_limit_parsed,
7730 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7731 "queue_mask <queue_mask_value>: "
7732 "Set rate limit for queues of VF on port_id",
7734 (void *)&cmd_vf_rate_limit_set,
7735 (void *)&cmd_vf_rate_limit_port,
7736 (void *)&cmd_vf_rate_limit_portnum,
7737 (void *)&cmd_vf_rate_limit_vf,
7738 (void *)&cmd_vf_rate_limit_vfnum,
7739 (void *)&cmd_vf_rate_limit_rate,
7740 (void *)&cmd_vf_rate_limit_ratenum,
7741 (void *)&cmd_vf_rate_limit_q_msk,
7742 (void *)&cmd_vf_rate_limit_q_msk_val,
7747 /* *** ADD TUNNEL FILTER OF A PORT *** */
7748 struct cmd_tunnel_filter_result {
7749 cmdline_fixed_string_t cmd;
7750 cmdline_fixed_string_t what;
7752 struct ether_addr outer_mac;
7753 struct ether_addr inner_mac;
7754 cmdline_ipaddr_t ip_value;
7755 uint16_t inner_vlan;
7756 cmdline_fixed_string_t tunnel_type;
7757 cmdline_fixed_string_t filter_type;
7763 cmd_tunnel_filter_parsed(void *parsed_result,
7764 __attribute__((unused)) struct cmdline *cl,
7765 __attribute__((unused)) void *data)
7767 struct cmd_tunnel_filter_result *res = parsed_result;
7768 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7771 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7773 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7774 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7775 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7777 if (res->ip_value.family == AF_INET) {
7778 tunnel_filter_conf.ip_addr.ipv4_addr =
7779 res->ip_value.addr.ipv4.s_addr;
7780 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7782 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7783 &(res->ip_value.addr.ipv6),
7784 sizeof(struct in6_addr));
7785 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7788 if (!strcmp(res->filter_type, "imac-ivlan"))
7789 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7790 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7791 tunnel_filter_conf.filter_type =
7792 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7793 else if (!strcmp(res->filter_type, "imac-tenid"))
7794 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7795 else if (!strcmp(res->filter_type, "imac"))
7796 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7797 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7798 tunnel_filter_conf.filter_type =
7799 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7800 else if (!strcmp(res->filter_type, "oip"))
7801 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7802 else if (!strcmp(res->filter_type, "iip"))
7803 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7805 printf("The filter type is not supported");
7809 if (!strcmp(res->tunnel_type, "vxlan"))
7810 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7811 else if (!strcmp(res->tunnel_type, "nvgre"))
7812 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7813 else if (!strcmp(res->tunnel_type, "ipingre"))
7814 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7816 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7820 tunnel_filter_conf.tenant_id = res->tenant_id;
7821 tunnel_filter_conf.queue_id = res->queue_num;
7822 if (!strcmp(res->what, "add"))
7823 ret = rte_eth_dev_filter_ctrl(res->port_id,
7824 RTE_ETH_FILTER_TUNNEL,
7826 &tunnel_filter_conf);
7828 ret = rte_eth_dev_filter_ctrl(res->port_id,
7829 RTE_ETH_FILTER_TUNNEL,
7830 RTE_ETH_FILTER_DELETE,
7831 &tunnel_filter_conf);
7833 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7837 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7838 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7839 cmd, "tunnel_filter");
7840 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7841 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7843 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7844 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7846 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7847 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7849 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7850 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7852 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7853 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7854 inner_vlan, UINT16);
7855 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7856 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7858 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7859 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7860 tunnel_type, "vxlan#nvgre#ipingre");
7862 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7863 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7864 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7865 "imac#omac-imac-tenid");
7866 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7867 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7869 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7870 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7873 cmdline_parse_inst_t cmd_tunnel_filter = {
7874 .f = cmd_tunnel_filter_parsed,
7876 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7877 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7878 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7879 "<queue_id>: Add/Rm tunnel filter of a port",
7881 (void *)&cmd_tunnel_filter_cmd,
7882 (void *)&cmd_tunnel_filter_what,
7883 (void *)&cmd_tunnel_filter_port_id,
7884 (void *)&cmd_tunnel_filter_outer_mac,
7885 (void *)&cmd_tunnel_filter_inner_mac,
7886 (void *)&cmd_tunnel_filter_ip_value,
7887 (void *)&cmd_tunnel_filter_innner_vlan,
7888 (void *)&cmd_tunnel_filter_tunnel_type,
7889 (void *)&cmd_tunnel_filter_filter_type,
7890 (void *)&cmd_tunnel_filter_tenant_id,
7891 (void *)&cmd_tunnel_filter_queue_num,
7896 /* *** CONFIGURE TUNNEL UDP PORT *** */
7897 struct cmd_tunnel_udp_config {
7898 cmdline_fixed_string_t cmd;
7899 cmdline_fixed_string_t what;
7905 cmd_tunnel_udp_config_parsed(void *parsed_result,
7906 __attribute__((unused)) struct cmdline *cl,
7907 __attribute__((unused)) void *data)
7909 struct cmd_tunnel_udp_config *res = parsed_result;
7910 struct rte_eth_udp_tunnel tunnel_udp;
7913 tunnel_udp.udp_port = res->udp_port;
7915 if (!strcmp(res->cmd, "rx_vxlan_port"))
7916 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7918 if (!strcmp(res->what, "add"))
7919 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7922 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7926 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7929 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7930 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7931 cmd, "rx_vxlan_port");
7932 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7933 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7935 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7936 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7938 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7939 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7942 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7943 .f = cmd_tunnel_udp_config_parsed,
7945 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7946 "Add/Remove a tunneling UDP port filter",
7948 (void *)&cmd_tunnel_udp_config_cmd,
7949 (void *)&cmd_tunnel_udp_config_what,
7950 (void *)&cmd_tunnel_udp_config_udp_port,
7951 (void *)&cmd_tunnel_udp_config_port_id,
7956 /* *** GLOBAL CONFIG *** */
7957 struct cmd_global_config_result {
7958 cmdline_fixed_string_t cmd;
7960 cmdline_fixed_string_t cfg_type;
7965 cmd_global_config_parsed(void *parsed_result,
7966 __attribute__((unused)) struct cmdline *cl,
7967 __attribute__((unused)) void *data)
7969 struct cmd_global_config_result *res = parsed_result;
7970 struct rte_eth_global_cfg conf;
7973 memset(&conf, 0, sizeof(conf));
7974 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7975 conf.cfg.gre_key_len = res->len;
7976 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7977 RTE_ETH_FILTER_SET, &conf);
7979 printf("Global config error\n");
7982 cmdline_parse_token_string_t cmd_global_config_cmd =
7983 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7985 cmdline_parse_token_num_t cmd_global_config_port_id =
7986 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7987 cmdline_parse_token_string_t cmd_global_config_type =
7988 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7989 cfg_type, "gre-key-len");
7990 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7991 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7994 cmdline_parse_inst_t cmd_global_config = {
7995 .f = cmd_global_config_parsed,
7996 .data = (void *)NULL,
7997 .help_str = "global_config <port_id> gre-key-len <key_len>",
7999 (void *)&cmd_global_config_cmd,
8000 (void *)&cmd_global_config_port_id,
8001 (void *)&cmd_global_config_type,
8002 (void *)&cmd_global_config_gre_key_len,
8007 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8008 struct cmd_set_mirror_mask_result {
8009 cmdline_fixed_string_t set;
8010 cmdline_fixed_string_t port;
8012 cmdline_fixed_string_t mirror;
8014 cmdline_fixed_string_t what;
8015 cmdline_fixed_string_t value;
8016 cmdline_fixed_string_t dstpool;
8018 cmdline_fixed_string_t on;
8021 cmdline_parse_token_string_t cmd_mirror_mask_set =
8022 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8024 cmdline_parse_token_string_t cmd_mirror_mask_port =
8025 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8027 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8028 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8030 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8031 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8032 mirror, "mirror-rule");
8033 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8034 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8036 cmdline_parse_token_string_t cmd_mirror_mask_what =
8037 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8038 what, "pool-mirror-up#pool-mirror-down"
8040 cmdline_parse_token_string_t cmd_mirror_mask_value =
8041 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8043 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8044 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8045 dstpool, "dst-pool");
8046 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8047 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8049 cmdline_parse_token_string_t cmd_mirror_mask_on =
8050 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8054 cmd_set_mirror_mask_parsed(void *parsed_result,
8055 __attribute__((unused)) struct cmdline *cl,
8056 __attribute__((unused)) void *data)
8059 struct cmd_set_mirror_mask_result *res = parsed_result;
8060 struct rte_eth_mirror_conf mr_conf;
8062 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8064 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8066 mr_conf.dst_pool = res->dstpool_id;
8068 if (!strcmp(res->what, "pool-mirror-up")) {
8069 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8070 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8071 } else if (!strcmp(res->what, "pool-mirror-down")) {
8072 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8073 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8074 } else if (!strcmp(res->what, "vlan-mirror")) {
8075 mr_conf.rule_type = ETH_MIRROR_VLAN;
8076 nb_item = parse_item_list(res->value, "vlan",
8077 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8081 for (i = 0; i < nb_item; i++) {
8082 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8083 printf("Invalid vlan_id: must be < 4096\n");
8087 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8088 mr_conf.vlan.vlan_mask |= 1ULL << i;
8092 if (!strcmp(res->on, "on"))
8093 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8096 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8099 printf("mirror rule add error: (%s)\n", strerror(-ret));
8102 cmdline_parse_inst_t cmd_set_mirror_mask = {
8103 .f = cmd_set_mirror_mask_parsed,
8105 .help_str = "set port <port_id> mirror-rule <rule_id> "
8106 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8107 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8109 (void *)&cmd_mirror_mask_set,
8110 (void *)&cmd_mirror_mask_port,
8111 (void *)&cmd_mirror_mask_portid,
8112 (void *)&cmd_mirror_mask_mirror,
8113 (void *)&cmd_mirror_mask_ruleid,
8114 (void *)&cmd_mirror_mask_what,
8115 (void *)&cmd_mirror_mask_value,
8116 (void *)&cmd_mirror_mask_dstpool,
8117 (void *)&cmd_mirror_mask_poolid,
8118 (void *)&cmd_mirror_mask_on,
8123 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8124 struct cmd_set_mirror_link_result {
8125 cmdline_fixed_string_t set;
8126 cmdline_fixed_string_t port;
8128 cmdline_fixed_string_t mirror;
8130 cmdline_fixed_string_t what;
8131 cmdline_fixed_string_t dstpool;
8133 cmdline_fixed_string_t on;
8136 cmdline_parse_token_string_t cmd_mirror_link_set =
8137 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8139 cmdline_parse_token_string_t cmd_mirror_link_port =
8140 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8142 cmdline_parse_token_num_t cmd_mirror_link_portid =
8143 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8145 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8146 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8147 mirror, "mirror-rule");
8148 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8149 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8151 cmdline_parse_token_string_t cmd_mirror_link_what =
8152 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8153 what, "uplink-mirror#downlink-mirror");
8154 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8155 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8156 dstpool, "dst-pool");
8157 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8158 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8160 cmdline_parse_token_string_t cmd_mirror_link_on =
8161 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8165 cmd_set_mirror_link_parsed(void *parsed_result,
8166 __attribute__((unused)) struct cmdline *cl,
8167 __attribute__((unused)) void *data)
8170 struct cmd_set_mirror_link_result *res = parsed_result;
8171 struct rte_eth_mirror_conf mr_conf;
8173 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8174 if (!strcmp(res->what, "uplink-mirror"))
8175 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8177 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8179 mr_conf.dst_pool = res->dstpool_id;
8181 if (!strcmp(res->on, "on"))
8182 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8185 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8188 /* check the return value and print it if is < 0 */
8190 printf("mirror rule add error: (%s)\n", strerror(-ret));
8194 cmdline_parse_inst_t cmd_set_mirror_link = {
8195 .f = cmd_set_mirror_link_parsed,
8197 .help_str = "set port <port_id> mirror-rule <rule_id> "
8198 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8200 (void *)&cmd_mirror_link_set,
8201 (void *)&cmd_mirror_link_port,
8202 (void *)&cmd_mirror_link_portid,
8203 (void *)&cmd_mirror_link_mirror,
8204 (void *)&cmd_mirror_link_ruleid,
8205 (void *)&cmd_mirror_link_what,
8206 (void *)&cmd_mirror_link_dstpool,
8207 (void *)&cmd_mirror_link_poolid,
8208 (void *)&cmd_mirror_link_on,
8213 /* *** RESET VM MIRROR RULE *** */
8214 struct cmd_rm_mirror_rule_result {
8215 cmdline_fixed_string_t reset;
8216 cmdline_fixed_string_t port;
8218 cmdline_fixed_string_t mirror;
8222 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8223 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8225 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8226 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8228 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8229 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8231 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8232 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8233 mirror, "mirror-rule");
8234 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8235 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8239 cmd_reset_mirror_rule_parsed(void *parsed_result,
8240 __attribute__((unused)) struct cmdline *cl,
8241 __attribute__((unused)) void *data)
8244 struct cmd_set_mirror_link_result *res = parsed_result;
8246 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8248 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8251 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8252 .f = cmd_reset_mirror_rule_parsed,
8254 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8256 (void *)&cmd_rm_mirror_rule_reset,
8257 (void *)&cmd_rm_mirror_rule_port,
8258 (void *)&cmd_rm_mirror_rule_portid,
8259 (void *)&cmd_rm_mirror_rule_mirror,
8260 (void *)&cmd_rm_mirror_rule_ruleid,
8265 /* ******************************************************************************** */
8267 struct cmd_dump_result {
8268 cmdline_fixed_string_t dump;
8272 dump_struct_sizes(void)
8274 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8275 DUMP_SIZE(struct rte_mbuf);
8276 DUMP_SIZE(struct rte_mempool);
8277 DUMP_SIZE(struct rte_ring);
8281 static void cmd_dump_parsed(void *parsed_result,
8282 __attribute__((unused)) struct cmdline *cl,
8283 __attribute__((unused)) void *data)
8285 struct cmd_dump_result *res = parsed_result;
8287 if (!strcmp(res->dump, "dump_physmem"))
8288 rte_dump_physmem_layout(stdout);
8289 else if (!strcmp(res->dump, "dump_memzone"))
8290 rte_memzone_dump(stdout);
8291 else if (!strcmp(res->dump, "dump_struct_sizes"))
8292 dump_struct_sizes();
8293 else if (!strcmp(res->dump, "dump_ring"))
8294 rte_ring_list_dump(stdout);
8295 else if (!strcmp(res->dump, "dump_mempool"))
8296 rte_mempool_list_dump(stdout);
8297 else if (!strcmp(res->dump, "dump_devargs"))
8298 rte_eal_devargs_dump(stdout);
8299 else if (!strcmp(res->dump, "dump_log_types"))
8300 rte_log_dump(stdout);
8303 cmdline_parse_token_string_t cmd_dump_dump =
8304 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8307 "dump_struct_sizes#"
8313 cmdline_parse_inst_t cmd_dump = {
8314 .f = cmd_dump_parsed, /* function to call */
8315 .data = NULL, /* 2nd arg of func */
8316 .help_str = "Dump status",
8317 .tokens = { /* token list, NULL terminated */
8318 (void *)&cmd_dump_dump,
8323 /* ******************************************************************************** */
8325 struct cmd_dump_one_result {
8326 cmdline_fixed_string_t dump;
8327 cmdline_fixed_string_t name;
8330 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8331 __attribute__((unused)) void *data)
8333 struct cmd_dump_one_result *res = parsed_result;
8335 if (!strcmp(res->dump, "dump_ring")) {
8337 r = rte_ring_lookup(res->name);
8339 cmdline_printf(cl, "Cannot find ring\n");
8342 rte_ring_dump(stdout, r);
8343 } else if (!strcmp(res->dump, "dump_mempool")) {
8344 struct rte_mempool *mp;
8345 mp = rte_mempool_lookup(res->name);
8347 cmdline_printf(cl, "Cannot find mempool\n");
8350 rte_mempool_dump(stdout, mp);
8354 cmdline_parse_token_string_t cmd_dump_one_dump =
8355 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8356 "dump_ring#dump_mempool");
8358 cmdline_parse_token_string_t cmd_dump_one_name =
8359 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8361 cmdline_parse_inst_t cmd_dump_one = {
8362 .f = cmd_dump_one_parsed, /* function to call */
8363 .data = NULL, /* 2nd arg of func */
8364 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8365 .tokens = { /* token list, NULL terminated */
8366 (void *)&cmd_dump_one_dump,
8367 (void *)&cmd_dump_one_name,
8372 /* *** Add/Del syn filter *** */
8373 struct cmd_syn_filter_result {
8374 cmdline_fixed_string_t filter;
8376 cmdline_fixed_string_t ops;
8377 cmdline_fixed_string_t priority;
8378 cmdline_fixed_string_t high;
8379 cmdline_fixed_string_t queue;
8384 cmd_syn_filter_parsed(void *parsed_result,
8385 __attribute__((unused)) struct cmdline *cl,
8386 __attribute__((unused)) void *data)
8388 struct cmd_syn_filter_result *res = parsed_result;
8389 struct rte_eth_syn_filter syn_filter;
8392 ret = rte_eth_dev_filter_supported(res->port_id,
8393 RTE_ETH_FILTER_SYN);
8395 printf("syn filter is not supported on port %u.\n",
8400 memset(&syn_filter, 0, sizeof(syn_filter));
8402 if (!strcmp(res->ops, "add")) {
8403 if (!strcmp(res->high, "high"))
8404 syn_filter.hig_pri = 1;
8406 syn_filter.hig_pri = 0;
8408 syn_filter.queue = res->queue_id;
8409 ret = rte_eth_dev_filter_ctrl(res->port_id,
8414 ret = rte_eth_dev_filter_ctrl(res->port_id,
8416 RTE_ETH_FILTER_DELETE,
8420 printf("syn filter programming error: (%s)\n",
8424 cmdline_parse_token_string_t cmd_syn_filter_filter =
8425 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8426 filter, "syn_filter");
8427 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8428 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8430 cmdline_parse_token_string_t cmd_syn_filter_ops =
8431 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8433 cmdline_parse_token_string_t cmd_syn_filter_priority =
8434 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8435 priority, "priority");
8436 cmdline_parse_token_string_t cmd_syn_filter_high =
8437 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8439 cmdline_parse_token_string_t cmd_syn_filter_queue =
8440 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8442 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8443 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8446 cmdline_parse_inst_t cmd_syn_filter = {
8447 .f = cmd_syn_filter_parsed,
8449 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8450 "<queue_id>: Add/Delete syn filter",
8452 (void *)&cmd_syn_filter_filter,
8453 (void *)&cmd_syn_filter_port_id,
8454 (void *)&cmd_syn_filter_ops,
8455 (void *)&cmd_syn_filter_priority,
8456 (void *)&cmd_syn_filter_high,
8457 (void *)&cmd_syn_filter_queue,
8458 (void *)&cmd_syn_filter_queue_id,
8463 /* *** ADD/REMOVE A 2tuple FILTER *** */
8464 struct cmd_2tuple_filter_result {
8465 cmdline_fixed_string_t filter;
8467 cmdline_fixed_string_t ops;
8468 cmdline_fixed_string_t dst_port;
8469 uint16_t dst_port_value;
8470 cmdline_fixed_string_t protocol;
8471 uint8_t protocol_value;
8472 cmdline_fixed_string_t mask;
8474 cmdline_fixed_string_t tcp_flags;
8475 uint8_t tcp_flags_value;
8476 cmdline_fixed_string_t priority;
8477 uint8_t priority_value;
8478 cmdline_fixed_string_t queue;
8483 cmd_2tuple_filter_parsed(void *parsed_result,
8484 __attribute__((unused)) struct cmdline *cl,
8485 __attribute__((unused)) void *data)
8487 struct rte_eth_ntuple_filter filter;
8488 struct cmd_2tuple_filter_result *res = parsed_result;
8491 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8493 printf("ntuple filter is not supported on port %u.\n",
8498 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8500 filter.flags = RTE_2TUPLE_FLAGS;
8501 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8502 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8503 filter.proto = res->protocol_value;
8504 filter.priority = res->priority_value;
8505 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8506 printf("nonzero tcp_flags is only meaningful"
8507 " when protocol is TCP.\n");
8510 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8511 printf("invalid TCP flags.\n");
8515 if (res->tcp_flags_value != 0) {
8516 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8517 filter.tcp_flags = res->tcp_flags_value;
8520 /* need convert to big endian. */
8521 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8522 filter.queue = res->queue_id;
8524 if (!strcmp(res->ops, "add"))
8525 ret = rte_eth_dev_filter_ctrl(res->port_id,
8526 RTE_ETH_FILTER_NTUPLE,
8530 ret = rte_eth_dev_filter_ctrl(res->port_id,
8531 RTE_ETH_FILTER_NTUPLE,
8532 RTE_ETH_FILTER_DELETE,
8535 printf("2tuple filter programming error: (%s)\n",
8540 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8541 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8542 filter, "2tuple_filter");
8543 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8544 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8546 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8547 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8549 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8550 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8551 dst_port, "dst_port");
8552 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8553 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8554 dst_port_value, UINT16);
8555 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8556 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8557 protocol, "protocol");
8558 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8559 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8560 protocol_value, UINT8);
8561 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8562 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8564 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8565 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8567 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8568 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8569 tcp_flags, "tcp_flags");
8570 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8571 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8572 tcp_flags_value, UINT8);
8573 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8574 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8575 priority, "priority");
8576 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8577 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8578 priority_value, UINT8);
8579 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8580 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8582 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8583 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8586 cmdline_parse_inst_t cmd_2tuple_filter = {
8587 .f = cmd_2tuple_filter_parsed,
8589 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8590 "<value> mask <value> tcp_flags <value> priority <value> queue "
8591 "<queue_id>: Add a 2tuple filter",
8593 (void *)&cmd_2tuple_filter_filter,
8594 (void *)&cmd_2tuple_filter_port_id,
8595 (void *)&cmd_2tuple_filter_ops,
8596 (void *)&cmd_2tuple_filter_dst_port,
8597 (void *)&cmd_2tuple_filter_dst_port_value,
8598 (void *)&cmd_2tuple_filter_protocol,
8599 (void *)&cmd_2tuple_filter_protocol_value,
8600 (void *)&cmd_2tuple_filter_mask,
8601 (void *)&cmd_2tuple_filter_mask_value,
8602 (void *)&cmd_2tuple_filter_tcp_flags,
8603 (void *)&cmd_2tuple_filter_tcp_flags_value,
8604 (void *)&cmd_2tuple_filter_priority,
8605 (void *)&cmd_2tuple_filter_priority_value,
8606 (void *)&cmd_2tuple_filter_queue,
8607 (void *)&cmd_2tuple_filter_queue_id,
8612 /* *** ADD/REMOVE A 5tuple FILTER *** */
8613 struct cmd_5tuple_filter_result {
8614 cmdline_fixed_string_t filter;
8616 cmdline_fixed_string_t ops;
8617 cmdline_fixed_string_t dst_ip;
8618 cmdline_ipaddr_t dst_ip_value;
8619 cmdline_fixed_string_t src_ip;
8620 cmdline_ipaddr_t src_ip_value;
8621 cmdline_fixed_string_t dst_port;
8622 uint16_t dst_port_value;
8623 cmdline_fixed_string_t src_port;
8624 uint16_t src_port_value;
8625 cmdline_fixed_string_t protocol;
8626 uint8_t protocol_value;
8627 cmdline_fixed_string_t mask;
8629 cmdline_fixed_string_t tcp_flags;
8630 uint8_t tcp_flags_value;
8631 cmdline_fixed_string_t priority;
8632 uint8_t priority_value;
8633 cmdline_fixed_string_t queue;
8638 cmd_5tuple_filter_parsed(void *parsed_result,
8639 __attribute__((unused)) struct cmdline *cl,
8640 __attribute__((unused)) void *data)
8642 struct rte_eth_ntuple_filter filter;
8643 struct cmd_5tuple_filter_result *res = parsed_result;
8646 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8648 printf("ntuple filter is not supported on port %u.\n",
8653 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8655 filter.flags = RTE_5TUPLE_FLAGS;
8656 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8657 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8658 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8659 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8660 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8661 filter.proto = res->protocol_value;
8662 filter.priority = res->priority_value;
8663 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8664 printf("nonzero tcp_flags is only meaningful"
8665 " when protocol is TCP.\n");
8668 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8669 printf("invalid TCP flags.\n");
8673 if (res->tcp_flags_value != 0) {
8674 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8675 filter.tcp_flags = res->tcp_flags_value;
8678 if (res->dst_ip_value.family == AF_INET)
8679 /* no need to convert, already big endian. */
8680 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8682 if (filter.dst_ip_mask == 0) {
8683 printf("can not support ipv6 involved compare.\n");
8689 if (res->src_ip_value.family == AF_INET)
8690 /* no need to convert, already big endian. */
8691 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8693 if (filter.src_ip_mask == 0) {
8694 printf("can not support ipv6 involved compare.\n");
8699 /* need convert to big endian. */
8700 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8701 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8702 filter.queue = res->queue_id;
8704 if (!strcmp(res->ops, "add"))
8705 ret = rte_eth_dev_filter_ctrl(res->port_id,
8706 RTE_ETH_FILTER_NTUPLE,
8710 ret = rte_eth_dev_filter_ctrl(res->port_id,
8711 RTE_ETH_FILTER_NTUPLE,
8712 RTE_ETH_FILTER_DELETE,
8715 printf("5tuple filter programming error: (%s)\n",
8719 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8720 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8721 filter, "5tuple_filter");
8722 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8723 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8725 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8726 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8728 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8729 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8731 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8732 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8734 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8735 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8737 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8738 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8740 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8741 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8742 dst_port, "dst_port");
8743 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8744 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8745 dst_port_value, UINT16);
8746 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8747 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8748 src_port, "src_port");
8749 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8750 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8751 src_port_value, UINT16);
8752 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8753 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8754 protocol, "protocol");
8755 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8756 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8757 protocol_value, UINT8);
8758 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8759 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8761 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8762 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8764 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8765 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8766 tcp_flags, "tcp_flags");
8767 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8768 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8769 tcp_flags_value, UINT8);
8770 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8771 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8772 priority, "priority");
8773 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8774 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8775 priority_value, UINT8);
8776 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8777 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8779 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8780 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8783 cmdline_parse_inst_t cmd_5tuple_filter = {
8784 .f = cmd_5tuple_filter_parsed,
8786 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8787 "src_ip <value> dst_port <value> src_port <value> "
8788 "protocol <value> mask <value> tcp_flags <value> "
8789 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8791 (void *)&cmd_5tuple_filter_filter,
8792 (void *)&cmd_5tuple_filter_port_id,
8793 (void *)&cmd_5tuple_filter_ops,
8794 (void *)&cmd_5tuple_filter_dst_ip,
8795 (void *)&cmd_5tuple_filter_dst_ip_value,
8796 (void *)&cmd_5tuple_filter_src_ip,
8797 (void *)&cmd_5tuple_filter_src_ip_value,
8798 (void *)&cmd_5tuple_filter_dst_port,
8799 (void *)&cmd_5tuple_filter_dst_port_value,
8800 (void *)&cmd_5tuple_filter_src_port,
8801 (void *)&cmd_5tuple_filter_src_port_value,
8802 (void *)&cmd_5tuple_filter_protocol,
8803 (void *)&cmd_5tuple_filter_protocol_value,
8804 (void *)&cmd_5tuple_filter_mask,
8805 (void *)&cmd_5tuple_filter_mask_value,
8806 (void *)&cmd_5tuple_filter_tcp_flags,
8807 (void *)&cmd_5tuple_filter_tcp_flags_value,
8808 (void *)&cmd_5tuple_filter_priority,
8809 (void *)&cmd_5tuple_filter_priority_value,
8810 (void *)&cmd_5tuple_filter_queue,
8811 (void *)&cmd_5tuple_filter_queue_id,
8816 /* *** ADD/REMOVE A flex FILTER *** */
8817 struct cmd_flex_filter_result {
8818 cmdline_fixed_string_t filter;
8819 cmdline_fixed_string_t ops;
8821 cmdline_fixed_string_t len;
8823 cmdline_fixed_string_t bytes;
8824 cmdline_fixed_string_t bytes_value;
8825 cmdline_fixed_string_t mask;
8826 cmdline_fixed_string_t mask_value;
8827 cmdline_fixed_string_t priority;
8828 uint8_t priority_value;
8829 cmdline_fixed_string_t queue;
8833 static int xdigit2val(unsigned char c)
8838 else if (isupper(c))
8846 cmd_flex_filter_parsed(void *parsed_result,
8847 __attribute__((unused)) struct cmdline *cl,
8848 __attribute__((unused)) void *data)
8851 struct rte_eth_flex_filter filter;
8852 struct cmd_flex_filter_result *res = parsed_result;
8853 char *bytes_ptr, *mask_ptr;
8854 uint16_t len, i, j = 0;
8859 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8860 printf("the len exceed the max length 128\n");
8863 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8864 filter.len = res->len_value;
8865 filter.priority = res->priority_value;
8866 filter.queue = res->queue_id;
8867 bytes_ptr = res->bytes_value;
8868 mask_ptr = res->mask_value;
8870 /* translate bytes string to array. */
8871 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8872 (bytes_ptr[1] == 'X')))
8874 len = strnlen(bytes_ptr, res->len_value * 2);
8875 if (len == 0 || (len % 8 != 0)) {
8876 printf("please check len and bytes input\n");
8879 for (i = 0; i < len; i++) {
8881 if (isxdigit(c) == 0) {
8882 /* invalid characters. */
8883 printf("invalid input\n");
8886 val = xdigit2val(c);
8889 filter.bytes[j] = byte;
8890 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8897 /* translate mask string to uint8_t array. */
8898 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8899 (mask_ptr[1] == 'X')))
8901 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8903 printf("invalid input\n");
8908 for (i = 0; i < len; i++) {
8910 if (isxdigit(c) == 0) {
8911 /* invalid characters. */
8912 printf("invalid input\n");
8915 val = xdigit2val(c);
8918 filter.mask[j] = byte;
8919 printf("mask[%d]:%02x ", j, filter.mask[j]);
8927 if (!strcmp(res->ops, "add"))
8928 ret = rte_eth_dev_filter_ctrl(res->port_id,
8929 RTE_ETH_FILTER_FLEXIBLE,
8933 ret = rte_eth_dev_filter_ctrl(res->port_id,
8934 RTE_ETH_FILTER_FLEXIBLE,
8935 RTE_ETH_FILTER_DELETE,
8939 printf("flex filter setting error: (%s)\n", strerror(-ret));
8942 cmdline_parse_token_string_t cmd_flex_filter_filter =
8943 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8944 filter, "flex_filter");
8945 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8946 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8948 cmdline_parse_token_string_t cmd_flex_filter_ops =
8949 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8951 cmdline_parse_token_string_t cmd_flex_filter_len =
8952 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8954 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8955 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8957 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8958 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8960 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8961 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8963 cmdline_parse_token_string_t cmd_flex_filter_mask =
8964 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8966 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8967 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8969 cmdline_parse_token_string_t cmd_flex_filter_priority =
8970 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8971 priority, "priority");
8972 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8973 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8974 priority_value, UINT8);
8975 cmdline_parse_token_string_t cmd_flex_filter_queue =
8976 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8978 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8979 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8981 cmdline_parse_inst_t cmd_flex_filter = {
8982 .f = cmd_flex_filter_parsed,
8984 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8985 "<value> mask <value> priority <value> queue <queue_id>: "
8986 "Add/Del a flex filter",
8988 (void *)&cmd_flex_filter_filter,
8989 (void *)&cmd_flex_filter_port_id,
8990 (void *)&cmd_flex_filter_ops,
8991 (void *)&cmd_flex_filter_len,
8992 (void *)&cmd_flex_filter_len_value,
8993 (void *)&cmd_flex_filter_bytes,
8994 (void *)&cmd_flex_filter_bytes_value,
8995 (void *)&cmd_flex_filter_mask,
8996 (void *)&cmd_flex_filter_mask_value,
8997 (void *)&cmd_flex_filter_priority,
8998 (void *)&cmd_flex_filter_priority_value,
8999 (void *)&cmd_flex_filter_queue,
9000 (void *)&cmd_flex_filter_queue_id,
9005 /* *** Filters Control *** */
9007 /* *** deal with ethertype filter *** */
9008 struct cmd_ethertype_filter_result {
9009 cmdline_fixed_string_t filter;
9011 cmdline_fixed_string_t ops;
9012 cmdline_fixed_string_t mac;
9013 struct ether_addr mac_addr;
9014 cmdline_fixed_string_t ethertype;
9015 uint16_t ethertype_value;
9016 cmdline_fixed_string_t drop;
9017 cmdline_fixed_string_t queue;
9021 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9022 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9023 filter, "ethertype_filter");
9024 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9025 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9027 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9028 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9030 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9031 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9032 mac, "mac_addr#mac_ignr");
9033 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9034 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9036 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9037 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9038 ethertype, "ethertype");
9039 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9040 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9041 ethertype_value, UINT16);
9042 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9043 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9045 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9046 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9048 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9049 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9053 cmd_ethertype_filter_parsed(void *parsed_result,
9054 __attribute__((unused)) struct cmdline *cl,
9055 __attribute__((unused)) void *data)
9057 struct cmd_ethertype_filter_result *res = parsed_result;
9058 struct rte_eth_ethertype_filter filter;
9061 ret = rte_eth_dev_filter_supported(res->port_id,
9062 RTE_ETH_FILTER_ETHERTYPE);
9064 printf("ethertype filter is not supported on port %u.\n",
9069 memset(&filter, 0, sizeof(filter));
9070 if (!strcmp(res->mac, "mac_addr")) {
9071 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9072 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9073 sizeof(struct ether_addr));
9075 if (!strcmp(res->drop, "drop"))
9076 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9077 filter.ether_type = res->ethertype_value;
9078 filter.queue = res->queue_id;
9080 if (!strcmp(res->ops, "add"))
9081 ret = rte_eth_dev_filter_ctrl(res->port_id,
9082 RTE_ETH_FILTER_ETHERTYPE,
9086 ret = rte_eth_dev_filter_ctrl(res->port_id,
9087 RTE_ETH_FILTER_ETHERTYPE,
9088 RTE_ETH_FILTER_DELETE,
9091 printf("ethertype filter programming error: (%s)\n",
9095 cmdline_parse_inst_t cmd_ethertype_filter = {
9096 .f = cmd_ethertype_filter_parsed,
9098 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9099 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9100 "Add or delete an ethertype filter entry",
9102 (void *)&cmd_ethertype_filter_filter,
9103 (void *)&cmd_ethertype_filter_port_id,
9104 (void *)&cmd_ethertype_filter_ops,
9105 (void *)&cmd_ethertype_filter_mac,
9106 (void *)&cmd_ethertype_filter_mac_addr,
9107 (void *)&cmd_ethertype_filter_ethertype,
9108 (void *)&cmd_ethertype_filter_ethertype_value,
9109 (void *)&cmd_ethertype_filter_drop,
9110 (void *)&cmd_ethertype_filter_queue,
9111 (void *)&cmd_ethertype_filter_queue_id,
9116 /* *** deal with flow director filter *** */
9117 struct cmd_flow_director_result {
9118 cmdline_fixed_string_t flow_director_filter;
9120 cmdline_fixed_string_t mode;
9121 cmdline_fixed_string_t mode_value;
9122 cmdline_fixed_string_t ops;
9123 cmdline_fixed_string_t flow;
9124 cmdline_fixed_string_t flow_type;
9125 cmdline_fixed_string_t ether;
9126 uint16_t ether_type;
9127 cmdline_fixed_string_t src;
9128 cmdline_ipaddr_t ip_src;
9130 cmdline_fixed_string_t dst;
9131 cmdline_ipaddr_t ip_dst;
9133 cmdline_fixed_string_t verify_tag;
9134 uint32_t verify_tag_value;
9135 cmdline_ipaddr_t tos;
9137 cmdline_ipaddr_t proto;
9138 uint8_t proto_value;
9139 cmdline_ipaddr_t ttl;
9141 cmdline_fixed_string_t vlan;
9142 uint16_t vlan_value;
9143 cmdline_fixed_string_t flexbytes;
9144 cmdline_fixed_string_t flexbytes_value;
9145 cmdline_fixed_string_t pf_vf;
9146 cmdline_fixed_string_t drop;
9147 cmdline_fixed_string_t queue;
9149 cmdline_fixed_string_t fd_id;
9150 uint32_t fd_id_value;
9151 cmdline_fixed_string_t mac;
9152 struct ether_addr mac_addr;
9153 cmdline_fixed_string_t tunnel;
9154 cmdline_fixed_string_t tunnel_type;
9155 cmdline_fixed_string_t tunnel_id;
9156 uint32_t tunnel_id_value;
9160 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9163 const char *p, *p0 = q_arg;
9165 unsigned long int_fld;
9166 char *str_fld[max_num];
9171 p = strchr(p0, '(');
9175 p0 = strchr(p, ')');
9180 if (size >= sizeof(s))
9183 snprintf(s, sizeof(s), "%.*s", size, p);
9184 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9185 if (ret < 0 || ret > max_num)
9187 for (i = 0; i < ret; i++) {
9189 int_fld = strtoul(str_fld[i], &end, 0);
9190 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9192 flexbytes[i] = (uint8_t)int_fld;
9198 str2flowtype(char *string)
9201 static const struct {
9204 } flowtype_str[] = {
9205 {"raw", RTE_ETH_FLOW_RAW},
9206 {"ipv4", RTE_ETH_FLOW_IPV4},
9207 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9208 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9209 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9210 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9211 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9212 {"ipv6", RTE_ETH_FLOW_IPV6},
9213 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9214 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9215 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9216 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9217 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9218 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9221 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9222 if (!strcmp(flowtype_str[i].str, string))
9223 return flowtype_str[i].type;
9226 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9227 return (uint16_t)atoi(string);
9229 return RTE_ETH_FLOW_UNKNOWN;
9232 static enum rte_eth_fdir_tunnel_type
9233 str2fdir_tunneltype(char *string)
9237 static const struct {
9239 enum rte_eth_fdir_tunnel_type type;
9240 } tunneltype_str[] = {
9241 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9242 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9245 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9246 if (!strcmp(tunneltype_str[i].str, string))
9247 return tunneltype_str[i].type;
9249 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9252 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9254 if ((ip_addr).family == AF_INET) \
9255 (ip) = (ip_addr).addr.ipv4.s_addr; \
9257 printf("invalid parameter.\n"); \
9262 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9264 if ((ip_addr).family == AF_INET6) \
9266 &((ip_addr).addr.ipv6), \
9267 sizeof(struct in6_addr)); \
9269 printf("invalid parameter.\n"); \
9275 cmd_flow_director_filter_parsed(void *parsed_result,
9276 __attribute__((unused)) struct cmdline *cl,
9277 __attribute__((unused)) void *data)
9279 struct cmd_flow_director_result *res = parsed_result;
9280 struct rte_eth_fdir_filter entry;
9281 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9283 unsigned long vf_id;
9286 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9288 printf("flow director is not supported on port %u.\n",
9292 memset(flexbytes, 0, sizeof(flexbytes));
9293 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9295 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9296 if (strcmp(res->mode_value, "MAC-VLAN")) {
9297 printf("Please set mode to MAC-VLAN.\n");
9300 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9301 if (strcmp(res->mode_value, "Tunnel")) {
9302 printf("Please set mode to Tunnel.\n");
9306 if (strcmp(res->mode_value, "IP")) {
9307 printf("Please set mode to IP.\n");
9310 entry.input.flow_type = str2flowtype(res->flow_type);
9313 ret = parse_flexbytes(res->flexbytes_value,
9315 RTE_ETH_FDIR_MAX_FLEXLEN);
9317 printf("error: Cannot parse flexbytes input.\n");
9321 switch (entry.input.flow_type) {
9322 case RTE_ETH_FLOW_FRAG_IPV4:
9323 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9324 entry.input.flow.ip4_flow.proto = res->proto_value;
9326 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9327 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9328 IPV4_ADDR_TO_UINT(res->ip_dst,
9329 entry.input.flow.ip4_flow.dst_ip);
9330 IPV4_ADDR_TO_UINT(res->ip_src,
9331 entry.input.flow.ip4_flow.src_ip);
9332 entry.input.flow.ip4_flow.tos = res->tos_value;
9333 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9334 /* need convert to big endian. */
9335 entry.input.flow.udp4_flow.dst_port =
9336 rte_cpu_to_be_16(res->port_dst);
9337 entry.input.flow.udp4_flow.src_port =
9338 rte_cpu_to_be_16(res->port_src);
9340 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9341 IPV4_ADDR_TO_UINT(res->ip_dst,
9342 entry.input.flow.sctp4_flow.ip.dst_ip);
9343 IPV4_ADDR_TO_UINT(res->ip_src,
9344 entry.input.flow.sctp4_flow.ip.src_ip);
9345 entry.input.flow.ip4_flow.tos = res->tos_value;
9346 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9347 /* need convert to big endian. */
9348 entry.input.flow.sctp4_flow.dst_port =
9349 rte_cpu_to_be_16(res->port_dst);
9350 entry.input.flow.sctp4_flow.src_port =
9351 rte_cpu_to_be_16(res->port_src);
9352 entry.input.flow.sctp4_flow.verify_tag =
9353 rte_cpu_to_be_32(res->verify_tag_value);
9355 case RTE_ETH_FLOW_FRAG_IPV6:
9356 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9357 entry.input.flow.ipv6_flow.proto = res->proto_value;
9359 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9360 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9361 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9362 entry.input.flow.ipv6_flow.dst_ip);
9363 IPV6_ADDR_TO_ARRAY(res->ip_src,
9364 entry.input.flow.ipv6_flow.src_ip);
9365 entry.input.flow.ipv6_flow.tc = res->tos_value;
9366 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9367 /* need convert to big endian. */
9368 entry.input.flow.udp6_flow.dst_port =
9369 rte_cpu_to_be_16(res->port_dst);
9370 entry.input.flow.udp6_flow.src_port =
9371 rte_cpu_to_be_16(res->port_src);
9373 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9374 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9375 entry.input.flow.sctp6_flow.ip.dst_ip);
9376 IPV6_ADDR_TO_ARRAY(res->ip_src,
9377 entry.input.flow.sctp6_flow.ip.src_ip);
9378 entry.input.flow.ipv6_flow.tc = res->tos_value;
9379 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9380 /* need convert to big endian. */
9381 entry.input.flow.sctp6_flow.dst_port =
9382 rte_cpu_to_be_16(res->port_dst);
9383 entry.input.flow.sctp6_flow.src_port =
9384 rte_cpu_to_be_16(res->port_src);
9385 entry.input.flow.sctp6_flow.verify_tag =
9386 rte_cpu_to_be_32(res->verify_tag_value);
9388 case RTE_ETH_FLOW_L2_PAYLOAD:
9389 entry.input.flow.l2_flow.ether_type =
9390 rte_cpu_to_be_16(res->ether_type);
9396 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9397 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9399 sizeof(struct ether_addr));
9401 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9402 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9404 sizeof(struct ether_addr));
9405 entry.input.flow.tunnel_flow.tunnel_type =
9406 str2fdir_tunneltype(res->tunnel_type);
9407 entry.input.flow.tunnel_flow.tunnel_id =
9408 rte_cpu_to_be_32(res->tunnel_id_value);
9411 rte_memcpy(entry.input.flow_ext.flexbytes,
9413 RTE_ETH_FDIR_MAX_FLEXLEN);
9415 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9417 entry.action.flex_off = 0; /*use 0 by default */
9418 if (!strcmp(res->drop, "drop"))
9419 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9421 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9423 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9424 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9425 if (!strcmp(res->pf_vf, "pf"))
9426 entry.input.flow_ext.is_vf = 0;
9427 else if (!strncmp(res->pf_vf, "vf", 2)) {
9428 struct rte_eth_dev_info dev_info;
9430 memset(&dev_info, 0, sizeof(dev_info));
9431 rte_eth_dev_info_get(res->port_id, &dev_info);
9433 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9434 if (errno != 0 || *end != '\0' ||
9435 vf_id >= dev_info.max_vfs) {
9436 printf("invalid parameter %s.\n", res->pf_vf);
9439 entry.input.flow_ext.is_vf = 1;
9440 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9442 printf("invalid parameter %s.\n", res->pf_vf);
9447 /* set to report FD ID by default */
9448 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9449 entry.action.rx_queue = res->queue_id;
9450 entry.soft_id = res->fd_id_value;
9451 if (!strcmp(res->ops, "add"))
9452 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9453 RTE_ETH_FILTER_ADD, &entry);
9454 else if (!strcmp(res->ops, "del"))
9455 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9456 RTE_ETH_FILTER_DELETE, &entry);
9458 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9459 RTE_ETH_FILTER_UPDATE, &entry);
9461 printf("flow director programming error: (%s)\n",
9465 cmdline_parse_token_string_t cmd_flow_director_filter =
9466 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9467 flow_director_filter, "flow_director_filter");
9468 cmdline_parse_token_num_t cmd_flow_director_port_id =
9469 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9471 cmdline_parse_token_string_t cmd_flow_director_ops =
9472 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9473 ops, "add#del#update");
9474 cmdline_parse_token_string_t cmd_flow_director_flow =
9475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9477 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9478 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9479 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9480 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9481 cmdline_parse_token_string_t cmd_flow_director_ether =
9482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9484 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9485 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9486 ether_type, UINT16);
9487 cmdline_parse_token_string_t cmd_flow_director_src =
9488 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9490 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9491 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9493 cmdline_parse_token_num_t cmd_flow_director_port_src =
9494 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9496 cmdline_parse_token_string_t cmd_flow_director_dst =
9497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9499 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9500 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9502 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9503 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9505 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9507 verify_tag, "verify_tag");
9508 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9509 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9510 verify_tag_value, UINT32);
9511 cmdline_parse_token_string_t cmd_flow_director_tos =
9512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9514 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9515 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9517 cmdline_parse_token_string_t cmd_flow_director_proto =
9518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9520 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9521 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9522 proto_value, UINT8);
9523 cmdline_parse_token_string_t cmd_flow_director_ttl =
9524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9526 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9527 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9529 cmdline_parse_token_string_t cmd_flow_director_vlan =
9530 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9532 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9533 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9534 vlan_value, UINT16);
9535 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9536 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9537 flexbytes, "flexbytes");
9538 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9540 flexbytes_value, NULL);
9541 cmdline_parse_token_string_t cmd_flow_director_drop =
9542 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9544 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9547 cmdline_parse_token_string_t cmd_flow_director_queue =
9548 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9550 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9551 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9553 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9556 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9557 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9558 fd_id_value, UINT32);
9560 cmdline_parse_token_string_t cmd_flow_director_mode =
9561 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9563 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9564 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9566 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9567 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9568 mode_value, "MAC-VLAN");
9569 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9571 mode_value, "Tunnel");
9572 cmdline_parse_token_string_t cmd_flow_director_mac =
9573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9575 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9576 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9578 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9581 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9583 tunnel_type, "NVGRE#VxLAN");
9584 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9585 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9586 tunnel_id, "tunnel-id");
9587 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9588 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9589 tunnel_id_value, UINT32);
9591 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9592 .f = cmd_flow_director_filter_parsed,
9594 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9595 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9596 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9597 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9598 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9599 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9600 "fd_id <fd_id_value>: "
9601 "Add or delete an ip flow director entry on NIC",
9603 (void *)&cmd_flow_director_filter,
9604 (void *)&cmd_flow_director_port_id,
9605 (void *)&cmd_flow_director_mode,
9606 (void *)&cmd_flow_director_mode_ip,
9607 (void *)&cmd_flow_director_ops,
9608 (void *)&cmd_flow_director_flow,
9609 (void *)&cmd_flow_director_flow_type,
9610 (void *)&cmd_flow_director_src,
9611 (void *)&cmd_flow_director_ip_src,
9612 (void *)&cmd_flow_director_dst,
9613 (void *)&cmd_flow_director_ip_dst,
9614 (void *)&cmd_flow_director_tos,
9615 (void *)&cmd_flow_director_tos_value,
9616 (void *)&cmd_flow_director_proto,
9617 (void *)&cmd_flow_director_proto_value,
9618 (void *)&cmd_flow_director_ttl,
9619 (void *)&cmd_flow_director_ttl_value,
9620 (void *)&cmd_flow_director_vlan,
9621 (void *)&cmd_flow_director_vlan_value,
9622 (void *)&cmd_flow_director_flexbytes,
9623 (void *)&cmd_flow_director_flexbytes_value,
9624 (void *)&cmd_flow_director_drop,
9625 (void *)&cmd_flow_director_pf_vf,
9626 (void *)&cmd_flow_director_queue,
9627 (void *)&cmd_flow_director_queue_id,
9628 (void *)&cmd_flow_director_fd_id,
9629 (void *)&cmd_flow_director_fd_id_value,
9634 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9635 .f = cmd_flow_director_filter_parsed,
9637 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9638 "director entry on NIC",
9640 (void *)&cmd_flow_director_filter,
9641 (void *)&cmd_flow_director_port_id,
9642 (void *)&cmd_flow_director_mode,
9643 (void *)&cmd_flow_director_mode_ip,
9644 (void *)&cmd_flow_director_ops,
9645 (void *)&cmd_flow_director_flow,
9646 (void *)&cmd_flow_director_flow_type,
9647 (void *)&cmd_flow_director_src,
9648 (void *)&cmd_flow_director_ip_src,
9649 (void *)&cmd_flow_director_port_src,
9650 (void *)&cmd_flow_director_dst,
9651 (void *)&cmd_flow_director_ip_dst,
9652 (void *)&cmd_flow_director_port_dst,
9653 (void *)&cmd_flow_director_tos,
9654 (void *)&cmd_flow_director_tos_value,
9655 (void *)&cmd_flow_director_ttl,
9656 (void *)&cmd_flow_director_ttl_value,
9657 (void *)&cmd_flow_director_vlan,
9658 (void *)&cmd_flow_director_vlan_value,
9659 (void *)&cmd_flow_director_flexbytes,
9660 (void *)&cmd_flow_director_flexbytes_value,
9661 (void *)&cmd_flow_director_drop,
9662 (void *)&cmd_flow_director_pf_vf,
9663 (void *)&cmd_flow_director_queue,
9664 (void *)&cmd_flow_director_queue_id,
9665 (void *)&cmd_flow_director_fd_id,
9666 (void *)&cmd_flow_director_fd_id_value,
9671 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9672 .f = cmd_flow_director_filter_parsed,
9674 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9675 "director entry on NIC",
9677 (void *)&cmd_flow_director_filter,
9678 (void *)&cmd_flow_director_port_id,
9679 (void *)&cmd_flow_director_mode,
9680 (void *)&cmd_flow_director_mode_ip,
9681 (void *)&cmd_flow_director_ops,
9682 (void *)&cmd_flow_director_flow,
9683 (void *)&cmd_flow_director_flow_type,
9684 (void *)&cmd_flow_director_src,
9685 (void *)&cmd_flow_director_ip_src,
9686 (void *)&cmd_flow_director_port_dst,
9687 (void *)&cmd_flow_director_dst,
9688 (void *)&cmd_flow_director_ip_dst,
9689 (void *)&cmd_flow_director_port_dst,
9690 (void *)&cmd_flow_director_verify_tag,
9691 (void *)&cmd_flow_director_verify_tag_value,
9692 (void *)&cmd_flow_director_tos,
9693 (void *)&cmd_flow_director_tos_value,
9694 (void *)&cmd_flow_director_ttl,
9695 (void *)&cmd_flow_director_ttl_value,
9696 (void *)&cmd_flow_director_vlan,
9697 (void *)&cmd_flow_director_vlan_value,
9698 (void *)&cmd_flow_director_flexbytes,
9699 (void *)&cmd_flow_director_flexbytes_value,
9700 (void *)&cmd_flow_director_drop,
9701 (void *)&cmd_flow_director_pf_vf,
9702 (void *)&cmd_flow_director_queue,
9703 (void *)&cmd_flow_director_queue_id,
9704 (void *)&cmd_flow_director_fd_id,
9705 (void *)&cmd_flow_director_fd_id_value,
9710 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9711 .f = cmd_flow_director_filter_parsed,
9713 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9714 "director entry on NIC",
9716 (void *)&cmd_flow_director_filter,
9717 (void *)&cmd_flow_director_port_id,
9718 (void *)&cmd_flow_director_mode,
9719 (void *)&cmd_flow_director_mode_ip,
9720 (void *)&cmd_flow_director_ops,
9721 (void *)&cmd_flow_director_flow,
9722 (void *)&cmd_flow_director_flow_type,
9723 (void *)&cmd_flow_director_ether,
9724 (void *)&cmd_flow_director_ether_type,
9725 (void *)&cmd_flow_director_flexbytes,
9726 (void *)&cmd_flow_director_flexbytes_value,
9727 (void *)&cmd_flow_director_drop,
9728 (void *)&cmd_flow_director_pf_vf,
9729 (void *)&cmd_flow_director_queue,
9730 (void *)&cmd_flow_director_queue_id,
9731 (void *)&cmd_flow_director_fd_id,
9732 (void *)&cmd_flow_director_fd_id_value,
9737 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9738 .f = cmd_flow_director_filter_parsed,
9740 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9741 "director entry on NIC",
9743 (void *)&cmd_flow_director_filter,
9744 (void *)&cmd_flow_director_port_id,
9745 (void *)&cmd_flow_director_mode,
9746 (void *)&cmd_flow_director_mode_mac_vlan,
9747 (void *)&cmd_flow_director_ops,
9748 (void *)&cmd_flow_director_mac,
9749 (void *)&cmd_flow_director_mac_addr,
9750 (void *)&cmd_flow_director_vlan,
9751 (void *)&cmd_flow_director_vlan_value,
9752 (void *)&cmd_flow_director_flexbytes,
9753 (void *)&cmd_flow_director_flexbytes_value,
9754 (void *)&cmd_flow_director_drop,
9755 (void *)&cmd_flow_director_queue,
9756 (void *)&cmd_flow_director_queue_id,
9757 (void *)&cmd_flow_director_fd_id,
9758 (void *)&cmd_flow_director_fd_id_value,
9763 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9764 .f = cmd_flow_director_filter_parsed,
9766 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9767 "director entry on NIC",
9769 (void *)&cmd_flow_director_filter,
9770 (void *)&cmd_flow_director_port_id,
9771 (void *)&cmd_flow_director_mode,
9772 (void *)&cmd_flow_director_mode_tunnel,
9773 (void *)&cmd_flow_director_ops,
9774 (void *)&cmd_flow_director_mac,
9775 (void *)&cmd_flow_director_mac_addr,
9776 (void *)&cmd_flow_director_vlan,
9777 (void *)&cmd_flow_director_vlan_value,
9778 (void *)&cmd_flow_director_tunnel,
9779 (void *)&cmd_flow_director_tunnel_type,
9780 (void *)&cmd_flow_director_tunnel_id,
9781 (void *)&cmd_flow_director_tunnel_id_value,
9782 (void *)&cmd_flow_director_flexbytes,
9783 (void *)&cmd_flow_director_flexbytes_value,
9784 (void *)&cmd_flow_director_drop,
9785 (void *)&cmd_flow_director_queue,
9786 (void *)&cmd_flow_director_queue_id,
9787 (void *)&cmd_flow_director_fd_id,
9788 (void *)&cmd_flow_director_fd_id_value,
9793 struct cmd_flush_flow_director_result {
9794 cmdline_fixed_string_t flush_flow_director;
9798 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9799 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9800 flush_flow_director, "flush_flow_director");
9801 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9802 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9806 cmd_flush_flow_director_parsed(void *parsed_result,
9807 __attribute__((unused)) struct cmdline *cl,
9808 __attribute__((unused)) void *data)
9810 struct cmd_flow_director_result *res = parsed_result;
9813 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9815 printf("flow director is not supported on port %u.\n",
9820 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9821 RTE_ETH_FILTER_FLUSH, NULL);
9823 printf("flow director table flushing error: (%s)\n",
9827 cmdline_parse_inst_t cmd_flush_flow_director = {
9828 .f = cmd_flush_flow_director_parsed,
9830 .help_str = "flush_flow_director <port_id>: "
9831 "Flush all flow director entries of a device on NIC",
9833 (void *)&cmd_flush_flow_director_flush,
9834 (void *)&cmd_flush_flow_director_port_id,
9839 /* *** deal with flow director mask *** */
9840 struct cmd_flow_director_mask_result {
9841 cmdline_fixed_string_t flow_director_mask;
9843 cmdline_fixed_string_t mode;
9844 cmdline_fixed_string_t mode_value;
9845 cmdline_fixed_string_t vlan;
9847 cmdline_fixed_string_t src_mask;
9848 cmdline_ipaddr_t ipv4_src;
9849 cmdline_ipaddr_t ipv6_src;
9851 cmdline_fixed_string_t dst_mask;
9852 cmdline_ipaddr_t ipv4_dst;
9853 cmdline_ipaddr_t ipv6_dst;
9855 cmdline_fixed_string_t mac;
9856 uint8_t mac_addr_byte_mask;
9857 cmdline_fixed_string_t tunnel_id;
9858 uint32_t tunnel_id_mask;
9859 cmdline_fixed_string_t tunnel_type;
9860 uint8_t tunnel_type_mask;
9864 cmd_flow_director_mask_parsed(void *parsed_result,
9865 __attribute__((unused)) struct cmdline *cl,
9866 __attribute__((unused)) void *data)
9868 struct cmd_flow_director_mask_result *res = parsed_result;
9869 struct rte_eth_fdir_masks *mask;
9870 struct rte_port *port;
9872 if (res->port_id > nb_ports) {
9873 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9877 port = &ports[res->port_id];
9878 /** Check if the port is not started **/
9879 if (port->port_status != RTE_PORT_STOPPED) {
9880 printf("Please stop port %d first\n", res->port_id);
9884 mask = &port->dev_conf.fdir_conf.mask;
9886 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9887 if (strcmp(res->mode_value, "MAC-VLAN")) {
9888 printf("Please set mode to MAC-VLAN.\n");
9892 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9893 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9894 if (strcmp(res->mode_value, "Tunnel")) {
9895 printf("Please set mode to Tunnel.\n");
9899 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9900 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9901 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9902 mask->tunnel_type_mask = res->tunnel_type_mask;
9904 if (strcmp(res->mode_value, "IP")) {
9905 printf("Please set mode to IP.\n");
9909 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9910 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9911 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9912 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9913 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9914 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9915 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9918 cmd_reconfig_device_queue(res->port_id, 1, 1);
9921 cmdline_parse_token_string_t cmd_flow_director_mask =
9922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9923 flow_director_mask, "flow_director_mask");
9924 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9925 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9927 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9930 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9931 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9933 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9935 src_mask, "src_mask");
9936 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9937 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9939 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9940 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9942 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9943 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9945 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9947 dst_mask, "dst_mask");
9948 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9949 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9951 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9952 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9954 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9955 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9958 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9961 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9964 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9966 mode_value, "MAC-VLAN");
9967 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9969 mode_value, "Tunnel");
9970 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9973 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9974 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9975 mac_addr_byte_mask, UINT8);
9976 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9978 tunnel_type, "tunnel-type");
9979 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9980 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9981 tunnel_type_mask, UINT8);
9982 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9984 tunnel_id, "tunnel-id");
9985 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9986 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9987 tunnel_id_mask, UINT32);
9989 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9990 .f = cmd_flow_director_mask_parsed,
9992 .help_str = "flow_director_mask ... : "
9993 "Set IP mode flow director's mask on NIC",
9995 (void *)&cmd_flow_director_mask,
9996 (void *)&cmd_flow_director_mask_port_id,
9997 (void *)&cmd_flow_director_mask_mode,
9998 (void *)&cmd_flow_director_mask_mode_ip,
9999 (void *)&cmd_flow_director_mask_vlan,
10000 (void *)&cmd_flow_director_mask_vlan_value,
10001 (void *)&cmd_flow_director_mask_src,
10002 (void *)&cmd_flow_director_mask_ipv4_src,
10003 (void *)&cmd_flow_director_mask_ipv6_src,
10004 (void *)&cmd_flow_director_mask_port_src,
10005 (void *)&cmd_flow_director_mask_dst,
10006 (void *)&cmd_flow_director_mask_ipv4_dst,
10007 (void *)&cmd_flow_director_mask_ipv6_dst,
10008 (void *)&cmd_flow_director_mask_port_dst,
10013 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10014 .f = cmd_flow_director_mask_parsed,
10016 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10017 "flow director's mask on NIC",
10019 (void *)&cmd_flow_director_mask,
10020 (void *)&cmd_flow_director_mask_port_id,
10021 (void *)&cmd_flow_director_mask_mode,
10022 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10023 (void *)&cmd_flow_director_mask_vlan,
10024 (void *)&cmd_flow_director_mask_vlan_value,
10029 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10030 .f = cmd_flow_director_mask_parsed,
10032 .help_str = "flow_director_mask ... : Set tunnel mode "
10033 "flow director's mask on NIC",
10035 (void *)&cmd_flow_director_mask,
10036 (void *)&cmd_flow_director_mask_port_id,
10037 (void *)&cmd_flow_director_mask_mode,
10038 (void *)&cmd_flow_director_mask_mode_tunnel,
10039 (void *)&cmd_flow_director_mask_vlan,
10040 (void *)&cmd_flow_director_mask_vlan_value,
10041 (void *)&cmd_flow_director_mask_mac,
10042 (void *)&cmd_flow_director_mask_mac_value,
10043 (void *)&cmd_flow_director_mask_tunnel_type,
10044 (void *)&cmd_flow_director_mask_tunnel_type_value,
10045 (void *)&cmd_flow_director_mask_tunnel_id,
10046 (void *)&cmd_flow_director_mask_tunnel_id_value,
10051 /* *** deal with flow director mask on flexible payload *** */
10052 struct cmd_flow_director_flex_mask_result {
10053 cmdline_fixed_string_t flow_director_flexmask;
10055 cmdline_fixed_string_t flow;
10056 cmdline_fixed_string_t flow_type;
10057 cmdline_fixed_string_t mask;
10061 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10062 __attribute__((unused)) struct cmdline *cl,
10063 __attribute__((unused)) void *data)
10065 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10066 struct rte_eth_fdir_info fdir_info;
10067 struct rte_eth_fdir_flex_mask flex_mask;
10068 struct rte_port *port;
10069 uint32_t flow_type_mask;
10073 if (res->port_id > nb_ports) {
10074 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10078 port = &ports[res->port_id];
10079 /** Check if the port is not started **/
10080 if (port->port_status != RTE_PORT_STOPPED) {
10081 printf("Please stop port %d first\n", res->port_id);
10085 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10086 ret = parse_flexbytes(res->mask,
10088 RTE_ETH_FDIR_MAX_FLEXLEN);
10090 printf("error: Cannot parse mask input.\n");
10094 memset(&fdir_info, 0, sizeof(fdir_info));
10095 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10096 RTE_ETH_FILTER_INFO, &fdir_info);
10098 printf("Cannot get FDir filter info\n");
10102 if (!strcmp(res->flow_type, "none")) {
10103 /* means don't specify the flow type */
10104 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10105 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10106 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10107 0, sizeof(struct rte_eth_fdir_flex_mask));
10108 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10109 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10111 sizeof(struct rte_eth_fdir_flex_mask));
10112 cmd_reconfig_device_queue(res->port_id, 1, 1);
10115 flow_type_mask = fdir_info.flow_types_mask[0];
10116 if (!strcmp(res->flow_type, "all")) {
10117 if (!flow_type_mask) {
10118 printf("No flow type supported\n");
10121 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10122 if (flow_type_mask & (1 << i)) {
10123 flex_mask.flow_type = i;
10124 fdir_set_flex_mask(res->port_id, &flex_mask);
10127 cmd_reconfig_device_queue(res->port_id, 1, 1);
10130 flex_mask.flow_type = str2flowtype(res->flow_type);
10131 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10132 printf("Flow type %s not supported on port %d\n",
10133 res->flow_type, res->port_id);
10136 fdir_set_flex_mask(res->port_id, &flex_mask);
10137 cmd_reconfig_device_queue(res->port_id, 1, 1);
10140 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10142 flow_director_flexmask,
10143 "flow_director_flex_mask");
10144 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10145 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10147 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10148 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10150 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10152 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10153 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10154 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10158 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10159 .f = cmd_flow_director_flex_mask_parsed,
10161 .help_str = "flow_director_flex_mask ... : "
10162 "Set flow director's flex mask on NIC",
10164 (void *)&cmd_flow_director_flexmask,
10165 (void *)&cmd_flow_director_flexmask_port_id,
10166 (void *)&cmd_flow_director_flexmask_flow,
10167 (void *)&cmd_flow_director_flexmask_flow_type,
10168 (void *)&cmd_flow_director_flexmask_mask,
10173 /* *** deal with flow director flexible payload configuration *** */
10174 struct cmd_flow_director_flexpayload_result {
10175 cmdline_fixed_string_t flow_director_flexpayload;
10177 cmdline_fixed_string_t payload_layer;
10178 cmdline_fixed_string_t payload_cfg;
10182 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10185 const char *p, *p0 = q_arg;
10187 unsigned long int_fld;
10188 char *str_fld[max_num];
10193 p = strchr(p0, '(');
10197 p0 = strchr(p, ')');
10202 if (size >= sizeof(s))
10205 snprintf(s, sizeof(s), "%.*s", size, p);
10206 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10207 if (ret < 0 || ret > max_num)
10209 for (i = 0; i < ret; i++) {
10211 int_fld = strtoul(str_fld[i], &end, 0);
10212 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10214 offsets[i] = (uint16_t)int_fld;
10220 cmd_flow_director_flxpld_parsed(void *parsed_result,
10221 __attribute__((unused)) struct cmdline *cl,
10222 __attribute__((unused)) void *data)
10224 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10225 struct rte_eth_flex_payload_cfg flex_cfg;
10226 struct rte_port *port;
10229 if (res->port_id > nb_ports) {
10230 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10234 port = &ports[res->port_id];
10235 /** Check if the port is not started **/
10236 if (port->port_status != RTE_PORT_STOPPED) {
10237 printf("Please stop port %d first\n", res->port_id);
10241 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10243 if (!strcmp(res->payload_layer, "raw"))
10244 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10245 else if (!strcmp(res->payload_layer, "l2"))
10246 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10247 else if (!strcmp(res->payload_layer, "l3"))
10248 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10249 else if (!strcmp(res->payload_layer, "l4"))
10250 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10252 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10253 RTE_ETH_FDIR_MAX_FLEXLEN);
10255 printf("error: Cannot parse flex payload input.\n");
10259 fdir_set_flex_payload(res->port_id, &flex_cfg);
10260 cmd_reconfig_device_queue(res->port_id, 1, 1);
10263 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10265 flow_director_flexpayload,
10266 "flow_director_flex_payload");
10267 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10268 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10270 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10272 payload_layer, "raw#l2#l3#l4");
10273 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10275 payload_cfg, NULL);
10277 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10278 .f = cmd_flow_director_flxpld_parsed,
10280 .help_str = "flow_director_flexpayload ... : "
10281 "Set flow director's flex payload on NIC",
10283 (void *)&cmd_flow_director_flexpayload,
10284 (void *)&cmd_flow_director_flexpayload_port_id,
10285 (void *)&cmd_flow_director_flexpayload_payload_layer,
10286 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10291 /* Generic flow interface command. */
10292 extern cmdline_parse_inst_t cmd_flow;
10294 /* *** Classification Filters Control *** */
10295 /* *** Get symmetric hash enable per port *** */
10296 struct cmd_get_sym_hash_ena_per_port_result {
10297 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10302 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10303 __rte_unused struct cmdline *cl,
10304 __rte_unused void *data)
10306 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10307 struct rte_eth_hash_filter_info info;
10310 if (rte_eth_dev_filter_supported(res->port_id,
10311 RTE_ETH_FILTER_HASH) < 0) {
10312 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10317 memset(&info, 0, sizeof(info));
10318 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10319 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10320 RTE_ETH_FILTER_GET, &info);
10323 printf("Cannot get symmetric hash enable per port "
10324 "on port %u\n", res->port_id);
10328 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10329 "enabled" : "disabled", res->port_id);
10332 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10333 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10334 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10335 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10336 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10339 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10340 .f = cmd_get_sym_hash_per_port_parsed,
10342 .help_str = "get_sym_hash_ena_per_port <port_id>",
10344 (void *)&cmd_get_sym_hash_ena_per_port_all,
10345 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10350 /* *** Set symmetric hash enable per port *** */
10351 struct cmd_set_sym_hash_ena_per_port_result {
10352 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10353 cmdline_fixed_string_t enable;
10358 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10359 __rte_unused struct cmdline *cl,
10360 __rte_unused void *data)
10362 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10363 struct rte_eth_hash_filter_info info;
10366 if (rte_eth_dev_filter_supported(res->port_id,
10367 RTE_ETH_FILTER_HASH) < 0) {
10368 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10373 memset(&info, 0, sizeof(info));
10374 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10375 if (!strcmp(res->enable, "enable"))
10376 info.info.enable = 1;
10377 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10378 RTE_ETH_FILTER_SET, &info);
10380 printf("Cannot set symmetric hash enable per port on "
10381 "port %u\n", res->port_id);
10384 printf("Symmetric hash has been set to %s on port %u\n",
10385 res->enable, res->port_id);
10388 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10389 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10390 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10391 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10392 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10394 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10395 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10396 enable, "enable#disable");
10398 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10399 .f = cmd_set_sym_hash_per_port_parsed,
10401 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10403 (void *)&cmd_set_sym_hash_ena_per_port_all,
10404 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10405 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10410 /* Get global config of hash function */
10411 struct cmd_get_hash_global_config_result {
10412 cmdline_fixed_string_t get_hash_global_config;
10417 flowtype_to_str(uint16_t ftype)
10423 } ftype_table[] = {
10424 {"ipv4", RTE_ETH_FLOW_IPV4},
10425 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10426 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10427 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10428 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10429 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10430 {"ipv6", RTE_ETH_FLOW_IPV6},
10431 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10432 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10433 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10434 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10435 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10436 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10437 {"port", RTE_ETH_FLOW_PORT},
10438 {"vxlan", RTE_ETH_FLOW_VXLAN},
10439 {"geneve", RTE_ETH_FLOW_GENEVE},
10440 {"nvgre", RTE_ETH_FLOW_NVGRE},
10443 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10444 if (ftype_table[i].ftype == ftype)
10445 return ftype_table[i].str;
10452 cmd_get_hash_global_config_parsed(void *parsed_result,
10453 __rte_unused struct cmdline *cl,
10454 __rte_unused void *data)
10456 struct cmd_get_hash_global_config_result *res = parsed_result;
10457 struct rte_eth_hash_filter_info info;
10458 uint32_t idx, offset;
10463 if (rte_eth_dev_filter_supported(res->port_id,
10464 RTE_ETH_FILTER_HASH) < 0) {
10465 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10470 memset(&info, 0, sizeof(info));
10471 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10472 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10473 RTE_ETH_FILTER_GET, &info);
10475 printf("Cannot get hash global configurations by port %d\n",
10480 switch (info.info.global_conf.hash_func) {
10481 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10482 printf("Hash function is Toeplitz\n");
10484 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10485 printf("Hash function is Simple XOR\n");
10488 printf("Unknown hash function\n");
10492 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10493 idx = i / UINT32_BIT;
10494 offset = i % UINT32_BIT;
10495 if (!(info.info.global_conf.valid_bit_mask[idx] &
10498 str = flowtype_to_str(i);
10501 printf("Symmetric hash is %s globally for flow type %s "
10503 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10504 (1UL << offset)) ? "enabled" : "disabled"), str,
10509 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10510 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10511 get_hash_global_config, "get_hash_global_config");
10512 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10513 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10516 cmdline_parse_inst_t cmd_get_hash_global_config = {
10517 .f = cmd_get_hash_global_config_parsed,
10519 .help_str = "get_hash_global_config <port_id>",
10521 (void *)&cmd_get_hash_global_config_all,
10522 (void *)&cmd_get_hash_global_config_port_id,
10527 /* Set global config of hash function */
10528 struct cmd_set_hash_global_config_result {
10529 cmdline_fixed_string_t set_hash_global_config;
10531 cmdline_fixed_string_t hash_func;
10532 cmdline_fixed_string_t flow_type;
10533 cmdline_fixed_string_t enable;
10537 cmd_set_hash_global_config_parsed(void *parsed_result,
10538 __rte_unused struct cmdline *cl,
10539 __rte_unused void *data)
10541 struct cmd_set_hash_global_config_result *res = parsed_result;
10542 struct rte_eth_hash_filter_info info;
10543 uint32_t ftype, idx, offset;
10546 if (rte_eth_dev_filter_supported(res->port_id,
10547 RTE_ETH_FILTER_HASH) < 0) {
10548 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10552 memset(&info, 0, sizeof(info));
10553 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10554 if (!strcmp(res->hash_func, "toeplitz"))
10555 info.info.global_conf.hash_func =
10556 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10557 else if (!strcmp(res->hash_func, "simple_xor"))
10558 info.info.global_conf.hash_func =
10559 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10560 else if (!strcmp(res->hash_func, "default"))
10561 info.info.global_conf.hash_func =
10562 RTE_ETH_HASH_FUNCTION_DEFAULT;
10564 ftype = str2flowtype(res->flow_type);
10565 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10566 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10567 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10568 if (!strcmp(res->enable, "enable"))
10569 info.info.global_conf.sym_hash_enable_mask[idx] |=
10571 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10572 RTE_ETH_FILTER_SET, &info);
10574 printf("Cannot set global hash configurations by port %d\n",
10577 printf("Global hash configurations have been set "
10578 "succcessfully by port %d\n", res->port_id);
10581 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10582 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10583 set_hash_global_config, "set_hash_global_config");
10584 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10585 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10587 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10588 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10589 hash_func, "toeplitz#simple_xor#default");
10590 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10591 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10593 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10594 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10595 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10596 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10597 enable, "enable#disable");
10599 cmdline_parse_inst_t cmd_set_hash_global_config = {
10600 .f = cmd_set_hash_global_config_parsed,
10602 .help_str = "set_hash_global_config <port_id> "
10603 "toeplitz|simple_xor|default "
10604 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10605 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10606 "l2_payload enable|disable",
10608 (void *)&cmd_set_hash_global_config_all,
10609 (void *)&cmd_set_hash_global_config_port_id,
10610 (void *)&cmd_set_hash_global_config_hash_func,
10611 (void *)&cmd_set_hash_global_config_flow_type,
10612 (void *)&cmd_set_hash_global_config_enable,
10617 /* Set hash input set */
10618 struct cmd_set_hash_input_set_result {
10619 cmdline_fixed_string_t set_hash_input_set;
10621 cmdline_fixed_string_t flow_type;
10622 cmdline_fixed_string_t inset_field;
10623 cmdline_fixed_string_t select;
10626 static enum rte_eth_input_set_field
10627 str2inset(char *string)
10631 static const struct {
10633 enum rte_eth_input_set_field inset;
10634 } inset_table[] = {
10635 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10636 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10637 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10638 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10639 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10640 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10641 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10642 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10643 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10644 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10645 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10646 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10647 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10648 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10649 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10650 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10651 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10652 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10653 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10654 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10655 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10656 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10657 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10658 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10659 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10660 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10661 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10662 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10663 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10664 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10665 {"none", RTE_ETH_INPUT_SET_NONE},
10668 for (i = 0; i < RTE_DIM(inset_table); i++) {
10669 if (!strcmp(string, inset_table[i].str))
10670 return inset_table[i].inset;
10673 return RTE_ETH_INPUT_SET_UNKNOWN;
10677 cmd_set_hash_input_set_parsed(void *parsed_result,
10678 __rte_unused struct cmdline *cl,
10679 __rte_unused void *data)
10681 struct cmd_set_hash_input_set_result *res = parsed_result;
10682 struct rte_eth_hash_filter_info info;
10684 memset(&info, 0, sizeof(info));
10685 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10686 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10687 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10688 info.info.input_set_conf.inset_size = 1;
10689 if (!strcmp(res->select, "select"))
10690 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10691 else if (!strcmp(res->select, "add"))
10692 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10693 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10694 RTE_ETH_FILTER_SET, &info);
10697 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10698 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10699 set_hash_input_set, "set_hash_input_set");
10700 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10701 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10703 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10704 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10706 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10707 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10709 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10710 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10711 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10712 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10713 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10715 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10716 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10717 select, "select#add");
10719 cmdline_parse_inst_t cmd_set_hash_input_set = {
10720 .f = cmd_set_hash_input_set_parsed,
10722 .help_str = "set_hash_input_set <port_id> "
10723 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10724 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
10725 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10726 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10727 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10728 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10729 "fld-7th|fld-8th|none select|add",
10731 (void *)&cmd_set_hash_input_set_cmd,
10732 (void *)&cmd_set_hash_input_set_port_id,
10733 (void *)&cmd_set_hash_input_set_flow_type,
10734 (void *)&cmd_set_hash_input_set_field,
10735 (void *)&cmd_set_hash_input_set_select,
10740 /* Set flow director input set */
10741 struct cmd_set_fdir_input_set_result {
10742 cmdline_fixed_string_t set_fdir_input_set;
10744 cmdline_fixed_string_t flow_type;
10745 cmdline_fixed_string_t inset_field;
10746 cmdline_fixed_string_t select;
10750 cmd_set_fdir_input_set_parsed(void *parsed_result,
10751 __rte_unused struct cmdline *cl,
10752 __rte_unused void *data)
10754 struct cmd_set_fdir_input_set_result *res = parsed_result;
10755 struct rte_eth_fdir_filter_info info;
10757 memset(&info, 0, sizeof(info));
10758 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10759 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10760 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10761 info.info.input_set_conf.inset_size = 1;
10762 if (!strcmp(res->select, "select"))
10763 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10764 else if (!strcmp(res->select, "add"))
10765 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10766 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10767 RTE_ETH_FILTER_SET, &info);
10770 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10771 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10772 set_fdir_input_set, "set_fdir_input_set");
10773 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10774 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10776 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10777 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10779 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10780 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10781 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10782 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10784 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10785 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10786 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10787 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10788 "sctp-veri-tag#none");
10789 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10790 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10791 select, "select#add");
10793 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10794 .f = cmd_set_fdir_input_set_parsed,
10796 .help_str = "set_fdir_input_set <port_id> "
10797 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10798 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10799 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10800 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10801 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10802 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10803 "sctp-veri-tag|none select|add",
10805 (void *)&cmd_set_fdir_input_set_cmd,
10806 (void *)&cmd_set_fdir_input_set_port_id,
10807 (void *)&cmd_set_fdir_input_set_flow_type,
10808 (void *)&cmd_set_fdir_input_set_field,
10809 (void *)&cmd_set_fdir_input_set_select,
10814 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10815 struct cmd_mcast_addr_result {
10816 cmdline_fixed_string_t mcast_addr_cmd;
10817 cmdline_fixed_string_t what;
10819 struct ether_addr mc_addr;
10822 static void cmd_mcast_addr_parsed(void *parsed_result,
10823 __attribute__((unused)) struct cmdline *cl,
10824 __attribute__((unused)) void *data)
10826 struct cmd_mcast_addr_result *res = parsed_result;
10828 if (!is_multicast_ether_addr(&res->mc_addr)) {
10829 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10830 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10831 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10832 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10835 if (strcmp(res->what, "add") == 0)
10836 mcast_addr_add(res->port_num, &res->mc_addr);
10838 mcast_addr_remove(res->port_num, &res->mc_addr);
10841 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10842 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10843 mcast_addr_cmd, "mcast_addr");
10844 cmdline_parse_token_string_t cmd_mcast_addr_what =
10845 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10847 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10848 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10849 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10850 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10852 cmdline_parse_inst_t cmd_mcast_addr = {
10853 .f = cmd_mcast_addr_parsed,
10855 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10856 "Add/Remove multicast MAC address on port_id",
10858 (void *)&cmd_mcast_addr_cmd,
10859 (void *)&cmd_mcast_addr_what,
10860 (void *)&cmd_mcast_addr_portnum,
10861 (void *)&cmd_mcast_addr_addr,
10866 /* l2 tunnel config
10867 * only support E-tag now.
10870 /* Ether type config */
10871 struct cmd_config_l2_tunnel_eth_type_result {
10872 cmdline_fixed_string_t port;
10873 cmdline_fixed_string_t config;
10874 cmdline_fixed_string_t all;
10876 cmdline_fixed_string_t l2_tunnel;
10877 cmdline_fixed_string_t l2_tunnel_type;
10878 cmdline_fixed_string_t eth_type;
10879 uint16_t eth_type_val;
10882 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10883 TOKEN_STRING_INITIALIZER
10884 (struct cmd_config_l2_tunnel_eth_type_result,
10886 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10887 TOKEN_STRING_INITIALIZER
10888 (struct cmd_config_l2_tunnel_eth_type_result,
10890 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10891 TOKEN_STRING_INITIALIZER
10892 (struct cmd_config_l2_tunnel_eth_type_result,
10894 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10895 TOKEN_NUM_INITIALIZER
10896 (struct cmd_config_l2_tunnel_eth_type_result,
10898 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10899 TOKEN_STRING_INITIALIZER
10900 (struct cmd_config_l2_tunnel_eth_type_result,
10901 l2_tunnel, "l2-tunnel");
10902 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10903 TOKEN_STRING_INITIALIZER
10904 (struct cmd_config_l2_tunnel_eth_type_result,
10905 l2_tunnel_type, "E-tag");
10906 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10907 TOKEN_STRING_INITIALIZER
10908 (struct cmd_config_l2_tunnel_eth_type_result,
10909 eth_type, "ether-type");
10910 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10911 TOKEN_NUM_INITIALIZER
10912 (struct cmd_config_l2_tunnel_eth_type_result,
10913 eth_type_val, UINT16);
10915 static enum rte_eth_tunnel_type
10916 str2fdir_l2_tunnel_type(char *string)
10920 static const struct {
10922 enum rte_eth_tunnel_type type;
10923 } l2_tunnel_type_str[] = {
10924 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10927 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10928 if (!strcmp(l2_tunnel_type_str[i].str, string))
10929 return l2_tunnel_type_str[i].type;
10931 return RTE_TUNNEL_TYPE_NONE;
10934 /* ether type config for all ports */
10936 cmd_config_l2_tunnel_eth_type_all_parsed
10937 (void *parsed_result,
10938 __attribute__((unused)) struct cmdline *cl,
10939 __attribute__((unused)) void *data)
10941 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10942 struct rte_eth_l2_tunnel_conf entry;
10945 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10946 entry.ether_type = res->eth_type_val;
10948 RTE_ETH_FOREACH_DEV(pid) {
10949 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10953 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10954 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10956 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10958 (void *)&cmd_config_l2_tunnel_eth_type_port,
10959 (void *)&cmd_config_l2_tunnel_eth_type_config,
10960 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10961 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10962 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10963 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10964 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10969 /* ether type config for a specific port */
10971 cmd_config_l2_tunnel_eth_type_specific_parsed(
10972 void *parsed_result,
10973 __attribute__((unused)) struct cmdline *cl,
10974 __attribute__((unused)) void *data)
10976 struct cmd_config_l2_tunnel_eth_type_result *res =
10978 struct rte_eth_l2_tunnel_conf entry;
10980 if (port_id_is_invalid(res->id, ENABLED_WARN))
10983 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10984 entry.ether_type = res->eth_type_val;
10986 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10989 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10990 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10992 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10994 (void *)&cmd_config_l2_tunnel_eth_type_port,
10995 (void *)&cmd_config_l2_tunnel_eth_type_config,
10996 (void *)&cmd_config_l2_tunnel_eth_type_id,
10997 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10998 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10999 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11000 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11005 /* Enable/disable l2 tunnel */
11006 struct cmd_config_l2_tunnel_en_dis_result {
11007 cmdline_fixed_string_t port;
11008 cmdline_fixed_string_t config;
11009 cmdline_fixed_string_t all;
11011 cmdline_fixed_string_t l2_tunnel;
11012 cmdline_fixed_string_t l2_tunnel_type;
11013 cmdline_fixed_string_t en_dis;
11016 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11017 TOKEN_STRING_INITIALIZER
11018 (struct cmd_config_l2_tunnel_en_dis_result,
11020 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11021 TOKEN_STRING_INITIALIZER
11022 (struct cmd_config_l2_tunnel_en_dis_result,
11024 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11025 TOKEN_STRING_INITIALIZER
11026 (struct cmd_config_l2_tunnel_en_dis_result,
11028 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11029 TOKEN_NUM_INITIALIZER
11030 (struct cmd_config_l2_tunnel_en_dis_result,
11032 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11033 TOKEN_STRING_INITIALIZER
11034 (struct cmd_config_l2_tunnel_en_dis_result,
11035 l2_tunnel, "l2-tunnel");
11036 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11037 TOKEN_STRING_INITIALIZER
11038 (struct cmd_config_l2_tunnel_en_dis_result,
11039 l2_tunnel_type, "E-tag");
11040 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11041 TOKEN_STRING_INITIALIZER
11042 (struct cmd_config_l2_tunnel_en_dis_result,
11043 en_dis, "enable#disable");
11045 /* enable/disable l2 tunnel for all ports */
11047 cmd_config_l2_tunnel_en_dis_all_parsed(
11048 void *parsed_result,
11049 __attribute__((unused)) struct cmdline *cl,
11050 __attribute__((unused)) void *data)
11052 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11053 struct rte_eth_l2_tunnel_conf entry;
11057 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11059 if (!strcmp("enable", res->en_dis))
11064 RTE_ETH_FOREACH_DEV(pid) {
11065 rte_eth_dev_l2_tunnel_offload_set(pid,
11067 ETH_L2_TUNNEL_ENABLE_MASK,
11072 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11073 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11075 .help_str = "port config all l2-tunnel E-tag enable|disable",
11077 (void *)&cmd_config_l2_tunnel_en_dis_port,
11078 (void *)&cmd_config_l2_tunnel_en_dis_config,
11079 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11080 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11081 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11082 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11087 /* enable/disable l2 tunnel for a port */
11089 cmd_config_l2_tunnel_en_dis_specific_parsed(
11090 void *parsed_result,
11091 __attribute__((unused)) struct cmdline *cl,
11092 __attribute__((unused)) void *data)
11094 struct cmd_config_l2_tunnel_en_dis_result *res =
11096 struct rte_eth_l2_tunnel_conf entry;
11098 if (port_id_is_invalid(res->id, ENABLED_WARN))
11101 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11103 if (!strcmp("enable", res->en_dis))
11104 rte_eth_dev_l2_tunnel_offload_set(res->id,
11106 ETH_L2_TUNNEL_ENABLE_MASK,
11109 rte_eth_dev_l2_tunnel_offload_set(res->id,
11111 ETH_L2_TUNNEL_ENABLE_MASK,
11115 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11116 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11118 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11120 (void *)&cmd_config_l2_tunnel_en_dis_port,
11121 (void *)&cmd_config_l2_tunnel_en_dis_config,
11122 (void *)&cmd_config_l2_tunnel_en_dis_id,
11123 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11124 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11125 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11130 /* E-tag configuration */
11132 /* Common result structure for all E-tag configuration */
11133 struct cmd_config_e_tag_result {
11134 cmdline_fixed_string_t e_tag;
11135 cmdline_fixed_string_t set;
11136 cmdline_fixed_string_t insertion;
11137 cmdline_fixed_string_t stripping;
11138 cmdline_fixed_string_t forwarding;
11139 cmdline_fixed_string_t filter;
11140 cmdline_fixed_string_t add;
11141 cmdline_fixed_string_t del;
11142 cmdline_fixed_string_t on;
11143 cmdline_fixed_string_t off;
11144 cmdline_fixed_string_t on_off;
11145 cmdline_fixed_string_t port_tag_id;
11146 uint32_t port_tag_id_val;
11147 cmdline_fixed_string_t e_tag_id;
11148 uint16_t e_tag_id_val;
11149 cmdline_fixed_string_t dst_pool;
11150 uint8_t dst_pool_val;
11151 cmdline_fixed_string_t port;
11153 cmdline_fixed_string_t vf;
11157 /* Common CLI fields for all E-tag configuration */
11158 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11159 TOKEN_STRING_INITIALIZER
11160 (struct cmd_config_e_tag_result,
11162 cmdline_parse_token_string_t cmd_config_e_tag_set =
11163 TOKEN_STRING_INITIALIZER
11164 (struct cmd_config_e_tag_result,
11166 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11167 TOKEN_STRING_INITIALIZER
11168 (struct cmd_config_e_tag_result,
11169 insertion, "insertion");
11170 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11171 TOKEN_STRING_INITIALIZER
11172 (struct cmd_config_e_tag_result,
11173 stripping, "stripping");
11174 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11175 TOKEN_STRING_INITIALIZER
11176 (struct cmd_config_e_tag_result,
11177 forwarding, "forwarding");
11178 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11179 TOKEN_STRING_INITIALIZER
11180 (struct cmd_config_e_tag_result,
11182 cmdline_parse_token_string_t cmd_config_e_tag_add =
11183 TOKEN_STRING_INITIALIZER
11184 (struct cmd_config_e_tag_result,
11186 cmdline_parse_token_string_t cmd_config_e_tag_del =
11187 TOKEN_STRING_INITIALIZER
11188 (struct cmd_config_e_tag_result,
11190 cmdline_parse_token_string_t cmd_config_e_tag_on =
11191 TOKEN_STRING_INITIALIZER
11192 (struct cmd_config_e_tag_result,
11194 cmdline_parse_token_string_t cmd_config_e_tag_off =
11195 TOKEN_STRING_INITIALIZER
11196 (struct cmd_config_e_tag_result,
11198 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11199 TOKEN_STRING_INITIALIZER
11200 (struct cmd_config_e_tag_result,
11202 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11203 TOKEN_STRING_INITIALIZER
11204 (struct cmd_config_e_tag_result,
11205 port_tag_id, "port-tag-id");
11206 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11207 TOKEN_NUM_INITIALIZER
11208 (struct cmd_config_e_tag_result,
11209 port_tag_id_val, UINT32);
11210 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11211 TOKEN_STRING_INITIALIZER
11212 (struct cmd_config_e_tag_result,
11213 e_tag_id, "e-tag-id");
11214 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11215 TOKEN_NUM_INITIALIZER
11216 (struct cmd_config_e_tag_result,
11217 e_tag_id_val, UINT16);
11218 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11219 TOKEN_STRING_INITIALIZER
11220 (struct cmd_config_e_tag_result,
11221 dst_pool, "dst-pool");
11222 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11223 TOKEN_NUM_INITIALIZER
11224 (struct cmd_config_e_tag_result,
11225 dst_pool_val, UINT8);
11226 cmdline_parse_token_string_t cmd_config_e_tag_port =
11227 TOKEN_STRING_INITIALIZER
11228 (struct cmd_config_e_tag_result,
11230 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11231 TOKEN_NUM_INITIALIZER
11232 (struct cmd_config_e_tag_result,
11234 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11235 TOKEN_STRING_INITIALIZER
11236 (struct cmd_config_e_tag_result,
11238 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11239 TOKEN_NUM_INITIALIZER
11240 (struct cmd_config_e_tag_result,
11243 /* E-tag insertion configuration */
11245 cmd_config_e_tag_insertion_en_parsed(
11246 void *parsed_result,
11247 __attribute__((unused)) struct cmdline *cl,
11248 __attribute__((unused)) void *data)
11250 struct cmd_config_e_tag_result *res =
11252 struct rte_eth_l2_tunnel_conf entry;
11254 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11257 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11258 entry.tunnel_id = res->port_tag_id_val;
11259 entry.vf_id = res->vf_id;
11260 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11262 ETH_L2_TUNNEL_INSERTION_MASK,
11267 cmd_config_e_tag_insertion_dis_parsed(
11268 void *parsed_result,
11269 __attribute__((unused)) struct cmdline *cl,
11270 __attribute__((unused)) void *data)
11272 struct cmd_config_e_tag_result *res =
11274 struct rte_eth_l2_tunnel_conf entry;
11276 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11279 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11280 entry.vf_id = res->vf_id;
11282 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11284 ETH_L2_TUNNEL_INSERTION_MASK,
11288 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11289 .f = cmd_config_e_tag_insertion_en_parsed,
11291 .help_str = "E-tag ... : E-tag insertion enable",
11293 (void *)&cmd_config_e_tag_e_tag,
11294 (void *)&cmd_config_e_tag_set,
11295 (void *)&cmd_config_e_tag_insertion,
11296 (void *)&cmd_config_e_tag_on,
11297 (void *)&cmd_config_e_tag_port_tag_id,
11298 (void *)&cmd_config_e_tag_port_tag_id_val,
11299 (void *)&cmd_config_e_tag_port,
11300 (void *)&cmd_config_e_tag_port_id,
11301 (void *)&cmd_config_e_tag_vf,
11302 (void *)&cmd_config_e_tag_vf_id,
11307 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11308 .f = cmd_config_e_tag_insertion_dis_parsed,
11310 .help_str = "E-tag ... : E-tag insertion disable",
11312 (void *)&cmd_config_e_tag_e_tag,
11313 (void *)&cmd_config_e_tag_set,
11314 (void *)&cmd_config_e_tag_insertion,
11315 (void *)&cmd_config_e_tag_off,
11316 (void *)&cmd_config_e_tag_port,
11317 (void *)&cmd_config_e_tag_port_id,
11318 (void *)&cmd_config_e_tag_vf,
11319 (void *)&cmd_config_e_tag_vf_id,
11324 /* E-tag stripping configuration */
11326 cmd_config_e_tag_stripping_parsed(
11327 void *parsed_result,
11328 __attribute__((unused)) struct cmdline *cl,
11329 __attribute__((unused)) void *data)
11331 struct cmd_config_e_tag_result *res =
11333 struct rte_eth_l2_tunnel_conf entry;
11335 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11338 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11340 if (!strcmp(res->on_off, "on"))
11341 rte_eth_dev_l2_tunnel_offload_set
11344 ETH_L2_TUNNEL_STRIPPING_MASK,
11347 rte_eth_dev_l2_tunnel_offload_set
11350 ETH_L2_TUNNEL_STRIPPING_MASK,
11354 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11355 .f = cmd_config_e_tag_stripping_parsed,
11357 .help_str = "E-tag ... : E-tag stripping enable/disable",
11359 (void *)&cmd_config_e_tag_e_tag,
11360 (void *)&cmd_config_e_tag_set,
11361 (void *)&cmd_config_e_tag_stripping,
11362 (void *)&cmd_config_e_tag_on_off,
11363 (void *)&cmd_config_e_tag_port,
11364 (void *)&cmd_config_e_tag_port_id,
11369 /* E-tag forwarding configuration */
11371 cmd_config_e_tag_forwarding_parsed(
11372 void *parsed_result,
11373 __attribute__((unused)) struct cmdline *cl,
11374 __attribute__((unused)) void *data)
11376 struct cmd_config_e_tag_result *res = parsed_result;
11377 struct rte_eth_l2_tunnel_conf entry;
11379 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11382 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11384 if (!strcmp(res->on_off, "on"))
11385 rte_eth_dev_l2_tunnel_offload_set
11388 ETH_L2_TUNNEL_FORWARDING_MASK,
11391 rte_eth_dev_l2_tunnel_offload_set
11394 ETH_L2_TUNNEL_FORWARDING_MASK,
11398 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11399 .f = cmd_config_e_tag_forwarding_parsed,
11401 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11403 (void *)&cmd_config_e_tag_e_tag,
11404 (void *)&cmd_config_e_tag_set,
11405 (void *)&cmd_config_e_tag_forwarding,
11406 (void *)&cmd_config_e_tag_on_off,
11407 (void *)&cmd_config_e_tag_port,
11408 (void *)&cmd_config_e_tag_port_id,
11413 /* E-tag filter configuration */
11415 cmd_config_e_tag_filter_add_parsed(
11416 void *parsed_result,
11417 __attribute__((unused)) struct cmdline *cl,
11418 __attribute__((unused)) void *data)
11420 struct cmd_config_e_tag_result *res = parsed_result;
11421 struct rte_eth_l2_tunnel_conf entry;
11424 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11427 if (res->e_tag_id_val > 0x3fff) {
11428 printf("e-tag-id must be equal or less than 0x3fff.\n");
11432 ret = rte_eth_dev_filter_supported(res->port_id,
11433 RTE_ETH_FILTER_L2_TUNNEL);
11435 printf("E-tag filter is not supported on port %u.\n",
11440 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11441 entry.tunnel_id = res->e_tag_id_val;
11442 entry.pool = res->dst_pool_val;
11444 ret = rte_eth_dev_filter_ctrl(res->port_id,
11445 RTE_ETH_FILTER_L2_TUNNEL,
11446 RTE_ETH_FILTER_ADD,
11449 printf("E-tag filter programming error: (%s)\n",
11453 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11454 .f = cmd_config_e_tag_filter_add_parsed,
11456 .help_str = "E-tag ... : E-tag filter add",
11458 (void *)&cmd_config_e_tag_e_tag,
11459 (void *)&cmd_config_e_tag_set,
11460 (void *)&cmd_config_e_tag_filter,
11461 (void *)&cmd_config_e_tag_add,
11462 (void *)&cmd_config_e_tag_e_tag_id,
11463 (void *)&cmd_config_e_tag_e_tag_id_val,
11464 (void *)&cmd_config_e_tag_dst_pool,
11465 (void *)&cmd_config_e_tag_dst_pool_val,
11466 (void *)&cmd_config_e_tag_port,
11467 (void *)&cmd_config_e_tag_port_id,
11473 cmd_config_e_tag_filter_del_parsed(
11474 void *parsed_result,
11475 __attribute__((unused)) struct cmdline *cl,
11476 __attribute__((unused)) void *data)
11478 struct cmd_config_e_tag_result *res = parsed_result;
11479 struct rte_eth_l2_tunnel_conf entry;
11482 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11485 if (res->e_tag_id_val > 0x3fff) {
11486 printf("e-tag-id must be less than 0x3fff.\n");
11490 ret = rte_eth_dev_filter_supported(res->port_id,
11491 RTE_ETH_FILTER_L2_TUNNEL);
11493 printf("E-tag filter is not supported on port %u.\n",
11498 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11499 entry.tunnel_id = res->e_tag_id_val;
11501 ret = rte_eth_dev_filter_ctrl(res->port_id,
11502 RTE_ETH_FILTER_L2_TUNNEL,
11503 RTE_ETH_FILTER_DELETE,
11506 printf("E-tag filter programming error: (%s)\n",
11510 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11511 .f = cmd_config_e_tag_filter_del_parsed,
11513 .help_str = "E-tag ... : E-tag filter delete",
11515 (void *)&cmd_config_e_tag_e_tag,
11516 (void *)&cmd_config_e_tag_set,
11517 (void *)&cmd_config_e_tag_filter,
11518 (void *)&cmd_config_e_tag_del,
11519 (void *)&cmd_config_e_tag_e_tag_id,
11520 (void *)&cmd_config_e_tag_e_tag_id_val,
11521 (void *)&cmd_config_e_tag_port,
11522 (void *)&cmd_config_e_tag_port_id,
11527 /* vf vlan anti spoof configuration */
11529 /* Common result structure for vf vlan anti spoof */
11530 struct cmd_vf_vlan_anti_spoof_result {
11531 cmdline_fixed_string_t set;
11532 cmdline_fixed_string_t vf;
11533 cmdline_fixed_string_t vlan;
11534 cmdline_fixed_string_t antispoof;
11537 cmdline_fixed_string_t on_off;
11540 /* Common CLI fields for vf vlan anti spoof enable disable */
11541 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11542 TOKEN_STRING_INITIALIZER
11543 (struct cmd_vf_vlan_anti_spoof_result,
11545 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11546 TOKEN_STRING_INITIALIZER
11547 (struct cmd_vf_vlan_anti_spoof_result,
11549 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11550 TOKEN_STRING_INITIALIZER
11551 (struct cmd_vf_vlan_anti_spoof_result,
11553 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11554 TOKEN_STRING_INITIALIZER
11555 (struct cmd_vf_vlan_anti_spoof_result,
11556 antispoof, "antispoof");
11557 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11558 TOKEN_NUM_INITIALIZER
11559 (struct cmd_vf_vlan_anti_spoof_result,
11561 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11562 TOKEN_NUM_INITIALIZER
11563 (struct cmd_vf_vlan_anti_spoof_result,
11565 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11566 TOKEN_STRING_INITIALIZER
11567 (struct cmd_vf_vlan_anti_spoof_result,
11571 cmd_set_vf_vlan_anti_spoof_parsed(
11572 void *parsed_result,
11573 __attribute__((unused)) struct cmdline *cl,
11574 __attribute__((unused)) void *data)
11576 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11577 int ret = -ENOTSUP;
11579 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11584 #ifdef RTE_LIBRTE_IXGBE_PMD
11585 if (ret == -ENOTSUP)
11586 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11587 res->vf_id, is_on);
11589 #ifdef RTE_LIBRTE_I40E_PMD
11590 if (ret == -ENOTSUP)
11591 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11592 res->vf_id, is_on);
11594 #ifdef RTE_LIBRTE_BNXT_PMD
11595 if (ret == -ENOTSUP)
11596 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11597 res->vf_id, is_on);
11604 printf("invalid vf_id %d\n", res->vf_id);
11607 printf("invalid port_id %d\n", res->port_id);
11610 printf("function not implemented\n");
11613 printf("programming error: (%s)\n", strerror(-ret));
11617 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11618 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11620 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11622 (void *)&cmd_vf_vlan_anti_spoof_set,
11623 (void *)&cmd_vf_vlan_anti_spoof_vf,
11624 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11625 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11626 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11627 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11628 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11633 /* vf mac anti spoof configuration */
11635 /* Common result structure for vf mac anti spoof */
11636 struct cmd_vf_mac_anti_spoof_result {
11637 cmdline_fixed_string_t set;
11638 cmdline_fixed_string_t vf;
11639 cmdline_fixed_string_t mac;
11640 cmdline_fixed_string_t antispoof;
11643 cmdline_fixed_string_t on_off;
11646 /* Common CLI fields for vf mac anti spoof enable disable */
11647 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11648 TOKEN_STRING_INITIALIZER
11649 (struct cmd_vf_mac_anti_spoof_result,
11651 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11652 TOKEN_STRING_INITIALIZER
11653 (struct cmd_vf_mac_anti_spoof_result,
11655 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11656 TOKEN_STRING_INITIALIZER
11657 (struct cmd_vf_mac_anti_spoof_result,
11659 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11660 TOKEN_STRING_INITIALIZER
11661 (struct cmd_vf_mac_anti_spoof_result,
11662 antispoof, "antispoof");
11663 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11664 TOKEN_NUM_INITIALIZER
11665 (struct cmd_vf_mac_anti_spoof_result,
11667 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11668 TOKEN_NUM_INITIALIZER
11669 (struct cmd_vf_mac_anti_spoof_result,
11671 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11672 TOKEN_STRING_INITIALIZER
11673 (struct cmd_vf_mac_anti_spoof_result,
11677 cmd_set_vf_mac_anti_spoof_parsed(
11678 void *parsed_result,
11679 __attribute__((unused)) struct cmdline *cl,
11680 __attribute__((unused)) void *data)
11682 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11683 int ret = -ENOTSUP;
11685 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11690 #ifdef RTE_LIBRTE_IXGBE_PMD
11691 if (ret == -ENOTSUP)
11692 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11693 res->vf_id, is_on);
11695 #ifdef RTE_LIBRTE_I40E_PMD
11696 if (ret == -ENOTSUP)
11697 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11698 res->vf_id, is_on);
11700 #ifdef RTE_LIBRTE_BNXT_PMD
11701 if (ret == -ENOTSUP)
11702 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11703 res->vf_id, is_on);
11710 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11713 printf("invalid port_id %d\n", res->port_id);
11716 printf("function not implemented\n");
11719 printf("programming error: (%s)\n", strerror(-ret));
11723 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11724 .f = cmd_set_vf_mac_anti_spoof_parsed,
11726 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11728 (void *)&cmd_vf_mac_anti_spoof_set,
11729 (void *)&cmd_vf_mac_anti_spoof_vf,
11730 (void *)&cmd_vf_mac_anti_spoof_mac,
11731 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11732 (void *)&cmd_vf_mac_anti_spoof_port_id,
11733 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11734 (void *)&cmd_vf_mac_anti_spoof_on_off,
11739 /* vf vlan strip queue configuration */
11741 /* Common result structure for vf mac anti spoof */
11742 struct cmd_vf_vlan_stripq_result {
11743 cmdline_fixed_string_t set;
11744 cmdline_fixed_string_t vf;
11745 cmdline_fixed_string_t vlan;
11746 cmdline_fixed_string_t stripq;
11749 cmdline_fixed_string_t on_off;
11752 /* Common CLI fields for vf vlan strip enable disable */
11753 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11754 TOKEN_STRING_INITIALIZER
11755 (struct cmd_vf_vlan_stripq_result,
11757 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11758 TOKEN_STRING_INITIALIZER
11759 (struct cmd_vf_vlan_stripq_result,
11761 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11762 TOKEN_STRING_INITIALIZER
11763 (struct cmd_vf_vlan_stripq_result,
11765 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11766 TOKEN_STRING_INITIALIZER
11767 (struct cmd_vf_vlan_stripq_result,
11769 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11770 TOKEN_NUM_INITIALIZER
11771 (struct cmd_vf_vlan_stripq_result,
11773 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11774 TOKEN_NUM_INITIALIZER
11775 (struct cmd_vf_vlan_stripq_result,
11777 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11778 TOKEN_STRING_INITIALIZER
11779 (struct cmd_vf_vlan_stripq_result,
11783 cmd_set_vf_vlan_stripq_parsed(
11784 void *parsed_result,
11785 __attribute__((unused)) struct cmdline *cl,
11786 __attribute__((unused)) void *data)
11788 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11789 int ret = -ENOTSUP;
11791 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11793 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11796 #ifdef RTE_LIBRTE_IXGBE_PMD
11797 if (ret == -ENOTSUP)
11798 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11799 res->vf_id, is_on);
11801 #ifdef RTE_LIBRTE_I40E_PMD
11802 if (ret == -ENOTSUP)
11803 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11804 res->vf_id, is_on);
11806 #ifdef RTE_LIBRTE_BNXT_PMD
11807 if (ret == -ENOTSUP)
11808 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11809 res->vf_id, is_on);
11816 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11819 printf("invalid port_id %d\n", res->port_id);
11822 printf("function not implemented\n");
11825 printf("programming error: (%s)\n", strerror(-ret));
11829 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11830 .f = cmd_set_vf_vlan_stripq_parsed,
11832 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11834 (void *)&cmd_vf_vlan_stripq_set,
11835 (void *)&cmd_vf_vlan_stripq_vf,
11836 (void *)&cmd_vf_vlan_stripq_vlan,
11837 (void *)&cmd_vf_vlan_stripq_stripq,
11838 (void *)&cmd_vf_vlan_stripq_port_id,
11839 (void *)&cmd_vf_vlan_stripq_vf_id,
11840 (void *)&cmd_vf_vlan_stripq_on_off,
11845 /* vf vlan insert configuration */
11847 /* Common result structure for vf vlan insert */
11848 struct cmd_vf_vlan_insert_result {
11849 cmdline_fixed_string_t set;
11850 cmdline_fixed_string_t vf;
11851 cmdline_fixed_string_t vlan;
11852 cmdline_fixed_string_t insert;
11858 /* Common CLI fields for vf vlan insert enable disable */
11859 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11860 TOKEN_STRING_INITIALIZER
11861 (struct cmd_vf_vlan_insert_result,
11863 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11864 TOKEN_STRING_INITIALIZER
11865 (struct cmd_vf_vlan_insert_result,
11867 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11868 TOKEN_STRING_INITIALIZER
11869 (struct cmd_vf_vlan_insert_result,
11871 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11872 TOKEN_STRING_INITIALIZER
11873 (struct cmd_vf_vlan_insert_result,
11875 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11876 TOKEN_NUM_INITIALIZER
11877 (struct cmd_vf_vlan_insert_result,
11879 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11880 TOKEN_NUM_INITIALIZER
11881 (struct cmd_vf_vlan_insert_result,
11883 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11884 TOKEN_NUM_INITIALIZER
11885 (struct cmd_vf_vlan_insert_result,
11889 cmd_set_vf_vlan_insert_parsed(
11890 void *parsed_result,
11891 __attribute__((unused)) struct cmdline *cl,
11892 __attribute__((unused)) void *data)
11894 struct cmd_vf_vlan_insert_result *res = parsed_result;
11895 int ret = -ENOTSUP;
11897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11900 #ifdef RTE_LIBRTE_IXGBE_PMD
11901 if (ret == -ENOTSUP)
11902 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11905 #ifdef RTE_LIBRTE_I40E_PMD
11906 if (ret == -ENOTSUP)
11907 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11910 #ifdef RTE_LIBRTE_BNXT_PMD
11911 if (ret == -ENOTSUP)
11912 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11920 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11923 printf("invalid port_id %d\n", res->port_id);
11926 printf("function not implemented\n");
11929 printf("programming error: (%s)\n", strerror(-ret));
11933 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11934 .f = cmd_set_vf_vlan_insert_parsed,
11936 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11938 (void *)&cmd_vf_vlan_insert_set,
11939 (void *)&cmd_vf_vlan_insert_vf,
11940 (void *)&cmd_vf_vlan_insert_vlan,
11941 (void *)&cmd_vf_vlan_insert_insert,
11942 (void *)&cmd_vf_vlan_insert_port_id,
11943 (void *)&cmd_vf_vlan_insert_vf_id,
11944 (void *)&cmd_vf_vlan_insert_vlan_id,
11949 /* tx loopback configuration */
11951 /* Common result structure for tx loopback */
11952 struct cmd_tx_loopback_result {
11953 cmdline_fixed_string_t set;
11954 cmdline_fixed_string_t tx;
11955 cmdline_fixed_string_t loopback;
11957 cmdline_fixed_string_t on_off;
11960 /* Common CLI fields for tx loopback enable disable */
11961 cmdline_parse_token_string_t cmd_tx_loopback_set =
11962 TOKEN_STRING_INITIALIZER
11963 (struct cmd_tx_loopback_result,
11965 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11966 TOKEN_STRING_INITIALIZER
11967 (struct cmd_tx_loopback_result,
11969 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11970 TOKEN_STRING_INITIALIZER
11971 (struct cmd_tx_loopback_result,
11972 loopback, "loopback");
11973 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11974 TOKEN_NUM_INITIALIZER
11975 (struct cmd_tx_loopback_result,
11977 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11978 TOKEN_STRING_INITIALIZER
11979 (struct cmd_tx_loopback_result,
11983 cmd_set_tx_loopback_parsed(
11984 void *parsed_result,
11985 __attribute__((unused)) struct cmdline *cl,
11986 __attribute__((unused)) void *data)
11988 struct cmd_tx_loopback_result *res = parsed_result;
11989 int ret = -ENOTSUP;
11991 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11993 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11996 #ifdef RTE_LIBRTE_IXGBE_PMD
11997 if (ret == -ENOTSUP)
11998 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12000 #ifdef RTE_LIBRTE_I40E_PMD
12001 if (ret == -ENOTSUP)
12002 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12004 #ifdef RTE_LIBRTE_BNXT_PMD
12005 if (ret == -ENOTSUP)
12006 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12013 printf("invalid is_on %d\n", is_on);
12016 printf("invalid port_id %d\n", res->port_id);
12019 printf("function not implemented\n");
12022 printf("programming error: (%s)\n", strerror(-ret));
12026 cmdline_parse_inst_t cmd_set_tx_loopback = {
12027 .f = cmd_set_tx_loopback_parsed,
12029 .help_str = "set tx loopback <port_id> on|off",
12031 (void *)&cmd_tx_loopback_set,
12032 (void *)&cmd_tx_loopback_tx,
12033 (void *)&cmd_tx_loopback_loopback,
12034 (void *)&cmd_tx_loopback_port_id,
12035 (void *)&cmd_tx_loopback_on_off,
12040 /* all queues drop enable configuration */
12042 /* Common result structure for all queues drop enable */
12043 struct cmd_all_queues_drop_en_result {
12044 cmdline_fixed_string_t set;
12045 cmdline_fixed_string_t all;
12046 cmdline_fixed_string_t queues;
12047 cmdline_fixed_string_t drop;
12049 cmdline_fixed_string_t on_off;
12052 /* Common CLI fields for tx loopback enable disable */
12053 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12054 TOKEN_STRING_INITIALIZER
12055 (struct cmd_all_queues_drop_en_result,
12057 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12058 TOKEN_STRING_INITIALIZER
12059 (struct cmd_all_queues_drop_en_result,
12061 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12062 TOKEN_STRING_INITIALIZER
12063 (struct cmd_all_queues_drop_en_result,
12065 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12066 TOKEN_STRING_INITIALIZER
12067 (struct cmd_all_queues_drop_en_result,
12069 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12070 TOKEN_NUM_INITIALIZER
12071 (struct cmd_all_queues_drop_en_result,
12073 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12074 TOKEN_STRING_INITIALIZER
12075 (struct cmd_all_queues_drop_en_result,
12079 cmd_set_all_queues_drop_en_parsed(
12080 void *parsed_result,
12081 __attribute__((unused)) struct cmdline *cl,
12082 __attribute__((unused)) void *data)
12084 struct cmd_all_queues_drop_en_result *res = parsed_result;
12085 int ret = -ENOTSUP;
12086 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12088 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12091 #ifdef RTE_LIBRTE_IXGBE_PMD
12092 if (ret == -ENOTSUP)
12093 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12095 #ifdef RTE_LIBRTE_BNXT_PMD
12096 if (ret == -ENOTSUP)
12097 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12103 printf("invalid is_on %d\n", is_on);
12106 printf("invalid port_id %d\n", res->port_id);
12109 printf("function not implemented\n");
12112 printf("programming error: (%s)\n", strerror(-ret));
12116 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12117 .f = cmd_set_all_queues_drop_en_parsed,
12119 .help_str = "set all queues drop <port_id> on|off",
12121 (void *)&cmd_all_queues_drop_en_set,
12122 (void *)&cmd_all_queues_drop_en_all,
12123 (void *)&cmd_all_queues_drop_en_queues,
12124 (void *)&cmd_all_queues_drop_en_drop,
12125 (void *)&cmd_all_queues_drop_en_port_id,
12126 (void *)&cmd_all_queues_drop_en_on_off,
12131 /* vf split drop enable configuration */
12133 /* Common result structure for vf split drop enable */
12134 struct cmd_vf_split_drop_en_result {
12135 cmdline_fixed_string_t set;
12136 cmdline_fixed_string_t vf;
12137 cmdline_fixed_string_t split;
12138 cmdline_fixed_string_t drop;
12141 cmdline_fixed_string_t on_off;
12144 /* Common CLI fields for vf split drop enable disable */
12145 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12146 TOKEN_STRING_INITIALIZER
12147 (struct cmd_vf_split_drop_en_result,
12149 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12150 TOKEN_STRING_INITIALIZER
12151 (struct cmd_vf_split_drop_en_result,
12153 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12154 TOKEN_STRING_INITIALIZER
12155 (struct cmd_vf_split_drop_en_result,
12157 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12158 TOKEN_STRING_INITIALIZER
12159 (struct cmd_vf_split_drop_en_result,
12161 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12162 TOKEN_NUM_INITIALIZER
12163 (struct cmd_vf_split_drop_en_result,
12165 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12166 TOKEN_NUM_INITIALIZER
12167 (struct cmd_vf_split_drop_en_result,
12169 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_vf_split_drop_en_result,
12175 cmd_set_vf_split_drop_en_parsed(
12176 void *parsed_result,
12177 __attribute__((unused)) struct cmdline *cl,
12178 __attribute__((unused)) void *data)
12180 struct cmd_vf_split_drop_en_result *res = parsed_result;
12181 int ret = -ENOTSUP;
12182 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12184 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12187 #ifdef RTE_LIBRTE_IXGBE_PMD
12188 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12195 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12198 printf("invalid port_id %d\n", res->port_id);
12201 printf("not supported on port %d\n", res->port_id);
12204 printf("programming error: (%s)\n", strerror(-ret));
12208 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12209 .f = cmd_set_vf_split_drop_en_parsed,
12211 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12213 (void *)&cmd_vf_split_drop_en_set,
12214 (void *)&cmd_vf_split_drop_en_vf,
12215 (void *)&cmd_vf_split_drop_en_split,
12216 (void *)&cmd_vf_split_drop_en_drop,
12217 (void *)&cmd_vf_split_drop_en_port_id,
12218 (void *)&cmd_vf_split_drop_en_vf_id,
12219 (void *)&cmd_vf_split_drop_en_on_off,
12224 /* vf mac address configuration */
12226 /* Common result structure for vf mac address */
12227 struct cmd_set_vf_mac_addr_result {
12228 cmdline_fixed_string_t set;
12229 cmdline_fixed_string_t vf;
12230 cmdline_fixed_string_t mac;
12231 cmdline_fixed_string_t addr;
12234 struct ether_addr mac_addr;
12238 /* Common CLI fields for vf split drop enable disable */
12239 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12240 TOKEN_STRING_INITIALIZER
12241 (struct cmd_set_vf_mac_addr_result,
12243 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12244 TOKEN_STRING_INITIALIZER
12245 (struct cmd_set_vf_mac_addr_result,
12247 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12248 TOKEN_STRING_INITIALIZER
12249 (struct cmd_set_vf_mac_addr_result,
12251 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12252 TOKEN_STRING_INITIALIZER
12253 (struct cmd_set_vf_mac_addr_result,
12255 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12256 TOKEN_NUM_INITIALIZER
12257 (struct cmd_set_vf_mac_addr_result,
12259 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12260 TOKEN_NUM_INITIALIZER
12261 (struct cmd_set_vf_mac_addr_result,
12263 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12264 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12268 cmd_set_vf_mac_addr_parsed(
12269 void *parsed_result,
12270 __attribute__((unused)) struct cmdline *cl,
12271 __attribute__((unused)) void *data)
12273 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12274 int ret = -ENOTSUP;
12276 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12279 #ifdef RTE_LIBRTE_IXGBE_PMD
12280 if (ret == -ENOTSUP)
12281 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12284 #ifdef RTE_LIBRTE_I40E_PMD
12285 if (ret == -ENOTSUP)
12286 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12289 #ifdef RTE_LIBRTE_BNXT_PMD
12290 if (ret == -ENOTSUP)
12291 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12299 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12302 printf("invalid port_id %d\n", res->port_id);
12305 printf("function not implemented\n");
12308 printf("programming error: (%s)\n", strerror(-ret));
12312 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12313 .f = cmd_set_vf_mac_addr_parsed,
12315 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12317 (void *)&cmd_set_vf_mac_addr_set,
12318 (void *)&cmd_set_vf_mac_addr_vf,
12319 (void *)&cmd_set_vf_mac_addr_mac,
12320 (void *)&cmd_set_vf_mac_addr_addr,
12321 (void *)&cmd_set_vf_mac_addr_port_id,
12322 (void *)&cmd_set_vf_mac_addr_vf_id,
12323 (void *)&cmd_set_vf_mac_addr_mac_addr,
12328 /* MACsec configuration */
12330 /* Common result structure for MACsec offload enable */
12331 struct cmd_macsec_offload_on_result {
12332 cmdline_fixed_string_t set;
12333 cmdline_fixed_string_t macsec;
12334 cmdline_fixed_string_t offload;
12336 cmdline_fixed_string_t on;
12337 cmdline_fixed_string_t encrypt;
12338 cmdline_fixed_string_t en_on_off;
12339 cmdline_fixed_string_t replay_protect;
12340 cmdline_fixed_string_t rp_on_off;
12343 /* Common CLI fields for MACsec offload disable */
12344 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12345 TOKEN_STRING_INITIALIZER
12346 (struct cmd_macsec_offload_on_result,
12348 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12349 TOKEN_STRING_INITIALIZER
12350 (struct cmd_macsec_offload_on_result,
12352 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12353 TOKEN_STRING_INITIALIZER
12354 (struct cmd_macsec_offload_on_result,
12355 offload, "offload");
12356 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12357 TOKEN_NUM_INITIALIZER
12358 (struct cmd_macsec_offload_on_result,
12360 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12361 TOKEN_STRING_INITIALIZER
12362 (struct cmd_macsec_offload_on_result,
12364 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12365 TOKEN_STRING_INITIALIZER
12366 (struct cmd_macsec_offload_on_result,
12367 encrypt, "encrypt");
12368 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12369 TOKEN_STRING_INITIALIZER
12370 (struct cmd_macsec_offload_on_result,
12371 en_on_off, "on#off");
12372 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12373 TOKEN_STRING_INITIALIZER
12374 (struct cmd_macsec_offload_on_result,
12375 replay_protect, "replay-protect");
12376 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_macsec_offload_on_result,
12379 rp_on_off, "on#off");
12382 cmd_set_macsec_offload_on_parsed(
12383 void *parsed_result,
12384 __attribute__((unused)) struct cmdline *cl,
12385 __attribute__((unused)) void *data)
12387 struct cmd_macsec_offload_on_result *res = parsed_result;
12388 int ret = -ENOTSUP;
12389 portid_t port_id = res->port_id;
12390 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12391 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12393 if (port_id_is_invalid(port_id, ENABLED_WARN))
12396 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12397 #ifdef RTE_LIBRTE_IXGBE_PMD
12398 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12407 printf("invalid port_id %d\n", port_id);
12410 printf("not supported on port %d\n", port_id);
12413 printf("programming error: (%s)\n", strerror(-ret));
12417 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12418 .f = cmd_set_macsec_offload_on_parsed,
12420 .help_str = "set macsec offload <port_id> on "
12421 "encrypt on|off replay-protect on|off",
12423 (void *)&cmd_macsec_offload_on_set,
12424 (void *)&cmd_macsec_offload_on_macsec,
12425 (void *)&cmd_macsec_offload_on_offload,
12426 (void *)&cmd_macsec_offload_on_port_id,
12427 (void *)&cmd_macsec_offload_on_on,
12428 (void *)&cmd_macsec_offload_on_encrypt,
12429 (void *)&cmd_macsec_offload_on_en_on_off,
12430 (void *)&cmd_macsec_offload_on_replay_protect,
12431 (void *)&cmd_macsec_offload_on_rp_on_off,
12436 /* Common result structure for MACsec offload disable */
12437 struct cmd_macsec_offload_off_result {
12438 cmdline_fixed_string_t set;
12439 cmdline_fixed_string_t macsec;
12440 cmdline_fixed_string_t offload;
12442 cmdline_fixed_string_t off;
12445 /* Common CLI fields for MACsec offload disable */
12446 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12447 TOKEN_STRING_INITIALIZER
12448 (struct cmd_macsec_offload_off_result,
12450 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12451 TOKEN_STRING_INITIALIZER
12452 (struct cmd_macsec_offload_off_result,
12454 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12455 TOKEN_STRING_INITIALIZER
12456 (struct cmd_macsec_offload_off_result,
12457 offload, "offload");
12458 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12459 TOKEN_NUM_INITIALIZER
12460 (struct cmd_macsec_offload_off_result,
12462 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12463 TOKEN_STRING_INITIALIZER
12464 (struct cmd_macsec_offload_off_result,
12468 cmd_set_macsec_offload_off_parsed(
12469 void *parsed_result,
12470 __attribute__((unused)) struct cmdline *cl,
12471 __attribute__((unused)) void *data)
12473 struct cmd_macsec_offload_off_result *res = parsed_result;
12474 int ret = -ENOTSUP;
12475 portid_t port_id = res->port_id;
12477 if (port_id_is_invalid(port_id, ENABLED_WARN))
12480 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12481 #ifdef RTE_LIBRTE_IXGBE_PMD
12482 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12489 printf("invalid port_id %d\n", port_id);
12492 printf("not supported on port %d\n", port_id);
12495 printf("programming error: (%s)\n", strerror(-ret));
12499 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12500 .f = cmd_set_macsec_offload_off_parsed,
12502 .help_str = "set macsec offload <port_id> off",
12504 (void *)&cmd_macsec_offload_off_set,
12505 (void *)&cmd_macsec_offload_off_macsec,
12506 (void *)&cmd_macsec_offload_off_offload,
12507 (void *)&cmd_macsec_offload_off_port_id,
12508 (void *)&cmd_macsec_offload_off_off,
12513 /* Common result structure for MACsec secure connection configure */
12514 struct cmd_macsec_sc_result {
12515 cmdline_fixed_string_t set;
12516 cmdline_fixed_string_t macsec;
12517 cmdline_fixed_string_t sc;
12518 cmdline_fixed_string_t tx_rx;
12520 struct ether_addr mac;
12524 /* Common CLI fields for MACsec secure connection configure */
12525 cmdline_parse_token_string_t cmd_macsec_sc_set =
12526 TOKEN_STRING_INITIALIZER
12527 (struct cmd_macsec_sc_result,
12529 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12530 TOKEN_STRING_INITIALIZER
12531 (struct cmd_macsec_sc_result,
12533 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12534 TOKEN_STRING_INITIALIZER
12535 (struct cmd_macsec_sc_result,
12537 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12538 TOKEN_STRING_INITIALIZER
12539 (struct cmd_macsec_sc_result,
12541 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12542 TOKEN_NUM_INITIALIZER
12543 (struct cmd_macsec_sc_result,
12545 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12546 TOKEN_ETHERADDR_INITIALIZER
12547 (struct cmd_macsec_sc_result,
12549 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12550 TOKEN_NUM_INITIALIZER
12551 (struct cmd_macsec_sc_result,
12555 cmd_set_macsec_sc_parsed(
12556 void *parsed_result,
12557 __attribute__((unused)) struct cmdline *cl,
12558 __attribute__((unused)) void *data)
12560 struct cmd_macsec_sc_result *res = parsed_result;
12561 int ret = -ENOTSUP;
12562 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12564 #ifdef RTE_LIBRTE_IXGBE_PMD
12566 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12567 res->mac.addr_bytes) :
12568 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12569 res->mac.addr_bytes, res->pi);
12571 RTE_SET_USED(is_tx);
12577 printf("invalid port_id %d\n", res->port_id);
12580 printf("not supported on port %d\n", res->port_id);
12583 printf("programming error: (%s)\n", strerror(-ret));
12587 cmdline_parse_inst_t cmd_set_macsec_sc = {
12588 .f = cmd_set_macsec_sc_parsed,
12590 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12592 (void *)&cmd_macsec_sc_set,
12593 (void *)&cmd_macsec_sc_macsec,
12594 (void *)&cmd_macsec_sc_sc,
12595 (void *)&cmd_macsec_sc_tx_rx,
12596 (void *)&cmd_macsec_sc_port_id,
12597 (void *)&cmd_macsec_sc_mac,
12598 (void *)&cmd_macsec_sc_pi,
12603 /* Common result structure for MACsec secure connection configure */
12604 struct cmd_macsec_sa_result {
12605 cmdline_fixed_string_t set;
12606 cmdline_fixed_string_t macsec;
12607 cmdline_fixed_string_t sa;
12608 cmdline_fixed_string_t tx_rx;
12613 cmdline_fixed_string_t key;
12616 /* Common CLI fields for MACsec secure connection configure */
12617 cmdline_parse_token_string_t cmd_macsec_sa_set =
12618 TOKEN_STRING_INITIALIZER
12619 (struct cmd_macsec_sa_result,
12621 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12622 TOKEN_STRING_INITIALIZER
12623 (struct cmd_macsec_sa_result,
12625 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12626 TOKEN_STRING_INITIALIZER
12627 (struct cmd_macsec_sa_result,
12629 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12630 TOKEN_STRING_INITIALIZER
12631 (struct cmd_macsec_sa_result,
12633 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12634 TOKEN_NUM_INITIALIZER
12635 (struct cmd_macsec_sa_result,
12637 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12638 TOKEN_NUM_INITIALIZER
12639 (struct cmd_macsec_sa_result,
12641 cmdline_parse_token_num_t cmd_macsec_sa_an =
12642 TOKEN_NUM_INITIALIZER
12643 (struct cmd_macsec_sa_result,
12645 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12646 TOKEN_NUM_INITIALIZER
12647 (struct cmd_macsec_sa_result,
12649 cmdline_parse_token_string_t cmd_macsec_sa_key =
12650 TOKEN_STRING_INITIALIZER
12651 (struct cmd_macsec_sa_result,
12655 cmd_set_macsec_sa_parsed(
12656 void *parsed_result,
12657 __attribute__((unused)) struct cmdline *cl,
12658 __attribute__((unused)) void *data)
12660 struct cmd_macsec_sa_result *res = parsed_result;
12661 int ret = -ENOTSUP;
12662 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12663 uint8_t key[16] = { 0 };
12669 key_len = strlen(res->key) / 2;
12673 for (i = 0; i < key_len; i++) {
12674 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12677 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12680 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12683 #ifdef RTE_LIBRTE_IXGBE_PMD
12685 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12686 res->idx, res->an, res->pn, key) :
12687 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12688 res->idx, res->an, res->pn, key);
12690 RTE_SET_USED(is_tx);
12697 printf("invalid idx %d or an %d\n", res->idx, res->an);
12700 printf("invalid port_id %d\n", res->port_id);
12703 printf("not supported on port %d\n", res->port_id);
12706 printf("programming error: (%s)\n", strerror(-ret));
12710 cmdline_parse_inst_t cmd_set_macsec_sa = {
12711 .f = cmd_set_macsec_sa_parsed,
12713 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12715 (void *)&cmd_macsec_sa_set,
12716 (void *)&cmd_macsec_sa_macsec,
12717 (void *)&cmd_macsec_sa_sa,
12718 (void *)&cmd_macsec_sa_tx_rx,
12719 (void *)&cmd_macsec_sa_port_id,
12720 (void *)&cmd_macsec_sa_idx,
12721 (void *)&cmd_macsec_sa_an,
12722 (void *)&cmd_macsec_sa_pn,
12723 (void *)&cmd_macsec_sa_key,
12728 /* VF unicast promiscuous mode configuration */
12730 /* Common result structure for VF unicast promiscuous mode */
12731 struct cmd_vf_promisc_result {
12732 cmdline_fixed_string_t set;
12733 cmdline_fixed_string_t vf;
12734 cmdline_fixed_string_t promisc;
12737 cmdline_fixed_string_t on_off;
12740 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12741 cmdline_parse_token_string_t cmd_vf_promisc_set =
12742 TOKEN_STRING_INITIALIZER
12743 (struct cmd_vf_promisc_result,
12745 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12746 TOKEN_STRING_INITIALIZER
12747 (struct cmd_vf_promisc_result,
12749 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12750 TOKEN_STRING_INITIALIZER
12751 (struct cmd_vf_promisc_result,
12752 promisc, "promisc");
12753 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12754 TOKEN_NUM_INITIALIZER
12755 (struct cmd_vf_promisc_result,
12757 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12758 TOKEN_NUM_INITIALIZER
12759 (struct cmd_vf_promisc_result,
12761 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12762 TOKEN_STRING_INITIALIZER
12763 (struct cmd_vf_promisc_result,
12767 cmd_set_vf_promisc_parsed(
12768 void *parsed_result,
12769 __attribute__((unused)) struct cmdline *cl,
12770 __attribute__((unused)) void *data)
12772 struct cmd_vf_promisc_result *res = parsed_result;
12773 int ret = -ENOTSUP;
12775 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12777 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12780 #ifdef RTE_LIBRTE_I40E_PMD
12781 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12782 res->vf_id, is_on);
12789 printf("invalid vf_id %d\n", res->vf_id);
12792 printf("invalid port_id %d\n", res->port_id);
12795 printf("function not implemented\n");
12798 printf("programming error: (%s)\n", strerror(-ret));
12802 cmdline_parse_inst_t cmd_set_vf_promisc = {
12803 .f = cmd_set_vf_promisc_parsed,
12805 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12806 "Set unicast promiscuous mode for a VF from the PF",
12808 (void *)&cmd_vf_promisc_set,
12809 (void *)&cmd_vf_promisc_vf,
12810 (void *)&cmd_vf_promisc_promisc,
12811 (void *)&cmd_vf_promisc_port_id,
12812 (void *)&cmd_vf_promisc_vf_id,
12813 (void *)&cmd_vf_promisc_on_off,
12818 /* VF multicast promiscuous mode configuration */
12820 /* Common result structure for VF multicast promiscuous mode */
12821 struct cmd_vf_allmulti_result {
12822 cmdline_fixed_string_t set;
12823 cmdline_fixed_string_t vf;
12824 cmdline_fixed_string_t allmulti;
12827 cmdline_fixed_string_t on_off;
12830 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12831 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12832 TOKEN_STRING_INITIALIZER
12833 (struct cmd_vf_allmulti_result,
12835 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12836 TOKEN_STRING_INITIALIZER
12837 (struct cmd_vf_allmulti_result,
12839 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12840 TOKEN_STRING_INITIALIZER
12841 (struct cmd_vf_allmulti_result,
12842 allmulti, "allmulti");
12843 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12844 TOKEN_NUM_INITIALIZER
12845 (struct cmd_vf_allmulti_result,
12847 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12848 TOKEN_NUM_INITIALIZER
12849 (struct cmd_vf_allmulti_result,
12851 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12852 TOKEN_STRING_INITIALIZER
12853 (struct cmd_vf_allmulti_result,
12857 cmd_set_vf_allmulti_parsed(
12858 void *parsed_result,
12859 __attribute__((unused)) struct cmdline *cl,
12860 __attribute__((unused)) void *data)
12862 struct cmd_vf_allmulti_result *res = parsed_result;
12863 int ret = -ENOTSUP;
12865 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12867 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12870 #ifdef RTE_LIBRTE_I40E_PMD
12871 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12872 res->vf_id, is_on);
12879 printf("invalid vf_id %d\n", res->vf_id);
12882 printf("invalid port_id %d\n", res->port_id);
12885 printf("function not implemented\n");
12888 printf("programming error: (%s)\n", strerror(-ret));
12892 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12893 .f = cmd_set_vf_allmulti_parsed,
12895 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12896 "Set multicast promiscuous mode for a VF from the PF",
12898 (void *)&cmd_vf_allmulti_set,
12899 (void *)&cmd_vf_allmulti_vf,
12900 (void *)&cmd_vf_allmulti_allmulti,
12901 (void *)&cmd_vf_allmulti_port_id,
12902 (void *)&cmd_vf_allmulti_vf_id,
12903 (void *)&cmd_vf_allmulti_on_off,
12908 /* vf broadcast mode configuration */
12910 /* Common result structure for vf broadcast */
12911 struct cmd_set_vf_broadcast_result {
12912 cmdline_fixed_string_t set;
12913 cmdline_fixed_string_t vf;
12914 cmdline_fixed_string_t broadcast;
12917 cmdline_fixed_string_t on_off;
12920 /* Common CLI fields for vf broadcast enable disable */
12921 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12922 TOKEN_STRING_INITIALIZER
12923 (struct cmd_set_vf_broadcast_result,
12925 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12926 TOKEN_STRING_INITIALIZER
12927 (struct cmd_set_vf_broadcast_result,
12929 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12930 TOKEN_STRING_INITIALIZER
12931 (struct cmd_set_vf_broadcast_result,
12932 broadcast, "broadcast");
12933 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12934 TOKEN_NUM_INITIALIZER
12935 (struct cmd_set_vf_broadcast_result,
12937 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12938 TOKEN_NUM_INITIALIZER
12939 (struct cmd_set_vf_broadcast_result,
12941 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12942 TOKEN_STRING_INITIALIZER
12943 (struct cmd_set_vf_broadcast_result,
12947 cmd_set_vf_broadcast_parsed(
12948 void *parsed_result,
12949 __attribute__((unused)) struct cmdline *cl,
12950 __attribute__((unused)) void *data)
12952 struct cmd_set_vf_broadcast_result *res = parsed_result;
12953 int ret = -ENOTSUP;
12955 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12957 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12960 #ifdef RTE_LIBRTE_I40E_PMD
12961 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12962 res->vf_id, is_on);
12969 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12972 printf("invalid port_id %d\n", res->port_id);
12975 printf("function not implemented\n");
12978 printf("programming error: (%s)\n", strerror(-ret));
12982 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12983 .f = cmd_set_vf_broadcast_parsed,
12985 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12987 (void *)&cmd_set_vf_broadcast_set,
12988 (void *)&cmd_set_vf_broadcast_vf,
12989 (void *)&cmd_set_vf_broadcast_broadcast,
12990 (void *)&cmd_set_vf_broadcast_port_id,
12991 (void *)&cmd_set_vf_broadcast_vf_id,
12992 (void *)&cmd_set_vf_broadcast_on_off,
12997 /* vf vlan tag configuration */
12999 /* Common result structure for vf vlan tag */
13000 struct cmd_set_vf_vlan_tag_result {
13001 cmdline_fixed_string_t set;
13002 cmdline_fixed_string_t vf;
13003 cmdline_fixed_string_t vlan;
13004 cmdline_fixed_string_t tag;
13007 cmdline_fixed_string_t on_off;
13010 /* Common CLI fields for vf vlan tag enable disable */
13011 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13012 TOKEN_STRING_INITIALIZER
13013 (struct cmd_set_vf_vlan_tag_result,
13015 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13016 TOKEN_STRING_INITIALIZER
13017 (struct cmd_set_vf_vlan_tag_result,
13019 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13020 TOKEN_STRING_INITIALIZER
13021 (struct cmd_set_vf_vlan_tag_result,
13023 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13024 TOKEN_STRING_INITIALIZER
13025 (struct cmd_set_vf_vlan_tag_result,
13027 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13028 TOKEN_NUM_INITIALIZER
13029 (struct cmd_set_vf_vlan_tag_result,
13031 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13032 TOKEN_NUM_INITIALIZER
13033 (struct cmd_set_vf_vlan_tag_result,
13035 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13036 TOKEN_STRING_INITIALIZER
13037 (struct cmd_set_vf_vlan_tag_result,
13041 cmd_set_vf_vlan_tag_parsed(
13042 void *parsed_result,
13043 __attribute__((unused)) struct cmdline *cl,
13044 __attribute__((unused)) void *data)
13046 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13047 int ret = -ENOTSUP;
13049 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13051 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13054 #ifdef RTE_LIBRTE_I40E_PMD
13055 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13056 res->vf_id, is_on);
13063 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13066 printf("invalid port_id %d\n", res->port_id);
13069 printf("function not implemented\n");
13072 printf("programming error: (%s)\n", strerror(-ret));
13076 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13077 .f = cmd_set_vf_vlan_tag_parsed,
13079 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13081 (void *)&cmd_set_vf_vlan_tag_set,
13082 (void *)&cmd_set_vf_vlan_tag_vf,
13083 (void *)&cmd_set_vf_vlan_tag_vlan,
13084 (void *)&cmd_set_vf_vlan_tag_tag,
13085 (void *)&cmd_set_vf_vlan_tag_port_id,
13086 (void *)&cmd_set_vf_vlan_tag_vf_id,
13087 (void *)&cmd_set_vf_vlan_tag_on_off,
13092 /* Common definition of VF and TC TX bandwidth configuration */
13093 struct cmd_vf_tc_bw_result {
13094 cmdline_fixed_string_t set;
13095 cmdline_fixed_string_t vf;
13096 cmdline_fixed_string_t tc;
13097 cmdline_fixed_string_t tx;
13098 cmdline_fixed_string_t min_bw;
13099 cmdline_fixed_string_t max_bw;
13100 cmdline_fixed_string_t strict_link_prio;
13105 cmdline_fixed_string_t bw_list;
13109 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13110 TOKEN_STRING_INITIALIZER
13111 (struct cmd_vf_tc_bw_result,
13113 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13114 TOKEN_STRING_INITIALIZER
13115 (struct cmd_vf_tc_bw_result,
13117 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13118 TOKEN_STRING_INITIALIZER
13119 (struct cmd_vf_tc_bw_result,
13121 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13122 TOKEN_STRING_INITIALIZER
13123 (struct cmd_vf_tc_bw_result,
13125 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13126 TOKEN_STRING_INITIALIZER
13127 (struct cmd_vf_tc_bw_result,
13128 strict_link_prio, "strict-link-priority");
13129 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13130 TOKEN_STRING_INITIALIZER
13131 (struct cmd_vf_tc_bw_result,
13132 min_bw, "min-bandwidth");
13133 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13134 TOKEN_STRING_INITIALIZER
13135 (struct cmd_vf_tc_bw_result,
13136 max_bw, "max-bandwidth");
13137 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13138 TOKEN_NUM_INITIALIZER
13139 (struct cmd_vf_tc_bw_result,
13141 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13142 TOKEN_NUM_INITIALIZER
13143 (struct cmd_vf_tc_bw_result,
13145 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13146 TOKEN_NUM_INITIALIZER
13147 (struct cmd_vf_tc_bw_result,
13149 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13150 TOKEN_NUM_INITIALIZER
13151 (struct cmd_vf_tc_bw_result,
13153 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13154 TOKEN_STRING_INITIALIZER
13155 (struct cmd_vf_tc_bw_result,
13157 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13158 TOKEN_NUM_INITIALIZER
13159 (struct cmd_vf_tc_bw_result,
13162 /* VF max bandwidth setting */
13164 cmd_vf_max_bw_parsed(
13165 void *parsed_result,
13166 __attribute__((unused)) struct cmdline *cl,
13167 __attribute__((unused)) void *data)
13169 struct cmd_vf_tc_bw_result *res = parsed_result;
13170 int ret = -ENOTSUP;
13172 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13175 #ifdef RTE_LIBRTE_I40E_PMD
13176 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13177 res->vf_id, res->bw);
13184 printf("invalid vf_id %d or bandwidth %d\n",
13185 res->vf_id, res->bw);
13188 printf("invalid port_id %d\n", res->port_id);
13191 printf("function not implemented\n");
13194 printf("programming error: (%s)\n", strerror(-ret));
13198 cmdline_parse_inst_t cmd_vf_max_bw = {
13199 .f = cmd_vf_max_bw_parsed,
13201 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13203 (void *)&cmd_vf_tc_bw_set,
13204 (void *)&cmd_vf_tc_bw_vf,
13205 (void *)&cmd_vf_tc_bw_tx,
13206 (void *)&cmd_vf_tc_bw_max_bw,
13207 (void *)&cmd_vf_tc_bw_port_id,
13208 (void *)&cmd_vf_tc_bw_vf_id,
13209 (void *)&cmd_vf_tc_bw_bw,
13215 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13220 const char *p, *p0 = str;
13227 p = strchr(p0, '(');
13229 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13233 p0 = strchr(p, ')');
13235 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13239 if (size >= sizeof(s)) {
13240 printf("The string size exceeds the internal buffer size\n");
13243 snprintf(s, sizeof(s), "%.*s", size, p);
13244 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13246 printf("Failed to get the bandwidth list. ");
13250 for (i = 0; i < ret; i++)
13251 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13256 /* TC min bandwidth setting */
13258 cmd_vf_tc_min_bw_parsed(
13259 void *parsed_result,
13260 __attribute__((unused)) struct cmdline *cl,
13261 __attribute__((unused)) void *data)
13263 struct cmd_vf_tc_bw_result *res = parsed_result;
13266 int ret = -ENOTSUP;
13268 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13271 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13275 #ifdef RTE_LIBRTE_I40E_PMD
13276 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13284 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13287 printf("invalid port_id %d\n", res->port_id);
13290 printf("function not implemented\n");
13293 printf("programming error: (%s)\n", strerror(-ret));
13297 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13298 .f = cmd_vf_tc_min_bw_parsed,
13300 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13301 " <bw1, bw2, ...>",
13303 (void *)&cmd_vf_tc_bw_set,
13304 (void *)&cmd_vf_tc_bw_vf,
13305 (void *)&cmd_vf_tc_bw_tc,
13306 (void *)&cmd_vf_tc_bw_tx,
13307 (void *)&cmd_vf_tc_bw_min_bw,
13308 (void *)&cmd_vf_tc_bw_port_id,
13309 (void *)&cmd_vf_tc_bw_vf_id,
13310 (void *)&cmd_vf_tc_bw_bw_list,
13316 cmd_tc_min_bw_parsed(
13317 void *parsed_result,
13318 __attribute__((unused)) struct cmdline *cl,
13319 __attribute__((unused)) void *data)
13321 struct cmd_vf_tc_bw_result *res = parsed_result;
13322 struct rte_port *port;
13325 int ret = -ENOTSUP;
13327 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13330 port = &ports[res->port_id];
13331 /** Check if the port is not started **/
13332 if (port->port_status != RTE_PORT_STOPPED) {
13333 printf("Please stop port %d first\n", res->port_id);
13337 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13341 #ifdef RTE_LIBRTE_IXGBE_PMD
13342 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13349 printf("invalid bandwidth\n");
13352 printf("invalid port_id %d\n", res->port_id);
13355 printf("function not implemented\n");
13358 printf("programming error: (%s)\n", strerror(-ret));
13362 cmdline_parse_inst_t cmd_tc_min_bw = {
13363 .f = cmd_tc_min_bw_parsed,
13365 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13367 (void *)&cmd_vf_tc_bw_set,
13368 (void *)&cmd_vf_tc_bw_tc,
13369 (void *)&cmd_vf_tc_bw_tx,
13370 (void *)&cmd_vf_tc_bw_min_bw,
13371 (void *)&cmd_vf_tc_bw_port_id,
13372 (void *)&cmd_vf_tc_bw_bw_list,
13377 /* TC max bandwidth setting */
13379 cmd_vf_tc_max_bw_parsed(
13380 void *parsed_result,
13381 __attribute__((unused)) struct cmdline *cl,
13382 __attribute__((unused)) void *data)
13384 struct cmd_vf_tc_bw_result *res = parsed_result;
13385 int ret = -ENOTSUP;
13387 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13390 #ifdef RTE_LIBRTE_I40E_PMD
13391 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13392 res->tc_no, res->bw);
13399 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13400 res->vf_id, res->tc_no, res->bw);
13403 printf("invalid port_id %d\n", res->port_id);
13406 printf("function not implemented\n");
13409 printf("programming error: (%s)\n", strerror(-ret));
13413 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13414 .f = cmd_vf_tc_max_bw_parsed,
13416 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13419 (void *)&cmd_vf_tc_bw_set,
13420 (void *)&cmd_vf_tc_bw_vf,
13421 (void *)&cmd_vf_tc_bw_tc,
13422 (void *)&cmd_vf_tc_bw_tx,
13423 (void *)&cmd_vf_tc_bw_max_bw,
13424 (void *)&cmd_vf_tc_bw_port_id,
13425 (void *)&cmd_vf_tc_bw_vf_id,
13426 (void *)&cmd_vf_tc_bw_tc_no,
13427 (void *)&cmd_vf_tc_bw_bw,
13433 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
13435 /* *** Set Port default Traffic Management Hierarchy *** */
13436 struct cmd_set_port_tm_hierarchy_default_result {
13437 cmdline_fixed_string_t set;
13438 cmdline_fixed_string_t port;
13439 cmdline_fixed_string_t tm;
13440 cmdline_fixed_string_t hierarchy;
13441 cmdline_fixed_string_t def;
13445 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
13446 TOKEN_STRING_INITIALIZER(
13447 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
13448 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
13449 TOKEN_STRING_INITIALIZER(
13450 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
13451 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
13452 TOKEN_STRING_INITIALIZER(
13453 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
13454 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
13455 TOKEN_STRING_INITIALIZER(
13456 struct cmd_set_port_tm_hierarchy_default_result,
13457 hierarchy, "hierarchy");
13458 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
13459 TOKEN_STRING_INITIALIZER(
13460 struct cmd_set_port_tm_hierarchy_default_result,
13462 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
13463 TOKEN_NUM_INITIALIZER(
13464 struct cmd_set_port_tm_hierarchy_default_result,
13467 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
13468 __attribute__((unused)) struct cmdline *cl,
13469 __attribute__((unused)) void *data)
13471 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
13472 struct rte_port *p;
13473 uint16_t port_id = res->port_id;
13475 if (port_id_is_invalid(port_id, ENABLED_WARN))
13478 p = &ports[port_id];
13481 if (p->softport.tm_flag == 0) {
13482 printf(" tm not enabled on port %u (error)\n", port_id);
13486 /* Forward mode: tm */
13487 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
13488 printf(" tm mode not enabled(error)\n");
13492 /* Set the default tm hierarchy */
13493 p->softport.tm.default_hierarchy_enable = 1;
13496 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
13497 .f = cmd_set_port_tm_hierarchy_default_parsed,
13499 .help_str = "set port tm hierarchy default <port_id>",
13501 (void *)&cmd_set_port_tm_hierarchy_default_set,
13502 (void *)&cmd_set_port_tm_hierarchy_default_port,
13503 (void *)&cmd_set_port_tm_hierarchy_default_tm,
13504 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
13505 (void *)&cmd_set_port_tm_hierarchy_default_default,
13506 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
13512 /* Strict link priority scheduling mode setting */
13514 cmd_strict_link_prio_parsed(
13515 void *parsed_result,
13516 __attribute__((unused)) struct cmdline *cl,
13517 __attribute__((unused)) void *data)
13519 struct cmd_vf_tc_bw_result *res = parsed_result;
13520 int ret = -ENOTSUP;
13522 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13525 #ifdef RTE_LIBRTE_I40E_PMD
13526 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13533 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13536 printf("invalid port_id %d\n", res->port_id);
13539 printf("function not implemented\n");
13542 printf("programming error: (%s)\n", strerror(-ret));
13546 cmdline_parse_inst_t cmd_strict_link_prio = {
13547 .f = cmd_strict_link_prio_parsed,
13549 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13551 (void *)&cmd_vf_tc_bw_set,
13552 (void *)&cmd_vf_tc_bw_tx,
13553 (void *)&cmd_vf_tc_bw_strict_link_prio,
13554 (void *)&cmd_vf_tc_bw_port_id,
13555 (void *)&cmd_vf_tc_bw_tc_map,
13560 /* Load dynamic device personalization*/
13561 struct cmd_ddp_add_result {
13562 cmdline_fixed_string_t ddp;
13563 cmdline_fixed_string_t add;
13568 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13569 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13570 cmdline_parse_token_string_t cmd_ddp_add_add =
13571 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13572 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13573 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13574 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13575 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13578 cmd_ddp_add_parsed(
13579 void *parsed_result,
13580 __attribute__((unused)) struct cmdline *cl,
13581 __attribute__((unused)) void *data)
13583 struct cmd_ddp_add_result *res = parsed_result;
13589 int ret = -ENOTSUP;
13591 if (res->port_id > nb_ports) {
13592 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13596 if (!all_ports_stopped()) {
13597 printf("Please stop all ports first\n");
13601 filepath = strdup(res->filepath);
13602 if (filepath == NULL) {
13603 printf("Failed to allocate memory\n");
13606 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13608 buff = open_ddp_package_file(file_fld[0], &size);
13610 free((void *)filepath);
13614 #ifdef RTE_LIBRTE_I40E_PMD
13615 if (ret == -ENOTSUP)
13616 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13618 RTE_PMD_I40E_PKG_OP_WR_ADD);
13621 if (ret == -EEXIST)
13622 printf("Profile has already existed.\n");
13624 printf("Failed to load profile.\n");
13625 else if (file_num == 2)
13626 save_ddp_package_file(file_fld[1], buff, size);
13628 close_ddp_package_file(buff);
13629 free((void *)filepath);
13632 cmdline_parse_inst_t cmd_ddp_add = {
13633 .f = cmd_ddp_add_parsed,
13635 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13637 (void *)&cmd_ddp_add_ddp,
13638 (void *)&cmd_ddp_add_add,
13639 (void *)&cmd_ddp_add_port_id,
13640 (void *)&cmd_ddp_add_filepath,
13645 /* Delete dynamic device personalization*/
13646 struct cmd_ddp_del_result {
13647 cmdline_fixed_string_t ddp;
13648 cmdline_fixed_string_t del;
13653 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13654 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13655 cmdline_parse_token_string_t cmd_ddp_del_del =
13656 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13657 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13658 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13659 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13660 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13663 cmd_ddp_del_parsed(
13664 void *parsed_result,
13665 __attribute__((unused)) struct cmdline *cl,
13666 __attribute__((unused)) void *data)
13668 struct cmd_ddp_del_result *res = parsed_result;
13671 int ret = -ENOTSUP;
13673 if (res->port_id > nb_ports) {
13674 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13678 if (!all_ports_stopped()) {
13679 printf("Please stop all ports first\n");
13683 buff = open_ddp_package_file(res->filepath, &size);
13687 #ifdef RTE_LIBRTE_I40E_PMD
13688 if (ret == -ENOTSUP)
13689 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13691 RTE_PMD_I40E_PKG_OP_WR_DEL);
13694 if (ret == -EACCES)
13695 printf("Profile does not exist.\n");
13697 printf("Failed to delete profile.\n");
13699 close_ddp_package_file(buff);
13702 cmdline_parse_inst_t cmd_ddp_del = {
13703 .f = cmd_ddp_del_parsed,
13705 .help_str = "ddp del <port_id> <profile_path>",
13707 (void *)&cmd_ddp_del_ddp,
13708 (void *)&cmd_ddp_del_del,
13709 (void *)&cmd_ddp_del_port_id,
13710 (void *)&cmd_ddp_del_filepath,
13715 /* Get dynamic device personalization profile info */
13716 struct cmd_ddp_info_result {
13717 cmdline_fixed_string_t ddp;
13718 cmdline_fixed_string_t get;
13719 cmdline_fixed_string_t info;
13723 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13724 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13725 cmdline_parse_token_string_t cmd_ddp_info_get =
13726 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13727 cmdline_parse_token_string_t cmd_ddp_info_info =
13728 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13729 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13730 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13733 cmd_ddp_info_parsed(
13734 void *parsed_result,
13735 __attribute__((unused)) struct cmdline *cl,
13736 __attribute__((unused)) void *data)
13738 struct cmd_ddp_info_result *res = parsed_result;
13741 int ret = -ENOTSUP;
13742 #ifdef RTE_LIBRTE_I40E_PMD
13745 uint32_t buff_size = 0;
13746 struct rte_pmd_i40e_profile_info info;
13747 uint32_t dev_num = 0;
13748 struct rte_pmd_i40e_ddp_device_id *devs;
13749 uint32_t proto_num = 0;
13750 struct rte_pmd_i40e_proto_info *proto;
13751 uint32_t pctype_num = 0;
13752 struct rte_pmd_i40e_ptype_info *pctype;
13753 uint32_t ptype_num = 0;
13754 struct rte_pmd_i40e_ptype_info *ptype;
13759 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13763 #ifdef RTE_LIBRTE_I40E_PMD
13764 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13765 (uint8_t *)&info, sizeof(info),
13766 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13768 printf("Global Track id: 0x%x\n", info.track_id);
13769 printf("Global Version: %d.%d.%d.%d\n",
13770 info.version.major,
13771 info.version.minor,
13772 info.version.update,
13773 info.version.draft);
13774 printf("Global Package name: %s\n\n", info.name);
13777 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13778 (uint8_t *)&info, sizeof(info),
13779 RTE_PMD_I40E_PKG_INFO_HEADER);
13781 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13782 printf("i40e Profile Version: %d.%d.%d.%d\n",
13783 info.version.major,
13784 info.version.minor,
13785 info.version.update,
13786 info.version.draft);
13787 printf("i40e Profile name: %s\n\n", info.name);
13790 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13791 (uint8_t *)&buff_size, sizeof(buff_size),
13792 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13793 if (!ret && buff_size) {
13794 buff = (uint8_t *)malloc(buff_size);
13796 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13798 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13800 printf("Package Notes:\n%s\n\n", buff);
13805 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13806 (uint8_t *)&dev_num, sizeof(dev_num),
13807 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13808 if (!ret && dev_num) {
13809 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13810 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13812 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13813 (uint8_t *)devs, buff_size,
13814 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13816 printf("List of supported devices:\n");
13817 for (i = 0; i < dev_num; i++) {
13818 printf(" %04X:%04X %04X:%04X\n",
13819 devs[i].vendor_dev_id >> 16,
13820 devs[i].vendor_dev_id & 0xFFFF,
13821 devs[i].sub_vendor_dev_id >> 16,
13822 devs[i].sub_vendor_dev_id & 0xFFFF);
13830 /* get information about protocols and packet types */
13831 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13832 (uint8_t *)&proto_num, sizeof(proto_num),
13833 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13834 if (ret || !proto_num)
13835 goto no_print_return;
13837 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13838 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13840 goto no_print_return;
13842 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13844 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13846 printf("List of used protocols:\n");
13847 for (i = 0; i < proto_num; i++)
13848 printf(" %2u: %s\n", proto[i].proto_id,
13852 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13853 (uint8_t *)&pctype_num, sizeof(pctype_num),
13854 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13855 if (ret || !pctype_num)
13856 goto no_print_pctypes;
13858 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13859 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13861 goto no_print_pctypes;
13863 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13865 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13868 goto no_print_pctypes;
13871 printf("List of defined packet classification types:\n");
13872 for (i = 0; i < pctype_num; i++) {
13873 printf(" %2u:", pctype[i].ptype_id);
13874 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13875 proto_id = pctype[i].protocols[j];
13876 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13877 for (n = 0; n < proto_num; n++) {
13878 if (proto[n].proto_id == proto_id) {
13879 printf(" %s", proto[n].name);
13892 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13894 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13895 if (ret || !ptype_num)
13896 goto no_print_return;
13898 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13899 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13901 goto no_print_return;
13903 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13905 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13908 goto no_print_return;
13910 printf("List of defined packet types:\n");
13911 for (i = 0; i < ptype_num; i++) {
13912 printf(" %2u:", ptype[i].ptype_id);
13913 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13914 proto_id = ptype[i].protocols[j];
13915 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13916 for (n = 0; n < proto_num; n++) {
13917 if (proto[n].proto_id == proto_id) {
13918 printf(" %s", proto[n].name);
13933 if (ret == -ENOTSUP)
13934 printf("Function not supported in PMD driver\n");
13935 close_ddp_package_file(pkg);
13938 cmdline_parse_inst_t cmd_ddp_get_info = {
13939 .f = cmd_ddp_info_parsed,
13941 .help_str = "ddp get info <profile_path>",
13943 (void *)&cmd_ddp_info_ddp,
13944 (void *)&cmd_ddp_info_get,
13945 (void *)&cmd_ddp_info_info,
13946 (void *)&cmd_ddp_info_filepath,
13951 /* Get dynamic device personalization profile info list*/
13952 #define PROFILE_INFO_SIZE 48
13953 #define MAX_PROFILE_NUM 16
13955 struct cmd_ddp_get_list_result {
13956 cmdline_fixed_string_t ddp;
13957 cmdline_fixed_string_t get;
13958 cmdline_fixed_string_t list;
13962 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13963 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13964 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13965 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13966 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13967 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13968 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13969 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13972 cmd_ddp_get_list_parsed(
13973 void *parsed_result,
13974 __attribute__((unused)) struct cmdline *cl,
13975 __attribute__((unused)) void *data)
13977 struct cmd_ddp_get_list_result *res = parsed_result;
13978 #ifdef RTE_LIBRTE_I40E_PMD
13979 struct rte_pmd_i40e_profile_list *p_list;
13980 struct rte_pmd_i40e_profile_info *p_info;
13985 int ret = -ENOTSUP;
13987 if (res->port_id > nb_ports) {
13988 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13992 #ifdef RTE_LIBRTE_I40E_PMD
13993 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13994 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13996 printf("%s: Failed to malloc buffer\n", __func__);
13998 if (ret == -ENOTSUP)
13999 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14000 (uint8_t *)p_list, size);
14003 p_num = p_list->p_count;
14004 printf("Profile number is: %d\n\n", p_num);
14006 for (i = 0; i < p_num; i++) {
14007 p_info = &p_list->p_info[i];
14008 printf("Profile %d:\n", i);
14009 printf("Track id: 0x%x\n", p_info->track_id);
14010 printf("Version: %d.%d.%d.%d\n",
14011 p_info->version.major,
14012 p_info->version.minor,
14013 p_info->version.update,
14014 p_info->version.draft);
14015 printf("Profile name: %s\n\n", p_info->name);
14023 printf("Failed to get ddp list\n");
14026 cmdline_parse_inst_t cmd_ddp_get_list = {
14027 .f = cmd_ddp_get_list_parsed,
14029 .help_str = "ddp get list <port_id>",
14031 (void *)&cmd_ddp_get_list_ddp,
14032 (void *)&cmd_ddp_get_list_get,
14033 (void *)&cmd_ddp_get_list_list,
14034 (void *)&cmd_ddp_get_list_port_id,
14039 /* show vf stats */
14041 /* Common result structure for show vf stats */
14042 struct cmd_show_vf_stats_result {
14043 cmdline_fixed_string_t show;
14044 cmdline_fixed_string_t vf;
14045 cmdline_fixed_string_t stats;
14050 /* Common CLI fields show vf stats*/
14051 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14052 TOKEN_STRING_INITIALIZER
14053 (struct cmd_show_vf_stats_result,
14055 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14056 TOKEN_STRING_INITIALIZER
14057 (struct cmd_show_vf_stats_result,
14059 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14060 TOKEN_STRING_INITIALIZER
14061 (struct cmd_show_vf_stats_result,
14063 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14064 TOKEN_NUM_INITIALIZER
14065 (struct cmd_show_vf_stats_result,
14067 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14068 TOKEN_NUM_INITIALIZER
14069 (struct cmd_show_vf_stats_result,
14073 cmd_show_vf_stats_parsed(
14074 void *parsed_result,
14075 __attribute__((unused)) struct cmdline *cl,
14076 __attribute__((unused)) void *data)
14078 struct cmd_show_vf_stats_result *res = parsed_result;
14079 struct rte_eth_stats stats;
14080 int ret = -ENOTSUP;
14081 static const char *nic_stats_border = "########################";
14083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14086 memset(&stats, 0, sizeof(stats));
14088 #ifdef RTE_LIBRTE_I40E_PMD
14089 if (ret == -ENOTSUP)
14090 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14094 #ifdef RTE_LIBRTE_BNXT_PMD
14095 if (ret == -ENOTSUP)
14096 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14105 printf("invalid vf_id %d\n", res->vf_id);
14108 printf("invalid port_id %d\n", res->port_id);
14111 printf("function not implemented\n");
14114 printf("programming error: (%s)\n", strerror(-ret));
14117 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14118 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14120 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14122 stats.ipackets, stats.imissed, stats.ibytes);
14123 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14124 printf(" RX-nombuf: %-10"PRIu64"\n",
14126 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14128 stats.opackets, stats.oerrors, stats.obytes);
14130 printf(" %s############################%s\n",
14131 nic_stats_border, nic_stats_border);
14134 cmdline_parse_inst_t cmd_show_vf_stats = {
14135 .f = cmd_show_vf_stats_parsed,
14137 .help_str = "show vf stats <port_id> <vf_id>",
14139 (void *)&cmd_show_vf_stats_show,
14140 (void *)&cmd_show_vf_stats_vf,
14141 (void *)&cmd_show_vf_stats_stats,
14142 (void *)&cmd_show_vf_stats_port_id,
14143 (void *)&cmd_show_vf_stats_vf_id,
14148 /* clear vf stats */
14150 /* Common result structure for clear vf stats */
14151 struct cmd_clear_vf_stats_result {
14152 cmdline_fixed_string_t clear;
14153 cmdline_fixed_string_t vf;
14154 cmdline_fixed_string_t stats;
14159 /* Common CLI fields clear vf stats*/
14160 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14161 TOKEN_STRING_INITIALIZER
14162 (struct cmd_clear_vf_stats_result,
14164 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14165 TOKEN_STRING_INITIALIZER
14166 (struct cmd_clear_vf_stats_result,
14168 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14169 TOKEN_STRING_INITIALIZER
14170 (struct cmd_clear_vf_stats_result,
14172 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14173 TOKEN_NUM_INITIALIZER
14174 (struct cmd_clear_vf_stats_result,
14176 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14177 TOKEN_NUM_INITIALIZER
14178 (struct cmd_clear_vf_stats_result,
14182 cmd_clear_vf_stats_parsed(
14183 void *parsed_result,
14184 __attribute__((unused)) struct cmdline *cl,
14185 __attribute__((unused)) void *data)
14187 struct cmd_clear_vf_stats_result *res = parsed_result;
14188 int ret = -ENOTSUP;
14190 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14193 #ifdef RTE_LIBRTE_I40E_PMD
14194 if (ret == -ENOTSUP)
14195 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14198 #ifdef RTE_LIBRTE_BNXT_PMD
14199 if (ret == -ENOTSUP)
14200 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14208 printf("invalid vf_id %d\n", res->vf_id);
14211 printf("invalid port_id %d\n", res->port_id);
14214 printf("function not implemented\n");
14217 printf("programming error: (%s)\n", strerror(-ret));
14221 cmdline_parse_inst_t cmd_clear_vf_stats = {
14222 .f = cmd_clear_vf_stats_parsed,
14224 .help_str = "clear vf stats <port_id> <vf_id>",
14226 (void *)&cmd_clear_vf_stats_clear,
14227 (void *)&cmd_clear_vf_stats_vf,
14228 (void *)&cmd_clear_vf_stats_stats,
14229 (void *)&cmd_clear_vf_stats_port_id,
14230 (void *)&cmd_clear_vf_stats_vf_id,
14235 /* port config pctype mapping reset */
14237 /* Common result structure for port config pctype mapping reset */
14238 struct cmd_pctype_mapping_reset_result {
14239 cmdline_fixed_string_t port;
14240 cmdline_fixed_string_t config;
14242 cmdline_fixed_string_t pctype;
14243 cmdline_fixed_string_t mapping;
14244 cmdline_fixed_string_t reset;
14247 /* Common CLI fields for port config pctype mapping reset*/
14248 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14249 TOKEN_STRING_INITIALIZER
14250 (struct cmd_pctype_mapping_reset_result,
14252 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14253 TOKEN_STRING_INITIALIZER
14254 (struct cmd_pctype_mapping_reset_result,
14256 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14257 TOKEN_NUM_INITIALIZER
14258 (struct cmd_pctype_mapping_reset_result,
14260 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14261 TOKEN_STRING_INITIALIZER
14262 (struct cmd_pctype_mapping_reset_result,
14264 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14265 TOKEN_STRING_INITIALIZER
14266 (struct cmd_pctype_mapping_reset_result,
14267 mapping, "mapping");
14268 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14269 TOKEN_STRING_INITIALIZER
14270 (struct cmd_pctype_mapping_reset_result,
14274 cmd_pctype_mapping_reset_parsed(
14275 void *parsed_result,
14276 __attribute__((unused)) struct cmdline *cl,
14277 __attribute__((unused)) void *data)
14279 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14280 int ret = -ENOTSUP;
14282 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14285 #ifdef RTE_LIBRTE_I40E_PMD
14286 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14293 printf("invalid port_id %d\n", res->port_id);
14296 printf("function not implemented\n");
14299 printf("programming error: (%s)\n", strerror(-ret));
14303 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14304 .f = cmd_pctype_mapping_reset_parsed,
14306 .help_str = "port config <port_id> pctype mapping reset",
14308 (void *)&cmd_pctype_mapping_reset_port,
14309 (void *)&cmd_pctype_mapping_reset_config,
14310 (void *)&cmd_pctype_mapping_reset_port_id,
14311 (void *)&cmd_pctype_mapping_reset_pctype,
14312 (void *)&cmd_pctype_mapping_reset_mapping,
14313 (void *)&cmd_pctype_mapping_reset_reset,
14318 /* show port pctype mapping */
14320 /* Common result structure for show port pctype mapping */
14321 struct cmd_pctype_mapping_get_result {
14322 cmdline_fixed_string_t show;
14323 cmdline_fixed_string_t port;
14325 cmdline_fixed_string_t pctype;
14326 cmdline_fixed_string_t mapping;
14329 /* Common CLI fields for pctype mapping get */
14330 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14331 TOKEN_STRING_INITIALIZER
14332 (struct cmd_pctype_mapping_get_result,
14334 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14335 TOKEN_STRING_INITIALIZER
14336 (struct cmd_pctype_mapping_get_result,
14338 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14339 TOKEN_NUM_INITIALIZER
14340 (struct cmd_pctype_mapping_get_result,
14342 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14343 TOKEN_STRING_INITIALIZER
14344 (struct cmd_pctype_mapping_get_result,
14346 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14347 TOKEN_STRING_INITIALIZER
14348 (struct cmd_pctype_mapping_get_result,
14349 mapping, "mapping");
14352 cmd_pctype_mapping_get_parsed(
14353 void *parsed_result,
14354 __attribute__((unused)) struct cmdline *cl,
14355 __attribute__((unused)) void *data)
14357 struct cmd_pctype_mapping_get_result *res = parsed_result;
14358 int ret = -ENOTSUP;
14359 #ifdef RTE_LIBRTE_I40E_PMD
14360 struct rte_pmd_i40e_flow_type_mapping
14361 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14362 int i, j, first_pctype;
14365 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14368 #ifdef RTE_LIBRTE_I40E_PMD
14369 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14376 printf("invalid port_id %d\n", res->port_id);
14379 printf("function not implemented\n");
14382 printf("programming error: (%s)\n", strerror(-ret));
14386 #ifdef RTE_LIBRTE_I40E_PMD
14387 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14388 if (mapping[i].pctype != 0ULL) {
14391 printf("pctype: ");
14392 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14393 if (mapping[i].pctype & (1ULL << j)) {
14394 printf(first_pctype ?
14395 "%02d" : ",%02d", j);
14399 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14405 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14406 .f = cmd_pctype_mapping_get_parsed,
14408 .help_str = "show port <port_id> pctype mapping",
14410 (void *)&cmd_pctype_mapping_get_show,
14411 (void *)&cmd_pctype_mapping_get_port,
14412 (void *)&cmd_pctype_mapping_get_port_id,
14413 (void *)&cmd_pctype_mapping_get_pctype,
14414 (void *)&cmd_pctype_mapping_get_mapping,
14419 /* port config pctype mapping update */
14421 /* Common result structure for port config pctype mapping update */
14422 struct cmd_pctype_mapping_update_result {
14423 cmdline_fixed_string_t port;
14424 cmdline_fixed_string_t config;
14426 cmdline_fixed_string_t pctype;
14427 cmdline_fixed_string_t mapping;
14428 cmdline_fixed_string_t update;
14429 cmdline_fixed_string_t pctype_list;
14430 uint16_t flow_type;
14433 /* Common CLI fields for pctype mapping update*/
14434 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14435 TOKEN_STRING_INITIALIZER
14436 (struct cmd_pctype_mapping_update_result,
14438 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14439 TOKEN_STRING_INITIALIZER
14440 (struct cmd_pctype_mapping_update_result,
14442 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14443 TOKEN_NUM_INITIALIZER
14444 (struct cmd_pctype_mapping_update_result,
14446 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14447 TOKEN_STRING_INITIALIZER
14448 (struct cmd_pctype_mapping_update_result,
14450 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14451 TOKEN_STRING_INITIALIZER
14452 (struct cmd_pctype_mapping_update_result,
14453 mapping, "mapping");
14454 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14455 TOKEN_STRING_INITIALIZER
14456 (struct cmd_pctype_mapping_update_result,
14458 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14459 TOKEN_STRING_INITIALIZER
14460 (struct cmd_pctype_mapping_update_result,
14461 pctype_list, NULL);
14462 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14463 TOKEN_NUM_INITIALIZER
14464 (struct cmd_pctype_mapping_update_result,
14465 flow_type, UINT16);
14468 cmd_pctype_mapping_update_parsed(
14469 void *parsed_result,
14470 __attribute__((unused)) struct cmdline *cl,
14471 __attribute__((unused)) void *data)
14473 struct cmd_pctype_mapping_update_result *res = parsed_result;
14474 int ret = -ENOTSUP;
14475 #ifdef RTE_LIBRTE_I40E_PMD
14476 struct rte_pmd_i40e_flow_type_mapping mapping;
14478 unsigned int nb_item;
14479 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14482 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14485 #ifdef RTE_LIBRTE_I40E_PMD
14486 nb_item = parse_item_list(res->pctype_list, "pctypes",
14487 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14488 mapping.flow_type = res->flow_type;
14489 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14490 mapping.pctype |= (1ULL << pctype_list[i]);
14491 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14501 printf("invalid pctype or flow type\n");
14504 printf("invalid port_id %d\n", res->port_id);
14507 printf("function not implemented\n");
14510 printf("programming error: (%s)\n", strerror(-ret));
14514 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14515 .f = cmd_pctype_mapping_update_parsed,
14517 .help_str = "port config <port_id> pctype mapping update"
14518 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14520 (void *)&cmd_pctype_mapping_update_port,
14521 (void *)&cmd_pctype_mapping_update_config,
14522 (void *)&cmd_pctype_mapping_update_port_id,
14523 (void *)&cmd_pctype_mapping_update_pctype,
14524 (void *)&cmd_pctype_mapping_update_mapping,
14525 (void *)&cmd_pctype_mapping_update_update,
14526 (void *)&cmd_pctype_mapping_update_pc_type,
14527 (void *)&cmd_pctype_mapping_update_flow_type,
14532 /* ptype mapping get */
14534 /* Common result structure for ptype mapping get */
14535 struct cmd_ptype_mapping_get_result {
14536 cmdline_fixed_string_t ptype;
14537 cmdline_fixed_string_t mapping;
14538 cmdline_fixed_string_t get;
14540 uint8_t valid_only;
14543 /* Common CLI fields for ptype mapping get */
14544 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14545 TOKEN_STRING_INITIALIZER
14546 (struct cmd_ptype_mapping_get_result,
14548 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14549 TOKEN_STRING_INITIALIZER
14550 (struct cmd_ptype_mapping_get_result,
14551 mapping, "mapping");
14552 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14553 TOKEN_STRING_INITIALIZER
14554 (struct cmd_ptype_mapping_get_result,
14556 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14557 TOKEN_NUM_INITIALIZER
14558 (struct cmd_ptype_mapping_get_result,
14560 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14561 TOKEN_NUM_INITIALIZER
14562 (struct cmd_ptype_mapping_get_result,
14563 valid_only, UINT8);
14566 cmd_ptype_mapping_get_parsed(
14567 void *parsed_result,
14568 __attribute__((unused)) struct cmdline *cl,
14569 __attribute__((unused)) void *data)
14571 struct cmd_ptype_mapping_get_result *res = parsed_result;
14572 int ret = -ENOTSUP;
14573 #ifdef RTE_LIBRTE_I40E_PMD
14574 int max_ptype_num = 256;
14575 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14580 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14583 #ifdef RTE_LIBRTE_I40E_PMD
14584 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14595 printf("invalid port_id %d\n", res->port_id);
14598 printf("function not implemented\n");
14601 printf("programming error: (%s)\n", strerror(-ret));
14604 #ifdef RTE_LIBRTE_I40E_PMD
14606 for (i = 0; i < count; i++)
14607 printf("%3d\t0x%08x\n",
14608 mapping[i].hw_ptype, mapping[i].sw_ptype);
14613 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14614 .f = cmd_ptype_mapping_get_parsed,
14616 .help_str = "ptype mapping get <port_id> <valid_only>",
14618 (void *)&cmd_ptype_mapping_get_ptype,
14619 (void *)&cmd_ptype_mapping_get_mapping,
14620 (void *)&cmd_ptype_mapping_get_get,
14621 (void *)&cmd_ptype_mapping_get_port_id,
14622 (void *)&cmd_ptype_mapping_get_valid_only,
14627 /* ptype mapping replace */
14629 /* Common result structure for ptype mapping replace */
14630 struct cmd_ptype_mapping_replace_result {
14631 cmdline_fixed_string_t ptype;
14632 cmdline_fixed_string_t mapping;
14633 cmdline_fixed_string_t replace;
14640 /* Common CLI fields for ptype mapping replace */
14641 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14642 TOKEN_STRING_INITIALIZER
14643 (struct cmd_ptype_mapping_replace_result,
14645 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14646 TOKEN_STRING_INITIALIZER
14647 (struct cmd_ptype_mapping_replace_result,
14648 mapping, "mapping");
14649 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14650 TOKEN_STRING_INITIALIZER
14651 (struct cmd_ptype_mapping_replace_result,
14652 replace, "replace");
14653 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14654 TOKEN_NUM_INITIALIZER
14655 (struct cmd_ptype_mapping_replace_result,
14657 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14658 TOKEN_NUM_INITIALIZER
14659 (struct cmd_ptype_mapping_replace_result,
14661 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14662 TOKEN_NUM_INITIALIZER
14663 (struct cmd_ptype_mapping_replace_result,
14665 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14666 TOKEN_NUM_INITIALIZER
14667 (struct cmd_ptype_mapping_replace_result,
14671 cmd_ptype_mapping_replace_parsed(
14672 void *parsed_result,
14673 __attribute__((unused)) struct cmdline *cl,
14674 __attribute__((unused)) void *data)
14676 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14677 int ret = -ENOTSUP;
14679 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14682 #ifdef RTE_LIBRTE_I40E_PMD
14683 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
14693 printf("invalid ptype 0x%8x or 0x%8x\n",
14694 res->target, res->pkt_type);
14697 printf("invalid port_id %d\n", res->port_id);
14700 printf("function not implemented\n");
14703 printf("programming error: (%s)\n", strerror(-ret));
14707 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
14708 .f = cmd_ptype_mapping_replace_parsed,
14711 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
14713 (void *)&cmd_ptype_mapping_replace_ptype,
14714 (void *)&cmd_ptype_mapping_replace_mapping,
14715 (void *)&cmd_ptype_mapping_replace_replace,
14716 (void *)&cmd_ptype_mapping_replace_port_id,
14717 (void *)&cmd_ptype_mapping_replace_target,
14718 (void *)&cmd_ptype_mapping_replace_mask,
14719 (void *)&cmd_ptype_mapping_replace_pkt_type,
14724 /* ptype mapping reset */
14726 /* Common result structure for ptype mapping reset */
14727 struct cmd_ptype_mapping_reset_result {
14728 cmdline_fixed_string_t ptype;
14729 cmdline_fixed_string_t mapping;
14730 cmdline_fixed_string_t reset;
14734 /* Common CLI fields for ptype mapping reset*/
14735 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
14736 TOKEN_STRING_INITIALIZER
14737 (struct cmd_ptype_mapping_reset_result,
14739 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
14740 TOKEN_STRING_INITIALIZER
14741 (struct cmd_ptype_mapping_reset_result,
14742 mapping, "mapping");
14743 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
14744 TOKEN_STRING_INITIALIZER
14745 (struct cmd_ptype_mapping_reset_result,
14747 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
14748 TOKEN_NUM_INITIALIZER
14749 (struct cmd_ptype_mapping_reset_result,
14753 cmd_ptype_mapping_reset_parsed(
14754 void *parsed_result,
14755 __attribute__((unused)) struct cmdline *cl,
14756 __attribute__((unused)) void *data)
14758 struct cmd_ptype_mapping_reset_result *res = parsed_result;
14759 int ret = -ENOTSUP;
14761 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14764 #ifdef RTE_LIBRTE_I40E_PMD
14765 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
14772 printf("invalid port_id %d\n", res->port_id);
14775 printf("function not implemented\n");
14778 printf("programming error: (%s)\n", strerror(-ret));
14782 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
14783 .f = cmd_ptype_mapping_reset_parsed,
14785 .help_str = "ptype mapping reset <port_id>",
14787 (void *)&cmd_ptype_mapping_reset_ptype,
14788 (void *)&cmd_ptype_mapping_reset_mapping,
14789 (void *)&cmd_ptype_mapping_reset_reset,
14790 (void *)&cmd_ptype_mapping_reset_port_id,
14795 /* ptype mapping update */
14797 /* Common result structure for ptype mapping update */
14798 struct cmd_ptype_mapping_update_result {
14799 cmdline_fixed_string_t ptype;
14800 cmdline_fixed_string_t mapping;
14801 cmdline_fixed_string_t reset;
14807 /* Common CLI fields for ptype mapping update*/
14808 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
14809 TOKEN_STRING_INITIALIZER
14810 (struct cmd_ptype_mapping_update_result,
14812 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
14813 TOKEN_STRING_INITIALIZER
14814 (struct cmd_ptype_mapping_update_result,
14815 mapping, "mapping");
14816 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
14817 TOKEN_STRING_INITIALIZER
14818 (struct cmd_ptype_mapping_update_result,
14820 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
14821 TOKEN_NUM_INITIALIZER
14822 (struct cmd_ptype_mapping_update_result,
14824 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14825 TOKEN_NUM_INITIALIZER
14826 (struct cmd_ptype_mapping_update_result,
14828 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14829 TOKEN_NUM_INITIALIZER
14830 (struct cmd_ptype_mapping_update_result,
14834 cmd_ptype_mapping_update_parsed(
14835 void *parsed_result,
14836 __attribute__((unused)) struct cmdline *cl,
14837 __attribute__((unused)) void *data)
14839 struct cmd_ptype_mapping_update_result *res = parsed_result;
14840 int ret = -ENOTSUP;
14841 #ifdef RTE_LIBRTE_I40E_PMD
14842 struct rte_pmd_i40e_ptype_mapping mapping;
14844 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14847 #ifdef RTE_LIBRTE_I40E_PMD
14848 mapping.hw_ptype = res->hw_ptype;
14849 mapping.sw_ptype = res->sw_ptype;
14850 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14860 printf("invalid ptype 0x%8x\n", res->sw_ptype);
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_ptype_mapping_update = {
14874 .f = cmd_ptype_mapping_update_parsed,
14876 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14878 (void *)&cmd_ptype_mapping_update_ptype,
14879 (void *)&cmd_ptype_mapping_update_mapping,
14880 (void *)&cmd_ptype_mapping_update_update,
14881 (void *)&cmd_ptype_mapping_update_port_id,
14882 (void *)&cmd_ptype_mapping_update_hw_ptype,
14883 (void *)&cmd_ptype_mapping_update_sw_ptype,
14888 /* Common result structure for file commands */
14889 struct cmd_cmdfile_result {
14890 cmdline_fixed_string_t load;
14891 cmdline_fixed_string_t filename;
14894 /* Common CLI fields for file commands */
14895 cmdline_parse_token_string_t cmd_load_cmdfile =
14896 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14897 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14898 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14901 cmd_load_from_file_parsed(
14902 void *parsed_result,
14903 __attribute__((unused)) struct cmdline *cl,
14904 __attribute__((unused)) void *data)
14906 struct cmd_cmdfile_result *res = parsed_result;
14908 cmdline_read_from_file(res->filename);
14911 cmdline_parse_inst_t cmd_load_from_file = {
14912 .f = cmd_load_from_file_parsed,
14914 .help_str = "load <filename>",
14916 (void *)&cmd_load_cmdfile,
14917 (void *)&cmd_load_cmdfile_filename,
14922 /* ******************************************************************************** */
14924 /* list of instructions */
14925 cmdline_parse_ctx_t main_ctx[] = {
14926 (cmdline_parse_inst_t *)&cmd_help_brief,
14927 (cmdline_parse_inst_t *)&cmd_help_long,
14928 (cmdline_parse_inst_t *)&cmd_quit,
14929 (cmdline_parse_inst_t *)&cmd_load_from_file,
14930 (cmdline_parse_inst_t *)&cmd_showport,
14931 (cmdline_parse_inst_t *)&cmd_showqueue,
14932 (cmdline_parse_inst_t *)&cmd_showportall,
14933 (cmdline_parse_inst_t *)&cmd_showcfg,
14934 (cmdline_parse_inst_t *)&cmd_start,
14935 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14936 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14937 (cmdline_parse_inst_t *)&cmd_set_link_up,
14938 (cmdline_parse_inst_t *)&cmd_set_link_down,
14939 (cmdline_parse_inst_t *)&cmd_reset,
14940 (cmdline_parse_inst_t *)&cmd_set_numbers,
14941 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14942 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14943 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14944 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14945 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14946 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14947 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14948 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14949 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14950 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14951 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14952 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14953 (cmdline_parse_inst_t *)&cmd_set_link_check,
14954 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14955 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14956 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14957 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14958 #ifdef RTE_LIBRTE_PMD_BOND
14959 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14960 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14961 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14962 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14963 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14964 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14965 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14966 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14967 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14968 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14969 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
14971 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14972 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14973 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14974 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14975 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14976 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14977 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14978 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14979 (cmdline_parse_inst_t *)&cmd_csum_set,
14980 (cmdline_parse_inst_t *)&cmd_csum_show,
14981 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14982 (cmdline_parse_inst_t *)&cmd_tso_set,
14983 (cmdline_parse_inst_t *)&cmd_tso_show,
14984 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14985 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14986 (cmdline_parse_inst_t *)&cmd_gro_enable,
14987 (cmdline_parse_inst_t *)&cmd_gro_flush,
14988 (cmdline_parse_inst_t *)&cmd_gro_show,
14989 (cmdline_parse_inst_t *)&cmd_gso_enable,
14990 (cmdline_parse_inst_t *)&cmd_gso_size,
14991 (cmdline_parse_inst_t *)&cmd_gso_show,
14992 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14993 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14994 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14995 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14996 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14997 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14998 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14999 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15000 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15001 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15002 (cmdline_parse_inst_t *)&cmd_config_dcb,
15003 (cmdline_parse_inst_t *)&cmd_read_reg,
15004 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15005 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15006 (cmdline_parse_inst_t *)&cmd_write_reg,
15007 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15008 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15009 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15010 (cmdline_parse_inst_t *)&cmd_stop,
15011 (cmdline_parse_inst_t *)&cmd_mac_addr,
15012 (cmdline_parse_inst_t *)&cmd_set_qmap,
15013 (cmdline_parse_inst_t *)&cmd_operate_port,
15014 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15015 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15016 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15017 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15018 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15019 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15020 (cmdline_parse_inst_t *)&cmd_config_mtu,
15021 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15022 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15023 (cmdline_parse_inst_t *)&cmd_config_rss,
15024 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15025 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15026 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15027 (cmdline_parse_inst_t *)&cmd_showport_reta,
15028 (cmdline_parse_inst_t *)&cmd_config_burst,
15029 (cmdline_parse_inst_t *)&cmd_config_thresh,
15030 (cmdline_parse_inst_t *)&cmd_config_threshold,
15031 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15032 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15033 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15034 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15035 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15036 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15037 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15038 (cmdline_parse_inst_t *)&cmd_global_config,
15039 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15040 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15041 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15042 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15043 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15044 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15045 (cmdline_parse_inst_t *)&cmd_dump,
15046 (cmdline_parse_inst_t *)&cmd_dump_one,
15047 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15048 (cmdline_parse_inst_t *)&cmd_syn_filter,
15049 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15050 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15051 (cmdline_parse_inst_t *)&cmd_flex_filter,
15052 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15053 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15054 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15055 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15056 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15057 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15058 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15059 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15060 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15061 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15062 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15063 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15064 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15065 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15066 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15067 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15068 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15069 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15070 (cmdline_parse_inst_t *)&cmd_flow,
15071 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15072 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15073 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15074 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15075 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15076 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15077 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15078 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15079 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15080 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15081 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15082 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15083 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15084 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15085 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15086 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15087 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15088 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15089 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15090 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15091 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15092 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15093 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15094 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15095 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15096 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15097 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15098 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15099 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15100 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15101 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15102 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15103 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15104 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15105 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15106 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15107 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15108 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15110 (cmdline_parse_inst_t *)&cmd_ddp_add,
15111 (cmdline_parse_inst_t *)&cmd_ddp_del,
15112 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15113 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15114 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15115 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15116 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15117 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15118 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15119 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15121 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15122 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15123 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15127 /* read cmdline commands from file */
15129 cmdline_read_from_file(const char *filename)
15131 struct cmdline *cl;
15133 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15135 printf("Failed to create file based cmdline context: %s\n",
15140 cmdline_interact(cl);
15145 printf("Read CLI commands from %s\n", filename);
15148 /* prompt function, called from main on MASTER lcore */
15152 /* initialize non-constant commands */
15153 cmd_set_fwd_mode_init();
15154 cmd_set_fwd_retry_mode_init();
15156 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15157 if (testpmd_cl == NULL)
15159 cmdline_interact(testpmd_cl);
15160 cmdline_stdin_exit(testpmd_cl);
15166 if (testpmd_cl != NULL)
15167 cmdline_quit(testpmd_cl);
15171 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15173 if (id == (portid_t)RTE_PORT_ALL) {
15176 RTE_ETH_FOREACH_DEV(pid) {
15177 /* check if need_reconfig has been set to 1 */
15178 if (ports[pid].need_reconfig == 0)
15179 ports[pid].need_reconfig = dev;
15180 /* check if need_reconfig_queues has been set to 1 */
15181 if (ports[pid].need_reconfig_queues == 0)
15182 ports[pid].need_reconfig_queues = queue;
15184 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15185 /* check if need_reconfig has been set to 1 */
15186 if (ports[id].need_reconfig == 0)
15187 ports[id].need_reconfig = dev;
15188 /* check if need_reconfig_queues has been set to 1 */
15189 if (ports[id].need_reconfig_queues == 0)
15190 ports[id].need_reconfig_queues = queue;