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|rx-timestamp|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, "rx-timestamp")) {
1623 if (!strcmp(res->value, "on"))
1624 rx_mode.hw_timestamp = 1;
1625 else if (!strcmp(res->value, "off"))
1626 rx_mode.hw_timestamp = 0;
1628 printf("Unknown parameter\n");
1631 } else if (!strcmp(res->name, "hw-vlan")) {
1632 if (!strcmp(res->value, "on")) {
1633 rx_mode.hw_vlan_filter = 1;
1634 rx_mode.hw_vlan_strip = 1;
1636 else if (!strcmp(res->value, "off")) {
1637 rx_mode.hw_vlan_filter = 0;
1638 rx_mode.hw_vlan_strip = 0;
1641 printf("Unknown parameter\n");
1644 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1645 if (!strcmp(res->value, "on"))
1646 rx_mode.hw_vlan_filter = 1;
1647 else if (!strcmp(res->value, "off"))
1648 rx_mode.hw_vlan_filter = 0;
1650 printf("Unknown parameter\n");
1653 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1654 if (!strcmp(res->value, "on"))
1655 rx_mode.hw_vlan_strip = 1;
1656 else if (!strcmp(res->value, "off"))
1657 rx_mode.hw_vlan_strip = 0;
1659 printf("Unknown parameter\n");
1662 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1663 if (!strcmp(res->value, "on"))
1664 rx_mode.hw_vlan_extend = 1;
1665 else if (!strcmp(res->value, "off"))
1666 rx_mode.hw_vlan_extend = 0;
1668 printf("Unknown parameter\n");
1671 } else if (!strcmp(res->name, "drop-en")) {
1672 if (!strcmp(res->value, "on"))
1674 else if (!strcmp(res->value, "off"))
1677 printf("Unknown parameter\n");
1681 printf("Unknown parameter\n");
1687 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1690 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1692 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1693 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1695 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1697 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1699 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1700 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1701 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1705 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1706 .f = cmd_config_rx_mode_flag_parsed,
1708 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1709 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1711 (void *)&cmd_config_rx_mode_flag_port,
1712 (void *)&cmd_config_rx_mode_flag_keyword,
1713 (void *)&cmd_config_rx_mode_flag_all,
1714 (void *)&cmd_config_rx_mode_flag_name,
1715 (void *)&cmd_config_rx_mode_flag_value,
1720 /* *** configure rss *** */
1721 struct cmd_config_rss {
1722 cmdline_fixed_string_t port;
1723 cmdline_fixed_string_t keyword;
1724 cmdline_fixed_string_t all;
1725 cmdline_fixed_string_t name;
1726 cmdline_fixed_string_t value;
1730 cmd_config_rss_parsed(void *parsed_result,
1731 __attribute__((unused)) struct cmdline *cl,
1732 __attribute__((unused)) void *data)
1734 struct cmd_config_rss *res = parsed_result;
1735 struct rte_eth_rss_conf rss_conf;
1739 if (!strcmp(res->value, "all"))
1740 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1741 ETH_RSS_UDP | ETH_RSS_SCTP |
1743 else if (!strcmp(res->value, "ip"))
1744 rss_conf.rss_hf = ETH_RSS_IP;
1745 else if (!strcmp(res->value, "udp"))
1746 rss_conf.rss_hf = ETH_RSS_UDP;
1747 else if (!strcmp(res->value, "tcp"))
1748 rss_conf.rss_hf = ETH_RSS_TCP;
1749 else if (!strcmp(res->value, "sctp"))
1750 rss_conf.rss_hf = ETH_RSS_SCTP;
1751 else if (!strcmp(res->value, "ether"))
1752 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1753 else if (!strcmp(res->value, "port"))
1754 rss_conf.rss_hf = ETH_RSS_PORT;
1755 else if (!strcmp(res->value, "vxlan"))
1756 rss_conf.rss_hf = ETH_RSS_VXLAN;
1757 else if (!strcmp(res->value, "geneve"))
1758 rss_conf.rss_hf = ETH_RSS_GENEVE;
1759 else if (!strcmp(res->value, "nvgre"))
1760 rss_conf.rss_hf = ETH_RSS_NVGRE;
1761 else if (!strcmp(res->value, "none"))
1762 rss_conf.rss_hf = 0;
1763 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1764 atoi(res->value) < 64)
1765 rss_conf.rss_hf = 1ULL << atoi(res->value);
1767 printf("Unknown parameter\n");
1770 rss_conf.rss_key = NULL;
1771 for (i = 0; i < rte_eth_dev_count(); i++) {
1772 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1774 printf("Configuration of RSS hash at ethernet port %d "
1775 "failed with error (%d): %s.\n",
1776 i, -diag, strerror(-diag));
1780 cmdline_parse_token_string_t cmd_config_rss_port =
1781 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1782 cmdline_parse_token_string_t cmd_config_rss_keyword =
1783 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1784 cmdline_parse_token_string_t cmd_config_rss_all =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1786 cmdline_parse_token_string_t cmd_config_rss_name =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1788 cmdline_parse_token_string_t cmd_config_rss_value =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1791 cmdline_parse_inst_t cmd_config_rss = {
1792 .f = cmd_config_rss_parsed,
1794 .help_str = "port config all rss "
1795 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1797 (void *)&cmd_config_rss_port,
1798 (void *)&cmd_config_rss_keyword,
1799 (void *)&cmd_config_rss_all,
1800 (void *)&cmd_config_rss_name,
1801 (void *)&cmd_config_rss_value,
1806 /* *** configure rss hash key *** */
1807 struct cmd_config_rss_hash_key {
1808 cmdline_fixed_string_t port;
1809 cmdline_fixed_string_t config;
1811 cmdline_fixed_string_t rss_hash_key;
1812 cmdline_fixed_string_t rss_type;
1813 cmdline_fixed_string_t key;
1817 hexa_digit_to_value(char hexa_digit)
1819 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1820 return (uint8_t) (hexa_digit - '0');
1821 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1822 return (uint8_t) ((hexa_digit - 'a') + 10);
1823 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1824 return (uint8_t) ((hexa_digit - 'A') + 10);
1825 /* Invalid hexa digit */
1830 parse_and_check_key_hexa_digit(char *key, int idx)
1834 hexa_v = hexa_digit_to_value(key[idx]);
1836 printf("invalid key: character %c at position %d is not a "
1837 "valid hexa digit\n", key[idx], idx);
1842 cmd_config_rss_hash_key_parsed(void *parsed_result,
1843 __attribute__((unused)) struct cmdline *cl,
1844 __attribute__((unused)) void *data)
1846 struct cmd_config_rss_hash_key *res = parsed_result;
1847 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1851 struct rte_eth_dev_info dev_info;
1852 uint8_t hash_key_size;
1855 memset(&dev_info, 0, sizeof(dev_info));
1856 rte_eth_dev_info_get(res->port_id, &dev_info);
1857 if (dev_info.hash_key_size > 0 &&
1858 dev_info.hash_key_size <= sizeof(hash_key))
1859 hash_key_size = dev_info.hash_key_size;
1861 printf("dev_info did not provide a valid hash key size\n");
1864 /* Check the length of the RSS hash key */
1865 key_len = strlen(res->key);
1866 if (key_len != (hash_key_size * 2)) {
1867 printf("key length: %d invalid - key must be a string of %d"
1868 " hexa-decimal numbers\n",
1869 (int) key_len, hash_key_size * 2);
1872 /* Translate RSS hash key into binary representation */
1873 for (i = 0; i < hash_key_size; i++) {
1874 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1877 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1880 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1882 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1886 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1887 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1888 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1889 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1891 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1892 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1893 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1894 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1895 rss_hash_key, "rss-hash-key");
1896 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1897 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1898 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1899 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1900 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1901 "ipv6-tcp-ex#ipv6-udp-ex");
1902 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1903 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1905 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1906 .f = cmd_config_rss_hash_key_parsed,
1908 .help_str = "port config <port_id> rss-hash-key "
1909 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1910 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1911 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1912 "<string of hex digits (variable length, NIC dependent)>",
1914 (void *)&cmd_config_rss_hash_key_port,
1915 (void *)&cmd_config_rss_hash_key_config,
1916 (void *)&cmd_config_rss_hash_key_port_id,
1917 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1918 (void *)&cmd_config_rss_hash_key_rss_type,
1919 (void *)&cmd_config_rss_hash_key_value,
1924 /* *** configure port rxq/txq start/stop *** */
1925 struct cmd_config_rxtx_queue {
1926 cmdline_fixed_string_t port;
1928 cmdline_fixed_string_t rxtxq;
1930 cmdline_fixed_string_t opname;
1934 cmd_config_rxtx_queue_parsed(void *parsed_result,
1935 __attribute__((unused)) struct cmdline *cl,
1936 __attribute__((unused)) void *data)
1938 struct cmd_config_rxtx_queue *res = parsed_result;
1943 if (test_done == 0) {
1944 printf("Please stop forwarding first\n");
1948 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1951 if (port_is_started(res->portid) != 1) {
1952 printf("Please start port %u first\n", res->portid);
1956 if (!strcmp(res->rxtxq, "rxq"))
1958 else if (!strcmp(res->rxtxq, "txq"))
1961 printf("Unknown parameter\n");
1965 if (isrx && rx_queue_id_is_invalid(res->qid))
1967 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1970 if (!strcmp(res->opname, "start"))
1972 else if (!strcmp(res->opname, "stop"))
1975 printf("Unknown parameter\n");
1979 if (isstart && isrx)
1980 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1981 else if (!isstart && isrx)
1982 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1983 else if (isstart && !isrx)
1984 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1986 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1988 if (ret == -ENOTSUP)
1989 printf("Function not supported in PMD driver\n");
1992 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1993 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1994 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1995 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1996 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1997 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1998 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1999 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2000 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2001 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2004 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2005 .f = cmd_config_rxtx_queue_parsed,
2007 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2009 (void *)&cmd_config_speed_all_port,
2010 (void *)&cmd_config_rxtx_queue_portid,
2011 (void *)&cmd_config_rxtx_queue_rxtxq,
2012 (void *)&cmd_config_rxtx_queue_qid,
2013 (void *)&cmd_config_rxtx_queue_opname,
2018 /* *** Configure RSS RETA *** */
2019 struct cmd_config_rss_reta {
2020 cmdline_fixed_string_t port;
2021 cmdline_fixed_string_t keyword;
2023 cmdline_fixed_string_t name;
2024 cmdline_fixed_string_t list_name;
2025 cmdline_fixed_string_t list_of_items;
2029 parse_reta_config(const char *str,
2030 struct rte_eth_rss_reta_entry64 *reta_conf,
2031 uint16_t nb_entries)
2035 uint16_t hash_index, idx, shift;
2038 const char *p, *p0 = str;
2045 unsigned long int_fld[_NUM_FLD];
2046 char *str_fld[_NUM_FLD];
2048 while ((p = strchr(p0,'(')) != NULL) {
2050 if((p0 = strchr(p,')')) == NULL)
2054 if(size >= sizeof(s))
2057 snprintf(s, sizeof(s), "%.*s", size, p);
2058 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2060 for (i = 0; i < _NUM_FLD; i++) {
2062 int_fld[i] = strtoul(str_fld[i], &end, 0);
2063 if (errno != 0 || end == str_fld[i] ||
2068 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2069 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2071 if (hash_index >= nb_entries) {
2072 printf("Invalid RETA hash index=%d\n", hash_index);
2076 idx = hash_index / RTE_RETA_GROUP_SIZE;
2077 shift = hash_index % RTE_RETA_GROUP_SIZE;
2078 reta_conf[idx].mask |= (1ULL << shift);
2079 reta_conf[idx].reta[shift] = nb_queue;
2086 cmd_set_rss_reta_parsed(void *parsed_result,
2087 __attribute__((unused)) struct cmdline *cl,
2088 __attribute__((unused)) void *data)
2091 struct rte_eth_dev_info dev_info;
2092 struct rte_eth_rss_reta_entry64 reta_conf[8];
2093 struct cmd_config_rss_reta *res = parsed_result;
2095 memset(&dev_info, 0, sizeof(dev_info));
2096 rte_eth_dev_info_get(res->port_id, &dev_info);
2097 if (dev_info.reta_size == 0) {
2098 printf("Redirection table size is 0 which is "
2099 "invalid for RSS\n");
2102 printf("The reta size of port %d is %u\n",
2103 res->port_id, dev_info.reta_size);
2104 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2105 printf("Currently do not support more than %u entries of "
2106 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2110 memset(reta_conf, 0, sizeof(reta_conf));
2111 if (!strcmp(res->list_name, "reta")) {
2112 if (parse_reta_config(res->list_of_items, reta_conf,
2113 dev_info.reta_size)) {
2114 printf("Invalid RSS Redirection Table "
2115 "config entered\n");
2118 ret = rte_eth_dev_rss_reta_update(res->port_id,
2119 reta_conf, dev_info.reta_size);
2121 printf("Bad redirection table parameter, "
2122 "return code = %d \n", ret);
2126 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2128 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2130 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2131 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2132 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2134 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2136 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2139 cmdline_parse_inst_t cmd_config_rss_reta = {
2140 .f = cmd_set_rss_reta_parsed,
2142 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2144 (void *)&cmd_config_rss_reta_port,
2145 (void *)&cmd_config_rss_reta_keyword,
2146 (void *)&cmd_config_rss_reta_port_id,
2147 (void *)&cmd_config_rss_reta_name,
2148 (void *)&cmd_config_rss_reta_list_name,
2149 (void *)&cmd_config_rss_reta_list_of_items,
2154 /* *** SHOW PORT RETA INFO *** */
2155 struct cmd_showport_reta {
2156 cmdline_fixed_string_t show;
2157 cmdline_fixed_string_t port;
2159 cmdline_fixed_string_t rss;
2160 cmdline_fixed_string_t reta;
2162 cmdline_fixed_string_t list_of_items;
2166 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2167 uint16_t nb_entries,
2171 const char *p, *p0 = str;
2176 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2177 RTE_RETA_GROUP_SIZE;
2180 p = strchr(p0, '(');
2184 p0 = strchr(p, ')');
2188 if (size >= sizeof(s)) {
2189 printf("The string size exceeds the internal buffer size\n");
2192 snprintf(s, sizeof(s), "%.*s", size, p);
2193 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2194 if (ret <= 0 || ret != num) {
2195 printf("The bits of masks do not match the number of "
2196 "reta entries: %u\n", num);
2199 for (i = 0; i < ret; i++)
2200 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2206 cmd_showport_reta_parsed(void *parsed_result,
2207 __attribute__((unused)) struct cmdline *cl,
2208 __attribute__((unused)) void *data)
2210 struct cmd_showport_reta *res = parsed_result;
2211 struct rte_eth_rss_reta_entry64 reta_conf[8];
2212 struct rte_eth_dev_info dev_info;
2213 uint16_t max_reta_size;
2215 memset(&dev_info, 0, sizeof(dev_info));
2216 rte_eth_dev_info_get(res->port_id, &dev_info);
2217 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2218 if (res->size == 0 || res->size > max_reta_size) {
2219 printf("Invalid redirection table size: %u (1-%u)\n",
2220 res->size, max_reta_size);
2224 memset(reta_conf, 0, sizeof(reta_conf));
2225 if (showport_parse_reta_config(reta_conf, res->size,
2226 res->list_of_items) < 0) {
2227 printf("Invalid string: %s for reta masks\n",
2228 res->list_of_items);
2231 port_rss_reta_info(res->port_id, reta_conf, res->size);
2234 cmdline_parse_token_string_t cmd_showport_reta_show =
2235 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2236 cmdline_parse_token_string_t cmd_showport_reta_port =
2237 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2238 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2239 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2240 cmdline_parse_token_string_t cmd_showport_reta_rss =
2241 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2242 cmdline_parse_token_string_t cmd_showport_reta_reta =
2243 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2244 cmdline_parse_token_num_t cmd_showport_reta_size =
2245 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2246 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2247 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2248 list_of_items, NULL);
2250 cmdline_parse_inst_t cmd_showport_reta = {
2251 .f = cmd_showport_reta_parsed,
2253 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2255 (void *)&cmd_showport_reta_show,
2256 (void *)&cmd_showport_reta_port,
2257 (void *)&cmd_showport_reta_port_id,
2258 (void *)&cmd_showport_reta_rss,
2259 (void *)&cmd_showport_reta_reta,
2260 (void *)&cmd_showport_reta_size,
2261 (void *)&cmd_showport_reta_list_of_items,
2266 /* *** Show RSS hash configuration *** */
2267 struct cmd_showport_rss_hash {
2268 cmdline_fixed_string_t show;
2269 cmdline_fixed_string_t port;
2271 cmdline_fixed_string_t rss_hash;
2272 cmdline_fixed_string_t rss_type;
2273 cmdline_fixed_string_t key; /* optional argument */
2276 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2277 __attribute__((unused)) struct cmdline *cl,
2280 struct cmd_showport_rss_hash *res = parsed_result;
2282 port_rss_hash_conf_show(res->port_id, res->rss_type,
2283 show_rss_key != NULL);
2286 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2287 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2288 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2289 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2290 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2291 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2292 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2293 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2295 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2296 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2297 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2298 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2299 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2300 "ipv6-tcp-ex#ipv6-udp-ex");
2301 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2302 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2304 cmdline_parse_inst_t cmd_showport_rss_hash = {
2305 .f = cmd_showport_rss_hash_parsed,
2307 .help_str = "show port <port_id> rss-hash "
2308 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2309 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2310 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2312 (void *)&cmd_showport_rss_hash_show,
2313 (void *)&cmd_showport_rss_hash_port,
2314 (void *)&cmd_showport_rss_hash_port_id,
2315 (void *)&cmd_showport_rss_hash_rss_hash,
2316 (void *)&cmd_showport_rss_hash_rss_hash_info,
2321 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2322 .f = cmd_showport_rss_hash_parsed,
2324 .help_str = "show port <port_id> rss-hash "
2325 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2326 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2327 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2329 (void *)&cmd_showport_rss_hash_show,
2330 (void *)&cmd_showport_rss_hash_port,
2331 (void *)&cmd_showport_rss_hash_port_id,
2332 (void *)&cmd_showport_rss_hash_rss_hash,
2333 (void *)&cmd_showport_rss_hash_rss_hash_info,
2334 (void *)&cmd_showport_rss_hash_rss_key,
2339 /* *** Configure DCB *** */
2340 struct cmd_config_dcb {
2341 cmdline_fixed_string_t port;
2342 cmdline_fixed_string_t config;
2344 cmdline_fixed_string_t dcb;
2345 cmdline_fixed_string_t vt;
2346 cmdline_fixed_string_t vt_en;
2348 cmdline_fixed_string_t pfc;
2349 cmdline_fixed_string_t pfc_en;
2353 cmd_config_dcb_parsed(void *parsed_result,
2354 __attribute__((unused)) struct cmdline *cl,
2355 __attribute__((unused)) void *data)
2357 struct cmd_config_dcb *res = parsed_result;
2358 portid_t port_id = res->port_id;
2359 struct rte_port *port;
2363 port = &ports[port_id];
2364 /** Check if the port is not started **/
2365 if (port->port_status != RTE_PORT_STOPPED) {
2366 printf("Please stop port %d first\n", port_id);
2370 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2371 printf("The invalid number of traffic class,"
2372 " only 4 or 8 allowed.\n");
2376 if (nb_fwd_lcores < res->num_tcs) {
2377 printf("nb_cores shouldn't be less than number of TCs.\n");
2380 if (!strncmp(res->pfc_en, "on", 2))
2385 /* DCB in VT mode */
2386 if (!strncmp(res->vt_en, "on", 2))
2387 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2388 (enum rte_eth_nb_tcs)res->num_tcs,
2391 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2392 (enum rte_eth_nb_tcs)res->num_tcs,
2397 printf("Cannot initialize network ports.\n");
2401 cmd_reconfig_device_queue(port_id, 1, 1);
2404 cmdline_parse_token_string_t cmd_config_dcb_port =
2405 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2406 cmdline_parse_token_string_t cmd_config_dcb_config =
2407 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2408 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2409 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2410 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2411 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2412 cmdline_parse_token_string_t cmd_config_dcb_vt =
2413 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2414 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2416 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2417 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2418 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2420 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2423 cmdline_parse_inst_t cmd_config_dcb = {
2424 .f = cmd_config_dcb_parsed,
2426 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2428 (void *)&cmd_config_dcb_port,
2429 (void *)&cmd_config_dcb_config,
2430 (void *)&cmd_config_dcb_port_id,
2431 (void *)&cmd_config_dcb_dcb,
2432 (void *)&cmd_config_dcb_vt,
2433 (void *)&cmd_config_dcb_vt_en,
2434 (void *)&cmd_config_dcb_num_tcs,
2435 (void *)&cmd_config_dcb_pfc,
2436 (void *)&cmd_config_dcb_pfc_en,
2441 /* *** configure number of packets per burst *** */
2442 struct cmd_config_burst {
2443 cmdline_fixed_string_t port;
2444 cmdline_fixed_string_t keyword;
2445 cmdline_fixed_string_t all;
2446 cmdline_fixed_string_t name;
2451 cmd_config_burst_parsed(void *parsed_result,
2452 __attribute__((unused)) struct cmdline *cl,
2453 __attribute__((unused)) void *data)
2455 struct cmd_config_burst *res = parsed_result;
2457 if (!all_ports_stopped()) {
2458 printf("Please stop all ports first\n");
2462 if (!strcmp(res->name, "burst")) {
2463 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2464 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2467 nb_pkt_per_burst = res->value;
2469 printf("Unknown parameter\n");
2475 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2478 cmdline_parse_token_string_t cmd_config_burst_port =
2479 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2480 cmdline_parse_token_string_t cmd_config_burst_keyword =
2481 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2482 cmdline_parse_token_string_t cmd_config_burst_all =
2483 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2484 cmdline_parse_token_string_t cmd_config_burst_name =
2485 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2486 cmdline_parse_token_num_t cmd_config_burst_value =
2487 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2489 cmdline_parse_inst_t cmd_config_burst = {
2490 .f = cmd_config_burst_parsed,
2492 .help_str = "port config all burst <value>",
2494 (void *)&cmd_config_burst_port,
2495 (void *)&cmd_config_burst_keyword,
2496 (void *)&cmd_config_burst_all,
2497 (void *)&cmd_config_burst_name,
2498 (void *)&cmd_config_burst_value,
2503 /* *** configure rx/tx queues *** */
2504 struct cmd_config_thresh {
2505 cmdline_fixed_string_t port;
2506 cmdline_fixed_string_t keyword;
2507 cmdline_fixed_string_t all;
2508 cmdline_fixed_string_t name;
2513 cmd_config_thresh_parsed(void *parsed_result,
2514 __attribute__((unused)) struct cmdline *cl,
2515 __attribute__((unused)) void *data)
2517 struct cmd_config_thresh *res = parsed_result;
2519 if (!all_ports_stopped()) {
2520 printf("Please stop all ports first\n");
2524 if (!strcmp(res->name, "txpt"))
2525 tx_pthresh = res->value;
2526 else if(!strcmp(res->name, "txht"))
2527 tx_hthresh = res->value;
2528 else if(!strcmp(res->name, "txwt"))
2529 tx_wthresh = res->value;
2530 else if(!strcmp(res->name, "rxpt"))
2531 rx_pthresh = res->value;
2532 else if(!strcmp(res->name, "rxht"))
2533 rx_hthresh = res->value;
2534 else if(!strcmp(res->name, "rxwt"))
2535 rx_wthresh = res->value;
2537 printf("Unknown parameter\n");
2543 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2546 cmdline_parse_token_string_t cmd_config_thresh_port =
2547 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2548 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2549 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2550 cmdline_parse_token_string_t cmd_config_thresh_all =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2552 cmdline_parse_token_string_t cmd_config_thresh_name =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2554 "txpt#txht#txwt#rxpt#rxht#rxwt");
2555 cmdline_parse_token_num_t cmd_config_thresh_value =
2556 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2558 cmdline_parse_inst_t cmd_config_thresh = {
2559 .f = cmd_config_thresh_parsed,
2561 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2563 (void *)&cmd_config_thresh_port,
2564 (void *)&cmd_config_thresh_keyword,
2565 (void *)&cmd_config_thresh_all,
2566 (void *)&cmd_config_thresh_name,
2567 (void *)&cmd_config_thresh_value,
2572 /* *** configure free/rs threshold *** */
2573 struct cmd_config_threshold {
2574 cmdline_fixed_string_t port;
2575 cmdline_fixed_string_t keyword;
2576 cmdline_fixed_string_t all;
2577 cmdline_fixed_string_t name;
2582 cmd_config_threshold_parsed(void *parsed_result,
2583 __attribute__((unused)) struct cmdline *cl,
2584 __attribute__((unused)) void *data)
2586 struct cmd_config_threshold *res = parsed_result;
2588 if (!all_ports_stopped()) {
2589 printf("Please stop all ports first\n");
2593 if (!strcmp(res->name, "txfreet"))
2594 tx_free_thresh = res->value;
2595 else if (!strcmp(res->name, "txrst"))
2596 tx_rs_thresh = res->value;
2597 else if (!strcmp(res->name, "rxfreet"))
2598 rx_free_thresh = res->value;
2600 printf("Unknown parameter\n");
2606 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2609 cmdline_parse_token_string_t cmd_config_threshold_port =
2610 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2611 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2612 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2614 cmdline_parse_token_string_t cmd_config_threshold_all =
2615 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2616 cmdline_parse_token_string_t cmd_config_threshold_name =
2617 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2618 "txfreet#txrst#rxfreet");
2619 cmdline_parse_token_num_t cmd_config_threshold_value =
2620 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2622 cmdline_parse_inst_t cmd_config_threshold = {
2623 .f = cmd_config_threshold_parsed,
2625 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2627 (void *)&cmd_config_threshold_port,
2628 (void *)&cmd_config_threshold_keyword,
2629 (void *)&cmd_config_threshold_all,
2630 (void *)&cmd_config_threshold_name,
2631 (void *)&cmd_config_threshold_value,
2637 struct cmd_stop_result {
2638 cmdline_fixed_string_t stop;
2641 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2642 __attribute__((unused)) struct cmdline *cl,
2643 __attribute__((unused)) void *data)
2645 stop_packet_forwarding();
2648 cmdline_parse_token_string_t cmd_stop_stop =
2649 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2651 cmdline_parse_inst_t cmd_stop = {
2652 .f = cmd_stop_parsed,
2654 .help_str = "stop: Stop packet forwarding",
2656 (void *)&cmd_stop_stop,
2661 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2664 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2665 unsigned int *parsed_items, int check_unique_values)
2667 unsigned int nb_item;
2675 * First parse all items in the list and store their value.
2680 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2682 if ((c >= '0') && (c <= '9')) {
2683 value = (unsigned int) (value * 10 + (c - '0'));
2688 printf("character %c is not a decimal digit\n", c);
2692 printf("No valid value before comma\n");
2695 if (nb_item < max_items) {
2696 parsed_items[nb_item] = value;
2702 if (nb_item >= max_items) {
2703 printf("Number of %s = %u > %u (maximum items)\n",
2704 item_name, nb_item + 1, max_items);
2707 parsed_items[nb_item++] = value;
2708 if (! check_unique_values)
2712 * Then, check that all values in the list are differents.
2713 * No optimization here...
2715 for (i = 0; i < nb_item; i++) {
2716 for (j = i + 1; j < nb_item; j++) {
2717 if (parsed_items[j] == parsed_items[i]) {
2718 printf("duplicated %s %u at index %u and %u\n",
2719 item_name, parsed_items[i], i, j);
2727 struct cmd_set_list_result {
2728 cmdline_fixed_string_t cmd_keyword;
2729 cmdline_fixed_string_t list_name;
2730 cmdline_fixed_string_t list_of_items;
2733 static void cmd_set_list_parsed(void *parsed_result,
2734 __attribute__((unused)) struct cmdline *cl,
2735 __attribute__((unused)) void *data)
2737 struct cmd_set_list_result *res;
2739 unsigned int lcorelist[RTE_MAX_LCORE];
2740 unsigned int portlist[RTE_MAX_ETHPORTS];
2742 unsigned int nb_item;
2744 if (test_done == 0) {
2745 printf("Please stop forwarding first\n");
2749 res = parsed_result;
2750 if (!strcmp(res->list_name, "corelist")) {
2751 nb_item = parse_item_list(res->list_of_items, "core",
2753 parsed_items.lcorelist, 1);
2755 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2760 if (!strcmp(res->list_name, "portlist")) {
2761 nb_item = parse_item_list(res->list_of_items, "port",
2763 parsed_items.portlist, 1);
2765 set_fwd_ports_list(parsed_items.portlist, nb_item);
2771 cmdline_parse_token_string_t cmd_set_list_keyword =
2772 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2774 cmdline_parse_token_string_t cmd_set_list_name =
2775 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2776 "corelist#portlist");
2777 cmdline_parse_token_string_t cmd_set_list_of_items =
2778 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2781 cmdline_parse_inst_t cmd_set_fwd_list = {
2782 .f = cmd_set_list_parsed,
2784 .help_str = "set corelist|portlist <list0[,list1]*>",
2786 (void *)&cmd_set_list_keyword,
2787 (void *)&cmd_set_list_name,
2788 (void *)&cmd_set_list_of_items,
2793 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2795 struct cmd_setmask_result {
2796 cmdline_fixed_string_t set;
2797 cmdline_fixed_string_t mask;
2801 static void cmd_set_mask_parsed(void *parsed_result,
2802 __attribute__((unused)) struct cmdline *cl,
2803 __attribute__((unused)) void *data)
2805 struct cmd_setmask_result *res = parsed_result;
2807 if (test_done == 0) {
2808 printf("Please stop forwarding first\n");
2811 if (!strcmp(res->mask, "coremask")) {
2812 set_fwd_lcores_mask(res->hexavalue);
2814 } else if (!strcmp(res->mask, "portmask")) {
2815 set_fwd_ports_mask(res->hexavalue);
2820 cmdline_parse_token_string_t cmd_setmask_set =
2821 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2822 cmdline_parse_token_string_t cmd_setmask_mask =
2823 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2824 "coremask#portmask");
2825 cmdline_parse_token_num_t cmd_setmask_value =
2826 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2828 cmdline_parse_inst_t cmd_set_fwd_mask = {
2829 .f = cmd_set_mask_parsed,
2831 .help_str = "set coremask|portmask <hexadecimal value>",
2833 (void *)&cmd_setmask_set,
2834 (void *)&cmd_setmask_mask,
2835 (void *)&cmd_setmask_value,
2841 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2843 struct cmd_set_result {
2844 cmdline_fixed_string_t set;
2845 cmdline_fixed_string_t what;
2849 static void cmd_set_parsed(void *parsed_result,
2850 __attribute__((unused)) struct cmdline *cl,
2851 __attribute__((unused)) void *data)
2853 struct cmd_set_result *res = parsed_result;
2854 if (!strcmp(res->what, "nbport")) {
2855 set_fwd_ports_number(res->value);
2857 } else if (!strcmp(res->what, "nbcore")) {
2858 set_fwd_lcores_number(res->value);
2860 } else if (!strcmp(res->what, "burst"))
2861 set_nb_pkt_per_burst(res->value);
2862 else if (!strcmp(res->what, "verbose"))
2863 set_verbose_level(res->value);
2866 cmdline_parse_token_string_t cmd_set_set =
2867 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2868 cmdline_parse_token_string_t cmd_set_what =
2869 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2870 "nbport#nbcore#burst#verbose");
2871 cmdline_parse_token_num_t cmd_set_value =
2872 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2874 cmdline_parse_inst_t cmd_set_numbers = {
2875 .f = cmd_set_parsed,
2877 .help_str = "set nbport|nbcore|burst|verbose <value>",
2879 (void *)&cmd_set_set,
2880 (void *)&cmd_set_what,
2881 (void *)&cmd_set_value,
2886 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2888 struct cmd_set_txpkts_result {
2889 cmdline_fixed_string_t cmd_keyword;
2890 cmdline_fixed_string_t txpkts;
2891 cmdline_fixed_string_t seg_lengths;
2895 cmd_set_txpkts_parsed(void *parsed_result,
2896 __attribute__((unused)) struct cmdline *cl,
2897 __attribute__((unused)) void *data)
2899 struct cmd_set_txpkts_result *res;
2900 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2901 unsigned int nb_segs;
2903 res = parsed_result;
2904 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2905 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2907 set_tx_pkt_segments(seg_lengths, nb_segs);
2910 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2911 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2912 cmd_keyword, "set");
2913 cmdline_parse_token_string_t cmd_set_txpkts_name =
2914 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2916 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2917 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2920 cmdline_parse_inst_t cmd_set_txpkts = {
2921 .f = cmd_set_txpkts_parsed,
2923 .help_str = "set txpkts <len0[,len1]*>",
2925 (void *)&cmd_set_txpkts_keyword,
2926 (void *)&cmd_set_txpkts_name,
2927 (void *)&cmd_set_txpkts_lengths,
2932 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2934 struct cmd_set_txsplit_result {
2935 cmdline_fixed_string_t cmd_keyword;
2936 cmdline_fixed_string_t txsplit;
2937 cmdline_fixed_string_t mode;
2941 cmd_set_txsplit_parsed(void *parsed_result,
2942 __attribute__((unused)) struct cmdline *cl,
2943 __attribute__((unused)) void *data)
2945 struct cmd_set_txsplit_result *res;
2947 res = parsed_result;
2948 set_tx_pkt_split(res->mode);
2951 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2952 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2953 cmd_keyword, "set");
2954 cmdline_parse_token_string_t cmd_set_txsplit_name =
2955 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2956 txsplit, "txsplit");
2957 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2958 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2961 cmdline_parse_inst_t cmd_set_txsplit = {
2962 .f = cmd_set_txsplit_parsed,
2964 .help_str = "set txsplit on|off|rand",
2966 (void *)&cmd_set_txsplit_keyword,
2967 (void *)&cmd_set_txsplit_name,
2968 (void *)&cmd_set_txsplit_mode,
2973 /* *** CONFIG TX QUEUE FLAGS *** */
2975 struct cmd_config_txqflags_result {
2976 cmdline_fixed_string_t port;
2977 cmdline_fixed_string_t config;
2978 cmdline_fixed_string_t all;
2979 cmdline_fixed_string_t what;
2983 static void cmd_config_txqflags_parsed(void *parsed_result,
2984 __attribute__((unused)) struct cmdline *cl,
2985 __attribute__((unused)) void *data)
2987 struct cmd_config_txqflags_result *res = parsed_result;
2989 if (!all_ports_stopped()) {
2990 printf("Please stop all ports first\n");
2994 if (strcmp(res->what, "txqflags")) {
2995 printf("Unknown parameter\n");
2999 if (res->hexvalue >= 0) {
3000 txq_flags = res->hexvalue;
3002 printf("txqflags must be >= 0\n");
3008 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3011 cmdline_parse_token_string_t cmd_config_txqflags_port =
3012 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3014 cmdline_parse_token_string_t cmd_config_txqflags_config =
3015 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3017 cmdline_parse_token_string_t cmd_config_txqflags_all =
3018 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3020 cmdline_parse_token_string_t cmd_config_txqflags_what =
3021 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3023 cmdline_parse_token_num_t cmd_config_txqflags_value =
3024 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3027 cmdline_parse_inst_t cmd_config_txqflags = {
3028 .f = cmd_config_txqflags_parsed,
3030 .help_str = "port config all txqflags <value>",
3032 (void *)&cmd_config_txqflags_port,
3033 (void *)&cmd_config_txqflags_config,
3034 (void *)&cmd_config_txqflags_all,
3035 (void *)&cmd_config_txqflags_what,
3036 (void *)&cmd_config_txqflags_value,
3041 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3042 struct cmd_rx_vlan_filter_all_result {
3043 cmdline_fixed_string_t rx_vlan;
3044 cmdline_fixed_string_t what;
3045 cmdline_fixed_string_t all;
3050 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3051 __attribute__((unused)) struct cmdline *cl,
3052 __attribute__((unused)) void *data)
3054 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3056 if (!strcmp(res->what, "add"))
3057 rx_vlan_all_filter_set(res->port_id, 1);
3059 rx_vlan_all_filter_set(res->port_id, 0);
3062 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3063 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3064 rx_vlan, "rx_vlan");
3065 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3066 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3068 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3069 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3071 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3072 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3075 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3076 .f = cmd_rx_vlan_filter_all_parsed,
3078 .help_str = "rx_vlan add|rm all <port_id>: "
3079 "Add/Remove all identifiers to/from the set of VLAN "
3080 "identifiers filtered by a port",
3082 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3083 (void *)&cmd_rx_vlan_filter_all_what,
3084 (void *)&cmd_rx_vlan_filter_all_all,
3085 (void *)&cmd_rx_vlan_filter_all_portid,
3090 /* *** VLAN OFFLOAD SET ON A PORT *** */
3091 struct cmd_vlan_offload_result {
3092 cmdline_fixed_string_t vlan;
3093 cmdline_fixed_string_t set;
3094 cmdline_fixed_string_t vlan_type;
3095 cmdline_fixed_string_t what;
3096 cmdline_fixed_string_t on;
3097 cmdline_fixed_string_t port_id;
3101 cmd_vlan_offload_parsed(void *parsed_result,
3102 __attribute__((unused)) struct cmdline *cl,
3103 __attribute__((unused)) void *data)
3106 struct cmd_vlan_offload_result *res = parsed_result;
3109 portid_t port_id = 0;
3113 len = strnlen(str, STR_TOKEN_SIZE);
3115 /* Get port_id first */
3123 tmp = strtoul(str, NULL, 0);
3124 /* If port_id greater that what portid_t can represent, return */
3125 if(tmp >= RTE_MAX_ETHPORTS)
3127 port_id = (portid_t)tmp;
3129 if (!strcmp(res->on, "on"))
3134 if (!strcmp(res->what, "strip"))
3135 rx_vlan_strip_set(port_id, on);
3136 else if(!strcmp(res->what, "stripq")){
3137 uint16_t queue_id = 0;
3139 /* No queue_id, return */
3141 printf("must specify (port,queue_id)\n");
3144 tmp = strtoul(str + i + 1, NULL, 0);
3145 /* If queue_id greater that what 16-bits can represent, return */
3149 queue_id = (uint16_t)tmp;
3150 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3152 else if (!strcmp(res->what, "filter"))
3153 rx_vlan_filter_set(port_id, on);
3155 vlan_extend_set(port_id, on);
3160 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3161 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3163 cmdline_parse_token_string_t cmd_vlan_offload_set =
3164 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3166 cmdline_parse_token_string_t cmd_vlan_offload_what =
3167 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3168 what, "strip#filter#qinq#stripq");
3169 cmdline_parse_token_string_t cmd_vlan_offload_on =
3170 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3172 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3173 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3176 cmdline_parse_inst_t cmd_vlan_offload = {
3177 .f = cmd_vlan_offload_parsed,
3179 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3180 "<port_id[,queue_id]>: "
3181 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3183 (void *)&cmd_vlan_offload_vlan,
3184 (void *)&cmd_vlan_offload_set,
3185 (void *)&cmd_vlan_offload_what,
3186 (void *)&cmd_vlan_offload_on,
3187 (void *)&cmd_vlan_offload_portid,
3192 /* *** VLAN TPID SET ON A PORT *** */
3193 struct cmd_vlan_tpid_result {
3194 cmdline_fixed_string_t vlan;
3195 cmdline_fixed_string_t set;
3196 cmdline_fixed_string_t vlan_type;
3197 cmdline_fixed_string_t what;
3203 cmd_vlan_tpid_parsed(void *parsed_result,
3204 __attribute__((unused)) struct cmdline *cl,
3205 __attribute__((unused)) void *data)
3207 struct cmd_vlan_tpid_result *res = parsed_result;
3208 enum rte_vlan_type vlan_type;
3210 if (!strcmp(res->vlan_type, "inner"))
3211 vlan_type = ETH_VLAN_TYPE_INNER;
3212 else if (!strcmp(res->vlan_type, "outer"))
3213 vlan_type = ETH_VLAN_TYPE_OUTER;
3215 printf("Unknown vlan type\n");
3218 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3221 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3222 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3224 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3225 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3227 cmdline_parse_token_string_t cmd_vlan_type =
3228 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3229 vlan_type, "inner#outer");
3230 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3231 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3233 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3234 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3236 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3237 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3240 cmdline_parse_inst_t cmd_vlan_tpid = {
3241 .f = cmd_vlan_tpid_parsed,
3243 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3244 "Set the VLAN Ether type",
3246 (void *)&cmd_vlan_tpid_vlan,
3247 (void *)&cmd_vlan_tpid_set,
3248 (void *)&cmd_vlan_type,
3249 (void *)&cmd_vlan_tpid_what,
3250 (void *)&cmd_vlan_tpid_tpid,
3251 (void *)&cmd_vlan_tpid_portid,
3256 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3257 struct cmd_rx_vlan_filter_result {
3258 cmdline_fixed_string_t rx_vlan;
3259 cmdline_fixed_string_t what;
3265 cmd_rx_vlan_filter_parsed(void *parsed_result,
3266 __attribute__((unused)) struct cmdline *cl,
3267 __attribute__((unused)) void *data)
3269 struct cmd_rx_vlan_filter_result *res = parsed_result;
3271 if (!strcmp(res->what, "add"))
3272 rx_vft_set(res->port_id, res->vlan_id, 1);
3274 rx_vft_set(res->port_id, res->vlan_id, 0);
3277 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3278 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3279 rx_vlan, "rx_vlan");
3280 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3281 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3283 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3284 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3286 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3287 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3290 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3291 .f = cmd_rx_vlan_filter_parsed,
3293 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3294 "Add/Remove a VLAN identifier to/from the set of VLAN "
3295 "identifiers filtered by a port",
3297 (void *)&cmd_rx_vlan_filter_rx_vlan,
3298 (void *)&cmd_rx_vlan_filter_what,
3299 (void *)&cmd_rx_vlan_filter_vlanid,
3300 (void *)&cmd_rx_vlan_filter_portid,
3305 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3306 struct cmd_tx_vlan_set_result {
3307 cmdline_fixed_string_t tx_vlan;
3308 cmdline_fixed_string_t set;
3314 cmd_tx_vlan_set_parsed(void *parsed_result,
3315 __attribute__((unused)) struct cmdline *cl,
3316 __attribute__((unused)) void *data)
3318 struct cmd_tx_vlan_set_result *res = parsed_result;
3320 tx_vlan_set(res->port_id, res->vlan_id);
3323 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3324 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3325 tx_vlan, "tx_vlan");
3326 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3327 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3329 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3330 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3332 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3333 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3336 cmdline_parse_inst_t cmd_tx_vlan_set = {
3337 .f = cmd_tx_vlan_set_parsed,
3339 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3340 "Enable hardware insertion of a single VLAN header "
3341 "with a given TAG Identifier in packets sent on a port",
3343 (void *)&cmd_tx_vlan_set_tx_vlan,
3344 (void *)&cmd_tx_vlan_set_set,
3345 (void *)&cmd_tx_vlan_set_portid,
3346 (void *)&cmd_tx_vlan_set_vlanid,
3351 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3352 struct cmd_tx_vlan_set_qinq_result {
3353 cmdline_fixed_string_t tx_vlan;
3354 cmdline_fixed_string_t set;
3357 uint16_t vlan_id_outer;
3361 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3362 __attribute__((unused)) struct cmdline *cl,
3363 __attribute__((unused)) void *data)
3365 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3367 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3370 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3371 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3372 tx_vlan, "tx_vlan");
3373 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3374 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3376 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3377 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3379 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3380 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3382 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3383 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3384 vlan_id_outer, UINT16);
3386 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3387 .f = cmd_tx_vlan_set_qinq_parsed,
3389 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3390 "Enable hardware insertion of double VLAN header "
3391 "with given TAG Identifiers in packets sent on a port",
3393 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3394 (void *)&cmd_tx_vlan_set_qinq_set,
3395 (void *)&cmd_tx_vlan_set_qinq_portid,
3396 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3397 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3402 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3403 struct cmd_tx_vlan_set_pvid_result {
3404 cmdline_fixed_string_t tx_vlan;
3405 cmdline_fixed_string_t set;
3406 cmdline_fixed_string_t pvid;
3409 cmdline_fixed_string_t mode;
3413 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3414 __attribute__((unused)) struct cmdline *cl,
3415 __attribute__((unused)) void *data)
3417 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3419 if (strcmp(res->mode, "on") == 0)
3420 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3422 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3425 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3426 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3427 tx_vlan, "tx_vlan");
3428 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3429 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3431 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3432 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3434 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3435 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3437 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3438 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3440 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3441 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3444 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3445 .f = cmd_tx_vlan_set_pvid_parsed,
3447 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3449 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3450 (void *)&cmd_tx_vlan_set_pvid_set,
3451 (void *)&cmd_tx_vlan_set_pvid_pvid,
3452 (void *)&cmd_tx_vlan_set_pvid_port_id,
3453 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3454 (void *)&cmd_tx_vlan_set_pvid_mode,
3459 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3460 struct cmd_tx_vlan_reset_result {
3461 cmdline_fixed_string_t tx_vlan;
3462 cmdline_fixed_string_t reset;
3467 cmd_tx_vlan_reset_parsed(void *parsed_result,
3468 __attribute__((unused)) struct cmdline *cl,
3469 __attribute__((unused)) void *data)
3471 struct cmd_tx_vlan_reset_result *res = parsed_result;
3473 tx_vlan_reset(res->port_id);
3476 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3477 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3478 tx_vlan, "tx_vlan");
3479 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3480 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3482 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3483 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3486 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3487 .f = cmd_tx_vlan_reset_parsed,
3489 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3490 "VLAN header in packets sent on a port",
3492 (void *)&cmd_tx_vlan_reset_tx_vlan,
3493 (void *)&cmd_tx_vlan_reset_reset,
3494 (void *)&cmd_tx_vlan_reset_portid,
3500 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3501 struct cmd_csum_result {
3502 cmdline_fixed_string_t csum;
3503 cmdline_fixed_string_t mode;
3504 cmdline_fixed_string_t proto;
3505 cmdline_fixed_string_t hwsw;
3510 csum_show(int port_id)
3512 struct rte_eth_dev_info dev_info;
3515 ol_flags = ports[port_id].tx_ol_flags;
3516 printf("Parse tunnel is %s\n",
3517 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3518 printf("IP checksum offload is %s\n",
3519 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3520 printf("UDP checksum offload is %s\n",
3521 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3522 printf("TCP checksum offload is %s\n",
3523 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3524 printf("SCTP checksum offload is %s\n",
3525 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3526 printf("Outer-Ip checksum offload is %s\n",
3527 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3529 /* display warnings if configuration is not supported by the NIC */
3530 rte_eth_dev_info_get(port_id, &dev_info);
3531 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3532 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3533 printf("Warning: hardware IP checksum enabled but not "
3534 "supported by port %d\n", port_id);
3536 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3537 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3538 printf("Warning: hardware UDP checksum enabled but not "
3539 "supported by port %d\n", port_id);
3541 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3542 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3543 printf("Warning: hardware TCP checksum enabled but not "
3544 "supported by port %d\n", port_id);
3546 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3547 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3548 printf("Warning: hardware SCTP checksum enabled but not "
3549 "supported by port %d\n", port_id);
3551 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3552 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3553 printf("Warning: hardware outer IP checksum enabled but not "
3554 "supported by port %d\n", port_id);
3559 cmd_csum_parsed(void *parsed_result,
3560 __attribute__((unused)) struct cmdline *cl,
3561 __attribute__((unused)) void *data)
3563 struct cmd_csum_result *res = parsed_result;
3567 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3568 printf("invalid port %d\n", res->port_id);
3572 if (!strcmp(res->mode, "set")) {
3574 if (!strcmp(res->hwsw, "hw"))
3577 if (!strcmp(res->proto, "ip")) {
3578 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3579 } else if (!strcmp(res->proto, "udp")) {
3580 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3581 } else if (!strcmp(res->proto, "tcp")) {
3582 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3583 } else if (!strcmp(res->proto, "sctp")) {
3584 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3585 } else if (!strcmp(res->proto, "outer-ip")) {
3586 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3590 ports[res->port_id].tx_ol_flags |= mask;
3592 ports[res->port_id].tx_ol_flags &= (~mask);
3594 csum_show(res->port_id);
3597 cmdline_parse_token_string_t cmd_csum_csum =
3598 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3600 cmdline_parse_token_string_t cmd_csum_mode =
3601 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3603 cmdline_parse_token_string_t cmd_csum_proto =
3604 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3605 proto, "ip#tcp#udp#sctp#outer-ip");
3606 cmdline_parse_token_string_t cmd_csum_hwsw =
3607 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3609 cmdline_parse_token_num_t cmd_csum_portid =
3610 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3613 cmdline_parse_inst_t cmd_csum_set = {
3614 .f = cmd_csum_parsed,
3616 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3617 "Enable/Disable hardware calculation of L3/L4 checksum when "
3618 "using csum forward engine",
3620 (void *)&cmd_csum_csum,
3621 (void *)&cmd_csum_mode,
3622 (void *)&cmd_csum_proto,
3623 (void *)&cmd_csum_hwsw,
3624 (void *)&cmd_csum_portid,
3629 cmdline_parse_token_string_t cmd_csum_mode_show =
3630 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3633 cmdline_parse_inst_t cmd_csum_show = {
3634 .f = cmd_csum_parsed,
3636 .help_str = "csum show <port_id>: Show checksum offload configuration",
3638 (void *)&cmd_csum_csum,
3639 (void *)&cmd_csum_mode_show,
3640 (void *)&cmd_csum_portid,
3645 /* Enable/disable tunnel parsing */
3646 struct cmd_csum_tunnel_result {
3647 cmdline_fixed_string_t csum;
3648 cmdline_fixed_string_t parse;
3649 cmdline_fixed_string_t onoff;
3654 cmd_csum_tunnel_parsed(void *parsed_result,
3655 __attribute__((unused)) struct cmdline *cl,
3656 __attribute__((unused)) void *data)
3658 struct cmd_csum_tunnel_result *res = parsed_result;
3660 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3663 if (!strcmp(res->onoff, "on"))
3664 ports[res->port_id].tx_ol_flags |=
3665 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3667 ports[res->port_id].tx_ol_flags &=
3668 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3670 csum_show(res->port_id);
3673 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3674 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3676 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3677 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3678 parse, "parse_tunnel");
3679 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3680 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3682 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3683 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3686 cmdline_parse_inst_t cmd_csum_tunnel = {
3687 .f = cmd_csum_tunnel_parsed,
3689 .help_str = "csum parse_tunnel on|off <port_id>: "
3690 "Enable/Disable parsing of tunnels for csum engine",
3692 (void *)&cmd_csum_tunnel_csum,
3693 (void *)&cmd_csum_tunnel_parse,
3694 (void *)&cmd_csum_tunnel_onoff,
3695 (void *)&cmd_csum_tunnel_portid,
3700 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3701 struct cmd_tso_set_result {
3702 cmdline_fixed_string_t tso;
3703 cmdline_fixed_string_t mode;
3709 cmd_tso_set_parsed(void *parsed_result,
3710 __attribute__((unused)) struct cmdline *cl,
3711 __attribute__((unused)) void *data)
3713 struct cmd_tso_set_result *res = parsed_result;
3714 struct rte_eth_dev_info dev_info;
3716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3719 if (!strcmp(res->mode, "set"))
3720 ports[res->port_id].tso_segsz = res->tso_segsz;
3722 if (ports[res->port_id].tso_segsz == 0)
3723 printf("TSO for non-tunneled packets is disabled\n");
3725 printf("TSO segment size for non-tunneled packets is %d\n",
3726 ports[res->port_id].tso_segsz);
3728 /* display warnings if configuration is not supported by the NIC */
3729 rte_eth_dev_info_get(res->port_id, &dev_info);
3730 if ((ports[res->port_id].tso_segsz != 0) &&
3731 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3732 printf("Warning: TSO enabled but not "
3733 "supported by port %d\n", res->port_id);
3737 cmdline_parse_token_string_t cmd_tso_set_tso =
3738 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3740 cmdline_parse_token_string_t cmd_tso_set_mode =
3741 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3743 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3744 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3746 cmdline_parse_token_num_t cmd_tso_set_portid =
3747 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3750 cmdline_parse_inst_t cmd_tso_set = {
3751 .f = cmd_tso_set_parsed,
3753 .help_str = "tso set <tso_segsz> <port_id>: "
3754 "Set TSO segment size of non-tunneled packets for csum engine "
3757 (void *)&cmd_tso_set_tso,
3758 (void *)&cmd_tso_set_mode,
3759 (void *)&cmd_tso_set_tso_segsz,
3760 (void *)&cmd_tso_set_portid,
3765 cmdline_parse_token_string_t cmd_tso_show_mode =
3766 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3770 cmdline_parse_inst_t cmd_tso_show = {
3771 .f = cmd_tso_set_parsed,
3773 .help_str = "tso show <port_id>: "
3774 "Show TSO segment size of non-tunneled packets for csum engine",
3776 (void *)&cmd_tso_set_tso,
3777 (void *)&cmd_tso_show_mode,
3778 (void *)&cmd_tso_set_portid,
3783 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3784 struct cmd_tunnel_tso_set_result {
3785 cmdline_fixed_string_t tso;
3786 cmdline_fixed_string_t mode;
3792 check_tunnel_tso_nic_support(uint8_t port_id)
3794 struct rte_eth_dev_info dev_info;
3796 rte_eth_dev_info_get(port_id, &dev_info);
3797 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3798 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3799 "supported by port %d\n", port_id);
3800 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3801 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3802 "supported by port %d\n", port_id);
3803 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3804 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3805 "supported by port %d\n", port_id);
3806 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3807 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3808 "supported by port %d\n", port_id);
3812 cmd_tunnel_tso_set_parsed(void *parsed_result,
3813 __attribute__((unused)) struct cmdline *cl,
3814 __attribute__((unused)) void *data)
3816 struct cmd_tunnel_tso_set_result *res = parsed_result;
3818 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3821 if (!strcmp(res->mode, "set"))
3822 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3824 if (ports[res->port_id].tunnel_tso_segsz == 0)
3825 printf("TSO for tunneled packets is disabled\n");
3827 printf("TSO segment size for tunneled packets is %d\n",
3828 ports[res->port_id].tunnel_tso_segsz);
3830 /* Below conditions are needed to make it work:
3831 * (1) tunnel TSO is supported by the NIC;
3832 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3834 * (3) for tunneled pkts with outer L3 of IPv4,
3835 * "csum set outer-ip" must be set to hw, because after tso,
3836 * total_len of outer IP header is changed, and the checksum
3837 * of outer IP header calculated by sw should be wrong; that
3838 * is not necessary for IPv6 tunneled pkts because there's no
3839 * checksum in IP header anymore.
3841 check_tunnel_tso_nic_support(res->port_id);
3843 if (!(ports[res->port_id].tx_ol_flags &
3844 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3845 printf("Warning: csum parse_tunnel must be set "
3846 "so that tunneled packets are recognized\n");
3847 if (!(ports[res->port_id].tx_ol_flags &
3848 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3849 printf("Warning: csum set outer-ip must be set to hw "
3850 "if outer L3 is IPv4; not necessary for IPv6\n");
3854 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3855 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3857 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3858 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3860 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3861 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3863 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3864 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3867 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3868 .f = cmd_tunnel_tso_set_parsed,
3870 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3871 "Set TSO segment size of tunneled packets for csum engine "
3874 (void *)&cmd_tunnel_tso_set_tso,
3875 (void *)&cmd_tunnel_tso_set_mode,
3876 (void *)&cmd_tunnel_tso_set_tso_segsz,
3877 (void *)&cmd_tunnel_tso_set_portid,
3882 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3883 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3887 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3888 .f = cmd_tunnel_tso_set_parsed,
3890 .help_str = "tunnel_tso show <port_id> "
3891 "Show TSO segment size of tunneled packets for csum engine",
3893 (void *)&cmd_tunnel_tso_set_tso,
3894 (void *)&cmd_tunnel_tso_show_mode,
3895 (void *)&cmd_tunnel_tso_set_portid,
3900 /* *** SET GRO FOR A PORT *** */
3901 struct cmd_gro_enable_result {
3902 cmdline_fixed_string_t cmd_set;
3903 cmdline_fixed_string_t cmd_port;
3904 cmdline_fixed_string_t cmd_keyword;
3905 cmdline_fixed_string_t cmd_onoff;
3910 cmd_gro_enable_parsed(void *parsed_result,
3911 __attribute__((unused)) struct cmdline *cl,
3912 __attribute__((unused)) void *data)
3914 struct cmd_gro_enable_result *res;
3916 res = parsed_result;
3917 if (!strcmp(res->cmd_keyword, "gro"))
3918 setup_gro(res->cmd_onoff, res->cmd_pid);
3921 cmdline_parse_token_string_t cmd_gro_enable_set =
3922 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3924 cmdline_parse_token_string_t cmd_gro_enable_port =
3925 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3926 cmd_keyword, "port");
3927 cmdline_parse_token_num_t cmd_gro_enable_pid =
3928 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
3930 cmdline_parse_token_string_t cmd_gro_enable_keyword =
3931 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3932 cmd_keyword, "gro");
3933 cmdline_parse_token_string_t cmd_gro_enable_onoff =
3934 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3935 cmd_onoff, "on#off");
3937 cmdline_parse_inst_t cmd_gro_enable = {
3938 .f = cmd_gro_enable_parsed,
3940 .help_str = "set port <port_id> gro on|off",
3942 (void *)&cmd_gro_enable_set,
3943 (void *)&cmd_gro_enable_port,
3944 (void *)&cmd_gro_enable_pid,
3945 (void *)&cmd_gro_enable_keyword,
3946 (void *)&cmd_gro_enable_onoff,
3951 /* *** DISPLAY GRO CONFIGURATION *** */
3952 struct cmd_gro_show_result {
3953 cmdline_fixed_string_t cmd_show;
3954 cmdline_fixed_string_t cmd_port;
3955 cmdline_fixed_string_t cmd_keyword;
3960 cmd_gro_show_parsed(void *parsed_result,
3961 __attribute__((unused)) struct cmdline *cl,
3962 __attribute__((unused)) void *data)
3964 struct cmd_gro_show_result *res;
3966 res = parsed_result;
3967 if (!strcmp(res->cmd_keyword, "gro"))
3968 show_gro(res->cmd_pid);
3971 cmdline_parse_token_string_t cmd_gro_show_show =
3972 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3974 cmdline_parse_token_string_t cmd_gro_show_port =
3975 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3977 cmdline_parse_token_num_t cmd_gro_show_pid =
3978 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
3980 cmdline_parse_token_string_t cmd_gro_show_keyword =
3981 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3982 cmd_keyword, "gro");
3984 cmdline_parse_inst_t cmd_gro_show = {
3985 .f = cmd_gro_show_parsed,
3987 .help_str = "show port <port_id> gro",
3989 (void *)&cmd_gro_show_show,
3990 (void *)&cmd_gro_show_port,
3991 (void *)&cmd_gro_show_pid,
3992 (void *)&cmd_gro_show_keyword,
3997 /* *** SET FLUSH CYCLES FOR GRO *** */
3998 struct cmd_gro_flush_result {
3999 cmdline_fixed_string_t cmd_set;
4000 cmdline_fixed_string_t cmd_keyword;
4001 cmdline_fixed_string_t cmd_flush;
4006 cmd_gro_flush_parsed(void *parsed_result,
4007 __attribute__((unused)) struct cmdline *cl,
4008 __attribute__((unused)) void *data)
4010 struct cmd_gro_flush_result *res;
4012 res = parsed_result;
4013 if ((!strcmp(res->cmd_keyword, "gro")) &&
4014 (!strcmp(res->cmd_flush, "flush")))
4015 setup_gro_flush_cycles(res->cmd_cycles);
4018 cmdline_parse_token_string_t cmd_gro_flush_set =
4019 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4021 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4022 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4023 cmd_keyword, "gro");
4024 cmdline_parse_token_string_t cmd_gro_flush_flush =
4025 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4026 cmd_flush, "flush");
4027 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4028 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4031 cmdline_parse_inst_t cmd_gro_flush = {
4032 .f = cmd_gro_flush_parsed,
4034 .help_str = "set gro flush <cycles>",
4036 (void *)&cmd_gro_flush_set,
4037 (void *)&cmd_gro_flush_keyword,
4038 (void *)&cmd_gro_flush_flush,
4039 (void *)&cmd_gro_flush_cycles,
4044 /* *** ENABLE/DISABLE GSO *** */
4045 struct cmd_gso_enable_result {
4046 cmdline_fixed_string_t cmd_set;
4047 cmdline_fixed_string_t cmd_port;
4048 cmdline_fixed_string_t cmd_keyword;
4049 cmdline_fixed_string_t cmd_mode;
4054 cmd_gso_enable_parsed(void *parsed_result,
4055 __attribute__((unused)) struct cmdline *cl,
4056 __attribute__((unused)) void *data)
4058 struct cmd_gso_enable_result *res;
4060 res = parsed_result;
4061 if (!strcmp(res->cmd_keyword, "gso"))
4062 setup_gso(res->cmd_mode, res->cmd_pid);
4065 cmdline_parse_token_string_t cmd_gso_enable_set =
4066 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4068 cmdline_parse_token_string_t cmd_gso_enable_port =
4069 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4071 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4072 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4073 cmd_keyword, "gso");
4074 cmdline_parse_token_string_t cmd_gso_enable_mode =
4075 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4076 cmd_mode, "on#off");
4077 cmdline_parse_token_num_t cmd_gso_enable_pid =
4078 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4081 cmdline_parse_inst_t cmd_gso_enable = {
4082 .f = cmd_gso_enable_parsed,
4084 .help_str = "set port <port_id> gso on|off",
4086 (void *)&cmd_gso_enable_set,
4087 (void *)&cmd_gso_enable_port,
4088 (void *)&cmd_gso_enable_pid,
4089 (void *)&cmd_gso_enable_keyword,
4090 (void *)&cmd_gso_enable_mode,
4095 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4096 struct cmd_gso_size_result {
4097 cmdline_fixed_string_t cmd_set;
4098 cmdline_fixed_string_t cmd_keyword;
4099 cmdline_fixed_string_t cmd_segsz;
4104 cmd_gso_size_parsed(void *parsed_result,
4105 __attribute__((unused)) struct cmdline *cl,
4106 __attribute__((unused)) void *data)
4108 struct cmd_gso_size_result *res = parsed_result;
4110 if (test_done == 0) {
4111 printf("Before setting GSO segsz, please first"
4112 " stop fowarding\n");
4116 if (!strcmp(res->cmd_keyword, "gso") &&
4117 !strcmp(res->cmd_segsz, "segsz")) {
4118 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4119 printf("gso_size should be larger than %zu."
4120 " Please input a legal value\n",
4121 RTE_GSO_SEG_SIZE_MIN);
4123 gso_max_segment_size = res->cmd_size;
4127 cmdline_parse_token_string_t cmd_gso_size_set =
4128 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4130 cmdline_parse_token_string_t cmd_gso_size_keyword =
4131 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4132 cmd_keyword, "gso");
4133 cmdline_parse_token_string_t cmd_gso_size_segsz =
4134 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4135 cmd_segsz, "segsz");
4136 cmdline_parse_token_num_t cmd_gso_size_size =
4137 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4140 cmdline_parse_inst_t cmd_gso_size = {
4141 .f = cmd_gso_size_parsed,
4143 .help_str = "set gso segsz <length>",
4145 (void *)&cmd_gso_size_set,
4146 (void *)&cmd_gso_size_keyword,
4147 (void *)&cmd_gso_size_segsz,
4148 (void *)&cmd_gso_size_size,
4153 /* *** SHOW GSO CONFIGURATION *** */
4154 struct cmd_gso_show_result {
4155 cmdline_fixed_string_t cmd_show;
4156 cmdline_fixed_string_t cmd_port;
4157 cmdline_fixed_string_t cmd_keyword;
4162 cmd_gso_show_parsed(void *parsed_result,
4163 __attribute__((unused)) struct cmdline *cl,
4164 __attribute__((unused)) void *data)
4166 struct cmd_gso_show_result *res = parsed_result;
4168 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4169 printf("invalid port id %u\n", res->cmd_pid);
4172 if (!strcmp(res->cmd_keyword, "gso")) {
4173 if (gso_ports[res->cmd_pid].enable) {
4174 printf("Max GSO'd packet size: %uB\n"
4175 "Supported GSO types: TCP/IPv4, "
4176 "VxLAN with inner TCP/IPv4 packet, "
4177 "GRE with inner TCP/IPv4 packet\n",
4178 gso_max_segment_size);
4180 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4184 cmdline_parse_token_string_t cmd_gso_show_show =
4185 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4187 cmdline_parse_token_string_t cmd_gso_show_port =
4188 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4190 cmdline_parse_token_string_t cmd_gso_show_keyword =
4191 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4192 cmd_keyword, "gso");
4193 cmdline_parse_token_num_t cmd_gso_show_pid =
4194 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4197 cmdline_parse_inst_t cmd_gso_show = {
4198 .f = cmd_gso_show_parsed,
4200 .help_str = "show port <port_id> gso",
4202 (void *)&cmd_gso_show_show,
4203 (void *)&cmd_gso_show_port,
4204 (void *)&cmd_gso_show_pid,
4205 (void *)&cmd_gso_show_keyword,
4210 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4211 struct cmd_set_flush_rx {
4212 cmdline_fixed_string_t set;
4213 cmdline_fixed_string_t flush_rx;
4214 cmdline_fixed_string_t mode;
4218 cmd_set_flush_rx_parsed(void *parsed_result,
4219 __attribute__((unused)) struct cmdline *cl,
4220 __attribute__((unused)) void *data)
4222 struct cmd_set_flush_rx *res = parsed_result;
4223 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4226 cmdline_parse_token_string_t cmd_setflushrx_set =
4227 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4229 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4230 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4231 flush_rx, "flush_rx");
4232 cmdline_parse_token_string_t cmd_setflushrx_mode =
4233 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4237 cmdline_parse_inst_t cmd_set_flush_rx = {
4238 .f = cmd_set_flush_rx_parsed,
4239 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4242 (void *)&cmd_setflushrx_set,
4243 (void *)&cmd_setflushrx_flush_rx,
4244 (void *)&cmd_setflushrx_mode,
4249 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4250 struct cmd_set_link_check {
4251 cmdline_fixed_string_t set;
4252 cmdline_fixed_string_t link_check;
4253 cmdline_fixed_string_t mode;
4257 cmd_set_link_check_parsed(void *parsed_result,
4258 __attribute__((unused)) struct cmdline *cl,
4259 __attribute__((unused)) void *data)
4261 struct cmd_set_link_check *res = parsed_result;
4262 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4265 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4266 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4268 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4269 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4270 link_check, "link_check");
4271 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4272 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4276 cmdline_parse_inst_t cmd_set_link_check = {
4277 .f = cmd_set_link_check_parsed,
4278 .help_str = "set link_check on|off: Enable/Disable link status check "
4279 "when starting/stopping a port",
4282 (void *)&cmd_setlinkcheck_set,
4283 (void *)&cmd_setlinkcheck_link_check,
4284 (void *)&cmd_setlinkcheck_mode,
4289 /* *** SET NIC BYPASS MODE *** */
4290 struct cmd_set_bypass_mode_result {
4291 cmdline_fixed_string_t set;
4292 cmdline_fixed_string_t bypass;
4293 cmdline_fixed_string_t mode;
4294 cmdline_fixed_string_t value;
4299 cmd_set_bypass_mode_parsed(void *parsed_result,
4300 __attribute__((unused)) struct cmdline *cl,
4301 __attribute__((unused)) void *data)
4303 struct cmd_set_bypass_mode_result *res = parsed_result;
4304 portid_t port_id = res->port_id;
4305 int32_t rc = -EINVAL;
4307 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4308 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4310 if (!strcmp(res->value, "bypass"))
4311 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4312 else if (!strcmp(res->value, "isolate"))
4313 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4315 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4317 /* Set the bypass mode for the relevant port. */
4318 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4321 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4324 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4325 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4327 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4328 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4330 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4331 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4333 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4334 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4335 value, "normal#bypass#isolate");
4336 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4337 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4340 cmdline_parse_inst_t cmd_set_bypass_mode = {
4341 .f = cmd_set_bypass_mode_parsed,
4342 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4343 "Set the NIC bypass mode for port_id",
4346 (void *)&cmd_setbypass_mode_set,
4347 (void *)&cmd_setbypass_mode_bypass,
4348 (void *)&cmd_setbypass_mode_mode,
4349 (void *)&cmd_setbypass_mode_value,
4350 (void *)&cmd_setbypass_mode_port,
4355 /* *** SET NIC BYPASS EVENT *** */
4356 struct cmd_set_bypass_event_result {
4357 cmdline_fixed_string_t set;
4358 cmdline_fixed_string_t bypass;
4359 cmdline_fixed_string_t event;
4360 cmdline_fixed_string_t event_value;
4361 cmdline_fixed_string_t mode;
4362 cmdline_fixed_string_t mode_value;
4367 cmd_set_bypass_event_parsed(void *parsed_result,
4368 __attribute__((unused)) struct cmdline *cl,
4369 __attribute__((unused)) void *data)
4371 int32_t rc = -EINVAL;
4372 struct cmd_set_bypass_event_result *res = parsed_result;
4373 portid_t port_id = res->port_id;
4375 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4376 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4377 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4379 if (!strcmp(res->event_value, "timeout"))
4380 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4381 else if (!strcmp(res->event_value, "os_on"))
4382 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4383 else if (!strcmp(res->event_value, "os_off"))
4384 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4385 else if (!strcmp(res->event_value, "power_on"))
4386 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4387 else if (!strcmp(res->event_value, "power_off"))
4388 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4390 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4392 if (!strcmp(res->mode_value, "bypass"))
4393 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4394 else if (!strcmp(res->mode_value, "isolate"))
4395 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4397 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4399 /* Set the watchdog timeout. */
4400 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4403 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4404 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4408 printf("Failed to set timeout value %u "
4409 "for port %d, errto code: %d.\n",
4410 bypass_timeout, port_id, rc);
4414 /* Set the bypass event to transition to bypass mode. */
4415 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4420 printf("\t Failed to set bypass event for port = %d.\n",
4424 cmdline_parse_token_string_t cmd_setbypass_event_set =
4425 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4427 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4428 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4430 cmdline_parse_token_string_t cmd_setbypass_event_event =
4431 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4433 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4434 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4435 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4436 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4437 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4439 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4441 mode_value, "normal#bypass#isolate");
4442 cmdline_parse_token_num_t cmd_setbypass_event_port =
4443 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4446 cmdline_parse_inst_t cmd_set_bypass_event = {
4447 .f = cmd_set_bypass_event_parsed,
4448 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4449 "power_off mode normal|bypass|isolate <port_id>: "
4450 "Set the NIC bypass event mode for port_id",
4453 (void *)&cmd_setbypass_event_set,
4454 (void *)&cmd_setbypass_event_bypass,
4455 (void *)&cmd_setbypass_event_event,
4456 (void *)&cmd_setbypass_event_event_value,
4457 (void *)&cmd_setbypass_event_mode,
4458 (void *)&cmd_setbypass_event_mode_value,
4459 (void *)&cmd_setbypass_event_port,
4465 /* *** SET NIC BYPASS TIMEOUT *** */
4466 struct cmd_set_bypass_timeout_result {
4467 cmdline_fixed_string_t set;
4468 cmdline_fixed_string_t bypass;
4469 cmdline_fixed_string_t timeout;
4470 cmdline_fixed_string_t value;
4474 cmd_set_bypass_timeout_parsed(void *parsed_result,
4475 __attribute__((unused)) struct cmdline *cl,
4476 __attribute__((unused)) void *data)
4478 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4480 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4481 if (!strcmp(res->value, "1.5"))
4482 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4483 else if (!strcmp(res->value, "2"))
4484 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4485 else if (!strcmp(res->value, "3"))
4486 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4487 else if (!strcmp(res->value, "4"))
4488 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4489 else if (!strcmp(res->value, "8"))
4490 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4491 else if (!strcmp(res->value, "16"))
4492 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4493 else if (!strcmp(res->value, "32"))
4494 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4496 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4500 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4501 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4503 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4504 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4506 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4507 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4508 timeout, "timeout");
4509 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4510 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4511 value, "0#1.5#2#3#4#8#16#32");
4513 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4514 .f = cmd_set_bypass_timeout_parsed,
4515 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4516 "Set the NIC bypass watchdog timeout in seconds",
4519 (void *)&cmd_setbypass_timeout_set,
4520 (void *)&cmd_setbypass_timeout_bypass,
4521 (void *)&cmd_setbypass_timeout_timeout,
4522 (void *)&cmd_setbypass_timeout_value,
4527 /* *** SHOW NIC BYPASS MODE *** */
4528 struct cmd_show_bypass_config_result {
4529 cmdline_fixed_string_t show;
4530 cmdline_fixed_string_t bypass;
4531 cmdline_fixed_string_t config;
4536 cmd_show_bypass_config_parsed(void *parsed_result,
4537 __attribute__((unused)) struct cmdline *cl,
4538 __attribute__((unused)) void *data)
4540 struct cmd_show_bypass_config_result *res = parsed_result;
4541 portid_t port_id = res->port_id;
4543 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4544 uint32_t event_mode;
4545 uint32_t bypass_mode;
4546 uint32_t timeout = bypass_timeout;
4549 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4550 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4551 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4552 {"UNKNOWN", "normal", "bypass", "isolate"};
4553 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4560 int num_events = (sizeof events) / (sizeof events[0]);
4562 /* Display the bypass mode.*/
4563 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4564 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4568 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4569 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4571 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4574 /* Display the bypass timeout.*/
4575 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4576 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4578 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4580 /* Display the bypass events and associated modes. */
4581 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4583 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4584 printf("\tFailed to get bypass mode for event = %s\n",
4587 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4588 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4590 printf("\tbypass event: %-16s = %s\n", events[i],
4596 printf("\tFailed to get bypass configuration for port = %d\n",
4600 cmdline_parse_token_string_t cmd_showbypass_config_show =
4601 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4603 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4604 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4606 cmdline_parse_token_string_t cmd_showbypass_config_config =
4607 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4609 cmdline_parse_token_num_t cmd_showbypass_config_port =
4610 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4613 cmdline_parse_inst_t cmd_show_bypass_config = {
4614 .f = cmd_show_bypass_config_parsed,
4615 .help_str = "show bypass config <port_id>: "
4616 "Show the NIC bypass config for port_id",
4619 (void *)&cmd_showbypass_config_show,
4620 (void *)&cmd_showbypass_config_bypass,
4621 (void *)&cmd_showbypass_config_config,
4622 (void *)&cmd_showbypass_config_port,
4627 #ifdef RTE_LIBRTE_PMD_BOND
4628 /* *** SET BONDING MODE *** */
4629 struct cmd_set_bonding_mode_result {
4630 cmdline_fixed_string_t set;
4631 cmdline_fixed_string_t bonding;
4632 cmdline_fixed_string_t mode;
4637 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4638 __attribute__((unused)) struct cmdline *cl,
4639 __attribute__((unused)) void *data)
4641 struct cmd_set_bonding_mode_result *res = parsed_result;
4642 portid_t port_id = res->port_id;
4644 /* Set the bonding mode for the relevant port. */
4645 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4646 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4649 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4650 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4652 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4653 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4654 bonding, "bonding");
4655 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4656 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4658 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4659 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4661 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4662 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4665 cmdline_parse_inst_t cmd_set_bonding_mode = {
4666 .f = cmd_set_bonding_mode_parsed,
4667 .help_str = "set bonding mode <mode_value> <port_id>: "
4668 "Set the bonding mode for port_id",
4671 (void *) &cmd_setbonding_mode_set,
4672 (void *) &cmd_setbonding_mode_bonding,
4673 (void *) &cmd_setbonding_mode_mode,
4674 (void *) &cmd_setbonding_mode_value,
4675 (void *) &cmd_setbonding_mode_port,
4680 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4681 struct cmd_set_bonding_lacp_dedicated_queues_result {
4682 cmdline_fixed_string_t set;
4683 cmdline_fixed_string_t bonding;
4684 cmdline_fixed_string_t lacp;
4685 cmdline_fixed_string_t dedicated_queues;
4687 cmdline_fixed_string_t mode;
4690 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4691 __attribute__((unused)) struct cmdline *cl,
4692 __attribute__((unused)) void *data)
4694 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4695 portid_t port_id = res->port_id;
4696 struct rte_port *port;
4698 port = &ports[port_id];
4700 /** Check if the port is not started **/
4701 if (port->port_status != RTE_PORT_STOPPED) {
4702 printf("Please stop port %d first\n", port_id);
4706 if (!strcmp(res->mode, "enable")) {
4707 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4708 printf("Dedicate queues for LACP control packets"
4711 printf("Enabling dedicate queues for LACP control "
4712 "packets on port %d failed\n", port_id);
4713 } else if (!strcmp(res->mode, "disable")) {
4714 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4715 printf("Dedicated queues for LACP control packets "
4718 printf("Disabling dedicated queues for LACP control "
4719 "traffic on port %d failed\n", port_id);
4723 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4724 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4726 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4727 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4728 bonding, "bonding");
4729 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4730 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4732 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4733 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4734 dedicated_queues, "dedicated_queues");
4735 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4736 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4738 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4739 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4740 mode, "enable#disable");
4742 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4743 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4744 .help_str = "set bonding lacp dedicated_queues <port_id> "
4746 "Enable/disable dedicated queues for LACP control traffic for port_id",
4749 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4750 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4751 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4752 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4753 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4754 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4759 /* *** SET BALANCE XMIT POLICY *** */
4760 struct cmd_set_bonding_balance_xmit_policy_result {
4761 cmdline_fixed_string_t set;
4762 cmdline_fixed_string_t bonding;
4763 cmdline_fixed_string_t balance_xmit_policy;
4765 cmdline_fixed_string_t policy;
4768 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4769 __attribute__((unused)) struct cmdline *cl,
4770 __attribute__((unused)) void *data)
4772 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4773 portid_t port_id = res->port_id;
4776 if (!strcmp(res->policy, "l2")) {
4777 policy = BALANCE_XMIT_POLICY_LAYER2;
4778 } else if (!strcmp(res->policy, "l23")) {
4779 policy = BALANCE_XMIT_POLICY_LAYER23;
4780 } else if (!strcmp(res->policy, "l34")) {
4781 policy = BALANCE_XMIT_POLICY_LAYER34;
4783 printf("\t Invalid xmit policy selection");
4787 /* Set the bonding mode for the relevant port. */
4788 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4789 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4794 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4797 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4798 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4799 bonding, "bonding");
4800 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4801 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4802 balance_xmit_policy, "balance_xmit_policy");
4803 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4804 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4806 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4807 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4808 policy, "l2#l23#l34");
4810 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4811 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4812 .help_str = "set bonding balance_xmit_policy <port_id> "
4814 "Set the bonding balance_xmit_policy for port_id",
4817 (void *)&cmd_setbonding_balance_xmit_policy_set,
4818 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4819 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4820 (void *)&cmd_setbonding_balance_xmit_policy_port,
4821 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4826 /* *** SHOW NIC BONDING CONFIGURATION *** */
4827 struct cmd_show_bonding_config_result {
4828 cmdline_fixed_string_t show;
4829 cmdline_fixed_string_t bonding;
4830 cmdline_fixed_string_t config;
4834 static void cmd_show_bonding_config_parsed(void *parsed_result,
4835 __attribute__((unused)) struct cmdline *cl,
4836 __attribute__((unused)) void *data)
4838 struct cmd_show_bonding_config_result *res = parsed_result;
4839 int bonding_mode, agg_mode;
4840 portid_t slaves[RTE_MAX_ETHPORTS];
4841 int num_slaves, num_active_slaves;
4844 portid_t port_id = res->port_id;
4846 /* Display the bonding mode.*/
4847 bonding_mode = rte_eth_bond_mode_get(port_id);
4848 if (bonding_mode < 0) {
4849 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4852 printf("\tBonding mode: %d\n", bonding_mode);
4854 if (bonding_mode == BONDING_MODE_BALANCE) {
4855 int balance_xmit_policy;
4857 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4858 if (balance_xmit_policy < 0) {
4859 printf("\tFailed to get balance xmit policy for port = %d\n",
4863 printf("\tBalance Xmit Policy: ");
4865 switch (balance_xmit_policy) {
4866 case BALANCE_XMIT_POLICY_LAYER2:
4867 printf("BALANCE_XMIT_POLICY_LAYER2");
4869 case BALANCE_XMIT_POLICY_LAYER23:
4870 printf("BALANCE_XMIT_POLICY_LAYER23");
4872 case BALANCE_XMIT_POLICY_LAYER34:
4873 printf("BALANCE_XMIT_POLICY_LAYER34");
4880 if (bonding_mode == BONDING_MODE_8023AD) {
4881 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4882 printf("\tIEEE802.3AD Aggregator Mode: ");
4885 printf("bandwidth");
4897 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4899 if (num_slaves < 0) {
4900 printf("\tFailed to get slave list for port = %d\n", port_id);
4903 if (num_slaves > 0) {
4904 printf("\tSlaves (%d): [", num_slaves);
4905 for (i = 0; i < num_slaves - 1; i++)
4906 printf("%d ", slaves[i]);
4908 printf("%d]\n", slaves[num_slaves - 1]);
4910 printf("\tSlaves: []\n");
4914 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4917 if (num_active_slaves < 0) {
4918 printf("\tFailed to get active slave list for port = %d\n", port_id);
4921 if (num_active_slaves > 0) {
4922 printf("\tActive Slaves (%d): [", num_active_slaves);
4923 for (i = 0; i < num_active_slaves - 1; i++)
4924 printf("%d ", slaves[i]);
4926 printf("%d]\n", slaves[num_active_slaves - 1]);
4929 printf("\tActive Slaves: []\n");
4933 primary_id = rte_eth_bond_primary_get(port_id);
4934 if (primary_id < 0) {
4935 printf("\tFailed to get primary slave for port = %d\n", port_id);
4938 printf("\tPrimary: [%d]\n", primary_id);
4942 cmdline_parse_token_string_t cmd_showbonding_config_show =
4943 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4945 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4946 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4947 bonding, "bonding");
4948 cmdline_parse_token_string_t cmd_showbonding_config_config =
4949 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4951 cmdline_parse_token_num_t cmd_showbonding_config_port =
4952 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4955 cmdline_parse_inst_t cmd_show_bonding_config = {
4956 .f = cmd_show_bonding_config_parsed,
4957 .help_str = "show bonding config <port_id>: "
4958 "Show the bonding config for port_id",
4961 (void *)&cmd_showbonding_config_show,
4962 (void *)&cmd_showbonding_config_bonding,
4963 (void *)&cmd_showbonding_config_config,
4964 (void *)&cmd_showbonding_config_port,
4969 /* *** SET BONDING PRIMARY *** */
4970 struct cmd_set_bonding_primary_result {
4971 cmdline_fixed_string_t set;
4972 cmdline_fixed_string_t bonding;
4973 cmdline_fixed_string_t primary;
4978 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4979 __attribute__((unused)) struct cmdline *cl,
4980 __attribute__((unused)) void *data)
4982 struct cmd_set_bonding_primary_result *res = parsed_result;
4983 portid_t master_port_id = res->port_id;
4984 portid_t slave_port_id = res->slave_id;
4986 /* Set the primary slave for a bonded device. */
4987 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4988 printf("\t Failed to set primary slave for port = %d.\n",
4995 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4996 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4998 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4999 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5000 bonding, "bonding");
5001 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5002 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5003 primary, "primary");
5004 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5005 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5007 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5008 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5011 cmdline_parse_inst_t cmd_set_bonding_primary = {
5012 .f = cmd_set_bonding_primary_parsed,
5013 .help_str = "set bonding primary <slave_id> <port_id>: "
5014 "Set the primary slave for port_id",
5017 (void *)&cmd_setbonding_primary_set,
5018 (void *)&cmd_setbonding_primary_bonding,
5019 (void *)&cmd_setbonding_primary_primary,
5020 (void *)&cmd_setbonding_primary_slave,
5021 (void *)&cmd_setbonding_primary_port,
5026 /* *** ADD SLAVE *** */
5027 struct cmd_add_bonding_slave_result {
5028 cmdline_fixed_string_t add;
5029 cmdline_fixed_string_t bonding;
5030 cmdline_fixed_string_t slave;
5035 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5036 __attribute__((unused)) struct cmdline *cl,
5037 __attribute__((unused)) void *data)
5039 struct cmd_add_bonding_slave_result *res = parsed_result;
5040 portid_t master_port_id = res->port_id;
5041 portid_t slave_port_id = res->slave_id;
5043 /* add the slave for a bonded device. */
5044 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5045 printf("\t Failed to add slave %d to master port = %d.\n",
5046 slave_port_id, master_port_id);
5050 set_port_slave_flag(slave_port_id);
5053 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5054 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5056 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5057 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5058 bonding, "bonding");
5059 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5060 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5062 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5063 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5065 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5066 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5069 cmdline_parse_inst_t cmd_add_bonding_slave = {
5070 .f = cmd_add_bonding_slave_parsed,
5071 .help_str = "add bonding slave <slave_id> <port_id>: "
5072 "Add a slave device to a bonded device",
5075 (void *)&cmd_addbonding_slave_add,
5076 (void *)&cmd_addbonding_slave_bonding,
5077 (void *)&cmd_addbonding_slave_slave,
5078 (void *)&cmd_addbonding_slave_slaveid,
5079 (void *)&cmd_addbonding_slave_port,
5084 /* *** REMOVE SLAVE *** */
5085 struct cmd_remove_bonding_slave_result {
5086 cmdline_fixed_string_t remove;
5087 cmdline_fixed_string_t bonding;
5088 cmdline_fixed_string_t slave;
5093 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5094 __attribute__((unused)) struct cmdline *cl,
5095 __attribute__((unused)) void *data)
5097 struct cmd_remove_bonding_slave_result *res = parsed_result;
5098 portid_t master_port_id = res->port_id;
5099 portid_t slave_port_id = res->slave_id;
5101 /* remove the slave from a bonded device. */
5102 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5103 printf("\t Failed to remove slave %d from master port = %d.\n",
5104 slave_port_id, master_port_id);
5108 clear_port_slave_flag(slave_port_id);
5111 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5112 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5114 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5115 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5116 bonding, "bonding");
5117 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5118 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5120 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5121 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5123 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5124 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5127 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5128 .f = cmd_remove_bonding_slave_parsed,
5129 .help_str = "remove bonding slave <slave_id> <port_id>: "
5130 "Remove a slave device from a bonded device",
5133 (void *)&cmd_removebonding_slave_remove,
5134 (void *)&cmd_removebonding_slave_bonding,
5135 (void *)&cmd_removebonding_slave_slave,
5136 (void *)&cmd_removebonding_slave_slaveid,
5137 (void *)&cmd_removebonding_slave_port,
5142 /* *** CREATE BONDED DEVICE *** */
5143 struct cmd_create_bonded_device_result {
5144 cmdline_fixed_string_t create;
5145 cmdline_fixed_string_t bonded;
5146 cmdline_fixed_string_t device;
5151 static int bond_dev_num = 0;
5153 static void cmd_create_bonded_device_parsed(void *parsed_result,
5154 __attribute__((unused)) struct cmdline *cl,
5155 __attribute__((unused)) void *data)
5157 struct cmd_create_bonded_device_result *res = parsed_result;
5158 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5161 if (test_done == 0) {
5162 printf("Please stop forwarding first\n");
5166 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5169 /* Create a new bonded device. */
5170 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5172 printf("\t Failed to create bonded device.\n");
5175 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5178 /* Update number of ports */
5179 nb_ports = rte_eth_dev_count();
5180 reconfig(port_id, res->socket);
5181 rte_eth_promiscuous_enable(port_id);
5186 cmdline_parse_token_string_t cmd_createbonded_device_create =
5187 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5189 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5190 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5192 cmdline_parse_token_string_t cmd_createbonded_device_device =
5193 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5195 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5196 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5198 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5199 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5202 cmdline_parse_inst_t cmd_create_bonded_device = {
5203 .f = cmd_create_bonded_device_parsed,
5204 .help_str = "create bonded device <mode> <socket>: "
5205 "Create a new bonded device with specific bonding mode and socket",
5208 (void *)&cmd_createbonded_device_create,
5209 (void *)&cmd_createbonded_device_bonded,
5210 (void *)&cmd_createbonded_device_device,
5211 (void *)&cmd_createbonded_device_mode,
5212 (void *)&cmd_createbonded_device_socket,
5217 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5218 struct cmd_set_bond_mac_addr_result {
5219 cmdline_fixed_string_t set;
5220 cmdline_fixed_string_t bonding;
5221 cmdline_fixed_string_t mac_addr;
5223 struct ether_addr address;
5226 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5227 __attribute__((unused)) struct cmdline *cl,
5228 __attribute__((unused)) void *data)
5230 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5233 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5236 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5238 /* check the return value and print it if is < 0 */
5240 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5243 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5244 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5245 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5246 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5248 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5249 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5251 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5252 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
5253 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5254 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5256 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5257 .f = cmd_set_bond_mac_addr_parsed,
5259 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5261 (void *)&cmd_set_bond_mac_addr_set,
5262 (void *)&cmd_set_bond_mac_addr_bonding,
5263 (void *)&cmd_set_bond_mac_addr_mac,
5264 (void *)&cmd_set_bond_mac_addr_portnum,
5265 (void *)&cmd_set_bond_mac_addr_addr,
5271 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5272 struct cmd_set_bond_mon_period_result {
5273 cmdline_fixed_string_t set;
5274 cmdline_fixed_string_t bonding;
5275 cmdline_fixed_string_t mon_period;
5280 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5281 __attribute__((unused)) struct cmdline *cl,
5282 __attribute__((unused)) void *data)
5284 struct cmd_set_bond_mon_period_result *res = parsed_result;
5287 if (res->port_num >= nb_ports) {
5288 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5292 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5294 /* check the return value and print it if is < 0 */
5296 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5299 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5300 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5302 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5303 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5304 bonding, "bonding");
5305 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5306 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5307 mon_period, "mon_period");
5308 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5309 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5311 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5312 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5315 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5316 .f = cmd_set_bond_mon_period_parsed,
5318 .help_str = "set bonding mon_period <port_id> <period_ms>",
5320 (void *)&cmd_set_bond_mon_period_set,
5321 (void *)&cmd_set_bond_mon_period_bonding,
5322 (void *)&cmd_set_bond_mon_period_mon_period,
5323 (void *)&cmd_set_bond_mon_period_portnum,
5324 (void *)&cmd_set_bond_mon_period_period_ms,
5331 struct cmd_set_bonding_agg_mode_policy_result {
5332 cmdline_fixed_string_t set;
5333 cmdline_fixed_string_t bonding;
5334 cmdline_fixed_string_t agg_mode;
5336 cmdline_fixed_string_t policy;
5341 cmd_set_bonding_agg_mode(void *parsed_result,
5342 __attribute__((unused)) struct cmdline *cl,
5343 __attribute__((unused)) void *data)
5345 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5346 uint8_t policy = AGG_BANDWIDTH;
5348 if (res->port_num >= nb_ports) {
5349 printf("Port id %d must be less than %d\n",
5350 res->port_num, nb_ports);
5354 if (!strcmp(res->policy, "bandwidth"))
5355 policy = AGG_BANDWIDTH;
5356 else if (!strcmp(res->policy, "stable"))
5357 policy = AGG_STABLE;
5358 else if (!strcmp(res->policy, "count"))
5361 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5365 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5366 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5368 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5369 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5370 bonding, "bonding");
5372 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5374 agg_mode, "agg_mode");
5376 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5377 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5380 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5381 TOKEN_STRING_INITIALIZER(
5382 struct cmd_set_bonding_balance_xmit_policy_result,
5383 policy, "stable#bandwidth#count");
5385 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5386 .f = cmd_set_bonding_agg_mode,
5388 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5390 (void *)&cmd_set_bonding_agg_mode_set,
5391 (void *)&cmd_set_bonding_agg_mode_bonding,
5392 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5393 (void *)&cmd_set_bonding_agg_mode_portnum,
5394 (void *)&cmd_set_bonding_agg_mode_policy_string,
5400 #endif /* RTE_LIBRTE_PMD_BOND */
5402 /* *** SET FORWARDING MODE *** */
5403 struct cmd_set_fwd_mode_result {
5404 cmdline_fixed_string_t set;
5405 cmdline_fixed_string_t fwd;
5406 cmdline_fixed_string_t mode;
5409 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5410 __attribute__((unused)) struct cmdline *cl,
5411 __attribute__((unused)) void *data)
5413 struct cmd_set_fwd_mode_result *res = parsed_result;
5416 set_pkt_forwarding_mode(res->mode);
5419 cmdline_parse_token_string_t cmd_setfwd_set =
5420 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5421 cmdline_parse_token_string_t cmd_setfwd_fwd =
5422 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5423 cmdline_parse_token_string_t cmd_setfwd_mode =
5424 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5425 "" /* defined at init */);
5427 cmdline_parse_inst_t cmd_set_fwd_mode = {
5428 .f = cmd_set_fwd_mode_parsed,
5430 .help_str = NULL, /* defined at init */
5432 (void *)&cmd_setfwd_set,
5433 (void *)&cmd_setfwd_fwd,
5434 (void *)&cmd_setfwd_mode,
5439 static void cmd_set_fwd_mode_init(void)
5442 static char token[128];
5443 static char help[256];
5444 cmdline_parse_token_string_t *token_struct;
5446 modes = list_pkt_forwarding_modes();
5447 snprintf(help, sizeof(help), "set fwd %s: "
5448 "Set packet forwarding mode", modes);
5449 cmd_set_fwd_mode.help_str = help;
5451 /* string token separator is # */
5452 for (c = token; *modes != '\0'; modes++)
5457 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5458 token_struct->string_data.str = token;
5461 /* *** SET RETRY FORWARDING MODE *** */
5462 struct cmd_set_fwd_retry_mode_result {
5463 cmdline_fixed_string_t set;
5464 cmdline_fixed_string_t fwd;
5465 cmdline_fixed_string_t mode;
5466 cmdline_fixed_string_t retry;
5469 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5470 __attribute__((unused)) struct cmdline *cl,
5471 __attribute__((unused)) void *data)
5473 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5476 set_pkt_forwarding_mode(res->mode);
5479 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5480 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5482 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5483 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5485 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5486 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5488 "" /* defined at init */);
5489 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5490 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5493 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5494 .f = cmd_set_fwd_retry_mode_parsed,
5496 .help_str = NULL, /* defined at init */
5498 (void *)&cmd_setfwd_retry_set,
5499 (void *)&cmd_setfwd_retry_fwd,
5500 (void *)&cmd_setfwd_retry_mode,
5501 (void *)&cmd_setfwd_retry_retry,
5506 static void cmd_set_fwd_retry_mode_init(void)
5509 static char token[128];
5510 static char help[256];
5511 cmdline_parse_token_string_t *token_struct;
5513 modes = list_pkt_forwarding_retry_modes();
5514 snprintf(help, sizeof(help), "set fwd %s retry: "
5515 "Set packet forwarding mode with retry", modes);
5516 cmd_set_fwd_retry_mode.help_str = help;
5518 /* string token separator is # */
5519 for (c = token; *modes != '\0'; modes++)
5524 token_struct = (cmdline_parse_token_string_t *)
5525 cmd_set_fwd_retry_mode.tokens[2];
5526 token_struct->string_data.str = token;
5529 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5530 struct cmd_set_burst_tx_retry_result {
5531 cmdline_fixed_string_t set;
5532 cmdline_fixed_string_t burst;
5533 cmdline_fixed_string_t tx;
5534 cmdline_fixed_string_t delay;
5536 cmdline_fixed_string_t retry;
5540 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5541 __attribute__((unused)) struct cmdline *cl,
5542 __attribute__((unused)) void *data)
5544 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5546 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5547 && !strcmp(res->tx, "tx")) {
5548 if (!strcmp(res->delay, "delay"))
5549 burst_tx_delay_time = res->time;
5550 if (!strcmp(res->retry, "retry"))
5551 burst_tx_retry_num = res->retry_num;
5556 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5557 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5558 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5561 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5562 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5563 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5565 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5566 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5567 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5569 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5570 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5572 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5573 .f = cmd_set_burst_tx_retry_parsed,
5574 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5576 (void *)&cmd_set_burst_tx_retry_set,
5577 (void *)&cmd_set_burst_tx_retry_burst,
5578 (void *)&cmd_set_burst_tx_retry_tx,
5579 (void *)&cmd_set_burst_tx_retry_delay,
5580 (void *)&cmd_set_burst_tx_retry_time,
5581 (void *)&cmd_set_burst_tx_retry_retry,
5582 (void *)&cmd_set_burst_tx_retry_retry_num,
5587 /* *** SET PROMISC MODE *** */
5588 struct cmd_set_promisc_mode_result {
5589 cmdline_fixed_string_t set;
5590 cmdline_fixed_string_t promisc;
5591 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5592 uint8_t port_num; /* valid if "allports" argument == 0 */
5593 cmdline_fixed_string_t mode;
5596 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5597 __attribute__((unused)) struct cmdline *cl,
5600 struct cmd_set_promisc_mode_result *res = parsed_result;
5604 if (!strcmp(res->mode, "on"))
5611 RTE_ETH_FOREACH_DEV(i) {
5613 rte_eth_promiscuous_enable(i);
5615 rte_eth_promiscuous_disable(i);
5620 rte_eth_promiscuous_enable(res->port_num);
5622 rte_eth_promiscuous_disable(res->port_num);
5626 cmdline_parse_token_string_t cmd_setpromisc_set =
5627 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5628 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5631 cmdline_parse_token_string_t cmd_setpromisc_portall =
5632 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5634 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5635 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5637 cmdline_parse_token_string_t cmd_setpromisc_mode =
5638 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5641 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5642 .f = cmd_set_promisc_mode_parsed,
5644 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5646 (void *)&cmd_setpromisc_set,
5647 (void *)&cmd_setpromisc_promisc,
5648 (void *)&cmd_setpromisc_portall,
5649 (void *)&cmd_setpromisc_mode,
5654 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5655 .f = cmd_set_promisc_mode_parsed,
5657 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5659 (void *)&cmd_setpromisc_set,
5660 (void *)&cmd_setpromisc_promisc,
5661 (void *)&cmd_setpromisc_portnum,
5662 (void *)&cmd_setpromisc_mode,
5667 /* *** SET ALLMULTI MODE *** */
5668 struct cmd_set_allmulti_mode_result {
5669 cmdline_fixed_string_t set;
5670 cmdline_fixed_string_t allmulti;
5671 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5672 uint8_t port_num; /* valid if "allports" argument == 0 */
5673 cmdline_fixed_string_t mode;
5676 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5677 __attribute__((unused)) struct cmdline *cl,
5680 struct cmd_set_allmulti_mode_result *res = parsed_result;
5684 if (!strcmp(res->mode, "on"))
5691 RTE_ETH_FOREACH_DEV(i) {
5693 rte_eth_allmulticast_enable(i);
5695 rte_eth_allmulticast_disable(i);
5700 rte_eth_allmulticast_enable(res->port_num);
5702 rte_eth_allmulticast_disable(res->port_num);
5706 cmdline_parse_token_string_t cmd_setallmulti_set =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5708 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5709 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5711 cmdline_parse_token_string_t cmd_setallmulti_portall =
5712 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5714 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5715 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5717 cmdline_parse_token_string_t cmd_setallmulti_mode =
5718 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5721 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5722 .f = cmd_set_allmulti_mode_parsed,
5724 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5726 (void *)&cmd_setallmulti_set,
5727 (void *)&cmd_setallmulti_allmulti,
5728 (void *)&cmd_setallmulti_portall,
5729 (void *)&cmd_setallmulti_mode,
5734 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5735 .f = cmd_set_allmulti_mode_parsed,
5737 .help_str = "set allmulti <port_id> on|off: "
5738 "Set allmulti mode on port_id",
5740 (void *)&cmd_setallmulti_set,
5741 (void *)&cmd_setallmulti_allmulti,
5742 (void *)&cmd_setallmulti_portnum,
5743 (void *)&cmd_setallmulti_mode,
5748 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5749 struct cmd_link_flow_ctrl_set_result {
5750 cmdline_fixed_string_t set;
5751 cmdline_fixed_string_t flow_ctrl;
5752 cmdline_fixed_string_t rx;
5753 cmdline_fixed_string_t rx_lfc_mode;
5754 cmdline_fixed_string_t tx;
5755 cmdline_fixed_string_t tx_lfc_mode;
5756 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5757 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5758 cmdline_fixed_string_t autoneg_str;
5759 cmdline_fixed_string_t autoneg;
5760 cmdline_fixed_string_t hw_str;
5761 uint32_t high_water;
5762 cmdline_fixed_string_t lw_str;
5764 cmdline_fixed_string_t pt_str;
5765 uint16_t pause_time;
5766 cmdline_fixed_string_t xon_str;
5771 cmdline_parse_token_string_t cmd_lfc_set_set =
5772 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5774 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5775 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5776 flow_ctrl, "flow_ctrl");
5777 cmdline_parse_token_string_t cmd_lfc_set_rx =
5778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5780 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5781 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5782 rx_lfc_mode, "on#off");
5783 cmdline_parse_token_string_t cmd_lfc_set_tx =
5784 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5786 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5787 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5788 tx_lfc_mode, "on#off");
5789 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5790 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5791 hw_str, "high_water");
5792 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5793 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5794 high_water, UINT32);
5795 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5796 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5797 lw_str, "low_water");
5798 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5799 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5801 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5802 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5803 pt_str, "pause_time");
5804 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5805 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5806 pause_time, UINT16);
5807 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5808 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5809 xon_str, "send_xon");
5810 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5811 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5813 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5814 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5815 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5816 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5817 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5818 mac_ctrl_frame_fwd_mode, "on#off");
5819 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5820 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5821 autoneg_str, "autoneg");
5822 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5823 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5825 cmdline_parse_token_num_t cmd_lfc_set_portid =
5826 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5829 /* forward declaration */
5831 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5834 cmdline_parse_inst_t cmd_link_flow_control_set = {
5835 .f = cmd_link_flow_ctrl_set_parsed,
5837 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5838 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5839 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5841 (void *)&cmd_lfc_set_set,
5842 (void *)&cmd_lfc_set_flow_ctrl,
5843 (void *)&cmd_lfc_set_rx,
5844 (void *)&cmd_lfc_set_rx_mode,
5845 (void *)&cmd_lfc_set_tx,
5846 (void *)&cmd_lfc_set_tx_mode,
5847 (void *)&cmd_lfc_set_high_water,
5848 (void *)&cmd_lfc_set_low_water,
5849 (void *)&cmd_lfc_set_pause_time,
5850 (void *)&cmd_lfc_set_send_xon,
5851 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5852 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5853 (void *)&cmd_lfc_set_autoneg_str,
5854 (void *)&cmd_lfc_set_autoneg,
5855 (void *)&cmd_lfc_set_portid,
5860 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5861 .f = cmd_link_flow_ctrl_set_parsed,
5862 .data = (void *)&cmd_link_flow_control_set_rx,
5863 .help_str = "set flow_ctrl rx on|off <port_id>: "
5864 "Change rx flow control parameter",
5866 (void *)&cmd_lfc_set_set,
5867 (void *)&cmd_lfc_set_flow_ctrl,
5868 (void *)&cmd_lfc_set_rx,
5869 (void *)&cmd_lfc_set_rx_mode,
5870 (void *)&cmd_lfc_set_portid,
5875 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5876 .f = cmd_link_flow_ctrl_set_parsed,
5877 .data = (void *)&cmd_link_flow_control_set_tx,
5878 .help_str = "set flow_ctrl tx on|off <port_id>: "
5879 "Change tx flow control parameter",
5881 (void *)&cmd_lfc_set_set,
5882 (void *)&cmd_lfc_set_flow_ctrl,
5883 (void *)&cmd_lfc_set_tx,
5884 (void *)&cmd_lfc_set_tx_mode,
5885 (void *)&cmd_lfc_set_portid,
5890 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5891 .f = cmd_link_flow_ctrl_set_parsed,
5892 .data = (void *)&cmd_link_flow_control_set_hw,
5893 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5894 "Change high water flow control parameter",
5896 (void *)&cmd_lfc_set_set,
5897 (void *)&cmd_lfc_set_flow_ctrl,
5898 (void *)&cmd_lfc_set_high_water_str,
5899 (void *)&cmd_lfc_set_high_water,
5900 (void *)&cmd_lfc_set_portid,
5905 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5906 .f = cmd_link_flow_ctrl_set_parsed,
5907 .data = (void *)&cmd_link_flow_control_set_lw,
5908 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5909 "Change low water flow control parameter",
5911 (void *)&cmd_lfc_set_set,
5912 (void *)&cmd_lfc_set_flow_ctrl,
5913 (void *)&cmd_lfc_set_low_water_str,
5914 (void *)&cmd_lfc_set_low_water,
5915 (void *)&cmd_lfc_set_portid,
5920 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5921 .f = cmd_link_flow_ctrl_set_parsed,
5922 .data = (void *)&cmd_link_flow_control_set_pt,
5923 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5924 "Change pause time flow control parameter",
5926 (void *)&cmd_lfc_set_set,
5927 (void *)&cmd_lfc_set_flow_ctrl,
5928 (void *)&cmd_lfc_set_pause_time_str,
5929 (void *)&cmd_lfc_set_pause_time,
5930 (void *)&cmd_lfc_set_portid,
5935 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5936 .f = cmd_link_flow_ctrl_set_parsed,
5937 .data = (void *)&cmd_link_flow_control_set_xon,
5938 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5939 "Change send_xon flow control parameter",
5941 (void *)&cmd_lfc_set_set,
5942 (void *)&cmd_lfc_set_flow_ctrl,
5943 (void *)&cmd_lfc_set_send_xon_str,
5944 (void *)&cmd_lfc_set_send_xon,
5945 (void *)&cmd_lfc_set_portid,
5950 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5951 .f = cmd_link_flow_ctrl_set_parsed,
5952 .data = (void *)&cmd_link_flow_control_set_macfwd,
5953 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5954 "Change mac ctrl fwd flow control parameter",
5956 (void *)&cmd_lfc_set_set,
5957 (void *)&cmd_lfc_set_flow_ctrl,
5958 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5959 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5960 (void *)&cmd_lfc_set_portid,
5965 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5966 .f = cmd_link_flow_ctrl_set_parsed,
5967 .data = (void *)&cmd_link_flow_control_set_autoneg,
5968 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5969 "Change autoneg flow control parameter",
5971 (void *)&cmd_lfc_set_set,
5972 (void *)&cmd_lfc_set_flow_ctrl,
5973 (void *)&cmd_lfc_set_autoneg_str,
5974 (void *)&cmd_lfc_set_autoneg,
5975 (void *)&cmd_lfc_set_portid,
5981 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5982 __attribute__((unused)) struct cmdline *cl,
5985 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5986 cmdline_parse_inst_t *cmd = data;
5987 struct rte_eth_fc_conf fc_conf;
5993 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5994 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5995 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5996 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5998 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5999 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6002 /* Partial command line, retrieve current configuration */
6004 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6006 printf("cannot get current flow ctrl parameters, return"
6007 "code = %d\n", ret);
6011 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6012 (fc_conf.mode == RTE_FC_FULL))
6014 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6015 (fc_conf.mode == RTE_FC_FULL))
6019 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6020 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6022 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6023 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6025 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6027 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6028 fc_conf.high_water = res->high_water;
6030 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6031 fc_conf.low_water = res->low_water;
6033 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6034 fc_conf.pause_time = res->pause_time;
6036 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6037 fc_conf.send_xon = res->send_xon;
6039 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6040 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6041 fc_conf.mac_ctrl_frame_fwd = 1;
6043 fc_conf.mac_ctrl_frame_fwd = 0;
6046 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6047 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6049 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6051 printf("bad flow contrl parameter, return code = %d \n", ret);
6054 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6055 struct cmd_priority_flow_ctrl_set_result {
6056 cmdline_fixed_string_t set;
6057 cmdline_fixed_string_t pfc_ctrl;
6058 cmdline_fixed_string_t rx;
6059 cmdline_fixed_string_t rx_pfc_mode;
6060 cmdline_fixed_string_t tx;
6061 cmdline_fixed_string_t tx_pfc_mode;
6062 uint32_t high_water;
6064 uint16_t pause_time;
6070 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6071 __attribute__((unused)) struct cmdline *cl,
6072 __attribute__((unused)) void *data)
6074 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6075 struct rte_eth_pfc_conf pfc_conf;
6076 int rx_fc_enable, tx_fc_enable;
6080 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6081 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6082 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6083 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6085 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6086 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6089 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6090 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6091 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6092 pfc_conf.fc.high_water = res->high_water;
6093 pfc_conf.fc.low_water = res->low_water;
6094 pfc_conf.fc.pause_time = res->pause_time;
6095 pfc_conf.priority = res->priority;
6097 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6099 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6102 cmdline_parse_token_string_t cmd_pfc_set_set =
6103 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6105 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6106 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6107 pfc_ctrl, "pfc_ctrl");
6108 cmdline_parse_token_string_t cmd_pfc_set_rx =
6109 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6111 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6112 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6113 rx_pfc_mode, "on#off");
6114 cmdline_parse_token_string_t cmd_pfc_set_tx =
6115 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6117 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6118 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6119 tx_pfc_mode, "on#off");
6120 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6121 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6122 high_water, UINT32);
6123 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6124 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6126 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6127 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6128 pause_time, UINT16);
6129 cmdline_parse_token_num_t cmd_pfc_set_priority =
6130 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6132 cmdline_parse_token_num_t cmd_pfc_set_portid =
6133 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6136 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6137 .f = cmd_priority_flow_ctrl_set_parsed,
6139 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6140 "<pause_time> <priority> <port_id>: "
6141 "Configure the Ethernet priority flow control",
6143 (void *)&cmd_pfc_set_set,
6144 (void *)&cmd_pfc_set_flow_ctrl,
6145 (void *)&cmd_pfc_set_rx,
6146 (void *)&cmd_pfc_set_rx_mode,
6147 (void *)&cmd_pfc_set_tx,
6148 (void *)&cmd_pfc_set_tx_mode,
6149 (void *)&cmd_pfc_set_high_water,
6150 (void *)&cmd_pfc_set_low_water,
6151 (void *)&cmd_pfc_set_pause_time,
6152 (void *)&cmd_pfc_set_priority,
6153 (void *)&cmd_pfc_set_portid,
6158 /* *** RESET CONFIGURATION *** */
6159 struct cmd_reset_result {
6160 cmdline_fixed_string_t reset;
6161 cmdline_fixed_string_t def;
6164 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6166 __attribute__((unused)) void *data)
6168 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6169 set_def_fwd_config();
6172 cmdline_parse_token_string_t cmd_reset_set =
6173 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6174 cmdline_parse_token_string_t cmd_reset_def =
6175 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6178 cmdline_parse_inst_t cmd_reset = {
6179 .f = cmd_reset_parsed,
6181 .help_str = "set default: Reset default forwarding configuration",
6183 (void *)&cmd_reset_set,
6184 (void *)&cmd_reset_def,
6189 /* *** START FORWARDING *** */
6190 struct cmd_start_result {
6191 cmdline_fixed_string_t start;
6194 cmdline_parse_token_string_t cmd_start_start =
6195 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6197 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6198 __attribute__((unused)) struct cmdline *cl,
6199 __attribute__((unused)) void *data)
6201 start_packet_forwarding(0);
6204 cmdline_parse_inst_t cmd_start = {
6205 .f = cmd_start_parsed,
6207 .help_str = "start: Start packet forwarding",
6209 (void *)&cmd_start_start,
6214 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6215 struct cmd_start_tx_first_result {
6216 cmdline_fixed_string_t start;
6217 cmdline_fixed_string_t tx_first;
6221 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6222 __attribute__((unused)) struct cmdline *cl,
6223 __attribute__((unused)) void *data)
6225 start_packet_forwarding(1);
6228 cmdline_parse_token_string_t cmd_start_tx_first_start =
6229 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6231 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6232 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6233 tx_first, "tx_first");
6235 cmdline_parse_inst_t cmd_start_tx_first = {
6236 .f = cmd_start_tx_first_parsed,
6238 .help_str = "start tx_first: Start packet forwarding, "
6239 "after sending 1 burst of packets",
6241 (void *)&cmd_start_tx_first_start,
6242 (void *)&cmd_start_tx_first_tx_first,
6247 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6248 struct cmd_start_tx_first_n_result {
6249 cmdline_fixed_string_t start;
6250 cmdline_fixed_string_t tx_first;
6255 cmd_start_tx_first_n_parsed(void *parsed_result,
6256 __attribute__((unused)) struct cmdline *cl,
6257 __attribute__((unused)) void *data)
6259 struct cmd_start_tx_first_n_result *res = parsed_result;
6261 start_packet_forwarding(res->tx_num);
6264 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6265 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6267 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6268 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6269 tx_first, "tx_first");
6270 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6271 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6274 cmdline_parse_inst_t cmd_start_tx_first_n = {
6275 .f = cmd_start_tx_first_n_parsed,
6277 .help_str = "start tx_first <num>: "
6278 "packet forwarding, after sending <num> bursts of packets",
6280 (void *)&cmd_start_tx_first_n_start,
6281 (void *)&cmd_start_tx_first_n_tx_first,
6282 (void *)&cmd_start_tx_first_n_tx_num,
6287 /* *** SET LINK UP *** */
6288 struct cmd_set_link_up_result {
6289 cmdline_fixed_string_t set;
6290 cmdline_fixed_string_t link_up;
6291 cmdline_fixed_string_t port;
6295 cmdline_parse_token_string_t cmd_set_link_up_set =
6296 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6297 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6298 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6300 cmdline_parse_token_string_t cmd_set_link_up_port =
6301 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6302 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6303 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
6305 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6306 __attribute__((unused)) struct cmdline *cl,
6307 __attribute__((unused)) void *data)
6309 struct cmd_set_link_up_result *res = parsed_result;
6310 dev_set_link_up(res->port_id);
6313 cmdline_parse_inst_t cmd_set_link_up = {
6314 .f = cmd_set_link_up_parsed,
6316 .help_str = "set link-up port <port id>",
6318 (void *)&cmd_set_link_up_set,
6319 (void *)&cmd_set_link_up_link_up,
6320 (void *)&cmd_set_link_up_port,
6321 (void *)&cmd_set_link_up_port_id,
6326 /* *** SET LINK DOWN *** */
6327 struct cmd_set_link_down_result {
6328 cmdline_fixed_string_t set;
6329 cmdline_fixed_string_t link_down;
6330 cmdline_fixed_string_t port;
6334 cmdline_parse_token_string_t cmd_set_link_down_set =
6335 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6336 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6337 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6339 cmdline_parse_token_string_t cmd_set_link_down_port =
6340 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6341 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6342 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
6344 static void cmd_set_link_down_parsed(
6345 __attribute__((unused)) void *parsed_result,
6346 __attribute__((unused)) struct cmdline *cl,
6347 __attribute__((unused)) void *data)
6349 struct cmd_set_link_down_result *res = parsed_result;
6350 dev_set_link_down(res->port_id);
6353 cmdline_parse_inst_t cmd_set_link_down = {
6354 .f = cmd_set_link_down_parsed,
6356 .help_str = "set link-down port <port id>",
6358 (void *)&cmd_set_link_down_set,
6359 (void *)&cmd_set_link_down_link_down,
6360 (void *)&cmd_set_link_down_port,
6361 (void *)&cmd_set_link_down_port_id,
6366 /* *** SHOW CFG *** */
6367 struct cmd_showcfg_result {
6368 cmdline_fixed_string_t show;
6369 cmdline_fixed_string_t cfg;
6370 cmdline_fixed_string_t what;
6373 static void cmd_showcfg_parsed(void *parsed_result,
6374 __attribute__((unused)) struct cmdline *cl,
6375 __attribute__((unused)) void *data)
6377 struct cmd_showcfg_result *res = parsed_result;
6378 if (!strcmp(res->what, "rxtx"))
6379 rxtx_config_display();
6380 else if (!strcmp(res->what, "cores"))
6381 fwd_lcores_config_display();
6382 else if (!strcmp(res->what, "fwd"))
6383 pkt_fwd_config_display(&cur_fwd_config);
6384 else if (!strcmp(res->what, "txpkts"))
6385 show_tx_pkt_segments();
6388 cmdline_parse_token_string_t cmd_showcfg_show =
6389 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6390 cmdline_parse_token_string_t cmd_showcfg_port =
6391 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6392 cmdline_parse_token_string_t cmd_showcfg_what =
6393 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6394 "rxtx#cores#fwd#txpkts");
6396 cmdline_parse_inst_t cmd_showcfg = {
6397 .f = cmd_showcfg_parsed,
6399 .help_str = "show config rxtx|cores|fwd|txpkts",
6401 (void *)&cmd_showcfg_show,
6402 (void *)&cmd_showcfg_port,
6403 (void *)&cmd_showcfg_what,
6408 /* *** SHOW ALL PORT INFO *** */
6409 struct cmd_showportall_result {
6410 cmdline_fixed_string_t show;
6411 cmdline_fixed_string_t port;
6412 cmdline_fixed_string_t what;
6413 cmdline_fixed_string_t all;
6416 static void cmd_showportall_parsed(void *parsed_result,
6417 __attribute__((unused)) struct cmdline *cl,
6418 __attribute__((unused)) void *data)
6422 struct cmd_showportall_result *res = parsed_result;
6423 if (!strcmp(res->show, "clear")) {
6424 if (!strcmp(res->what, "stats"))
6425 RTE_ETH_FOREACH_DEV(i)
6427 else if (!strcmp(res->what, "xstats"))
6428 RTE_ETH_FOREACH_DEV(i)
6429 nic_xstats_clear(i);
6430 } else if (!strcmp(res->what, "info"))
6431 RTE_ETH_FOREACH_DEV(i)
6432 port_infos_display(i);
6433 else if (!strcmp(res->what, "stats"))
6434 RTE_ETH_FOREACH_DEV(i)
6435 nic_stats_display(i);
6436 else if (!strcmp(res->what, "xstats"))
6437 RTE_ETH_FOREACH_DEV(i)
6438 nic_xstats_display(i);
6439 else if (!strcmp(res->what, "fdir"))
6440 RTE_ETH_FOREACH_DEV(i)
6442 else if (!strcmp(res->what, "stat_qmap"))
6443 RTE_ETH_FOREACH_DEV(i)
6444 nic_stats_mapping_display(i);
6445 else if (!strcmp(res->what, "dcb_tc"))
6446 RTE_ETH_FOREACH_DEV(i)
6447 port_dcb_info_display(i);
6448 else if (!strcmp(res->what, "cap"))
6449 RTE_ETH_FOREACH_DEV(i)
6450 port_offload_cap_display(i);
6453 cmdline_parse_token_string_t cmd_showportall_show =
6454 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6456 cmdline_parse_token_string_t cmd_showportall_port =
6457 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6458 cmdline_parse_token_string_t cmd_showportall_what =
6459 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6460 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6461 cmdline_parse_token_string_t cmd_showportall_all =
6462 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6463 cmdline_parse_inst_t cmd_showportall = {
6464 .f = cmd_showportall_parsed,
6466 .help_str = "show|clear port "
6467 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6469 (void *)&cmd_showportall_show,
6470 (void *)&cmd_showportall_port,
6471 (void *)&cmd_showportall_what,
6472 (void *)&cmd_showportall_all,
6477 /* *** SHOW PORT INFO *** */
6478 struct cmd_showport_result {
6479 cmdline_fixed_string_t show;
6480 cmdline_fixed_string_t port;
6481 cmdline_fixed_string_t what;
6485 static void cmd_showport_parsed(void *parsed_result,
6486 __attribute__((unused)) struct cmdline *cl,
6487 __attribute__((unused)) void *data)
6489 struct cmd_showport_result *res = parsed_result;
6490 if (!strcmp(res->show, "clear")) {
6491 if (!strcmp(res->what, "stats"))
6492 nic_stats_clear(res->portnum);
6493 else if (!strcmp(res->what, "xstats"))
6494 nic_xstats_clear(res->portnum);
6495 } else if (!strcmp(res->what, "info"))
6496 port_infos_display(res->portnum);
6497 else if (!strcmp(res->what, "stats"))
6498 nic_stats_display(res->portnum);
6499 else if (!strcmp(res->what, "xstats"))
6500 nic_xstats_display(res->portnum);
6501 else if (!strcmp(res->what, "fdir"))
6502 fdir_get_infos(res->portnum);
6503 else if (!strcmp(res->what, "stat_qmap"))
6504 nic_stats_mapping_display(res->portnum);
6505 else if (!strcmp(res->what, "dcb_tc"))
6506 port_dcb_info_display(res->portnum);
6507 else if (!strcmp(res->what, "cap"))
6508 port_offload_cap_display(res->portnum);
6511 cmdline_parse_token_string_t cmd_showport_show =
6512 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6514 cmdline_parse_token_string_t cmd_showport_port =
6515 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6516 cmdline_parse_token_string_t cmd_showport_what =
6517 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6518 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6519 cmdline_parse_token_num_t cmd_showport_portnum =
6520 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6522 cmdline_parse_inst_t cmd_showport = {
6523 .f = cmd_showport_parsed,
6525 .help_str = "show|clear port "
6526 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6529 (void *)&cmd_showport_show,
6530 (void *)&cmd_showport_port,
6531 (void *)&cmd_showport_what,
6532 (void *)&cmd_showport_portnum,
6537 /* *** SHOW QUEUE INFO *** */
6538 struct cmd_showqueue_result {
6539 cmdline_fixed_string_t show;
6540 cmdline_fixed_string_t type;
6541 cmdline_fixed_string_t what;
6547 cmd_showqueue_parsed(void *parsed_result,
6548 __attribute__((unused)) struct cmdline *cl,
6549 __attribute__((unused)) void *data)
6551 struct cmd_showqueue_result *res = parsed_result;
6553 if (!strcmp(res->type, "rxq"))
6554 rx_queue_infos_display(res->portnum, res->queuenum);
6555 else if (!strcmp(res->type, "txq"))
6556 tx_queue_infos_display(res->portnum, res->queuenum);
6559 cmdline_parse_token_string_t cmd_showqueue_show =
6560 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6561 cmdline_parse_token_string_t cmd_showqueue_type =
6562 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6563 cmdline_parse_token_string_t cmd_showqueue_what =
6564 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6565 cmdline_parse_token_num_t cmd_showqueue_portnum =
6566 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6567 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6568 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6570 cmdline_parse_inst_t cmd_showqueue = {
6571 .f = cmd_showqueue_parsed,
6573 .help_str = "show rxq|txq info <port_id> <queue_id>",
6575 (void *)&cmd_showqueue_show,
6576 (void *)&cmd_showqueue_type,
6577 (void *)&cmd_showqueue_what,
6578 (void *)&cmd_showqueue_portnum,
6579 (void *)&cmd_showqueue_queuenum,
6584 /* *** READ PORT REGISTER *** */
6585 struct cmd_read_reg_result {
6586 cmdline_fixed_string_t read;
6587 cmdline_fixed_string_t reg;
6593 cmd_read_reg_parsed(void *parsed_result,
6594 __attribute__((unused)) struct cmdline *cl,
6595 __attribute__((unused)) void *data)
6597 struct cmd_read_reg_result *res = parsed_result;
6598 port_reg_display(res->port_id, res->reg_off);
6601 cmdline_parse_token_string_t cmd_read_reg_read =
6602 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6603 cmdline_parse_token_string_t cmd_read_reg_reg =
6604 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6605 cmdline_parse_token_num_t cmd_read_reg_port_id =
6606 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6607 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6608 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6610 cmdline_parse_inst_t cmd_read_reg = {
6611 .f = cmd_read_reg_parsed,
6613 .help_str = "read reg <port_id> <reg_off>",
6615 (void *)&cmd_read_reg_read,
6616 (void *)&cmd_read_reg_reg,
6617 (void *)&cmd_read_reg_port_id,
6618 (void *)&cmd_read_reg_reg_off,
6623 /* *** READ PORT REGISTER BIT FIELD *** */
6624 struct cmd_read_reg_bit_field_result {
6625 cmdline_fixed_string_t read;
6626 cmdline_fixed_string_t regfield;
6634 cmd_read_reg_bit_field_parsed(void *parsed_result,
6635 __attribute__((unused)) struct cmdline *cl,
6636 __attribute__((unused)) void *data)
6638 struct cmd_read_reg_bit_field_result *res = parsed_result;
6639 port_reg_bit_field_display(res->port_id, res->reg_off,
6640 res->bit1_pos, res->bit2_pos);
6643 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6644 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6646 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6647 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6648 regfield, "regfield");
6649 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6650 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6652 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6653 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6655 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6656 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6658 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6659 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6662 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6663 .f = cmd_read_reg_bit_field_parsed,
6665 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6666 "Read register bit field between bit_x and bit_y included",
6668 (void *)&cmd_read_reg_bit_field_read,
6669 (void *)&cmd_read_reg_bit_field_regfield,
6670 (void *)&cmd_read_reg_bit_field_port_id,
6671 (void *)&cmd_read_reg_bit_field_reg_off,
6672 (void *)&cmd_read_reg_bit_field_bit1_pos,
6673 (void *)&cmd_read_reg_bit_field_bit2_pos,
6678 /* *** READ PORT REGISTER BIT *** */
6679 struct cmd_read_reg_bit_result {
6680 cmdline_fixed_string_t read;
6681 cmdline_fixed_string_t regbit;
6688 cmd_read_reg_bit_parsed(void *parsed_result,
6689 __attribute__((unused)) struct cmdline *cl,
6690 __attribute__((unused)) void *data)
6692 struct cmd_read_reg_bit_result *res = parsed_result;
6693 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6696 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6697 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6698 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6699 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6701 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6702 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6703 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6704 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6705 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6706 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6708 cmdline_parse_inst_t cmd_read_reg_bit = {
6709 .f = cmd_read_reg_bit_parsed,
6711 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6713 (void *)&cmd_read_reg_bit_read,
6714 (void *)&cmd_read_reg_bit_regbit,
6715 (void *)&cmd_read_reg_bit_port_id,
6716 (void *)&cmd_read_reg_bit_reg_off,
6717 (void *)&cmd_read_reg_bit_bit_pos,
6722 /* *** WRITE PORT REGISTER *** */
6723 struct cmd_write_reg_result {
6724 cmdline_fixed_string_t write;
6725 cmdline_fixed_string_t reg;
6732 cmd_write_reg_parsed(void *parsed_result,
6733 __attribute__((unused)) struct cmdline *cl,
6734 __attribute__((unused)) void *data)
6736 struct cmd_write_reg_result *res = parsed_result;
6737 port_reg_set(res->port_id, res->reg_off, res->value);
6740 cmdline_parse_token_string_t cmd_write_reg_write =
6741 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6742 cmdline_parse_token_string_t cmd_write_reg_reg =
6743 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6744 cmdline_parse_token_num_t cmd_write_reg_port_id =
6745 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6746 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6747 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6748 cmdline_parse_token_num_t cmd_write_reg_value =
6749 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6751 cmdline_parse_inst_t cmd_write_reg = {
6752 .f = cmd_write_reg_parsed,
6754 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6756 (void *)&cmd_write_reg_write,
6757 (void *)&cmd_write_reg_reg,
6758 (void *)&cmd_write_reg_port_id,
6759 (void *)&cmd_write_reg_reg_off,
6760 (void *)&cmd_write_reg_value,
6765 /* *** WRITE PORT REGISTER BIT FIELD *** */
6766 struct cmd_write_reg_bit_field_result {
6767 cmdline_fixed_string_t write;
6768 cmdline_fixed_string_t regfield;
6777 cmd_write_reg_bit_field_parsed(void *parsed_result,
6778 __attribute__((unused)) struct cmdline *cl,
6779 __attribute__((unused)) void *data)
6781 struct cmd_write_reg_bit_field_result *res = parsed_result;
6782 port_reg_bit_field_set(res->port_id, res->reg_off,
6783 res->bit1_pos, res->bit2_pos, res->value);
6786 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6787 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6789 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6790 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6791 regfield, "regfield");
6792 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6793 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6795 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6796 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6798 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6799 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6801 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6802 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6804 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6805 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6808 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6809 .f = cmd_write_reg_bit_field_parsed,
6811 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6813 "Set register bit field between bit_x and bit_y included",
6815 (void *)&cmd_write_reg_bit_field_write,
6816 (void *)&cmd_write_reg_bit_field_regfield,
6817 (void *)&cmd_write_reg_bit_field_port_id,
6818 (void *)&cmd_write_reg_bit_field_reg_off,
6819 (void *)&cmd_write_reg_bit_field_bit1_pos,
6820 (void *)&cmd_write_reg_bit_field_bit2_pos,
6821 (void *)&cmd_write_reg_bit_field_value,
6826 /* *** WRITE PORT REGISTER BIT *** */
6827 struct cmd_write_reg_bit_result {
6828 cmdline_fixed_string_t write;
6829 cmdline_fixed_string_t regbit;
6837 cmd_write_reg_bit_parsed(void *parsed_result,
6838 __attribute__((unused)) struct cmdline *cl,
6839 __attribute__((unused)) void *data)
6841 struct cmd_write_reg_bit_result *res = parsed_result;
6842 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6845 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6846 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6848 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6849 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6851 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6852 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6853 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6854 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6855 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6856 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6857 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6858 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6860 cmdline_parse_inst_t cmd_write_reg_bit = {
6861 .f = cmd_write_reg_bit_parsed,
6863 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6866 (void *)&cmd_write_reg_bit_write,
6867 (void *)&cmd_write_reg_bit_regbit,
6868 (void *)&cmd_write_reg_bit_port_id,
6869 (void *)&cmd_write_reg_bit_reg_off,
6870 (void *)&cmd_write_reg_bit_bit_pos,
6871 (void *)&cmd_write_reg_bit_value,
6876 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6877 struct cmd_read_rxd_txd_result {
6878 cmdline_fixed_string_t read;
6879 cmdline_fixed_string_t rxd_txd;
6886 cmd_read_rxd_txd_parsed(void *parsed_result,
6887 __attribute__((unused)) struct cmdline *cl,
6888 __attribute__((unused)) void *data)
6890 struct cmd_read_rxd_txd_result *res = parsed_result;
6892 if (!strcmp(res->rxd_txd, "rxd"))
6893 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6894 else if (!strcmp(res->rxd_txd, "txd"))
6895 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6898 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6899 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6900 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6901 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6903 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6904 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6905 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6906 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6907 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6908 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6910 cmdline_parse_inst_t cmd_read_rxd_txd = {
6911 .f = cmd_read_rxd_txd_parsed,
6913 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6915 (void *)&cmd_read_rxd_txd_read,
6916 (void *)&cmd_read_rxd_txd_rxd_txd,
6917 (void *)&cmd_read_rxd_txd_port_id,
6918 (void *)&cmd_read_rxd_txd_queue_id,
6919 (void *)&cmd_read_rxd_txd_desc_id,
6925 struct cmd_quit_result {
6926 cmdline_fixed_string_t quit;
6929 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6931 __attribute__((unused)) void *data)
6937 cmdline_parse_token_string_t cmd_quit_quit =
6938 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6940 cmdline_parse_inst_t cmd_quit = {
6941 .f = cmd_quit_parsed,
6943 .help_str = "quit: Exit application",
6945 (void *)&cmd_quit_quit,
6950 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6951 struct cmd_mac_addr_result {
6952 cmdline_fixed_string_t mac_addr_cmd;
6953 cmdline_fixed_string_t what;
6955 struct ether_addr address;
6958 static void cmd_mac_addr_parsed(void *parsed_result,
6959 __attribute__((unused)) struct cmdline *cl,
6960 __attribute__((unused)) void *data)
6962 struct cmd_mac_addr_result *res = parsed_result;
6965 if (strcmp(res->what, "add") == 0)
6966 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6967 else if (strcmp(res->what, "set") == 0)
6968 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6971 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6973 /* check the return value and print it if is < 0 */
6975 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6979 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6980 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6982 cmdline_parse_token_string_t cmd_mac_addr_what =
6983 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6985 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6986 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6987 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6988 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6990 cmdline_parse_inst_t cmd_mac_addr = {
6991 .f = cmd_mac_addr_parsed,
6993 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6994 "Add/Remove/Set MAC address on port_id",
6996 (void *)&cmd_mac_addr_cmd,
6997 (void *)&cmd_mac_addr_what,
6998 (void *)&cmd_mac_addr_portnum,
6999 (void *)&cmd_mac_addr_addr,
7005 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7006 struct cmd_set_qmap_result {
7007 cmdline_fixed_string_t set;
7008 cmdline_fixed_string_t qmap;
7009 cmdline_fixed_string_t what;
7016 cmd_set_qmap_parsed(void *parsed_result,
7017 __attribute__((unused)) struct cmdline *cl,
7018 __attribute__((unused)) void *data)
7020 struct cmd_set_qmap_result *res = parsed_result;
7021 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7023 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7026 cmdline_parse_token_string_t cmd_setqmap_set =
7027 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7029 cmdline_parse_token_string_t cmd_setqmap_qmap =
7030 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7032 cmdline_parse_token_string_t cmd_setqmap_what =
7033 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7035 cmdline_parse_token_num_t cmd_setqmap_portid =
7036 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7038 cmdline_parse_token_num_t cmd_setqmap_queueid =
7039 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7041 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7042 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7045 cmdline_parse_inst_t cmd_set_qmap = {
7046 .f = cmd_set_qmap_parsed,
7048 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7049 "Set statistics mapping value on tx|rx queue_id of port_id",
7051 (void *)&cmd_setqmap_set,
7052 (void *)&cmd_setqmap_qmap,
7053 (void *)&cmd_setqmap_what,
7054 (void *)&cmd_setqmap_portid,
7055 (void *)&cmd_setqmap_queueid,
7056 (void *)&cmd_setqmap_mapvalue,
7061 /* *** CONFIGURE UNICAST HASH TABLE *** */
7062 struct cmd_set_uc_hash_table {
7063 cmdline_fixed_string_t set;
7064 cmdline_fixed_string_t port;
7066 cmdline_fixed_string_t what;
7067 struct ether_addr address;
7068 cmdline_fixed_string_t mode;
7072 cmd_set_uc_hash_parsed(void *parsed_result,
7073 __attribute__((unused)) struct cmdline *cl,
7074 __attribute__((unused)) void *data)
7077 struct cmd_set_uc_hash_table *res = parsed_result;
7079 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7081 if (strcmp(res->what, "uta") == 0)
7082 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7083 &res->address,(uint8_t)is_on);
7085 printf("bad unicast hash table parameter, return code = %d \n", ret);
7089 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7090 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7092 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7093 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7095 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7096 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7098 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7099 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7101 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7102 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7104 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7105 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7108 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7109 .f = cmd_set_uc_hash_parsed,
7111 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7113 (void *)&cmd_set_uc_hash_set,
7114 (void *)&cmd_set_uc_hash_port,
7115 (void *)&cmd_set_uc_hash_portid,
7116 (void *)&cmd_set_uc_hash_what,
7117 (void *)&cmd_set_uc_hash_mac,
7118 (void *)&cmd_set_uc_hash_mode,
7123 struct cmd_set_uc_all_hash_table {
7124 cmdline_fixed_string_t set;
7125 cmdline_fixed_string_t port;
7127 cmdline_fixed_string_t what;
7128 cmdline_fixed_string_t value;
7129 cmdline_fixed_string_t mode;
7133 cmd_set_uc_all_hash_parsed(void *parsed_result,
7134 __attribute__((unused)) struct cmdline *cl,
7135 __attribute__((unused)) void *data)
7138 struct cmd_set_uc_all_hash_table *res = parsed_result;
7140 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7142 if ((strcmp(res->what, "uta") == 0) &&
7143 (strcmp(res->value, "all") == 0))
7144 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7146 printf("bad unicast hash table parameter,"
7147 "return code = %d \n", ret);
7150 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7151 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7153 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7154 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7156 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7157 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7159 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7160 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7162 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7163 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7165 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7166 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7169 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7170 .f = cmd_set_uc_all_hash_parsed,
7172 .help_str = "set port <port_id> uta all on|off",
7174 (void *)&cmd_set_uc_all_hash_set,
7175 (void *)&cmd_set_uc_all_hash_port,
7176 (void *)&cmd_set_uc_all_hash_portid,
7177 (void *)&cmd_set_uc_all_hash_what,
7178 (void *)&cmd_set_uc_all_hash_value,
7179 (void *)&cmd_set_uc_all_hash_mode,
7184 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7185 struct cmd_set_vf_macvlan_filter {
7186 cmdline_fixed_string_t set;
7187 cmdline_fixed_string_t port;
7189 cmdline_fixed_string_t vf;
7191 struct ether_addr address;
7192 cmdline_fixed_string_t filter_type;
7193 cmdline_fixed_string_t mode;
7197 cmd_set_vf_macvlan_parsed(void *parsed_result,
7198 __attribute__((unused)) struct cmdline *cl,
7199 __attribute__((unused)) void *data)
7202 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7203 struct rte_eth_mac_filter filter;
7205 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7207 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7209 /* set VF MAC filter */
7213 filter.dst_id = res->vf_id;
7215 if (!strcmp(res->filter_type, "exact-mac"))
7216 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7217 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7218 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7219 else if (!strcmp(res->filter_type, "hashmac"))
7220 filter.filter_type = RTE_MAC_HASH_MATCH;
7221 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7222 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7224 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7227 ret = rte_eth_dev_filter_ctrl(res->port_id,
7228 RTE_ETH_FILTER_MACVLAN,
7232 ret = rte_eth_dev_filter_ctrl(res->port_id,
7233 RTE_ETH_FILTER_MACVLAN,
7234 RTE_ETH_FILTER_DELETE,
7238 printf("bad set MAC hash parameter, return code = %d\n", ret);
7242 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7243 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7245 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7246 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7248 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7249 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7251 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7252 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7254 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7255 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7257 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7258 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7260 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7261 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7262 filter_type, "exact-mac#exact-mac-vlan"
7263 "#hashmac#hashmac-vlan");
7264 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7265 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7268 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7269 .f = cmd_set_vf_macvlan_parsed,
7271 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7272 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7273 "Exact match rule: exact match of MAC or MAC and VLAN; "
7274 "hash match rule: hash match of MAC and exact match of VLAN",
7276 (void *)&cmd_set_vf_macvlan_set,
7277 (void *)&cmd_set_vf_macvlan_port,
7278 (void *)&cmd_set_vf_macvlan_portid,
7279 (void *)&cmd_set_vf_macvlan_vf,
7280 (void *)&cmd_set_vf_macvlan_vf_id,
7281 (void *)&cmd_set_vf_macvlan_mac,
7282 (void *)&cmd_set_vf_macvlan_filter_type,
7283 (void *)&cmd_set_vf_macvlan_mode,
7288 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7289 struct cmd_set_vf_traffic {
7290 cmdline_fixed_string_t set;
7291 cmdline_fixed_string_t port;
7293 cmdline_fixed_string_t vf;
7295 cmdline_fixed_string_t what;
7296 cmdline_fixed_string_t mode;
7300 cmd_set_vf_traffic_parsed(void *parsed_result,
7301 __attribute__((unused)) struct cmdline *cl,
7302 __attribute__((unused)) void *data)
7304 struct cmd_set_vf_traffic *res = parsed_result;
7305 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7306 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7308 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7311 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7312 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7314 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7315 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7317 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7318 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7320 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7321 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7323 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7324 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7326 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7327 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7329 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7330 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7333 cmdline_parse_inst_t cmd_set_vf_traffic = {
7334 .f = cmd_set_vf_traffic_parsed,
7336 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7338 (void *)&cmd_setvf_traffic_set,
7339 (void *)&cmd_setvf_traffic_port,
7340 (void *)&cmd_setvf_traffic_portid,
7341 (void *)&cmd_setvf_traffic_vf,
7342 (void *)&cmd_setvf_traffic_vfid,
7343 (void *)&cmd_setvf_traffic_what,
7344 (void *)&cmd_setvf_traffic_mode,
7349 /* *** CONFIGURE VF RECEIVE MODE *** */
7350 struct cmd_set_vf_rxmode {
7351 cmdline_fixed_string_t set;
7352 cmdline_fixed_string_t port;
7354 cmdline_fixed_string_t vf;
7356 cmdline_fixed_string_t what;
7357 cmdline_fixed_string_t mode;
7358 cmdline_fixed_string_t on;
7362 cmd_set_vf_rxmode_parsed(void *parsed_result,
7363 __attribute__((unused)) struct cmdline *cl,
7364 __attribute__((unused)) void *data)
7367 uint16_t rx_mode = 0;
7368 struct cmd_set_vf_rxmode *res = parsed_result;
7370 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7371 if (!strcmp(res->what,"rxmode")) {
7372 if (!strcmp(res->mode, "AUPE"))
7373 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7374 else if (!strcmp(res->mode, "ROPE"))
7375 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7376 else if (!strcmp(res->mode, "BAM"))
7377 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7378 else if (!strncmp(res->mode, "MPE",3))
7379 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7382 #ifdef RTE_LIBRTE_IXGBE_PMD
7383 if (ret == -ENOTSUP)
7384 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7385 rx_mode, (uint8_t)is_on);
7387 #ifdef RTE_LIBRTE_BNXT_PMD
7388 if (ret == -ENOTSUP)
7389 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7390 rx_mode, (uint8_t)is_on);
7393 printf("bad VF receive mode parameter, return code = %d \n",
7397 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7398 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7400 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7401 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7403 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7404 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7406 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7407 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7409 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7410 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7412 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7413 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7415 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7416 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7417 mode, "AUPE#ROPE#BAM#MPE");
7418 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7419 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7422 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7423 .f = cmd_set_vf_rxmode_parsed,
7425 .help_str = "set port <port_id> vf <vf_id> rxmode "
7426 "AUPE|ROPE|BAM|MPE on|off",
7428 (void *)&cmd_set_vf_rxmode_set,
7429 (void *)&cmd_set_vf_rxmode_port,
7430 (void *)&cmd_set_vf_rxmode_portid,
7431 (void *)&cmd_set_vf_rxmode_vf,
7432 (void *)&cmd_set_vf_rxmode_vfid,
7433 (void *)&cmd_set_vf_rxmode_what,
7434 (void *)&cmd_set_vf_rxmode_mode,
7435 (void *)&cmd_set_vf_rxmode_on,
7440 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7441 struct cmd_vf_mac_addr_result {
7442 cmdline_fixed_string_t mac_addr_cmd;
7443 cmdline_fixed_string_t what;
7444 cmdline_fixed_string_t port;
7446 cmdline_fixed_string_t vf;
7448 struct ether_addr address;
7451 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7452 __attribute__((unused)) struct cmdline *cl,
7453 __attribute__((unused)) void *data)
7455 struct cmd_vf_mac_addr_result *res = parsed_result;
7458 if (strcmp(res->what, "add") != 0)
7461 #ifdef RTE_LIBRTE_I40E_PMD
7462 if (ret == -ENOTSUP)
7463 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7466 #ifdef RTE_LIBRTE_BNXT_PMD
7467 if (ret == -ENOTSUP)
7468 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7473 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7477 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7478 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7479 mac_addr_cmd,"mac_addr");
7480 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7481 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7483 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7484 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7486 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7487 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7489 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7490 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7492 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7493 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7495 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7496 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7499 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7500 .f = cmd_vf_mac_addr_parsed,
7502 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7503 "Add MAC address filtering for a VF on port_id",
7505 (void *)&cmd_vf_mac_addr_cmd,
7506 (void *)&cmd_vf_mac_addr_what,
7507 (void *)&cmd_vf_mac_addr_port,
7508 (void *)&cmd_vf_mac_addr_portnum,
7509 (void *)&cmd_vf_mac_addr_vf,
7510 (void *)&cmd_vf_mac_addr_vfnum,
7511 (void *)&cmd_vf_mac_addr_addr,
7516 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7517 struct cmd_vf_rx_vlan_filter {
7518 cmdline_fixed_string_t rx_vlan;
7519 cmdline_fixed_string_t what;
7521 cmdline_fixed_string_t port;
7523 cmdline_fixed_string_t vf;
7528 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7529 __attribute__((unused)) struct cmdline *cl,
7530 __attribute__((unused)) void *data)
7532 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7535 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7537 #ifdef RTE_LIBRTE_IXGBE_PMD
7538 if (ret == -ENOTSUP)
7539 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7540 res->vlan_id, res->vf_mask, is_add);
7542 #ifdef RTE_LIBRTE_I40E_PMD
7543 if (ret == -ENOTSUP)
7544 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7545 res->vlan_id, res->vf_mask, is_add);
7547 #ifdef RTE_LIBRTE_BNXT_PMD
7548 if (ret == -ENOTSUP)
7549 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7550 res->vlan_id, res->vf_mask, is_add);
7557 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7558 res->vlan_id, res->vf_mask);
7561 printf("invalid port_id %d\n", res->port_id);
7564 printf("function not implemented or supported\n");
7567 printf("programming error: (%s)\n", strerror(-ret));
7571 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7572 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7573 rx_vlan, "rx_vlan");
7574 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7575 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7577 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7578 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7580 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7581 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7583 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7584 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7586 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7587 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7589 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7590 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7593 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7594 .f = cmd_vf_rx_vlan_filter_parsed,
7596 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7597 "(vf_mask = hexadecimal VF mask)",
7599 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7600 (void *)&cmd_vf_rx_vlan_filter_what,
7601 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7602 (void *)&cmd_vf_rx_vlan_filter_port,
7603 (void *)&cmd_vf_rx_vlan_filter_portid,
7604 (void *)&cmd_vf_rx_vlan_filter_vf,
7605 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7610 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7611 struct cmd_queue_rate_limit_result {
7612 cmdline_fixed_string_t set;
7613 cmdline_fixed_string_t port;
7615 cmdline_fixed_string_t queue;
7617 cmdline_fixed_string_t rate;
7621 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7622 __attribute__((unused)) struct cmdline *cl,
7623 __attribute__((unused)) void *data)
7625 struct cmd_queue_rate_limit_result *res = parsed_result;
7628 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7629 && (strcmp(res->queue, "queue") == 0)
7630 && (strcmp(res->rate, "rate") == 0))
7631 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7634 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7638 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7639 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7641 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7642 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7644 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7645 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7647 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7648 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7650 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7651 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7653 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7654 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7656 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7657 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7660 cmdline_parse_inst_t cmd_queue_rate_limit = {
7661 .f = cmd_queue_rate_limit_parsed,
7663 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7664 "Set rate limit for a queue on port_id",
7666 (void *)&cmd_queue_rate_limit_set,
7667 (void *)&cmd_queue_rate_limit_port,
7668 (void *)&cmd_queue_rate_limit_portnum,
7669 (void *)&cmd_queue_rate_limit_queue,
7670 (void *)&cmd_queue_rate_limit_queuenum,
7671 (void *)&cmd_queue_rate_limit_rate,
7672 (void *)&cmd_queue_rate_limit_ratenum,
7677 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7678 struct cmd_vf_rate_limit_result {
7679 cmdline_fixed_string_t set;
7680 cmdline_fixed_string_t port;
7682 cmdline_fixed_string_t vf;
7684 cmdline_fixed_string_t rate;
7686 cmdline_fixed_string_t q_msk;
7690 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7691 __attribute__((unused)) struct cmdline *cl,
7692 __attribute__((unused)) void *data)
7694 struct cmd_vf_rate_limit_result *res = parsed_result;
7697 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7698 && (strcmp(res->vf, "vf") == 0)
7699 && (strcmp(res->rate, "rate") == 0)
7700 && (strcmp(res->q_msk, "queue_mask") == 0))
7701 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7702 res->rate_num, res->q_msk_val);
7704 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7708 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7709 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7711 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7712 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7714 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7715 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7717 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7718 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7720 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7721 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7723 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7724 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7726 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7727 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7729 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7730 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7731 q_msk, "queue_mask");
7732 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7733 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7736 cmdline_parse_inst_t cmd_vf_rate_limit = {
7737 .f = cmd_vf_rate_limit_parsed,
7739 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7740 "queue_mask <queue_mask_value>: "
7741 "Set rate limit for queues of VF on port_id",
7743 (void *)&cmd_vf_rate_limit_set,
7744 (void *)&cmd_vf_rate_limit_port,
7745 (void *)&cmd_vf_rate_limit_portnum,
7746 (void *)&cmd_vf_rate_limit_vf,
7747 (void *)&cmd_vf_rate_limit_vfnum,
7748 (void *)&cmd_vf_rate_limit_rate,
7749 (void *)&cmd_vf_rate_limit_ratenum,
7750 (void *)&cmd_vf_rate_limit_q_msk,
7751 (void *)&cmd_vf_rate_limit_q_msk_val,
7756 /* *** ADD TUNNEL FILTER OF A PORT *** */
7757 struct cmd_tunnel_filter_result {
7758 cmdline_fixed_string_t cmd;
7759 cmdline_fixed_string_t what;
7761 struct ether_addr outer_mac;
7762 struct ether_addr inner_mac;
7763 cmdline_ipaddr_t ip_value;
7764 uint16_t inner_vlan;
7765 cmdline_fixed_string_t tunnel_type;
7766 cmdline_fixed_string_t filter_type;
7772 cmd_tunnel_filter_parsed(void *parsed_result,
7773 __attribute__((unused)) struct cmdline *cl,
7774 __attribute__((unused)) void *data)
7776 struct cmd_tunnel_filter_result *res = parsed_result;
7777 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7780 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7782 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7783 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7784 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7786 if (res->ip_value.family == AF_INET) {
7787 tunnel_filter_conf.ip_addr.ipv4_addr =
7788 res->ip_value.addr.ipv4.s_addr;
7789 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7791 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7792 &(res->ip_value.addr.ipv6),
7793 sizeof(struct in6_addr));
7794 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7797 if (!strcmp(res->filter_type, "imac-ivlan"))
7798 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7799 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7800 tunnel_filter_conf.filter_type =
7801 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7802 else if (!strcmp(res->filter_type, "imac-tenid"))
7803 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7804 else if (!strcmp(res->filter_type, "imac"))
7805 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7806 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7807 tunnel_filter_conf.filter_type =
7808 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7809 else if (!strcmp(res->filter_type, "oip"))
7810 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7811 else if (!strcmp(res->filter_type, "iip"))
7812 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7814 printf("The filter type is not supported");
7818 if (!strcmp(res->tunnel_type, "vxlan"))
7819 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7820 else if (!strcmp(res->tunnel_type, "nvgre"))
7821 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7822 else if (!strcmp(res->tunnel_type, "ipingre"))
7823 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7825 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7829 tunnel_filter_conf.tenant_id = res->tenant_id;
7830 tunnel_filter_conf.queue_id = res->queue_num;
7831 if (!strcmp(res->what, "add"))
7832 ret = rte_eth_dev_filter_ctrl(res->port_id,
7833 RTE_ETH_FILTER_TUNNEL,
7835 &tunnel_filter_conf);
7837 ret = rte_eth_dev_filter_ctrl(res->port_id,
7838 RTE_ETH_FILTER_TUNNEL,
7839 RTE_ETH_FILTER_DELETE,
7840 &tunnel_filter_conf);
7842 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7846 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7847 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7848 cmd, "tunnel_filter");
7849 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7850 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7852 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7853 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7855 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7856 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7858 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7859 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7861 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7862 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7863 inner_vlan, UINT16);
7864 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7865 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7867 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7868 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7869 tunnel_type, "vxlan#nvgre#ipingre");
7871 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7872 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7873 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7874 "imac#omac-imac-tenid");
7875 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7876 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7878 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7879 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7882 cmdline_parse_inst_t cmd_tunnel_filter = {
7883 .f = cmd_tunnel_filter_parsed,
7885 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7886 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7887 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7888 "<queue_id>: Add/Rm tunnel filter of a port",
7890 (void *)&cmd_tunnel_filter_cmd,
7891 (void *)&cmd_tunnel_filter_what,
7892 (void *)&cmd_tunnel_filter_port_id,
7893 (void *)&cmd_tunnel_filter_outer_mac,
7894 (void *)&cmd_tunnel_filter_inner_mac,
7895 (void *)&cmd_tunnel_filter_ip_value,
7896 (void *)&cmd_tunnel_filter_innner_vlan,
7897 (void *)&cmd_tunnel_filter_tunnel_type,
7898 (void *)&cmd_tunnel_filter_filter_type,
7899 (void *)&cmd_tunnel_filter_tenant_id,
7900 (void *)&cmd_tunnel_filter_queue_num,
7905 /* *** CONFIGURE TUNNEL UDP PORT *** */
7906 struct cmd_tunnel_udp_config {
7907 cmdline_fixed_string_t cmd;
7908 cmdline_fixed_string_t what;
7914 cmd_tunnel_udp_config_parsed(void *parsed_result,
7915 __attribute__((unused)) struct cmdline *cl,
7916 __attribute__((unused)) void *data)
7918 struct cmd_tunnel_udp_config *res = parsed_result;
7919 struct rte_eth_udp_tunnel tunnel_udp;
7922 tunnel_udp.udp_port = res->udp_port;
7924 if (!strcmp(res->cmd, "rx_vxlan_port"))
7925 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7927 if (!strcmp(res->what, "add"))
7928 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7931 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7935 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7938 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7939 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7940 cmd, "rx_vxlan_port");
7941 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7942 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7944 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7945 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7947 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7948 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7951 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7952 .f = cmd_tunnel_udp_config_parsed,
7954 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7955 "Add/Remove a tunneling UDP port filter",
7957 (void *)&cmd_tunnel_udp_config_cmd,
7958 (void *)&cmd_tunnel_udp_config_what,
7959 (void *)&cmd_tunnel_udp_config_udp_port,
7960 (void *)&cmd_tunnel_udp_config_port_id,
7965 /* *** GLOBAL CONFIG *** */
7966 struct cmd_global_config_result {
7967 cmdline_fixed_string_t cmd;
7969 cmdline_fixed_string_t cfg_type;
7974 cmd_global_config_parsed(void *parsed_result,
7975 __attribute__((unused)) struct cmdline *cl,
7976 __attribute__((unused)) void *data)
7978 struct cmd_global_config_result *res = parsed_result;
7979 struct rte_eth_global_cfg conf;
7982 memset(&conf, 0, sizeof(conf));
7983 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7984 conf.cfg.gre_key_len = res->len;
7985 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7986 RTE_ETH_FILTER_SET, &conf);
7988 printf("Global config error\n");
7991 cmdline_parse_token_string_t cmd_global_config_cmd =
7992 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7994 cmdline_parse_token_num_t cmd_global_config_port_id =
7995 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7996 cmdline_parse_token_string_t cmd_global_config_type =
7997 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7998 cfg_type, "gre-key-len");
7999 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8000 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8003 cmdline_parse_inst_t cmd_global_config = {
8004 .f = cmd_global_config_parsed,
8005 .data = (void *)NULL,
8006 .help_str = "global_config <port_id> gre-key-len <key_len>",
8008 (void *)&cmd_global_config_cmd,
8009 (void *)&cmd_global_config_port_id,
8010 (void *)&cmd_global_config_type,
8011 (void *)&cmd_global_config_gre_key_len,
8016 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8017 struct cmd_set_mirror_mask_result {
8018 cmdline_fixed_string_t set;
8019 cmdline_fixed_string_t port;
8021 cmdline_fixed_string_t mirror;
8023 cmdline_fixed_string_t what;
8024 cmdline_fixed_string_t value;
8025 cmdline_fixed_string_t dstpool;
8027 cmdline_fixed_string_t on;
8030 cmdline_parse_token_string_t cmd_mirror_mask_set =
8031 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8033 cmdline_parse_token_string_t cmd_mirror_mask_port =
8034 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8036 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8037 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8039 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8040 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8041 mirror, "mirror-rule");
8042 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8043 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8045 cmdline_parse_token_string_t cmd_mirror_mask_what =
8046 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8047 what, "pool-mirror-up#pool-mirror-down"
8049 cmdline_parse_token_string_t cmd_mirror_mask_value =
8050 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8052 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8053 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8054 dstpool, "dst-pool");
8055 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8056 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8058 cmdline_parse_token_string_t cmd_mirror_mask_on =
8059 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8063 cmd_set_mirror_mask_parsed(void *parsed_result,
8064 __attribute__((unused)) struct cmdline *cl,
8065 __attribute__((unused)) void *data)
8068 struct cmd_set_mirror_mask_result *res = parsed_result;
8069 struct rte_eth_mirror_conf mr_conf;
8071 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8073 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8075 mr_conf.dst_pool = res->dstpool_id;
8077 if (!strcmp(res->what, "pool-mirror-up")) {
8078 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8079 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8080 } else if (!strcmp(res->what, "pool-mirror-down")) {
8081 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8082 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8083 } else if (!strcmp(res->what, "vlan-mirror")) {
8084 mr_conf.rule_type = ETH_MIRROR_VLAN;
8085 nb_item = parse_item_list(res->value, "vlan",
8086 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8090 for (i = 0; i < nb_item; i++) {
8091 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8092 printf("Invalid vlan_id: must be < 4096\n");
8096 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8097 mr_conf.vlan.vlan_mask |= 1ULL << i;
8101 if (!strcmp(res->on, "on"))
8102 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8105 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8108 printf("mirror rule add error: (%s)\n", strerror(-ret));
8111 cmdline_parse_inst_t cmd_set_mirror_mask = {
8112 .f = cmd_set_mirror_mask_parsed,
8114 .help_str = "set port <port_id> mirror-rule <rule_id> "
8115 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8116 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8118 (void *)&cmd_mirror_mask_set,
8119 (void *)&cmd_mirror_mask_port,
8120 (void *)&cmd_mirror_mask_portid,
8121 (void *)&cmd_mirror_mask_mirror,
8122 (void *)&cmd_mirror_mask_ruleid,
8123 (void *)&cmd_mirror_mask_what,
8124 (void *)&cmd_mirror_mask_value,
8125 (void *)&cmd_mirror_mask_dstpool,
8126 (void *)&cmd_mirror_mask_poolid,
8127 (void *)&cmd_mirror_mask_on,
8132 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8133 struct cmd_set_mirror_link_result {
8134 cmdline_fixed_string_t set;
8135 cmdline_fixed_string_t port;
8137 cmdline_fixed_string_t mirror;
8139 cmdline_fixed_string_t what;
8140 cmdline_fixed_string_t dstpool;
8142 cmdline_fixed_string_t on;
8145 cmdline_parse_token_string_t cmd_mirror_link_set =
8146 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8148 cmdline_parse_token_string_t cmd_mirror_link_port =
8149 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8151 cmdline_parse_token_num_t cmd_mirror_link_portid =
8152 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8154 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8155 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8156 mirror, "mirror-rule");
8157 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8158 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8160 cmdline_parse_token_string_t cmd_mirror_link_what =
8161 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8162 what, "uplink-mirror#downlink-mirror");
8163 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8164 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8165 dstpool, "dst-pool");
8166 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8167 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8169 cmdline_parse_token_string_t cmd_mirror_link_on =
8170 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8174 cmd_set_mirror_link_parsed(void *parsed_result,
8175 __attribute__((unused)) struct cmdline *cl,
8176 __attribute__((unused)) void *data)
8179 struct cmd_set_mirror_link_result *res = parsed_result;
8180 struct rte_eth_mirror_conf mr_conf;
8182 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8183 if (!strcmp(res->what, "uplink-mirror"))
8184 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8186 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8188 mr_conf.dst_pool = res->dstpool_id;
8190 if (!strcmp(res->on, "on"))
8191 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8194 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8197 /* check the return value and print it if is < 0 */
8199 printf("mirror rule add error: (%s)\n", strerror(-ret));
8203 cmdline_parse_inst_t cmd_set_mirror_link = {
8204 .f = cmd_set_mirror_link_parsed,
8206 .help_str = "set port <port_id> mirror-rule <rule_id> "
8207 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8209 (void *)&cmd_mirror_link_set,
8210 (void *)&cmd_mirror_link_port,
8211 (void *)&cmd_mirror_link_portid,
8212 (void *)&cmd_mirror_link_mirror,
8213 (void *)&cmd_mirror_link_ruleid,
8214 (void *)&cmd_mirror_link_what,
8215 (void *)&cmd_mirror_link_dstpool,
8216 (void *)&cmd_mirror_link_poolid,
8217 (void *)&cmd_mirror_link_on,
8222 /* *** RESET VM MIRROR RULE *** */
8223 struct cmd_rm_mirror_rule_result {
8224 cmdline_fixed_string_t reset;
8225 cmdline_fixed_string_t port;
8227 cmdline_fixed_string_t mirror;
8231 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8232 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8234 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8235 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8237 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8238 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8240 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8241 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8242 mirror, "mirror-rule");
8243 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8244 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8248 cmd_reset_mirror_rule_parsed(void *parsed_result,
8249 __attribute__((unused)) struct cmdline *cl,
8250 __attribute__((unused)) void *data)
8253 struct cmd_set_mirror_link_result *res = parsed_result;
8255 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8257 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8260 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8261 .f = cmd_reset_mirror_rule_parsed,
8263 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8265 (void *)&cmd_rm_mirror_rule_reset,
8266 (void *)&cmd_rm_mirror_rule_port,
8267 (void *)&cmd_rm_mirror_rule_portid,
8268 (void *)&cmd_rm_mirror_rule_mirror,
8269 (void *)&cmd_rm_mirror_rule_ruleid,
8274 /* ******************************************************************************** */
8276 struct cmd_dump_result {
8277 cmdline_fixed_string_t dump;
8281 dump_struct_sizes(void)
8283 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8284 DUMP_SIZE(struct rte_mbuf);
8285 DUMP_SIZE(struct rte_mempool);
8286 DUMP_SIZE(struct rte_ring);
8290 static void cmd_dump_parsed(void *parsed_result,
8291 __attribute__((unused)) struct cmdline *cl,
8292 __attribute__((unused)) void *data)
8294 struct cmd_dump_result *res = parsed_result;
8296 if (!strcmp(res->dump, "dump_physmem"))
8297 rte_dump_physmem_layout(stdout);
8298 else if (!strcmp(res->dump, "dump_memzone"))
8299 rte_memzone_dump(stdout);
8300 else if (!strcmp(res->dump, "dump_struct_sizes"))
8301 dump_struct_sizes();
8302 else if (!strcmp(res->dump, "dump_ring"))
8303 rte_ring_list_dump(stdout);
8304 else if (!strcmp(res->dump, "dump_mempool"))
8305 rte_mempool_list_dump(stdout);
8306 else if (!strcmp(res->dump, "dump_devargs"))
8307 rte_eal_devargs_dump(stdout);
8308 else if (!strcmp(res->dump, "dump_log_types"))
8309 rte_log_dump(stdout);
8312 cmdline_parse_token_string_t cmd_dump_dump =
8313 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8316 "dump_struct_sizes#"
8322 cmdline_parse_inst_t cmd_dump = {
8323 .f = cmd_dump_parsed, /* function to call */
8324 .data = NULL, /* 2nd arg of func */
8325 .help_str = "Dump status",
8326 .tokens = { /* token list, NULL terminated */
8327 (void *)&cmd_dump_dump,
8332 /* ******************************************************************************** */
8334 struct cmd_dump_one_result {
8335 cmdline_fixed_string_t dump;
8336 cmdline_fixed_string_t name;
8339 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8340 __attribute__((unused)) void *data)
8342 struct cmd_dump_one_result *res = parsed_result;
8344 if (!strcmp(res->dump, "dump_ring")) {
8346 r = rte_ring_lookup(res->name);
8348 cmdline_printf(cl, "Cannot find ring\n");
8351 rte_ring_dump(stdout, r);
8352 } else if (!strcmp(res->dump, "dump_mempool")) {
8353 struct rte_mempool *mp;
8354 mp = rte_mempool_lookup(res->name);
8356 cmdline_printf(cl, "Cannot find mempool\n");
8359 rte_mempool_dump(stdout, mp);
8363 cmdline_parse_token_string_t cmd_dump_one_dump =
8364 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8365 "dump_ring#dump_mempool");
8367 cmdline_parse_token_string_t cmd_dump_one_name =
8368 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8370 cmdline_parse_inst_t cmd_dump_one = {
8371 .f = cmd_dump_one_parsed, /* function to call */
8372 .data = NULL, /* 2nd arg of func */
8373 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8374 .tokens = { /* token list, NULL terminated */
8375 (void *)&cmd_dump_one_dump,
8376 (void *)&cmd_dump_one_name,
8381 /* *** Add/Del syn filter *** */
8382 struct cmd_syn_filter_result {
8383 cmdline_fixed_string_t filter;
8385 cmdline_fixed_string_t ops;
8386 cmdline_fixed_string_t priority;
8387 cmdline_fixed_string_t high;
8388 cmdline_fixed_string_t queue;
8393 cmd_syn_filter_parsed(void *parsed_result,
8394 __attribute__((unused)) struct cmdline *cl,
8395 __attribute__((unused)) void *data)
8397 struct cmd_syn_filter_result *res = parsed_result;
8398 struct rte_eth_syn_filter syn_filter;
8401 ret = rte_eth_dev_filter_supported(res->port_id,
8402 RTE_ETH_FILTER_SYN);
8404 printf("syn filter is not supported on port %u.\n",
8409 memset(&syn_filter, 0, sizeof(syn_filter));
8411 if (!strcmp(res->ops, "add")) {
8412 if (!strcmp(res->high, "high"))
8413 syn_filter.hig_pri = 1;
8415 syn_filter.hig_pri = 0;
8417 syn_filter.queue = res->queue_id;
8418 ret = rte_eth_dev_filter_ctrl(res->port_id,
8423 ret = rte_eth_dev_filter_ctrl(res->port_id,
8425 RTE_ETH_FILTER_DELETE,
8429 printf("syn filter programming error: (%s)\n",
8433 cmdline_parse_token_string_t cmd_syn_filter_filter =
8434 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8435 filter, "syn_filter");
8436 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8437 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8439 cmdline_parse_token_string_t cmd_syn_filter_ops =
8440 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8442 cmdline_parse_token_string_t cmd_syn_filter_priority =
8443 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8444 priority, "priority");
8445 cmdline_parse_token_string_t cmd_syn_filter_high =
8446 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8448 cmdline_parse_token_string_t cmd_syn_filter_queue =
8449 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8451 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8452 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8455 cmdline_parse_inst_t cmd_syn_filter = {
8456 .f = cmd_syn_filter_parsed,
8458 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8459 "<queue_id>: Add/Delete syn filter",
8461 (void *)&cmd_syn_filter_filter,
8462 (void *)&cmd_syn_filter_port_id,
8463 (void *)&cmd_syn_filter_ops,
8464 (void *)&cmd_syn_filter_priority,
8465 (void *)&cmd_syn_filter_high,
8466 (void *)&cmd_syn_filter_queue,
8467 (void *)&cmd_syn_filter_queue_id,
8472 /* *** ADD/REMOVE A 2tuple FILTER *** */
8473 struct cmd_2tuple_filter_result {
8474 cmdline_fixed_string_t filter;
8476 cmdline_fixed_string_t ops;
8477 cmdline_fixed_string_t dst_port;
8478 uint16_t dst_port_value;
8479 cmdline_fixed_string_t protocol;
8480 uint8_t protocol_value;
8481 cmdline_fixed_string_t mask;
8483 cmdline_fixed_string_t tcp_flags;
8484 uint8_t tcp_flags_value;
8485 cmdline_fixed_string_t priority;
8486 uint8_t priority_value;
8487 cmdline_fixed_string_t queue;
8492 cmd_2tuple_filter_parsed(void *parsed_result,
8493 __attribute__((unused)) struct cmdline *cl,
8494 __attribute__((unused)) void *data)
8496 struct rte_eth_ntuple_filter filter;
8497 struct cmd_2tuple_filter_result *res = parsed_result;
8500 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8502 printf("ntuple filter is not supported on port %u.\n",
8507 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8509 filter.flags = RTE_2TUPLE_FLAGS;
8510 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8511 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8512 filter.proto = res->protocol_value;
8513 filter.priority = res->priority_value;
8514 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8515 printf("nonzero tcp_flags is only meaningful"
8516 " when protocol is TCP.\n");
8519 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8520 printf("invalid TCP flags.\n");
8524 if (res->tcp_flags_value != 0) {
8525 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8526 filter.tcp_flags = res->tcp_flags_value;
8529 /* need convert to big endian. */
8530 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8531 filter.queue = res->queue_id;
8533 if (!strcmp(res->ops, "add"))
8534 ret = rte_eth_dev_filter_ctrl(res->port_id,
8535 RTE_ETH_FILTER_NTUPLE,
8539 ret = rte_eth_dev_filter_ctrl(res->port_id,
8540 RTE_ETH_FILTER_NTUPLE,
8541 RTE_ETH_FILTER_DELETE,
8544 printf("2tuple filter programming error: (%s)\n",
8549 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8550 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8551 filter, "2tuple_filter");
8552 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8553 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8555 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8556 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8558 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8559 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8560 dst_port, "dst_port");
8561 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8562 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8563 dst_port_value, UINT16);
8564 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8565 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8566 protocol, "protocol");
8567 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8568 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8569 protocol_value, UINT8);
8570 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8571 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8573 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8574 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8576 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8577 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8578 tcp_flags, "tcp_flags");
8579 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8580 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8581 tcp_flags_value, UINT8);
8582 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8583 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8584 priority, "priority");
8585 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8586 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8587 priority_value, UINT8);
8588 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8589 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8591 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8592 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8595 cmdline_parse_inst_t cmd_2tuple_filter = {
8596 .f = cmd_2tuple_filter_parsed,
8598 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8599 "<value> mask <value> tcp_flags <value> priority <value> queue "
8600 "<queue_id>: Add a 2tuple filter",
8602 (void *)&cmd_2tuple_filter_filter,
8603 (void *)&cmd_2tuple_filter_port_id,
8604 (void *)&cmd_2tuple_filter_ops,
8605 (void *)&cmd_2tuple_filter_dst_port,
8606 (void *)&cmd_2tuple_filter_dst_port_value,
8607 (void *)&cmd_2tuple_filter_protocol,
8608 (void *)&cmd_2tuple_filter_protocol_value,
8609 (void *)&cmd_2tuple_filter_mask,
8610 (void *)&cmd_2tuple_filter_mask_value,
8611 (void *)&cmd_2tuple_filter_tcp_flags,
8612 (void *)&cmd_2tuple_filter_tcp_flags_value,
8613 (void *)&cmd_2tuple_filter_priority,
8614 (void *)&cmd_2tuple_filter_priority_value,
8615 (void *)&cmd_2tuple_filter_queue,
8616 (void *)&cmd_2tuple_filter_queue_id,
8621 /* *** ADD/REMOVE A 5tuple FILTER *** */
8622 struct cmd_5tuple_filter_result {
8623 cmdline_fixed_string_t filter;
8625 cmdline_fixed_string_t ops;
8626 cmdline_fixed_string_t dst_ip;
8627 cmdline_ipaddr_t dst_ip_value;
8628 cmdline_fixed_string_t src_ip;
8629 cmdline_ipaddr_t src_ip_value;
8630 cmdline_fixed_string_t dst_port;
8631 uint16_t dst_port_value;
8632 cmdline_fixed_string_t src_port;
8633 uint16_t src_port_value;
8634 cmdline_fixed_string_t protocol;
8635 uint8_t protocol_value;
8636 cmdline_fixed_string_t mask;
8638 cmdline_fixed_string_t tcp_flags;
8639 uint8_t tcp_flags_value;
8640 cmdline_fixed_string_t priority;
8641 uint8_t priority_value;
8642 cmdline_fixed_string_t queue;
8647 cmd_5tuple_filter_parsed(void *parsed_result,
8648 __attribute__((unused)) struct cmdline *cl,
8649 __attribute__((unused)) void *data)
8651 struct rte_eth_ntuple_filter filter;
8652 struct cmd_5tuple_filter_result *res = parsed_result;
8655 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8657 printf("ntuple filter is not supported on port %u.\n",
8662 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8664 filter.flags = RTE_5TUPLE_FLAGS;
8665 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8666 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8667 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8668 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8669 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8670 filter.proto = res->protocol_value;
8671 filter.priority = res->priority_value;
8672 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8673 printf("nonzero tcp_flags is only meaningful"
8674 " when protocol is TCP.\n");
8677 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8678 printf("invalid TCP flags.\n");
8682 if (res->tcp_flags_value != 0) {
8683 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8684 filter.tcp_flags = res->tcp_flags_value;
8687 if (res->dst_ip_value.family == AF_INET)
8688 /* no need to convert, already big endian. */
8689 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8691 if (filter.dst_ip_mask == 0) {
8692 printf("can not support ipv6 involved compare.\n");
8698 if (res->src_ip_value.family == AF_INET)
8699 /* no need to convert, already big endian. */
8700 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8702 if (filter.src_ip_mask == 0) {
8703 printf("can not support ipv6 involved compare.\n");
8708 /* need convert to big endian. */
8709 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8710 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8711 filter.queue = res->queue_id;
8713 if (!strcmp(res->ops, "add"))
8714 ret = rte_eth_dev_filter_ctrl(res->port_id,
8715 RTE_ETH_FILTER_NTUPLE,
8719 ret = rte_eth_dev_filter_ctrl(res->port_id,
8720 RTE_ETH_FILTER_NTUPLE,
8721 RTE_ETH_FILTER_DELETE,
8724 printf("5tuple filter programming error: (%s)\n",
8728 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8729 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8730 filter, "5tuple_filter");
8731 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8732 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8734 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8735 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8737 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8738 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8740 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8741 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8743 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8744 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8746 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8747 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8749 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8750 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8751 dst_port, "dst_port");
8752 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8753 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8754 dst_port_value, UINT16);
8755 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8756 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8757 src_port, "src_port");
8758 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8759 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8760 src_port_value, UINT16);
8761 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8762 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8763 protocol, "protocol");
8764 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8765 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8766 protocol_value, UINT8);
8767 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8768 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8770 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8771 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8773 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8774 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8775 tcp_flags, "tcp_flags");
8776 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8777 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8778 tcp_flags_value, UINT8);
8779 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8780 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8781 priority, "priority");
8782 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8783 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8784 priority_value, UINT8);
8785 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8786 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8788 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8789 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8792 cmdline_parse_inst_t cmd_5tuple_filter = {
8793 .f = cmd_5tuple_filter_parsed,
8795 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8796 "src_ip <value> dst_port <value> src_port <value> "
8797 "protocol <value> mask <value> tcp_flags <value> "
8798 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8800 (void *)&cmd_5tuple_filter_filter,
8801 (void *)&cmd_5tuple_filter_port_id,
8802 (void *)&cmd_5tuple_filter_ops,
8803 (void *)&cmd_5tuple_filter_dst_ip,
8804 (void *)&cmd_5tuple_filter_dst_ip_value,
8805 (void *)&cmd_5tuple_filter_src_ip,
8806 (void *)&cmd_5tuple_filter_src_ip_value,
8807 (void *)&cmd_5tuple_filter_dst_port,
8808 (void *)&cmd_5tuple_filter_dst_port_value,
8809 (void *)&cmd_5tuple_filter_src_port,
8810 (void *)&cmd_5tuple_filter_src_port_value,
8811 (void *)&cmd_5tuple_filter_protocol,
8812 (void *)&cmd_5tuple_filter_protocol_value,
8813 (void *)&cmd_5tuple_filter_mask,
8814 (void *)&cmd_5tuple_filter_mask_value,
8815 (void *)&cmd_5tuple_filter_tcp_flags,
8816 (void *)&cmd_5tuple_filter_tcp_flags_value,
8817 (void *)&cmd_5tuple_filter_priority,
8818 (void *)&cmd_5tuple_filter_priority_value,
8819 (void *)&cmd_5tuple_filter_queue,
8820 (void *)&cmd_5tuple_filter_queue_id,
8825 /* *** ADD/REMOVE A flex FILTER *** */
8826 struct cmd_flex_filter_result {
8827 cmdline_fixed_string_t filter;
8828 cmdline_fixed_string_t ops;
8830 cmdline_fixed_string_t len;
8832 cmdline_fixed_string_t bytes;
8833 cmdline_fixed_string_t bytes_value;
8834 cmdline_fixed_string_t mask;
8835 cmdline_fixed_string_t mask_value;
8836 cmdline_fixed_string_t priority;
8837 uint8_t priority_value;
8838 cmdline_fixed_string_t queue;
8842 static int xdigit2val(unsigned char c)
8847 else if (isupper(c))
8855 cmd_flex_filter_parsed(void *parsed_result,
8856 __attribute__((unused)) struct cmdline *cl,
8857 __attribute__((unused)) void *data)
8860 struct rte_eth_flex_filter filter;
8861 struct cmd_flex_filter_result *res = parsed_result;
8862 char *bytes_ptr, *mask_ptr;
8863 uint16_t len, i, j = 0;
8868 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8869 printf("the len exceed the max length 128\n");
8872 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8873 filter.len = res->len_value;
8874 filter.priority = res->priority_value;
8875 filter.queue = res->queue_id;
8876 bytes_ptr = res->bytes_value;
8877 mask_ptr = res->mask_value;
8879 /* translate bytes string to array. */
8880 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8881 (bytes_ptr[1] == 'X')))
8883 len = strnlen(bytes_ptr, res->len_value * 2);
8884 if (len == 0 || (len % 8 != 0)) {
8885 printf("please check len and bytes input\n");
8888 for (i = 0; i < len; i++) {
8890 if (isxdigit(c) == 0) {
8891 /* invalid characters. */
8892 printf("invalid input\n");
8895 val = xdigit2val(c);
8898 filter.bytes[j] = byte;
8899 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8906 /* translate mask string to uint8_t array. */
8907 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8908 (mask_ptr[1] == 'X')))
8910 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8912 printf("invalid input\n");
8917 for (i = 0; i < len; i++) {
8919 if (isxdigit(c) == 0) {
8920 /* invalid characters. */
8921 printf("invalid input\n");
8924 val = xdigit2val(c);
8927 filter.mask[j] = byte;
8928 printf("mask[%d]:%02x ", j, filter.mask[j]);
8936 if (!strcmp(res->ops, "add"))
8937 ret = rte_eth_dev_filter_ctrl(res->port_id,
8938 RTE_ETH_FILTER_FLEXIBLE,
8942 ret = rte_eth_dev_filter_ctrl(res->port_id,
8943 RTE_ETH_FILTER_FLEXIBLE,
8944 RTE_ETH_FILTER_DELETE,
8948 printf("flex filter setting error: (%s)\n", strerror(-ret));
8951 cmdline_parse_token_string_t cmd_flex_filter_filter =
8952 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8953 filter, "flex_filter");
8954 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8955 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8957 cmdline_parse_token_string_t cmd_flex_filter_ops =
8958 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8960 cmdline_parse_token_string_t cmd_flex_filter_len =
8961 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8963 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8964 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8966 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8967 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8969 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8970 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8972 cmdline_parse_token_string_t cmd_flex_filter_mask =
8973 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8975 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8976 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8978 cmdline_parse_token_string_t cmd_flex_filter_priority =
8979 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8980 priority, "priority");
8981 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8982 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8983 priority_value, UINT8);
8984 cmdline_parse_token_string_t cmd_flex_filter_queue =
8985 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8987 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8988 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8990 cmdline_parse_inst_t cmd_flex_filter = {
8991 .f = cmd_flex_filter_parsed,
8993 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8994 "<value> mask <value> priority <value> queue <queue_id>: "
8995 "Add/Del a flex filter",
8997 (void *)&cmd_flex_filter_filter,
8998 (void *)&cmd_flex_filter_port_id,
8999 (void *)&cmd_flex_filter_ops,
9000 (void *)&cmd_flex_filter_len,
9001 (void *)&cmd_flex_filter_len_value,
9002 (void *)&cmd_flex_filter_bytes,
9003 (void *)&cmd_flex_filter_bytes_value,
9004 (void *)&cmd_flex_filter_mask,
9005 (void *)&cmd_flex_filter_mask_value,
9006 (void *)&cmd_flex_filter_priority,
9007 (void *)&cmd_flex_filter_priority_value,
9008 (void *)&cmd_flex_filter_queue,
9009 (void *)&cmd_flex_filter_queue_id,
9014 /* *** Filters Control *** */
9016 /* *** deal with ethertype filter *** */
9017 struct cmd_ethertype_filter_result {
9018 cmdline_fixed_string_t filter;
9020 cmdline_fixed_string_t ops;
9021 cmdline_fixed_string_t mac;
9022 struct ether_addr mac_addr;
9023 cmdline_fixed_string_t ethertype;
9024 uint16_t ethertype_value;
9025 cmdline_fixed_string_t drop;
9026 cmdline_fixed_string_t queue;
9030 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9031 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9032 filter, "ethertype_filter");
9033 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9034 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9036 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9037 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9039 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9040 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9041 mac, "mac_addr#mac_ignr");
9042 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9043 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9045 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9046 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9047 ethertype, "ethertype");
9048 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9049 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9050 ethertype_value, UINT16);
9051 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9052 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9054 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9055 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9057 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9058 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9062 cmd_ethertype_filter_parsed(void *parsed_result,
9063 __attribute__((unused)) struct cmdline *cl,
9064 __attribute__((unused)) void *data)
9066 struct cmd_ethertype_filter_result *res = parsed_result;
9067 struct rte_eth_ethertype_filter filter;
9070 ret = rte_eth_dev_filter_supported(res->port_id,
9071 RTE_ETH_FILTER_ETHERTYPE);
9073 printf("ethertype filter is not supported on port %u.\n",
9078 memset(&filter, 0, sizeof(filter));
9079 if (!strcmp(res->mac, "mac_addr")) {
9080 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9081 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9082 sizeof(struct ether_addr));
9084 if (!strcmp(res->drop, "drop"))
9085 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9086 filter.ether_type = res->ethertype_value;
9087 filter.queue = res->queue_id;
9089 if (!strcmp(res->ops, "add"))
9090 ret = rte_eth_dev_filter_ctrl(res->port_id,
9091 RTE_ETH_FILTER_ETHERTYPE,
9095 ret = rte_eth_dev_filter_ctrl(res->port_id,
9096 RTE_ETH_FILTER_ETHERTYPE,
9097 RTE_ETH_FILTER_DELETE,
9100 printf("ethertype filter programming error: (%s)\n",
9104 cmdline_parse_inst_t cmd_ethertype_filter = {
9105 .f = cmd_ethertype_filter_parsed,
9107 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9108 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9109 "Add or delete an ethertype filter entry",
9111 (void *)&cmd_ethertype_filter_filter,
9112 (void *)&cmd_ethertype_filter_port_id,
9113 (void *)&cmd_ethertype_filter_ops,
9114 (void *)&cmd_ethertype_filter_mac,
9115 (void *)&cmd_ethertype_filter_mac_addr,
9116 (void *)&cmd_ethertype_filter_ethertype,
9117 (void *)&cmd_ethertype_filter_ethertype_value,
9118 (void *)&cmd_ethertype_filter_drop,
9119 (void *)&cmd_ethertype_filter_queue,
9120 (void *)&cmd_ethertype_filter_queue_id,
9125 /* *** deal with flow director filter *** */
9126 struct cmd_flow_director_result {
9127 cmdline_fixed_string_t flow_director_filter;
9129 cmdline_fixed_string_t mode;
9130 cmdline_fixed_string_t mode_value;
9131 cmdline_fixed_string_t ops;
9132 cmdline_fixed_string_t flow;
9133 cmdline_fixed_string_t flow_type;
9134 cmdline_fixed_string_t ether;
9135 uint16_t ether_type;
9136 cmdline_fixed_string_t src;
9137 cmdline_ipaddr_t ip_src;
9139 cmdline_fixed_string_t dst;
9140 cmdline_ipaddr_t ip_dst;
9142 cmdline_fixed_string_t verify_tag;
9143 uint32_t verify_tag_value;
9144 cmdline_ipaddr_t tos;
9146 cmdline_ipaddr_t proto;
9147 uint8_t proto_value;
9148 cmdline_ipaddr_t ttl;
9150 cmdline_fixed_string_t vlan;
9151 uint16_t vlan_value;
9152 cmdline_fixed_string_t flexbytes;
9153 cmdline_fixed_string_t flexbytes_value;
9154 cmdline_fixed_string_t pf_vf;
9155 cmdline_fixed_string_t drop;
9156 cmdline_fixed_string_t queue;
9158 cmdline_fixed_string_t fd_id;
9159 uint32_t fd_id_value;
9160 cmdline_fixed_string_t mac;
9161 struct ether_addr mac_addr;
9162 cmdline_fixed_string_t tunnel;
9163 cmdline_fixed_string_t tunnel_type;
9164 cmdline_fixed_string_t tunnel_id;
9165 uint32_t tunnel_id_value;
9169 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9172 const char *p, *p0 = q_arg;
9174 unsigned long int_fld;
9175 char *str_fld[max_num];
9180 p = strchr(p0, '(');
9184 p0 = strchr(p, ')');
9189 if (size >= sizeof(s))
9192 snprintf(s, sizeof(s), "%.*s", size, p);
9193 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9194 if (ret < 0 || ret > max_num)
9196 for (i = 0; i < ret; i++) {
9198 int_fld = strtoul(str_fld[i], &end, 0);
9199 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9201 flexbytes[i] = (uint8_t)int_fld;
9207 str2flowtype(char *string)
9210 static const struct {
9213 } flowtype_str[] = {
9214 {"raw", RTE_ETH_FLOW_RAW},
9215 {"ipv4", RTE_ETH_FLOW_IPV4},
9216 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9217 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9218 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9219 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9220 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9221 {"ipv6", RTE_ETH_FLOW_IPV6},
9222 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9223 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9224 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9225 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9226 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9227 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9230 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9231 if (!strcmp(flowtype_str[i].str, string))
9232 return flowtype_str[i].type;
9235 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9236 return (uint16_t)atoi(string);
9238 return RTE_ETH_FLOW_UNKNOWN;
9241 static enum rte_eth_fdir_tunnel_type
9242 str2fdir_tunneltype(char *string)
9246 static const struct {
9248 enum rte_eth_fdir_tunnel_type type;
9249 } tunneltype_str[] = {
9250 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9251 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9254 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9255 if (!strcmp(tunneltype_str[i].str, string))
9256 return tunneltype_str[i].type;
9258 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9261 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9263 if ((ip_addr).family == AF_INET) \
9264 (ip) = (ip_addr).addr.ipv4.s_addr; \
9266 printf("invalid parameter.\n"); \
9271 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9273 if ((ip_addr).family == AF_INET6) \
9275 &((ip_addr).addr.ipv6), \
9276 sizeof(struct in6_addr)); \
9278 printf("invalid parameter.\n"); \
9284 cmd_flow_director_filter_parsed(void *parsed_result,
9285 __attribute__((unused)) struct cmdline *cl,
9286 __attribute__((unused)) void *data)
9288 struct cmd_flow_director_result *res = parsed_result;
9289 struct rte_eth_fdir_filter entry;
9290 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9292 unsigned long vf_id;
9295 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9297 printf("flow director is not supported on port %u.\n",
9301 memset(flexbytes, 0, sizeof(flexbytes));
9302 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9304 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9305 if (strcmp(res->mode_value, "MAC-VLAN")) {
9306 printf("Please set mode to MAC-VLAN.\n");
9309 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9310 if (strcmp(res->mode_value, "Tunnel")) {
9311 printf("Please set mode to Tunnel.\n");
9315 if (strcmp(res->mode_value, "IP")) {
9316 printf("Please set mode to IP.\n");
9319 entry.input.flow_type = str2flowtype(res->flow_type);
9322 ret = parse_flexbytes(res->flexbytes_value,
9324 RTE_ETH_FDIR_MAX_FLEXLEN);
9326 printf("error: Cannot parse flexbytes input.\n");
9330 switch (entry.input.flow_type) {
9331 case RTE_ETH_FLOW_FRAG_IPV4:
9332 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9333 entry.input.flow.ip4_flow.proto = res->proto_value;
9335 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9336 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9337 IPV4_ADDR_TO_UINT(res->ip_dst,
9338 entry.input.flow.ip4_flow.dst_ip);
9339 IPV4_ADDR_TO_UINT(res->ip_src,
9340 entry.input.flow.ip4_flow.src_ip);
9341 entry.input.flow.ip4_flow.tos = res->tos_value;
9342 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9343 /* need convert to big endian. */
9344 entry.input.flow.udp4_flow.dst_port =
9345 rte_cpu_to_be_16(res->port_dst);
9346 entry.input.flow.udp4_flow.src_port =
9347 rte_cpu_to_be_16(res->port_src);
9349 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9350 IPV4_ADDR_TO_UINT(res->ip_dst,
9351 entry.input.flow.sctp4_flow.ip.dst_ip);
9352 IPV4_ADDR_TO_UINT(res->ip_src,
9353 entry.input.flow.sctp4_flow.ip.src_ip);
9354 entry.input.flow.ip4_flow.tos = res->tos_value;
9355 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9356 /* need convert to big endian. */
9357 entry.input.flow.sctp4_flow.dst_port =
9358 rte_cpu_to_be_16(res->port_dst);
9359 entry.input.flow.sctp4_flow.src_port =
9360 rte_cpu_to_be_16(res->port_src);
9361 entry.input.flow.sctp4_flow.verify_tag =
9362 rte_cpu_to_be_32(res->verify_tag_value);
9364 case RTE_ETH_FLOW_FRAG_IPV6:
9365 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9366 entry.input.flow.ipv6_flow.proto = res->proto_value;
9368 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9369 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9370 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9371 entry.input.flow.ipv6_flow.dst_ip);
9372 IPV6_ADDR_TO_ARRAY(res->ip_src,
9373 entry.input.flow.ipv6_flow.src_ip);
9374 entry.input.flow.ipv6_flow.tc = res->tos_value;
9375 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9376 /* need convert to big endian. */
9377 entry.input.flow.udp6_flow.dst_port =
9378 rte_cpu_to_be_16(res->port_dst);
9379 entry.input.flow.udp6_flow.src_port =
9380 rte_cpu_to_be_16(res->port_src);
9382 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9383 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9384 entry.input.flow.sctp6_flow.ip.dst_ip);
9385 IPV6_ADDR_TO_ARRAY(res->ip_src,
9386 entry.input.flow.sctp6_flow.ip.src_ip);
9387 entry.input.flow.ipv6_flow.tc = res->tos_value;
9388 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9389 /* need convert to big endian. */
9390 entry.input.flow.sctp6_flow.dst_port =
9391 rte_cpu_to_be_16(res->port_dst);
9392 entry.input.flow.sctp6_flow.src_port =
9393 rte_cpu_to_be_16(res->port_src);
9394 entry.input.flow.sctp6_flow.verify_tag =
9395 rte_cpu_to_be_32(res->verify_tag_value);
9397 case RTE_ETH_FLOW_L2_PAYLOAD:
9398 entry.input.flow.l2_flow.ether_type =
9399 rte_cpu_to_be_16(res->ether_type);
9405 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9406 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9408 sizeof(struct ether_addr));
9410 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9411 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9413 sizeof(struct ether_addr));
9414 entry.input.flow.tunnel_flow.tunnel_type =
9415 str2fdir_tunneltype(res->tunnel_type);
9416 entry.input.flow.tunnel_flow.tunnel_id =
9417 rte_cpu_to_be_32(res->tunnel_id_value);
9420 rte_memcpy(entry.input.flow_ext.flexbytes,
9422 RTE_ETH_FDIR_MAX_FLEXLEN);
9424 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9426 entry.action.flex_off = 0; /*use 0 by default */
9427 if (!strcmp(res->drop, "drop"))
9428 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9430 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9432 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9433 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9434 if (!strcmp(res->pf_vf, "pf"))
9435 entry.input.flow_ext.is_vf = 0;
9436 else if (!strncmp(res->pf_vf, "vf", 2)) {
9437 struct rte_eth_dev_info dev_info;
9439 memset(&dev_info, 0, sizeof(dev_info));
9440 rte_eth_dev_info_get(res->port_id, &dev_info);
9442 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9443 if (errno != 0 || *end != '\0' ||
9444 vf_id >= dev_info.max_vfs) {
9445 printf("invalid parameter %s.\n", res->pf_vf);
9448 entry.input.flow_ext.is_vf = 1;
9449 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9451 printf("invalid parameter %s.\n", res->pf_vf);
9456 /* set to report FD ID by default */
9457 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9458 entry.action.rx_queue = res->queue_id;
9459 entry.soft_id = res->fd_id_value;
9460 if (!strcmp(res->ops, "add"))
9461 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9462 RTE_ETH_FILTER_ADD, &entry);
9463 else if (!strcmp(res->ops, "del"))
9464 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9465 RTE_ETH_FILTER_DELETE, &entry);
9467 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9468 RTE_ETH_FILTER_UPDATE, &entry);
9470 printf("flow director programming error: (%s)\n",
9474 cmdline_parse_token_string_t cmd_flow_director_filter =
9475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9476 flow_director_filter, "flow_director_filter");
9477 cmdline_parse_token_num_t cmd_flow_director_port_id =
9478 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9480 cmdline_parse_token_string_t cmd_flow_director_ops =
9481 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9482 ops, "add#del#update");
9483 cmdline_parse_token_string_t cmd_flow_director_flow =
9484 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9486 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9487 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9488 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9489 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9490 cmdline_parse_token_string_t cmd_flow_director_ether =
9491 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9493 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9494 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9495 ether_type, UINT16);
9496 cmdline_parse_token_string_t cmd_flow_director_src =
9497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9499 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9500 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9502 cmdline_parse_token_num_t cmd_flow_director_port_src =
9503 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9505 cmdline_parse_token_string_t cmd_flow_director_dst =
9506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9508 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9509 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9511 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9512 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9514 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9516 verify_tag, "verify_tag");
9517 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9518 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9519 verify_tag_value, UINT32);
9520 cmdline_parse_token_string_t cmd_flow_director_tos =
9521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9523 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9524 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9526 cmdline_parse_token_string_t cmd_flow_director_proto =
9527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9529 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9530 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9531 proto_value, UINT8);
9532 cmdline_parse_token_string_t cmd_flow_director_ttl =
9533 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9535 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9536 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9538 cmdline_parse_token_string_t cmd_flow_director_vlan =
9539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9541 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9542 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9543 vlan_value, UINT16);
9544 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9546 flexbytes, "flexbytes");
9547 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9548 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9549 flexbytes_value, NULL);
9550 cmdline_parse_token_string_t cmd_flow_director_drop =
9551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9553 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9556 cmdline_parse_token_string_t cmd_flow_director_queue =
9557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9559 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9560 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9562 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9565 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9566 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9567 fd_id_value, UINT32);
9569 cmdline_parse_token_string_t cmd_flow_director_mode =
9570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9572 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9575 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9577 mode_value, "MAC-VLAN");
9578 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9580 mode_value, "Tunnel");
9581 cmdline_parse_token_string_t cmd_flow_director_mac =
9582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9584 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9585 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9587 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9590 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9592 tunnel_type, "NVGRE#VxLAN");
9593 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9595 tunnel_id, "tunnel-id");
9596 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9597 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9598 tunnel_id_value, UINT32);
9600 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9601 .f = cmd_flow_director_filter_parsed,
9603 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9604 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9605 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9606 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9607 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9608 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9609 "fd_id <fd_id_value>: "
9610 "Add or delete an ip flow director entry on NIC",
9612 (void *)&cmd_flow_director_filter,
9613 (void *)&cmd_flow_director_port_id,
9614 (void *)&cmd_flow_director_mode,
9615 (void *)&cmd_flow_director_mode_ip,
9616 (void *)&cmd_flow_director_ops,
9617 (void *)&cmd_flow_director_flow,
9618 (void *)&cmd_flow_director_flow_type,
9619 (void *)&cmd_flow_director_src,
9620 (void *)&cmd_flow_director_ip_src,
9621 (void *)&cmd_flow_director_dst,
9622 (void *)&cmd_flow_director_ip_dst,
9623 (void *)&cmd_flow_director_tos,
9624 (void *)&cmd_flow_director_tos_value,
9625 (void *)&cmd_flow_director_proto,
9626 (void *)&cmd_flow_director_proto_value,
9627 (void *)&cmd_flow_director_ttl,
9628 (void *)&cmd_flow_director_ttl_value,
9629 (void *)&cmd_flow_director_vlan,
9630 (void *)&cmd_flow_director_vlan_value,
9631 (void *)&cmd_flow_director_flexbytes,
9632 (void *)&cmd_flow_director_flexbytes_value,
9633 (void *)&cmd_flow_director_drop,
9634 (void *)&cmd_flow_director_pf_vf,
9635 (void *)&cmd_flow_director_queue,
9636 (void *)&cmd_flow_director_queue_id,
9637 (void *)&cmd_flow_director_fd_id,
9638 (void *)&cmd_flow_director_fd_id_value,
9643 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9644 .f = cmd_flow_director_filter_parsed,
9646 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9647 "director entry on NIC",
9649 (void *)&cmd_flow_director_filter,
9650 (void *)&cmd_flow_director_port_id,
9651 (void *)&cmd_flow_director_mode,
9652 (void *)&cmd_flow_director_mode_ip,
9653 (void *)&cmd_flow_director_ops,
9654 (void *)&cmd_flow_director_flow,
9655 (void *)&cmd_flow_director_flow_type,
9656 (void *)&cmd_flow_director_src,
9657 (void *)&cmd_flow_director_ip_src,
9658 (void *)&cmd_flow_director_port_src,
9659 (void *)&cmd_flow_director_dst,
9660 (void *)&cmd_flow_director_ip_dst,
9661 (void *)&cmd_flow_director_port_dst,
9662 (void *)&cmd_flow_director_tos,
9663 (void *)&cmd_flow_director_tos_value,
9664 (void *)&cmd_flow_director_ttl,
9665 (void *)&cmd_flow_director_ttl_value,
9666 (void *)&cmd_flow_director_vlan,
9667 (void *)&cmd_flow_director_vlan_value,
9668 (void *)&cmd_flow_director_flexbytes,
9669 (void *)&cmd_flow_director_flexbytes_value,
9670 (void *)&cmd_flow_director_drop,
9671 (void *)&cmd_flow_director_pf_vf,
9672 (void *)&cmd_flow_director_queue,
9673 (void *)&cmd_flow_director_queue_id,
9674 (void *)&cmd_flow_director_fd_id,
9675 (void *)&cmd_flow_director_fd_id_value,
9680 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9681 .f = cmd_flow_director_filter_parsed,
9683 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9684 "director entry on NIC",
9686 (void *)&cmd_flow_director_filter,
9687 (void *)&cmd_flow_director_port_id,
9688 (void *)&cmd_flow_director_mode,
9689 (void *)&cmd_flow_director_mode_ip,
9690 (void *)&cmd_flow_director_ops,
9691 (void *)&cmd_flow_director_flow,
9692 (void *)&cmd_flow_director_flow_type,
9693 (void *)&cmd_flow_director_src,
9694 (void *)&cmd_flow_director_ip_src,
9695 (void *)&cmd_flow_director_port_dst,
9696 (void *)&cmd_flow_director_dst,
9697 (void *)&cmd_flow_director_ip_dst,
9698 (void *)&cmd_flow_director_port_dst,
9699 (void *)&cmd_flow_director_verify_tag,
9700 (void *)&cmd_flow_director_verify_tag_value,
9701 (void *)&cmd_flow_director_tos,
9702 (void *)&cmd_flow_director_tos_value,
9703 (void *)&cmd_flow_director_ttl,
9704 (void *)&cmd_flow_director_ttl_value,
9705 (void *)&cmd_flow_director_vlan,
9706 (void *)&cmd_flow_director_vlan_value,
9707 (void *)&cmd_flow_director_flexbytes,
9708 (void *)&cmd_flow_director_flexbytes_value,
9709 (void *)&cmd_flow_director_drop,
9710 (void *)&cmd_flow_director_pf_vf,
9711 (void *)&cmd_flow_director_queue,
9712 (void *)&cmd_flow_director_queue_id,
9713 (void *)&cmd_flow_director_fd_id,
9714 (void *)&cmd_flow_director_fd_id_value,
9719 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9720 .f = cmd_flow_director_filter_parsed,
9722 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9723 "director entry on NIC",
9725 (void *)&cmd_flow_director_filter,
9726 (void *)&cmd_flow_director_port_id,
9727 (void *)&cmd_flow_director_mode,
9728 (void *)&cmd_flow_director_mode_ip,
9729 (void *)&cmd_flow_director_ops,
9730 (void *)&cmd_flow_director_flow,
9731 (void *)&cmd_flow_director_flow_type,
9732 (void *)&cmd_flow_director_ether,
9733 (void *)&cmd_flow_director_ether_type,
9734 (void *)&cmd_flow_director_flexbytes,
9735 (void *)&cmd_flow_director_flexbytes_value,
9736 (void *)&cmd_flow_director_drop,
9737 (void *)&cmd_flow_director_pf_vf,
9738 (void *)&cmd_flow_director_queue,
9739 (void *)&cmd_flow_director_queue_id,
9740 (void *)&cmd_flow_director_fd_id,
9741 (void *)&cmd_flow_director_fd_id_value,
9746 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9747 .f = cmd_flow_director_filter_parsed,
9749 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9750 "director entry on NIC",
9752 (void *)&cmd_flow_director_filter,
9753 (void *)&cmd_flow_director_port_id,
9754 (void *)&cmd_flow_director_mode,
9755 (void *)&cmd_flow_director_mode_mac_vlan,
9756 (void *)&cmd_flow_director_ops,
9757 (void *)&cmd_flow_director_mac,
9758 (void *)&cmd_flow_director_mac_addr,
9759 (void *)&cmd_flow_director_vlan,
9760 (void *)&cmd_flow_director_vlan_value,
9761 (void *)&cmd_flow_director_flexbytes,
9762 (void *)&cmd_flow_director_flexbytes_value,
9763 (void *)&cmd_flow_director_drop,
9764 (void *)&cmd_flow_director_queue,
9765 (void *)&cmd_flow_director_queue_id,
9766 (void *)&cmd_flow_director_fd_id,
9767 (void *)&cmd_flow_director_fd_id_value,
9772 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9773 .f = cmd_flow_director_filter_parsed,
9775 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9776 "director entry on NIC",
9778 (void *)&cmd_flow_director_filter,
9779 (void *)&cmd_flow_director_port_id,
9780 (void *)&cmd_flow_director_mode,
9781 (void *)&cmd_flow_director_mode_tunnel,
9782 (void *)&cmd_flow_director_ops,
9783 (void *)&cmd_flow_director_mac,
9784 (void *)&cmd_flow_director_mac_addr,
9785 (void *)&cmd_flow_director_vlan,
9786 (void *)&cmd_flow_director_vlan_value,
9787 (void *)&cmd_flow_director_tunnel,
9788 (void *)&cmd_flow_director_tunnel_type,
9789 (void *)&cmd_flow_director_tunnel_id,
9790 (void *)&cmd_flow_director_tunnel_id_value,
9791 (void *)&cmd_flow_director_flexbytes,
9792 (void *)&cmd_flow_director_flexbytes_value,
9793 (void *)&cmd_flow_director_drop,
9794 (void *)&cmd_flow_director_queue,
9795 (void *)&cmd_flow_director_queue_id,
9796 (void *)&cmd_flow_director_fd_id,
9797 (void *)&cmd_flow_director_fd_id_value,
9802 struct cmd_flush_flow_director_result {
9803 cmdline_fixed_string_t flush_flow_director;
9807 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9808 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9809 flush_flow_director, "flush_flow_director");
9810 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9811 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9815 cmd_flush_flow_director_parsed(void *parsed_result,
9816 __attribute__((unused)) struct cmdline *cl,
9817 __attribute__((unused)) void *data)
9819 struct cmd_flow_director_result *res = parsed_result;
9822 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9824 printf("flow director is not supported on port %u.\n",
9829 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9830 RTE_ETH_FILTER_FLUSH, NULL);
9832 printf("flow director table flushing error: (%s)\n",
9836 cmdline_parse_inst_t cmd_flush_flow_director = {
9837 .f = cmd_flush_flow_director_parsed,
9839 .help_str = "flush_flow_director <port_id>: "
9840 "Flush all flow director entries of a device on NIC",
9842 (void *)&cmd_flush_flow_director_flush,
9843 (void *)&cmd_flush_flow_director_port_id,
9848 /* *** deal with flow director mask *** */
9849 struct cmd_flow_director_mask_result {
9850 cmdline_fixed_string_t flow_director_mask;
9852 cmdline_fixed_string_t mode;
9853 cmdline_fixed_string_t mode_value;
9854 cmdline_fixed_string_t vlan;
9856 cmdline_fixed_string_t src_mask;
9857 cmdline_ipaddr_t ipv4_src;
9858 cmdline_ipaddr_t ipv6_src;
9860 cmdline_fixed_string_t dst_mask;
9861 cmdline_ipaddr_t ipv4_dst;
9862 cmdline_ipaddr_t ipv6_dst;
9864 cmdline_fixed_string_t mac;
9865 uint8_t mac_addr_byte_mask;
9866 cmdline_fixed_string_t tunnel_id;
9867 uint32_t tunnel_id_mask;
9868 cmdline_fixed_string_t tunnel_type;
9869 uint8_t tunnel_type_mask;
9873 cmd_flow_director_mask_parsed(void *parsed_result,
9874 __attribute__((unused)) struct cmdline *cl,
9875 __attribute__((unused)) void *data)
9877 struct cmd_flow_director_mask_result *res = parsed_result;
9878 struct rte_eth_fdir_masks *mask;
9879 struct rte_port *port;
9881 if (res->port_id > nb_ports) {
9882 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9886 port = &ports[res->port_id];
9887 /** Check if the port is not started **/
9888 if (port->port_status != RTE_PORT_STOPPED) {
9889 printf("Please stop port %d first\n", res->port_id);
9893 mask = &port->dev_conf.fdir_conf.mask;
9895 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9896 if (strcmp(res->mode_value, "MAC-VLAN")) {
9897 printf("Please set mode to MAC-VLAN.\n");
9901 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9902 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9903 if (strcmp(res->mode_value, "Tunnel")) {
9904 printf("Please set mode to Tunnel.\n");
9908 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9909 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9910 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9911 mask->tunnel_type_mask = res->tunnel_type_mask;
9913 if (strcmp(res->mode_value, "IP")) {
9914 printf("Please set mode to IP.\n");
9918 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9919 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9920 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9921 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9922 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9923 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9924 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9927 cmd_reconfig_device_queue(res->port_id, 1, 1);
9930 cmdline_parse_token_string_t cmd_flow_director_mask =
9931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9932 flow_director_mask, "flow_director_mask");
9933 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9934 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9936 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9939 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9940 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9942 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9944 src_mask, "src_mask");
9945 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9946 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9948 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9949 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9951 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9952 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9954 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9956 dst_mask, "dst_mask");
9957 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9958 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9960 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9961 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9963 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9964 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9967 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9970 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9973 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9975 mode_value, "MAC-VLAN");
9976 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9978 mode_value, "Tunnel");
9979 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9982 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9983 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9984 mac_addr_byte_mask, UINT8);
9985 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9987 tunnel_type, "tunnel-type");
9988 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9989 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9990 tunnel_type_mask, UINT8);
9991 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9992 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9993 tunnel_id, "tunnel-id");
9994 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9995 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9996 tunnel_id_mask, UINT32);
9998 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9999 .f = cmd_flow_director_mask_parsed,
10001 .help_str = "flow_director_mask ... : "
10002 "Set IP mode flow director's mask on NIC",
10004 (void *)&cmd_flow_director_mask,
10005 (void *)&cmd_flow_director_mask_port_id,
10006 (void *)&cmd_flow_director_mask_mode,
10007 (void *)&cmd_flow_director_mask_mode_ip,
10008 (void *)&cmd_flow_director_mask_vlan,
10009 (void *)&cmd_flow_director_mask_vlan_value,
10010 (void *)&cmd_flow_director_mask_src,
10011 (void *)&cmd_flow_director_mask_ipv4_src,
10012 (void *)&cmd_flow_director_mask_ipv6_src,
10013 (void *)&cmd_flow_director_mask_port_src,
10014 (void *)&cmd_flow_director_mask_dst,
10015 (void *)&cmd_flow_director_mask_ipv4_dst,
10016 (void *)&cmd_flow_director_mask_ipv6_dst,
10017 (void *)&cmd_flow_director_mask_port_dst,
10022 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10023 .f = cmd_flow_director_mask_parsed,
10025 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10026 "flow director's mask on NIC",
10028 (void *)&cmd_flow_director_mask,
10029 (void *)&cmd_flow_director_mask_port_id,
10030 (void *)&cmd_flow_director_mask_mode,
10031 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10032 (void *)&cmd_flow_director_mask_vlan,
10033 (void *)&cmd_flow_director_mask_vlan_value,
10038 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10039 .f = cmd_flow_director_mask_parsed,
10041 .help_str = "flow_director_mask ... : Set tunnel mode "
10042 "flow director's mask on NIC",
10044 (void *)&cmd_flow_director_mask,
10045 (void *)&cmd_flow_director_mask_port_id,
10046 (void *)&cmd_flow_director_mask_mode,
10047 (void *)&cmd_flow_director_mask_mode_tunnel,
10048 (void *)&cmd_flow_director_mask_vlan,
10049 (void *)&cmd_flow_director_mask_vlan_value,
10050 (void *)&cmd_flow_director_mask_mac,
10051 (void *)&cmd_flow_director_mask_mac_value,
10052 (void *)&cmd_flow_director_mask_tunnel_type,
10053 (void *)&cmd_flow_director_mask_tunnel_type_value,
10054 (void *)&cmd_flow_director_mask_tunnel_id,
10055 (void *)&cmd_flow_director_mask_tunnel_id_value,
10060 /* *** deal with flow director mask on flexible payload *** */
10061 struct cmd_flow_director_flex_mask_result {
10062 cmdline_fixed_string_t flow_director_flexmask;
10064 cmdline_fixed_string_t flow;
10065 cmdline_fixed_string_t flow_type;
10066 cmdline_fixed_string_t mask;
10070 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10071 __attribute__((unused)) struct cmdline *cl,
10072 __attribute__((unused)) void *data)
10074 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10075 struct rte_eth_fdir_info fdir_info;
10076 struct rte_eth_fdir_flex_mask flex_mask;
10077 struct rte_port *port;
10078 uint32_t flow_type_mask;
10082 if (res->port_id > nb_ports) {
10083 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10087 port = &ports[res->port_id];
10088 /** Check if the port is not started **/
10089 if (port->port_status != RTE_PORT_STOPPED) {
10090 printf("Please stop port %d first\n", res->port_id);
10094 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10095 ret = parse_flexbytes(res->mask,
10097 RTE_ETH_FDIR_MAX_FLEXLEN);
10099 printf("error: Cannot parse mask input.\n");
10103 memset(&fdir_info, 0, sizeof(fdir_info));
10104 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10105 RTE_ETH_FILTER_INFO, &fdir_info);
10107 printf("Cannot get FDir filter info\n");
10111 if (!strcmp(res->flow_type, "none")) {
10112 /* means don't specify the flow type */
10113 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10114 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10115 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10116 0, sizeof(struct rte_eth_fdir_flex_mask));
10117 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10118 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10120 sizeof(struct rte_eth_fdir_flex_mask));
10121 cmd_reconfig_device_queue(res->port_id, 1, 1);
10124 flow_type_mask = fdir_info.flow_types_mask[0];
10125 if (!strcmp(res->flow_type, "all")) {
10126 if (!flow_type_mask) {
10127 printf("No flow type supported\n");
10130 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10131 if (flow_type_mask & (1 << i)) {
10132 flex_mask.flow_type = i;
10133 fdir_set_flex_mask(res->port_id, &flex_mask);
10136 cmd_reconfig_device_queue(res->port_id, 1, 1);
10139 flex_mask.flow_type = str2flowtype(res->flow_type);
10140 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10141 printf("Flow type %s not supported on port %d\n",
10142 res->flow_type, res->port_id);
10145 fdir_set_flex_mask(res->port_id, &flex_mask);
10146 cmd_reconfig_device_queue(res->port_id, 1, 1);
10149 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10150 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10151 flow_director_flexmask,
10152 "flow_director_flex_mask");
10153 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10154 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10156 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10159 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10161 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10162 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10163 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10164 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10167 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10168 .f = cmd_flow_director_flex_mask_parsed,
10170 .help_str = "flow_director_flex_mask ... : "
10171 "Set flow director's flex mask on NIC",
10173 (void *)&cmd_flow_director_flexmask,
10174 (void *)&cmd_flow_director_flexmask_port_id,
10175 (void *)&cmd_flow_director_flexmask_flow,
10176 (void *)&cmd_flow_director_flexmask_flow_type,
10177 (void *)&cmd_flow_director_flexmask_mask,
10182 /* *** deal with flow director flexible payload configuration *** */
10183 struct cmd_flow_director_flexpayload_result {
10184 cmdline_fixed_string_t flow_director_flexpayload;
10186 cmdline_fixed_string_t payload_layer;
10187 cmdline_fixed_string_t payload_cfg;
10191 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10194 const char *p, *p0 = q_arg;
10196 unsigned long int_fld;
10197 char *str_fld[max_num];
10202 p = strchr(p0, '(');
10206 p0 = strchr(p, ')');
10211 if (size >= sizeof(s))
10214 snprintf(s, sizeof(s), "%.*s", size, p);
10215 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10216 if (ret < 0 || ret > max_num)
10218 for (i = 0; i < ret; i++) {
10220 int_fld = strtoul(str_fld[i], &end, 0);
10221 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10223 offsets[i] = (uint16_t)int_fld;
10229 cmd_flow_director_flxpld_parsed(void *parsed_result,
10230 __attribute__((unused)) struct cmdline *cl,
10231 __attribute__((unused)) void *data)
10233 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10234 struct rte_eth_flex_payload_cfg flex_cfg;
10235 struct rte_port *port;
10238 if (res->port_id > nb_ports) {
10239 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10243 port = &ports[res->port_id];
10244 /** Check if the port is not started **/
10245 if (port->port_status != RTE_PORT_STOPPED) {
10246 printf("Please stop port %d first\n", res->port_id);
10250 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10252 if (!strcmp(res->payload_layer, "raw"))
10253 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10254 else if (!strcmp(res->payload_layer, "l2"))
10255 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10256 else if (!strcmp(res->payload_layer, "l3"))
10257 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10258 else if (!strcmp(res->payload_layer, "l4"))
10259 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10261 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10262 RTE_ETH_FDIR_MAX_FLEXLEN);
10264 printf("error: Cannot parse flex payload input.\n");
10268 fdir_set_flex_payload(res->port_id, &flex_cfg);
10269 cmd_reconfig_device_queue(res->port_id, 1, 1);
10272 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10274 flow_director_flexpayload,
10275 "flow_director_flex_payload");
10276 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10277 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10279 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10281 payload_layer, "raw#l2#l3#l4");
10282 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10284 payload_cfg, NULL);
10286 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10287 .f = cmd_flow_director_flxpld_parsed,
10289 .help_str = "flow_director_flexpayload ... : "
10290 "Set flow director's flex payload on NIC",
10292 (void *)&cmd_flow_director_flexpayload,
10293 (void *)&cmd_flow_director_flexpayload_port_id,
10294 (void *)&cmd_flow_director_flexpayload_payload_layer,
10295 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10300 /* Generic flow interface command. */
10301 extern cmdline_parse_inst_t cmd_flow;
10303 /* *** Classification Filters Control *** */
10304 /* *** Get symmetric hash enable per port *** */
10305 struct cmd_get_sym_hash_ena_per_port_result {
10306 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10311 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10312 __rte_unused struct cmdline *cl,
10313 __rte_unused void *data)
10315 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10316 struct rte_eth_hash_filter_info info;
10319 if (rte_eth_dev_filter_supported(res->port_id,
10320 RTE_ETH_FILTER_HASH) < 0) {
10321 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10326 memset(&info, 0, sizeof(info));
10327 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10328 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10329 RTE_ETH_FILTER_GET, &info);
10332 printf("Cannot get symmetric hash enable per port "
10333 "on port %u\n", res->port_id);
10337 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10338 "enabled" : "disabled", res->port_id);
10341 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10342 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10343 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10344 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10345 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10348 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10349 .f = cmd_get_sym_hash_per_port_parsed,
10351 .help_str = "get_sym_hash_ena_per_port <port_id>",
10353 (void *)&cmd_get_sym_hash_ena_per_port_all,
10354 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10359 /* *** Set symmetric hash enable per port *** */
10360 struct cmd_set_sym_hash_ena_per_port_result {
10361 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10362 cmdline_fixed_string_t enable;
10367 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10368 __rte_unused struct cmdline *cl,
10369 __rte_unused void *data)
10371 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10372 struct rte_eth_hash_filter_info info;
10375 if (rte_eth_dev_filter_supported(res->port_id,
10376 RTE_ETH_FILTER_HASH) < 0) {
10377 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10382 memset(&info, 0, sizeof(info));
10383 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10384 if (!strcmp(res->enable, "enable"))
10385 info.info.enable = 1;
10386 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10387 RTE_ETH_FILTER_SET, &info);
10389 printf("Cannot set symmetric hash enable per port on "
10390 "port %u\n", res->port_id);
10393 printf("Symmetric hash has been set to %s on port %u\n",
10394 res->enable, res->port_id);
10397 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10398 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10399 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10400 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10401 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10403 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10404 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10405 enable, "enable#disable");
10407 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10408 .f = cmd_set_sym_hash_per_port_parsed,
10410 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10412 (void *)&cmd_set_sym_hash_ena_per_port_all,
10413 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10414 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10419 /* Get global config of hash function */
10420 struct cmd_get_hash_global_config_result {
10421 cmdline_fixed_string_t get_hash_global_config;
10426 flowtype_to_str(uint16_t ftype)
10432 } ftype_table[] = {
10433 {"ipv4", RTE_ETH_FLOW_IPV4},
10434 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10435 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10436 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10437 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10438 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10439 {"ipv6", RTE_ETH_FLOW_IPV6},
10440 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10441 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10442 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10443 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10444 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10445 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10446 {"port", RTE_ETH_FLOW_PORT},
10447 {"vxlan", RTE_ETH_FLOW_VXLAN},
10448 {"geneve", RTE_ETH_FLOW_GENEVE},
10449 {"nvgre", RTE_ETH_FLOW_NVGRE},
10452 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10453 if (ftype_table[i].ftype == ftype)
10454 return ftype_table[i].str;
10461 cmd_get_hash_global_config_parsed(void *parsed_result,
10462 __rte_unused struct cmdline *cl,
10463 __rte_unused void *data)
10465 struct cmd_get_hash_global_config_result *res = parsed_result;
10466 struct rte_eth_hash_filter_info info;
10467 uint32_t idx, offset;
10472 if (rte_eth_dev_filter_supported(res->port_id,
10473 RTE_ETH_FILTER_HASH) < 0) {
10474 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10479 memset(&info, 0, sizeof(info));
10480 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10481 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10482 RTE_ETH_FILTER_GET, &info);
10484 printf("Cannot get hash global configurations by port %d\n",
10489 switch (info.info.global_conf.hash_func) {
10490 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10491 printf("Hash function is Toeplitz\n");
10493 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10494 printf("Hash function is Simple XOR\n");
10497 printf("Unknown hash function\n");
10501 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10502 idx = i / UINT32_BIT;
10503 offset = i % UINT32_BIT;
10504 if (!(info.info.global_conf.valid_bit_mask[idx] &
10507 str = flowtype_to_str(i);
10510 printf("Symmetric hash is %s globally for flow type %s "
10512 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10513 (1UL << offset)) ? "enabled" : "disabled"), str,
10518 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10519 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10520 get_hash_global_config, "get_hash_global_config");
10521 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10522 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10525 cmdline_parse_inst_t cmd_get_hash_global_config = {
10526 .f = cmd_get_hash_global_config_parsed,
10528 .help_str = "get_hash_global_config <port_id>",
10530 (void *)&cmd_get_hash_global_config_all,
10531 (void *)&cmd_get_hash_global_config_port_id,
10536 /* Set global config of hash function */
10537 struct cmd_set_hash_global_config_result {
10538 cmdline_fixed_string_t set_hash_global_config;
10540 cmdline_fixed_string_t hash_func;
10541 cmdline_fixed_string_t flow_type;
10542 cmdline_fixed_string_t enable;
10546 cmd_set_hash_global_config_parsed(void *parsed_result,
10547 __rte_unused struct cmdline *cl,
10548 __rte_unused void *data)
10550 struct cmd_set_hash_global_config_result *res = parsed_result;
10551 struct rte_eth_hash_filter_info info;
10552 uint32_t ftype, idx, offset;
10555 if (rte_eth_dev_filter_supported(res->port_id,
10556 RTE_ETH_FILTER_HASH) < 0) {
10557 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10561 memset(&info, 0, sizeof(info));
10562 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10563 if (!strcmp(res->hash_func, "toeplitz"))
10564 info.info.global_conf.hash_func =
10565 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10566 else if (!strcmp(res->hash_func, "simple_xor"))
10567 info.info.global_conf.hash_func =
10568 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10569 else if (!strcmp(res->hash_func, "default"))
10570 info.info.global_conf.hash_func =
10571 RTE_ETH_HASH_FUNCTION_DEFAULT;
10573 ftype = str2flowtype(res->flow_type);
10574 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10575 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10576 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10577 if (!strcmp(res->enable, "enable"))
10578 info.info.global_conf.sym_hash_enable_mask[idx] |=
10580 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10581 RTE_ETH_FILTER_SET, &info);
10583 printf("Cannot set global hash configurations by port %d\n",
10586 printf("Global hash configurations have been set "
10587 "succcessfully by port %d\n", res->port_id);
10590 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10591 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10592 set_hash_global_config, "set_hash_global_config");
10593 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10594 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10596 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10597 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10598 hash_func, "toeplitz#simple_xor#default");
10599 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10600 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10602 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10603 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10604 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10605 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10606 enable, "enable#disable");
10608 cmdline_parse_inst_t cmd_set_hash_global_config = {
10609 .f = cmd_set_hash_global_config_parsed,
10611 .help_str = "set_hash_global_config <port_id> "
10612 "toeplitz|simple_xor|default "
10613 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10614 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10615 "l2_payload enable|disable",
10617 (void *)&cmd_set_hash_global_config_all,
10618 (void *)&cmd_set_hash_global_config_port_id,
10619 (void *)&cmd_set_hash_global_config_hash_func,
10620 (void *)&cmd_set_hash_global_config_flow_type,
10621 (void *)&cmd_set_hash_global_config_enable,
10626 /* Set hash input set */
10627 struct cmd_set_hash_input_set_result {
10628 cmdline_fixed_string_t set_hash_input_set;
10630 cmdline_fixed_string_t flow_type;
10631 cmdline_fixed_string_t inset_field;
10632 cmdline_fixed_string_t select;
10635 static enum rte_eth_input_set_field
10636 str2inset(char *string)
10640 static const struct {
10642 enum rte_eth_input_set_field inset;
10643 } inset_table[] = {
10644 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10645 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10646 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10647 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10648 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10649 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10650 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10651 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10652 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10653 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10654 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10655 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10656 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10657 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10658 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10659 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10660 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10661 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10662 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10663 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10664 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10665 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10666 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10667 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10668 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10669 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10670 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10671 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10672 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10673 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10674 {"none", RTE_ETH_INPUT_SET_NONE},
10677 for (i = 0; i < RTE_DIM(inset_table); i++) {
10678 if (!strcmp(string, inset_table[i].str))
10679 return inset_table[i].inset;
10682 return RTE_ETH_INPUT_SET_UNKNOWN;
10686 cmd_set_hash_input_set_parsed(void *parsed_result,
10687 __rte_unused struct cmdline *cl,
10688 __rte_unused void *data)
10690 struct cmd_set_hash_input_set_result *res = parsed_result;
10691 struct rte_eth_hash_filter_info info;
10693 memset(&info, 0, sizeof(info));
10694 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10695 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10696 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10697 info.info.input_set_conf.inset_size = 1;
10698 if (!strcmp(res->select, "select"))
10699 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10700 else if (!strcmp(res->select, "add"))
10701 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10702 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10703 RTE_ETH_FILTER_SET, &info);
10706 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10707 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10708 set_hash_input_set, "set_hash_input_set");
10709 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10710 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10712 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10713 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10715 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10716 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10718 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10719 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10720 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10721 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10722 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10724 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10725 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10726 select, "select#add");
10728 cmdline_parse_inst_t cmd_set_hash_input_set = {
10729 .f = cmd_set_hash_input_set_parsed,
10731 .help_str = "set_hash_input_set <port_id> "
10732 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10733 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
10734 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10735 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10736 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10737 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10738 "fld-7th|fld-8th|none select|add",
10740 (void *)&cmd_set_hash_input_set_cmd,
10741 (void *)&cmd_set_hash_input_set_port_id,
10742 (void *)&cmd_set_hash_input_set_flow_type,
10743 (void *)&cmd_set_hash_input_set_field,
10744 (void *)&cmd_set_hash_input_set_select,
10749 /* Set flow director input set */
10750 struct cmd_set_fdir_input_set_result {
10751 cmdline_fixed_string_t set_fdir_input_set;
10753 cmdline_fixed_string_t flow_type;
10754 cmdline_fixed_string_t inset_field;
10755 cmdline_fixed_string_t select;
10759 cmd_set_fdir_input_set_parsed(void *parsed_result,
10760 __rte_unused struct cmdline *cl,
10761 __rte_unused void *data)
10763 struct cmd_set_fdir_input_set_result *res = parsed_result;
10764 struct rte_eth_fdir_filter_info info;
10766 memset(&info, 0, sizeof(info));
10767 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10768 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10769 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10770 info.info.input_set_conf.inset_size = 1;
10771 if (!strcmp(res->select, "select"))
10772 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10773 else if (!strcmp(res->select, "add"))
10774 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10775 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10776 RTE_ETH_FILTER_SET, &info);
10779 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10780 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10781 set_fdir_input_set, "set_fdir_input_set");
10782 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10783 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10785 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10786 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10788 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10789 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10790 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10791 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10793 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10794 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10795 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10796 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10797 "sctp-veri-tag#none");
10798 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10799 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10800 select, "select#add");
10802 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10803 .f = cmd_set_fdir_input_set_parsed,
10805 .help_str = "set_fdir_input_set <port_id> "
10806 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10807 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10808 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10809 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10810 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10811 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10812 "sctp-veri-tag|none select|add",
10814 (void *)&cmd_set_fdir_input_set_cmd,
10815 (void *)&cmd_set_fdir_input_set_port_id,
10816 (void *)&cmd_set_fdir_input_set_flow_type,
10817 (void *)&cmd_set_fdir_input_set_field,
10818 (void *)&cmd_set_fdir_input_set_select,
10823 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10824 struct cmd_mcast_addr_result {
10825 cmdline_fixed_string_t mcast_addr_cmd;
10826 cmdline_fixed_string_t what;
10828 struct ether_addr mc_addr;
10831 static void cmd_mcast_addr_parsed(void *parsed_result,
10832 __attribute__((unused)) struct cmdline *cl,
10833 __attribute__((unused)) void *data)
10835 struct cmd_mcast_addr_result *res = parsed_result;
10837 if (!is_multicast_ether_addr(&res->mc_addr)) {
10838 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10839 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10840 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10841 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10844 if (strcmp(res->what, "add") == 0)
10845 mcast_addr_add(res->port_num, &res->mc_addr);
10847 mcast_addr_remove(res->port_num, &res->mc_addr);
10850 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10851 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10852 mcast_addr_cmd, "mcast_addr");
10853 cmdline_parse_token_string_t cmd_mcast_addr_what =
10854 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10856 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10857 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10858 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10859 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10861 cmdline_parse_inst_t cmd_mcast_addr = {
10862 .f = cmd_mcast_addr_parsed,
10864 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10865 "Add/Remove multicast MAC address on port_id",
10867 (void *)&cmd_mcast_addr_cmd,
10868 (void *)&cmd_mcast_addr_what,
10869 (void *)&cmd_mcast_addr_portnum,
10870 (void *)&cmd_mcast_addr_addr,
10875 /* l2 tunnel config
10876 * only support E-tag now.
10879 /* Ether type config */
10880 struct cmd_config_l2_tunnel_eth_type_result {
10881 cmdline_fixed_string_t port;
10882 cmdline_fixed_string_t config;
10883 cmdline_fixed_string_t all;
10885 cmdline_fixed_string_t l2_tunnel;
10886 cmdline_fixed_string_t l2_tunnel_type;
10887 cmdline_fixed_string_t eth_type;
10888 uint16_t eth_type_val;
10891 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10892 TOKEN_STRING_INITIALIZER
10893 (struct cmd_config_l2_tunnel_eth_type_result,
10895 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10896 TOKEN_STRING_INITIALIZER
10897 (struct cmd_config_l2_tunnel_eth_type_result,
10899 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10900 TOKEN_STRING_INITIALIZER
10901 (struct cmd_config_l2_tunnel_eth_type_result,
10903 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10904 TOKEN_NUM_INITIALIZER
10905 (struct cmd_config_l2_tunnel_eth_type_result,
10907 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10908 TOKEN_STRING_INITIALIZER
10909 (struct cmd_config_l2_tunnel_eth_type_result,
10910 l2_tunnel, "l2-tunnel");
10911 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10912 TOKEN_STRING_INITIALIZER
10913 (struct cmd_config_l2_tunnel_eth_type_result,
10914 l2_tunnel_type, "E-tag");
10915 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10916 TOKEN_STRING_INITIALIZER
10917 (struct cmd_config_l2_tunnel_eth_type_result,
10918 eth_type, "ether-type");
10919 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10920 TOKEN_NUM_INITIALIZER
10921 (struct cmd_config_l2_tunnel_eth_type_result,
10922 eth_type_val, UINT16);
10924 static enum rte_eth_tunnel_type
10925 str2fdir_l2_tunnel_type(char *string)
10929 static const struct {
10931 enum rte_eth_tunnel_type type;
10932 } l2_tunnel_type_str[] = {
10933 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10936 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10937 if (!strcmp(l2_tunnel_type_str[i].str, string))
10938 return l2_tunnel_type_str[i].type;
10940 return RTE_TUNNEL_TYPE_NONE;
10943 /* ether type config for all ports */
10945 cmd_config_l2_tunnel_eth_type_all_parsed
10946 (void *parsed_result,
10947 __attribute__((unused)) struct cmdline *cl,
10948 __attribute__((unused)) void *data)
10950 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10951 struct rte_eth_l2_tunnel_conf entry;
10954 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10955 entry.ether_type = res->eth_type_val;
10957 RTE_ETH_FOREACH_DEV(pid) {
10958 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10962 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10963 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10965 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10967 (void *)&cmd_config_l2_tunnel_eth_type_port,
10968 (void *)&cmd_config_l2_tunnel_eth_type_config,
10969 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10970 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10971 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10972 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10973 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10978 /* ether type config for a specific port */
10980 cmd_config_l2_tunnel_eth_type_specific_parsed(
10981 void *parsed_result,
10982 __attribute__((unused)) struct cmdline *cl,
10983 __attribute__((unused)) void *data)
10985 struct cmd_config_l2_tunnel_eth_type_result *res =
10987 struct rte_eth_l2_tunnel_conf entry;
10989 if (port_id_is_invalid(res->id, ENABLED_WARN))
10992 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10993 entry.ether_type = res->eth_type_val;
10995 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10998 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10999 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11001 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11003 (void *)&cmd_config_l2_tunnel_eth_type_port,
11004 (void *)&cmd_config_l2_tunnel_eth_type_config,
11005 (void *)&cmd_config_l2_tunnel_eth_type_id,
11006 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11007 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11008 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11009 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11014 /* Enable/disable l2 tunnel */
11015 struct cmd_config_l2_tunnel_en_dis_result {
11016 cmdline_fixed_string_t port;
11017 cmdline_fixed_string_t config;
11018 cmdline_fixed_string_t all;
11020 cmdline_fixed_string_t l2_tunnel;
11021 cmdline_fixed_string_t l2_tunnel_type;
11022 cmdline_fixed_string_t en_dis;
11025 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11026 TOKEN_STRING_INITIALIZER
11027 (struct cmd_config_l2_tunnel_en_dis_result,
11029 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11030 TOKEN_STRING_INITIALIZER
11031 (struct cmd_config_l2_tunnel_en_dis_result,
11033 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11034 TOKEN_STRING_INITIALIZER
11035 (struct cmd_config_l2_tunnel_en_dis_result,
11037 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11038 TOKEN_NUM_INITIALIZER
11039 (struct cmd_config_l2_tunnel_en_dis_result,
11041 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11042 TOKEN_STRING_INITIALIZER
11043 (struct cmd_config_l2_tunnel_en_dis_result,
11044 l2_tunnel, "l2-tunnel");
11045 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11046 TOKEN_STRING_INITIALIZER
11047 (struct cmd_config_l2_tunnel_en_dis_result,
11048 l2_tunnel_type, "E-tag");
11049 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11050 TOKEN_STRING_INITIALIZER
11051 (struct cmd_config_l2_tunnel_en_dis_result,
11052 en_dis, "enable#disable");
11054 /* enable/disable l2 tunnel for all ports */
11056 cmd_config_l2_tunnel_en_dis_all_parsed(
11057 void *parsed_result,
11058 __attribute__((unused)) struct cmdline *cl,
11059 __attribute__((unused)) void *data)
11061 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11062 struct rte_eth_l2_tunnel_conf entry;
11066 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11068 if (!strcmp("enable", res->en_dis))
11073 RTE_ETH_FOREACH_DEV(pid) {
11074 rte_eth_dev_l2_tunnel_offload_set(pid,
11076 ETH_L2_TUNNEL_ENABLE_MASK,
11081 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11082 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11084 .help_str = "port config all l2-tunnel E-tag enable|disable",
11086 (void *)&cmd_config_l2_tunnel_en_dis_port,
11087 (void *)&cmd_config_l2_tunnel_en_dis_config,
11088 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11089 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11090 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11091 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11096 /* enable/disable l2 tunnel for a port */
11098 cmd_config_l2_tunnel_en_dis_specific_parsed(
11099 void *parsed_result,
11100 __attribute__((unused)) struct cmdline *cl,
11101 __attribute__((unused)) void *data)
11103 struct cmd_config_l2_tunnel_en_dis_result *res =
11105 struct rte_eth_l2_tunnel_conf entry;
11107 if (port_id_is_invalid(res->id, ENABLED_WARN))
11110 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11112 if (!strcmp("enable", res->en_dis))
11113 rte_eth_dev_l2_tunnel_offload_set(res->id,
11115 ETH_L2_TUNNEL_ENABLE_MASK,
11118 rte_eth_dev_l2_tunnel_offload_set(res->id,
11120 ETH_L2_TUNNEL_ENABLE_MASK,
11124 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11125 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11127 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11129 (void *)&cmd_config_l2_tunnel_en_dis_port,
11130 (void *)&cmd_config_l2_tunnel_en_dis_config,
11131 (void *)&cmd_config_l2_tunnel_en_dis_id,
11132 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11133 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11134 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11139 /* E-tag configuration */
11141 /* Common result structure for all E-tag configuration */
11142 struct cmd_config_e_tag_result {
11143 cmdline_fixed_string_t e_tag;
11144 cmdline_fixed_string_t set;
11145 cmdline_fixed_string_t insertion;
11146 cmdline_fixed_string_t stripping;
11147 cmdline_fixed_string_t forwarding;
11148 cmdline_fixed_string_t filter;
11149 cmdline_fixed_string_t add;
11150 cmdline_fixed_string_t del;
11151 cmdline_fixed_string_t on;
11152 cmdline_fixed_string_t off;
11153 cmdline_fixed_string_t on_off;
11154 cmdline_fixed_string_t port_tag_id;
11155 uint32_t port_tag_id_val;
11156 cmdline_fixed_string_t e_tag_id;
11157 uint16_t e_tag_id_val;
11158 cmdline_fixed_string_t dst_pool;
11159 uint8_t dst_pool_val;
11160 cmdline_fixed_string_t port;
11162 cmdline_fixed_string_t vf;
11166 /* Common CLI fields for all E-tag configuration */
11167 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11168 TOKEN_STRING_INITIALIZER
11169 (struct cmd_config_e_tag_result,
11171 cmdline_parse_token_string_t cmd_config_e_tag_set =
11172 TOKEN_STRING_INITIALIZER
11173 (struct cmd_config_e_tag_result,
11175 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11176 TOKEN_STRING_INITIALIZER
11177 (struct cmd_config_e_tag_result,
11178 insertion, "insertion");
11179 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11180 TOKEN_STRING_INITIALIZER
11181 (struct cmd_config_e_tag_result,
11182 stripping, "stripping");
11183 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11184 TOKEN_STRING_INITIALIZER
11185 (struct cmd_config_e_tag_result,
11186 forwarding, "forwarding");
11187 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11188 TOKEN_STRING_INITIALIZER
11189 (struct cmd_config_e_tag_result,
11191 cmdline_parse_token_string_t cmd_config_e_tag_add =
11192 TOKEN_STRING_INITIALIZER
11193 (struct cmd_config_e_tag_result,
11195 cmdline_parse_token_string_t cmd_config_e_tag_del =
11196 TOKEN_STRING_INITIALIZER
11197 (struct cmd_config_e_tag_result,
11199 cmdline_parse_token_string_t cmd_config_e_tag_on =
11200 TOKEN_STRING_INITIALIZER
11201 (struct cmd_config_e_tag_result,
11203 cmdline_parse_token_string_t cmd_config_e_tag_off =
11204 TOKEN_STRING_INITIALIZER
11205 (struct cmd_config_e_tag_result,
11207 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11208 TOKEN_STRING_INITIALIZER
11209 (struct cmd_config_e_tag_result,
11211 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11212 TOKEN_STRING_INITIALIZER
11213 (struct cmd_config_e_tag_result,
11214 port_tag_id, "port-tag-id");
11215 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11216 TOKEN_NUM_INITIALIZER
11217 (struct cmd_config_e_tag_result,
11218 port_tag_id_val, UINT32);
11219 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11220 TOKEN_STRING_INITIALIZER
11221 (struct cmd_config_e_tag_result,
11222 e_tag_id, "e-tag-id");
11223 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11224 TOKEN_NUM_INITIALIZER
11225 (struct cmd_config_e_tag_result,
11226 e_tag_id_val, UINT16);
11227 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11228 TOKEN_STRING_INITIALIZER
11229 (struct cmd_config_e_tag_result,
11230 dst_pool, "dst-pool");
11231 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11232 TOKEN_NUM_INITIALIZER
11233 (struct cmd_config_e_tag_result,
11234 dst_pool_val, UINT8);
11235 cmdline_parse_token_string_t cmd_config_e_tag_port =
11236 TOKEN_STRING_INITIALIZER
11237 (struct cmd_config_e_tag_result,
11239 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11240 TOKEN_NUM_INITIALIZER
11241 (struct cmd_config_e_tag_result,
11243 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11244 TOKEN_STRING_INITIALIZER
11245 (struct cmd_config_e_tag_result,
11247 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11248 TOKEN_NUM_INITIALIZER
11249 (struct cmd_config_e_tag_result,
11252 /* E-tag insertion configuration */
11254 cmd_config_e_tag_insertion_en_parsed(
11255 void *parsed_result,
11256 __attribute__((unused)) struct cmdline *cl,
11257 __attribute__((unused)) void *data)
11259 struct cmd_config_e_tag_result *res =
11261 struct rte_eth_l2_tunnel_conf entry;
11263 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11266 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11267 entry.tunnel_id = res->port_tag_id_val;
11268 entry.vf_id = res->vf_id;
11269 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11271 ETH_L2_TUNNEL_INSERTION_MASK,
11276 cmd_config_e_tag_insertion_dis_parsed(
11277 void *parsed_result,
11278 __attribute__((unused)) struct cmdline *cl,
11279 __attribute__((unused)) void *data)
11281 struct cmd_config_e_tag_result *res =
11283 struct rte_eth_l2_tunnel_conf entry;
11285 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11288 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11289 entry.vf_id = res->vf_id;
11291 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11293 ETH_L2_TUNNEL_INSERTION_MASK,
11297 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11298 .f = cmd_config_e_tag_insertion_en_parsed,
11300 .help_str = "E-tag ... : E-tag insertion enable",
11302 (void *)&cmd_config_e_tag_e_tag,
11303 (void *)&cmd_config_e_tag_set,
11304 (void *)&cmd_config_e_tag_insertion,
11305 (void *)&cmd_config_e_tag_on,
11306 (void *)&cmd_config_e_tag_port_tag_id,
11307 (void *)&cmd_config_e_tag_port_tag_id_val,
11308 (void *)&cmd_config_e_tag_port,
11309 (void *)&cmd_config_e_tag_port_id,
11310 (void *)&cmd_config_e_tag_vf,
11311 (void *)&cmd_config_e_tag_vf_id,
11316 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11317 .f = cmd_config_e_tag_insertion_dis_parsed,
11319 .help_str = "E-tag ... : E-tag insertion disable",
11321 (void *)&cmd_config_e_tag_e_tag,
11322 (void *)&cmd_config_e_tag_set,
11323 (void *)&cmd_config_e_tag_insertion,
11324 (void *)&cmd_config_e_tag_off,
11325 (void *)&cmd_config_e_tag_port,
11326 (void *)&cmd_config_e_tag_port_id,
11327 (void *)&cmd_config_e_tag_vf,
11328 (void *)&cmd_config_e_tag_vf_id,
11333 /* E-tag stripping configuration */
11335 cmd_config_e_tag_stripping_parsed(
11336 void *parsed_result,
11337 __attribute__((unused)) struct cmdline *cl,
11338 __attribute__((unused)) void *data)
11340 struct cmd_config_e_tag_result *res =
11342 struct rte_eth_l2_tunnel_conf entry;
11344 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11347 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11349 if (!strcmp(res->on_off, "on"))
11350 rte_eth_dev_l2_tunnel_offload_set
11353 ETH_L2_TUNNEL_STRIPPING_MASK,
11356 rte_eth_dev_l2_tunnel_offload_set
11359 ETH_L2_TUNNEL_STRIPPING_MASK,
11363 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11364 .f = cmd_config_e_tag_stripping_parsed,
11366 .help_str = "E-tag ... : E-tag stripping enable/disable",
11368 (void *)&cmd_config_e_tag_e_tag,
11369 (void *)&cmd_config_e_tag_set,
11370 (void *)&cmd_config_e_tag_stripping,
11371 (void *)&cmd_config_e_tag_on_off,
11372 (void *)&cmd_config_e_tag_port,
11373 (void *)&cmd_config_e_tag_port_id,
11378 /* E-tag forwarding configuration */
11380 cmd_config_e_tag_forwarding_parsed(
11381 void *parsed_result,
11382 __attribute__((unused)) struct cmdline *cl,
11383 __attribute__((unused)) void *data)
11385 struct cmd_config_e_tag_result *res = parsed_result;
11386 struct rte_eth_l2_tunnel_conf entry;
11388 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11391 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11393 if (!strcmp(res->on_off, "on"))
11394 rte_eth_dev_l2_tunnel_offload_set
11397 ETH_L2_TUNNEL_FORWARDING_MASK,
11400 rte_eth_dev_l2_tunnel_offload_set
11403 ETH_L2_TUNNEL_FORWARDING_MASK,
11407 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11408 .f = cmd_config_e_tag_forwarding_parsed,
11410 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11412 (void *)&cmd_config_e_tag_e_tag,
11413 (void *)&cmd_config_e_tag_set,
11414 (void *)&cmd_config_e_tag_forwarding,
11415 (void *)&cmd_config_e_tag_on_off,
11416 (void *)&cmd_config_e_tag_port,
11417 (void *)&cmd_config_e_tag_port_id,
11422 /* E-tag filter configuration */
11424 cmd_config_e_tag_filter_add_parsed(
11425 void *parsed_result,
11426 __attribute__((unused)) struct cmdline *cl,
11427 __attribute__((unused)) void *data)
11429 struct cmd_config_e_tag_result *res = parsed_result;
11430 struct rte_eth_l2_tunnel_conf entry;
11433 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11436 if (res->e_tag_id_val > 0x3fff) {
11437 printf("e-tag-id must be equal or less than 0x3fff.\n");
11441 ret = rte_eth_dev_filter_supported(res->port_id,
11442 RTE_ETH_FILTER_L2_TUNNEL);
11444 printf("E-tag filter is not supported on port %u.\n",
11449 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11450 entry.tunnel_id = res->e_tag_id_val;
11451 entry.pool = res->dst_pool_val;
11453 ret = rte_eth_dev_filter_ctrl(res->port_id,
11454 RTE_ETH_FILTER_L2_TUNNEL,
11455 RTE_ETH_FILTER_ADD,
11458 printf("E-tag filter programming error: (%s)\n",
11462 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11463 .f = cmd_config_e_tag_filter_add_parsed,
11465 .help_str = "E-tag ... : E-tag filter add",
11467 (void *)&cmd_config_e_tag_e_tag,
11468 (void *)&cmd_config_e_tag_set,
11469 (void *)&cmd_config_e_tag_filter,
11470 (void *)&cmd_config_e_tag_add,
11471 (void *)&cmd_config_e_tag_e_tag_id,
11472 (void *)&cmd_config_e_tag_e_tag_id_val,
11473 (void *)&cmd_config_e_tag_dst_pool,
11474 (void *)&cmd_config_e_tag_dst_pool_val,
11475 (void *)&cmd_config_e_tag_port,
11476 (void *)&cmd_config_e_tag_port_id,
11482 cmd_config_e_tag_filter_del_parsed(
11483 void *parsed_result,
11484 __attribute__((unused)) struct cmdline *cl,
11485 __attribute__((unused)) void *data)
11487 struct cmd_config_e_tag_result *res = parsed_result;
11488 struct rte_eth_l2_tunnel_conf entry;
11491 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11494 if (res->e_tag_id_val > 0x3fff) {
11495 printf("e-tag-id must be less than 0x3fff.\n");
11499 ret = rte_eth_dev_filter_supported(res->port_id,
11500 RTE_ETH_FILTER_L2_TUNNEL);
11502 printf("E-tag filter is not supported on port %u.\n",
11507 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11508 entry.tunnel_id = res->e_tag_id_val;
11510 ret = rte_eth_dev_filter_ctrl(res->port_id,
11511 RTE_ETH_FILTER_L2_TUNNEL,
11512 RTE_ETH_FILTER_DELETE,
11515 printf("E-tag filter programming error: (%s)\n",
11519 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11520 .f = cmd_config_e_tag_filter_del_parsed,
11522 .help_str = "E-tag ... : E-tag filter delete",
11524 (void *)&cmd_config_e_tag_e_tag,
11525 (void *)&cmd_config_e_tag_set,
11526 (void *)&cmd_config_e_tag_filter,
11527 (void *)&cmd_config_e_tag_del,
11528 (void *)&cmd_config_e_tag_e_tag_id,
11529 (void *)&cmd_config_e_tag_e_tag_id_val,
11530 (void *)&cmd_config_e_tag_port,
11531 (void *)&cmd_config_e_tag_port_id,
11536 /* vf vlan anti spoof configuration */
11538 /* Common result structure for vf vlan anti spoof */
11539 struct cmd_vf_vlan_anti_spoof_result {
11540 cmdline_fixed_string_t set;
11541 cmdline_fixed_string_t vf;
11542 cmdline_fixed_string_t vlan;
11543 cmdline_fixed_string_t antispoof;
11546 cmdline_fixed_string_t on_off;
11549 /* Common CLI fields for vf vlan anti spoof enable disable */
11550 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11551 TOKEN_STRING_INITIALIZER
11552 (struct cmd_vf_vlan_anti_spoof_result,
11554 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11555 TOKEN_STRING_INITIALIZER
11556 (struct cmd_vf_vlan_anti_spoof_result,
11558 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11559 TOKEN_STRING_INITIALIZER
11560 (struct cmd_vf_vlan_anti_spoof_result,
11562 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11563 TOKEN_STRING_INITIALIZER
11564 (struct cmd_vf_vlan_anti_spoof_result,
11565 antispoof, "antispoof");
11566 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11567 TOKEN_NUM_INITIALIZER
11568 (struct cmd_vf_vlan_anti_spoof_result,
11570 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11571 TOKEN_NUM_INITIALIZER
11572 (struct cmd_vf_vlan_anti_spoof_result,
11574 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11575 TOKEN_STRING_INITIALIZER
11576 (struct cmd_vf_vlan_anti_spoof_result,
11580 cmd_set_vf_vlan_anti_spoof_parsed(
11581 void *parsed_result,
11582 __attribute__((unused)) struct cmdline *cl,
11583 __attribute__((unused)) void *data)
11585 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11586 int ret = -ENOTSUP;
11588 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11593 #ifdef RTE_LIBRTE_IXGBE_PMD
11594 if (ret == -ENOTSUP)
11595 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11596 res->vf_id, is_on);
11598 #ifdef RTE_LIBRTE_I40E_PMD
11599 if (ret == -ENOTSUP)
11600 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11601 res->vf_id, is_on);
11603 #ifdef RTE_LIBRTE_BNXT_PMD
11604 if (ret == -ENOTSUP)
11605 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11606 res->vf_id, is_on);
11613 printf("invalid vf_id %d\n", res->vf_id);
11616 printf("invalid port_id %d\n", res->port_id);
11619 printf("function not implemented\n");
11622 printf("programming error: (%s)\n", strerror(-ret));
11626 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11627 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11629 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11631 (void *)&cmd_vf_vlan_anti_spoof_set,
11632 (void *)&cmd_vf_vlan_anti_spoof_vf,
11633 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11634 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11635 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11636 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11637 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11642 /* vf mac anti spoof configuration */
11644 /* Common result structure for vf mac anti spoof */
11645 struct cmd_vf_mac_anti_spoof_result {
11646 cmdline_fixed_string_t set;
11647 cmdline_fixed_string_t vf;
11648 cmdline_fixed_string_t mac;
11649 cmdline_fixed_string_t antispoof;
11652 cmdline_fixed_string_t on_off;
11655 /* Common CLI fields for vf mac anti spoof enable disable */
11656 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11657 TOKEN_STRING_INITIALIZER
11658 (struct cmd_vf_mac_anti_spoof_result,
11660 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11661 TOKEN_STRING_INITIALIZER
11662 (struct cmd_vf_mac_anti_spoof_result,
11664 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11665 TOKEN_STRING_INITIALIZER
11666 (struct cmd_vf_mac_anti_spoof_result,
11668 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11669 TOKEN_STRING_INITIALIZER
11670 (struct cmd_vf_mac_anti_spoof_result,
11671 antispoof, "antispoof");
11672 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11673 TOKEN_NUM_INITIALIZER
11674 (struct cmd_vf_mac_anti_spoof_result,
11676 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11677 TOKEN_NUM_INITIALIZER
11678 (struct cmd_vf_mac_anti_spoof_result,
11680 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11681 TOKEN_STRING_INITIALIZER
11682 (struct cmd_vf_mac_anti_spoof_result,
11686 cmd_set_vf_mac_anti_spoof_parsed(
11687 void *parsed_result,
11688 __attribute__((unused)) struct cmdline *cl,
11689 __attribute__((unused)) void *data)
11691 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11692 int ret = -ENOTSUP;
11694 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11696 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11699 #ifdef RTE_LIBRTE_IXGBE_PMD
11700 if (ret == -ENOTSUP)
11701 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11702 res->vf_id, is_on);
11704 #ifdef RTE_LIBRTE_I40E_PMD
11705 if (ret == -ENOTSUP)
11706 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11707 res->vf_id, is_on);
11709 #ifdef RTE_LIBRTE_BNXT_PMD
11710 if (ret == -ENOTSUP)
11711 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11712 res->vf_id, is_on);
11719 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11722 printf("invalid port_id %d\n", res->port_id);
11725 printf("function not implemented\n");
11728 printf("programming error: (%s)\n", strerror(-ret));
11732 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11733 .f = cmd_set_vf_mac_anti_spoof_parsed,
11735 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11737 (void *)&cmd_vf_mac_anti_spoof_set,
11738 (void *)&cmd_vf_mac_anti_spoof_vf,
11739 (void *)&cmd_vf_mac_anti_spoof_mac,
11740 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11741 (void *)&cmd_vf_mac_anti_spoof_port_id,
11742 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11743 (void *)&cmd_vf_mac_anti_spoof_on_off,
11748 /* vf vlan strip queue configuration */
11750 /* Common result structure for vf mac anti spoof */
11751 struct cmd_vf_vlan_stripq_result {
11752 cmdline_fixed_string_t set;
11753 cmdline_fixed_string_t vf;
11754 cmdline_fixed_string_t vlan;
11755 cmdline_fixed_string_t stripq;
11758 cmdline_fixed_string_t on_off;
11761 /* Common CLI fields for vf vlan strip enable disable */
11762 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11763 TOKEN_STRING_INITIALIZER
11764 (struct cmd_vf_vlan_stripq_result,
11766 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11767 TOKEN_STRING_INITIALIZER
11768 (struct cmd_vf_vlan_stripq_result,
11770 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11771 TOKEN_STRING_INITIALIZER
11772 (struct cmd_vf_vlan_stripq_result,
11774 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11775 TOKEN_STRING_INITIALIZER
11776 (struct cmd_vf_vlan_stripq_result,
11778 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11779 TOKEN_NUM_INITIALIZER
11780 (struct cmd_vf_vlan_stripq_result,
11782 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11783 TOKEN_NUM_INITIALIZER
11784 (struct cmd_vf_vlan_stripq_result,
11786 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11787 TOKEN_STRING_INITIALIZER
11788 (struct cmd_vf_vlan_stripq_result,
11792 cmd_set_vf_vlan_stripq_parsed(
11793 void *parsed_result,
11794 __attribute__((unused)) struct cmdline *cl,
11795 __attribute__((unused)) void *data)
11797 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11798 int ret = -ENOTSUP;
11800 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11802 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11805 #ifdef RTE_LIBRTE_IXGBE_PMD
11806 if (ret == -ENOTSUP)
11807 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11808 res->vf_id, is_on);
11810 #ifdef RTE_LIBRTE_I40E_PMD
11811 if (ret == -ENOTSUP)
11812 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11813 res->vf_id, is_on);
11815 #ifdef RTE_LIBRTE_BNXT_PMD
11816 if (ret == -ENOTSUP)
11817 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11818 res->vf_id, is_on);
11825 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11828 printf("invalid port_id %d\n", res->port_id);
11831 printf("function not implemented\n");
11834 printf("programming error: (%s)\n", strerror(-ret));
11838 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11839 .f = cmd_set_vf_vlan_stripq_parsed,
11841 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11843 (void *)&cmd_vf_vlan_stripq_set,
11844 (void *)&cmd_vf_vlan_stripq_vf,
11845 (void *)&cmd_vf_vlan_stripq_vlan,
11846 (void *)&cmd_vf_vlan_stripq_stripq,
11847 (void *)&cmd_vf_vlan_stripq_port_id,
11848 (void *)&cmd_vf_vlan_stripq_vf_id,
11849 (void *)&cmd_vf_vlan_stripq_on_off,
11854 /* vf vlan insert configuration */
11856 /* Common result structure for vf vlan insert */
11857 struct cmd_vf_vlan_insert_result {
11858 cmdline_fixed_string_t set;
11859 cmdline_fixed_string_t vf;
11860 cmdline_fixed_string_t vlan;
11861 cmdline_fixed_string_t insert;
11867 /* Common CLI fields for vf vlan insert enable disable */
11868 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11869 TOKEN_STRING_INITIALIZER
11870 (struct cmd_vf_vlan_insert_result,
11872 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11873 TOKEN_STRING_INITIALIZER
11874 (struct cmd_vf_vlan_insert_result,
11876 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11877 TOKEN_STRING_INITIALIZER
11878 (struct cmd_vf_vlan_insert_result,
11880 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11881 TOKEN_STRING_INITIALIZER
11882 (struct cmd_vf_vlan_insert_result,
11884 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11885 TOKEN_NUM_INITIALIZER
11886 (struct cmd_vf_vlan_insert_result,
11888 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11889 TOKEN_NUM_INITIALIZER
11890 (struct cmd_vf_vlan_insert_result,
11892 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11893 TOKEN_NUM_INITIALIZER
11894 (struct cmd_vf_vlan_insert_result,
11898 cmd_set_vf_vlan_insert_parsed(
11899 void *parsed_result,
11900 __attribute__((unused)) struct cmdline *cl,
11901 __attribute__((unused)) void *data)
11903 struct cmd_vf_vlan_insert_result *res = parsed_result;
11904 int ret = -ENOTSUP;
11906 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11909 #ifdef RTE_LIBRTE_IXGBE_PMD
11910 if (ret == -ENOTSUP)
11911 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11914 #ifdef RTE_LIBRTE_I40E_PMD
11915 if (ret == -ENOTSUP)
11916 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11919 #ifdef RTE_LIBRTE_BNXT_PMD
11920 if (ret == -ENOTSUP)
11921 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11929 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11932 printf("invalid port_id %d\n", res->port_id);
11935 printf("function not implemented\n");
11938 printf("programming error: (%s)\n", strerror(-ret));
11942 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11943 .f = cmd_set_vf_vlan_insert_parsed,
11945 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11947 (void *)&cmd_vf_vlan_insert_set,
11948 (void *)&cmd_vf_vlan_insert_vf,
11949 (void *)&cmd_vf_vlan_insert_vlan,
11950 (void *)&cmd_vf_vlan_insert_insert,
11951 (void *)&cmd_vf_vlan_insert_port_id,
11952 (void *)&cmd_vf_vlan_insert_vf_id,
11953 (void *)&cmd_vf_vlan_insert_vlan_id,
11958 /* tx loopback configuration */
11960 /* Common result structure for tx loopback */
11961 struct cmd_tx_loopback_result {
11962 cmdline_fixed_string_t set;
11963 cmdline_fixed_string_t tx;
11964 cmdline_fixed_string_t loopback;
11966 cmdline_fixed_string_t on_off;
11969 /* Common CLI fields for tx loopback enable disable */
11970 cmdline_parse_token_string_t cmd_tx_loopback_set =
11971 TOKEN_STRING_INITIALIZER
11972 (struct cmd_tx_loopback_result,
11974 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11975 TOKEN_STRING_INITIALIZER
11976 (struct cmd_tx_loopback_result,
11978 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11979 TOKEN_STRING_INITIALIZER
11980 (struct cmd_tx_loopback_result,
11981 loopback, "loopback");
11982 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11983 TOKEN_NUM_INITIALIZER
11984 (struct cmd_tx_loopback_result,
11986 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11987 TOKEN_STRING_INITIALIZER
11988 (struct cmd_tx_loopback_result,
11992 cmd_set_tx_loopback_parsed(
11993 void *parsed_result,
11994 __attribute__((unused)) struct cmdline *cl,
11995 __attribute__((unused)) void *data)
11997 struct cmd_tx_loopback_result *res = parsed_result;
11998 int ret = -ENOTSUP;
12000 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12005 #ifdef RTE_LIBRTE_IXGBE_PMD
12006 if (ret == -ENOTSUP)
12007 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12009 #ifdef RTE_LIBRTE_I40E_PMD
12010 if (ret == -ENOTSUP)
12011 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12013 #ifdef RTE_LIBRTE_BNXT_PMD
12014 if (ret == -ENOTSUP)
12015 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12022 printf("invalid is_on %d\n", is_on);
12025 printf("invalid port_id %d\n", res->port_id);
12028 printf("function not implemented\n");
12031 printf("programming error: (%s)\n", strerror(-ret));
12035 cmdline_parse_inst_t cmd_set_tx_loopback = {
12036 .f = cmd_set_tx_loopback_parsed,
12038 .help_str = "set tx loopback <port_id> on|off",
12040 (void *)&cmd_tx_loopback_set,
12041 (void *)&cmd_tx_loopback_tx,
12042 (void *)&cmd_tx_loopback_loopback,
12043 (void *)&cmd_tx_loopback_port_id,
12044 (void *)&cmd_tx_loopback_on_off,
12049 /* all queues drop enable configuration */
12051 /* Common result structure for all queues drop enable */
12052 struct cmd_all_queues_drop_en_result {
12053 cmdline_fixed_string_t set;
12054 cmdline_fixed_string_t all;
12055 cmdline_fixed_string_t queues;
12056 cmdline_fixed_string_t drop;
12058 cmdline_fixed_string_t on_off;
12061 /* Common CLI fields for tx loopback enable disable */
12062 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12063 TOKEN_STRING_INITIALIZER
12064 (struct cmd_all_queues_drop_en_result,
12066 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12067 TOKEN_STRING_INITIALIZER
12068 (struct cmd_all_queues_drop_en_result,
12070 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12071 TOKEN_STRING_INITIALIZER
12072 (struct cmd_all_queues_drop_en_result,
12074 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12075 TOKEN_STRING_INITIALIZER
12076 (struct cmd_all_queues_drop_en_result,
12078 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12079 TOKEN_NUM_INITIALIZER
12080 (struct cmd_all_queues_drop_en_result,
12082 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12083 TOKEN_STRING_INITIALIZER
12084 (struct cmd_all_queues_drop_en_result,
12088 cmd_set_all_queues_drop_en_parsed(
12089 void *parsed_result,
12090 __attribute__((unused)) struct cmdline *cl,
12091 __attribute__((unused)) void *data)
12093 struct cmd_all_queues_drop_en_result *res = parsed_result;
12094 int ret = -ENOTSUP;
12095 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12097 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12100 #ifdef RTE_LIBRTE_IXGBE_PMD
12101 if (ret == -ENOTSUP)
12102 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12104 #ifdef RTE_LIBRTE_BNXT_PMD
12105 if (ret == -ENOTSUP)
12106 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12112 printf("invalid is_on %d\n", is_on);
12115 printf("invalid port_id %d\n", res->port_id);
12118 printf("function not implemented\n");
12121 printf("programming error: (%s)\n", strerror(-ret));
12125 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12126 .f = cmd_set_all_queues_drop_en_parsed,
12128 .help_str = "set all queues drop <port_id> on|off",
12130 (void *)&cmd_all_queues_drop_en_set,
12131 (void *)&cmd_all_queues_drop_en_all,
12132 (void *)&cmd_all_queues_drop_en_queues,
12133 (void *)&cmd_all_queues_drop_en_drop,
12134 (void *)&cmd_all_queues_drop_en_port_id,
12135 (void *)&cmd_all_queues_drop_en_on_off,
12140 /* vf split drop enable configuration */
12142 /* Common result structure for vf split drop enable */
12143 struct cmd_vf_split_drop_en_result {
12144 cmdline_fixed_string_t set;
12145 cmdline_fixed_string_t vf;
12146 cmdline_fixed_string_t split;
12147 cmdline_fixed_string_t drop;
12150 cmdline_fixed_string_t on_off;
12153 /* Common CLI fields for vf split drop enable disable */
12154 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12155 TOKEN_STRING_INITIALIZER
12156 (struct cmd_vf_split_drop_en_result,
12158 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12159 TOKEN_STRING_INITIALIZER
12160 (struct cmd_vf_split_drop_en_result,
12162 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12163 TOKEN_STRING_INITIALIZER
12164 (struct cmd_vf_split_drop_en_result,
12166 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12167 TOKEN_STRING_INITIALIZER
12168 (struct cmd_vf_split_drop_en_result,
12170 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12171 TOKEN_NUM_INITIALIZER
12172 (struct cmd_vf_split_drop_en_result,
12174 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12175 TOKEN_NUM_INITIALIZER
12176 (struct cmd_vf_split_drop_en_result,
12178 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12179 TOKEN_STRING_INITIALIZER
12180 (struct cmd_vf_split_drop_en_result,
12184 cmd_set_vf_split_drop_en_parsed(
12185 void *parsed_result,
12186 __attribute__((unused)) struct cmdline *cl,
12187 __attribute__((unused)) void *data)
12189 struct cmd_vf_split_drop_en_result *res = parsed_result;
12190 int ret = -ENOTSUP;
12191 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12193 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12196 #ifdef RTE_LIBRTE_IXGBE_PMD
12197 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12204 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12207 printf("invalid port_id %d\n", res->port_id);
12210 printf("not supported on port %d\n", res->port_id);
12213 printf("programming error: (%s)\n", strerror(-ret));
12217 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12218 .f = cmd_set_vf_split_drop_en_parsed,
12220 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12222 (void *)&cmd_vf_split_drop_en_set,
12223 (void *)&cmd_vf_split_drop_en_vf,
12224 (void *)&cmd_vf_split_drop_en_split,
12225 (void *)&cmd_vf_split_drop_en_drop,
12226 (void *)&cmd_vf_split_drop_en_port_id,
12227 (void *)&cmd_vf_split_drop_en_vf_id,
12228 (void *)&cmd_vf_split_drop_en_on_off,
12233 /* vf mac address configuration */
12235 /* Common result structure for vf mac address */
12236 struct cmd_set_vf_mac_addr_result {
12237 cmdline_fixed_string_t set;
12238 cmdline_fixed_string_t vf;
12239 cmdline_fixed_string_t mac;
12240 cmdline_fixed_string_t addr;
12243 struct ether_addr mac_addr;
12247 /* Common CLI fields for vf split drop enable disable */
12248 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12249 TOKEN_STRING_INITIALIZER
12250 (struct cmd_set_vf_mac_addr_result,
12252 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12253 TOKEN_STRING_INITIALIZER
12254 (struct cmd_set_vf_mac_addr_result,
12256 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12257 TOKEN_STRING_INITIALIZER
12258 (struct cmd_set_vf_mac_addr_result,
12260 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12261 TOKEN_STRING_INITIALIZER
12262 (struct cmd_set_vf_mac_addr_result,
12264 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12265 TOKEN_NUM_INITIALIZER
12266 (struct cmd_set_vf_mac_addr_result,
12268 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12269 TOKEN_NUM_INITIALIZER
12270 (struct cmd_set_vf_mac_addr_result,
12272 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12273 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12277 cmd_set_vf_mac_addr_parsed(
12278 void *parsed_result,
12279 __attribute__((unused)) struct cmdline *cl,
12280 __attribute__((unused)) void *data)
12282 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12283 int ret = -ENOTSUP;
12285 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12288 #ifdef RTE_LIBRTE_IXGBE_PMD
12289 if (ret == -ENOTSUP)
12290 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12293 #ifdef RTE_LIBRTE_I40E_PMD
12294 if (ret == -ENOTSUP)
12295 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12298 #ifdef RTE_LIBRTE_BNXT_PMD
12299 if (ret == -ENOTSUP)
12300 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12308 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12311 printf("invalid port_id %d\n", res->port_id);
12314 printf("function not implemented\n");
12317 printf("programming error: (%s)\n", strerror(-ret));
12321 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12322 .f = cmd_set_vf_mac_addr_parsed,
12324 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12326 (void *)&cmd_set_vf_mac_addr_set,
12327 (void *)&cmd_set_vf_mac_addr_vf,
12328 (void *)&cmd_set_vf_mac_addr_mac,
12329 (void *)&cmd_set_vf_mac_addr_addr,
12330 (void *)&cmd_set_vf_mac_addr_port_id,
12331 (void *)&cmd_set_vf_mac_addr_vf_id,
12332 (void *)&cmd_set_vf_mac_addr_mac_addr,
12337 /* MACsec configuration */
12339 /* Common result structure for MACsec offload enable */
12340 struct cmd_macsec_offload_on_result {
12341 cmdline_fixed_string_t set;
12342 cmdline_fixed_string_t macsec;
12343 cmdline_fixed_string_t offload;
12345 cmdline_fixed_string_t on;
12346 cmdline_fixed_string_t encrypt;
12347 cmdline_fixed_string_t en_on_off;
12348 cmdline_fixed_string_t replay_protect;
12349 cmdline_fixed_string_t rp_on_off;
12352 /* Common CLI fields for MACsec offload disable */
12353 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12354 TOKEN_STRING_INITIALIZER
12355 (struct cmd_macsec_offload_on_result,
12357 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12358 TOKEN_STRING_INITIALIZER
12359 (struct cmd_macsec_offload_on_result,
12361 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12362 TOKEN_STRING_INITIALIZER
12363 (struct cmd_macsec_offload_on_result,
12364 offload, "offload");
12365 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12366 TOKEN_NUM_INITIALIZER
12367 (struct cmd_macsec_offload_on_result,
12369 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12370 TOKEN_STRING_INITIALIZER
12371 (struct cmd_macsec_offload_on_result,
12373 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_macsec_offload_on_result,
12376 encrypt, "encrypt");
12377 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_macsec_offload_on_result,
12380 en_on_off, "on#off");
12381 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_macsec_offload_on_result,
12384 replay_protect, "replay-protect");
12385 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12386 TOKEN_STRING_INITIALIZER
12387 (struct cmd_macsec_offload_on_result,
12388 rp_on_off, "on#off");
12391 cmd_set_macsec_offload_on_parsed(
12392 void *parsed_result,
12393 __attribute__((unused)) struct cmdline *cl,
12394 __attribute__((unused)) void *data)
12396 struct cmd_macsec_offload_on_result *res = parsed_result;
12397 int ret = -ENOTSUP;
12398 portid_t port_id = res->port_id;
12399 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12400 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12402 if (port_id_is_invalid(port_id, ENABLED_WARN))
12405 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12406 #ifdef RTE_LIBRTE_IXGBE_PMD
12407 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12416 printf("invalid port_id %d\n", port_id);
12419 printf("not supported on port %d\n", port_id);
12422 printf("programming error: (%s)\n", strerror(-ret));
12426 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12427 .f = cmd_set_macsec_offload_on_parsed,
12429 .help_str = "set macsec offload <port_id> on "
12430 "encrypt on|off replay-protect on|off",
12432 (void *)&cmd_macsec_offload_on_set,
12433 (void *)&cmd_macsec_offload_on_macsec,
12434 (void *)&cmd_macsec_offload_on_offload,
12435 (void *)&cmd_macsec_offload_on_port_id,
12436 (void *)&cmd_macsec_offload_on_on,
12437 (void *)&cmd_macsec_offload_on_encrypt,
12438 (void *)&cmd_macsec_offload_on_en_on_off,
12439 (void *)&cmd_macsec_offload_on_replay_protect,
12440 (void *)&cmd_macsec_offload_on_rp_on_off,
12445 /* Common result structure for MACsec offload disable */
12446 struct cmd_macsec_offload_off_result {
12447 cmdline_fixed_string_t set;
12448 cmdline_fixed_string_t macsec;
12449 cmdline_fixed_string_t offload;
12451 cmdline_fixed_string_t off;
12454 /* Common CLI fields for MACsec offload disable */
12455 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12456 TOKEN_STRING_INITIALIZER
12457 (struct cmd_macsec_offload_off_result,
12459 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12460 TOKEN_STRING_INITIALIZER
12461 (struct cmd_macsec_offload_off_result,
12463 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12464 TOKEN_STRING_INITIALIZER
12465 (struct cmd_macsec_offload_off_result,
12466 offload, "offload");
12467 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12468 TOKEN_NUM_INITIALIZER
12469 (struct cmd_macsec_offload_off_result,
12471 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12472 TOKEN_STRING_INITIALIZER
12473 (struct cmd_macsec_offload_off_result,
12477 cmd_set_macsec_offload_off_parsed(
12478 void *parsed_result,
12479 __attribute__((unused)) struct cmdline *cl,
12480 __attribute__((unused)) void *data)
12482 struct cmd_macsec_offload_off_result *res = parsed_result;
12483 int ret = -ENOTSUP;
12484 portid_t port_id = res->port_id;
12486 if (port_id_is_invalid(port_id, ENABLED_WARN))
12489 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12490 #ifdef RTE_LIBRTE_IXGBE_PMD
12491 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12498 printf("invalid port_id %d\n", port_id);
12501 printf("not supported on port %d\n", port_id);
12504 printf("programming error: (%s)\n", strerror(-ret));
12508 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12509 .f = cmd_set_macsec_offload_off_parsed,
12511 .help_str = "set macsec offload <port_id> off",
12513 (void *)&cmd_macsec_offload_off_set,
12514 (void *)&cmd_macsec_offload_off_macsec,
12515 (void *)&cmd_macsec_offload_off_offload,
12516 (void *)&cmd_macsec_offload_off_port_id,
12517 (void *)&cmd_macsec_offload_off_off,
12522 /* Common result structure for MACsec secure connection configure */
12523 struct cmd_macsec_sc_result {
12524 cmdline_fixed_string_t set;
12525 cmdline_fixed_string_t macsec;
12526 cmdline_fixed_string_t sc;
12527 cmdline_fixed_string_t tx_rx;
12529 struct ether_addr mac;
12533 /* Common CLI fields for MACsec secure connection configure */
12534 cmdline_parse_token_string_t cmd_macsec_sc_set =
12535 TOKEN_STRING_INITIALIZER
12536 (struct cmd_macsec_sc_result,
12538 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12539 TOKEN_STRING_INITIALIZER
12540 (struct cmd_macsec_sc_result,
12542 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12543 TOKEN_STRING_INITIALIZER
12544 (struct cmd_macsec_sc_result,
12546 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12547 TOKEN_STRING_INITIALIZER
12548 (struct cmd_macsec_sc_result,
12550 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12551 TOKEN_NUM_INITIALIZER
12552 (struct cmd_macsec_sc_result,
12554 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12555 TOKEN_ETHERADDR_INITIALIZER
12556 (struct cmd_macsec_sc_result,
12558 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12559 TOKEN_NUM_INITIALIZER
12560 (struct cmd_macsec_sc_result,
12564 cmd_set_macsec_sc_parsed(
12565 void *parsed_result,
12566 __attribute__((unused)) struct cmdline *cl,
12567 __attribute__((unused)) void *data)
12569 struct cmd_macsec_sc_result *res = parsed_result;
12570 int ret = -ENOTSUP;
12571 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12573 #ifdef RTE_LIBRTE_IXGBE_PMD
12575 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12576 res->mac.addr_bytes) :
12577 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12578 res->mac.addr_bytes, res->pi);
12580 RTE_SET_USED(is_tx);
12586 printf("invalid port_id %d\n", res->port_id);
12589 printf("not supported on port %d\n", res->port_id);
12592 printf("programming error: (%s)\n", strerror(-ret));
12596 cmdline_parse_inst_t cmd_set_macsec_sc = {
12597 .f = cmd_set_macsec_sc_parsed,
12599 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12601 (void *)&cmd_macsec_sc_set,
12602 (void *)&cmd_macsec_sc_macsec,
12603 (void *)&cmd_macsec_sc_sc,
12604 (void *)&cmd_macsec_sc_tx_rx,
12605 (void *)&cmd_macsec_sc_port_id,
12606 (void *)&cmd_macsec_sc_mac,
12607 (void *)&cmd_macsec_sc_pi,
12612 /* Common result structure for MACsec secure connection configure */
12613 struct cmd_macsec_sa_result {
12614 cmdline_fixed_string_t set;
12615 cmdline_fixed_string_t macsec;
12616 cmdline_fixed_string_t sa;
12617 cmdline_fixed_string_t tx_rx;
12622 cmdline_fixed_string_t key;
12625 /* Common CLI fields for MACsec secure connection configure */
12626 cmdline_parse_token_string_t cmd_macsec_sa_set =
12627 TOKEN_STRING_INITIALIZER
12628 (struct cmd_macsec_sa_result,
12630 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12631 TOKEN_STRING_INITIALIZER
12632 (struct cmd_macsec_sa_result,
12634 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12635 TOKEN_STRING_INITIALIZER
12636 (struct cmd_macsec_sa_result,
12638 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12639 TOKEN_STRING_INITIALIZER
12640 (struct cmd_macsec_sa_result,
12642 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12643 TOKEN_NUM_INITIALIZER
12644 (struct cmd_macsec_sa_result,
12646 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12647 TOKEN_NUM_INITIALIZER
12648 (struct cmd_macsec_sa_result,
12650 cmdline_parse_token_num_t cmd_macsec_sa_an =
12651 TOKEN_NUM_INITIALIZER
12652 (struct cmd_macsec_sa_result,
12654 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12655 TOKEN_NUM_INITIALIZER
12656 (struct cmd_macsec_sa_result,
12658 cmdline_parse_token_string_t cmd_macsec_sa_key =
12659 TOKEN_STRING_INITIALIZER
12660 (struct cmd_macsec_sa_result,
12664 cmd_set_macsec_sa_parsed(
12665 void *parsed_result,
12666 __attribute__((unused)) struct cmdline *cl,
12667 __attribute__((unused)) void *data)
12669 struct cmd_macsec_sa_result *res = parsed_result;
12670 int ret = -ENOTSUP;
12671 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12672 uint8_t key[16] = { 0 };
12678 key_len = strlen(res->key) / 2;
12682 for (i = 0; i < key_len; i++) {
12683 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12686 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12689 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12692 #ifdef RTE_LIBRTE_IXGBE_PMD
12694 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12695 res->idx, res->an, res->pn, key) :
12696 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12697 res->idx, res->an, res->pn, key);
12699 RTE_SET_USED(is_tx);
12706 printf("invalid idx %d or an %d\n", res->idx, res->an);
12709 printf("invalid port_id %d\n", res->port_id);
12712 printf("not supported on port %d\n", res->port_id);
12715 printf("programming error: (%s)\n", strerror(-ret));
12719 cmdline_parse_inst_t cmd_set_macsec_sa = {
12720 .f = cmd_set_macsec_sa_parsed,
12722 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12724 (void *)&cmd_macsec_sa_set,
12725 (void *)&cmd_macsec_sa_macsec,
12726 (void *)&cmd_macsec_sa_sa,
12727 (void *)&cmd_macsec_sa_tx_rx,
12728 (void *)&cmd_macsec_sa_port_id,
12729 (void *)&cmd_macsec_sa_idx,
12730 (void *)&cmd_macsec_sa_an,
12731 (void *)&cmd_macsec_sa_pn,
12732 (void *)&cmd_macsec_sa_key,
12737 /* VF unicast promiscuous mode configuration */
12739 /* Common result structure for VF unicast promiscuous mode */
12740 struct cmd_vf_promisc_result {
12741 cmdline_fixed_string_t set;
12742 cmdline_fixed_string_t vf;
12743 cmdline_fixed_string_t promisc;
12746 cmdline_fixed_string_t on_off;
12749 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12750 cmdline_parse_token_string_t cmd_vf_promisc_set =
12751 TOKEN_STRING_INITIALIZER
12752 (struct cmd_vf_promisc_result,
12754 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12755 TOKEN_STRING_INITIALIZER
12756 (struct cmd_vf_promisc_result,
12758 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12759 TOKEN_STRING_INITIALIZER
12760 (struct cmd_vf_promisc_result,
12761 promisc, "promisc");
12762 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12763 TOKEN_NUM_INITIALIZER
12764 (struct cmd_vf_promisc_result,
12766 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12767 TOKEN_NUM_INITIALIZER
12768 (struct cmd_vf_promisc_result,
12770 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12771 TOKEN_STRING_INITIALIZER
12772 (struct cmd_vf_promisc_result,
12776 cmd_set_vf_promisc_parsed(
12777 void *parsed_result,
12778 __attribute__((unused)) struct cmdline *cl,
12779 __attribute__((unused)) void *data)
12781 struct cmd_vf_promisc_result *res = parsed_result;
12782 int ret = -ENOTSUP;
12784 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12789 #ifdef RTE_LIBRTE_I40E_PMD
12790 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12791 res->vf_id, is_on);
12798 printf("invalid vf_id %d\n", res->vf_id);
12801 printf("invalid port_id %d\n", res->port_id);
12804 printf("function not implemented\n");
12807 printf("programming error: (%s)\n", strerror(-ret));
12811 cmdline_parse_inst_t cmd_set_vf_promisc = {
12812 .f = cmd_set_vf_promisc_parsed,
12814 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12815 "Set unicast promiscuous mode for a VF from the PF",
12817 (void *)&cmd_vf_promisc_set,
12818 (void *)&cmd_vf_promisc_vf,
12819 (void *)&cmd_vf_promisc_promisc,
12820 (void *)&cmd_vf_promisc_port_id,
12821 (void *)&cmd_vf_promisc_vf_id,
12822 (void *)&cmd_vf_promisc_on_off,
12827 /* VF multicast promiscuous mode configuration */
12829 /* Common result structure for VF multicast promiscuous mode */
12830 struct cmd_vf_allmulti_result {
12831 cmdline_fixed_string_t set;
12832 cmdline_fixed_string_t vf;
12833 cmdline_fixed_string_t allmulti;
12836 cmdline_fixed_string_t on_off;
12839 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12840 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_vf_allmulti_result,
12844 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_vf_allmulti_result,
12848 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12849 TOKEN_STRING_INITIALIZER
12850 (struct cmd_vf_allmulti_result,
12851 allmulti, "allmulti");
12852 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12853 TOKEN_NUM_INITIALIZER
12854 (struct cmd_vf_allmulti_result,
12856 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12857 TOKEN_NUM_INITIALIZER
12858 (struct cmd_vf_allmulti_result,
12860 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12861 TOKEN_STRING_INITIALIZER
12862 (struct cmd_vf_allmulti_result,
12866 cmd_set_vf_allmulti_parsed(
12867 void *parsed_result,
12868 __attribute__((unused)) struct cmdline *cl,
12869 __attribute__((unused)) void *data)
12871 struct cmd_vf_allmulti_result *res = parsed_result;
12872 int ret = -ENOTSUP;
12874 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12876 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12879 #ifdef RTE_LIBRTE_I40E_PMD
12880 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12881 res->vf_id, is_on);
12888 printf("invalid vf_id %d\n", res->vf_id);
12891 printf("invalid port_id %d\n", res->port_id);
12894 printf("function not implemented\n");
12897 printf("programming error: (%s)\n", strerror(-ret));
12901 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12902 .f = cmd_set_vf_allmulti_parsed,
12904 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12905 "Set multicast promiscuous mode for a VF from the PF",
12907 (void *)&cmd_vf_allmulti_set,
12908 (void *)&cmd_vf_allmulti_vf,
12909 (void *)&cmd_vf_allmulti_allmulti,
12910 (void *)&cmd_vf_allmulti_port_id,
12911 (void *)&cmd_vf_allmulti_vf_id,
12912 (void *)&cmd_vf_allmulti_on_off,
12917 /* vf broadcast mode configuration */
12919 /* Common result structure for vf broadcast */
12920 struct cmd_set_vf_broadcast_result {
12921 cmdline_fixed_string_t set;
12922 cmdline_fixed_string_t vf;
12923 cmdline_fixed_string_t broadcast;
12926 cmdline_fixed_string_t on_off;
12929 /* Common CLI fields for vf broadcast enable disable */
12930 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12931 TOKEN_STRING_INITIALIZER
12932 (struct cmd_set_vf_broadcast_result,
12934 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12935 TOKEN_STRING_INITIALIZER
12936 (struct cmd_set_vf_broadcast_result,
12938 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12939 TOKEN_STRING_INITIALIZER
12940 (struct cmd_set_vf_broadcast_result,
12941 broadcast, "broadcast");
12942 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12943 TOKEN_NUM_INITIALIZER
12944 (struct cmd_set_vf_broadcast_result,
12946 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12947 TOKEN_NUM_INITIALIZER
12948 (struct cmd_set_vf_broadcast_result,
12950 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12951 TOKEN_STRING_INITIALIZER
12952 (struct cmd_set_vf_broadcast_result,
12956 cmd_set_vf_broadcast_parsed(
12957 void *parsed_result,
12958 __attribute__((unused)) struct cmdline *cl,
12959 __attribute__((unused)) void *data)
12961 struct cmd_set_vf_broadcast_result *res = parsed_result;
12962 int ret = -ENOTSUP;
12964 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12966 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12969 #ifdef RTE_LIBRTE_I40E_PMD
12970 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12971 res->vf_id, is_on);
12978 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12981 printf("invalid port_id %d\n", res->port_id);
12984 printf("function not implemented\n");
12987 printf("programming error: (%s)\n", strerror(-ret));
12991 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12992 .f = cmd_set_vf_broadcast_parsed,
12994 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12996 (void *)&cmd_set_vf_broadcast_set,
12997 (void *)&cmd_set_vf_broadcast_vf,
12998 (void *)&cmd_set_vf_broadcast_broadcast,
12999 (void *)&cmd_set_vf_broadcast_port_id,
13000 (void *)&cmd_set_vf_broadcast_vf_id,
13001 (void *)&cmd_set_vf_broadcast_on_off,
13006 /* vf vlan tag configuration */
13008 /* Common result structure for vf vlan tag */
13009 struct cmd_set_vf_vlan_tag_result {
13010 cmdline_fixed_string_t set;
13011 cmdline_fixed_string_t vf;
13012 cmdline_fixed_string_t vlan;
13013 cmdline_fixed_string_t tag;
13016 cmdline_fixed_string_t on_off;
13019 /* Common CLI fields for vf vlan tag enable disable */
13020 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13021 TOKEN_STRING_INITIALIZER
13022 (struct cmd_set_vf_vlan_tag_result,
13024 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13025 TOKEN_STRING_INITIALIZER
13026 (struct cmd_set_vf_vlan_tag_result,
13028 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13029 TOKEN_STRING_INITIALIZER
13030 (struct cmd_set_vf_vlan_tag_result,
13032 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13033 TOKEN_STRING_INITIALIZER
13034 (struct cmd_set_vf_vlan_tag_result,
13036 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13037 TOKEN_NUM_INITIALIZER
13038 (struct cmd_set_vf_vlan_tag_result,
13040 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13041 TOKEN_NUM_INITIALIZER
13042 (struct cmd_set_vf_vlan_tag_result,
13044 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13045 TOKEN_STRING_INITIALIZER
13046 (struct cmd_set_vf_vlan_tag_result,
13050 cmd_set_vf_vlan_tag_parsed(
13051 void *parsed_result,
13052 __attribute__((unused)) struct cmdline *cl,
13053 __attribute__((unused)) void *data)
13055 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13056 int ret = -ENOTSUP;
13058 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13063 #ifdef RTE_LIBRTE_I40E_PMD
13064 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13065 res->vf_id, is_on);
13072 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13075 printf("invalid port_id %d\n", res->port_id);
13078 printf("function not implemented\n");
13081 printf("programming error: (%s)\n", strerror(-ret));
13085 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13086 .f = cmd_set_vf_vlan_tag_parsed,
13088 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13090 (void *)&cmd_set_vf_vlan_tag_set,
13091 (void *)&cmd_set_vf_vlan_tag_vf,
13092 (void *)&cmd_set_vf_vlan_tag_vlan,
13093 (void *)&cmd_set_vf_vlan_tag_tag,
13094 (void *)&cmd_set_vf_vlan_tag_port_id,
13095 (void *)&cmd_set_vf_vlan_tag_vf_id,
13096 (void *)&cmd_set_vf_vlan_tag_on_off,
13101 /* Common definition of VF and TC TX bandwidth configuration */
13102 struct cmd_vf_tc_bw_result {
13103 cmdline_fixed_string_t set;
13104 cmdline_fixed_string_t vf;
13105 cmdline_fixed_string_t tc;
13106 cmdline_fixed_string_t tx;
13107 cmdline_fixed_string_t min_bw;
13108 cmdline_fixed_string_t max_bw;
13109 cmdline_fixed_string_t strict_link_prio;
13114 cmdline_fixed_string_t bw_list;
13118 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13119 TOKEN_STRING_INITIALIZER
13120 (struct cmd_vf_tc_bw_result,
13122 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13123 TOKEN_STRING_INITIALIZER
13124 (struct cmd_vf_tc_bw_result,
13126 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13127 TOKEN_STRING_INITIALIZER
13128 (struct cmd_vf_tc_bw_result,
13130 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13131 TOKEN_STRING_INITIALIZER
13132 (struct cmd_vf_tc_bw_result,
13134 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13135 TOKEN_STRING_INITIALIZER
13136 (struct cmd_vf_tc_bw_result,
13137 strict_link_prio, "strict-link-priority");
13138 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13139 TOKEN_STRING_INITIALIZER
13140 (struct cmd_vf_tc_bw_result,
13141 min_bw, "min-bandwidth");
13142 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13143 TOKEN_STRING_INITIALIZER
13144 (struct cmd_vf_tc_bw_result,
13145 max_bw, "max-bandwidth");
13146 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13147 TOKEN_NUM_INITIALIZER
13148 (struct cmd_vf_tc_bw_result,
13150 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13151 TOKEN_NUM_INITIALIZER
13152 (struct cmd_vf_tc_bw_result,
13154 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13155 TOKEN_NUM_INITIALIZER
13156 (struct cmd_vf_tc_bw_result,
13158 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13159 TOKEN_NUM_INITIALIZER
13160 (struct cmd_vf_tc_bw_result,
13162 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13163 TOKEN_STRING_INITIALIZER
13164 (struct cmd_vf_tc_bw_result,
13166 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13167 TOKEN_NUM_INITIALIZER
13168 (struct cmd_vf_tc_bw_result,
13171 /* VF max bandwidth setting */
13173 cmd_vf_max_bw_parsed(
13174 void *parsed_result,
13175 __attribute__((unused)) struct cmdline *cl,
13176 __attribute__((unused)) void *data)
13178 struct cmd_vf_tc_bw_result *res = parsed_result;
13179 int ret = -ENOTSUP;
13181 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13184 #ifdef RTE_LIBRTE_I40E_PMD
13185 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13186 res->vf_id, res->bw);
13193 printf("invalid vf_id %d or bandwidth %d\n",
13194 res->vf_id, res->bw);
13197 printf("invalid port_id %d\n", res->port_id);
13200 printf("function not implemented\n");
13203 printf("programming error: (%s)\n", strerror(-ret));
13207 cmdline_parse_inst_t cmd_vf_max_bw = {
13208 .f = cmd_vf_max_bw_parsed,
13210 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13212 (void *)&cmd_vf_tc_bw_set,
13213 (void *)&cmd_vf_tc_bw_vf,
13214 (void *)&cmd_vf_tc_bw_tx,
13215 (void *)&cmd_vf_tc_bw_max_bw,
13216 (void *)&cmd_vf_tc_bw_port_id,
13217 (void *)&cmd_vf_tc_bw_vf_id,
13218 (void *)&cmd_vf_tc_bw_bw,
13224 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13229 const char *p, *p0 = str;
13236 p = strchr(p0, '(');
13238 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13242 p0 = strchr(p, ')');
13244 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13248 if (size >= sizeof(s)) {
13249 printf("The string size exceeds the internal buffer size\n");
13252 snprintf(s, sizeof(s), "%.*s", size, p);
13253 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13255 printf("Failed to get the bandwidth list. ");
13259 for (i = 0; i < ret; i++)
13260 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13265 /* TC min bandwidth setting */
13267 cmd_vf_tc_min_bw_parsed(
13268 void *parsed_result,
13269 __attribute__((unused)) struct cmdline *cl,
13270 __attribute__((unused)) void *data)
13272 struct cmd_vf_tc_bw_result *res = parsed_result;
13275 int ret = -ENOTSUP;
13277 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13280 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13284 #ifdef RTE_LIBRTE_I40E_PMD
13285 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13293 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13296 printf("invalid port_id %d\n", res->port_id);
13299 printf("function not implemented\n");
13302 printf("programming error: (%s)\n", strerror(-ret));
13306 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13307 .f = cmd_vf_tc_min_bw_parsed,
13309 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13310 " <bw1, bw2, ...>",
13312 (void *)&cmd_vf_tc_bw_set,
13313 (void *)&cmd_vf_tc_bw_vf,
13314 (void *)&cmd_vf_tc_bw_tc,
13315 (void *)&cmd_vf_tc_bw_tx,
13316 (void *)&cmd_vf_tc_bw_min_bw,
13317 (void *)&cmd_vf_tc_bw_port_id,
13318 (void *)&cmd_vf_tc_bw_vf_id,
13319 (void *)&cmd_vf_tc_bw_bw_list,
13325 cmd_tc_min_bw_parsed(
13326 void *parsed_result,
13327 __attribute__((unused)) struct cmdline *cl,
13328 __attribute__((unused)) void *data)
13330 struct cmd_vf_tc_bw_result *res = parsed_result;
13331 struct rte_port *port;
13334 int ret = -ENOTSUP;
13336 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13339 port = &ports[res->port_id];
13340 /** Check if the port is not started **/
13341 if (port->port_status != RTE_PORT_STOPPED) {
13342 printf("Please stop port %d first\n", res->port_id);
13346 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13350 #ifdef RTE_LIBRTE_IXGBE_PMD
13351 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13358 printf("invalid bandwidth\n");
13361 printf("invalid port_id %d\n", res->port_id);
13364 printf("function not implemented\n");
13367 printf("programming error: (%s)\n", strerror(-ret));
13371 cmdline_parse_inst_t cmd_tc_min_bw = {
13372 .f = cmd_tc_min_bw_parsed,
13374 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13376 (void *)&cmd_vf_tc_bw_set,
13377 (void *)&cmd_vf_tc_bw_tc,
13378 (void *)&cmd_vf_tc_bw_tx,
13379 (void *)&cmd_vf_tc_bw_min_bw,
13380 (void *)&cmd_vf_tc_bw_port_id,
13381 (void *)&cmd_vf_tc_bw_bw_list,
13386 /* TC max bandwidth setting */
13388 cmd_vf_tc_max_bw_parsed(
13389 void *parsed_result,
13390 __attribute__((unused)) struct cmdline *cl,
13391 __attribute__((unused)) void *data)
13393 struct cmd_vf_tc_bw_result *res = parsed_result;
13394 int ret = -ENOTSUP;
13396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13399 #ifdef RTE_LIBRTE_I40E_PMD
13400 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13401 res->tc_no, res->bw);
13408 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13409 res->vf_id, res->tc_no, res->bw);
13412 printf("invalid port_id %d\n", res->port_id);
13415 printf("function not implemented\n");
13418 printf("programming error: (%s)\n", strerror(-ret));
13422 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13423 .f = cmd_vf_tc_max_bw_parsed,
13425 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13428 (void *)&cmd_vf_tc_bw_set,
13429 (void *)&cmd_vf_tc_bw_vf,
13430 (void *)&cmd_vf_tc_bw_tc,
13431 (void *)&cmd_vf_tc_bw_tx,
13432 (void *)&cmd_vf_tc_bw_max_bw,
13433 (void *)&cmd_vf_tc_bw_port_id,
13434 (void *)&cmd_vf_tc_bw_vf_id,
13435 (void *)&cmd_vf_tc_bw_tc_no,
13436 (void *)&cmd_vf_tc_bw_bw,
13442 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
13444 /* *** Set Port default Traffic Management Hierarchy *** */
13445 struct cmd_set_port_tm_hierarchy_default_result {
13446 cmdline_fixed_string_t set;
13447 cmdline_fixed_string_t port;
13448 cmdline_fixed_string_t tm;
13449 cmdline_fixed_string_t hierarchy;
13450 cmdline_fixed_string_t def;
13454 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
13455 TOKEN_STRING_INITIALIZER(
13456 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
13457 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
13458 TOKEN_STRING_INITIALIZER(
13459 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
13460 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
13461 TOKEN_STRING_INITIALIZER(
13462 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
13463 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
13464 TOKEN_STRING_INITIALIZER(
13465 struct cmd_set_port_tm_hierarchy_default_result,
13466 hierarchy, "hierarchy");
13467 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
13468 TOKEN_STRING_INITIALIZER(
13469 struct cmd_set_port_tm_hierarchy_default_result,
13471 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
13472 TOKEN_NUM_INITIALIZER(
13473 struct cmd_set_port_tm_hierarchy_default_result,
13476 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
13477 __attribute__((unused)) struct cmdline *cl,
13478 __attribute__((unused)) void *data)
13480 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
13481 struct rte_port *p;
13482 uint16_t port_id = res->port_id;
13484 if (port_id_is_invalid(port_id, ENABLED_WARN))
13487 p = &ports[port_id];
13490 if (p->softport.tm_flag == 0) {
13491 printf(" tm not enabled on port %u (error)\n", port_id);
13495 /* Forward mode: tm */
13496 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
13497 printf(" tm mode not enabled(error)\n");
13501 /* Set the default tm hierarchy */
13502 p->softport.tm.default_hierarchy_enable = 1;
13505 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
13506 .f = cmd_set_port_tm_hierarchy_default_parsed,
13508 .help_str = "set port tm hierarchy default <port_id>",
13510 (void *)&cmd_set_port_tm_hierarchy_default_set,
13511 (void *)&cmd_set_port_tm_hierarchy_default_port,
13512 (void *)&cmd_set_port_tm_hierarchy_default_tm,
13513 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
13514 (void *)&cmd_set_port_tm_hierarchy_default_default,
13515 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
13521 /* Strict link priority scheduling mode setting */
13523 cmd_strict_link_prio_parsed(
13524 void *parsed_result,
13525 __attribute__((unused)) struct cmdline *cl,
13526 __attribute__((unused)) void *data)
13528 struct cmd_vf_tc_bw_result *res = parsed_result;
13529 int ret = -ENOTSUP;
13531 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13534 #ifdef RTE_LIBRTE_I40E_PMD
13535 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13542 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13545 printf("invalid port_id %d\n", res->port_id);
13548 printf("function not implemented\n");
13551 printf("programming error: (%s)\n", strerror(-ret));
13555 cmdline_parse_inst_t cmd_strict_link_prio = {
13556 .f = cmd_strict_link_prio_parsed,
13558 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13560 (void *)&cmd_vf_tc_bw_set,
13561 (void *)&cmd_vf_tc_bw_tx,
13562 (void *)&cmd_vf_tc_bw_strict_link_prio,
13563 (void *)&cmd_vf_tc_bw_port_id,
13564 (void *)&cmd_vf_tc_bw_tc_map,
13569 /* Load dynamic device personalization*/
13570 struct cmd_ddp_add_result {
13571 cmdline_fixed_string_t ddp;
13572 cmdline_fixed_string_t add;
13577 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13578 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13579 cmdline_parse_token_string_t cmd_ddp_add_add =
13580 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13581 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13582 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13583 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13584 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13587 cmd_ddp_add_parsed(
13588 void *parsed_result,
13589 __attribute__((unused)) struct cmdline *cl,
13590 __attribute__((unused)) void *data)
13592 struct cmd_ddp_add_result *res = parsed_result;
13598 int ret = -ENOTSUP;
13600 if (res->port_id > nb_ports) {
13601 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13605 if (!all_ports_stopped()) {
13606 printf("Please stop all ports first\n");
13610 filepath = strdup(res->filepath);
13611 if (filepath == NULL) {
13612 printf("Failed to allocate memory\n");
13615 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13617 buff = open_ddp_package_file(file_fld[0], &size);
13619 free((void *)filepath);
13623 #ifdef RTE_LIBRTE_I40E_PMD
13624 if (ret == -ENOTSUP)
13625 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13627 RTE_PMD_I40E_PKG_OP_WR_ADD);
13630 if (ret == -EEXIST)
13631 printf("Profile has already existed.\n");
13633 printf("Failed to load profile.\n");
13634 else if (file_num == 2)
13635 save_ddp_package_file(file_fld[1], buff, size);
13637 close_ddp_package_file(buff);
13638 free((void *)filepath);
13641 cmdline_parse_inst_t cmd_ddp_add = {
13642 .f = cmd_ddp_add_parsed,
13644 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13646 (void *)&cmd_ddp_add_ddp,
13647 (void *)&cmd_ddp_add_add,
13648 (void *)&cmd_ddp_add_port_id,
13649 (void *)&cmd_ddp_add_filepath,
13654 /* Delete dynamic device personalization*/
13655 struct cmd_ddp_del_result {
13656 cmdline_fixed_string_t ddp;
13657 cmdline_fixed_string_t del;
13662 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13663 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13664 cmdline_parse_token_string_t cmd_ddp_del_del =
13665 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13666 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13667 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13668 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13669 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13672 cmd_ddp_del_parsed(
13673 void *parsed_result,
13674 __attribute__((unused)) struct cmdline *cl,
13675 __attribute__((unused)) void *data)
13677 struct cmd_ddp_del_result *res = parsed_result;
13680 int ret = -ENOTSUP;
13682 if (res->port_id > nb_ports) {
13683 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13687 if (!all_ports_stopped()) {
13688 printf("Please stop all ports first\n");
13692 buff = open_ddp_package_file(res->filepath, &size);
13696 #ifdef RTE_LIBRTE_I40E_PMD
13697 if (ret == -ENOTSUP)
13698 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13700 RTE_PMD_I40E_PKG_OP_WR_DEL);
13703 if (ret == -EACCES)
13704 printf("Profile does not exist.\n");
13706 printf("Failed to delete profile.\n");
13708 close_ddp_package_file(buff);
13711 cmdline_parse_inst_t cmd_ddp_del = {
13712 .f = cmd_ddp_del_parsed,
13714 .help_str = "ddp del <port_id> <profile_path>",
13716 (void *)&cmd_ddp_del_ddp,
13717 (void *)&cmd_ddp_del_del,
13718 (void *)&cmd_ddp_del_port_id,
13719 (void *)&cmd_ddp_del_filepath,
13724 /* Get dynamic device personalization profile info */
13725 struct cmd_ddp_info_result {
13726 cmdline_fixed_string_t ddp;
13727 cmdline_fixed_string_t get;
13728 cmdline_fixed_string_t info;
13732 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13733 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13734 cmdline_parse_token_string_t cmd_ddp_info_get =
13735 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13736 cmdline_parse_token_string_t cmd_ddp_info_info =
13737 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13738 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13739 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13742 cmd_ddp_info_parsed(
13743 void *parsed_result,
13744 __attribute__((unused)) struct cmdline *cl,
13745 __attribute__((unused)) void *data)
13747 struct cmd_ddp_info_result *res = parsed_result;
13750 int ret = -ENOTSUP;
13751 #ifdef RTE_LIBRTE_I40E_PMD
13754 uint32_t buff_size = 0;
13755 struct rte_pmd_i40e_profile_info info;
13756 uint32_t dev_num = 0;
13757 struct rte_pmd_i40e_ddp_device_id *devs;
13758 uint32_t proto_num = 0;
13759 struct rte_pmd_i40e_proto_info *proto;
13760 uint32_t pctype_num = 0;
13761 struct rte_pmd_i40e_ptype_info *pctype;
13762 uint32_t ptype_num = 0;
13763 struct rte_pmd_i40e_ptype_info *ptype;
13768 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13772 #ifdef RTE_LIBRTE_I40E_PMD
13773 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13774 (uint8_t *)&info, sizeof(info),
13775 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13777 printf("Global Track id: 0x%x\n", info.track_id);
13778 printf("Global Version: %d.%d.%d.%d\n",
13779 info.version.major,
13780 info.version.minor,
13781 info.version.update,
13782 info.version.draft);
13783 printf("Global Package name: %s\n\n", info.name);
13786 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13787 (uint8_t *)&info, sizeof(info),
13788 RTE_PMD_I40E_PKG_INFO_HEADER);
13790 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13791 printf("i40e Profile Version: %d.%d.%d.%d\n",
13792 info.version.major,
13793 info.version.minor,
13794 info.version.update,
13795 info.version.draft);
13796 printf("i40e Profile name: %s\n\n", info.name);
13799 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13800 (uint8_t *)&buff_size, sizeof(buff_size),
13801 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13802 if (!ret && buff_size) {
13803 buff = (uint8_t *)malloc(buff_size);
13805 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13807 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13809 printf("Package Notes:\n%s\n\n", buff);
13814 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13815 (uint8_t *)&dev_num, sizeof(dev_num),
13816 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13817 if (!ret && dev_num) {
13818 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13819 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13821 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13822 (uint8_t *)devs, buff_size,
13823 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13825 printf("List of supported devices:\n");
13826 for (i = 0; i < dev_num; i++) {
13827 printf(" %04X:%04X %04X:%04X\n",
13828 devs[i].vendor_dev_id >> 16,
13829 devs[i].vendor_dev_id & 0xFFFF,
13830 devs[i].sub_vendor_dev_id >> 16,
13831 devs[i].sub_vendor_dev_id & 0xFFFF);
13839 /* get information about protocols and packet types */
13840 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13841 (uint8_t *)&proto_num, sizeof(proto_num),
13842 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13843 if (ret || !proto_num)
13844 goto no_print_return;
13846 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13847 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13849 goto no_print_return;
13851 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13853 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13855 printf("List of used protocols:\n");
13856 for (i = 0; i < proto_num; i++)
13857 printf(" %2u: %s\n", proto[i].proto_id,
13861 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13862 (uint8_t *)&pctype_num, sizeof(pctype_num),
13863 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13864 if (ret || !pctype_num)
13865 goto no_print_pctypes;
13867 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13868 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13870 goto no_print_pctypes;
13872 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13874 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13877 goto no_print_pctypes;
13880 printf("List of defined packet classification types:\n");
13881 for (i = 0; i < pctype_num; i++) {
13882 printf(" %2u:", pctype[i].ptype_id);
13883 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13884 proto_id = pctype[i].protocols[j];
13885 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13886 for (n = 0; n < proto_num; n++) {
13887 if (proto[n].proto_id == proto_id) {
13888 printf(" %s", proto[n].name);
13901 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13903 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13904 if (ret || !ptype_num)
13905 goto no_print_return;
13907 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13908 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13910 goto no_print_return;
13912 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13914 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13917 goto no_print_return;
13919 printf("List of defined packet types:\n");
13920 for (i = 0; i < ptype_num; i++) {
13921 printf(" %2u:", ptype[i].ptype_id);
13922 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13923 proto_id = ptype[i].protocols[j];
13924 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13925 for (n = 0; n < proto_num; n++) {
13926 if (proto[n].proto_id == proto_id) {
13927 printf(" %s", proto[n].name);
13942 if (ret == -ENOTSUP)
13943 printf("Function not supported in PMD driver\n");
13944 close_ddp_package_file(pkg);
13947 cmdline_parse_inst_t cmd_ddp_get_info = {
13948 .f = cmd_ddp_info_parsed,
13950 .help_str = "ddp get info <profile_path>",
13952 (void *)&cmd_ddp_info_ddp,
13953 (void *)&cmd_ddp_info_get,
13954 (void *)&cmd_ddp_info_info,
13955 (void *)&cmd_ddp_info_filepath,
13960 /* Get dynamic device personalization profile info list*/
13961 #define PROFILE_INFO_SIZE 48
13962 #define MAX_PROFILE_NUM 16
13964 struct cmd_ddp_get_list_result {
13965 cmdline_fixed_string_t ddp;
13966 cmdline_fixed_string_t get;
13967 cmdline_fixed_string_t list;
13971 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13972 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13973 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13974 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13975 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13976 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13977 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13978 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13981 cmd_ddp_get_list_parsed(
13982 void *parsed_result,
13983 __attribute__((unused)) struct cmdline *cl,
13984 __attribute__((unused)) void *data)
13986 struct cmd_ddp_get_list_result *res = parsed_result;
13987 #ifdef RTE_LIBRTE_I40E_PMD
13988 struct rte_pmd_i40e_profile_list *p_list;
13989 struct rte_pmd_i40e_profile_info *p_info;
13994 int ret = -ENOTSUP;
13996 if (res->port_id > nb_ports) {
13997 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14001 #ifdef RTE_LIBRTE_I40E_PMD
14002 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14003 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14005 printf("%s: Failed to malloc buffer\n", __func__);
14007 if (ret == -ENOTSUP)
14008 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14009 (uint8_t *)p_list, size);
14012 p_num = p_list->p_count;
14013 printf("Profile number is: %d\n\n", p_num);
14015 for (i = 0; i < p_num; i++) {
14016 p_info = &p_list->p_info[i];
14017 printf("Profile %d:\n", i);
14018 printf("Track id: 0x%x\n", p_info->track_id);
14019 printf("Version: %d.%d.%d.%d\n",
14020 p_info->version.major,
14021 p_info->version.minor,
14022 p_info->version.update,
14023 p_info->version.draft);
14024 printf("Profile name: %s\n\n", p_info->name);
14032 printf("Failed to get ddp list\n");
14035 cmdline_parse_inst_t cmd_ddp_get_list = {
14036 .f = cmd_ddp_get_list_parsed,
14038 .help_str = "ddp get list <port_id>",
14040 (void *)&cmd_ddp_get_list_ddp,
14041 (void *)&cmd_ddp_get_list_get,
14042 (void *)&cmd_ddp_get_list_list,
14043 (void *)&cmd_ddp_get_list_port_id,
14048 /* show vf stats */
14050 /* Common result structure for show vf stats */
14051 struct cmd_show_vf_stats_result {
14052 cmdline_fixed_string_t show;
14053 cmdline_fixed_string_t vf;
14054 cmdline_fixed_string_t stats;
14059 /* Common CLI fields show vf stats*/
14060 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14061 TOKEN_STRING_INITIALIZER
14062 (struct cmd_show_vf_stats_result,
14064 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14065 TOKEN_STRING_INITIALIZER
14066 (struct cmd_show_vf_stats_result,
14068 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14069 TOKEN_STRING_INITIALIZER
14070 (struct cmd_show_vf_stats_result,
14072 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14073 TOKEN_NUM_INITIALIZER
14074 (struct cmd_show_vf_stats_result,
14076 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14077 TOKEN_NUM_INITIALIZER
14078 (struct cmd_show_vf_stats_result,
14082 cmd_show_vf_stats_parsed(
14083 void *parsed_result,
14084 __attribute__((unused)) struct cmdline *cl,
14085 __attribute__((unused)) void *data)
14087 struct cmd_show_vf_stats_result *res = parsed_result;
14088 struct rte_eth_stats stats;
14089 int ret = -ENOTSUP;
14090 static const char *nic_stats_border = "########################";
14092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14095 memset(&stats, 0, sizeof(stats));
14097 #ifdef RTE_LIBRTE_I40E_PMD
14098 if (ret == -ENOTSUP)
14099 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14103 #ifdef RTE_LIBRTE_BNXT_PMD
14104 if (ret == -ENOTSUP)
14105 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14114 printf("invalid vf_id %d\n", res->vf_id);
14117 printf("invalid port_id %d\n", res->port_id);
14120 printf("function not implemented\n");
14123 printf("programming error: (%s)\n", strerror(-ret));
14126 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14127 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14129 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14131 stats.ipackets, stats.imissed, stats.ibytes);
14132 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14133 printf(" RX-nombuf: %-10"PRIu64"\n",
14135 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14137 stats.opackets, stats.oerrors, stats.obytes);
14139 printf(" %s############################%s\n",
14140 nic_stats_border, nic_stats_border);
14143 cmdline_parse_inst_t cmd_show_vf_stats = {
14144 .f = cmd_show_vf_stats_parsed,
14146 .help_str = "show vf stats <port_id> <vf_id>",
14148 (void *)&cmd_show_vf_stats_show,
14149 (void *)&cmd_show_vf_stats_vf,
14150 (void *)&cmd_show_vf_stats_stats,
14151 (void *)&cmd_show_vf_stats_port_id,
14152 (void *)&cmd_show_vf_stats_vf_id,
14157 /* clear vf stats */
14159 /* Common result structure for clear vf stats */
14160 struct cmd_clear_vf_stats_result {
14161 cmdline_fixed_string_t clear;
14162 cmdline_fixed_string_t vf;
14163 cmdline_fixed_string_t stats;
14168 /* Common CLI fields clear vf stats*/
14169 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14170 TOKEN_STRING_INITIALIZER
14171 (struct cmd_clear_vf_stats_result,
14173 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14174 TOKEN_STRING_INITIALIZER
14175 (struct cmd_clear_vf_stats_result,
14177 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14178 TOKEN_STRING_INITIALIZER
14179 (struct cmd_clear_vf_stats_result,
14181 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14182 TOKEN_NUM_INITIALIZER
14183 (struct cmd_clear_vf_stats_result,
14185 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14186 TOKEN_NUM_INITIALIZER
14187 (struct cmd_clear_vf_stats_result,
14191 cmd_clear_vf_stats_parsed(
14192 void *parsed_result,
14193 __attribute__((unused)) struct cmdline *cl,
14194 __attribute__((unused)) void *data)
14196 struct cmd_clear_vf_stats_result *res = parsed_result;
14197 int ret = -ENOTSUP;
14199 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14202 #ifdef RTE_LIBRTE_I40E_PMD
14203 if (ret == -ENOTSUP)
14204 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14207 #ifdef RTE_LIBRTE_BNXT_PMD
14208 if (ret == -ENOTSUP)
14209 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14217 printf("invalid vf_id %d\n", res->vf_id);
14220 printf("invalid port_id %d\n", res->port_id);
14223 printf("function not implemented\n");
14226 printf("programming error: (%s)\n", strerror(-ret));
14230 cmdline_parse_inst_t cmd_clear_vf_stats = {
14231 .f = cmd_clear_vf_stats_parsed,
14233 .help_str = "clear vf stats <port_id> <vf_id>",
14235 (void *)&cmd_clear_vf_stats_clear,
14236 (void *)&cmd_clear_vf_stats_vf,
14237 (void *)&cmd_clear_vf_stats_stats,
14238 (void *)&cmd_clear_vf_stats_port_id,
14239 (void *)&cmd_clear_vf_stats_vf_id,
14244 /* port config pctype mapping reset */
14246 /* Common result structure for port config pctype mapping reset */
14247 struct cmd_pctype_mapping_reset_result {
14248 cmdline_fixed_string_t port;
14249 cmdline_fixed_string_t config;
14251 cmdline_fixed_string_t pctype;
14252 cmdline_fixed_string_t mapping;
14253 cmdline_fixed_string_t reset;
14256 /* Common CLI fields for port config pctype mapping reset*/
14257 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14258 TOKEN_STRING_INITIALIZER
14259 (struct cmd_pctype_mapping_reset_result,
14261 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14262 TOKEN_STRING_INITIALIZER
14263 (struct cmd_pctype_mapping_reset_result,
14265 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14266 TOKEN_NUM_INITIALIZER
14267 (struct cmd_pctype_mapping_reset_result,
14269 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14270 TOKEN_STRING_INITIALIZER
14271 (struct cmd_pctype_mapping_reset_result,
14273 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14274 TOKEN_STRING_INITIALIZER
14275 (struct cmd_pctype_mapping_reset_result,
14276 mapping, "mapping");
14277 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14278 TOKEN_STRING_INITIALIZER
14279 (struct cmd_pctype_mapping_reset_result,
14283 cmd_pctype_mapping_reset_parsed(
14284 void *parsed_result,
14285 __attribute__((unused)) struct cmdline *cl,
14286 __attribute__((unused)) void *data)
14288 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14289 int ret = -ENOTSUP;
14291 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14294 #ifdef RTE_LIBRTE_I40E_PMD
14295 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14302 printf("invalid port_id %d\n", res->port_id);
14305 printf("function not implemented\n");
14308 printf("programming error: (%s)\n", strerror(-ret));
14312 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14313 .f = cmd_pctype_mapping_reset_parsed,
14315 .help_str = "port config <port_id> pctype mapping reset",
14317 (void *)&cmd_pctype_mapping_reset_port,
14318 (void *)&cmd_pctype_mapping_reset_config,
14319 (void *)&cmd_pctype_mapping_reset_port_id,
14320 (void *)&cmd_pctype_mapping_reset_pctype,
14321 (void *)&cmd_pctype_mapping_reset_mapping,
14322 (void *)&cmd_pctype_mapping_reset_reset,
14327 /* show port pctype mapping */
14329 /* Common result structure for show port pctype mapping */
14330 struct cmd_pctype_mapping_get_result {
14331 cmdline_fixed_string_t show;
14332 cmdline_fixed_string_t port;
14334 cmdline_fixed_string_t pctype;
14335 cmdline_fixed_string_t mapping;
14338 /* Common CLI fields for pctype mapping get */
14339 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14340 TOKEN_STRING_INITIALIZER
14341 (struct cmd_pctype_mapping_get_result,
14343 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14344 TOKEN_STRING_INITIALIZER
14345 (struct cmd_pctype_mapping_get_result,
14347 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14348 TOKEN_NUM_INITIALIZER
14349 (struct cmd_pctype_mapping_get_result,
14351 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14352 TOKEN_STRING_INITIALIZER
14353 (struct cmd_pctype_mapping_get_result,
14355 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14356 TOKEN_STRING_INITIALIZER
14357 (struct cmd_pctype_mapping_get_result,
14358 mapping, "mapping");
14361 cmd_pctype_mapping_get_parsed(
14362 void *parsed_result,
14363 __attribute__((unused)) struct cmdline *cl,
14364 __attribute__((unused)) void *data)
14366 struct cmd_pctype_mapping_get_result *res = parsed_result;
14367 int ret = -ENOTSUP;
14368 #ifdef RTE_LIBRTE_I40E_PMD
14369 struct rte_pmd_i40e_flow_type_mapping
14370 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14371 int i, j, first_pctype;
14374 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14377 #ifdef RTE_LIBRTE_I40E_PMD
14378 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14385 printf("invalid port_id %d\n", res->port_id);
14388 printf("function not implemented\n");
14391 printf("programming error: (%s)\n", strerror(-ret));
14395 #ifdef RTE_LIBRTE_I40E_PMD
14396 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14397 if (mapping[i].pctype != 0ULL) {
14400 printf("pctype: ");
14401 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14402 if (mapping[i].pctype & (1ULL << j)) {
14403 printf(first_pctype ?
14404 "%02d" : ",%02d", j);
14408 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14414 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14415 .f = cmd_pctype_mapping_get_parsed,
14417 .help_str = "show port <port_id> pctype mapping",
14419 (void *)&cmd_pctype_mapping_get_show,
14420 (void *)&cmd_pctype_mapping_get_port,
14421 (void *)&cmd_pctype_mapping_get_port_id,
14422 (void *)&cmd_pctype_mapping_get_pctype,
14423 (void *)&cmd_pctype_mapping_get_mapping,
14428 /* port config pctype mapping update */
14430 /* Common result structure for port config pctype mapping update */
14431 struct cmd_pctype_mapping_update_result {
14432 cmdline_fixed_string_t port;
14433 cmdline_fixed_string_t config;
14435 cmdline_fixed_string_t pctype;
14436 cmdline_fixed_string_t mapping;
14437 cmdline_fixed_string_t update;
14438 cmdline_fixed_string_t pctype_list;
14439 uint16_t flow_type;
14442 /* Common CLI fields for pctype mapping update*/
14443 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14444 TOKEN_STRING_INITIALIZER
14445 (struct cmd_pctype_mapping_update_result,
14447 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14448 TOKEN_STRING_INITIALIZER
14449 (struct cmd_pctype_mapping_update_result,
14451 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14452 TOKEN_NUM_INITIALIZER
14453 (struct cmd_pctype_mapping_update_result,
14455 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14456 TOKEN_STRING_INITIALIZER
14457 (struct cmd_pctype_mapping_update_result,
14459 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14460 TOKEN_STRING_INITIALIZER
14461 (struct cmd_pctype_mapping_update_result,
14462 mapping, "mapping");
14463 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14464 TOKEN_STRING_INITIALIZER
14465 (struct cmd_pctype_mapping_update_result,
14467 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14468 TOKEN_STRING_INITIALIZER
14469 (struct cmd_pctype_mapping_update_result,
14470 pctype_list, NULL);
14471 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14472 TOKEN_NUM_INITIALIZER
14473 (struct cmd_pctype_mapping_update_result,
14474 flow_type, UINT16);
14477 cmd_pctype_mapping_update_parsed(
14478 void *parsed_result,
14479 __attribute__((unused)) struct cmdline *cl,
14480 __attribute__((unused)) void *data)
14482 struct cmd_pctype_mapping_update_result *res = parsed_result;
14483 int ret = -ENOTSUP;
14484 #ifdef RTE_LIBRTE_I40E_PMD
14485 struct rte_pmd_i40e_flow_type_mapping mapping;
14487 unsigned int nb_item;
14488 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14491 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14494 #ifdef RTE_LIBRTE_I40E_PMD
14495 nb_item = parse_item_list(res->pctype_list, "pctypes",
14496 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14497 mapping.flow_type = res->flow_type;
14498 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14499 mapping.pctype |= (1ULL << pctype_list[i]);
14500 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14510 printf("invalid pctype or flow type\n");
14513 printf("invalid port_id %d\n", res->port_id);
14516 printf("function not implemented\n");
14519 printf("programming error: (%s)\n", strerror(-ret));
14523 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14524 .f = cmd_pctype_mapping_update_parsed,
14526 .help_str = "port config <port_id> pctype mapping update"
14527 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14529 (void *)&cmd_pctype_mapping_update_port,
14530 (void *)&cmd_pctype_mapping_update_config,
14531 (void *)&cmd_pctype_mapping_update_port_id,
14532 (void *)&cmd_pctype_mapping_update_pctype,
14533 (void *)&cmd_pctype_mapping_update_mapping,
14534 (void *)&cmd_pctype_mapping_update_update,
14535 (void *)&cmd_pctype_mapping_update_pc_type,
14536 (void *)&cmd_pctype_mapping_update_flow_type,
14541 /* ptype mapping get */
14543 /* Common result structure for ptype mapping get */
14544 struct cmd_ptype_mapping_get_result {
14545 cmdline_fixed_string_t ptype;
14546 cmdline_fixed_string_t mapping;
14547 cmdline_fixed_string_t get;
14549 uint8_t valid_only;
14552 /* Common CLI fields for ptype mapping get */
14553 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14554 TOKEN_STRING_INITIALIZER
14555 (struct cmd_ptype_mapping_get_result,
14557 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14558 TOKEN_STRING_INITIALIZER
14559 (struct cmd_ptype_mapping_get_result,
14560 mapping, "mapping");
14561 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14562 TOKEN_STRING_INITIALIZER
14563 (struct cmd_ptype_mapping_get_result,
14565 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14566 TOKEN_NUM_INITIALIZER
14567 (struct cmd_ptype_mapping_get_result,
14569 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14570 TOKEN_NUM_INITIALIZER
14571 (struct cmd_ptype_mapping_get_result,
14572 valid_only, UINT8);
14575 cmd_ptype_mapping_get_parsed(
14576 void *parsed_result,
14577 __attribute__((unused)) struct cmdline *cl,
14578 __attribute__((unused)) void *data)
14580 struct cmd_ptype_mapping_get_result *res = parsed_result;
14581 int ret = -ENOTSUP;
14582 #ifdef RTE_LIBRTE_I40E_PMD
14583 int max_ptype_num = 256;
14584 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14589 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14592 #ifdef RTE_LIBRTE_I40E_PMD
14593 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14604 printf("invalid port_id %d\n", res->port_id);
14607 printf("function not implemented\n");
14610 printf("programming error: (%s)\n", strerror(-ret));
14613 #ifdef RTE_LIBRTE_I40E_PMD
14615 for (i = 0; i < count; i++)
14616 printf("%3d\t0x%08x\n",
14617 mapping[i].hw_ptype, mapping[i].sw_ptype);
14622 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14623 .f = cmd_ptype_mapping_get_parsed,
14625 .help_str = "ptype mapping get <port_id> <valid_only>",
14627 (void *)&cmd_ptype_mapping_get_ptype,
14628 (void *)&cmd_ptype_mapping_get_mapping,
14629 (void *)&cmd_ptype_mapping_get_get,
14630 (void *)&cmd_ptype_mapping_get_port_id,
14631 (void *)&cmd_ptype_mapping_get_valid_only,
14636 /* ptype mapping replace */
14638 /* Common result structure for ptype mapping replace */
14639 struct cmd_ptype_mapping_replace_result {
14640 cmdline_fixed_string_t ptype;
14641 cmdline_fixed_string_t mapping;
14642 cmdline_fixed_string_t replace;
14649 /* Common CLI fields for ptype mapping replace */
14650 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14651 TOKEN_STRING_INITIALIZER
14652 (struct cmd_ptype_mapping_replace_result,
14654 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14655 TOKEN_STRING_INITIALIZER
14656 (struct cmd_ptype_mapping_replace_result,
14657 mapping, "mapping");
14658 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14659 TOKEN_STRING_INITIALIZER
14660 (struct cmd_ptype_mapping_replace_result,
14661 replace, "replace");
14662 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14663 TOKEN_NUM_INITIALIZER
14664 (struct cmd_ptype_mapping_replace_result,
14666 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14667 TOKEN_NUM_INITIALIZER
14668 (struct cmd_ptype_mapping_replace_result,
14670 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14671 TOKEN_NUM_INITIALIZER
14672 (struct cmd_ptype_mapping_replace_result,
14674 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14675 TOKEN_NUM_INITIALIZER
14676 (struct cmd_ptype_mapping_replace_result,
14680 cmd_ptype_mapping_replace_parsed(
14681 void *parsed_result,
14682 __attribute__((unused)) struct cmdline *cl,
14683 __attribute__((unused)) void *data)
14685 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14686 int ret = -ENOTSUP;
14688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14691 #ifdef RTE_LIBRTE_I40E_PMD
14692 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
14702 printf("invalid ptype 0x%8x or 0x%8x\n",
14703 res->target, res->pkt_type);
14706 printf("invalid port_id %d\n", res->port_id);
14709 printf("function not implemented\n");
14712 printf("programming error: (%s)\n", strerror(-ret));
14716 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
14717 .f = cmd_ptype_mapping_replace_parsed,
14720 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
14722 (void *)&cmd_ptype_mapping_replace_ptype,
14723 (void *)&cmd_ptype_mapping_replace_mapping,
14724 (void *)&cmd_ptype_mapping_replace_replace,
14725 (void *)&cmd_ptype_mapping_replace_port_id,
14726 (void *)&cmd_ptype_mapping_replace_target,
14727 (void *)&cmd_ptype_mapping_replace_mask,
14728 (void *)&cmd_ptype_mapping_replace_pkt_type,
14733 /* ptype mapping reset */
14735 /* Common result structure for ptype mapping reset */
14736 struct cmd_ptype_mapping_reset_result {
14737 cmdline_fixed_string_t ptype;
14738 cmdline_fixed_string_t mapping;
14739 cmdline_fixed_string_t reset;
14743 /* Common CLI fields for ptype mapping reset*/
14744 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
14745 TOKEN_STRING_INITIALIZER
14746 (struct cmd_ptype_mapping_reset_result,
14748 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
14749 TOKEN_STRING_INITIALIZER
14750 (struct cmd_ptype_mapping_reset_result,
14751 mapping, "mapping");
14752 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
14753 TOKEN_STRING_INITIALIZER
14754 (struct cmd_ptype_mapping_reset_result,
14756 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
14757 TOKEN_NUM_INITIALIZER
14758 (struct cmd_ptype_mapping_reset_result,
14762 cmd_ptype_mapping_reset_parsed(
14763 void *parsed_result,
14764 __attribute__((unused)) struct cmdline *cl,
14765 __attribute__((unused)) void *data)
14767 struct cmd_ptype_mapping_reset_result *res = parsed_result;
14768 int ret = -ENOTSUP;
14770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14773 #ifdef RTE_LIBRTE_I40E_PMD
14774 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
14781 printf("invalid port_id %d\n", res->port_id);
14784 printf("function not implemented\n");
14787 printf("programming error: (%s)\n", strerror(-ret));
14791 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
14792 .f = cmd_ptype_mapping_reset_parsed,
14794 .help_str = "ptype mapping reset <port_id>",
14796 (void *)&cmd_ptype_mapping_reset_ptype,
14797 (void *)&cmd_ptype_mapping_reset_mapping,
14798 (void *)&cmd_ptype_mapping_reset_reset,
14799 (void *)&cmd_ptype_mapping_reset_port_id,
14804 /* ptype mapping update */
14806 /* Common result structure for ptype mapping update */
14807 struct cmd_ptype_mapping_update_result {
14808 cmdline_fixed_string_t ptype;
14809 cmdline_fixed_string_t mapping;
14810 cmdline_fixed_string_t reset;
14816 /* Common CLI fields for ptype mapping update*/
14817 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
14818 TOKEN_STRING_INITIALIZER
14819 (struct cmd_ptype_mapping_update_result,
14821 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
14822 TOKEN_STRING_INITIALIZER
14823 (struct cmd_ptype_mapping_update_result,
14824 mapping, "mapping");
14825 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
14826 TOKEN_STRING_INITIALIZER
14827 (struct cmd_ptype_mapping_update_result,
14829 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
14830 TOKEN_NUM_INITIALIZER
14831 (struct cmd_ptype_mapping_update_result,
14833 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14834 TOKEN_NUM_INITIALIZER
14835 (struct cmd_ptype_mapping_update_result,
14837 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14838 TOKEN_NUM_INITIALIZER
14839 (struct cmd_ptype_mapping_update_result,
14843 cmd_ptype_mapping_update_parsed(
14844 void *parsed_result,
14845 __attribute__((unused)) struct cmdline *cl,
14846 __attribute__((unused)) void *data)
14848 struct cmd_ptype_mapping_update_result *res = parsed_result;
14849 int ret = -ENOTSUP;
14850 #ifdef RTE_LIBRTE_I40E_PMD
14851 struct rte_pmd_i40e_ptype_mapping mapping;
14853 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14856 #ifdef RTE_LIBRTE_I40E_PMD
14857 mapping.hw_ptype = res->hw_ptype;
14858 mapping.sw_ptype = res->sw_ptype;
14859 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14869 printf("invalid ptype 0x%8x\n", res->sw_ptype);
14872 printf("invalid port_id %d\n", res->port_id);
14875 printf("function not implemented\n");
14878 printf("programming error: (%s)\n", strerror(-ret));
14882 cmdline_parse_inst_t cmd_ptype_mapping_update = {
14883 .f = cmd_ptype_mapping_update_parsed,
14885 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14887 (void *)&cmd_ptype_mapping_update_ptype,
14888 (void *)&cmd_ptype_mapping_update_mapping,
14889 (void *)&cmd_ptype_mapping_update_update,
14890 (void *)&cmd_ptype_mapping_update_port_id,
14891 (void *)&cmd_ptype_mapping_update_hw_ptype,
14892 (void *)&cmd_ptype_mapping_update_sw_ptype,
14897 /* Common result structure for file commands */
14898 struct cmd_cmdfile_result {
14899 cmdline_fixed_string_t load;
14900 cmdline_fixed_string_t filename;
14903 /* Common CLI fields for file commands */
14904 cmdline_parse_token_string_t cmd_load_cmdfile =
14905 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14906 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14907 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14910 cmd_load_from_file_parsed(
14911 void *parsed_result,
14912 __attribute__((unused)) struct cmdline *cl,
14913 __attribute__((unused)) void *data)
14915 struct cmd_cmdfile_result *res = parsed_result;
14917 cmdline_read_from_file(res->filename);
14920 cmdline_parse_inst_t cmd_load_from_file = {
14921 .f = cmd_load_from_file_parsed,
14923 .help_str = "load <filename>",
14925 (void *)&cmd_load_cmdfile,
14926 (void *)&cmd_load_cmdfile_filename,
14931 /* ******************************************************************************** */
14933 /* list of instructions */
14934 cmdline_parse_ctx_t main_ctx[] = {
14935 (cmdline_parse_inst_t *)&cmd_help_brief,
14936 (cmdline_parse_inst_t *)&cmd_help_long,
14937 (cmdline_parse_inst_t *)&cmd_quit,
14938 (cmdline_parse_inst_t *)&cmd_load_from_file,
14939 (cmdline_parse_inst_t *)&cmd_showport,
14940 (cmdline_parse_inst_t *)&cmd_showqueue,
14941 (cmdline_parse_inst_t *)&cmd_showportall,
14942 (cmdline_parse_inst_t *)&cmd_showcfg,
14943 (cmdline_parse_inst_t *)&cmd_start,
14944 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14945 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14946 (cmdline_parse_inst_t *)&cmd_set_link_up,
14947 (cmdline_parse_inst_t *)&cmd_set_link_down,
14948 (cmdline_parse_inst_t *)&cmd_reset,
14949 (cmdline_parse_inst_t *)&cmd_set_numbers,
14950 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14951 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14952 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14953 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14954 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14955 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14956 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14957 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14958 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14959 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14960 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14961 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14962 (cmdline_parse_inst_t *)&cmd_set_link_check,
14963 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14964 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14965 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14966 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14967 #ifdef RTE_LIBRTE_PMD_BOND
14968 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14969 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14970 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14971 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14972 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14973 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14974 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14975 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14976 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14977 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14978 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
14980 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14981 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14982 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14983 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14984 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14985 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14986 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14987 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14988 (cmdline_parse_inst_t *)&cmd_csum_set,
14989 (cmdline_parse_inst_t *)&cmd_csum_show,
14990 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14991 (cmdline_parse_inst_t *)&cmd_tso_set,
14992 (cmdline_parse_inst_t *)&cmd_tso_show,
14993 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14994 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14995 (cmdline_parse_inst_t *)&cmd_gro_enable,
14996 (cmdline_parse_inst_t *)&cmd_gro_flush,
14997 (cmdline_parse_inst_t *)&cmd_gro_show,
14998 (cmdline_parse_inst_t *)&cmd_gso_enable,
14999 (cmdline_parse_inst_t *)&cmd_gso_size,
15000 (cmdline_parse_inst_t *)&cmd_gso_show,
15001 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15002 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15003 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15004 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15005 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15006 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15007 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15008 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15009 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15010 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15011 (cmdline_parse_inst_t *)&cmd_config_dcb,
15012 (cmdline_parse_inst_t *)&cmd_read_reg,
15013 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15014 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15015 (cmdline_parse_inst_t *)&cmd_write_reg,
15016 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15017 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15018 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15019 (cmdline_parse_inst_t *)&cmd_stop,
15020 (cmdline_parse_inst_t *)&cmd_mac_addr,
15021 (cmdline_parse_inst_t *)&cmd_set_qmap,
15022 (cmdline_parse_inst_t *)&cmd_operate_port,
15023 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15024 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15025 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15026 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15027 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15028 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15029 (cmdline_parse_inst_t *)&cmd_config_mtu,
15030 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15031 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15032 (cmdline_parse_inst_t *)&cmd_config_rss,
15033 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15034 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15035 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15036 (cmdline_parse_inst_t *)&cmd_showport_reta,
15037 (cmdline_parse_inst_t *)&cmd_config_burst,
15038 (cmdline_parse_inst_t *)&cmd_config_thresh,
15039 (cmdline_parse_inst_t *)&cmd_config_threshold,
15040 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15041 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15042 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15043 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15044 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15045 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15046 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15047 (cmdline_parse_inst_t *)&cmd_global_config,
15048 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15049 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15050 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15051 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15052 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15053 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15054 (cmdline_parse_inst_t *)&cmd_dump,
15055 (cmdline_parse_inst_t *)&cmd_dump_one,
15056 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15057 (cmdline_parse_inst_t *)&cmd_syn_filter,
15058 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15059 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15060 (cmdline_parse_inst_t *)&cmd_flex_filter,
15061 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15062 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15063 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15064 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15065 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15066 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15067 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15068 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15069 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15070 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15071 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15072 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15073 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15074 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15075 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15076 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15077 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15078 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15079 (cmdline_parse_inst_t *)&cmd_flow,
15080 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15081 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15082 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15083 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15084 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15085 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15086 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15087 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15088 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15089 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15090 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15091 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15092 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15093 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15094 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15095 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15096 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15097 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15098 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15099 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15100 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15101 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15102 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15103 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15104 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15105 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15106 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15107 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15108 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15109 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15110 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15111 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15112 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15113 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15114 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15115 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15116 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15117 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15119 (cmdline_parse_inst_t *)&cmd_ddp_add,
15120 (cmdline_parse_inst_t *)&cmd_ddp_del,
15121 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15122 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15123 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15124 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15125 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15126 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15127 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15128 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15130 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15131 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15132 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15136 /* read cmdline commands from file */
15138 cmdline_read_from_file(const char *filename)
15140 struct cmdline *cl;
15142 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15144 printf("Failed to create file based cmdline context: %s\n",
15149 cmdline_interact(cl);
15154 printf("Read CLI commands from %s\n", filename);
15157 /* prompt function, called from main on MASTER lcore */
15161 /* initialize non-constant commands */
15162 cmd_set_fwd_mode_init();
15163 cmd_set_fwd_retry_mode_init();
15165 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15166 if (testpmd_cl == NULL)
15168 cmdline_interact(testpmd_cl);
15169 cmdline_stdin_exit(testpmd_cl);
15175 if (testpmd_cl != NULL)
15176 cmdline_quit(testpmd_cl);
15180 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15182 if (id == (portid_t)RTE_PORT_ALL) {
15185 RTE_ETH_FOREACH_DEV(pid) {
15186 /* check if need_reconfig has been set to 1 */
15187 if (ports[pid].need_reconfig == 0)
15188 ports[pid].need_reconfig = dev;
15189 /* check if need_reconfig_queues has been set to 1 */
15190 if (ports[pid].need_reconfig_queues == 0)
15191 ports[pid].need_reconfig_queues = queue;
15193 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15194 /* check if need_reconfig has been set to 1 */
15195 if (ports[id].need_reconfig == 0)
15196 ports[id].need_reconfig = dev;
15197 /* check if need_reconfig_queues has been set to 1 */
15198 if (ports[id].need_reconfig_queues == 0)
15199 ports[id].need_reconfig_queues = queue;