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.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
77 #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>
91 #ifdef RTE_LIBRTE_IXGBE_PMD
92 #include <rte_pmd_ixgbe.h>
94 #ifdef RTE_LIBRTE_I40E_PMD
95 #include <rte_pmd_i40e.h>
99 static struct cmdline *testpmd_cl;
101 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
103 /* *** Help command with introduction. *** */
104 struct cmd_help_brief_result {
105 cmdline_fixed_string_t help;
108 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
110 __attribute__((unused)) void *data)
115 "Help is available for the following sections:\n\n"
116 " help control : Start and stop forwarding.\n"
117 " help display : Displaying port, stats and config "
119 " help config : Configuration information.\n"
120 " help ports : Configuring ports.\n"
121 " help registers : Reading and setting port registers.\n"
122 " help filters : Filters configuration help.\n"
123 " help all : All of the above sections.\n\n"
128 cmdline_parse_token_string_t cmd_help_brief_help =
129 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
131 cmdline_parse_inst_t cmd_help_brief = {
132 .f = cmd_help_brief_parsed,
134 .help_str = "help: Show help",
136 (void *)&cmd_help_brief_help,
141 /* *** Help command with help sections. *** */
142 struct cmd_help_long_result {
143 cmdline_fixed_string_t help;
144 cmdline_fixed_string_t section;
147 static void cmd_help_long_parsed(void *parsed_result,
149 __attribute__((unused)) void *data)
152 struct cmd_help_long_result *res = parsed_result;
154 if (!strcmp(res->section, "all"))
157 if (show_all || !strcmp(res->section, "control")) {
162 "Control forwarding:\n"
163 "-------------------\n\n"
166 " Start packet forwarding with current configuration.\n\n"
169 " Start packet forwarding with current config"
170 " after sending one burst of packets.\n\n"
173 " Stop packet forwarding, and display accumulated"
177 " Quit to prompt.\n\n"
181 if (show_all || !strcmp(res->section, "display")) {
189 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
190 " Display information for port_id, or all.\n\n"
192 "show port X rss reta (size) (mask0,mask1,...)\n"
193 " Display the rss redirection table entry indicated"
194 " by masks on port X. size is used to indicate the"
195 " hardware supported reta size\n\n"
197 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
198 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
199 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
200 " Display the RSS hash functions and RSS hash key"
203 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
204 " Clear information for port_id, or all.\n\n"
206 "show (rxq|txq) info (port_id) (queue_id)\n"
207 " Display information for configured RX/TX queue.\n\n"
209 "show config (rxtx|cores|fwd|txpkts)\n"
210 " Display the given configuration.\n\n"
212 "read rxd (port_id) (queue_id) (rxd_id)\n"
213 " Display an RX descriptor of a port RX queue.\n\n"
215 "read txd (port_id) (queue_id) (txd_id)\n"
216 " Display a TX descriptor of a port TX queue.\n\n"
220 if (show_all || !strcmp(res->section, "config")) {
226 "Configuration changes only become active when"
227 " forwarding is started/restarted.\n\n"
230 " Reset forwarding to the default configuration.\n\n"
232 "set verbose (level)\n"
233 " Set the debug verbosity level X.\n\n"
236 " Set number of ports.\n\n"
239 " Set number of cores.\n\n"
241 "set coremask (mask)\n"
242 " Set the forwarding cores hexadecimal mask.\n\n"
244 "set portmask (mask)\n"
245 " Set the forwarding ports hexadecimal mask.\n\n"
248 " Set number of packets per burst.\n\n"
250 "set burst tx delay (microseconds) retry (num)\n"
251 " Set the transmit delay time and number of retries,"
252 " effective when retry is enabled.\n\n"
254 "set txpkts (x[,y]*)\n"
255 " Set the length of each segment of TXONLY"
256 " and optionally CSUM packets.\n\n"
258 "set txsplit (off|on|rand)\n"
259 " Set the split policy for the TX packets."
260 " Right now only applicable for CSUM and TXONLY"
263 "set corelist (x[,y]*)\n"
264 " Set the list of forwarding cores.\n\n"
266 "set portlist (x[,y]*)\n"
267 " Set the list of forwarding ports.\n\n"
269 "set tx loopback (port_id) (on|off)\n"
270 " Enable or disable tx loopback.\n\n"
272 #ifdef RTE_LIBRTE_IXGBE_PMD
273 "set all queues drop (port_id) (on|off)\n"
274 " Set drop enable bit for all queues.\n\n"
276 "set vf split drop (port_id) (vf_id) (on|off)\n"
277 " Set split drop enable bit for a VF from the PF.\n\n"
280 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
281 " Set MAC antispoof for a VF from the PF.\n\n"
283 #ifdef RTE_LIBRTE_IXGBE_PMD
284 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
285 " Enable MACsec offload.\n\n"
287 "set macsec offload (port_id) off\n"
288 " Disable MACsec offload.\n\n"
290 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
291 " Configure MACsec secure connection (SC).\n\n"
293 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
294 " Configure MACsec secure association (SA).\n\n"
297 "set vf broadcast (port_id) (vf_id) (on|off)\n"
298 " Set VF broadcast for a VF from the PF.\n\n"
300 "vlan set strip (on|off) (port_id)\n"
301 " Set the VLAN strip on a port.\n\n"
303 "vlan set stripq (on|off) (port_id,queue_id)\n"
304 " Set the VLAN strip for a queue on a port.\n\n"
306 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
307 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
309 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
310 " Set VLAN insert for a VF from the PF.\n\n"
312 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
313 " Set VLAN antispoof for a VF from the PF.\n\n"
315 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
316 " Set VLAN tag for a VF from the PF.\n\n"
318 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
319 " Set a VF's max bandwidth(Mbps).\n\n"
321 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
322 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
324 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
325 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
327 "vlan set filter (on|off) (port_id)\n"
328 " Set the VLAN filter on a port.\n\n"
330 "vlan set qinq (on|off) (port_id)\n"
331 " Set the VLAN QinQ (extended queue in queue)"
334 "vlan set (inner|outer) tpid (value) (port_id)\n"
335 " Set the VLAN TPID for Packet Filtering on"
338 "rx_vlan add (vlan_id|all) (port_id)\n"
339 " Add a vlan_id, or all identifiers, to the set"
340 " of VLAN identifiers filtered by port_id.\n\n"
342 "rx_vlan rm (vlan_id|all) (port_id)\n"
343 " Remove a vlan_id, or all identifiers, from the set"
344 " of VLAN identifiers filtered by port_id.\n\n"
346 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
347 " Add a vlan_id, to the set of VLAN identifiers"
348 "filtered for VF(s) from port_id.\n\n"
350 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
351 " Remove a vlan_id, to the set of VLAN identifiers"
352 "filtered for VF(s) from port_id.\n\n"
354 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
355 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
356 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
357 " add a tunnel filter of a port.\n\n"
359 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
360 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
361 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
362 " remove a tunnel filter of a port.\n\n"
364 "rx_vxlan_port add (udp_port) (port_id)\n"
365 " Add an UDP port for VXLAN packet filter on a port\n\n"
367 "rx_vxlan_port rm (udp_port) (port_id)\n"
368 " Remove an UDP port for VXLAN packet filter on a port\n\n"
370 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
371 " Set hardware insertion of VLAN IDs (single or double VLAN "
372 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
374 "tx_vlan set pvid port_id vlan_id (on|off)\n"
375 " Set port based TX VLAN insertion.\n\n"
377 "tx_vlan reset (port_id)\n"
378 " Disable hardware insertion of a VLAN header in"
379 " packets sent on a port.\n\n"
381 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
382 " Select hardware or software calculation of the"
383 " checksum when transmitting a packet using the"
384 " csum forward engine.\n"
385 " ip|udp|tcp|sctp always concern the inner layer.\n"
386 " outer-ip concerns the outer IP layer in"
387 " case the packet is recognized as a tunnel packet by"
388 " the forward engine (vxlan, gre and ipip are supported)\n"
389 " Please check the NIC datasheet for HW limits.\n\n"
391 "csum parse-tunnel (on|off) (tx_port_id)\n"
392 " If disabled, treat tunnel packets as non-tunneled"
393 " packets (treat inner headers as payload). The port\n"
394 " argument is the port used for TX in csum forward"
397 "csum show (port_id)\n"
398 " Display tx checksum offload configuration\n\n"
400 "tso set (segsize) (portid)\n"
401 " Enable TCP Segmentation Offload in csum forward"
403 " Please check the NIC datasheet for HW limits.\n\n"
406 " Display the status of TCP Segmentation Offload.\n\n"
409 " Set packet forwarding mode.\n\n"
411 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
412 " Add a MAC address on port_id.\n\n"
414 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
415 " Remove a MAC address from port_id.\n\n"
417 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
418 " Set the default MAC address for port_id.\n\n"
420 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
421 " Add a MAC address for a VF on the port.\n\n"
423 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
424 " Set the MAC address for a VF from the PF.\n\n"
426 "set port (port_id) uta (mac_address|all) (on|off)\n"
427 " Add/Remove a or all unicast hash filter(s)"
430 "set promisc (port_id|all) (on|off)\n"
431 " Set the promiscuous mode on port_id, or all.\n\n"
433 "set allmulti (port_id|all) (on|off)\n"
434 " Set the allmulti mode on port_id, or all.\n\n"
436 "set vf promisc (port_id) (vf_id) (on|off)\n"
437 " Set unicast promiscuous mode for a VF from the PF.\n\n"
439 "set vf allmulti (port_id) (vf_id) (on|off)\n"
440 " Set multicast promiscuous mode for a VF from the PF.\n\n"
442 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
443 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
444 " (on|off) autoneg (on|off) (port_id)\n"
445 "set flow_ctrl rx (on|off) (portid)\n"
446 "set flow_ctrl tx (on|off) (portid)\n"
447 "set flow_ctrl high_water (high_water) (portid)\n"
448 "set flow_ctrl low_water (low_water) (portid)\n"
449 "set flow_ctrl pause_time (pause_time) (portid)\n"
450 "set flow_ctrl send_xon (send_xon) (portid)\n"
451 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
452 "set flow_ctrl autoneg (on|off) (port_id)\n"
453 " Set the link flow control parameter on a port.\n\n"
455 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
456 " (low_water) (pause_time) (priority) (port_id)\n"
457 " Set the priority flow control parameter on a"
460 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
461 " Set statistics mapping (qmapping 0..15) for RX/TX"
463 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
464 " on port 0 to mapping 5.\n\n"
466 "set port (port_id) vf (vf_id) rx|tx on|off\n"
467 " Enable/Disable a VF receive/tranmit from a port\n\n"
469 "set port (port_id) vf (vf_id) (mac_addr)"
470 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
471 " Add/Remove unicast or multicast MAC addr filter"
474 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
476 " AUPE:accepts untagged VLAN;"
477 "ROPE:accept unicast hash\n\n"
478 " BAM:accepts broadcast packets;"
479 "MPE:accepts all multicast packets\n\n"
480 " Enable/Disable a VF receive mode of a port\n\n"
482 "set port (port_id) queue (queue_id) rate (rate_num)\n"
483 " Set rate limit for a queue of a port\n\n"
485 "set port (port_id) vf (vf_id) rate (rate_num) "
486 "queue_mask (queue_mask_value)\n"
487 " Set rate limit for queues in VF of a port\n\n"
489 "set port (port_id) mirror-rule (rule_id)"
490 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
491 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
492 " Set pool or vlan type mirror rule on a port.\n"
493 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
494 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
497 "set port (port_id) mirror-rule (rule_id)"
498 " (uplink-mirror|downlink-mirror) dst-pool"
499 " (pool_id) (on|off)\n"
500 " Set uplink or downlink type mirror rule on a port.\n"
501 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
502 " 0 on' enable mirror income traffic to pool 0.\n\n"
504 "reset port (port_id) mirror-rule (rule_id)\n"
505 " Reset a mirror rule.\n\n"
507 "set flush_rx (on|off)\n"
508 " Flush (default) or don't flush RX streams before"
509 " forwarding. Mainly used with PCAP drivers.\n\n"
511 #ifdef RTE_NIC_BYPASS
512 "set bypass mode (normal|bypass|isolate) (port_id)\n"
513 " Set the bypass mode for the lowest port on bypass enabled"
516 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
517 "mode (normal|bypass|isolate) (port_id)\n"
518 " Set the event required to initiate specified bypass mode for"
519 " the lowest port on a bypass enabled NIC where:\n"
520 " timeout = enable bypass after watchdog timeout.\n"
521 " os_on = enable bypass when OS/board is powered on.\n"
522 " os_off = enable bypass when OS/board is powered off.\n"
523 " power_on = enable bypass when power supply is turned on.\n"
524 " power_off = enable bypass when power supply is turned off."
527 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
528 " Set the bypass watchdog timeout to 'n' seconds"
529 " where 0 = instant.\n\n"
531 "show bypass config (port_id)\n"
532 " Show the bypass configuration for a bypass enabled NIC"
533 " using the lowest port on the NIC.\n\n"
535 #ifdef RTE_LIBRTE_PMD_BOND
536 "create bonded device (mode) (socket)\n"
537 " Create a new bonded device with specific bonding mode and socket.\n\n"
539 "add bonding slave (slave_id) (port_id)\n"
540 " Add a slave device to a bonded device.\n\n"
542 "remove bonding slave (slave_id) (port_id)\n"
543 " Remove a slave device from a bonded device.\n\n"
545 "set bonding mode (value) (port_id)\n"
546 " Set the bonding mode on a bonded device.\n\n"
548 "set bonding primary (slave_id) (port_id)\n"
549 " Set the primary slave for a bonded device.\n\n"
551 "show bonding config (port_id)\n"
552 " Show the bonding config for port_id.\n\n"
554 "set bonding mac_addr (port_id) (address)\n"
555 " Set the MAC address of a bonded device.\n\n"
557 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
558 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
560 "set bonding mon_period (port_id) (value)\n"
561 " Set the bonding link status monitoring polling period in ms.\n\n"
563 "set link-up port (port_id)\n"
564 " Set link up for a port.\n\n"
566 "set link-down port (port_id)\n"
567 " Set link down for a port.\n\n"
569 "E-tag set insertion on port-tag-id (value)"
570 " port (port_id) vf (vf_id)\n"
571 " Enable E-tag insertion for a VF on a port\n\n"
573 "E-tag set insertion off port (port_id) vf (vf_id)\n"
574 " Disable E-tag insertion for a VF on a port\n\n"
576 "E-tag set stripping (on|off) port (port_id)\n"
577 " Enable/disable E-tag stripping on a port\n\n"
579 "E-tag set forwarding (on|off) port (port_id)\n"
580 " Enable/disable E-tag based forwarding"
583 "E-tag set filter add e-tag-id (value) dst-pool"
584 " (pool_id) port (port_id)\n"
585 " Add an E-tag forwarding filter on a port\n\n"
587 "E-tag set filter del e-tag-id (value) port (port_id)\n"
588 " Delete an E-tag forwarding filter on a port\n\n"
590 , list_pkt_forwarding_modes()
594 if (show_all || !strcmp(res->section, "ports")) {
600 "----------------\n\n"
602 "port start (port_id|all)\n"
603 " Start all ports or port_id.\n\n"
605 "port stop (port_id|all)\n"
606 " Stop all ports or port_id.\n\n"
608 "port close (port_id|all)\n"
609 " Close all ports or port_id.\n\n"
611 "port attach (ident)\n"
612 " Attach physical or virtual dev by pci address or virtual device name\n\n"
614 "port detach (port_id)\n"
615 " Detach physical or virtual dev by port_id\n\n"
617 "port config (port_id|all)"
618 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
619 " duplex (half|full|auto)\n"
620 " Set speed and duplex for all ports or port_id\n\n"
622 "port config all (rxq|txq|rxd|txd) (value)\n"
623 " Set number for rxq/txq/rxd/txd.\n\n"
625 "port config all max-pkt-len (value)\n"
626 " Set the max packet length.\n\n"
628 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
629 "hw-vlan-strip|hw-vlan-extend|drop-en)"
631 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
634 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
635 " Set the RSS mode.\n\n"
637 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
638 " Set the RSS redirection table.\n\n"
640 "port config (port_id) dcb vt (on|off) (traffic_class)"
642 " Set the DCB mode.\n\n"
644 "port config all burst (value)\n"
645 " Set the number of packets per burst.\n\n"
647 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
649 " Set the ring prefetch/host/writeback threshold"
650 " for tx/rx queue.\n\n"
652 "port config all (txfreet|txrst|rxfreet) (value)\n"
653 " Set free threshold for rx/tx, or set"
654 " tx rs bit threshold.\n\n"
655 "port config mtu X value\n"
656 " Set the MTU of port X to a given value\n\n"
658 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
659 " Start/stop a rx/tx queue of port X. Only take effect"
660 " when port X is started\n\n"
662 "port config (port_id|all) l2-tunnel E-tag ether-type"
664 " Set the value of E-tag ether-type.\n\n"
666 "port config (port_id|all) l2-tunnel E-tag"
667 " (enable|disable)\n"
668 " Enable/disable the E-tag support.\n\n"
672 if (show_all || !strcmp(res->section, "registers")) {
680 "read reg (port_id) (address)\n"
681 " Display value of a port register.\n\n"
683 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
684 " Display a port register bit field.\n\n"
686 "read regbit (port_id) (address) (bit_x)\n"
687 " Display a single port register bit.\n\n"
689 "write reg (port_id) (address) (value)\n"
690 " Set value of a port register.\n\n"
692 "write regfield (port_id) (address) (bit_x) (bit_y)"
694 " Set bit field of a port register.\n\n"
696 "write regbit (port_id) (address) (bit_x) (value)\n"
697 " Set single bit value of a port register.\n\n"
700 if (show_all || !strcmp(res->section, "filters")) {
708 "ethertype_filter (port_id) (add|del)"
709 " (mac_addr|mac_ignr) (mac_address) ethertype"
710 " (ether_type) (drop|fwd) queue (queue_id)\n"
711 " Add/Del an ethertype filter.\n\n"
713 "2tuple_filter (port_id) (add|del)"
714 " dst_port (dst_port_value) protocol (protocol_value)"
715 " mask (mask_value) tcp_flags (tcp_flags_value)"
716 " priority (prio_value) queue (queue_id)\n"
717 " Add/Del a 2tuple filter.\n\n"
719 "5tuple_filter (port_id) (add|del)"
720 " dst_ip (dst_address) src_ip (src_address)"
721 " dst_port (dst_port_value) src_port (src_port_value)"
722 " protocol (protocol_value)"
723 " mask (mask_value) tcp_flags (tcp_flags_value)"
724 " priority (prio_value) queue (queue_id)\n"
725 " Add/Del a 5tuple filter.\n\n"
727 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
728 " Add/Del syn filter.\n\n"
730 "flex_filter (port_id) (add|del) len (len_value)"
731 " bytes (bytes_value) mask (mask_value)"
732 " priority (prio_value) queue (queue_id)\n"
733 " Add/Del a flex filter.\n\n"
735 "flow_director_filter (port_id) mode IP (add|del|update)"
736 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
737 " src (src_ip_address) dst (dst_ip_address)"
738 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
739 " vlan (vlan_value) flexbytes (flexbytes_value)"
740 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
741 " fd_id (fd_id_value)\n"
742 " Add/Del an IP type flow director filter.\n\n"
744 "flow_director_filter (port_id) mode IP (add|del|update)"
745 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
746 " src (src_ip_address) (src_port)"
747 " dst (dst_ip_address) (dst_port)"
748 " tos (tos_value) ttl (ttl_value)"
749 " vlan (vlan_value) flexbytes (flexbytes_value)"
750 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
751 " fd_id (fd_id_value)\n"
752 " Add/Del an UDP/TCP type flow director filter.\n\n"
754 "flow_director_filter (port_id) mode IP (add|del|update)"
755 " flow (ipv4-sctp|ipv6-sctp)"
756 " src (src_ip_address) (src_port)"
757 " dst (dst_ip_address) (dst_port)"
758 " tag (verification_tag) "
759 " tos (tos_value) ttl (ttl_value)"
761 " flexbytes (flexbytes_value) (drop|fwd)"
762 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
763 " Add/Del a SCTP type flow director filter.\n\n"
765 "flow_director_filter (port_id) mode IP (add|del|update)"
766 " flow l2_payload ether (ethertype)"
767 " flexbytes (flexbytes_value) (drop|fwd)"
768 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
769 " Add/Del a l2 payload type flow director filter.\n\n"
771 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
772 " mac (mac_address) vlan (vlan_value)"
773 " flexbytes (flexbytes_value) (drop|fwd)"
774 " queue (queue_id) fd_id (fd_id_value)\n"
775 " Add/Del a MAC-VLAN flow director filter.\n\n"
777 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
778 " mac (mac_address) vlan (vlan_value)"
779 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
780 " flexbytes (flexbytes_value) (drop|fwd)"
781 " queue (queue_id) fd_id (fd_id_value)\n"
782 " Add/Del a Tunnel flow director filter.\n\n"
784 "flush_flow_director (port_id)\n"
785 " Flush all flow director entries of a device.\n\n"
787 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
788 " src_mask (ipv4_src) (ipv6_src) (src_port)"
789 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
790 " Set flow director IP mask.\n\n"
792 "flow_director_mask (port_id) mode MAC-VLAN"
793 " vlan (vlan_value)\n"
794 " Set flow director MAC-VLAN mask.\n\n"
796 "flow_director_mask (port_id) mode Tunnel"
797 " vlan (vlan_value) mac (mac_value)"
798 " tunnel-type (tunnel_type_value)"
799 " tunnel-id (tunnel_id_value)\n"
800 " Set flow director Tunnel mask.\n\n"
802 "flow_director_flex_mask (port_id)"
803 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
804 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
806 " Configure mask of flex payload.\n\n"
808 "flow_director_flex_payload (port_id)"
809 " (raw|l2|l3|l4) (config)\n"
810 " Configure flex payload selection.\n\n"
812 "get_sym_hash_ena_per_port (port_id)\n"
813 " get symmetric hash enable configuration per port.\n\n"
815 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
816 " set symmetric hash enable configuration per port"
817 " to enable or disable.\n\n"
819 "get_hash_global_config (port_id)\n"
820 " Get the global configurations of hash filters.\n\n"
822 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
823 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
824 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
825 " (enable|disable)\n"
826 " Set the global configurations of hash filters.\n\n"
828 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
829 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
830 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
831 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
832 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
833 "ipv6-next-header|udp-src-port|udp-dst-port|"
834 "tcp-src-port|tcp-dst-port|sctp-src-port|"
835 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
836 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
837 "fld-8th|none) (select|add)\n"
838 " Set the input set for hash.\n\n"
840 "set_fdir_input_set (port_id) "
841 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
842 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
843 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
844 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
845 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
846 "udp-dst-port|tcp-src-port|tcp-dst-port|"
847 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
849 " Set the input set for FDir.\n\n"
851 "flow validate {port_id}"
852 " [group {group_id}] [priority {level}]"
853 " [ingress] [egress]"
854 " pattern {item} [/ {item} [...]] / end"
855 " actions {action} [/ {action} [...]] / end\n"
856 " Check whether a flow rule can be created.\n\n"
858 "flow create {port_id}"
859 " [group {group_id}] [priority {level}]"
860 " [ingress] [egress]"
861 " pattern {item} [/ {item} [...]] / end"
862 " actions {action} [/ {action} [...]] / end\n"
863 " Create a flow rule.\n\n"
865 "flow destroy {port_id} rule {rule_id} [...]\n"
866 " Destroy specific flow rules.\n\n"
868 "flow flush {port_id}\n"
869 " Destroy all flow rules.\n\n"
871 "flow query {port_id} {rule_id} {action}\n"
872 " Query an existing flow rule.\n\n"
874 "flow list {port_id} [group {group_id}] [...]\n"
875 " List existing flow rules sorted by priority,"
876 " filtered by group identifiers.\n\n"
881 cmdline_parse_token_string_t cmd_help_long_help =
882 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
884 cmdline_parse_token_string_t cmd_help_long_section =
885 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
886 "all#control#display#config#"
887 "ports#registers#filters");
889 cmdline_parse_inst_t cmd_help_long = {
890 .f = cmd_help_long_parsed,
892 .help_str = "help all|control|display|config|ports|register|filters: "
895 (void *)&cmd_help_long_help,
896 (void *)&cmd_help_long_section,
902 /* *** start/stop/close all ports *** */
903 struct cmd_operate_port_result {
904 cmdline_fixed_string_t keyword;
905 cmdline_fixed_string_t name;
906 cmdline_fixed_string_t value;
909 static void cmd_operate_port_parsed(void *parsed_result,
910 __attribute__((unused)) struct cmdline *cl,
911 __attribute__((unused)) void *data)
913 struct cmd_operate_port_result *res = parsed_result;
915 if (!strcmp(res->name, "start"))
916 start_port(RTE_PORT_ALL);
917 else if (!strcmp(res->name, "stop"))
918 stop_port(RTE_PORT_ALL);
919 else if (!strcmp(res->name, "close"))
920 close_port(RTE_PORT_ALL);
922 printf("Unknown parameter\n");
925 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
926 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
928 cmdline_parse_token_string_t cmd_operate_port_all_port =
929 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
931 cmdline_parse_token_string_t cmd_operate_port_all_all =
932 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
934 cmdline_parse_inst_t cmd_operate_port = {
935 .f = cmd_operate_port_parsed,
937 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
939 (void *)&cmd_operate_port_all_cmd,
940 (void *)&cmd_operate_port_all_port,
941 (void *)&cmd_operate_port_all_all,
946 /* *** start/stop/close specific port *** */
947 struct cmd_operate_specific_port_result {
948 cmdline_fixed_string_t keyword;
949 cmdline_fixed_string_t name;
953 static void cmd_operate_specific_port_parsed(void *parsed_result,
954 __attribute__((unused)) struct cmdline *cl,
955 __attribute__((unused)) void *data)
957 struct cmd_operate_specific_port_result *res = parsed_result;
959 if (!strcmp(res->name, "start"))
960 start_port(res->value);
961 else if (!strcmp(res->name, "stop"))
962 stop_port(res->value);
963 else if (!strcmp(res->name, "close"))
964 close_port(res->value);
966 printf("Unknown parameter\n");
969 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
970 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
972 cmdline_parse_token_string_t cmd_operate_specific_port_port =
973 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
974 name, "start#stop#close");
975 cmdline_parse_token_num_t cmd_operate_specific_port_id =
976 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
979 cmdline_parse_inst_t cmd_operate_specific_port = {
980 .f = cmd_operate_specific_port_parsed,
982 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
984 (void *)&cmd_operate_specific_port_cmd,
985 (void *)&cmd_operate_specific_port_port,
986 (void *)&cmd_operate_specific_port_id,
991 /* *** attach a specified port *** */
992 struct cmd_operate_attach_port_result {
993 cmdline_fixed_string_t port;
994 cmdline_fixed_string_t keyword;
995 cmdline_fixed_string_t identifier;
998 static void cmd_operate_attach_port_parsed(void *parsed_result,
999 __attribute__((unused)) struct cmdline *cl,
1000 __attribute__((unused)) void *data)
1002 struct cmd_operate_attach_port_result *res = parsed_result;
1004 if (!strcmp(res->keyword, "attach"))
1005 attach_port(res->identifier);
1007 printf("Unknown parameter\n");
1010 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1011 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1013 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1014 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1016 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1017 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1020 cmdline_parse_inst_t cmd_operate_attach_port = {
1021 .f = cmd_operate_attach_port_parsed,
1023 .help_str = "port attach <identifier>: "
1024 "(identifier: pci address or virtual dev name)",
1026 (void *)&cmd_operate_attach_port_port,
1027 (void *)&cmd_operate_attach_port_keyword,
1028 (void *)&cmd_operate_attach_port_identifier,
1033 /* *** detach a specified port *** */
1034 struct cmd_operate_detach_port_result {
1035 cmdline_fixed_string_t port;
1036 cmdline_fixed_string_t keyword;
1040 static void cmd_operate_detach_port_parsed(void *parsed_result,
1041 __attribute__((unused)) struct cmdline *cl,
1042 __attribute__((unused)) void *data)
1044 struct cmd_operate_detach_port_result *res = parsed_result;
1046 if (!strcmp(res->keyword, "detach"))
1047 detach_port(res->port_id);
1049 printf("Unknown parameter\n");
1052 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1053 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1055 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1056 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1058 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1059 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1062 cmdline_parse_inst_t cmd_operate_detach_port = {
1063 .f = cmd_operate_detach_port_parsed,
1065 .help_str = "port detach <port_id>",
1067 (void *)&cmd_operate_detach_port_port,
1068 (void *)&cmd_operate_detach_port_keyword,
1069 (void *)&cmd_operate_detach_port_port_id,
1074 /* *** configure speed for all ports *** */
1075 struct cmd_config_speed_all {
1076 cmdline_fixed_string_t port;
1077 cmdline_fixed_string_t keyword;
1078 cmdline_fixed_string_t all;
1079 cmdline_fixed_string_t item1;
1080 cmdline_fixed_string_t item2;
1081 cmdline_fixed_string_t value1;
1082 cmdline_fixed_string_t value2;
1086 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1091 if (!strcmp(duplexstr, "half")) {
1092 duplex = ETH_LINK_HALF_DUPLEX;
1093 } else if (!strcmp(duplexstr, "full")) {
1094 duplex = ETH_LINK_FULL_DUPLEX;
1095 } else if (!strcmp(duplexstr, "auto")) {
1096 duplex = ETH_LINK_FULL_DUPLEX;
1098 printf("Unknown duplex parameter\n");
1102 if (!strcmp(speedstr, "10")) {
1103 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1104 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1105 } else if (!strcmp(speedstr, "100")) {
1106 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1107 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1109 if (duplex != ETH_LINK_FULL_DUPLEX) {
1110 printf("Invalid speed/duplex parameters\n");
1113 if (!strcmp(speedstr, "1000")) {
1114 *speed = ETH_LINK_SPEED_1G;
1115 } else if (!strcmp(speedstr, "10000")) {
1116 *speed = ETH_LINK_SPEED_10G;
1117 } else if (!strcmp(speedstr, "25000")) {
1118 *speed = ETH_LINK_SPEED_25G;
1119 } else if (!strcmp(speedstr, "40000")) {
1120 *speed = ETH_LINK_SPEED_40G;
1121 } else if (!strcmp(speedstr, "50000")) {
1122 *speed = ETH_LINK_SPEED_50G;
1123 } else if (!strcmp(speedstr, "100000")) {
1124 *speed = ETH_LINK_SPEED_100G;
1125 } else if (!strcmp(speedstr, "auto")) {
1126 *speed = ETH_LINK_SPEED_AUTONEG;
1128 printf("Unknown speed parameter\n");
1137 cmd_config_speed_all_parsed(void *parsed_result,
1138 __attribute__((unused)) struct cmdline *cl,
1139 __attribute__((unused)) void *data)
1141 struct cmd_config_speed_all *res = parsed_result;
1142 uint32_t link_speed;
1145 if (!all_ports_stopped()) {
1146 printf("Please stop all ports first\n");
1150 if (parse_and_check_speed_duplex(res->value1, res->value2,
1154 FOREACH_PORT(pid, ports) {
1155 ports[pid].dev_conf.link_speeds = link_speed;
1158 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1161 cmdline_parse_token_string_t cmd_config_speed_all_port =
1162 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1163 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1164 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1166 cmdline_parse_token_string_t cmd_config_speed_all_all =
1167 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1168 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1169 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1170 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1171 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1172 "10#100#1000#10000#25000#40000#50000#100000#auto");
1173 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1174 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1175 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1176 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1179 cmdline_parse_inst_t cmd_config_speed_all = {
1180 .f = cmd_config_speed_all_parsed,
1182 .help_str = "port config all speed "
1183 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1186 (void *)&cmd_config_speed_all_port,
1187 (void *)&cmd_config_speed_all_keyword,
1188 (void *)&cmd_config_speed_all_all,
1189 (void *)&cmd_config_speed_all_item1,
1190 (void *)&cmd_config_speed_all_value1,
1191 (void *)&cmd_config_speed_all_item2,
1192 (void *)&cmd_config_speed_all_value2,
1197 /* *** configure speed for specific port *** */
1198 struct cmd_config_speed_specific {
1199 cmdline_fixed_string_t port;
1200 cmdline_fixed_string_t keyword;
1202 cmdline_fixed_string_t item1;
1203 cmdline_fixed_string_t item2;
1204 cmdline_fixed_string_t value1;
1205 cmdline_fixed_string_t value2;
1209 cmd_config_speed_specific_parsed(void *parsed_result,
1210 __attribute__((unused)) struct cmdline *cl,
1211 __attribute__((unused)) void *data)
1213 struct cmd_config_speed_specific *res = parsed_result;
1214 uint32_t link_speed;
1216 if (!all_ports_stopped()) {
1217 printf("Please stop all ports first\n");
1221 if (port_id_is_invalid(res->id, ENABLED_WARN))
1224 if (parse_and_check_speed_duplex(res->value1, res->value2,
1228 ports[res->id].dev_conf.link_speeds = link_speed;
1230 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1234 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1235 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1237 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1238 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1240 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1241 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1242 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1243 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1245 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1246 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1247 "10#100#1000#10000#25000#40000#50000#100000#auto");
1248 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1249 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1251 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1252 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1255 cmdline_parse_inst_t cmd_config_speed_specific = {
1256 .f = cmd_config_speed_specific_parsed,
1258 .help_str = "port config <port_id> speed "
1259 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1262 (void *)&cmd_config_speed_specific_port,
1263 (void *)&cmd_config_speed_specific_keyword,
1264 (void *)&cmd_config_speed_specific_id,
1265 (void *)&cmd_config_speed_specific_item1,
1266 (void *)&cmd_config_speed_specific_value1,
1267 (void *)&cmd_config_speed_specific_item2,
1268 (void *)&cmd_config_speed_specific_value2,
1273 /* *** configure txq/rxq, txd/rxd *** */
1274 struct cmd_config_rx_tx {
1275 cmdline_fixed_string_t port;
1276 cmdline_fixed_string_t keyword;
1277 cmdline_fixed_string_t all;
1278 cmdline_fixed_string_t name;
1283 cmd_config_rx_tx_parsed(void *parsed_result,
1284 __attribute__((unused)) struct cmdline *cl,
1285 __attribute__((unused)) void *data)
1287 struct cmd_config_rx_tx *res = parsed_result;
1289 if (!all_ports_stopped()) {
1290 printf("Please stop all ports first\n");
1293 if (!strcmp(res->name, "rxq")) {
1294 if (!res->value && !nb_txq) {
1295 printf("Warning: Either rx or tx queues should be non zero\n");
1298 nb_rxq = res->value;
1300 else if (!strcmp(res->name, "txq")) {
1301 if (!res->value && !nb_rxq) {
1302 printf("Warning: Either rx or tx queues should be non zero\n");
1305 nb_txq = res->value;
1307 else if (!strcmp(res->name, "rxd")) {
1308 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1309 printf("rxd %d invalid - must be > 0 && <= %d\n",
1310 res->value, RTE_TEST_RX_DESC_MAX);
1313 nb_rxd = res->value;
1314 } else if (!strcmp(res->name, "txd")) {
1315 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1316 printf("txd %d invalid - must be > 0 && <= %d\n",
1317 res->value, RTE_TEST_TX_DESC_MAX);
1320 nb_txd = res->value;
1322 printf("Unknown parameter\n");
1330 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1333 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1334 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1335 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1336 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1337 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1338 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1339 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1340 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1342 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1343 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1345 cmdline_parse_inst_t cmd_config_rx_tx = {
1346 .f = cmd_config_rx_tx_parsed,
1348 .help_str = "port config all rxq|txq|rxd|txd <value>",
1350 (void *)&cmd_config_rx_tx_port,
1351 (void *)&cmd_config_rx_tx_keyword,
1352 (void *)&cmd_config_rx_tx_all,
1353 (void *)&cmd_config_rx_tx_name,
1354 (void *)&cmd_config_rx_tx_value,
1359 /* *** config max packet length *** */
1360 struct cmd_config_max_pkt_len_result {
1361 cmdline_fixed_string_t port;
1362 cmdline_fixed_string_t keyword;
1363 cmdline_fixed_string_t all;
1364 cmdline_fixed_string_t name;
1369 cmd_config_max_pkt_len_parsed(void *parsed_result,
1370 __attribute__((unused)) struct cmdline *cl,
1371 __attribute__((unused)) void *data)
1373 struct cmd_config_max_pkt_len_result *res = parsed_result;
1375 if (!all_ports_stopped()) {
1376 printf("Please stop all ports first\n");
1380 if (!strcmp(res->name, "max-pkt-len")) {
1381 if (res->value < ETHER_MIN_LEN) {
1382 printf("max-pkt-len can not be less than %d\n",
1386 if (res->value == rx_mode.max_rx_pkt_len)
1389 rx_mode.max_rx_pkt_len = res->value;
1390 if (res->value > ETHER_MAX_LEN)
1391 rx_mode.jumbo_frame = 1;
1393 rx_mode.jumbo_frame = 0;
1395 printf("Unknown parameter\n");
1401 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1404 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1407 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1410 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1413 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1416 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1417 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1420 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1421 .f = cmd_config_max_pkt_len_parsed,
1423 .help_str = "port config all max-pkt-len <value>",
1425 (void *)&cmd_config_max_pkt_len_port,
1426 (void *)&cmd_config_max_pkt_len_keyword,
1427 (void *)&cmd_config_max_pkt_len_all,
1428 (void *)&cmd_config_max_pkt_len_name,
1429 (void *)&cmd_config_max_pkt_len_value,
1434 /* *** configure port MTU *** */
1435 struct cmd_config_mtu_result {
1436 cmdline_fixed_string_t port;
1437 cmdline_fixed_string_t keyword;
1438 cmdline_fixed_string_t mtu;
1444 cmd_config_mtu_parsed(void *parsed_result,
1445 __attribute__((unused)) struct cmdline *cl,
1446 __attribute__((unused)) void *data)
1448 struct cmd_config_mtu_result *res = parsed_result;
1450 if (res->value < ETHER_MIN_LEN) {
1451 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1454 port_mtu_set(res->port_id, res->value);
1457 cmdline_parse_token_string_t cmd_config_mtu_port =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1460 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1463 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1464 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1466 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1467 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1468 cmdline_parse_token_num_t cmd_config_mtu_value =
1469 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1471 cmdline_parse_inst_t cmd_config_mtu = {
1472 .f = cmd_config_mtu_parsed,
1474 .help_str = "port config mtu <port_id> <value>",
1476 (void *)&cmd_config_mtu_port,
1477 (void *)&cmd_config_mtu_keyword,
1478 (void *)&cmd_config_mtu_mtu,
1479 (void *)&cmd_config_mtu_port_id,
1480 (void *)&cmd_config_mtu_value,
1485 /* *** configure rx mode *** */
1486 struct cmd_config_rx_mode_flag {
1487 cmdline_fixed_string_t port;
1488 cmdline_fixed_string_t keyword;
1489 cmdline_fixed_string_t all;
1490 cmdline_fixed_string_t name;
1491 cmdline_fixed_string_t value;
1495 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1496 __attribute__((unused)) struct cmdline *cl,
1497 __attribute__((unused)) void *data)
1499 struct cmd_config_rx_mode_flag *res = parsed_result;
1501 if (!all_ports_stopped()) {
1502 printf("Please stop all ports first\n");
1506 if (!strcmp(res->name, "crc-strip")) {
1507 if (!strcmp(res->value, "on"))
1508 rx_mode.hw_strip_crc = 1;
1509 else if (!strcmp(res->value, "off"))
1510 rx_mode.hw_strip_crc = 0;
1512 printf("Unknown parameter\n");
1515 } else if (!strcmp(res->name, "scatter")) {
1516 if (!strcmp(res->value, "on"))
1517 rx_mode.enable_scatter = 1;
1518 else if (!strcmp(res->value, "off"))
1519 rx_mode.enable_scatter = 0;
1521 printf("Unknown parameter\n");
1524 } else if (!strcmp(res->name, "rx-cksum")) {
1525 if (!strcmp(res->value, "on"))
1526 rx_mode.hw_ip_checksum = 1;
1527 else if (!strcmp(res->value, "off"))
1528 rx_mode.hw_ip_checksum = 0;
1530 printf("Unknown parameter\n");
1533 } else if (!strcmp(res->name, "hw-vlan")) {
1534 if (!strcmp(res->value, "on")) {
1535 rx_mode.hw_vlan_filter = 1;
1536 rx_mode.hw_vlan_strip = 1;
1538 else if (!strcmp(res->value, "off")) {
1539 rx_mode.hw_vlan_filter = 0;
1540 rx_mode.hw_vlan_strip = 0;
1543 printf("Unknown parameter\n");
1546 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1547 if (!strcmp(res->value, "on"))
1548 rx_mode.hw_vlan_filter = 1;
1549 else if (!strcmp(res->value, "off"))
1550 rx_mode.hw_vlan_filter = 0;
1552 printf("Unknown parameter\n");
1555 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1556 if (!strcmp(res->value, "on"))
1557 rx_mode.hw_vlan_strip = 1;
1558 else if (!strcmp(res->value, "off"))
1559 rx_mode.hw_vlan_strip = 0;
1561 printf("Unknown parameter\n");
1564 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1565 if (!strcmp(res->value, "on"))
1566 rx_mode.hw_vlan_extend = 1;
1567 else if (!strcmp(res->value, "off"))
1568 rx_mode.hw_vlan_extend = 0;
1570 printf("Unknown parameter\n");
1573 } else if (!strcmp(res->name, "drop-en")) {
1574 if (!strcmp(res->value, "on"))
1576 else if (!strcmp(res->value, "off"))
1579 printf("Unknown parameter\n");
1583 printf("Unknown parameter\n");
1589 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1592 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1593 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1594 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1595 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1597 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1598 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1599 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1600 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1601 "crc-strip#scatter#rx-cksum#hw-vlan#"
1602 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1603 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1604 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1607 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1608 .f = cmd_config_rx_mode_flag_parsed,
1610 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1611 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1613 (void *)&cmd_config_rx_mode_flag_port,
1614 (void *)&cmd_config_rx_mode_flag_keyword,
1615 (void *)&cmd_config_rx_mode_flag_all,
1616 (void *)&cmd_config_rx_mode_flag_name,
1617 (void *)&cmd_config_rx_mode_flag_value,
1622 /* *** configure rss *** */
1623 struct cmd_config_rss {
1624 cmdline_fixed_string_t port;
1625 cmdline_fixed_string_t keyword;
1626 cmdline_fixed_string_t all;
1627 cmdline_fixed_string_t name;
1628 cmdline_fixed_string_t value;
1632 cmd_config_rss_parsed(void *parsed_result,
1633 __attribute__((unused)) struct cmdline *cl,
1634 __attribute__((unused)) void *data)
1636 struct cmd_config_rss *res = parsed_result;
1637 struct rte_eth_rss_conf rss_conf;
1641 if (!strcmp(res->value, "all"))
1642 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1643 ETH_RSS_UDP | ETH_RSS_SCTP |
1645 else if (!strcmp(res->value, "ip"))
1646 rss_conf.rss_hf = ETH_RSS_IP;
1647 else if (!strcmp(res->value, "udp"))
1648 rss_conf.rss_hf = ETH_RSS_UDP;
1649 else if (!strcmp(res->value, "tcp"))
1650 rss_conf.rss_hf = ETH_RSS_TCP;
1651 else if (!strcmp(res->value, "sctp"))
1652 rss_conf.rss_hf = ETH_RSS_SCTP;
1653 else if (!strcmp(res->value, "ether"))
1654 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1655 else if (!strcmp(res->value, "port"))
1656 rss_conf.rss_hf = ETH_RSS_PORT;
1657 else if (!strcmp(res->value, "vxlan"))
1658 rss_conf.rss_hf = ETH_RSS_VXLAN;
1659 else if (!strcmp(res->value, "geneve"))
1660 rss_conf.rss_hf = ETH_RSS_GENEVE;
1661 else if (!strcmp(res->value, "nvgre"))
1662 rss_conf.rss_hf = ETH_RSS_NVGRE;
1663 else if (!strcmp(res->value, "none"))
1664 rss_conf.rss_hf = 0;
1666 printf("Unknown parameter\n");
1669 rss_conf.rss_key = NULL;
1670 for (i = 0; i < rte_eth_dev_count(); i++) {
1671 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1673 printf("Configuration of RSS hash at ethernet port %d "
1674 "failed with error (%d): %s.\n",
1675 i, -diag, strerror(-diag));
1679 cmdline_parse_token_string_t cmd_config_rss_port =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1681 cmdline_parse_token_string_t cmd_config_rss_keyword =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1683 cmdline_parse_token_string_t cmd_config_rss_all =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1685 cmdline_parse_token_string_t cmd_config_rss_name =
1686 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1687 cmdline_parse_token_string_t cmd_config_rss_value =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1689 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1691 cmdline_parse_inst_t cmd_config_rss = {
1692 .f = cmd_config_rss_parsed,
1694 .help_str = "port config all rss "
1695 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1697 (void *)&cmd_config_rss_port,
1698 (void *)&cmd_config_rss_keyword,
1699 (void *)&cmd_config_rss_all,
1700 (void *)&cmd_config_rss_name,
1701 (void *)&cmd_config_rss_value,
1706 /* *** configure rss hash key *** */
1707 struct cmd_config_rss_hash_key {
1708 cmdline_fixed_string_t port;
1709 cmdline_fixed_string_t config;
1711 cmdline_fixed_string_t rss_hash_key;
1712 cmdline_fixed_string_t rss_type;
1713 cmdline_fixed_string_t key;
1717 hexa_digit_to_value(char hexa_digit)
1719 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1720 return (uint8_t) (hexa_digit - '0');
1721 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1722 return (uint8_t) ((hexa_digit - 'a') + 10);
1723 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1724 return (uint8_t) ((hexa_digit - 'A') + 10);
1725 /* Invalid hexa digit */
1730 parse_and_check_key_hexa_digit(char *key, int idx)
1734 hexa_v = hexa_digit_to_value(key[idx]);
1736 printf("invalid key: character %c at position %d is not a "
1737 "valid hexa digit\n", key[idx], idx);
1742 cmd_config_rss_hash_key_parsed(void *parsed_result,
1743 __attribute__((unused)) struct cmdline *cl,
1744 __attribute__((unused)) void *data)
1746 struct cmd_config_rss_hash_key *res = parsed_result;
1747 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1751 struct rte_eth_dev_info dev_info;
1752 uint8_t hash_key_size;
1755 memset(&dev_info, 0, sizeof(dev_info));
1756 rte_eth_dev_info_get(res->port_id, &dev_info);
1757 if (dev_info.hash_key_size > 0 &&
1758 dev_info.hash_key_size <= sizeof(hash_key))
1759 hash_key_size = dev_info.hash_key_size;
1761 printf("dev_info did not provide a valid hash key size\n");
1764 /* Check the length of the RSS hash key */
1765 key_len = strlen(res->key);
1766 if (key_len != (hash_key_size * 2)) {
1767 printf("key length: %d invalid - key must be a string of %d"
1768 " hexa-decimal numbers\n",
1769 (int) key_len, hash_key_size * 2);
1772 /* Translate RSS hash key into binary representation */
1773 for (i = 0; i < hash_key_size; i++) {
1774 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1777 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1780 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1782 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1786 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1788 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1791 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1792 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1793 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1795 rss_hash_key, "rss-hash-key");
1796 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1798 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1799 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1800 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1801 "ipv6-tcp-ex#ipv6-udp-ex");
1802 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1805 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1806 .f = cmd_config_rss_hash_key_parsed,
1808 .help_str = "port config <port_id> rss-hash-key "
1809 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1810 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1811 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1812 "<string of hex digits (variable length, NIC dependent)>",
1814 (void *)&cmd_config_rss_hash_key_port,
1815 (void *)&cmd_config_rss_hash_key_config,
1816 (void *)&cmd_config_rss_hash_key_port_id,
1817 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1818 (void *)&cmd_config_rss_hash_key_rss_type,
1819 (void *)&cmd_config_rss_hash_key_value,
1824 /* *** configure port rxq/txq start/stop *** */
1825 struct cmd_config_rxtx_queue {
1826 cmdline_fixed_string_t port;
1828 cmdline_fixed_string_t rxtxq;
1830 cmdline_fixed_string_t opname;
1834 cmd_config_rxtx_queue_parsed(void *parsed_result,
1835 __attribute__((unused)) struct cmdline *cl,
1836 __attribute__((unused)) void *data)
1838 struct cmd_config_rxtx_queue *res = parsed_result;
1843 if (test_done == 0) {
1844 printf("Please stop forwarding first\n");
1848 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1851 if (port_is_started(res->portid) != 1) {
1852 printf("Please start port %u first\n", res->portid);
1856 if (!strcmp(res->rxtxq, "rxq"))
1858 else if (!strcmp(res->rxtxq, "txq"))
1861 printf("Unknown parameter\n");
1865 if (isrx && rx_queue_id_is_invalid(res->qid))
1867 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1870 if (!strcmp(res->opname, "start"))
1872 else if (!strcmp(res->opname, "stop"))
1875 printf("Unknown parameter\n");
1879 if (isstart && isrx)
1880 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1881 else if (!isstart && isrx)
1882 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1883 else if (isstart && !isrx)
1884 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1886 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1888 if (ret == -ENOTSUP)
1889 printf("Function not supported in PMD driver\n");
1892 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1893 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1894 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1895 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1896 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1897 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1898 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1899 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1900 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1901 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1904 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1905 .f = cmd_config_rxtx_queue_parsed,
1907 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1909 (void *)&cmd_config_speed_all_port,
1910 (void *)&cmd_config_rxtx_queue_portid,
1911 (void *)&cmd_config_rxtx_queue_rxtxq,
1912 (void *)&cmd_config_rxtx_queue_qid,
1913 (void *)&cmd_config_rxtx_queue_opname,
1918 /* *** Configure RSS RETA *** */
1919 struct cmd_config_rss_reta {
1920 cmdline_fixed_string_t port;
1921 cmdline_fixed_string_t keyword;
1923 cmdline_fixed_string_t name;
1924 cmdline_fixed_string_t list_name;
1925 cmdline_fixed_string_t list_of_items;
1929 parse_reta_config(const char *str,
1930 struct rte_eth_rss_reta_entry64 *reta_conf,
1931 uint16_t nb_entries)
1935 uint16_t hash_index, idx, shift;
1938 const char *p, *p0 = str;
1945 unsigned long int_fld[_NUM_FLD];
1946 char *str_fld[_NUM_FLD];
1948 while ((p = strchr(p0,'(')) != NULL) {
1950 if((p0 = strchr(p,')')) == NULL)
1954 if(size >= sizeof(s))
1957 snprintf(s, sizeof(s), "%.*s", size, p);
1958 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1960 for (i = 0; i < _NUM_FLD; i++) {
1962 int_fld[i] = strtoul(str_fld[i], &end, 0);
1963 if (errno != 0 || end == str_fld[i] ||
1968 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1969 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1971 if (hash_index >= nb_entries) {
1972 printf("Invalid RETA hash index=%d\n", hash_index);
1976 idx = hash_index / RTE_RETA_GROUP_SIZE;
1977 shift = hash_index % RTE_RETA_GROUP_SIZE;
1978 reta_conf[idx].mask |= (1ULL << shift);
1979 reta_conf[idx].reta[shift] = nb_queue;
1986 cmd_set_rss_reta_parsed(void *parsed_result,
1987 __attribute__((unused)) struct cmdline *cl,
1988 __attribute__((unused)) void *data)
1991 struct rte_eth_dev_info dev_info;
1992 struct rte_eth_rss_reta_entry64 reta_conf[8];
1993 struct cmd_config_rss_reta *res = parsed_result;
1995 memset(&dev_info, 0, sizeof(dev_info));
1996 rte_eth_dev_info_get(res->port_id, &dev_info);
1997 if (dev_info.reta_size == 0) {
1998 printf("Redirection table size is 0 which is "
1999 "invalid for RSS\n");
2002 printf("The reta size of port %d is %u\n",
2003 res->port_id, dev_info.reta_size);
2004 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2005 printf("Currently do not support more than %u entries of "
2006 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2010 memset(reta_conf, 0, sizeof(reta_conf));
2011 if (!strcmp(res->list_name, "reta")) {
2012 if (parse_reta_config(res->list_of_items, reta_conf,
2013 dev_info.reta_size)) {
2014 printf("Invalid RSS Redirection Table "
2015 "config entered\n");
2018 ret = rte_eth_dev_rss_reta_update(res->port_id,
2019 reta_conf, dev_info.reta_size);
2021 printf("Bad redirection table parameter, "
2022 "return code = %d \n", ret);
2026 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2028 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2029 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2030 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2031 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2032 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2034 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2036 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2037 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2039 cmdline_parse_inst_t cmd_config_rss_reta = {
2040 .f = cmd_set_rss_reta_parsed,
2042 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2044 (void *)&cmd_config_rss_reta_port,
2045 (void *)&cmd_config_rss_reta_keyword,
2046 (void *)&cmd_config_rss_reta_port_id,
2047 (void *)&cmd_config_rss_reta_name,
2048 (void *)&cmd_config_rss_reta_list_name,
2049 (void *)&cmd_config_rss_reta_list_of_items,
2054 /* *** SHOW PORT RETA INFO *** */
2055 struct cmd_showport_reta {
2056 cmdline_fixed_string_t show;
2057 cmdline_fixed_string_t port;
2059 cmdline_fixed_string_t rss;
2060 cmdline_fixed_string_t reta;
2062 cmdline_fixed_string_t list_of_items;
2066 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2067 uint16_t nb_entries,
2071 const char *p, *p0 = str;
2075 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2078 p = strchr(p0, '(');
2082 p0 = strchr(p, ')');
2086 if (size >= sizeof(s)) {
2087 printf("The string size exceeds the internal buffer size\n");
2090 snprintf(s, sizeof(s), "%.*s", size, p);
2091 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2092 if (ret <= 0 || ret != num) {
2093 printf("The bits of masks do not match the number of "
2094 "reta entries: %u\n", num);
2097 for (i = 0; i < ret; i++)
2098 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2104 cmd_showport_reta_parsed(void *parsed_result,
2105 __attribute__((unused)) struct cmdline *cl,
2106 __attribute__((unused)) void *data)
2108 struct cmd_showport_reta *res = parsed_result;
2109 struct rte_eth_rss_reta_entry64 reta_conf[8];
2110 struct rte_eth_dev_info dev_info;
2112 memset(&dev_info, 0, sizeof(dev_info));
2113 rte_eth_dev_info_get(res->port_id, &dev_info);
2114 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2115 res->size > ETH_RSS_RETA_SIZE_512) {
2116 printf("Invalid redirection table size: %u\n", res->size);
2120 memset(reta_conf, 0, sizeof(reta_conf));
2121 if (showport_parse_reta_config(reta_conf, res->size,
2122 res->list_of_items) < 0) {
2123 printf("Invalid string: %s for reta masks\n",
2124 res->list_of_items);
2127 port_rss_reta_info(res->port_id, reta_conf, res->size);
2130 cmdline_parse_token_string_t cmd_showport_reta_show =
2131 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2132 cmdline_parse_token_string_t cmd_showport_reta_port =
2133 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2134 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2135 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2136 cmdline_parse_token_string_t cmd_showport_reta_rss =
2137 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2138 cmdline_parse_token_string_t cmd_showport_reta_reta =
2139 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2140 cmdline_parse_token_num_t cmd_showport_reta_size =
2141 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2142 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2143 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2144 list_of_items, NULL);
2146 cmdline_parse_inst_t cmd_showport_reta = {
2147 .f = cmd_showport_reta_parsed,
2149 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2151 (void *)&cmd_showport_reta_show,
2152 (void *)&cmd_showport_reta_port,
2153 (void *)&cmd_showport_reta_port_id,
2154 (void *)&cmd_showport_reta_rss,
2155 (void *)&cmd_showport_reta_reta,
2156 (void *)&cmd_showport_reta_size,
2157 (void *)&cmd_showport_reta_list_of_items,
2162 /* *** Show RSS hash configuration *** */
2163 struct cmd_showport_rss_hash {
2164 cmdline_fixed_string_t show;
2165 cmdline_fixed_string_t port;
2167 cmdline_fixed_string_t rss_hash;
2168 cmdline_fixed_string_t rss_type;
2169 cmdline_fixed_string_t key; /* optional argument */
2172 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2173 __attribute__((unused)) struct cmdline *cl,
2176 struct cmd_showport_rss_hash *res = parsed_result;
2178 port_rss_hash_conf_show(res->port_id, res->rss_type,
2179 show_rss_key != NULL);
2182 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2183 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2184 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2185 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2186 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2187 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2188 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2189 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2191 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2192 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2193 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2194 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2195 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2196 "ipv6-tcp-ex#ipv6-udp-ex");
2197 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2198 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2200 cmdline_parse_inst_t cmd_showport_rss_hash = {
2201 .f = cmd_showport_rss_hash_parsed,
2203 .help_str = "show port <port_id> rss-hash "
2204 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2205 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2206 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2208 (void *)&cmd_showport_rss_hash_show,
2209 (void *)&cmd_showport_rss_hash_port,
2210 (void *)&cmd_showport_rss_hash_port_id,
2211 (void *)&cmd_showport_rss_hash_rss_hash,
2212 (void *)&cmd_showport_rss_hash_rss_hash_info,
2217 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2218 .f = cmd_showport_rss_hash_parsed,
2220 .help_str = "show port <port_id> rss-hash "
2221 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2222 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2223 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2225 (void *)&cmd_showport_rss_hash_show,
2226 (void *)&cmd_showport_rss_hash_port,
2227 (void *)&cmd_showport_rss_hash_port_id,
2228 (void *)&cmd_showport_rss_hash_rss_hash,
2229 (void *)&cmd_showport_rss_hash_rss_hash_info,
2230 (void *)&cmd_showport_rss_hash_rss_key,
2235 /* *** Configure DCB *** */
2236 struct cmd_config_dcb {
2237 cmdline_fixed_string_t port;
2238 cmdline_fixed_string_t config;
2240 cmdline_fixed_string_t dcb;
2241 cmdline_fixed_string_t vt;
2242 cmdline_fixed_string_t vt_en;
2244 cmdline_fixed_string_t pfc;
2245 cmdline_fixed_string_t pfc_en;
2249 cmd_config_dcb_parsed(void *parsed_result,
2250 __attribute__((unused)) struct cmdline *cl,
2251 __attribute__((unused)) void *data)
2253 struct cmd_config_dcb *res = parsed_result;
2254 portid_t port_id = res->port_id;
2255 struct rte_port *port;
2259 port = &ports[port_id];
2260 /** Check if the port is not started **/
2261 if (port->port_status != RTE_PORT_STOPPED) {
2262 printf("Please stop port %d first\n", port_id);
2266 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2267 printf("The invalid number of traffic class,"
2268 " only 4 or 8 allowed.\n");
2272 if (nb_fwd_lcores < res->num_tcs) {
2273 printf("nb_cores shouldn't be less than number of TCs.\n");
2276 if (!strncmp(res->pfc_en, "on", 2))
2281 /* DCB in VT mode */
2282 if (!strncmp(res->vt_en, "on", 2))
2283 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2284 (enum rte_eth_nb_tcs)res->num_tcs,
2287 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2288 (enum rte_eth_nb_tcs)res->num_tcs,
2293 printf("Cannot initialize network ports.\n");
2297 cmd_reconfig_device_queue(port_id, 1, 1);
2300 cmdline_parse_token_string_t cmd_config_dcb_port =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2302 cmdline_parse_token_string_t cmd_config_dcb_config =
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2304 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2305 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2306 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2307 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2308 cmdline_parse_token_string_t cmd_config_dcb_vt =
2309 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2310 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2311 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2312 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2313 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2314 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2315 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2316 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2317 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2319 cmdline_parse_inst_t cmd_config_dcb = {
2320 .f = cmd_config_dcb_parsed,
2322 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2324 (void *)&cmd_config_dcb_port,
2325 (void *)&cmd_config_dcb_config,
2326 (void *)&cmd_config_dcb_port_id,
2327 (void *)&cmd_config_dcb_dcb,
2328 (void *)&cmd_config_dcb_vt,
2329 (void *)&cmd_config_dcb_vt_en,
2330 (void *)&cmd_config_dcb_num_tcs,
2331 (void *)&cmd_config_dcb_pfc,
2332 (void *)&cmd_config_dcb_pfc_en,
2337 /* *** configure number of packets per burst *** */
2338 struct cmd_config_burst {
2339 cmdline_fixed_string_t port;
2340 cmdline_fixed_string_t keyword;
2341 cmdline_fixed_string_t all;
2342 cmdline_fixed_string_t name;
2347 cmd_config_burst_parsed(void *parsed_result,
2348 __attribute__((unused)) struct cmdline *cl,
2349 __attribute__((unused)) void *data)
2351 struct cmd_config_burst *res = parsed_result;
2353 if (!all_ports_stopped()) {
2354 printf("Please stop all ports first\n");
2358 if (!strcmp(res->name, "burst")) {
2359 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2360 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2363 nb_pkt_per_burst = res->value;
2365 printf("Unknown parameter\n");
2371 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2374 cmdline_parse_token_string_t cmd_config_burst_port =
2375 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2376 cmdline_parse_token_string_t cmd_config_burst_keyword =
2377 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2378 cmdline_parse_token_string_t cmd_config_burst_all =
2379 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2380 cmdline_parse_token_string_t cmd_config_burst_name =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2382 cmdline_parse_token_num_t cmd_config_burst_value =
2383 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2385 cmdline_parse_inst_t cmd_config_burst = {
2386 .f = cmd_config_burst_parsed,
2388 .help_str = "port config all burst <value>",
2390 (void *)&cmd_config_burst_port,
2391 (void *)&cmd_config_burst_keyword,
2392 (void *)&cmd_config_burst_all,
2393 (void *)&cmd_config_burst_name,
2394 (void *)&cmd_config_burst_value,
2399 /* *** configure rx/tx queues *** */
2400 struct cmd_config_thresh {
2401 cmdline_fixed_string_t port;
2402 cmdline_fixed_string_t keyword;
2403 cmdline_fixed_string_t all;
2404 cmdline_fixed_string_t name;
2409 cmd_config_thresh_parsed(void *parsed_result,
2410 __attribute__((unused)) struct cmdline *cl,
2411 __attribute__((unused)) void *data)
2413 struct cmd_config_thresh *res = parsed_result;
2415 if (!all_ports_stopped()) {
2416 printf("Please stop all ports first\n");
2420 if (!strcmp(res->name, "txpt"))
2421 tx_pthresh = res->value;
2422 else if(!strcmp(res->name, "txht"))
2423 tx_hthresh = res->value;
2424 else if(!strcmp(res->name, "txwt"))
2425 tx_wthresh = res->value;
2426 else if(!strcmp(res->name, "rxpt"))
2427 rx_pthresh = res->value;
2428 else if(!strcmp(res->name, "rxht"))
2429 rx_hthresh = res->value;
2430 else if(!strcmp(res->name, "rxwt"))
2431 rx_wthresh = res->value;
2433 printf("Unknown parameter\n");
2439 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2442 cmdline_parse_token_string_t cmd_config_thresh_port =
2443 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2444 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2445 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2446 cmdline_parse_token_string_t cmd_config_thresh_all =
2447 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2448 cmdline_parse_token_string_t cmd_config_thresh_name =
2449 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2450 "txpt#txht#txwt#rxpt#rxht#rxwt");
2451 cmdline_parse_token_num_t cmd_config_thresh_value =
2452 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2454 cmdline_parse_inst_t cmd_config_thresh = {
2455 .f = cmd_config_thresh_parsed,
2457 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2459 (void *)&cmd_config_thresh_port,
2460 (void *)&cmd_config_thresh_keyword,
2461 (void *)&cmd_config_thresh_all,
2462 (void *)&cmd_config_thresh_name,
2463 (void *)&cmd_config_thresh_value,
2468 /* *** configure free/rs threshold *** */
2469 struct cmd_config_threshold {
2470 cmdline_fixed_string_t port;
2471 cmdline_fixed_string_t keyword;
2472 cmdline_fixed_string_t all;
2473 cmdline_fixed_string_t name;
2478 cmd_config_threshold_parsed(void *parsed_result,
2479 __attribute__((unused)) struct cmdline *cl,
2480 __attribute__((unused)) void *data)
2482 struct cmd_config_threshold *res = parsed_result;
2484 if (!all_ports_stopped()) {
2485 printf("Please stop all ports first\n");
2489 if (!strcmp(res->name, "txfreet"))
2490 tx_free_thresh = res->value;
2491 else if (!strcmp(res->name, "txrst"))
2492 tx_rs_thresh = res->value;
2493 else if (!strcmp(res->name, "rxfreet"))
2494 rx_free_thresh = res->value;
2496 printf("Unknown parameter\n");
2502 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2505 cmdline_parse_token_string_t cmd_config_threshold_port =
2506 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2507 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2508 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2510 cmdline_parse_token_string_t cmd_config_threshold_all =
2511 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2512 cmdline_parse_token_string_t cmd_config_threshold_name =
2513 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2514 "txfreet#txrst#rxfreet");
2515 cmdline_parse_token_num_t cmd_config_threshold_value =
2516 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2518 cmdline_parse_inst_t cmd_config_threshold = {
2519 .f = cmd_config_threshold_parsed,
2521 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2523 (void *)&cmd_config_threshold_port,
2524 (void *)&cmd_config_threshold_keyword,
2525 (void *)&cmd_config_threshold_all,
2526 (void *)&cmd_config_threshold_name,
2527 (void *)&cmd_config_threshold_value,
2533 struct cmd_stop_result {
2534 cmdline_fixed_string_t stop;
2537 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2538 __attribute__((unused)) struct cmdline *cl,
2539 __attribute__((unused)) void *data)
2541 stop_packet_forwarding();
2544 cmdline_parse_token_string_t cmd_stop_stop =
2545 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2547 cmdline_parse_inst_t cmd_stop = {
2548 .f = cmd_stop_parsed,
2550 .help_str = "stop: Stop packet forwarding",
2552 (void *)&cmd_stop_stop,
2557 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2560 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2561 unsigned int *parsed_items, int check_unique_values)
2563 unsigned int nb_item;
2571 * First parse all items in the list and store their value.
2576 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2578 if ((c >= '0') && (c <= '9')) {
2579 value = (unsigned int) (value * 10 + (c - '0'));
2584 printf("character %c is not a decimal digit\n", c);
2588 printf("No valid value before comma\n");
2591 if (nb_item < max_items) {
2592 parsed_items[nb_item] = value;
2598 if (nb_item >= max_items) {
2599 printf("Number of %s = %u > %u (maximum items)\n",
2600 item_name, nb_item + 1, max_items);
2603 parsed_items[nb_item++] = value;
2604 if (! check_unique_values)
2608 * Then, check that all values in the list are differents.
2609 * No optimization here...
2611 for (i = 0; i < nb_item; i++) {
2612 for (j = i + 1; j < nb_item; j++) {
2613 if (parsed_items[j] == parsed_items[i]) {
2614 printf("duplicated %s %u at index %u and %u\n",
2615 item_name, parsed_items[i], i, j);
2623 struct cmd_set_list_result {
2624 cmdline_fixed_string_t cmd_keyword;
2625 cmdline_fixed_string_t list_name;
2626 cmdline_fixed_string_t list_of_items;
2629 static void cmd_set_list_parsed(void *parsed_result,
2630 __attribute__((unused)) struct cmdline *cl,
2631 __attribute__((unused)) void *data)
2633 struct cmd_set_list_result *res;
2635 unsigned int lcorelist[RTE_MAX_LCORE];
2636 unsigned int portlist[RTE_MAX_ETHPORTS];
2638 unsigned int nb_item;
2640 if (test_done == 0) {
2641 printf("Please stop forwarding first\n");
2645 res = parsed_result;
2646 if (!strcmp(res->list_name, "corelist")) {
2647 nb_item = parse_item_list(res->list_of_items, "core",
2649 parsed_items.lcorelist, 1);
2651 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2656 if (!strcmp(res->list_name, "portlist")) {
2657 nb_item = parse_item_list(res->list_of_items, "port",
2659 parsed_items.portlist, 1);
2661 set_fwd_ports_list(parsed_items.portlist, nb_item);
2667 cmdline_parse_token_string_t cmd_set_list_keyword =
2668 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2670 cmdline_parse_token_string_t cmd_set_list_name =
2671 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2672 "corelist#portlist");
2673 cmdline_parse_token_string_t cmd_set_list_of_items =
2674 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2677 cmdline_parse_inst_t cmd_set_fwd_list = {
2678 .f = cmd_set_list_parsed,
2680 .help_str = "set corelist|portlist <list0[,list1]*>",
2682 (void *)&cmd_set_list_keyword,
2683 (void *)&cmd_set_list_name,
2684 (void *)&cmd_set_list_of_items,
2689 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2691 struct cmd_setmask_result {
2692 cmdline_fixed_string_t set;
2693 cmdline_fixed_string_t mask;
2697 static void cmd_set_mask_parsed(void *parsed_result,
2698 __attribute__((unused)) struct cmdline *cl,
2699 __attribute__((unused)) void *data)
2701 struct cmd_setmask_result *res = parsed_result;
2703 if (test_done == 0) {
2704 printf("Please stop forwarding first\n");
2707 if (!strcmp(res->mask, "coremask")) {
2708 set_fwd_lcores_mask(res->hexavalue);
2710 } else if (!strcmp(res->mask, "portmask")) {
2711 set_fwd_ports_mask(res->hexavalue);
2716 cmdline_parse_token_string_t cmd_setmask_set =
2717 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2718 cmdline_parse_token_string_t cmd_setmask_mask =
2719 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2720 "coremask#portmask");
2721 cmdline_parse_token_num_t cmd_setmask_value =
2722 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2724 cmdline_parse_inst_t cmd_set_fwd_mask = {
2725 .f = cmd_set_mask_parsed,
2727 .help_str = "set coremask|portmask <hexadecimal value>",
2729 (void *)&cmd_setmask_set,
2730 (void *)&cmd_setmask_mask,
2731 (void *)&cmd_setmask_value,
2737 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2739 struct cmd_set_result {
2740 cmdline_fixed_string_t set;
2741 cmdline_fixed_string_t what;
2745 static void cmd_set_parsed(void *parsed_result,
2746 __attribute__((unused)) struct cmdline *cl,
2747 __attribute__((unused)) void *data)
2749 struct cmd_set_result *res = parsed_result;
2750 if (!strcmp(res->what, "nbport")) {
2751 set_fwd_ports_number(res->value);
2753 } else if (!strcmp(res->what, "nbcore")) {
2754 set_fwd_lcores_number(res->value);
2756 } else if (!strcmp(res->what, "burst"))
2757 set_nb_pkt_per_burst(res->value);
2758 else if (!strcmp(res->what, "verbose"))
2759 set_verbose_level(res->value);
2762 cmdline_parse_token_string_t cmd_set_set =
2763 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2764 cmdline_parse_token_string_t cmd_set_what =
2765 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2766 "nbport#nbcore#burst#verbose");
2767 cmdline_parse_token_num_t cmd_set_value =
2768 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2770 cmdline_parse_inst_t cmd_set_numbers = {
2771 .f = cmd_set_parsed,
2773 .help_str = "set nbport|nbcore|burst|verbose <value>",
2775 (void *)&cmd_set_set,
2776 (void *)&cmd_set_what,
2777 (void *)&cmd_set_value,
2782 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2784 struct cmd_set_txpkts_result {
2785 cmdline_fixed_string_t cmd_keyword;
2786 cmdline_fixed_string_t txpkts;
2787 cmdline_fixed_string_t seg_lengths;
2791 cmd_set_txpkts_parsed(void *parsed_result,
2792 __attribute__((unused)) struct cmdline *cl,
2793 __attribute__((unused)) void *data)
2795 struct cmd_set_txpkts_result *res;
2796 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2797 unsigned int nb_segs;
2799 res = parsed_result;
2800 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2801 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2803 set_tx_pkt_segments(seg_lengths, nb_segs);
2806 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2807 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2808 cmd_keyword, "set");
2809 cmdline_parse_token_string_t cmd_set_txpkts_name =
2810 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2812 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2813 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2816 cmdline_parse_inst_t cmd_set_txpkts = {
2817 .f = cmd_set_txpkts_parsed,
2819 .help_str = "set txpkts <len0[,len1]*>",
2821 (void *)&cmd_set_txpkts_keyword,
2822 (void *)&cmd_set_txpkts_name,
2823 (void *)&cmd_set_txpkts_lengths,
2828 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2830 struct cmd_set_txsplit_result {
2831 cmdline_fixed_string_t cmd_keyword;
2832 cmdline_fixed_string_t txsplit;
2833 cmdline_fixed_string_t mode;
2837 cmd_set_txsplit_parsed(void *parsed_result,
2838 __attribute__((unused)) struct cmdline *cl,
2839 __attribute__((unused)) void *data)
2841 struct cmd_set_txsplit_result *res;
2843 res = parsed_result;
2844 set_tx_pkt_split(res->mode);
2847 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2848 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2849 cmd_keyword, "set");
2850 cmdline_parse_token_string_t cmd_set_txsplit_name =
2851 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2852 txsplit, "txsplit");
2853 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2854 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2857 cmdline_parse_inst_t cmd_set_txsplit = {
2858 .f = cmd_set_txsplit_parsed,
2860 .help_str = "set txsplit on|off|rand",
2862 (void *)&cmd_set_txsplit_keyword,
2863 (void *)&cmd_set_txsplit_name,
2864 (void *)&cmd_set_txsplit_mode,
2869 /* *** CONFIG TX QUEUE FLAGS *** */
2871 struct cmd_config_txqflags_result {
2872 cmdline_fixed_string_t port;
2873 cmdline_fixed_string_t config;
2874 cmdline_fixed_string_t all;
2875 cmdline_fixed_string_t what;
2879 static void cmd_config_txqflags_parsed(void *parsed_result,
2880 __attribute__((unused)) struct cmdline *cl,
2881 __attribute__((unused)) void *data)
2883 struct cmd_config_txqflags_result *res = parsed_result;
2885 if (!all_ports_stopped()) {
2886 printf("Please stop all ports first\n");
2890 if (strcmp(res->what, "txqflags")) {
2891 printf("Unknown parameter\n");
2895 if (res->hexvalue >= 0) {
2896 txq_flags = res->hexvalue;
2898 printf("txqflags must be >= 0\n");
2904 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2907 cmdline_parse_token_string_t cmd_config_txqflags_port =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2910 cmdline_parse_token_string_t cmd_config_txqflags_config =
2911 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2913 cmdline_parse_token_string_t cmd_config_txqflags_all =
2914 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2916 cmdline_parse_token_string_t cmd_config_txqflags_what =
2917 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2919 cmdline_parse_token_num_t cmd_config_txqflags_value =
2920 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2923 cmdline_parse_inst_t cmd_config_txqflags = {
2924 .f = cmd_config_txqflags_parsed,
2926 .help_str = "port config all txqflags <value>",
2928 (void *)&cmd_config_txqflags_port,
2929 (void *)&cmd_config_txqflags_config,
2930 (void *)&cmd_config_txqflags_all,
2931 (void *)&cmd_config_txqflags_what,
2932 (void *)&cmd_config_txqflags_value,
2937 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2938 struct cmd_rx_vlan_filter_all_result {
2939 cmdline_fixed_string_t rx_vlan;
2940 cmdline_fixed_string_t what;
2941 cmdline_fixed_string_t all;
2946 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2947 __attribute__((unused)) struct cmdline *cl,
2948 __attribute__((unused)) void *data)
2950 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2952 if (!strcmp(res->what, "add"))
2953 rx_vlan_all_filter_set(res->port_id, 1);
2955 rx_vlan_all_filter_set(res->port_id, 0);
2958 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2959 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2960 rx_vlan, "rx_vlan");
2961 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2962 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2964 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2965 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2967 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2968 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2971 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2972 .f = cmd_rx_vlan_filter_all_parsed,
2974 .help_str = "rx_vlan add|rm all <port_id>: "
2975 "Add/Remove all identifiers to/from the set of VLAN "
2976 "identifiers filtered by a port",
2978 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2979 (void *)&cmd_rx_vlan_filter_all_what,
2980 (void *)&cmd_rx_vlan_filter_all_all,
2981 (void *)&cmd_rx_vlan_filter_all_portid,
2986 /* *** VLAN OFFLOAD SET ON A PORT *** */
2987 struct cmd_vlan_offload_result {
2988 cmdline_fixed_string_t vlan;
2989 cmdline_fixed_string_t set;
2990 cmdline_fixed_string_t vlan_type;
2991 cmdline_fixed_string_t what;
2992 cmdline_fixed_string_t on;
2993 cmdline_fixed_string_t port_id;
2997 cmd_vlan_offload_parsed(void *parsed_result,
2998 __attribute__((unused)) struct cmdline *cl,
2999 __attribute__((unused)) void *data)
3002 struct cmd_vlan_offload_result *res = parsed_result;
3005 portid_t port_id = 0;
3009 len = strnlen(str, STR_TOKEN_SIZE);
3011 /* Get port_id first */
3019 tmp = strtoul(str, NULL, 0);
3020 /* If port_id greater that what portid_t can represent, return */
3021 if(tmp >= RTE_MAX_ETHPORTS)
3023 port_id = (portid_t)tmp;
3025 if (!strcmp(res->on, "on"))
3030 if (!strcmp(res->what, "strip"))
3031 rx_vlan_strip_set(port_id, on);
3032 else if(!strcmp(res->what, "stripq")){
3033 uint16_t queue_id = 0;
3035 /* No queue_id, return */
3037 printf("must specify (port,queue_id)\n");
3040 tmp = strtoul(str + i + 1, NULL, 0);
3041 /* If queue_id greater that what 16-bits can represent, return */
3045 queue_id = (uint16_t)tmp;
3046 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3048 else if (!strcmp(res->what, "filter"))
3049 rx_vlan_filter_set(port_id, on);
3051 vlan_extend_set(port_id, on);
3056 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3057 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3059 cmdline_parse_token_string_t cmd_vlan_offload_set =
3060 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3062 cmdline_parse_token_string_t cmd_vlan_offload_what =
3063 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3064 what, "strip#filter#qinq#stripq");
3065 cmdline_parse_token_string_t cmd_vlan_offload_on =
3066 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3068 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3069 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3072 cmdline_parse_inst_t cmd_vlan_offload = {
3073 .f = cmd_vlan_offload_parsed,
3075 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3076 "<port_id[,queue_id]>: "
3077 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3079 (void *)&cmd_vlan_offload_vlan,
3080 (void *)&cmd_vlan_offload_set,
3081 (void *)&cmd_vlan_offload_what,
3082 (void *)&cmd_vlan_offload_on,
3083 (void *)&cmd_vlan_offload_portid,
3088 /* *** VLAN TPID SET ON A PORT *** */
3089 struct cmd_vlan_tpid_result {
3090 cmdline_fixed_string_t vlan;
3091 cmdline_fixed_string_t set;
3092 cmdline_fixed_string_t vlan_type;
3093 cmdline_fixed_string_t what;
3099 cmd_vlan_tpid_parsed(void *parsed_result,
3100 __attribute__((unused)) struct cmdline *cl,
3101 __attribute__((unused)) void *data)
3103 struct cmd_vlan_tpid_result *res = parsed_result;
3104 enum rte_vlan_type vlan_type;
3106 if (!strcmp(res->vlan_type, "inner"))
3107 vlan_type = ETH_VLAN_TYPE_INNER;
3108 else if (!strcmp(res->vlan_type, "outer"))
3109 vlan_type = ETH_VLAN_TYPE_OUTER;
3111 printf("Unknown vlan type\n");
3114 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3117 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3118 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3120 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3121 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3123 cmdline_parse_token_string_t cmd_vlan_type =
3124 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3125 vlan_type, "inner#outer");
3126 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3127 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3129 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3130 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3132 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3133 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3136 cmdline_parse_inst_t cmd_vlan_tpid = {
3137 .f = cmd_vlan_tpid_parsed,
3139 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3140 "Set the VLAN Ether type",
3142 (void *)&cmd_vlan_tpid_vlan,
3143 (void *)&cmd_vlan_tpid_set,
3144 (void *)&cmd_vlan_type,
3145 (void *)&cmd_vlan_tpid_what,
3146 (void *)&cmd_vlan_tpid_tpid,
3147 (void *)&cmd_vlan_tpid_portid,
3152 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3153 struct cmd_rx_vlan_filter_result {
3154 cmdline_fixed_string_t rx_vlan;
3155 cmdline_fixed_string_t what;
3161 cmd_rx_vlan_filter_parsed(void *parsed_result,
3162 __attribute__((unused)) struct cmdline *cl,
3163 __attribute__((unused)) void *data)
3165 struct cmd_rx_vlan_filter_result *res = parsed_result;
3167 if (!strcmp(res->what, "add"))
3168 rx_vft_set(res->port_id, res->vlan_id, 1);
3170 rx_vft_set(res->port_id, res->vlan_id, 0);
3173 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3174 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3175 rx_vlan, "rx_vlan");
3176 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3177 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3179 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3180 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3182 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3183 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3186 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3187 .f = cmd_rx_vlan_filter_parsed,
3189 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3190 "Add/Remove a VLAN identifier to/from the set of VLAN "
3191 "identifiers filtered by a port",
3193 (void *)&cmd_rx_vlan_filter_rx_vlan,
3194 (void *)&cmd_rx_vlan_filter_what,
3195 (void *)&cmd_rx_vlan_filter_vlanid,
3196 (void *)&cmd_rx_vlan_filter_portid,
3201 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3202 struct cmd_tx_vlan_set_result {
3203 cmdline_fixed_string_t tx_vlan;
3204 cmdline_fixed_string_t set;
3210 cmd_tx_vlan_set_parsed(void *parsed_result,
3211 __attribute__((unused)) struct cmdline *cl,
3212 __attribute__((unused)) void *data)
3214 struct cmd_tx_vlan_set_result *res = parsed_result;
3216 tx_vlan_set(res->port_id, res->vlan_id);
3219 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3220 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3221 tx_vlan, "tx_vlan");
3222 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3223 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3225 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3226 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3228 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3229 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3232 cmdline_parse_inst_t cmd_tx_vlan_set = {
3233 .f = cmd_tx_vlan_set_parsed,
3235 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3236 "Enable hardware insertion of a single VLAN header "
3237 "with a given TAG Identifier in packets sent on a port",
3239 (void *)&cmd_tx_vlan_set_tx_vlan,
3240 (void *)&cmd_tx_vlan_set_set,
3241 (void *)&cmd_tx_vlan_set_portid,
3242 (void *)&cmd_tx_vlan_set_vlanid,
3247 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3248 struct cmd_tx_vlan_set_qinq_result {
3249 cmdline_fixed_string_t tx_vlan;
3250 cmdline_fixed_string_t set;
3253 uint16_t vlan_id_outer;
3257 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3258 __attribute__((unused)) struct cmdline *cl,
3259 __attribute__((unused)) void *data)
3261 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3263 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3266 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3267 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3268 tx_vlan, "tx_vlan");
3269 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3270 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3272 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3273 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3275 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3276 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3278 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3279 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3280 vlan_id_outer, UINT16);
3282 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3283 .f = cmd_tx_vlan_set_qinq_parsed,
3285 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3286 "Enable hardware insertion of double VLAN header "
3287 "with given TAG Identifiers in packets sent on a port",
3289 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3290 (void *)&cmd_tx_vlan_set_qinq_set,
3291 (void *)&cmd_tx_vlan_set_qinq_portid,
3292 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3293 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3298 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3299 struct cmd_tx_vlan_set_pvid_result {
3300 cmdline_fixed_string_t tx_vlan;
3301 cmdline_fixed_string_t set;
3302 cmdline_fixed_string_t pvid;
3305 cmdline_fixed_string_t mode;
3309 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3310 __attribute__((unused)) struct cmdline *cl,
3311 __attribute__((unused)) void *data)
3313 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3315 if (strcmp(res->mode, "on") == 0)
3316 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3318 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3321 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3322 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3323 tx_vlan, "tx_vlan");
3324 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3325 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3327 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3328 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3330 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3331 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3333 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3334 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3336 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3337 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3340 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3341 .f = cmd_tx_vlan_set_pvid_parsed,
3343 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3345 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3346 (void *)&cmd_tx_vlan_set_pvid_set,
3347 (void *)&cmd_tx_vlan_set_pvid_pvid,
3348 (void *)&cmd_tx_vlan_set_pvid_port_id,
3349 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3350 (void *)&cmd_tx_vlan_set_pvid_mode,
3355 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3356 struct cmd_tx_vlan_reset_result {
3357 cmdline_fixed_string_t tx_vlan;
3358 cmdline_fixed_string_t reset;
3363 cmd_tx_vlan_reset_parsed(void *parsed_result,
3364 __attribute__((unused)) struct cmdline *cl,
3365 __attribute__((unused)) void *data)
3367 struct cmd_tx_vlan_reset_result *res = parsed_result;
3369 tx_vlan_reset(res->port_id);
3372 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3373 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3374 tx_vlan, "tx_vlan");
3375 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3376 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3378 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3379 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3382 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3383 .f = cmd_tx_vlan_reset_parsed,
3385 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3386 "VLAN header in packets sent on a port",
3388 (void *)&cmd_tx_vlan_reset_tx_vlan,
3389 (void *)&cmd_tx_vlan_reset_reset,
3390 (void *)&cmd_tx_vlan_reset_portid,
3396 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3397 struct cmd_csum_result {
3398 cmdline_fixed_string_t csum;
3399 cmdline_fixed_string_t mode;
3400 cmdline_fixed_string_t proto;
3401 cmdline_fixed_string_t hwsw;
3406 csum_show(int port_id)
3408 struct rte_eth_dev_info dev_info;
3411 ol_flags = ports[port_id].tx_ol_flags;
3412 printf("Parse tunnel is %s\n",
3413 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3414 printf("IP checksum offload is %s\n",
3415 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3416 printf("UDP checksum offload is %s\n",
3417 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3418 printf("TCP checksum offload is %s\n",
3419 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3420 printf("SCTP checksum offload is %s\n",
3421 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3422 printf("Outer-Ip checksum offload is %s\n",
3423 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3425 /* display warnings if configuration is not supported by the NIC */
3426 rte_eth_dev_info_get(port_id, &dev_info);
3427 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3428 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3429 printf("Warning: hardware IP checksum enabled but not "
3430 "supported by port %d\n", port_id);
3432 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3433 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3434 printf("Warning: hardware UDP checksum enabled but not "
3435 "supported by port %d\n", port_id);
3437 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3438 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3439 printf("Warning: hardware TCP checksum enabled but not "
3440 "supported by port %d\n", port_id);
3442 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3443 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3444 printf("Warning: hardware SCTP checksum enabled but not "
3445 "supported by port %d\n", port_id);
3447 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3448 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3449 printf("Warning: hardware outer IP checksum enabled but not "
3450 "supported by port %d\n", port_id);
3455 cmd_csum_parsed(void *parsed_result,
3456 __attribute__((unused)) struct cmdline *cl,
3457 __attribute__((unused)) void *data)
3459 struct cmd_csum_result *res = parsed_result;
3463 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3464 printf("invalid port %d\n", res->port_id);
3468 if (!strcmp(res->mode, "set")) {
3470 if (!strcmp(res->hwsw, "hw"))
3473 if (!strcmp(res->proto, "ip")) {
3474 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3475 } else if (!strcmp(res->proto, "udp")) {
3476 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3477 } else if (!strcmp(res->proto, "tcp")) {
3478 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3479 } else if (!strcmp(res->proto, "sctp")) {
3480 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3481 } else if (!strcmp(res->proto, "outer-ip")) {
3482 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3486 ports[res->port_id].tx_ol_flags |= mask;
3488 ports[res->port_id].tx_ol_flags &= (~mask);
3490 csum_show(res->port_id);
3493 cmdline_parse_token_string_t cmd_csum_csum =
3494 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3496 cmdline_parse_token_string_t cmd_csum_mode =
3497 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3499 cmdline_parse_token_string_t cmd_csum_proto =
3500 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3501 proto, "ip#tcp#udp#sctp#outer-ip");
3502 cmdline_parse_token_string_t cmd_csum_hwsw =
3503 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3505 cmdline_parse_token_num_t cmd_csum_portid =
3506 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3509 cmdline_parse_inst_t cmd_csum_set = {
3510 .f = cmd_csum_parsed,
3512 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3513 "Enable/Disable hardware calculation of L3/L4 checksum when "
3514 "using csum forward engine",
3516 (void *)&cmd_csum_csum,
3517 (void *)&cmd_csum_mode,
3518 (void *)&cmd_csum_proto,
3519 (void *)&cmd_csum_hwsw,
3520 (void *)&cmd_csum_portid,
3525 cmdline_parse_token_string_t cmd_csum_mode_show =
3526 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3529 cmdline_parse_inst_t cmd_csum_show = {
3530 .f = cmd_csum_parsed,
3532 .help_str = "csum show <port_id>: Show checksum offload configuration",
3534 (void *)&cmd_csum_csum,
3535 (void *)&cmd_csum_mode_show,
3536 (void *)&cmd_csum_portid,
3541 /* Enable/disable tunnel parsing */
3542 struct cmd_csum_tunnel_result {
3543 cmdline_fixed_string_t csum;
3544 cmdline_fixed_string_t parse;
3545 cmdline_fixed_string_t onoff;
3550 cmd_csum_tunnel_parsed(void *parsed_result,
3551 __attribute__((unused)) struct cmdline *cl,
3552 __attribute__((unused)) void *data)
3554 struct cmd_csum_tunnel_result *res = parsed_result;
3556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3559 if (!strcmp(res->onoff, "on"))
3560 ports[res->port_id].tx_ol_flags |=
3561 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3563 ports[res->port_id].tx_ol_flags &=
3564 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3566 csum_show(res->port_id);
3569 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3570 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3572 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3573 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3574 parse, "parse_tunnel");
3575 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3576 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3578 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3579 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3582 cmdline_parse_inst_t cmd_csum_tunnel = {
3583 .f = cmd_csum_tunnel_parsed,
3585 .help_str = "csum parse_tunnel on|off <port_id>: "
3586 "Enable/Disable parsing of tunnels for csum engine",
3588 (void *)&cmd_csum_tunnel_csum,
3589 (void *)&cmd_csum_tunnel_parse,
3590 (void *)&cmd_csum_tunnel_onoff,
3591 (void *)&cmd_csum_tunnel_portid,
3596 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3597 struct cmd_tso_set_result {
3598 cmdline_fixed_string_t tso;
3599 cmdline_fixed_string_t mode;
3605 cmd_tso_set_parsed(void *parsed_result,
3606 __attribute__((unused)) struct cmdline *cl,
3607 __attribute__((unused)) void *data)
3609 struct cmd_tso_set_result *res = parsed_result;
3610 struct rte_eth_dev_info dev_info;
3612 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3615 if (!strcmp(res->mode, "set"))
3616 ports[res->port_id].tso_segsz = res->tso_segsz;
3618 if (ports[res->port_id].tso_segsz == 0)
3619 printf("TSO for non-tunneled packets is disabled\n");
3621 printf("TSO segment size for non-tunneled packets is %d\n",
3622 ports[res->port_id].tso_segsz);
3624 /* display warnings if configuration is not supported by the NIC */
3625 rte_eth_dev_info_get(res->port_id, &dev_info);
3626 if ((ports[res->port_id].tso_segsz != 0) &&
3627 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3628 printf("Warning: TSO enabled but not "
3629 "supported by port %d\n", res->port_id);
3633 cmdline_parse_token_string_t cmd_tso_set_tso =
3634 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3636 cmdline_parse_token_string_t cmd_tso_set_mode =
3637 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3639 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3640 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3642 cmdline_parse_token_num_t cmd_tso_set_portid =
3643 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3646 cmdline_parse_inst_t cmd_tso_set = {
3647 .f = cmd_tso_set_parsed,
3649 .help_str = "tso set <tso_segsz> <port_id>: "
3650 "Set TSO segment size of non-tunneled packets for csum engine "
3653 (void *)&cmd_tso_set_tso,
3654 (void *)&cmd_tso_set_mode,
3655 (void *)&cmd_tso_set_tso_segsz,
3656 (void *)&cmd_tso_set_portid,
3661 cmdline_parse_token_string_t cmd_tso_show_mode =
3662 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3666 cmdline_parse_inst_t cmd_tso_show = {
3667 .f = cmd_tso_set_parsed,
3669 .help_str = "tso show <port_id>: "
3670 "Show TSO segment size of non-tunneled packets for csum engine",
3672 (void *)&cmd_tso_set_tso,
3673 (void *)&cmd_tso_show_mode,
3674 (void *)&cmd_tso_set_portid,
3679 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3680 struct cmd_tunnel_tso_set_result {
3681 cmdline_fixed_string_t tso;
3682 cmdline_fixed_string_t mode;
3688 check_tunnel_tso_nic_support(uint8_t port_id)
3690 struct rte_eth_dev_info dev_info;
3692 rte_eth_dev_info_get(port_id, &dev_info);
3693 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3694 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3695 "supported by port %d\n", port_id);
3696 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3697 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3698 "supported by port %d\n", port_id);
3699 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3700 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3701 "supported by port %d\n", port_id);
3702 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3703 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3704 "supported by port %d\n", port_id);
3708 cmd_tunnel_tso_set_parsed(void *parsed_result,
3709 __attribute__((unused)) struct cmdline *cl,
3710 __attribute__((unused)) void *data)
3712 struct cmd_tunnel_tso_set_result *res = parsed_result;
3714 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3717 if (!strcmp(res->mode, "set"))
3718 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3720 if (ports[res->port_id].tunnel_tso_segsz == 0)
3721 printf("TSO for tunneled packets is disabled\n");
3723 printf("TSO segment size for tunneled packets is %d\n",
3724 ports[res->port_id].tunnel_tso_segsz);
3726 /* Below conditions are needed to make it work:
3727 * (1) tunnel TSO is supported by the NIC;
3728 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3730 * (3) for tunneled pkts with outer L3 of IPv4,
3731 * "csum set outer-ip" must be set to hw, because after tso,
3732 * total_len of outer IP header is changed, and the checksum
3733 * of outer IP header calculated by sw should be wrong; that
3734 * is not necessary for IPv6 tunneled pkts because there's no
3735 * checksum in IP header anymore.
3737 check_tunnel_tso_nic_support(res->port_id);
3739 if (!(ports[res->port_id].tx_ol_flags &
3740 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3741 printf("Warning: csum parse_tunnel must be set "
3742 "so that tunneled packets are recognized\n");
3743 if (!(ports[res->port_id].tx_ol_flags &
3744 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3745 printf("Warning: csum set outer-ip must be set to hw "
3746 "if outer L3 is IPv4; not necessary for IPv6\n");
3750 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3751 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3753 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3754 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3756 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3757 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3759 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3760 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3763 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3764 .f = cmd_tunnel_tso_set_parsed,
3766 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3767 "Set TSO segment size of tunneled packets for csum engine "
3770 (void *)&cmd_tunnel_tso_set_tso,
3771 (void *)&cmd_tunnel_tso_set_mode,
3772 (void *)&cmd_tunnel_tso_set_tso_segsz,
3773 (void *)&cmd_tunnel_tso_set_portid,
3778 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3779 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3783 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3784 .f = cmd_tunnel_tso_set_parsed,
3786 .help_str = "tunnel_tso show <port_id> "
3787 "Show TSO segment size of tunneled packets for csum engine",
3789 (void *)&cmd_tunnel_tso_set_tso,
3790 (void *)&cmd_tunnel_tso_show_mode,
3791 (void *)&cmd_tunnel_tso_set_portid,
3796 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3797 struct cmd_set_flush_rx {
3798 cmdline_fixed_string_t set;
3799 cmdline_fixed_string_t flush_rx;
3800 cmdline_fixed_string_t mode;
3804 cmd_set_flush_rx_parsed(void *parsed_result,
3805 __attribute__((unused)) struct cmdline *cl,
3806 __attribute__((unused)) void *data)
3808 struct cmd_set_flush_rx *res = parsed_result;
3809 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3812 cmdline_parse_token_string_t cmd_setflushrx_set =
3813 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3815 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3816 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3817 flush_rx, "flush_rx");
3818 cmdline_parse_token_string_t cmd_setflushrx_mode =
3819 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3823 cmdline_parse_inst_t cmd_set_flush_rx = {
3824 .f = cmd_set_flush_rx_parsed,
3825 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3828 (void *)&cmd_setflushrx_set,
3829 (void *)&cmd_setflushrx_flush_rx,
3830 (void *)&cmd_setflushrx_mode,
3835 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3836 struct cmd_set_link_check {
3837 cmdline_fixed_string_t set;
3838 cmdline_fixed_string_t link_check;
3839 cmdline_fixed_string_t mode;
3843 cmd_set_link_check_parsed(void *parsed_result,
3844 __attribute__((unused)) struct cmdline *cl,
3845 __attribute__((unused)) void *data)
3847 struct cmd_set_link_check *res = parsed_result;
3848 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3851 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3854 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3855 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3856 link_check, "link_check");
3857 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3858 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3862 cmdline_parse_inst_t cmd_set_link_check = {
3863 .f = cmd_set_link_check_parsed,
3864 .help_str = "set link_check on|off: Enable/Disable link status check "
3865 "when starting/stopping a port",
3868 (void *)&cmd_setlinkcheck_set,
3869 (void *)&cmd_setlinkcheck_link_check,
3870 (void *)&cmd_setlinkcheck_mode,
3875 #ifdef RTE_NIC_BYPASS
3876 /* *** SET NIC BYPASS MODE *** */
3877 struct cmd_set_bypass_mode_result {
3878 cmdline_fixed_string_t set;
3879 cmdline_fixed_string_t bypass;
3880 cmdline_fixed_string_t mode;
3881 cmdline_fixed_string_t value;
3886 cmd_set_bypass_mode_parsed(void *parsed_result,
3887 __attribute__((unused)) struct cmdline *cl,
3888 __attribute__((unused)) void *data)
3890 struct cmd_set_bypass_mode_result *res = parsed_result;
3891 portid_t port_id = res->port_id;
3892 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3894 if (!strcmp(res->value, "bypass"))
3895 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3896 else if (!strcmp(res->value, "isolate"))
3897 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3899 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3901 /* Set the bypass mode for the relevant port. */
3902 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3903 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3907 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3910 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3911 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3913 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3914 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3916 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3918 value, "normal#bypass#isolate");
3919 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3920 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3923 cmdline_parse_inst_t cmd_set_bypass_mode = {
3924 .f = cmd_set_bypass_mode_parsed,
3925 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3926 "Set the NIC bypass mode for port_id",
3929 (void *)&cmd_setbypass_mode_set,
3930 (void *)&cmd_setbypass_mode_bypass,
3931 (void *)&cmd_setbypass_mode_mode,
3932 (void *)&cmd_setbypass_mode_value,
3933 (void *)&cmd_setbypass_mode_port,
3938 /* *** SET NIC BYPASS EVENT *** */
3939 struct cmd_set_bypass_event_result {
3940 cmdline_fixed_string_t set;
3941 cmdline_fixed_string_t bypass;
3942 cmdline_fixed_string_t event;
3943 cmdline_fixed_string_t event_value;
3944 cmdline_fixed_string_t mode;
3945 cmdline_fixed_string_t mode_value;
3950 cmd_set_bypass_event_parsed(void *parsed_result,
3951 __attribute__((unused)) struct cmdline *cl,
3952 __attribute__((unused)) void *data)
3955 struct cmd_set_bypass_event_result *res = parsed_result;
3956 portid_t port_id = res->port_id;
3957 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3958 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3960 if (!strcmp(res->event_value, "timeout"))
3961 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3962 else if (!strcmp(res->event_value, "os_on"))
3963 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3964 else if (!strcmp(res->event_value, "os_off"))
3965 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3966 else if (!strcmp(res->event_value, "power_on"))
3967 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3968 else if (!strcmp(res->event_value, "power_off"))
3969 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3971 bypass_event = RTE_BYPASS_EVENT_NONE;
3973 if (!strcmp(res->mode_value, "bypass"))
3974 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3975 else if (!strcmp(res->mode_value, "isolate"))
3976 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3978 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3980 /* Set the watchdog timeout. */
3981 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3984 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3985 (rc = rte_eth_dev_wd_timeout_store(port_id,
3986 bypass_timeout)) != 0) {
3987 printf("Failed to set timeout value %u "
3988 "for port %d, errto code: %d.\n",
3989 bypass_timeout, port_id, rc);
3993 /* Set the bypass event to transition to bypass mode. */
3994 if (0 != rte_eth_dev_bypass_event_store(port_id,
3995 bypass_event, bypass_mode)) {
3996 printf("\t Failed to set bypass event for port = %d.\n", port_id);
4001 cmdline_parse_token_string_t cmd_setbypass_event_set =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4004 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4005 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4007 cmdline_parse_token_string_t cmd_setbypass_event_event =
4008 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4010 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4011 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4012 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4013 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4014 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4016 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4017 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4018 mode_value, "normal#bypass#isolate");
4019 cmdline_parse_token_num_t cmd_setbypass_event_port =
4020 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4023 cmdline_parse_inst_t cmd_set_bypass_event = {
4024 .f = cmd_set_bypass_event_parsed,
4025 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4026 "power_off mode normal|bypass|isolate <port_id>: "
4027 "Set the NIC bypass event mode for port_id",
4030 (void *)&cmd_setbypass_event_set,
4031 (void *)&cmd_setbypass_event_bypass,
4032 (void *)&cmd_setbypass_event_event,
4033 (void *)&cmd_setbypass_event_event_value,
4034 (void *)&cmd_setbypass_event_mode,
4035 (void *)&cmd_setbypass_event_mode_value,
4036 (void *)&cmd_setbypass_event_port,
4042 /* *** SET NIC BYPASS TIMEOUT *** */
4043 struct cmd_set_bypass_timeout_result {
4044 cmdline_fixed_string_t set;
4045 cmdline_fixed_string_t bypass;
4046 cmdline_fixed_string_t timeout;
4047 cmdline_fixed_string_t value;
4051 cmd_set_bypass_timeout_parsed(void *parsed_result,
4052 __attribute__((unused)) struct cmdline *cl,
4053 __attribute__((unused)) void *data)
4055 struct cmd_set_bypass_timeout_result *res = parsed_result;
4057 if (!strcmp(res->value, "1.5"))
4058 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4059 else if (!strcmp(res->value, "2"))
4060 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4061 else if (!strcmp(res->value, "3"))
4062 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4063 else if (!strcmp(res->value, "4"))
4064 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4065 else if (!strcmp(res->value, "8"))
4066 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4067 else if (!strcmp(res->value, "16"))
4068 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4069 else if (!strcmp(res->value, "32"))
4070 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4072 bypass_timeout = RTE_BYPASS_TMT_OFF;
4075 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4078 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4079 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4081 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4082 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4083 timeout, "timeout");
4084 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4086 value, "0#1.5#2#3#4#8#16#32");
4088 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4089 .f = cmd_set_bypass_timeout_parsed,
4090 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4091 "Set the NIC bypass watchdog timeout in seconds",
4094 (void *)&cmd_setbypass_timeout_set,
4095 (void *)&cmd_setbypass_timeout_bypass,
4096 (void *)&cmd_setbypass_timeout_timeout,
4097 (void *)&cmd_setbypass_timeout_value,
4102 /* *** SHOW NIC BYPASS MODE *** */
4103 struct cmd_show_bypass_config_result {
4104 cmdline_fixed_string_t show;
4105 cmdline_fixed_string_t bypass;
4106 cmdline_fixed_string_t config;
4111 cmd_show_bypass_config_parsed(void *parsed_result,
4112 __attribute__((unused)) struct cmdline *cl,
4113 __attribute__((unused)) void *data)
4115 struct cmd_show_bypass_config_result *res = parsed_result;
4116 uint32_t event_mode;
4117 uint32_t bypass_mode;
4118 portid_t port_id = res->port_id;
4119 uint32_t timeout = bypass_timeout;
4122 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4123 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4124 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4125 {"UNKNOWN", "normal", "bypass", "isolate"};
4126 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4133 int num_events = (sizeof events) / (sizeof events[0]);
4135 /* Display the bypass mode.*/
4136 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4137 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4141 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4142 bypass_mode = RTE_BYPASS_MODE_NONE;
4144 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4147 /* Display the bypass timeout.*/
4148 if (!RTE_BYPASS_TMT_VALID(timeout))
4149 timeout = RTE_BYPASS_TMT_OFF;
4151 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4153 /* Display the bypass events and associated modes. */
4154 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4156 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4157 printf("\tFailed to get bypass mode for event = %s\n",
4160 if (!RTE_BYPASS_MODE_VALID(event_mode))
4161 event_mode = RTE_BYPASS_MODE_NONE;
4163 printf("\tbypass event: %-16s = %s\n", events[i],
4169 cmdline_parse_token_string_t cmd_showbypass_config_show =
4170 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4172 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4173 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4175 cmdline_parse_token_string_t cmd_showbypass_config_config =
4176 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4178 cmdline_parse_token_num_t cmd_showbypass_config_port =
4179 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4182 cmdline_parse_inst_t cmd_show_bypass_config = {
4183 .f = cmd_show_bypass_config_parsed,
4184 .help_str = "show bypass config <port_id>: "
4185 "Show the NIC bypass config for port_id",
4188 (void *)&cmd_showbypass_config_show,
4189 (void *)&cmd_showbypass_config_bypass,
4190 (void *)&cmd_showbypass_config_config,
4191 (void *)&cmd_showbypass_config_port,
4197 #ifdef RTE_LIBRTE_PMD_BOND
4198 /* *** SET BONDING MODE *** */
4199 struct cmd_set_bonding_mode_result {
4200 cmdline_fixed_string_t set;
4201 cmdline_fixed_string_t bonding;
4202 cmdline_fixed_string_t mode;
4207 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4208 __attribute__((unused)) struct cmdline *cl,
4209 __attribute__((unused)) void *data)
4211 struct cmd_set_bonding_mode_result *res = parsed_result;
4212 portid_t port_id = res->port_id;
4214 /* Set the bonding mode for the relevant port. */
4215 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4216 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4219 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4220 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4222 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4223 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4224 bonding, "bonding");
4225 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4226 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4228 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4229 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4231 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4232 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4235 cmdline_parse_inst_t cmd_set_bonding_mode = {
4236 .f = cmd_set_bonding_mode_parsed,
4237 .help_str = "set bonding mode <mode_value> <port_id>: "
4238 "Set the bonding mode for port_id",
4241 (void *) &cmd_setbonding_mode_set,
4242 (void *) &cmd_setbonding_mode_bonding,
4243 (void *) &cmd_setbonding_mode_mode,
4244 (void *) &cmd_setbonding_mode_value,
4245 (void *) &cmd_setbonding_mode_port,
4250 /* *** SET BALANCE XMIT POLICY *** */
4251 struct cmd_set_bonding_balance_xmit_policy_result {
4252 cmdline_fixed_string_t set;
4253 cmdline_fixed_string_t bonding;
4254 cmdline_fixed_string_t balance_xmit_policy;
4256 cmdline_fixed_string_t policy;
4259 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4260 __attribute__((unused)) struct cmdline *cl,
4261 __attribute__((unused)) void *data)
4263 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4264 portid_t port_id = res->port_id;
4267 if (!strcmp(res->policy, "l2")) {
4268 policy = BALANCE_XMIT_POLICY_LAYER2;
4269 } else if (!strcmp(res->policy, "l23")) {
4270 policy = BALANCE_XMIT_POLICY_LAYER23;
4271 } else if (!strcmp(res->policy, "l34")) {
4272 policy = BALANCE_XMIT_POLICY_LAYER34;
4274 printf("\t Invalid xmit policy selection");
4278 /* Set the bonding mode for the relevant port. */
4279 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4280 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4285 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4288 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4289 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4290 bonding, "bonding");
4291 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4292 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4293 balance_xmit_policy, "balance_xmit_policy");
4294 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4295 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4297 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4298 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4299 policy, "l2#l23#l34");
4301 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4302 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4303 .help_str = "set bonding balance_xmit_policy <port_id> "
4305 "Set the bonding balance_xmit_policy for port_id",
4308 (void *)&cmd_setbonding_balance_xmit_policy_set,
4309 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4310 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4311 (void *)&cmd_setbonding_balance_xmit_policy_port,
4312 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4317 /* *** SHOW NIC BONDING CONFIGURATION *** */
4318 struct cmd_show_bonding_config_result {
4319 cmdline_fixed_string_t show;
4320 cmdline_fixed_string_t bonding;
4321 cmdline_fixed_string_t config;
4325 static void cmd_show_bonding_config_parsed(void *parsed_result,
4326 __attribute__((unused)) struct cmdline *cl,
4327 __attribute__((unused)) void *data)
4329 struct cmd_show_bonding_config_result *res = parsed_result;
4331 uint8_t slaves[RTE_MAX_ETHPORTS];
4332 int num_slaves, num_active_slaves;
4335 portid_t port_id = res->port_id;
4337 /* Display the bonding mode.*/
4338 bonding_mode = rte_eth_bond_mode_get(port_id);
4339 if (bonding_mode < 0) {
4340 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4343 printf("\tBonding mode: %d\n", bonding_mode);
4345 if (bonding_mode == BONDING_MODE_BALANCE) {
4346 int balance_xmit_policy;
4348 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4349 if (balance_xmit_policy < 0) {
4350 printf("\tFailed to get balance xmit policy for port = %d\n",
4354 printf("\tBalance Xmit Policy: ");
4356 switch (balance_xmit_policy) {
4357 case BALANCE_XMIT_POLICY_LAYER2:
4358 printf("BALANCE_XMIT_POLICY_LAYER2");
4360 case BALANCE_XMIT_POLICY_LAYER23:
4361 printf("BALANCE_XMIT_POLICY_LAYER23");
4363 case BALANCE_XMIT_POLICY_LAYER34:
4364 printf("BALANCE_XMIT_POLICY_LAYER34");
4371 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4373 if (num_slaves < 0) {
4374 printf("\tFailed to get slave list for port = %d\n", port_id);
4377 if (num_slaves > 0) {
4378 printf("\tSlaves (%d): [", num_slaves);
4379 for (i = 0; i < num_slaves - 1; i++)
4380 printf("%d ", slaves[i]);
4382 printf("%d]\n", slaves[num_slaves - 1]);
4384 printf("\tSlaves: []\n");
4388 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4391 if (num_active_slaves < 0) {
4392 printf("\tFailed to get active slave list for port = %d\n", port_id);
4395 if (num_active_slaves > 0) {
4396 printf("\tActive Slaves (%d): [", num_active_slaves);
4397 for (i = 0; i < num_active_slaves - 1; i++)
4398 printf("%d ", slaves[i]);
4400 printf("%d]\n", slaves[num_active_slaves - 1]);
4403 printf("\tActive Slaves: []\n");
4407 primary_id = rte_eth_bond_primary_get(port_id);
4408 if (primary_id < 0) {
4409 printf("\tFailed to get primary slave for port = %d\n", port_id);
4412 printf("\tPrimary: [%d]\n", primary_id);
4416 cmdline_parse_token_string_t cmd_showbonding_config_show =
4417 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4419 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4420 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4421 bonding, "bonding");
4422 cmdline_parse_token_string_t cmd_showbonding_config_config =
4423 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4425 cmdline_parse_token_num_t cmd_showbonding_config_port =
4426 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4429 cmdline_parse_inst_t cmd_show_bonding_config = {
4430 .f = cmd_show_bonding_config_parsed,
4431 .help_str = "show bonding config <port_id>: "
4432 "Show the bonding config for port_id",
4435 (void *)&cmd_showbonding_config_show,
4436 (void *)&cmd_showbonding_config_bonding,
4437 (void *)&cmd_showbonding_config_config,
4438 (void *)&cmd_showbonding_config_port,
4443 /* *** SET BONDING PRIMARY *** */
4444 struct cmd_set_bonding_primary_result {
4445 cmdline_fixed_string_t set;
4446 cmdline_fixed_string_t bonding;
4447 cmdline_fixed_string_t primary;
4452 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4453 __attribute__((unused)) struct cmdline *cl,
4454 __attribute__((unused)) void *data)
4456 struct cmd_set_bonding_primary_result *res = parsed_result;
4457 portid_t master_port_id = res->port_id;
4458 portid_t slave_port_id = res->slave_id;
4460 /* Set the primary slave for a bonded device. */
4461 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4462 printf("\t Failed to set primary slave for port = %d.\n",
4469 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4470 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4472 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4473 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4474 bonding, "bonding");
4475 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4476 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4477 primary, "primary");
4478 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4479 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4481 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4482 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4485 cmdline_parse_inst_t cmd_set_bonding_primary = {
4486 .f = cmd_set_bonding_primary_parsed,
4487 .help_str = "set bonding primary <slave_id> <port_id>: "
4488 "Set the primary slave for port_id",
4491 (void *)&cmd_setbonding_primary_set,
4492 (void *)&cmd_setbonding_primary_bonding,
4493 (void *)&cmd_setbonding_primary_primary,
4494 (void *)&cmd_setbonding_primary_slave,
4495 (void *)&cmd_setbonding_primary_port,
4500 /* *** ADD SLAVE *** */
4501 struct cmd_add_bonding_slave_result {
4502 cmdline_fixed_string_t add;
4503 cmdline_fixed_string_t bonding;
4504 cmdline_fixed_string_t slave;
4509 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4510 __attribute__((unused)) struct cmdline *cl,
4511 __attribute__((unused)) void *data)
4513 struct cmd_add_bonding_slave_result *res = parsed_result;
4514 portid_t master_port_id = res->port_id;
4515 portid_t slave_port_id = res->slave_id;
4517 /* Set the primary slave for a bonded device. */
4518 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4519 printf("\t Failed to add slave %d to master port = %d.\n",
4520 slave_port_id, master_port_id);
4524 set_port_slave_flag(slave_port_id);
4527 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4528 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4530 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4531 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4532 bonding, "bonding");
4533 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4534 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4536 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4537 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4539 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4540 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4543 cmdline_parse_inst_t cmd_add_bonding_slave = {
4544 .f = cmd_add_bonding_slave_parsed,
4545 .help_str = "add bonding slave <slave_id> <port_id>: "
4546 "Add a slave device to a bonded device",
4549 (void *)&cmd_addbonding_slave_add,
4550 (void *)&cmd_addbonding_slave_bonding,
4551 (void *)&cmd_addbonding_slave_slave,
4552 (void *)&cmd_addbonding_slave_slaveid,
4553 (void *)&cmd_addbonding_slave_port,
4558 /* *** REMOVE SLAVE *** */
4559 struct cmd_remove_bonding_slave_result {
4560 cmdline_fixed_string_t remove;
4561 cmdline_fixed_string_t bonding;
4562 cmdline_fixed_string_t slave;
4567 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4568 __attribute__((unused)) struct cmdline *cl,
4569 __attribute__((unused)) void *data)
4571 struct cmd_remove_bonding_slave_result *res = parsed_result;
4572 portid_t master_port_id = res->port_id;
4573 portid_t slave_port_id = res->slave_id;
4575 /* Set the primary slave for a bonded device. */
4576 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4577 printf("\t Failed to remove slave %d from master port = %d.\n",
4578 slave_port_id, master_port_id);
4582 clear_port_slave_flag(slave_port_id);
4585 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4586 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4588 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4589 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4590 bonding, "bonding");
4591 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4592 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4594 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4595 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4597 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4598 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4601 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4602 .f = cmd_remove_bonding_slave_parsed,
4603 .help_str = "remove bonding slave <slave_id> <port_id>: "
4604 "Remove a slave device from a bonded device",
4607 (void *)&cmd_removebonding_slave_remove,
4608 (void *)&cmd_removebonding_slave_bonding,
4609 (void *)&cmd_removebonding_slave_slave,
4610 (void *)&cmd_removebonding_slave_slaveid,
4611 (void *)&cmd_removebonding_slave_port,
4616 /* *** CREATE BONDED DEVICE *** */
4617 struct cmd_create_bonded_device_result {
4618 cmdline_fixed_string_t create;
4619 cmdline_fixed_string_t bonded;
4620 cmdline_fixed_string_t device;
4625 static int bond_dev_num = 0;
4627 static void cmd_create_bonded_device_parsed(void *parsed_result,
4628 __attribute__((unused)) struct cmdline *cl,
4629 __attribute__((unused)) void *data)
4631 struct cmd_create_bonded_device_result *res = parsed_result;
4632 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4635 if (test_done == 0) {
4636 printf("Please stop forwarding first\n");
4640 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4643 /* Create a new bonded device. */
4644 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4646 printf("\t Failed to create bonded device.\n");
4649 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4652 /* Update number of ports */
4653 nb_ports = rte_eth_dev_count();
4654 reconfig(port_id, res->socket);
4655 rte_eth_promiscuous_enable(port_id);
4656 ports[port_id].enabled = 1;
4661 cmdline_parse_token_string_t cmd_createbonded_device_create =
4662 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4664 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4665 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4667 cmdline_parse_token_string_t cmd_createbonded_device_device =
4668 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4670 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4671 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4673 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4674 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4677 cmdline_parse_inst_t cmd_create_bonded_device = {
4678 .f = cmd_create_bonded_device_parsed,
4679 .help_str = "create bonded device <mode> <socket>: "
4680 "Create a new bonded device with specific bonding mode and socket",
4683 (void *)&cmd_createbonded_device_create,
4684 (void *)&cmd_createbonded_device_bonded,
4685 (void *)&cmd_createbonded_device_device,
4686 (void *)&cmd_createbonded_device_mode,
4687 (void *)&cmd_createbonded_device_socket,
4692 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4693 struct cmd_set_bond_mac_addr_result {
4694 cmdline_fixed_string_t set;
4695 cmdline_fixed_string_t bonding;
4696 cmdline_fixed_string_t mac_addr;
4698 struct ether_addr address;
4701 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4702 __attribute__((unused)) struct cmdline *cl,
4703 __attribute__((unused)) void *data)
4705 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4708 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4711 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4713 /* check the return value and print it if is < 0 */
4715 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4718 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4719 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4720 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4721 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4723 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4724 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4726 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4727 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4728 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4729 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4731 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4732 .f = cmd_set_bond_mac_addr_parsed,
4734 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4736 (void *)&cmd_set_bond_mac_addr_set,
4737 (void *)&cmd_set_bond_mac_addr_bonding,
4738 (void *)&cmd_set_bond_mac_addr_mac,
4739 (void *)&cmd_set_bond_mac_addr_portnum,
4740 (void *)&cmd_set_bond_mac_addr_addr,
4746 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4747 struct cmd_set_bond_mon_period_result {
4748 cmdline_fixed_string_t set;
4749 cmdline_fixed_string_t bonding;
4750 cmdline_fixed_string_t mon_period;
4755 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4756 __attribute__((unused)) struct cmdline *cl,
4757 __attribute__((unused)) void *data)
4759 struct cmd_set_bond_mon_period_result *res = parsed_result;
4762 if (res->port_num >= nb_ports) {
4763 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4767 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4769 /* check the return value and print it if is < 0 */
4771 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4774 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4775 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4777 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4778 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4779 bonding, "bonding");
4780 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4781 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4782 mon_period, "mon_period");
4783 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4784 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4786 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4787 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4790 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4791 .f = cmd_set_bond_mon_period_parsed,
4793 .help_str = "set bonding mon_period <port_id> <period_ms>",
4795 (void *)&cmd_set_bond_mon_period_set,
4796 (void *)&cmd_set_bond_mon_period_bonding,
4797 (void *)&cmd_set_bond_mon_period_mon_period,
4798 (void *)&cmd_set_bond_mon_period_portnum,
4799 (void *)&cmd_set_bond_mon_period_period_ms,
4804 #endif /* RTE_LIBRTE_PMD_BOND */
4806 /* *** SET FORWARDING MODE *** */
4807 struct cmd_set_fwd_mode_result {
4808 cmdline_fixed_string_t set;
4809 cmdline_fixed_string_t fwd;
4810 cmdline_fixed_string_t mode;
4813 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4814 __attribute__((unused)) struct cmdline *cl,
4815 __attribute__((unused)) void *data)
4817 struct cmd_set_fwd_mode_result *res = parsed_result;
4820 set_pkt_forwarding_mode(res->mode);
4823 cmdline_parse_token_string_t cmd_setfwd_set =
4824 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4825 cmdline_parse_token_string_t cmd_setfwd_fwd =
4826 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4827 cmdline_parse_token_string_t cmd_setfwd_mode =
4828 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4829 "" /* defined at init */);
4831 cmdline_parse_inst_t cmd_set_fwd_mode = {
4832 .f = cmd_set_fwd_mode_parsed,
4834 .help_str = NULL, /* defined at init */
4836 (void *)&cmd_setfwd_set,
4837 (void *)&cmd_setfwd_fwd,
4838 (void *)&cmd_setfwd_mode,
4843 static void cmd_set_fwd_mode_init(void)
4846 static char token[128];
4847 static char help[256];
4848 cmdline_parse_token_string_t *token_struct;
4850 modes = list_pkt_forwarding_modes();
4851 snprintf(help, sizeof(help), "set fwd %s: "
4852 "Set packet forwarding mode", modes);
4853 cmd_set_fwd_mode.help_str = help;
4855 /* string token separator is # */
4856 for (c = token; *modes != '\0'; modes++)
4861 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4862 token_struct->string_data.str = token;
4865 /* *** SET RETRY FORWARDING MODE *** */
4866 struct cmd_set_fwd_retry_mode_result {
4867 cmdline_fixed_string_t set;
4868 cmdline_fixed_string_t fwd;
4869 cmdline_fixed_string_t mode;
4870 cmdline_fixed_string_t retry;
4873 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4874 __attribute__((unused)) struct cmdline *cl,
4875 __attribute__((unused)) void *data)
4877 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4880 set_pkt_forwarding_mode(res->mode);
4883 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4884 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4886 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4887 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4889 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4890 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4892 "" /* defined at init */);
4893 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4894 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4897 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4898 .f = cmd_set_fwd_retry_mode_parsed,
4900 .help_str = NULL, /* defined at init */
4902 (void *)&cmd_setfwd_retry_set,
4903 (void *)&cmd_setfwd_retry_fwd,
4904 (void *)&cmd_setfwd_retry_mode,
4905 (void *)&cmd_setfwd_retry_retry,
4910 static void cmd_set_fwd_retry_mode_init(void)
4913 static char token[128];
4914 static char help[256];
4915 cmdline_parse_token_string_t *token_struct;
4917 modes = list_pkt_forwarding_retry_modes();
4918 snprintf(help, sizeof(help), "set fwd %s retry: "
4919 "Set packet forwarding mode with retry", modes);
4920 cmd_set_fwd_retry_mode.help_str = help;
4922 /* string token separator is # */
4923 for (c = token; *modes != '\0'; modes++)
4928 token_struct = (cmdline_parse_token_string_t *)
4929 cmd_set_fwd_retry_mode.tokens[2];
4930 token_struct->string_data.str = token;
4933 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4934 struct cmd_set_burst_tx_retry_result {
4935 cmdline_fixed_string_t set;
4936 cmdline_fixed_string_t burst;
4937 cmdline_fixed_string_t tx;
4938 cmdline_fixed_string_t delay;
4940 cmdline_fixed_string_t retry;
4944 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4945 __attribute__((unused)) struct cmdline *cl,
4946 __attribute__((unused)) void *data)
4948 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4950 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4951 && !strcmp(res->tx, "tx")) {
4952 if (!strcmp(res->delay, "delay"))
4953 burst_tx_delay_time = res->time;
4954 if (!strcmp(res->retry, "retry"))
4955 burst_tx_retry_num = res->retry_num;
4960 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4961 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4962 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4963 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4965 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4966 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4967 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4968 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4969 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4970 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4971 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4972 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4973 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4974 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4976 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4977 .f = cmd_set_burst_tx_retry_parsed,
4978 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4980 (void *)&cmd_set_burst_tx_retry_set,
4981 (void *)&cmd_set_burst_tx_retry_burst,
4982 (void *)&cmd_set_burst_tx_retry_tx,
4983 (void *)&cmd_set_burst_tx_retry_delay,
4984 (void *)&cmd_set_burst_tx_retry_time,
4985 (void *)&cmd_set_burst_tx_retry_retry,
4986 (void *)&cmd_set_burst_tx_retry_retry_num,
4991 /* *** SET PROMISC MODE *** */
4992 struct cmd_set_promisc_mode_result {
4993 cmdline_fixed_string_t set;
4994 cmdline_fixed_string_t promisc;
4995 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4996 uint8_t port_num; /* valid if "allports" argument == 0 */
4997 cmdline_fixed_string_t mode;
5000 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5001 __attribute__((unused)) struct cmdline *cl,
5004 struct cmd_set_promisc_mode_result *res = parsed_result;
5008 if (!strcmp(res->mode, "on"))
5015 FOREACH_PORT(i, ports) {
5017 rte_eth_promiscuous_enable(i);
5019 rte_eth_promiscuous_disable(i);
5024 rte_eth_promiscuous_enable(res->port_num);
5026 rte_eth_promiscuous_disable(res->port_num);
5030 cmdline_parse_token_string_t cmd_setpromisc_set =
5031 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5032 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5035 cmdline_parse_token_string_t cmd_setpromisc_portall =
5036 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5038 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5039 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5041 cmdline_parse_token_string_t cmd_setpromisc_mode =
5042 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5045 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5046 .f = cmd_set_promisc_mode_parsed,
5048 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5050 (void *)&cmd_setpromisc_set,
5051 (void *)&cmd_setpromisc_promisc,
5052 (void *)&cmd_setpromisc_portall,
5053 (void *)&cmd_setpromisc_mode,
5058 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5059 .f = cmd_set_promisc_mode_parsed,
5061 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5063 (void *)&cmd_setpromisc_set,
5064 (void *)&cmd_setpromisc_promisc,
5065 (void *)&cmd_setpromisc_portnum,
5066 (void *)&cmd_setpromisc_mode,
5071 /* *** SET ALLMULTI MODE *** */
5072 struct cmd_set_allmulti_mode_result {
5073 cmdline_fixed_string_t set;
5074 cmdline_fixed_string_t allmulti;
5075 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5076 uint8_t port_num; /* valid if "allports" argument == 0 */
5077 cmdline_fixed_string_t mode;
5080 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5081 __attribute__((unused)) struct cmdline *cl,
5084 struct cmd_set_allmulti_mode_result *res = parsed_result;
5088 if (!strcmp(res->mode, "on"))
5095 FOREACH_PORT(i, ports) {
5097 rte_eth_allmulticast_enable(i);
5099 rte_eth_allmulticast_disable(i);
5104 rte_eth_allmulticast_enable(res->port_num);
5106 rte_eth_allmulticast_disable(res->port_num);
5110 cmdline_parse_token_string_t cmd_setallmulti_set =
5111 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5112 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5113 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5115 cmdline_parse_token_string_t cmd_setallmulti_portall =
5116 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5118 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5119 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5121 cmdline_parse_token_string_t cmd_setallmulti_mode =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5125 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5126 .f = cmd_set_allmulti_mode_parsed,
5128 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5130 (void *)&cmd_setallmulti_set,
5131 (void *)&cmd_setallmulti_allmulti,
5132 (void *)&cmd_setallmulti_portall,
5133 (void *)&cmd_setallmulti_mode,
5138 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5139 .f = cmd_set_allmulti_mode_parsed,
5141 .help_str = "set allmulti <port_id> on|off: "
5142 "Set allmulti mode on port_id",
5144 (void *)&cmd_setallmulti_set,
5145 (void *)&cmd_setallmulti_allmulti,
5146 (void *)&cmd_setallmulti_portnum,
5147 (void *)&cmd_setallmulti_mode,
5152 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5153 struct cmd_link_flow_ctrl_set_result {
5154 cmdline_fixed_string_t set;
5155 cmdline_fixed_string_t flow_ctrl;
5156 cmdline_fixed_string_t rx;
5157 cmdline_fixed_string_t rx_lfc_mode;
5158 cmdline_fixed_string_t tx;
5159 cmdline_fixed_string_t tx_lfc_mode;
5160 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5161 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5162 cmdline_fixed_string_t autoneg_str;
5163 cmdline_fixed_string_t autoneg;
5164 cmdline_fixed_string_t hw_str;
5165 uint32_t high_water;
5166 cmdline_fixed_string_t lw_str;
5168 cmdline_fixed_string_t pt_str;
5169 uint16_t pause_time;
5170 cmdline_fixed_string_t xon_str;
5175 cmdline_parse_token_string_t cmd_lfc_set_set =
5176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5178 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5180 flow_ctrl, "flow_ctrl");
5181 cmdline_parse_token_string_t cmd_lfc_set_rx =
5182 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5184 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5186 rx_lfc_mode, "on#off");
5187 cmdline_parse_token_string_t cmd_lfc_set_tx =
5188 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5190 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5191 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 tx_lfc_mode, "on#off");
5193 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5194 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5195 hw_str, "high_water");
5196 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5197 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 high_water, UINT32);
5199 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5200 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5201 lw_str, "low_water");
5202 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5203 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5205 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5206 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5207 pt_str, "pause_time");
5208 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5209 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5210 pause_time, UINT16);
5211 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5212 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5213 xon_str, "send_xon");
5214 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5215 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5217 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5218 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5219 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5220 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5221 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5222 mac_ctrl_frame_fwd_mode, "on#off");
5223 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5224 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5225 autoneg_str, "autoneg");
5226 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5227 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5229 cmdline_parse_token_num_t cmd_lfc_set_portid =
5230 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5233 /* forward declaration */
5235 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5238 cmdline_parse_inst_t cmd_link_flow_control_set = {
5239 .f = cmd_link_flow_ctrl_set_parsed,
5241 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5242 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5243 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5245 (void *)&cmd_lfc_set_set,
5246 (void *)&cmd_lfc_set_flow_ctrl,
5247 (void *)&cmd_lfc_set_rx,
5248 (void *)&cmd_lfc_set_rx_mode,
5249 (void *)&cmd_lfc_set_tx,
5250 (void *)&cmd_lfc_set_tx_mode,
5251 (void *)&cmd_lfc_set_high_water,
5252 (void *)&cmd_lfc_set_low_water,
5253 (void *)&cmd_lfc_set_pause_time,
5254 (void *)&cmd_lfc_set_send_xon,
5255 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5256 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5257 (void *)&cmd_lfc_set_autoneg_str,
5258 (void *)&cmd_lfc_set_autoneg,
5259 (void *)&cmd_lfc_set_portid,
5264 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5265 .f = cmd_link_flow_ctrl_set_parsed,
5266 .data = (void *)&cmd_link_flow_control_set_rx,
5267 .help_str = "set flow_ctrl rx on|off <port_id>: "
5268 "Change rx flow control parameter",
5270 (void *)&cmd_lfc_set_set,
5271 (void *)&cmd_lfc_set_flow_ctrl,
5272 (void *)&cmd_lfc_set_rx,
5273 (void *)&cmd_lfc_set_rx_mode,
5274 (void *)&cmd_lfc_set_portid,
5279 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5280 .f = cmd_link_flow_ctrl_set_parsed,
5281 .data = (void *)&cmd_link_flow_control_set_tx,
5282 .help_str = "set flow_ctrl tx on|off <port_id>: "
5283 "Change tx flow control parameter",
5285 (void *)&cmd_lfc_set_set,
5286 (void *)&cmd_lfc_set_flow_ctrl,
5287 (void *)&cmd_lfc_set_tx,
5288 (void *)&cmd_lfc_set_tx_mode,
5289 (void *)&cmd_lfc_set_portid,
5294 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5295 .f = cmd_link_flow_ctrl_set_parsed,
5296 .data = (void *)&cmd_link_flow_control_set_hw,
5297 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5298 "Change high water flow control parameter",
5300 (void *)&cmd_lfc_set_set,
5301 (void *)&cmd_lfc_set_flow_ctrl,
5302 (void *)&cmd_lfc_set_high_water_str,
5303 (void *)&cmd_lfc_set_high_water,
5304 (void *)&cmd_lfc_set_portid,
5309 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5310 .f = cmd_link_flow_ctrl_set_parsed,
5311 .data = (void *)&cmd_link_flow_control_set_lw,
5312 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5313 "Change low water flow control parameter",
5315 (void *)&cmd_lfc_set_set,
5316 (void *)&cmd_lfc_set_flow_ctrl,
5317 (void *)&cmd_lfc_set_low_water_str,
5318 (void *)&cmd_lfc_set_low_water,
5319 (void *)&cmd_lfc_set_portid,
5324 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5325 .f = cmd_link_flow_ctrl_set_parsed,
5326 .data = (void *)&cmd_link_flow_control_set_pt,
5327 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5328 "Change pause time flow control parameter",
5330 (void *)&cmd_lfc_set_set,
5331 (void *)&cmd_lfc_set_flow_ctrl,
5332 (void *)&cmd_lfc_set_pause_time_str,
5333 (void *)&cmd_lfc_set_pause_time,
5334 (void *)&cmd_lfc_set_portid,
5339 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5340 .f = cmd_link_flow_ctrl_set_parsed,
5341 .data = (void *)&cmd_link_flow_control_set_xon,
5342 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5343 "Change send_xon flow control parameter",
5345 (void *)&cmd_lfc_set_set,
5346 (void *)&cmd_lfc_set_flow_ctrl,
5347 (void *)&cmd_lfc_set_send_xon_str,
5348 (void *)&cmd_lfc_set_send_xon,
5349 (void *)&cmd_lfc_set_portid,
5354 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5355 .f = cmd_link_flow_ctrl_set_parsed,
5356 .data = (void *)&cmd_link_flow_control_set_macfwd,
5357 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5358 "Change mac ctrl fwd flow control parameter",
5360 (void *)&cmd_lfc_set_set,
5361 (void *)&cmd_lfc_set_flow_ctrl,
5362 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5363 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5364 (void *)&cmd_lfc_set_portid,
5369 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5370 .f = cmd_link_flow_ctrl_set_parsed,
5371 .data = (void *)&cmd_link_flow_control_set_autoneg,
5372 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5373 "Change autoneg flow control parameter",
5375 (void *)&cmd_lfc_set_set,
5376 (void *)&cmd_lfc_set_flow_ctrl,
5377 (void *)&cmd_lfc_set_autoneg_str,
5378 (void *)&cmd_lfc_set_autoneg,
5379 (void *)&cmd_lfc_set_portid,
5385 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5386 __attribute__((unused)) struct cmdline *cl,
5389 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5390 cmdline_parse_inst_t *cmd = data;
5391 struct rte_eth_fc_conf fc_conf;
5397 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5398 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5399 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5400 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5402 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5403 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5406 /* Partial command line, retrieve current configuration */
5408 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5410 printf("cannot get current flow ctrl parameters, return"
5411 "code = %d\n", ret);
5415 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5416 (fc_conf.mode == RTE_FC_FULL))
5418 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5419 (fc_conf.mode == RTE_FC_FULL))
5423 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5424 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5426 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5427 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5429 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5431 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5432 fc_conf.high_water = res->high_water;
5434 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5435 fc_conf.low_water = res->low_water;
5437 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5438 fc_conf.pause_time = res->pause_time;
5440 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5441 fc_conf.send_xon = res->send_xon;
5443 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5444 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5445 fc_conf.mac_ctrl_frame_fwd = 1;
5447 fc_conf.mac_ctrl_frame_fwd = 0;
5450 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5451 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5453 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5455 printf("bad flow contrl parameter, return code = %d \n", ret);
5458 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5459 struct cmd_priority_flow_ctrl_set_result {
5460 cmdline_fixed_string_t set;
5461 cmdline_fixed_string_t pfc_ctrl;
5462 cmdline_fixed_string_t rx;
5463 cmdline_fixed_string_t rx_pfc_mode;
5464 cmdline_fixed_string_t tx;
5465 cmdline_fixed_string_t tx_pfc_mode;
5466 uint32_t high_water;
5468 uint16_t pause_time;
5474 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5475 __attribute__((unused)) struct cmdline *cl,
5476 __attribute__((unused)) void *data)
5478 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5479 struct rte_eth_pfc_conf pfc_conf;
5480 int rx_fc_enable, tx_fc_enable;
5484 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5485 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5486 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5487 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5489 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5490 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5493 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5494 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5495 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5496 pfc_conf.fc.high_water = res->high_water;
5497 pfc_conf.fc.low_water = res->low_water;
5498 pfc_conf.fc.pause_time = res->pause_time;
5499 pfc_conf.priority = res->priority;
5501 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5503 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5506 cmdline_parse_token_string_t cmd_pfc_set_set =
5507 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5509 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5510 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5511 pfc_ctrl, "pfc_ctrl");
5512 cmdline_parse_token_string_t cmd_pfc_set_rx =
5513 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5515 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5516 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5517 rx_pfc_mode, "on#off");
5518 cmdline_parse_token_string_t cmd_pfc_set_tx =
5519 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5521 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5522 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5523 tx_pfc_mode, "on#off");
5524 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5525 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5526 high_water, UINT32);
5527 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5528 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5530 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5531 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5532 pause_time, UINT16);
5533 cmdline_parse_token_num_t cmd_pfc_set_priority =
5534 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5536 cmdline_parse_token_num_t cmd_pfc_set_portid =
5537 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5540 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5541 .f = cmd_priority_flow_ctrl_set_parsed,
5543 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5544 "<pause_time> <priority> <port_id>: "
5545 "Configure the Ethernet priority flow control",
5547 (void *)&cmd_pfc_set_set,
5548 (void *)&cmd_pfc_set_flow_ctrl,
5549 (void *)&cmd_pfc_set_rx,
5550 (void *)&cmd_pfc_set_rx_mode,
5551 (void *)&cmd_pfc_set_tx,
5552 (void *)&cmd_pfc_set_tx_mode,
5553 (void *)&cmd_pfc_set_high_water,
5554 (void *)&cmd_pfc_set_low_water,
5555 (void *)&cmd_pfc_set_pause_time,
5556 (void *)&cmd_pfc_set_priority,
5557 (void *)&cmd_pfc_set_portid,
5562 /* *** RESET CONFIGURATION *** */
5563 struct cmd_reset_result {
5564 cmdline_fixed_string_t reset;
5565 cmdline_fixed_string_t def;
5568 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5570 __attribute__((unused)) void *data)
5572 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5573 set_def_fwd_config();
5576 cmdline_parse_token_string_t cmd_reset_set =
5577 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5578 cmdline_parse_token_string_t cmd_reset_def =
5579 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5582 cmdline_parse_inst_t cmd_reset = {
5583 .f = cmd_reset_parsed,
5585 .help_str = "set default: Reset default forwarding configuration",
5587 (void *)&cmd_reset_set,
5588 (void *)&cmd_reset_def,
5593 /* *** START FORWARDING *** */
5594 struct cmd_start_result {
5595 cmdline_fixed_string_t start;
5598 cmdline_parse_token_string_t cmd_start_start =
5599 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5601 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5602 __attribute__((unused)) struct cmdline *cl,
5603 __attribute__((unused)) void *data)
5605 start_packet_forwarding(0);
5608 cmdline_parse_inst_t cmd_start = {
5609 .f = cmd_start_parsed,
5611 .help_str = "start: Start packet forwarding",
5613 (void *)&cmd_start_start,
5618 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5619 struct cmd_start_tx_first_result {
5620 cmdline_fixed_string_t start;
5621 cmdline_fixed_string_t tx_first;
5625 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5626 __attribute__((unused)) struct cmdline *cl,
5627 __attribute__((unused)) void *data)
5629 start_packet_forwarding(1);
5632 cmdline_parse_token_string_t cmd_start_tx_first_start =
5633 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5635 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5636 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5637 tx_first, "tx_first");
5639 cmdline_parse_inst_t cmd_start_tx_first = {
5640 .f = cmd_start_tx_first_parsed,
5642 .help_str = "start tx_first: Start packet forwarding, "
5643 "after sending 1 burst of packets",
5645 (void *)&cmd_start_tx_first_start,
5646 (void *)&cmd_start_tx_first_tx_first,
5651 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5652 struct cmd_start_tx_first_n_result {
5653 cmdline_fixed_string_t start;
5654 cmdline_fixed_string_t tx_first;
5659 cmd_start_tx_first_n_parsed(void *parsed_result,
5660 __attribute__((unused)) struct cmdline *cl,
5661 __attribute__((unused)) void *data)
5663 struct cmd_start_tx_first_n_result *res = parsed_result;
5665 start_packet_forwarding(res->tx_num);
5668 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5669 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5671 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5672 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5673 tx_first, "tx_first");
5674 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5675 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5678 cmdline_parse_inst_t cmd_start_tx_first_n = {
5679 .f = cmd_start_tx_first_n_parsed,
5681 .help_str = "start tx_first <num>: "
5682 "packet forwarding, after sending <num> bursts of packets",
5684 (void *)&cmd_start_tx_first_n_start,
5685 (void *)&cmd_start_tx_first_n_tx_first,
5686 (void *)&cmd_start_tx_first_n_tx_num,
5691 /* *** SET LINK UP *** */
5692 struct cmd_set_link_up_result {
5693 cmdline_fixed_string_t set;
5694 cmdline_fixed_string_t link_up;
5695 cmdline_fixed_string_t port;
5699 cmdline_parse_token_string_t cmd_set_link_up_set =
5700 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5701 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5704 cmdline_parse_token_string_t cmd_set_link_up_port =
5705 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5706 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5707 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5709 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5710 __attribute__((unused)) struct cmdline *cl,
5711 __attribute__((unused)) void *data)
5713 struct cmd_set_link_up_result *res = parsed_result;
5714 dev_set_link_up(res->port_id);
5717 cmdline_parse_inst_t cmd_set_link_up = {
5718 .f = cmd_set_link_up_parsed,
5720 .help_str = "set link-up port <port id>",
5722 (void *)&cmd_set_link_up_set,
5723 (void *)&cmd_set_link_up_link_up,
5724 (void *)&cmd_set_link_up_port,
5725 (void *)&cmd_set_link_up_port_id,
5730 /* *** SET LINK DOWN *** */
5731 struct cmd_set_link_down_result {
5732 cmdline_fixed_string_t set;
5733 cmdline_fixed_string_t link_down;
5734 cmdline_fixed_string_t port;
5738 cmdline_parse_token_string_t cmd_set_link_down_set =
5739 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5740 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5741 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5743 cmdline_parse_token_string_t cmd_set_link_down_port =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5745 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5746 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5748 static void cmd_set_link_down_parsed(
5749 __attribute__((unused)) void *parsed_result,
5750 __attribute__((unused)) struct cmdline *cl,
5751 __attribute__((unused)) void *data)
5753 struct cmd_set_link_down_result *res = parsed_result;
5754 dev_set_link_down(res->port_id);
5757 cmdline_parse_inst_t cmd_set_link_down = {
5758 .f = cmd_set_link_down_parsed,
5760 .help_str = "set link-down port <port id>",
5762 (void *)&cmd_set_link_down_set,
5763 (void *)&cmd_set_link_down_link_down,
5764 (void *)&cmd_set_link_down_port,
5765 (void *)&cmd_set_link_down_port_id,
5770 /* *** SHOW CFG *** */
5771 struct cmd_showcfg_result {
5772 cmdline_fixed_string_t show;
5773 cmdline_fixed_string_t cfg;
5774 cmdline_fixed_string_t what;
5777 static void cmd_showcfg_parsed(void *parsed_result,
5778 __attribute__((unused)) struct cmdline *cl,
5779 __attribute__((unused)) void *data)
5781 struct cmd_showcfg_result *res = parsed_result;
5782 if (!strcmp(res->what, "rxtx"))
5783 rxtx_config_display();
5784 else if (!strcmp(res->what, "cores"))
5785 fwd_lcores_config_display();
5786 else if (!strcmp(res->what, "fwd"))
5787 pkt_fwd_config_display(&cur_fwd_config);
5788 else if (!strcmp(res->what, "txpkts"))
5789 show_tx_pkt_segments();
5792 cmdline_parse_token_string_t cmd_showcfg_show =
5793 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5794 cmdline_parse_token_string_t cmd_showcfg_port =
5795 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5796 cmdline_parse_token_string_t cmd_showcfg_what =
5797 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5798 "rxtx#cores#fwd#txpkts");
5800 cmdline_parse_inst_t cmd_showcfg = {
5801 .f = cmd_showcfg_parsed,
5803 .help_str = "show config rxtx|cores|fwd|txpkts",
5805 (void *)&cmd_showcfg_show,
5806 (void *)&cmd_showcfg_port,
5807 (void *)&cmd_showcfg_what,
5812 /* *** SHOW ALL PORT INFO *** */
5813 struct cmd_showportall_result {
5814 cmdline_fixed_string_t show;
5815 cmdline_fixed_string_t port;
5816 cmdline_fixed_string_t what;
5817 cmdline_fixed_string_t all;
5820 static void cmd_showportall_parsed(void *parsed_result,
5821 __attribute__((unused)) struct cmdline *cl,
5822 __attribute__((unused)) void *data)
5826 struct cmd_showportall_result *res = parsed_result;
5827 if (!strcmp(res->show, "clear")) {
5828 if (!strcmp(res->what, "stats"))
5829 FOREACH_PORT(i, ports)
5831 else if (!strcmp(res->what, "xstats"))
5832 FOREACH_PORT(i, ports)
5833 nic_xstats_clear(i);
5834 } else if (!strcmp(res->what, "info"))
5835 FOREACH_PORT(i, ports)
5836 port_infos_display(i);
5837 else if (!strcmp(res->what, "stats"))
5838 FOREACH_PORT(i, ports)
5839 nic_stats_display(i);
5840 else if (!strcmp(res->what, "xstats"))
5841 FOREACH_PORT(i, ports)
5842 nic_xstats_display(i);
5843 else if (!strcmp(res->what, "fdir"))
5844 FOREACH_PORT(i, ports)
5846 else if (!strcmp(res->what, "stat_qmap"))
5847 FOREACH_PORT(i, ports)
5848 nic_stats_mapping_display(i);
5849 else if (!strcmp(res->what, "dcb_tc"))
5850 FOREACH_PORT(i, ports)
5851 port_dcb_info_display(i);
5852 else if (!strcmp(res->what, "cap"))
5853 FOREACH_PORT(i, ports)
5854 port_offload_cap_display(i);
5857 cmdline_parse_token_string_t cmd_showportall_show =
5858 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5860 cmdline_parse_token_string_t cmd_showportall_port =
5861 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5862 cmdline_parse_token_string_t cmd_showportall_what =
5863 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5864 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5865 cmdline_parse_token_string_t cmd_showportall_all =
5866 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5867 cmdline_parse_inst_t cmd_showportall = {
5868 .f = cmd_showportall_parsed,
5870 .help_str = "show|clear port "
5871 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5873 (void *)&cmd_showportall_show,
5874 (void *)&cmd_showportall_port,
5875 (void *)&cmd_showportall_what,
5876 (void *)&cmd_showportall_all,
5881 /* *** SHOW PORT INFO *** */
5882 struct cmd_showport_result {
5883 cmdline_fixed_string_t show;
5884 cmdline_fixed_string_t port;
5885 cmdline_fixed_string_t what;
5889 static void cmd_showport_parsed(void *parsed_result,
5890 __attribute__((unused)) struct cmdline *cl,
5891 __attribute__((unused)) void *data)
5893 struct cmd_showport_result *res = parsed_result;
5894 if (!strcmp(res->show, "clear")) {
5895 if (!strcmp(res->what, "stats"))
5896 nic_stats_clear(res->portnum);
5897 else if (!strcmp(res->what, "xstats"))
5898 nic_xstats_clear(res->portnum);
5899 } else if (!strcmp(res->what, "info"))
5900 port_infos_display(res->portnum);
5901 else if (!strcmp(res->what, "stats"))
5902 nic_stats_display(res->portnum);
5903 else if (!strcmp(res->what, "xstats"))
5904 nic_xstats_display(res->portnum);
5905 else if (!strcmp(res->what, "fdir"))
5906 fdir_get_infos(res->portnum);
5907 else if (!strcmp(res->what, "stat_qmap"))
5908 nic_stats_mapping_display(res->portnum);
5909 else if (!strcmp(res->what, "dcb_tc"))
5910 port_dcb_info_display(res->portnum);
5911 else if (!strcmp(res->what, "cap"))
5912 port_offload_cap_display(res->portnum);
5915 cmdline_parse_token_string_t cmd_showport_show =
5916 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5918 cmdline_parse_token_string_t cmd_showport_port =
5919 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5920 cmdline_parse_token_string_t cmd_showport_what =
5921 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5922 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5923 cmdline_parse_token_num_t cmd_showport_portnum =
5924 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5926 cmdline_parse_inst_t cmd_showport = {
5927 .f = cmd_showport_parsed,
5929 .help_str = "show|clear port "
5930 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5933 (void *)&cmd_showport_show,
5934 (void *)&cmd_showport_port,
5935 (void *)&cmd_showport_what,
5936 (void *)&cmd_showport_portnum,
5941 /* *** SHOW QUEUE INFO *** */
5942 struct cmd_showqueue_result {
5943 cmdline_fixed_string_t show;
5944 cmdline_fixed_string_t type;
5945 cmdline_fixed_string_t what;
5951 cmd_showqueue_parsed(void *parsed_result,
5952 __attribute__((unused)) struct cmdline *cl,
5953 __attribute__((unused)) void *data)
5955 struct cmd_showqueue_result *res = parsed_result;
5957 if (!strcmp(res->type, "rxq"))
5958 rx_queue_infos_display(res->portnum, res->queuenum);
5959 else if (!strcmp(res->type, "txq"))
5960 tx_queue_infos_display(res->portnum, res->queuenum);
5963 cmdline_parse_token_string_t cmd_showqueue_show =
5964 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5965 cmdline_parse_token_string_t cmd_showqueue_type =
5966 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5967 cmdline_parse_token_string_t cmd_showqueue_what =
5968 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5969 cmdline_parse_token_num_t cmd_showqueue_portnum =
5970 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5971 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5972 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5974 cmdline_parse_inst_t cmd_showqueue = {
5975 .f = cmd_showqueue_parsed,
5977 .help_str = "show rxq|txq info <port_id> <queue_id>",
5979 (void *)&cmd_showqueue_show,
5980 (void *)&cmd_showqueue_type,
5981 (void *)&cmd_showqueue_what,
5982 (void *)&cmd_showqueue_portnum,
5983 (void *)&cmd_showqueue_queuenum,
5988 /* *** READ PORT REGISTER *** */
5989 struct cmd_read_reg_result {
5990 cmdline_fixed_string_t read;
5991 cmdline_fixed_string_t reg;
5997 cmd_read_reg_parsed(void *parsed_result,
5998 __attribute__((unused)) struct cmdline *cl,
5999 __attribute__((unused)) void *data)
6001 struct cmd_read_reg_result *res = parsed_result;
6002 port_reg_display(res->port_id, res->reg_off);
6005 cmdline_parse_token_string_t cmd_read_reg_read =
6006 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6007 cmdline_parse_token_string_t cmd_read_reg_reg =
6008 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6009 cmdline_parse_token_num_t cmd_read_reg_port_id =
6010 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6011 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6012 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6014 cmdline_parse_inst_t cmd_read_reg = {
6015 .f = cmd_read_reg_parsed,
6017 .help_str = "read reg <port_id> <reg_off>",
6019 (void *)&cmd_read_reg_read,
6020 (void *)&cmd_read_reg_reg,
6021 (void *)&cmd_read_reg_port_id,
6022 (void *)&cmd_read_reg_reg_off,
6027 /* *** READ PORT REGISTER BIT FIELD *** */
6028 struct cmd_read_reg_bit_field_result {
6029 cmdline_fixed_string_t read;
6030 cmdline_fixed_string_t regfield;
6038 cmd_read_reg_bit_field_parsed(void *parsed_result,
6039 __attribute__((unused)) struct cmdline *cl,
6040 __attribute__((unused)) void *data)
6042 struct cmd_read_reg_bit_field_result *res = parsed_result;
6043 port_reg_bit_field_display(res->port_id, res->reg_off,
6044 res->bit1_pos, res->bit2_pos);
6047 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6048 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6050 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6051 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6052 regfield, "regfield");
6053 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6054 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6056 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6057 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6059 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6060 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6062 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6063 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6066 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6067 .f = cmd_read_reg_bit_field_parsed,
6069 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6070 "Read register bit field between bit_x and bit_y included",
6072 (void *)&cmd_read_reg_bit_field_read,
6073 (void *)&cmd_read_reg_bit_field_regfield,
6074 (void *)&cmd_read_reg_bit_field_port_id,
6075 (void *)&cmd_read_reg_bit_field_reg_off,
6076 (void *)&cmd_read_reg_bit_field_bit1_pos,
6077 (void *)&cmd_read_reg_bit_field_bit2_pos,
6082 /* *** READ PORT REGISTER BIT *** */
6083 struct cmd_read_reg_bit_result {
6084 cmdline_fixed_string_t read;
6085 cmdline_fixed_string_t regbit;
6092 cmd_read_reg_bit_parsed(void *parsed_result,
6093 __attribute__((unused)) struct cmdline *cl,
6094 __attribute__((unused)) void *data)
6096 struct cmd_read_reg_bit_result *res = parsed_result;
6097 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6100 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6101 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6102 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6103 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6105 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6106 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6107 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6108 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6109 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6110 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6112 cmdline_parse_inst_t cmd_read_reg_bit = {
6113 .f = cmd_read_reg_bit_parsed,
6115 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6117 (void *)&cmd_read_reg_bit_read,
6118 (void *)&cmd_read_reg_bit_regbit,
6119 (void *)&cmd_read_reg_bit_port_id,
6120 (void *)&cmd_read_reg_bit_reg_off,
6121 (void *)&cmd_read_reg_bit_bit_pos,
6126 /* *** WRITE PORT REGISTER *** */
6127 struct cmd_write_reg_result {
6128 cmdline_fixed_string_t write;
6129 cmdline_fixed_string_t reg;
6136 cmd_write_reg_parsed(void *parsed_result,
6137 __attribute__((unused)) struct cmdline *cl,
6138 __attribute__((unused)) void *data)
6140 struct cmd_write_reg_result *res = parsed_result;
6141 port_reg_set(res->port_id, res->reg_off, res->value);
6144 cmdline_parse_token_string_t cmd_write_reg_write =
6145 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6146 cmdline_parse_token_string_t cmd_write_reg_reg =
6147 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6148 cmdline_parse_token_num_t cmd_write_reg_port_id =
6149 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6150 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6151 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6152 cmdline_parse_token_num_t cmd_write_reg_value =
6153 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6155 cmdline_parse_inst_t cmd_write_reg = {
6156 .f = cmd_write_reg_parsed,
6158 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6160 (void *)&cmd_write_reg_write,
6161 (void *)&cmd_write_reg_reg,
6162 (void *)&cmd_write_reg_port_id,
6163 (void *)&cmd_write_reg_reg_off,
6164 (void *)&cmd_write_reg_value,
6169 /* *** WRITE PORT REGISTER BIT FIELD *** */
6170 struct cmd_write_reg_bit_field_result {
6171 cmdline_fixed_string_t write;
6172 cmdline_fixed_string_t regfield;
6181 cmd_write_reg_bit_field_parsed(void *parsed_result,
6182 __attribute__((unused)) struct cmdline *cl,
6183 __attribute__((unused)) void *data)
6185 struct cmd_write_reg_bit_field_result *res = parsed_result;
6186 port_reg_bit_field_set(res->port_id, res->reg_off,
6187 res->bit1_pos, res->bit2_pos, res->value);
6190 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6191 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6193 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6194 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6195 regfield, "regfield");
6196 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6199 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6200 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6202 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6203 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6205 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6206 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6208 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6209 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6212 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6213 .f = cmd_write_reg_bit_field_parsed,
6215 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6217 "Set register bit field between bit_x and bit_y included",
6219 (void *)&cmd_write_reg_bit_field_write,
6220 (void *)&cmd_write_reg_bit_field_regfield,
6221 (void *)&cmd_write_reg_bit_field_port_id,
6222 (void *)&cmd_write_reg_bit_field_reg_off,
6223 (void *)&cmd_write_reg_bit_field_bit1_pos,
6224 (void *)&cmd_write_reg_bit_field_bit2_pos,
6225 (void *)&cmd_write_reg_bit_field_value,
6230 /* *** WRITE PORT REGISTER BIT *** */
6231 struct cmd_write_reg_bit_result {
6232 cmdline_fixed_string_t write;
6233 cmdline_fixed_string_t regbit;
6241 cmd_write_reg_bit_parsed(void *parsed_result,
6242 __attribute__((unused)) struct cmdline *cl,
6243 __attribute__((unused)) void *data)
6245 struct cmd_write_reg_bit_result *res = parsed_result;
6246 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6249 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6250 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6252 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6253 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6255 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6256 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6257 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6258 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6259 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6260 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6261 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6262 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6264 cmdline_parse_inst_t cmd_write_reg_bit = {
6265 .f = cmd_write_reg_bit_parsed,
6267 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6270 (void *)&cmd_write_reg_bit_write,
6271 (void *)&cmd_write_reg_bit_regbit,
6272 (void *)&cmd_write_reg_bit_port_id,
6273 (void *)&cmd_write_reg_bit_reg_off,
6274 (void *)&cmd_write_reg_bit_bit_pos,
6275 (void *)&cmd_write_reg_bit_value,
6280 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6281 struct cmd_read_rxd_txd_result {
6282 cmdline_fixed_string_t read;
6283 cmdline_fixed_string_t rxd_txd;
6290 cmd_read_rxd_txd_parsed(void *parsed_result,
6291 __attribute__((unused)) struct cmdline *cl,
6292 __attribute__((unused)) void *data)
6294 struct cmd_read_rxd_txd_result *res = parsed_result;
6296 if (!strcmp(res->rxd_txd, "rxd"))
6297 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6298 else if (!strcmp(res->rxd_txd, "txd"))
6299 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6302 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6303 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6304 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6305 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6307 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6308 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6309 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6310 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6311 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6312 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6314 cmdline_parse_inst_t cmd_read_rxd_txd = {
6315 .f = cmd_read_rxd_txd_parsed,
6317 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6319 (void *)&cmd_read_rxd_txd_read,
6320 (void *)&cmd_read_rxd_txd_rxd_txd,
6321 (void *)&cmd_read_rxd_txd_port_id,
6322 (void *)&cmd_read_rxd_txd_queue_id,
6323 (void *)&cmd_read_rxd_txd_desc_id,
6329 struct cmd_quit_result {
6330 cmdline_fixed_string_t quit;
6333 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6335 __attribute__((unused)) void *data)
6341 cmdline_parse_token_string_t cmd_quit_quit =
6342 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6344 cmdline_parse_inst_t cmd_quit = {
6345 .f = cmd_quit_parsed,
6347 .help_str = "quit: Exit application",
6349 (void *)&cmd_quit_quit,
6354 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6355 struct cmd_mac_addr_result {
6356 cmdline_fixed_string_t mac_addr_cmd;
6357 cmdline_fixed_string_t what;
6359 struct ether_addr address;
6362 static void cmd_mac_addr_parsed(void *parsed_result,
6363 __attribute__((unused)) struct cmdline *cl,
6364 __attribute__((unused)) void *data)
6366 struct cmd_mac_addr_result *res = parsed_result;
6369 if (strcmp(res->what, "add") == 0)
6370 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6371 else if (strcmp(res->what, "set") == 0)
6372 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6375 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6377 /* check the return value and print it if is < 0 */
6379 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6383 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6384 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6386 cmdline_parse_token_string_t cmd_mac_addr_what =
6387 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6389 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6390 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6391 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6392 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6394 cmdline_parse_inst_t cmd_mac_addr = {
6395 .f = cmd_mac_addr_parsed,
6397 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6398 "Add/Remove/Set MAC address on port_id",
6400 (void *)&cmd_mac_addr_cmd,
6401 (void *)&cmd_mac_addr_what,
6402 (void *)&cmd_mac_addr_portnum,
6403 (void *)&cmd_mac_addr_addr,
6409 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6410 struct cmd_set_qmap_result {
6411 cmdline_fixed_string_t set;
6412 cmdline_fixed_string_t qmap;
6413 cmdline_fixed_string_t what;
6420 cmd_set_qmap_parsed(void *parsed_result,
6421 __attribute__((unused)) struct cmdline *cl,
6422 __attribute__((unused)) void *data)
6424 struct cmd_set_qmap_result *res = parsed_result;
6425 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6427 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6430 cmdline_parse_token_string_t cmd_setqmap_set =
6431 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6433 cmdline_parse_token_string_t cmd_setqmap_qmap =
6434 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6436 cmdline_parse_token_string_t cmd_setqmap_what =
6437 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6439 cmdline_parse_token_num_t cmd_setqmap_portid =
6440 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6442 cmdline_parse_token_num_t cmd_setqmap_queueid =
6443 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6445 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6446 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6449 cmdline_parse_inst_t cmd_set_qmap = {
6450 .f = cmd_set_qmap_parsed,
6452 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6453 "Set statistics mapping value on tx|rx queue_id of port_id",
6455 (void *)&cmd_setqmap_set,
6456 (void *)&cmd_setqmap_qmap,
6457 (void *)&cmd_setqmap_what,
6458 (void *)&cmd_setqmap_portid,
6459 (void *)&cmd_setqmap_queueid,
6460 (void *)&cmd_setqmap_mapvalue,
6465 /* *** CONFIGURE UNICAST HASH TABLE *** */
6466 struct cmd_set_uc_hash_table {
6467 cmdline_fixed_string_t set;
6468 cmdline_fixed_string_t port;
6470 cmdline_fixed_string_t what;
6471 struct ether_addr address;
6472 cmdline_fixed_string_t mode;
6476 cmd_set_uc_hash_parsed(void *parsed_result,
6477 __attribute__((unused)) struct cmdline *cl,
6478 __attribute__((unused)) void *data)
6481 struct cmd_set_uc_hash_table *res = parsed_result;
6483 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6485 if (strcmp(res->what, "uta") == 0)
6486 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6487 &res->address,(uint8_t)is_on);
6489 printf("bad unicast hash table parameter, return code = %d \n", ret);
6493 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6496 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6497 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6499 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6500 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6502 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6505 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6506 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6508 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6509 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6512 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6513 .f = cmd_set_uc_hash_parsed,
6515 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6517 (void *)&cmd_set_uc_hash_set,
6518 (void *)&cmd_set_uc_hash_port,
6519 (void *)&cmd_set_uc_hash_portid,
6520 (void *)&cmd_set_uc_hash_what,
6521 (void *)&cmd_set_uc_hash_mac,
6522 (void *)&cmd_set_uc_hash_mode,
6527 struct cmd_set_uc_all_hash_table {
6528 cmdline_fixed_string_t set;
6529 cmdline_fixed_string_t port;
6531 cmdline_fixed_string_t what;
6532 cmdline_fixed_string_t value;
6533 cmdline_fixed_string_t mode;
6537 cmd_set_uc_all_hash_parsed(void *parsed_result,
6538 __attribute__((unused)) struct cmdline *cl,
6539 __attribute__((unused)) void *data)
6542 struct cmd_set_uc_all_hash_table *res = parsed_result;
6544 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6546 if ((strcmp(res->what, "uta") == 0) &&
6547 (strcmp(res->value, "all") == 0))
6548 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6550 printf("bad unicast hash table parameter,"
6551 "return code = %d \n", ret);
6554 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6555 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6557 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6558 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6560 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6561 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6563 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6566 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6567 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6569 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6573 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6574 .f = cmd_set_uc_all_hash_parsed,
6576 .help_str = "set port <port_id> uta all on|off",
6578 (void *)&cmd_set_uc_all_hash_set,
6579 (void *)&cmd_set_uc_all_hash_port,
6580 (void *)&cmd_set_uc_all_hash_portid,
6581 (void *)&cmd_set_uc_all_hash_what,
6582 (void *)&cmd_set_uc_all_hash_value,
6583 (void *)&cmd_set_uc_all_hash_mode,
6588 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6589 struct cmd_set_vf_macvlan_filter {
6590 cmdline_fixed_string_t set;
6591 cmdline_fixed_string_t port;
6593 cmdline_fixed_string_t vf;
6595 struct ether_addr address;
6596 cmdline_fixed_string_t filter_type;
6597 cmdline_fixed_string_t mode;
6601 cmd_set_vf_macvlan_parsed(void *parsed_result,
6602 __attribute__((unused)) struct cmdline *cl,
6603 __attribute__((unused)) void *data)
6606 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6607 struct rte_eth_mac_filter filter;
6609 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6611 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6613 /* set VF MAC filter */
6617 filter.dst_id = res->vf_id;
6619 if (!strcmp(res->filter_type, "exact-mac"))
6620 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6621 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6622 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6623 else if (!strcmp(res->filter_type, "hashmac"))
6624 filter.filter_type = RTE_MAC_HASH_MATCH;
6625 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6626 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6628 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6631 ret = rte_eth_dev_filter_ctrl(res->port_id,
6632 RTE_ETH_FILTER_MACVLAN,
6636 ret = rte_eth_dev_filter_ctrl(res->port_id,
6637 RTE_ETH_FILTER_MACVLAN,
6638 RTE_ETH_FILTER_DELETE,
6642 printf("bad set MAC hash parameter, return code = %d\n", ret);
6646 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6649 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6652 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6653 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6655 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6656 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6658 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6659 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6661 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6662 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6664 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6665 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6666 filter_type, "exact-mac#exact-mac-vlan"
6667 "#hashmac#hashmac-vlan");
6668 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6672 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6673 .f = cmd_set_vf_macvlan_parsed,
6675 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6676 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6677 "Exact match rule: exact match of MAC or MAC and VLAN; "
6678 "hash match rule: hash match of MAC and exact match of VLAN",
6680 (void *)&cmd_set_vf_macvlan_set,
6681 (void *)&cmd_set_vf_macvlan_port,
6682 (void *)&cmd_set_vf_macvlan_portid,
6683 (void *)&cmd_set_vf_macvlan_vf,
6684 (void *)&cmd_set_vf_macvlan_vf_id,
6685 (void *)&cmd_set_vf_macvlan_mac,
6686 (void *)&cmd_set_vf_macvlan_filter_type,
6687 (void *)&cmd_set_vf_macvlan_mode,
6692 #ifdef RTE_LIBRTE_IXGBE_PMD
6693 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6694 struct cmd_set_vf_traffic {
6695 cmdline_fixed_string_t set;
6696 cmdline_fixed_string_t port;
6698 cmdline_fixed_string_t vf;
6700 cmdline_fixed_string_t what;
6701 cmdline_fixed_string_t mode;
6705 cmd_set_vf_traffic_parsed(void *parsed_result,
6706 __attribute__((unused)) struct cmdline *cl,
6707 __attribute__((unused)) void *data)
6709 struct cmd_set_vf_traffic *res = parsed_result;
6710 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6711 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6713 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6716 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6719 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6720 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6722 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6723 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6725 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6728 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6729 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6731 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6734 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6738 cmdline_parse_inst_t cmd_set_vf_traffic = {
6739 .f = cmd_set_vf_traffic_parsed,
6741 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6743 (void *)&cmd_setvf_traffic_set,
6744 (void *)&cmd_setvf_traffic_port,
6745 (void *)&cmd_setvf_traffic_portid,
6746 (void *)&cmd_setvf_traffic_vf,
6747 (void *)&cmd_setvf_traffic_vfid,
6748 (void *)&cmd_setvf_traffic_what,
6749 (void *)&cmd_setvf_traffic_mode,
6754 /* *** CONFIGURE VF RECEIVE MODE *** */
6755 struct cmd_set_vf_rxmode {
6756 cmdline_fixed_string_t set;
6757 cmdline_fixed_string_t port;
6759 cmdline_fixed_string_t vf;
6761 cmdline_fixed_string_t what;
6762 cmdline_fixed_string_t mode;
6763 cmdline_fixed_string_t on;
6767 cmd_set_vf_rxmode_parsed(void *parsed_result,
6768 __attribute__((unused)) struct cmdline *cl,
6769 __attribute__((unused)) void *data)
6772 uint16_t rx_mode = 0;
6773 struct cmd_set_vf_rxmode *res = parsed_result;
6775 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6776 if (!strcmp(res->what,"rxmode")) {
6777 if (!strcmp(res->mode, "AUPE"))
6778 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6779 else if (!strcmp(res->mode, "ROPE"))
6780 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6781 else if (!strcmp(res->mode, "BAM"))
6782 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6783 else if (!strncmp(res->mode, "MPE",3))
6784 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6787 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6789 printf("bad VF receive mode parameter, return code = %d \n",
6793 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6794 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6796 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6797 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6799 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6800 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6802 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6805 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6806 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6808 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6809 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6811 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6812 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6813 mode, "AUPE#ROPE#BAM#MPE");
6814 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6815 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6818 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6819 .f = cmd_set_vf_rxmode_parsed,
6821 .help_str = "set port <port_id> vf <vf_id> rxmode "
6822 "AUPE|ROPE|BAM|MPE on|off",
6824 (void *)&cmd_set_vf_rxmode_set,
6825 (void *)&cmd_set_vf_rxmode_port,
6826 (void *)&cmd_set_vf_rxmode_portid,
6827 (void *)&cmd_set_vf_rxmode_vf,
6828 (void *)&cmd_set_vf_rxmode_vfid,
6829 (void *)&cmd_set_vf_rxmode_what,
6830 (void *)&cmd_set_vf_rxmode_mode,
6831 (void *)&cmd_set_vf_rxmode_on,
6837 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6838 struct cmd_vf_mac_addr_result {
6839 cmdline_fixed_string_t mac_addr_cmd;
6840 cmdline_fixed_string_t what;
6841 cmdline_fixed_string_t port;
6843 cmdline_fixed_string_t vf;
6845 struct ether_addr address;
6848 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6849 __attribute__((unused)) struct cmdline *cl,
6850 __attribute__((unused)) void *data)
6852 struct cmd_vf_mac_addr_result *res = parsed_result;
6855 if (strcmp(res->what, "add") == 0)
6856 ret = rte_eth_dev_mac_addr_add(res->port_num,
6857 &res->address, res->vf_num);
6859 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6863 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6864 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6865 mac_addr_cmd,"mac_addr");
6866 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6867 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6869 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6870 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6872 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6873 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6875 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6876 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6878 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6879 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6881 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6882 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6885 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6886 .f = cmd_vf_mac_addr_parsed,
6888 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6889 "Add MAC address filtering for a VF on port_id",
6891 (void *)&cmd_vf_mac_addr_cmd,
6892 (void *)&cmd_vf_mac_addr_what,
6893 (void *)&cmd_vf_mac_addr_port,
6894 (void *)&cmd_vf_mac_addr_portnum,
6895 (void *)&cmd_vf_mac_addr_vf,
6896 (void *)&cmd_vf_mac_addr_vfnum,
6897 (void *)&cmd_vf_mac_addr_addr,
6902 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6903 struct cmd_vf_rx_vlan_filter {
6904 cmdline_fixed_string_t rx_vlan;
6905 cmdline_fixed_string_t what;
6907 cmdline_fixed_string_t port;
6909 cmdline_fixed_string_t vf;
6914 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6915 __attribute__((unused)) struct cmdline *cl,
6916 __attribute__((unused)) void *data)
6918 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6921 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6923 #ifdef RTE_LIBRTE_IXGBE_PMD
6924 if (ret == -ENOTSUP)
6925 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6926 res->vlan_id, res->vf_mask, is_add);
6928 #ifdef RTE_LIBRTE_I40E_PMD
6929 if (ret == -ENOTSUP)
6930 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6931 res->vlan_id, res->vf_mask, is_add);
6938 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6939 res->vlan_id, res->vf_mask);
6942 printf("invalid port_id %d\n", res->port_id);
6945 printf("function not implemented or supported\n");
6948 printf("programming error: (%s)\n", strerror(-ret));
6952 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6953 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6954 rx_vlan, "rx_vlan");
6955 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6956 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6958 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6959 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6961 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6962 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6964 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6965 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6967 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6968 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6970 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6971 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6974 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6975 .f = cmd_vf_rx_vlan_filter_parsed,
6977 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6978 "(vf_mask = hexadecimal VF mask)",
6980 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6981 (void *)&cmd_vf_rx_vlan_filter_what,
6982 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6983 (void *)&cmd_vf_rx_vlan_filter_port,
6984 (void *)&cmd_vf_rx_vlan_filter_portid,
6985 (void *)&cmd_vf_rx_vlan_filter_vf,
6986 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6991 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6992 struct cmd_queue_rate_limit_result {
6993 cmdline_fixed_string_t set;
6994 cmdline_fixed_string_t port;
6996 cmdline_fixed_string_t queue;
6998 cmdline_fixed_string_t rate;
7002 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7003 __attribute__((unused)) struct cmdline *cl,
7004 __attribute__((unused)) void *data)
7006 struct cmd_queue_rate_limit_result *res = parsed_result;
7009 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7010 && (strcmp(res->queue, "queue") == 0)
7011 && (strcmp(res->rate, "rate") == 0))
7012 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7015 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7019 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7020 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7022 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7023 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7025 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7026 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7028 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7029 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7031 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7032 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7034 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7035 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7037 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7038 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7041 cmdline_parse_inst_t cmd_queue_rate_limit = {
7042 .f = cmd_queue_rate_limit_parsed,
7044 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7045 "Set rate limit for a queue on port_id",
7047 (void *)&cmd_queue_rate_limit_set,
7048 (void *)&cmd_queue_rate_limit_port,
7049 (void *)&cmd_queue_rate_limit_portnum,
7050 (void *)&cmd_queue_rate_limit_queue,
7051 (void *)&cmd_queue_rate_limit_queuenum,
7052 (void *)&cmd_queue_rate_limit_rate,
7053 (void *)&cmd_queue_rate_limit_ratenum,
7058 #ifdef RTE_LIBRTE_IXGBE_PMD
7059 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7060 struct cmd_vf_rate_limit_result {
7061 cmdline_fixed_string_t set;
7062 cmdline_fixed_string_t port;
7064 cmdline_fixed_string_t vf;
7066 cmdline_fixed_string_t rate;
7068 cmdline_fixed_string_t q_msk;
7072 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7073 __attribute__((unused)) struct cmdline *cl,
7074 __attribute__((unused)) void *data)
7076 struct cmd_vf_rate_limit_result *res = parsed_result;
7079 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7080 && (strcmp(res->vf, "vf") == 0)
7081 && (strcmp(res->rate, "rate") == 0)
7082 && (strcmp(res->q_msk, "queue_mask") == 0))
7083 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7084 res->rate_num, res->q_msk_val);
7086 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7090 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7091 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7093 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7094 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7096 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7097 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7099 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7100 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7102 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7103 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7105 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7106 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7108 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7109 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7111 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7112 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7113 q_msk, "queue_mask");
7114 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7115 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7118 cmdline_parse_inst_t cmd_vf_rate_limit = {
7119 .f = cmd_vf_rate_limit_parsed,
7121 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7122 "queue_mask <queue_mask_value>: "
7123 "Set rate limit for queues of VF on port_id",
7125 (void *)&cmd_vf_rate_limit_set,
7126 (void *)&cmd_vf_rate_limit_port,
7127 (void *)&cmd_vf_rate_limit_portnum,
7128 (void *)&cmd_vf_rate_limit_vf,
7129 (void *)&cmd_vf_rate_limit_vfnum,
7130 (void *)&cmd_vf_rate_limit_rate,
7131 (void *)&cmd_vf_rate_limit_ratenum,
7132 (void *)&cmd_vf_rate_limit_q_msk,
7133 (void *)&cmd_vf_rate_limit_q_msk_val,
7139 /* *** ADD TUNNEL FILTER OF A PORT *** */
7140 struct cmd_tunnel_filter_result {
7141 cmdline_fixed_string_t cmd;
7142 cmdline_fixed_string_t what;
7144 struct ether_addr outer_mac;
7145 struct ether_addr inner_mac;
7146 cmdline_ipaddr_t ip_value;
7147 uint16_t inner_vlan;
7148 cmdline_fixed_string_t tunnel_type;
7149 cmdline_fixed_string_t filter_type;
7155 cmd_tunnel_filter_parsed(void *parsed_result,
7156 __attribute__((unused)) struct cmdline *cl,
7157 __attribute__((unused)) void *data)
7159 struct cmd_tunnel_filter_result *res = parsed_result;
7160 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7163 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7165 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7166 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7167 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7169 if (res->ip_value.family == AF_INET) {
7170 tunnel_filter_conf.ip_addr.ipv4_addr =
7171 res->ip_value.addr.ipv4.s_addr;
7172 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7174 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7175 &(res->ip_value.addr.ipv6),
7176 sizeof(struct in6_addr));
7177 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7180 if (!strcmp(res->filter_type, "imac-ivlan"))
7181 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7182 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7183 tunnel_filter_conf.filter_type =
7184 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7185 else if (!strcmp(res->filter_type, "imac-tenid"))
7186 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7187 else if (!strcmp(res->filter_type, "imac"))
7188 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7189 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7190 tunnel_filter_conf.filter_type =
7191 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7192 else if (!strcmp(res->filter_type, "oip"))
7193 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7194 else if (!strcmp(res->filter_type, "iip"))
7195 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7197 printf("The filter type is not supported");
7201 if (!strcmp(res->tunnel_type, "vxlan"))
7202 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7203 else if (!strcmp(res->tunnel_type, "nvgre"))
7204 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7205 else if (!strcmp(res->tunnel_type, "ipingre"))
7206 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7208 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7212 tunnel_filter_conf.tenant_id = res->tenant_id;
7213 tunnel_filter_conf.queue_id = res->queue_num;
7214 if (!strcmp(res->what, "add"))
7215 ret = rte_eth_dev_filter_ctrl(res->port_id,
7216 RTE_ETH_FILTER_TUNNEL,
7218 &tunnel_filter_conf);
7220 ret = rte_eth_dev_filter_ctrl(res->port_id,
7221 RTE_ETH_FILTER_TUNNEL,
7222 RTE_ETH_FILTER_DELETE,
7223 &tunnel_filter_conf);
7225 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7229 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7230 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7231 cmd, "tunnel_filter");
7232 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7233 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7235 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7236 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7238 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7239 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7241 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7244 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7245 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7246 inner_vlan, UINT16);
7247 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7248 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7250 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7251 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7252 tunnel_type, "vxlan#nvgre#ipingre");
7254 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7255 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7256 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7257 "imac#omac-imac-tenid");
7258 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7259 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7261 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7262 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7265 cmdline_parse_inst_t cmd_tunnel_filter = {
7266 .f = cmd_tunnel_filter_parsed,
7268 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7269 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7270 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7271 "<queue_id>: Add/Rm tunnel filter of a port",
7273 (void *)&cmd_tunnel_filter_cmd,
7274 (void *)&cmd_tunnel_filter_what,
7275 (void *)&cmd_tunnel_filter_port_id,
7276 (void *)&cmd_tunnel_filter_outer_mac,
7277 (void *)&cmd_tunnel_filter_inner_mac,
7278 (void *)&cmd_tunnel_filter_ip_value,
7279 (void *)&cmd_tunnel_filter_innner_vlan,
7280 (void *)&cmd_tunnel_filter_tunnel_type,
7281 (void *)&cmd_tunnel_filter_filter_type,
7282 (void *)&cmd_tunnel_filter_tenant_id,
7283 (void *)&cmd_tunnel_filter_queue_num,
7288 /* *** CONFIGURE TUNNEL UDP PORT *** */
7289 struct cmd_tunnel_udp_config {
7290 cmdline_fixed_string_t cmd;
7291 cmdline_fixed_string_t what;
7297 cmd_tunnel_udp_config_parsed(void *parsed_result,
7298 __attribute__((unused)) struct cmdline *cl,
7299 __attribute__((unused)) void *data)
7301 struct cmd_tunnel_udp_config *res = parsed_result;
7302 struct rte_eth_udp_tunnel tunnel_udp;
7305 tunnel_udp.udp_port = res->udp_port;
7307 if (!strcmp(res->cmd, "rx_vxlan_port"))
7308 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7310 if (!strcmp(res->what, "add"))
7311 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7314 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7318 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7321 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7322 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7323 cmd, "rx_vxlan_port");
7324 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7325 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7327 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7328 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7330 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7331 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7334 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7335 .f = cmd_tunnel_udp_config_parsed,
7337 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7338 "Add/Remove a tunneling UDP port filter",
7340 (void *)&cmd_tunnel_udp_config_cmd,
7341 (void *)&cmd_tunnel_udp_config_what,
7342 (void *)&cmd_tunnel_udp_config_udp_port,
7343 (void *)&cmd_tunnel_udp_config_port_id,
7348 /* *** GLOBAL CONFIG *** */
7349 struct cmd_global_config_result {
7350 cmdline_fixed_string_t cmd;
7352 cmdline_fixed_string_t cfg_type;
7357 cmd_global_config_parsed(void *parsed_result,
7358 __attribute__((unused)) struct cmdline *cl,
7359 __attribute__((unused)) void *data)
7361 struct cmd_global_config_result *res = parsed_result;
7362 struct rte_eth_global_cfg conf;
7365 memset(&conf, 0, sizeof(conf));
7366 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7367 conf.cfg.gre_key_len = res->len;
7368 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7369 RTE_ETH_FILTER_SET, &conf);
7371 printf("Global config error\n");
7374 cmdline_parse_token_string_t cmd_global_config_cmd =
7375 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7377 cmdline_parse_token_num_t cmd_global_config_port_id =
7378 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7379 cmdline_parse_token_string_t cmd_global_config_type =
7380 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7381 cfg_type, "gre-key-len");
7382 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7383 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7386 cmdline_parse_inst_t cmd_global_config = {
7387 .f = cmd_global_config_parsed,
7388 .data = (void *)NULL,
7389 .help_str = "global_config <port_id> gre-key-len <key_len>",
7391 (void *)&cmd_global_config_cmd,
7392 (void *)&cmd_global_config_port_id,
7393 (void *)&cmd_global_config_type,
7394 (void *)&cmd_global_config_gre_key_len,
7399 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7400 struct cmd_set_mirror_mask_result {
7401 cmdline_fixed_string_t set;
7402 cmdline_fixed_string_t port;
7404 cmdline_fixed_string_t mirror;
7406 cmdline_fixed_string_t what;
7407 cmdline_fixed_string_t value;
7408 cmdline_fixed_string_t dstpool;
7410 cmdline_fixed_string_t on;
7413 cmdline_parse_token_string_t cmd_mirror_mask_set =
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7416 cmdline_parse_token_string_t cmd_mirror_mask_port =
7417 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7419 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7420 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7422 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7423 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7424 mirror, "mirror-rule");
7425 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7426 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7428 cmdline_parse_token_string_t cmd_mirror_mask_what =
7429 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7430 what, "pool-mirror-up#pool-mirror-down"
7432 cmdline_parse_token_string_t cmd_mirror_mask_value =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7435 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7436 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7437 dstpool, "dst-pool");
7438 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7439 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7441 cmdline_parse_token_string_t cmd_mirror_mask_on =
7442 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7446 cmd_set_mirror_mask_parsed(void *parsed_result,
7447 __attribute__((unused)) struct cmdline *cl,
7448 __attribute__((unused)) void *data)
7451 struct cmd_set_mirror_mask_result *res = parsed_result;
7452 struct rte_eth_mirror_conf mr_conf;
7454 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7456 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7458 mr_conf.dst_pool = res->dstpool_id;
7460 if (!strcmp(res->what, "pool-mirror-up")) {
7461 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7462 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7463 } else if (!strcmp(res->what, "pool-mirror-down")) {
7464 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7465 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7466 } else if (!strcmp(res->what, "vlan-mirror")) {
7467 mr_conf.rule_type = ETH_MIRROR_VLAN;
7468 nb_item = parse_item_list(res->value, "vlan",
7469 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7473 for (i = 0; i < nb_item; i++) {
7474 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7475 printf("Invalid vlan_id: must be < 4096\n");
7479 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7480 mr_conf.vlan.vlan_mask |= 1ULL << i;
7484 if (!strcmp(res->on, "on"))
7485 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7488 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7491 printf("mirror rule add error: (%s)\n", strerror(-ret));
7494 cmdline_parse_inst_t cmd_set_mirror_mask = {
7495 .f = cmd_set_mirror_mask_parsed,
7497 .help_str = "set port <port_id> mirror-rule <rule_id> "
7498 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7499 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7501 (void *)&cmd_mirror_mask_set,
7502 (void *)&cmd_mirror_mask_port,
7503 (void *)&cmd_mirror_mask_portid,
7504 (void *)&cmd_mirror_mask_mirror,
7505 (void *)&cmd_mirror_mask_ruleid,
7506 (void *)&cmd_mirror_mask_what,
7507 (void *)&cmd_mirror_mask_value,
7508 (void *)&cmd_mirror_mask_dstpool,
7509 (void *)&cmd_mirror_mask_poolid,
7510 (void *)&cmd_mirror_mask_on,
7515 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7516 struct cmd_set_mirror_link_result {
7517 cmdline_fixed_string_t set;
7518 cmdline_fixed_string_t port;
7520 cmdline_fixed_string_t mirror;
7522 cmdline_fixed_string_t what;
7523 cmdline_fixed_string_t dstpool;
7525 cmdline_fixed_string_t on;
7528 cmdline_parse_token_string_t cmd_mirror_link_set =
7529 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7531 cmdline_parse_token_string_t cmd_mirror_link_port =
7532 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7534 cmdline_parse_token_num_t cmd_mirror_link_portid =
7535 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7537 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7538 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7539 mirror, "mirror-rule");
7540 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7541 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7543 cmdline_parse_token_string_t cmd_mirror_link_what =
7544 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7545 what, "uplink-mirror#downlink-mirror");
7546 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7547 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7548 dstpool, "dst-pool");
7549 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7550 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7552 cmdline_parse_token_string_t cmd_mirror_link_on =
7553 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7557 cmd_set_mirror_link_parsed(void *parsed_result,
7558 __attribute__((unused)) struct cmdline *cl,
7559 __attribute__((unused)) void *data)
7562 struct cmd_set_mirror_link_result *res = parsed_result;
7563 struct rte_eth_mirror_conf mr_conf;
7565 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7566 if (!strcmp(res->what, "uplink-mirror"))
7567 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7569 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7571 mr_conf.dst_pool = res->dstpool_id;
7573 if (!strcmp(res->on, "on"))
7574 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7577 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7580 /* check the return value and print it if is < 0 */
7582 printf("mirror rule add error: (%s)\n", strerror(-ret));
7586 cmdline_parse_inst_t cmd_set_mirror_link = {
7587 .f = cmd_set_mirror_link_parsed,
7589 .help_str = "set port <port_id> mirror-rule <rule_id> "
7590 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7592 (void *)&cmd_mirror_link_set,
7593 (void *)&cmd_mirror_link_port,
7594 (void *)&cmd_mirror_link_portid,
7595 (void *)&cmd_mirror_link_mirror,
7596 (void *)&cmd_mirror_link_ruleid,
7597 (void *)&cmd_mirror_link_what,
7598 (void *)&cmd_mirror_link_dstpool,
7599 (void *)&cmd_mirror_link_poolid,
7600 (void *)&cmd_mirror_link_on,
7605 /* *** RESET VM MIRROR RULE *** */
7606 struct cmd_rm_mirror_rule_result {
7607 cmdline_fixed_string_t reset;
7608 cmdline_fixed_string_t port;
7610 cmdline_fixed_string_t mirror;
7614 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7615 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7617 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7618 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7620 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7621 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7623 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7624 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7625 mirror, "mirror-rule");
7626 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7627 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7631 cmd_reset_mirror_rule_parsed(void *parsed_result,
7632 __attribute__((unused)) struct cmdline *cl,
7633 __attribute__((unused)) void *data)
7636 struct cmd_set_mirror_link_result *res = parsed_result;
7638 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7640 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7643 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7644 .f = cmd_reset_mirror_rule_parsed,
7646 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7648 (void *)&cmd_rm_mirror_rule_reset,
7649 (void *)&cmd_rm_mirror_rule_port,
7650 (void *)&cmd_rm_mirror_rule_portid,
7651 (void *)&cmd_rm_mirror_rule_mirror,
7652 (void *)&cmd_rm_mirror_rule_ruleid,
7657 /* ******************************************************************************** */
7659 struct cmd_dump_result {
7660 cmdline_fixed_string_t dump;
7664 dump_struct_sizes(void)
7666 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7667 DUMP_SIZE(struct rte_mbuf);
7668 DUMP_SIZE(struct rte_mempool);
7669 DUMP_SIZE(struct rte_ring);
7673 static void cmd_dump_parsed(void *parsed_result,
7674 __attribute__((unused)) struct cmdline *cl,
7675 __attribute__((unused)) void *data)
7677 struct cmd_dump_result *res = parsed_result;
7679 if (!strcmp(res->dump, "dump_physmem"))
7680 rte_dump_physmem_layout(stdout);
7681 else if (!strcmp(res->dump, "dump_memzone"))
7682 rte_memzone_dump(stdout);
7683 else if (!strcmp(res->dump, "dump_struct_sizes"))
7684 dump_struct_sizes();
7685 else if (!strcmp(res->dump, "dump_ring"))
7686 rte_ring_list_dump(stdout);
7687 else if (!strcmp(res->dump, "dump_mempool"))
7688 rte_mempool_list_dump(stdout);
7689 else if (!strcmp(res->dump, "dump_devargs"))
7690 rte_eal_devargs_dump(stdout);
7693 cmdline_parse_token_string_t cmd_dump_dump =
7694 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7697 "dump_struct_sizes#"
7702 cmdline_parse_inst_t cmd_dump = {
7703 .f = cmd_dump_parsed, /* function to call */
7704 .data = NULL, /* 2nd arg of func */
7705 .help_str = "Dump status",
7706 .tokens = { /* token list, NULL terminated */
7707 (void *)&cmd_dump_dump,
7712 /* ******************************************************************************** */
7714 struct cmd_dump_one_result {
7715 cmdline_fixed_string_t dump;
7716 cmdline_fixed_string_t name;
7719 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7720 __attribute__((unused)) void *data)
7722 struct cmd_dump_one_result *res = parsed_result;
7724 if (!strcmp(res->dump, "dump_ring")) {
7726 r = rte_ring_lookup(res->name);
7728 cmdline_printf(cl, "Cannot find ring\n");
7731 rte_ring_dump(stdout, r);
7732 } else if (!strcmp(res->dump, "dump_mempool")) {
7733 struct rte_mempool *mp;
7734 mp = rte_mempool_lookup(res->name);
7736 cmdline_printf(cl, "Cannot find mempool\n");
7739 rte_mempool_dump(stdout, mp);
7743 cmdline_parse_token_string_t cmd_dump_one_dump =
7744 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7745 "dump_ring#dump_mempool");
7747 cmdline_parse_token_string_t cmd_dump_one_name =
7748 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7750 cmdline_parse_inst_t cmd_dump_one = {
7751 .f = cmd_dump_one_parsed, /* function to call */
7752 .data = NULL, /* 2nd arg of func */
7753 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7754 .tokens = { /* token list, NULL terminated */
7755 (void *)&cmd_dump_one_dump,
7756 (void *)&cmd_dump_one_name,
7761 /* *** Add/Del syn filter *** */
7762 struct cmd_syn_filter_result {
7763 cmdline_fixed_string_t filter;
7765 cmdline_fixed_string_t ops;
7766 cmdline_fixed_string_t priority;
7767 cmdline_fixed_string_t high;
7768 cmdline_fixed_string_t queue;
7773 cmd_syn_filter_parsed(void *parsed_result,
7774 __attribute__((unused)) struct cmdline *cl,
7775 __attribute__((unused)) void *data)
7777 struct cmd_syn_filter_result *res = parsed_result;
7778 struct rte_eth_syn_filter syn_filter;
7781 ret = rte_eth_dev_filter_supported(res->port_id,
7782 RTE_ETH_FILTER_SYN);
7784 printf("syn filter is not supported on port %u.\n",
7789 memset(&syn_filter, 0, sizeof(syn_filter));
7791 if (!strcmp(res->ops, "add")) {
7792 if (!strcmp(res->high, "high"))
7793 syn_filter.hig_pri = 1;
7795 syn_filter.hig_pri = 0;
7797 syn_filter.queue = res->queue_id;
7798 ret = rte_eth_dev_filter_ctrl(res->port_id,
7803 ret = rte_eth_dev_filter_ctrl(res->port_id,
7805 RTE_ETH_FILTER_DELETE,
7809 printf("syn filter programming error: (%s)\n",
7813 cmdline_parse_token_string_t cmd_syn_filter_filter =
7814 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7815 filter, "syn_filter");
7816 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7817 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7819 cmdline_parse_token_string_t cmd_syn_filter_ops =
7820 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7822 cmdline_parse_token_string_t cmd_syn_filter_priority =
7823 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7824 priority, "priority");
7825 cmdline_parse_token_string_t cmd_syn_filter_high =
7826 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7828 cmdline_parse_token_string_t cmd_syn_filter_queue =
7829 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7831 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7832 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7835 cmdline_parse_inst_t cmd_syn_filter = {
7836 .f = cmd_syn_filter_parsed,
7838 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7839 "<queue_id>: Add/Delete syn filter",
7841 (void *)&cmd_syn_filter_filter,
7842 (void *)&cmd_syn_filter_port_id,
7843 (void *)&cmd_syn_filter_ops,
7844 (void *)&cmd_syn_filter_priority,
7845 (void *)&cmd_syn_filter_high,
7846 (void *)&cmd_syn_filter_queue,
7847 (void *)&cmd_syn_filter_queue_id,
7852 /* *** ADD/REMOVE A 2tuple FILTER *** */
7853 struct cmd_2tuple_filter_result {
7854 cmdline_fixed_string_t filter;
7856 cmdline_fixed_string_t ops;
7857 cmdline_fixed_string_t dst_port;
7858 uint16_t dst_port_value;
7859 cmdline_fixed_string_t protocol;
7860 uint8_t protocol_value;
7861 cmdline_fixed_string_t mask;
7863 cmdline_fixed_string_t tcp_flags;
7864 uint8_t tcp_flags_value;
7865 cmdline_fixed_string_t priority;
7866 uint8_t priority_value;
7867 cmdline_fixed_string_t queue;
7872 cmd_2tuple_filter_parsed(void *parsed_result,
7873 __attribute__((unused)) struct cmdline *cl,
7874 __attribute__((unused)) void *data)
7876 struct rte_eth_ntuple_filter filter;
7877 struct cmd_2tuple_filter_result *res = parsed_result;
7880 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7882 printf("ntuple filter is not supported on port %u.\n",
7887 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7889 filter.flags = RTE_2TUPLE_FLAGS;
7890 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7891 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7892 filter.proto = res->protocol_value;
7893 filter.priority = res->priority_value;
7894 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7895 printf("nonzero tcp_flags is only meaningful"
7896 " when protocol is TCP.\n");
7899 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7900 printf("invalid TCP flags.\n");
7904 if (res->tcp_flags_value != 0) {
7905 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7906 filter.tcp_flags = res->tcp_flags_value;
7909 /* need convert to big endian. */
7910 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7911 filter.queue = res->queue_id;
7913 if (!strcmp(res->ops, "add"))
7914 ret = rte_eth_dev_filter_ctrl(res->port_id,
7915 RTE_ETH_FILTER_NTUPLE,
7919 ret = rte_eth_dev_filter_ctrl(res->port_id,
7920 RTE_ETH_FILTER_NTUPLE,
7921 RTE_ETH_FILTER_DELETE,
7924 printf("2tuple filter programming error: (%s)\n",
7929 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7930 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7931 filter, "2tuple_filter");
7932 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7933 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7935 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7936 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7938 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7939 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7940 dst_port, "dst_port");
7941 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7942 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7943 dst_port_value, UINT16);
7944 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7945 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7946 protocol, "protocol");
7947 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7948 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7949 protocol_value, UINT8);
7950 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7951 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7953 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7954 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7956 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7957 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7958 tcp_flags, "tcp_flags");
7959 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7960 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7961 tcp_flags_value, UINT8);
7962 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7963 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7964 priority, "priority");
7965 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7966 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7967 priority_value, UINT8);
7968 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7969 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7971 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7972 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7975 cmdline_parse_inst_t cmd_2tuple_filter = {
7976 .f = cmd_2tuple_filter_parsed,
7978 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7979 "<value> mask <value> tcp_flags <value> priority <value> queue "
7980 "<queue_id>: Add a 2tuple filter",
7982 (void *)&cmd_2tuple_filter_filter,
7983 (void *)&cmd_2tuple_filter_port_id,
7984 (void *)&cmd_2tuple_filter_ops,
7985 (void *)&cmd_2tuple_filter_dst_port,
7986 (void *)&cmd_2tuple_filter_dst_port_value,
7987 (void *)&cmd_2tuple_filter_protocol,
7988 (void *)&cmd_2tuple_filter_protocol_value,
7989 (void *)&cmd_2tuple_filter_mask,
7990 (void *)&cmd_2tuple_filter_mask_value,
7991 (void *)&cmd_2tuple_filter_tcp_flags,
7992 (void *)&cmd_2tuple_filter_tcp_flags_value,
7993 (void *)&cmd_2tuple_filter_priority,
7994 (void *)&cmd_2tuple_filter_priority_value,
7995 (void *)&cmd_2tuple_filter_queue,
7996 (void *)&cmd_2tuple_filter_queue_id,
8001 /* *** ADD/REMOVE A 5tuple FILTER *** */
8002 struct cmd_5tuple_filter_result {
8003 cmdline_fixed_string_t filter;
8005 cmdline_fixed_string_t ops;
8006 cmdline_fixed_string_t dst_ip;
8007 cmdline_ipaddr_t dst_ip_value;
8008 cmdline_fixed_string_t src_ip;
8009 cmdline_ipaddr_t src_ip_value;
8010 cmdline_fixed_string_t dst_port;
8011 uint16_t dst_port_value;
8012 cmdline_fixed_string_t src_port;
8013 uint16_t src_port_value;
8014 cmdline_fixed_string_t protocol;
8015 uint8_t protocol_value;
8016 cmdline_fixed_string_t mask;
8018 cmdline_fixed_string_t tcp_flags;
8019 uint8_t tcp_flags_value;
8020 cmdline_fixed_string_t priority;
8021 uint8_t priority_value;
8022 cmdline_fixed_string_t queue;
8027 cmd_5tuple_filter_parsed(void *parsed_result,
8028 __attribute__((unused)) struct cmdline *cl,
8029 __attribute__((unused)) void *data)
8031 struct rte_eth_ntuple_filter filter;
8032 struct cmd_5tuple_filter_result *res = parsed_result;
8035 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8037 printf("ntuple filter is not supported on port %u.\n",
8042 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8044 filter.flags = RTE_5TUPLE_FLAGS;
8045 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8046 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8047 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8048 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8049 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8050 filter.proto = res->protocol_value;
8051 filter.priority = res->priority_value;
8052 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8053 printf("nonzero tcp_flags is only meaningful"
8054 " when protocol is TCP.\n");
8057 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8058 printf("invalid TCP flags.\n");
8062 if (res->tcp_flags_value != 0) {
8063 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8064 filter.tcp_flags = res->tcp_flags_value;
8067 if (res->dst_ip_value.family == AF_INET)
8068 /* no need to convert, already big endian. */
8069 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8071 if (filter.dst_ip_mask == 0) {
8072 printf("can not support ipv6 involved compare.\n");
8078 if (res->src_ip_value.family == AF_INET)
8079 /* no need to convert, already big endian. */
8080 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8082 if (filter.src_ip_mask == 0) {
8083 printf("can not support ipv6 involved compare.\n");
8088 /* need convert to big endian. */
8089 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8090 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8091 filter.queue = res->queue_id;
8093 if (!strcmp(res->ops, "add"))
8094 ret = rte_eth_dev_filter_ctrl(res->port_id,
8095 RTE_ETH_FILTER_NTUPLE,
8099 ret = rte_eth_dev_filter_ctrl(res->port_id,
8100 RTE_ETH_FILTER_NTUPLE,
8101 RTE_ETH_FILTER_DELETE,
8104 printf("5tuple filter programming error: (%s)\n",
8108 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8109 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8110 filter, "5tuple_filter");
8111 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8112 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8114 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8115 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8117 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8118 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8120 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8121 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8123 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8124 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8126 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8127 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8129 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8130 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8131 dst_port, "dst_port");
8132 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8133 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8134 dst_port_value, UINT16);
8135 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8136 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8137 src_port, "src_port");
8138 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8139 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8140 src_port_value, UINT16);
8141 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8142 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8143 protocol, "protocol");
8144 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8145 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8146 protocol_value, UINT8);
8147 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8148 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8150 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8151 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8153 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8154 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8155 tcp_flags, "tcp_flags");
8156 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8157 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8158 tcp_flags_value, UINT8);
8159 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8160 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8161 priority, "priority");
8162 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8163 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8164 priority_value, UINT8);
8165 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8166 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8168 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8169 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8172 cmdline_parse_inst_t cmd_5tuple_filter = {
8173 .f = cmd_5tuple_filter_parsed,
8175 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8176 "src_ip <value> dst_port <value> src_port <value> "
8177 "protocol <value> mask <value> tcp_flags <value> "
8178 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8180 (void *)&cmd_5tuple_filter_filter,
8181 (void *)&cmd_5tuple_filter_port_id,
8182 (void *)&cmd_5tuple_filter_ops,
8183 (void *)&cmd_5tuple_filter_dst_ip,
8184 (void *)&cmd_5tuple_filter_dst_ip_value,
8185 (void *)&cmd_5tuple_filter_src_ip,
8186 (void *)&cmd_5tuple_filter_src_ip_value,
8187 (void *)&cmd_5tuple_filter_dst_port,
8188 (void *)&cmd_5tuple_filter_dst_port_value,
8189 (void *)&cmd_5tuple_filter_src_port,
8190 (void *)&cmd_5tuple_filter_src_port_value,
8191 (void *)&cmd_5tuple_filter_protocol,
8192 (void *)&cmd_5tuple_filter_protocol_value,
8193 (void *)&cmd_5tuple_filter_mask,
8194 (void *)&cmd_5tuple_filter_mask_value,
8195 (void *)&cmd_5tuple_filter_tcp_flags,
8196 (void *)&cmd_5tuple_filter_tcp_flags_value,
8197 (void *)&cmd_5tuple_filter_priority,
8198 (void *)&cmd_5tuple_filter_priority_value,
8199 (void *)&cmd_5tuple_filter_queue,
8200 (void *)&cmd_5tuple_filter_queue_id,
8205 /* *** ADD/REMOVE A flex FILTER *** */
8206 struct cmd_flex_filter_result {
8207 cmdline_fixed_string_t filter;
8208 cmdline_fixed_string_t ops;
8210 cmdline_fixed_string_t len;
8212 cmdline_fixed_string_t bytes;
8213 cmdline_fixed_string_t bytes_value;
8214 cmdline_fixed_string_t mask;
8215 cmdline_fixed_string_t mask_value;
8216 cmdline_fixed_string_t priority;
8217 uint8_t priority_value;
8218 cmdline_fixed_string_t queue;
8222 static int xdigit2val(unsigned char c)
8227 else if (isupper(c))
8235 cmd_flex_filter_parsed(void *parsed_result,
8236 __attribute__((unused)) struct cmdline *cl,
8237 __attribute__((unused)) void *data)
8240 struct rte_eth_flex_filter filter;
8241 struct cmd_flex_filter_result *res = parsed_result;
8242 char *bytes_ptr, *mask_ptr;
8243 uint16_t len, i, j = 0;
8248 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8249 printf("the len exceed the max length 128\n");
8252 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8253 filter.len = res->len_value;
8254 filter.priority = res->priority_value;
8255 filter.queue = res->queue_id;
8256 bytes_ptr = res->bytes_value;
8257 mask_ptr = res->mask_value;
8259 /* translate bytes string to array. */
8260 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8261 (bytes_ptr[1] == 'X')))
8263 len = strnlen(bytes_ptr, res->len_value * 2);
8264 if (len == 0 || (len % 8 != 0)) {
8265 printf("please check len and bytes input\n");
8268 for (i = 0; i < len; i++) {
8270 if (isxdigit(c) == 0) {
8271 /* invalid characters. */
8272 printf("invalid input\n");
8275 val = xdigit2val(c);
8278 filter.bytes[j] = byte;
8279 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8286 /* translate mask string to uint8_t array. */
8287 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8288 (mask_ptr[1] == 'X')))
8290 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8292 printf("invalid input\n");
8297 for (i = 0; i < len; i++) {
8299 if (isxdigit(c) == 0) {
8300 /* invalid characters. */
8301 printf("invalid input\n");
8304 val = xdigit2val(c);
8307 filter.mask[j] = byte;
8308 printf("mask[%d]:%02x ", j, filter.mask[j]);
8316 if (!strcmp(res->ops, "add"))
8317 ret = rte_eth_dev_filter_ctrl(res->port_id,
8318 RTE_ETH_FILTER_FLEXIBLE,
8322 ret = rte_eth_dev_filter_ctrl(res->port_id,
8323 RTE_ETH_FILTER_FLEXIBLE,
8324 RTE_ETH_FILTER_DELETE,
8328 printf("flex filter setting error: (%s)\n", strerror(-ret));
8331 cmdline_parse_token_string_t cmd_flex_filter_filter =
8332 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8333 filter, "flex_filter");
8334 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8335 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8337 cmdline_parse_token_string_t cmd_flex_filter_ops =
8338 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8340 cmdline_parse_token_string_t cmd_flex_filter_len =
8341 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8343 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8344 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8346 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8347 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8349 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8350 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8352 cmdline_parse_token_string_t cmd_flex_filter_mask =
8353 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8355 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8358 cmdline_parse_token_string_t cmd_flex_filter_priority =
8359 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8360 priority, "priority");
8361 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8362 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8363 priority_value, UINT8);
8364 cmdline_parse_token_string_t cmd_flex_filter_queue =
8365 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8367 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8368 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8370 cmdline_parse_inst_t cmd_flex_filter = {
8371 .f = cmd_flex_filter_parsed,
8373 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8374 "<value> mask <value> priority <value> queue <queue_id>: "
8375 "Add/Del a flex filter",
8377 (void *)&cmd_flex_filter_filter,
8378 (void *)&cmd_flex_filter_port_id,
8379 (void *)&cmd_flex_filter_ops,
8380 (void *)&cmd_flex_filter_len,
8381 (void *)&cmd_flex_filter_len_value,
8382 (void *)&cmd_flex_filter_bytes,
8383 (void *)&cmd_flex_filter_bytes_value,
8384 (void *)&cmd_flex_filter_mask,
8385 (void *)&cmd_flex_filter_mask_value,
8386 (void *)&cmd_flex_filter_priority,
8387 (void *)&cmd_flex_filter_priority_value,
8388 (void *)&cmd_flex_filter_queue,
8389 (void *)&cmd_flex_filter_queue_id,
8394 /* *** Filters Control *** */
8396 /* *** deal with ethertype filter *** */
8397 struct cmd_ethertype_filter_result {
8398 cmdline_fixed_string_t filter;
8400 cmdline_fixed_string_t ops;
8401 cmdline_fixed_string_t mac;
8402 struct ether_addr mac_addr;
8403 cmdline_fixed_string_t ethertype;
8404 uint16_t ethertype_value;
8405 cmdline_fixed_string_t drop;
8406 cmdline_fixed_string_t queue;
8410 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8411 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8412 filter, "ethertype_filter");
8413 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8414 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8416 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8417 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8419 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8420 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8421 mac, "mac_addr#mac_ignr");
8422 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8423 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8425 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8426 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8427 ethertype, "ethertype");
8428 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8429 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8430 ethertype_value, UINT16);
8431 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8432 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8434 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8435 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8437 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8438 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8442 cmd_ethertype_filter_parsed(void *parsed_result,
8443 __attribute__((unused)) struct cmdline *cl,
8444 __attribute__((unused)) void *data)
8446 struct cmd_ethertype_filter_result *res = parsed_result;
8447 struct rte_eth_ethertype_filter filter;
8450 ret = rte_eth_dev_filter_supported(res->port_id,
8451 RTE_ETH_FILTER_ETHERTYPE);
8453 printf("ethertype filter is not supported on port %u.\n",
8458 memset(&filter, 0, sizeof(filter));
8459 if (!strcmp(res->mac, "mac_addr")) {
8460 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8461 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8462 sizeof(struct ether_addr));
8464 if (!strcmp(res->drop, "drop"))
8465 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8466 filter.ether_type = res->ethertype_value;
8467 filter.queue = res->queue_id;
8469 if (!strcmp(res->ops, "add"))
8470 ret = rte_eth_dev_filter_ctrl(res->port_id,
8471 RTE_ETH_FILTER_ETHERTYPE,
8475 ret = rte_eth_dev_filter_ctrl(res->port_id,
8476 RTE_ETH_FILTER_ETHERTYPE,
8477 RTE_ETH_FILTER_DELETE,
8480 printf("ethertype filter programming error: (%s)\n",
8484 cmdline_parse_inst_t cmd_ethertype_filter = {
8485 .f = cmd_ethertype_filter_parsed,
8487 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8488 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8489 "Add or delete an ethertype filter entry",
8491 (void *)&cmd_ethertype_filter_filter,
8492 (void *)&cmd_ethertype_filter_port_id,
8493 (void *)&cmd_ethertype_filter_ops,
8494 (void *)&cmd_ethertype_filter_mac,
8495 (void *)&cmd_ethertype_filter_mac_addr,
8496 (void *)&cmd_ethertype_filter_ethertype,
8497 (void *)&cmd_ethertype_filter_ethertype_value,
8498 (void *)&cmd_ethertype_filter_drop,
8499 (void *)&cmd_ethertype_filter_queue,
8500 (void *)&cmd_ethertype_filter_queue_id,
8505 /* *** deal with flow director filter *** */
8506 struct cmd_flow_director_result {
8507 cmdline_fixed_string_t flow_director_filter;
8509 cmdline_fixed_string_t mode;
8510 cmdline_fixed_string_t mode_value;
8511 cmdline_fixed_string_t ops;
8512 cmdline_fixed_string_t flow;
8513 cmdline_fixed_string_t flow_type;
8514 cmdline_fixed_string_t ether;
8515 uint16_t ether_type;
8516 cmdline_fixed_string_t src;
8517 cmdline_ipaddr_t ip_src;
8519 cmdline_fixed_string_t dst;
8520 cmdline_ipaddr_t ip_dst;
8522 cmdline_fixed_string_t verify_tag;
8523 uint32_t verify_tag_value;
8524 cmdline_ipaddr_t tos;
8526 cmdline_ipaddr_t proto;
8527 uint8_t proto_value;
8528 cmdline_ipaddr_t ttl;
8530 cmdline_fixed_string_t vlan;
8531 uint16_t vlan_value;
8532 cmdline_fixed_string_t flexbytes;
8533 cmdline_fixed_string_t flexbytes_value;
8534 cmdline_fixed_string_t pf_vf;
8535 cmdline_fixed_string_t drop;
8536 cmdline_fixed_string_t queue;
8538 cmdline_fixed_string_t fd_id;
8539 uint32_t fd_id_value;
8540 cmdline_fixed_string_t mac;
8541 struct ether_addr mac_addr;
8542 cmdline_fixed_string_t tunnel;
8543 cmdline_fixed_string_t tunnel_type;
8544 cmdline_fixed_string_t tunnel_id;
8545 uint32_t tunnel_id_value;
8549 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8552 const char *p, *p0 = q_arg;
8554 unsigned long int_fld;
8555 char *str_fld[max_num];
8560 p = strchr(p0, '(');
8564 p0 = strchr(p, ')');
8569 if (size >= sizeof(s))
8572 snprintf(s, sizeof(s), "%.*s", size, p);
8573 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8574 if (ret < 0 || ret > max_num)
8576 for (i = 0; i < ret; i++) {
8578 int_fld = strtoul(str_fld[i], &end, 0);
8579 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8581 flexbytes[i] = (uint8_t)int_fld;
8587 str2flowtype(char *string)
8590 static const struct {
8593 } flowtype_str[] = {
8594 {"raw", RTE_ETH_FLOW_RAW},
8595 {"ipv4", RTE_ETH_FLOW_IPV4},
8596 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8597 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8598 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8599 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8600 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8601 {"ipv6", RTE_ETH_FLOW_IPV6},
8602 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8603 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8604 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8605 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8606 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8607 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8610 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8611 if (!strcmp(flowtype_str[i].str, string))
8612 return flowtype_str[i].type;
8614 return RTE_ETH_FLOW_UNKNOWN;
8617 static enum rte_eth_fdir_tunnel_type
8618 str2fdir_tunneltype(char *string)
8622 static const struct {
8624 enum rte_eth_fdir_tunnel_type type;
8625 } tunneltype_str[] = {
8626 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8627 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8630 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8631 if (!strcmp(tunneltype_str[i].str, string))
8632 return tunneltype_str[i].type;
8634 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8637 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8639 if ((ip_addr).family == AF_INET) \
8640 (ip) = (ip_addr).addr.ipv4.s_addr; \
8642 printf("invalid parameter.\n"); \
8647 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8649 if ((ip_addr).family == AF_INET6) \
8650 (void)rte_memcpy(&(ip), \
8651 &((ip_addr).addr.ipv6), \
8652 sizeof(struct in6_addr)); \
8654 printf("invalid parameter.\n"); \
8660 cmd_flow_director_filter_parsed(void *parsed_result,
8661 __attribute__((unused)) struct cmdline *cl,
8662 __attribute__((unused)) void *data)
8664 struct cmd_flow_director_result *res = parsed_result;
8665 struct rte_eth_fdir_filter entry;
8666 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8668 unsigned long vf_id;
8671 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8673 printf("flow director is not supported on port %u.\n",
8677 memset(flexbytes, 0, sizeof(flexbytes));
8678 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8680 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8681 if (strcmp(res->mode_value, "MAC-VLAN")) {
8682 printf("Please set mode to MAC-VLAN.\n");
8685 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8686 if (strcmp(res->mode_value, "Tunnel")) {
8687 printf("Please set mode to Tunnel.\n");
8691 if (strcmp(res->mode_value, "IP")) {
8692 printf("Please set mode to IP.\n");
8695 entry.input.flow_type = str2flowtype(res->flow_type);
8698 ret = parse_flexbytes(res->flexbytes_value,
8700 RTE_ETH_FDIR_MAX_FLEXLEN);
8702 printf("error: Cannot parse flexbytes input.\n");
8706 switch (entry.input.flow_type) {
8707 case RTE_ETH_FLOW_FRAG_IPV4:
8708 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8709 entry.input.flow.ip4_flow.proto = res->proto_value;
8710 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8711 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8712 IPV4_ADDR_TO_UINT(res->ip_dst,
8713 entry.input.flow.ip4_flow.dst_ip);
8714 IPV4_ADDR_TO_UINT(res->ip_src,
8715 entry.input.flow.ip4_flow.src_ip);
8716 entry.input.flow.ip4_flow.tos = res->tos_value;
8717 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8718 /* need convert to big endian. */
8719 entry.input.flow.udp4_flow.dst_port =
8720 rte_cpu_to_be_16(res->port_dst);
8721 entry.input.flow.udp4_flow.src_port =
8722 rte_cpu_to_be_16(res->port_src);
8724 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8725 IPV4_ADDR_TO_UINT(res->ip_dst,
8726 entry.input.flow.sctp4_flow.ip.dst_ip);
8727 IPV4_ADDR_TO_UINT(res->ip_src,
8728 entry.input.flow.sctp4_flow.ip.src_ip);
8729 entry.input.flow.ip4_flow.tos = res->tos_value;
8730 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8731 /* need convert to big endian. */
8732 entry.input.flow.sctp4_flow.dst_port =
8733 rte_cpu_to_be_16(res->port_dst);
8734 entry.input.flow.sctp4_flow.src_port =
8735 rte_cpu_to_be_16(res->port_src);
8736 entry.input.flow.sctp4_flow.verify_tag =
8737 rte_cpu_to_be_32(res->verify_tag_value);
8739 case RTE_ETH_FLOW_FRAG_IPV6:
8740 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8741 entry.input.flow.ipv6_flow.proto = res->proto_value;
8742 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8743 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8744 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8745 entry.input.flow.ipv6_flow.dst_ip);
8746 IPV6_ADDR_TO_ARRAY(res->ip_src,
8747 entry.input.flow.ipv6_flow.src_ip);
8748 entry.input.flow.ipv6_flow.tc = res->tos_value;
8749 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8750 /* need convert to big endian. */
8751 entry.input.flow.udp6_flow.dst_port =
8752 rte_cpu_to_be_16(res->port_dst);
8753 entry.input.flow.udp6_flow.src_port =
8754 rte_cpu_to_be_16(res->port_src);
8756 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8757 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8758 entry.input.flow.sctp6_flow.ip.dst_ip);
8759 IPV6_ADDR_TO_ARRAY(res->ip_src,
8760 entry.input.flow.sctp6_flow.ip.src_ip);
8761 entry.input.flow.ipv6_flow.tc = res->tos_value;
8762 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8763 /* need convert to big endian. */
8764 entry.input.flow.sctp6_flow.dst_port =
8765 rte_cpu_to_be_16(res->port_dst);
8766 entry.input.flow.sctp6_flow.src_port =
8767 rte_cpu_to_be_16(res->port_src);
8768 entry.input.flow.sctp6_flow.verify_tag =
8769 rte_cpu_to_be_32(res->verify_tag_value);
8771 case RTE_ETH_FLOW_L2_PAYLOAD:
8772 entry.input.flow.l2_flow.ether_type =
8773 rte_cpu_to_be_16(res->ether_type);
8779 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8780 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8782 sizeof(struct ether_addr));
8784 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8785 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8787 sizeof(struct ether_addr));
8788 entry.input.flow.tunnel_flow.tunnel_type =
8789 str2fdir_tunneltype(res->tunnel_type);
8790 entry.input.flow.tunnel_flow.tunnel_id =
8791 rte_cpu_to_be_32(res->tunnel_id_value);
8794 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8796 RTE_ETH_FDIR_MAX_FLEXLEN);
8798 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8800 entry.action.flex_off = 0; /*use 0 by default */
8801 if (!strcmp(res->drop, "drop"))
8802 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8804 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8806 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8807 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8808 if (!strcmp(res->pf_vf, "pf"))
8809 entry.input.flow_ext.is_vf = 0;
8810 else if (!strncmp(res->pf_vf, "vf", 2)) {
8811 struct rte_eth_dev_info dev_info;
8813 memset(&dev_info, 0, sizeof(dev_info));
8814 rte_eth_dev_info_get(res->port_id, &dev_info);
8816 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8817 if (errno != 0 || *end != '\0' ||
8818 vf_id >= dev_info.max_vfs) {
8819 printf("invalid parameter %s.\n", res->pf_vf);
8822 entry.input.flow_ext.is_vf = 1;
8823 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8825 printf("invalid parameter %s.\n", res->pf_vf);
8830 /* set to report FD ID by default */
8831 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8832 entry.action.rx_queue = res->queue_id;
8833 entry.soft_id = res->fd_id_value;
8834 if (!strcmp(res->ops, "add"))
8835 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8836 RTE_ETH_FILTER_ADD, &entry);
8837 else if (!strcmp(res->ops, "del"))
8838 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8839 RTE_ETH_FILTER_DELETE, &entry);
8841 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8842 RTE_ETH_FILTER_UPDATE, &entry);
8844 printf("flow director programming error: (%s)\n",
8848 cmdline_parse_token_string_t cmd_flow_director_filter =
8849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8850 flow_director_filter, "flow_director_filter");
8851 cmdline_parse_token_num_t cmd_flow_director_port_id =
8852 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8854 cmdline_parse_token_string_t cmd_flow_director_ops =
8855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8856 ops, "add#del#update");
8857 cmdline_parse_token_string_t cmd_flow_director_flow =
8858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8860 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8862 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8863 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8864 cmdline_parse_token_string_t cmd_flow_director_ether =
8865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8867 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8868 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8869 ether_type, UINT16);
8870 cmdline_parse_token_string_t cmd_flow_director_src =
8871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8873 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8874 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8876 cmdline_parse_token_num_t cmd_flow_director_port_src =
8877 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8879 cmdline_parse_token_string_t cmd_flow_director_dst =
8880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8882 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8883 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8885 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8886 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8888 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8890 verify_tag, "verify_tag");
8891 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8892 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8893 verify_tag_value, UINT32);
8894 cmdline_parse_token_string_t cmd_flow_director_tos =
8895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8897 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8898 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8900 cmdline_parse_token_string_t cmd_flow_director_proto =
8901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8903 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8904 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8905 proto_value, UINT8);
8906 cmdline_parse_token_string_t cmd_flow_director_ttl =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8909 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8910 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8912 cmdline_parse_token_string_t cmd_flow_director_vlan =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8915 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8916 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8917 vlan_value, UINT16);
8918 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8920 flexbytes, "flexbytes");
8921 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8923 flexbytes_value, NULL);
8924 cmdline_parse_token_string_t cmd_flow_director_drop =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8927 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8930 cmdline_parse_token_string_t cmd_flow_director_queue =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8933 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8934 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8936 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8939 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8940 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8941 fd_id_value, UINT32);
8943 cmdline_parse_token_string_t cmd_flow_director_mode =
8944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8946 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8949 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8951 mode_value, "MAC-VLAN");
8952 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8954 mode_value, "Tunnel");
8955 cmdline_parse_token_string_t cmd_flow_director_mac =
8956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8958 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8959 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8961 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8964 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8966 tunnel_type, "NVGRE#VxLAN");
8967 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8969 tunnel_id, "tunnel-id");
8970 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8971 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8972 tunnel_id_value, UINT32);
8974 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8975 .f = cmd_flow_director_filter_parsed,
8977 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8978 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8979 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8980 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8981 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8982 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8983 "fd_id <fd_id_value>: "
8984 "Add or delete an ip flow director entry on NIC",
8986 (void *)&cmd_flow_director_filter,
8987 (void *)&cmd_flow_director_port_id,
8988 (void *)&cmd_flow_director_mode,
8989 (void *)&cmd_flow_director_mode_ip,
8990 (void *)&cmd_flow_director_ops,
8991 (void *)&cmd_flow_director_flow,
8992 (void *)&cmd_flow_director_flow_type,
8993 (void *)&cmd_flow_director_src,
8994 (void *)&cmd_flow_director_ip_src,
8995 (void *)&cmd_flow_director_dst,
8996 (void *)&cmd_flow_director_ip_dst,
8997 (void *)&cmd_flow_director_tos,
8998 (void *)&cmd_flow_director_tos_value,
8999 (void *)&cmd_flow_director_proto,
9000 (void *)&cmd_flow_director_proto_value,
9001 (void *)&cmd_flow_director_ttl,
9002 (void *)&cmd_flow_director_ttl_value,
9003 (void *)&cmd_flow_director_vlan,
9004 (void *)&cmd_flow_director_vlan_value,
9005 (void *)&cmd_flow_director_flexbytes,
9006 (void *)&cmd_flow_director_flexbytes_value,
9007 (void *)&cmd_flow_director_drop,
9008 (void *)&cmd_flow_director_pf_vf,
9009 (void *)&cmd_flow_director_queue,
9010 (void *)&cmd_flow_director_queue_id,
9011 (void *)&cmd_flow_director_fd_id,
9012 (void *)&cmd_flow_director_fd_id_value,
9017 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9018 .f = cmd_flow_director_filter_parsed,
9020 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9021 "director entry on NIC",
9023 (void *)&cmd_flow_director_filter,
9024 (void *)&cmd_flow_director_port_id,
9025 (void *)&cmd_flow_director_mode,
9026 (void *)&cmd_flow_director_mode_ip,
9027 (void *)&cmd_flow_director_ops,
9028 (void *)&cmd_flow_director_flow,
9029 (void *)&cmd_flow_director_flow_type,
9030 (void *)&cmd_flow_director_src,
9031 (void *)&cmd_flow_director_ip_src,
9032 (void *)&cmd_flow_director_port_src,
9033 (void *)&cmd_flow_director_dst,
9034 (void *)&cmd_flow_director_ip_dst,
9035 (void *)&cmd_flow_director_port_dst,
9036 (void *)&cmd_flow_director_tos,
9037 (void *)&cmd_flow_director_tos_value,
9038 (void *)&cmd_flow_director_ttl,
9039 (void *)&cmd_flow_director_ttl_value,
9040 (void *)&cmd_flow_director_vlan,
9041 (void *)&cmd_flow_director_vlan_value,
9042 (void *)&cmd_flow_director_flexbytes,
9043 (void *)&cmd_flow_director_flexbytes_value,
9044 (void *)&cmd_flow_director_drop,
9045 (void *)&cmd_flow_director_pf_vf,
9046 (void *)&cmd_flow_director_queue,
9047 (void *)&cmd_flow_director_queue_id,
9048 (void *)&cmd_flow_director_fd_id,
9049 (void *)&cmd_flow_director_fd_id_value,
9054 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9055 .f = cmd_flow_director_filter_parsed,
9057 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9058 "director entry on NIC",
9060 (void *)&cmd_flow_director_filter,
9061 (void *)&cmd_flow_director_port_id,
9062 (void *)&cmd_flow_director_mode,
9063 (void *)&cmd_flow_director_mode_ip,
9064 (void *)&cmd_flow_director_ops,
9065 (void *)&cmd_flow_director_flow,
9066 (void *)&cmd_flow_director_flow_type,
9067 (void *)&cmd_flow_director_src,
9068 (void *)&cmd_flow_director_ip_src,
9069 (void *)&cmd_flow_director_port_dst,
9070 (void *)&cmd_flow_director_dst,
9071 (void *)&cmd_flow_director_ip_dst,
9072 (void *)&cmd_flow_director_port_dst,
9073 (void *)&cmd_flow_director_verify_tag,
9074 (void *)&cmd_flow_director_verify_tag_value,
9075 (void *)&cmd_flow_director_tos,
9076 (void *)&cmd_flow_director_tos_value,
9077 (void *)&cmd_flow_director_ttl,
9078 (void *)&cmd_flow_director_ttl_value,
9079 (void *)&cmd_flow_director_vlan,
9080 (void *)&cmd_flow_director_vlan_value,
9081 (void *)&cmd_flow_director_flexbytes,
9082 (void *)&cmd_flow_director_flexbytes_value,
9083 (void *)&cmd_flow_director_drop,
9084 (void *)&cmd_flow_director_pf_vf,
9085 (void *)&cmd_flow_director_queue,
9086 (void *)&cmd_flow_director_queue_id,
9087 (void *)&cmd_flow_director_fd_id,
9088 (void *)&cmd_flow_director_fd_id_value,
9093 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9094 .f = cmd_flow_director_filter_parsed,
9096 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9097 "director entry on NIC",
9099 (void *)&cmd_flow_director_filter,
9100 (void *)&cmd_flow_director_port_id,
9101 (void *)&cmd_flow_director_mode,
9102 (void *)&cmd_flow_director_mode_ip,
9103 (void *)&cmd_flow_director_ops,
9104 (void *)&cmd_flow_director_flow,
9105 (void *)&cmd_flow_director_flow_type,
9106 (void *)&cmd_flow_director_ether,
9107 (void *)&cmd_flow_director_ether_type,
9108 (void *)&cmd_flow_director_flexbytes,
9109 (void *)&cmd_flow_director_flexbytes_value,
9110 (void *)&cmd_flow_director_drop,
9111 (void *)&cmd_flow_director_pf_vf,
9112 (void *)&cmd_flow_director_queue,
9113 (void *)&cmd_flow_director_queue_id,
9114 (void *)&cmd_flow_director_fd_id,
9115 (void *)&cmd_flow_director_fd_id_value,
9120 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9121 .f = cmd_flow_director_filter_parsed,
9123 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9124 "director entry on NIC",
9126 (void *)&cmd_flow_director_filter,
9127 (void *)&cmd_flow_director_port_id,
9128 (void *)&cmd_flow_director_mode,
9129 (void *)&cmd_flow_director_mode_mac_vlan,
9130 (void *)&cmd_flow_director_ops,
9131 (void *)&cmd_flow_director_mac,
9132 (void *)&cmd_flow_director_mac_addr,
9133 (void *)&cmd_flow_director_vlan,
9134 (void *)&cmd_flow_director_vlan_value,
9135 (void *)&cmd_flow_director_flexbytes,
9136 (void *)&cmd_flow_director_flexbytes_value,
9137 (void *)&cmd_flow_director_drop,
9138 (void *)&cmd_flow_director_queue,
9139 (void *)&cmd_flow_director_queue_id,
9140 (void *)&cmd_flow_director_fd_id,
9141 (void *)&cmd_flow_director_fd_id_value,
9146 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9147 .f = cmd_flow_director_filter_parsed,
9149 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9150 "director entry on NIC",
9152 (void *)&cmd_flow_director_filter,
9153 (void *)&cmd_flow_director_port_id,
9154 (void *)&cmd_flow_director_mode,
9155 (void *)&cmd_flow_director_mode_tunnel,
9156 (void *)&cmd_flow_director_ops,
9157 (void *)&cmd_flow_director_mac,
9158 (void *)&cmd_flow_director_mac_addr,
9159 (void *)&cmd_flow_director_vlan,
9160 (void *)&cmd_flow_director_vlan_value,
9161 (void *)&cmd_flow_director_tunnel,
9162 (void *)&cmd_flow_director_tunnel_type,
9163 (void *)&cmd_flow_director_tunnel_id,
9164 (void *)&cmd_flow_director_tunnel_id_value,
9165 (void *)&cmd_flow_director_flexbytes,
9166 (void *)&cmd_flow_director_flexbytes_value,
9167 (void *)&cmd_flow_director_drop,
9168 (void *)&cmd_flow_director_queue,
9169 (void *)&cmd_flow_director_queue_id,
9170 (void *)&cmd_flow_director_fd_id,
9171 (void *)&cmd_flow_director_fd_id_value,
9176 struct cmd_flush_flow_director_result {
9177 cmdline_fixed_string_t flush_flow_director;
9181 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9182 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9183 flush_flow_director, "flush_flow_director");
9184 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9185 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9189 cmd_flush_flow_director_parsed(void *parsed_result,
9190 __attribute__((unused)) struct cmdline *cl,
9191 __attribute__((unused)) void *data)
9193 struct cmd_flow_director_result *res = parsed_result;
9196 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9198 printf("flow director is not supported on port %u.\n",
9203 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9204 RTE_ETH_FILTER_FLUSH, NULL);
9206 printf("flow director table flushing error: (%s)\n",
9210 cmdline_parse_inst_t cmd_flush_flow_director = {
9211 .f = cmd_flush_flow_director_parsed,
9213 .help_str = "flush_flow_director <port_id>: "
9214 "Flush all flow director entries of a device on NIC",
9216 (void *)&cmd_flush_flow_director_flush,
9217 (void *)&cmd_flush_flow_director_port_id,
9222 /* *** deal with flow director mask *** */
9223 struct cmd_flow_director_mask_result {
9224 cmdline_fixed_string_t flow_director_mask;
9226 cmdline_fixed_string_t mode;
9227 cmdline_fixed_string_t mode_value;
9228 cmdline_fixed_string_t vlan;
9230 cmdline_fixed_string_t src_mask;
9231 cmdline_ipaddr_t ipv4_src;
9232 cmdline_ipaddr_t ipv6_src;
9234 cmdline_fixed_string_t dst_mask;
9235 cmdline_ipaddr_t ipv4_dst;
9236 cmdline_ipaddr_t ipv6_dst;
9238 cmdline_fixed_string_t mac;
9239 uint8_t mac_addr_byte_mask;
9240 cmdline_fixed_string_t tunnel_id;
9241 uint32_t tunnel_id_mask;
9242 cmdline_fixed_string_t tunnel_type;
9243 uint8_t tunnel_type_mask;
9247 cmd_flow_director_mask_parsed(void *parsed_result,
9248 __attribute__((unused)) struct cmdline *cl,
9249 __attribute__((unused)) void *data)
9251 struct cmd_flow_director_mask_result *res = parsed_result;
9252 struct rte_eth_fdir_masks *mask;
9253 struct rte_port *port;
9255 if (res->port_id > nb_ports) {
9256 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9260 port = &ports[res->port_id];
9261 /** Check if the port is not started **/
9262 if (port->port_status != RTE_PORT_STOPPED) {
9263 printf("Please stop port %d first\n", res->port_id);
9267 mask = &port->dev_conf.fdir_conf.mask;
9269 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9270 if (strcmp(res->mode_value, "MAC-VLAN")) {
9271 printf("Please set mode to MAC-VLAN.\n");
9275 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9276 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9277 if (strcmp(res->mode_value, "Tunnel")) {
9278 printf("Please set mode to Tunnel.\n");
9282 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9283 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9284 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9285 mask->tunnel_type_mask = res->tunnel_type_mask;
9287 if (strcmp(res->mode_value, "IP")) {
9288 printf("Please set mode to IP.\n");
9292 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9293 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9294 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9295 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9296 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9297 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9298 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9301 cmd_reconfig_device_queue(res->port_id, 1, 1);
9304 cmdline_parse_token_string_t cmd_flow_director_mask =
9305 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9306 flow_director_mask, "flow_director_mask");
9307 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9308 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9310 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9313 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9314 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9316 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9318 src_mask, "src_mask");
9319 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9320 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9322 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9323 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9325 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9326 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9328 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9330 dst_mask, "dst_mask");
9331 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9332 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9334 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9335 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9337 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9338 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9341 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9344 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9347 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9349 mode_value, "MAC-VLAN");
9350 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9352 mode_value, "Tunnel");
9353 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9356 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9357 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9358 mac_addr_byte_mask, UINT8);
9359 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9361 tunnel_type, "tunnel-type");
9362 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9363 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9364 tunnel_type_mask, UINT8);
9365 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9366 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9367 tunnel_id, "tunnel-id");
9368 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9369 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9370 tunnel_id_mask, UINT32);
9372 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9373 .f = cmd_flow_director_mask_parsed,
9375 .help_str = "flow_director_mask ... : "
9376 "Set IP mode flow director's mask on NIC",
9378 (void *)&cmd_flow_director_mask,
9379 (void *)&cmd_flow_director_mask_port_id,
9380 (void *)&cmd_flow_director_mask_mode,
9381 (void *)&cmd_flow_director_mask_mode_ip,
9382 (void *)&cmd_flow_director_mask_vlan,
9383 (void *)&cmd_flow_director_mask_vlan_value,
9384 (void *)&cmd_flow_director_mask_src,
9385 (void *)&cmd_flow_director_mask_ipv4_src,
9386 (void *)&cmd_flow_director_mask_ipv6_src,
9387 (void *)&cmd_flow_director_mask_port_src,
9388 (void *)&cmd_flow_director_mask_dst,
9389 (void *)&cmd_flow_director_mask_ipv4_dst,
9390 (void *)&cmd_flow_director_mask_ipv6_dst,
9391 (void *)&cmd_flow_director_mask_port_dst,
9396 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9397 .f = cmd_flow_director_mask_parsed,
9399 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9400 "flow director's mask on NIC",
9402 (void *)&cmd_flow_director_mask,
9403 (void *)&cmd_flow_director_mask_port_id,
9404 (void *)&cmd_flow_director_mask_mode,
9405 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9406 (void *)&cmd_flow_director_mask_vlan,
9407 (void *)&cmd_flow_director_mask_vlan_value,
9412 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9413 .f = cmd_flow_director_mask_parsed,
9415 .help_str = "flow_director_mask ... : Set tunnel mode "
9416 "flow director's mask on NIC",
9418 (void *)&cmd_flow_director_mask,
9419 (void *)&cmd_flow_director_mask_port_id,
9420 (void *)&cmd_flow_director_mask_mode,
9421 (void *)&cmd_flow_director_mask_mode_tunnel,
9422 (void *)&cmd_flow_director_mask_vlan,
9423 (void *)&cmd_flow_director_mask_vlan_value,
9424 (void *)&cmd_flow_director_mask_mac,
9425 (void *)&cmd_flow_director_mask_mac_value,
9426 (void *)&cmd_flow_director_mask_tunnel_type,
9427 (void *)&cmd_flow_director_mask_tunnel_type_value,
9428 (void *)&cmd_flow_director_mask_tunnel_id,
9429 (void *)&cmd_flow_director_mask_tunnel_id_value,
9434 /* *** deal with flow director mask on flexible payload *** */
9435 struct cmd_flow_director_flex_mask_result {
9436 cmdline_fixed_string_t flow_director_flexmask;
9438 cmdline_fixed_string_t flow;
9439 cmdline_fixed_string_t flow_type;
9440 cmdline_fixed_string_t mask;
9444 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9445 __attribute__((unused)) struct cmdline *cl,
9446 __attribute__((unused)) void *data)
9448 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9449 struct rte_eth_fdir_info fdir_info;
9450 struct rte_eth_fdir_flex_mask flex_mask;
9451 struct rte_port *port;
9452 uint32_t flow_type_mask;
9456 if (res->port_id > nb_ports) {
9457 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9461 port = &ports[res->port_id];
9462 /** Check if the port is not started **/
9463 if (port->port_status != RTE_PORT_STOPPED) {
9464 printf("Please stop port %d first\n", res->port_id);
9468 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9469 ret = parse_flexbytes(res->mask,
9471 RTE_ETH_FDIR_MAX_FLEXLEN);
9473 printf("error: Cannot parse mask input.\n");
9477 memset(&fdir_info, 0, sizeof(fdir_info));
9478 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9479 RTE_ETH_FILTER_INFO, &fdir_info);
9481 printf("Cannot get FDir filter info\n");
9485 if (!strcmp(res->flow_type, "none")) {
9486 /* means don't specify the flow type */
9487 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9488 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9489 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9490 0, sizeof(struct rte_eth_fdir_flex_mask));
9491 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9492 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9494 sizeof(struct rte_eth_fdir_flex_mask));
9495 cmd_reconfig_device_queue(res->port_id, 1, 1);
9498 flow_type_mask = fdir_info.flow_types_mask[0];
9499 if (!strcmp(res->flow_type, "all")) {
9500 if (!flow_type_mask) {
9501 printf("No flow type supported\n");
9504 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9505 if (flow_type_mask & (1 << i)) {
9506 flex_mask.flow_type = i;
9507 fdir_set_flex_mask(res->port_id, &flex_mask);
9510 cmd_reconfig_device_queue(res->port_id, 1, 1);
9513 flex_mask.flow_type = str2flowtype(res->flow_type);
9514 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9515 printf("Flow type %s not supported on port %d\n",
9516 res->flow_type, res->port_id);
9519 fdir_set_flex_mask(res->port_id, &flex_mask);
9520 cmd_reconfig_device_queue(res->port_id, 1, 1);
9523 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9525 flow_director_flexmask,
9526 "flow_director_flex_mask");
9527 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9528 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9530 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9533 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9535 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9536 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9537 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9538 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9541 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9542 .f = cmd_flow_director_flex_mask_parsed,
9544 .help_str = "flow_director_flex_mask ... : "
9545 "Set flow director's flex mask on NIC",
9547 (void *)&cmd_flow_director_flexmask,
9548 (void *)&cmd_flow_director_flexmask_port_id,
9549 (void *)&cmd_flow_director_flexmask_flow,
9550 (void *)&cmd_flow_director_flexmask_flow_type,
9551 (void *)&cmd_flow_director_flexmask_mask,
9556 /* *** deal with flow director flexible payload configuration *** */
9557 struct cmd_flow_director_flexpayload_result {
9558 cmdline_fixed_string_t flow_director_flexpayload;
9560 cmdline_fixed_string_t payload_layer;
9561 cmdline_fixed_string_t payload_cfg;
9565 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9568 const char *p, *p0 = q_arg;
9570 unsigned long int_fld;
9571 char *str_fld[max_num];
9576 p = strchr(p0, '(');
9580 p0 = strchr(p, ')');
9585 if (size >= sizeof(s))
9588 snprintf(s, sizeof(s), "%.*s", size, p);
9589 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9590 if (ret < 0 || ret > max_num)
9592 for (i = 0; i < ret; i++) {
9594 int_fld = strtoul(str_fld[i], &end, 0);
9595 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9597 offsets[i] = (uint16_t)int_fld;
9603 cmd_flow_director_flxpld_parsed(void *parsed_result,
9604 __attribute__((unused)) struct cmdline *cl,
9605 __attribute__((unused)) void *data)
9607 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9608 struct rte_eth_flex_payload_cfg flex_cfg;
9609 struct rte_port *port;
9612 if (res->port_id > nb_ports) {
9613 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9617 port = &ports[res->port_id];
9618 /** Check if the port is not started **/
9619 if (port->port_status != RTE_PORT_STOPPED) {
9620 printf("Please stop port %d first\n", res->port_id);
9624 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9626 if (!strcmp(res->payload_layer, "raw"))
9627 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9628 else if (!strcmp(res->payload_layer, "l2"))
9629 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9630 else if (!strcmp(res->payload_layer, "l3"))
9631 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9632 else if (!strcmp(res->payload_layer, "l4"))
9633 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9635 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9636 RTE_ETH_FDIR_MAX_FLEXLEN);
9638 printf("error: Cannot parse flex payload input.\n");
9642 fdir_set_flex_payload(res->port_id, &flex_cfg);
9643 cmd_reconfig_device_queue(res->port_id, 1, 1);
9646 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9648 flow_director_flexpayload,
9649 "flow_director_flex_payload");
9650 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9651 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9653 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9655 payload_layer, "raw#l2#l3#l4");
9656 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9657 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9660 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9661 .f = cmd_flow_director_flxpld_parsed,
9663 .help_str = "flow_director_flexpayload ... : "
9664 "Set flow director's flex payload on NIC",
9666 (void *)&cmd_flow_director_flexpayload,
9667 (void *)&cmd_flow_director_flexpayload_port_id,
9668 (void *)&cmd_flow_director_flexpayload_payload_layer,
9669 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9674 /* Generic flow interface command. */
9675 extern cmdline_parse_inst_t cmd_flow;
9677 /* *** Classification Filters Control *** */
9678 /* *** Get symmetric hash enable per port *** */
9679 struct cmd_get_sym_hash_ena_per_port_result {
9680 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9685 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9686 __rte_unused struct cmdline *cl,
9687 __rte_unused void *data)
9689 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9690 struct rte_eth_hash_filter_info info;
9693 if (rte_eth_dev_filter_supported(res->port_id,
9694 RTE_ETH_FILTER_HASH) < 0) {
9695 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9700 memset(&info, 0, sizeof(info));
9701 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9702 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9703 RTE_ETH_FILTER_GET, &info);
9706 printf("Cannot get symmetric hash enable per port "
9707 "on port %u\n", res->port_id);
9711 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9712 "enabled" : "disabled", res->port_id);
9715 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9716 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9717 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9718 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9719 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9722 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9723 .f = cmd_get_sym_hash_per_port_parsed,
9725 .help_str = "get_sym_hash_ena_per_port <port_id>",
9727 (void *)&cmd_get_sym_hash_ena_per_port_all,
9728 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9733 /* *** Set symmetric hash enable per port *** */
9734 struct cmd_set_sym_hash_ena_per_port_result {
9735 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9736 cmdline_fixed_string_t enable;
9741 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9742 __rte_unused struct cmdline *cl,
9743 __rte_unused void *data)
9745 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9746 struct rte_eth_hash_filter_info info;
9749 if (rte_eth_dev_filter_supported(res->port_id,
9750 RTE_ETH_FILTER_HASH) < 0) {
9751 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9756 memset(&info, 0, sizeof(info));
9757 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9758 if (!strcmp(res->enable, "enable"))
9759 info.info.enable = 1;
9760 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9761 RTE_ETH_FILTER_SET, &info);
9763 printf("Cannot set symmetric hash enable per port on "
9764 "port %u\n", res->port_id);
9767 printf("Symmetric hash has been set to %s on port %u\n",
9768 res->enable, res->port_id);
9771 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9772 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9773 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9774 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9775 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9777 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9778 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9779 enable, "enable#disable");
9781 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9782 .f = cmd_set_sym_hash_per_port_parsed,
9784 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9786 (void *)&cmd_set_sym_hash_ena_per_port_all,
9787 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9788 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9793 /* Get global config of hash function */
9794 struct cmd_get_hash_global_config_result {
9795 cmdline_fixed_string_t get_hash_global_config;
9800 flowtype_to_str(uint16_t ftype)
9807 {"ipv4", RTE_ETH_FLOW_IPV4},
9808 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9809 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9810 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9811 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9812 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9813 {"ipv6", RTE_ETH_FLOW_IPV6},
9814 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9815 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9816 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9817 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9818 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9819 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9820 {"port", RTE_ETH_FLOW_PORT},
9821 {"vxlan", RTE_ETH_FLOW_VXLAN},
9822 {"geneve", RTE_ETH_FLOW_GENEVE},
9823 {"nvgre", RTE_ETH_FLOW_NVGRE},
9826 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9827 if (ftype_table[i].ftype == ftype)
9828 return ftype_table[i].str;
9835 cmd_get_hash_global_config_parsed(void *parsed_result,
9836 __rte_unused struct cmdline *cl,
9837 __rte_unused void *data)
9839 struct cmd_get_hash_global_config_result *res = parsed_result;
9840 struct rte_eth_hash_filter_info info;
9841 uint32_t idx, offset;
9846 if (rte_eth_dev_filter_supported(res->port_id,
9847 RTE_ETH_FILTER_HASH) < 0) {
9848 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9853 memset(&info, 0, sizeof(info));
9854 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9855 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9856 RTE_ETH_FILTER_GET, &info);
9858 printf("Cannot get hash global configurations by port %d\n",
9863 switch (info.info.global_conf.hash_func) {
9864 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9865 printf("Hash function is Toeplitz\n");
9867 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9868 printf("Hash function is Simple XOR\n");
9871 printf("Unknown hash function\n");
9875 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9876 idx = i / UINT32_BIT;
9877 offset = i % UINT32_BIT;
9878 if (!(info.info.global_conf.valid_bit_mask[idx] &
9881 str = flowtype_to_str(i);
9884 printf("Symmetric hash is %s globally for flow type %s "
9886 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9887 (1UL << offset)) ? "enabled" : "disabled"), str,
9892 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9893 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9894 get_hash_global_config, "get_hash_global_config");
9895 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9896 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9899 cmdline_parse_inst_t cmd_get_hash_global_config = {
9900 .f = cmd_get_hash_global_config_parsed,
9902 .help_str = "get_hash_global_config <port_id>",
9904 (void *)&cmd_get_hash_global_config_all,
9905 (void *)&cmd_get_hash_global_config_port_id,
9910 /* Set global config of hash function */
9911 struct cmd_set_hash_global_config_result {
9912 cmdline_fixed_string_t set_hash_global_config;
9914 cmdline_fixed_string_t hash_func;
9915 cmdline_fixed_string_t flow_type;
9916 cmdline_fixed_string_t enable;
9920 cmd_set_hash_global_config_parsed(void *parsed_result,
9921 __rte_unused struct cmdline *cl,
9922 __rte_unused void *data)
9924 struct cmd_set_hash_global_config_result *res = parsed_result;
9925 struct rte_eth_hash_filter_info info;
9926 uint32_t ftype, idx, offset;
9929 if (rte_eth_dev_filter_supported(res->port_id,
9930 RTE_ETH_FILTER_HASH) < 0) {
9931 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9935 memset(&info, 0, sizeof(info));
9936 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9937 if (!strcmp(res->hash_func, "toeplitz"))
9938 info.info.global_conf.hash_func =
9939 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9940 else if (!strcmp(res->hash_func, "simple_xor"))
9941 info.info.global_conf.hash_func =
9942 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9943 else if (!strcmp(res->hash_func, "default"))
9944 info.info.global_conf.hash_func =
9945 RTE_ETH_HASH_FUNCTION_DEFAULT;
9947 ftype = str2flowtype(res->flow_type);
9948 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9949 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9950 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9951 if (!strcmp(res->enable, "enable"))
9952 info.info.global_conf.sym_hash_enable_mask[idx] |=
9954 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9955 RTE_ETH_FILTER_SET, &info);
9957 printf("Cannot set global hash configurations by port %d\n",
9960 printf("Global hash configurations have been set "
9961 "succcessfully by port %d\n", res->port_id);
9964 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9965 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9966 set_hash_global_config, "set_hash_global_config");
9967 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9968 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9970 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9971 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9972 hash_func, "toeplitz#simple_xor#default");
9973 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9974 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9976 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9977 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9978 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9979 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9980 enable, "enable#disable");
9982 cmdline_parse_inst_t cmd_set_hash_global_config = {
9983 .f = cmd_set_hash_global_config_parsed,
9985 .help_str = "set_hash_global_config <port_id> "
9986 "toeplitz|simple_xor|default "
9987 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9988 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9989 "l2_payload enable|disable",
9991 (void *)&cmd_set_hash_global_config_all,
9992 (void *)&cmd_set_hash_global_config_port_id,
9993 (void *)&cmd_set_hash_global_config_hash_func,
9994 (void *)&cmd_set_hash_global_config_flow_type,
9995 (void *)&cmd_set_hash_global_config_enable,
10000 /* Set hash input set */
10001 struct cmd_set_hash_input_set_result {
10002 cmdline_fixed_string_t set_hash_input_set;
10004 cmdline_fixed_string_t flow_type;
10005 cmdline_fixed_string_t inset_field;
10006 cmdline_fixed_string_t select;
10009 static enum rte_eth_input_set_field
10010 str2inset(char *string)
10014 static const struct {
10016 enum rte_eth_input_set_field inset;
10017 } inset_table[] = {
10018 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10019 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10020 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10021 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10022 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10023 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10024 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10025 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10026 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10027 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10028 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10029 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10030 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10031 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10032 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10033 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10034 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10035 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10036 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10037 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10038 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10039 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10040 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10041 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10042 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10043 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10044 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10045 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10046 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10047 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10048 {"none", RTE_ETH_INPUT_SET_NONE},
10051 for (i = 0; i < RTE_DIM(inset_table); i++) {
10052 if (!strcmp(string, inset_table[i].str))
10053 return inset_table[i].inset;
10056 return RTE_ETH_INPUT_SET_UNKNOWN;
10060 cmd_set_hash_input_set_parsed(void *parsed_result,
10061 __rte_unused struct cmdline *cl,
10062 __rte_unused void *data)
10064 struct cmd_set_hash_input_set_result *res = parsed_result;
10065 struct rte_eth_hash_filter_info info;
10067 memset(&info, 0, sizeof(info));
10068 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10069 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10070 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10071 info.info.input_set_conf.inset_size = 1;
10072 if (!strcmp(res->select, "select"))
10073 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10074 else if (!strcmp(res->select, "add"))
10075 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10076 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10077 RTE_ETH_FILTER_SET, &info);
10080 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10081 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10082 set_hash_input_set, "set_hash_input_set");
10083 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10084 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10086 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10087 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10089 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10090 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10091 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10092 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10094 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10095 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10096 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10097 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10098 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10100 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10101 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10102 select, "select#add");
10104 cmdline_parse_inst_t cmd_set_hash_input_set = {
10105 .f = cmd_set_hash_input_set_parsed,
10107 .help_str = "set_hash_input_set <port_id> "
10108 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10109 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10110 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10111 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10112 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10113 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10114 "fld-7th|fld-8th|none select|add",
10116 (void *)&cmd_set_hash_input_set_cmd,
10117 (void *)&cmd_set_hash_input_set_port_id,
10118 (void *)&cmd_set_hash_input_set_flow_type,
10119 (void *)&cmd_set_hash_input_set_field,
10120 (void *)&cmd_set_hash_input_set_select,
10125 /* Set flow director input set */
10126 struct cmd_set_fdir_input_set_result {
10127 cmdline_fixed_string_t set_fdir_input_set;
10129 cmdline_fixed_string_t flow_type;
10130 cmdline_fixed_string_t inset_field;
10131 cmdline_fixed_string_t select;
10135 cmd_set_fdir_input_set_parsed(void *parsed_result,
10136 __rte_unused struct cmdline *cl,
10137 __rte_unused void *data)
10139 struct cmd_set_fdir_input_set_result *res = parsed_result;
10140 struct rte_eth_fdir_filter_info info;
10142 memset(&info, 0, sizeof(info));
10143 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10144 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10145 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10146 info.info.input_set_conf.inset_size = 1;
10147 if (!strcmp(res->select, "select"))
10148 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10149 else if (!strcmp(res->select, "add"))
10150 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10151 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10152 RTE_ETH_FILTER_SET, &info);
10155 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10156 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10157 set_fdir_input_set, "set_fdir_input_set");
10158 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10159 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10161 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10162 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10164 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10165 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10166 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10167 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10169 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10170 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10171 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10172 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10173 "sctp-veri-tag#none");
10174 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10175 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10176 select, "select#add");
10178 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10179 .f = cmd_set_fdir_input_set_parsed,
10181 .help_str = "set_fdir_input_set <port_id> "
10182 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10183 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10184 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10185 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10186 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10187 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10188 "sctp-veri-tag|none select|add",
10190 (void *)&cmd_set_fdir_input_set_cmd,
10191 (void *)&cmd_set_fdir_input_set_port_id,
10192 (void *)&cmd_set_fdir_input_set_flow_type,
10193 (void *)&cmd_set_fdir_input_set_field,
10194 (void *)&cmd_set_fdir_input_set_select,
10199 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10200 struct cmd_mcast_addr_result {
10201 cmdline_fixed_string_t mcast_addr_cmd;
10202 cmdline_fixed_string_t what;
10204 struct ether_addr mc_addr;
10207 static void cmd_mcast_addr_parsed(void *parsed_result,
10208 __attribute__((unused)) struct cmdline *cl,
10209 __attribute__((unused)) void *data)
10211 struct cmd_mcast_addr_result *res = parsed_result;
10213 if (!is_multicast_ether_addr(&res->mc_addr)) {
10214 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10215 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10216 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10217 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10220 if (strcmp(res->what, "add") == 0)
10221 mcast_addr_add(res->port_num, &res->mc_addr);
10223 mcast_addr_remove(res->port_num, &res->mc_addr);
10226 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10227 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10228 mcast_addr_cmd, "mcast_addr");
10229 cmdline_parse_token_string_t cmd_mcast_addr_what =
10230 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10232 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10233 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10234 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10235 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10237 cmdline_parse_inst_t cmd_mcast_addr = {
10238 .f = cmd_mcast_addr_parsed,
10240 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10241 "Add/Remove multicast MAC address on port_id",
10243 (void *)&cmd_mcast_addr_cmd,
10244 (void *)&cmd_mcast_addr_what,
10245 (void *)&cmd_mcast_addr_portnum,
10246 (void *)&cmd_mcast_addr_addr,
10251 /* l2 tunnel config
10252 * only support E-tag now.
10255 /* Ether type config */
10256 struct cmd_config_l2_tunnel_eth_type_result {
10257 cmdline_fixed_string_t port;
10258 cmdline_fixed_string_t config;
10259 cmdline_fixed_string_t all;
10261 cmdline_fixed_string_t l2_tunnel;
10262 cmdline_fixed_string_t l2_tunnel_type;
10263 cmdline_fixed_string_t eth_type;
10264 uint16_t eth_type_val;
10267 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10268 TOKEN_STRING_INITIALIZER
10269 (struct cmd_config_l2_tunnel_eth_type_result,
10271 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10272 TOKEN_STRING_INITIALIZER
10273 (struct cmd_config_l2_tunnel_eth_type_result,
10275 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10276 TOKEN_STRING_INITIALIZER
10277 (struct cmd_config_l2_tunnel_eth_type_result,
10279 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10280 TOKEN_NUM_INITIALIZER
10281 (struct cmd_config_l2_tunnel_eth_type_result,
10283 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10284 TOKEN_STRING_INITIALIZER
10285 (struct cmd_config_l2_tunnel_eth_type_result,
10286 l2_tunnel, "l2-tunnel");
10287 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10288 TOKEN_STRING_INITIALIZER
10289 (struct cmd_config_l2_tunnel_eth_type_result,
10290 l2_tunnel_type, "E-tag");
10291 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10292 TOKEN_STRING_INITIALIZER
10293 (struct cmd_config_l2_tunnel_eth_type_result,
10294 eth_type, "ether-type");
10295 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10296 TOKEN_NUM_INITIALIZER
10297 (struct cmd_config_l2_tunnel_eth_type_result,
10298 eth_type_val, UINT16);
10300 static enum rte_eth_tunnel_type
10301 str2fdir_l2_tunnel_type(char *string)
10305 static const struct {
10307 enum rte_eth_tunnel_type type;
10308 } l2_tunnel_type_str[] = {
10309 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10312 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10313 if (!strcmp(l2_tunnel_type_str[i].str, string))
10314 return l2_tunnel_type_str[i].type;
10316 return RTE_TUNNEL_TYPE_NONE;
10319 /* ether type config for all ports */
10321 cmd_config_l2_tunnel_eth_type_all_parsed
10322 (void *parsed_result,
10323 __attribute__((unused)) struct cmdline *cl,
10324 __attribute__((unused)) void *data)
10326 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10327 struct rte_eth_l2_tunnel_conf entry;
10330 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10331 entry.ether_type = res->eth_type_val;
10333 FOREACH_PORT(pid, ports) {
10334 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10338 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10339 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10341 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10343 (void *)&cmd_config_l2_tunnel_eth_type_port,
10344 (void *)&cmd_config_l2_tunnel_eth_type_config,
10345 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10346 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10347 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10348 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10349 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10354 /* ether type config for a specific port */
10356 cmd_config_l2_tunnel_eth_type_specific_parsed(
10357 void *parsed_result,
10358 __attribute__((unused)) struct cmdline *cl,
10359 __attribute__((unused)) void *data)
10361 struct cmd_config_l2_tunnel_eth_type_result *res =
10363 struct rte_eth_l2_tunnel_conf entry;
10365 if (port_id_is_invalid(res->id, ENABLED_WARN))
10368 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10369 entry.ether_type = res->eth_type_val;
10371 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10374 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10375 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10377 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10379 (void *)&cmd_config_l2_tunnel_eth_type_port,
10380 (void *)&cmd_config_l2_tunnel_eth_type_config,
10381 (void *)&cmd_config_l2_tunnel_eth_type_id,
10382 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10383 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10384 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10385 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10390 /* Enable/disable l2 tunnel */
10391 struct cmd_config_l2_tunnel_en_dis_result {
10392 cmdline_fixed_string_t port;
10393 cmdline_fixed_string_t config;
10394 cmdline_fixed_string_t all;
10396 cmdline_fixed_string_t l2_tunnel;
10397 cmdline_fixed_string_t l2_tunnel_type;
10398 cmdline_fixed_string_t en_dis;
10401 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10402 TOKEN_STRING_INITIALIZER
10403 (struct cmd_config_l2_tunnel_en_dis_result,
10405 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10406 TOKEN_STRING_INITIALIZER
10407 (struct cmd_config_l2_tunnel_en_dis_result,
10409 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10410 TOKEN_STRING_INITIALIZER
10411 (struct cmd_config_l2_tunnel_en_dis_result,
10413 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10414 TOKEN_NUM_INITIALIZER
10415 (struct cmd_config_l2_tunnel_en_dis_result,
10417 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10418 TOKEN_STRING_INITIALIZER
10419 (struct cmd_config_l2_tunnel_en_dis_result,
10420 l2_tunnel, "l2-tunnel");
10421 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10422 TOKEN_STRING_INITIALIZER
10423 (struct cmd_config_l2_tunnel_en_dis_result,
10424 l2_tunnel_type, "E-tag");
10425 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10426 TOKEN_STRING_INITIALIZER
10427 (struct cmd_config_l2_tunnel_en_dis_result,
10428 en_dis, "enable#disable");
10430 /* enable/disable l2 tunnel for all ports */
10432 cmd_config_l2_tunnel_en_dis_all_parsed(
10433 void *parsed_result,
10434 __attribute__((unused)) struct cmdline *cl,
10435 __attribute__((unused)) void *data)
10437 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10438 struct rte_eth_l2_tunnel_conf entry;
10442 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10444 if (!strcmp("enable", res->en_dis))
10449 FOREACH_PORT(pid, ports) {
10450 rte_eth_dev_l2_tunnel_offload_set(pid,
10452 ETH_L2_TUNNEL_ENABLE_MASK,
10457 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10458 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10460 .help_str = "port config all l2-tunnel E-tag enable|disable",
10462 (void *)&cmd_config_l2_tunnel_en_dis_port,
10463 (void *)&cmd_config_l2_tunnel_en_dis_config,
10464 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10465 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10466 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10467 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10472 /* enable/disable l2 tunnel for a port */
10474 cmd_config_l2_tunnel_en_dis_specific_parsed(
10475 void *parsed_result,
10476 __attribute__((unused)) struct cmdline *cl,
10477 __attribute__((unused)) void *data)
10479 struct cmd_config_l2_tunnel_en_dis_result *res =
10481 struct rte_eth_l2_tunnel_conf entry;
10483 if (port_id_is_invalid(res->id, ENABLED_WARN))
10486 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10488 if (!strcmp("enable", res->en_dis))
10489 rte_eth_dev_l2_tunnel_offload_set(res->id,
10491 ETH_L2_TUNNEL_ENABLE_MASK,
10494 rte_eth_dev_l2_tunnel_offload_set(res->id,
10496 ETH_L2_TUNNEL_ENABLE_MASK,
10500 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10501 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10503 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10505 (void *)&cmd_config_l2_tunnel_en_dis_port,
10506 (void *)&cmd_config_l2_tunnel_en_dis_config,
10507 (void *)&cmd_config_l2_tunnel_en_dis_id,
10508 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10509 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10510 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10515 /* E-tag configuration */
10517 /* Common result structure for all E-tag configuration */
10518 struct cmd_config_e_tag_result {
10519 cmdline_fixed_string_t e_tag;
10520 cmdline_fixed_string_t set;
10521 cmdline_fixed_string_t insertion;
10522 cmdline_fixed_string_t stripping;
10523 cmdline_fixed_string_t forwarding;
10524 cmdline_fixed_string_t filter;
10525 cmdline_fixed_string_t add;
10526 cmdline_fixed_string_t del;
10527 cmdline_fixed_string_t on;
10528 cmdline_fixed_string_t off;
10529 cmdline_fixed_string_t on_off;
10530 cmdline_fixed_string_t port_tag_id;
10531 uint32_t port_tag_id_val;
10532 cmdline_fixed_string_t e_tag_id;
10533 uint16_t e_tag_id_val;
10534 cmdline_fixed_string_t dst_pool;
10535 uint8_t dst_pool_val;
10536 cmdline_fixed_string_t port;
10538 cmdline_fixed_string_t vf;
10542 /* Common CLI fields for all E-tag configuration */
10543 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10544 TOKEN_STRING_INITIALIZER
10545 (struct cmd_config_e_tag_result,
10547 cmdline_parse_token_string_t cmd_config_e_tag_set =
10548 TOKEN_STRING_INITIALIZER
10549 (struct cmd_config_e_tag_result,
10551 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10552 TOKEN_STRING_INITIALIZER
10553 (struct cmd_config_e_tag_result,
10554 insertion, "insertion");
10555 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10556 TOKEN_STRING_INITIALIZER
10557 (struct cmd_config_e_tag_result,
10558 stripping, "stripping");
10559 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10560 TOKEN_STRING_INITIALIZER
10561 (struct cmd_config_e_tag_result,
10562 forwarding, "forwarding");
10563 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10564 TOKEN_STRING_INITIALIZER
10565 (struct cmd_config_e_tag_result,
10567 cmdline_parse_token_string_t cmd_config_e_tag_add =
10568 TOKEN_STRING_INITIALIZER
10569 (struct cmd_config_e_tag_result,
10571 cmdline_parse_token_string_t cmd_config_e_tag_del =
10572 TOKEN_STRING_INITIALIZER
10573 (struct cmd_config_e_tag_result,
10575 cmdline_parse_token_string_t cmd_config_e_tag_on =
10576 TOKEN_STRING_INITIALIZER
10577 (struct cmd_config_e_tag_result,
10579 cmdline_parse_token_string_t cmd_config_e_tag_off =
10580 TOKEN_STRING_INITIALIZER
10581 (struct cmd_config_e_tag_result,
10583 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10584 TOKEN_STRING_INITIALIZER
10585 (struct cmd_config_e_tag_result,
10587 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10588 TOKEN_STRING_INITIALIZER
10589 (struct cmd_config_e_tag_result,
10590 port_tag_id, "port-tag-id");
10591 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10592 TOKEN_NUM_INITIALIZER
10593 (struct cmd_config_e_tag_result,
10594 port_tag_id_val, UINT32);
10595 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10596 TOKEN_STRING_INITIALIZER
10597 (struct cmd_config_e_tag_result,
10598 e_tag_id, "e-tag-id");
10599 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10600 TOKEN_NUM_INITIALIZER
10601 (struct cmd_config_e_tag_result,
10602 e_tag_id_val, UINT16);
10603 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10604 TOKEN_STRING_INITIALIZER
10605 (struct cmd_config_e_tag_result,
10606 dst_pool, "dst-pool");
10607 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10608 TOKEN_NUM_INITIALIZER
10609 (struct cmd_config_e_tag_result,
10610 dst_pool_val, UINT8);
10611 cmdline_parse_token_string_t cmd_config_e_tag_port =
10612 TOKEN_STRING_INITIALIZER
10613 (struct cmd_config_e_tag_result,
10615 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10616 TOKEN_NUM_INITIALIZER
10617 (struct cmd_config_e_tag_result,
10619 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10620 TOKEN_STRING_INITIALIZER
10621 (struct cmd_config_e_tag_result,
10623 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10624 TOKEN_NUM_INITIALIZER
10625 (struct cmd_config_e_tag_result,
10628 /* E-tag insertion configuration */
10630 cmd_config_e_tag_insertion_en_parsed(
10631 void *parsed_result,
10632 __attribute__((unused)) struct cmdline *cl,
10633 __attribute__((unused)) void *data)
10635 struct cmd_config_e_tag_result *res =
10637 struct rte_eth_l2_tunnel_conf entry;
10639 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10642 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10643 entry.tunnel_id = res->port_tag_id_val;
10644 entry.vf_id = res->vf_id;
10645 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10647 ETH_L2_TUNNEL_INSERTION_MASK,
10652 cmd_config_e_tag_insertion_dis_parsed(
10653 void *parsed_result,
10654 __attribute__((unused)) struct cmdline *cl,
10655 __attribute__((unused)) void *data)
10657 struct cmd_config_e_tag_result *res =
10659 struct rte_eth_l2_tunnel_conf entry;
10661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10664 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10665 entry.vf_id = res->vf_id;
10667 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10669 ETH_L2_TUNNEL_INSERTION_MASK,
10673 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10674 .f = cmd_config_e_tag_insertion_en_parsed,
10676 .help_str = "E-tag ... : E-tag insertion enable",
10678 (void *)&cmd_config_e_tag_e_tag,
10679 (void *)&cmd_config_e_tag_set,
10680 (void *)&cmd_config_e_tag_insertion,
10681 (void *)&cmd_config_e_tag_on,
10682 (void *)&cmd_config_e_tag_port_tag_id,
10683 (void *)&cmd_config_e_tag_port_tag_id_val,
10684 (void *)&cmd_config_e_tag_port,
10685 (void *)&cmd_config_e_tag_port_id,
10686 (void *)&cmd_config_e_tag_vf,
10687 (void *)&cmd_config_e_tag_vf_id,
10692 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10693 .f = cmd_config_e_tag_insertion_dis_parsed,
10695 .help_str = "E-tag ... : E-tag insertion disable",
10697 (void *)&cmd_config_e_tag_e_tag,
10698 (void *)&cmd_config_e_tag_set,
10699 (void *)&cmd_config_e_tag_insertion,
10700 (void *)&cmd_config_e_tag_off,
10701 (void *)&cmd_config_e_tag_port,
10702 (void *)&cmd_config_e_tag_port_id,
10703 (void *)&cmd_config_e_tag_vf,
10704 (void *)&cmd_config_e_tag_vf_id,
10709 /* E-tag stripping configuration */
10711 cmd_config_e_tag_stripping_parsed(
10712 void *parsed_result,
10713 __attribute__((unused)) struct cmdline *cl,
10714 __attribute__((unused)) void *data)
10716 struct cmd_config_e_tag_result *res =
10718 struct rte_eth_l2_tunnel_conf entry;
10720 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10723 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10725 if (!strcmp(res->on_off, "on"))
10726 rte_eth_dev_l2_tunnel_offload_set
10729 ETH_L2_TUNNEL_STRIPPING_MASK,
10732 rte_eth_dev_l2_tunnel_offload_set
10735 ETH_L2_TUNNEL_STRIPPING_MASK,
10739 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10740 .f = cmd_config_e_tag_stripping_parsed,
10742 .help_str = "E-tag ... : E-tag stripping enable/disable",
10744 (void *)&cmd_config_e_tag_e_tag,
10745 (void *)&cmd_config_e_tag_set,
10746 (void *)&cmd_config_e_tag_stripping,
10747 (void *)&cmd_config_e_tag_on_off,
10748 (void *)&cmd_config_e_tag_port,
10749 (void *)&cmd_config_e_tag_port_id,
10754 /* E-tag forwarding configuration */
10756 cmd_config_e_tag_forwarding_parsed(
10757 void *parsed_result,
10758 __attribute__((unused)) struct cmdline *cl,
10759 __attribute__((unused)) void *data)
10761 struct cmd_config_e_tag_result *res = parsed_result;
10762 struct rte_eth_l2_tunnel_conf entry;
10764 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10767 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10769 if (!strcmp(res->on_off, "on"))
10770 rte_eth_dev_l2_tunnel_offload_set
10773 ETH_L2_TUNNEL_FORWARDING_MASK,
10776 rte_eth_dev_l2_tunnel_offload_set
10779 ETH_L2_TUNNEL_FORWARDING_MASK,
10783 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10784 .f = cmd_config_e_tag_forwarding_parsed,
10786 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10788 (void *)&cmd_config_e_tag_e_tag,
10789 (void *)&cmd_config_e_tag_set,
10790 (void *)&cmd_config_e_tag_forwarding,
10791 (void *)&cmd_config_e_tag_on_off,
10792 (void *)&cmd_config_e_tag_port,
10793 (void *)&cmd_config_e_tag_port_id,
10798 /* E-tag filter configuration */
10800 cmd_config_e_tag_filter_add_parsed(
10801 void *parsed_result,
10802 __attribute__((unused)) struct cmdline *cl,
10803 __attribute__((unused)) void *data)
10805 struct cmd_config_e_tag_result *res = parsed_result;
10806 struct rte_eth_l2_tunnel_conf entry;
10809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10812 if (res->e_tag_id_val > 0x3fff) {
10813 printf("e-tag-id must be equal or less than 0x3fff.\n");
10817 ret = rte_eth_dev_filter_supported(res->port_id,
10818 RTE_ETH_FILTER_L2_TUNNEL);
10820 printf("E-tag filter is not supported on port %u.\n",
10825 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10826 entry.tunnel_id = res->e_tag_id_val;
10827 entry.pool = res->dst_pool_val;
10829 ret = rte_eth_dev_filter_ctrl(res->port_id,
10830 RTE_ETH_FILTER_L2_TUNNEL,
10831 RTE_ETH_FILTER_ADD,
10834 printf("E-tag filter programming error: (%s)\n",
10838 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10839 .f = cmd_config_e_tag_filter_add_parsed,
10841 .help_str = "E-tag ... : E-tag filter add",
10843 (void *)&cmd_config_e_tag_e_tag,
10844 (void *)&cmd_config_e_tag_set,
10845 (void *)&cmd_config_e_tag_filter,
10846 (void *)&cmd_config_e_tag_add,
10847 (void *)&cmd_config_e_tag_e_tag_id,
10848 (void *)&cmd_config_e_tag_e_tag_id_val,
10849 (void *)&cmd_config_e_tag_dst_pool,
10850 (void *)&cmd_config_e_tag_dst_pool_val,
10851 (void *)&cmd_config_e_tag_port,
10852 (void *)&cmd_config_e_tag_port_id,
10858 cmd_config_e_tag_filter_del_parsed(
10859 void *parsed_result,
10860 __attribute__((unused)) struct cmdline *cl,
10861 __attribute__((unused)) void *data)
10863 struct cmd_config_e_tag_result *res = parsed_result;
10864 struct rte_eth_l2_tunnel_conf entry;
10867 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10870 if (res->e_tag_id_val > 0x3fff) {
10871 printf("e-tag-id must be less than 0x3fff.\n");
10875 ret = rte_eth_dev_filter_supported(res->port_id,
10876 RTE_ETH_FILTER_L2_TUNNEL);
10878 printf("E-tag filter is not supported on port %u.\n",
10883 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10884 entry.tunnel_id = res->e_tag_id_val;
10886 ret = rte_eth_dev_filter_ctrl(res->port_id,
10887 RTE_ETH_FILTER_L2_TUNNEL,
10888 RTE_ETH_FILTER_DELETE,
10891 printf("E-tag filter programming error: (%s)\n",
10895 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10896 .f = cmd_config_e_tag_filter_del_parsed,
10898 .help_str = "E-tag ... : E-tag filter delete",
10900 (void *)&cmd_config_e_tag_e_tag,
10901 (void *)&cmd_config_e_tag_set,
10902 (void *)&cmd_config_e_tag_filter,
10903 (void *)&cmd_config_e_tag_del,
10904 (void *)&cmd_config_e_tag_e_tag_id,
10905 (void *)&cmd_config_e_tag_e_tag_id_val,
10906 (void *)&cmd_config_e_tag_port,
10907 (void *)&cmd_config_e_tag_port_id,
10912 /* vf vlan anti spoof configuration */
10914 /* Common result structure for vf vlan anti spoof */
10915 struct cmd_vf_vlan_anti_spoof_result {
10916 cmdline_fixed_string_t set;
10917 cmdline_fixed_string_t vf;
10918 cmdline_fixed_string_t vlan;
10919 cmdline_fixed_string_t antispoof;
10922 cmdline_fixed_string_t on_off;
10925 /* Common CLI fields for vf vlan anti spoof enable disable */
10926 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10927 TOKEN_STRING_INITIALIZER
10928 (struct cmd_vf_vlan_anti_spoof_result,
10930 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10931 TOKEN_STRING_INITIALIZER
10932 (struct cmd_vf_vlan_anti_spoof_result,
10934 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10935 TOKEN_STRING_INITIALIZER
10936 (struct cmd_vf_vlan_anti_spoof_result,
10938 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10939 TOKEN_STRING_INITIALIZER
10940 (struct cmd_vf_vlan_anti_spoof_result,
10941 antispoof, "antispoof");
10942 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10943 TOKEN_NUM_INITIALIZER
10944 (struct cmd_vf_vlan_anti_spoof_result,
10946 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10947 TOKEN_NUM_INITIALIZER
10948 (struct cmd_vf_vlan_anti_spoof_result,
10950 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10951 TOKEN_STRING_INITIALIZER
10952 (struct cmd_vf_vlan_anti_spoof_result,
10956 cmd_set_vf_vlan_anti_spoof_parsed(
10957 void *parsed_result,
10958 __attribute__((unused)) struct cmdline *cl,
10959 __attribute__((unused)) void *data)
10961 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10962 int ret = -ENOTSUP;
10964 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10966 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10969 #ifdef RTE_LIBRTE_IXGBE_PMD
10970 if (ret == -ENOTSUP)
10971 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10972 res->vf_id, is_on);
10974 #ifdef RTE_LIBRTE_I40E_PMD
10975 if (ret == -ENOTSUP)
10976 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10977 res->vf_id, is_on);
10984 printf("invalid vf_id %d\n", res->vf_id);
10987 printf("invalid port_id %d\n", res->port_id);
10990 printf("function not implemented\n");
10993 printf("programming error: (%s)\n", strerror(-ret));
10997 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10998 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11000 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11002 (void *)&cmd_vf_vlan_anti_spoof_set,
11003 (void *)&cmd_vf_vlan_anti_spoof_vf,
11004 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11005 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11006 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11007 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11008 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11013 /* vf mac anti spoof configuration */
11015 /* Common result structure for vf mac anti spoof */
11016 struct cmd_vf_mac_anti_spoof_result {
11017 cmdline_fixed_string_t set;
11018 cmdline_fixed_string_t vf;
11019 cmdline_fixed_string_t mac;
11020 cmdline_fixed_string_t antispoof;
11023 cmdline_fixed_string_t on_off;
11026 /* Common CLI fields for vf mac anti spoof enable disable */
11027 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11028 TOKEN_STRING_INITIALIZER
11029 (struct cmd_vf_mac_anti_spoof_result,
11031 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11032 TOKEN_STRING_INITIALIZER
11033 (struct cmd_vf_mac_anti_spoof_result,
11035 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11036 TOKEN_STRING_INITIALIZER
11037 (struct cmd_vf_mac_anti_spoof_result,
11039 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11040 TOKEN_STRING_INITIALIZER
11041 (struct cmd_vf_mac_anti_spoof_result,
11042 antispoof, "antispoof");
11043 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11044 TOKEN_NUM_INITIALIZER
11045 (struct cmd_vf_mac_anti_spoof_result,
11047 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11048 TOKEN_NUM_INITIALIZER
11049 (struct cmd_vf_mac_anti_spoof_result,
11051 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11052 TOKEN_STRING_INITIALIZER
11053 (struct cmd_vf_mac_anti_spoof_result,
11057 cmd_set_vf_mac_anti_spoof_parsed(
11058 void *parsed_result,
11059 __attribute__((unused)) struct cmdline *cl,
11060 __attribute__((unused)) void *data)
11062 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11063 int ret = -ENOTSUP;
11065 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11067 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11070 #ifdef RTE_LIBRTE_IXGBE_PMD
11071 if (ret == -ENOTSUP)
11072 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11073 res->vf_id, is_on);
11075 #ifdef RTE_LIBRTE_I40E_PMD
11076 if (ret == -ENOTSUP)
11077 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11078 res->vf_id, is_on);
11085 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11088 printf("invalid port_id %d\n", res->port_id);
11091 printf("function not implemented\n");
11094 printf("programming error: (%s)\n", strerror(-ret));
11098 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11099 .f = cmd_set_vf_mac_anti_spoof_parsed,
11101 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11103 (void *)&cmd_vf_mac_anti_spoof_set,
11104 (void *)&cmd_vf_mac_anti_spoof_vf,
11105 (void *)&cmd_vf_mac_anti_spoof_mac,
11106 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11107 (void *)&cmd_vf_mac_anti_spoof_port_id,
11108 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11109 (void *)&cmd_vf_mac_anti_spoof_on_off,
11114 /* vf vlan strip queue configuration */
11116 /* Common result structure for vf mac anti spoof */
11117 struct cmd_vf_vlan_stripq_result {
11118 cmdline_fixed_string_t set;
11119 cmdline_fixed_string_t vf;
11120 cmdline_fixed_string_t vlan;
11121 cmdline_fixed_string_t stripq;
11124 cmdline_fixed_string_t on_off;
11127 /* Common CLI fields for vf vlan strip enable disable */
11128 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11129 TOKEN_STRING_INITIALIZER
11130 (struct cmd_vf_vlan_stripq_result,
11132 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11133 TOKEN_STRING_INITIALIZER
11134 (struct cmd_vf_vlan_stripq_result,
11136 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11137 TOKEN_STRING_INITIALIZER
11138 (struct cmd_vf_vlan_stripq_result,
11140 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11141 TOKEN_STRING_INITIALIZER
11142 (struct cmd_vf_vlan_stripq_result,
11144 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11145 TOKEN_NUM_INITIALIZER
11146 (struct cmd_vf_vlan_stripq_result,
11148 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11149 TOKEN_NUM_INITIALIZER
11150 (struct cmd_vf_vlan_stripq_result,
11152 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11153 TOKEN_STRING_INITIALIZER
11154 (struct cmd_vf_vlan_stripq_result,
11158 cmd_set_vf_vlan_stripq_parsed(
11159 void *parsed_result,
11160 __attribute__((unused)) struct cmdline *cl,
11161 __attribute__((unused)) void *data)
11163 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11164 int ret = -ENOTSUP;
11166 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11168 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11171 #ifdef RTE_LIBRTE_IXGBE_PMD
11172 if (ret == -ENOTSUP)
11173 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11174 res->vf_id, is_on);
11176 #ifdef RTE_LIBRTE_I40E_PMD
11177 if (ret == -ENOTSUP)
11178 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11179 res->vf_id, is_on);
11186 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11189 printf("invalid port_id %d\n", res->port_id);
11192 printf("function not implemented\n");
11195 printf("programming error: (%s)\n", strerror(-ret));
11199 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11200 .f = cmd_set_vf_vlan_stripq_parsed,
11202 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11204 (void *)&cmd_vf_vlan_stripq_set,
11205 (void *)&cmd_vf_vlan_stripq_vf,
11206 (void *)&cmd_vf_vlan_stripq_vlan,
11207 (void *)&cmd_vf_vlan_stripq_stripq,
11208 (void *)&cmd_vf_vlan_stripq_port_id,
11209 (void *)&cmd_vf_vlan_stripq_vf_id,
11210 (void *)&cmd_vf_vlan_stripq_on_off,
11215 /* vf vlan insert configuration */
11217 /* Common result structure for vf vlan insert */
11218 struct cmd_vf_vlan_insert_result {
11219 cmdline_fixed_string_t set;
11220 cmdline_fixed_string_t vf;
11221 cmdline_fixed_string_t vlan;
11222 cmdline_fixed_string_t insert;
11228 /* Common CLI fields for vf vlan insert enable disable */
11229 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11230 TOKEN_STRING_INITIALIZER
11231 (struct cmd_vf_vlan_insert_result,
11233 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11234 TOKEN_STRING_INITIALIZER
11235 (struct cmd_vf_vlan_insert_result,
11237 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11238 TOKEN_STRING_INITIALIZER
11239 (struct cmd_vf_vlan_insert_result,
11241 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11242 TOKEN_STRING_INITIALIZER
11243 (struct cmd_vf_vlan_insert_result,
11245 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11246 TOKEN_NUM_INITIALIZER
11247 (struct cmd_vf_vlan_insert_result,
11249 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11250 TOKEN_NUM_INITIALIZER
11251 (struct cmd_vf_vlan_insert_result,
11253 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11254 TOKEN_NUM_INITIALIZER
11255 (struct cmd_vf_vlan_insert_result,
11259 cmd_set_vf_vlan_insert_parsed(
11260 void *parsed_result,
11261 __attribute__((unused)) struct cmdline *cl,
11262 __attribute__((unused)) void *data)
11264 struct cmd_vf_vlan_insert_result *res = parsed_result;
11265 int ret = -ENOTSUP;
11267 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11270 #ifdef RTE_LIBRTE_IXGBE_PMD
11271 if (ret == -ENOTSUP)
11272 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11275 #ifdef RTE_LIBRTE_I40E_PMD
11276 if (ret == -ENOTSUP)
11277 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11285 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11288 printf("invalid port_id %d\n", res->port_id);
11291 printf("function not implemented\n");
11294 printf("programming error: (%s)\n", strerror(-ret));
11298 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11299 .f = cmd_set_vf_vlan_insert_parsed,
11301 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11303 (void *)&cmd_vf_vlan_insert_set,
11304 (void *)&cmd_vf_vlan_insert_vf,
11305 (void *)&cmd_vf_vlan_insert_vlan,
11306 (void *)&cmd_vf_vlan_insert_insert,
11307 (void *)&cmd_vf_vlan_insert_port_id,
11308 (void *)&cmd_vf_vlan_insert_vf_id,
11309 (void *)&cmd_vf_vlan_insert_vlan_id,
11314 /* tx loopback configuration */
11316 /* Common result structure for tx loopback */
11317 struct cmd_tx_loopback_result {
11318 cmdline_fixed_string_t set;
11319 cmdline_fixed_string_t tx;
11320 cmdline_fixed_string_t loopback;
11322 cmdline_fixed_string_t on_off;
11325 /* Common CLI fields for tx loopback enable disable */
11326 cmdline_parse_token_string_t cmd_tx_loopback_set =
11327 TOKEN_STRING_INITIALIZER
11328 (struct cmd_tx_loopback_result,
11330 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11331 TOKEN_STRING_INITIALIZER
11332 (struct cmd_tx_loopback_result,
11334 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11335 TOKEN_STRING_INITIALIZER
11336 (struct cmd_tx_loopback_result,
11337 loopback, "loopback");
11338 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11339 TOKEN_NUM_INITIALIZER
11340 (struct cmd_tx_loopback_result,
11342 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11343 TOKEN_STRING_INITIALIZER
11344 (struct cmd_tx_loopback_result,
11348 cmd_set_tx_loopback_parsed(
11349 void *parsed_result,
11350 __attribute__((unused)) struct cmdline *cl,
11351 __attribute__((unused)) void *data)
11353 struct cmd_tx_loopback_result *res = parsed_result;
11354 int ret = -ENOTSUP;
11356 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11358 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11361 #ifdef RTE_LIBRTE_IXGBE_PMD
11362 if (ret == -ENOTSUP)
11363 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11365 #ifdef RTE_LIBRTE_I40E_PMD
11366 if (ret == -ENOTSUP)
11367 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11374 printf("invalid is_on %d\n", is_on);
11377 printf("invalid port_id %d\n", res->port_id);
11380 printf("function not implemented\n");
11383 printf("programming error: (%s)\n", strerror(-ret));
11387 cmdline_parse_inst_t cmd_set_tx_loopback = {
11388 .f = cmd_set_tx_loopback_parsed,
11390 .help_str = "set tx loopback <port_id> on|off",
11392 (void *)&cmd_tx_loopback_set,
11393 (void *)&cmd_tx_loopback_tx,
11394 (void *)&cmd_tx_loopback_loopback,
11395 (void *)&cmd_tx_loopback_port_id,
11396 (void *)&cmd_tx_loopback_on_off,
11401 #ifdef RTE_LIBRTE_IXGBE_PMD
11402 /* all queues drop enable configuration */
11404 /* Common result structure for all queues drop enable */
11405 struct cmd_all_queues_drop_en_result {
11406 cmdline_fixed_string_t set;
11407 cmdline_fixed_string_t all;
11408 cmdline_fixed_string_t queues;
11409 cmdline_fixed_string_t drop;
11411 cmdline_fixed_string_t on_off;
11414 /* Common CLI fields for tx loopback enable disable */
11415 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11416 TOKEN_STRING_INITIALIZER
11417 (struct cmd_all_queues_drop_en_result,
11419 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11420 TOKEN_STRING_INITIALIZER
11421 (struct cmd_all_queues_drop_en_result,
11423 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11424 TOKEN_STRING_INITIALIZER
11425 (struct cmd_all_queues_drop_en_result,
11427 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11428 TOKEN_STRING_INITIALIZER
11429 (struct cmd_all_queues_drop_en_result,
11431 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11432 TOKEN_NUM_INITIALIZER
11433 (struct cmd_all_queues_drop_en_result,
11435 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11436 TOKEN_STRING_INITIALIZER
11437 (struct cmd_all_queues_drop_en_result,
11441 cmd_set_all_queues_drop_en_parsed(
11442 void *parsed_result,
11443 __attribute__((unused)) struct cmdline *cl,
11444 __attribute__((unused)) void *data)
11446 struct cmd_all_queues_drop_en_result *res = parsed_result;
11448 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11453 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11458 printf("invalid is_on %d\n", is_on);
11461 printf("invalid port_id %d\n", res->port_id);
11464 printf("function not implemented\n");
11467 printf("programming error: (%s)\n", strerror(-ret));
11471 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11472 .f = cmd_set_all_queues_drop_en_parsed,
11474 .help_str = "set all queues drop <port_id> on|off",
11476 (void *)&cmd_all_queues_drop_en_set,
11477 (void *)&cmd_all_queues_drop_en_all,
11478 (void *)&cmd_all_queues_drop_en_queues,
11479 (void *)&cmd_all_queues_drop_en_drop,
11480 (void *)&cmd_all_queues_drop_en_port_id,
11481 (void *)&cmd_all_queues_drop_en_on_off,
11486 /* vf split drop enable configuration */
11488 /* Common result structure for vf split drop enable */
11489 struct cmd_vf_split_drop_en_result {
11490 cmdline_fixed_string_t set;
11491 cmdline_fixed_string_t vf;
11492 cmdline_fixed_string_t split;
11493 cmdline_fixed_string_t drop;
11496 cmdline_fixed_string_t on_off;
11499 /* Common CLI fields for vf split drop enable disable */
11500 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11501 TOKEN_STRING_INITIALIZER
11502 (struct cmd_vf_split_drop_en_result,
11504 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11505 TOKEN_STRING_INITIALIZER
11506 (struct cmd_vf_split_drop_en_result,
11508 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11509 TOKEN_STRING_INITIALIZER
11510 (struct cmd_vf_split_drop_en_result,
11512 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11513 TOKEN_STRING_INITIALIZER
11514 (struct cmd_vf_split_drop_en_result,
11516 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11517 TOKEN_NUM_INITIALIZER
11518 (struct cmd_vf_split_drop_en_result,
11520 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11521 TOKEN_NUM_INITIALIZER
11522 (struct cmd_vf_split_drop_en_result,
11524 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11525 TOKEN_STRING_INITIALIZER
11526 (struct cmd_vf_split_drop_en_result,
11530 cmd_set_vf_split_drop_en_parsed(
11531 void *parsed_result,
11532 __attribute__((unused)) struct cmdline *cl,
11533 __attribute__((unused)) void *data)
11535 struct cmd_vf_split_drop_en_result *res = parsed_result;
11537 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11539 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11542 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11548 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11551 printf("invalid port_id %d\n", res->port_id);
11554 printf("programming error: (%s)\n", strerror(-ret));
11558 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11559 .f = cmd_set_vf_split_drop_en_parsed,
11561 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11563 (void *)&cmd_vf_split_drop_en_set,
11564 (void *)&cmd_vf_split_drop_en_vf,
11565 (void *)&cmd_vf_split_drop_en_split,
11566 (void *)&cmd_vf_split_drop_en_drop,
11567 (void *)&cmd_vf_split_drop_en_port_id,
11568 (void *)&cmd_vf_split_drop_en_vf_id,
11569 (void *)&cmd_vf_split_drop_en_on_off,
11575 /* vf mac address configuration */
11577 /* Common result structure for vf mac address */
11578 struct cmd_set_vf_mac_addr_result {
11579 cmdline_fixed_string_t set;
11580 cmdline_fixed_string_t vf;
11581 cmdline_fixed_string_t mac;
11582 cmdline_fixed_string_t addr;
11585 struct ether_addr mac_addr;
11589 /* Common CLI fields for vf split drop enable disable */
11590 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11591 TOKEN_STRING_INITIALIZER
11592 (struct cmd_set_vf_mac_addr_result,
11594 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11595 TOKEN_STRING_INITIALIZER
11596 (struct cmd_set_vf_mac_addr_result,
11598 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11599 TOKEN_STRING_INITIALIZER
11600 (struct cmd_set_vf_mac_addr_result,
11602 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11603 TOKEN_STRING_INITIALIZER
11604 (struct cmd_set_vf_mac_addr_result,
11606 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11607 TOKEN_NUM_INITIALIZER
11608 (struct cmd_set_vf_mac_addr_result,
11610 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11611 TOKEN_NUM_INITIALIZER
11612 (struct cmd_set_vf_mac_addr_result,
11614 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11615 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11619 cmd_set_vf_mac_addr_parsed(
11620 void *parsed_result,
11621 __attribute__((unused)) struct cmdline *cl,
11622 __attribute__((unused)) void *data)
11624 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11625 int ret = -ENOTSUP;
11627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11630 #ifdef RTE_LIBRTE_IXGBE_PMD
11631 if (ret == -ENOTSUP)
11632 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11635 #ifdef RTE_LIBRTE_I40E_PMD
11636 if (ret == -ENOTSUP)
11637 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11645 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11648 printf("invalid port_id %d\n", res->port_id);
11651 printf("function not implemented\n");
11654 printf("programming error: (%s)\n", strerror(-ret));
11658 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11659 .f = cmd_set_vf_mac_addr_parsed,
11661 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11663 (void *)&cmd_set_vf_mac_addr_set,
11664 (void *)&cmd_set_vf_mac_addr_vf,
11665 (void *)&cmd_set_vf_mac_addr_mac,
11666 (void *)&cmd_set_vf_mac_addr_addr,
11667 (void *)&cmd_set_vf_mac_addr_port_id,
11668 (void *)&cmd_set_vf_mac_addr_vf_id,
11669 (void *)&cmd_set_vf_mac_addr_mac_addr,
11674 #ifdef RTE_LIBRTE_IXGBE_PMD
11675 /* MACsec configuration */
11677 /* Common result structure for MACsec offload enable */
11678 struct cmd_macsec_offload_on_result {
11679 cmdline_fixed_string_t set;
11680 cmdline_fixed_string_t macsec;
11681 cmdline_fixed_string_t offload;
11683 cmdline_fixed_string_t on;
11684 cmdline_fixed_string_t encrypt;
11685 cmdline_fixed_string_t en_on_off;
11686 cmdline_fixed_string_t replay_protect;
11687 cmdline_fixed_string_t rp_on_off;
11690 /* Common CLI fields for MACsec offload disable */
11691 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11692 TOKEN_STRING_INITIALIZER
11693 (struct cmd_macsec_offload_on_result,
11695 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11696 TOKEN_STRING_INITIALIZER
11697 (struct cmd_macsec_offload_on_result,
11699 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11700 TOKEN_STRING_INITIALIZER
11701 (struct cmd_macsec_offload_on_result,
11702 offload, "offload");
11703 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11704 TOKEN_NUM_INITIALIZER
11705 (struct cmd_macsec_offload_on_result,
11707 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11708 TOKEN_STRING_INITIALIZER
11709 (struct cmd_macsec_offload_on_result,
11711 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11712 TOKEN_STRING_INITIALIZER
11713 (struct cmd_macsec_offload_on_result,
11714 encrypt, "encrypt");
11715 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_macsec_offload_on_result,
11718 en_on_off, "on#off");
11719 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11720 TOKEN_STRING_INITIALIZER
11721 (struct cmd_macsec_offload_on_result,
11722 replay_protect, "replay-protect");
11723 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11724 TOKEN_STRING_INITIALIZER
11725 (struct cmd_macsec_offload_on_result,
11726 rp_on_off, "on#off");
11729 cmd_set_macsec_offload_on_parsed(
11730 void *parsed_result,
11731 __attribute__((unused)) struct cmdline *cl,
11732 __attribute__((unused)) void *data)
11734 struct cmd_macsec_offload_on_result *res = parsed_result;
11736 portid_t port_id = res->port_id;
11737 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11738 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11740 if (port_id_is_invalid(port_id, ENABLED_WARN))
11743 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11744 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11750 printf("invalid port_id %d\n", port_id);
11753 printf("programming error: (%s)\n", strerror(-ret));
11757 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11758 .f = cmd_set_macsec_offload_on_parsed,
11760 .help_str = "set macsec offload <port_id> on "
11761 "encrypt on|off replay-protect on|off",
11763 (void *)&cmd_macsec_offload_on_set,
11764 (void *)&cmd_macsec_offload_on_macsec,
11765 (void *)&cmd_macsec_offload_on_offload,
11766 (void *)&cmd_macsec_offload_on_port_id,
11767 (void *)&cmd_macsec_offload_on_on,
11768 (void *)&cmd_macsec_offload_on_encrypt,
11769 (void *)&cmd_macsec_offload_on_en_on_off,
11770 (void *)&cmd_macsec_offload_on_replay_protect,
11771 (void *)&cmd_macsec_offload_on_rp_on_off,
11776 /* Common result structure for MACsec offload disable */
11777 struct cmd_macsec_offload_off_result {
11778 cmdline_fixed_string_t set;
11779 cmdline_fixed_string_t macsec;
11780 cmdline_fixed_string_t offload;
11782 cmdline_fixed_string_t off;
11785 /* Common CLI fields for MACsec offload disable */
11786 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11787 TOKEN_STRING_INITIALIZER
11788 (struct cmd_macsec_offload_off_result,
11790 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11791 TOKEN_STRING_INITIALIZER
11792 (struct cmd_macsec_offload_off_result,
11794 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11795 TOKEN_STRING_INITIALIZER
11796 (struct cmd_macsec_offload_off_result,
11797 offload, "offload");
11798 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11799 TOKEN_NUM_INITIALIZER
11800 (struct cmd_macsec_offload_off_result,
11802 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11803 TOKEN_STRING_INITIALIZER
11804 (struct cmd_macsec_offload_off_result,
11808 cmd_set_macsec_offload_off_parsed(
11809 void *parsed_result,
11810 __attribute__((unused)) struct cmdline *cl,
11811 __attribute__((unused)) void *data)
11813 struct cmd_macsec_offload_off_result *res = parsed_result;
11815 portid_t port_id = res->port_id;
11817 if (port_id_is_invalid(port_id, ENABLED_WARN))
11820 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11821 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11827 printf("invalid port_id %d\n", port_id);
11830 printf("programming error: (%s)\n", strerror(-ret));
11834 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11835 .f = cmd_set_macsec_offload_off_parsed,
11837 .help_str = "set macsec offload <port_id> off",
11839 (void *)&cmd_macsec_offload_off_set,
11840 (void *)&cmd_macsec_offload_off_macsec,
11841 (void *)&cmd_macsec_offload_off_offload,
11842 (void *)&cmd_macsec_offload_off_port_id,
11843 (void *)&cmd_macsec_offload_off_off,
11848 /* Common result structure for MACsec secure connection configure */
11849 struct cmd_macsec_sc_result {
11850 cmdline_fixed_string_t set;
11851 cmdline_fixed_string_t macsec;
11852 cmdline_fixed_string_t sc;
11853 cmdline_fixed_string_t tx_rx;
11855 struct ether_addr mac;
11859 /* Common CLI fields for MACsec secure connection configure */
11860 cmdline_parse_token_string_t cmd_macsec_sc_set =
11861 TOKEN_STRING_INITIALIZER
11862 (struct cmd_macsec_sc_result,
11864 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11865 TOKEN_STRING_INITIALIZER
11866 (struct cmd_macsec_sc_result,
11868 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11869 TOKEN_STRING_INITIALIZER
11870 (struct cmd_macsec_sc_result,
11872 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11873 TOKEN_STRING_INITIALIZER
11874 (struct cmd_macsec_sc_result,
11876 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11877 TOKEN_NUM_INITIALIZER
11878 (struct cmd_macsec_sc_result,
11880 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11881 TOKEN_ETHERADDR_INITIALIZER
11882 (struct cmd_macsec_sc_result,
11884 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11885 TOKEN_NUM_INITIALIZER
11886 (struct cmd_macsec_sc_result,
11890 cmd_set_macsec_sc_parsed(
11891 void *parsed_result,
11892 __attribute__((unused)) struct cmdline *cl,
11893 __attribute__((unused)) void *data)
11895 struct cmd_macsec_sc_result *res = parsed_result;
11897 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11900 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11901 res->mac.addr_bytes) :
11902 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11903 res->mac.addr_bytes, res->pi);
11908 printf("invalid port_id %d\n", res->port_id);
11911 printf("programming error: (%s)\n", strerror(-ret));
11915 cmdline_parse_inst_t cmd_set_macsec_sc = {
11916 .f = cmd_set_macsec_sc_parsed,
11918 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11920 (void *)&cmd_macsec_sc_set,
11921 (void *)&cmd_macsec_sc_macsec,
11922 (void *)&cmd_macsec_sc_sc,
11923 (void *)&cmd_macsec_sc_tx_rx,
11924 (void *)&cmd_macsec_sc_port_id,
11925 (void *)&cmd_macsec_sc_mac,
11926 (void *)&cmd_macsec_sc_pi,
11931 /* Common result structure for MACsec secure connection configure */
11932 struct cmd_macsec_sa_result {
11933 cmdline_fixed_string_t set;
11934 cmdline_fixed_string_t macsec;
11935 cmdline_fixed_string_t sa;
11936 cmdline_fixed_string_t tx_rx;
11941 cmdline_fixed_string_t key;
11944 /* Common CLI fields for MACsec secure connection configure */
11945 cmdline_parse_token_string_t cmd_macsec_sa_set =
11946 TOKEN_STRING_INITIALIZER
11947 (struct cmd_macsec_sa_result,
11949 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11950 TOKEN_STRING_INITIALIZER
11951 (struct cmd_macsec_sa_result,
11953 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11954 TOKEN_STRING_INITIALIZER
11955 (struct cmd_macsec_sa_result,
11957 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11958 TOKEN_STRING_INITIALIZER
11959 (struct cmd_macsec_sa_result,
11961 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11962 TOKEN_NUM_INITIALIZER
11963 (struct cmd_macsec_sa_result,
11965 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11966 TOKEN_NUM_INITIALIZER
11967 (struct cmd_macsec_sa_result,
11969 cmdline_parse_token_num_t cmd_macsec_sa_an =
11970 TOKEN_NUM_INITIALIZER
11971 (struct cmd_macsec_sa_result,
11973 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11974 TOKEN_NUM_INITIALIZER
11975 (struct cmd_macsec_sa_result,
11977 cmdline_parse_token_string_t cmd_macsec_sa_key =
11978 TOKEN_STRING_INITIALIZER
11979 (struct cmd_macsec_sa_result,
11983 cmd_set_macsec_sa_parsed(
11984 void *parsed_result,
11985 __attribute__((unused)) struct cmdline *cl,
11986 __attribute__((unused)) void *data)
11988 struct cmd_macsec_sa_result *res = parsed_result;
11990 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11991 uint8_t key[16] = { 0 };
11997 key_len = strlen(res->key) / 2;
12001 for (i = 0; i < key_len; i++) {
12002 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12005 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12008 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12012 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12013 res->idx, res->an, res->pn, key) :
12014 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12015 res->idx, res->an, res->pn, key);
12020 printf("invalid idx %d or an %d\n", res->idx, res->an);
12023 printf("invalid port_id %d\n", res->port_id);
12026 printf("programming error: (%s)\n", strerror(-ret));
12030 cmdline_parse_inst_t cmd_set_macsec_sa = {
12031 .f = cmd_set_macsec_sa_parsed,
12033 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12035 (void *)&cmd_macsec_sa_set,
12036 (void *)&cmd_macsec_sa_macsec,
12037 (void *)&cmd_macsec_sa_sa,
12038 (void *)&cmd_macsec_sa_tx_rx,
12039 (void *)&cmd_macsec_sa_port_id,
12040 (void *)&cmd_macsec_sa_idx,
12041 (void *)&cmd_macsec_sa_an,
12042 (void *)&cmd_macsec_sa_pn,
12043 (void *)&cmd_macsec_sa_key,
12049 /* VF unicast promiscuous mode configuration */
12051 /* Common result structure for VF unicast promiscuous mode */
12052 struct cmd_vf_promisc_result {
12053 cmdline_fixed_string_t set;
12054 cmdline_fixed_string_t vf;
12055 cmdline_fixed_string_t promisc;
12058 cmdline_fixed_string_t on_off;
12061 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12062 cmdline_parse_token_string_t cmd_vf_promisc_set =
12063 TOKEN_STRING_INITIALIZER
12064 (struct cmd_vf_promisc_result,
12066 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12067 TOKEN_STRING_INITIALIZER
12068 (struct cmd_vf_promisc_result,
12070 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12071 TOKEN_STRING_INITIALIZER
12072 (struct cmd_vf_promisc_result,
12073 promisc, "promisc");
12074 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12075 TOKEN_NUM_INITIALIZER
12076 (struct cmd_vf_promisc_result,
12078 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12079 TOKEN_NUM_INITIALIZER
12080 (struct cmd_vf_promisc_result,
12082 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12083 TOKEN_STRING_INITIALIZER
12084 (struct cmd_vf_promisc_result,
12088 cmd_set_vf_promisc_parsed(
12089 void *parsed_result,
12090 __attribute__((unused)) struct cmdline *cl,
12091 __attribute__((unused)) void *data)
12093 struct cmd_vf_promisc_result *res = parsed_result;
12094 int ret = -ENOTSUP;
12096 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12098 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12101 #ifdef RTE_LIBRTE_I40E_PMD
12102 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12103 res->vf_id, is_on);
12110 printf("invalid vf_id %d\n", res->vf_id);
12113 printf("invalid port_id %d\n", res->port_id);
12116 printf("function not implemented\n");
12119 printf("programming error: (%s)\n", strerror(-ret));
12123 cmdline_parse_inst_t cmd_set_vf_promisc = {
12124 .f = cmd_set_vf_promisc_parsed,
12126 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12127 "Set unicast promiscuous mode for a VF from the PF",
12129 (void *)&cmd_vf_promisc_set,
12130 (void *)&cmd_vf_promisc_vf,
12131 (void *)&cmd_vf_promisc_promisc,
12132 (void *)&cmd_vf_promisc_port_id,
12133 (void *)&cmd_vf_promisc_vf_id,
12134 (void *)&cmd_vf_promisc_on_off,
12139 /* VF multicast promiscuous mode configuration */
12141 /* Common result structure for VF multicast promiscuous mode */
12142 struct cmd_vf_allmulti_result {
12143 cmdline_fixed_string_t set;
12144 cmdline_fixed_string_t vf;
12145 cmdline_fixed_string_t allmulti;
12148 cmdline_fixed_string_t on_off;
12151 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12152 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12153 TOKEN_STRING_INITIALIZER
12154 (struct cmd_vf_allmulti_result,
12156 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12157 TOKEN_STRING_INITIALIZER
12158 (struct cmd_vf_allmulti_result,
12160 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12161 TOKEN_STRING_INITIALIZER
12162 (struct cmd_vf_allmulti_result,
12163 allmulti, "allmulti");
12164 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12165 TOKEN_NUM_INITIALIZER
12166 (struct cmd_vf_allmulti_result,
12168 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12169 TOKEN_NUM_INITIALIZER
12170 (struct cmd_vf_allmulti_result,
12172 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12173 TOKEN_STRING_INITIALIZER
12174 (struct cmd_vf_allmulti_result,
12178 cmd_set_vf_allmulti_parsed(
12179 void *parsed_result,
12180 __attribute__((unused)) struct cmdline *cl,
12181 __attribute__((unused)) void *data)
12183 struct cmd_vf_allmulti_result *res = parsed_result;
12184 int ret = -ENOTSUP;
12186 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12188 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12191 #ifdef RTE_LIBRTE_I40E_PMD
12192 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12193 res->vf_id, is_on);
12200 printf("invalid vf_id %d\n", res->vf_id);
12203 printf("invalid port_id %d\n", res->port_id);
12206 printf("function not implemented\n");
12209 printf("programming error: (%s)\n", strerror(-ret));
12213 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12214 .f = cmd_set_vf_allmulti_parsed,
12216 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12217 "Set multicast promiscuous mode for a VF from the PF",
12219 (void *)&cmd_vf_allmulti_set,
12220 (void *)&cmd_vf_allmulti_vf,
12221 (void *)&cmd_vf_allmulti_allmulti,
12222 (void *)&cmd_vf_allmulti_port_id,
12223 (void *)&cmd_vf_allmulti_vf_id,
12224 (void *)&cmd_vf_allmulti_on_off,
12229 /* vf broadcast mode configuration */
12231 /* Common result structure for vf broadcast */
12232 struct cmd_set_vf_broadcast_result {
12233 cmdline_fixed_string_t set;
12234 cmdline_fixed_string_t vf;
12235 cmdline_fixed_string_t broadcast;
12238 cmdline_fixed_string_t on_off;
12241 /* Common CLI fields for vf broadcast enable disable */
12242 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12243 TOKEN_STRING_INITIALIZER
12244 (struct cmd_set_vf_broadcast_result,
12246 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12247 TOKEN_STRING_INITIALIZER
12248 (struct cmd_set_vf_broadcast_result,
12250 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12251 TOKEN_STRING_INITIALIZER
12252 (struct cmd_set_vf_broadcast_result,
12253 broadcast, "broadcast");
12254 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12255 TOKEN_NUM_INITIALIZER
12256 (struct cmd_set_vf_broadcast_result,
12258 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12259 TOKEN_NUM_INITIALIZER
12260 (struct cmd_set_vf_broadcast_result,
12262 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12263 TOKEN_STRING_INITIALIZER
12264 (struct cmd_set_vf_broadcast_result,
12268 cmd_set_vf_broadcast_parsed(
12269 void *parsed_result,
12270 __attribute__((unused)) struct cmdline *cl,
12271 __attribute__((unused)) void *data)
12273 struct cmd_set_vf_broadcast_result *res = parsed_result;
12274 int ret = -ENOTSUP;
12276 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12278 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12281 #ifdef RTE_LIBRTE_I40E_PMD
12282 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12283 res->vf_id, is_on);
12290 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12293 printf("invalid port_id %d\n", res->port_id);
12296 printf("function not implemented\n");
12299 printf("programming error: (%s)\n", strerror(-ret));
12303 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12304 .f = cmd_set_vf_broadcast_parsed,
12306 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12308 (void *)&cmd_set_vf_broadcast_set,
12309 (void *)&cmd_set_vf_broadcast_vf,
12310 (void *)&cmd_set_vf_broadcast_broadcast,
12311 (void *)&cmd_set_vf_broadcast_port_id,
12312 (void *)&cmd_set_vf_broadcast_vf_id,
12313 (void *)&cmd_set_vf_broadcast_on_off,
12318 /* vf vlan tag configuration */
12320 /* Common result structure for vf vlan tag */
12321 struct cmd_set_vf_vlan_tag_result {
12322 cmdline_fixed_string_t set;
12323 cmdline_fixed_string_t vf;
12324 cmdline_fixed_string_t vlan;
12325 cmdline_fixed_string_t tag;
12328 cmdline_fixed_string_t on_off;
12331 /* Common CLI fields for vf vlan tag enable disable */
12332 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12333 TOKEN_STRING_INITIALIZER
12334 (struct cmd_set_vf_vlan_tag_result,
12336 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12337 TOKEN_STRING_INITIALIZER
12338 (struct cmd_set_vf_vlan_tag_result,
12340 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12341 TOKEN_STRING_INITIALIZER
12342 (struct cmd_set_vf_vlan_tag_result,
12344 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12345 TOKEN_STRING_INITIALIZER
12346 (struct cmd_set_vf_vlan_tag_result,
12348 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12349 TOKEN_NUM_INITIALIZER
12350 (struct cmd_set_vf_vlan_tag_result,
12352 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12353 TOKEN_NUM_INITIALIZER
12354 (struct cmd_set_vf_vlan_tag_result,
12356 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12357 TOKEN_STRING_INITIALIZER
12358 (struct cmd_set_vf_vlan_tag_result,
12362 cmd_set_vf_vlan_tag_parsed(
12363 void *parsed_result,
12364 __attribute__((unused)) struct cmdline *cl,
12365 __attribute__((unused)) void *data)
12367 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12368 int ret = -ENOTSUP;
12370 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12372 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12375 #ifdef RTE_LIBRTE_I40E_PMD
12376 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12377 res->vf_id, is_on);
12384 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12387 printf("invalid port_id %d\n", res->port_id);
12390 printf("function not implemented\n");
12393 printf("programming error: (%s)\n", strerror(-ret));
12397 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12398 .f = cmd_set_vf_vlan_tag_parsed,
12400 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12402 (void *)&cmd_set_vf_vlan_tag_set,
12403 (void *)&cmd_set_vf_vlan_tag_vf,
12404 (void *)&cmd_set_vf_vlan_tag_vlan,
12405 (void *)&cmd_set_vf_vlan_tag_tag,
12406 (void *)&cmd_set_vf_vlan_tag_port_id,
12407 (void *)&cmd_set_vf_vlan_tag_vf_id,
12408 (void *)&cmd_set_vf_vlan_tag_on_off,
12413 /* Common definition of VF and TC TX bandwidth configuration */
12414 struct cmd_vf_tc_bw_result {
12415 cmdline_fixed_string_t set;
12416 cmdline_fixed_string_t vf;
12417 cmdline_fixed_string_t tc;
12418 cmdline_fixed_string_t tx;
12419 cmdline_fixed_string_t min_bw;
12420 cmdline_fixed_string_t max_bw;
12425 cmdline_fixed_string_t bw_list;
12428 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12429 TOKEN_STRING_INITIALIZER
12430 (struct cmd_vf_tc_bw_result,
12432 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12433 TOKEN_STRING_INITIALIZER
12434 (struct cmd_vf_tc_bw_result,
12436 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12437 TOKEN_STRING_INITIALIZER
12438 (struct cmd_vf_tc_bw_result,
12440 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12441 TOKEN_STRING_INITIALIZER
12442 (struct cmd_vf_tc_bw_result,
12444 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12445 TOKEN_STRING_INITIALIZER
12446 (struct cmd_vf_tc_bw_result,
12447 min_bw, "min-bandwidth");
12448 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12449 TOKEN_STRING_INITIALIZER
12450 (struct cmd_vf_tc_bw_result,
12451 max_bw, "max-bandwidth");
12452 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12453 TOKEN_NUM_INITIALIZER
12454 (struct cmd_vf_tc_bw_result,
12456 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12457 TOKEN_NUM_INITIALIZER
12458 (struct cmd_vf_tc_bw_result,
12460 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12461 TOKEN_NUM_INITIALIZER
12462 (struct cmd_vf_tc_bw_result,
12464 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12465 TOKEN_NUM_INITIALIZER
12466 (struct cmd_vf_tc_bw_result,
12468 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_vf_tc_bw_result,
12473 /* VF max bandwidth setting */
12475 cmd_vf_max_bw_parsed(
12476 void *parsed_result,
12477 __attribute__((unused)) struct cmdline *cl,
12478 __attribute__((unused)) void *data)
12480 struct cmd_vf_tc_bw_result *res = parsed_result;
12481 int ret = -ENOTSUP;
12483 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12486 #ifdef RTE_LIBRTE_I40E_PMD
12487 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12488 res->vf_id, res->bw);
12495 printf("invalid vf_id %d or bandwidth %d\n",
12496 res->vf_id, res->bw);
12499 printf("invalid port_id %d\n", res->port_id);
12502 printf("function not implemented\n");
12505 printf("programming error: (%s)\n", strerror(-ret));
12509 cmdline_parse_inst_t cmd_vf_max_bw = {
12510 .f = cmd_vf_max_bw_parsed,
12512 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12514 (void *)&cmd_vf_tc_bw_set,
12515 (void *)&cmd_vf_tc_bw_vf,
12516 (void *)&cmd_vf_tc_bw_tx,
12517 (void *)&cmd_vf_tc_bw_max_bw,
12518 (void *)&cmd_vf_tc_bw_port_id,
12519 (void *)&cmd_vf_tc_bw_vf_id,
12520 (void *)&cmd_vf_tc_bw_bw,
12526 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12531 const char *p, *p0 = str;
12538 p = strchr(p0, '(');
12540 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12544 p0 = strchr(p, ')');
12546 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12550 if (size >= sizeof(s)) {
12551 printf("The string size exceeds the internal buffer size\n");
12554 snprintf(s, sizeof(s), "%.*s", size, p);
12555 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12557 printf("Failed to get the bandwidth list. ");
12561 for (i = 0; i < ret; i++)
12562 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12567 /* TC min bandwidth setting */
12569 cmd_vf_tc_min_bw_parsed(
12570 void *parsed_result,
12571 __attribute__((unused)) struct cmdline *cl,
12572 __attribute__((unused)) void *data)
12574 struct cmd_vf_tc_bw_result *res = parsed_result;
12577 int ret = -ENOTSUP;
12579 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12582 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12586 #ifdef RTE_LIBRTE_I40E_PMD
12587 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12595 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12598 printf("invalid port_id %d\n", res->port_id);
12601 printf("function not implemented\n");
12604 printf("programming error: (%s)\n", strerror(-ret));
12608 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12609 .f = cmd_vf_tc_min_bw_parsed,
12611 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12612 " <bw1, bw2, ...>",
12614 (void *)&cmd_vf_tc_bw_set,
12615 (void *)&cmd_vf_tc_bw_vf,
12616 (void *)&cmd_vf_tc_bw_tc,
12617 (void *)&cmd_vf_tc_bw_tx,
12618 (void *)&cmd_vf_tc_bw_min_bw,
12619 (void *)&cmd_vf_tc_bw_port_id,
12620 (void *)&cmd_vf_tc_bw_vf_id,
12621 (void *)&cmd_vf_tc_bw_bw_list,
12626 /* TC max bandwidth setting */
12628 cmd_vf_tc_max_bw_parsed(
12629 void *parsed_result,
12630 __attribute__((unused)) struct cmdline *cl,
12631 __attribute__((unused)) void *data)
12633 struct cmd_vf_tc_bw_result *res = parsed_result;
12634 int ret = -ENOTSUP;
12636 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12639 #ifdef RTE_LIBRTE_I40E_PMD
12640 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12641 res->tc_no, res->bw);
12648 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12649 res->vf_id, res->tc_no, res->bw);
12652 printf("invalid port_id %d\n", res->port_id);
12655 printf("function not implemented\n");
12658 printf("programming error: (%s)\n", strerror(-ret));
12662 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12663 .f = cmd_vf_tc_max_bw_parsed,
12665 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12668 (void *)&cmd_vf_tc_bw_set,
12669 (void *)&cmd_vf_tc_bw_vf,
12670 (void *)&cmd_vf_tc_bw_tc,
12671 (void *)&cmd_vf_tc_bw_tx,
12672 (void *)&cmd_vf_tc_bw_max_bw,
12673 (void *)&cmd_vf_tc_bw_port_id,
12674 (void *)&cmd_vf_tc_bw_vf_id,
12675 (void *)&cmd_vf_tc_bw_tc_no,
12676 (void *)&cmd_vf_tc_bw_bw,
12682 /* ******************************************************************************** */
12684 /* list of instructions */
12685 cmdline_parse_ctx_t main_ctx[] = {
12686 (cmdline_parse_inst_t *)&cmd_help_brief,
12687 (cmdline_parse_inst_t *)&cmd_help_long,
12688 (cmdline_parse_inst_t *)&cmd_quit,
12689 (cmdline_parse_inst_t *)&cmd_showport,
12690 (cmdline_parse_inst_t *)&cmd_showqueue,
12691 (cmdline_parse_inst_t *)&cmd_showportall,
12692 (cmdline_parse_inst_t *)&cmd_showcfg,
12693 (cmdline_parse_inst_t *)&cmd_start,
12694 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12695 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12696 (cmdline_parse_inst_t *)&cmd_set_link_up,
12697 (cmdline_parse_inst_t *)&cmd_set_link_down,
12698 (cmdline_parse_inst_t *)&cmd_reset,
12699 (cmdline_parse_inst_t *)&cmd_set_numbers,
12700 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12701 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12702 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12703 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12704 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12705 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12706 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12707 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12708 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12709 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12710 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12711 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12712 (cmdline_parse_inst_t *)&cmd_set_link_check,
12713 #ifdef RTE_NIC_BYPASS
12714 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12715 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12716 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12717 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12719 #ifdef RTE_LIBRTE_PMD_BOND
12720 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12721 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12722 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12723 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12724 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12725 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12726 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12727 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12728 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12730 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12731 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12732 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12733 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12734 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12735 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12736 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12737 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12738 (cmdline_parse_inst_t *)&cmd_csum_set,
12739 (cmdline_parse_inst_t *)&cmd_csum_show,
12740 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12741 (cmdline_parse_inst_t *)&cmd_tso_set,
12742 (cmdline_parse_inst_t *)&cmd_tso_show,
12743 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12744 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12745 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12746 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12747 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12748 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12749 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12750 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12751 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12752 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12753 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12754 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12755 (cmdline_parse_inst_t *)&cmd_config_dcb,
12756 (cmdline_parse_inst_t *)&cmd_read_reg,
12757 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12758 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12759 (cmdline_parse_inst_t *)&cmd_write_reg,
12760 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12761 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12762 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12763 (cmdline_parse_inst_t *)&cmd_stop,
12764 (cmdline_parse_inst_t *)&cmd_mac_addr,
12765 (cmdline_parse_inst_t *)&cmd_set_qmap,
12766 (cmdline_parse_inst_t *)&cmd_operate_port,
12767 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12768 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12769 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12770 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12771 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12772 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12773 (cmdline_parse_inst_t *)&cmd_config_mtu,
12774 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12775 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12776 (cmdline_parse_inst_t *)&cmd_config_rss,
12777 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12778 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12779 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12780 (cmdline_parse_inst_t *)&cmd_showport_reta,
12781 (cmdline_parse_inst_t *)&cmd_config_burst,
12782 (cmdline_parse_inst_t *)&cmd_config_thresh,
12783 (cmdline_parse_inst_t *)&cmd_config_threshold,
12784 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12785 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12786 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12787 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12788 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12789 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12790 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12791 (cmdline_parse_inst_t *)&cmd_global_config,
12792 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12793 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12794 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12795 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12796 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12797 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12798 (cmdline_parse_inst_t *)&cmd_dump,
12799 (cmdline_parse_inst_t *)&cmd_dump_one,
12800 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12801 (cmdline_parse_inst_t *)&cmd_syn_filter,
12802 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12803 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12804 (cmdline_parse_inst_t *)&cmd_flex_filter,
12805 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12806 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12807 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12808 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12809 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12810 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12811 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12812 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12813 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12814 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12815 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12816 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12817 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12818 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12819 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12820 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12821 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12822 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12823 (cmdline_parse_inst_t *)&cmd_flow,
12824 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12825 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12826 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12827 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12828 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12829 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12830 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12831 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12832 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12833 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12834 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12835 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12836 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12837 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12838 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12839 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12840 #ifdef RTE_LIBRTE_IXGBE_PMD
12841 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12842 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12843 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12844 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12845 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12846 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12847 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12848 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12849 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12851 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12852 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12853 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12854 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12855 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
12856 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
12857 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
12858 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
12859 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
12863 /* prompt function, called from main on MASTER lcore */
12867 /* initialize non-constant commands */
12868 cmd_set_fwd_mode_init();
12869 cmd_set_fwd_retry_mode_init();
12871 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12872 if (testpmd_cl == NULL)
12874 cmdline_interact(testpmd_cl);
12875 cmdline_stdin_exit(testpmd_cl);
12881 if (testpmd_cl != NULL)
12882 cmdline_quit(testpmd_cl);
12886 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12888 if (id == (portid_t)RTE_PORT_ALL) {
12891 FOREACH_PORT(pid, ports) {
12892 /* check if need_reconfig has been set to 1 */
12893 if (ports[pid].need_reconfig == 0)
12894 ports[pid].need_reconfig = dev;
12895 /* check if need_reconfig_queues has been set to 1 */
12896 if (ports[pid].need_reconfig_queues == 0)
12897 ports[pid].need_reconfig_queues = queue;
12899 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12900 /* check if need_reconfig has been set to 1 */
12901 if (ports[id].need_reconfig == 0)
12902 ports[id].need_reconfig = dev;
12903 /* check if need_reconfig_queues has been set to 1 */
12904 if (ports[id].need_reconfig_queues == 0)
12905 ports[id].need_reconfig_queues = queue;