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 "vlan set filter (on|off) (port_id)\n"
325 " Set the VLAN filter on a port.\n\n"
327 "vlan set qinq (on|off) (port_id)\n"
328 " Set the VLAN QinQ (extended queue in queue)"
331 "vlan set (inner|outer) tpid (value) (port_id)\n"
332 " Set the VLAN TPID for Packet Filtering on"
335 "rx_vlan add (vlan_id|all) (port_id)\n"
336 " Add a vlan_id, or all identifiers, to the set"
337 " of VLAN identifiers filtered by port_id.\n\n"
339 "rx_vlan rm (vlan_id|all) (port_id)\n"
340 " Remove a vlan_id, or all identifiers, from the set"
341 " of VLAN identifiers filtered by port_id.\n\n"
343 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
344 " Add a vlan_id, to the set of VLAN identifiers"
345 "filtered for VF(s) from port_id.\n\n"
347 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
348 " Remove a vlan_id, to the set of VLAN identifiers"
349 "filtered for VF(s) from port_id.\n\n"
351 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
352 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
353 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
354 " add a tunnel filter of a port.\n\n"
356 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
357 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
358 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
359 " remove a tunnel filter of a port.\n\n"
361 "rx_vxlan_port add (udp_port) (port_id)\n"
362 " Add an UDP port for VXLAN packet filter on a port\n\n"
364 "rx_vxlan_port rm (udp_port) (port_id)\n"
365 " Remove an UDP port for VXLAN packet filter on a port\n\n"
367 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
368 " Set hardware insertion of VLAN IDs (single or double VLAN "
369 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
371 "tx_vlan set pvid port_id vlan_id (on|off)\n"
372 " Set port based TX VLAN insertion.\n\n"
374 "tx_vlan reset (port_id)\n"
375 " Disable hardware insertion of a VLAN header in"
376 " packets sent on a port.\n\n"
378 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
379 " Select hardware or software calculation of the"
380 " checksum when transmitting a packet using the"
381 " csum forward engine.\n"
382 " ip|udp|tcp|sctp always concern the inner layer.\n"
383 " outer-ip concerns the outer IP layer in"
384 " case the packet is recognized as a tunnel packet by"
385 " the forward engine (vxlan, gre and ipip are supported)\n"
386 " Please check the NIC datasheet for HW limits.\n\n"
388 "csum parse-tunnel (on|off) (tx_port_id)\n"
389 " If disabled, treat tunnel packets as non-tunneled"
390 " packets (treat inner headers as payload). The port\n"
391 " argument is the port used for TX in csum forward"
394 "csum show (port_id)\n"
395 " Display tx checksum offload configuration\n\n"
397 "tso set (segsize) (portid)\n"
398 " Enable TCP Segmentation Offload in csum forward"
400 " Please check the NIC datasheet for HW limits.\n\n"
403 " Display the status of TCP Segmentation Offload.\n\n"
406 " Set packet forwarding mode.\n\n"
408 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
409 " Add a MAC address on port_id.\n\n"
411 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
412 " Remove a MAC address from port_id.\n\n"
414 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
415 " Set the default MAC address for port_id.\n\n"
417 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
418 " Add a MAC address for a VF on the port.\n\n"
420 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
421 " Set the MAC address for a VF from the PF.\n\n"
423 "set port (port_id) uta (mac_address|all) (on|off)\n"
424 " Add/Remove a or all unicast hash filter(s)"
427 "set promisc (port_id|all) (on|off)\n"
428 " Set the promiscuous mode on port_id, or all.\n\n"
430 "set allmulti (port_id|all) (on|off)\n"
431 " Set the allmulti mode on port_id, or all.\n\n"
433 "set vf promisc (port_id) (vf_id) (on|off)\n"
434 " Set unicast promiscuous mode for a VF from the PF.\n\n"
436 "set vf allmulti (port_id) (vf_id) (on|off)\n"
437 " Set multicast promiscuous mode for a VF from the PF.\n\n"
439 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
440 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
441 " (on|off) autoneg (on|off) (port_id)\n"
442 "set flow_ctrl rx (on|off) (portid)\n"
443 "set flow_ctrl tx (on|off) (portid)\n"
444 "set flow_ctrl high_water (high_water) (portid)\n"
445 "set flow_ctrl low_water (low_water) (portid)\n"
446 "set flow_ctrl pause_time (pause_time) (portid)\n"
447 "set flow_ctrl send_xon (send_xon) (portid)\n"
448 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
449 "set flow_ctrl autoneg (on|off) (port_id)\n"
450 " Set the link flow control parameter on a port.\n\n"
452 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
453 " (low_water) (pause_time) (priority) (port_id)\n"
454 " Set the priority flow control parameter on a"
457 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
458 " Set statistics mapping (qmapping 0..15) for RX/TX"
460 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
461 " on port 0 to mapping 5.\n\n"
463 "set port (port_id) vf (vf_id) rx|tx on|off\n"
464 " Enable/Disable a VF receive/tranmit from a port\n\n"
466 "set port (port_id) vf (vf_id) (mac_addr)"
467 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
468 " Add/Remove unicast or multicast MAC addr filter"
471 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
473 " AUPE:accepts untagged VLAN;"
474 "ROPE:accept unicast hash\n\n"
475 " BAM:accepts broadcast packets;"
476 "MPE:accepts all multicast packets\n\n"
477 " Enable/Disable a VF receive mode of a port\n\n"
479 "set port (port_id) queue (queue_id) rate (rate_num)\n"
480 " Set rate limit for a queue of a port\n\n"
482 "set port (port_id) vf (vf_id) rate (rate_num) "
483 "queue_mask (queue_mask_value)\n"
484 " Set rate limit for queues in VF of a port\n\n"
486 "set port (port_id) mirror-rule (rule_id)"
487 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
488 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
489 " Set pool or vlan type mirror rule on a port.\n"
490 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
491 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
494 "set port (port_id) mirror-rule (rule_id)"
495 " (uplink-mirror|downlink-mirror) dst-pool"
496 " (pool_id) (on|off)\n"
497 " Set uplink or downlink type mirror rule on a port.\n"
498 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
499 " 0 on' enable mirror income traffic to pool 0.\n\n"
501 "reset port (port_id) mirror-rule (rule_id)\n"
502 " Reset a mirror rule.\n\n"
504 "set flush_rx (on|off)\n"
505 " Flush (default) or don't flush RX streams before"
506 " forwarding. Mainly used with PCAP drivers.\n\n"
508 #ifdef RTE_NIC_BYPASS
509 "set bypass mode (normal|bypass|isolate) (port_id)\n"
510 " Set the bypass mode for the lowest port on bypass enabled"
513 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
514 "mode (normal|bypass|isolate) (port_id)\n"
515 " Set the event required to initiate specified bypass mode for"
516 " the lowest port on a bypass enabled NIC where:\n"
517 " timeout = enable bypass after watchdog timeout.\n"
518 " os_on = enable bypass when OS/board is powered on.\n"
519 " os_off = enable bypass when OS/board is powered off.\n"
520 " power_on = enable bypass when power supply is turned on.\n"
521 " power_off = enable bypass when power supply is turned off."
524 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
525 " Set the bypass watchdog timeout to 'n' seconds"
526 " where 0 = instant.\n\n"
528 "show bypass config (port_id)\n"
529 " Show the bypass configuration for a bypass enabled NIC"
530 " using the lowest port on the NIC.\n\n"
532 #ifdef RTE_LIBRTE_PMD_BOND
533 "create bonded device (mode) (socket)\n"
534 " Create a new bonded device with specific bonding mode and socket.\n\n"
536 "add bonding slave (slave_id) (port_id)\n"
537 " Add a slave device to a bonded device.\n\n"
539 "remove bonding slave (slave_id) (port_id)\n"
540 " Remove a slave device from a bonded device.\n\n"
542 "set bonding mode (value) (port_id)\n"
543 " Set the bonding mode on a bonded device.\n\n"
545 "set bonding primary (slave_id) (port_id)\n"
546 " Set the primary slave for a bonded device.\n\n"
548 "show bonding config (port_id)\n"
549 " Show the bonding config for port_id.\n\n"
551 "set bonding mac_addr (port_id) (address)\n"
552 " Set the MAC address of a bonded device.\n\n"
554 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
555 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
557 "set bonding mon_period (port_id) (value)\n"
558 " Set the bonding link status monitoring polling period in ms.\n\n"
560 "set link-up port (port_id)\n"
561 " Set link up for a port.\n\n"
563 "set link-down port (port_id)\n"
564 " Set link down for a port.\n\n"
566 "E-tag set insertion on port-tag-id (value)"
567 " port (port_id) vf (vf_id)\n"
568 " Enable E-tag insertion for a VF on a port\n\n"
570 "E-tag set insertion off port (port_id) vf (vf_id)\n"
571 " Disable E-tag insertion for a VF on a port\n\n"
573 "E-tag set stripping (on|off) port (port_id)\n"
574 " Enable/disable E-tag stripping on a port\n\n"
576 "E-tag set forwarding (on|off) port (port_id)\n"
577 " Enable/disable E-tag based forwarding"
580 "E-tag set filter add e-tag-id (value) dst-pool"
581 " (pool_id) port (port_id)\n"
582 " Add an E-tag forwarding filter on a port\n\n"
584 "E-tag set filter del e-tag-id (value) port (port_id)\n"
585 " Delete an E-tag forwarding filter on a port\n\n"
587 , list_pkt_forwarding_modes()
591 if (show_all || !strcmp(res->section, "ports")) {
597 "----------------\n\n"
599 "port start (port_id|all)\n"
600 " Start all ports or port_id.\n\n"
602 "port stop (port_id|all)\n"
603 " Stop all ports or port_id.\n\n"
605 "port close (port_id|all)\n"
606 " Close all ports or port_id.\n\n"
608 "port attach (ident)\n"
609 " Attach physical or virtual dev by pci address or virtual device name\n\n"
611 "port detach (port_id)\n"
612 " Detach physical or virtual dev by port_id\n\n"
614 "port config (port_id|all)"
615 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
616 " duplex (half|full|auto)\n"
617 " Set speed and duplex for all ports or port_id\n\n"
619 "port config all (rxq|txq|rxd|txd) (value)\n"
620 " Set number for rxq/txq/rxd/txd.\n\n"
622 "port config all max-pkt-len (value)\n"
623 " Set the max packet length.\n\n"
625 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
626 "hw-vlan-strip|hw-vlan-extend|drop-en)"
628 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
631 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
632 " Set the RSS mode.\n\n"
634 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
635 " Set the RSS redirection table.\n\n"
637 "port config (port_id) dcb vt (on|off) (traffic_class)"
639 " Set the DCB mode.\n\n"
641 "port config all burst (value)\n"
642 " Set the number of packets per burst.\n\n"
644 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
646 " Set the ring prefetch/host/writeback threshold"
647 " for tx/rx queue.\n\n"
649 "port config all (txfreet|txrst|rxfreet) (value)\n"
650 " Set free threshold for rx/tx, or set"
651 " tx rs bit threshold.\n\n"
652 "port config mtu X value\n"
653 " Set the MTU of port X to a given value\n\n"
655 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
656 " Start/stop a rx/tx queue of port X. Only take effect"
657 " when port X is started\n\n"
659 "port config (port_id|all) l2-tunnel E-tag ether-type"
661 " Set the value of E-tag ether-type.\n\n"
663 "port config (port_id|all) l2-tunnel E-tag"
664 " (enable|disable)\n"
665 " Enable/disable the E-tag support.\n\n"
669 if (show_all || !strcmp(res->section, "registers")) {
677 "read reg (port_id) (address)\n"
678 " Display value of a port register.\n\n"
680 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
681 " Display a port register bit field.\n\n"
683 "read regbit (port_id) (address) (bit_x)\n"
684 " Display a single port register bit.\n\n"
686 "write reg (port_id) (address) (value)\n"
687 " Set value of a port register.\n\n"
689 "write regfield (port_id) (address) (bit_x) (bit_y)"
691 " Set bit field of a port register.\n\n"
693 "write regbit (port_id) (address) (bit_x) (value)\n"
694 " Set single bit value of a port register.\n\n"
697 if (show_all || !strcmp(res->section, "filters")) {
705 "ethertype_filter (port_id) (add|del)"
706 " (mac_addr|mac_ignr) (mac_address) ethertype"
707 " (ether_type) (drop|fwd) queue (queue_id)\n"
708 " Add/Del an ethertype filter.\n\n"
710 "2tuple_filter (port_id) (add|del)"
711 " dst_port (dst_port_value) protocol (protocol_value)"
712 " mask (mask_value) tcp_flags (tcp_flags_value)"
713 " priority (prio_value) queue (queue_id)\n"
714 " Add/Del a 2tuple filter.\n\n"
716 "5tuple_filter (port_id) (add|del)"
717 " dst_ip (dst_address) src_ip (src_address)"
718 " dst_port (dst_port_value) src_port (src_port_value)"
719 " protocol (protocol_value)"
720 " mask (mask_value) tcp_flags (tcp_flags_value)"
721 " priority (prio_value) queue (queue_id)\n"
722 " Add/Del a 5tuple filter.\n\n"
724 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
725 " Add/Del syn filter.\n\n"
727 "flex_filter (port_id) (add|del) len (len_value)"
728 " bytes (bytes_value) mask (mask_value)"
729 " priority (prio_value) queue (queue_id)\n"
730 " Add/Del a flex filter.\n\n"
732 "flow_director_filter (port_id) mode IP (add|del|update)"
733 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
734 " src (src_ip_address) dst (dst_ip_address)"
735 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
736 " vlan (vlan_value) flexbytes (flexbytes_value)"
737 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
738 " fd_id (fd_id_value)\n"
739 " Add/Del an IP type flow director filter.\n\n"
741 "flow_director_filter (port_id) mode IP (add|del|update)"
742 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
743 " src (src_ip_address) (src_port)"
744 " dst (dst_ip_address) (dst_port)"
745 " tos (tos_value) ttl (ttl_value)"
746 " vlan (vlan_value) flexbytes (flexbytes_value)"
747 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
748 " fd_id (fd_id_value)\n"
749 " Add/Del an UDP/TCP type flow director filter.\n\n"
751 "flow_director_filter (port_id) mode IP (add|del|update)"
752 " flow (ipv4-sctp|ipv6-sctp)"
753 " src (src_ip_address) (src_port)"
754 " dst (dst_ip_address) (dst_port)"
755 " tag (verification_tag) "
756 " tos (tos_value) ttl (ttl_value)"
758 " flexbytes (flexbytes_value) (drop|fwd)"
759 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
760 " Add/Del a SCTP type flow director filter.\n\n"
762 "flow_director_filter (port_id) mode IP (add|del|update)"
763 " flow l2_payload ether (ethertype)"
764 " flexbytes (flexbytes_value) (drop|fwd)"
765 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
766 " Add/Del a l2 payload type flow director filter.\n\n"
768 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
769 " mac (mac_address) vlan (vlan_value)"
770 " flexbytes (flexbytes_value) (drop|fwd)"
771 " queue (queue_id) fd_id (fd_id_value)\n"
772 " Add/Del a MAC-VLAN flow director filter.\n\n"
774 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
775 " mac (mac_address) vlan (vlan_value)"
776 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
777 " flexbytes (flexbytes_value) (drop|fwd)"
778 " queue (queue_id) fd_id (fd_id_value)\n"
779 " Add/Del a Tunnel flow director filter.\n\n"
781 "flush_flow_director (port_id)\n"
782 " Flush all flow director entries of a device.\n\n"
784 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
785 " src_mask (ipv4_src) (ipv6_src) (src_port)"
786 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
787 " Set flow director IP mask.\n\n"
789 "flow_director_mask (port_id) mode MAC-VLAN"
790 " vlan (vlan_value)\n"
791 " Set flow director MAC-VLAN mask.\n\n"
793 "flow_director_mask (port_id) mode Tunnel"
794 " vlan (vlan_value) mac (mac_value)"
795 " tunnel-type (tunnel_type_value)"
796 " tunnel-id (tunnel_id_value)\n"
797 " Set flow director Tunnel mask.\n\n"
799 "flow_director_flex_mask (port_id)"
800 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
801 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
803 " Configure mask of flex payload.\n\n"
805 "flow_director_flex_payload (port_id)"
806 " (raw|l2|l3|l4) (config)\n"
807 " Configure flex payload selection.\n\n"
809 "get_sym_hash_ena_per_port (port_id)\n"
810 " get symmetric hash enable configuration per port.\n\n"
812 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
813 " set symmetric hash enable configuration per port"
814 " to enable or disable.\n\n"
816 "get_hash_global_config (port_id)\n"
817 " Get the global configurations of hash filters.\n\n"
819 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
820 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
821 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
822 " (enable|disable)\n"
823 " Set the global configurations of hash filters.\n\n"
825 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
826 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
827 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
828 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
829 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
830 "ipv6-next-header|udp-src-port|udp-dst-port|"
831 "tcp-src-port|tcp-dst-port|sctp-src-port|"
832 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
833 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
834 "fld-8th|none) (select|add)\n"
835 " Set the input set for hash.\n\n"
837 "set_fdir_input_set (port_id) "
838 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
839 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
840 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
841 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
842 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
843 "udp-dst-port|tcp-src-port|tcp-dst-port|"
844 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
846 " Set the input set for FDir.\n\n"
848 "flow validate {port_id}"
849 " [group {group_id}] [priority {level}]"
850 " [ingress] [egress]"
851 " pattern {item} [/ {item} [...]] / end"
852 " actions {action} [/ {action} [...]] / end\n"
853 " Check whether a flow rule can be created.\n\n"
855 "flow create {port_id}"
856 " [group {group_id}] [priority {level}]"
857 " [ingress] [egress]"
858 " pattern {item} [/ {item} [...]] / end"
859 " actions {action} [/ {action} [...]] / end\n"
860 " Create a flow rule.\n\n"
862 "flow destroy {port_id} rule {rule_id} [...]\n"
863 " Destroy specific flow rules.\n\n"
865 "flow flush {port_id}\n"
866 " Destroy all flow rules.\n\n"
868 "flow query {port_id} {rule_id} {action}\n"
869 " Query an existing flow rule.\n\n"
871 "flow list {port_id} [group {group_id}] [...]\n"
872 " List existing flow rules sorted by priority,"
873 " filtered by group identifiers.\n\n"
878 cmdline_parse_token_string_t cmd_help_long_help =
879 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
881 cmdline_parse_token_string_t cmd_help_long_section =
882 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
883 "all#control#display#config#"
884 "ports#registers#filters");
886 cmdline_parse_inst_t cmd_help_long = {
887 .f = cmd_help_long_parsed,
889 .help_str = "help all|control|display|config|ports|register|filters: "
892 (void *)&cmd_help_long_help,
893 (void *)&cmd_help_long_section,
899 /* *** start/stop/close all ports *** */
900 struct cmd_operate_port_result {
901 cmdline_fixed_string_t keyword;
902 cmdline_fixed_string_t name;
903 cmdline_fixed_string_t value;
906 static void cmd_operate_port_parsed(void *parsed_result,
907 __attribute__((unused)) struct cmdline *cl,
908 __attribute__((unused)) void *data)
910 struct cmd_operate_port_result *res = parsed_result;
912 if (!strcmp(res->name, "start"))
913 start_port(RTE_PORT_ALL);
914 else if (!strcmp(res->name, "stop"))
915 stop_port(RTE_PORT_ALL);
916 else if (!strcmp(res->name, "close"))
917 close_port(RTE_PORT_ALL);
919 printf("Unknown parameter\n");
922 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
923 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
925 cmdline_parse_token_string_t cmd_operate_port_all_port =
926 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
928 cmdline_parse_token_string_t cmd_operate_port_all_all =
929 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
931 cmdline_parse_inst_t cmd_operate_port = {
932 .f = cmd_operate_port_parsed,
934 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
936 (void *)&cmd_operate_port_all_cmd,
937 (void *)&cmd_operate_port_all_port,
938 (void *)&cmd_operate_port_all_all,
943 /* *** start/stop/close specific port *** */
944 struct cmd_operate_specific_port_result {
945 cmdline_fixed_string_t keyword;
946 cmdline_fixed_string_t name;
950 static void cmd_operate_specific_port_parsed(void *parsed_result,
951 __attribute__((unused)) struct cmdline *cl,
952 __attribute__((unused)) void *data)
954 struct cmd_operate_specific_port_result *res = parsed_result;
956 if (!strcmp(res->name, "start"))
957 start_port(res->value);
958 else if (!strcmp(res->name, "stop"))
959 stop_port(res->value);
960 else if (!strcmp(res->name, "close"))
961 close_port(res->value);
963 printf("Unknown parameter\n");
966 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
967 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
969 cmdline_parse_token_string_t cmd_operate_specific_port_port =
970 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
971 name, "start#stop#close");
972 cmdline_parse_token_num_t cmd_operate_specific_port_id =
973 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
976 cmdline_parse_inst_t cmd_operate_specific_port = {
977 .f = cmd_operate_specific_port_parsed,
979 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
981 (void *)&cmd_operate_specific_port_cmd,
982 (void *)&cmd_operate_specific_port_port,
983 (void *)&cmd_operate_specific_port_id,
988 /* *** attach a specified port *** */
989 struct cmd_operate_attach_port_result {
990 cmdline_fixed_string_t port;
991 cmdline_fixed_string_t keyword;
992 cmdline_fixed_string_t identifier;
995 static void cmd_operate_attach_port_parsed(void *parsed_result,
996 __attribute__((unused)) struct cmdline *cl,
997 __attribute__((unused)) void *data)
999 struct cmd_operate_attach_port_result *res = parsed_result;
1001 if (!strcmp(res->keyword, "attach"))
1002 attach_port(res->identifier);
1004 printf("Unknown parameter\n");
1007 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1008 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1010 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1011 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1013 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1014 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1017 cmdline_parse_inst_t cmd_operate_attach_port = {
1018 .f = cmd_operate_attach_port_parsed,
1020 .help_str = "port attach <identifier>: "
1021 "(identifier: pci address or virtual dev name)",
1023 (void *)&cmd_operate_attach_port_port,
1024 (void *)&cmd_operate_attach_port_keyword,
1025 (void *)&cmd_operate_attach_port_identifier,
1030 /* *** detach a specified port *** */
1031 struct cmd_operate_detach_port_result {
1032 cmdline_fixed_string_t port;
1033 cmdline_fixed_string_t keyword;
1037 static void cmd_operate_detach_port_parsed(void *parsed_result,
1038 __attribute__((unused)) struct cmdline *cl,
1039 __attribute__((unused)) void *data)
1041 struct cmd_operate_detach_port_result *res = parsed_result;
1043 if (!strcmp(res->keyword, "detach"))
1044 detach_port(res->port_id);
1046 printf("Unknown parameter\n");
1049 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1050 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1052 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1053 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1055 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1056 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1059 cmdline_parse_inst_t cmd_operate_detach_port = {
1060 .f = cmd_operate_detach_port_parsed,
1062 .help_str = "port detach <port_id>",
1064 (void *)&cmd_operate_detach_port_port,
1065 (void *)&cmd_operate_detach_port_keyword,
1066 (void *)&cmd_operate_detach_port_port_id,
1071 /* *** configure speed for all ports *** */
1072 struct cmd_config_speed_all {
1073 cmdline_fixed_string_t port;
1074 cmdline_fixed_string_t keyword;
1075 cmdline_fixed_string_t all;
1076 cmdline_fixed_string_t item1;
1077 cmdline_fixed_string_t item2;
1078 cmdline_fixed_string_t value1;
1079 cmdline_fixed_string_t value2;
1083 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1088 if (!strcmp(duplexstr, "half")) {
1089 duplex = ETH_LINK_HALF_DUPLEX;
1090 } else if (!strcmp(duplexstr, "full")) {
1091 duplex = ETH_LINK_FULL_DUPLEX;
1092 } else if (!strcmp(duplexstr, "auto")) {
1093 duplex = ETH_LINK_FULL_DUPLEX;
1095 printf("Unknown duplex parameter\n");
1099 if (!strcmp(speedstr, "10")) {
1100 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1101 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1102 } else if (!strcmp(speedstr, "100")) {
1103 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1104 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1106 if (duplex != ETH_LINK_FULL_DUPLEX) {
1107 printf("Invalid speed/duplex parameters\n");
1110 if (!strcmp(speedstr, "1000")) {
1111 *speed = ETH_LINK_SPEED_1G;
1112 } else if (!strcmp(speedstr, "10000")) {
1113 *speed = ETH_LINK_SPEED_10G;
1114 } else if (!strcmp(speedstr, "25000")) {
1115 *speed = ETH_LINK_SPEED_25G;
1116 } else if (!strcmp(speedstr, "40000")) {
1117 *speed = ETH_LINK_SPEED_40G;
1118 } else if (!strcmp(speedstr, "50000")) {
1119 *speed = ETH_LINK_SPEED_50G;
1120 } else if (!strcmp(speedstr, "100000")) {
1121 *speed = ETH_LINK_SPEED_100G;
1122 } else if (!strcmp(speedstr, "auto")) {
1123 *speed = ETH_LINK_SPEED_AUTONEG;
1125 printf("Unknown speed parameter\n");
1134 cmd_config_speed_all_parsed(void *parsed_result,
1135 __attribute__((unused)) struct cmdline *cl,
1136 __attribute__((unused)) void *data)
1138 struct cmd_config_speed_all *res = parsed_result;
1139 uint32_t link_speed;
1142 if (!all_ports_stopped()) {
1143 printf("Please stop all ports first\n");
1147 if (parse_and_check_speed_duplex(res->value1, res->value2,
1151 FOREACH_PORT(pid, ports) {
1152 ports[pid].dev_conf.link_speeds = link_speed;
1155 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1158 cmdline_parse_token_string_t cmd_config_speed_all_port =
1159 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1160 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1161 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1163 cmdline_parse_token_string_t cmd_config_speed_all_all =
1164 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1165 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1166 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1167 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1168 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1169 "10#100#1000#10000#25000#40000#50000#100000#auto");
1170 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1171 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1172 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1173 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1176 cmdline_parse_inst_t cmd_config_speed_all = {
1177 .f = cmd_config_speed_all_parsed,
1179 .help_str = "port config all speed "
1180 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1183 (void *)&cmd_config_speed_all_port,
1184 (void *)&cmd_config_speed_all_keyword,
1185 (void *)&cmd_config_speed_all_all,
1186 (void *)&cmd_config_speed_all_item1,
1187 (void *)&cmd_config_speed_all_value1,
1188 (void *)&cmd_config_speed_all_item2,
1189 (void *)&cmd_config_speed_all_value2,
1194 /* *** configure speed for specific port *** */
1195 struct cmd_config_speed_specific {
1196 cmdline_fixed_string_t port;
1197 cmdline_fixed_string_t keyword;
1199 cmdline_fixed_string_t item1;
1200 cmdline_fixed_string_t item2;
1201 cmdline_fixed_string_t value1;
1202 cmdline_fixed_string_t value2;
1206 cmd_config_speed_specific_parsed(void *parsed_result,
1207 __attribute__((unused)) struct cmdline *cl,
1208 __attribute__((unused)) void *data)
1210 struct cmd_config_speed_specific *res = parsed_result;
1211 uint32_t link_speed;
1213 if (!all_ports_stopped()) {
1214 printf("Please stop all ports first\n");
1218 if (port_id_is_invalid(res->id, ENABLED_WARN))
1221 if (parse_and_check_speed_duplex(res->value1, res->value2,
1225 ports[res->id].dev_conf.link_speeds = link_speed;
1227 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1231 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1234 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1235 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1237 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1238 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1239 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1240 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1242 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1243 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1244 "10#100#1000#10000#25000#40000#50000#100000#auto");
1245 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1246 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1248 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1249 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1252 cmdline_parse_inst_t cmd_config_speed_specific = {
1253 .f = cmd_config_speed_specific_parsed,
1255 .help_str = "port config <port_id> speed "
1256 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1259 (void *)&cmd_config_speed_specific_port,
1260 (void *)&cmd_config_speed_specific_keyword,
1261 (void *)&cmd_config_speed_specific_id,
1262 (void *)&cmd_config_speed_specific_item1,
1263 (void *)&cmd_config_speed_specific_value1,
1264 (void *)&cmd_config_speed_specific_item2,
1265 (void *)&cmd_config_speed_specific_value2,
1270 /* *** configure txq/rxq, txd/rxd *** */
1271 struct cmd_config_rx_tx {
1272 cmdline_fixed_string_t port;
1273 cmdline_fixed_string_t keyword;
1274 cmdline_fixed_string_t all;
1275 cmdline_fixed_string_t name;
1280 cmd_config_rx_tx_parsed(void *parsed_result,
1281 __attribute__((unused)) struct cmdline *cl,
1282 __attribute__((unused)) void *data)
1284 struct cmd_config_rx_tx *res = parsed_result;
1286 if (!all_ports_stopped()) {
1287 printf("Please stop all ports first\n");
1290 if (!strcmp(res->name, "rxq")) {
1291 if (!res->value && !nb_txq) {
1292 printf("Warning: Either rx or tx queues should be non zero\n");
1295 nb_rxq = res->value;
1297 else if (!strcmp(res->name, "txq")) {
1298 if (!res->value && !nb_rxq) {
1299 printf("Warning: Either rx or tx queues should be non zero\n");
1302 nb_txq = res->value;
1304 else if (!strcmp(res->name, "rxd")) {
1305 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1306 printf("rxd %d invalid - must be > 0 && <= %d\n",
1307 res->value, RTE_TEST_RX_DESC_MAX);
1310 nb_rxd = res->value;
1311 } else if (!strcmp(res->name, "txd")) {
1312 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1313 printf("txd %d invalid - must be > 0 && <= %d\n",
1314 res->value, RTE_TEST_TX_DESC_MAX);
1317 nb_txd = res->value;
1319 printf("Unknown parameter\n");
1327 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1330 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1331 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1332 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1333 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1334 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1335 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1336 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1337 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1339 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1340 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1342 cmdline_parse_inst_t cmd_config_rx_tx = {
1343 .f = cmd_config_rx_tx_parsed,
1345 .help_str = "port config all rxq|txq|rxd|txd <value>",
1347 (void *)&cmd_config_rx_tx_port,
1348 (void *)&cmd_config_rx_tx_keyword,
1349 (void *)&cmd_config_rx_tx_all,
1350 (void *)&cmd_config_rx_tx_name,
1351 (void *)&cmd_config_rx_tx_value,
1356 /* *** config max packet length *** */
1357 struct cmd_config_max_pkt_len_result {
1358 cmdline_fixed_string_t port;
1359 cmdline_fixed_string_t keyword;
1360 cmdline_fixed_string_t all;
1361 cmdline_fixed_string_t name;
1366 cmd_config_max_pkt_len_parsed(void *parsed_result,
1367 __attribute__((unused)) struct cmdline *cl,
1368 __attribute__((unused)) void *data)
1370 struct cmd_config_max_pkt_len_result *res = parsed_result;
1372 if (!all_ports_stopped()) {
1373 printf("Please stop all ports first\n");
1377 if (!strcmp(res->name, "max-pkt-len")) {
1378 if (res->value < ETHER_MIN_LEN) {
1379 printf("max-pkt-len can not be less than %d\n",
1383 if (res->value == rx_mode.max_rx_pkt_len)
1386 rx_mode.max_rx_pkt_len = res->value;
1387 if (res->value > ETHER_MAX_LEN)
1388 rx_mode.jumbo_frame = 1;
1390 rx_mode.jumbo_frame = 0;
1392 printf("Unknown parameter\n");
1398 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1401 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1404 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1407 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1410 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1413 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1414 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1417 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1418 .f = cmd_config_max_pkt_len_parsed,
1420 .help_str = "port config all max-pkt-len <value>",
1422 (void *)&cmd_config_max_pkt_len_port,
1423 (void *)&cmd_config_max_pkt_len_keyword,
1424 (void *)&cmd_config_max_pkt_len_all,
1425 (void *)&cmd_config_max_pkt_len_name,
1426 (void *)&cmd_config_max_pkt_len_value,
1431 /* *** configure port MTU *** */
1432 struct cmd_config_mtu_result {
1433 cmdline_fixed_string_t port;
1434 cmdline_fixed_string_t keyword;
1435 cmdline_fixed_string_t mtu;
1441 cmd_config_mtu_parsed(void *parsed_result,
1442 __attribute__((unused)) struct cmdline *cl,
1443 __attribute__((unused)) void *data)
1445 struct cmd_config_mtu_result *res = parsed_result;
1447 if (res->value < ETHER_MIN_LEN) {
1448 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1451 port_mtu_set(res->port_id, res->value);
1454 cmdline_parse_token_string_t cmd_config_mtu_port =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1457 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1460 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1463 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1464 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1465 cmdline_parse_token_num_t cmd_config_mtu_value =
1466 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1468 cmdline_parse_inst_t cmd_config_mtu = {
1469 .f = cmd_config_mtu_parsed,
1471 .help_str = "port config mtu <port_id> <value>",
1473 (void *)&cmd_config_mtu_port,
1474 (void *)&cmd_config_mtu_keyword,
1475 (void *)&cmd_config_mtu_mtu,
1476 (void *)&cmd_config_mtu_port_id,
1477 (void *)&cmd_config_mtu_value,
1482 /* *** configure rx mode *** */
1483 struct cmd_config_rx_mode_flag {
1484 cmdline_fixed_string_t port;
1485 cmdline_fixed_string_t keyword;
1486 cmdline_fixed_string_t all;
1487 cmdline_fixed_string_t name;
1488 cmdline_fixed_string_t value;
1492 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1493 __attribute__((unused)) struct cmdline *cl,
1494 __attribute__((unused)) void *data)
1496 struct cmd_config_rx_mode_flag *res = parsed_result;
1498 if (!all_ports_stopped()) {
1499 printf("Please stop all ports first\n");
1503 if (!strcmp(res->name, "crc-strip")) {
1504 if (!strcmp(res->value, "on"))
1505 rx_mode.hw_strip_crc = 1;
1506 else if (!strcmp(res->value, "off"))
1507 rx_mode.hw_strip_crc = 0;
1509 printf("Unknown parameter\n");
1512 } else if (!strcmp(res->name, "scatter")) {
1513 if (!strcmp(res->value, "on"))
1514 rx_mode.enable_scatter = 1;
1515 else if (!strcmp(res->value, "off"))
1516 rx_mode.enable_scatter = 0;
1518 printf("Unknown parameter\n");
1521 } else if (!strcmp(res->name, "rx-cksum")) {
1522 if (!strcmp(res->value, "on"))
1523 rx_mode.hw_ip_checksum = 1;
1524 else if (!strcmp(res->value, "off"))
1525 rx_mode.hw_ip_checksum = 0;
1527 printf("Unknown parameter\n");
1530 } else if (!strcmp(res->name, "hw-vlan")) {
1531 if (!strcmp(res->value, "on")) {
1532 rx_mode.hw_vlan_filter = 1;
1533 rx_mode.hw_vlan_strip = 1;
1535 else if (!strcmp(res->value, "off")) {
1536 rx_mode.hw_vlan_filter = 0;
1537 rx_mode.hw_vlan_strip = 0;
1540 printf("Unknown parameter\n");
1543 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1544 if (!strcmp(res->value, "on"))
1545 rx_mode.hw_vlan_filter = 1;
1546 else if (!strcmp(res->value, "off"))
1547 rx_mode.hw_vlan_filter = 0;
1549 printf("Unknown parameter\n");
1552 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1553 if (!strcmp(res->value, "on"))
1554 rx_mode.hw_vlan_strip = 1;
1555 else if (!strcmp(res->value, "off"))
1556 rx_mode.hw_vlan_strip = 0;
1558 printf("Unknown parameter\n");
1561 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1562 if (!strcmp(res->value, "on"))
1563 rx_mode.hw_vlan_extend = 1;
1564 else if (!strcmp(res->value, "off"))
1565 rx_mode.hw_vlan_extend = 0;
1567 printf("Unknown parameter\n");
1570 } else if (!strcmp(res->name, "drop-en")) {
1571 if (!strcmp(res->value, "on"))
1573 else if (!strcmp(res->value, "off"))
1576 printf("Unknown parameter\n");
1580 printf("Unknown parameter\n");
1586 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1589 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1590 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1591 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1592 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1594 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1595 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1596 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1597 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1598 "crc-strip#scatter#rx-cksum#hw-vlan#"
1599 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1600 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1601 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1604 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1605 .f = cmd_config_rx_mode_flag_parsed,
1607 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1608 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1610 (void *)&cmd_config_rx_mode_flag_port,
1611 (void *)&cmd_config_rx_mode_flag_keyword,
1612 (void *)&cmd_config_rx_mode_flag_all,
1613 (void *)&cmd_config_rx_mode_flag_name,
1614 (void *)&cmd_config_rx_mode_flag_value,
1619 /* *** configure rss *** */
1620 struct cmd_config_rss {
1621 cmdline_fixed_string_t port;
1622 cmdline_fixed_string_t keyword;
1623 cmdline_fixed_string_t all;
1624 cmdline_fixed_string_t name;
1625 cmdline_fixed_string_t value;
1629 cmd_config_rss_parsed(void *parsed_result,
1630 __attribute__((unused)) struct cmdline *cl,
1631 __attribute__((unused)) void *data)
1633 struct cmd_config_rss *res = parsed_result;
1634 struct rte_eth_rss_conf rss_conf;
1638 if (!strcmp(res->value, "all"))
1639 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1640 ETH_RSS_UDP | ETH_RSS_SCTP |
1642 else if (!strcmp(res->value, "ip"))
1643 rss_conf.rss_hf = ETH_RSS_IP;
1644 else if (!strcmp(res->value, "udp"))
1645 rss_conf.rss_hf = ETH_RSS_UDP;
1646 else if (!strcmp(res->value, "tcp"))
1647 rss_conf.rss_hf = ETH_RSS_TCP;
1648 else if (!strcmp(res->value, "sctp"))
1649 rss_conf.rss_hf = ETH_RSS_SCTP;
1650 else if (!strcmp(res->value, "ether"))
1651 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1652 else if (!strcmp(res->value, "port"))
1653 rss_conf.rss_hf = ETH_RSS_PORT;
1654 else if (!strcmp(res->value, "vxlan"))
1655 rss_conf.rss_hf = ETH_RSS_VXLAN;
1656 else if (!strcmp(res->value, "geneve"))
1657 rss_conf.rss_hf = ETH_RSS_GENEVE;
1658 else if (!strcmp(res->value, "nvgre"))
1659 rss_conf.rss_hf = ETH_RSS_NVGRE;
1660 else if (!strcmp(res->value, "none"))
1661 rss_conf.rss_hf = 0;
1663 printf("Unknown parameter\n");
1666 rss_conf.rss_key = NULL;
1667 for (i = 0; i < rte_eth_dev_count(); i++) {
1668 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1670 printf("Configuration of RSS hash at ethernet port %d "
1671 "failed with error (%d): %s.\n",
1672 i, -diag, strerror(-diag));
1676 cmdline_parse_token_string_t cmd_config_rss_port =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1678 cmdline_parse_token_string_t cmd_config_rss_keyword =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1680 cmdline_parse_token_string_t cmd_config_rss_all =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1682 cmdline_parse_token_string_t cmd_config_rss_name =
1683 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1684 cmdline_parse_token_string_t cmd_config_rss_value =
1685 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1686 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1688 cmdline_parse_inst_t cmd_config_rss = {
1689 .f = cmd_config_rss_parsed,
1691 .help_str = "port config all rss "
1692 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1694 (void *)&cmd_config_rss_port,
1695 (void *)&cmd_config_rss_keyword,
1696 (void *)&cmd_config_rss_all,
1697 (void *)&cmd_config_rss_name,
1698 (void *)&cmd_config_rss_value,
1703 /* *** configure rss hash key *** */
1704 struct cmd_config_rss_hash_key {
1705 cmdline_fixed_string_t port;
1706 cmdline_fixed_string_t config;
1708 cmdline_fixed_string_t rss_hash_key;
1709 cmdline_fixed_string_t rss_type;
1710 cmdline_fixed_string_t key;
1714 hexa_digit_to_value(char hexa_digit)
1716 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1717 return (uint8_t) (hexa_digit - '0');
1718 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1719 return (uint8_t) ((hexa_digit - 'a') + 10);
1720 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1721 return (uint8_t) ((hexa_digit - 'A') + 10);
1722 /* Invalid hexa digit */
1727 parse_and_check_key_hexa_digit(char *key, int idx)
1731 hexa_v = hexa_digit_to_value(key[idx]);
1733 printf("invalid key: character %c at position %d is not a "
1734 "valid hexa digit\n", key[idx], idx);
1739 cmd_config_rss_hash_key_parsed(void *parsed_result,
1740 __attribute__((unused)) struct cmdline *cl,
1741 __attribute__((unused)) void *data)
1743 struct cmd_config_rss_hash_key *res = parsed_result;
1744 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1748 struct rte_eth_dev_info dev_info;
1749 uint8_t hash_key_size;
1752 memset(&dev_info, 0, sizeof(dev_info));
1753 rte_eth_dev_info_get(res->port_id, &dev_info);
1754 if (dev_info.hash_key_size > 0 &&
1755 dev_info.hash_key_size <= sizeof(hash_key))
1756 hash_key_size = dev_info.hash_key_size;
1758 printf("dev_info did not provide a valid hash key size\n");
1761 /* Check the length of the RSS hash key */
1762 key_len = strlen(res->key);
1763 if (key_len != (hash_key_size * 2)) {
1764 printf("key length: %d invalid - key must be a string of %d"
1765 " hexa-decimal numbers\n",
1766 (int) key_len, hash_key_size * 2);
1769 /* Translate RSS hash key into binary representation */
1770 for (i = 0; i < hash_key_size; i++) {
1771 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1774 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1777 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1779 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1783 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1784 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1785 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1786 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1788 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1789 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1790 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1792 rss_hash_key, "rss-hash-key");
1793 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1795 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1796 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1797 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1798 "ipv6-tcp-ex#ipv6-udp-ex");
1799 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1802 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1803 .f = cmd_config_rss_hash_key_parsed,
1805 .help_str = "port config <port_id> rss-hash-key "
1806 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1807 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1808 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1809 "<string of hex digits (variable length, NIC dependent)>",
1811 (void *)&cmd_config_rss_hash_key_port,
1812 (void *)&cmd_config_rss_hash_key_config,
1813 (void *)&cmd_config_rss_hash_key_port_id,
1814 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1815 (void *)&cmd_config_rss_hash_key_rss_type,
1816 (void *)&cmd_config_rss_hash_key_value,
1821 /* *** configure port rxq/txq start/stop *** */
1822 struct cmd_config_rxtx_queue {
1823 cmdline_fixed_string_t port;
1825 cmdline_fixed_string_t rxtxq;
1827 cmdline_fixed_string_t opname;
1831 cmd_config_rxtx_queue_parsed(void *parsed_result,
1832 __attribute__((unused)) struct cmdline *cl,
1833 __attribute__((unused)) void *data)
1835 struct cmd_config_rxtx_queue *res = parsed_result;
1840 if (test_done == 0) {
1841 printf("Please stop forwarding first\n");
1845 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1848 if (port_is_started(res->portid) != 1) {
1849 printf("Please start port %u first\n", res->portid);
1853 if (!strcmp(res->rxtxq, "rxq"))
1855 else if (!strcmp(res->rxtxq, "txq"))
1858 printf("Unknown parameter\n");
1862 if (isrx && rx_queue_id_is_invalid(res->qid))
1864 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1867 if (!strcmp(res->opname, "start"))
1869 else if (!strcmp(res->opname, "stop"))
1872 printf("Unknown parameter\n");
1876 if (isstart && isrx)
1877 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1878 else if (!isstart && isrx)
1879 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1880 else if (isstart && !isrx)
1881 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1883 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1885 if (ret == -ENOTSUP)
1886 printf("Function not supported in PMD driver\n");
1889 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1890 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1891 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1892 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1893 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1894 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1895 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1896 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1897 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1898 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1901 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1902 .f = cmd_config_rxtx_queue_parsed,
1904 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1906 (void *)&cmd_config_speed_all_port,
1907 (void *)&cmd_config_rxtx_queue_portid,
1908 (void *)&cmd_config_rxtx_queue_rxtxq,
1909 (void *)&cmd_config_rxtx_queue_qid,
1910 (void *)&cmd_config_rxtx_queue_opname,
1915 /* *** Configure RSS RETA *** */
1916 struct cmd_config_rss_reta {
1917 cmdline_fixed_string_t port;
1918 cmdline_fixed_string_t keyword;
1920 cmdline_fixed_string_t name;
1921 cmdline_fixed_string_t list_name;
1922 cmdline_fixed_string_t list_of_items;
1926 parse_reta_config(const char *str,
1927 struct rte_eth_rss_reta_entry64 *reta_conf,
1928 uint16_t nb_entries)
1932 uint16_t hash_index, idx, shift;
1935 const char *p, *p0 = str;
1942 unsigned long int_fld[_NUM_FLD];
1943 char *str_fld[_NUM_FLD];
1945 while ((p = strchr(p0,'(')) != NULL) {
1947 if((p0 = strchr(p,')')) == NULL)
1951 if(size >= sizeof(s))
1954 snprintf(s, sizeof(s), "%.*s", size, p);
1955 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1957 for (i = 0; i < _NUM_FLD; i++) {
1959 int_fld[i] = strtoul(str_fld[i], &end, 0);
1960 if (errno != 0 || end == str_fld[i] ||
1965 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1966 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1968 if (hash_index >= nb_entries) {
1969 printf("Invalid RETA hash index=%d\n", hash_index);
1973 idx = hash_index / RTE_RETA_GROUP_SIZE;
1974 shift = hash_index % RTE_RETA_GROUP_SIZE;
1975 reta_conf[idx].mask |= (1ULL << shift);
1976 reta_conf[idx].reta[shift] = nb_queue;
1983 cmd_set_rss_reta_parsed(void *parsed_result,
1984 __attribute__((unused)) struct cmdline *cl,
1985 __attribute__((unused)) void *data)
1988 struct rte_eth_dev_info dev_info;
1989 struct rte_eth_rss_reta_entry64 reta_conf[8];
1990 struct cmd_config_rss_reta *res = parsed_result;
1992 memset(&dev_info, 0, sizeof(dev_info));
1993 rte_eth_dev_info_get(res->port_id, &dev_info);
1994 if (dev_info.reta_size == 0) {
1995 printf("Redirection table size is 0 which is "
1996 "invalid for RSS\n");
1999 printf("The reta size of port %d is %u\n",
2000 res->port_id, dev_info.reta_size);
2001 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2002 printf("Currently do not support more than %u entries of "
2003 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2007 memset(reta_conf, 0, sizeof(reta_conf));
2008 if (!strcmp(res->list_name, "reta")) {
2009 if (parse_reta_config(res->list_of_items, reta_conf,
2010 dev_info.reta_size)) {
2011 printf("Invalid RSS Redirection Table "
2012 "config entered\n");
2015 ret = rte_eth_dev_rss_reta_update(res->port_id,
2016 reta_conf, dev_info.reta_size);
2018 printf("Bad redirection table parameter, "
2019 "return code = %d \n", ret);
2023 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2024 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2025 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2027 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2028 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2029 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2031 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2032 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2033 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2034 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2036 cmdline_parse_inst_t cmd_config_rss_reta = {
2037 .f = cmd_set_rss_reta_parsed,
2039 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2041 (void *)&cmd_config_rss_reta_port,
2042 (void *)&cmd_config_rss_reta_keyword,
2043 (void *)&cmd_config_rss_reta_port_id,
2044 (void *)&cmd_config_rss_reta_name,
2045 (void *)&cmd_config_rss_reta_list_name,
2046 (void *)&cmd_config_rss_reta_list_of_items,
2051 /* *** SHOW PORT RETA INFO *** */
2052 struct cmd_showport_reta {
2053 cmdline_fixed_string_t show;
2054 cmdline_fixed_string_t port;
2056 cmdline_fixed_string_t rss;
2057 cmdline_fixed_string_t reta;
2059 cmdline_fixed_string_t list_of_items;
2063 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2064 uint16_t nb_entries,
2068 const char *p, *p0 = str;
2072 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2075 p = strchr(p0, '(');
2079 p0 = strchr(p, ')');
2083 if (size >= sizeof(s)) {
2084 printf("The string size exceeds the internal buffer size\n");
2087 snprintf(s, sizeof(s), "%.*s", size, p);
2088 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2089 if (ret <= 0 || ret != num) {
2090 printf("The bits of masks do not match the number of "
2091 "reta entries: %u\n", num);
2094 for (i = 0; i < ret; i++)
2095 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2101 cmd_showport_reta_parsed(void *parsed_result,
2102 __attribute__((unused)) struct cmdline *cl,
2103 __attribute__((unused)) void *data)
2105 struct cmd_showport_reta *res = parsed_result;
2106 struct rte_eth_rss_reta_entry64 reta_conf[8];
2107 struct rte_eth_dev_info dev_info;
2109 memset(&dev_info, 0, sizeof(dev_info));
2110 rte_eth_dev_info_get(res->port_id, &dev_info);
2111 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2112 res->size > ETH_RSS_RETA_SIZE_512) {
2113 printf("Invalid redirection table size: %u\n", res->size);
2117 memset(reta_conf, 0, sizeof(reta_conf));
2118 if (showport_parse_reta_config(reta_conf, res->size,
2119 res->list_of_items) < 0) {
2120 printf("Invalid string: %s for reta masks\n",
2121 res->list_of_items);
2124 port_rss_reta_info(res->port_id, reta_conf, res->size);
2127 cmdline_parse_token_string_t cmd_showport_reta_show =
2128 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2129 cmdline_parse_token_string_t cmd_showport_reta_port =
2130 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2131 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2132 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2133 cmdline_parse_token_string_t cmd_showport_reta_rss =
2134 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2135 cmdline_parse_token_string_t cmd_showport_reta_reta =
2136 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2137 cmdline_parse_token_num_t cmd_showport_reta_size =
2138 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2139 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2140 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2141 list_of_items, NULL);
2143 cmdline_parse_inst_t cmd_showport_reta = {
2144 .f = cmd_showport_reta_parsed,
2146 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2148 (void *)&cmd_showport_reta_show,
2149 (void *)&cmd_showport_reta_port,
2150 (void *)&cmd_showport_reta_port_id,
2151 (void *)&cmd_showport_reta_rss,
2152 (void *)&cmd_showport_reta_reta,
2153 (void *)&cmd_showport_reta_size,
2154 (void *)&cmd_showport_reta_list_of_items,
2159 /* *** Show RSS hash configuration *** */
2160 struct cmd_showport_rss_hash {
2161 cmdline_fixed_string_t show;
2162 cmdline_fixed_string_t port;
2164 cmdline_fixed_string_t rss_hash;
2165 cmdline_fixed_string_t rss_type;
2166 cmdline_fixed_string_t key; /* optional argument */
2169 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2170 __attribute__((unused)) struct cmdline *cl,
2173 struct cmd_showport_rss_hash *res = parsed_result;
2175 port_rss_hash_conf_show(res->port_id, res->rss_type,
2176 show_rss_key != NULL);
2179 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2180 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2181 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2182 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2183 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2184 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2185 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2186 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2188 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2189 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2190 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2191 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2192 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2193 "ipv6-tcp-ex#ipv6-udp-ex");
2194 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2195 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2197 cmdline_parse_inst_t cmd_showport_rss_hash = {
2198 .f = cmd_showport_rss_hash_parsed,
2200 .help_str = "show port <port_id> rss-hash "
2201 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2202 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2203 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2205 (void *)&cmd_showport_rss_hash_show,
2206 (void *)&cmd_showport_rss_hash_port,
2207 (void *)&cmd_showport_rss_hash_port_id,
2208 (void *)&cmd_showport_rss_hash_rss_hash,
2209 (void *)&cmd_showport_rss_hash_rss_hash_info,
2214 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2215 .f = cmd_showport_rss_hash_parsed,
2217 .help_str = "show port <port_id> rss-hash "
2218 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2219 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2220 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2222 (void *)&cmd_showport_rss_hash_show,
2223 (void *)&cmd_showport_rss_hash_port,
2224 (void *)&cmd_showport_rss_hash_port_id,
2225 (void *)&cmd_showport_rss_hash_rss_hash,
2226 (void *)&cmd_showport_rss_hash_rss_hash_info,
2227 (void *)&cmd_showport_rss_hash_rss_key,
2232 /* *** Configure DCB *** */
2233 struct cmd_config_dcb {
2234 cmdline_fixed_string_t port;
2235 cmdline_fixed_string_t config;
2237 cmdline_fixed_string_t dcb;
2238 cmdline_fixed_string_t vt;
2239 cmdline_fixed_string_t vt_en;
2241 cmdline_fixed_string_t pfc;
2242 cmdline_fixed_string_t pfc_en;
2246 cmd_config_dcb_parsed(void *parsed_result,
2247 __attribute__((unused)) struct cmdline *cl,
2248 __attribute__((unused)) void *data)
2250 struct cmd_config_dcb *res = parsed_result;
2251 portid_t port_id = res->port_id;
2252 struct rte_port *port;
2256 port = &ports[port_id];
2257 /** Check if the port is not started **/
2258 if (port->port_status != RTE_PORT_STOPPED) {
2259 printf("Please stop port %d first\n", port_id);
2263 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2264 printf("The invalid number of traffic class,"
2265 " only 4 or 8 allowed.\n");
2269 if (nb_fwd_lcores < res->num_tcs) {
2270 printf("nb_cores shouldn't be less than number of TCs.\n");
2273 if (!strncmp(res->pfc_en, "on", 2))
2278 /* DCB in VT mode */
2279 if (!strncmp(res->vt_en, "on", 2))
2280 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2281 (enum rte_eth_nb_tcs)res->num_tcs,
2284 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2285 (enum rte_eth_nb_tcs)res->num_tcs,
2290 printf("Cannot initialize network ports.\n");
2294 cmd_reconfig_device_queue(port_id, 1, 1);
2297 cmdline_parse_token_string_t cmd_config_dcb_port =
2298 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2299 cmdline_parse_token_string_t cmd_config_dcb_config =
2300 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2301 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2302 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2303 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2304 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2305 cmdline_parse_token_string_t cmd_config_dcb_vt =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2307 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2309 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2310 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2311 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2313 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2316 cmdline_parse_inst_t cmd_config_dcb = {
2317 .f = cmd_config_dcb_parsed,
2319 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2321 (void *)&cmd_config_dcb_port,
2322 (void *)&cmd_config_dcb_config,
2323 (void *)&cmd_config_dcb_port_id,
2324 (void *)&cmd_config_dcb_dcb,
2325 (void *)&cmd_config_dcb_vt,
2326 (void *)&cmd_config_dcb_vt_en,
2327 (void *)&cmd_config_dcb_num_tcs,
2328 (void *)&cmd_config_dcb_pfc,
2329 (void *)&cmd_config_dcb_pfc_en,
2334 /* *** configure number of packets per burst *** */
2335 struct cmd_config_burst {
2336 cmdline_fixed_string_t port;
2337 cmdline_fixed_string_t keyword;
2338 cmdline_fixed_string_t all;
2339 cmdline_fixed_string_t name;
2344 cmd_config_burst_parsed(void *parsed_result,
2345 __attribute__((unused)) struct cmdline *cl,
2346 __attribute__((unused)) void *data)
2348 struct cmd_config_burst *res = parsed_result;
2350 if (!all_ports_stopped()) {
2351 printf("Please stop all ports first\n");
2355 if (!strcmp(res->name, "burst")) {
2356 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2357 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2360 nb_pkt_per_burst = res->value;
2362 printf("Unknown parameter\n");
2368 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2371 cmdline_parse_token_string_t cmd_config_burst_port =
2372 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2373 cmdline_parse_token_string_t cmd_config_burst_keyword =
2374 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2375 cmdline_parse_token_string_t cmd_config_burst_all =
2376 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2377 cmdline_parse_token_string_t cmd_config_burst_name =
2378 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2379 cmdline_parse_token_num_t cmd_config_burst_value =
2380 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2382 cmdline_parse_inst_t cmd_config_burst = {
2383 .f = cmd_config_burst_parsed,
2385 .help_str = "port config all burst <value>",
2387 (void *)&cmd_config_burst_port,
2388 (void *)&cmd_config_burst_keyword,
2389 (void *)&cmd_config_burst_all,
2390 (void *)&cmd_config_burst_name,
2391 (void *)&cmd_config_burst_value,
2396 /* *** configure rx/tx queues *** */
2397 struct cmd_config_thresh {
2398 cmdline_fixed_string_t port;
2399 cmdline_fixed_string_t keyword;
2400 cmdline_fixed_string_t all;
2401 cmdline_fixed_string_t name;
2406 cmd_config_thresh_parsed(void *parsed_result,
2407 __attribute__((unused)) struct cmdline *cl,
2408 __attribute__((unused)) void *data)
2410 struct cmd_config_thresh *res = parsed_result;
2412 if (!all_ports_stopped()) {
2413 printf("Please stop all ports first\n");
2417 if (!strcmp(res->name, "txpt"))
2418 tx_pthresh = res->value;
2419 else if(!strcmp(res->name, "txht"))
2420 tx_hthresh = res->value;
2421 else if(!strcmp(res->name, "txwt"))
2422 tx_wthresh = res->value;
2423 else if(!strcmp(res->name, "rxpt"))
2424 rx_pthresh = res->value;
2425 else if(!strcmp(res->name, "rxht"))
2426 rx_hthresh = res->value;
2427 else if(!strcmp(res->name, "rxwt"))
2428 rx_wthresh = res->value;
2430 printf("Unknown parameter\n");
2436 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2439 cmdline_parse_token_string_t cmd_config_thresh_port =
2440 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2441 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2442 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2443 cmdline_parse_token_string_t cmd_config_thresh_all =
2444 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2445 cmdline_parse_token_string_t cmd_config_thresh_name =
2446 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2447 "txpt#txht#txwt#rxpt#rxht#rxwt");
2448 cmdline_parse_token_num_t cmd_config_thresh_value =
2449 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2451 cmdline_parse_inst_t cmd_config_thresh = {
2452 .f = cmd_config_thresh_parsed,
2454 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2456 (void *)&cmd_config_thresh_port,
2457 (void *)&cmd_config_thresh_keyword,
2458 (void *)&cmd_config_thresh_all,
2459 (void *)&cmd_config_thresh_name,
2460 (void *)&cmd_config_thresh_value,
2465 /* *** configure free/rs threshold *** */
2466 struct cmd_config_threshold {
2467 cmdline_fixed_string_t port;
2468 cmdline_fixed_string_t keyword;
2469 cmdline_fixed_string_t all;
2470 cmdline_fixed_string_t name;
2475 cmd_config_threshold_parsed(void *parsed_result,
2476 __attribute__((unused)) struct cmdline *cl,
2477 __attribute__((unused)) void *data)
2479 struct cmd_config_threshold *res = parsed_result;
2481 if (!all_ports_stopped()) {
2482 printf("Please stop all ports first\n");
2486 if (!strcmp(res->name, "txfreet"))
2487 tx_free_thresh = res->value;
2488 else if (!strcmp(res->name, "txrst"))
2489 tx_rs_thresh = res->value;
2490 else if (!strcmp(res->name, "rxfreet"))
2491 rx_free_thresh = res->value;
2493 printf("Unknown parameter\n");
2499 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2502 cmdline_parse_token_string_t cmd_config_threshold_port =
2503 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2504 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2505 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2507 cmdline_parse_token_string_t cmd_config_threshold_all =
2508 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2509 cmdline_parse_token_string_t cmd_config_threshold_name =
2510 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2511 "txfreet#txrst#rxfreet");
2512 cmdline_parse_token_num_t cmd_config_threshold_value =
2513 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2515 cmdline_parse_inst_t cmd_config_threshold = {
2516 .f = cmd_config_threshold_parsed,
2518 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2520 (void *)&cmd_config_threshold_port,
2521 (void *)&cmd_config_threshold_keyword,
2522 (void *)&cmd_config_threshold_all,
2523 (void *)&cmd_config_threshold_name,
2524 (void *)&cmd_config_threshold_value,
2530 struct cmd_stop_result {
2531 cmdline_fixed_string_t stop;
2534 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2535 __attribute__((unused)) struct cmdline *cl,
2536 __attribute__((unused)) void *data)
2538 stop_packet_forwarding();
2541 cmdline_parse_token_string_t cmd_stop_stop =
2542 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2544 cmdline_parse_inst_t cmd_stop = {
2545 .f = cmd_stop_parsed,
2547 .help_str = "stop: Stop packet forwarding",
2549 (void *)&cmd_stop_stop,
2554 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2557 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2558 unsigned int *parsed_items, int check_unique_values)
2560 unsigned int nb_item;
2568 * First parse all items in the list and store their value.
2573 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2575 if ((c >= '0') && (c <= '9')) {
2576 value = (unsigned int) (value * 10 + (c - '0'));
2581 printf("character %c is not a decimal digit\n", c);
2585 printf("No valid value before comma\n");
2588 if (nb_item < max_items) {
2589 parsed_items[nb_item] = value;
2595 if (nb_item >= max_items) {
2596 printf("Number of %s = %u > %u (maximum items)\n",
2597 item_name, nb_item + 1, max_items);
2600 parsed_items[nb_item++] = value;
2601 if (! check_unique_values)
2605 * Then, check that all values in the list are differents.
2606 * No optimization here...
2608 for (i = 0; i < nb_item; i++) {
2609 for (j = i + 1; j < nb_item; j++) {
2610 if (parsed_items[j] == parsed_items[i]) {
2611 printf("duplicated %s %u at index %u and %u\n",
2612 item_name, parsed_items[i], i, j);
2620 struct cmd_set_list_result {
2621 cmdline_fixed_string_t cmd_keyword;
2622 cmdline_fixed_string_t list_name;
2623 cmdline_fixed_string_t list_of_items;
2626 static void cmd_set_list_parsed(void *parsed_result,
2627 __attribute__((unused)) struct cmdline *cl,
2628 __attribute__((unused)) void *data)
2630 struct cmd_set_list_result *res;
2632 unsigned int lcorelist[RTE_MAX_LCORE];
2633 unsigned int portlist[RTE_MAX_ETHPORTS];
2635 unsigned int nb_item;
2637 if (test_done == 0) {
2638 printf("Please stop forwarding first\n");
2642 res = parsed_result;
2643 if (!strcmp(res->list_name, "corelist")) {
2644 nb_item = parse_item_list(res->list_of_items, "core",
2646 parsed_items.lcorelist, 1);
2648 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2653 if (!strcmp(res->list_name, "portlist")) {
2654 nb_item = parse_item_list(res->list_of_items, "port",
2656 parsed_items.portlist, 1);
2658 set_fwd_ports_list(parsed_items.portlist, nb_item);
2664 cmdline_parse_token_string_t cmd_set_list_keyword =
2665 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2667 cmdline_parse_token_string_t cmd_set_list_name =
2668 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2669 "corelist#portlist");
2670 cmdline_parse_token_string_t cmd_set_list_of_items =
2671 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2674 cmdline_parse_inst_t cmd_set_fwd_list = {
2675 .f = cmd_set_list_parsed,
2677 .help_str = "set corelist|portlist <list0[,list1]*>",
2679 (void *)&cmd_set_list_keyword,
2680 (void *)&cmd_set_list_name,
2681 (void *)&cmd_set_list_of_items,
2686 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2688 struct cmd_setmask_result {
2689 cmdline_fixed_string_t set;
2690 cmdline_fixed_string_t mask;
2694 static void cmd_set_mask_parsed(void *parsed_result,
2695 __attribute__((unused)) struct cmdline *cl,
2696 __attribute__((unused)) void *data)
2698 struct cmd_setmask_result *res = parsed_result;
2700 if (test_done == 0) {
2701 printf("Please stop forwarding first\n");
2704 if (!strcmp(res->mask, "coremask")) {
2705 set_fwd_lcores_mask(res->hexavalue);
2707 } else if (!strcmp(res->mask, "portmask")) {
2708 set_fwd_ports_mask(res->hexavalue);
2713 cmdline_parse_token_string_t cmd_setmask_set =
2714 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2715 cmdline_parse_token_string_t cmd_setmask_mask =
2716 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2717 "coremask#portmask");
2718 cmdline_parse_token_num_t cmd_setmask_value =
2719 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2721 cmdline_parse_inst_t cmd_set_fwd_mask = {
2722 .f = cmd_set_mask_parsed,
2724 .help_str = "set coremask|portmask <hexadecimal value>",
2726 (void *)&cmd_setmask_set,
2727 (void *)&cmd_setmask_mask,
2728 (void *)&cmd_setmask_value,
2734 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2736 struct cmd_set_result {
2737 cmdline_fixed_string_t set;
2738 cmdline_fixed_string_t what;
2742 static void cmd_set_parsed(void *parsed_result,
2743 __attribute__((unused)) struct cmdline *cl,
2744 __attribute__((unused)) void *data)
2746 struct cmd_set_result *res = parsed_result;
2747 if (!strcmp(res->what, "nbport")) {
2748 set_fwd_ports_number(res->value);
2750 } else if (!strcmp(res->what, "nbcore")) {
2751 set_fwd_lcores_number(res->value);
2753 } else if (!strcmp(res->what, "burst"))
2754 set_nb_pkt_per_burst(res->value);
2755 else if (!strcmp(res->what, "verbose"))
2756 set_verbose_level(res->value);
2759 cmdline_parse_token_string_t cmd_set_set =
2760 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2761 cmdline_parse_token_string_t cmd_set_what =
2762 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2763 "nbport#nbcore#burst#verbose");
2764 cmdline_parse_token_num_t cmd_set_value =
2765 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2767 cmdline_parse_inst_t cmd_set_numbers = {
2768 .f = cmd_set_parsed,
2770 .help_str = "set nbport|nbcore|burst|verbose <value>",
2772 (void *)&cmd_set_set,
2773 (void *)&cmd_set_what,
2774 (void *)&cmd_set_value,
2779 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2781 struct cmd_set_txpkts_result {
2782 cmdline_fixed_string_t cmd_keyword;
2783 cmdline_fixed_string_t txpkts;
2784 cmdline_fixed_string_t seg_lengths;
2788 cmd_set_txpkts_parsed(void *parsed_result,
2789 __attribute__((unused)) struct cmdline *cl,
2790 __attribute__((unused)) void *data)
2792 struct cmd_set_txpkts_result *res;
2793 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2794 unsigned int nb_segs;
2796 res = parsed_result;
2797 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2798 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2800 set_tx_pkt_segments(seg_lengths, nb_segs);
2803 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2804 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2805 cmd_keyword, "set");
2806 cmdline_parse_token_string_t cmd_set_txpkts_name =
2807 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2809 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2810 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2813 cmdline_parse_inst_t cmd_set_txpkts = {
2814 .f = cmd_set_txpkts_parsed,
2816 .help_str = "set txpkts <len0[,len1]*>",
2818 (void *)&cmd_set_txpkts_keyword,
2819 (void *)&cmd_set_txpkts_name,
2820 (void *)&cmd_set_txpkts_lengths,
2825 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2827 struct cmd_set_txsplit_result {
2828 cmdline_fixed_string_t cmd_keyword;
2829 cmdline_fixed_string_t txsplit;
2830 cmdline_fixed_string_t mode;
2834 cmd_set_txsplit_parsed(void *parsed_result,
2835 __attribute__((unused)) struct cmdline *cl,
2836 __attribute__((unused)) void *data)
2838 struct cmd_set_txsplit_result *res;
2840 res = parsed_result;
2841 set_tx_pkt_split(res->mode);
2844 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2845 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2846 cmd_keyword, "set");
2847 cmdline_parse_token_string_t cmd_set_txsplit_name =
2848 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2849 txsplit, "txsplit");
2850 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2851 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2854 cmdline_parse_inst_t cmd_set_txsplit = {
2855 .f = cmd_set_txsplit_parsed,
2857 .help_str = "set txsplit on|off|rand",
2859 (void *)&cmd_set_txsplit_keyword,
2860 (void *)&cmd_set_txsplit_name,
2861 (void *)&cmd_set_txsplit_mode,
2866 /* *** CONFIG TX QUEUE FLAGS *** */
2868 struct cmd_config_txqflags_result {
2869 cmdline_fixed_string_t port;
2870 cmdline_fixed_string_t config;
2871 cmdline_fixed_string_t all;
2872 cmdline_fixed_string_t what;
2876 static void cmd_config_txqflags_parsed(void *parsed_result,
2877 __attribute__((unused)) struct cmdline *cl,
2878 __attribute__((unused)) void *data)
2880 struct cmd_config_txqflags_result *res = parsed_result;
2882 if (!all_ports_stopped()) {
2883 printf("Please stop all ports first\n");
2887 if (strcmp(res->what, "txqflags")) {
2888 printf("Unknown parameter\n");
2892 if (res->hexvalue >= 0) {
2893 txq_flags = res->hexvalue;
2895 printf("txqflags must be >= 0\n");
2901 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2904 cmdline_parse_token_string_t cmd_config_txqflags_port =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2907 cmdline_parse_token_string_t cmd_config_txqflags_config =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2910 cmdline_parse_token_string_t cmd_config_txqflags_all =
2911 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2913 cmdline_parse_token_string_t cmd_config_txqflags_what =
2914 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2916 cmdline_parse_token_num_t cmd_config_txqflags_value =
2917 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2920 cmdline_parse_inst_t cmd_config_txqflags = {
2921 .f = cmd_config_txqflags_parsed,
2923 .help_str = "port config all txqflags <value>",
2925 (void *)&cmd_config_txqflags_port,
2926 (void *)&cmd_config_txqflags_config,
2927 (void *)&cmd_config_txqflags_all,
2928 (void *)&cmd_config_txqflags_what,
2929 (void *)&cmd_config_txqflags_value,
2934 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2935 struct cmd_rx_vlan_filter_all_result {
2936 cmdline_fixed_string_t rx_vlan;
2937 cmdline_fixed_string_t what;
2938 cmdline_fixed_string_t all;
2943 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2944 __attribute__((unused)) struct cmdline *cl,
2945 __attribute__((unused)) void *data)
2947 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2949 if (!strcmp(res->what, "add"))
2950 rx_vlan_all_filter_set(res->port_id, 1);
2952 rx_vlan_all_filter_set(res->port_id, 0);
2955 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2956 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2957 rx_vlan, "rx_vlan");
2958 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2959 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2961 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2962 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2964 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2965 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2968 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2969 .f = cmd_rx_vlan_filter_all_parsed,
2971 .help_str = "rx_vlan add|rm all <port_id>: "
2972 "Add/Remove all identifiers to/from the set of VLAN "
2973 "identifiers filtered by a port",
2975 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2976 (void *)&cmd_rx_vlan_filter_all_what,
2977 (void *)&cmd_rx_vlan_filter_all_all,
2978 (void *)&cmd_rx_vlan_filter_all_portid,
2983 /* *** VLAN OFFLOAD SET ON A PORT *** */
2984 struct cmd_vlan_offload_result {
2985 cmdline_fixed_string_t vlan;
2986 cmdline_fixed_string_t set;
2987 cmdline_fixed_string_t vlan_type;
2988 cmdline_fixed_string_t what;
2989 cmdline_fixed_string_t on;
2990 cmdline_fixed_string_t port_id;
2994 cmd_vlan_offload_parsed(void *parsed_result,
2995 __attribute__((unused)) struct cmdline *cl,
2996 __attribute__((unused)) void *data)
2999 struct cmd_vlan_offload_result *res = parsed_result;
3002 portid_t port_id = 0;
3006 len = strnlen(str, STR_TOKEN_SIZE);
3008 /* Get port_id first */
3016 tmp = strtoul(str, NULL, 0);
3017 /* If port_id greater that what portid_t can represent, return */
3018 if(tmp >= RTE_MAX_ETHPORTS)
3020 port_id = (portid_t)tmp;
3022 if (!strcmp(res->on, "on"))
3027 if (!strcmp(res->what, "strip"))
3028 rx_vlan_strip_set(port_id, on);
3029 else if(!strcmp(res->what, "stripq")){
3030 uint16_t queue_id = 0;
3032 /* No queue_id, return */
3034 printf("must specify (port,queue_id)\n");
3037 tmp = strtoul(str + i + 1, NULL, 0);
3038 /* If queue_id greater that what 16-bits can represent, return */
3042 queue_id = (uint16_t)tmp;
3043 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3045 else if (!strcmp(res->what, "filter"))
3046 rx_vlan_filter_set(port_id, on);
3048 vlan_extend_set(port_id, on);
3053 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3054 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3056 cmdline_parse_token_string_t cmd_vlan_offload_set =
3057 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3059 cmdline_parse_token_string_t cmd_vlan_offload_what =
3060 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3061 what, "strip#filter#qinq#stripq");
3062 cmdline_parse_token_string_t cmd_vlan_offload_on =
3063 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3065 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3066 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3069 cmdline_parse_inst_t cmd_vlan_offload = {
3070 .f = cmd_vlan_offload_parsed,
3072 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3073 "<port_id[,queue_id]>: "
3074 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3076 (void *)&cmd_vlan_offload_vlan,
3077 (void *)&cmd_vlan_offload_set,
3078 (void *)&cmd_vlan_offload_what,
3079 (void *)&cmd_vlan_offload_on,
3080 (void *)&cmd_vlan_offload_portid,
3085 /* *** VLAN TPID SET ON A PORT *** */
3086 struct cmd_vlan_tpid_result {
3087 cmdline_fixed_string_t vlan;
3088 cmdline_fixed_string_t set;
3089 cmdline_fixed_string_t vlan_type;
3090 cmdline_fixed_string_t what;
3096 cmd_vlan_tpid_parsed(void *parsed_result,
3097 __attribute__((unused)) struct cmdline *cl,
3098 __attribute__((unused)) void *data)
3100 struct cmd_vlan_tpid_result *res = parsed_result;
3101 enum rte_vlan_type vlan_type;
3103 if (!strcmp(res->vlan_type, "inner"))
3104 vlan_type = ETH_VLAN_TYPE_INNER;
3105 else if (!strcmp(res->vlan_type, "outer"))
3106 vlan_type = ETH_VLAN_TYPE_OUTER;
3108 printf("Unknown vlan type\n");
3111 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3114 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3117 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3118 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3120 cmdline_parse_token_string_t cmd_vlan_type =
3121 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3122 vlan_type, "inner#outer");
3123 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3124 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3126 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3127 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3129 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3130 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3133 cmdline_parse_inst_t cmd_vlan_tpid = {
3134 .f = cmd_vlan_tpid_parsed,
3136 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3137 "Set the VLAN Ether type",
3139 (void *)&cmd_vlan_tpid_vlan,
3140 (void *)&cmd_vlan_tpid_set,
3141 (void *)&cmd_vlan_type,
3142 (void *)&cmd_vlan_tpid_what,
3143 (void *)&cmd_vlan_tpid_tpid,
3144 (void *)&cmd_vlan_tpid_portid,
3149 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3150 struct cmd_rx_vlan_filter_result {
3151 cmdline_fixed_string_t rx_vlan;
3152 cmdline_fixed_string_t what;
3158 cmd_rx_vlan_filter_parsed(void *parsed_result,
3159 __attribute__((unused)) struct cmdline *cl,
3160 __attribute__((unused)) void *data)
3162 struct cmd_rx_vlan_filter_result *res = parsed_result;
3164 if (!strcmp(res->what, "add"))
3165 rx_vft_set(res->port_id, res->vlan_id, 1);
3167 rx_vft_set(res->port_id, res->vlan_id, 0);
3170 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3171 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3172 rx_vlan, "rx_vlan");
3173 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3174 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3176 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3177 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3179 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3180 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3183 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3184 .f = cmd_rx_vlan_filter_parsed,
3186 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3187 "Add/Remove a VLAN identifier to/from the set of VLAN "
3188 "identifiers filtered by a port",
3190 (void *)&cmd_rx_vlan_filter_rx_vlan,
3191 (void *)&cmd_rx_vlan_filter_what,
3192 (void *)&cmd_rx_vlan_filter_vlanid,
3193 (void *)&cmd_rx_vlan_filter_portid,
3198 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3199 struct cmd_tx_vlan_set_result {
3200 cmdline_fixed_string_t tx_vlan;
3201 cmdline_fixed_string_t set;
3207 cmd_tx_vlan_set_parsed(void *parsed_result,
3208 __attribute__((unused)) struct cmdline *cl,
3209 __attribute__((unused)) void *data)
3211 struct cmd_tx_vlan_set_result *res = parsed_result;
3213 tx_vlan_set(res->port_id, res->vlan_id);
3216 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3217 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3218 tx_vlan, "tx_vlan");
3219 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3220 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3222 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3223 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3225 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3226 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3229 cmdline_parse_inst_t cmd_tx_vlan_set = {
3230 .f = cmd_tx_vlan_set_parsed,
3232 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3233 "Enable hardware insertion of a single VLAN header "
3234 "with a given TAG Identifier in packets sent on a port",
3236 (void *)&cmd_tx_vlan_set_tx_vlan,
3237 (void *)&cmd_tx_vlan_set_set,
3238 (void *)&cmd_tx_vlan_set_portid,
3239 (void *)&cmd_tx_vlan_set_vlanid,
3244 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3245 struct cmd_tx_vlan_set_qinq_result {
3246 cmdline_fixed_string_t tx_vlan;
3247 cmdline_fixed_string_t set;
3250 uint16_t vlan_id_outer;
3254 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3255 __attribute__((unused)) struct cmdline *cl,
3256 __attribute__((unused)) void *data)
3258 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3260 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3263 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3264 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3265 tx_vlan, "tx_vlan");
3266 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3267 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3269 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3270 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3272 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3273 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3275 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3276 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3277 vlan_id_outer, UINT16);
3279 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3280 .f = cmd_tx_vlan_set_qinq_parsed,
3282 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3283 "Enable hardware insertion of double VLAN header "
3284 "with given TAG Identifiers in packets sent on a port",
3286 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3287 (void *)&cmd_tx_vlan_set_qinq_set,
3288 (void *)&cmd_tx_vlan_set_qinq_portid,
3289 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3290 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3295 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3296 struct cmd_tx_vlan_set_pvid_result {
3297 cmdline_fixed_string_t tx_vlan;
3298 cmdline_fixed_string_t set;
3299 cmdline_fixed_string_t pvid;
3302 cmdline_fixed_string_t mode;
3306 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3307 __attribute__((unused)) struct cmdline *cl,
3308 __attribute__((unused)) void *data)
3310 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3312 if (strcmp(res->mode, "on") == 0)
3313 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3315 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3318 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3319 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3320 tx_vlan, "tx_vlan");
3321 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3322 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3324 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3325 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3327 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3328 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3330 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3331 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3333 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3334 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3337 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3338 .f = cmd_tx_vlan_set_pvid_parsed,
3340 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3342 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3343 (void *)&cmd_tx_vlan_set_pvid_set,
3344 (void *)&cmd_tx_vlan_set_pvid_pvid,
3345 (void *)&cmd_tx_vlan_set_pvid_port_id,
3346 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3347 (void *)&cmd_tx_vlan_set_pvid_mode,
3352 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3353 struct cmd_tx_vlan_reset_result {
3354 cmdline_fixed_string_t tx_vlan;
3355 cmdline_fixed_string_t reset;
3360 cmd_tx_vlan_reset_parsed(void *parsed_result,
3361 __attribute__((unused)) struct cmdline *cl,
3362 __attribute__((unused)) void *data)
3364 struct cmd_tx_vlan_reset_result *res = parsed_result;
3366 tx_vlan_reset(res->port_id);
3369 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3370 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3371 tx_vlan, "tx_vlan");
3372 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3373 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3375 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3376 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3379 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3380 .f = cmd_tx_vlan_reset_parsed,
3382 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3383 "VLAN header in packets sent on a port",
3385 (void *)&cmd_tx_vlan_reset_tx_vlan,
3386 (void *)&cmd_tx_vlan_reset_reset,
3387 (void *)&cmd_tx_vlan_reset_portid,
3393 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3394 struct cmd_csum_result {
3395 cmdline_fixed_string_t csum;
3396 cmdline_fixed_string_t mode;
3397 cmdline_fixed_string_t proto;
3398 cmdline_fixed_string_t hwsw;
3403 csum_show(int port_id)
3405 struct rte_eth_dev_info dev_info;
3408 ol_flags = ports[port_id].tx_ol_flags;
3409 printf("Parse tunnel is %s\n",
3410 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3411 printf("IP checksum offload is %s\n",
3412 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3413 printf("UDP checksum offload is %s\n",
3414 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3415 printf("TCP checksum offload is %s\n",
3416 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3417 printf("SCTP checksum offload is %s\n",
3418 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3419 printf("Outer-Ip checksum offload is %s\n",
3420 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3422 /* display warnings if configuration is not supported by the NIC */
3423 rte_eth_dev_info_get(port_id, &dev_info);
3424 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3425 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3426 printf("Warning: hardware IP checksum enabled but not "
3427 "supported by port %d\n", port_id);
3429 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3430 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3431 printf("Warning: hardware UDP checksum enabled but not "
3432 "supported by port %d\n", port_id);
3434 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3435 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3436 printf("Warning: hardware TCP checksum enabled but not "
3437 "supported by port %d\n", port_id);
3439 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3440 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3441 printf("Warning: hardware SCTP checksum enabled but not "
3442 "supported by port %d\n", port_id);
3444 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3445 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3446 printf("Warning: hardware outer IP checksum enabled but not "
3447 "supported by port %d\n", port_id);
3452 cmd_csum_parsed(void *parsed_result,
3453 __attribute__((unused)) struct cmdline *cl,
3454 __attribute__((unused)) void *data)
3456 struct cmd_csum_result *res = parsed_result;
3460 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3461 printf("invalid port %d\n", res->port_id);
3465 if (!strcmp(res->mode, "set")) {
3467 if (!strcmp(res->hwsw, "hw"))
3470 if (!strcmp(res->proto, "ip")) {
3471 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3472 } else if (!strcmp(res->proto, "udp")) {
3473 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3474 } else if (!strcmp(res->proto, "tcp")) {
3475 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3476 } else if (!strcmp(res->proto, "sctp")) {
3477 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3478 } else if (!strcmp(res->proto, "outer-ip")) {
3479 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3483 ports[res->port_id].tx_ol_flags |= mask;
3485 ports[res->port_id].tx_ol_flags &= (~mask);
3487 csum_show(res->port_id);
3490 cmdline_parse_token_string_t cmd_csum_csum =
3491 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3493 cmdline_parse_token_string_t cmd_csum_mode =
3494 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3496 cmdline_parse_token_string_t cmd_csum_proto =
3497 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3498 proto, "ip#tcp#udp#sctp#outer-ip");
3499 cmdline_parse_token_string_t cmd_csum_hwsw =
3500 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3502 cmdline_parse_token_num_t cmd_csum_portid =
3503 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3506 cmdline_parse_inst_t cmd_csum_set = {
3507 .f = cmd_csum_parsed,
3509 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3510 "Enable/Disable hardware calculation of L3/L4 checksum when "
3511 "using csum forward engine",
3513 (void *)&cmd_csum_csum,
3514 (void *)&cmd_csum_mode,
3515 (void *)&cmd_csum_proto,
3516 (void *)&cmd_csum_hwsw,
3517 (void *)&cmd_csum_portid,
3522 cmdline_parse_token_string_t cmd_csum_mode_show =
3523 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3526 cmdline_parse_inst_t cmd_csum_show = {
3527 .f = cmd_csum_parsed,
3529 .help_str = "csum show <port_id>: Show checksum offload configuration",
3531 (void *)&cmd_csum_csum,
3532 (void *)&cmd_csum_mode_show,
3533 (void *)&cmd_csum_portid,
3538 /* Enable/disable tunnel parsing */
3539 struct cmd_csum_tunnel_result {
3540 cmdline_fixed_string_t csum;
3541 cmdline_fixed_string_t parse;
3542 cmdline_fixed_string_t onoff;
3547 cmd_csum_tunnel_parsed(void *parsed_result,
3548 __attribute__((unused)) struct cmdline *cl,
3549 __attribute__((unused)) void *data)
3551 struct cmd_csum_tunnel_result *res = parsed_result;
3553 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3556 if (!strcmp(res->onoff, "on"))
3557 ports[res->port_id].tx_ol_flags |=
3558 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3560 ports[res->port_id].tx_ol_flags &=
3561 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3563 csum_show(res->port_id);
3566 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3567 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3569 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3570 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3571 parse, "parse_tunnel");
3572 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3573 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3575 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3576 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3579 cmdline_parse_inst_t cmd_csum_tunnel = {
3580 .f = cmd_csum_tunnel_parsed,
3582 .help_str = "csum parse_tunnel on|off <port_id>: "
3583 "Enable/Disable parsing of tunnels for csum engine",
3585 (void *)&cmd_csum_tunnel_csum,
3586 (void *)&cmd_csum_tunnel_parse,
3587 (void *)&cmd_csum_tunnel_onoff,
3588 (void *)&cmd_csum_tunnel_portid,
3593 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3594 struct cmd_tso_set_result {
3595 cmdline_fixed_string_t tso;
3596 cmdline_fixed_string_t mode;
3602 cmd_tso_set_parsed(void *parsed_result,
3603 __attribute__((unused)) struct cmdline *cl,
3604 __attribute__((unused)) void *data)
3606 struct cmd_tso_set_result *res = parsed_result;
3607 struct rte_eth_dev_info dev_info;
3609 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3612 if (!strcmp(res->mode, "set"))
3613 ports[res->port_id].tso_segsz = res->tso_segsz;
3615 if (ports[res->port_id].tso_segsz == 0)
3616 printf("TSO for non-tunneled packets is disabled\n");
3618 printf("TSO segment size for non-tunneled packets is %d\n",
3619 ports[res->port_id].tso_segsz);
3621 /* display warnings if configuration is not supported by the NIC */
3622 rte_eth_dev_info_get(res->port_id, &dev_info);
3623 if ((ports[res->port_id].tso_segsz != 0) &&
3624 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3625 printf("Warning: TSO enabled but not "
3626 "supported by port %d\n", res->port_id);
3630 cmdline_parse_token_string_t cmd_tso_set_tso =
3631 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3633 cmdline_parse_token_string_t cmd_tso_set_mode =
3634 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3636 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3637 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3639 cmdline_parse_token_num_t cmd_tso_set_portid =
3640 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3643 cmdline_parse_inst_t cmd_tso_set = {
3644 .f = cmd_tso_set_parsed,
3646 .help_str = "tso set <tso_segsz> <port_id>: "
3647 "Set TSO segment size of non-tunneled packets for csum engine "
3650 (void *)&cmd_tso_set_tso,
3651 (void *)&cmd_tso_set_mode,
3652 (void *)&cmd_tso_set_tso_segsz,
3653 (void *)&cmd_tso_set_portid,
3658 cmdline_parse_token_string_t cmd_tso_show_mode =
3659 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3663 cmdline_parse_inst_t cmd_tso_show = {
3664 .f = cmd_tso_set_parsed,
3666 .help_str = "tso show <port_id>: "
3667 "Show TSO segment size of non-tunneled packets for csum engine",
3669 (void *)&cmd_tso_set_tso,
3670 (void *)&cmd_tso_show_mode,
3671 (void *)&cmd_tso_set_portid,
3676 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3677 struct cmd_tunnel_tso_set_result {
3678 cmdline_fixed_string_t tso;
3679 cmdline_fixed_string_t mode;
3685 check_tunnel_tso_nic_support(uint8_t port_id)
3687 struct rte_eth_dev_info dev_info;
3689 rte_eth_dev_info_get(port_id, &dev_info);
3690 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3691 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3692 "supported by port %d\n", port_id);
3693 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3694 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3695 "supported by port %d\n", port_id);
3696 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3697 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3698 "supported by port %d\n", port_id);
3699 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3700 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3701 "supported by port %d\n", port_id);
3705 cmd_tunnel_tso_set_parsed(void *parsed_result,
3706 __attribute__((unused)) struct cmdline *cl,
3707 __attribute__((unused)) void *data)
3709 struct cmd_tunnel_tso_set_result *res = parsed_result;
3711 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3714 if (!strcmp(res->mode, "set"))
3715 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3717 if (ports[res->port_id].tunnel_tso_segsz == 0)
3718 printf("TSO for tunneled packets is disabled\n");
3720 printf("TSO segment size for tunneled packets is %d\n",
3721 ports[res->port_id].tunnel_tso_segsz);
3723 /* Below conditions are needed to make it work:
3724 * (1) tunnel TSO is supported by the NIC;
3725 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3727 * (3) for tunneled pkts with outer L3 of IPv4,
3728 * "csum set outer-ip" must be set to hw, because after tso,
3729 * total_len of outer IP header is changed, and the checksum
3730 * of outer IP header calculated by sw should be wrong; that
3731 * is not necessary for IPv6 tunneled pkts because there's no
3732 * checksum in IP header anymore.
3734 check_tunnel_tso_nic_support(res->port_id);
3736 if (!(ports[res->port_id].tx_ol_flags &
3737 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3738 printf("Warning: csum parse_tunnel must be set "
3739 "so that tunneled packets are recognized\n");
3740 if (!(ports[res->port_id].tx_ol_flags &
3741 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3742 printf("Warning: csum set outer-ip must be set to hw "
3743 "if outer L3 is IPv4; not necessary for IPv6\n");
3747 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3748 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3750 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3751 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3753 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3754 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3756 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3757 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3760 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3761 .f = cmd_tunnel_tso_set_parsed,
3763 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3764 "Set TSO segment size of tunneled packets for csum engine "
3767 (void *)&cmd_tunnel_tso_set_tso,
3768 (void *)&cmd_tunnel_tso_set_mode,
3769 (void *)&cmd_tunnel_tso_set_tso_segsz,
3770 (void *)&cmd_tunnel_tso_set_portid,
3775 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3776 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3780 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3781 .f = cmd_tunnel_tso_set_parsed,
3783 .help_str = "tunnel_tso show <port_id> "
3784 "Show TSO segment size of tunneled packets for csum engine",
3786 (void *)&cmd_tunnel_tso_set_tso,
3787 (void *)&cmd_tunnel_tso_show_mode,
3788 (void *)&cmd_tunnel_tso_set_portid,
3793 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3794 struct cmd_set_flush_rx {
3795 cmdline_fixed_string_t set;
3796 cmdline_fixed_string_t flush_rx;
3797 cmdline_fixed_string_t mode;
3801 cmd_set_flush_rx_parsed(void *parsed_result,
3802 __attribute__((unused)) struct cmdline *cl,
3803 __attribute__((unused)) void *data)
3805 struct cmd_set_flush_rx *res = parsed_result;
3806 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3809 cmdline_parse_token_string_t cmd_setflushrx_set =
3810 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3812 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3813 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3814 flush_rx, "flush_rx");
3815 cmdline_parse_token_string_t cmd_setflushrx_mode =
3816 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3820 cmdline_parse_inst_t cmd_set_flush_rx = {
3821 .f = cmd_set_flush_rx_parsed,
3822 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3825 (void *)&cmd_setflushrx_set,
3826 (void *)&cmd_setflushrx_flush_rx,
3827 (void *)&cmd_setflushrx_mode,
3832 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3833 struct cmd_set_link_check {
3834 cmdline_fixed_string_t set;
3835 cmdline_fixed_string_t link_check;
3836 cmdline_fixed_string_t mode;
3840 cmd_set_link_check_parsed(void *parsed_result,
3841 __attribute__((unused)) struct cmdline *cl,
3842 __attribute__((unused)) void *data)
3844 struct cmd_set_link_check *res = parsed_result;
3845 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3848 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3851 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3853 link_check, "link_check");
3854 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3855 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3859 cmdline_parse_inst_t cmd_set_link_check = {
3860 .f = cmd_set_link_check_parsed,
3861 .help_str = "set link_check on|off: Enable/Disable link status check "
3862 "when starting/stopping a port",
3865 (void *)&cmd_setlinkcheck_set,
3866 (void *)&cmd_setlinkcheck_link_check,
3867 (void *)&cmd_setlinkcheck_mode,
3872 #ifdef RTE_NIC_BYPASS
3873 /* *** SET NIC BYPASS MODE *** */
3874 struct cmd_set_bypass_mode_result {
3875 cmdline_fixed_string_t set;
3876 cmdline_fixed_string_t bypass;
3877 cmdline_fixed_string_t mode;
3878 cmdline_fixed_string_t value;
3883 cmd_set_bypass_mode_parsed(void *parsed_result,
3884 __attribute__((unused)) struct cmdline *cl,
3885 __attribute__((unused)) void *data)
3887 struct cmd_set_bypass_mode_result *res = parsed_result;
3888 portid_t port_id = res->port_id;
3889 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3891 if (!strcmp(res->value, "bypass"))
3892 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3893 else if (!strcmp(res->value, "isolate"))
3894 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3896 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3898 /* Set the bypass mode for the relevant port. */
3899 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3900 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3904 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3907 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3910 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3911 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3913 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3914 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3915 value, "normal#bypass#isolate");
3916 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3917 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3920 cmdline_parse_inst_t cmd_set_bypass_mode = {
3921 .f = cmd_set_bypass_mode_parsed,
3922 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3923 "Set the NIC bypass mode for port_id",
3926 (void *)&cmd_setbypass_mode_set,
3927 (void *)&cmd_setbypass_mode_bypass,
3928 (void *)&cmd_setbypass_mode_mode,
3929 (void *)&cmd_setbypass_mode_value,
3930 (void *)&cmd_setbypass_mode_port,
3935 /* *** SET NIC BYPASS EVENT *** */
3936 struct cmd_set_bypass_event_result {
3937 cmdline_fixed_string_t set;
3938 cmdline_fixed_string_t bypass;
3939 cmdline_fixed_string_t event;
3940 cmdline_fixed_string_t event_value;
3941 cmdline_fixed_string_t mode;
3942 cmdline_fixed_string_t mode_value;
3947 cmd_set_bypass_event_parsed(void *parsed_result,
3948 __attribute__((unused)) struct cmdline *cl,
3949 __attribute__((unused)) void *data)
3952 struct cmd_set_bypass_event_result *res = parsed_result;
3953 portid_t port_id = res->port_id;
3954 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3955 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3957 if (!strcmp(res->event_value, "timeout"))
3958 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3959 else if (!strcmp(res->event_value, "os_on"))
3960 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3961 else if (!strcmp(res->event_value, "os_off"))
3962 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3963 else if (!strcmp(res->event_value, "power_on"))
3964 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3965 else if (!strcmp(res->event_value, "power_off"))
3966 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3968 bypass_event = RTE_BYPASS_EVENT_NONE;
3970 if (!strcmp(res->mode_value, "bypass"))
3971 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3972 else if (!strcmp(res->mode_value, "isolate"))
3973 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3975 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3977 /* Set the watchdog timeout. */
3978 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3981 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3982 (rc = rte_eth_dev_wd_timeout_store(port_id,
3983 bypass_timeout)) != 0) {
3984 printf("Failed to set timeout value %u "
3985 "for port %d, errto code: %d.\n",
3986 bypass_timeout, port_id, rc);
3990 /* Set the bypass event to transition to bypass mode. */
3991 if (0 != rte_eth_dev_bypass_event_store(port_id,
3992 bypass_event, bypass_mode)) {
3993 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3998 cmdline_parse_token_string_t cmd_setbypass_event_set =
3999 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4001 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4004 cmdline_parse_token_string_t cmd_setbypass_event_event =
4005 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4007 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4008 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4009 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4010 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4011 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4013 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4014 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4015 mode_value, "normal#bypass#isolate");
4016 cmdline_parse_token_num_t cmd_setbypass_event_port =
4017 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4020 cmdline_parse_inst_t cmd_set_bypass_event = {
4021 .f = cmd_set_bypass_event_parsed,
4022 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4023 "power_off mode normal|bypass|isolate <port_id>: "
4024 "Set the NIC bypass event mode for port_id",
4027 (void *)&cmd_setbypass_event_set,
4028 (void *)&cmd_setbypass_event_bypass,
4029 (void *)&cmd_setbypass_event_event,
4030 (void *)&cmd_setbypass_event_event_value,
4031 (void *)&cmd_setbypass_event_mode,
4032 (void *)&cmd_setbypass_event_mode_value,
4033 (void *)&cmd_setbypass_event_port,
4039 /* *** SET NIC BYPASS TIMEOUT *** */
4040 struct cmd_set_bypass_timeout_result {
4041 cmdline_fixed_string_t set;
4042 cmdline_fixed_string_t bypass;
4043 cmdline_fixed_string_t timeout;
4044 cmdline_fixed_string_t value;
4048 cmd_set_bypass_timeout_parsed(void *parsed_result,
4049 __attribute__((unused)) struct cmdline *cl,
4050 __attribute__((unused)) void *data)
4052 struct cmd_set_bypass_timeout_result *res = parsed_result;
4054 if (!strcmp(res->value, "1.5"))
4055 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4056 else if (!strcmp(res->value, "2"))
4057 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4058 else if (!strcmp(res->value, "3"))
4059 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4060 else if (!strcmp(res->value, "4"))
4061 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4062 else if (!strcmp(res->value, "8"))
4063 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4064 else if (!strcmp(res->value, "16"))
4065 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4066 else if (!strcmp(res->value, "32"))
4067 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4069 bypass_timeout = RTE_BYPASS_TMT_OFF;
4072 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4073 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4075 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4078 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4079 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4080 timeout, "timeout");
4081 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4082 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4083 value, "0#1.5#2#3#4#8#16#32");
4085 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4086 .f = cmd_set_bypass_timeout_parsed,
4087 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4088 "Set the NIC bypass watchdog timeout in seconds",
4091 (void *)&cmd_setbypass_timeout_set,
4092 (void *)&cmd_setbypass_timeout_bypass,
4093 (void *)&cmd_setbypass_timeout_timeout,
4094 (void *)&cmd_setbypass_timeout_value,
4099 /* *** SHOW NIC BYPASS MODE *** */
4100 struct cmd_show_bypass_config_result {
4101 cmdline_fixed_string_t show;
4102 cmdline_fixed_string_t bypass;
4103 cmdline_fixed_string_t config;
4108 cmd_show_bypass_config_parsed(void *parsed_result,
4109 __attribute__((unused)) struct cmdline *cl,
4110 __attribute__((unused)) void *data)
4112 struct cmd_show_bypass_config_result *res = parsed_result;
4113 uint32_t event_mode;
4114 uint32_t bypass_mode;
4115 portid_t port_id = res->port_id;
4116 uint32_t timeout = bypass_timeout;
4119 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4120 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4121 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4122 {"UNKNOWN", "normal", "bypass", "isolate"};
4123 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4130 int num_events = (sizeof events) / (sizeof events[0]);
4132 /* Display the bypass mode.*/
4133 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4134 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4138 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4139 bypass_mode = RTE_BYPASS_MODE_NONE;
4141 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4144 /* Display the bypass timeout.*/
4145 if (!RTE_BYPASS_TMT_VALID(timeout))
4146 timeout = RTE_BYPASS_TMT_OFF;
4148 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4150 /* Display the bypass events and associated modes. */
4151 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4153 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4154 printf("\tFailed to get bypass mode for event = %s\n",
4157 if (!RTE_BYPASS_MODE_VALID(event_mode))
4158 event_mode = RTE_BYPASS_MODE_NONE;
4160 printf("\tbypass event: %-16s = %s\n", events[i],
4166 cmdline_parse_token_string_t cmd_showbypass_config_show =
4167 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4169 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4170 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4172 cmdline_parse_token_string_t cmd_showbypass_config_config =
4173 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4175 cmdline_parse_token_num_t cmd_showbypass_config_port =
4176 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4179 cmdline_parse_inst_t cmd_show_bypass_config = {
4180 .f = cmd_show_bypass_config_parsed,
4181 .help_str = "show bypass config <port_id>: "
4182 "Show the NIC bypass config for port_id",
4185 (void *)&cmd_showbypass_config_show,
4186 (void *)&cmd_showbypass_config_bypass,
4187 (void *)&cmd_showbypass_config_config,
4188 (void *)&cmd_showbypass_config_port,
4194 #ifdef RTE_LIBRTE_PMD_BOND
4195 /* *** SET BONDING MODE *** */
4196 struct cmd_set_bonding_mode_result {
4197 cmdline_fixed_string_t set;
4198 cmdline_fixed_string_t bonding;
4199 cmdline_fixed_string_t mode;
4204 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4205 __attribute__((unused)) struct cmdline *cl,
4206 __attribute__((unused)) void *data)
4208 struct cmd_set_bonding_mode_result *res = parsed_result;
4209 portid_t port_id = res->port_id;
4211 /* Set the bonding mode for the relevant port. */
4212 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4213 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4216 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4217 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4219 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4220 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4221 bonding, "bonding");
4222 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4223 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4225 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4226 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4228 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4229 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4232 cmdline_parse_inst_t cmd_set_bonding_mode = {
4233 .f = cmd_set_bonding_mode_parsed,
4234 .help_str = "set bonding mode <mode_value> <port_id>: "
4235 "Set the bonding mode for port_id",
4238 (void *) &cmd_setbonding_mode_set,
4239 (void *) &cmd_setbonding_mode_bonding,
4240 (void *) &cmd_setbonding_mode_mode,
4241 (void *) &cmd_setbonding_mode_value,
4242 (void *) &cmd_setbonding_mode_port,
4247 /* *** SET BALANCE XMIT POLICY *** */
4248 struct cmd_set_bonding_balance_xmit_policy_result {
4249 cmdline_fixed_string_t set;
4250 cmdline_fixed_string_t bonding;
4251 cmdline_fixed_string_t balance_xmit_policy;
4253 cmdline_fixed_string_t policy;
4256 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4257 __attribute__((unused)) struct cmdline *cl,
4258 __attribute__((unused)) void *data)
4260 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4261 portid_t port_id = res->port_id;
4264 if (!strcmp(res->policy, "l2")) {
4265 policy = BALANCE_XMIT_POLICY_LAYER2;
4266 } else if (!strcmp(res->policy, "l23")) {
4267 policy = BALANCE_XMIT_POLICY_LAYER23;
4268 } else if (!strcmp(res->policy, "l34")) {
4269 policy = BALANCE_XMIT_POLICY_LAYER34;
4271 printf("\t Invalid xmit policy selection");
4275 /* Set the bonding mode for the relevant port. */
4276 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4277 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4282 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4283 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4285 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4287 bonding, "bonding");
4288 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4289 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4290 balance_xmit_policy, "balance_xmit_policy");
4291 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4292 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4294 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4295 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4296 policy, "l2#l23#l34");
4298 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4299 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4300 .help_str = "set bonding balance_xmit_policy <port_id> "
4302 "Set the bonding balance_xmit_policy for port_id",
4305 (void *)&cmd_setbonding_balance_xmit_policy_set,
4306 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4307 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4308 (void *)&cmd_setbonding_balance_xmit_policy_port,
4309 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4314 /* *** SHOW NIC BONDING CONFIGURATION *** */
4315 struct cmd_show_bonding_config_result {
4316 cmdline_fixed_string_t show;
4317 cmdline_fixed_string_t bonding;
4318 cmdline_fixed_string_t config;
4322 static void cmd_show_bonding_config_parsed(void *parsed_result,
4323 __attribute__((unused)) struct cmdline *cl,
4324 __attribute__((unused)) void *data)
4326 struct cmd_show_bonding_config_result *res = parsed_result;
4328 uint8_t slaves[RTE_MAX_ETHPORTS];
4329 int num_slaves, num_active_slaves;
4332 portid_t port_id = res->port_id;
4334 /* Display the bonding mode.*/
4335 bonding_mode = rte_eth_bond_mode_get(port_id);
4336 if (bonding_mode < 0) {
4337 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4340 printf("\tBonding mode: %d\n", bonding_mode);
4342 if (bonding_mode == BONDING_MODE_BALANCE) {
4343 int balance_xmit_policy;
4345 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4346 if (balance_xmit_policy < 0) {
4347 printf("\tFailed to get balance xmit policy for port = %d\n",
4351 printf("\tBalance Xmit Policy: ");
4353 switch (balance_xmit_policy) {
4354 case BALANCE_XMIT_POLICY_LAYER2:
4355 printf("BALANCE_XMIT_POLICY_LAYER2");
4357 case BALANCE_XMIT_POLICY_LAYER23:
4358 printf("BALANCE_XMIT_POLICY_LAYER23");
4360 case BALANCE_XMIT_POLICY_LAYER34:
4361 printf("BALANCE_XMIT_POLICY_LAYER34");
4368 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4370 if (num_slaves < 0) {
4371 printf("\tFailed to get slave list for port = %d\n", port_id);
4374 if (num_slaves > 0) {
4375 printf("\tSlaves (%d): [", num_slaves);
4376 for (i = 0; i < num_slaves - 1; i++)
4377 printf("%d ", slaves[i]);
4379 printf("%d]\n", slaves[num_slaves - 1]);
4381 printf("\tSlaves: []\n");
4385 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4388 if (num_active_slaves < 0) {
4389 printf("\tFailed to get active slave list for port = %d\n", port_id);
4392 if (num_active_slaves > 0) {
4393 printf("\tActive Slaves (%d): [", num_active_slaves);
4394 for (i = 0; i < num_active_slaves - 1; i++)
4395 printf("%d ", slaves[i]);
4397 printf("%d]\n", slaves[num_active_slaves - 1]);
4400 printf("\tActive Slaves: []\n");
4404 primary_id = rte_eth_bond_primary_get(port_id);
4405 if (primary_id < 0) {
4406 printf("\tFailed to get primary slave for port = %d\n", port_id);
4409 printf("\tPrimary: [%d]\n", primary_id);
4413 cmdline_parse_token_string_t cmd_showbonding_config_show =
4414 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4416 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4417 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4418 bonding, "bonding");
4419 cmdline_parse_token_string_t cmd_showbonding_config_config =
4420 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4422 cmdline_parse_token_num_t cmd_showbonding_config_port =
4423 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4426 cmdline_parse_inst_t cmd_show_bonding_config = {
4427 .f = cmd_show_bonding_config_parsed,
4428 .help_str = "show bonding config <port_id>: "
4429 "Show the bonding config for port_id",
4432 (void *)&cmd_showbonding_config_show,
4433 (void *)&cmd_showbonding_config_bonding,
4434 (void *)&cmd_showbonding_config_config,
4435 (void *)&cmd_showbonding_config_port,
4440 /* *** SET BONDING PRIMARY *** */
4441 struct cmd_set_bonding_primary_result {
4442 cmdline_fixed_string_t set;
4443 cmdline_fixed_string_t bonding;
4444 cmdline_fixed_string_t primary;
4449 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4450 __attribute__((unused)) struct cmdline *cl,
4451 __attribute__((unused)) void *data)
4453 struct cmd_set_bonding_primary_result *res = parsed_result;
4454 portid_t master_port_id = res->port_id;
4455 portid_t slave_port_id = res->slave_id;
4457 /* Set the primary slave for a bonded device. */
4458 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4459 printf("\t Failed to set primary slave for port = %d.\n",
4466 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4467 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4469 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4470 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4471 bonding, "bonding");
4472 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4473 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4474 primary, "primary");
4475 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4476 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4478 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4479 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4482 cmdline_parse_inst_t cmd_set_bonding_primary = {
4483 .f = cmd_set_bonding_primary_parsed,
4484 .help_str = "set bonding primary <slave_id> <port_id>: "
4485 "Set the primary slave for port_id",
4488 (void *)&cmd_setbonding_primary_set,
4489 (void *)&cmd_setbonding_primary_bonding,
4490 (void *)&cmd_setbonding_primary_primary,
4491 (void *)&cmd_setbonding_primary_slave,
4492 (void *)&cmd_setbonding_primary_port,
4497 /* *** ADD SLAVE *** */
4498 struct cmd_add_bonding_slave_result {
4499 cmdline_fixed_string_t add;
4500 cmdline_fixed_string_t bonding;
4501 cmdline_fixed_string_t slave;
4506 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4507 __attribute__((unused)) struct cmdline *cl,
4508 __attribute__((unused)) void *data)
4510 struct cmd_add_bonding_slave_result *res = parsed_result;
4511 portid_t master_port_id = res->port_id;
4512 portid_t slave_port_id = res->slave_id;
4514 /* Set the primary slave for a bonded device. */
4515 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4516 printf("\t Failed to add slave %d to master port = %d.\n",
4517 slave_port_id, master_port_id);
4521 set_port_slave_flag(slave_port_id);
4524 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4525 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4527 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4528 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4529 bonding, "bonding");
4530 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4531 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4533 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4534 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4536 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4537 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4540 cmdline_parse_inst_t cmd_add_bonding_slave = {
4541 .f = cmd_add_bonding_slave_parsed,
4542 .help_str = "add bonding slave <slave_id> <port_id>: "
4543 "Add a slave device to a bonded device",
4546 (void *)&cmd_addbonding_slave_add,
4547 (void *)&cmd_addbonding_slave_bonding,
4548 (void *)&cmd_addbonding_slave_slave,
4549 (void *)&cmd_addbonding_slave_slaveid,
4550 (void *)&cmd_addbonding_slave_port,
4555 /* *** REMOVE SLAVE *** */
4556 struct cmd_remove_bonding_slave_result {
4557 cmdline_fixed_string_t remove;
4558 cmdline_fixed_string_t bonding;
4559 cmdline_fixed_string_t slave;
4564 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4565 __attribute__((unused)) struct cmdline *cl,
4566 __attribute__((unused)) void *data)
4568 struct cmd_remove_bonding_slave_result *res = parsed_result;
4569 portid_t master_port_id = res->port_id;
4570 portid_t slave_port_id = res->slave_id;
4572 /* Set the primary slave for a bonded device. */
4573 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4574 printf("\t Failed to remove slave %d from master port = %d.\n",
4575 slave_port_id, master_port_id);
4579 clear_port_slave_flag(slave_port_id);
4582 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4583 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4585 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4586 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4587 bonding, "bonding");
4588 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4589 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4591 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4592 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4594 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4595 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4598 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4599 .f = cmd_remove_bonding_slave_parsed,
4600 .help_str = "remove bonding slave <slave_id> <port_id>: "
4601 "Remove a slave device from a bonded device",
4604 (void *)&cmd_removebonding_slave_remove,
4605 (void *)&cmd_removebonding_slave_bonding,
4606 (void *)&cmd_removebonding_slave_slave,
4607 (void *)&cmd_removebonding_slave_slaveid,
4608 (void *)&cmd_removebonding_slave_port,
4613 /* *** CREATE BONDED DEVICE *** */
4614 struct cmd_create_bonded_device_result {
4615 cmdline_fixed_string_t create;
4616 cmdline_fixed_string_t bonded;
4617 cmdline_fixed_string_t device;
4622 static int bond_dev_num = 0;
4624 static void cmd_create_bonded_device_parsed(void *parsed_result,
4625 __attribute__((unused)) struct cmdline *cl,
4626 __attribute__((unused)) void *data)
4628 struct cmd_create_bonded_device_result *res = parsed_result;
4629 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4632 if (test_done == 0) {
4633 printf("Please stop forwarding first\n");
4637 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4640 /* Create a new bonded device. */
4641 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4643 printf("\t Failed to create bonded device.\n");
4646 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4649 /* Update number of ports */
4650 nb_ports = rte_eth_dev_count();
4651 reconfig(port_id, res->socket);
4652 rte_eth_promiscuous_enable(port_id);
4653 ports[port_id].enabled = 1;
4658 cmdline_parse_token_string_t cmd_createbonded_device_create =
4659 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4661 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4662 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4664 cmdline_parse_token_string_t cmd_createbonded_device_device =
4665 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4667 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4668 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4670 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4671 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4674 cmdline_parse_inst_t cmd_create_bonded_device = {
4675 .f = cmd_create_bonded_device_parsed,
4676 .help_str = "create bonded device <mode> <socket>: "
4677 "Create a new bonded device with specific bonding mode and socket",
4680 (void *)&cmd_createbonded_device_create,
4681 (void *)&cmd_createbonded_device_bonded,
4682 (void *)&cmd_createbonded_device_device,
4683 (void *)&cmd_createbonded_device_mode,
4684 (void *)&cmd_createbonded_device_socket,
4689 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4690 struct cmd_set_bond_mac_addr_result {
4691 cmdline_fixed_string_t set;
4692 cmdline_fixed_string_t bonding;
4693 cmdline_fixed_string_t mac_addr;
4695 struct ether_addr address;
4698 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4699 __attribute__((unused)) struct cmdline *cl,
4700 __attribute__((unused)) void *data)
4702 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4705 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4708 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4710 /* check the return value and print it if is < 0 */
4712 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4715 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4716 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4717 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4718 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4720 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4721 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4723 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4724 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4725 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4726 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4728 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4729 .f = cmd_set_bond_mac_addr_parsed,
4731 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4733 (void *)&cmd_set_bond_mac_addr_set,
4734 (void *)&cmd_set_bond_mac_addr_bonding,
4735 (void *)&cmd_set_bond_mac_addr_mac,
4736 (void *)&cmd_set_bond_mac_addr_portnum,
4737 (void *)&cmd_set_bond_mac_addr_addr,
4743 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4744 struct cmd_set_bond_mon_period_result {
4745 cmdline_fixed_string_t set;
4746 cmdline_fixed_string_t bonding;
4747 cmdline_fixed_string_t mon_period;
4752 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4753 __attribute__((unused)) struct cmdline *cl,
4754 __attribute__((unused)) void *data)
4756 struct cmd_set_bond_mon_period_result *res = parsed_result;
4759 if (res->port_num >= nb_ports) {
4760 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4764 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4766 /* check the return value and print it if is < 0 */
4768 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4771 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4772 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4774 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4775 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4776 bonding, "bonding");
4777 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4778 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4779 mon_period, "mon_period");
4780 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4781 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4783 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4784 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4787 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4788 .f = cmd_set_bond_mon_period_parsed,
4790 .help_str = "set bonding mon_period <port_id> <period_ms>",
4792 (void *)&cmd_set_bond_mon_period_set,
4793 (void *)&cmd_set_bond_mon_period_bonding,
4794 (void *)&cmd_set_bond_mon_period_mon_period,
4795 (void *)&cmd_set_bond_mon_period_portnum,
4796 (void *)&cmd_set_bond_mon_period_period_ms,
4801 #endif /* RTE_LIBRTE_PMD_BOND */
4803 /* *** SET FORWARDING MODE *** */
4804 struct cmd_set_fwd_mode_result {
4805 cmdline_fixed_string_t set;
4806 cmdline_fixed_string_t fwd;
4807 cmdline_fixed_string_t mode;
4810 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4811 __attribute__((unused)) struct cmdline *cl,
4812 __attribute__((unused)) void *data)
4814 struct cmd_set_fwd_mode_result *res = parsed_result;
4817 set_pkt_forwarding_mode(res->mode);
4820 cmdline_parse_token_string_t cmd_setfwd_set =
4821 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4822 cmdline_parse_token_string_t cmd_setfwd_fwd =
4823 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4824 cmdline_parse_token_string_t cmd_setfwd_mode =
4825 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4826 "" /* defined at init */);
4828 cmdline_parse_inst_t cmd_set_fwd_mode = {
4829 .f = cmd_set_fwd_mode_parsed,
4831 .help_str = NULL, /* defined at init */
4833 (void *)&cmd_setfwd_set,
4834 (void *)&cmd_setfwd_fwd,
4835 (void *)&cmd_setfwd_mode,
4840 static void cmd_set_fwd_mode_init(void)
4843 static char token[128];
4844 static char help[256];
4845 cmdline_parse_token_string_t *token_struct;
4847 modes = list_pkt_forwarding_modes();
4848 snprintf(help, sizeof(help), "set fwd %s: "
4849 "Set packet forwarding mode", modes);
4850 cmd_set_fwd_mode.help_str = help;
4852 /* string token separator is # */
4853 for (c = token; *modes != '\0'; modes++)
4858 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4859 token_struct->string_data.str = token;
4862 /* *** SET RETRY FORWARDING MODE *** */
4863 struct cmd_set_fwd_retry_mode_result {
4864 cmdline_fixed_string_t set;
4865 cmdline_fixed_string_t fwd;
4866 cmdline_fixed_string_t mode;
4867 cmdline_fixed_string_t retry;
4870 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4871 __attribute__((unused)) struct cmdline *cl,
4872 __attribute__((unused)) void *data)
4874 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4877 set_pkt_forwarding_mode(res->mode);
4880 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4883 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4884 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4886 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4887 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4889 "" /* defined at init */);
4890 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4891 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4894 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4895 .f = cmd_set_fwd_retry_mode_parsed,
4897 .help_str = NULL, /* defined at init */
4899 (void *)&cmd_setfwd_retry_set,
4900 (void *)&cmd_setfwd_retry_fwd,
4901 (void *)&cmd_setfwd_retry_mode,
4902 (void *)&cmd_setfwd_retry_retry,
4907 static void cmd_set_fwd_retry_mode_init(void)
4910 static char token[128];
4911 static char help[256];
4912 cmdline_parse_token_string_t *token_struct;
4914 modes = list_pkt_forwarding_retry_modes();
4915 snprintf(help, sizeof(help), "set fwd %s retry: "
4916 "Set packet forwarding mode with retry", modes);
4917 cmd_set_fwd_retry_mode.help_str = help;
4919 /* string token separator is # */
4920 for (c = token; *modes != '\0'; modes++)
4925 token_struct = (cmdline_parse_token_string_t *)
4926 cmd_set_fwd_retry_mode.tokens[2];
4927 token_struct->string_data.str = token;
4930 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4931 struct cmd_set_burst_tx_retry_result {
4932 cmdline_fixed_string_t set;
4933 cmdline_fixed_string_t burst;
4934 cmdline_fixed_string_t tx;
4935 cmdline_fixed_string_t delay;
4937 cmdline_fixed_string_t retry;
4941 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4942 __attribute__((unused)) struct cmdline *cl,
4943 __attribute__((unused)) void *data)
4945 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4947 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4948 && !strcmp(res->tx, "tx")) {
4949 if (!strcmp(res->delay, "delay"))
4950 burst_tx_delay_time = res->time;
4951 if (!strcmp(res->retry, "retry"))
4952 burst_tx_retry_num = res->retry_num;
4957 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4958 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4959 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4960 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4962 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4963 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4964 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4965 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4966 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4967 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4968 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4969 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4970 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4971 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4973 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4974 .f = cmd_set_burst_tx_retry_parsed,
4975 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4977 (void *)&cmd_set_burst_tx_retry_set,
4978 (void *)&cmd_set_burst_tx_retry_burst,
4979 (void *)&cmd_set_burst_tx_retry_tx,
4980 (void *)&cmd_set_burst_tx_retry_delay,
4981 (void *)&cmd_set_burst_tx_retry_time,
4982 (void *)&cmd_set_burst_tx_retry_retry,
4983 (void *)&cmd_set_burst_tx_retry_retry_num,
4988 /* *** SET PROMISC MODE *** */
4989 struct cmd_set_promisc_mode_result {
4990 cmdline_fixed_string_t set;
4991 cmdline_fixed_string_t promisc;
4992 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4993 uint8_t port_num; /* valid if "allports" argument == 0 */
4994 cmdline_fixed_string_t mode;
4997 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4998 __attribute__((unused)) struct cmdline *cl,
5001 struct cmd_set_promisc_mode_result *res = parsed_result;
5005 if (!strcmp(res->mode, "on"))
5012 FOREACH_PORT(i, ports) {
5014 rte_eth_promiscuous_enable(i);
5016 rte_eth_promiscuous_disable(i);
5021 rte_eth_promiscuous_enable(res->port_num);
5023 rte_eth_promiscuous_disable(res->port_num);
5027 cmdline_parse_token_string_t cmd_setpromisc_set =
5028 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5029 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5030 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5032 cmdline_parse_token_string_t cmd_setpromisc_portall =
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5035 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5036 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5038 cmdline_parse_token_string_t cmd_setpromisc_mode =
5039 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5042 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5043 .f = cmd_set_promisc_mode_parsed,
5045 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5047 (void *)&cmd_setpromisc_set,
5048 (void *)&cmd_setpromisc_promisc,
5049 (void *)&cmd_setpromisc_portall,
5050 (void *)&cmd_setpromisc_mode,
5055 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5056 .f = cmd_set_promisc_mode_parsed,
5058 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5060 (void *)&cmd_setpromisc_set,
5061 (void *)&cmd_setpromisc_promisc,
5062 (void *)&cmd_setpromisc_portnum,
5063 (void *)&cmd_setpromisc_mode,
5068 /* *** SET ALLMULTI MODE *** */
5069 struct cmd_set_allmulti_mode_result {
5070 cmdline_fixed_string_t set;
5071 cmdline_fixed_string_t allmulti;
5072 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5073 uint8_t port_num; /* valid if "allports" argument == 0 */
5074 cmdline_fixed_string_t mode;
5077 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5078 __attribute__((unused)) struct cmdline *cl,
5081 struct cmd_set_allmulti_mode_result *res = parsed_result;
5085 if (!strcmp(res->mode, "on"))
5092 FOREACH_PORT(i, ports) {
5094 rte_eth_allmulticast_enable(i);
5096 rte_eth_allmulticast_disable(i);
5101 rte_eth_allmulticast_enable(res->port_num);
5103 rte_eth_allmulticast_disable(res->port_num);
5107 cmdline_parse_token_string_t cmd_setallmulti_set =
5108 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5109 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5110 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5112 cmdline_parse_token_string_t cmd_setallmulti_portall =
5113 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5115 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5116 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5118 cmdline_parse_token_string_t cmd_setallmulti_mode =
5119 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5122 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5123 .f = cmd_set_allmulti_mode_parsed,
5125 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5127 (void *)&cmd_setallmulti_set,
5128 (void *)&cmd_setallmulti_allmulti,
5129 (void *)&cmd_setallmulti_portall,
5130 (void *)&cmd_setallmulti_mode,
5135 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5136 .f = cmd_set_allmulti_mode_parsed,
5138 .help_str = "set allmulti <port_id> on|off: "
5139 "Set allmulti mode on port_id",
5141 (void *)&cmd_setallmulti_set,
5142 (void *)&cmd_setallmulti_allmulti,
5143 (void *)&cmd_setallmulti_portnum,
5144 (void *)&cmd_setallmulti_mode,
5149 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5150 struct cmd_link_flow_ctrl_set_result {
5151 cmdline_fixed_string_t set;
5152 cmdline_fixed_string_t flow_ctrl;
5153 cmdline_fixed_string_t rx;
5154 cmdline_fixed_string_t rx_lfc_mode;
5155 cmdline_fixed_string_t tx;
5156 cmdline_fixed_string_t tx_lfc_mode;
5157 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5158 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5159 cmdline_fixed_string_t autoneg_str;
5160 cmdline_fixed_string_t autoneg;
5161 cmdline_fixed_string_t hw_str;
5162 uint32_t high_water;
5163 cmdline_fixed_string_t lw_str;
5165 cmdline_fixed_string_t pt_str;
5166 uint16_t pause_time;
5167 cmdline_fixed_string_t xon_str;
5172 cmdline_parse_token_string_t cmd_lfc_set_set =
5173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5175 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5177 flow_ctrl, "flow_ctrl");
5178 cmdline_parse_token_string_t cmd_lfc_set_rx =
5179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5181 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5182 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5183 rx_lfc_mode, "on#off");
5184 cmdline_parse_token_string_t cmd_lfc_set_tx =
5185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5187 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5188 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5189 tx_lfc_mode, "on#off");
5190 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5191 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 hw_str, "high_water");
5193 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5194 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5195 high_water, UINT32);
5196 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5197 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 lw_str, "low_water");
5199 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5200 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5202 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5203 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 pt_str, "pause_time");
5205 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5206 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5207 pause_time, UINT16);
5208 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5209 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5210 xon_str, "send_xon");
5211 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5212 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5214 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5215 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5216 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5217 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5218 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5219 mac_ctrl_frame_fwd_mode, "on#off");
5220 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5221 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5222 autoneg_str, "autoneg");
5223 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5224 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5226 cmdline_parse_token_num_t cmd_lfc_set_portid =
5227 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5230 /* forward declaration */
5232 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5235 cmdline_parse_inst_t cmd_link_flow_control_set = {
5236 .f = cmd_link_flow_ctrl_set_parsed,
5238 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5239 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5240 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5242 (void *)&cmd_lfc_set_set,
5243 (void *)&cmd_lfc_set_flow_ctrl,
5244 (void *)&cmd_lfc_set_rx,
5245 (void *)&cmd_lfc_set_rx_mode,
5246 (void *)&cmd_lfc_set_tx,
5247 (void *)&cmd_lfc_set_tx_mode,
5248 (void *)&cmd_lfc_set_high_water,
5249 (void *)&cmd_lfc_set_low_water,
5250 (void *)&cmd_lfc_set_pause_time,
5251 (void *)&cmd_lfc_set_send_xon,
5252 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5253 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5254 (void *)&cmd_lfc_set_autoneg_str,
5255 (void *)&cmd_lfc_set_autoneg,
5256 (void *)&cmd_lfc_set_portid,
5261 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5262 .f = cmd_link_flow_ctrl_set_parsed,
5263 .data = (void *)&cmd_link_flow_control_set_rx,
5264 .help_str = "set flow_ctrl rx on|off <port_id>: "
5265 "Change rx flow control parameter",
5267 (void *)&cmd_lfc_set_set,
5268 (void *)&cmd_lfc_set_flow_ctrl,
5269 (void *)&cmd_lfc_set_rx,
5270 (void *)&cmd_lfc_set_rx_mode,
5271 (void *)&cmd_lfc_set_portid,
5276 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5277 .f = cmd_link_flow_ctrl_set_parsed,
5278 .data = (void *)&cmd_link_flow_control_set_tx,
5279 .help_str = "set flow_ctrl tx on|off <port_id>: "
5280 "Change tx flow control parameter",
5282 (void *)&cmd_lfc_set_set,
5283 (void *)&cmd_lfc_set_flow_ctrl,
5284 (void *)&cmd_lfc_set_tx,
5285 (void *)&cmd_lfc_set_tx_mode,
5286 (void *)&cmd_lfc_set_portid,
5291 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5292 .f = cmd_link_flow_ctrl_set_parsed,
5293 .data = (void *)&cmd_link_flow_control_set_hw,
5294 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5295 "Change high water flow control parameter",
5297 (void *)&cmd_lfc_set_set,
5298 (void *)&cmd_lfc_set_flow_ctrl,
5299 (void *)&cmd_lfc_set_high_water_str,
5300 (void *)&cmd_lfc_set_high_water,
5301 (void *)&cmd_lfc_set_portid,
5306 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5307 .f = cmd_link_flow_ctrl_set_parsed,
5308 .data = (void *)&cmd_link_flow_control_set_lw,
5309 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5310 "Change low water flow control parameter",
5312 (void *)&cmd_lfc_set_set,
5313 (void *)&cmd_lfc_set_flow_ctrl,
5314 (void *)&cmd_lfc_set_low_water_str,
5315 (void *)&cmd_lfc_set_low_water,
5316 (void *)&cmd_lfc_set_portid,
5321 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5322 .f = cmd_link_flow_ctrl_set_parsed,
5323 .data = (void *)&cmd_link_flow_control_set_pt,
5324 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5325 "Change pause time flow control parameter",
5327 (void *)&cmd_lfc_set_set,
5328 (void *)&cmd_lfc_set_flow_ctrl,
5329 (void *)&cmd_lfc_set_pause_time_str,
5330 (void *)&cmd_lfc_set_pause_time,
5331 (void *)&cmd_lfc_set_portid,
5336 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5337 .f = cmd_link_flow_ctrl_set_parsed,
5338 .data = (void *)&cmd_link_flow_control_set_xon,
5339 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5340 "Change send_xon flow control parameter",
5342 (void *)&cmd_lfc_set_set,
5343 (void *)&cmd_lfc_set_flow_ctrl,
5344 (void *)&cmd_lfc_set_send_xon_str,
5345 (void *)&cmd_lfc_set_send_xon,
5346 (void *)&cmd_lfc_set_portid,
5351 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5352 .f = cmd_link_flow_ctrl_set_parsed,
5353 .data = (void *)&cmd_link_flow_control_set_macfwd,
5354 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5355 "Change mac ctrl fwd flow control parameter",
5357 (void *)&cmd_lfc_set_set,
5358 (void *)&cmd_lfc_set_flow_ctrl,
5359 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5360 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5361 (void *)&cmd_lfc_set_portid,
5366 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5367 .f = cmd_link_flow_ctrl_set_parsed,
5368 .data = (void *)&cmd_link_flow_control_set_autoneg,
5369 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5370 "Change autoneg flow control parameter",
5372 (void *)&cmd_lfc_set_set,
5373 (void *)&cmd_lfc_set_flow_ctrl,
5374 (void *)&cmd_lfc_set_autoneg_str,
5375 (void *)&cmd_lfc_set_autoneg,
5376 (void *)&cmd_lfc_set_portid,
5382 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5383 __attribute__((unused)) struct cmdline *cl,
5386 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5387 cmdline_parse_inst_t *cmd = data;
5388 struct rte_eth_fc_conf fc_conf;
5394 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5395 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5396 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5397 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5399 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5400 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5403 /* Partial command line, retrieve current configuration */
5405 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5407 printf("cannot get current flow ctrl parameters, return"
5408 "code = %d\n", ret);
5412 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5413 (fc_conf.mode == RTE_FC_FULL))
5415 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5416 (fc_conf.mode == RTE_FC_FULL))
5420 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5421 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5423 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5424 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5426 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5428 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5429 fc_conf.high_water = res->high_water;
5431 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5432 fc_conf.low_water = res->low_water;
5434 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5435 fc_conf.pause_time = res->pause_time;
5437 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5438 fc_conf.send_xon = res->send_xon;
5440 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5441 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5442 fc_conf.mac_ctrl_frame_fwd = 1;
5444 fc_conf.mac_ctrl_frame_fwd = 0;
5447 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5448 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5450 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5452 printf("bad flow contrl parameter, return code = %d \n", ret);
5455 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5456 struct cmd_priority_flow_ctrl_set_result {
5457 cmdline_fixed_string_t set;
5458 cmdline_fixed_string_t pfc_ctrl;
5459 cmdline_fixed_string_t rx;
5460 cmdline_fixed_string_t rx_pfc_mode;
5461 cmdline_fixed_string_t tx;
5462 cmdline_fixed_string_t tx_pfc_mode;
5463 uint32_t high_water;
5465 uint16_t pause_time;
5471 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5472 __attribute__((unused)) struct cmdline *cl,
5473 __attribute__((unused)) void *data)
5475 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5476 struct rte_eth_pfc_conf pfc_conf;
5477 int rx_fc_enable, tx_fc_enable;
5481 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5482 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5483 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5484 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5486 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5487 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5490 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5491 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5492 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5493 pfc_conf.fc.high_water = res->high_water;
5494 pfc_conf.fc.low_water = res->low_water;
5495 pfc_conf.fc.pause_time = res->pause_time;
5496 pfc_conf.priority = res->priority;
5498 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5500 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5503 cmdline_parse_token_string_t cmd_pfc_set_set =
5504 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5506 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5507 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5508 pfc_ctrl, "pfc_ctrl");
5509 cmdline_parse_token_string_t cmd_pfc_set_rx =
5510 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5512 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5513 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5514 rx_pfc_mode, "on#off");
5515 cmdline_parse_token_string_t cmd_pfc_set_tx =
5516 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5518 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5519 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5520 tx_pfc_mode, "on#off");
5521 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5522 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5523 high_water, UINT32);
5524 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5525 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5527 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5528 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5529 pause_time, UINT16);
5530 cmdline_parse_token_num_t cmd_pfc_set_priority =
5531 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5533 cmdline_parse_token_num_t cmd_pfc_set_portid =
5534 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5537 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5538 .f = cmd_priority_flow_ctrl_set_parsed,
5540 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5541 "<pause_time> <priority> <port_id>: "
5542 "Configure the Ethernet priority flow control",
5544 (void *)&cmd_pfc_set_set,
5545 (void *)&cmd_pfc_set_flow_ctrl,
5546 (void *)&cmd_pfc_set_rx,
5547 (void *)&cmd_pfc_set_rx_mode,
5548 (void *)&cmd_pfc_set_tx,
5549 (void *)&cmd_pfc_set_tx_mode,
5550 (void *)&cmd_pfc_set_high_water,
5551 (void *)&cmd_pfc_set_low_water,
5552 (void *)&cmd_pfc_set_pause_time,
5553 (void *)&cmd_pfc_set_priority,
5554 (void *)&cmd_pfc_set_portid,
5559 /* *** RESET CONFIGURATION *** */
5560 struct cmd_reset_result {
5561 cmdline_fixed_string_t reset;
5562 cmdline_fixed_string_t def;
5565 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5567 __attribute__((unused)) void *data)
5569 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5570 set_def_fwd_config();
5573 cmdline_parse_token_string_t cmd_reset_set =
5574 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5575 cmdline_parse_token_string_t cmd_reset_def =
5576 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5579 cmdline_parse_inst_t cmd_reset = {
5580 .f = cmd_reset_parsed,
5582 .help_str = "set default: Reset default forwarding configuration",
5584 (void *)&cmd_reset_set,
5585 (void *)&cmd_reset_def,
5590 /* *** START FORWARDING *** */
5591 struct cmd_start_result {
5592 cmdline_fixed_string_t start;
5595 cmdline_parse_token_string_t cmd_start_start =
5596 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5598 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5599 __attribute__((unused)) struct cmdline *cl,
5600 __attribute__((unused)) void *data)
5602 start_packet_forwarding(0);
5605 cmdline_parse_inst_t cmd_start = {
5606 .f = cmd_start_parsed,
5608 .help_str = "start: Start packet forwarding",
5610 (void *)&cmd_start_start,
5615 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5616 struct cmd_start_tx_first_result {
5617 cmdline_fixed_string_t start;
5618 cmdline_fixed_string_t tx_first;
5622 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5623 __attribute__((unused)) struct cmdline *cl,
5624 __attribute__((unused)) void *data)
5626 start_packet_forwarding(1);
5629 cmdline_parse_token_string_t cmd_start_tx_first_start =
5630 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5632 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5633 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5634 tx_first, "tx_first");
5636 cmdline_parse_inst_t cmd_start_tx_first = {
5637 .f = cmd_start_tx_first_parsed,
5639 .help_str = "start tx_first: Start packet forwarding, "
5640 "after sending 1 burst of packets",
5642 (void *)&cmd_start_tx_first_start,
5643 (void *)&cmd_start_tx_first_tx_first,
5648 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5649 struct cmd_start_tx_first_n_result {
5650 cmdline_fixed_string_t start;
5651 cmdline_fixed_string_t tx_first;
5656 cmd_start_tx_first_n_parsed(void *parsed_result,
5657 __attribute__((unused)) struct cmdline *cl,
5658 __attribute__((unused)) void *data)
5660 struct cmd_start_tx_first_n_result *res = parsed_result;
5662 start_packet_forwarding(res->tx_num);
5665 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5666 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5668 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5669 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5670 tx_first, "tx_first");
5671 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5672 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5675 cmdline_parse_inst_t cmd_start_tx_first_n = {
5676 .f = cmd_start_tx_first_n_parsed,
5678 .help_str = "start tx_first <num>: "
5679 "packet forwarding, after sending <num> bursts of packets",
5681 (void *)&cmd_start_tx_first_n_start,
5682 (void *)&cmd_start_tx_first_n_tx_first,
5683 (void *)&cmd_start_tx_first_n_tx_num,
5688 /* *** SET LINK UP *** */
5689 struct cmd_set_link_up_result {
5690 cmdline_fixed_string_t set;
5691 cmdline_fixed_string_t link_up;
5692 cmdline_fixed_string_t port;
5696 cmdline_parse_token_string_t cmd_set_link_up_set =
5697 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5698 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5701 cmdline_parse_token_string_t cmd_set_link_up_port =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5703 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5704 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5706 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5707 __attribute__((unused)) struct cmdline *cl,
5708 __attribute__((unused)) void *data)
5710 struct cmd_set_link_up_result *res = parsed_result;
5711 dev_set_link_up(res->port_id);
5714 cmdline_parse_inst_t cmd_set_link_up = {
5715 .f = cmd_set_link_up_parsed,
5717 .help_str = "set link-up port <port id>",
5719 (void *)&cmd_set_link_up_set,
5720 (void *)&cmd_set_link_up_link_up,
5721 (void *)&cmd_set_link_up_port,
5722 (void *)&cmd_set_link_up_port_id,
5727 /* *** SET LINK DOWN *** */
5728 struct cmd_set_link_down_result {
5729 cmdline_fixed_string_t set;
5730 cmdline_fixed_string_t link_down;
5731 cmdline_fixed_string_t port;
5735 cmdline_parse_token_string_t cmd_set_link_down_set =
5736 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5737 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5738 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5740 cmdline_parse_token_string_t cmd_set_link_down_port =
5741 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5742 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5743 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5745 static void cmd_set_link_down_parsed(
5746 __attribute__((unused)) void *parsed_result,
5747 __attribute__((unused)) struct cmdline *cl,
5748 __attribute__((unused)) void *data)
5750 struct cmd_set_link_down_result *res = parsed_result;
5751 dev_set_link_down(res->port_id);
5754 cmdline_parse_inst_t cmd_set_link_down = {
5755 .f = cmd_set_link_down_parsed,
5757 .help_str = "set link-down port <port id>",
5759 (void *)&cmd_set_link_down_set,
5760 (void *)&cmd_set_link_down_link_down,
5761 (void *)&cmd_set_link_down_port,
5762 (void *)&cmd_set_link_down_port_id,
5767 /* *** SHOW CFG *** */
5768 struct cmd_showcfg_result {
5769 cmdline_fixed_string_t show;
5770 cmdline_fixed_string_t cfg;
5771 cmdline_fixed_string_t what;
5774 static void cmd_showcfg_parsed(void *parsed_result,
5775 __attribute__((unused)) struct cmdline *cl,
5776 __attribute__((unused)) void *data)
5778 struct cmd_showcfg_result *res = parsed_result;
5779 if (!strcmp(res->what, "rxtx"))
5780 rxtx_config_display();
5781 else if (!strcmp(res->what, "cores"))
5782 fwd_lcores_config_display();
5783 else if (!strcmp(res->what, "fwd"))
5784 pkt_fwd_config_display(&cur_fwd_config);
5785 else if (!strcmp(res->what, "txpkts"))
5786 show_tx_pkt_segments();
5789 cmdline_parse_token_string_t cmd_showcfg_show =
5790 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5791 cmdline_parse_token_string_t cmd_showcfg_port =
5792 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5793 cmdline_parse_token_string_t cmd_showcfg_what =
5794 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5795 "rxtx#cores#fwd#txpkts");
5797 cmdline_parse_inst_t cmd_showcfg = {
5798 .f = cmd_showcfg_parsed,
5800 .help_str = "show config rxtx|cores|fwd|txpkts",
5802 (void *)&cmd_showcfg_show,
5803 (void *)&cmd_showcfg_port,
5804 (void *)&cmd_showcfg_what,
5809 /* *** SHOW ALL PORT INFO *** */
5810 struct cmd_showportall_result {
5811 cmdline_fixed_string_t show;
5812 cmdline_fixed_string_t port;
5813 cmdline_fixed_string_t what;
5814 cmdline_fixed_string_t all;
5817 static void cmd_showportall_parsed(void *parsed_result,
5818 __attribute__((unused)) struct cmdline *cl,
5819 __attribute__((unused)) void *data)
5823 struct cmd_showportall_result *res = parsed_result;
5824 if (!strcmp(res->show, "clear")) {
5825 if (!strcmp(res->what, "stats"))
5826 FOREACH_PORT(i, ports)
5828 else if (!strcmp(res->what, "xstats"))
5829 FOREACH_PORT(i, ports)
5830 nic_xstats_clear(i);
5831 } else if (!strcmp(res->what, "info"))
5832 FOREACH_PORT(i, ports)
5833 port_infos_display(i);
5834 else if (!strcmp(res->what, "stats"))
5835 FOREACH_PORT(i, ports)
5836 nic_stats_display(i);
5837 else if (!strcmp(res->what, "xstats"))
5838 FOREACH_PORT(i, ports)
5839 nic_xstats_display(i);
5840 else if (!strcmp(res->what, "fdir"))
5841 FOREACH_PORT(i, ports)
5843 else if (!strcmp(res->what, "stat_qmap"))
5844 FOREACH_PORT(i, ports)
5845 nic_stats_mapping_display(i);
5846 else if (!strcmp(res->what, "dcb_tc"))
5847 FOREACH_PORT(i, ports)
5848 port_dcb_info_display(i);
5849 else if (!strcmp(res->what, "cap"))
5850 FOREACH_PORT(i, ports)
5851 port_offload_cap_display(i);
5854 cmdline_parse_token_string_t cmd_showportall_show =
5855 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5857 cmdline_parse_token_string_t cmd_showportall_port =
5858 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5859 cmdline_parse_token_string_t cmd_showportall_what =
5860 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5861 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5862 cmdline_parse_token_string_t cmd_showportall_all =
5863 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5864 cmdline_parse_inst_t cmd_showportall = {
5865 .f = cmd_showportall_parsed,
5867 .help_str = "show|clear port "
5868 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5870 (void *)&cmd_showportall_show,
5871 (void *)&cmd_showportall_port,
5872 (void *)&cmd_showportall_what,
5873 (void *)&cmd_showportall_all,
5878 /* *** SHOW PORT INFO *** */
5879 struct cmd_showport_result {
5880 cmdline_fixed_string_t show;
5881 cmdline_fixed_string_t port;
5882 cmdline_fixed_string_t what;
5886 static void cmd_showport_parsed(void *parsed_result,
5887 __attribute__((unused)) struct cmdline *cl,
5888 __attribute__((unused)) void *data)
5890 struct cmd_showport_result *res = parsed_result;
5891 if (!strcmp(res->show, "clear")) {
5892 if (!strcmp(res->what, "stats"))
5893 nic_stats_clear(res->portnum);
5894 else if (!strcmp(res->what, "xstats"))
5895 nic_xstats_clear(res->portnum);
5896 } else if (!strcmp(res->what, "info"))
5897 port_infos_display(res->portnum);
5898 else if (!strcmp(res->what, "stats"))
5899 nic_stats_display(res->portnum);
5900 else if (!strcmp(res->what, "xstats"))
5901 nic_xstats_display(res->portnum);
5902 else if (!strcmp(res->what, "fdir"))
5903 fdir_get_infos(res->portnum);
5904 else if (!strcmp(res->what, "stat_qmap"))
5905 nic_stats_mapping_display(res->portnum);
5906 else if (!strcmp(res->what, "dcb_tc"))
5907 port_dcb_info_display(res->portnum);
5908 else if (!strcmp(res->what, "cap"))
5909 port_offload_cap_display(res->portnum);
5912 cmdline_parse_token_string_t cmd_showport_show =
5913 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5915 cmdline_parse_token_string_t cmd_showport_port =
5916 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5917 cmdline_parse_token_string_t cmd_showport_what =
5918 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5919 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5920 cmdline_parse_token_num_t cmd_showport_portnum =
5921 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5923 cmdline_parse_inst_t cmd_showport = {
5924 .f = cmd_showport_parsed,
5926 .help_str = "show|clear port "
5927 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5930 (void *)&cmd_showport_show,
5931 (void *)&cmd_showport_port,
5932 (void *)&cmd_showport_what,
5933 (void *)&cmd_showport_portnum,
5938 /* *** SHOW QUEUE INFO *** */
5939 struct cmd_showqueue_result {
5940 cmdline_fixed_string_t show;
5941 cmdline_fixed_string_t type;
5942 cmdline_fixed_string_t what;
5948 cmd_showqueue_parsed(void *parsed_result,
5949 __attribute__((unused)) struct cmdline *cl,
5950 __attribute__((unused)) void *data)
5952 struct cmd_showqueue_result *res = parsed_result;
5954 if (!strcmp(res->type, "rxq"))
5955 rx_queue_infos_display(res->portnum, res->queuenum);
5956 else if (!strcmp(res->type, "txq"))
5957 tx_queue_infos_display(res->portnum, res->queuenum);
5960 cmdline_parse_token_string_t cmd_showqueue_show =
5961 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5962 cmdline_parse_token_string_t cmd_showqueue_type =
5963 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5964 cmdline_parse_token_string_t cmd_showqueue_what =
5965 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5966 cmdline_parse_token_num_t cmd_showqueue_portnum =
5967 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5968 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5969 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5971 cmdline_parse_inst_t cmd_showqueue = {
5972 .f = cmd_showqueue_parsed,
5974 .help_str = "show rxq|txq info <port_id> <queue_id>",
5976 (void *)&cmd_showqueue_show,
5977 (void *)&cmd_showqueue_type,
5978 (void *)&cmd_showqueue_what,
5979 (void *)&cmd_showqueue_portnum,
5980 (void *)&cmd_showqueue_queuenum,
5985 /* *** READ PORT REGISTER *** */
5986 struct cmd_read_reg_result {
5987 cmdline_fixed_string_t read;
5988 cmdline_fixed_string_t reg;
5994 cmd_read_reg_parsed(void *parsed_result,
5995 __attribute__((unused)) struct cmdline *cl,
5996 __attribute__((unused)) void *data)
5998 struct cmd_read_reg_result *res = parsed_result;
5999 port_reg_display(res->port_id, res->reg_off);
6002 cmdline_parse_token_string_t cmd_read_reg_read =
6003 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6004 cmdline_parse_token_string_t cmd_read_reg_reg =
6005 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6006 cmdline_parse_token_num_t cmd_read_reg_port_id =
6007 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6008 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6009 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6011 cmdline_parse_inst_t cmd_read_reg = {
6012 .f = cmd_read_reg_parsed,
6014 .help_str = "read reg <port_id> <reg_off>",
6016 (void *)&cmd_read_reg_read,
6017 (void *)&cmd_read_reg_reg,
6018 (void *)&cmd_read_reg_port_id,
6019 (void *)&cmd_read_reg_reg_off,
6024 /* *** READ PORT REGISTER BIT FIELD *** */
6025 struct cmd_read_reg_bit_field_result {
6026 cmdline_fixed_string_t read;
6027 cmdline_fixed_string_t regfield;
6035 cmd_read_reg_bit_field_parsed(void *parsed_result,
6036 __attribute__((unused)) struct cmdline *cl,
6037 __attribute__((unused)) void *data)
6039 struct cmd_read_reg_bit_field_result *res = parsed_result;
6040 port_reg_bit_field_display(res->port_id, res->reg_off,
6041 res->bit1_pos, res->bit2_pos);
6044 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6045 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6047 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6048 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6049 regfield, "regfield");
6050 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6051 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6053 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6054 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6056 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6057 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6059 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6060 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6063 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6064 .f = cmd_read_reg_bit_field_parsed,
6066 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6067 "Read register bit field between bit_x and bit_y included",
6069 (void *)&cmd_read_reg_bit_field_read,
6070 (void *)&cmd_read_reg_bit_field_regfield,
6071 (void *)&cmd_read_reg_bit_field_port_id,
6072 (void *)&cmd_read_reg_bit_field_reg_off,
6073 (void *)&cmd_read_reg_bit_field_bit1_pos,
6074 (void *)&cmd_read_reg_bit_field_bit2_pos,
6079 /* *** READ PORT REGISTER BIT *** */
6080 struct cmd_read_reg_bit_result {
6081 cmdline_fixed_string_t read;
6082 cmdline_fixed_string_t regbit;
6089 cmd_read_reg_bit_parsed(void *parsed_result,
6090 __attribute__((unused)) struct cmdline *cl,
6091 __attribute__((unused)) void *data)
6093 struct cmd_read_reg_bit_result *res = parsed_result;
6094 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6097 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6098 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6099 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6100 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6102 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6103 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6104 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6105 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6106 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6107 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6109 cmdline_parse_inst_t cmd_read_reg_bit = {
6110 .f = cmd_read_reg_bit_parsed,
6112 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6114 (void *)&cmd_read_reg_bit_read,
6115 (void *)&cmd_read_reg_bit_regbit,
6116 (void *)&cmd_read_reg_bit_port_id,
6117 (void *)&cmd_read_reg_bit_reg_off,
6118 (void *)&cmd_read_reg_bit_bit_pos,
6123 /* *** WRITE PORT REGISTER *** */
6124 struct cmd_write_reg_result {
6125 cmdline_fixed_string_t write;
6126 cmdline_fixed_string_t reg;
6133 cmd_write_reg_parsed(void *parsed_result,
6134 __attribute__((unused)) struct cmdline *cl,
6135 __attribute__((unused)) void *data)
6137 struct cmd_write_reg_result *res = parsed_result;
6138 port_reg_set(res->port_id, res->reg_off, res->value);
6141 cmdline_parse_token_string_t cmd_write_reg_write =
6142 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6143 cmdline_parse_token_string_t cmd_write_reg_reg =
6144 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6145 cmdline_parse_token_num_t cmd_write_reg_port_id =
6146 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6147 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6148 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6149 cmdline_parse_token_num_t cmd_write_reg_value =
6150 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6152 cmdline_parse_inst_t cmd_write_reg = {
6153 .f = cmd_write_reg_parsed,
6155 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6157 (void *)&cmd_write_reg_write,
6158 (void *)&cmd_write_reg_reg,
6159 (void *)&cmd_write_reg_port_id,
6160 (void *)&cmd_write_reg_reg_off,
6161 (void *)&cmd_write_reg_value,
6166 /* *** WRITE PORT REGISTER BIT FIELD *** */
6167 struct cmd_write_reg_bit_field_result {
6168 cmdline_fixed_string_t write;
6169 cmdline_fixed_string_t regfield;
6178 cmd_write_reg_bit_field_parsed(void *parsed_result,
6179 __attribute__((unused)) struct cmdline *cl,
6180 __attribute__((unused)) void *data)
6182 struct cmd_write_reg_bit_field_result *res = parsed_result;
6183 port_reg_bit_field_set(res->port_id, res->reg_off,
6184 res->bit1_pos, res->bit2_pos, res->value);
6187 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6188 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6190 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6191 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6192 regfield, "regfield");
6193 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6194 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6196 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6199 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6200 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6202 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6203 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6205 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6206 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6209 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6210 .f = cmd_write_reg_bit_field_parsed,
6212 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6214 "Set register bit field between bit_x and bit_y included",
6216 (void *)&cmd_write_reg_bit_field_write,
6217 (void *)&cmd_write_reg_bit_field_regfield,
6218 (void *)&cmd_write_reg_bit_field_port_id,
6219 (void *)&cmd_write_reg_bit_field_reg_off,
6220 (void *)&cmd_write_reg_bit_field_bit1_pos,
6221 (void *)&cmd_write_reg_bit_field_bit2_pos,
6222 (void *)&cmd_write_reg_bit_field_value,
6227 /* *** WRITE PORT REGISTER BIT *** */
6228 struct cmd_write_reg_bit_result {
6229 cmdline_fixed_string_t write;
6230 cmdline_fixed_string_t regbit;
6238 cmd_write_reg_bit_parsed(void *parsed_result,
6239 __attribute__((unused)) struct cmdline *cl,
6240 __attribute__((unused)) void *data)
6242 struct cmd_write_reg_bit_result *res = parsed_result;
6243 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6246 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6247 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6249 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6250 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6252 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6253 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6254 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6255 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6256 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6257 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6258 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6259 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6261 cmdline_parse_inst_t cmd_write_reg_bit = {
6262 .f = cmd_write_reg_bit_parsed,
6264 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6267 (void *)&cmd_write_reg_bit_write,
6268 (void *)&cmd_write_reg_bit_regbit,
6269 (void *)&cmd_write_reg_bit_port_id,
6270 (void *)&cmd_write_reg_bit_reg_off,
6271 (void *)&cmd_write_reg_bit_bit_pos,
6272 (void *)&cmd_write_reg_bit_value,
6277 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6278 struct cmd_read_rxd_txd_result {
6279 cmdline_fixed_string_t read;
6280 cmdline_fixed_string_t rxd_txd;
6287 cmd_read_rxd_txd_parsed(void *parsed_result,
6288 __attribute__((unused)) struct cmdline *cl,
6289 __attribute__((unused)) void *data)
6291 struct cmd_read_rxd_txd_result *res = parsed_result;
6293 if (!strcmp(res->rxd_txd, "rxd"))
6294 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6295 else if (!strcmp(res->rxd_txd, "txd"))
6296 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6299 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6300 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6301 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6302 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6304 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6305 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6306 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6307 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6308 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6309 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6311 cmdline_parse_inst_t cmd_read_rxd_txd = {
6312 .f = cmd_read_rxd_txd_parsed,
6314 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6316 (void *)&cmd_read_rxd_txd_read,
6317 (void *)&cmd_read_rxd_txd_rxd_txd,
6318 (void *)&cmd_read_rxd_txd_port_id,
6319 (void *)&cmd_read_rxd_txd_queue_id,
6320 (void *)&cmd_read_rxd_txd_desc_id,
6326 struct cmd_quit_result {
6327 cmdline_fixed_string_t quit;
6330 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6332 __attribute__((unused)) void *data)
6338 cmdline_parse_token_string_t cmd_quit_quit =
6339 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6341 cmdline_parse_inst_t cmd_quit = {
6342 .f = cmd_quit_parsed,
6344 .help_str = "quit: Exit application",
6346 (void *)&cmd_quit_quit,
6351 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6352 struct cmd_mac_addr_result {
6353 cmdline_fixed_string_t mac_addr_cmd;
6354 cmdline_fixed_string_t what;
6356 struct ether_addr address;
6359 static void cmd_mac_addr_parsed(void *parsed_result,
6360 __attribute__((unused)) struct cmdline *cl,
6361 __attribute__((unused)) void *data)
6363 struct cmd_mac_addr_result *res = parsed_result;
6366 if (strcmp(res->what, "add") == 0)
6367 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6368 else if (strcmp(res->what, "set") == 0)
6369 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6372 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6374 /* check the return value and print it if is < 0 */
6376 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6380 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6381 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6383 cmdline_parse_token_string_t cmd_mac_addr_what =
6384 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6386 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6387 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6388 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6389 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6391 cmdline_parse_inst_t cmd_mac_addr = {
6392 .f = cmd_mac_addr_parsed,
6394 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6395 "Add/Remove/Set MAC address on port_id",
6397 (void *)&cmd_mac_addr_cmd,
6398 (void *)&cmd_mac_addr_what,
6399 (void *)&cmd_mac_addr_portnum,
6400 (void *)&cmd_mac_addr_addr,
6406 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6407 struct cmd_set_qmap_result {
6408 cmdline_fixed_string_t set;
6409 cmdline_fixed_string_t qmap;
6410 cmdline_fixed_string_t what;
6417 cmd_set_qmap_parsed(void *parsed_result,
6418 __attribute__((unused)) struct cmdline *cl,
6419 __attribute__((unused)) void *data)
6421 struct cmd_set_qmap_result *res = parsed_result;
6422 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6424 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6427 cmdline_parse_token_string_t cmd_setqmap_set =
6428 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6430 cmdline_parse_token_string_t cmd_setqmap_qmap =
6431 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6433 cmdline_parse_token_string_t cmd_setqmap_what =
6434 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6436 cmdline_parse_token_num_t cmd_setqmap_portid =
6437 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6439 cmdline_parse_token_num_t cmd_setqmap_queueid =
6440 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6442 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6443 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6446 cmdline_parse_inst_t cmd_set_qmap = {
6447 .f = cmd_set_qmap_parsed,
6449 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6450 "Set statistics mapping value on tx|rx queue_id of port_id",
6452 (void *)&cmd_setqmap_set,
6453 (void *)&cmd_setqmap_qmap,
6454 (void *)&cmd_setqmap_what,
6455 (void *)&cmd_setqmap_portid,
6456 (void *)&cmd_setqmap_queueid,
6457 (void *)&cmd_setqmap_mapvalue,
6462 /* *** CONFIGURE UNICAST HASH TABLE *** */
6463 struct cmd_set_uc_hash_table {
6464 cmdline_fixed_string_t set;
6465 cmdline_fixed_string_t port;
6467 cmdline_fixed_string_t what;
6468 struct ether_addr address;
6469 cmdline_fixed_string_t mode;
6473 cmd_set_uc_hash_parsed(void *parsed_result,
6474 __attribute__((unused)) struct cmdline *cl,
6475 __attribute__((unused)) void *data)
6478 struct cmd_set_uc_hash_table *res = parsed_result;
6480 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6482 if (strcmp(res->what, "uta") == 0)
6483 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6484 &res->address,(uint8_t)is_on);
6486 printf("bad unicast hash table parameter, return code = %d \n", ret);
6490 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6491 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6493 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6496 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6497 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6499 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6502 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6503 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6505 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6506 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6509 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6510 .f = cmd_set_uc_hash_parsed,
6512 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6514 (void *)&cmd_set_uc_hash_set,
6515 (void *)&cmd_set_uc_hash_port,
6516 (void *)&cmd_set_uc_hash_portid,
6517 (void *)&cmd_set_uc_hash_what,
6518 (void *)&cmd_set_uc_hash_mac,
6519 (void *)&cmd_set_uc_hash_mode,
6524 struct cmd_set_uc_all_hash_table {
6525 cmdline_fixed_string_t set;
6526 cmdline_fixed_string_t port;
6528 cmdline_fixed_string_t what;
6529 cmdline_fixed_string_t value;
6530 cmdline_fixed_string_t mode;
6534 cmd_set_uc_all_hash_parsed(void *parsed_result,
6535 __attribute__((unused)) struct cmdline *cl,
6536 __attribute__((unused)) void *data)
6539 struct cmd_set_uc_all_hash_table *res = parsed_result;
6541 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6543 if ((strcmp(res->what, "uta") == 0) &&
6544 (strcmp(res->value, "all") == 0))
6545 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6547 printf("bad unicast hash table parameter,"
6548 "return code = %d \n", ret);
6551 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6554 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6555 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6557 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6558 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6560 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6561 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6563 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6566 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6567 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6570 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6571 .f = cmd_set_uc_all_hash_parsed,
6573 .help_str = "set port <port_id> uta all on|off",
6575 (void *)&cmd_set_uc_all_hash_set,
6576 (void *)&cmd_set_uc_all_hash_port,
6577 (void *)&cmd_set_uc_all_hash_portid,
6578 (void *)&cmd_set_uc_all_hash_what,
6579 (void *)&cmd_set_uc_all_hash_value,
6580 (void *)&cmd_set_uc_all_hash_mode,
6585 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6586 struct cmd_set_vf_macvlan_filter {
6587 cmdline_fixed_string_t set;
6588 cmdline_fixed_string_t port;
6590 cmdline_fixed_string_t vf;
6592 struct ether_addr address;
6593 cmdline_fixed_string_t filter_type;
6594 cmdline_fixed_string_t mode;
6598 cmd_set_vf_macvlan_parsed(void *parsed_result,
6599 __attribute__((unused)) struct cmdline *cl,
6600 __attribute__((unused)) void *data)
6603 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6604 struct rte_eth_mac_filter filter;
6606 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6608 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6610 /* set VF MAC filter */
6614 filter.dst_id = res->vf_id;
6616 if (!strcmp(res->filter_type, "exact-mac"))
6617 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6618 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6619 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6620 else if (!strcmp(res->filter_type, "hashmac"))
6621 filter.filter_type = RTE_MAC_HASH_MATCH;
6622 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6623 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6625 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6628 ret = rte_eth_dev_filter_ctrl(res->port_id,
6629 RTE_ETH_FILTER_MACVLAN,
6633 ret = rte_eth_dev_filter_ctrl(res->port_id,
6634 RTE_ETH_FILTER_MACVLAN,
6635 RTE_ETH_FILTER_DELETE,
6639 printf("bad set MAC hash parameter, return code = %d\n", ret);
6643 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6644 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6646 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6649 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6650 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6652 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6653 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6655 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6656 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6658 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6659 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6661 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6662 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6663 filter_type, "exact-mac#exact-mac-vlan"
6664 "#hashmac#hashmac-vlan");
6665 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6666 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6669 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6670 .f = cmd_set_vf_macvlan_parsed,
6672 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6673 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6674 "Exact match rule: exact match of MAC or MAC and VLAN; "
6675 "hash match rule: hash match of MAC and exact match of VLAN",
6677 (void *)&cmd_set_vf_macvlan_set,
6678 (void *)&cmd_set_vf_macvlan_port,
6679 (void *)&cmd_set_vf_macvlan_portid,
6680 (void *)&cmd_set_vf_macvlan_vf,
6681 (void *)&cmd_set_vf_macvlan_vf_id,
6682 (void *)&cmd_set_vf_macvlan_mac,
6683 (void *)&cmd_set_vf_macvlan_filter_type,
6684 (void *)&cmd_set_vf_macvlan_mode,
6689 #ifdef RTE_LIBRTE_IXGBE_PMD
6690 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6691 struct cmd_set_vf_traffic {
6692 cmdline_fixed_string_t set;
6693 cmdline_fixed_string_t port;
6695 cmdline_fixed_string_t vf;
6697 cmdline_fixed_string_t what;
6698 cmdline_fixed_string_t mode;
6702 cmd_set_vf_traffic_parsed(void *parsed_result,
6703 __attribute__((unused)) struct cmdline *cl,
6704 __attribute__((unused)) void *data)
6706 struct cmd_set_vf_traffic *res = parsed_result;
6707 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6708 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6710 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6713 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6716 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6719 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6720 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6722 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6723 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6725 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6726 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6728 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6731 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6735 cmdline_parse_inst_t cmd_set_vf_traffic = {
6736 .f = cmd_set_vf_traffic_parsed,
6738 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6740 (void *)&cmd_setvf_traffic_set,
6741 (void *)&cmd_setvf_traffic_port,
6742 (void *)&cmd_setvf_traffic_portid,
6743 (void *)&cmd_setvf_traffic_vf,
6744 (void *)&cmd_setvf_traffic_vfid,
6745 (void *)&cmd_setvf_traffic_what,
6746 (void *)&cmd_setvf_traffic_mode,
6751 /* *** CONFIGURE VF RECEIVE MODE *** */
6752 struct cmd_set_vf_rxmode {
6753 cmdline_fixed_string_t set;
6754 cmdline_fixed_string_t port;
6756 cmdline_fixed_string_t vf;
6758 cmdline_fixed_string_t what;
6759 cmdline_fixed_string_t mode;
6760 cmdline_fixed_string_t on;
6764 cmd_set_vf_rxmode_parsed(void *parsed_result,
6765 __attribute__((unused)) struct cmdline *cl,
6766 __attribute__((unused)) void *data)
6769 uint16_t rx_mode = 0;
6770 struct cmd_set_vf_rxmode *res = parsed_result;
6772 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6773 if (!strcmp(res->what,"rxmode")) {
6774 if (!strcmp(res->mode, "AUPE"))
6775 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6776 else if (!strcmp(res->mode, "ROPE"))
6777 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6778 else if (!strcmp(res->mode, "BAM"))
6779 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6780 else if (!strncmp(res->mode, "MPE",3))
6781 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6784 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6786 printf("bad VF receive mode parameter, return code = %d \n",
6790 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6791 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6793 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6794 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6796 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6797 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6799 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6800 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6802 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6803 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6805 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6806 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6808 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6809 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6810 mode, "AUPE#ROPE#BAM#MPE");
6811 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6812 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6815 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6816 .f = cmd_set_vf_rxmode_parsed,
6818 .help_str = "set port <port_id> vf <vf_id> rxmode "
6819 "AUPE|ROPE|BAM|MPE on|off",
6821 (void *)&cmd_set_vf_rxmode_set,
6822 (void *)&cmd_set_vf_rxmode_port,
6823 (void *)&cmd_set_vf_rxmode_portid,
6824 (void *)&cmd_set_vf_rxmode_vf,
6825 (void *)&cmd_set_vf_rxmode_vfid,
6826 (void *)&cmd_set_vf_rxmode_what,
6827 (void *)&cmd_set_vf_rxmode_mode,
6828 (void *)&cmd_set_vf_rxmode_on,
6834 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6835 struct cmd_vf_mac_addr_result {
6836 cmdline_fixed_string_t mac_addr_cmd;
6837 cmdline_fixed_string_t what;
6838 cmdline_fixed_string_t port;
6840 cmdline_fixed_string_t vf;
6842 struct ether_addr address;
6845 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6846 __attribute__((unused)) struct cmdline *cl,
6847 __attribute__((unused)) void *data)
6849 struct cmd_vf_mac_addr_result *res = parsed_result;
6852 if (strcmp(res->what, "add") == 0)
6853 ret = rte_eth_dev_mac_addr_add(res->port_num,
6854 &res->address, res->vf_num);
6856 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6860 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6861 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6862 mac_addr_cmd,"mac_addr");
6863 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6864 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6866 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6867 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6869 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6870 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6872 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6873 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6875 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6876 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6878 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6879 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6882 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6883 .f = cmd_vf_mac_addr_parsed,
6885 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6886 "Add MAC address filtering for a VF on port_id",
6888 (void *)&cmd_vf_mac_addr_cmd,
6889 (void *)&cmd_vf_mac_addr_what,
6890 (void *)&cmd_vf_mac_addr_port,
6891 (void *)&cmd_vf_mac_addr_portnum,
6892 (void *)&cmd_vf_mac_addr_vf,
6893 (void *)&cmd_vf_mac_addr_vfnum,
6894 (void *)&cmd_vf_mac_addr_addr,
6899 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6900 struct cmd_vf_rx_vlan_filter {
6901 cmdline_fixed_string_t rx_vlan;
6902 cmdline_fixed_string_t what;
6904 cmdline_fixed_string_t port;
6906 cmdline_fixed_string_t vf;
6911 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6912 __attribute__((unused)) struct cmdline *cl,
6913 __attribute__((unused)) void *data)
6915 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6918 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6920 #ifdef RTE_LIBRTE_IXGBE_PMD
6921 if (ret == -ENOTSUP)
6922 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6923 res->vlan_id, res->vf_mask, is_add);
6925 #ifdef RTE_LIBRTE_I40E_PMD
6926 if (ret == -ENOTSUP)
6927 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6928 res->vlan_id, res->vf_mask, is_add);
6935 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6936 res->vlan_id, res->vf_mask);
6939 printf("invalid port_id %d\n", res->port_id);
6942 printf("function not implemented or supported\n");
6945 printf("programming error: (%s)\n", strerror(-ret));
6949 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6950 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6951 rx_vlan, "rx_vlan");
6952 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6953 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6955 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6956 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6958 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6959 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6961 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6962 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6964 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6965 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6967 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6968 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6971 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6972 .f = cmd_vf_rx_vlan_filter_parsed,
6974 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6975 "(vf_mask = hexadecimal VF mask)",
6977 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6978 (void *)&cmd_vf_rx_vlan_filter_what,
6979 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6980 (void *)&cmd_vf_rx_vlan_filter_port,
6981 (void *)&cmd_vf_rx_vlan_filter_portid,
6982 (void *)&cmd_vf_rx_vlan_filter_vf,
6983 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6988 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6989 struct cmd_queue_rate_limit_result {
6990 cmdline_fixed_string_t set;
6991 cmdline_fixed_string_t port;
6993 cmdline_fixed_string_t queue;
6995 cmdline_fixed_string_t rate;
6999 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7000 __attribute__((unused)) struct cmdline *cl,
7001 __attribute__((unused)) void *data)
7003 struct cmd_queue_rate_limit_result *res = parsed_result;
7006 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7007 && (strcmp(res->queue, "queue") == 0)
7008 && (strcmp(res->rate, "rate") == 0))
7009 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7012 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7016 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7017 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7019 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7020 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7022 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7023 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7025 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7026 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7028 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7029 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7031 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7032 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7034 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7035 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7038 cmdline_parse_inst_t cmd_queue_rate_limit = {
7039 .f = cmd_queue_rate_limit_parsed,
7041 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7042 "Set rate limit for a queue on port_id",
7044 (void *)&cmd_queue_rate_limit_set,
7045 (void *)&cmd_queue_rate_limit_port,
7046 (void *)&cmd_queue_rate_limit_portnum,
7047 (void *)&cmd_queue_rate_limit_queue,
7048 (void *)&cmd_queue_rate_limit_queuenum,
7049 (void *)&cmd_queue_rate_limit_rate,
7050 (void *)&cmd_queue_rate_limit_ratenum,
7055 #ifdef RTE_LIBRTE_IXGBE_PMD
7056 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7057 struct cmd_vf_rate_limit_result {
7058 cmdline_fixed_string_t set;
7059 cmdline_fixed_string_t port;
7061 cmdline_fixed_string_t vf;
7063 cmdline_fixed_string_t rate;
7065 cmdline_fixed_string_t q_msk;
7069 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7070 __attribute__((unused)) struct cmdline *cl,
7071 __attribute__((unused)) void *data)
7073 struct cmd_vf_rate_limit_result *res = parsed_result;
7076 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7077 && (strcmp(res->vf, "vf") == 0)
7078 && (strcmp(res->rate, "rate") == 0)
7079 && (strcmp(res->q_msk, "queue_mask") == 0))
7080 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7081 res->rate_num, res->q_msk_val);
7083 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7087 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7088 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7090 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7091 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7093 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7094 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7096 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7097 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7099 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7100 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7102 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7103 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7105 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7106 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7108 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7109 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7110 q_msk, "queue_mask");
7111 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7112 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7115 cmdline_parse_inst_t cmd_vf_rate_limit = {
7116 .f = cmd_vf_rate_limit_parsed,
7118 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7119 "queue_mask <queue_mask_value>: "
7120 "Set rate limit for queues of VF on port_id",
7122 (void *)&cmd_vf_rate_limit_set,
7123 (void *)&cmd_vf_rate_limit_port,
7124 (void *)&cmd_vf_rate_limit_portnum,
7125 (void *)&cmd_vf_rate_limit_vf,
7126 (void *)&cmd_vf_rate_limit_vfnum,
7127 (void *)&cmd_vf_rate_limit_rate,
7128 (void *)&cmd_vf_rate_limit_ratenum,
7129 (void *)&cmd_vf_rate_limit_q_msk,
7130 (void *)&cmd_vf_rate_limit_q_msk_val,
7136 /* *** ADD TUNNEL FILTER OF A PORT *** */
7137 struct cmd_tunnel_filter_result {
7138 cmdline_fixed_string_t cmd;
7139 cmdline_fixed_string_t what;
7141 struct ether_addr outer_mac;
7142 struct ether_addr inner_mac;
7143 cmdline_ipaddr_t ip_value;
7144 uint16_t inner_vlan;
7145 cmdline_fixed_string_t tunnel_type;
7146 cmdline_fixed_string_t filter_type;
7152 cmd_tunnel_filter_parsed(void *parsed_result,
7153 __attribute__((unused)) struct cmdline *cl,
7154 __attribute__((unused)) void *data)
7156 struct cmd_tunnel_filter_result *res = parsed_result;
7157 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7160 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7162 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7163 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7164 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7166 if (res->ip_value.family == AF_INET) {
7167 tunnel_filter_conf.ip_addr.ipv4_addr =
7168 res->ip_value.addr.ipv4.s_addr;
7169 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7171 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7172 &(res->ip_value.addr.ipv6),
7173 sizeof(struct in6_addr));
7174 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7177 if (!strcmp(res->filter_type, "imac-ivlan"))
7178 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7179 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7180 tunnel_filter_conf.filter_type =
7181 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7182 else if (!strcmp(res->filter_type, "imac-tenid"))
7183 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7184 else if (!strcmp(res->filter_type, "imac"))
7185 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7186 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7187 tunnel_filter_conf.filter_type =
7188 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7189 else if (!strcmp(res->filter_type, "oip"))
7190 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7191 else if (!strcmp(res->filter_type, "iip"))
7192 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7194 printf("The filter type is not supported");
7198 if (!strcmp(res->tunnel_type, "vxlan"))
7199 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7200 else if (!strcmp(res->tunnel_type, "nvgre"))
7201 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7202 else if (!strcmp(res->tunnel_type, "ipingre"))
7203 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7205 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7209 tunnel_filter_conf.tenant_id = res->tenant_id;
7210 tunnel_filter_conf.queue_id = res->queue_num;
7211 if (!strcmp(res->what, "add"))
7212 ret = rte_eth_dev_filter_ctrl(res->port_id,
7213 RTE_ETH_FILTER_TUNNEL,
7215 &tunnel_filter_conf);
7217 ret = rte_eth_dev_filter_ctrl(res->port_id,
7218 RTE_ETH_FILTER_TUNNEL,
7219 RTE_ETH_FILTER_DELETE,
7220 &tunnel_filter_conf);
7222 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7226 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7227 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7228 cmd, "tunnel_filter");
7229 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7230 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7232 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7233 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7235 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7236 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7238 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7239 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7241 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7242 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7243 inner_vlan, UINT16);
7244 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7245 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7247 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7248 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7249 tunnel_type, "vxlan#nvgre#ipingre");
7251 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7252 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7253 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7254 "imac#omac-imac-tenid");
7255 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7256 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7258 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7259 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7262 cmdline_parse_inst_t cmd_tunnel_filter = {
7263 .f = cmd_tunnel_filter_parsed,
7265 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7266 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7267 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7268 "<queue_id>: Add/Rm tunnel filter of a port",
7270 (void *)&cmd_tunnel_filter_cmd,
7271 (void *)&cmd_tunnel_filter_what,
7272 (void *)&cmd_tunnel_filter_port_id,
7273 (void *)&cmd_tunnel_filter_outer_mac,
7274 (void *)&cmd_tunnel_filter_inner_mac,
7275 (void *)&cmd_tunnel_filter_ip_value,
7276 (void *)&cmd_tunnel_filter_innner_vlan,
7277 (void *)&cmd_tunnel_filter_tunnel_type,
7278 (void *)&cmd_tunnel_filter_filter_type,
7279 (void *)&cmd_tunnel_filter_tenant_id,
7280 (void *)&cmd_tunnel_filter_queue_num,
7285 /* *** CONFIGURE TUNNEL UDP PORT *** */
7286 struct cmd_tunnel_udp_config {
7287 cmdline_fixed_string_t cmd;
7288 cmdline_fixed_string_t what;
7294 cmd_tunnel_udp_config_parsed(void *parsed_result,
7295 __attribute__((unused)) struct cmdline *cl,
7296 __attribute__((unused)) void *data)
7298 struct cmd_tunnel_udp_config *res = parsed_result;
7299 struct rte_eth_udp_tunnel tunnel_udp;
7302 tunnel_udp.udp_port = res->udp_port;
7304 if (!strcmp(res->cmd, "rx_vxlan_port"))
7305 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7307 if (!strcmp(res->what, "add"))
7308 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7311 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7315 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7318 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7319 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7320 cmd, "rx_vxlan_port");
7321 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7322 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7324 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7325 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7327 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7328 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7331 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7332 .f = cmd_tunnel_udp_config_parsed,
7334 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7335 "Add/Remove a tunneling UDP port filter",
7337 (void *)&cmd_tunnel_udp_config_cmd,
7338 (void *)&cmd_tunnel_udp_config_what,
7339 (void *)&cmd_tunnel_udp_config_udp_port,
7340 (void *)&cmd_tunnel_udp_config_port_id,
7345 /* *** GLOBAL CONFIG *** */
7346 struct cmd_global_config_result {
7347 cmdline_fixed_string_t cmd;
7349 cmdline_fixed_string_t cfg_type;
7354 cmd_global_config_parsed(void *parsed_result,
7355 __attribute__((unused)) struct cmdline *cl,
7356 __attribute__((unused)) void *data)
7358 struct cmd_global_config_result *res = parsed_result;
7359 struct rte_eth_global_cfg conf;
7362 memset(&conf, 0, sizeof(conf));
7363 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7364 conf.cfg.gre_key_len = res->len;
7365 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7366 RTE_ETH_FILTER_SET, &conf);
7368 printf("Global config error\n");
7371 cmdline_parse_token_string_t cmd_global_config_cmd =
7372 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7374 cmdline_parse_token_num_t cmd_global_config_port_id =
7375 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7376 cmdline_parse_token_string_t cmd_global_config_type =
7377 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7378 cfg_type, "gre-key-len");
7379 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7380 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7383 cmdline_parse_inst_t cmd_global_config = {
7384 .f = cmd_global_config_parsed,
7385 .data = (void *)NULL,
7386 .help_str = "global_config <port_id> gre-key-len <key_len>",
7388 (void *)&cmd_global_config_cmd,
7389 (void *)&cmd_global_config_port_id,
7390 (void *)&cmd_global_config_type,
7391 (void *)&cmd_global_config_gre_key_len,
7396 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7397 struct cmd_set_mirror_mask_result {
7398 cmdline_fixed_string_t set;
7399 cmdline_fixed_string_t port;
7401 cmdline_fixed_string_t mirror;
7403 cmdline_fixed_string_t what;
7404 cmdline_fixed_string_t value;
7405 cmdline_fixed_string_t dstpool;
7407 cmdline_fixed_string_t on;
7410 cmdline_parse_token_string_t cmd_mirror_mask_set =
7411 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7413 cmdline_parse_token_string_t cmd_mirror_mask_port =
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7416 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7417 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7419 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7420 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7421 mirror, "mirror-rule");
7422 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7423 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7425 cmdline_parse_token_string_t cmd_mirror_mask_what =
7426 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7427 what, "pool-mirror-up#pool-mirror-down"
7429 cmdline_parse_token_string_t cmd_mirror_mask_value =
7430 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7432 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7434 dstpool, "dst-pool");
7435 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7436 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7438 cmdline_parse_token_string_t cmd_mirror_mask_on =
7439 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7443 cmd_set_mirror_mask_parsed(void *parsed_result,
7444 __attribute__((unused)) struct cmdline *cl,
7445 __attribute__((unused)) void *data)
7448 struct cmd_set_mirror_mask_result *res = parsed_result;
7449 struct rte_eth_mirror_conf mr_conf;
7451 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7453 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7455 mr_conf.dst_pool = res->dstpool_id;
7457 if (!strcmp(res->what, "pool-mirror-up")) {
7458 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7459 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7460 } else if (!strcmp(res->what, "pool-mirror-down")) {
7461 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7462 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7463 } else if (!strcmp(res->what, "vlan-mirror")) {
7464 mr_conf.rule_type = ETH_MIRROR_VLAN;
7465 nb_item = parse_item_list(res->value, "vlan",
7466 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7470 for (i = 0; i < nb_item; i++) {
7471 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7472 printf("Invalid vlan_id: must be < 4096\n");
7476 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7477 mr_conf.vlan.vlan_mask |= 1ULL << i;
7481 if (!strcmp(res->on, "on"))
7482 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7485 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7488 printf("mirror rule add error: (%s)\n", strerror(-ret));
7491 cmdline_parse_inst_t cmd_set_mirror_mask = {
7492 .f = cmd_set_mirror_mask_parsed,
7494 .help_str = "set port <port_id> mirror-rule <rule_id> "
7495 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7496 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7498 (void *)&cmd_mirror_mask_set,
7499 (void *)&cmd_mirror_mask_port,
7500 (void *)&cmd_mirror_mask_portid,
7501 (void *)&cmd_mirror_mask_mirror,
7502 (void *)&cmd_mirror_mask_ruleid,
7503 (void *)&cmd_mirror_mask_what,
7504 (void *)&cmd_mirror_mask_value,
7505 (void *)&cmd_mirror_mask_dstpool,
7506 (void *)&cmd_mirror_mask_poolid,
7507 (void *)&cmd_mirror_mask_on,
7512 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7513 struct cmd_set_mirror_link_result {
7514 cmdline_fixed_string_t set;
7515 cmdline_fixed_string_t port;
7517 cmdline_fixed_string_t mirror;
7519 cmdline_fixed_string_t what;
7520 cmdline_fixed_string_t dstpool;
7522 cmdline_fixed_string_t on;
7525 cmdline_parse_token_string_t cmd_mirror_link_set =
7526 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7528 cmdline_parse_token_string_t cmd_mirror_link_port =
7529 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7531 cmdline_parse_token_num_t cmd_mirror_link_portid =
7532 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7534 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7535 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7536 mirror, "mirror-rule");
7537 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7538 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7540 cmdline_parse_token_string_t cmd_mirror_link_what =
7541 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7542 what, "uplink-mirror#downlink-mirror");
7543 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7544 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7545 dstpool, "dst-pool");
7546 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7547 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7549 cmdline_parse_token_string_t cmd_mirror_link_on =
7550 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7554 cmd_set_mirror_link_parsed(void *parsed_result,
7555 __attribute__((unused)) struct cmdline *cl,
7556 __attribute__((unused)) void *data)
7559 struct cmd_set_mirror_link_result *res = parsed_result;
7560 struct rte_eth_mirror_conf mr_conf;
7562 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7563 if (!strcmp(res->what, "uplink-mirror"))
7564 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7566 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7568 mr_conf.dst_pool = res->dstpool_id;
7570 if (!strcmp(res->on, "on"))
7571 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7574 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7577 /* check the return value and print it if is < 0 */
7579 printf("mirror rule add error: (%s)\n", strerror(-ret));
7583 cmdline_parse_inst_t cmd_set_mirror_link = {
7584 .f = cmd_set_mirror_link_parsed,
7586 .help_str = "set port <port_id> mirror-rule <rule_id> "
7587 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7589 (void *)&cmd_mirror_link_set,
7590 (void *)&cmd_mirror_link_port,
7591 (void *)&cmd_mirror_link_portid,
7592 (void *)&cmd_mirror_link_mirror,
7593 (void *)&cmd_mirror_link_ruleid,
7594 (void *)&cmd_mirror_link_what,
7595 (void *)&cmd_mirror_link_dstpool,
7596 (void *)&cmd_mirror_link_poolid,
7597 (void *)&cmd_mirror_link_on,
7602 /* *** RESET VM MIRROR RULE *** */
7603 struct cmd_rm_mirror_rule_result {
7604 cmdline_fixed_string_t reset;
7605 cmdline_fixed_string_t port;
7607 cmdline_fixed_string_t mirror;
7611 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7612 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7614 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7615 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7617 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7618 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7620 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7621 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7622 mirror, "mirror-rule");
7623 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7624 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7628 cmd_reset_mirror_rule_parsed(void *parsed_result,
7629 __attribute__((unused)) struct cmdline *cl,
7630 __attribute__((unused)) void *data)
7633 struct cmd_set_mirror_link_result *res = parsed_result;
7635 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7637 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7640 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7641 .f = cmd_reset_mirror_rule_parsed,
7643 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7645 (void *)&cmd_rm_mirror_rule_reset,
7646 (void *)&cmd_rm_mirror_rule_port,
7647 (void *)&cmd_rm_mirror_rule_portid,
7648 (void *)&cmd_rm_mirror_rule_mirror,
7649 (void *)&cmd_rm_mirror_rule_ruleid,
7654 /* ******************************************************************************** */
7656 struct cmd_dump_result {
7657 cmdline_fixed_string_t dump;
7661 dump_struct_sizes(void)
7663 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7664 DUMP_SIZE(struct rte_mbuf);
7665 DUMP_SIZE(struct rte_mempool);
7666 DUMP_SIZE(struct rte_ring);
7670 static void cmd_dump_parsed(void *parsed_result,
7671 __attribute__((unused)) struct cmdline *cl,
7672 __attribute__((unused)) void *data)
7674 struct cmd_dump_result *res = parsed_result;
7676 if (!strcmp(res->dump, "dump_physmem"))
7677 rte_dump_physmem_layout(stdout);
7678 else if (!strcmp(res->dump, "dump_memzone"))
7679 rte_memzone_dump(stdout);
7680 else if (!strcmp(res->dump, "dump_struct_sizes"))
7681 dump_struct_sizes();
7682 else if (!strcmp(res->dump, "dump_ring"))
7683 rte_ring_list_dump(stdout);
7684 else if (!strcmp(res->dump, "dump_mempool"))
7685 rte_mempool_list_dump(stdout);
7686 else if (!strcmp(res->dump, "dump_devargs"))
7687 rte_eal_devargs_dump(stdout);
7690 cmdline_parse_token_string_t cmd_dump_dump =
7691 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7694 "dump_struct_sizes#"
7699 cmdline_parse_inst_t cmd_dump = {
7700 .f = cmd_dump_parsed, /* function to call */
7701 .data = NULL, /* 2nd arg of func */
7702 .help_str = "Dump status",
7703 .tokens = { /* token list, NULL terminated */
7704 (void *)&cmd_dump_dump,
7709 /* ******************************************************************************** */
7711 struct cmd_dump_one_result {
7712 cmdline_fixed_string_t dump;
7713 cmdline_fixed_string_t name;
7716 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7717 __attribute__((unused)) void *data)
7719 struct cmd_dump_one_result *res = parsed_result;
7721 if (!strcmp(res->dump, "dump_ring")) {
7723 r = rte_ring_lookup(res->name);
7725 cmdline_printf(cl, "Cannot find ring\n");
7728 rte_ring_dump(stdout, r);
7729 } else if (!strcmp(res->dump, "dump_mempool")) {
7730 struct rte_mempool *mp;
7731 mp = rte_mempool_lookup(res->name);
7733 cmdline_printf(cl, "Cannot find mempool\n");
7736 rte_mempool_dump(stdout, mp);
7740 cmdline_parse_token_string_t cmd_dump_one_dump =
7741 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7742 "dump_ring#dump_mempool");
7744 cmdline_parse_token_string_t cmd_dump_one_name =
7745 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7747 cmdline_parse_inst_t cmd_dump_one = {
7748 .f = cmd_dump_one_parsed, /* function to call */
7749 .data = NULL, /* 2nd arg of func */
7750 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7751 .tokens = { /* token list, NULL terminated */
7752 (void *)&cmd_dump_one_dump,
7753 (void *)&cmd_dump_one_name,
7758 /* *** Add/Del syn filter *** */
7759 struct cmd_syn_filter_result {
7760 cmdline_fixed_string_t filter;
7762 cmdline_fixed_string_t ops;
7763 cmdline_fixed_string_t priority;
7764 cmdline_fixed_string_t high;
7765 cmdline_fixed_string_t queue;
7770 cmd_syn_filter_parsed(void *parsed_result,
7771 __attribute__((unused)) struct cmdline *cl,
7772 __attribute__((unused)) void *data)
7774 struct cmd_syn_filter_result *res = parsed_result;
7775 struct rte_eth_syn_filter syn_filter;
7778 ret = rte_eth_dev_filter_supported(res->port_id,
7779 RTE_ETH_FILTER_SYN);
7781 printf("syn filter is not supported on port %u.\n",
7786 memset(&syn_filter, 0, sizeof(syn_filter));
7788 if (!strcmp(res->ops, "add")) {
7789 if (!strcmp(res->high, "high"))
7790 syn_filter.hig_pri = 1;
7792 syn_filter.hig_pri = 0;
7794 syn_filter.queue = res->queue_id;
7795 ret = rte_eth_dev_filter_ctrl(res->port_id,
7800 ret = rte_eth_dev_filter_ctrl(res->port_id,
7802 RTE_ETH_FILTER_DELETE,
7806 printf("syn filter programming error: (%s)\n",
7810 cmdline_parse_token_string_t cmd_syn_filter_filter =
7811 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7812 filter, "syn_filter");
7813 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7814 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7816 cmdline_parse_token_string_t cmd_syn_filter_ops =
7817 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7819 cmdline_parse_token_string_t cmd_syn_filter_priority =
7820 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7821 priority, "priority");
7822 cmdline_parse_token_string_t cmd_syn_filter_high =
7823 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7825 cmdline_parse_token_string_t cmd_syn_filter_queue =
7826 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7828 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7829 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7832 cmdline_parse_inst_t cmd_syn_filter = {
7833 .f = cmd_syn_filter_parsed,
7835 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7836 "<queue_id>: Add/Delete syn filter",
7838 (void *)&cmd_syn_filter_filter,
7839 (void *)&cmd_syn_filter_port_id,
7840 (void *)&cmd_syn_filter_ops,
7841 (void *)&cmd_syn_filter_priority,
7842 (void *)&cmd_syn_filter_high,
7843 (void *)&cmd_syn_filter_queue,
7844 (void *)&cmd_syn_filter_queue_id,
7849 /* *** ADD/REMOVE A 2tuple FILTER *** */
7850 struct cmd_2tuple_filter_result {
7851 cmdline_fixed_string_t filter;
7853 cmdline_fixed_string_t ops;
7854 cmdline_fixed_string_t dst_port;
7855 uint16_t dst_port_value;
7856 cmdline_fixed_string_t protocol;
7857 uint8_t protocol_value;
7858 cmdline_fixed_string_t mask;
7860 cmdline_fixed_string_t tcp_flags;
7861 uint8_t tcp_flags_value;
7862 cmdline_fixed_string_t priority;
7863 uint8_t priority_value;
7864 cmdline_fixed_string_t queue;
7869 cmd_2tuple_filter_parsed(void *parsed_result,
7870 __attribute__((unused)) struct cmdline *cl,
7871 __attribute__((unused)) void *data)
7873 struct rte_eth_ntuple_filter filter;
7874 struct cmd_2tuple_filter_result *res = parsed_result;
7877 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7879 printf("ntuple filter is not supported on port %u.\n",
7884 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7886 filter.flags = RTE_2TUPLE_FLAGS;
7887 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7888 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7889 filter.proto = res->protocol_value;
7890 filter.priority = res->priority_value;
7891 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7892 printf("nonzero tcp_flags is only meaningful"
7893 " when protocol is TCP.\n");
7896 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7897 printf("invalid TCP flags.\n");
7901 if (res->tcp_flags_value != 0) {
7902 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7903 filter.tcp_flags = res->tcp_flags_value;
7906 /* need convert to big endian. */
7907 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7908 filter.queue = res->queue_id;
7910 if (!strcmp(res->ops, "add"))
7911 ret = rte_eth_dev_filter_ctrl(res->port_id,
7912 RTE_ETH_FILTER_NTUPLE,
7916 ret = rte_eth_dev_filter_ctrl(res->port_id,
7917 RTE_ETH_FILTER_NTUPLE,
7918 RTE_ETH_FILTER_DELETE,
7921 printf("2tuple filter programming error: (%s)\n",
7926 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7927 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7928 filter, "2tuple_filter");
7929 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7930 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7932 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7933 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7935 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7936 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7937 dst_port, "dst_port");
7938 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7939 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7940 dst_port_value, UINT16);
7941 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7942 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7943 protocol, "protocol");
7944 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7945 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7946 protocol_value, UINT8);
7947 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7948 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7950 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7951 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7953 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7954 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7955 tcp_flags, "tcp_flags");
7956 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7957 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7958 tcp_flags_value, UINT8);
7959 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7960 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7961 priority, "priority");
7962 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7963 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7964 priority_value, UINT8);
7965 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7966 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7968 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7969 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7972 cmdline_parse_inst_t cmd_2tuple_filter = {
7973 .f = cmd_2tuple_filter_parsed,
7975 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7976 "<value> mask <value> tcp_flags <value> priority <value> queue "
7977 "<queue_id>: Add a 2tuple filter",
7979 (void *)&cmd_2tuple_filter_filter,
7980 (void *)&cmd_2tuple_filter_port_id,
7981 (void *)&cmd_2tuple_filter_ops,
7982 (void *)&cmd_2tuple_filter_dst_port,
7983 (void *)&cmd_2tuple_filter_dst_port_value,
7984 (void *)&cmd_2tuple_filter_protocol,
7985 (void *)&cmd_2tuple_filter_protocol_value,
7986 (void *)&cmd_2tuple_filter_mask,
7987 (void *)&cmd_2tuple_filter_mask_value,
7988 (void *)&cmd_2tuple_filter_tcp_flags,
7989 (void *)&cmd_2tuple_filter_tcp_flags_value,
7990 (void *)&cmd_2tuple_filter_priority,
7991 (void *)&cmd_2tuple_filter_priority_value,
7992 (void *)&cmd_2tuple_filter_queue,
7993 (void *)&cmd_2tuple_filter_queue_id,
7998 /* *** ADD/REMOVE A 5tuple FILTER *** */
7999 struct cmd_5tuple_filter_result {
8000 cmdline_fixed_string_t filter;
8002 cmdline_fixed_string_t ops;
8003 cmdline_fixed_string_t dst_ip;
8004 cmdline_ipaddr_t dst_ip_value;
8005 cmdline_fixed_string_t src_ip;
8006 cmdline_ipaddr_t src_ip_value;
8007 cmdline_fixed_string_t dst_port;
8008 uint16_t dst_port_value;
8009 cmdline_fixed_string_t src_port;
8010 uint16_t src_port_value;
8011 cmdline_fixed_string_t protocol;
8012 uint8_t protocol_value;
8013 cmdline_fixed_string_t mask;
8015 cmdline_fixed_string_t tcp_flags;
8016 uint8_t tcp_flags_value;
8017 cmdline_fixed_string_t priority;
8018 uint8_t priority_value;
8019 cmdline_fixed_string_t queue;
8024 cmd_5tuple_filter_parsed(void *parsed_result,
8025 __attribute__((unused)) struct cmdline *cl,
8026 __attribute__((unused)) void *data)
8028 struct rte_eth_ntuple_filter filter;
8029 struct cmd_5tuple_filter_result *res = parsed_result;
8032 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8034 printf("ntuple filter is not supported on port %u.\n",
8039 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8041 filter.flags = RTE_5TUPLE_FLAGS;
8042 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8043 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8044 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8045 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8046 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8047 filter.proto = res->protocol_value;
8048 filter.priority = res->priority_value;
8049 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8050 printf("nonzero tcp_flags is only meaningful"
8051 " when protocol is TCP.\n");
8054 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8055 printf("invalid TCP flags.\n");
8059 if (res->tcp_flags_value != 0) {
8060 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8061 filter.tcp_flags = res->tcp_flags_value;
8064 if (res->dst_ip_value.family == AF_INET)
8065 /* no need to convert, already big endian. */
8066 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8068 if (filter.dst_ip_mask == 0) {
8069 printf("can not support ipv6 involved compare.\n");
8075 if (res->src_ip_value.family == AF_INET)
8076 /* no need to convert, already big endian. */
8077 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8079 if (filter.src_ip_mask == 0) {
8080 printf("can not support ipv6 involved compare.\n");
8085 /* need convert to big endian. */
8086 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8087 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8088 filter.queue = res->queue_id;
8090 if (!strcmp(res->ops, "add"))
8091 ret = rte_eth_dev_filter_ctrl(res->port_id,
8092 RTE_ETH_FILTER_NTUPLE,
8096 ret = rte_eth_dev_filter_ctrl(res->port_id,
8097 RTE_ETH_FILTER_NTUPLE,
8098 RTE_ETH_FILTER_DELETE,
8101 printf("5tuple filter programming error: (%s)\n",
8105 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8106 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8107 filter, "5tuple_filter");
8108 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8109 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8111 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8112 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8114 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8115 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8117 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8118 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8120 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8121 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8123 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8124 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8126 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8127 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8128 dst_port, "dst_port");
8129 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8130 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8131 dst_port_value, UINT16);
8132 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8133 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8134 src_port, "src_port");
8135 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8136 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8137 src_port_value, UINT16);
8138 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8139 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8140 protocol, "protocol");
8141 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8142 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8143 protocol_value, UINT8);
8144 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8145 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8147 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8148 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8150 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8151 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8152 tcp_flags, "tcp_flags");
8153 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8154 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8155 tcp_flags_value, UINT8);
8156 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8157 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8158 priority, "priority");
8159 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8160 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8161 priority_value, UINT8);
8162 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8163 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8165 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8166 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8169 cmdline_parse_inst_t cmd_5tuple_filter = {
8170 .f = cmd_5tuple_filter_parsed,
8172 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8173 "src_ip <value> dst_port <value> src_port <value> "
8174 "protocol <value> mask <value> tcp_flags <value> "
8175 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8177 (void *)&cmd_5tuple_filter_filter,
8178 (void *)&cmd_5tuple_filter_port_id,
8179 (void *)&cmd_5tuple_filter_ops,
8180 (void *)&cmd_5tuple_filter_dst_ip,
8181 (void *)&cmd_5tuple_filter_dst_ip_value,
8182 (void *)&cmd_5tuple_filter_src_ip,
8183 (void *)&cmd_5tuple_filter_src_ip_value,
8184 (void *)&cmd_5tuple_filter_dst_port,
8185 (void *)&cmd_5tuple_filter_dst_port_value,
8186 (void *)&cmd_5tuple_filter_src_port,
8187 (void *)&cmd_5tuple_filter_src_port_value,
8188 (void *)&cmd_5tuple_filter_protocol,
8189 (void *)&cmd_5tuple_filter_protocol_value,
8190 (void *)&cmd_5tuple_filter_mask,
8191 (void *)&cmd_5tuple_filter_mask_value,
8192 (void *)&cmd_5tuple_filter_tcp_flags,
8193 (void *)&cmd_5tuple_filter_tcp_flags_value,
8194 (void *)&cmd_5tuple_filter_priority,
8195 (void *)&cmd_5tuple_filter_priority_value,
8196 (void *)&cmd_5tuple_filter_queue,
8197 (void *)&cmd_5tuple_filter_queue_id,
8202 /* *** ADD/REMOVE A flex FILTER *** */
8203 struct cmd_flex_filter_result {
8204 cmdline_fixed_string_t filter;
8205 cmdline_fixed_string_t ops;
8207 cmdline_fixed_string_t len;
8209 cmdline_fixed_string_t bytes;
8210 cmdline_fixed_string_t bytes_value;
8211 cmdline_fixed_string_t mask;
8212 cmdline_fixed_string_t mask_value;
8213 cmdline_fixed_string_t priority;
8214 uint8_t priority_value;
8215 cmdline_fixed_string_t queue;
8219 static int xdigit2val(unsigned char c)
8224 else if (isupper(c))
8232 cmd_flex_filter_parsed(void *parsed_result,
8233 __attribute__((unused)) struct cmdline *cl,
8234 __attribute__((unused)) void *data)
8237 struct rte_eth_flex_filter filter;
8238 struct cmd_flex_filter_result *res = parsed_result;
8239 char *bytes_ptr, *mask_ptr;
8240 uint16_t len, i, j = 0;
8245 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8246 printf("the len exceed the max length 128\n");
8249 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8250 filter.len = res->len_value;
8251 filter.priority = res->priority_value;
8252 filter.queue = res->queue_id;
8253 bytes_ptr = res->bytes_value;
8254 mask_ptr = res->mask_value;
8256 /* translate bytes string to array. */
8257 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8258 (bytes_ptr[1] == 'X')))
8260 len = strnlen(bytes_ptr, res->len_value * 2);
8261 if (len == 0 || (len % 8 != 0)) {
8262 printf("please check len and bytes input\n");
8265 for (i = 0; i < len; i++) {
8267 if (isxdigit(c) == 0) {
8268 /* invalid characters. */
8269 printf("invalid input\n");
8272 val = xdigit2val(c);
8275 filter.bytes[j] = byte;
8276 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8283 /* translate mask string to uint8_t array. */
8284 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8285 (mask_ptr[1] == 'X')))
8287 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8289 printf("invalid input\n");
8294 for (i = 0; i < len; i++) {
8296 if (isxdigit(c) == 0) {
8297 /* invalid characters. */
8298 printf("invalid input\n");
8301 val = xdigit2val(c);
8304 filter.mask[j] = byte;
8305 printf("mask[%d]:%02x ", j, filter.mask[j]);
8313 if (!strcmp(res->ops, "add"))
8314 ret = rte_eth_dev_filter_ctrl(res->port_id,
8315 RTE_ETH_FILTER_FLEXIBLE,
8319 ret = rte_eth_dev_filter_ctrl(res->port_id,
8320 RTE_ETH_FILTER_FLEXIBLE,
8321 RTE_ETH_FILTER_DELETE,
8325 printf("flex filter setting error: (%s)\n", strerror(-ret));
8328 cmdline_parse_token_string_t cmd_flex_filter_filter =
8329 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8330 filter, "flex_filter");
8331 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8332 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8334 cmdline_parse_token_string_t cmd_flex_filter_ops =
8335 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8337 cmdline_parse_token_string_t cmd_flex_filter_len =
8338 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8340 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8341 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8343 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8344 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8346 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8347 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8349 cmdline_parse_token_string_t cmd_flex_filter_mask =
8350 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8352 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8353 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8355 cmdline_parse_token_string_t cmd_flex_filter_priority =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8357 priority, "priority");
8358 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8359 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8360 priority_value, UINT8);
8361 cmdline_parse_token_string_t cmd_flex_filter_queue =
8362 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8364 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8365 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8367 cmdline_parse_inst_t cmd_flex_filter = {
8368 .f = cmd_flex_filter_parsed,
8370 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8371 "<value> mask <value> priority <value> queue <queue_id>: "
8372 "Add/Del a flex filter",
8374 (void *)&cmd_flex_filter_filter,
8375 (void *)&cmd_flex_filter_port_id,
8376 (void *)&cmd_flex_filter_ops,
8377 (void *)&cmd_flex_filter_len,
8378 (void *)&cmd_flex_filter_len_value,
8379 (void *)&cmd_flex_filter_bytes,
8380 (void *)&cmd_flex_filter_bytes_value,
8381 (void *)&cmd_flex_filter_mask,
8382 (void *)&cmd_flex_filter_mask_value,
8383 (void *)&cmd_flex_filter_priority,
8384 (void *)&cmd_flex_filter_priority_value,
8385 (void *)&cmd_flex_filter_queue,
8386 (void *)&cmd_flex_filter_queue_id,
8391 /* *** Filters Control *** */
8393 /* *** deal with ethertype filter *** */
8394 struct cmd_ethertype_filter_result {
8395 cmdline_fixed_string_t filter;
8397 cmdline_fixed_string_t ops;
8398 cmdline_fixed_string_t mac;
8399 struct ether_addr mac_addr;
8400 cmdline_fixed_string_t ethertype;
8401 uint16_t ethertype_value;
8402 cmdline_fixed_string_t drop;
8403 cmdline_fixed_string_t queue;
8407 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8408 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8409 filter, "ethertype_filter");
8410 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8411 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8413 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8414 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8416 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8417 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8418 mac, "mac_addr#mac_ignr");
8419 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8420 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8422 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8423 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8424 ethertype, "ethertype");
8425 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8426 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8427 ethertype_value, UINT16);
8428 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8429 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8431 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8432 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8434 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8435 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8439 cmd_ethertype_filter_parsed(void *parsed_result,
8440 __attribute__((unused)) struct cmdline *cl,
8441 __attribute__((unused)) void *data)
8443 struct cmd_ethertype_filter_result *res = parsed_result;
8444 struct rte_eth_ethertype_filter filter;
8447 ret = rte_eth_dev_filter_supported(res->port_id,
8448 RTE_ETH_FILTER_ETHERTYPE);
8450 printf("ethertype filter is not supported on port %u.\n",
8455 memset(&filter, 0, sizeof(filter));
8456 if (!strcmp(res->mac, "mac_addr")) {
8457 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8458 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8459 sizeof(struct ether_addr));
8461 if (!strcmp(res->drop, "drop"))
8462 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8463 filter.ether_type = res->ethertype_value;
8464 filter.queue = res->queue_id;
8466 if (!strcmp(res->ops, "add"))
8467 ret = rte_eth_dev_filter_ctrl(res->port_id,
8468 RTE_ETH_FILTER_ETHERTYPE,
8472 ret = rte_eth_dev_filter_ctrl(res->port_id,
8473 RTE_ETH_FILTER_ETHERTYPE,
8474 RTE_ETH_FILTER_DELETE,
8477 printf("ethertype filter programming error: (%s)\n",
8481 cmdline_parse_inst_t cmd_ethertype_filter = {
8482 .f = cmd_ethertype_filter_parsed,
8484 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8485 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8486 "Add or delete an ethertype filter entry",
8488 (void *)&cmd_ethertype_filter_filter,
8489 (void *)&cmd_ethertype_filter_port_id,
8490 (void *)&cmd_ethertype_filter_ops,
8491 (void *)&cmd_ethertype_filter_mac,
8492 (void *)&cmd_ethertype_filter_mac_addr,
8493 (void *)&cmd_ethertype_filter_ethertype,
8494 (void *)&cmd_ethertype_filter_ethertype_value,
8495 (void *)&cmd_ethertype_filter_drop,
8496 (void *)&cmd_ethertype_filter_queue,
8497 (void *)&cmd_ethertype_filter_queue_id,
8502 /* *** deal with flow director filter *** */
8503 struct cmd_flow_director_result {
8504 cmdline_fixed_string_t flow_director_filter;
8506 cmdline_fixed_string_t mode;
8507 cmdline_fixed_string_t mode_value;
8508 cmdline_fixed_string_t ops;
8509 cmdline_fixed_string_t flow;
8510 cmdline_fixed_string_t flow_type;
8511 cmdline_fixed_string_t ether;
8512 uint16_t ether_type;
8513 cmdline_fixed_string_t src;
8514 cmdline_ipaddr_t ip_src;
8516 cmdline_fixed_string_t dst;
8517 cmdline_ipaddr_t ip_dst;
8519 cmdline_fixed_string_t verify_tag;
8520 uint32_t verify_tag_value;
8521 cmdline_ipaddr_t tos;
8523 cmdline_ipaddr_t proto;
8524 uint8_t proto_value;
8525 cmdline_ipaddr_t ttl;
8527 cmdline_fixed_string_t vlan;
8528 uint16_t vlan_value;
8529 cmdline_fixed_string_t flexbytes;
8530 cmdline_fixed_string_t flexbytes_value;
8531 cmdline_fixed_string_t pf_vf;
8532 cmdline_fixed_string_t drop;
8533 cmdline_fixed_string_t queue;
8535 cmdline_fixed_string_t fd_id;
8536 uint32_t fd_id_value;
8537 cmdline_fixed_string_t mac;
8538 struct ether_addr mac_addr;
8539 cmdline_fixed_string_t tunnel;
8540 cmdline_fixed_string_t tunnel_type;
8541 cmdline_fixed_string_t tunnel_id;
8542 uint32_t tunnel_id_value;
8546 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8549 const char *p, *p0 = q_arg;
8551 unsigned long int_fld;
8552 char *str_fld[max_num];
8557 p = strchr(p0, '(');
8561 p0 = strchr(p, ')');
8566 if (size >= sizeof(s))
8569 snprintf(s, sizeof(s), "%.*s", size, p);
8570 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8571 if (ret < 0 || ret > max_num)
8573 for (i = 0; i < ret; i++) {
8575 int_fld = strtoul(str_fld[i], &end, 0);
8576 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8578 flexbytes[i] = (uint8_t)int_fld;
8584 str2flowtype(char *string)
8587 static const struct {
8590 } flowtype_str[] = {
8591 {"raw", RTE_ETH_FLOW_RAW},
8592 {"ipv4", RTE_ETH_FLOW_IPV4},
8593 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8594 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8595 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8596 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8597 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8598 {"ipv6", RTE_ETH_FLOW_IPV6},
8599 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8600 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8601 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8602 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8603 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8604 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8607 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8608 if (!strcmp(flowtype_str[i].str, string))
8609 return flowtype_str[i].type;
8611 return RTE_ETH_FLOW_UNKNOWN;
8614 static enum rte_eth_fdir_tunnel_type
8615 str2fdir_tunneltype(char *string)
8619 static const struct {
8621 enum rte_eth_fdir_tunnel_type type;
8622 } tunneltype_str[] = {
8623 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8624 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8627 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8628 if (!strcmp(tunneltype_str[i].str, string))
8629 return tunneltype_str[i].type;
8631 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8634 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8636 if ((ip_addr).family == AF_INET) \
8637 (ip) = (ip_addr).addr.ipv4.s_addr; \
8639 printf("invalid parameter.\n"); \
8644 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8646 if ((ip_addr).family == AF_INET6) \
8647 (void)rte_memcpy(&(ip), \
8648 &((ip_addr).addr.ipv6), \
8649 sizeof(struct in6_addr)); \
8651 printf("invalid parameter.\n"); \
8657 cmd_flow_director_filter_parsed(void *parsed_result,
8658 __attribute__((unused)) struct cmdline *cl,
8659 __attribute__((unused)) void *data)
8661 struct cmd_flow_director_result *res = parsed_result;
8662 struct rte_eth_fdir_filter entry;
8663 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8665 unsigned long vf_id;
8668 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8670 printf("flow director is not supported on port %u.\n",
8674 memset(flexbytes, 0, sizeof(flexbytes));
8675 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8677 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8678 if (strcmp(res->mode_value, "MAC-VLAN")) {
8679 printf("Please set mode to MAC-VLAN.\n");
8682 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8683 if (strcmp(res->mode_value, "Tunnel")) {
8684 printf("Please set mode to Tunnel.\n");
8688 if (strcmp(res->mode_value, "IP")) {
8689 printf("Please set mode to IP.\n");
8692 entry.input.flow_type = str2flowtype(res->flow_type);
8695 ret = parse_flexbytes(res->flexbytes_value,
8697 RTE_ETH_FDIR_MAX_FLEXLEN);
8699 printf("error: Cannot parse flexbytes input.\n");
8703 switch (entry.input.flow_type) {
8704 case RTE_ETH_FLOW_FRAG_IPV4:
8705 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8706 entry.input.flow.ip4_flow.proto = res->proto_value;
8707 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8708 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8709 IPV4_ADDR_TO_UINT(res->ip_dst,
8710 entry.input.flow.ip4_flow.dst_ip);
8711 IPV4_ADDR_TO_UINT(res->ip_src,
8712 entry.input.flow.ip4_flow.src_ip);
8713 entry.input.flow.ip4_flow.tos = res->tos_value;
8714 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8715 /* need convert to big endian. */
8716 entry.input.flow.udp4_flow.dst_port =
8717 rte_cpu_to_be_16(res->port_dst);
8718 entry.input.flow.udp4_flow.src_port =
8719 rte_cpu_to_be_16(res->port_src);
8721 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8722 IPV4_ADDR_TO_UINT(res->ip_dst,
8723 entry.input.flow.sctp4_flow.ip.dst_ip);
8724 IPV4_ADDR_TO_UINT(res->ip_src,
8725 entry.input.flow.sctp4_flow.ip.src_ip);
8726 entry.input.flow.ip4_flow.tos = res->tos_value;
8727 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8728 /* need convert to big endian. */
8729 entry.input.flow.sctp4_flow.dst_port =
8730 rte_cpu_to_be_16(res->port_dst);
8731 entry.input.flow.sctp4_flow.src_port =
8732 rte_cpu_to_be_16(res->port_src);
8733 entry.input.flow.sctp4_flow.verify_tag =
8734 rte_cpu_to_be_32(res->verify_tag_value);
8736 case RTE_ETH_FLOW_FRAG_IPV6:
8737 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8738 entry.input.flow.ipv6_flow.proto = res->proto_value;
8739 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8740 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8741 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8742 entry.input.flow.ipv6_flow.dst_ip);
8743 IPV6_ADDR_TO_ARRAY(res->ip_src,
8744 entry.input.flow.ipv6_flow.src_ip);
8745 entry.input.flow.ipv6_flow.tc = res->tos_value;
8746 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8747 /* need convert to big endian. */
8748 entry.input.flow.udp6_flow.dst_port =
8749 rte_cpu_to_be_16(res->port_dst);
8750 entry.input.flow.udp6_flow.src_port =
8751 rte_cpu_to_be_16(res->port_src);
8753 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8754 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8755 entry.input.flow.sctp6_flow.ip.dst_ip);
8756 IPV6_ADDR_TO_ARRAY(res->ip_src,
8757 entry.input.flow.sctp6_flow.ip.src_ip);
8758 entry.input.flow.ipv6_flow.tc = res->tos_value;
8759 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8760 /* need convert to big endian. */
8761 entry.input.flow.sctp6_flow.dst_port =
8762 rte_cpu_to_be_16(res->port_dst);
8763 entry.input.flow.sctp6_flow.src_port =
8764 rte_cpu_to_be_16(res->port_src);
8765 entry.input.flow.sctp6_flow.verify_tag =
8766 rte_cpu_to_be_32(res->verify_tag_value);
8768 case RTE_ETH_FLOW_L2_PAYLOAD:
8769 entry.input.flow.l2_flow.ether_type =
8770 rte_cpu_to_be_16(res->ether_type);
8776 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8777 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8779 sizeof(struct ether_addr));
8781 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8782 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8784 sizeof(struct ether_addr));
8785 entry.input.flow.tunnel_flow.tunnel_type =
8786 str2fdir_tunneltype(res->tunnel_type);
8787 entry.input.flow.tunnel_flow.tunnel_id =
8788 rte_cpu_to_be_32(res->tunnel_id_value);
8791 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8793 RTE_ETH_FDIR_MAX_FLEXLEN);
8795 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8797 entry.action.flex_off = 0; /*use 0 by default */
8798 if (!strcmp(res->drop, "drop"))
8799 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8801 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8803 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8804 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8805 if (!strcmp(res->pf_vf, "pf"))
8806 entry.input.flow_ext.is_vf = 0;
8807 else if (!strncmp(res->pf_vf, "vf", 2)) {
8808 struct rte_eth_dev_info dev_info;
8810 memset(&dev_info, 0, sizeof(dev_info));
8811 rte_eth_dev_info_get(res->port_id, &dev_info);
8813 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8814 if (errno != 0 || *end != '\0' ||
8815 vf_id >= dev_info.max_vfs) {
8816 printf("invalid parameter %s.\n", res->pf_vf);
8819 entry.input.flow_ext.is_vf = 1;
8820 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8822 printf("invalid parameter %s.\n", res->pf_vf);
8827 /* set to report FD ID by default */
8828 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8829 entry.action.rx_queue = res->queue_id;
8830 entry.soft_id = res->fd_id_value;
8831 if (!strcmp(res->ops, "add"))
8832 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8833 RTE_ETH_FILTER_ADD, &entry);
8834 else if (!strcmp(res->ops, "del"))
8835 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8836 RTE_ETH_FILTER_DELETE, &entry);
8838 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8839 RTE_ETH_FILTER_UPDATE, &entry);
8841 printf("flow director programming error: (%s)\n",
8845 cmdline_parse_token_string_t cmd_flow_director_filter =
8846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8847 flow_director_filter, "flow_director_filter");
8848 cmdline_parse_token_num_t cmd_flow_director_port_id =
8849 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8851 cmdline_parse_token_string_t cmd_flow_director_ops =
8852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8853 ops, "add#del#update");
8854 cmdline_parse_token_string_t cmd_flow_director_flow =
8855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8857 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8859 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8860 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8861 cmdline_parse_token_string_t cmd_flow_director_ether =
8862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8864 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8865 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8866 ether_type, UINT16);
8867 cmdline_parse_token_string_t cmd_flow_director_src =
8868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8870 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8871 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8873 cmdline_parse_token_num_t cmd_flow_director_port_src =
8874 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8876 cmdline_parse_token_string_t cmd_flow_director_dst =
8877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8879 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8880 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8882 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8883 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8885 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8887 verify_tag, "verify_tag");
8888 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8889 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8890 verify_tag_value, UINT32);
8891 cmdline_parse_token_string_t cmd_flow_director_tos =
8892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8894 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8895 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8897 cmdline_parse_token_string_t cmd_flow_director_proto =
8898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8900 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8901 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8902 proto_value, UINT8);
8903 cmdline_parse_token_string_t cmd_flow_director_ttl =
8904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8906 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8907 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8909 cmdline_parse_token_string_t cmd_flow_director_vlan =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8912 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8913 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8914 vlan_value, UINT16);
8915 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8917 flexbytes, "flexbytes");
8918 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8920 flexbytes_value, NULL);
8921 cmdline_parse_token_string_t cmd_flow_director_drop =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8927 cmdline_parse_token_string_t cmd_flow_director_queue =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8930 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8931 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8933 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8936 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8937 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8938 fd_id_value, UINT32);
8940 cmdline_parse_token_string_t cmd_flow_director_mode =
8941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8943 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8946 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8948 mode_value, "MAC-VLAN");
8949 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8951 mode_value, "Tunnel");
8952 cmdline_parse_token_string_t cmd_flow_director_mac =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8955 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8956 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8958 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8961 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8963 tunnel_type, "NVGRE#VxLAN");
8964 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8966 tunnel_id, "tunnel-id");
8967 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8968 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8969 tunnel_id_value, UINT32);
8971 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8972 .f = cmd_flow_director_filter_parsed,
8974 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8975 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8976 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8977 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8978 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8979 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8980 "fd_id <fd_id_value>: "
8981 "Add or delete an ip flow director entry on NIC",
8983 (void *)&cmd_flow_director_filter,
8984 (void *)&cmd_flow_director_port_id,
8985 (void *)&cmd_flow_director_mode,
8986 (void *)&cmd_flow_director_mode_ip,
8987 (void *)&cmd_flow_director_ops,
8988 (void *)&cmd_flow_director_flow,
8989 (void *)&cmd_flow_director_flow_type,
8990 (void *)&cmd_flow_director_src,
8991 (void *)&cmd_flow_director_ip_src,
8992 (void *)&cmd_flow_director_dst,
8993 (void *)&cmd_flow_director_ip_dst,
8994 (void *)&cmd_flow_director_tos,
8995 (void *)&cmd_flow_director_tos_value,
8996 (void *)&cmd_flow_director_proto,
8997 (void *)&cmd_flow_director_proto_value,
8998 (void *)&cmd_flow_director_ttl,
8999 (void *)&cmd_flow_director_ttl_value,
9000 (void *)&cmd_flow_director_vlan,
9001 (void *)&cmd_flow_director_vlan_value,
9002 (void *)&cmd_flow_director_flexbytes,
9003 (void *)&cmd_flow_director_flexbytes_value,
9004 (void *)&cmd_flow_director_drop,
9005 (void *)&cmd_flow_director_pf_vf,
9006 (void *)&cmd_flow_director_queue,
9007 (void *)&cmd_flow_director_queue_id,
9008 (void *)&cmd_flow_director_fd_id,
9009 (void *)&cmd_flow_director_fd_id_value,
9014 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9015 .f = cmd_flow_director_filter_parsed,
9017 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9018 "director entry on NIC",
9020 (void *)&cmd_flow_director_filter,
9021 (void *)&cmd_flow_director_port_id,
9022 (void *)&cmd_flow_director_mode,
9023 (void *)&cmd_flow_director_mode_ip,
9024 (void *)&cmd_flow_director_ops,
9025 (void *)&cmd_flow_director_flow,
9026 (void *)&cmd_flow_director_flow_type,
9027 (void *)&cmd_flow_director_src,
9028 (void *)&cmd_flow_director_ip_src,
9029 (void *)&cmd_flow_director_port_src,
9030 (void *)&cmd_flow_director_dst,
9031 (void *)&cmd_flow_director_ip_dst,
9032 (void *)&cmd_flow_director_port_dst,
9033 (void *)&cmd_flow_director_tos,
9034 (void *)&cmd_flow_director_tos_value,
9035 (void *)&cmd_flow_director_ttl,
9036 (void *)&cmd_flow_director_ttl_value,
9037 (void *)&cmd_flow_director_vlan,
9038 (void *)&cmd_flow_director_vlan_value,
9039 (void *)&cmd_flow_director_flexbytes,
9040 (void *)&cmd_flow_director_flexbytes_value,
9041 (void *)&cmd_flow_director_drop,
9042 (void *)&cmd_flow_director_pf_vf,
9043 (void *)&cmd_flow_director_queue,
9044 (void *)&cmd_flow_director_queue_id,
9045 (void *)&cmd_flow_director_fd_id,
9046 (void *)&cmd_flow_director_fd_id_value,
9051 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9052 .f = cmd_flow_director_filter_parsed,
9054 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9055 "director entry on NIC",
9057 (void *)&cmd_flow_director_filter,
9058 (void *)&cmd_flow_director_port_id,
9059 (void *)&cmd_flow_director_mode,
9060 (void *)&cmd_flow_director_mode_ip,
9061 (void *)&cmd_flow_director_ops,
9062 (void *)&cmd_flow_director_flow,
9063 (void *)&cmd_flow_director_flow_type,
9064 (void *)&cmd_flow_director_src,
9065 (void *)&cmd_flow_director_ip_src,
9066 (void *)&cmd_flow_director_port_dst,
9067 (void *)&cmd_flow_director_dst,
9068 (void *)&cmd_flow_director_ip_dst,
9069 (void *)&cmd_flow_director_port_dst,
9070 (void *)&cmd_flow_director_verify_tag,
9071 (void *)&cmd_flow_director_verify_tag_value,
9072 (void *)&cmd_flow_director_tos,
9073 (void *)&cmd_flow_director_tos_value,
9074 (void *)&cmd_flow_director_ttl,
9075 (void *)&cmd_flow_director_ttl_value,
9076 (void *)&cmd_flow_director_vlan,
9077 (void *)&cmd_flow_director_vlan_value,
9078 (void *)&cmd_flow_director_flexbytes,
9079 (void *)&cmd_flow_director_flexbytes_value,
9080 (void *)&cmd_flow_director_drop,
9081 (void *)&cmd_flow_director_pf_vf,
9082 (void *)&cmd_flow_director_queue,
9083 (void *)&cmd_flow_director_queue_id,
9084 (void *)&cmd_flow_director_fd_id,
9085 (void *)&cmd_flow_director_fd_id_value,
9090 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9091 .f = cmd_flow_director_filter_parsed,
9093 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9094 "director entry on NIC",
9096 (void *)&cmd_flow_director_filter,
9097 (void *)&cmd_flow_director_port_id,
9098 (void *)&cmd_flow_director_mode,
9099 (void *)&cmd_flow_director_mode_ip,
9100 (void *)&cmd_flow_director_ops,
9101 (void *)&cmd_flow_director_flow,
9102 (void *)&cmd_flow_director_flow_type,
9103 (void *)&cmd_flow_director_ether,
9104 (void *)&cmd_flow_director_ether_type,
9105 (void *)&cmd_flow_director_flexbytes,
9106 (void *)&cmd_flow_director_flexbytes_value,
9107 (void *)&cmd_flow_director_drop,
9108 (void *)&cmd_flow_director_pf_vf,
9109 (void *)&cmd_flow_director_queue,
9110 (void *)&cmd_flow_director_queue_id,
9111 (void *)&cmd_flow_director_fd_id,
9112 (void *)&cmd_flow_director_fd_id_value,
9117 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9118 .f = cmd_flow_director_filter_parsed,
9120 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9121 "director entry on NIC",
9123 (void *)&cmd_flow_director_filter,
9124 (void *)&cmd_flow_director_port_id,
9125 (void *)&cmd_flow_director_mode,
9126 (void *)&cmd_flow_director_mode_mac_vlan,
9127 (void *)&cmd_flow_director_ops,
9128 (void *)&cmd_flow_director_mac,
9129 (void *)&cmd_flow_director_mac_addr,
9130 (void *)&cmd_flow_director_vlan,
9131 (void *)&cmd_flow_director_vlan_value,
9132 (void *)&cmd_flow_director_flexbytes,
9133 (void *)&cmd_flow_director_flexbytes_value,
9134 (void *)&cmd_flow_director_drop,
9135 (void *)&cmd_flow_director_queue,
9136 (void *)&cmd_flow_director_queue_id,
9137 (void *)&cmd_flow_director_fd_id,
9138 (void *)&cmd_flow_director_fd_id_value,
9143 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9144 .f = cmd_flow_director_filter_parsed,
9146 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9147 "director entry on NIC",
9149 (void *)&cmd_flow_director_filter,
9150 (void *)&cmd_flow_director_port_id,
9151 (void *)&cmd_flow_director_mode,
9152 (void *)&cmd_flow_director_mode_tunnel,
9153 (void *)&cmd_flow_director_ops,
9154 (void *)&cmd_flow_director_mac,
9155 (void *)&cmd_flow_director_mac_addr,
9156 (void *)&cmd_flow_director_vlan,
9157 (void *)&cmd_flow_director_vlan_value,
9158 (void *)&cmd_flow_director_tunnel,
9159 (void *)&cmd_flow_director_tunnel_type,
9160 (void *)&cmd_flow_director_tunnel_id,
9161 (void *)&cmd_flow_director_tunnel_id_value,
9162 (void *)&cmd_flow_director_flexbytes,
9163 (void *)&cmd_flow_director_flexbytes_value,
9164 (void *)&cmd_flow_director_drop,
9165 (void *)&cmd_flow_director_queue,
9166 (void *)&cmd_flow_director_queue_id,
9167 (void *)&cmd_flow_director_fd_id,
9168 (void *)&cmd_flow_director_fd_id_value,
9173 struct cmd_flush_flow_director_result {
9174 cmdline_fixed_string_t flush_flow_director;
9178 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9179 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9180 flush_flow_director, "flush_flow_director");
9181 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9182 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9186 cmd_flush_flow_director_parsed(void *parsed_result,
9187 __attribute__((unused)) struct cmdline *cl,
9188 __attribute__((unused)) void *data)
9190 struct cmd_flow_director_result *res = parsed_result;
9193 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9195 printf("flow director is not supported on port %u.\n",
9200 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9201 RTE_ETH_FILTER_FLUSH, NULL);
9203 printf("flow director table flushing error: (%s)\n",
9207 cmdline_parse_inst_t cmd_flush_flow_director = {
9208 .f = cmd_flush_flow_director_parsed,
9210 .help_str = "flush_flow_director <port_id>: "
9211 "Flush all flow director entries of a device on NIC",
9213 (void *)&cmd_flush_flow_director_flush,
9214 (void *)&cmd_flush_flow_director_port_id,
9219 /* *** deal with flow director mask *** */
9220 struct cmd_flow_director_mask_result {
9221 cmdline_fixed_string_t flow_director_mask;
9223 cmdline_fixed_string_t mode;
9224 cmdline_fixed_string_t mode_value;
9225 cmdline_fixed_string_t vlan;
9227 cmdline_fixed_string_t src_mask;
9228 cmdline_ipaddr_t ipv4_src;
9229 cmdline_ipaddr_t ipv6_src;
9231 cmdline_fixed_string_t dst_mask;
9232 cmdline_ipaddr_t ipv4_dst;
9233 cmdline_ipaddr_t ipv6_dst;
9235 cmdline_fixed_string_t mac;
9236 uint8_t mac_addr_byte_mask;
9237 cmdline_fixed_string_t tunnel_id;
9238 uint32_t tunnel_id_mask;
9239 cmdline_fixed_string_t tunnel_type;
9240 uint8_t tunnel_type_mask;
9244 cmd_flow_director_mask_parsed(void *parsed_result,
9245 __attribute__((unused)) struct cmdline *cl,
9246 __attribute__((unused)) void *data)
9248 struct cmd_flow_director_mask_result *res = parsed_result;
9249 struct rte_eth_fdir_masks *mask;
9250 struct rte_port *port;
9252 if (res->port_id > nb_ports) {
9253 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9257 port = &ports[res->port_id];
9258 /** Check if the port is not started **/
9259 if (port->port_status != RTE_PORT_STOPPED) {
9260 printf("Please stop port %d first\n", res->port_id);
9264 mask = &port->dev_conf.fdir_conf.mask;
9266 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9267 if (strcmp(res->mode_value, "MAC-VLAN")) {
9268 printf("Please set mode to MAC-VLAN.\n");
9272 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9273 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9274 if (strcmp(res->mode_value, "Tunnel")) {
9275 printf("Please set mode to Tunnel.\n");
9279 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9280 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9281 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9282 mask->tunnel_type_mask = res->tunnel_type_mask;
9284 if (strcmp(res->mode_value, "IP")) {
9285 printf("Please set mode to IP.\n");
9289 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9290 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9291 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9292 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9293 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9294 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9295 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9298 cmd_reconfig_device_queue(res->port_id, 1, 1);
9301 cmdline_parse_token_string_t cmd_flow_director_mask =
9302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9303 flow_director_mask, "flow_director_mask");
9304 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9305 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9307 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9308 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9310 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9311 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9313 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9314 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9315 src_mask, "src_mask");
9316 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9317 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9319 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9320 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9322 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9323 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9325 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9327 dst_mask, "dst_mask");
9328 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9329 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9331 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9332 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9334 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9335 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9338 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9341 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9344 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9346 mode_value, "MAC-VLAN");
9347 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9349 mode_value, "Tunnel");
9350 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9353 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9354 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9355 mac_addr_byte_mask, UINT8);
9356 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9358 tunnel_type, "tunnel-type");
9359 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9360 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9361 tunnel_type_mask, UINT8);
9362 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9364 tunnel_id, "tunnel-id");
9365 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9366 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9367 tunnel_id_mask, UINT32);
9369 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9370 .f = cmd_flow_director_mask_parsed,
9372 .help_str = "flow_director_mask ... : "
9373 "Set IP mode flow director's mask on NIC",
9375 (void *)&cmd_flow_director_mask,
9376 (void *)&cmd_flow_director_mask_port_id,
9377 (void *)&cmd_flow_director_mask_mode,
9378 (void *)&cmd_flow_director_mask_mode_ip,
9379 (void *)&cmd_flow_director_mask_vlan,
9380 (void *)&cmd_flow_director_mask_vlan_value,
9381 (void *)&cmd_flow_director_mask_src,
9382 (void *)&cmd_flow_director_mask_ipv4_src,
9383 (void *)&cmd_flow_director_mask_ipv6_src,
9384 (void *)&cmd_flow_director_mask_port_src,
9385 (void *)&cmd_flow_director_mask_dst,
9386 (void *)&cmd_flow_director_mask_ipv4_dst,
9387 (void *)&cmd_flow_director_mask_ipv6_dst,
9388 (void *)&cmd_flow_director_mask_port_dst,
9393 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9394 .f = cmd_flow_director_mask_parsed,
9396 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9397 "flow director's mask on NIC",
9399 (void *)&cmd_flow_director_mask,
9400 (void *)&cmd_flow_director_mask_port_id,
9401 (void *)&cmd_flow_director_mask_mode,
9402 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9403 (void *)&cmd_flow_director_mask_vlan,
9404 (void *)&cmd_flow_director_mask_vlan_value,
9409 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9410 .f = cmd_flow_director_mask_parsed,
9412 .help_str = "flow_director_mask ... : Set tunnel mode "
9413 "flow director's mask on NIC",
9415 (void *)&cmd_flow_director_mask,
9416 (void *)&cmd_flow_director_mask_port_id,
9417 (void *)&cmd_flow_director_mask_mode,
9418 (void *)&cmd_flow_director_mask_mode_tunnel,
9419 (void *)&cmd_flow_director_mask_vlan,
9420 (void *)&cmd_flow_director_mask_vlan_value,
9421 (void *)&cmd_flow_director_mask_mac,
9422 (void *)&cmd_flow_director_mask_mac_value,
9423 (void *)&cmd_flow_director_mask_tunnel_type,
9424 (void *)&cmd_flow_director_mask_tunnel_type_value,
9425 (void *)&cmd_flow_director_mask_tunnel_id,
9426 (void *)&cmd_flow_director_mask_tunnel_id_value,
9431 /* *** deal with flow director mask on flexible payload *** */
9432 struct cmd_flow_director_flex_mask_result {
9433 cmdline_fixed_string_t flow_director_flexmask;
9435 cmdline_fixed_string_t flow;
9436 cmdline_fixed_string_t flow_type;
9437 cmdline_fixed_string_t mask;
9441 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9442 __attribute__((unused)) struct cmdline *cl,
9443 __attribute__((unused)) void *data)
9445 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9446 struct rte_eth_fdir_info fdir_info;
9447 struct rte_eth_fdir_flex_mask flex_mask;
9448 struct rte_port *port;
9449 uint32_t flow_type_mask;
9453 if (res->port_id > nb_ports) {
9454 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9458 port = &ports[res->port_id];
9459 /** Check if the port is not started **/
9460 if (port->port_status != RTE_PORT_STOPPED) {
9461 printf("Please stop port %d first\n", res->port_id);
9465 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9466 ret = parse_flexbytes(res->mask,
9468 RTE_ETH_FDIR_MAX_FLEXLEN);
9470 printf("error: Cannot parse mask input.\n");
9474 memset(&fdir_info, 0, sizeof(fdir_info));
9475 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9476 RTE_ETH_FILTER_INFO, &fdir_info);
9478 printf("Cannot get FDir filter info\n");
9482 if (!strcmp(res->flow_type, "none")) {
9483 /* means don't specify the flow type */
9484 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9485 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9486 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9487 0, sizeof(struct rte_eth_fdir_flex_mask));
9488 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9489 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9491 sizeof(struct rte_eth_fdir_flex_mask));
9492 cmd_reconfig_device_queue(res->port_id, 1, 1);
9495 flow_type_mask = fdir_info.flow_types_mask[0];
9496 if (!strcmp(res->flow_type, "all")) {
9497 if (!flow_type_mask) {
9498 printf("No flow type supported\n");
9501 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9502 if (flow_type_mask & (1 << i)) {
9503 flex_mask.flow_type = i;
9504 fdir_set_flex_mask(res->port_id, &flex_mask);
9507 cmd_reconfig_device_queue(res->port_id, 1, 1);
9510 flex_mask.flow_type = str2flowtype(res->flow_type);
9511 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9512 printf("Flow type %s not supported on port %d\n",
9513 res->flow_type, res->port_id);
9516 fdir_set_flex_mask(res->port_id, &flex_mask);
9517 cmd_reconfig_device_queue(res->port_id, 1, 1);
9520 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9522 flow_director_flexmask,
9523 "flow_director_flex_mask");
9524 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9525 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9527 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9528 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9530 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9532 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9533 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9534 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9535 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9538 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9539 .f = cmd_flow_director_flex_mask_parsed,
9541 .help_str = "flow_director_flex_mask ... : "
9542 "Set flow director's flex mask on NIC",
9544 (void *)&cmd_flow_director_flexmask,
9545 (void *)&cmd_flow_director_flexmask_port_id,
9546 (void *)&cmd_flow_director_flexmask_flow,
9547 (void *)&cmd_flow_director_flexmask_flow_type,
9548 (void *)&cmd_flow_director_flexmask_mask,
9553 /* *** deal with flow director flexible payload configuration *** */
9554 struct cmd_flow_director_flexpayload_result {
9555 cmdline_fixed_string_t flow_director_flexpayload;
9557 cmdline_fixed_string_t payload_layer;
9558 cmdline_fixed_string_t payload_cfg;
9562 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9565 const char *p, *p0 = q_arg;
9567 unsigned long int_fld;
9568 char *str_fld[max_num];
9573 p = strchr(p0, '(');
9577 p0 = strchr(p, ')');
9582 if (size >= sizeof(s))
9585 snprintf(s, sizeof(s), "%.*s", size, p);
9586 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9587 if (ret < 0 || ret > max_num)
9589 for (i = 0; i < ret; i++) {
9591 int_fld = strtoul(str_fld[i], &end, 0);
9592 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9594 offsets[i] = (uint16_t)int_fld;
9600 cmd_flow_director_flxpld_parsed(void *parsed_result,
9601 __attribute__((unused)) struct cmdline *cl,
9602 __attribute__((unused)) void *data)
9604 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9605 struct rte_eth_flex_payload_cfg flex_cfg;
9606 struct rte_port *port;
9609 if (res->port_id > nb_ports) {
9610 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9614 port = &ports[res->port_id];
9615 /** Check if the port is not started **/
9616 if (port->port_status != RTE_PORT_STOPPED) {
9617 printf("Please stop port %d first\n", res->port_id);
9621 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9623 if (!strcmp(res->payload_layer, "raw"))
9624 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9625 else if (!strcmp(res->payload_layer, "l2"))
9626 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9627 else if (!strcmp(res->payload_layer, "l3"))
9628 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9629 else if (!strcmp(res->payload_layer, "l4"))
9630 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9632 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9633 RTE_ETH_FDIR_MAX_FLEXLEN);
9635 printf("error: Cannot parse flex payload input.\n");
9639 fdir_set_flex_payload(res->port_id, &flex_cfg);
9640 cmd_reconfig_device_queue(res->port_id, 1, 1);
9643 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9644 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9645 flow_director_flexpayload,
9646 "flow_director_flex_payload");
9647 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9648 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9650 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9652 payload_layer, "raw#l2#l3#l4");
9653 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9657 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9658 .f = cmd_flow_director_flxpld_parsed,
9660 .help_str = "flow_director_flexpayload ... : "
9661 "Set flow director's flex payload on NIC",
9663 (void *)&cmd_flow_director_flexpayload,
9664 (void *)&cmd_flow_director_flexpayload_port_id,
9665 (void *)&cmd_flow_director_flexpayload_payload_layer,
9666 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9671 /* Generic flow interface command. */
9672 extern cmdline_parse_inst_t cmd_flow;
9674 /* *** Classification Filters Control *** */
9675 /* *** Get symmetric hash enable per port *** */
9676 struct cmd_get_sym_hash_ena_per_port_result {
9677 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9682 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9683 __rte_unused struct cmdline *cl,
9684 __rte_unused void *data)
9686 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9687 struct rte_eth_hash_filter_info info;
9690 if (rte_eth_dev_filter_supported(res->port_id,
9691 RTE_ETH_FILTER_HASH) < 0) {
9692 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9697 memset(&info, 0, sizeof(info));
9698 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9699 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9700 RTE_ETH_FILTER_GET, &info);
9703 printf("Cannot get symmetric hash enable per port "
9704 "on port %u\n", res->port_id);
9708 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9709 "enabled" : "disabled", res->port_id);
9712 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9713 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9714 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9715 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9716 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9719 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9720 .f = cmd_get_sym_hash_per_port_parsed,
9722 .help_str = "get_sym_hash_ena_per_port <port_id>",
9724 (void *)&cmd_get_sym_hash_ena_per_port_all,
9725 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9730 /* *** Set symmetric hash enable per port *** */
9731 struct cmd_set_sym_hash_ena_per_port_result {
9732 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9733 cmdline_fixed_string_t enable;
9738 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9739 __rte_unused struct cmdline *cl,
9740 __rte_unused void *data)
9742 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9743 struct rte_eth_hash_filter_info info;
9746 if (rte_eth_dev_filter_supported(res->port_id,
9747 RTE_ETH_FILTER_HASH) < 0) {
9748 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9753 memset(&info, 0, sizeof(info));
9754 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9755 if (!strcmp(res->enable, "enable"))
9756 info.info.enable = 1;
9757 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9758 RTE_ETH_FILTER_SET, &info);
9760 printf("Cannot set symmetric hash enable per port on "
9761 "port %u\n", res->port_id);
9764 printf("Symmetric hash has been set to %s on port %u\n",
9765 res->enable, res->port_id);
9768 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9769 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9770 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9771 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9772 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9774 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9775 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9776 enable, "enable#disable");
9778 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9779 .f = cmd_set_sym_hash_per_port_parsed,
9781 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9783 (void *)&cmd_set_sym_hash_ena_per_port_all,
9784 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9785 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9790 /* Get global config of hash function */
9791 struct cmd_get_hash_global_config_result {
9792 cmdline_fixed_string_t get_hash_global_config;
9797 flowtype_to_str(uint16_t ftype)
9804 {"ipv4", RTE_ETH_FLOW_IPV4},
9805 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9806 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9807 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9808 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9809 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9810 {"ipv6", RTE_ETH_FLOW_IPV6},
9811 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9812 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9813 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9814 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9815 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9816 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9817 {"port", RTE_ETH_FLOW_PORT},
9818 {"vxlan", RTE_ETH_FLOW_VXLAN},
9819 {"geneve", RTE_ETH_FLOW_GENEVE},
9820 {"nvgre", RTE_ETH_FLOW_NVGRE},
9823 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9824 if (ftype_table[i].ftype == ftype)
9825 return ftype_table[i].str;
9832 cmd_get_hash_global_config_parsed(void *parsed_result,
9833 __rte_unused struct cmdline *cl,
9834 __rte_unused void *data)
9836 struct cmd_get_hash_global_config_result *res = parsed_result;
9837 struct rte_eth_hash_filter_info info;
9838 uint32_t idx, offset;
9843 if (rte_eth_dev_filter_supported(res->port_id,
9844 RTE_ETH_FILTER_HASH) < 0) {
9845 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9850 memset(&info, 0, sizeof(info));
9851 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9852 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9853 RTE_ETH_FILTER_GET, &info);
9855 printf("Cannot get hash global configurations by port %d\n",
9860 switch (info.info.global_conf.hash_func) {
9861 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9862 printf("Hash function is Toeplitz\n");
9864 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9865 printf("Hash function is Simple XOR\n");
9868 printf("Unknown hash function\n");
9872 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9873 idx = i / UINT32_BIT;
9874 offset = i % UINT32_BIT;
9875 if (!(info.info.global_conf.valid_bit_mask[idx] &
9878 str = flowtype_to_str(i);
9881 printf("Symmetric hash is %s globally for flow type %s "
9883 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9884 (1UL << offset)) ? "enabled" : "disabled"), str,
9889 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9890 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9891 get_hash_global_config, "get_hash_global_config");
9892 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9893 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9896 cmdline_parse_inst_t cmd_get_hash_global_config = {
9897 .f = cmd_get_hash_global_config_parsed,
9899 .help_str = "get_hash_global_config <port_id>",
9901 (void *)&cmd_get_hash_global_config_all,
9902 (void *)&cmd_get_hash_global_config_port_id,
9907 /* Set global config of hash function */
9908 struct cmd_set_hash_global_config_result {
9909 cmdline_fixed_string_t set_hash_global_config;
9911 cmdline_fixed_string_t hash_func;
9912 cmdline_fixed_string_t flow_type;
9913 cmdline_fixed_string_t enable;
9917 cmd_set_hash_global_config_parsed(void *parsed_result,
9918 __rte_unused struct cmdline *cl,
9919 __rte_unused void *data)
9921 struct cmd_set_hash_global_config_result *res = parsed_result;
9922 struct rte_eth_hash_filter_info info;
9923 uint32_t ftype, idx, offset;
9926 if (rte_eth_dev_filter_supported(res->port_id,
9927 RTE_ETH_FILTER_HASH) < 0) {
9928 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9932 memset(&info, 0, sizeof(info));
9933 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9934 if (!strcmp(res->hash_func, "toeplitz"))
9935 info.info.global_conf.hash_func =
9936 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9937 else if (!strcmp(res->hash_func, "simple_xor"))
9938 info.info.global_conf.hash_func =
9939 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9940 else if (!strcmp(res->hash_func, "default"))
9941 info.info.global_conf.hash_func =
9942 RTE_ETH_HASH_FUNCTION_DEFAULT;
9944 ftype = str2flowtype(res->flow_type);
9945 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9946 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9947 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9948 if (!strcmp(res->enable, "enable"))
9949 info.info.global_conf.sym_hash_enable_mask[idx] |=
9951 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9952 RTE_ETH_FILTER_SET, &info);
9954 printf("Cannot set global hash configurations by port %d\n",
9957 printf("Global hash configurations have been set "
9958 "succcessfully by port %d\n", res->port_id);
9961 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9962 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9963 set_hash_global_config, "set_hash_global_config");
9964 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9965 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9967 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9968 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9969 hash_func, "toeplitz#simple_xor#default");
9970 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9971 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9973 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9974 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9975 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9976 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9977 enable, "enable#disable");
9979 cmdline_parse_inst_t cmd_set_hash_global_config = {
9980 .f = cmd_set_hash_global_config_parsed,
9982 .help_str = "set_hash_global_config <port_id> "
9983 "toeplitz|simple_xor|default "
9984 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9985 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9986 "l2_payload enable|disable",
9988 (void *)&cmd_set_hash_global_config_all,
9989 (void *)&cmd_set_hash_global_config_port_id,
9990 (void *)&cmd_set_hash_global_config_hash_func,
9991 (void *)&cmd_set_hash_global_config_flow_type,
9992 (void *)&cmd_set_hash_global_config_enable,
9997 /* Set hash input set */
9998 struct cmd_set_hash_input_set_result {
9999 cmdline_fixed_string_t set_hash_input_set;
10001 cmdline_fixed_string_t flow_type;
10002 cmdline_fixed_string_t inset_field;
10003 cmdline_fixed_string_t select;
10006 static enum rte_eth_input_set_field
10007 str2inset(char *string)
10011 static const struct {
10013 enum rte_eth_input_set_field inset;
10014 } inset_table[] = {
10015 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10016 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10017 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10018 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10019 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10020 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10021 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10022 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10023 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10024 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10025 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10026 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10027 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10028 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10029 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10030 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10031 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10032 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10033 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10034 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10035 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10036 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10037 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10038 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10039 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10040 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10041 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10042 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10043 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10044 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10045 {"none", RTE_ETH_INPUT_SET_NONE},
10048 for (i = 0; i < RTE_DIM(inset_table); i++) {
10049 if (!strcmp(string, inset_table[i].str))
10050 return inset_table[i].inset;
10053 return RTE_ETH_INPUT_SET_UNKNOWN;
10057 cmd_set_hash_input_set_parsed(void *parsed_result,
10058 __rte_unused struct cmdline *cl,
10059 __rte_unused void *data)
10061 struct cmd_set_hash_input_set_result *res = parsed_result;
10062 struct rte_eth_hash_filter_info info;
10064 memset(&info, 0, sizeof(info));
10065 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10066 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10067 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10068 info.info.input_set_conf.inset_size = 1;
10069 if (!strcmp(res->select, "select"))
10070 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10071 else if (!strcmp(res->select, "add"))
10072 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10073 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10074 RTE_ETH_FILTER_SET, &info);
10077 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10078 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10079 set_hash_input_set, "set_hash_input_set");
10080 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10081 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10083 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10084 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10086 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10087 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10088 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10089 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10091 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10092 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10093 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10094 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10095 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10097 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10098 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10099 select, "select#add");
10101 cmdline_parse_inst_t cmd_set_hash_input_set = {
10102 .f = cmd_set_hash_input_set_parsed,
10104 .help_str = "set_hash_input_set <port_id> "
10105 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10106 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10107 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10108 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10109 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10110 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10111 "fld-7th|fld-8th|none select|add",
10113 (void *)&cmd_set_hash_input_set_cmd,
10114 (void *)&cmd_set_hash_input_set_port_id,
10115 (void *)&cmd_set_hash_input_set_flow_type,
10116 (void *)&cmd_set_hash_input_set_field,
10117 (void *)&cmd_set_hash_input_set_select,
10122 /* Set flow director input set */
10123 struct cmd_set_fdir_input_set_result {
10124 cmdline_fixed_string_t set_fdir_input_set;
10126 cmdline_fixed_string_t flow_type;
10127 cmdline_fixed_string_t inset_field;
10128 cmdline_fixed_string_t select;
10132 cmd_set_fdir_input_set_parsed(void *parsed_result,
10133 __rte_unused struct cmdline *cl,
10134 __rte_unused void *data)
10136 struct cmd_set_fdir_input_set_result *res = parsed_result;
10137 struct rte_eth_fdir_filter_info info;
10139 memset(&info, 0, sizeof(info));
10140 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10141 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10142 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10143 info.info.input_set_conf.inset_size = 1;
10144 if (!strcmp(res->select, "select"))
10145 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10146 else if (!strcmp(res->select, "add"))
10147 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10148 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10149 RTE_ETH_FILTER_SET, &info);
10152 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10153 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10154 set_fdir_input_set, "set_fdir_input_set");
10155 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10156 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10158 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10159 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10161 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10162 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10163 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10164 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10166 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10167 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10168 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10169 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10170 "sctp-veri-tag#none");
10171 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10172 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10173 select, "select#add");
10175 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10176 .f = cmd_set_fdir_input_set_parsed,
10178 .help_str = "set_fdir_input_set <port_id> "
10179 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10180 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10181 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10182 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10183 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10184 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10185 "sctp-veri-tag|none select|add",
10187 (void *)&cmd_set_fdir_input_set_cmd,
10188 (void *)&cmd_set_fdir_input_set_port_id,
10189 (void *)&cmd_set_fdir_input_set_flow_type,
10190 (void *)&cmd_set_fdir_input_set_field,
10191 (void *)&cmd_set_fdir_input_set_select,
10196 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10197 struct cmd_mcast_addr_result {
10198 cmdline_fixed_string_t mcast_addr_cmd;
10199 cmdline_fixed_string_t what;
10201 struct ether_addr mc_addr;
10204 static void cmd_mcast_addr_parsed(void *parsed_result,
10205 __attribute__((unused)) struct cmdline *cl,
10206 __attribute__((unused)) void *data)
10208 struct cmd_mcast_addr_result *res = parsed_result;
10210 if (!is_multicast_ether_addr(&res->mc_addr)) {
10211 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10212 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10213 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10214 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10217 if (strcmp(res->what, "add") == 0)
10218 mcast_addr_add(res->port_num, &res->mc_addr);
10220 mcast_addr_remove(res->port_num, &res->mc_addr);
10223 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10224 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10225 mcast_addr_cmd, "mcast_addr");
10226 cmdline_parse_token_string_t cmd_mcast_addr_what =
10227 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10229 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10230 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10231 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10232 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10234 cmdline_parse_inst_t cmd_mcast_addr = {
10235 .f = cmd_mcast_addr_parsed,
10237 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10238 "Add/Remove multicast MAC address on port_id",
10240 (void *)&cmd_mcast_addr_cmd,
10241 (void *)&cmd_mcast_addr_what,
10242 (void *)&cmd_mcast_addr_portnum,
10243 (void *)&cmd_mcast_addr_addr,
10248 /* l2 tunnel config
10249 * only support E-tag now.
10252 /* Ether type config */
10253 struct cmd_config_l2_tunnel_eth_type_result {
10254 cmdline_fixed_string_t port;
10255 cmdline_fixed_string_t config;
10256 cmdline_fixed_string_t all;
10258 cmdline_fixed_string_t l2_tunnel;
10259 cmdline_fixed_string_t l2_tunnel_type;
10260 cmdline_fixed_string_t eth_type;
10261 uint16_t eth_type_val;
10264 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10265 TOKEN_STRING_INITIALIZER
10266 (struct cmd_config_l2_tunnel_eth_type_result,
10268 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10269 TOKEN_STRING_INITIALIZER
10270 (struct cmd_config_l2_tunnel_eth_type_result,
10272 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10273 TOKEN_STRING_INITIALIZER
10274 (struct cmd_config_l2_tunnel_eth_type_result,
10276 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10277 TOKEN_NUM_INITIALIZER
10278 (struct cmd_config_l2_tunnel_eth_type_result,
10280 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10281 TOKEN_STRING_INITIALIZER
10282 (struct cmd_config_l2_tunnel_eth_type_result,
10283 l2_tunnel, "l2-tunnel");
10284 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10285 TOKEN_STRING_INITIALIZER
10286 (struct cmd_config_l2_tunnel_eth_type_result,
10287 l2_tunnel_type, "E-tag");
10288 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10289 TOKEN_STRING_INITIALIZER
10290 (struct cmd_config_l2_tunnel_eth_type_result,
10291 eth_type, "ether-type");
10292 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10293 TOKEN_NUM_INITIALIZER
10294 (struct cmd_config_l2_tunnel_eth_type_result,
10295 eth_type_val, UINT16);
10297 static enum rte_eth_tunnel_type
10298 str2fdir_l2_tunnel_type(char *string)
10302 static const struct {
10304 enum rte_eth_tunnel_type type;
10305 } l2_tunnel_type_str[] = {
10306 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10309 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10310 if (!strcmp(l2_tunnel_type_str[i].str, string))
10311 return l2_tunnel_type_str[i].type;
10313 return RTE_TUNNEL_TYPE_NONE;
10316 /* ether type config for all ports */
10318 cmd_config_l2_tunnel_eth_type_all_parsed
10319 (void *parsed_result,
10320 __attribute__((unused)) struct cmdline *cl,
10321 __attribute__((unused)) void *data)
10323 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10324 struct rte_eth_l2_tunnel_conf entry;
10327 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10328 entry.ether_type = res->eth_type_val;
10330 FOREACH_PORT(pid, ports) {
10331 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10335 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10336 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10338 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10340 (void *)&cmd_config_l2_tunnel_eth_type_port,
10341 (void *)&cmd_config_l2_tunnel_eth_type_config,
10342 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10343 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10344 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10345 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10346 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10351 /* ether type config for a specific port */
10353 cmd_config_l2_tunnel_eth_type_specific_parsed(
10354 void *parsed_result,
10355 __attribute__((unused)) struct cmdline *cl,
10356 __attribute__((unused)) void *data)
10358 struct cmd_config_l2_tunnel_eth_type_result *res =
10360 struct rte_eth_l2_tunnel_conf entry;
10362 if (port_id_is_invalid(res->id, ENABLED_WARN))
10365 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10366 entry.ether_type = res->eth_type_val;
10368 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10371 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10372 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10374 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10376 (void *)&cmd_config_l2_tunnel_eth_type_port,
10377 (void *)&cmd_config_l2_tunnel_eth_type_config,
10378 (void *)&cmd_config_l2_tunnel_eth_type_id,
10379 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10380 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10381 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10382 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10387 /* Enable/disable l2 tunnel */
10388 struct cmd_config_l2_tunnel_en_dis_result {
10389 cmdline_fixed_string_t port;
10390 cmdline_fixed_string_t config;
10391 cmdline_fixed_string_t all;
10393 cmdline_fixed_string_t l2_tunnel;
10394 cmdline_fixed_string_t l2_tunnel_type;
10395 cmdline_fixed_string_t en_dis;
10398 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10399 TOKEN_STRING_INITIALIZER
10400 (struct cmd_config_l2_tunnel_en_dis_result,
10402 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10403 TOKEN_STRING_INITIALIZER
10404 (struct cmd_config_l2_tunnel_en_dis_result,
10406 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10407 TOKEN_STRING_INITIALIZER
10408 (struct cmd_config_l2_tunnel_en_dis_result,
10410 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10411 TOKEN_NUM_INITIALIZER
10412 (struct cmd_config_l2_tunnel_en_dis_result,
10414 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10415 TOKEN_STRING_INITIALIZER
10416 (struct cmd_config_l2_tunnel_en_dis_result,
10417 l2_tunnel, "l2-tunnel");
10418 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10419 TOKEN_STRING_INITIALIZER
10420 (struct cmd_config_l2_tunnel_en_dis_result,
10421 l2_tunnel_type, "E-tag");
10422 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10423 TOKEN_STRING_INITIALIZER
10424 (struct cmd_config_l2_tunnel_en_dis_result,
10425 en_dis, "enable#disable");
10427 /* enable/disable l2 tunnel for all ports */
10429 cmd_config_l2_tunnel_en_dis_all_parsed(
10430 void *parsed_result,
10431 __attribute__((unused)) struct cmdline *cl,
10432 __attribute__((unused)) void *data)
10434 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10435 struct rte_eth_l2_tunnel_conf entry;
10439 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10441 if (!strcmp("enable", res->en_dis))
10446 FOREACH_PORT(pid, ports) {
10447 rte_eth_dev_l2_tunnel_offload_set(pid,
10449 ETH_L2_TUNNEL_ENABLE_MASK,
10454 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10455 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10457 .help_str = "port config all l2-tunnel E-tag enable|disable",
10459 (void *)&cmd_config_l2_tunnel_en_dis_port,
10460 (void *)&cmd_config_l2_tunnel_en_dis_config,
10461 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10462 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10463 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10464 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10469 /* enable/disable l2 tunnel for a port */
10471 cmd_config_l2_tunnel_en_dis_specific_parsed(
10472 void *parsed_result,
10473 __attribute__((unused)) struct cmdline *cl,
10474 __attribute__((unused)) void *data)
10476 struct cmd_config_l2_tunnel_en_dis_result *res =
10478 struct rte_eth_l2_tunnel_conf entry;
10480 if (port_id_is_invalid(res->id, ENABLED_WARN))
10483 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10485 if (!strcmp("enable", res->en_dis))
10486 rte_eth_dev_l2_tunnel_offload_set(res->id,
10488 ETH_L2_TUNNEL_ENABLE_MASK,
10491 rte_eth_dev_l2_tunnel_offload_set(res->id,
10493 ETH_L2_TUNNEL_ENABLE_MASK,
10497 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10498 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10500 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10502 (void *)&cmd_config_l2_tunnel_en_dis_port,
10503 (void *)&cmd_config_l2_tunnel_en_dis_config,
10504 (void *)&cmd_config_l2_tunnel_en_dis_id,
10505 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10506 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10507 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10512 /* E-tag configuration */
10514 /* Common result structure for all E-tag configuration */
10515 struct cmd_config_e_tag_result {
10516 cmdline_fixed_string_t e_tag;
10517 cmdline_fixed_string_t set;
10518 cmdline_fixed_string_t insertion;
10519 cmdline_fixed_string_t stripping;
10520 cmdline_fixed_string_t forwarding;
10521 cmdline_fixed_string_t filter;
10522 cmdline_fixed_string_t add;
10523 cmdline_fixed_string_t del;
10524 cmdline_fixed_string_t on;
10525 cmdline_fixed_string_t off;
10526 cmdline_fixed_string_t on_off;
10527 cmdline_fixed_string_t port_tag_id;
10528 uint32_t port_tag_id_val;
10529 cmdline_fixed_string_t e_tag_id;
10530 uint16_t e_tag_id_val;
10531 cmdline_fixed_string_t dst_pool;
10532 uint8_t dst_pool_val;
10533 cmdline_fixed_string_t port;
10535 cmdline_fixed_string_t vf;
10539 /* Common CLI fields for all E-tag configuration */
10540 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10541 TOKEN_STRING_INITIALIZER
10542 (struct cmd_config_e_tag_result,
10544 cmdline_parse_token_string_t cmd_config_e_tag_set =
10545 TOKEN_STRING_INITIALIZER
10546 (struct cmd_config_e_tag_result,
10548 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10549 TOKEN_STRING_INITIALIZER
10550 (struct cmd_config_e_tag_result,
10551 insertion, "insertion");
10552 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10553 TOKEN_STRING_INITIALIZER
10554 (struct cmd_config_e_tag_result,
10555 stripping, "stripping");
10556 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10557 TOKEN_STRING_INITIALIZER
10558 (struct cmd_config_e_tag_result,
10559 forwarding, "forwarding");
10560 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10561 TOKEN_STRING_INITIALIZER
10562 (struct cmd_config_e_tag_result,
10564 cmdline_parse_token_string_t cmd_config_e_tag_add =
10565 TOKEN_STRING_INITIALIZER
10566 (struct cmd_config_e_tag_result,
10568 cmdline_parse_token_string_t cmd_config_e_tag_del =
10569 TOKEN_STRING_INITIALIZER
10570 (struct cmd_config_e_tag_result,
10572 cmdline_parse_token_string_t cmd_config_e_tag_on =
10573 TOKEN_STRING_INITIALIZER
10574 (struct cmd_config_e_tag_result,
10576 cmdline_parse_token_string_t cmd_config_e_tag_off =
10577 TOKEN_STRING_INITIALIZER
10578 (struct cmd_config_e_tag_result,
10580 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10581 TOKEN_STRING_INITIALIZER
10582 (struct cmd_config_e_tag_result,
10584 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10585 TOKEN_STRING_INITIALIZER
10586 (struct cmd_config_e_tag_result,
10587 port_tag_id, "port-tag-id");
10588 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10589 TOKEN_NUM_INITIALIZER
10590 (struct cmd_config_e_tag_result,
10591 port_tag_id_val, UINT32);
10592 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10593 TOKEN_STRING_INITIALIZER
10594 (struct cmd_config_e_tag_result,
10595 e_tag_id, "e-tag-id");
10596 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10597 TOKEN_NUM_INITIALIZER
10598 (struct cmd_config_e_tag_result,
10599 e_tag_id_val, UINT16);
10600 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10601 TOKEN_STRING_INITIALIZER
10602 (struct cmd_config_e_tag_result,
10603 dst_pool, "dst-pool");
10604 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10605 TOKEN_NUM_INITIALIZER
10606 (struct cmd_config_e_tag_result,
10607 dst_pool_val, UINT8);
10608 cmdline_parse_token_string_t cmd_config_e_tag_port =
10609 TOKEN_STRING_INITIALIZER
10610 (struct cmd_config_e_tag_result,
10612 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10613 TOKEN_NUM_INITIALIZER
10614 (struct cmd_config_e_tag_result,
10616 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10617 TOKEN_STRING_INITIALIZER
10618 (struct cmd_config_e_tag_result,
10620 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10621 TOKEN_NUM_INITIALIZER
10622 (struct cmd_config_e_tag_result,
10625 /* E-tag insertion configuration */
10627 cmd_config_e_tag_insertion_en_parsed(
10628 void *parsed_result,
10629 __attribute__((unused)) struct cmdline *cl,
10630 __attribute__((unused)) void *data)
10632 struct cmd_config_e_tag_result *res =
10634 struct rte_eth_l2_tunnel_conf entry;
10636 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10639 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10640 entry.tunnel_id = res->port_tag_id_val;
10641 entry.vf_id = res->vf_id;
10642 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10644 ETH_L2_TUNNEL_INSERTION_MASK,
10649 cmd_config_e_tag_insertion_dis_parsed(
10650 void *parsed_result,
10651 __attribute__((unused)) struct cmdline *cl,
10652 __attribute__((unused)) void *data)
10654 struct cmd_config_e_tag_result *res =
10656 struct rte_eth_l2_tunnel_conf entry;
10658 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10661 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10662 entry.vf_id = res->vf_id;
10664 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10666 ETH_L2_TUNNEL_INSERTION_MASK,
10670 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10671 .f = cmd_config_e_tag_insertion_en_parsed,
10673 .help_str = "E-tag ... : E-tag insertion enable",
10675 (void *)&cmd_config_e_tag_e_tag,
10676 (void *)&cmd_config_e_tag_set,
10677 (void *)&cmd_config_e_tag_insertion,
10678 (void *)&cmd_config_e_tag_on,
10679 (void *)&cmd_config_e_tag_port_tag_id,
10680 (void *)&cmd_config_e_tag_port_tag_id_val,
10681 (void *)&cmd_config_e_tag_port,
10682 (void *)&cmd_config_e_tag_port_id,
10683 (void *)&cmd_config_e_tag_vf,
10684 (void *)&cmd_config_e_tag_vf_id,
10689 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10690 .f = cmd_config_e_tag_insertion_dis_parsed,
10692 .help_str = "E-tag ... : E-tag insertion disable",
10694 (void *)&cmd_config_e_tag_e_tag,
10695 (void *)&cmd_config_e_tag_set,
10696 (void *)&cmd_config_e_tag_insertion,
10697 (void *)&cmd_config_e_tag_off,
10698 (void *)&cmd_config_e_tag_port,
10699 (void *)&cmd_config_e_tag_port_id,
10700 (void *)&cmd_config_e_tag_vf,
10701 (void *)&cmd_config_e_tag_vf_id,
10706 /* E-tag stripping configuration */
10708 cmd_config_e_tag_stripping_parsed(
10709 void *parsed_result,
10710 __attribute__((unused)) struct cmdline *cl,
10711 __attribute__((unused)) void *data)
10713 struct cmd_config_e_tag_result *res =
10715 struct rte_eth_l2_tunnel_conf entry;
10717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10720 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10722 if (!strcmp(res->on_off, "on"))
10723 rte_eth_dev_l2_tunnel_offload_set
10726 ETH_L2_TUNNEL_STRIPPING_MASK,
10729 rte_eth_dev_l2_tunnel_offload_set
10732 ETH_L2_TUNNEL_STRIPPING_MASK,
10736 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10737 .f = cmd_config_e_tag_stripping_parsed,
10739 .help_str = "E-tag ... : E-tag stripping enable/disable",
10741 (void *)&cmd_config_e_tag_e_tag,
10742 (void *)&cmd_config_e_tag_set,
10743 (void *)&cmd_config_e_tag_stripping,
10744 (void *)&cmd_config_e_tag_on_off,
10745 (void *)&cmd_config_e_tag_port,
10746 (void *)&cmd_config_e_tag_port_id,
10751 /* E-tag forwarding configuration */
10753 cmd_config_e_tag_forwarding_parsed(
10754 void *parsed_result,
10755 __attribute__((unused)) struct cmdline *cl,
10756 __attribute__((unused)) void *data)
10758 struct cmd_config_e_tag_result *res = parsed_result;
10759 struct rte_eth_l2_tunnel_conf entry;
10761 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10764 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10766 if (!strcmp(res->on_off, "on"))
10767 rte_eth_dev_l2_tunnel_offload_set
10770 ETH_L2_TUNNEL_FORWARDING_MASK,
10773 rte_eth_dev_l2_tunnel_offload_set
10776 ETH_L2_TUNNEL_FORWARDING_MASK,
10780 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10781 .f = cmd_config_e_tag_forwarding_parsed,
10783 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10785 (void *)&cmd_config_e_tag_e_tag,
10786 (void *)&cmd_config_e_tag_set,
10787 (void *)&cmd_config_e_tag_forwarding,
10788 (void *)&cmd_config_e_tag_on_off,
10789 (void *)&cmd_config_e_tag_port,
10790 (void *)&cmd_config_e_tag_port_id,
10795 /* E-tag filter configuration */
10797 cmd_config_e_tag_filter_add_parsed(
10798 void *parsed_result,
10799 __attribute__((unused)) struct cmdline *cl,
10800 __attribute__((unused)) void *data)
10802 struct cmd_config_e_tag_result *res = parsed_result;
10803 struct rte_eth_l2_tunnel_conf entry;
10806 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10809 if (res->e_tag_id_val > 0x3fff) {
10810 printf("e-tag-id must be equal or less than 0x3fff.\n");
10814 ret = rte_eth_dev_filter_supported(res->port_id,
10815 RTE_ETH_FILTER_L2_TUNNEL);
10817 printf("E-tag filter is not supported on port %u.\n",
10822 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10823 entry.tunnel_id = res->e_tag_id_val;
10824 entry.pool = res->dst_pool_val;
10826 ret = rte_eth_dev_filter_ctrl(res->port_id,
10827 RTE_ETH_FILTER_L2_TUNNEL,
10828 RTE_ETH_FILTER_ADD,
10831 printf("E-tag filter programming error: (%s)\n",
10835 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10836 .f = cmd_config_e_tag_filter_add_parsed,
10838 .help_str = "E-tag ... : E-tag filter add",
10840 (void *)&cmd_config_e_tag_e_tag,
10841 (void *)&cmd_config_e_tag_set,
10842 (void *)&cmd_config_e_tag_filter,
10843 (void *)&cmd_config_e_tag_add,
10844 (void *)&cmd_config_e_tag_e_tag_id,
10845 (void *)&cmd_config_e_tag_e_tag_id_val,
10846 (void *)&cmd_config_e_tag_dst_pool,
10847 (void *)&cmd_config_e_tag_dst_pool_val,
10848 (void *)&cmd_config_e_tag_port,
10849 (void *)&cmd_config_e_tag_port_id,
10855 cmd_config_e_tag_filter_del_parsed(
10856 void *parsed_result,
10857 __attribute__((unused)) struct cmdline *cl,
10858 __attribute__((unused)) void *data)
10860 struct cmd_config_e_tag_result *res = parsed_result;
10861 struct rte_eth_l2_tunnel_conf entry;
10864 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10867 if (res->e_tag_id_val > 0x3fff) {
10868 printf("e-tag-id must be less than 0x3fff.\n");
10872 ret = rte_eth_dev_filter_supported(res->port_id,
10873 RTE_ETH_FILTER_L2_TUNNEL);
10875 printf("E-tag filter is not supported on port %u.\n",
10880 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10881 entry.tunnel_id = res->e_tag_id_val;
10883 ret = rte_eth_dev_filter_ctrl(res->port_id,
10884 RTE_ETH_FILTER_L2_TUNNEL,
10885 RTE_ETH_FILTER_DELETE,
10888 printf("E-tag filter programming error: (%s)\n",
10892 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10893 .f = cmd_config_e_tag_filter_del_parsed,
10895 .help_str = "E-tag ... : E-tag filter delete",
10897 (void *)&cmd_config_e_tag_e_tag,
10898 (void *)&cmd_config_e_tag_set,
10899 (void *)&cmd_config_e_tag_filter,
10900 (void *)&cmd_config_e_tag_del,
10901 (void *)&cmd_config_e_tag_e_tag_id,
10902 (void *)&cmd_config_e_tag_e_tag_id_val,
10903 (void *)&cmd_config_e_tag_port,
10904 (void *)&cmd_config_e_tag_port_id,
10909 /* vf vlan anti spoof configuration */
10911 /* Common result structure for vf vlan anti spoof */
10912 struct cmd_vf_vlan_anti_spoof_result {
10913 cmdline_fixed_string_t set;
10914 cmdline_fixed_string_t vf;
10915 cmdline_fixed_string_t vlan;
10916 cmdline_fixed_string_t antispoof;
10919 cmdline_fixed_string_t on_off;
10922 /* Common CLI fields for vf vlan anti spoof enable disable */
10923 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10924 TOKEN_STRING_INITIALIZER
10925 (struct cmd_vf_vlan_anti_spoof_result,
10927 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10928 TOKEN_STRING_INITIALIZER
10929 (struct cmd_vf_vlan_anti_spoof_result,
10931 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10932 TOKEN_STRING_INITIALIZER
10933 (struct cmd_vf_vlan_anti_spoof_result,
10935 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10936 TOKEN_STRING_INITIALIZER
10937 (struct cmd_vf_vlan_anti_spoof_result,
10938 antispoof, "antispoof");
10939 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10940 TOKEN_NUM_INITIALIZER
10941 (struct cmd_vf_vlan_anti_spoof_result,
10943 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10944 TOKEN_NUM_INITIALIZER
10945 (struct cmd_vf_vlan_anti_spoof_result,
10947 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10948 TOKEN_STRING_INITIALIZER
10949 (struct cmd_vf_vlan_anti_spoof_result,
10953 cmd_set_vf_vlan_anti_spoof_parsed(
10954 void *parsed_result,
10955 __attribute__((unused)) struct cmdline *cl,
10956 __attribute__((unused)) void *data)
10958 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10959 int ret = -ENOTSUP;
10961 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10963 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10966 #ifdef RTE_LIBRTE_IXGBE_PMD
10967 if (ret == -ENOTSUP)
10968 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10969 res->vf_id, is_on);
10971 #ifdef RTE_LIBRTE_I40E_PMD
10972 if (ret == -ENOTSUP)
10973 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10974 res->vf_id, is_on);
10981 printf("invalid vf_id %d\n", res->vf_id);
10984 printf("invalid port_id %d\n", res->port_id);
10987 printf("function not implemented\n");
10990 printf("programming error: (%s)\n", strerror(-ret));
10994 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10995 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10997 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10999 (void *)&cmd_vf_vlan_anti_spoof_set,
11000 (void *)&cmd_vf_vlan_anti_spoof_vf,
11001 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11002 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11003 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11004 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11005 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11010 /* vf mac anti spoof configuration */
11012 /* Common result structure for vf mac anti spoof */
11013 struct cmd_vf_mac_anti_spoof_result {
11014 cmdline_fixed_string_t set;
11015 cmdline_fixed_string_t vf;
11016 cmdline_fixed_string_t mac;
11017 cmdline_fixed_string_t antispoof;
11020 cmdline_fixed_string_t on_off;
11023 /* Common CLI fields for vf mac anti spoof enable disable */
11024 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11025 TOKEN_STRING_INITIALIZER
11026 (struct cmd_vf_mac_anti_spoof_result,
11028 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11029 TOKEN_STRING_INITIALIZER
11030 (struct cmd_vf_mac_anti_spoof_result,
11032 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11033 TOKEN_STRING_INITIALIZER
11034 (struct cmd_vf_mac_anti_spoof_result,
11036 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11037 TOKEN_STRING_INITIALIZER
11038 (struct cmd_vf_mac_anti_spoof_result,
11039 antispoof, "antispoof");
11040 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11041 TOKEN_NUM_INITIALIZER
11042 (struct cmd_vf_mac_anti_spoof_result,
11044 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11045 TOKEN_NUM_INITIALIZER
11046 (struct cmd_vf_mac_anti_spoof_result,
11048 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11049 TOKEN_STRING_INITIALIZER
11050 (struct cmd_vf_mac_anti_spoof_result,
11054 cmd_set_vf_mac_anti_spoof_parsed(
11055 void *parsed_result,
11056 __attribute__((unused)) struct cmdline *cl,
11057 __attribute__((unused)) void *data)
11059 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11060 int ret = -ENOTSUP;
11062 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11064 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11067 #ifdef RTE_LIBRTE_IXGBE_PMD
11068 if (ret == -ENOTSUP)
11069 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11070 res->vf_id, is_on);
11072 #ifdef RTE_LIBRTE_I40E_PMD
11073 if (ret == -ENOTSUP)
11074 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11075 res->vf_id, is_on);
11082 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11085 printf("invalid port_id %d\n", res->port_id);
11088 printf("function not implemented\n");
11091 printf("programming error: (%s)\n", strerror(-ret));
11095 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11096 .f = cmd_set_vf_mac_anti_spoof_parsed,
11098 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11100 (void *)&cmd_vf_mac_anti_spoof_set,
11101 (void *)&cmd_vf_mac_anti_spoof_vf,
11102 (void *)&cmd_vf_mac_anti_spoof_mac,
11103 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11104 (void *)&cmd_vf_mac_anti_spoof_port_id,
11105 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11106 (void *)&cmd_vf_mac_anti_spoof_on_off,
11111 /* vf vlan strip queue configuration */
11113 /* Common result structure for vf mac anti spoof */
11114 struct cmd_vf_vlan_stripq_result {
11115 cmdline_fixed_string_t set;
11116 cmdline_fixed_string_t vf;
11117 cmdline_fixed_string_t vlan;
11118 cmdline_fixed_string_t stripq;
11121 cmdline_fixed_string_t on_off;
11124 /* Common CLI fields for vf vlan strip enable disable */
11125 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11126 TOKEN_STRING_INITIALIZER
11127 (struct cmd_vf_vlan_stripq_result,
11129 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11130 TOKEN_STRING_INITIALIZER
11131 (struct cmd_vf_vlan_stripq_result,
11133 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11134 TOKEN_STRING_INITIALIZER
11135 (struct cmd_vf_vlan_stripq_result,
11137 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11138 TOKEN_STRING_INITIALIZER
11139 (struct cmd_vf_vlan_stripq_result,
11141 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11142 TOKEN_NUM_INITIALIZER
11143 (struct cmd_vf_vlan_stripq_result,
11145 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11146 TOKEN_NUM_INITIALIZER
11147 (struct cmd_vf_vlan_stripq_result,
11149 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11150 TOKEN_STRING_INITIALIZER
11151 (struct cmd_vf_vlan_stripq_result,
11155 cmd_set_vf_vlan_stripq_parsed(
11156 void *parsed_result,
11157 __attribute__((unused)) struct cmdline *cl,
11158 __attribute__((unused)) void *data)
11160 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11161 int ret = -ENOTSUP;
11163 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11165 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11168 #ifdef RTE_LIBRTE_IXGBE_PMD
11169 if (ret == -ENOTSUP)
11170 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11171 res->vf_id, is_on);
11173 #ifdef RTE_LIBRTE_I40E_PMD
11174 if (ret == -ENOTSUP)
11175 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11176 res->vf_id, is_on);
11183 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11186 printf("invalid port_id %d\n", res->port_id);
11189 printf("function not implemented\n");
11192 printf("programming error: (%s)\n", strerror(-ret));
11196 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11197 .f = cmd_set_vf_vlan_stripq_parsed,
11199 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11201 (void *)&cmd_vf_vlan_stripq_set,
11202 (void *)&cmd_vf_vlan_stripq_vf,
11203 (void *)&cmd_vf_vlan_stripq_vlan,
11204 (void *)&cmd_vf_vlan_stripq_stripq,
11205 (void *)&cmd_vf_vlan_stripq_port_id,
11206 (void *)&cmd_vf_vlan_stripq_vf_id,
11207 (void *)&cmd_vf_vlan_stripq_on_off,
11212 /* vf vlan insert configuration */
11214 /* Common result structure for vf vlan insert */
11215 struct cmd_vf_vlan_insert_result {
11216 cmdline_fixed_string_t set;
11217 cmdline_fixed_string_t vf;
11218 cmdline_fixed_string_t vlan;
11219 cmdline_fixed_string_t insert;
11225 /* Common CLI fields for vf vlan insert enable disable */
11226 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11227 TOKEN_STRING_INITIALIZER
11228 (struct cmd_vf_vlan_insert_result,
11230 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11231 TOKEN_STRING_INITIALIZER
11232 (struct cmd_vf_vlan_insert_result,
11234 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11235 TOKEN_STRING_INITIALIZER
11236 (struct cmd_vf_vlan_insert_result,
11238 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11239 TOKEN_STRING_INITIALIZER
11240 (struct cmd_vf_vlan_insert_result,
11242 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11243 TOKEN_NUM_INITIALIZER
11244 (struct cmd_vf_vlan_insert_result,
11246 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11247 TOKEN_NUM_INITIALIZER
11248 (struct cmd_vf_vlan_insert_result,
11250 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11251 TOKEN_NUM_INITIALIZER
11252 (struct cmd_vf_vlan_insert_result,
11256 cmd_set_vf_vlan_insert_parsed(
11257 void *parsed_result,
11258 __attribute__((unused)) struct cmdline *cl,
11259 __attribute__((unused)) void *data)
11261 struct cmd_vf_vlan_insert_result *res = parsed_result;
11262 int ret = -ENOTSUP;
11264 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11267 #ifdef RTE_LIBRTE_IXGBE_PMD
11268 if (ret == -ENOTSUP)
11269 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11272 #ifdef RTE_LIBRTE_I40E_PMD
11273 if (ret == -ENOTSUP)
11274 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11282 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11285 printf("invalid port_id %d\n", res->port_id);
11288 printf("function not implemented\n");
11291 printf("programming error: (%s)\n", strerror(-ret));
11295 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11296 .f = cmd_set_vf_vlan_insert_parsed,
11298 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11300 (void *)&cmd_vf_vlan_insert_set,
11301 (void *)&cmd_vf_vlan_insert_vf,
11302 (void *)&cmd_vf_vlan_insert_vlan,
11303 (void *)&cmd_vf_vlan_insert_insert,
11304 (void *)&cmd_vf_vlan_insert_port_id,
11305 (void *)&cmd_vf_vlan_insert_vf_id,
11306 (void *)&cmd_vf_vlan_insert_vlan_id,
11311 /* tx loopback configuration */
11313 /* Common result structure for tx loopback */
11314 struct cmd_tx_loopback_result {
11315 cmdline_fixed_string_t set;
11316 cmdline_fixed_string_t tx;
11317 cmdline_fixed_string_t loopback;
11319 cmdline_fixed_string_t on_off;
11322 /* Common CLI fields for tx loopback enable disable */
11323 cmdline_parse_token_string_t cmd_tx_loopback_set =
11324 TOKEN_STRING_INITIALIZER
11325 (struct cmd_tx_loopback_result,
11327 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11328 TOKEN_STRING_INITIALIZER
11329 (struct cmd_tx_loopback_result,
11331 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11332 TOKEN_STRING_INITIALIZER
11333 (struct cmd_tx_loopback_result,
11334 loopback, "loopback");
11335 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11336 TOKEN_NUM_INITIALIZER
11337 (struct cmd_tx_loopback_result,
11339 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11340 TOKEN_STRING_INITIALIZER
11341 (struct cmd_tx_loopback_result,
11345 cmd_set_tx_loopback_parsed(
11346 void *parsed_result,
11347 __attribute__((unused)) struct cmdline *cl,
11348 __attribute__((unused)) void *data)
11350 struct cmd_tx_loopback_result *res = parsed_result;
11351 int ret = -ENOTSUP;
11353 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11355 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11358 #ifdef RTE_LIBRTE_IXGBE_PMD
11359 if (ret == -ENOTSUP)
11360 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11362 #ifdef RTE_LIBRTE_I40E_PMD
11363 if (ret == -ENOTSUP)
11364 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11371 printf("invalid is_on %d\n", is_on);
11374 printf("invalid port_id %d\n", res->port_id);
11377 printf("function not implemented\n");
11380 printf("programming error: (%s)\n", strerror(-ret));
11384 cmdline_parse_inst_t cmd_set_tx_loopback = {
11385 .f = cmd_set_tx_loopback_parsed,
11387 .help_str = "set tx loopback <port_id> on|off",
11389 (void *)&cmd_tx_loopback_set,
11390 (void *)&cmd_tx_loopback_tx,
11391 (void *)&cmd_tx_loopback_loopback,
11392 (void *)&cmd_tx_loopback_port_id,
11393 (void *)&cmd_tx_loopback_on_off,
11398 #ifdef RTE_LIBRTE_IXGBE_PMD
11399 /* all queues drop enable configuration */
11401 /* Common result structure for all queues drop enable */
11402 struct cmd_all_queues_drop_en_result {
11403 cmdline_fixed_string_t set;
11404 cmdline_fixed_string_t all;
11405 cmdline_fixed_string_t queues;
11406 cmdline_fixed_string_t drop;
11408 cmdline_fixed_string_t on_off;
11411 /* Common CLI fields for tx loopback enable disable */
11412 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11413 TOKEN_STRING_INITIALIZER
11414 (struct cmd_all_queues_drop_en_result,
11416 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11417 TOKEN_STRING_INITIALIZER
11418 (struct cmd_all_queues_drop_en_result,
11420 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11421 TOKEN_STRING_INITIALIZER
11422 (struct cmd_all_queues_drop_en_result,
11424 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11425 TOKEN_STRING_INITIALIZER
11426 (struct cmd_all_queues_drop_en_result,
11428 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11429 TOKEN_NUM_INITIALIZER
11430 (struct cmd_all_queues_drop_en_result,
11432 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11433 TOKEN_STRING_INITIALIZER
11434 (struct cmd_all_queues_drop_en_result,
11438 cmd_set_all_queues_drop_en_parsed(
11439 void *parsed_result,
11440 __attribute__((unused)) struct cmdline *cl,
11441 __attribute__((unused)) void *data)
11443 struct cmd_all_queues_drop_en_result *res = parsed_result;
11445 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11447 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11450 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11455 printf("invalid is_on %d\n", is_on);
11458 printf("invalid port_id %d\n", res->port_id);
11461 printf("function not implemented\n");
11464 printf("programming error: (%s)\n", strerror(-ret));
11468 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11469 .f = cmd_set_all_queues_drop_en_parsed,
11471 .help_str = "set all queues drop <port_id> on|off",
11473 (void *)&cmd_all_queues_drop_en_set,
11474 (void *)&cmd_all_queues_drop_en_all,
11475 (void *)&cmd_all_queues_drop_en_queues,
11476 (void *)&cmd_all_queues_drop_en_drop,
11477 (void *)&cmd_all_queues_drop_en_port_id,
11478 (void *)&cmd_all_queues_drop_en_on_off,
11483 /* vf split drop enable configuration */
11485 /* Common result structure for vf split drop enable */
11486 struct cmd_vf_split_drop_en_result {
11487 cmdline_fixed_string_t set;
11488 cmdline_fixed_string_t vf;
11489 cmdline_fixed_string_t split;
11490 cmdline_fixed_string_t drop;
11493 cmdline_fixed_string_t on_off;
11496 /* Common CLI fields for vf split drop enable disable */
11497 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11498 TOKEN_STRING_INITIALIZER
11499 (struct cmd_vf_split_drop_en_result,
11501 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11502 TOKEN_STRING_INITIALIZER
11503 (struct cmd_vf_split_drop_en_result,
11505 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11506 TOKEN_STRING_INITIALIZER
11507 (struct cmd_vf_split_drop_en_result,
11509 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11510 TOKEN_STRING_INITIALIZER
11511 (struct cmd_vf_split_drop_en_result,
11513 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11514 TOKEN_NUM_INITIALIZER
11515 (struct cmd_vf_split_drop_en_result,
11517 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11518 TOKEN_NUM_INITIALIZER
11519 (struct cmd_vf_split_drop_en_result,
11521 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11522 TOKEN_STRING_INITIALIZER
11523 (struct cmd_vf_split_drop_en_result,
11527 cmd_set_vf_split_drop_en_parsed(
11528 void *parsed_result,
11529 __attribute__((unused)) struct cmdline *cl,
11530 __attribute__((unused)) void *data)
11532 struct cmd_vf_split_drop_en_result *res = parsed_result;
11534 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11536 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11539 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11545 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11548 printf("invalid port_id %d\n", res->port_id);
11551 printf("programming error: (%s)\n", strerror(-ret));
11555 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11556 .f = cmd_set_vf_split_drop_en_parsed,
11558 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11560 (void *)&cmd_vf_split_drop_en_set,
11561 (void *)&cmd_vf_split_drop_en_vf,
11562 (void *)&cmd_vf_split_drop_en_split,
11563 (void *)&cmd_vf_split_drop_en_drop,
11564 (void *)&cmd_vf_split_drop_en_port_id,
11565 (void *)&cmd_vf_split_drop_en_vf_id,
11566 (void *)&cmd_vf_split_drop_en_on_off,
11572 /* vf mac address configuration */
11574 /* Common result structure for vf mac address */
11575 struct cmd_set_vf_mac_addr_result {
11576 cmdline_fixed_string_t set;
11577 cmdline_fixed_string_t vf;
11578 cmdline_fixed_string_t mac;
11579 cmdline_fixed_string_t addr;
11582 struct ether_addr mac_addr;
11586 /* Common CLI fields for vf split drop enable disable */
11587 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11588 TOKEN_STRING_INITIALIZER
11589 (struct cmd_set_vf_mac_addr_result,
11591 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11592 TOKEN_STRING_INITIALIZER
11593 (struct cmd_set_vf_mac_addr_result,
11595 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11596 TOKEN_STRING_INITIALIZER
11597 (struct cmd_set_vf_mac_addr_result,
11599 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11600 TOKEN_STRING_INITIALIZER
11601 (struct cmd_set_vf_mac_addr_result,
11603 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11604 TOKEN_NUM_INITIALIZER
11605 (struct cmd_set_vf_mac_addr_result,
11607 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11608 TOKEN_NUM_INITIALIZER
11609 (struct cmd_set_vf_mac_addr_result,
11611 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11612 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11616 cmd_set_vf_mac_addr_parsed(
11617 void *parsed_result,
11618 __attribute__((unused)) struct cmdline *cl,
11619 __attribute__((unused)) void *data)
11621 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11622 int ret = -ENOTSUP;
11624 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11627 #ifdef RTE_LIBRTE_IXGBE_PMD
11628 if (ret == -ENOTSUP)
11629 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11632 #ifdef RTE_LIBRTE_I40E_PMD
11633 if (ret == -ENOTSUP)
11634 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11642 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11645 printf("invalid port_id %d\n", res->port_id);
11648 printf("function not implemented\n");
11651 printf("programming error: (%s)\n", strerror(-ret));
11655 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11656 .f = cmd_set_vf_mac_addr_parsed,
11658 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11660 (void *)&cmd_set_vf_mac_addr_set,
11661 (void *)&cmd_set_vf_mac_addr_vf,
11662 (void *)&cmd_set_vf_mac_addr_mac,
11663 (void *)&cmd_set_vf_mac_addr_addr,
11664 (void *)&cmd_set_vf_mac_addr_port_id,
11665 (void *)&cmd_set_vf_mac_addr_vf_id,
11666 (void *)&cmd_set_vf_mac_addr_mac_addr,
11671 #ifdef RTE_LIBRTE_IXGBE_PMD
11672 /* MACsec configuration */
11674 /* Common result structure for MACsec offload enable */
11675 struct cmd_macsec_offload_on_result {
11676 cmdline_fixed_string_t set;
11677 cmdline_fixed_string_t macsec;
11678 cmdline_fixed_string_t offload;
11680 cmdline_fixed_string_t on;
11681 cmdline_fixed_string_t encrypt;
11682 cmdline_fixed_string_t en_on_off;
11683 cmdline_fixed_string_t replay_protect;
11684 cmdline_fixed_string_t rp_on_off;
11687 /* Common CLI fields for MACsec offload disable */
11688 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11689 TOKEN_STRING_INITIALIZER
11690 (struct cmd_macsec_offload_on_result,
11692 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11693 TOKEN_STRING_INITIALIZER
11694 (struct cmd_macsec_offload_on_result,
11696 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11697 TOKEN_STRING_INITIALIZER
11698 (struct cmd_macsec_offload_on_result,
11699 offload, "offload");
11700 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11701 TOKEN_NUM_INITIALIZER
11702 (struct cmd_macsec_offload_on_result,
11704 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11705 TOKEN_STRING_INITIALIZER
11706 (struct cmd_macsec_offload_on_result,
11708 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11709 TOKEN_STRING_INITIALIZER
11710 (struct cmd_macsec_offload_on_result,
11711 encrypt, "encrypt");
11712 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11713 TOKEN_STRING_INITIALIZER
11714 (struct cmd_macsec_offload_on_result,
11715 en_on_off, "on#off");
11716 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11717 TOKEN_STRING_INITIALIZER
11718 (struct cmd_macsec_offload_on_result,
11719 replay_protect, "replay-protect");
11720 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11721 TOKEN_STRING_INITIALIZER
11722 (struct cmd_macsec_offload_on_result,
11723 rp_on_off, "on#off");
11726 cmd_set_macsec_offload_on_parsed(
11727 void *parsed_result,
11728 __attribute__((unused)) struct cmdline *cl,
11729 __attribute__((unused)) void *data)
11731 struct cmd_macsec_offload_on_result *res = parsed_result;
11733 portid_t port_id = res->port_id;
11734 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11735 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11737 if (port_id_is_invalid(port_id, ENABLED_WARN))
11740 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11741 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11747 printf("invalid port_id %d\n", port_id);
11750 printf("programming error: (%s)\n", strerror(-ret));
11754 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11755 .f = cmd_set_macsec_offload_on_parsed,
11757 .help_str = "set macsec offload <port_id> on "
11758 "encrypt on|off replay-protect on|off",
11760 (void *)&cmd_macsec_offload_on_set,
11761 (void *)&cmd_macsec_offload_on_macsec,
11762 (void *)&cmd_macsec_offload_on_offload,
11763 (void *)&cmd_macsec_offload_on_port_id,
11764 (void *)&cmd_macsec_offload_on_on,
11765 (void *)&cmd_macsec_offload_on_encrypt,
11766 (void *)&cmd_macsec_offload_on_en_on_off,
11767 (void *)&cmd_macsec_offload_on_replay_protect,
11768 (void *)&cmd_macsec_offload_on_rp_on_off,
11773 /* Common result structure for MACsec offload disable */
11774 struct cmd_macsec_offload_off_result {
11775 cmdline_fixed_string_t set;
11776 cmdline_fixed_string_t macsec;
11777 cmdline_fixed_string_t offload;
11779 cmdline_fixed_string_t off;
11782 /* Common CLI fields for MACsec offload disable */
11783 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11784 TOKEN_STRING_INITIALIZER
11785 (struct cmd_macsec_offload_off_result,
11787 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11788 TOKEN_STRING_INITIALIZER
11789 (struct cmd_macsec_offload_off_result,
11791 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11792 TOKEN_STRING_INITIALIZER
11793 (struct cmd_macsec_offload_off_result,
11794 offload, "offload");
11795 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11796 TOKEN_NUM_INITIALIZER
11797 (struct cmd_macsec_offload_off_result,
11799 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11800 TOKEN_STRING_INITIALIZER
11801 (struct cmd_macsec_offload_off_result,
11805 cmd_set_macsec_offload_off_parsed(
11806 void *parsed_result,
11807 __attribute__((unused)) struct cmdline *cl,
11808 __attribute__((unused)) void *data)
11810 struct cmd_macsec_offload_off_result *res = parsed_result;
11812 portid_t port_id = res->port_id;
11814 if (port_id_is_invalid(port_id, ENABLED_WARN))
11817 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11818 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11824 printf("invalid port_id %d\n", port_id);
11827 printf("programming error: (%s)\n", strerror(-ret));
11831 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11832 .f = cmd_set_macsec_offload_off_parsed,
11834 .help_str = "set macsec offload <port_id> off",
11836 (void *)&cmd_macsec_offload_off_set,
11837 (void *)&cmd_macsec_offload_off_macsec,
11838 (void *)&cmd_macsec_offload_off_offload,
11839 (void *)&cmd_macsec_offload_off_port_id,
11840 (void *)&cmd_macsec_offload_off_off,
11845 /* Common result structure for MACsec secure connection configure */
11846 struct cmd_macsec_sc_result {
11847 cmdline_fixed_string_t set;
11848 cmdline_fixed_string_t macsec;
11849 cmdline_fixed_string_t sc;
11850 cmdline_fixed_string_t tx_rx;
11852 struct ether_addr mac;
11856 /* Common CLI fields for MACsec secure connection configure */
11857 cmdline_parse_token_string_t cmd_macsec_sc_set =
11858 TOKEN_STRING_INITIALIZER
11859 (struct cmd_macsec_sc_result,
11861 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11862 TOKEN_STRING_INITIALIZER
11863 (struct cmd_macsec_sc_result,
11865 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11866 TOKEN_STRING_INITIALIZER
11867 (struct cmd_macsec_sc_result,
11869 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11870 TOKEN_STRING_INITIALIZER
11871 (struct cmd_macsec_sc_result,
11873 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11874 TOKEN_NUM_INITIALIZER
11875 (struct cmd_macsec_sc_result,
11877 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11878 TOKEN_ETHERADDR_INITIALIZER
11879 (struct cmd_macsec_sc_result,
11881 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11882 TOKEN_NUM_INITIALIZER
11883 (struct cmd_macsec_sc_result,
11887 cmd_set_macsec_sc_parsed(
11888 void *parsed_result,
11889 __attribute__((unused)) struct cmdline *cl,
11890 __attribute__((unused)) void *data)
11892 struct cmd_macsec_sc_result *res = parsed_result;
11894 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11897 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11898 res->mac.addr_bytes) :
11899 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11900 res->mac.addr_bytes, res->pi);
11905 printf("invalid port_id %d\n", res->port_id);
11908 printf("programming error: (%s)\n", strerror(-ret));
11912 cmdline_parse_inst_t cmd_set_macsec_sc = {
11913 .f = cmd_set_macsec_sc_parsed,
11915 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11917 (void *)&cmd_macsec_sc_set,
11918 (void *)&cmd_macsec_sc_macsec,
11919 (void *)&cmd_macsec_sc_sc,
11920 (void *)&cmd_macsec_sc_tx_rx,
11921 (void *)&cmd_macsec_sc_port_id,
11922 (void *)&cmd_macsec_sc_mac,
11923 (void *)&cmd_macsec_sc_pi,
11928 /* Common result structure for MACsec secure connection configure */
11929 struct cmd_macsec_sa_result {
11930 cmdline_fixed_string_t set;
11931 cmdline_fixed_string_t macsec;
11932 cmdline_fixed_string_t sa;
11933 cmdline_fixed_string_t tx_rx;
11938 cmdline_fixed_string_t key;
11941 /* Common CLI fields for MACsec secure connection configure */
11942 cmdline_parse_token_string_t cmd_macsec_sa_set =
11943 TOKEN_STRING_INITIALIZER
11944 (struct cmd_macsec_sa_result,
11946 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11947 TOKEN_STRING_INITIALIZER
11948 (struct cmd_macsec_sa_result,
11950 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11951 TOKEN_STRING_INITIALIZER
11952 (struct cmd_macsec_sa_result,
11954 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11955 TOKEN_STRING_INITIALIZER
11956 (struct cmd_macsec_sa_result,
11958 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11959 TOKEN_NUM_INITIALIZER
11960 (struct cmd_macsec_sa_result,
11962 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11963 TOKEN_NUM_INITIALIZER
11964 (struct cmd_macsec_sa_result,
11966 cmdline_parse_token_num_t cmd_macsec_sa_an =
11967 TOKEN_NUM_INITIALIZER
11968 (struct cmd_macsec_sa_result,
11970 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11971 TOKEN_NUM_INITIALIZER
11972 (struct cmd_macsec_sa_result,
11974 cmdline_parse_token_string_t cmd_macsec_sa_key =
11975 TOKEN_STRING_INITIALIZER
11976 (struct cmd_macsec_sa_result,
11980 cmd_set_macsec_sa_parsed(
11981 void *parsed_result,
11982 __attribute__((unused)) struct cmdline *cl,
11983 __attribute__((unused)) void *data)
11985 struct cmd_macsec_sa_result *res = parsed_result;
11987 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11988 uint8_t key[16] = { 0 };
11994 key_len = strlen(res->key) / 2;
11998 for (i = 0; i < key_len; i++) {
11999 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12002 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12005 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12009 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12010 res->idx, res->an, res->pn, key) :
12011 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12012 res->idx, res->an, res->pn, key);
12017 printf("invalid idx %d or an %d\n", res->idx, res->an);
12020 printf("invalid port_id %d\n", res->port_id);
12023 printf("programming error: (%s)\n", strerror(-ret));
12027 cmdline_parse_inst_t cmd_set_macsec_sa = {
12028 .f = cmd_set_macsec_sa_parsed,
12030 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12032 (void *)&cmd_macsec_sa_set,
12033 (void *)&cmd_macsec_sa_macsec,
12034 (void *)&cmd_macsec_sa_sa,
12035 (void *)&cmd_macsec_sa_tx_rx,
12036 (void *)&cmd_macsec_sa_port_id,
12037 (void *)&cmd_macsec_sa_idx,
12038 (void *)&cmd_macsec_sa_an,
12039 (void *)&cmd_macsec_sa_pn,
12040 (void *)&cmd_macsec_sa_key,
12046 /* VF unicast promiscuous mode configuration */
12048 /* Common result structure for VF unicast promiscuous mode */
12049 struct cmd_vf_promisc_result {
12050 cmdline_fixed_string_t set;
12051 cmdline_fixed_string_t vf;
12052 cmdline_fixed_string_t promisc;
12055 cmdline_fixed_string_t on_off;
12058 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12059 cmdline_parse_token_string_t cmd_vf_promisc_set =
12060 TOKEN_STRING_INITIALIZER
12061 (struct cmd_vf_promisc_result,
12063 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12064 TOKEN_STRING_INITIALIZER
12065 (struct cmd_vf_promisc_result,
12067 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12068 TOKEN_STRING_INITIALIZER
12069 (struct cmd_vf_promisc_result,
12070 promisc, "promisc");
12071 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12072 TOKEN_NUM_INITIALIZER
12073 (struct cmd_vf_promisc_result,
12075 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12076 TOKEN_NUM_INITIALIZER
12077 (struct cmd_vf_promisc_result,
12079 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12080 TOKEN_STRING_INITIALIZER
12081 (struct cmd_vf_promisc_result,
12085 cmd_set_vf_promisc_parsed(
12086 void *parsed_result,
12087 __attribute__((unused)) struct cmdline *cl,
12088 __attribute__((unused)) void *data)
12090 struct cmd_vf_promisc_result *res = parsed_result;
12091 int ret = -ENOTSUP;
12093 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12095 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12098 #ifdef RTE_LIBRTE_I40E_PMD
12099 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12100 res->vf_id, is_on);
12107 printf("invalid vf_id %d\n", res->vf_id);
12110 printf("invalid port_id %d\n", res->port_id);
12113 printf("function not implemented\n");
12116 printf("programming error: (%s)\n", strerror(-ret));
12120 cmdline_parse_inst_t cmd_set_vf_promisc = {
12121 .f = cmd_set_vf_promisc_parsed,
12123 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12124 "Set unicast promiscuous mode for a VF from the PF",
12126 (void *)&cmd_vf_promisc_set,
12127 (void *)&cmd_vf_promisc_vf,
12128 (void *)&cmd_vf_promisc_promisc,
12129 (void *)&cmd_vf_promisc_port_id,
12130 (void *)&cmd_vf_promisc_vf_id,
12131 (void *)&cmd_vf_promisc_on_off,
12136 /* VF multicast promiscuous mode configuration */
12138 /* Common result structure for VF multicast promiscuous mode */
12139 struct cmd_vf_allmulti_result {
12140 cmdline_fixed_string_t set;
12141 cmdline_fixed_string_t vf;
12142 cmdline_fixed_string_t allmulti;
12145 cmdline_fixed_string_t on_off;
12148 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12149 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12150 TOKEN_STRING_INITIALIZER
12151 (struct cmd_vf_allmulti_result,
12153 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12154 TOKEN_STRING_INITIALIZER
12155 (struct cmd_vf_allmulti_result,
12157 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12158 TOKEN_STRING_INITIALIZER
12159 (struct cmd_vf_allmulti_result,
12160 allmulti, "allmulti");
12161 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12162 TOKEN_NUM_INITIALIZER
12163 (struct cmd_vf_allmulti_result,
12165 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12166 TOKEN_NUM_INITIALIZER
12167 (struct cmd_vf_allmulti_result,
12169 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_vf_allmulti_result,
12175 cmd_set_vf_allmulti_parsed(
12176 void *parsed_result,
12177 __attribute__((unused)) struct cmdline *cl,
12178 __attribute__((unused)) void *data)
12180 struct cmd_vf_allmulti_result *res = parsed_result;
12181 int ret = -ENOTSUP;
12183 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12185 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12188 #ifdef RTE_LIBRTE_I40E_PMD
12189 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12190 res->vf_id, is_on);
12197 printf("invalid vf_id %d\n", res->vf_id);
12200 printf("invalid port_id %d\n", res->port_id);
12203 printf("function not implemented\n");
12206 printf("programming error: (%s)\n", strerror(-ret));
12210 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12211 .f = cmd_set_vf_allmulti_parsed,
12213 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12214 "Set multicast promiscuous mode for a VF from the PF",
12216 (void *)&cmd_vf_allmulti_set,
12217 (void *)&cmd_vf_allmulti_vf,
12218 (void *)&cmd_vf_allmulti_allmulti,
12219 (void *)&cmd_vf_allmulti_port_id,
12220 (void *)&cmd_vf_allmulti_vf_id,
12221 (void *)&cmd_vf_allmulti_on_off,
12226 /* vf broadcast mode configuration */
12228 /* Common result structure for vf broadcast */
12229 struct cmd_set_vf_broadcast_result {
12230 cmdline_fixed_string_t set;
12231 cmdline_fixed_string_t vf;
12232 cmdline_fixed_string_t broadcast;
12235 cmdline_fixed_string_t on_off;
12238 /* Common CLI fields for vf broadcast enable disable */
12239 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12240 TOKEN_STRING_INITIALIZER
12241 (struct cmd_set_vf_broadcast_result,
12243 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12244 TOKEN_STRING_INITIALIZER
12245 (struct cmd_set_vf_broadcast_result,
12247 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12248 TOKEN_STRING_INITIALIZER
12249 (struct cmd_set_vf_broadcast_result,
12250 broadcast, "broadcast");
12251 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12252 TOKEN_NUM_INITIALIZER
12253 (struct cmd_set_vf_broadcast_result,
12255 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12256 TOKEN_NUM_INITIALIZER
12257 (struct cmd_set_vf_broadcast_result,
12259 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12260 TOKEN_STRING_INITIALIZER
12261 (struct cmd_set_vf_broadcast_result,
12265 cmd_set_vf_broadcast_parsed(
12266 void *parsed_result,
12267 __attribute__((unused)) struct cmdline *cl,
12268 __attribute__((unused)) void *data)
12270 struct cmd_set_vf_broadcast_result *res = parsed_result;
12271 int ret = -ENOTSUP;
12273 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12275 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12278 #ifdef RTE_LIBRTE_I40E_PMD
12279 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12280 res->vf_id, is_on);
12287 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12290 printf("invalid port_id %d\n", res->port_id);
12293 printf("function not implemented\n");
12296 printf("programming error: (%s)\n", strerror(-ret));
12300 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12301 .f = cmd_set_vf_broadcast_parsed,
12303 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12305 (void *)&cmd_set_vf_broadcast_set,
12306 (void *)&cmd_set_vf_broadcast_vf,
12307 (void *)&cmd_set_vf_broadcast_broadcast,
12308 (void *)&cmd_set_vf_broadcast_port_id,
12309 (void *)&cmd_set_vf_broadcast_vf_id,
12310 (void *)&cmd_set_vf_broadcast_on_off,
12315 /* vf vlan tag configuration */
12317 /* Common result structure for vf vlan tag */
12318 struct cmd_set_vf_vlan_tag_result {
12319 cmdline_fixed_string_t set;
12320 cmdline_fixed_string_t vf;
12321 cmdline_fixed_string_t vlan;
12322 cmdline_fixed_string_t tag;
12325 cmdline_fixed_string_t on_off;
12328 /* Common CLI fields for vf vlan tag enable disable */
12329 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12330 TOKEN_STRING_INITIALIZER
12331 (struct cmd_set_vf_vlan_tag_result,
12333 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12334 TOKEN_STRING_INITIALIZER
12335 (struct cmd_set_vf_vlan_tag_result,
12337 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12338 TOKEN_STRING_INITIALIZER
12339 (struct cmd_set_vf_vlan_tag_result,
12341 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12342 TOKEN_STRING_INITIALIZER
12343 (struct cmd_set_vf_vlan_tag_result,
12345 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12346 TOKEN_NUM_INITIALIZER
12347 (struct cmd_set_vf_vlan_tag_result,
12349 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12350 TOKEN_NUM_INITIALIZER
12351 (struct cmd_set_vf_vlan_tag_result,
12353 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12354 TOKEN_STRING_INITIALIZER
12355 (struct cmd_set_vf_vlan_tag_result,
12359 cmd_set_vf_vlan_tag_parsed(
12360 void *parsed_result,
12361 __attribute__((unused)) struct cmdline *cl,
12362 __attribute__((unused)) void *data)
12364 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12365 int ret = -ENOTSUP;
12367 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12369 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12372 #ifdef RTE_LIBRTE_I40E_PMD
12373 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12374 res->vf_id, is_on);
12381 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12384 printf("invalid port_id %d\n", res->port_id);
12387 printf("function not implemented\n");
12390 printf("programming error: (%s)\n", strerror(-ret));
12394 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12395 .f = cmd_set_vf_vlan_tag_parsed,
12397 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12399 (void *)&cmd_set_vf_vlan_tag_set,
12400 (void *)&cmd_set_vf_vlan_tag_vf,
12401 (void *)&cmd_set_vf_vlan_tag_vlan,
12402 (void *)&cmd_set_vf_vlan_tag_tag,
12403 (void *)&cmd_set_vf_vlan_tag_port_id,
12404 (void *)&cmd_set_vf_vlan_tag_vf_id,
12405 (void *)&cmd_set_vf_vlan_tag_on_off,
12410 /* Common definition of VF and TC TX bandwidth configuration */
12411 struct cmd_vf_tc_bw_result {
12412 cmdline_fixed_string_t set;
12413 cmdline_fixed_string_t vf;
12414 cmdline_fixed_string_t tc;
12415 cmdline_fixed_string_t tx;
12416 cmdline_fixed_string_t min_bw;
12417 cmdline_fixed_string_t max_bw;
12421 cmdline_fixed_string_t bw_list;
12424 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12425 TOKEN_STRING_INITIALIZER
12426 (struct cmd_vf_tc_bw_result,
12428 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12429 TOKEN_STRING_INITIALIZER
12430 (struct cmd_vf_tc_bw_result,
12432 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12433 TOKEN_STRING_INITIALIZER
12434 (struct cmd_vf_tc_bw_result,
12436 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12437 TOKEN_STRING_INITIALIZER
12438 (struct cmd_vf_tc_bw_result,
12440 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12441 TOKEN_STRING_INITIALIZER
12442 (struct cmd_vf_tc_bw_result,
12443 min_bw, "min-bandwidth");
12444 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12445 TOKEN_STRING_INITIALIZER
12446 (struct cmd_vf_tc_bw_result,
12447 max_bw, "max-bandwidth");
12448 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12449 TOKEN_NUM_INITIALIZER
12450 (struct cmd_vf_tc_bw_result,
12452 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12453 TOKEN_NUM_INITIALIZER
12454 (struct cmd_vf_tc_bw_result,
12456 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12457 TOKEN_NUM_INITIALIZER
12458 (struct cmd_vf_tc_bw_result,
12460 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12461 TOKEN_STRING_INITIALIZER
12462 (struct cmd_vf_tc_bw_result,
12465 /* VF max bandwidth setting */
12467 cmd_vf_max_bw_parsed(
12468 void *parsed_result,
12469 __attribute__((unused)) struct cmdline *cl,
12470 __attribute__((unused)) void *data)
12472 struct cmd_vf_tc_bw_result *res = parsed_result;
12473 int ret = -ENOTSUP;
12475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12478 #ifdef RTE_LIBRTE_I40E_PMD
12479 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12480 res->vf_id, res->bw);
12487 printf("invalid vf_id %d or bandwidth %d\n",
12488 res->vf_id, res->bw);
12491 printf("invalid port_id %d\n", res->port_id);
12494 printf("function not implemented\n");
12497 printf("programming error: (%s)\n", strerror(-ret));
12501 cmdline_parse_inst_t cmd_vf_max_bw = {
12502 .f = cmd_vf_max_bw_parsed,
12504 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12506 (void *)&cmd_vf_tc_bw_set,
12507 (void *)&cmd_vf_tc_bw_vf,
12508 (void *)&cmd_vf_tc_bw_tx,
12509 (void *)&cmd_vf_tc_bw_max_bw,
12510 (void *)&cmd_vf_tc_bw_port_id,
12511 (void *)&cmd_vf_tc_bw_vf_id,
12512 (void *)&cmd_vf_tc_bw_bw,
12518 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12523 const char *p, *p0 = str;
12530 p = strchr(p0, '(');
12532 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12536 p0 = strchr(p, ')');
12538 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12542 if (size >= sizeof(s)) {
12543 printf("The string size exceeds the internal buffer size\n");
12546 snprintf(s, sizeof(s), "%.*s", size, p);
12547 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12549 printf("Failed to get the bandwidth list. ");
12553 for (i = 0; i < ret; i++)
12554 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12559 /* TC min bandwidth setting */
12561 cmd_vf_tc_min_bw_parsed(
12562 void *parsed_result,
12563 __attribute__((unused)) struct cmdline *cl,
12564 __attribute__((unused)) void *data)
12566 struct cmd_vf_tc_bw_result *res = parsed_result;
12569 int ret = -ENOTSUP;
12571 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12574 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12578 #ifdef RTE_LIBRTE_I40E_PMD
12579 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12587 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12590 printf("invalid port_id %d\n", res->port_id);
12593 printf("function not implemented\n");
12596 printf("programming error: (%s)\n", strerror(-ret));
12600 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12601 .f = cmd_vf_tc_min_bw_parsed,
12603 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12604 " <bw1, bw2, ...>",
12606 (void *)&cmd_vf_tc_bw_set,
12607 (void *)&cmd_vf_tc_bw_vf,
12608 (void *)&cmd_vf_tc_bw_tc,
12609 (void *)&cmd_vf_tc_bw_tx,
12610 (void *)&cmd_vf_tc_bw_min_bw,
12611 (void *)&cmd_vf_tc_bw_port_id,
12612 (void *)&cmd_vf_tc_bw_vf_id,
12613 (void *)&cmd_vf_tc_bw_bw_list,
12619 /* ******************************************************************************** */
12621 /* list of instructions */
12622 cmdline_parse_ctx_t main_ctx[] = {
12623 (cmdline_parse_inst_t *)&cmd_help_brief,
12624 (cmdline_parse_inst_t *)&cmd_help_long,
12625 (cmdline_parse_inst_t *)&cmd_quit,
12626 (cmdline_parse_inst_t *)&cmd_showport,
12627 (cmdline_parse_inst_t *)&cmd_showqueue,
12628 (cmdline_parse_inst_t *)&cmd_showportall,
12629 (cmdline_parse_inst_t *)&cmd_showcfg,
12630 (cmdline_parse_inst_t *)&cmd_start,
12631 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12632 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12633 (cmdline_parse_inst_t *)&cmd_set_link_up,
12634 (cmdline_parse_inst_t *)&cmd_set_link_down,
12635 (cmdline_parse_inst_t *)&cmd_reset,
12636 (cmdline_parse_inst_t *)&cmd_set_numbers,
12637 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12638 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12639 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12640 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12641 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12642 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12643 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12644 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12645 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12646 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12647 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12648 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12649 (cmdline_parse_inst_t *)&cmd_set_link_check,
12650 #ifdef RTE_NIC_BYPASS
12651 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12652 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12653 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12654 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12656 #ifdef RTE_LIBRTE_PMD_BOND
12657 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12658 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12659 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12660 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12661 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12662 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12663 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12664 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12665 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12667 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12668 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12669 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12670 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12671 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12672 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12673 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12674 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12675 (cmdline_parse_inst_t *)&cmd_csum_set,
12676 (cmdline_parse_inst_t *)&cmd_csum_show,
12677 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12678 (cmdline_parse_inst_t *)&cmd_tso_set,
12679 (cmdline_parse_inst_t *)&cmd_tso_show,
12680 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12681 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12683 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12684 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12685 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12686 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12687 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12688 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12689 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12690 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12691 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12692 (cmdline_parse_inst_t *)&cmd_config_dcb,
12693 (cmdline_parse_inst_t *)&cmd_read_reg,
12694 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12695 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12696 (cmdline_parse_inst_t *)&cmd_write_reg,
12697 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12698 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12699 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12700 (cmdline_parse_inst_t *)&cmd_stop,
12701 (cmdline_parse_inst_t *)&cmd_mac_addr,
12702 (cmdline_parse_inst_t *)&cmd_set_qmap,
12703 (cmdline_parse_inst_t *)&cmd_operate_port,
12704 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12705 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12706 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12707 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12708 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12709 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12710 (cmdline_parse_inst_t *)&cmd_config_mtu,
12711 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12712 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12713 (cmdline_parse_inst_t *)&cmd_config_rss,
12714 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12715 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12716 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12717 (cmdline_parse_inst_t *)&cmd_showport_reta,
12718 (cmdline_parse_inst_t *)&cmd_config_burst,
12719 (cmdline_parse_inst_t *)&cmd_config_thresh,
12720 (cmdline_parse_inst_t *)&cmd_config_threshold,
12721 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12722 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12723 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12724 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12725 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12726 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12727 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12728 (cmdline_parse_inst_t *)&cmd_global_config,
12729 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12730 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12731 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12732 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12733 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12734 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12735 (cmdline_parse_inst_t *)&cmd_dump,
12736 (cmdline_parse_inst_t *)&cmd_dump_one,
12737 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12738 (cmdline_parse_inst_t *)&cmd_syn_filter,
12739 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12740 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12741 (cmdline_parse_inst_t *)&cmd_flex_filter,
12742 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12743 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12744 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12745 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12746 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12747 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12748 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12749 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12750 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12751 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12752 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12753 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12754 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12755 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12756 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12757 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12758 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12759 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12760 (cmdline_parse_inst_t *)&cmd_flow,
12761 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12762 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12763 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12764 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12765 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12766 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12767 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12768 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12769 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12770 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12771 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12772 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12773 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12774 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12775 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12776 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12777 #ifdef RTE_LIBRTE_IXGBE_PMD
12778 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12779 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12780 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12781 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12782 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12783 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12784 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12785 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12786 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12788 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12789 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12790 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12791 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12792 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
12793 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
12794 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
12795 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
12799 /* prompt function, called from main on MASTER lcore */
12803 /* initialize non-constant commands */
12804 cmd_set_fwd_mode_init();
12805 cmd_set_fwd_retry_mode_init();
12807 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12808 if (testpmd_cl == NULL)
12810 cmdline_interact(testpmd_cl);
12811 cmdline_stdin_exit(testpmd_cl);
12817 if (testpmd_cl != NULL)
12818 cmdline_quit(testpmd_cl);
12822 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12824 if (id == (portid_t)RTE_PORT_ALL) {
12827 FOREACH_PORT(pid, ports) {
12828 /* check if need_reconfig has been set to 1 */
12829 if (ports[pid].need_reconfig == 0)
12830 ports[pid].need_reconfig = dev;
12831 /* check if need_reconfig_queues has been set to 1 */
12832 if (ports[pid].need_reconfig_queues == 0)
12833 ports[pid].need_reconfig_queues = queue;
12835 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12836 /* check if need_reconfig has been set to 1 */
12837 if (ports[id].need_reconfig == 0)
12838 ports[id].need_reconfig = dev;
12839 /* check if need_reconfig_queues has been set to 1 */
12840 if (ports[id].need_reconfig_queues == 0)
12841 ports[id].need_reconfig_queues = queue;