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 "vlan set filter (on|off) (port_id)\n"
319 " Set the VLAN filter on a port.\n\n"
321 "vlan set qinq (on|off) (port_id)\n"
322 " Set the VLAN QinQ (extended queue in queue)"
325 "vlan set (inner|outer) tpid (value) (port_id)\n"
326 " Set the VLAN TPID for Packet Filtering on"
329 "rx_vlan add (vlan_id|all) (port_id)\n"
330 " Add a vlan_id, or all identifiers, to the set"
331 " of VLAN identifiers filtered by port_id.\n\n"
333 "rx_vlan rm (vlan_id|all) (port_id)\n"
334 " Remove a vlan_id, or all identifiers, from the set"
335 " of VLAN identifiers filtered by port_id.\n\n"
337 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
338 " Add a vlan_id, to the set of VLAN identifiers"
339 "filtered for VF(s) from port_id.\n\n"
341 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
342 " Remove a vlan_id, to the set of VLAN identifiers"
343 "filtered for VF(s) from port_id.\n\n"
345 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
346 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
347 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
348 " add a tunnel filter of a port.\n\n"
350 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
351 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
352 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
353 " remove a tunnel filter of a port.\n\n"
355 "rx_vxlan_port add (udp_port) (port_id)\n"
356 " Add an UDP port for VXLAN packet filter on a port\n\n"
358 "rx_vxlan_port rm (udp_port) (port_id)\n"
359 " Remove an UDP port for VXLAN packet filter on a port\n\n"
361 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
362 " Set hardware insertion of VLAN IDs (single or double VLAN "
363 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
365 "tx_vlan set pvid port_id vlan_id (on|off)\n"
366 " Set port based TX VLAN insertion.\n\n"
368 "tx_vlan reset (port_id)\n"
369 " Disable hardware insertion of a VLAN header in"
370 " packets sent on a port.\n\n"
372 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
373 " Select hardware or software calculation of the"
374 " checksum when transmitting a packet using the"
375 " csum forward engine.\n"
376 " ip|udp|tcp|sctp always concern the inner layer.\n"
377 " outer-ip concerns the outer IP layer in"
378 " case the packet is recognized as a tunnel packet by"
379 " the forward engine (vxlan, gre and ipip are supported)\n"
380 " Please check the NIC datasheet for HW limits.\n\n"
382 "csum parse-tunnel (on|off) (tx_port_id)\n"
383 " If disabled, treat tunnel packets as non-tunneled"
384 " packets (treat inner headers as payload). The port\n"
385 " argument is the port used for TX in csum forward"
388 "csum show (port_id)\n"
389 " Display tx checksum offload configuration\n\n"
391 "tso set (segsize) (portid)\n"
392 " Enable TCP Segmentation Offload in csum forward"
394 " Please check the NIC datasheet for HW limits.\n\n"
397 " Display the status of TCP Segmentation Offload.\n\n"
400 " Set packet forwarding mode.\n\n"
402 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
403 " Add a MAC address on port_id.\n\n"
405 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
406 " Remove a MAC address from port_id.\n\n"
408 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
409 " Add a MAC address for a VF on the port.\n\n"
411 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
412 " Set the MAC address for a VF from the PF.\n\n"
414 "set port (port_id) uta (mac_address|all) (on|off)\n"
415 " Add/Remove a or all unicast hash filter(s)"
418 "set promisc (port_id|all) (on|off)\n"
419 " Set the promiscuous mode on port_id, or all.\n\n"
421 "set allmulti (port_id|all) (on|off)\n"
422 " Set the allmulti mode on port_id, or all.\n\n"
424 "set vf promisc (port_id) (vf_id) (on|off)\n"
425 " Set unicast promiscuous mode for a VF from the PF.\n\n"
427 "set vf allmulti (port_id) (vf_id) (on|off)\n"
428 " Set multicast promiscuous mode for a VF from the PF.\n\n"
430 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
431 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
432 " (on|off) autoneg (on|off) (port_id)\n"
433 "set flow_ctrl rx (on|off) (portid)\n"
434 "set flow_ctrl tx (on|off) (portid)\n"
435 "set flow_ctrl high_water (high_water) (portid)\n"
436 "set flow_ctrl low_water (low_water) (portid)\n"
437 "set flow_ctrl pause_time (pause_time) (portid)\n"
438 "set flow_ctrl send_xon (send_xon) (portid)\n"
439 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
440 "set flow_ctrl autoneg (on|off) (port_id)\n"
441 " Set the link flow control parameter on a port.\n\n"
443 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
444 " (low_water) (pause_time) (priority) (port_id)\n"
445 " Set the priority flow control parameter on a"
448 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
449 " Set statistics mapping (qmapping 0..15) for RX/TX"
451 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
452 " on port 0 to mapping 5.\n\n"
454 "set port (port_id) vf (vf_id) rx|tx on|off\n"
455 " Enable/Disable a VF receive/tranmit from a port\n\n"
457 "set port (port_id) vf (vf_id) (mac_addr)"
458 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
459 " Add/Remove unicast or multicast MAC addr filter"
462 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
464 " AUPE:accepts untagged VLAN;"
465 "ROPE:accept unicast hash\n\n"
466 " BAM:accepts broadcast packets;"
467 "MPE:accepts all multicast packets\n\n"
468 " Enable/Disable a VF receive mode of a port\n\n"
470 "set port (port_id) queue (queue_id) rate (rate_num)\n"
471 " Set rate limit for a queue of a port\n\n"
473 "set port (port_id) vf (vf_id) rate (rate_num) "
474 "queue_mask (queue_mask_value)\n"
475 " Set rate limit for queues in VF of a port\n\n"
477 "set port (port_id) mirror-rule (rule_id)"
478 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
479 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
480 " Set pool or vlan type mirror rule on a port.\n"
481 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
482 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
485 "set port (port_id) mirror-rule (rule_id)"
486 " (uplink-mirror|downlink-mirror) dst-pool"
487 " (pool_id) (on|off)\n"
488 " Set uplink or downlink type mirror rule on a port.\n"
489 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
490 " 0 on' enable mirror income traffic to pool 0.\n\n"
492 "reset port (port_id) mirror-rule (rule_id)\n"
493 " Reset a mirror rule.\n\n"
495 "set flush_rx (on|off)\n"
496 " Flush (default) or don't flush RX streams before"
497 " forwarding. Mainly used with PCAP drivers.\n\n"
499 #ifdef RTE_NIC_BYPASS
500 "set bypass mode (normal|bypass|isolate) (port_id)\n"
501 " Set the bypass mode for the lowest port on bypass enabled"
504 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
505 "mode (normal|bypass|isolate) (port_id)\n"
506 " Set the event required to initiate specified bypass mode for"
507 " the lowest port on a bypass enabled NIC where:\n"
508 " timeout = enable bypass after watchdog timeout.\n"
509 " os_on = enable bypass when OS/board is powered on.\n"
510 " os_off = enable bypass when OS/board is powered off.\n"
511 " power_on = enable bypass when power supply is turned on.\n"
512 " power_off = enable bypass when power supply is turned off."
515 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
516 " Set the bypass watchdog timeout to 'n' seconds"
517 " where 0 = instant.\n\n"
519 "show bypass config (port_id)\n"
520 " Show the bypass configuration for a bypass enabled NIC"
521 " using the lowest port on the NIC.\n\n"
523 #ifdef RTE_LIBRTE_PMD_BOND
524 "create bonded device (mode) (socket)\n"
525 " Create a new bonded device with specific bonding mode and socket.\n\n"
527 "add bonding slave (slave_id) (port_id)\n"
528 " Add a slave device to a bonded device.\n\n"
530 "remove bonding slave (slave_id) (port_id)\n"
531 " Remove a slave device from a bonded device.\n\n"
533 "set bonding mode (value) (port_id)\n"
534 " Set the bonding mode on a bonded device.\n\n"
536 "set bonding primary (slave_id) (port_id)\n"
537 " Set the primary slave for a bonded device.\n\n"
539 "show bonding config (port_id)\n"
540 " Show the bonding config for port_id.\n\n"
542 "set bonding mac_addr (port_id) (address)\n"
543 " Set the MAC address of a bonded device.\n\n"
545 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
546 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
548 "set bonding mon_period (port_id) (value)\n"
549 " Set the bonding link status monitoring polling period in ms.\n\n"
551 "set link-up port (port_id)\n"
552 " Set link up for a port.\n\n"
554 "set link-down port (port_id)\n"
555 " Set link down for a port.\n\n"
557 "E-tag set insertion on port-tag-id (value)"
558 " port (port_id) vf (vf_id)\n"
559 " Enable E-tag insertion for a VF on a port\n\n"
561 "E-tag set insertion off port (port_id) vf (vf_id)\n"
562 " Disable E-tag insertion for a VF on a port\n\n"
564 "E-tag set stripping (on|off) port (port_id)\n"
565 " Enable/disable E-tag stripping on a port\n\n"
567 "E-tag set forwarding (on|off) port (port_id)\n"
568 " Enable/disable E-tag based forwarding"
571 "E-tag set filter add e-tag-id (value) dst-pool"
572 " (pool_id) port (port_id)\n"
573 " Add an E-tag forwarding filter on a port\n\n"
575 "E-tag set filter del e-tag-id (value) port (port_id)\n"
576 " Delete an E-tag forwarding filter on a port\n\n"
578 , list_pkt_forwarding_modes()
582 if (show_all || !strcmp(res->section, "ports")) {
588 "----------------\n\n"
590 "port start (port_id|all)\n"
591 " Start all ports or port_id.\n\n"
593 "port stop (port_id|all)\n"
594 " Stop all ports or port_id.\n\n"
596 "port close (port_id|all)\n"
597 " Close all ports or port_id.\n\n"
599 "port attach (ident)\n"
600 " Attach physical or virtual dev by pci address or virtual device name\n\n"
602 "port detach (port_id)\n"
603 " Detach physical or virtual dev by port_id\n\n"
605 "port config (port_id|all)"
606 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
607 " duplex (half|full|auto)\n"
608 " Set speed and duplex for all ports or port_id\n\n"
610 "port config all (rxq|txq|rxd|txd) (value)\n"
611 " Set number for rxq/txq/rxd/txd.\n\n"
613 "port config all max-pkt-len (value)\n"
614 " Set the max packet length.\n\n"
616 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
617 "hw-vlan-strip|hw-vlan-extend|drop-en)"
619 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
622 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
623 " Set the RSS mode.\n\n"
625 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
626 " Set the RSS redirection table.\n\n"
628 "port config (port_id) dcb vt (on|off) (traffic_class)"
630 " Set the DCB mode.\n\n"
632 "port config all burst (value)\n"
633 " Set the number of packets per burst.\n\n"
635 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
637 " Set the ring prefetch/host/writeback threshold"
638 " for tx/rx queue.\n\n"
640 "port config all (txfreet|txrst|rxfreet) (value)\n"
641 " Set free threshold for rx/tx, or set"
642 " tx rs bit threshold.\n\n"
643 "port config mtu X value\n"
644 " Set the MTU of port X to a given value\n\n"
646 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
647 " Start/stop a rx/tx queue of port X. Only take effect"
648 " when port X is started\n\n"
650 "port config (port_id|all) l2-tunnel E-tag ether-type"
652 " Set the value of E-tag ether-type.\n\n"
654 "port config (port_id|all) l2-tunnel E-tag"
655 " (enable|disable)\n"
656 " Enable/disable the E-tag support.\n\n"
660 if (show_all || !strcmp(res->section, "registers")) {
668 "read reg (port_id) (address)\n"
669 " Display value of a port register.\n\n"
671 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
672 " Display a port register bit field.\n\n"
674 "read regbit (port_id) (address) (bit_x)\n"
675 " Display a single port register bit.\n\n"
677 "write reg (port_id) (address) (value)\n"
678 " Set value of a port register.\n\n"
680 "write regfield (port_id) (address) (bit_x) (bit_y)"
682 " Set bit field of a port register.\n\n"
684 "write regbit (port_id) (address) (bit_x) (value)\n"
685 " Set single bit value of a port register.\n\n"
688 if (show_all || !strcmp(res->section, "filters")) {
696 "ethertype_filter (port_id) (add|del)"
697 " (mac_addr|mac_ignr) (mac_address) ethertype"
698 " (ether_type) (drop|fwd) queue (queue_id)\n"
699 " Add/Del an ethertype filter.\n\n"
701 "2tuple_filter (port_id) (add|del)"
702 " dst_port (dst_port_value) protocol (protocol_value)"
703 " mask (mask_value) tcp_flags (tcp_flags_value)"
704 " priority (prio_value) queue (queue_id)\n"
705 " Add/Del a 2tuple filter.\n\n"
707 "5tuple_filter (port_id) (add|del)"
708 " dst_ip (dst_address) src_ip (src_address)"
709 " dst_port (dst_port_value) src_port (src_port_value)"
710 " protocol (protocol_value)"
711 " mask (mask_value) tcp_flags (tcp_flags_value)"
712 " priority (prio_value) queue (queue_id)\n"
713 " Add/Del a 5tuple filter.\n\n"
715 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
716 " Add/Del syn filter.\n\n"
718 "flex_filter (port_id) (add|del) len (len_value)"
719 " bytes (bytes_value) mask (mask_value)"
720 " priority (prio_value) queue (queue_id)\n"
721 " Add/Del a flex filter.\n\n"
723 "flow_director_filter (port_id) mode IP (add|del|update)"
724 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
725 " src (src_ip_address) dst (dst_ip_address)"
726 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
727 " vlan (vlan_value) flexbytes (flexbytes_value)"
728 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
729 " fd_id (fd_id_value)\n"
730 " Add/Del an IP type flow director filter.\n\n"
732 "flow_director_filter (port_id) mode IP (add|del|update)"
733 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
734 " src (src_ip_address) (src_port)"
735 " dst (dst_ip_address) (dst_port)"
736 " tos (tos_value) ttl (ttl_value)"
737 " vlan (vlan_value) flexbytes (flexbytes_value)"
738 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
739 " fd_id (fd_id_value)\n"
740 " Add/Del an UDP/TCP type flow director filter.\n\n"
742 "flow_director_filter (port_id) mode IP (add|del|update)"
743 " flow (ipv4-sctp|ipv6-sctp)"
744 " src (src_ip_address) (src_port)"
745 " dst (dst_ip_address) (dst_port)"
746 " tag (verification_tag) "
747 " tos (tos_value) ttl (ttl_value)"
749 " flexbytes (flexbytes_value) (drop|fwd)"
750 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
751 " Add/Del a SCTP type flow director filter.\n\n"
753 "flow_director_filter (port_id) mode IP (add|del|update)"
754 " flow l2_payload ether (ethertype)"
755 " flexbytes (flexbytes_value) (drop|fwd)"
756 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
757 " Add/Del a l2 payload type flow director filter.\n\n"
759 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
760 " mac (mac_address) vlan (vlan_value)"
761 " flexbytes (flexbytes_value) (drop|fwd)"
762 " queue (queue_id) fd_id (fd_id_value)\n"
763 " Add/Del a MAC-VLAN flow director filter.\n\n"
765 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
766 " mac (mac_address) vlan (vlan_value)"
767 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
768 " flexbytes (flexbytes_value) (drop|fwd)"
769 " queue (queue_id) fd_id (fd_id_value)\n"
770 " Add/Del a Tunnel flow director filter.\n\n"
772 "flush_flow_director (port_id)\n"
773 " Flush all flow director entries of a device.\n\n"
775 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
776 " src_mask (ipv4_src) (ipv6_src) (src_port)"
777 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
778 " Set flow director IP mask.\n\n"
780 "flow_director_mask (port_id) mode MAC-VLAN"
781 " vlan (vlan_value)\n"
782 " Set flow director MAC-VLAN mask.\n\n"
784 "flow_director_mask (port_id) mode Tunnel"
785 " vlan (vlan_value) mac (mac_value)"
786 " tunnel-type (tunnel_type_value)"
787 " tunnel-id (tunnel_id_value)\n"
788 " Set flow director Tunnel mask.\n\n"
790 "flow_director_flex_mask (port_id)"
791 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
792 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
794 " Configure mask of flex payload.\n\n"
796 "flow_director_flex_payload (port_id)"
797 " (raw|l2|l3|l4) (config)\n"
798 " Configure flex payload selection.\n\n"
800 "get_sym_hash_ena_per_port (port_id)\n"
801 " get symmetric hash enable configuration per port.\n\n"
803 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
804 " set symmetric hash enable configuration per port"
805 " to enable or disable.\n\n"
807 "get_hash_global_config (port_id)\n"
808 " Get the global configurations of hash filters.\n\n"
810 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
811 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
812 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
813 " (enable|disable)\n"
814 " Set the global configurations of hash filters.\n\n"
816 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
817 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
818 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
819 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
820 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
821 "ipv6-next-header|udp-src-port|udp-dst-port|"
822 "tcp-src-port|tcp-dst-port|sctp-src-port|"
823 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
824 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
825 "fld-8th|none) (select|add)\n"
826 " Set the input set for hash.\n\n"
828 "set_fdir_input_set (port_id) "
829 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
830 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
831 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
832 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
833 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
834 "udp-dst-port|tcp-src-port|tcp-dst-port|"
835 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
837 " Set the input set for FDir.\n\n"
839 "flow validate {port_id}"
840 " [group {group_id}] [priority {level}]"
841 " [ingress] [egress]"
842 " pattern {item} [/ {item} [...]] / end"
843 " actions {action} [/ {action} [...]] / end\n"
844 " Check whether a flow rule can be created.\n\n"
846 "flow create {port_id}"
847 " [group {group_id}] [priority {level}]"
848 " [ingress] [egress]"
849 " pattern {item} [/ {item} [...]] / end"
850 " actions {action} [/ {action} [...]] / end\n"
851 " Create a flow rule.\n\n"
853 "flow destroy {port_id} rule {rule_id} [...]\n"
854 " Destroy specific flow rules.\n\n"
856 "flow flush {port_id}\n"
857 " Destroy all flow rules.\n\n"
859 "flow query {port_id} {rule_id} {action}\n"
860 " Query an existing flow rule.\n\n"
862 "flow list {port_id} [group {group_id}] [...]\n"
863 " List existing flow rules sorted by priority,"
864 " filtered by group identifiers.\n\n"
869 cmdline_parse_token_string_t cmd_help_long_help =
870 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
872 cmdline_parse_token_string_t cmd_help_long_section =
873 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
874 "all#control#display#config#"
875 "ports#registers#filters");
877 cmdline_parse_inst_t cmd_help_long = {
878 .f = cmd_help_long_parsed,
880 .help_str = "help all|control|display|config|ports|register|filters: "
883 (void *)&cmd_help_long_help,
884 (void *)&cmd_help_long_section,
890 /* *** start/stop/close all ports *** */
891 struct cmd_operate_port_result {
892 cmdline_fixed_string_t keyword;
893 cmdline_fixed_string_t name;
894 cmdline_fixed_string_t value;
897 static void cmd_operate_port_parsed(void *parsed_result,
898 __attribute__((unused)) struct cmdline *cl,
899 __attribute__((unused)) void *data)
901 struct cmd_operate_port_result *res = parsed_result;
903 if (!strcmp(res->name, "start"))
904 start_port(RTE_PORT_ALL);
905 else if (!strcmp(res->name, "stop"))
906 stop_port(RTE_PORT_ALL);
907 else if (!strcmp(res->name, "close"))
908 close_port(RTE_PORT_ALL);
910 printf("Unknown parameter\n");
913 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
914 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
916 cmdline_parse_token_string_t cmd_operate_port_all_port =
917 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
919 cmdline_parse_token_string_t cmd_operate_port_all_all =
920 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
922 cmdline_parse_inst_t cmd_operate_port = {
923 .f = cmd_operate_port_parsed,
925 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
927 (void *)&cmd_operate_port_all_cmd,
928 (void *)&cmd_operate_port_all_port,
929 (void *)&cmd_operate_port_all_all,
934 /* *** start/stop/close specific port *** */
935 struct cmd_operate_specific_port_result {
936 cmdline_fixed_string_t keyword;
937 cmdline_fixed_string_t name;
941 static void cmd_operate_specific_port_parsed(void *parsed_result,
942 __attribute__((unused)) struct cmdline *cl,
943 __attribute__((unused)) void *data)
945 struct cmd_operate_specific_port_result *res = parsed_result;
947 if (!strcmp(res->name, "start"))
948 start_port(res->value);
949 else if (!strcmp(res->name, "stop"))
950 stop_port(res->value);
951 else if (!strcmp(res->name, "close"))
952 close_port(res->value);
954 printf("Unknown parameter\n");
957 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
958 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
960 cmdline_parse_token_string_t cmd_operate_specific_port_port =
961 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
962 name, "start#stop#close");
963 cmdline_parse_token_num_t cmd_operate_specific_port_id =
964 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
967 cmdline_parse_inst_t cmd_operate_specific_port = {
968 .f = cmd_operate_specific_port_parsed,
970 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
972 (void *)&cmd_operate_specific_port_cmd,
973 (void *)&cmd_operate_specific_port_port,
974 (void *)&cmd_operate_specific_port_id,
979 /* *** attach a specified port *** */
980 struct cmd_operate_attach_port_result {
981 cmdline_fixed_string_t port;
982 cmdline_fixed_string_t keyword;
983 cmdline_fixed_string_t identifier;
986 static void cmd_operate_attach_port_parsed(void *parsed_result,
987 __attribute__((unused)) struct cmdline *cl,
988 __attribute__((unused)) void *data)
990 struct cmd_operate_attach_port_result *res = parsed_result;
992 if (!strcmp(res->keyword, "attach"))
993 attach_port(res->identifier);
995 printf("Unknown parameter\n");
998 cmdline_parse_token_string_t cmd_operate_attach_port_port =
999 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1001 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1002 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1004 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1005 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1008 cmdline_parse_inst_t cmd_operate_attach_port = {
1009 .f = cmd_operate_attach_port_parsed,
1011 .help_str = "port attach <identifier>: "
1012 "(identifier: pci address or virtual dev name)",
1014 (void *)&cmd_operate_attach_port_port,
1015 (void *)&cmd_operate_attach_port_keyword,
1016 (void *)&cmd_operate_attach_port_identifier,
1021 /* *** detach a specified port *** */
1022 struct cmd_operate_detach_port_result {
1023 cmdline_fixed_string_t port;
1024 cmdline_fixed_string_t keyword;
1028 static void cmd_operate_detach_port_parsed(void *parsed_result,
1029 __attribute__((unused)) struct cmdline *cl,
1030 __attribute__((unused)) void *data)
1032 struct cmd_operate_detach_port_result *res = parsed_result;
1034 if (!strcmp(res->keyword, "detach"))
1035 detach_port(res->port_id);
1037 printf("Unknown parameter\n");
1040 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1041 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1043 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1044 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1046 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1047 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1050 cmdline_parse_inst_t cmd_operate_detach_port = {
1051 .f = cmd_operate_detach_port_parsed,
1053 .help_str = "port detach <port_id>",
1055 (void *)&cmd_operate_detach_port_port,
1056 (void *)&cmd_operate_detach_port_keyword,
1057 (void *)&cmd_operate_detach_port_port_id,
1062 /* *** configure speed for all ports *** */
1063 struct cmd_config_speed_all {
1064 cmdline_fixed_string_t port;
1065 cmdline_fixed_string_t keyword;
1066 cmdline_fixed_string_t all;
1067 cmdline_fixed_string_t item1;
1068 cmdline_fixed_string_t item2;
1069 cmdline_fixed_string_t value1;
1070 cmdline_fixed_string_t value2;
1074 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1079 if (!strcmp(duplexstr, "half")) {
1080 duplex = ETH_LINK_HALF_DUPLEX;
1081 } else if (!strcmp(duplexstr, "full")) {
1082 duplex = ETH_LINK_FULL_DUPLEX;
1083 } else if (!strcmp(duplexstr, "auto")) {
1084 duplex = ETH_LINK_FULL_DUPLEX;
1086 printf("Unknown duplex parameter\n");
1090 if (!strcmp(speedstr, "10")) {
1091 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1092 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1093 } else if (!strcmp(speedstr, "100")) {
1094 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1095 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1097 if (duplex != ETH_LINK_FULL_DUPLEX) {
1098 printf("Invalid speed/duplex parameters\n");
1101 if (!strcmp(speedstr, "1000")) {
1102 *speed = ETH_LINK_SPEED_1G;
1103 } else if (!strcmp(speedstr, "10000")) {
1104 *speed = ETH_LINK_SPEED_10G;
1105 } else if (!strcmp(speedstr, "25000")) {
1106 *speed = ETH_LINK_SPEED_25G;
1107 } else if (!strcmp(speedstr, "40000")) {
1108 *speed = ETH_LINK_SPEED_40G;
1109 } else if (!strcmp(speedstr, "50000")) {
1110 *speed = ETH_LINK_SPEED_50G;
1111 } else if (!strcmp(speedstr, "100000")) {
1112 *speed = ETH_LINK_SPEED_100G;
1113 } else if (!strcmp(speedstr, "auto")) {
1114 *speed = ETH_LINK_SPEED_AUTONEG;
1116 printf("Unknown speed parameter\n");
1125 cmd_config_speed_all_parsed(void *parsed_result,
1126 __attribute__((unused)) struct cmdline *cl,
1127 __attribute__((unused)) void *data)
1129 struct cmd_config_speed_all *res = parsed_result;
1130 uint32_t link_speed;
1133 if (!all_ports_stopped()) {
1134 printf("Please stop all ports first\n");
1138 if (parse_and_check_speed_duplex(res->value1, res->value2,
1142 FOREACH_PORT(pid, ports) {
1143 ports[pid].dev_conf.link_speeds = link_speed;
1146 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1149 cmdline_parse_token_string_t cmd_config_speed_all_port =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1151 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1152 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1154 cmdline_parse_token_string_t cmd_config_speed_all_all =
1155 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1156 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1157 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1158 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1159 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1160 "10#100#1000#10000#25000#40000#50000#100000#auto");
1161 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1162 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1163 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1164 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1167 cmdline_parse_inst_t cmd_config_speed_all = {
1168 .f = cmd_config_speed_all_parsed,
1170 .help_str = "port config all speed "
1171 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1174 (void *)&cmd_config_speed_all_port,
1175 (void *)&cmd_config_speed_all_keyword,
1176 (void *)&cmd_config_speed_all_all,
1177 (void *)&cmd_config_speed_all_item1,
1178 (void *)&cmd_config_speed_all_value1,
1179 (void *)&cmd_config_speed_all_item2,
1180 (void *)&cmd_config_speed_all_value2,
1185 /* *** configure speed for specific port *** */
1186 struct cmd_config_speed_specific {
1187 cmdline_fixed_string_t port;
1188 cmdline_fixed_string_t keyword;
1190 cmdline_fixed_string_t item1;
1191 cmdline_fixed_string_t item2;
1192 cmdline_fixed_string_t value1;
1193 cmdline_fixed_string_t value2;
1197 cmd_config_speed_specific_parsed(void *parsed_result,
1198 __attribute__((unused)) struct cmdline *cl,
1199 __attribute__((unused)) void *data)
1201 struct cmd_config_speed_specific *res = parsed_result;
1202 uint32_t link_speed;
1204 if (!all_ports_stopped()) {
1205 printf("Please stop all ports first\n");
1209 if (port_id_is_invalid(res->id, ENABLED_WARN))
1212 if (parse_and_check_speed_duplex(res->value1, res->value2,
1216 ports[res->id].dev_conf.link_speeds = link_speed;
1218 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1222 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1223 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1225 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1226 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1228 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1229 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1230 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1231 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1233 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1235 "10#100#1000#10000#25000#40000#50000#100000#auto");
1236 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1237 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1239 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1240 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1243 cmdline_parse_inst_t cmd_config_speed_specific = {
1244 .f = cmd_config_speed_specific_parsed,
1246 .help_str = "port config <port_id> speed "
1247 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1250 (void *)&cmd_config_speed_specific_port,
1251 (void *)&cmd_config_speed_specific_keyword,
1252 (void *)&cmd_config_speed_specific_id,
1253 (void *)&cmd_config_speed_specific_item1,
1254 (void *)&cmd_config_speed_specific_value1,
1255 (void *)&cmd_config_speed_specific_item2,
1256 (void *)&cmd_config_speed_specific_value2,
1261 /* *** configure txq/rxq, txd/rxd *** */
1262 struct cmd_config_rx_tx {
1263 cmdline_fixed_string_t port;
1264 cmdline_fixed_string_t keyword;
1265 cmdline_fixed_string_t all;
1266 cmdline_fixed_string_t name;
1271 cmd_config_rx_tx_parsed(void *parsed_result,
1272 __attribute__((unused)) struct cmdline *cl,
1273 __attribute__((unused)) void *data)
1275 struct cmd_config_rx_tx *res = parsed_result;
1277 if (!all_ports_stopped()) {
1278 printf("Please stop all ports first\n");
1281 if (!strcmp(res->name, "rxq")) {
1282 if (!res->value && !nb_txq) {
1283 printf("Warning: Either rx or tx queues should be non zero\n");
1286 nb_rxq = res->value;
1288 else if (!strcmp(res->name, "txq")) {
1289 if (!res->value && !nb_rxq) {
1290 printf("Warning: Either rx or tx queues should be non zero\n");
1293 nb_txq = res->value;
1295 else if (!strcmp(res->name, "rxd")) {
1296 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1297 printf("rxd %d invalid - must be > 0 && <= %d\n",
1298 res->value, RTE_TEST_RX_DESC_MAX);
1301 nb_rxd = res->value;
1302 } else if (!strcmp(res->name, "txd")) {
1303 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1304 printf("txd %d invalid - must be > 0 && <= %d\n",
1305 res->value, RTE_TEST_TX_DESC_MAX);
1308 nb_txd = res->value;
1310 printf("Unknown parameter\n");
1318 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1321 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1323 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1324 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1325 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1326 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1327 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1328 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1330 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1331 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1333 cmdline_parse_inst_t cmd_config_rx_tx = {
1334 .f = cmd_config_rx_tx_parsed,
1336 .help_str = "port config all rxq|txq|rxd|txd <value>",
1338 (void *)&cmd_config_rx_tx_port,
1339 (void *)&cmd_config_rx_tx_keyword,
1340 (void *)&cmd_config_rx_tx_all,
1341 (void *)&cmd_config_rx_tx_name,
1342 (void *)&cmd_config_rx_tx_value,
1347 /* *** config max packet length *** */
1348 struct cmd_config_max_pkt_len_result {
1349 cmdline_fixed_string_t port;
1350 cmdline_fixed_string_t keyword;
1351 cmdline_fixed_string_t all;
1352 cmdline_fixed_string_t name;
1357 cmd_config_max_pkt_len_parsed(void *parsed_result,
1358 __attribute__((unused)) struct cmdline *cl,
1359 __attribute__((unused)) void *data)
1361 struct cmd_config_max_pkt_len_result *res = parsed_result;
1363 if (!all_ports_stopped()) {
1364 printf("Please stop all ports first\n");
1368 if (!strcmp(res->name, "max-pkt-len")) {
1369 if (res->value < ETHER_MIN_LEN) {
1370 printf("max-pkt-len can not be less than %d\n",
1374 if (res->value == rx_mode.max_rx_pkt_len)
1377 rx_mode.max_rx_pkt_len = res->value;
1378 if (res->value > ETHER_MAX_LEN)
1379 rx_mode.jumbo_frame = 1;
1381 rx_mode.jumbo_frame = 0;
1383 printf("Unknown parameter\n");
1389 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1392 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1395 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1398 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1401 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1404 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1405 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1408 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1409 .f = cmd_config_max_pkt_len_parsed,
1411 .help_str = "port config all max-pkt-len <value>",
1413 (void *)&cmd_config_max_pkt_len_port,
1414 (void *)&cmd_config_max_pkt_len_keyword,
1415 (void *)&cmd_config_max_pkt_len_all,
1416 (void *)&cmd_config_max_pkt_len_name,
1417 (void *)&cmd_config_max_pkt_len_value,
1422 /* *** configure port MTU *** */
1423 struct cmd_config_mtu_result {
1424 cmdline_fixed_string_t port;
1425 cmdline_fixed_string_t keyword;
1426 cmdline_fixed_string_t mtu;
1432 cmd_config_mtu_parsed(void *parsed_result,
1433 __attribute__((unused)) struct cmdline *cl,
1434 __attribute__((unused)) void *data)
1436 struct cmd_config_mtu_result *res = parsed_result;
1438 if (res->value < ETHER_MIN_LEN) {
1439 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1442 port_mtu_set(res->port_id, res->value);
1445 cmdline_parse_token_string_t cmd_config_mtu_port =
1446 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1448 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1449 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1451 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1452 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1454 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1455 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1456 cmdline_parse_token_num_t cmd_config_mtu_value =
1457 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1459 cmdline_parse_inst_t cmd_config_mtu = {
1460 .f = cmd_config_mtu_parsed,
1462 .help_str = "port config mtu <port_id> <value>",
1464 (void *)&cmd_config_mtu_port,
1465 (void *)&cmd_config_mtu_keyword,
1466 (void *)&cmd_config_mtu_mtu,
1467 (void *)&cmd_config_mtu_port_id,
1468 (void *)&cmd_config_mtu_value,
1473 /* *** configure rx mode *** */
1474 struct cmd_config_rx_mode_flag {
1475 cmdline_fixed_string_t port;
1476 cmdline_fixed_string_t keyword;
1477 cmdline_fixed_string_t all;
1478 cmdline_fixed_string_t name;
1479 cmdline_fixed_string_t value;
1483 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1484 __attribute__((unused)) struct cmdline *cl,
1485 __attribute__((unused)) void *data)
1487 struct cmd_config_rx_mode_flag *res = parsed_result;
1489 if (!all_ports_stopped()) {
1490 printf("Please stop all ports first\n");
1494 if (!strcmp(res->name, "crc-strip")) {
1495 if (!strcmp(res->value, "on"))
1496 rx_mode.hw_strip_crc = 1;
1497 else if (!strcmp(res->value, "off"))
1498 rx_mode.hw_strip_crc = 0;
1500 printf("Unknown parameter\n");
1503 } else if (!strcmp(res->name, "scatter")) {
1504 if (!strcmp(res->value, "on"))
1505 rx_mode.enable_scatter = 1;
1506 else if (!strcmp(res->value, "off"))
1507 rx_mode.enable_scatter = 0;
1509 printf("Unknown parameter\n");
1512 } else if (!strcmp(res->name, "rx-cksum")) {
1513 if (!strcmp(res->value, "on"))
1514 rx_mode.hw_ip_checksum = 1;
1515 else if (!strcmp(res->value, "off"))
1516 rx_mode.hw_ip_checksum = 0;
1518 printf("Unknown parameter\n");
1521 } else if (!strcmp(res->name, "hw-vlan")) {
1522 if (!strcmp(res->value, "on")) {
1523 rx_mode.hw_vlan_filter = 1;
1524 rx_mode.hw_vlan_strip = 1;
1526 else if (!strcmp(res->value, "off")) {
1527 rx_mode.hw_vlan_filter = 0;
1528 rx_mode.hw_vlan_strip = 0;
1531 printf("Unknown parameter\n");
1534 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1535 if (!strcmp(res->value, "on"))
1536 rx_mode.hw_vlan_filter = 1;
1537 else if (!strcmp(res->value, "off"))
1538 rx_mode.hw_vlan_filter = 0;
1540 printf("Unknown parameter\n");
1543 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1544 if (!strcmp(res->value, "on"))
1545 rx_mode.hw_vlan_strip = 1;
1546 else if (!strcmp(res->value, "off"))
1547 rx_mode.hw_vlan_strip = 0;
1549 printf("Unknown parameter\n");
1552 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1553 if (!strcmp(res->value, "on"))
1554 rx_mode.hw_vlan_extend = 1;
1555 else if (!strcmp(res->value, "off"))
1556 rx_mode.hw_vlan_extend = 0;
1558 printf("Unknown parameter\n");
1561 } else if (!strcmp(res->name, "drop-en")) {
1562 if (!strcmp(res->value, "on"))
1564 else if (!strcmp(res->value, "off"))
1567 printf("Unknown parameter\n");
1571 printf("Unknown parameter\n");
1577 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1580 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1582 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1585 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1587 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1588 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1589 "crc-strip#scatter#rx-cksum#hw-vlan#"
1590 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1591 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1592 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1595 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1596 .f = cmd_config_rx_mode_flag_parsed,
1598 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1599 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1601 (void *)&cmd_config_rx_mode_flag_port,
1602 (void *)&cmd_config_rx_mode_flag_keyword,
1603 (void *)&cmd_config_rx_mode_flag_all,
1604 (void *)&cmd_config_rx_mode_flag_name,
1605 (void *)&cmd_config_rx_mode_flag_value,
1610 /* *** configure rss *** */
1611 struct cmd_config_rss {
1612 cmdline_fixed_string_t port;
1613 cmdline_fixed_string_t keyword;
1614 cmdline_fixed_string_t all;
1615 cmdline_fixed_string_t name;
1616 cmdline_fixed_string_t value;
1620 cmd_config_rss_parsed(void *parsed_result,
1621 __attribute__((unused)) struct cmdline *cl,
1622 __attribute__((unused)) void *data)
1624 struct cmd_config_rss *res = parsed_result;
1625 struct rte_eth_rss_conf rss_conf;
1629 if (!strcmp(res->value, "all"))
1630 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1631 ETH_RSS_UDP | ETH_RSS_SCTP |
1633 else if (!strcmp(res->value, "ip"))
1634 rss_conf.rss_hf = ETH_RSS_IP;
1635 else if (!strcmp(res->value, "udp"))
1636 rss_conf.rss_hf = ETH_RSS_UDP;
1637 else if (!strcmp(res->value, "tcp"))
1638 rss_conf.rss_hf = ETH_RSS_TCP;
1639 else if (!strcmp(res->value, "sctp"))
1640 rss_conf.rss_hf = ETH_RSS_SCTP;
1641 else if (!strcmp(res->value, "ether"))
1642 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1643 else if (!strcmp(res->value, "port"))
1644 rss_conf.rss_hf = ETH_RSS_PORT;
1645 else if (!strcmp(res->value, "vxlan"))
1646 rss_conf.rss_hf = ETH_RSS_VXLAN;
1647 else if (!strcmp(res->value, "geneve"))
1648 rss_conf.rss_hf = ETH_RSS_GENEVE;
1649 else if (!strcmp(res->value, "nvgre"))
1650 rss_conf.rss_hf = ETH_RSS_NVGRE;
1651 else if (!strcmp(res->value, "none"))
1652 rss_conf.rss_hf = 0;
1654 printf("Unknown parameter\n");
1657 rss_conf.rss_key = NULL;
1658 for (i = 0; i < rte_eth_dev_count(); i++) {
1659 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1661 printf("Configuration of RSS hash at ethernet port %d "
1662 "failed with error (%d): %s.\n",
1663 i, -diag, strerror(-diag));
1667 cmdline_parse_token_string_t cmd_config_rss_port =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1669 cmdline_parse_token_string_t cmd_config_rss_keyword =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1671 cmdline_parse_token_string_t cmd_config_rss_all =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1673 cmdline_parse_token_string_t cmd_config_rss_name =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1675 cmdline_parse_token_string_t cmd_config_rss_value =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1677 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1679 cmdline_parse_inst_t cmd_config_rss = {
1680 .f = cmd_config_rss_parsed,
1682 .help_str = "port config all rss "
1683 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1685 (void *)&cmd_config_rss_port,
1686 (void *)&cmd_config_rss_keyword,
1687 (void *)&cmd_config_rss_all,
1688 (void *)&cmd_config_rss_name,
1689 (void *)&cmd_config_rss_value,
1694 /* *** configure rss hash key *** */
1695 struct cmd_config_rss_hash_key {
1696 cmdline_fixed_string_t port;
1697 cmdline_fixed_string_t config;
1699 cmdline_fixed_string_t rss_hash_key;
1700 cmdline_fixed_string_t rss_type;
1701 cmdline_fixed_string_t key;
1705 hexa_digit_to_value(char hexa_digit)
1707 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1708 return (uint8_t) (hexa_digit - '0');
1709 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1710 return (uint8_t) ((hexa_digit - 'a') + 10);
1711 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1712 return (uint8_t) ((hexa_digit - 'A') + 10);
1713 /* Invalid hexa digit */
1718 parse_and_check_key_hexa_digit(char *key, int idx)
1722 hexa_v = hexa_digit_to_value(key[idx]);
1724 printf("invalid key: character %c at position %d is not a "
1725 "valid hexa digit\n", key[idx], idx);
1730 cmd_config_rss_hash_key_parsed(void *parsed_result,
1731 __attribute__((unused)) struct cmdline *cl,
1732 __attribute__((unused)) void *data)
1734 struct cmd_config_rss_hash_key *res = parsed_result;
1735 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1739 struct rte_eth_dev_info dev_info;
1740 uint8_t hash_key_size;
1743 memset(&dev_info, 0, sizeof(dev_info));
1744 rte_eth_dev_info_get(res->port_id, &dev_info);
1745 if (dev_info.hash_key_size > 0 &&
1746 dev_info.hash_key_size <= sizeof(hash_key))
1747 hash_key_size = dev_info.hash_key_size;
1749 printf("dev_info did not provide a valid hash key size\n");
1752 /* Check the length of the RSS hash key */
1753 key_len = strlen(res->key);
1754 if (key_len != (hash_key_size * 2)) {
1755 printf("key length: %d invalid - key must be a string of %d"
1756 " hexa-decimal numbers\n",
1757 (int) key_len, hash_key_size * 2);
1760 /* Translate RSS hash key into binary representation */
1761 for (i = 0; i < hash_key_size; i++) {
1762 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1765 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1768 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1770 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1774 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1775 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1776 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1777 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1779 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1780 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1781 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1783 rss_hash_key, "rss-hash-key");
1784 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1786 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1787 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1788 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1789 "ipv6-tcp-ex#ipv6-udp-ex");
1790 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1793 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1794 .f = cmd_config_rss_hash_key_parsed,
1796 .help_str = "port config <port_id> rss-hash-key "
1797 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1798 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1799 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1800 "<string of hex digits (variable length, NIC dependent)>",
1802 (void *)&cmd_config_rss_hash_key_port,
1803 (void *)&cmd_config_rss_hash_key_config,
1804 (void *)&cmd_config_rss_hash_key_port_id,
1805 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1806 (void *)&cmd_config_rss_hash_key_rss_type,
1807 (void *)&cmd_config_rss_hash_key_value,
1812 /* *** configure port rxq/txq start/stop *** */
1813 struct cmd_config_rxtx_queue {
1814 cmdline_fixed_string_t port;
1816 cmdline_fixed_string_t rxtxq;
1818 cmdline_fixed_string_t opname;
1822 cmd_config_rxtx_queue_parsed(void *parsed_result,
1823 __attribute__((unused)) struct cmdline *cl,
1824 __attribute__((unused)) void *data)
1826 struct cmd_config_rxtx_queue *res = parsed_result;
1831 if (test_done == 0) {
1832 printf("Please stop forwarding first\n");
1836 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1839 if (port_is_started(res->portid) != 1) {
1840 printf("Please start port %u first\n", res->portid);
1844 if (!strcmp(res->rxtxq, "rxq"))
1846 else if (!strcmp(res->rxtxq, "txq"))
1849 printf("Unknown parameter\n");
1853 if (isrx && rx_queue_id_is_invalid(res->qid))
1855 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1858 if (!strcmp(res->opname, "start"))
1860 else if (!strcmp(res->opname, "stop"))
1863 printf("Unknown parameter\n");
1867 if (isstart && isrx)
1868 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1869 else if (!isstart && isrx)
1870 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1871 else if (isstart && !isrx)
1872 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1874 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1876 if (ret == -ENOTSUP)
1877 printf("Function not supported in PMD driver\n");
1880 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1881 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1882 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1883 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1884 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1885 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1886 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1887 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1888 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1889 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1892 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1893 .f = cmd_config_rxtx_queue_parsed,
1895 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1897 (void *)&cmd_config_speed_all_port,
1898 (void *)&cmd_config_rxtx_queue_portid,
1899 (void *)&cmd_config_rxtx_queue_rxtxq,
1900 (void *)&cmd_config_rxtx_queue_qid,
1901 (void *)&cmd_config_rxtx_queue_opname,
1906 /* *** Configure RSS RETA *** */
1907 struct cmd_config_rss_reta {
1908 cmdline_fixed_string_t port;
1909 cmdline_fixed_string_t keyword;
1911 cmdline_fixed_string_t name;
1912 cmdline_fixed_string_t list_name;
1913 cmdline_fixed_string_t list_of_items;
1917 parse_reta_config(const char *str,
1918 struct rte_eth_rss_reta_entry64 *reta_conf,
1919 uint16_t nb_entries)
1923 uint16_t hash_index, idx, shift;
1926 const char *p, *p0 = str;
1933 unsigned long int_fld[_NUM_FLD];
1934 char *str_fld[_NUM_FLD];
1936 while ((p = strchr(p0,'(')) != NULL) {
1938 if((p0 = strchr(p,')')) == NULL)
1942 if(size >= sizeof(s))
1945 snprintf(s, sizeof(s), "%.*s", size, p);
1946 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1948 for (i = 0; i < _NUM_FLD; i++) {
1950 int_fld[i] = strtoul(str_fld[i], &end, 0);
1951 if (errno != 0 || end == str_fld[i] ||
1956 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1957 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1959 if (hash_index >= nb_entries) {
1960 printf("Invalid RETA hash index=%d\n", hash_index);
1964 idx = hash_index / RTE_RETA_GROUP_SIZE;
1965 shift = hash_index % RTE_RETA_GROUP_SIZE;
1966 reta_conf[idx].mask |= (1ULL << shift);
1967 reta_conf[idx].reta[shift] = nb_queue;
1974 cmd_set_rss_reta_parsed(void *parsed_result,
1975 __attribute__((unused)) struct cmdline *cl,
1976 __attribute__((unused)) void *data)
1979 struct rte_eth_dev_info dev_info;
1980 struct rte_eth_rss_reta_entry64 reta_conf[8];
1981 struct cmd_config_rss_reta *res = parsed_result;
1983 memset(&dev_info, 0, sizeof(dev_info));
1984 rte_eth_dev_info_get(res->port_id, &dev_info);
1985 if (dev_info.reta_size == 0) {
1986 printf("Redirection table size is 0 which is "
1987 "invalid for RSS\n");
1990 printf("The reta size of port %d is %u\n",
1991 res->port_id, dev_info.reta_size);
1992 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1993 printf("Currently do not support more than %u entries of "
1994 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1998 memset(reta_conf, 0, sizeof(reta_conf));
1999 if (!strcmp(res->list_name, "reta")) {
2000 if (parse_reta_config(res->list_of_items, reta_conf,
2001 dev_info.reta_size)) {
2002 printf("Invalid RSS Redirection Table "
2003 "config entered\n");
2006 ret = rte_eth_dev_rss_reta_update(res->port_id,
2007 reta_conf, dev_info.reta_size);
2009 printf("Bad redirection table parameter, "
2010 "return code = %d \n", ret);
2014 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2015 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2016 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2018 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2019 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2020 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2021 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2022 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2024 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2025 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2027 cmdline_parse_inst_t cmd_config_rss_reta = {
2028 .f = cmd_set_rss_reta_parsed,
2030 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2032 (void *)&cmd_config_rss_reta_port,
2033 (void *)&cmd_config_rss_reta_keyword,
2034 (void *)&cmd_config_rss_reta_port_id,
2035 (void *)&cmd_config_rss_reta_name,
2036 (void *)&cmd_config_rss_reta_list_name,
2037 (void *)&cmd_config_rss_reta_list_of_items,
2042 /* *** SHOW PORT RETA INFO *** */
2043 struct cmd_showport_reta {
2044 cmdline_fixed_string_t show;
2045 cmdline_fixed_string_t port;
2047 cmdline_fixed_string_t rss;
2048 cmdline_fixed_string_t reta;
2050 cmdline_fixed_string_t list_of_items;
2054 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2055 uint16_t nb_entries,
2059 const char *p, *p0 = str;
2063 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2066 p = strchr(p0, '(');
2070 p0 = strchr(p, ')');
2074 if (size >= sizeof(s)) {
2075 printf("The string size exceeds the internal buffer size\n");
2078 snprintf(s, sizeof(s), "%.*s", size, p);
2079 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2080 if (ret <= 0 || ret != num) {
2081 printf("The bits of masks do not match the number of "
2082 "reta entries: %u\n", num);
2085 for (i = 0; i < ret; i++)
2086 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2092 cmd_showport_reta_parsed(void *parsed_result,
2093 __attribute__((unused)) struct cmdline *cl,
2094 __attribute__((unused)) void *data)
2096 struct cmd_showport_reta *res = parsed_result;
2097 struct rte_eth_rss_reta_entry64 reta_conf[8];
2098 struct rte_eth_dev_info dev_info;
2100 memset(&dev_info, 0, sizeof(dev_info));
2101 rte_eth_dev_info_get(res->port_id, &dev_info);
2102 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2103 res->size > ETH_RSS_RETA_SIZE_512) {
2104 printf("Invalid redirection table size: %u\n", res->size);
2108 memset(reta_conf, 0, sizeof(reta_conf));
2109 if (showport_parse_reta_config(reta_conf, res->size,
2110 res->list_of_items) < 0) {
2111 printf("Invalid string: %s for reta masks\n",
2112 res->list_of_items);
2115 port_rss_reta_info(res->port_id, reta_conf, res->size);
2118 cmdline_parse_token_string_t cmd_showport_reta_show =
2119 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2120 cmdline_parse_token_string_t cmd_showport_reta_port =
2121 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2122 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2123 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2124 cmdline_parse_token_string_t cmd_showport_reta_rss =
2125 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2126 cmdline_parse_token_string_t cmd_showport_reta_reta =
2127 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2128 cmdline_parse_token_num_t cmd_showport_reta_size =
2129 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2130 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2131 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2132 list_of_items, NULL);
2134 cmdline_parse_inst_t cmd_showport_reta = {
2135 .f = cmd_showport_reta_parsed,
2137 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2139 (void *)&cmd_showport_reta_show,
2140 (void *)&cmd_showport_reta_port,
2141 (void *)&cmd_showport_reta_port_id,
2142 (void *)&cmd_showport_reta_rss,
2143 (void *)&cmd_showport_reta_reta,
2144 (void *)&cmd_showport_reta_size,
2145 (void *)&cmd_showport_reta_list_of_items,
2150 /* *** Show RSS hash configuration *** */
2151 struct cmd_showport_rss_hash {
2152 cmdline_fixed_string_t show;
2153 cmdline_fixed_string_t port;
2155 cmdline_fixed_string_t rss_hash;
2156 cmdline_fixed_string_t rss_type;
2157 cmdline_fixed_string_t key; /* optional argument */
2160 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2161 __attribute__((unused)) struct cmdline *cl,
2164 struct cmd_showport_rss_hash *res = parsed_result;
2166 port_rss_hash_conf_show(res->port_id, res->rss_type,
2167 show_rss_key != NULL);
2170 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2171 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2172 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2173 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2174 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2175 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2176 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2177 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2179 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2180 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2181 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2182 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2183 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2184 "ipv6-tcp-ex#ipv6-udp-ex");
2185 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2186 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2188 cmdline_parse_inst_t cmd_showport_rss_hash = {
2189 .f = cmd_showport_rss_hash_parsed,
2191 .help_str = "show port <port_id> rss-hash "
2192 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2193 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2194 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2196 (void *)&cmd_showport_rss_hash_show,
2197 (void *)&cmd_showport_rss_hash_port,
2198 (void *)&cmd_showport_rss_hash_port_id,
2199 (void *)&cmd_showport_rss_hash_rss_hash,
2200 (void *)&cmd_showport_rss_hash_rss_hash_info,
2205 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2206 .f = cmd_showport_rss_hash_parsed,
2208 .help_str = "show port <port_id> rss-hash "
2209 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2210 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2211 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2213 (void *)&cmd_showport_rss_hash_show,
2214 (void *)&cmd_showport_rss_hash_port,
2215 (void *)&cmd_showport_rss_hash_port_id,
2216 (void *)&cmd_showport_rss_hash_rss_hash,
2217 (void *)&cmd_showport_rss_hash_rss_hash_info,
2218 (void *)&cmd_showport_rss_hash_rss_key,
2223 /* *** Configure DCB *** */
2224 struct cmd_config_dcb {
2225 cmdline_fixed_string_t port;
2226 cmdline_fixed_string_t config;
2228 cmdline_fixed_string_t dcb;
2229 cmdline_fixed_string_t vt;
2230 cmdline_fixed_string_t vt_en;
2232 cmdline_fixed_string_t pfc;
2233 cmdline_fixed_string_t pfc_en;
2237 cmd_config_dcb_parsed(void *parsed_result,
2238 __attribute__((unused)) struct cmdline *cl,
2239 __attribute__((unused)) void *data)
2241 struct cmd_config_dcb *res = parsed_result;
2242 portid_t port_id = res->port_id;
2243 struct rte_port *port;
2247 port = &ports[port_id];
2248 /** Check if the port is not started **/
2249 if (port->port_status != RTE_PORT_STOPPED) {
2250 printf("Please stop port %d first\n", port_id);
2254 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2255 printf("The invalid number of traffic class,"
2256 " only 4 or 8 allowed.\n");
2260 if (nb_fwd_lcores < res->num_tcs) {
2261 printf("nb_cores shouldn't be less than number of TCs.\n");
2264 if (!strncmp(res->pfc_en, "on", 2))
2269 /* DCB in VT mode */
2270 if (!strncmp(res->vt_en, "on", 2))
2271 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2272 (enum rte_eth_nb_tcs)res->num_tcs,
2275 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2276 (enum rte_eth_nb_tcs)res->num_tcs,
2281 printf("Cannot initialize network ports.\n");
2285 cmd_reconfig_device_queue(port_id, 1, 1);
2288 cmdline_parse_token_string_t cmd_config_dcb_port =
2289 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2290 cmdline_parse_token_string_t cmd_config_dcb_config =
2291 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2292 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2293 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2294 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2295 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2296 cmdline_parse_token_string_t cmd_config_dcb_vt =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2298 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2300 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2301 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2302 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2304 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2307 cmdline_parse_inst_t cmd_config_dcb = {
2308 .f = cmd_config_dcb_parsed,
2310 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2312 (void *)&cmd_config_dcb_port,
2313 (void *)&cmd_config_dcb_config,
2314 (void *)&cmd_config_dcb_port_id,
2315 (void *)&cmd_config_dcb_dcb,
2316 (void *)&cmd_config_dcb_vt,
2317 (void *)&cmd_config_dcb_vt_en,
2318 (void *)&cmd_config_dcb_num_tcs,
2319 (void *)&cmd_config_dcb_pfc,
2320 (void *)&cmd_config_dcb_pfc_en,
2325 /* *** configure number of packets per burst *** */
2326 struct cmd_config_burst {
2327 cmdline_fixed_string_t port;
2328 cmdline_fixed_string_t keyword;
2329 cmdline_fixed_string_t all;
2330 cmdline_fixed_string_t name;
2335 cmd_config_burst_parsed(void *parsed_result,
2336 __attribute__((unused)) struct cmdline *cl,
2337 __attribute__((unused)) void *data)
2339 struct cmd_config_burst *res = parsed_result;
2341 if (!all_ports_stopped()) {
2342 printf("Please stop all ports first\n");
2346 if (!strcmp(res->name, "burst")) {
2347 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2348 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2351 nb_pkt_per_burst = res->value;
2353 printf("Unknown parameter\n");
2359 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2362 cmdline_parse_token_string_t cmd_config_burst_port =
2363 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2364 cmdline_parse_token_string_t cmd_config_burst_keyword =
2365 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2366 cmdline_parse_token_string_t cmd_config_burst_all =
2367 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2368 cmdline_parse_token_string_t cmd_config_burst_name =
2369 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2370 cmdline_parse_token_num_t cmd_config_burst_value =
2371 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2373 cmdline_parse_inst_t cmd_config_burst = {
2374 .f = cmd_config_burst_parsed,
2376 .help_str = "port config all burst <value>",
2378 (void *)&cmd_config_burst_port,
2379 (void *)&cmd_config_burst_keyword,
2380 (void *)&cmd_config_burst_all,
2381 (void *)&cmd_config_burst_name,
2382 (void *)&cmd_config_burst_value,
2387 /* *** configure rx/tx queues *** */
2388 struct cmd_config_thresh {
2389 cmdline_fixed_string_t port;
2390 cmdline_fixed_string_t keyword;
2391 cmdline_fixed_string_t all;
2392 cmdline_fixed_string_t name;
2397 cmd_config_thresh_parsed(void *parsed_result,
2398 __attribute__((unused)) struct cmdline *cl,
2399 __attribute__((unused)) void *data)
2401 struct cmd_config_thresh *res = parsed_result;
2403 if (!all_ports_stopped()) {
2404 printf("Please stop all ports first\n");
2408 if (!strcmp(res->name, "txpt"))
2409 tx_pthresh = res->value;
2410 else if(!strcmp(res->name, "txht"))
2411 tx_hthresh = res->value;
2412 else if(!strcmp(res->name, "txwt"))
2413 tx_wthresh = res->value;
2414 else if(!strcmp(res->name, "rxpt"))
2415 rx_pthresh = res->value;
2416 else if(!strcmp(res->name, "rxht"))
2417 rx_hthresh = res->value;
2418 else if(!strcmp(res->name, "rxwt"))
2419 rx_wthresh = res->value;
2421 printf("Unknown parameter\n");
2427 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2430 cmdline_parse_token_string_t cmd_config_thresh_port =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2432 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2433 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2434 cmdline_parse_token_string_t cmd_config_thresh_all =
2435 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2436 cmdline_parse_token_string_t cmd_config_thresh_name =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2438 "txpt#txht#txwt#rxpt#rxht#rxwt");
2439 cmdline_parse_token_num_t cmd_config_thresh_value =
2440 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2442 cmdline_parse_inst_t cmd_config_thresh = {
2443 .f = cmd_config_thresh_parsed,
2445 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2447 (void *)&cmd_config_thresh_port,
2448 (void *)&cmd_config_thresh_keyword,
2449 (void *)&cmd_config_thresh_all,
2450 (void *)&cmd_config_thresh_name,
2451 (void *)&cmd_config_thresh_value,
2456 /* *** configure free/rs threshold *** */
2457 struct cmd_config_threshold {
2458 cmdline_fixed_string_t port;
2459 cmdline_fixed_string_t keyword;
2460 cmdline_fixed_string_t all;
2461 cmdline_fixed_string_t name;
2466 cmd_config_threshold_parsed(void *parsed_result,
2467 __attribute__((unused)) struct cmdline *cl,
2468 __attribute__((unused)) void *data)
2470 struct cmd_config_threshold *res = parsed_result;
2472 if (!all_ports_stopped()) {
2473 printf("Please stop all ports first\n");
2477 if (!strcmp(res->name, "txfreet"))
2478 tx_free_thresh = res->value;
2479 else if (!strcmp(res->name, "txrst"))
2480 tx_rs_thresh = res->value;
2481 else if (!strcmp(res->name, "rxfreet"))
2482 rx_free_thresh = res->value;
2484 printf("Unknown parameter\n");
2490 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2493 cmdline_parse_token_string_t cmd_config_threshold_port =
2494 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2495 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2496 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2498 cmdline_parse_token_string_t cmd_config_threshold_all =
2499 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2500 cmdline_parse_token_string_t cmd_config_threshold_name =
2501 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2502 "txfreet#txrst#rxfreet");
2503 cmdline_parse_token_num_t cmd_config_threshold_value =
2504 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2506 cmdline_parse_inst_t cmd_config_threshold = {
2507 .f = cmd_config_threshold_parsed,
2509 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2511 (void *)&cmd_config_threshold_port,
2512 (void *)&cmd_config_threshold_keyword,
2513 (void *)&cmd_config_threshold_all,
2514 (void *)&cmd_config_threshold_name,
2515 (void *)&cmd_config_threshold_value,
2521 struct cmd_stop_result {
2522 cmdline_fixed_string_t stop;
2525 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2526 __attribute__((unused)) struct cmdline *cl,
2527 __attribute__((unused)) void *data)
2529 stop_packet_forwarding();
2532 cmdline_parse_token_string_t cmd_stop_stop =
2533 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2535 cmdline_parse_inst_t cmd_stop = {
2536 .f = cmd_stop_parsed,
2538 .help_str = "stop: Stop packet forwarding",
2540 (void *)&cmd_stop_stop,
2545 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2548 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2549 unsigned int *parsed_items, int check_unique_values)
2551 unsigned int nb_item;
2559 * First parse all items in the list and store their value.
2564 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2566 if ((c >= '0') && (c <= '9')) {
2567 value = (unsigned int) (value * 10 + (c - '0'));
2572 printf("character %c is not a decimal digit\n", c);
2576 printf("No valid value before comma\n");
2579 if (nb_item < max_items) {
2580 parsed_items[nb_item] = value;
2586 if (nb_item >= max_items) {
2587 printf("Number of %s = %u > %u (maximum items)\n",
2588 item_name, nb_item + 1, max_items);
2591 parsed_items[nb_item++] = value;
2592 if (! check_unique_values)
2596 * Then, check that all values in the list are differents.
2597 * No optimization here...
2599 for (i = 0; i < nb_item; i++) {
2600 for (j = i + 1; j < nb_item; j++) {
2601 if (parsed_items[j] == parsed_items[i]) {
2602 printf("duplicated %s %u at index %u and %u\n",
2603 item_name, parsed_items[i], i, j);
2611 struct cmd_set_list_result {
2612 cmdline_fixed_string_t cmd_keyword;
2613 cmdline_fixed_string_t list_name;
2614 cmdline_fixed_string_t list_of_items;
2617 static void cmd_set_list_parsed(void *parsed_result,
2618 __attribute__((unused)) struct cmdline *cl,
2619 __attribute__((unused)) void *data)
2621 struct cmd_set_list_result *res;
2623 unsigned int lcorelist[RTE_MAX_LCORE];
2624 unsigned int portlist[RTE_MAX_ETHPORTS];
2626 unsigned int nb_item;
2628 if (test_done == 0) {
2629 printf("Please stop forwarding first\n");
2633 res = parsed_result;
2634 if (!strcmp(res->list_name, "corelist")) {
2635 nb_item = parse_item_list(res->list_of_items, "core",
2637 parsed_items.lcorelist, 1);
2639 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2644 if (!strcmp(res->list_name, "portlist")) {
2645 nb_item = parse_item_list(res->list_of_items, "port",
2647 parsed_items.portlist, 1);
2649 set_fwd_ports_list(parsed_items.portlist, nb_item);
2655 cmdline_parse_token_string_t cmd_set_list_keyword =
2656 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2658 cmdline_parse_token_string_t cmd_set_list_name =
2659 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2660 "corelist#portlist");
2661 cmdline_parse_token_string_t cmd_set_list_of_items =
2662 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2665 cmdline_parse_inst_t cmd_set_fwd_list = {
2666 .f = cmd_set_list_parsed,
2668 .help_str = "set corelist|portlist <list0[,list1]*>",
2670 (void *)&cmd_set_list_keyword,
2671 (void *)&cmd_set_list_name,
2672 (void *)&cmd_set_list_of_items,
2677 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2679 struct cmd_setmask_result {
2680 cmdline_fixed_string_t set;
2681 cmdline_fixed_string_t mask;
2685 static void cmd_set_mask_parsed(void *parsed_result,
2686 __attribute__((unused)) struct cmdline *cl,
2687 __attribute__((unused)) void *data)
2689 struct cmd_setmask_result *res = parsed_result;
2691 if (test_done == 0) {
2692 printf("Please stop forwarding first\n");
2695 if (!strcmp(res->mask, "coremask")) {
2696 set_fwd_lcores_mask(res->hexavalue);
2698 } else if (!strcmp(res->mask, "portmask")) {
2699 set_fwd_ports_mask(res->hexavalue);
2704 cmdline_parse_token_string_t cmd_setmask_set =
2705 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2706 cmdline_parse_token_string_t cmd_setmask_mask =
2707 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2708 "coremask#portmask");
2709 cmdline_parse_token_num_t cmd_setmask_value =
2710 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2712 cmdline_parse_inst_t cmd_set_fwd_mask = {
2713 .f = cmd_set_mask_parsed,
2715 .help_str = "set coremask|portmask <hexadecimal value>",
2717 (void *)&cmd_setmask_set,
2718 (void *)&cmd_setmask_mask,
2719 (void *)&cmd_setmask_value,
2725 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2727 struct cmd_set_result {
2728 cmdline_fixed_string_t set;
2729 cmdline_fixed_string_t what;
2733 static void cmd_set_parsed(void *parsed_result,
2734 __attribute__((unused)) struct cmdline *cl,
2735 __attribute__((unused)) void *data)
2737 struct cmd_set_result *res = parsed_result;
2738 if (!strcmp(res->what, "nbport")) {
2739 set_fwd_ports_number(res->value);
2741 } else if (!strcmp(res->what, "nbcore")) {
2742 set_fwd_lcores_number(res->value);
2744 } else if (!strcmp(res->what, "burst"))
2745 set_nb_pkt_per_burst(res->value);
2746 else if (!strcmp(res->what, "verbose"))
2747 set_verbose_level(res->value);
2750 cmdline_parse_token_string_t cmd_set_set =
2751 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2752 cmdline_parse_token_string_t cmd_set_what =
2753 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2754 "nbport#nbcore#burst#verbose");
2755 cmdline_parse_token_num_t cmd_set_value =
2756 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2758 cmdline_parse_inst_t cmd_set_numbers = {
2759 .f = cmd_set_parsed,
2761 .help_str = "set nbport|nbcore|burst|verbose <value>",
2763 (void *)&cmd_set_set,
2764 (void *)&cmd_set_what,
2765 (void *)&cmd_set_value,
2770 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2772 struct cmd_set_txpkts_result {
2773 cmdline_fixed_string_t cmd_keyword;
2774 cmdline_fixed_string_t txpkts;
2775 cmdline_fixed_string_t seg_lengths;
2779 cmd_set_txpkts_parsed(void *parsed_result,
2780 __attribute__((unused)) struct cmdline *cl,
2781 __attribute__((unused)) void *data)
2783 struct cmd_set_txpkts_result *res;
2784 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2785 unsigned int nb_segs;
2787 res = parsed_result;
2788 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2789 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2791 set_tx_pkt_segments(seg_lengths, nb_segs);
2794 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2795 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2796 cmd_keyword, "set");
2797 cmdline_parse_token_string_t cmd_set_txpkts_name =
2798 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2800 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2801 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2804 cmdline_parse_inst_t cmd_set_txpkts = {
2805 .f = cmd_set_txpkts_parsed,
2807 .help_str = "set txpkts <len0[,len1]*>",
2809 (void *)&cmd_set_txpkts_keyword,
2810 (void *)&cmd_set_txpkts_name,
2811 (void *)&cmd_set_txpkts_lengths,
2816 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2818 struct cmd_set_txsplit_result {
2819 cmdline_fixed_string_t cmd_keyword;
2820 cmdline_fixed_string_t txsplit;
2821 cmdline_fixed_string_t mode;
2825 cmd_set_txsplit_parsed(void *parsed_result,
2826 __attribute__((unused)) struct cmdline *cl,
2827 __attribute__((unused)) void *data)
2829 struct cmd_set_txsplit_result *res;
2831 res = parsed_result;
2832 set_tx_pkt_split(res->mode);
2835 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2836 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2837 cmd_keyword, "set");
2838 cmdline_parse_token_string_t cmd_set_txsplit_name =
2839 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2840 txsplit, "txsplit");
2841 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2842 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2845 cmdline_parse_inst_t cmd_set_txsplit = {
2846 .f = cmd_set_txsplit_parsed,
2848 .help_str = "set txsplit on|off|rand",
2850 (void *)&cmd_set_txsplit_keyword,
2851 (void *)&cmd_set_txsplit_name,
2852 (void *)&cmd_set_txsplit_mode,
2857 /* *** CONFIG TX QUEUE FLAGS *** */
2859 struct cmd_config_txqflags_result {
2860 cmdline_fixed_string_t port;
2861 cmdline_fixed_string_t config;
2862 cmdline_fixed_string_t all;
2863 cmdline_fixed_string_t what;
2867 static void cmd_config_txqflags_parsed(void *parsed_result,
2868 __attribute__((unused)) struct cmdline *cl,
2869 __attribute__((unused)) void *data)
2871 struct cmd_config_txqflags_result *res = parsed_result;
2873 if (!all_ports_stopped()) {
2874 printf("Please stop all ports first\n");
2878 if (strcmp(res->what, "txqflags")) {
2879 printf("Unknown parameter\n");
2883 if (res->hexvalue >= 0) {
2884 txq_flags = res->hexvalue;
2886 printf("txqflags must be >= 0\n");
2892 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2895 cmdline_parse_token_string_t cmd_config_txqflags_port =
2896 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2898 cmdline_parse_token_string_t cmd_config_txqflags_config =
2899 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2901 cmdline_parse_token_string_t cmd_config_txqflags_all =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2904 cmdline_parse_token_string_t cmd_config_txqflags_what =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2907 cmdline_parse_token_num_t cmd_config_txqflags_value =
2908 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2911 cmdline_parse_inst_t cmd_config_txqflags = {
2912 .f = cmd_config_txqflags_parsed,
2914 .help_str = "port config all txqflags <value>",
2916 (void *)&cmd_config_txqflags_port,
2917 (void *)&cmd_config_txqflags_config,
2918 (void *)&cmd_config_txqflags_all,
2919 (void *)&cmd_config_txqflags_what,
2920 (void *)&cmd_config_txqflags_value,
2925 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2926 struct cmd_rx_vlan_filter_all_result {
2927 cmdline_fixed_string_t rx_vlan;
2928 cmdline_fixed_string_t what;
2929 cmdline_fixed_string_t all;
2934 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2935 __attribute__((unused)) struct cmdline *cl,
2936 __attribute__((unused)) void *data)
2938 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2940 if (!strcmp(res->what, "add"))
2941 rx_vlan_all_filter_set(res->port_id, 1);
2943 rx_vlan_all_filter_set(res->port_id, 0);
2946 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2947 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2948 rx_vlan, "rx_vlan");
2949 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2950 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2952 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2953 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2955 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2956 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2959 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2960 .f = cmd_rx_vlan_filter_all_parsed,
2962 .help_str = "rx_vlan add|rm all <port_id>: "
2963 "Add/Remove all identifiers to/from the set of VLAN "
2964 "identifiers filtered by a port",
2966 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2967 (void *)&cmd_rx_vlan_filter_all_what,
2968 (void *)&cmd_rx_vlan_filter_all_all,
2969 (void *)&cmd_rx_vlan_filter_all_portid,
2974 /* *** VLAN OFFLOAD SET ON A PORT *** */
2975 struct cmd_vlan_offload_result {
2976 cmdline_fixed_string_t vlan;
2977 cmdline_fixed_string_t set;
2978 cmdline_fixed_string_t vlan_type;
2979 cmdline_fixed_string_t what;
2980 cmdline_fixed_string_t on;
2981 cmdline_fixed_string_t port_id;
2985 cmd_vlan_offload_parsed(void *parsed_result,
2986 __attribute__((unused)) struct cmdline *cl,
2987 __attribute__((unused)) void *data)
2990 struct cmd_vlan_offload_result *res = parsed_result;
2993 portid_t port_id = 0;
2997 len = strnlen(str, STR_TOKEN_SIZE);
2999 /* Get port_id first */
3007 tmp = strtoul(str, NULL, 0);
3008 /* If port_id greater that what portid_t can represent, return */
3009 if(tmp >= RTE_MAX_ETHPORTS)
3011 port_id = (portid_t)tmp;
3013 if (!strcmp(res->on, "on"))
3018 if (!strcmp(res->what, "strip"))
3019 rx_vlan_strip_set(port_id, on);
3020 else if(!strcmp(res->what, "stripq")){
3021 uint16_t queue_id = 0;
3023 /* No queue_id, return */
3025 printf("must specify (port,queue_id)\n");
3028 tmp = strtoul(str + i + 1, NULL, 0);
3029 /* If queue_id greater that what 16-bits can represent, return */
3033 queue_id = (uint16_t)tmp;
3034 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3036 else if (!strcmp(res->what, "filter"))
3037 rx_vlan_filter_set(port_id, on);
3039 vlan_extend_set(port_id, on);
3044 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3045 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3047 cmdline_parse_token_string_t cmd_vlan_offload_set =
3048 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3050 cmdline_parse_token_string_t cmd_vlan_offload_what =
3051 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3052 what, "strip#filter#qinq#stripq");
3053 cmdline_parse_token_string_t cmd_vlan_offload_on =
3054 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3056 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3057 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3060 cmdline_parse_inst_t cmd_vlan_offload = {
3061 .f = cmd_vlan_offload_parsed,
3063 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3064 "<port_id[,queue_id]>: "
3065 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3067 (void *)&cmd_vlan_offload_vlan,
3068 (void *)&cmd_vlan_offload_set,
3069 (void *)&cmd_vlan_offload_what,
3070 (void *)&cmd_vlan_offload_on,
3071 (void *)&cmd_vlan_offload_portid,
3076 /* *** VLAN TPID SET ON A PORT *** */
3077 struct cmd_vlan_tpid_result {
3078 cmdline_fixed_string_t vlan;
3079 cmdline_fixed_string_t set;
3080 cmdline_fixed_string_t vlan_type;
3081 cmdline_fixed_string_t what;
3087 cmd_vlan_tpid_parsed(void *parsed_result,
3088 __attribute__((unused)) struct cmdline *cl,
3089 __attribute__((unused)) void *data)
3091 struct cmd_vlan_tpid_result *res = parsed_result;
3092 enum rte_vlan_type vlan_type;
3094 if (!strcmp(res->vlan_type, "inner"))
3095 vlan_type = ETH_VLAN_TYPE_INNER;
3096 else if (!strcmp(res->vlan_type, "outer"))
3097 vlan_type = ETH_VLAN_TYPE_OUTER;
3099 printf("Unknown vlan type\n");
3102 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3105 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3106 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3108 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3109 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3111 cmdline_parse_token_string_t cmd_vlan_type =
3112 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3113 vlan_type, "inner#outer");
3114 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3117 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3118 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3120 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3121 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3124 cmdline_parse_inst_t cmd_vlan_tpid = {
3125 .f = cmd_vlan_tpid_parsed,
3127 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3128 "Set the VLAN Ether type",
3130 (void *)&cmd_vlan_tpid_vlan,
3131 (void *)&cmd_vlan_tpid_set,
3132 (void *)&cmd_vlan_type,
3133 (void *)&cmd_vlan_tpid_what,
3134 (void *)&cmd_vlan_tpid_tpid,
3135 (void *)&cmd_vlan_tpid_portid,
3140 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3141 struct cmd_rx_vlan_filter_result {
3142 cmdline_fixed_string_t rx_vlan;
3143 cmdline_fixed_string_t what;
3149 cmd_rx_vlan_filter_parsed(void *parsed_result,
3150 __attribute__((unused)) struct cmdline *cl,
3151 __attribute__((unused)) void *data)
3153 struct cmd_rx_vlan_filter_result *res = parsed_result;
3155 if (!strcmp(res->what, "add"))
3156 rx_vft_set(res->port_id, res->vlan_id, 1);
3158 rx_vft_set(res->port_id, res->vlan_id, 0);
3161 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3162 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3163 rx_vlan, "rx_vlan");
3164 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3165 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3167 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3168 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3170 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3171 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3174 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3175 .f = cmd_rx_vlan_filter_parsed,
3177 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3178 "Add/Remove a VLAN identifier to/from the set of VLAN "
3179 "identifiers filtered by a port",
3181 (void *)&cmd_rx_vlan_filter_rx_vlan,
3182 (void *)&cmd_rx_vlan_filter_what,
3183 (void *)&cmd_rx_vlan_filter_vlanid,
3184 (void *)&cmd_rx_vlan_filter_portid,
3189 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3190 struct cmd_tx_vlan_set_result {
3191 cmdline_fixed_string_t tx_vlan;
3192 cmdline_fixed_string_t set;
3198 cmd_tx_vlan_set_parsed(void *parsed_result,
3199 __attribute__((unused)) struct cmdline *cl,
3200 __attribute__((unused)) void *data)
3202 struct cmd_tx_vlan_set_result *res = parsed_result;
3204 tx_vlan_set(res->port_id, res->vlan_id);
3207 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3208 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3209 tx_vlan, "tx_vlan");
3210 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3211 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3213 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3214 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3216 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3217 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3220 cmdline_parse_inst_t cmd_tx_vlan_set = {
3221 .f = cmd_tx_vlan_set_parsed,
3223 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3224 "Enable hardware insertion of a single VLAN header "
3225 "with a given TAG Identifier in packets sent on a port",
3227 (void *)&cmd_tx_vlan_set_tx_vlan,
3228 (void *)&cmd_tx_vlan_set_set,
3229 (void *)&cmd_tx_vlan_set_portid,
3230 (void *)&cmd_tx_vlan_set_vlanid,
3235 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3236 struct cmd_tx_vlan_set_qinq_result {
3237 cmdline_fixed_string_t tx_vlan;
3238 cmdline_fixed_string_t set;
3241 uint16_t vlan_id_outer;
3245 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3246 __attribute__((unused)) struct cmdline *cl,
3247 __attribute__((unused)) void *data)
3249 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3251 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3254 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3255 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3256 tx_vlan, "tx_vlan");
3257 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3258 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3260 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3261 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3263 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3264 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3266 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3267 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3268 vlan_id_outer, UINT16);
3270 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3271 .f = cmd_tx_vlan_set_qinq_parsed,
3273 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3274 "Enable hardware insertion of double VLAN header "
3275 "with given TAG Identifiers in packets sent on a port",
3277 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3278 (void *)&cmd_tx_vlan_set_qinq_set,
3279 (void *)&cmd_tx_vlan_set_qinq_portid,
3280 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3281 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3286 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3287 struct cmd_tx_vlan_set_pvid_result {
3288 cmdline_fixed_string_t tx_vlan;
3289 cmdline_fixed_string_t set;
3290 cmdline_fixed_string_t pvid;
3293 cmdline_fixed_string_t mode;
3297 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3298 __attribute__((unused)) struct cmdline *cl,
3299 __attribute__((unused)) void *data)
3301 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3303 if (strcmp(res->mode, "on") == 0)
3304 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3306 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3309 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3310 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3311 tx_vlan, "tx_vlan");
3312 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3313 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3315 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3316 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3318 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3319 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3321 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3322 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3324 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3325 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3328 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3329 .f = cmd_tx_vlan_set_pvid_parsed,
3331 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3333 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3334 (void *)&cmd_tx_vlan_set_pvid_set,
3335 (void *)&cmd_tx_vlan_set_pvid_pvid,
3336 (void *)&cmd_tx_vlan_set_pvid_port_id,
3337 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3338 (void *)&cmd_tx_vlan_set_pvid_mode,
3343 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3344 struct cmd_tx_vlan_reset_result {
3345 cmdline_fixed_string_t tx_vlan;
3346 cmdline_fixed_string_t reset;
3351 cmd_tx_vlan_reset_parsed(void *parsed_result,
3352 __attribute__((unused)) struct cmdline *cl,
3353 __attribute__((unused)) void *data)
3355 struct cmd_tx_vlan_reset_result *res = parsed_result;
3357 tx_vlan_reset(res->port_id);
3360 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3361 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3362 tx_vlan, "tx_vlan");
3363 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3364 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3366 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3367 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3370 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3371 .f = cmd_tx_vlan_reset_parsed,
3373 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3374 "VLAN header in packets sent on a port",
3376 (void *)&cmd_tx_vlan_reset_tx_vlan,
3377 (void *)&cmd_tx_vlan_reset_reset,
3378 (void *)&cmd_tx_vlan_reset_portid,
3384 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3385 struct cmd_csum_result {
3386 cmdline_fixed_string_t csum;
3387 cmdline_fixed_string_t mode;
3388 cmdline_fixed_string_t proto;
3389 cmdline_fixed_string_t hwsw;
3394 csum_show(int port_id)
3396 struct rte_eth_dev_info dev_info;
3399 ol_flags = ports[port_id].tx_ol_flags;
3400 printf("Parse tunnel is %s\n",
3401 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3402 printf("IP checksum offload is %s\n",
3403 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3404 printf("UDP checksum offload is %s\n",
3405 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3406 printf("TCP checksum offload is %s\n",
3407 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3408 printf("SCTP checksum offload is %s\n",
3409 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3410 printf("Outer-Ip checksum offload is %s\n",
3411 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3413 /* display warnings if configuration is not supported by the NIC */
3414 rte_eth_dev_info_get(port_id, &dev_info);
3415 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3416 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3417 printf("Warning: hardware IP checksum enabled but not "
3418 "supported by port %d\n", port_id);
3420 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3421 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3422 printf("Warning: hardware UDP checksum enabled but not "
3423 "supported by port %d\n", port_id);
3425 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3426 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3427 printf("Warning: hardware TCP checksum enabled but not "
3428 "supported by port %d\n", port_id);
3430 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3431 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3432 printf("Warning: hardware SCTP checksum enabled but not "
3433 "supported by port %d\n", port_id);
3435 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3436 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3437 printf("Warning: hardware outer IP checksum enabled but not "
3438 "supported by port %d\n", port_id);
3443 cmd_csum_parsed(void *parsed_result,
3444 __attribute__((unused)) struct cmdline *cl,
3445 __attribute__((unused)) void *data)
3447 struct cmd_csum_result *res = parsed_result;
3451 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3452 printf("invalid port %d\n", res->port_id);
3456 if (!strcmp(res->mode, "set")) {
3458 if (!strcmp(res->hwsw, "hw"))
3461 if (!strcmp(res->proto, "ip")) {
3462 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3463 } else if (!strcmp(res->proto, "udp")) {
3464 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3465 } else if (!strcmp(res->proto, "tcp")) {
3466 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3467 } else if (!strcmp(res->proto, "sctp")) {
3468 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3469 } else if (!strcmp(res->proto, "outer-ip")) {
3470 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3474 ports[res->port_id].tx_ol_flags |= mask;
3476 ports[res->port_id].tx_ol_flags &= (~mask);
3478 csum_show(res->port_id);
3481 cmdline_parse_token_string_t cmd_csum_csum =
3482 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3484 cmdline_parse_token_string_t cmd_csum_mode =
3485 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3487 cmdline_parse_token_string_t cmd_csum_proto =
3488 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3489 proto, "ip#tcp#udp#sctp#outer-ip");
3490 cmdline_parse_token_string_t cmd_csum_hwsw =
3491 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3493 cmdline_parse_token_num_t cmd_csum_portid =
3494 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3497 cmdline_parse_inst_t cmd_csum_set = {
3498 .f = cmd_csum_parsed,
3500 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3501 "Enable/Disable hardware calculation of L3/L4 checksum when "
3502 "using csum forward engine",
3504 (void *)&cmd_csum_csum,
3505 (void *)&cmd_csum_mode,
3506 (void *)&cmd_csum_proto,
3507 (void *)&cmd_csum_hwsw,
3508 (void *)&cmd_csum_portid,
3513 cmdline_parse_token_string_t cmd_csum_mode_show =
3514 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3517 cmdline_parse_inst_t cmd_csum_show = {
3518 .f = cmd_csum_parsed,
3520 .help_str = "csum show <port_id>: Show checksum offload configuration",
3522 (void *)&cmd_csum_csum,
3523 (void *)&cmd_csum_mode_show,
3524 (void *)&cmd_csum_portid,
3529 /* Enable/disable tunnel parsing */
3530 struct cmd_csum_tunnel_result {
3531 cmdline_fixed_string_t csum;
3532 cmdline_fixed_string_t parse;
3533 cmdline_fixed_string_t onoff;
3538 cmd_csum_tunnel_parsed(void *parsed_result,
3539 __attribute__((unused)) struct cmdline *cl,
3540 __attribute__((unused)) void *data)
3542 struct cmd_csum_tunnel_result *res = parsed_result;
3544 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3547 if (!strcmp(res->onoff, "on"))
3548 ports[res->port_id].tx_ol_flags |=
3549 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3551 ports[res->port_id].tx_ol_flags &=
3552 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3554 csum_show(res->port_id);
3557 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3558 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3560 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3561 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3562 parse, "parse_tunnel");
3563 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3564 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3566 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3567 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3570 cmdline_parse_inst_t cmd_csum_tunnel = {
3571 .f = cmd_csum_tunnel_parsed,
3573 .help_str = "csum parse_tunnel on|off <port_id>: "
3574 "Enable/Disable parsing of tunnels for csum engine",
3576 (void *)&cmd_csum_tunnel_csum,
3577 (void *)&cmd_csum_tunnel_parse,
3578 (void *)&cmd_csum_tunnel_onoff,
3579 (void *)&cmd_csum_tunnel_portid,
3584 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3585 struct cmd_tso_set_result {
3586 cmdline_fixed_string_t tso;
3587 cmdline_fixed_string_t mode;
3593 cmd_tso_set_parsed(void *parsed_result,
3594 __attribute__((unused)) struct cmdline *cl,
3595 __attribute__((unused)) void *data)
3597 struct cmd_tso_set_result *res = parsed_result;
3598 struct rte_eth_dev_info dev_info;
3600 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3603 if (!strcmp(res->mode, "set"))
3604 ports[res->port_id].tso_segsz = res->tso_segsz;
3606 if (ports[res->port_id].tso_segsz == 0)
3607 printf("TSO for non-tunneled packets is disabled\n");
3609 printf("TSO segment size for non-tunneled packets is %d\n",
3610 ports[res->port_id].tso_segsz);
3612 /* display warnings if configuration is not supported by the NIC */
3613 rte_eth_dev_info_get(res->port_id, &dev_info);
3614 if ((ports[res->port_id].tso_segsz != 0) &&
3615 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3616 printf("Warning: TSO enabled but not "
3617 "supported by port %d\n", res->port_id);
3621 cmdline_parse_token_string_t cmd_tso_set_tso =
3622 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3624 cmdline_parse_token_string_t cmd_tso_set_mode =
3625 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3627 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3628 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3630 cmdline_parse_token_num_t cmd_tso_set_portid =
3631 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3634 cmdline_parse_inst_t cmd_tso_set = {
3635 .f = cmd_tso_set_parsed,
3637 .help_str = "tso set <tso_segsz> <port_id>: "
3638 "Set TSO segment size of non-tunneled packets for csum engine "
3641 (void *)&cmd_tso_set_tso,
3642 (void *)&cmd_tso_set_mode,
3643 (void *)&cmd_tso_set_tso_segsz,
3644 (void *)&cmd_tso_set_portid,
3649 cmdline_parse_token_string_t cmd_tso_show_mode =
3650 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3654 cmdline_parse_inst_t cmd_tso_show = {
3655 .f = cmd_tso_set_parsed,
3657 .help_str = "tso show <port_id>: "
3658 "Show TSO segment size of non-tunneled packets for csum engine",
3660 (void *)&cmd_tso_set_tso,
3661 (void *)&cmd_tso_show_mode,
3662 (void *)&cmd_tso_set_portid,
3667 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3668 struct cmd_tunnel_tso_set_result {
3669 cmdline_fixed_string_t tso;
3670 cmdline_fixed_string_t mode;
3676 check_tunnel_tso_nic_support(uint8_t port_id)
3678 struct rte_eth_dev_info dev_info;
3680 rte_eth_dev_info_get(port_id, &dev_info);
3681 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3682 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3683 "supported by port %d\n", port_id);
3684 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3685 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3686 "supported by port %d\n", port_id);
3687 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3688 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3689 "supported by port %d\n", port_id);
3690 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3691 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3692 "supported by port %d\n", port_id);
3696 cmd_tunnel_tso_set_parsed(void *parsed_result,
3697 __attribute__((unused)) struct cmdline *cl,
3698 __attribute__((unused)) void *data)
3700 struct cmd_tunnel_tso_set_result *res = parsed_result;
3702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3705 if (!strcmp(res->mode, "set"))
3706 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3708 if (ports[res->port_id].tunnel_tso_segsz == 0)
3709 printf("TSO for tunneled packets is disabled\n");
3711 printf("TSO segment size for tunneled packets is %d\n",
3712 ports[res->port_id].tunnel_tso_segsz);
3714 /* Below conditions are needed to make it work:
3715 * (1) tunnel TSO is supported by the NIC;
3716 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3718 * (3) for tunneled pkts with outer L3 of IPv4,
3719 * "csum set outer-ip" must be set to hw, because after tso,
3720 * total_len of outer IP header is changed, and the checksum
3721 * of outer IP header calculated by sw should be wrong; that
3722 * is not necessary for IPv6 tunneled pkts because there's no
3723 * checksum in IP header anymore.
3725 check_tunnel_tso_nic_support(res->port_id);
3727 if (!(ports[res->port_id].tx_ol_flags &
3728 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3729 printf("Warning: csum parse_tunnel must be set "
3730 "so that tunneled packets are recognized\n");
3731 if (!(ports[res->port_id].tx_ol_flags &
3732 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3733 printf("Warning: csum set outer-ip must be set to hw "
3734 "if outer L3 is IPv4; not necessary for IPv6\n");
3738 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3739 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3741 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3742 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3744 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3745 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3747 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3748 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3751 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3752 .f = cmd_tunnel_tso_set_parsed,
3754 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3755 "Set TSO segment size of tunneled packets for csum engine "
3758 (void *)&cmd_tunnel_tso_set_tso,
3759 (void *)&cmd_tunnel_tso_set_mode,
3760 (void *)&cmd_tunnel_tso_set_tso_segsz,
3761 (void *)&cmd_tunnel_tso_set_portid,
3766 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3767 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3771 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3772 .f = cmd_tunnel_tso_set_parsed,
3774 .help_str = "tunnel_tso show <port_id> "
3775 "Show TSO segment size of tunneled packets for csum engine",
3777 (void *)&cmd_tunnel_tso_set_tso,
3778 (void *)&cmd_tunnel_tso_show_mode,
3779 (void *)&cmd_tunnel_tso_set_portid,
3784 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3785 struct cmd_set_flush_rx {
3786 cmdline_fixed_string_t set;
3787 cmdline_fixed_string_t flush_rx;
3788 cmdline_fixed_string_t mode;
3792 cmd_set_flush_rx_parsed(void *parsed_result,
3793 __attribute__((unused)) struct cmdline *cl,
3794 __attribute__((unused)) void *data)
3796 struct cmd_set_flush_rx *res = parsed_result;
3797 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3800 cmdline_parse_token_string_t cmd_setflushrx_set =
3801 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3803 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3804 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3805 flush_rx, "flush_rx");
3806 cmdline_parse_token_string_t cmd_setflushrx_mode =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3811 cmdline_parse_inst_t cmd_set_flush_rx = {
3812 .f = cmd_set_flush_rx_parsed,
3813 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3816 (void *)&cmd_setflushrx_set,
3817 (void *)&cmd_setflushrx_flush_rx,
3818 (void *)&cmd_setflushrx_mode,
3823 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3824 struct cmd_set_link_check {
3825 cmdline_fixed_string_t set;
3826 cmdline_fixed_string_t link_check;
3827 cmdline_fixed_string_t mode;
3831 cmd_set_link_check_parsed(void *parsed_result,
3832 __attribute__((unused)) struct cmdline *cl,
3833 __attribute__((unused)) void *data)
3835 struct cmd_set_link_check *res = parsed_result;
3836 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3839 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3840 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3842 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3843 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3844 link_check, "link_check");
3845 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3850 cmdline_parse_inst_t cmd_set_link_check = {
3851 .f = cmd_set_link_check_parsed,
3852 .help_str = "set link_check on|off: Enable/Disable link status check "
3853 "when starting/stopping a port",
3856 (void *)&cmd_setlinkcheck_set,
3857 (void *)&cmd_setlinkcheck_link_check,
3858 (void *)&cmd_setlinkcheck_mode,
3863 #ifdef RTE_NIC_BYPASS
3864 /* *** SET NIC BYPASS MODE *** */
3865 struct cmd_set_bypass_mode_result {
3866 cmdline_fixed_string_t set;
3867 cmdline_fixed_string_t bypass;
3868 cmdline_fixed_string_t mode;
3869 cmdline_fixed_string_t value;
3874 cmd_set_bypass_mode_parsed(void *parsed_result,
3875 __attribute__((unused)) struct cmdline *cl,
3876 __attribute__((unused)) void *data)
3878 struct cmd_set_bypass_mode_result *res = parsed_result;
3879 portid_t port_id = res->port_id;
3880 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3882 if (!strcmp(res->value, "bypass"))
3883 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3884 else if (!strcmp(res->value, "isolate"))
3885 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3887 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3889 /* Set the bypass mode for the relevant port. */
3890 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3891 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3895 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3898 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3899 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3901 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3902 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3904 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3906 value, "normal#bypass#isolate");
3907 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3908 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3911 cmdline_parse_inst_t cmd_set_bypass_mode = {
3912 .f = cmd_set_bypass_mode_parsed,
3913 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3914 "Set the NIC bypass mode for port_id",
3917 (void *)&cmd_setbypass_mode_set,
3918 (void *)&cmd_setbypass_mode_bypass,
3919 (void *)&cmd_setbypass_mode_mode,
3920 (void *)&cmd_setbypass_mode_value,
3921 (void *)&cmd_setbypass_mode_port,
3926 /* *** SET NIC BYPASS EVENT *** */
3927 struct cmd_set_bypass_event_result {
3928 cmdline_fixed_string_t set;
3929 cmdline_fixed_string_t bypass;
3930 cmdline_fixed_string_t event;
3931 cmdline_fixed_string_t event_value;
3932 cmdline_fixed_string_t mode;
3933 cmdline_fixed_string_t mode_value;
3938 cmd_set_bypass_event_parsed(void *parsed_result,
3939 __attribute__((unused)) struct cmdline *cl,
3940 __attribute__((unused)) void *data)
3943 struct cmd_set_bypass_event_result *res = parsed_result;
3944 portid_t port_id = res->port_id;
3945 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3946 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3948 if (!strcmp(res->event_value, "timeout"))
3949 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3950 else if (!strcmp(res->event_value, "os_on"))
3951 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3952 else if (!strcmp(res->event_value, "os_off"))
3953 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3954 else if (!strcmp(res->event_value, "power_on"))
3955 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3956 else if (!strcmp(res->event_value, "power_off"))
3957 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3959 bypass_event = RTE_BYPASS_EVENT_NONE;
3961 if (!strcmp(res->mode_value, "bypass"))
3962 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3963 else if (!strcmp(res->mode_value, "isolate"))
3964 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3966 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3968 /* Set the watchdog timeout. */
3969 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3972 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3973 (rc = rte_eth_dev_wd_timeout_store(port_id,
3974 bypass_timeout)) != 0) {
3975 printf("Failed to set timeout value %u "
3976 "for port %d, errto code: %d.\n",
3977 bypass_timeout, port_id, rc);
3981 /* Set the bypass event to transition to bypass mode. */
3982 if (0 != rte_eth_dev_bypass_event_store(port_id,
3983 bypass_event, bypass_mode)) {
3984 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3989 cmdline_parse_token_string_t cmd_setbypass_event_set =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3992 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3995 cmdline_parse_token_string_t cmd_setbypass_event_event =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3998 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3999 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4000 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4001 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4004 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4005 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4006 mode_value, "normal#bypass#isolate");
4007 cmdline_parse_token_num_t cmd_setbypass_event_port =
4008 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4011 cmdline_parse_inst_t cmd_set_bypass_event = {
4012 .f = cmd_set_bypass_event_parsed,
4013 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4014 "power_off mode normal|bypass|isolate <port_id>: "
4015 "Set the NIC bypass event mode for port_id",
4018 (void *)&cmd_setbypass_event_set,
4019 (void *)&cmd_setbypass_event_bypass,
4020 (void *)&cmd_setbypass_event_event,
4021 (void *)&cmd_setbypass_event_event_value,
4022 (void *)&cmd_setbypass_event_mode,
4023 (void *)&cmd_setbypass_event_mode_value,
4024 (void *)&cmd_setbypass_event_port,
4030 /* *** SET NIC BYPASS TIMEOUT *** */
4031 struct cmd_set_bypass_timeout_result {
4032 cmdline_fixed_string_t set;
4033 cmdline_fixed_string_t bypass;
4034 cmdline_fixed_string_t timeout;
4035 cmdline_fixed_string_t value;
4039 cmd_set_bypass_timeout_parsed(void *parsed_result,
4040 __attribute__((unused)) struct cmdline *cl,
4041 __attribute__((unused)) void *data)
4043 struct cmd_set_bypass_timeout_result *res = parsed_result;
4045 if (!strcmp(res->value, "1.5"))
4046 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4047 else if (!strcmp(res->value, "2"))
4048 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4049 else if (!strcmp(res->value, "3"))
4050 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4051 else if (!strcmp(res->value, "4"))
4052 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4053 else if (!strcmp(res->value, "8"))
4054 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4055 else if (!strcmp(res->value, "16"))
4056 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4057 else if (!strcmp(res->value, "32"))
4058 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4060 bypass_timeout = RTE_BYPASS_TMT_OFF;
4063 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4064 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4066 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4067 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4069 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4070 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4071 timeout, "timeout");
4072 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4073 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4074 value, "0#1.5#2#3#4#8#16#32");
4076 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4077 .f = cmd_set_bypass_timeout_parsed,
4078 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4079 "Set the NIC bypass watchdog timeout in seconds",
4082 (void *)&cmd_setbypass_timeout_set,
4083 (void *)&cmd_setbypass_timeout_bypass,
4084 (void *)&cmd_setbypass_timeout_timeout,
4085 (void *)&cmd_setbypass_timeout_value,
4090 /* *** SHOW NIC BYPASS MODE *** */
4091 struct cmd_show_bypass_config_result {
4092 cmdline_fixed_string_t show;
4093 cmdline_fixed_string_t bypass;
4094 cmdline_fixed_string_t config;
4099 cmd_show_bypass_config_parsed(void *parsed_result,
4100 __attribute__((unused)) struct cmdline *cl,
4101 __attribute__((unused)) void *data)
4103 struct cmd_show_bypass_config_result *res = parsed_result;
4104 uint32_t event_mode;
4105 uint32_t bypass_mode;
4106 portid_t port_id = res->port_id;
4107 uint32_t timeout = bypass_timeout;
4110 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4111 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4112 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4113 {"UNKNOWN", "normal", "bypass", "isolate"};
4114 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4121 int num_events = (sizeof events) / (sizeof events[0]);
4123 /* Display the bypass mode.*/
4124 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4125 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4129 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4130 bypass_mode = RTE_BYPASS_MODE_NONE;
4132 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4135 /* Display the bypass timeout.*/
4136 if (!RTE_BYPASS_TMT_VALID(timeout))
4137 timeout = RTE_BYPASS_TMT_OFF;
4139 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4141 /* Display the bypass events and associated modes. */
4142 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4144 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4145 printf("\tFailed to get bypass mode for event = %s\n",
4148 if (!RTE_BYPASS_MODE_VALID(event_mode))
4149 event_mode = RTE_BYPASS_MODE_NONE;
4151 printf("\tbypass event: %-16s = %s\n", events[i],
4157 cmdline_parse_token_string_t cmd_showbypass_config_show =
4158 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4160 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4161 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4163 cmdline_parse_token_string_t cmd_showbypass_config_config =
4164 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4166 cmdline_parse_token_num_t cmd_showbypass_config_port =
4167 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4170 cmdline_parse_inst_t cmd_show_bypass_config = {
4171 .f = cmd_show_bypass_config_parsed,
4172 .help_str = "show bypass config <port_id>: "
4173 "Show the NIC bypass config for port_id",
4176 (void *)&cmd_showbypass_config_show,
4177 (void *)&cmd_showbypass_config_bypass,
4178 (void *)&cmd_showbypass_config_config,
4179 (void *)&cmd_showbypass_config_port,
4185 #ifdef RTE_LIBRTE_PMD_BOND
4186 /* *** SET BONDING MODE *** */
4187 struct cmd_set_bonding_mode_result {
4188 cmdline_fixed_string_t set;
4189 cmdline_fixed_string_t bonding;
4190 cmdline_fixed_string_t mode;
4195 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4196 __attribute__((unused)) struct cmdline *cl,
4197 __attribute__((unused)) void *data)
4199 struct cmd_set_bonding_mode_result *res = parsed_result;
4200 portid_t port_id = res->port_id;
4202 /* Set the bonding mode for the relevant port. */
4203 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4204 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4207 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4208 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4210 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4211 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4212 bonding, "bonding");
4213 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4214 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4216 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4217 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4219 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4220 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4223 cmdline_parse_inst_t cmd_set_bonding_mode = {
4224 .f = cmd_set_bonding_mode_parsed,
4225 .help_str = "set bonding mode <mode_value> <port_id>: "
4226 "Set the bonding mode for port_id",
4229 (void *) &cmd_setbonding_mode_set,
4230 (void *) &cmd_setbonding_mode_bonding,
4231 (void *) &cmd_setbonding_mode_mode,
4232 (void *) &cmd_setbonding_mode_value,
4233 (void *) &cmd_setbonding_mode_port,
4238 /* *** SET BALANCE XMIT POLICY *** */
4239 struct cmd_set_bonding_balance_xmit_policy_result {
4240 cmdline_fixed_string_t set;
4241 cmdline_fixed_string_t bonding;
4242 cmdline_fixed_string_t balance_xmit_policy;
4244 cmdline_fixed_string_t policy;
4247 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4248 __attribute__((unused)) struct cmdline *cl,
4249 __attribute__((unused)) void *data)
4251 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4252 portid_t port_id = res->port_id;
4255 if (!strcmp(res->policy, "l2")) {
4256 policy = BALANCE_XMIT_POLICY_LAYER2;
4257 } else if (!strcmp(res->policy, "l23")) {
4258 policy = BALANCE_XMIT_POLICY_LAYER23;
4259 } else if (!strcmp(res->policy, "l34")) {
4260 policy = BALANCE_XMIT_POLICY_LAYER34;
4262 printf("\t Invalid xmit policy selection");
4266 /* Set the bonding mode for the relevant port. */
4267 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4268 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4273 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4276 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4277 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4278 bonding, "bonding");
4279 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4280 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4281 balance_xmit_policy, "balance_xmit_policy");
4282 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4283 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4285 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4287 policy, "l2#l23#l34");
4289 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4290 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4291 .help_str = "set bonding balance_xmit_policy <port_id> "
4293 "Set the bonding balance_xmit_policy for port_id",
4296 (void *)&cmd_setbonding_balance_xmit_policy_set,
4297 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4298 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4299 (void *)&cmd_setbonding_balance_xmit_policy_port,
4300 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4305 /* *** SHOW NIC BONDING CONFIGURATION *** */
4306 struct cmd_show_bonding_config_result {
4307 cmdline_fixed_string_t show;
4308 cmdline_fixed_string_t bonding;
4309 cmdline_fixed_string_t config;
4313 static void cmd_show_bonding_config_parsed(void *parsed_result,
4314 __attribute__((unused)) struct cmdline *cl,
4315 __attribute__((unused)) void *data)
4317 struct cmd_show_bonding_config_result *res = parsed_result;
4319 uint8_t slaves[RTE_MAX_ETHPORTS];
4320 int num_slaves, num_active_slaves;
4323 portid_t port_id = res->port_id;
4325 /* Display the bonding mode.*/
4326 bonding_mode = rte_eth_bond_mode_get(port_id);
4327 if (bonding_mode < 0) {
4328 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4331 printf("\tBonding mode: %d\n", bonding_mode);
4333 if (bonding_mode == BONDING_MODE_BALANCE) {
4334 int balance_xmit_policy;
4336 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4337 if (balance_xmit_policy < 0) {
4338 printf("\tFailed to get balance xmit policy for port = %d\n",
4342 printf("\tBalance Xmit Policy: ");
4344 switch (balance_xmit_policy) {
4345 case BALANCE_XMIT_POLICY_LAYER2:
4346 printf("BALANCE_XMIT_POLICY_LAYER2");
4348 case BALANCE_XMIT_POLICY_LAYER23:
4349 printf("BALANCE_XMIT_POLICY_LAYER23");
4351 case BALANCE_XMIT_POLICY_LAYER34:
4352 printf("BALANCE_XMIT_POLICY_LAYER34");
4359 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4361 if (num_slaves < 0) {
4362 printf("\tFailed to get slave list for port = %d\n", port_id);
4365 if (num_slaves > 0) {
4366 printf("\tSlaves (%d): [", num_slaves);
4367 for (i = 0; i < num_slaves - 1; i++)
4368 printf("%d ", slaves[i]);
4370 printf("%d]\n", slaves[num_slaves - 1]);
4372 printf("\tSlaves: []\n");
4376 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4379 if (num_active_slaves < 0) {
4380 printf("\tFailed to get active slave list for port = %d\n", port_id);
4383 if (num_active_slaves > 0) {
4384 printf("\tActive Slaves (%d): [", num_active_slaves);
4385 for (i = 0; i < num_active_slaves - 1; i++)
4386 printf("%d ", slaves[i]);
4388 printf("%d]\n", slaves[num_active_slaves - 1]);
4391 printf("\tActive Slaves: []\n");
4395 primary_id = rte_eth_bond_primary_get(port_id);
4396 if (primary_id < 0) {
4397 printf("\tFailed to get primary slave for port = %d\n", port_id);
4400 printf("\tPrimary: [%d]\n", primary_id);
4404 cmdline_parse_token_string_t cmd_showbonding_config_show =
4405 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4407 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4408 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4409 bonding, "bonding");
4410 cmdline_parse_token_string_t cmd_showbonding_config_config =
4411 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4413 cmdline_parse_token_num_t cmd_showbonding_config_port =
4414 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4417 cmdline_parse_inst_t cmd_show_bonding_config = {
4418 .f = cmd_show_bonding_config_parsed,
4419 .help_str = "show bonding config <port_id>: "
4420 "Show the bonding config for port_id",
4423 (void *)&cmd_showbonding_config_show,
4424 (void *)&cmd_showbonding_config_bonding,
4425 (void *)&cmd_showbonding_config_config,
4426 (void *)&cmd_showbonding_config_port,
4431 /* *** SET BONDING PRIMARY *** */
4432 struct cmd_set_bonding_primary_result {
4433 cmdline_fixed_string_t set;
4434 cmdline_fixed_string_t bonding;
4435 cmdline_fixed_string_t primary;
4440 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4441 __attribute__((unused)) struct cmdline *cl,
4442 __attribute__((unused)) void *data)
4444 struct cmd_set_bonding_primary_result *res = parsed_result;
4445 portid_t master_port_id = res->port_id;
4446 portid_t slave_port_id = res->slave_id;
4448 /* Set the primary slave for a bonded device. */
4449 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4450 printf("\t Failed to set primary slave for port = %d.\n",
4457 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4458 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4460 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4461 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4462 bonding, "bonding");
4463 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4464 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4465 primary, "primary");
4466 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4467 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4469 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4470 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4473 cmdline_parse_inst_t cmd_set_bonding_primary = {
4474 .f = cmd_set_bonding_primary_parsed,
4475 .help_str = "set bonding primary <slave_id> <port_id>: "
4476 "Set the primary slave for port_id",
4479 (void *)&cmd_setbonding_primary_set,
4480 (void *)&cmd_setbonding_primary_bonding,
4481 (void *)&cmd_setbonding_primary_primary,
4482 (void *)&cmd_setbonding_primary_slave,
4483 (void *)&cmd_setbonding_primary_port,
4488 /* *** ADD SLAVE *** */
4489 struct cmd_add_bonding_slave_result {
4490 cmdline_fixed_string_t add;
4491 cmdline_fixed_string_t bonding;
4492 cmdline_fixed_string_t slave;
4497 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4498 __attribute__((unused)) struct cmdline *cl,
4499 __attribute__((unused)) void *data)
4501 struct cmd_add_bonding_slave_result *res = parsed_result;
4502 portid_t master_port_id = res->port_id;
4503 portid_t slave_port_id = res->slave_id;
4505 /* Set the primary slave for a bonded device. */
4506 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4507 printf("\t Failed to add slave %d to master port = %d.\n",
4508 slave_port_id, master_port_id);
4512 set_port_slave_flag(slave_port_id);
4515 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4516 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4518 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4519 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4520 bonding, "bonding");
4521 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4522 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4524 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4525 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4527 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4528 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4531 cmdline_parse_inst_t cmd_add_bonding_slave = {
4532 .f = cmd_add_bonding_slave_parsed,
4533 .help_str = "add bonding slave <slave_id> <port_id>: "
4534 "Add a slave device to a bonded device",
4537 (void *)&cmd_addbonding_slave_add,
4538 (void *)&cmd_addbonding_slave_bonding,
4539 (void *)&cmd_addbonding_slave_slave,
4540 (void *)&cmd_addbonding_slave_slaveid,
4541 (void *)&cmd_addbonding_slave_port,
4546 /* *** REMOVE SLAVE *** */
4547 struct cmd_remove_bonding_slave_result {
4548 cmdline_fixed_string_t remove;
4549 cmdline_fixed_string_t bonding;
4550 cmdline_fixed_string_t slave;
4555 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4556 __attribute__((unused)) struct cmdline *cl,
4557 __attribute__((unused)) void *data)
4559 struct cmd_remove_bonding_slave_result *res = parsed_result;
4560 portid_t master_port_id = res->port_id;
4561 portid_t slave_port_id = res->slave_id;
4563 /* Set the primary slave for a bonded device. */
4564 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4565 printf("\t Failed to remove slave %d from master port = %d.\n",
4566 slave_port_id, master_port_id);
4570 clear_port_slave_flag(slave_port_id);
4573 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4574 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4576 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4577 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4578 bonding, "bonding");
4579 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4580 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4582 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4583 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4585 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4586 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4589 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4590 .f = cmd_remove_bonding_slave_parsed,
4591 .help_str = "remove bonding slave <slave_id> <port_id>: "
4592 "Remove a slave device from a bonded device",
4595 (void *)&cmd_removebonding_slave_remove,
4596 (void *)&cmd_removebonding_slave_bonding,
4597 (void *)&cmd_removebonding_slave_slave,
4598 (void *)&cmd_removebonding_slave_slaveid,
4599 (void *)&cmd_removebonding_slave_port,
4604 /* *** CREATE BONDED DEVICE *** */
4605 struct cmd_create_bonded_device_result {
4606 cmdline_fixed_string_t create;
4607 cmdline_fixed_string_t bonded;
4608 cmdline_fixed_string_t device;
4613 static int bond_dev_num = 0;
4615 static void cmd_create_bonded_device_parsed(void *parsed_result,
4616 __attribute__((unused)) struct cmdline *cl,
4617 __attribute__((unused)) void *data)
4619 struct cmd_create_bonded_device_result *res = parsed_result;
4620 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4623 if (test_done == 0) {
4624 printf("Please stop forwarding first\n");
4628 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4631 /* Create a new bonded device. */
4632 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4634 printf("\t Failed to create bonded device.\n");
4637 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4640 /* Update number of ports */
4641 nb_ports = rte_eth_dev_count();
4642 reconfig(port_id, res->socket);
4643 rte_eth_promiscuous_enable(port_id);
4644 ports[port_id].enabled = 1;
4649 cmdline_parse_token_string_t cmd_createbonded_device_create =
4650 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4652 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4653 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4655 cmdline_parse_token_string_t cmd_createbonded_device_device =
4656 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4658 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4659 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4661 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4662 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4665 cmdline_parse_inst_t cmd_create_bonded_device = {
4666 .f = cmd_create_bonded_device_parsed,
4667 .help_str = "create bonded device <mode> <socket>: "
4668 "Create a new bonded device with specific bonding mode and socket",
4671 (void *)&cmd_createbonded_device_create,
4672 (void *)&cmd_createbonded_device_bonded,
4673 (void *)&cmd_createbonded_device_device,
4674 (void *)&cmd_createbonded_device_mode,
4675 (void *)&cmd_createbonded_device_socket,
4680 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4681 struct cmd_set_bond_mac_addr_result {
4682 cmdline_fixed_string_t set;
4683 cmdline_fixed_string_t bonding;
4684 cmdline_fixed_string_t mac_addr;
4686 struct ether_addr address;
4689 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4690 __attribute__((unused)) struct cmdline *cl,
4691 __attribute__((unused)) void *data)
4693 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4696 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4699 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4701 /* check the return value and print it if is < 0 */
4703 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4706 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4707 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4708 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4709 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4711 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4712 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4714 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4715 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4716 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4717 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4719 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4720 .f = cmd_set_bond_mac_addr_parsed,
4722 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4724 (void *)&cmd_set_bond_mac_addr_set,
4725 (void *)&cmd_set_bond_mac_addr_bonding,
4726 (void *)&cmd_set_bond_mac_addr_mac,
4727 (void *)&cmd_set_bond_mac_addr_portnum,
4728 (void *)&cmd_set_bond_mac_addr_addr,
4734 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4735 struct cmd_set_bond_mon_period_result {
4736 cmdline_fixed_string_t set;
4737 cmdline_fixed_string_t bonding;
4738 cmdline_fixed_string_t mon_period;
4743 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4744 __attribute__((unused)) struct cmdline *cl,
4745 __attribute__((unused)) void *data)
4747 struct cmd_set_bond_mon_period_result *res = parsed_result;
4750 if (res->port_num >= nb_ports) {
4751 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4755 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4757 /* check the return value and print it if is < 0 */
4759 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4762 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4763 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4765 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4766 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4767 bonding, "bonding");
4768 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4769 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4770 mon_period, "mon_period");
4771 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4772 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4774 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4775 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4778 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4779 .f = cmd_set_bond_mon_period_parsed,
4781 .help_str = "set bonding mon_period <port_id> <period_ms>",
4783 (void *)&cmd_set_bond_mon_period_set,
4784 (void *)&cmd_set_bond_mon_period_bonding,
4785 (void *)&cmd_set_bond_mon_period_mon_period,
4786 (void *)&cmd_set_bond_mon_period_portnum,
4787 (void *)&cmd_set_bond_mon_period_period_ms,
4792 #endif /* RTE_LIBRTE_PMD_BOND */
4794 /* *** SET FORWARDING MODE *** */
4795 struct cmd_set_fwd_mode_result {
4796 cmdline_fixed_string_t set;
4797 cmdline_fixed_string_t fwd;
4798 cmdline_fixed_string_t mode;
4801 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4802 __attribute__((unused)) struct cmdline *cl,
4803 __attribute__((unused)) void *data)
4805 struct cmd_set_fwd_mode_result *res = parsed_result;
4808 set_pkt_forwarding_mode(res->mode);
4811 cmdline_parse_token_string_t cmd_setfwd_set =
4812 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4813 cmdline_parse_token_string_t cmd_setfwd_fwd =
4814 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4815 cmdline_parse_token_string_t cmd_setfwd_mode =
4816 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4817 "" /* defined at init */);
4819 cmdline_parse_inst_t cmd_set_fwd_mode = {
4820 .f = cmd_set_fwd_mode_parsed,
4822 .help_str = NULL, /* defined at init */
4824 (void *)&cmd_setfwd_set,
4825 (void *)&cmd_setfwd_fwd,
4826 (void *)&cmd_setfwd_mode,
4831 static void cmd_set_fwd_mode_init(void)
4834 static char token[128];
4835 static char help[256];
4836 cmdline_parse_token_string_t *token_struct;
4838 modes = list_pkt_forwarding_modes();
4839 snprintf(help, sizeof(help), "set fwd %s: "
4840 "Set packet forwarding mode", modes);
4841 cmd_set_fwd_mode.help_str = help;
4843 /* string token separator is # */
4844 for (c = token; *modes != '\0'; modes++)
4849 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4850 token_struct->string_data.str = token;
4853 /* *** SET RETRY FORWARDING MODE *** */
4854 struct cmd_set_fwd_retry_mode_result {
4855 cmdline_fixed_string_t set;
4856 cmdline_fixed_string_t fwd;
4857 cmdline_fixed_string_t mode;
4858 cmdline_fixed_string_t retry;
4861 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4862 __attribute__((unused)) struct cmdline *cl,
4863 __attribute__((unused)) void *data)
4865 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4868 set_pkt_forwarding_mode(res->mode);
4871 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4872 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4874 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4875 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4877 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4880 "" /* defined at init */);
4881 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4882 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4885 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4886 .f = cmd_set_fwd_retry_mode_parsed,
4888 .help_str = NULL, /* defined at init */
4890 (void *)&cmd_setfwd_retry_set,
4891 (void *)&cmd_setfwd_retry_fwd,
4892 (void *)&cmd_setfwd_retry_mode,
4893 (void *)&cmd_setfwd_retry_retry,
4898 static void cmd_set_fwd_retry_mode_init(void)
4901 static char token[128];
4902 static char help[256];
4903 cmdline_parse_token_string_t *token_struct;
4905 modes = list_pkt_forwarding_retry_modes();
4906 snprintf(help, sizeof(help), "set fwd %s retry: "
4907 "Set packet forwarding mode with retry", modes);
4908 cmd_set_fwd_retry_mode.help_str = help;
4910 /* string token separator is # */
4911 for (c = token; *modes != '\0'; modes++)
4916 token_struct = (cmdline_parse_token_string_t *)
4917 cmd_set_fwd_retry_mode.tokens[2];
4918 token_struct->string_data.str = token;
4921 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4922 struct cmd_set_burst_tx_retry_result {
4923 cmdline_fixed_string_t set;
4924 cmdline_fixed_string_t burst;
4925 cmdline_fixed_string_t tx;
4926 cmdline_fixed_string_t delay;
4928 cmdline_fixed_string_t retry;
4932 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4933 __attribute__((unused)) struct cmdline *cl,
4934 __attribute__((unused)) void *data)
4936 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4938 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4939 && !strcmp(res->tx, "tx")) {
4940 if (!strcmp(res->delay, "delay"))
4941 burst_tx_delay_time = res->time;
4942 if (!strcmp(res->retry, "retry"))
4943 burst_tx_retry_num = res->retry_num;
4948 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4949 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4950 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4951 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4953 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4954 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4955 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4956 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4957 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4958 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4959 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4960 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4961 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4962 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4964 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4965 .f = cmd_set_burst_tx_retry_parsed,
4966 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4968 (void *)&cmd_set_burst_tx_retry_set,
4969 (void *)&cmd_set_burst_tx_retry_burst,
4970 (void *)&cmd_set_burst_tx_retry_tx,
4971 (void *)&cmd_set_burst_tx_retry_delay,
4972 (void *)&cmd_set_burst_tx_retry_time,
4973 (void *)&cmd_set_burst_tx_retry_retry,
4974 (void *)&cmd_set_burst_tx_retry_retry_num,
4979 /* *** SET PROMISC MODE *** */
4980 struct cmd_set_promisc_mode_result {
4981 cmdline_fixed_string_t set;
4982 cmdline_fixed_string_t promisc;
4983 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4984 uint8_t port_num; /* valid if "allports" argument == 0 */
4985 cmdline_fixed_string_t mode;
4988 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4989 __attribute__((unused)) struct cmdline *cl,
4992 struct cmd_set_promisc_mode_result *res = parsed_result;
4996 if (!strcmp(res->mode, "on"))
5003 FOREACH_PORT(i, ports) {
5005 rte_eth_promiscuous_enable(i);
5007 rte_eth_promiscuous_disable(i);
5012 rte_eth_promiscuous_enable(res->port_num);
5014 rte_eth_promiscuous_disable(res->port_num);
5018 cmdline_parse_token_string_t cmd_setpromisc_set =
5019 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5020 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5023 cmdline_parse_token_string_t cmd_setpromisc_portall =
5024 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5026 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5027 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5029 cmdline_parse_token_string_t cmd_setpromisc_mode =
5030 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5033 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5034 .f = cmd_set_promisc_mode_parsed,
5036 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5038 (void *)&cmd_setpromisc_set,
5039 (void *)&cmd_setpromisc_promisc,
5040 (void *)&cmd_setpromisc_portall,
5041 (void *)&cmd_setpromisc_mode,
5046 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5047 .f = cmd_set_promisc_mode_parsed,
5049 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5051 (void *)&cmd_setpromisc_set,
5052 (void *)&cmd_setpromisc_promisc,
5053 (void *)&cmd_setpromisc_portnum,
5054 (void *)&cmd_setpromisc_mode,
5059 /* *** SET ALLMULTI MODE *** */
5060 struct cmd_set_allmulti_mode_result {
5061 cmdline_fixed_string_t set;
5062 cmdline_fixed_string_t allmulti;
5063 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5064 uint8_t port_num; /* valid if "allports" argument == 0 */
5065 cmdline_fixed_string_t mode;
5068 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5069 __attribute__((unused)) struct cmdline *cl,
5072 struct cmd_set_allmulti_mode_result *res = parsed_result;
5076 if (!strcmp(res->mode, "on"))
5083 FOREACH_PORT(i, ports) {
5085 rte_eth_allmulticast_enable(i);
5087 rte_eth_allmulticast_disable(i);
5092 rte_eth_allmulticast_enable(res->port_num);
5094 rte_eth_allmulticast_disable(res->port_num);
5098 cmdline_parse_token_string_t cmd_setallmulti_set =
5099 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5100 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5101 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5103 cmdline_parse_token_string_t cmd_setallmulti_portall =
5104 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5106 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5107 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5109 cmdline_parse_token_string_t cmd_setallmulti_mode =
5110 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5113 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5114 .f = cmd_set_allmulti_mode_parsed,
5116 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5118 (void *)&cmd_setallmulti_set,
5119 (void *)&cmd_setallmulti_allmulti,
5120 (void *)&cmd_setallmulti_portall,
5121 (void *)&cmd_setallmulti_mode,
5126 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5127 .f = cmd_set_allmulti_mode_parsed,
5129 .help_str = "set allmulti <port_id> on|off: "
5130 "Set allmulti mode on port_id",
5132 (void *)&cmd_setallmulti_set,
5133 (void *)&cmd_setallmulti_allmulti,
5134 (void *)&cmd_setallmulti_portnum,
5135 (void *)&cmd_setallmulti_mode,
5140 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5141 struct cmd_link_flow_ctrl_set_result {
5142 cmdline_fixed_string_t set;
5143 cmdline_fixed_string_t flow_ctrl;
5144 cmdline_fixed_string_t rx;
5145 cmdline_fixed_string_t rx_lfc_mode;
5146 cmdline_fixed_string_t tx;
5147 cmdline_fixed_string_t tx_lfc_mode;
5148 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5149 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5150 cmdline_fixed_string_t autoneg_str;
5151 cmdline_fixed_string_t autoneg;
5152 cmdline_fixed_string_t hw_str;
5153 uint32_t high_water;
5154 cmdline_fixed_string_t lw_str;
5156 cmdline_fixed_string_t pt_str;
5157 uint16_t pause_time;
5158 cmdline_fixed_string_t xon_str;
5163 cmdline_parse_token_string_t cmd_lfc_set_set =
5164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5166 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5168 flow_ctrl, "flow_ctrl");
5169 cmdline_parse_token_string_t cmd_lfc_set_rx =
5170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5172 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5174 rx_lfc_mode, "on#off");
5175 cmdline_parse_token_string_t cmd_lfc_set_tx =
5176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5178 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5180 tx_lfc_mode, "on#off");
5181 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5182 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5183 hw_str, "high_water");
5184 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5185 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5186 high_water, UINT32);
5187 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5188 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5189 lw_str, "low_water");
5190 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5191 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5193 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5194 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5195 pt_str, "pause_time");
5196 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5197 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 pause_time, UINT16);
5199 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5200 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5201 xon_str, "send_xon");
5202 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5203 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5205 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5206 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5207 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5208 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5209 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5210 mac_ctrl_frame_fwd_mode, "on#off");
5211 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5212 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5213 autoneg_str, "autoneg");
5214 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5215 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5217 cmdline_parse_token_num_t cmd_lfc_set_portid =
5218 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5221 /* forward declaration */
5223 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5226 cmdline_parse_inst_t cmd_link_flow_control_set = {
5227 .f = cmd_link_flow_ctrl_set_parsed,
5229 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5230 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5231 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5233 (void *)&cmd_lfc_set_set,
5234 (void *)&cmd_lfc_set_flow_ctrl,
5235 (void *)&cmd_lfc_set_rx,
5236 (void *)&cmd_lfc_set_rx_mode,
5237 (void *)&cmd_lfc_set_tx,
5238 (void *)&cmd_lfc_set_tx_mode,
5239 (void *)&cmd_lfc_set_high_water,
5240 (void *)&cmd_lfc_set_low_water,
5241 (void *)&cmd_lfc_set_pause_time,
5242 (void *)&cmd_lfc_set_send_xon,
5243 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5244 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5245 (void *)&cmd_lfc_set_autoneg_str,
5246 (void *)&cmd_lfc_set_autoneg,
5247 (void *)&cmd_lfc_set_portid,
5252 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5253 .f = cmd_link_flow_ctrl_set_parsed,
5254 .data = (void *)&cmd_link_flow_control_set_rx,
5255 .help_str = "set flow_ctrl rx on|off <port_id>: "
5256 "Change rx flow control parameter",
5258 (void *)&cmd_lfc_set_set,
5259 (void *)&cmd_lfc_set_flow_ctrl,
5260 (void *)&cmd_lfc_set_rx,
5261 (void *)&cmd_lfc_set_rx_mode,
5262 (void *)&cmd_lfc_set_portid,
5267 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5268 .f = cmd_link_flow_ctrl_set_parsed,
5269 .data = (void *)&cmd_link_flow_control_set_tx,
5270 .help_str = "set flow_ctrl tx on|off <port_id>: "
5271 "Change tx flow control parameter",
5273 (void *)&cmd_lfc_set_set,
5274 (void *)&cmd_lfc_set_flow_ctrl,
5275 (void *)&cmd_lfc_set_tx,
5276 (void *)&cmd_lfc_set_tx_mode,
5277 (void *)&cmd_lfc_set_portid,
5282 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5283 .f = cmd_link_flow_ctrl_set_parsed,
5284 .data = (void *)&cmd_link_flow_control_set_hw,
5285 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5286 "Change high water flow control parameter",
5288 (void *)&cmd_lfc_set_set,
5289 (void *)&cmd_lfc_set_flow_ctrl,
5290 (void *)&cmd_lfc_set_high_water_str,
5291 (void *)&cmd_lfc_set_high_water,
5292 (void *)&cmd_lfc_set_portid,
5297 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5298 .f = cmd_link_flow_ctrl_set_parsed,
5299 .data = (void *)&cmd_link_flow_control_set_lw,
5300 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5301 "Change low water flow control parameter",
5303 (void *)&cmd_lfc_set_set,
5304 (void *)&cmd_lfc_set_flow_ctrl,
5305 (void *)&cmd_lfc_set_low_water_str,
5306 (void *)&cmd_lfc_set_low_water,
5307 (void *)&cmd_lfc_set_portid,
5312 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5313 .f = cmd_link_flow_ctrl_set_parsed,
5314 .data = (void *)&cmd_link_flow_control_set_pt,
5315 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5316 "Change pause time flow control parameter",
5318 (void *)&cmd_lfc_set_set,
5319 (void *)&cmd_lfc_set_flow_ctrl,
5320 (void *)&cmd_lfc_set_pause_time_str,
5321 (void *)&cmd_lfc_set_pause_time,
5322 (void *)&cmd_lfc_set_portid,
5327 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5328 .f = cmd_link_flow_ctrl_set_parsed,
5329 .data = (void *)&cmd_link_flow_control_set_xon,
5330 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5331 "Change send_xon flow control parameter",
5333 (void *)&cmd_lfc_set_set,
5334 (void *)&cmd_lfc_set_flow_ctrl,
5335 (void *)&cmd_lfc_set_send_xon_str,
5336 (void *)&cmd_lfc_set_send_xon,
5337 (void *)&cmd_lfc_set_portid,
5342 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5343 .f = cmd_link_flow_ctrl_set_parsed,
5344 .data = (void *)&cmd_link_flow_control_set_macfwd,
5345 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5346 "Change mac ctrl fwd flow control parameter",
5348 (void *)&cmd_lfc_set_set,
5349 (void *)&cmd_lfc_set_flow_ctrl,
5350 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5351 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5352 (void *)&cmd_lfc_set_portid,
5357 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5358 .f = cmd_link_flow_ctrl_set_parsed,
5359 .data = (void *)&cmd_link_flow_control_set_autoneg,
5360 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5361 "Change autoneg flow control parameter",
5363 (void *)&cmd_lfc_set_set,
5364 (void *)&cmd_lfc_set_flow_ctrl,
5365 (void *)&cmd_lfc_set_autoneg_str,
5366 (void *)&cmd_lfc_set_autoneg,
5367 (void *)&cmd_lfc_set_portid,
5373 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5374 __attribute__((unused)) struct cmdline *cl,
5377 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5378 cmdline_parse_inst_t *cmd = data;
5379 struct rte_eth_fc_conf fc_conf;
5385 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5386 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5387 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5388 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5390 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5391 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5394 /* Partial command line, retrieve current configuration */
5396 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5398 printf("cannot get current flow ctrl parameters, return"
5399 "code = %d\n", ret);
5403 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5404 (fc_conf.mode == RTE_FC_FULL))
5406 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5407 (fc_conf.mode == RTE_FC_FULL))
5411 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5412 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5414 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5415 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5417 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5419 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5420 fc_conf.high_water = res->high_water;
5422 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5423 fc_conf.low_water = res->low_water;
5425 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5426 fc_conf.pause_time = res->pause_time;
5428 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5429 fc_conf.send_xon = res->send_xon;
5431 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5432 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5433 fc_conf.mac_ctrl_frame_fwd = 1;
5435 fc_conf.mac_ctrl_frame_fwd = 0;
5438 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5439 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5441 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5443 printf("bad flow contrl parameter, return code = %d \n", ret);
5446 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5447 struct cmd_priority_flow_ctrl_set_result {
5448 cmdline_fixed_string_t set;
5449 cmdline_fixed_string_t pfc_ctrl;
5450 cmdline_fixed_string_t rx;
5451 cmdline_fixed_string_t rx_pfc_mode;
5452 cmdline_fixed_string_t tx;
5453 cmdline_fixed_string_t tx_pfc_mode;
5454 uint32_t high_water;
5456 uint16_t pause_time;
5462 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5463 __attribute__((unused)) struct cmdline *cl,
5464 __attribute__((unused)) void *data)
5466 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5467 struct rte_eth_pfc_conf pfc_conf;
5468 int rx_fc_enable, tx_fc_enable;
5472 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5473 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5474 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5475 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5477 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5478 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5481 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5482 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5483 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5484 pfc_conf.fc.high_water = res->high_water;
5485 pfc_conf.fc.low_water = res->low_water;
5486 pfc_conf.fc.pause_time = res->pause_time;
5487 pfc_conf.priority = res->priority;
5489 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5491 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5494 cmdline_parse_token_string_t cmd_pfc_set_set =
5495 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5497 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5498 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5499 pfc_ctrl, "pfc_ctrl");
5500 cmdline_parse_token_string_t cmd_pfc_set_rx =
5501 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5503 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5504 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5505 rx_pfc_mode, "on#off");
5506 cmdline_parse_token_string_t cmd_pfc_set_tx =
5507 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5509 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5510 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5511 tx_pfc_mode, "on#off");
5512 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5513 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5514 high_water, UINT32);
5515 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5516 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5518 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5519 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5520 pause_time, UINT16);
5521 cmdline_parse_token_num_t cmd_pfc_set_priority =
5522 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5524 cmdline_parse_token_num_t cmd_pfc_set_portid =
5525 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5528 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5529 .f = cmd_priority_flow_ctrl_set_parsed,
5531 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5532 "<pause_time> <priority> <port_id>: "
5533 "Configure the Ethernet priority flow control",
5535 (void *)&cmd_pfc_set_set,
5536 (void *)&cmd_pfc_set_flow_ctrl,
5537 (void *)&cmd_pfc_set_rx,
5538 (void *)&cmd_pfc_set_rx_mode,
5539 (void *)&cmd_pfc_set_tx,
5540 (void *)&cmd_pfc_set_tx_mode,
5541 (void *)&cmd_pfc_set_high_water,
5542 (void *)&cmd_pfc_set_low_water,
5543 (void *)&cmd_pfc_set_pause_time,
5544 (void *)&cmd_pfc_set_priority,
5545 (void *)&cmd_pfc_set_portid,
5550 /* *** RESET CONFIGURATION *** */
5551 struct cmd_reset_result {
5552 cmdline_fixed_string_t reset;
5553 cmdline_fixed_string_t def;
5556 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5558 __attribute__((unused)) void *data)
5560 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5561 set_def_fwd_config();
5564 cmdline_parse_token_string_t cmd_reset_set =
5565 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5566 cmdline_parse_token_string_t cmd_reset_def =
5567 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5570 cmdline_parse_inst_t cmd_reset = {
5571 .f = cmd_reset_parsed,
5573 .help_str = "set default: Reset default forwarding configuration",
5575 (void *)&cmd_reset_set,
5576 (void *)&cmd_reset_def,
5581 /* *** START FORWARDING *** */
5582 struct cmd_start_result {
5583 cmdline_fixed_string_t start;
5586 cmdline_parse_token_string_t cmd_start_start =
5587 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5589 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5590 __attribute__((unused)) struct cmdline *cl,
5591 __attribute__((unused)) void *data)
5593 start_packet_forwarding(0);
5596 cmdline_parse_inst_t cmd_start = {
5597 .f = cmd_start_parsed,
5599 .help_str = "start: Start packet forwarding",
5601 (void *)&cmd_start_start,
5606 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5607 struct cmd_start_tx_first_result {
5608 cmdline_fixed_string_t start;
5609 cmdline_fixed_string_t tx_first;
5613 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5614 __attribute__((unused)) struct cmdline *cl,
5615 __attribute__((unused)) void *data)
5617 start_packet_forwarding(1);
5620 cmdline_parse_token_string_t cmd_start_tx_first_start =
5621 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5623 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5624 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5625 tx_first, "tx_first");
5627 cmdline_parse_inst_t cmd_start_tx_first = {
5628 .f = cmd_start_tx_first_parsed,
5630 .help_str = "start tx_first: Start packet forwarding, "
5631 "after sending 1 burst of packets",
5633 (void *)&cmd_start_tx_first_start,
5634 (void *)&cmd_start_tx_first_tx_first,
5639 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5640 struct cmd_start_tx_first_n_result {
5641 cmdline_fixed_string_t start;
5642 cmdline_fixed_string_t tx_first;
5647 cmd_start_tx_first_n_parsed(void *parsed_result,
5648 __attribute__((unused)) struct cmdline *cl,
5649 __attribute__((unused)) void *data)
5651 struct cmd_start_tx_first_n_result *res = parsed_result;
5653 start_packet_forwarding(res->tx_num);
5656 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5657 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5659 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5660 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5661 tx_first, "tx_first");
5662 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5663 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5666 cmdline_parse_inst_t cmd_start_tx_first_n = {
5667 .f = cmd_start_tx_first_n_parsed,
5669 .help_str = "start tx_first <num>: "
5670 "packet forwarding, after sending <num> bursts of packets",
5672 (void *)&cmd_start_tx_first_n_start,
5673 (void *)&cmd_start_tx_first_n_tx_first,
5674 (void *)&cmd_start_tx_first_n_tx_num,
5679 /* *** SET LINK UP *** */
5680 struct cmd_set_link_up_result {
5681 cmdline_fixed_string_t set;
5682 cmdline_fixed_string_t link_up;
5683 cmdline_fixed_string_t port;
5687 cmdline_parse_token_string_t cmd_set_link_up_set =
5688 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5689 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5692 cmdline_parse_token_string_t cmd_set_link_up_port =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5694 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5695 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5697 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5698 __attribute__((unused)) struct cmdline *cl,
5699 __attribute__((unused)) void *data)
5701 struct cmd_set_link_up_result *res = parsed_result;
5702 dev_set_link_up(res->port_id);
5705 cmdline_parse_inst_t cmd_set_link_up = {
5706 .f = cmd_set_link_up_parsed,
5708 .help_str = "set link-up port <port id>",
5710 (void *)&cmd_set_link_up_set,
5711 (void *)&cmd_set_link_up_link_up,
5712 (void *)&cmd_set_link_up_port,
5713 (void *)&cmd_set_link_up_port_id,
5718 /* *** SET LINK DOWN *** */
5719 struct cmd_set_link_down_result {
5720 cmdline_fixed_string_t set;
5721 cmdline_fixed_string_t link_down;
5722 cmdline_fixed_string_t port;
5726 cmdline_parse_token_string_t cmd_set_link_down_set =
5727 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5728 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5729 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5731 cmdline_parse_token_string_t cmd_set_link_down_port =
5732 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5733 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5734 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5736 static void cmd_set_link_down_parsed(
5737 __attribute__((unused)) void *parsed_result,
5738 __attribute__((unused)) struct cmdline *cl,
5739 __attribute__((unused)) void *data)
5741 struct cmd_set_link_down_result *res = parsed_result;
5742 dev_set_link_down(res->port_id);
5745 cmdline_parse_inst_t cmd_set_link_down = {
5746 .f = cmd_set_link_down_parsed,
5748 .help_str = "set link-down port <port id>",
5750 (void *)&cmd_set_link_down_set,
5751 (void *)&cmd_set_link_down_link_down,
5752 (void *)&cmd_set_link_down_port,
5753 (void *)&cmd_set_link_down_port_id,
5758 /* *** SHOW CFG *** */
5759 struct cmd_showcfg_result {
5760 cmdline_fixed_string_t show;
5761 cmdline_fixed_string_t cfg;
5762 cmdline_fixed_string_t what;
5765 static void cmd_showcfg_parsed(void *parsed_result,
5766 __attribute__((unused)) struct cmdline *cl,
5767 __attribute__((unused)) void *data)
5769 struct cmd_showcfg_result *res = parsed_result;
5770 if (!strcmp(res->what, "rxtx"))
5771 rxtx_config_display();
5772 else if (!strcmp(res->what, "cores"))
5773 fwd_lcores_config_display();
5774 else if (!strcmp(res->what, "fwd"))
5775 pkt_fwd_config_display(&cur_fwd_config);
5776 else if (!strcmp(res->what, "txpkts"))
5777 show_tx_pkt_segments();
5780 cmdline_parse_token_string_t cmd_showcfg_show =
5781 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5782 cmdline_parse_token_string_t cmd_showcfg_port =
5783 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5784 cmdline_parse_token_string_t cmd_showcfg_what =
5785 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5786 "rxtx#cores#fwd#txpkts");
5788 cmdline_parse_inst_t cmd_showcfg = {
5789 .f = cmd_showcfg_parsed,
5791 .help_str = "show config rxtx|cores|fwd|txpkts",
5793 (void *)&cmd_showcfg_show,
5794 (void *)&cmd_showcfg_port,
5795 (void *)&cmd_showcfg_what,
5800 /* *** SHOW ALL PORT INFO *** */
5801 struct cmd_showportall_result {
5802 cmdline_fixed_string_t show;
5803 cmdline_fixed_string_t port;
5804 cmdline_fixed_string_t what;
5805 cmdline_fixed_string_t all;
5808 static void cmd_showportall_parsed(void *parsed_result,
5809 __attribute__((unused)) struct cmdline *cl,
5810 __attribute__((unused)) void *data)
5814 struct cmd_showportall_result *res = parsed_result;
5815 if (!strcmp(res->show, "clear")) {
5816 if (!strcmp(res->what, "stats"))
5817 FOREACH_PORT(i, ports)
5819 else if (!strcmp(res->what, "xstats"))
5820 FOREACH_PORT(i, ports)
5821 nic_xstats_clear(i);
5822 } else if (!strcmp(res->what, "info"))
5823 FOREACH_PORT(i, ports)
5824 port_infos_display(i);
5825 else if (!strcmp(res->what, "stats"))
5826 FOREACH_PORT(i, ports)
5827 nic_stats_display(i);
5828 else if (!strcmp(res->what, "xstats"))
5829 FOREACH_PORT(i, ports)
5830 nic_xstats_display(i);
5831 else if (!strcmp(res->what, "fdir"))
5832 FOREACH_PORT(i, ports)
5834 else if (!strcmp(res->what, "stat_qmap"))
5835 FOREACH_PORT(i, ports)
5836 nic_stats_mapping_display(i);
5837 else if (!strcmp(res->what, "dcb_tc"))
5838 FOREACH_PORT(i, ports)
5839 port_dcb_info_display(i);
5840 else if (!strcmp(res->what, "cap"))
5841 FOREACH_PORT(i, ports)
5842 port_offload_cap_display(i);
5845 cmdline_parse_token_string_t cmd_showportall_show =
5846 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5848 cmdline_parse_token_string_t cmd_showportall_port =
5849 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5850 cmdline_parse_token_string_t cmd_showportall_what =
5851 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5852 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5853 cmdline_parse_token_string_t cmd_showportall_all =
5854 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5855 cmdline_parse_inst_t cmd_showportall = {
5856 .f = cmd_showportall_parsed,
5858 .help_str = "show|clear port "
5859 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5861 (void *)&cmd_showportall_show,
5862 (void *)&cmd_showportall_port,
5863 (void *)&cmd_showportall_what,
5864 (void *)&cmd_showportall_all,
5869 /* *** SHOW PORT INFO *** */
5870 struct cmd_showport_result {
5871 cmdline_fixed_string_t show;
5872 cmdline_fixed_string_t port;
5873 cmdline_fixed_string_t what;
5877 static void cmd_showport_parsed(void *parsed_result,
5878 __attribute__((unused)) struct cmdline *cl,
5879 __attribute__((unused)) void *data)
5881 struct cmd_showport_result *res = parsed_result;
5882 if (!strcmp(res->show, "clear")) {
5883 if (!strcmp(res->what, "stats"))
5884 nic_stats_clear(res->portnum);
5885 else if (!strcmp(res->what, "xstats"))
5886 nic_xstats_clear(res->portnum);
5887 } else if (!strcmp(res->what, "info"))
5888 port_infos_display(res->portnum);
5889 else if (!strcmp(res->what, "stats"))
5890 nic_stats_display(res->portnum);
5891 else if (!strcmp(res->what, "xstats"))
5892 nic_xstats_display(res->portnum);
5893 else if (!strcmp(res->what, "fdir"))
5894 fdir_get_infos(res->portnum);
5895 else if (!strcmp(res->what, "stat_qmap"))
5896 nic_stats_mapping_display(res->portnum);
5897 else if (!strcmp(res->what, "dcb_tc"))
5898 port_dcb_info_display(res->portnum);
5899 else if (!strcmp(res->what, "cap"))
5900 port_offload_cap_display(res->portnum);
5903 cmdline_parse_token_string_t cmd_showport_show =
5904 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5906 cmdline_parse_token_string_t cmd_showport_port =
5907 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5908 cmdline_parse_token_string_t cmd_showport_what =
5909 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5910 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5911 cmdline_parse_token_num_t cmd_showport_portnum =
5912 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5914 cmdline_parse_inst_t cmd_showport = {
5915 .f = cmd_showport_parsed,
5917 .help_str = "show|clear port "
5918 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5921 (void *)&cmd_showport_show,
5922 (void *)&cmd_showport_port,
5923 (void *)&cmd_showport_what,
5924 (void *)&cmd_showport_portnum,
5929 /* *** SHOW QUEUE INFO *** */
5930 struct cmd_showqueue_result {
5931 cmdline_fixed_string_t show;
5932 cmdline_fixed_string_t type;
5933 cmdline_fixed_string_t what;
5939 cmd_showqueue_parsed(void *parsed_result,
5940 __attribute__((unused)) struct cmdline *cl,
5941 __attribute__((unused)) void *data)
5943 struct cmd_showqueue_result *res = parsed_result;
5945 if (!strcmp(res->type, "rxq"))
5946 rx_queue_infos_display(res->portnum, res->queuenum);
5947 else if (!strcmp(res->type, "txq"))
5948 tx_queue_infos_display(res->portnum, res->queuenum);
5951 cmdline_parse_token_string_t cmd_showqueue_show =
5952 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5953 cmdline_parse_token_string_t cmd_showqueue_type =
5954 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5955 cmdline_parse_token_string_t cmd_showqueue_what =
5956 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5957 cmdline_parse_token_num_t cmd_showqueue_portnum =
5958 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5959 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5960 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5962 cmdline_parse_inst_t cmd_showqueue = {
5963 .f = cmd_showqueue_parsed,
5965 .help_str = "show rxq|txq info <port_id> <queue_id>",
5967 (void *)&cmd_showqueue_show,
5968 (void *)&cmd_showqueue_type,
5969 (void *)&cmd_showqueue_what,
5970 (void *)&cmd_showqueue_portnum,
5971 (void *)&cmd_showqueue_queuenum,
5976 /* *** READ PORT REGISTER *** */
5977 struct cmd_read_reg_result {
5978 cmdline_fixed_string_t read;
5979 cmdline_fixed_string_t reg;
5985 cmd_read_reg_parsed(void *parsed_result,
5986 __attribute__((unused)) struct cmdline *cl,
5987 __attribute__((unused)) void *data)
5989 struct cmd_read_reg_result *res = parsed_result;
5990 port_reg_display(res->port_id, res->reg_off);
5993 cmdline_parse_token_string_t cmd_read_reg_read =
5994 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5995 cmdline_parse_token_string_t cmd_read_reg_reg =
5996 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5997 cmdline_parse_token_num_t cmd_read_reg_port_id =
5998 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5999 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6000 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6002 cmdline_parse_inst_t cmd_read_reg = {
6003 .f = cmd_read_reg_parsed,
6005 .help_str = "read reg <port_id> <reg_off>",
6007 (void *)&cmd_read_reg_read,
6008 (void *)&cmd_read_reg_reg,
6009 (void *)&cmd_read_reg_port_id,
6010 (void *)&cmd_read_reg_reg_off,
6015 /* *** READ PORT REGISTER BIT FIELD *** */
6016 struct cmd_read_reg_bit_field_result {
6017 cmdline_fixed_string_t read;
6018 cmdline_fixed_string_t regfield;
6026 cmd_read_reg_bit_field_parsed(void *parsed_result,
6027 __attribute__((unused)) struct cmdline *cl,
6028 __attribute__((unused)) void *data)
6030 struct cmd_read_reg_bit_field_result *res = parsed_result;
6031 port_reg_bit_field_display(res->port_id, res->reg_off,
6032 res->bit1_pos, res->bit2_pos);
6035 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6036 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6038 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6039 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6040 regfield, "regfield");
6041 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6042 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6044 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6045 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6047 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6048 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6050 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6051 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6054 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6055 .f = cmd_read_reg_bit_field_parsed,
6057 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6058 "Read register bit field between bit_x and bit_y included",
6060 (void *)&cmd_read_reg_bit_field_read,
6061 (void *)&cmd_read_reg_bit_field_regfield,
6062 (void *)&cmd_read_reg_bit_field_port_id,
6063 (void *)&cmd_read_reg_bit_field_reg_off,
6064 (void *)&cmd_read_reg_bit_field_bit1_pos,
6065 (void *)&cmd_read_reg_bit_field_bit2_pos,
6070 /* *** READ PORT REGISTER BIT *** */
6071 struct cmd_read_reg_bit_result {
6072 cmdline_fixed_string_t read;
6073 cmdline_fixed_string_t regbit;
6080 cmd_read_reg_bit_parsed(void *parsed_result,
6081 __attribute__((unused)) struct cmdline *cl,
6082 __attribute__((unused)) void *data)
6084 struct cmd_read_reg_bit_result *res = parsed_result;
6085 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6088 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6089 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6090 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6091 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6093 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6094 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6095 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6096 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6097 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6098 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6100 cmdline_parse_inst_t cmd_read_reg_bit = {
6101 .f = cmd_read_reg_bit_parsed,
6103 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6105 (void *)&cmd_read_reg_bit_read,
6106 (void *)&cmd_read_reg_bit_regbit,
6107 (void *)&cmd_read_reg_bit_port_id,
6108 (void *)&cmd_read_reg_bit_reg_off,
6109 (void *)&cmd_read_reg_bit_bit_pos,
6114 /* *** WRITE PORT REGISTER *** */
6115 struct cmd_write_reg_result {
6116 cmdline_fixed_string_t write;
6117 cmdline_fixed_string_t reg;
6124 cmd_write_reg_parsed(void *parsed_result,
6125 __attribute__((unused)) struct cmdline *cl,
6126 __attribute__((unused)) void *data)
6128 struct cmd_write_reg_result *res = parsed_result;
6129 port_reg_set(res->port_id, res->reg_off, res->value);
6132 cmdline_parse_token_string_t cmd_write_reg_write =
6133 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6134 cmdline_parse_token_string_t cmd_write_reg_reg =
6135 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6136 cmdline_parse_token_num_t cmd_write_reg_port_id =
6137 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6138 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6139 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6140 cmdline_parse_token_num_t cmd_write_reg_value =
6141 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6143 cmdline_parse_inst_t cmd_write_reg = {
6144 .f = cmd_write_reg_parsed,
6146 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6148 (void *)&cmd_write_reg_write,
6149 (void *)&cmd_write_reg_reg,
6150 (void *)&cmd_write_reg_port_id,
6151 (void *)&cmd_write_reg_reg_off,
6152 (void *)&cmd_write_reg_value,
6157 /* *** WRITE PORT REGISTER BIT FIELD *** */
6158 struct cmd_write_reg_bit_field_result {
6159 cmdline_fixed_string_t write;
6160 cmdline_fixed_string_t regfield;
6169 cmd_write_reg_bit_field_parsed(void *parsed_result,
6170 __attribute__((unused)) struct cmdline *cl,
6171 __attribute__((unused)) void *data)
6173 struct cmd_write_reg_bit_field_result *res = parsed_result;
6174 port_reg_bit_field_set(res->port_id, res->reg_off,
6175 res->bit1_pos, res->bit2_pos, res->value);
6178 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6179 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6181 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6182 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6183 regfield, "regfield");
6184 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6185 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6187 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6188 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6190 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6191 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6193 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6194 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6196 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6200 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6201 .f = cmd_write_reg_bit_field_parsed,
6203 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6205 "Set register bit field between bit_x and bit_y included",
6207 (void *)&cmd_write_reg_bit_field_write,
6208 (void *)&cmd_write_reg_bit_field_regfield,
6209 (void *)&cmd_write_reg_bit_field_port_id,
6210 (void *)&cmd_write_reg_bit_field_reg_off,
6211 (void *)&cmd_write_reg_bit_field_bit1_pos,
6212 (void *)&cmd_write_reg_bit_field_bit2_pos,
6213 (void *)&cmd_write_reg_bit_field_value,
6218 /* *** WRITE PORT REGISTER BIT *** */
6219 struct cmd_write_reg_bit_result {
6220 cmdline_fixed_string_t write;
6221 cmdline_fixed_string_t regbit;
6229 cmd_write_reg_bit_parsed(void *parsed_result,
6230 __attribute__((unused)) struct cmdline *cl,
6231 __attribute__((unused)) void *data)
6233 struct cmd_write_reg_bit_result *res = parsed_result;
6234 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6237 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6238 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6240 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6241 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6243 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6244 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6245 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6246 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6247 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6248 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6249 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6250 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6252 cmdline_parse_inst_t cmd_write_reg_bit = {
6253 .f = cmd_write_reg_bit_parsed,
6255 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6258 (void *)&cmd_write_reg_bit_write,
6259 (void *)&cmd_write_reg_bit_regbit,
6260 (void *)&cmd_write_reg_bit_port_id,
6261 (void *)&cmd_write_reg_bit_reg_off,
6262 (void *)&cmd_write_reg_bit_bit_pos,
6263 (void *)&cmd_write_reg_bit_value,
6268 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6269 struct cmd_read_rxd_txd_result {
6270 cmdline_fixed_string_t read;
6271 cmdline_fixed_string_t rxd_txd;
6278 cmd_read_rxd_txd_parsed(void *parsed_result,
6279 __attribute__((unused)) struct cmdline *cl,
6280 __attribute__((unused)) void *data)
6282 struct cmd_read_rxd_txd_result *res = parsed_result;
6284 if (!strcmp(res->rxd_txd, "rxd"))
6285 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6286 else if (!strcmp(res->rxd_txd, "txd"))
6287 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6290 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6291 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6292 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6293 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6295 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6296 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6297 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6298 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6299 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6300 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6302 cmdline_parse_inst_t cmd_read_rxd_txd = {
6303 .f = cmd_read_rxd_txd_parsed,
6305 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6307 (void *)&cmd_read_rxd_txd_read,
6308 (void *)&cmd_read_rxd_txd_rxd_txd,
6309 (void *)&cmd_read_rxd_txd_port_id,
6310 (void *)&cmd_read_rxd_txd_queue_id,
6311 (void *)&cmd_read_rxd_txd_desc_id,
6317 struct cmd_quit_result {
6318 cmdline_fixed_string_t quit;
6321 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6323 __attribute__((unused)) void *data)
6329 cmdline_parse_token_string_t cmd_quit_quit =
6330 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6332 cmdline_parse_inst_t cmd_quit = {
6333 .f = cmd_quit_parsed,
6335 .help_str = "quit: Exit application",
6337 (void *)&cmd_quit_quit,
6342 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6343 struct cmd_mac_addr_result {
6344 cmdline_fixed_string_t mac_addr_cmd;
6345 cmdline_fixed_string_t what;
6347 struct ether_addr address;
6350 static void cmd_mac_addr_parsed(void *parsed_result,
6351 __attribute__((unused)) struct cmdline *cl,
6352 __attribute__((unused)) void *data)
6354 struct cmd_mac_addr_result *res = parsed_result;
6357 if (strcmp(res->what, "add") == 0)
6358 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6360 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6362 /* check the return value and print it if is < 0 */
6364 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6368 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6369 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6371 cmdline_parse_token_string_t cmd_mac_addr_what =
6372 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6374 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6375 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6376 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6377 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6379 cmdline_parse_inst_t cmd_mac_addr = {
6380 .f = cmd_mac_addr_parsed,
6382 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6383 "Add/Remove MAC address on port_id",
6385 (void *)&cmd_mac_addr_cmd,
6386 (void *)&cmd_mac_addr_what,
6387 (void *)&cmd_mac_addr_portnum,
6388 (void *)&cmd_mac_addr_addr,
6394 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6395 struct cmd_set_qmap_result {
6396 cmdline_fixed_string_t set;
6397 cmdline_fixed_string_t qmap;
6398 cmdline_fixed_string_t what;
6405 cmd_set_qmap_parsed(void *parsed_result,
6406 __attribute__((unused)) struct cmdline *cl,
6407 __attribute__((unused)) void *data)
6409 struct cmd_set_qmap_result *res = parsed_result;
6410 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6412 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6415 cmdline_parse_token_string_t cmd_setqmap_set =
6416 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6418 cmdline_parse_token_string_t cmd_setqmap_qmap =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6421 cmdline_parse_token_string_t cmd_setqmap_what =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6424 cmdline_parse_token_num_t cmd_setqmap_portid =
6425 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6427 cmdline_parse_token_num_t cmd_setqmap_queueid =
6428 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6430 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6431 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6434 cmdline_parse_inst_t cmd_set_qmap = {
6435 .f = cmd_set_qmap_parsed,
6437 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6438 "Set statistics mapping value on tx|rx queue_id of port_id",
6440 (void *)&cmd_setqmap_set,
6441 (void *)&cmd_setqmap_qmap,
6442 (void *)&cmd_setqmap_what,
6443 (void *)&cmd_setqmap_portid,
6444 (void *)&cmd_setqmap_queueid,
6445 (void *)&cmd_setqmap_mapvalue,
6450 /* *** CONFIGURE UNICAST HASH TABLE *** */
6451 struct cmd_set_uc_hash_table {
6452 cmdline_fixed_string_t set;
6453 cmdline_fixed_string_t port;
6455 cmdline_fixed_string_t what;
6456 struct ether_addr address;
6457 cmdline_fixed_string_t mode;
6461 cmd_set_uc_hash_parsed(void *parsed_result,
6462 __attribute__((unused)) struct cmdline *cl,
6463 __attribute__((unused)) void *data)
6466 struct cmd_set_uc_hash_table *res = parsed_result;
6468 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6470 if (strcmp(res->what, "uta") == 0)
6471 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6472 &res->address,(uint8_t)is_on);
6474 printf("bad unicast hash table parameter, return code = %d \n", ret);
6478 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6481 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6484 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6487 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6490 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6491 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6493 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6497 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6498 .f = cmd_set_uc_hash_parsed,
6500 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6502 (void *)&cmd_set_uc_hash_set,
6503 (void *)&cmd_set_uc_hash_port,
6504 (void *)&cmd_set_uc_hash_portid,
6505 (void *)&cmd_set_uc_hash_what,
6506 (void *)&cmd_set_uc_hash_mac,
6507 (void *)&cmd_set_uc_hash_mode,
6512 struct cmd_set_uc_all_hash_table {
6513 cmdline_fixed_string_t set;
6514 cmdline_fixed_string_t port;
6516 cmdline_fixed_string_t what;
6517 cmdline_fixed_string_t value;
6518 cmdline_fixed_string_t mode;
6522 cmd_set_uc_all_hash_parsed(void *parsed_result,
6523 __attribute__((unused)) struct cmdline *cl,
6524 __attribute__((unused)) void *data)
6527 struct cmd_set_uc_all_hash_table *res = parsed_result;
6529 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6531 if ((strcmp(res->what, "uta") == 0) &&
6532 (strcmp(res->value, "all") == 0))
6533 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6535 printf("bad unicast hash table parameter,"
6536 "return code = %d \n", ret);
6539 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6542 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6543 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6545 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6546 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6548 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6551 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6554 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6555 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6558 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6559 .f = cmd_set_uc_all_hash_parsed,
6561 .help_str = "set port <port_id> uta all on|off",
6563 (void *)&cmd_set_uc_all_hash_set,
6564 (void *)&cmd_set_uc_all_hash_port,
6565 (void *)&cmd_set_uc_all_hash_portid,
6566 (void *)&cmd_set_uc_all_hash_what,
6567 (void *)&cmd_set_uc_all_hash_value,
6568 (void *)&cmd_set_uc_all_hash_mode,
6573 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6574 struct cmd_set_vf_macvlan_filter {
6575 cmdline_fixed_string_t set;
6576 cmdline_fixed_string_t port;
6578 cmdline_fixed_string_t vf;
6580 struct ether_addr address;
6581 cmdline_fixed_string_t filter_type;
6582 cmdline_fixed_string_t mode;
6586 cmd_set_vf_macvlan_parsed(void *parsed_result,
6587 __attribute__((unused)) struct cmdline *cl,
6588 __attribute__((unused)) void *data)
6591 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6592 struct rte_eth_mac_filter filter;
6594 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6596 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6598 /* set VF MAC filter */
6602 filter.dst_id = res->vf_id;
6604 if (!strcmp(res->filter_type, "exact-mac"))
6605 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6606 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6607 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6608 else if (!strcmp(res->filter_type, "hashmac"))
6609 filter.filter_type = RTE_MAC_HASH_MATCH;
6610 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6611 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6613 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6616 ret = rte_eth_dev_filter_ctrl(res->port_id,
6617 RTE_ETH_FILTER_MACVLAN,
6621 ret = rte_eth_dev_filter_ctrl(res->port_id,
6622 RTE_ETH_FILTER_MACVLAN,
6623 RTE_ETH_FILTER_DELETE,
6627 printf("bad set MAC hash parameter, return code = %d\n", ret);
6631 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6632 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6634 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6635 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6637 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6638 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6640 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6641 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6643 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6644 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6646 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6647 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6649 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6651 filter_type, "exact-mac#exact-mac-vlan"
6652 "#hashmac#hashmac-vlan");
6653 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6654 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6657 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6658 .f = cmd_set_vf_macvlan_parsed,
6660 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6661 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6662 "Exact match rule: exact match of MAC or MAC and VLAN; "
6663 "hash match rule: hash match of MAC and exact match of VLAN",
6665 (void *)&cmd_set_vf_macvlan_set,
6666 (void *)&cmd_set_vf_macvlan_port,
6667 (void *)&cmd_set_vf_macvlan_portid,
6668 (void *)&cmd_set_vf_macvlan_vf,
6669 (void *)&cmd_set_vf_macvlan_vf_id,
6670 (void *)&cmd_set_vf_macvlan_mac,
6671 (void *)&cmd_set_vf_macvlan_filter_type,
6672 (void *)&cmd_set_vf_macvlan_mode,
6677 #ifdef RTE_LIBRTE_IXGBE_PMD
6678 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6679 struct cmd_set_vf_traffic {
6680 cmdline_fixed_string_t set;
6681 cmdline_fixed_string_t port;
6683 cmdline_fixed_string_t vf;
6685 cmdline_fixed_string_t what;
6686 cmdline_fixed_string_t mode;
6690 cmd_set_vf_traffic_parsed(void *parsed_result,
6691 __attribute__((unused)) struct cmdline *cl,
6692 __attribute__((unused)) void *data)
6694 struct cmd_set_vf_traffic *res = parsed_result;
6695 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6696 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6698 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6701 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6704 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6705 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6707 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6708 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6710 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6711 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6713 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6714 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6716 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6719 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6720 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6723 cmdline_parse_inst_t cmd_set_vf_traffic = {
6724 .f = cmd_set_vf_traffic_parsed,
6726 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6728 (void *)&cmd_setvf_traffic_set,
6729 (void *)&cmd_setvf_traffic_port,
6730 (void *)&cmd_setvf_traffic_portid,
6731 (void *)&cmd_setvf_traffic_vf,
6732 (void *)&cmd_setvf_traffic_vfid,
6733 (void *)&cmd_setvf_traffic_what,
6734 (void *)&cmd_setvf_traffic_mode,
6739 /* *** CONFIGURE VF RECEIVE MODE *** */
6740 struct cmd_set_vf_rxmode {
6741 cmdline_fixed_string_t set;
6742 cmdline_fixed_string_t port;
6744 cmdline_fixed_string_t vf;
6746 cmdline_fixed_string_t what;
6747 cmdline_fixed_string_t mode;
6748 cmdline_fixed_string_t on;
6752 cmd_set_vf_rxmode_parsed(void *parsed_result,
6753 __attribute__((unused)) struct cmdline *cl,
6754 __attribute__((unused)) void *data)
6757 uint16_t rx_mode = 0;
6758 struct cmd_set_vf_rxmode *res = parsed_result;
6760 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6761 if (!strcmp(res->what,"rxmode")) {
6762 if (!strcmp(res->mode, "AUPE"))
6763 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6764 else if (!strcmp(res->mode, "ROPE"))
6765 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6766 else if (!strcmp(res->mode, "BAM"))
6767 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6768 else if (!strncmp(res->mode, "MPE",3))
6769 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6772 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6774 printf("bad VF receive mode parameter, return code = %d \n",
6778 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6779 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6781 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6782 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6784 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6785 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6787 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6790 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6791 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6793 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6794 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6796 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6797 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6798 mode, "AUPE#ROPE#BAM#MPE");
6799 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6800 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6803 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6804 .f = cmd_set_vf_rxmode_parsed,
6806 .help_str = "set port <port_id> vf <vf_id> rxmode "
6807 "AUPE|ROPE|BAM|MPE on|off",
6809 (void *)&cmd_set_vf_rxmode_set,
6810 (void *)&cmd_set_vf_rxmode_port,
6811 (void *)&cmd_set_vf_rxmode_portid,
6812 (void *)&cmd_set_vf_rxmode_vf,
6813 (void *)&cmd_set_vf_rxmode_vfid,
6814 (void *)&cmd_set_vf_rxmode_what,
6815 (void *)&cmd_set_vf_rxmode_mode,
6816 (void *)&cmd_set_vf_rxmode_on,
6822 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6823 struct cmd_vf_mac_addr_result {
6824 cmdline_fixed_string_t mac_addr_cmd;
6825 cmdline_fixed_string_t what;
6826 cmdline_fixed_string_t port;
6828 cmdline_fixed_string_t vf;
6830 struct ether_addr address;
6833 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6834 __attribute__((unused)) struct cmdline *cl,
6835 __attribute__((unused)) void *data)
6837 struct cmd_vf_mac_addr_result *res = parsed_result;
6840 if (strcmp(res->what, "add") == 0)
6841 ret = rte_eth_dev_mac_addr_add(res->port_num,
6842 &res->address, res->vf_num);
6844 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6848 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6849 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6850 mac_addr_cmd,"mac_addr");
6851 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6852 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6854 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6855 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6857 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6858 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6860 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6861 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6863 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6864 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6866 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6867 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6870 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6871 .f = cmd_vf_mac_addr_parsed,
6873 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6874 "Add MAC address filtering for a VF on port_id",
6876 (void *)&cmd_vf_mac_addr_cmd,
6877 (void *)&cmd_vf_mac_addr_what,
6878 (void *)&cmd_vf_mac_addr_port,
6879 (void *)&cmd_vf_mac_addr_portnum,
6880 (void *)&cmd_vf_mac_addr_vf,
6881 (void *)&cmd_vf_mac_addr_vfnum,
6882 (void *)&cmd_vf_mac_addr_addr,
6887 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6888 struct cmd_vf_rx_vlan_filter {
6889 cmdline_fixed_string_t rx_vlan;
6890 cmdline_fixed_string_t what;
6892 cmdline_fixed_string_t port;
6894 cmdline_fixed_string_t vf;
6899 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6900 __attribute__((unused)) struct cmdline *cl,
6901 __attribute__((unused)) void *data)
6903 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6906 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6908 #ifdef RTE_LIBRTE_IXGBE_PMD
6909 if (ret == -ENOTSUP)
6910 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6911 res->vlan_id, res->vf_mask, is_add);
6913 #ifdef RTE_LIBRTE_I40E_PMD
6914 if (ret == -ENOTSUP)
6915 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6916 res->vlan_id, res->vf_mask, is_add);
6923 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6924 res->vlan_id, res->vf_mask);
6927 printf("invalid port_id %d\n", res->port_id);
6930 printf("function not implemented or supported\n");
6933 printf("programming error: (%s)\n", strerror(-ret));
6937 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6938 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6939 rx_vlan, "rx_vlan");
6940 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6941 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6943 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6944 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6946 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6947 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6949 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6950 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6952 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6953 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6955 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6956 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6959 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6960 .f = cmd_vf_rx_vlan_filter_parsed,
6962 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6963 "(vf_mask = hexadecimal VF mask)",
6965 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6966 (void *)&cmd_vf_rx_vlan_filter_what,
6967 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6968 (void *)&cmd_vf_rx_vlan_filter_port,
6969 (void *)&cmd_vf_rx_vlan_filter_portid,
6970 (void *)&cmd_vf_rx_vlan_filter_vf,
6971 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6976 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6977 struct cmd_queue_rate_limit_result {
6978 cmdline_fixed_string_t set;
6979 cmdline_fixed_string_t port;
6981 cmdline_fixed_string_t queue;
6983 cmdline_fixed_string_t rate;
6987 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6988 __attribute__((unused)) struct cmdline *cl,
6989 __attribute__((unused)) void *data)
6991 struct cmd_queue_rate_limit_result *res = parsed_result;
6994 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6995 && (strcmp(res->queue, "queue") == 0)
6996 && (strcmp(res->rate, "rate") == 0))
6997 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7000 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7004 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7005 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7007 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7008 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7010 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7011 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7013 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7014 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7016 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7017 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7019 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7020 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7022 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7023 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7026 cmdline_parse_inst_t cmd_queue_rate_limit = {
7027 .f = cmd_queue_rate_limit_parsed,
7029 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7030 "Set rate limit for a queue on port_id",
7032 (void *)&cmd_queue_rate_limit_set,
7033 (void *)&cmd_queue_rate_limit_port,
7034 (void *)&cmd_queue_rate_limit_portnum,
7035 (void *)&cmd_queue_rate_limit_queue,
7036 (void *)&cmd_queue_rate_limit_queuenum,
7037 (void *)&cmd_queue_rate_limit_rate,
7038 (void *)&cmd_queue_rate_limit_ratenum,
7043 #ifdef RTE_LIBRTE_IXGBE_PMD
7044 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7045 struct cmd_vf_rate_limit_result {
7046 cmdline_fixed_string_t set;
7047 cmdline_fixed_string_t port;
7049 cmdline_fixed_string_t vf;
7051 cmdline_fixed_string_t rate;
7053 cmdline_fixed_string_t q_msk;
7057 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7058 __attribute__((unused)) struct cmdline *cl,
7059 __attribute__((unused)) void *data)
7061 struct cmd_vf_rate_limit_result *res = parsed_result;
7064 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7065 && (strcmp(res->vf, "vf") == 0)
7066 && (strcmp(res->rate, "rate") == 0)
7067 && (strcmp(res->q_msk, "queue_mask") == 0))
7068 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7069 res->rate_num, res->q_msk_val);
7071 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7075 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7076 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7078 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7079 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7081 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7082 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7084 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7085 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7087 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7088 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7090 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7091 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7093 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7094 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7096 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7097 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7098 q_msk, "queue_mask");
7099 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7100 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7103 cmdline_parse_inst_t cmd_vf_rate_limit = {
7104 .f = cmd_vf_rate_limit_parsed,
7106 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7107 "queue_mask <queue_mask_value>: "
7108 "Set rate limit for queues of VF on port_id",
7110 (void *)&cmd_vf_rate_limit_set,
7111 (void *)&cmd_vf_rate_limit_port,
7112 (void *)&cmd_vf_rate_limit_portnum,
7113 (void *)&cmd_vf_rate_limit_vf,
7114 (void *)&cmd_vf_rate_limit_vfnum,
7115 (void *)&cmd_vf_rate_limit_rate,
7116 (void *)&cmd_vf_rate_limit_ratenum,
7117 (void *)&cmd_vf_rate_limit_q_msk,
7118 (void *)&cmd_vf_rate_limit_q_msk_val,
7124 /* *** ADD TUNNEL FILTER OF A PORT *** */
7125 struct cmd_tunnel_filter_result {
7126 cmdline_fixed_string_t cmd;
7127 cmdline_fixed_string_t what;
7129 struct ether_addr outer_mac;
7130 struct ether_addr inner_mac;
7131 cmdline_ipaddr_t ip_value;
7132 uint16_t inner_vlan;
7133 cmdline_fixed_string_t tunnel_type;
7134 cmdline_fixed_string_t filter_type;
7140 cmd_tunnel_filter_parsed(void *parsed_result,
7141 __attribute__((unused)) struct cmdline *cl,
7142 __attribute__((unused)) void *data)
7144 struct cmd_tunnel_filter_result *res = parsed_result;
7145 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7148 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7150 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7151 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7152 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7154 if (res->ip_value.family == AF_INET) {
7155 tunnel_filter_conf.ip_addr.ipv4_addr =
7156 res->ip_value.addr.ipv4.s_addr;
7157 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7159 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7160 &(res->ip_value.addr.ipv6),
7161 sizeof(struct in6_addr));
7162 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7165 if (!strcmp(res->filter_type, "imac-ivlan"))
7166 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7167 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7168 tunnel_filter_conf.filter_type =
7169 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7170 else if (!strcmp(res->filter_type, "imac-tenid"))
7171 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7172 else if (!strcmp(res->filter_type, "imac"))
7173 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7174 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7175 tunnel_filter_conf.filter_type =
7176 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7177 else if (!strcmp(res->filter_type, "oip"))
7178 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7179 else if (!strcmp(res->filter_type, "iip"))
7180 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7182 printf("The filter type is not supported");
7186 if (!strcmp(res->tunnel_type, "vxlan"))
7187 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7188 else if (!strcmp(res->tunnel_type, "nvgre"))
7189 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7190 else if (!strcmp(res->tunnel_type, "ipingre"))
7191 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7193 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7197 tunnel_filter_conf.tenant_id = res->tenant_id;
7198 tunnel_filter_conf.queue_id = res->queue_num;
7199 if (!strcmp(res->what, "add"))
7200 ret = rte_eth_dev_filter_ctrl(res->port_id,
7201 RTE_ETH_FILTER_TUNNEL,
7203 &tunnel_filter_conf);
7205 ret = rte_eth_dev_filter_ctrl(res->port_id,
7206 RTE_ETH_FILTER_TUNNEL,
7207 RTE_ETH_FILTER_DELETE,
7208 &tunnel_filter_conf);
7210 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7214 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7215 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7216 cmd, "tunnel_filter");
7217 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7218 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7220 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7221 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7223 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7224 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7226 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7227 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7229 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7230 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7231 inner_vlan, UINT16);
7232 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7233 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7235 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7236 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7237 tunnel_type, "vxlan#nvgre#ipingre");
7239 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7240 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7241 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7242 "imac#omac-imac-tenid");
7243 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7244 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7246 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7247 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7250 cmdline_parse_inst_t cmd_tunnel_filter = {
7251 .f = cmd_tunnel_filter_parsed,
7253 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7254 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7255 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7256 "<queue_id>: Add/Rm tunnel filter of a port",
7258 (void *)&cmd_tunnel_filter_cmd,
7259 (void *)&cmd_tunnel_filter_what,
7260 (void *)&cmd_tunnel_filter_port_id,
7261 (void *)&cmd_tunnel_filter_outer_mac,
7262 (void *)&cmd_tunnel_filter_inner_mac,
7263 (void *)&cmd_tunnel_filter_ip_value,
7264 (void *)&cmd_tunnel_filter_innner_vlan,
7265 (void *)&cmd_tunnel_filter_tunnel_type,
7266 (void *)&cmd_tunnel_filter_filter_type,
7267 (void *)&cmd_tunnel_filter_tenant_id,
7268 (void *)&cmd_tunnel_filter_queue_num,
7273 /* *** CONFIGURE TUNNEL UDP PORT *** */
7274 struct cmd_tunnel_udp_config {
7275 cmdline_fixed_string_t cmd;
7276 cmdline_fixed_string_t what;
7282 cmd_tunnel_udp_config_parsed(void *parsed_result,
7283 __attribute__((unused)) struct cmdline *cl,
7284 __attribute__((unused)) void *data)
7286 struct cmd_tunnel_udp_config *res = parsed_result;
7287 struct rte_eth_udp_tunnel tunnel_udp;
7290 tunnel_udp.udp_port = res->udp_port;
7292 if (!strcmp(res->cmd, "rx_vxlan_port"))
7293 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7295 if (!strcmp(res->what, "add"))
7296 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7299 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7303 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7306 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7307 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7308 cmd, "rx_vxlan_port");
7309 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7310 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7312 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7313 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7315 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7316 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7319 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7320 .f = cmd_tunnel_udp_config_parsed,
7322 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7323 "Add/Remove a tunneling UDP port filter",
7325 (void *)&cmd_tunnel_udp_config_cmd,
7326 (void *)&cmd_tunnel_udp_config_what,
7327 (void *)&cmd_tunnel_udp_config_udp_port,
7328 (void *)&cmd_tunnel_udp_config_port_id,
7333 /* *** GLOBAL CONFIG *** */
7334 struct cmd_global_config_result {
7335 cmdline_fixed_string_t cmd;
7337 cmdline_fixed_string_t cfg_type;
7342 cmd_global_config_parsed(void *parsed_result,
7343 __attribute__((unused)) struct cmdline *cl,
7344 __attribute__((unused)) void *data)
7346 struct cmd_global_config_result *res = parsed_result;
7347 struct rte_eth_global_cfg conf;
7350 memset(&conf, 0, sizeof(conf));
7351 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7352 conf.cfg.gre_key_len = res->len;
7353 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7354 RTE_ETH_FILTER_SET, &conf);
7356 printf("Global config error\n");
7359 cmdline_parse_token_string_t cmd_global_config_cmd =
7360 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7362 cmdline_parse_token_num_t cmd_global_config_port_id =
7363 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7364 cmdline_parse_token_string_t cmd_global_config_type =
7365 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7366 cfg_type, "gre-key-len");
7367 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7368 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7371 cmdline_parse_inst_t cmd_global_config = {
7372 .f = cmd_global_config_parsed,
7373 .data = (void *)NULL,
7374 .help_str = "global_config <port_id> gre-key-len <key_len>",
7376 (void *)&cmd_global_config_cmd,
7377 (void *)&cmd_global_config_port_id,
7378 (void *)&cmd_global_config_type,
7379 (void *)&cmd_global_config_gre_key_len,
7384 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7385 struct cmd_set_mirror_mask_result {
7386 cmdline_fixed_string_t set;
7387 cmdline_fixed_string_t port;
7389 cmdline_fixed_string_t mirror;
7391 cmdline_fixed_string_t what;
7392 cmdline_fixed_string_t value;
7393 cmdline_fixed_string_t dstpool;
7395 cmdline_fixed_string_t on;
7398 cmdline_parse_token_string_t cmd_mirror_mask_set =
7399 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7401 cmdline_parse_token_string_t cmd_mirror_mask_port =
7402 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7404 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7405 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7407 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7409 mirror, "mirror-rule");
7410 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7411 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7413 cmdline_parse_token_string_t cmd_mirror_mask_what =
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7415 what, "pool-mirror-up#pool-mirror-down"
7417 cmdline_parse_token_string_t cmd_mirror_mask_value =
7418 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7420 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7421 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7422 dstpool, "dst-pool");
7423 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7424 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7426 cmdline_parse_token_string_t cmd_mirror_mask_on =
7427 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7431 cmd_set_mirror_mask_parsed(void *parsed_result,
7432 __attribute__((unused)) struct cmdline *cl,
7433 __attribute__((unused)) void *data)
7436 struct cmd_set_mirror_mask_result *res = parsed_result;
7437 struct rte_eth_mirror_conf mr_conf;
7439 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7441 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7443 mr_conf.dst_pool = res->dstpool_id;
7445 if (!strcmp(res->what, "pool-mirror-up")) {
7446 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7447 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7448 } else if (!strcmp(res->what, "pool-mirror-down")) {
7449 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7450 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7451 } else if (!strcmp(res->what, "vlan-mirror")) {
7452 mr_conf.rule_type = ETH_MIRROR_VLAN;
7453 nb_item = parse_item_list(res->value, "vlan",
7454 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7458 for (i = 0; i < nb_item; i++) {
7459 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7460 printf("Invalid vlan_id: must be < 4096\n");
7464 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7465 mr_conf.vlan.vlan_mask |= 1ULL << i;
7469 if (!strcmp(res->on, "on"))
7470 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7473 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7476 printf("mirror rule add error: (%s)\n", strerror(-ret));
7479 cmdline_parse_inst_t cmd_set_mirror_mask = {
7480 .f = cmd_set_mirror_mask_parsed,
7482 .help_str = "set port <port_id> mirror-rule <rule_id> "
7483 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7484 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7486 (void *)&cmd_mirror_mask_set,
7487 (void *)&cmd_mirror_mask_port,
7488 (void *)&cmd_mirror_mask_portid,
7489 (void *)&cmd_mirror_mask_mirror,
7490 (void *)&cmd_mirror_mask_ruleid,
7491 (void *)&cmd_mirror_mask_what,
7492 (void *)&cmd_mirror_mask_value,
7493 (void *)&cmd_mirror_mask_dstpool,
7494 (void *)&cmd_mirror_mask_poolid,
7495 (void *)&cmd_mirror_mask_on,
7500 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7501 struct cmd_set_mirror_link_result {
7502 cmdline_fixed_string_t set;
7503 cmdline_fixed_string_t port;
7505 cmdline_fixed_string_t mirror;
7507 cmdline_fixed_string_t what;
7508 cmdline_fixed_string_t dstpool;
7510 cmdline_fixed_string_t on;
7513 cmdline_parse_token_string_t cmd_mirror_link_set =
7514 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7516 cmdline_parse_token_string_t cmd_mirror_link_port =
7517 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7519 cmdline_parse_token_num_t cmd_mirror_link_portid =
7520 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7522 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7523 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7524 mirror, "mirror-rule");
7525 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7526 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7528 cmdline_parse_token_string_t cmd_mirror_link_what =
7529 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7530 what, "uplink-mirror#downlink-mirror");
7531 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7532 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7533 dstpool, "dst-pool");
7534 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7535 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7537 cmdline_parse_token_string_t cmd_mirror_link_on =
7538 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7542 cmd_set_mirror_link_parsed(void *parsed_result,
7543 __attribute__((unused)) struct cmdline *cl,
7544 __attribute__((unused)) void *data)
7547 struct cmd_set_mirror_link_result *res = parsed_result;
7548 struct rte_eth_mirror_conf mr_conf;
7550 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7551 if (!strcmp(res->what, "uplink-mirror"))
7552 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7554 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7556 mr_conf.dst_pool = res->dstpool_id;
7558 if (!strcmp(res->on, "on"))
7559 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7562 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7565 /* check the return value and print it if is < 0 */
7567 printf("mirror rule add error: (%s)\n", strerror(-ret));
7571 cmdline_parse_inst_t cmd_set_mirror_link = {
7572 .f = cmd_set_mirror_link_parsed,
7574 .help_str = "set port <port_id> mirror-rule <rule_id> "
7575 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7577 (void *)&cmd_mirror_link_set,
7578 (void *)&cmd_mirror_link_port,
7579 (void *)&cmd_mirror_link_portid,
7580 (void *)&cmd_mirror_link_mirror,
7581 (void *)&cmd_mirror_link_ruleid,
7582 (void *)&cmd_mirror_link_what,
7583 (void *)&cmd_mirror_link_dstpool,
7584 (void *)&cmd_mirror_link_poolid,
7585 (void *)&cmd_mirror_link_on,
7590 /* *** RESET VM MIRROR RULE *** */
7591 struct cmd_rm_mirror_rule_result {
7592 cmdline_fixed_string_t reset;
7593 cmdline_fixed_string_t port;
7595 cmdline_fixed_string_t mirror;
7599 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7600 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7602 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7603 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7605 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7606 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7608 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7609 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7610 mirror, "mirror-rule");
7611 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7612 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7616 cmd_reset_mirror_rule_parsed(void *parsed_result,
7617 __attribute__((unused)) struct cmdline *cl,
7618 __attribute__((unused)) void *data)
7621 struct cmd_set_mirror_link_result *res = parsed_result;
7623 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7625 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7628 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7629 .f = cmd_reset_mirror_rule_parsed,
7631 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7633 (void *)&cmd_rm_mirror_rule_reset,
7634 (void *)&cmd_rm_mirror_rule_port,
7635 (void *)&cmd_rm_mirror_rule_portid,
7636 (void *)&cmd_rm_mirror_rule_mirror,
7637 (void *)&cmd_rm_mirror_rule_ruleid,
7642 /* ******************************************************************************** */
7644 struct cmd_dump_result {
7645 cmdline_fixed_string_t dump;
7649 dump_struct_sizes(void)
7651 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7652 DUMP_SIZE(struct rte_mbuf);
7653 DUMP_SIZE(struct rte_mempool);
7654 DUMP_SIZE(struct rte_ring);
7658 static void cmd_dump_parsed(void *parsed_result,
7659 __attribute__((unused)) struct cmdline *cl,
7660 __attribute__((unused)) void *data)
7662 struct cmd_dump_result *res = parsed_result;
7664 if (!strcmp(res->dump, "dump_physmem"))
7665 rte_dump_physmem_layout(stdout);
7666 else if (!strcmp(res->dump, "dump_memzone"))
7667 rte_memzone_dump(stdout);
7668 else if (!strcmp(res->dump, "dump_struct_sizes"))
7669 dump_struct_sizes();
7670 else if (!strcmp(res->dump, "dump_ring"))
7671 rte_ring_list_dump(stdout);
7672 else if (!strcmp(res->dump, "dump_mempool"))
7673 rte_mempool_list_dump(stdout);
7674 else if (!strcmp(res->dump, "dump_devargs"))
7675 rte_eal_devargs_dump(stdout);
7678 cmdline_parse_token_string_t cmd_dump_dump =
7679 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7682 "dump_struct_sizes#"
7687 cmdline_parse_inst_t cmd_dump = {
7688 .f = cmd_dump_parsed, /* function to call */
7689 .data = NULL, /* 2nd arg of func */
7690 .help_str = "Dump status",
7691 .tokens = { /* token list, NULL terminated */
7692 (void *)&cmd_dump_dump,
7697 /* ******************************************************************************** */
7699 struct cmd_dump_one_result {
7700 cmdline_fixed_string_t dump;
7701 cmdline_fixed_string_t name;
7704 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7705 __attribute__((unused)) void *data)
7707 struct cmd_dump_one_result *res = parsed_result;
7709 if (!strcmp(res->dump, "dump_ring")) {
7711 r = rte_ring_lookup(res->name);
7713 cmdline_printf(cl, "Cannot find ring\n");
7716 rte_ring_dump(stdout, r);
7717 } else if (!strcmp(res->dump, "dump_mempool")) {
7718 struct rte_mempool *mp;
7719 mp = rte_mempool_lookup(res->name);
7721 cmdline_printf(cl, "Cannot find mempool\n");
7724 rte_mempool_dump(stdout, mp);
7728 cmdline_parse_token_string_t cmd_dump_one_dump =
7729 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7730 "dump_ring#dump_mempool");
7732 cmdline_parse_token_string_t cmd_dump_one_name =
7733 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7735 cmdline_parse_inst_t cmd_dump_one = {
7736 .f = cmd_dump_one_parsed, /* function to call */
7737 .data = NULL, /* 2nd arg of func */
7738 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7739 .tokens = { /* token list, NULL terminated */
7740 (void *)&cmd_dump_one_dump,
7741 (void *)&cmd_dump_one_name,
7746 /* *** Add/Del syn filter *** */
7747 struct cmd_syn_filter_result {
7748 cmdline_fixed_string_t filter;
7750 cmdline_fixed_string_t ops;
7751 cmdline_fixed_string_t priority;
7752 cmdline_fixed_string_t high;
7753 cmdline_fixed_string_t queue;
7758 cmd_syn_filter_parsed(void *parsed_result,
7759 __attribute__((unused)) struct cmdline *cl,
7760 __attribute__((unused)) void *data)
7762 struct cmd_syn_filter_result *res = parsed_result;
7763 struct rte_eth_syn_filter syn_filter;
7766 ret = rte_eth_dev_filter_supported(res->port_id,
7767 RTE_ETH_FILTER_SYN);
7769 printf("syn filter is not supported on port %u.\n",
7774 memset(&syn_filter, 0, sizeof(syn_filter));
7776 if (!strcmp(res->ops, "add")) {
7777 if (!strcmp(res->high, "high"))
7778 syn_filter.hig_pri = 1;
7780 syn_filter.hig_pri = 0;
7782 syn_filter.queue = res->queue_id;
7783 ret = rte_eth_dev_filter_ctrl(res->port_id,
7788 ret = rte_eth_dev_filter_ctrl(res->port_id,
7790 RTE_ETH_FILTER_DELETE,
7794 printf("syn filter programming error: (%s)\n",
7798 cmdline_parse_token_string_t cmd_syn_filter_filter =
7799 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7800 filter, "syn_filter");
7801 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7802 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7804 cmdline_parse_token_string_t cmd_syn_filter_ops =
7805 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7807 cmdline_parse_token_string_t cmd_syn_filter_priority =
7808 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7809 priority, "priority");
7810 cmdline_parse_token_string_t cmd_syn_filter_high =
7811 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7813 cmdline_parse_token_string_t cmd_syn_filter_queue =
7814 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7816 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7817 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7820 cmdline_parse_inst_t cmd_syn_filter = {
7821 .f = cmd_syn_filter_parsed,
7823 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7824 "<queue_id>: Add/Delete syn filter",
7826 (void *)&cmd_syn_filter_filter,
7827 (void *)&cmd_syn_filter_port_id,
7828 (void *)&cmd_syn_filter_ops,
7829 (void *)&cmd_syn_filter_priority,
7830 (void *)&cmd_syn_filter_high,
7831 (void *)&cmd_syn_filter_queue,
7832 (void *)&cmd_syn_filter_queue_id,
7837 /* *** ADD/REMOVE A 2tuple FILTER *** */
7838 struct cmd_2tuple_filter_result {
7839 cmdline_fixed_string_t filter;
7841 cmdline_fixed_string_t ops;
7842 cmdline_fixed_string_t dst_port;
7843 uint16_t dst_port_value;
7844 cmdline_fixed_string_t protocol;
7845 uint8_t protocol_value;
7846 cmdline_fixed_string_t mask;
7848 cmdline_fixed_string_t tcp_flags;
7849 uint8_t tcp_flags_value;
7850 cmdline_fixed_string_t priority;
7851 uint8_t priority_value;
7852 cmdline_fixed_string_t queue;
7857 cmd_2tuple_filter_parsed(void *parsed_result,
7858 __attribute__((unused)) struct cmdline *cl,
7859 __attribute__((unused)) void *data)
7861 struct rte_eth_ntuple_filter filter;
7862 struct cmd_2tuple_filter_result *res = parsed_result;
7865 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7867 printf("ntuple filter is not supported on port %u.\n",
7872 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7874 filter.flags = RTE_2TUPLE_FLAGS;
7875 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7876 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7877 filter.proto = res->protocol_value;
7878 filter.priority = res->priority_value;
7879 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7880 printf("nonzero tcp_flags is only meaningful"
7881 " when protocol is TCP.\n");
7884 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7885 printf("invalid TCP flags.\n");
7889 if (res->tcp_flags_value != 0) {
7890 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7891 filter.tcp_flags = res->tcp_flags_value;
7894 /* need convert to big endian. */
7895 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7896 filter.queue = res->queue_id;
7898 if (!strcmp(res->ops, "add"))
7899 ret = rte_eth_dev_filter_ctrl(res->port_id,
7900 RTE_ETH_FILTER_NTUPLE,
7904 ret = rte_eth_dev_filter_ctrl(res->port_id,
7905 RTE_ETH_FILTER_NTUPLE,
7906 RTE_ETH_FILTER_DELETE,
7909 printf("2tuple filter programming error: (%s)\n",
7914 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7915 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7916 filter, "2tuple_filter");
7917 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7918 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7920 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7921 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7923 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7924 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7925 dst_port, "dst_port");
7926 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7927 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7928 dst_port_value, UINT16);
7929 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7930 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7931 protocol, "protocol");
7932 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7933 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7934 protocol_value, UINT8);
7935 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7936 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7938 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7939 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7941 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7942 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7943 tcp_flags, "tcp_flags");
7944 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7945 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7946 tcp_flags_value, UINT8);
7947 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7948 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7949 priority, "priority");
7950 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7951 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7952 priority_value, UINT8);
7953 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7954 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7956 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7957 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7960 cmdline_parse_inst_t cmd_2tuple_filter = {
7961 .f = cmd_2tuple_filter_parsed,
7963 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7964 "<value> mask <value> tcp_flags <value> priority <value> queue "
7965 "<queue_id>: Add a 2tuple filter",
7967 (void *)&cmd_2tuple_filter_filter,
7968 (void *)&cmd_2tuple_filter_port_id,
7969 (void *)&cmd_2tuple_filter_ops,
7970 (void *)&cmd_2tuple_filter_dst_port,
7971 (void *)&cmd_2tuple_filter_dst_port_value,
7972 (void *)&cmd_2tuple_filter_protocol,
7973 (void *)&cmd_2tuple_filter_protocol_value,
7974 (void *)&cmd_2tuple_filter_mask,
7975 (void *)&cmd_2tuple_filter_mask_value,
7976 (void *)&cmd_2tuple_filter_tcp_flags,
7977 (void *)&cmd_2tuple_filter_tcp_flags_value,
7978 (void *)&cmd_2tuple_filter_priority,
7979 (void *)&cmd_2tuple_filter_priority_value,
7980 (void *)&cmd_2tuple_filter_queue,
7981 (void *)&cmd_2tuple_filter_queue_id,
7986 /* *** ADD/REMOVE A 5tuple FILTER *** */
7987 struct cmd_5tuple_filter_result {
7988 cmdline_fixed_string_t filter;
7990 cmdline_fixed_string_t ops;
7991 cmdline_fixed_string_t dst_ip;
7992 cmdline_ipaddr_t dst_ip_value;
7993 cmdline_fixed_string_t src_ip;
7994 cmdline_ipaddr_t src_ip_value;
7995 cmdline_fixed_string_t dst_port;
7996 uint16_t dst_port_value;
7997 cmdline_fixed_string_t src_port;
7998 uint16_t src_port_value;
7999 cmdline_fixed_string_t protocol;
8000 uint8_t protocol_value;
8001 cmdline_fixed_string_t mask;
8003 cmdline_fixed_string_t tcp_flags;
8004 uint8_t tcp_flags_value;
8005 cmdline_fixed_string_t priority;
8006 uint8_t priority_value;
8007 cmdline_fixed_string_t queue;
8012 cmd_5tuple_filter_parsed(void *parsed_result,
8013 __attribute__((unused)) struct cmdline *cl,
8014 __attribute__((unused)) void *data)
8016 struct rte_eth_ntuple_filter filter;
8017 struct cmd_5tuple_filter_result *res = parsed_result;
8020 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8022 printf("ntuple filter is not supported on port %u.\n",
8027 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8029 filter.flags = RTE_5TUPLE_FLAGS;
8030 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8031 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8032 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8033 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8034 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8035 filter.proto = res->protocol_value;
8036 filter.priority = res->priority_value;
8037 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8038 printf("nonzero tcp_flags is only meaningful"
8039 " when protocol is TCP.\n");
8042 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8043 printf("invalid TCP flags.\n");
8047 if (res->tcp_flags_value != 0) {
8048 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8049 filter.tcp_flags = res->tcp_flags_value;
8052 if (res->dst_ip_value.family == AF_INET)
8053 /* no need to convert, already big endian. */
8054 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8056 if (filter.dst_ip_mask == 0) {
8057 printf("can not support ipv6 involved compare.\n");
8063 if (res->src_ip_value.family == AF_INET)
8064 /* no need to convert, already big endian. */
8065 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8067 if (filter.src_ip_mask == 0) {
8068 printf("can not support ipv6 involved compare.\n");
8073 /* need convert to big endian. */
8074 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8075 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8076 filter.queue = res->queue_id;
8078 if (!strcmp(res->ops, "add"))
8079 ret = rte_eth_dev_filter_ctrl(res->port_id,
8080 RTE_ETH_FILTER_NTUPLE,
8084 ret = rte_eth_dev_filter_ctrl(res->port_id,
8085 RTE_ETH_FILTER_NTUPLE,
8086 RTE_ETH_FILTER_DELETE,
8089 printf("5tuple filter programming error: (%s)\n",
8093 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8094 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8095 filter, "5tuple_filter");
8096 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8097 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8099 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8100 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8102 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8103 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8105 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8106 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8108 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8109 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8111 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8112 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8114 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8115 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8116 dst_port, "dst_port");
8117 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8118 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8119 dst_port_value, UINT16);
8120 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8121 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8122 src_port, "src_port");
8123 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8124 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8125 src_port_value, UINT16);
8126 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8127 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8128 protocol, "protocol");
8129 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8130 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8131 protocol_value, UINT8);
8132 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8133 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8135 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8136 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8138 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8139 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8140 tcp_flags, "tcp_flags");
8141 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8142 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8143 tcp_flags_value, UINT8);
8144 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8145 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8146 priority, "priority");
8147 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8148 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8149 priority_value, UINT8);
8150 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8151 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8153 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8154 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8157 cmdline_parse_inst_t cmd_5tuple_filter = {
8158 .f = cmd_5tuple_filter_parsed,
8160 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8161 "src_ip <value> dst_port <value> src_port <value> "
8162 "protocol <value> mask <value> tcp_flags <value> "
8163 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8165 (void *)&cmd_5tuple_filter_filter,
8166 (void *)&cmd_5tuple_filter_port_id,
8167 (void *)&cmd_5tuple_filter_ops,
8168 (void *)&cmd_5tuple_filter_dst_ip,
8169 (void *)&cmd_5tuple_filter_dst_ip_value,
8170 (void *)&cmd_5tuple_filter_src_ip,
8171 (void *)&cmd_5tuple_filter_src_ip_value,
8172 (void *)&cmd_5tuple_filter_dst_port,
8173 (void *)&cmd_5tuple_filter_dst_port_value,
8174 (void *)&cmd_5tuple_filter_src_port,
8175 (void *)&cmd_5tuple_filter_src_port_value,
8176 (void *)&cmd_5tuple_filter_protocol,
8177 (void *)&cmd_5tuple_filter_protocol_value,
8178 (void *)&cmd_5tuple_filter_mask,
8179 (void *)&cmd_5tuple_filter_mask_value,
8180 (void *)&cmd_5tuple_filter_tcp_flags,
8181 (void *)&cmd_5tuple_filter_tcp_flags_value,
8182 (void *)&cmd_5tuple_filter_priority,
8183 (void *)&cmd_5tuple_filter_priority_value,
8184 (void *)&cmd_5tuple_filter_queue,
8185 (void *)&cmd_5tuple_filter_queue_id,
8190 /* *** ADD/REMOVE A flex FILTER *** */
8191 struct cmd_flex_filter_result {
8192 cmdline_fixed_string_t filter;
8193 cmdline_fixed_string_t ops;
8195 cmdline_fixed_string_t len;
8197 cmdline_fixed_string_t bytes;
8198 cmdline_fixed_string_t bytes_value;
8199 cmdline_fixed_string_t mask;
8200 cmdline_fixed_string_t mask_value;
8201 cmdline_fixed_string_t priority;
8202 uint8_t priority_value;
8203 cmdline_fixed_string_t queue;
8207 static int xdigit2val(unsigned char c)
8212 else if (isupper(c))
8220 cmd_flex_filter_parsed(void *parsed_result,
8221 __attribute__((unused)) struct cmdline *cl,
8222 __attribute__((unused)) void *data)
8225 struct rte_eth_flex_filter filter;
8226 struct cmd_flex_filter_result *res = parsed_result;
8227 char *bytes_ptr, *mask_ptr;
8228 uint16_t len, i, j = 0;
8233 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8234 printf("the len exceed the max length 128\n");
8237 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8238 filter.len = res->len_value;
8239 filter.priority = res->priority_value;
8240 filter.queue = res->queue_id;
8241 bytes_ptr = res->bytes_value;
8242 mask_ptr = res->mask_value;
8244 /* translate bytes string to array. */
8245 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8246 (bytes_ptr[1] == 'X')))
8248 len = strnlen(bytes_ptr, res->len_value * 2);
8249 if (len == 0 || (len % 8 != 0)) {
8250 printf("please check len and bytes input\n");
8253 for (i = 0; i < len; i++) {
8255 if (isxdigit(c) == 0) {
8256 /* invalid characters. */
8257 printf("invalid input\n");
8260 val = xdigit2val(c);
8263 filter.bytes[j] = byte;
8264 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8271 /* translate mask string to uint8_t array. */
8272 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8273 (mask_ptr[1] == 'X')))
8275 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8277 printf("invalid input\n");
8282 for (i = 0; i < len; i++) {
8284 if (isxdigit(c) == 0) {
8285 /* invalid characters. */
8286 printf("invalid input\n");
8289 val = xdigit2val(c);
8292 filter.mask[j] = byte;
8293 printf("mask[%d]:%02x ", j, filter.mask[j]);
8301 if (!strcmp(res->ops, "add"))
8302 ret = rte_eth_dev_filter_ctrl(res->port_id,
8303 RTE_ETH_FILTER_FLEXIBLE,
8307 ret = rte_eth_dev_filter_ctrl(res->port_id,
8308 RTE_ETH_FILTER_FLEXIBLE,
8309 RTE_ETH_FILTER_DELETE,
8313 printf("flex filter setting error: (%s)\n", strerror(-ret));
8316 cmdline_parse_token_string_t cmd_flex_filter_filter =
8317 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8318 filter, "flex_filter");
8319 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8320 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8322 cmdline_parse_token_string_t cmd_flex_filter_ops =
8323 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8325 cmdline_parse_token_string_t cmd_flex_filter_len =
8326 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8328 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8329 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8331 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8332 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8334 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8335 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8337 cmdline_parse_token_string_t cmd_flex_filter_mask =
8338 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8340 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8341 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8343 cmdline_parse_token_string_t cmd_flex_filter_priority =
8344 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8345 priority, "priority");
8346 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8347 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8348 priority_value, UINT8);
8349 cmdline_parse_token_string_t cmd_flex_filter_queue =
8350 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8352 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8353 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8355 cmdline_parse_inst_t cmd_flex_filter = {
8356 .f = cmd_flex_filter_parsed,
8358 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8359 "<value> mask <value> priority <value> queue <queue_id>: "
8360 "Add/Del a flex filter",
8362 (void *)&cmd_flex_filter_filter,
8363 (void *)&cmd_flex_filter_port_id,
8364 (void *)&cmd_flex_filter_ops,
8365 (void *)&cmd_flex_filter_len,
8366 (void *)&cmd_flex_filter_len_value,
8367 (void *)&cmd_flex_filter_bytes,
8368 (void *)&cmd_flex_filter_bytes_value,
8369 (void *)&cmd_flex_filter_mask,
8370 (void *)&cmd_flex_filter_mask_value,
8371 (void *)&cmd_flex_filter_priority,
8372 (void *)&cmd_flex_filter_priority_value,
8373 (void *)&cmd_flex_filter_queue,
8374 (void *)&cmd_flex_filter_queue_id,
8379 /* *** Filters Control *** */
8381 /* *** deal with ethertype filter *** */
8382 struct cmd_ethertype_filter_result {
8383 cmdline_fixed_string_t filter;
8385 cmdline_fixed_string_t ops;
8386 cmdline_fixed_string_t mac;
8387 struct ether_addr mac_addr;
8388 cmdline_fixed_string_t ethertype;
8389 uint16_t ethertype_value;
8390 cmdline_fixed_string_t drop;
8391 cmdline_fixed_string_t queue;
8395 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8396 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8397 filter, "ethertype_filter");
8398 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8399 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8401 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8402 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8404 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8405 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8406 mac, "mac_addr#mac_ignr");
8407 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8408 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8410 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8411 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8412 ethertype, "ethertype");
8413 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8414 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8415 ethertype_value, UINT16);
8416 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8417 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8419 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8420 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8422 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8423 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8427 cmd_ethertype_filter_parsed(void *parsed_result,
8428 __attribute__((unused)) struct cmdline *cl,
8429 __attribute__((unused)) void *data)
8431 struct cmd_ethertype_filter_result *res = parsed_result;
8432 struct rte_eth_ethertype_filter filter;
8435 ret = rte_eth_dev_filter_supported(res->port_id,
8436 RTE_ETH_FILTER_ETHERTYPE);
8438 printf("ethertype filter is not supported on port %u.\n",
8443 memset(&filter, 0, sizeof(filter));
8444 if (!strcmp(res->mac, "mac_addr")) {
8445 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8446 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8447 sizeof(struct ether_addr));
8449 if (!strcmp(res->drop, "drop"))
8450 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8451 filter.ether_type = res->ethertype_value;
8452 filter.queue = res->queue_id;
8454 if (!strcmp(res->ops, "add"))
8455 ret = rte_eth_dev_filter_ctrl(res->port_id,
8456 RTE_ETH_FILTER_ETHERTYPE,
8460 ret = rte_eth_dev_filter_ctrl(res->port_id,
8461 RTE_ETH_FILTER_ETHERTYPE,
8462 RTE_ETH_FILTER_DELETE,
8465 printf("ethertype filter programming error: (%s)\n",
8469 cmdline_parse_inst_t cmd_ethertype_filter = {
8470 .f = cmd_ethertype_filter_parsed,
8472 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8473 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8474 "Add or delete an ethertype filter entry",
8476 (void *)&cmd_ethertype_filter_filter,
8477 (void *)&cmd_ethertype_filter_port_id,
8478 (void *)&cmd_ethertype_filter_ops,
8479 (void *)&cmd_ethertype_filter_mac,
8480 (void *)&cmd_ethertype_filter_mac_addr,
8481 (void *)&cmd_ethertype_filter_ethertype,
8482 (void *)&cmd_ethertype_filter_ethertype_value,
8483 (void *)&cmd_ethertype_filter_drop,
8484 (void *)&cmd_ethertype_filter_queue,
8485 (void *)&cmd_ethertype_filter_queue_id,
8490 /* *** deal with flow director filter *** */
8491 struct cmd_flow_director_result {
8492 cmdline_fixed_string_t flow_director_filter;
8494 cmdline_fixed_string_t mode;
8495 cmdline_fixed_string_t mode_value;
8496 cmdline_fixed_string_t ops;
8497 cmdline_fixed_string_t flow;
8498 cmdline_fixed_string_t flow_type;
8499 cmdline_fixed_string_t ether;
8500 uint16_t ether_type;
8501 cmdline_fixed_string_t src;
8502 cmdline_ipaddr_t ip_src;
8504 cmdline_fixed_string_t dst;
8505 cmdline_ipaddr_t ip_dst;
8507 cmdline_fixed_string_t verify_tag;
8508 uint32_t verify_tag_value;
8509 cmdline_ipaddr_t tos;
8511 cmdline_ipaddr_t proto;
8512 uint8_t proto_value;
8513 cmdline_ipaddr_t ttl;
8515 cmdline_fixed_string_t vlan;
8516 uint16_t vlan_value;
8517 cmdline_fixed_string_t flexbytes;
8518 cmdline_fixed_string_t flexbytes_value;
8519 cmdline_fixed_string_t pf_vf;
8520 cmdline_fixed_string_t drop;
8521 cmdline_fixed_string_t queue;
8523 cmdline_fixed_string_t fd_id;
8524 uint32_t fd_id_value;
8525 cmdline_fixed_string_t mac;
8526 struct ether_addr mac_addr;
8527 cmdline_fixed_string_t tunnel;
8528 cmdline_fixed_string_t tunnel_type;
8529 cmdline_fixed_string_t tunnel_id;
8530 uint32_t tunnel_id_value;
8534 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8537 const char *p, *p0 = q_arg;
8539 unsigned long int_fld;
8540 char *str_fld[max_num];
8545 p = strchr(p0, '(');
8549 p0 = strchr(p, ')');
8554 if (size >= sizeof(s))
8557 snprintf(s, sizeof(s), "%.*s", size, p);
8558 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8559 if (ret < 0 || ret > max_num)
8561 for (i = 0; i < ret; i++) {
8563 int_fld = strtoul(str_fld[i], &end, 0);
8564 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8566 flexbytes[i] = (uint8_t)int_fld;
8572 str2flowtype(char *string)
8575 static const struct {
8578 } flowtype_str[] = {
8579 {"raw", RTE_ETH_FLOW_RAW},
8580 {"ipv4", RTE_ETH_FLOW_IPV4},
8581 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8582 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8583 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8584 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8585 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8586 {"ipv6", RTE_ETH_FLOW_IPV6},
8587 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8588 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8589 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8590 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8591 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8592 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8595 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8596 if (!strcmp(flowtype_str[i].str, string))
8597 return flowtype_str[i].type;
8599 return RTE_ETH_FLOW_UNKNOWN;
8602 static enum rte_eth_fdir_tunnel_type
8603 str2fdir_tunneltype(char *string)
8607 static const struct {
8609 enum rte_eth_fdir_tunnel_type type;
8610 } tunneltype_str[] = {
8611 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8612 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8615 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8616 if (!strcmp(tunneltype_str[i].str, string))
8617 return tunneltype_str[i].type;
8619 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8622 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8624 if ((ip_addr).family == AF_INET) \
8625 (ip) = (ip_addr).addr.ipv4.s_addr; \
8627 printf("invalid parameter.\n"); \
8632 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8634 if ((ip_addr).family == AF_INET6) \
8635 (void)rte_memcpy(&(ip), \
8636 &((ip_addr).addr.ipv6), \
8637 sizeof(struct in6_addr)); \
8639 printf("invalid parameter.\n"); \
8645 cmd_flow_director_filter_parsed(void *parsed_result,
8646 __attribute__((unused)) struct cmdline *cl,
8647 __attribute__((unused)) void *data)
8649 struct cmd_flow_director_result *res = parsed_result;
8650 struct rte_eth_fdir_filter entry;
8651 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8653 unsigned long vf_id;
8656 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8658 printf("flow director is not supported on port %u.\n",
8662 memset(flexbytes, 0, sizeof(flexbytes));
8663 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8665 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8666 if (strcmp(res->mode_value, "MAC-VLAN")) {
8667 printf("Please set mode to MAC-VLAN.\n");
8670 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8671 if (strcmp(res->mode_value, "Tunnel")) {
8672 printf("Please set mode to Tunnel.\n");
8676 if (strcmp(res->mode_value, "IP")) {
8677 printf("Please set mode to IP.\n");
8680 entry.input.flow_type = str2flowtype(res->flow_type);
8683 ret = parse_flexbytes(res->flexbytes_value,
8685 RTE_ETH_FDIR_MAX_FLEXLEN);
8687 printf("error: Cannot parse flexbytes input.\n");
8691 switch (entry.input.flow_type) {
8692 case RTE_ETH_FLOW_FRAG_IPV4:
8693 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8694 entry.input.flow.ip4_flow.proto = res->proto_value;
8695 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8696 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8697 IPV4_ADDR_TO_UINT(res->ip_dst,
8698 entry.input.flow.ip4_flow.dst_ip);
8699 IPV4_ADDR_TO_UINT(res->ip_src,
8700 entry.input.flow.ip4_flow.src_ip);
8701 entry.input.flow.ip4_flow.tos = res->tos_value;
8702 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8703 /* need convert to big endian. */
8704 entry.input.flow.udp4_flow.dst_port =
8705 rte_cpu_to_be_16(res->port_dst);
8706 entry.input.flow.udp4_flow.src_port =
8707 rte_cpu_to_be_16(res->port_src);
8709 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8710 IPV4_ADDR_TO_UINT(res->ip_dst,
8711 entry.input.flow.sctp4_flow.ip.dst_ip);
8712 IPV4_ADDR_TO_UINT(res->ip_src,
8713 entry.input.flow.sctp4_flow.ip.src_ip);
8714 entry.input.flow.ip4_flow.tos = res->tos_value;
8715 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8716 /* need convert to big endian. */
8717 entry.input.flow.sctp4_flow.dst_port =
8718 rte_cpu_to_be_16(res->port_dst);
8719 entry.input.flow.sctp4_flow.src_port =
8720 rte_cpu_to_be_16(res->port_src);
8721 entry.input.flow.sctp4_flow.verify_tag =
8722 rte_cpu_to_be_32(res->verify_tag_value);
8724 case RTE_ETH_FLOW_FRAG_IPV6:
8725 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8726 entry.input.flow.ipv6_flow.proto = res->proto_value;
8727 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8728 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8729 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8730 entry.input.flow.ipv6_flow.dst_ip);
8731 IPV6_ADDR_TO_ARRAY(res->ip_src,
8732 entry.input.flow.ipv6_flow.src_ip);
8733 entry.input.flow.ipv6_flow.tc = res->tos_value;
8734 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8735 /* need convert to big endian. */
8736 entry.input.flow.udp6_flow.dst_port =
8737 rte_cpu_to_be_16(res->port_dst);
8738 entry.input.flow.udp6_flow.src_port =
8739 rte_cpu_to_be_16(res->port_src);
8741 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8742 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8743 entry.input.flow.sctp6_flow.ip.dst_ip);
8744 IPV6_ADDR_TO_ARRAY(res->ip_src,
8745 entry.input.flow.sctp6_flow.ip.src_ip);
8746 entry.input.flow.ipv6_flow.tc = res->tos_value;
8747 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8748 /* need convert to big endian. */
8749 entry.input.flow.sctp6_flow.dst_port =
8750 rte_cpu_to_be_16(res->port_dst);
8751 entry.input.flow.sctp6_flow.src_port =
8752 rte_cpu_to_be_16(res->port_src);
8753 entry.input.flow.sctp6_flow.verify_tag =
8754 rte_cpu_to_be_32(res->verify_tag_value);
8756 case RTE_ETH_FLOW_L2_PAYLOAD:
8757 entry.input.flow.l2_flow.ether_type =
8758 rte_cpu_to_be_16(res->ether_type);
8764 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8765 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8767 sizeof(struct ether_addr));
8769 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8770 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8772 sizeof(struct ether_addr));
8773 entry.input.flow.tunnel_flow.tunnel_type =
8774 str2fdir_tunneltype(res->tunnel_type);
8775 entry.input.flow.tunnel_flow.tunnel_id =
8776 rte_cpu_to_be_32(res->tunnel_id_value);
8779 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8781 RTE_ETH_FDIR_MAX_FLEXLEN);
8783 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8785 entry.action.flex_off = 0; /*use 0 by default */
8786 if (!strcmp(res->drop, "drop"))
8787 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8789 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8791 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8792 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8793 if (!strcmp(res->pf_vf, "pf"))
8794 entry.input.flow_ext.is_vf = 0;
8795 else if (!strncmp(res->pf_vf, "vf", 2)) {
8796 struct rte_eth_dev_info dev_info;
8798 memset(&dev_info, 0, sizeof(dev_info));
8799 rte_eth_dev_info_get(res->port_id, &dev_info);
8801 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8802 if (errno != 0 || *end != '\0' ||
8803 vf_id >= dev_info.max_vfs) {
8804 printf("invalid parameter %s.\n", res->pf_vf);
8807 entry.input.flow_ext.is_vf = 1;
8808 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8810 printf("invalid parameter %s.\n", res->pf_vf);
8815 /* set to report FD ID by default */
8816 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8817 entry.action.rx_queue = res->queue_id;
8818 entry.soft_id = res->fd_id_value;
8819 if (!strcmp(res->ops, "add"))
8820 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8821 RTE_ETH_FILTER_ADD, &entry);
8822 else if (!strcmp(res->ops, "del"))
8823 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8824 RTE_ETH_FILTER_DELETE, &entry);
8826 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8827 RTE_ETH_FILTER_UPDATE, &entry);
8829 printf("flow director programming error: (%s)\n",
8833 cmdline_parse_token_string_t cmd_flow_director_filter =
8834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8835 flow_director_filter, "flow_director_filter");
8836 cmdline_parse_token_num_t cmd_flow_director_port_id =
8837 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8839 cmdline_parse_token_string_t cmd_flow_director_ops =
8840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8841 ops, "add#del#update");
8842 cmdline_parse_token_string_t cmd_flow_director_flow =
8843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8845 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8847 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8848 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8849 cmdline_parse_token_string_t cmd_flow_director_ether =
8850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8852 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8853 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8854 ether_type, UINT16);
8855 cmdline_parse_token_string_t cmd_flow_director_src =
8856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8858 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8859 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8861 cmdline_parse_token_num_t cmd_flow_director_port_src =
8862 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8864 cmdline_parse_token_string_t cmd_flow_director_dst =
8865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8867 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8868 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8870 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8871 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8873 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8875 verify_tag, "verify_tag");
8876 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8877 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8878 verify_tag_value, UINT32);
8879 cmdline_parse_token_string_t cmd_flow_director_tos =
8880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8882 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8883 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8885 cmdline_parse_token_string_t cmd_flow_director_proto =
8886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8888 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8889 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8890 proto_value, UINT8);
8891 cmdline_parse_token_string_t cmd_flow_director_ttl =
8892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8894 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8895 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8897 cmdline_parse_token_string_t cmd_flow_director_vlan =
8898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8900 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8901 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8902 vlan_value, UINT16);
8903 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8905 flexbytes, "flexbytes");
8906 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8908 flexbytes_value, NULL);
8909 cmdline_parse_token_string_t cmd_flow_director_drop =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8912 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8915 cmdline_parse_token_string_t cmd_flow_director_queue =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8918 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8919 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8921 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8925 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8926 fd_id_value, UINT32);
8928 cmdline_parse_token_string_t cmd_flow_director_mode =
8929 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8931 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8932 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8934 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8935 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8936 mode_value, "MAC-VLAN");
8937 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8938 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8939 mode_value, "Tunnel");
8940 cmdline_parse_token_string_t cmd_flow_director_mac =
8941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8943 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8944 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8946 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8949 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8951 tunnel_type, "NVGRE#VxLAN");
8952 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8954 tunnel_id, "tunnel-id");
8955 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8956 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8957 tunnel_id_value, UINT32);
8959 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8960 .f = cmd_flow_director_filter_parsed,
8962 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8963 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8964 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8965 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8966 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8967 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8968 "fd_id <fd_id_value>: "
8969 "Add or delete an ip flow director entry on NIC",
8971 (void *)&cmd_flow_director_filter,
8972 (void *)&cmd_flow_director_port_id,
8973 (void *)&cmd_flow_director_mode,
8974 (void *)&cmd_flow_director_mode_ip,
8975 (void *)&cmd_flow_director_ops,
8976 (void *)&cmd_flow_director_flow,
8977 (void *)&cmd_flow_director_flow_type,
8978 (void *)&cmd_flow_director_src,
8979 (void *)&cmd_flow_director_ip_src,
8980 (void *)&cmd_flow_director_dst,
8981 (void *)&cmd_flow_director_ip_dst,
8982 (void *)&cmd_flow_director_tos,
8983 (void *)&cmd_flow_director_tos_value,
8984 (void *)&cmd_flow_director_proto,
8985 (void *)&cmd_flow_director_proto_value,
8986 (void *)&cmd_flow_director_ttl,
8987 (void *)&cmd_flow_director_ttl_value,
8988 (void *)&cmd_flow_director_vlan,
8989 (void *)&cmd_flow_director_vlan_value,
8990 (void *)&cmd_flow_director_flexbytes,
8991 (void *)&cmd_flow_director_flexbytes_value,
8992 (void *)&cmd_flow_director_drop,
8993 (void *)&cmd_flow_director_pf_vf,
8994 (void *)&cmd_flow_director_queue,
8995 (void *)&cmd_flow_director_queue_id,
8996 (void *)&cmd_flow_director_fd_id,
8997 (void *)&cmd_flow_director_fd_id_value,
9002 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9003 .f = cmd_flow_director_filter_parsed,
9005 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9006 "director entry on NIC",
9008 (void *)&cmd_flow_director_filter,
9009 (void *)&cmd_flow_director_port_id,
9010 (void *)&cmd_flow_director_mode,
9011 (void *)&cmd_flow_director_mode_ip,
9012 (void *)&cmd_flow_director_ops,
9013 (void *)&cmd_flow_director_flow,
9014 (void *)&cmd_flow_director_flow_type,
9015 (void *)&cmd_flow_director_src,
9016 (void *)&cmd_flow_director_ip_src,
9017 (void *)&cmd_flow_director_port_src,
9018 (void *)&cmd_flow_director_dst,
9019 (void *)&cmd_flow_director_ip_dst,
9020 (void *)&cmd_flow_director_port_dst,
9021 (void *)&cmd_flow_director_tos,
9022 (void *)&cmd_flow_director_tos_value,
9023 (void *)&cmd_flow_director_ttl,
9024 (void *)&cmd_flow_director_ttl_value,
9025 (void *)&cmd_flow_director_vlan,
9026 (void *)&cmd_flow_director_vlan_value,
9027 (void *)&cmd_flow_director_flexbytes,
9028 (void *)&cmd_flow_director_flexbytes_value,
9029 (void *)&cmd_flow_director_drop,
9030 (void *)&cmd_flow_director_pf_vf,
9031 (void *)&cmd_flow_director_queue,
9032 (void *)&cmd_flow_director_queue_id,
9033 (void *)&cmd_flow_director_fd_id,
9034 (void *)&cmd_flow_director_fd_id_value,
9039 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9040 .f = cmd_flow_director_filter_parsed,
9042 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9043 "director entry on NIC",
9045 (void *)&cmd_flow_director_filter,
9046 (void *)&cmd_flow_director_port_id,
9047 (void *)&cmd_flow_director_mode,
9048 (void *)&cmd_flow_director_mode_ip,
9049 (void *)&cmd_flow_director_ops,
9050 (void *)&cmd_flow_director_flow,
9051 (void *)&cmd_flow_director_flow_type,
9052 (void *)&cmd_flow_director_src,
9053 (void *)&cmd_flow_director_ip_src,
9054 (void *)&cmd_flow_director_port_dst,
9055 (void *)&cmd_flow_director_dst,
9056 (void *)&cmd_flow_director_ip_dst,
9057 (void *)&cmd_flow_director_port_dst,
9058 (void *)&cmd_flow_director_verify_tag,
9059 (void *)&cmd_flow_director_verify_tag_value,
9060 (void *)&cmd_flow_director_tos,
9061 (void *)&cmd_flow_director_tos_value,
9062 (void *)&cmd_flow_director_ttl,
9063 (void *)&cmd_flow_director_ttl_value,
9064 (void *)&cmd_flow_director_vlan,
9065 (void *)&cmd_flow_director_vlan_value,
9066 (void *)&cmd_flow_director_flexbytes,
9067 (void *)&cmd_flow_director_flexbytes_value,
9068 (void *)&cmd_flow_director_drop,
9069 (void *)&cmd_flow_director_pf_vf,
9070 (void *)&cmd_flow_director_queue,
9071 (void *)&cmd_flow_director_queue_id,
9072 (void *)&cmd_flow_director_fd_id,
9073 (void *)&cmd_flow_director_fd_id_value,
9078 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9079 .f = cmd_flow_director_filter_parsed,
9081 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9082 "director entry on NIC",
9084 (void *)&cmd_flow_director_filter,
9085 (void *)&cmd_flow_director_port_id,
9086 (void *)&cmd_flow_director_mode,
9087 (void *)&cmd_flow_director_mode_ip,
9088 (void *)&cmd_flow_director_ops,
9089 (void *)&cmd_flow_director_flow,
9090 (void *)&cmd_flow_director_flow_type,
9091 (void *)&cmd_flow_director_ether,
9092 (void *)&cmd_flow_director_ether_type,
9093 (void *)&cmd_flow_director_flexbytes,
9094 (void *)&cmd_flow_director_flexbytes_value,
9095 (void *)&cmd_flow_director_drop,
9096 (void *)&cmd_flow_director_pf_vf,
9097 (void *)&cmd_flow_director_queue,
9098 (void *)&cmd_flow_director_queue_id,
9099 (void *)&cmd_flow_director_fd_id,
9100 (void *)&cmd_flow_director_fd_id_value,
9105 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9106 .f = cmd_flow_director_filter_parsed,
9108 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9109 "director entry on NIC",
9111 (void *)&cmd_flow_director_filter,
9112 (void *)&cmd_flow_director_port_id,
9113 (void *)&cmd_flow_director_mode,
9114 (void *)&cmd_flow_director_mode_mac_vlan,
9115 (void *)&cmd_flow_director_ops,
9116 (void *)&cmd_flow_director_mac,
9117 (void *)&cmd_flow_director_mac_addr,
9118 (void *)&cmd_flow_director_vlan,
9119 (void *)&cmd_flow_director_vlan_value,
9120 (void *)&cmd_flow_director_flexbytes,
9121 (void *)&cmd_flow_director_flexbytes_value,
9122 (void *)&cmd_flow_director_drop,
9123 (void *)&cmd_flow_director_queue,
9124 (void *)&cmd_flow_director_queue_id,
9125 (void *)&cmd_flow_director_fd_id,
9126 (void *)&cmd_flow_director_fd_id_value,
9131 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9132 .f = cmd_flow_director_filter_parsed,
9134 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9135 "director entry on NIC",
9137 (void *)&cmd_flow_director_filter,
9138 (void *)&cmd_flow_director_port_id,
9139 (void *)&cmd_flow_director_mode,
9140 (void *)&cmd_flow_director_mode_tunnel,
9141 (void *)&cmd_flow_director_ops,
9142 (void *)&cmd_flow_director_mac,
9143 (void *)&cmd_flow_director_mac_addr,
9144 (void *)&cmd_flow_director_vlan,
9145 (void *)&cmd_flow_director_vlan_value,
9146 (void *)&cmd_flow_director_tunnel,
9147 (void *)&cmd_flow_director_tunnel_type,
9148 (void *)&cmd_flow_director_tunnel_id,
9149 (void *)&cmd_flow_director_tunnel_id_value,
9150 (void *)&cmd_flow_director_flexbytes,
9151 (void *)&cmd_flow_director_flexbytes_value,
9152 (void *)&cmd_flow_director_drop,
9153 (void *)&cmd_flow_director_queue,
9154 (void *)&cmd_flow_director_queue_id,
9155 (void *)&cmd_flow_director_fd_id,
9156 (void *)&cmd_flow_director_fd_id_value,
9161 struct cmd_flush_flow_director_result {
9162 cmdline_fixed_string_t flush_flow_director;
9166 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9167 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9168 flush_flow_director, "flush_flow_director");
9169 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9170 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9174 cmd_flush_flow_director_parsed(void *parsed_result,
9175 __attribute__((unused)) struct cmdline *cl,
9176 __attribute__((unused)) void *data)
9178 struct cmd_flow_director_result *res = parsed_result;
9181 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9183 printf("flow director is not supported on port %u.\n",
9188 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9189 RTE_ETH_FILTER_FLUSH, NULL);
9191 printf("flow director table flushing error: (%s)\n",
9195 cmdline_parse_inst_t cmd_flush_flow_director = {
9196 .f = cmd_flush_flow_director_parsed,
9198 .help_str = "flush_flow_director <port_id>: "
9199 "Flush all flow director entries of a device on NIC",
9201 (void *)&cmd_flush_flow_director_flush,
9202 (void *)&cmd_flush_flow_director_port_id,
9207 /* *** deal with flow director mask *** */
9208 struct cmd_flow_director_mask_result {
9209 cmdline_fixed_string_t flow_director_mask;
9211 cmdline_fixed_string_t mode;
9212 cmdline_fixed_string_t mode_value;
9213 cmdline_fixed_string_t vlan;
9215 cmdline_fixed_string_t src_mask;
9216 cmdline_ipaddr_t ipv4_src;
9217 cmdline_ipaddr_t ipv6_src;
9219 cmdline_fixed_string_t dst_mask;
9220 cmdline_ipaddr_t ipv4_dst;
9221 cmdline_ipaddr_t ipv6_dst;
9223 cmdline_fixed_string_t mac;
9224 uint8_t mac_addr_byte_mask;
9225 cmdline_fixed_string_t tunnel_id;
9226 uint32_t tunnel_id_mask;
9227 cmdline_fixed_string_t tunnel_type;
9228 uint8_t tunnel_type_mask;
9232 cmd_flow_director_mask_parsed(void *parsed_result,
9233 __attribute__((unused)) struct cmdline *cl,
9234 __attribute__((unused)) void *data)
9236 struct cmd_flow_director_mask_result *res = parsed_result;
9237 struct rte_eth_fdir_masks *mask;
9238 struct rte_port *port;
9240 if (res->port_id > nb_ports) {
9241 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9245 port = &ports[res->port_id];
9246 /** Check if the port is not started **/
9247 if (port->port_status != RTE_PORT_STOPPED) {
9248 printf("Please stop port %d first\n", res->port_id);
9252 mask = &port->dev_conf.fdir_conf.mask;
9254 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9255 if (strcmp(res->mode_value, "MAC-VLAN")) {
9256 printf("Please set mode to MAC-VLAN.\n");
9260 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9261 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9262 if (strcmp(res->mode_value, "Tunnel")) {
9263 printf("Please set mode to Tunnel.\n");
9267 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9268 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9269 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9270 mask->tunnel_type_mask = res->tunnel_type_mask;
9272 if (strcmp(res->mode_value, "IP")) {
9273 printf("Please set mode to IP.\n");
9277 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9278 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9279 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9280 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9281 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9282 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9283 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9286 cmd_reconfig_device_queue(res->port_id, 1, 1);
9289 cmdline_parse_token_string_t cmd_flow_director_mask =
9290 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9291 flow_director_mask, "flow_director_mask");
9292 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9293 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9295 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9298 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9299 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9301 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9303 src_mask, "src_mask");
9304 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9305 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9307 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9308 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9310 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9311 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9313 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9314 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9315 dst_mask, "dst_mask");
9316 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9317 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9319 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9320 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9322 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9323 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9326 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9329 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9330 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9332 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9334 mode_value, "MAC-VLAN");
9335 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9337 mode_value, "Tunnel");
9338 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9341 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9342 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9343 mac_addr_byte_mask, UINT8);
9344 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9346 tunnel_type, "tunnel-type");
9347 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9348 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9349 tunnel_type_mask, UINT8);
9350 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9352 tunnel_id, "tunnel-id");
9353 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9354 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9355 tunnel_id_mask, UINT32);
9357 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9358 .f = cmd_flow_director_mask_parsed,
9360 .help_str = "flow_director_mask ... : "
9361 "Set IP mode flow director's mask on NIC",
9363 (void *)&cmd_flow_director_mask,
9364 (void *)&cmd_flow_director_mask_port_id,
9365 (void *)&cmd_flow_director_mask_mode,
9366 (void *)&cmd_flow_director_mask_mode_ip,
9367 (void *)&cmd_flow_director_mask_vlan,
9368 (void *)&cmd_flow_director_mask_vlan_value,
9369 (void *)&cmd_flow_director_mask_src,
9370 (void *)&cmd_flow_director_mask_ipv4_src,
9371 (void *)&cmd_flow_director_mask_ipv6_src,
9372 (void *)&cmd_flow_director_mask_port_src,
9373 (void *)&cmd_flow_director_mask_dst,
9374 (void *)&cmd_flow_director_mask_ipv4_dst,
9375 (void *)&cmd_flow_director_mask_ipv6_dst,
9376 (void *)&cmd_flow_director_mask_port_dst,
9381 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9382 .f = cmd_flow_director_mask_parsed,
9384 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9385 "flow director's mask on NIC",
9387 (void *)&cmd_flow_director_mask,
9388 (void *)&cmd_flow_director_mask_port_id,
9389 (void *)&cmd_flow_director_mask_mode,
9390 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9391 (void *)&cmd_flow_director_mask_vlan,
9392 (void *)&cmd_flow_director_mask_vlan_value,
9397 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9398 .f = cmd_flow_director_mask_parsed,
9400 .help_str = "flow_director_mask ... : Set tunnel mode "
9401 "flow director's mask on NIC",
9403 (void *)&cmd_flow_director_mask,
9404 (void *)&cmd_flow_director_mask_port_id,
9405 (void *)&cmd_flow_director_mask_mode,
9406 (void *)&cmd_flow_director_mask_mode_tunnel,
9407 (void *)&cmd_flow_director_mask_vlan,
9408 (void *)&cmd_flow_director_mask_vlan_value,
9409 (void *)&cmd_flow_director_mask_mac,
9410 (void *)&cmd_flow_director_mask_mac_value,
9411 (void *)&cmd_flow_director_mask_tunnel_type,
9412 (void *)&cmd_flow_director_mask_tunnel_type_value,
9413 (void *)&cmd_flow_director_mask_tunnel_id,
9414 (void *)&cmd_flow_director_mask_tunnel_id_value,
9419 /* *** deal with flow director mask on flexible payload *** */
9420 struct cmd_flow_director_flex_mask_result {
9421 cmdline_fixed_string_t flow_director_flexmask;
9423 cmdline_fixed_string_t flow;
9424 cmdline_fixed_string_t flow_type;
9425 cmdline_fixed_string_t mask;
9429 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9430 __attribute__((unused)) struct cmdline *cl,
9431 __attribute__((unused)) void *data)
9433 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9434 struct rte_eth_fdir_info fdir_info;
9435 struct rte_eth_fdir_flex_mask flex_mask;
9436 struct rte_port *port;
9437 uint32_t flow_type_mask;
9441 if (res->port_id > nb_ports) {
9442 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9446 port = &ports[res->port_id];
9447 /** Check if the port is not started **/
9448 if (port->port_status != RTE_PORT_STOPPED) {
9449 printf("Please stop port %d first\n", res->port_id);
9453 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9454 ret = parse_flexbytes(res->mask,
9456 RTE_ETH_FDIR_MAX_FLEXLEN);
9458 printf("error: Cannot parse mask input.\n");
9462 memset(&fdir_info, 0, sizeof(fdir_info));
9463 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9464 RTE_ETH_FILTER_INFO, &fdir_info);
9466 printf("Cannot get FDir filter info\n");
9470 if (!strcmp(res->flow_type, "none")) {
9471 /* means don't specify the flow type */
9472 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9473 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9474 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9475 0, sizeof(struct rte_eth_fdir_flex_mask));
9476 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9477 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9479 sizeof(struct rte_eth_fdir_flex_mask));
9480 cmd_reconfig_device_queue(res->port_id, 1, 1);
9483 flow_type_mask = fdir_info.flow_types_mask[0];
9484 if (!strcmp(res->flow_type, "all")) {
9485 if (!flow_type_mask) {
9486 printf("No flow type supported\n");
9489 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9490 if (flow_type_mask & (1 << i)) {
9491 flex_mask.flow_type = i;
9492 fdir_set_flex_mask(res->port_id, &flex_mask);
9495 cmd_reconfig_device_queue(res->port_id, 1, 1);
9498 flex_mask.flow_type = str2flowtype(res->flow_type);
9499 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9500 printf("Flow type %s not supported on port %d\n",
9501 res->flow_type, res->port_id);
9504 fdir_set_flex_mask(res->port_id, &flex_mask);
9505 cmd_reconfig_device_queue(res->port_id, 1, 1);
9508 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9510 flow_director_flexmask,
9511 "flow_director_flex_mask");
9512 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9513 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9515 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9516 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9518 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9519 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9520 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9521 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9522 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9523 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9526 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9527 .f = cmd_flow_director_flex_mask_parsed,
9529 .help_str = "flow_director_flex_mask ... : "
9530 "Set flow director's flex mask on NIC",
9532 (void *)&cmd_flow_director_flexmask,
9533 (void *)&cmd_flow_director_flexmask_port_id,
9534 (void *)&cmd_flow_director_flexmask_flow,
9535 (void *)&cmd_flow_director_flexmask_flow_type,
9536 (void *)&cmd_flow_director_flexmask_mask,
9541 /* *** deal with flow director flexible payload configuration *** */
9542 struct cmd_flow_director_flexpayload_result {
9543 cmdline_fixed_string_t flow_director_flexpayload;
9545 cmdline_fixed_string_t payload_layer;
9546 cmdline_fixed_string_t payload_cfg;
9550 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9553 const char *p, *p0 = q_arg;
9555 unsigned long int_fld;
9556 char *str_fld[max_num];
9561 p = strchr(p0, '(');
9565 p0 = strchr(p, ')');
9570 if (size >= sizeof(s))
9573 snprintf(s, sizeof(s), "%.*s", size, p);
9574 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9575 if (ret < 0 || ret > max_num)
9577 for (i = 0; i < ret; i++) {
9579 int_fld = strtoul(str_fld[i], &end, 0);
9580 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9582 offsets[i] = (uint16_t)int_fld;
9588 cmd_flow_director_flxpld_parsed(void *parsed_result,
9589 __attribute__((unused)) struct cmdline *cl,
9590 __attribute__((unused)) void *data)
9592 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9593 struct rte_eth_flex_payload_cfg flex_cfg;
9594 struct rte_port *port;
9597 if (res->port_id > nb_ports) {
9598 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9602 port = &ports[res->port_id];
9603 /** Check if the port is not started **/
9604 if (port->port_status != RTE_PORT_STOPPED) {
9605 printf("Please stop port %d first\n", res->port_id);
9609 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9611 if (!strcmp(res->payload_layer, "raw"))
9612 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9613 else if (!strcmp(res->payload_layer, "l2"))
9614 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9615 else if (!strcmp(res->payload_layer, "l3"))
9616 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9617 else if (!strcmp(res->payload_layer, "l4"))
9618 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9620 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9621 RTE_ETH_FDIR_MAX_FLEXLEN);
9623 printf("error: Cannot parse flex payload input.\n");
9627 fdir_set_flex_payload(res->port_id, &flex_cfg);
9628 cmd_reconfig_device_queue(res->port_id, 1, 1);
9631 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9632 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9633 flow_director_flexpayload,
9634 "flow_director_flex_payload");
9635 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9636 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9638 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9640 payload_layer, "raw#l2#l3#l4");
9641 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9642 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9645 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9646 .f = cmd_flow_director_flxpld_parsed,
9648 .help_str = "flow_director_flexpayload ... : "
9649 "Set flow director's flex payload on NIC",
9651 (void *)&cmd_flow_director_flexpayload,
9652 (void *)&cmd_flow_director_flexpayload_port_id,
9653 (void *)&cmd_flow_director_flexpayload_payload_layer,
9654 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9659 /* Generic flow interface command. */
9660 extern cmdline_parse_inst_t cmd_flow;
9662 /* *** Classification Filters Control *** */
9663 /* *** Get symmetric hash enable per port *** */
9664 struct cmd_get_sym_hash_ena_per_port_result {
9665 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9670 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9671 __rte_unused struct cmdline *cl,
9672 __rte_unused void *data)
9674 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9675 struct rte_eth_hash_filter_info info;
9678 if (rte_eth_dev_filter_supported(res->port_id,
9679 RTE_ETH_FILTER_HASH) < 0) {
9680 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9685 memset(&info, 0, sizeof(info));
9686 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9687 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9688 RTE_ETH_FILTER_GET, &info);
9691 printf("Cannot get symmetric hash enable per port "
9692 "on port %u\n", res->port_id);
9696 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9697 "enabled" : "disabled", res->port_id);
9700 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9701 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9702 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9703 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9704 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9707 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9708 .f = cmd_get_sym_hash_per_port_parsed,
9710 .help_str = "get_sym_hash_ena_per_port <port_id>",
9712 (void *)&cmd_get_sym_hash_ena_per_port_all,
9713 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9718 /* *** Set symmetric hash enable per port *** */
9719 struct cmd_set_sym_hash_ena_per_port_result {
9720 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9721 cmdline_fixed_string_t enable;
9726 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9727 __rte_unused struct cmdline *cl,
9728 __rte_unused void *data)
9730 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9731 struct rte_eth_hash_filter_info info;
9734 if (rte_eth_dev_filter_supported(res->port_id,
9735 RTE_ETH_FILTER_HASH) < 0) {
9736 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9741 memset(&info, 0, sizeof(info));
9742 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9743 if (!strcmp(res->enable, "enable"))
9744 info.info.enable = 1;
9745 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9746 RTE_ETH_FILTER_SET, &info);
9748 printf("Cannot set symmetric hash enable per port on "
9749 "port %u\n", res->port_id);
9752 printf("Symmetric hash has been set to %s on port %u\n",
9753 res->enable, res->port_id);
9756 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9757 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9758 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9759 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9760 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9762 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9763 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9764 enable, "enable#disable");
9766 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9767 .f = cmd_set_sym_hash_per_port_parsed,
9769 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9771 (void *)&cmd_set_sym_hash_ena_per_port_all,
9772 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9773 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9778 /* Get global config of hash function */
9779 struct cmd_get_hash_global_config_result {
9780 cmdline_fixed_string_t get_hash_global_config;
9785 flowtype_to_str(uint16_t ftype)
9792 {"ipv4", RTE_ETH_FLOW_IPV4},
9793 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9794 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9795 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9796 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9797 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9798 {"ipv6", RTE_ETH_FLOW_IPV6},
9799 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9800 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9801 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9802 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9803 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9804 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9805 {"port", RTE_ETH_FLOW_PORT},
9806 {"vxlan", RTE_ETH_FLOW_VXLAN},
9807 {"geneve", RTE_ETH_FLOW_GENEVE},
9808 {"nvgre", RTE_ETH_FLOW_NVGRE},
9811 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9812 if (ftype_table[i].ftype == ftype)
9813 return ftype_table[i].str;
9820 cmd_get_hash_global_config_parsed(void *parsed_result,
9821 __rte_unused struct cmdline *cl,
9822 __rte_unused void *data)
9824 struct cmd_get_hash_global_config_result *res = parsed_result;
9825 struct rte_eth_hash_filter_info info;
9826 uint32_t idx, offset;
9831 if (rte_eth_dev_filter_supported(res->port_id,
9832 RTE_ETH_FILTER_HASH) < 0) {
9833 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9838 memset(&info, 0, sizeof(info));
9839 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9840 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9841 RTE_ETH_FILTER_GET, &info);
9843 printf("Cannot get hash global configurations by port %d\n",
9848 switch (info.info.global_conf.hash_func) {
9849 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9850 printf("Hash function is Toeplitz\n");
9852 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9853 printf("Hash function is Simple XOR\n");
9856 printf("Unknown hash function\n");
9860 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9861 idx = i / UINT32_BIT;
9862 offset = i % UINT32_BIT;
9863 if (!(info.info.global_conf.valid_bit_mask[idx] &
9866 str = flowtype_to_str(i);
9869 printf("Symmetric hash is %s globally for flow type %s "
9871 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9872 (1UL << offset)) ? "enabled" : "disabled"), str,
9877 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9878 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9879 get_hash_global_config, "get_hash_global_config");
9880 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9881 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9884 cmdline_parse_inst_t cmd_get_hash_global_config = {
9885 .f = cmd_get_hash_global_config_parsed,
9887 .help_str = "get_hash_global_config <port_id>",
9889 (void *)&cmd_get_hash_global_config_all,
9890 (void *)&cmd_get_hash_global_config_port_id,
9895 /* Set global config of hash function */
9896 struct cmd_set_hash_global_config_result {
9897 cmdline_fixed_string_t set_hash_global_config;
9899 cmdline_fixed_string_t hash_func;
9900 cmdline_fixed_string_t flow_type;
9901 cmdline_fixed_string_t enable;
9905 cmd_set_hash_global_config_parsed(void *parsed_result,
9906 __rte_unused struct cmdline *cl,
9907 __rte_unused void *data)
9909 struct cmd_set_hash_global_config_result *res = parsed_result;
9910 struct rte_eth_hash_filter_info info;
9911 uint32_t ftype, idx, offset;
9914 if (rte_eth_dev_filter_supported(res->port_id,
9915 RTE_ETH_FILTER_HASH) < 0) {
9916 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9920 memset(&info, 0, sizeof(info));
9921 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9922 if (!strcmp(res->hash_func, "toeplitz"))
9923 info.info.global_conf.hash_func =
9924 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9925 else if (!strcmp(res->hash_func, "simple_xor"))
9926 info.info.global_conf.hash_func =
9927 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9928 else if (!strcmp(res->hash_func, "default"))
9929 info.info.global_conf.hash_func =
9930 RTE_ETH_HASH_FUNCTION_DEFAULT;
9932 ftype = str2flowtype(res->flow_type);
9933 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9934 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9935 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9936 if (!strcmp(res->enable, "enable"))
9937 info.info.global_conf.sym_hash_enable_mask[idx] |=
9939 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9940 RTE_ETH_FILTER_SET, &info);
9942 printf("Cannot set global hash configurations by port %d\n",
9945 printf("Global hash configurations have been set "
9946 "succcessfully by port %d\n", res->port_id);
9949 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9950 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9951 set_hash_global_config, "set_hash_global_config");
9952 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9953 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9955 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9956 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9957 hash_func, "toeplitz#simple_xor#default");
9958 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9959 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9961 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9962 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9963 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9964 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9965 enable, "enable#disable");
9967 cmdline_parse_inst_t cmd_set_hash_global_config = {
9968 .f = cmd_set_hash_global_config_parsed,
9970 .help_str = "set_hash_global_config <port_id> "
9971 "toeplitz|simple_xor|default "
9972 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9973 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9974 "l2_payload enable|disable",
9976 (void *)&cmd_set_hash_global_config_all,
9977 (void *)&cmd_set_hash_global_config_port_id,
9978 (void *)&cmd_set_hash_global_config_hash_func,
9979 (void *)&cmd_set_hash_global_config_flow_type,
9980 (void *)&cmd_set_hash_global_config_enable,
9985 /* Set hash input set */
9986 struct cmd_set_hash_input_set_result {
9987 cmdline_fixed_string_t set_hash_input_set;
9989 cmdline_fixed_string_t flow_type;
9990 cmdline_fixed_string_t inset_field;
9991 cmdline_fixed_string_t select;
9994 static enum rte_eth_input_set_field
9995 str2inset(char *string)
9999 static const struct {
10001 enum rte_eth_input_set_field inset;
10002 } inset_table[] = {
10003 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10004 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10005 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10006 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10007 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10008 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10009 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10010 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10011 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10012 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10013 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10014 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10015 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10016 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10017 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10018 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10019 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10020 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10021 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10022 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10023 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10024 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10025 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10026 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10027 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10028 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10029 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10030 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10031 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10032 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10033 {"none", RTE_ETH_INPUT_SET_NONE},
10036 for (i = 0; i < RTE_DIM(inset_table); i++) {
10037 if (!strcmp(string, inset_table[i].str))
10038 return inset_table[i].inset;
10041 return RTE_ETH_INPUT_SET_UNKNOWN;
10045 cmd_set_hash_input_set_parsed(void *parsed_result,
10046 __rte_unused struct cmdline *cl,
10047 __rte_unused void *data)
10049 struct cmd_set_hash_input_set_result *res = parsed_result;
10050 struct rte_eth_hash_filter_info info;
10052 memset(&info, 0, sizeof(info));
10053 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10054 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10055 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10056 info.info.input_set_conf.inset_size = 1;
10057 if (!strcmp(res->select, "select"))
10058 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10059 else if (!strcmp(res->select, "add"))
10060 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10061 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10062 RTE_ETH_FILTER_SET, &info);
10065 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10066 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10067 set_hash_input_set, "set_hash_input_set");
10068 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10069 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10071 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10072 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10074 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10075 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10076 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10077 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10079 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10080 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10081 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10082 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10083 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10085 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10086 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10087 select, "select#add");
10089 cmdline_parse_inst_t cmd_set_hash_input_set = {
10090 .f = cmd_set_hash_input_set_parsed,
10092 .help_str = "set_hash_input_set <port_id> "
10093 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10094 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10095 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10096 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10097 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10098 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10099 "fld-7th|fld-8th|none select|add",
10101 (void *)&cmd_set_hash_input_set_cmd,
10102 (void *)&cmd_set_hash_input_set_port_id,
10103 (void *)&cmd_set_hash_input_set_flow_type,
10104 (void *)&cmd_set_hash_input_set_field,
10105 (void *)&cmd_set_hash_input_set_select,
10110 /* Set flow director input set */
10111 struct cmd_set_fdir_input_set_result {
10112 cmdline_fixed_string_t set_fdir_input_set;
10114 cmdline_fixed_string_t flow_type;
10115 cmdline_fixed_string_t inset_field;
10116 cmdline_fixed_string_t select;
10120 cmd_set_fdir_input_set_parsed(void *parsed_result,
10121 __rte_unused struct cmdline *cl,
10122 __rte_unused void *data)
10124 struct cmd_set_fdir_input_set_result *res = parsed_result;
10125 struct rte_eth_fdir_filter_info info;
10127 memset(&info, 0, sizeof(info));
10128 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10129 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10130 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10131 info.info.input_set_conf.inset_size = 1;
10132 if (!strcmp(res->select, "select"))
10133 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10134 else if (!strcmp(res->select, "add"))
10135 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10136 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10137 RTE_ETH_FILTER_SET, &info);
10140 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10141 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10142 set_fdir_input_set, "set_fdir_input_set");
10143 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10144 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10146 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10147 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10149 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10150 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10151 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10152 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10154 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10155 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10156 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10157 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10158 "sctp-veri-tag#none");
10159 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10160 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10161 select, "select#add");
10163 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10164 .f = cmd_set_fdir_input_set_parsed,
10166 .help_str = "set_fdir_input_set <port_id> "
10167 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10168 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10169 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10170 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10171 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10172 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10173 "sctp-veri-tag|none select|add",
10175 (void *)&cmd_set_fdir_input_set_cmd,
10176 (void *)&cmd_set_fdir_input_set_port_id,
10177 (void *)&cmd_set_fdir_input_set_flow_type,
10178 (void *)&cmd_set_fdir_input_set_field,
10179 (void *)&cmd_set_fdir_input_set_select,
10184 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10185 struct cmd_mcast_addr_result {
10186 cmdline_fixed_string_t mcast_addr_cmd;
10187 cmdline_fixed_string_t what;
10189 struct ether_addr mc_addr;
10192 static void cmd_mcast_addr_parsed(void *parsed_result,
10193 __attribute__((unused)) struct cmdline *cl,
10194 __attribute__((unused)) void *data)
10196 struct cmd_mcast_addr_result *res = parsed_result;
10198 if (!is_multicast_ether_addr(&res->mc_addr)) {
10199 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10200 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10201 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10202 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10205 if (strcmp(res->what, "add") == 0)
10206 mcast_addr_add(res->port_num, &res->mc_addr);
10208 mcast_addr_remove(res->port_num, &res->mc_addr);
10211 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10212 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10213 mcast_addr_cmd, "mcast_addr");
10214 cmdline_parse_token_string_t cmd_mcast_addr_what =
10215 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10217 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10218 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10219 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10220 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10222 cmdline_parse_inst_t cmd_mcast_addr = {
10223 .f = cmd_mcast_addr_parsed,
10225 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10226 "Add/Remove multicast MAC address on port_id",
10228 (void *)&cmd_mcast_addr_cmd,
10229 (void *)&cmd_mcast_addr_what,
10230 (void *)&cmd_mcast_addr_portnum,
10231 (void *)&cmd_mcast_addr_addr,
10236 /* l2 tunnel config
10237 * only support E-tag now.
10240 /* Ether type config */
10241 struct cmd_config_l2_tunnel_eth_type_result {
10242 cmdline_fixed_string_t port;
10243 cmdline_fixed_string_t config;
10244 cmdline_fixed_string_t all;
10246 cmdline_fixed_string_t l2_tunnel;
10247 cmdline_fixed_string_t l2_tunnel_type;
10248 cmdline_fixed_string_t eth_type;
10249 uint16_t eth_type_val;
10252 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10253 TOKEN_STRING_INITIALIZER
10254 (struct cmd_config_l2_tunnel_eth_type_result,
10256 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10257 TOKEN_STRING_INITIALIZER
10258 (struct cmd_config_l2_tunnel_eth_type_result,
10260 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10261 TOKEN_STRING_INITIALIZER
10262 (struct cmd_config_l2_tunnel_eth_type_result,
10264 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10265 TOKEN_NUM_INITIALIZER
10266 (struct cmd_config_l2_tunnel_eth_type_result,
10268 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10269 TOKEN_STRING_INITIALIZER
10270 (struct cmd_config_l2_tunnel_eth_type_result,
10271 l2_tunnel, "l2-tunnel");
10272 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10273 TOKEN_STRING_INITIALIZER
10274 (struct cmd_config_l2_tunnel_eth_type_result,
10275 l2_tunnel_type, "E-tag");
10276 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10277 TOKEN_STRING_INITIALIZER
10278 (struct cmd_config_l2_tunnel_eth_type_result,
10279 eth_type, "ether-type");
10280 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10281 TOKEN_NUM_INITIALIZER
10282 (struct cmd_config_l2_tunnel_eth_type_result,
10283 eth_type_val, UINT16);
10285 static enum rte_eth_tunnel_type
10286 str2fdir_l2_tunnel_type(char *string)
10290 static const struct {
10292 enum rte_eth_tunnel_type type;
10293 } l2_tunnel_type_str[] = {
10294 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10297 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10298 if (!strcmp(l2_tunnel_type_str[i].str, string))
10299 return l2_tunnel_type_str[i].type;
10301 return RTE_TUNNEL_TYPE_NONE;
10304 /* ether type config for all ports */
10306 cmd_config_l2_tunnel_eth_type_all_parsed
10307 (void *parsed_result,
10308 __attribute__((unused)) struct cmdline *cl,
10309 __attribute__((unused)) void *data)
10311 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10312 struct rte_eth_l2_tunnel_conf entry;
10315 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10316 entry.ether_type = res->eth_type_val;
10318 FOREACH_PORT(pid, ports) {
10319 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10323 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10324 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10326 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10328 (void *)&cmd_config_l2_tunnel_eth_type_port,
10329 (void *)&cmd_config_l2_tunnel_eth_type_config,
10330 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10331 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10332 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10333 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10334 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10339 /* ether type config for a specific port */
10341 cmd_config_l2_tunnel_eth_type_specific_parsed(
10342 void *parsed_result,
10343 __attribute__((unused)) struct cmdline *cl,
10344 __attribute__((unused)) void *data)
10346 struct cmd_config_l2_tunnel_eth_type_result *res =
10348 struct rte_eth_l2_tunnel_conf entry;
10350 if (port_id_is_invalid(res->id, ENABLED_WARN))
10353 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10354 entry.ether_type = res->eth_type_val;
10356 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10359 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10360 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10362 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10364 (void *)&cmd_config_l2_tunnel_eth_type_port,
10365 (void *)&cmd_config_l2_tunnel_eth_type_config,
10366 (void *)&cmd_config_l2_tunnel_eth_type_id,
10367 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10368 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10369 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10370 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10375 /* Enable/disable l2 tunnel */
10376 struct cmd_config_l2_tunnel_en_dis_result {
10377 cmdline_fixed_string_t port;
10378 cmdline_fixed_string_t config;
10379 cmdline_fixed_string_t all;
10381 cmdline_fixed_string_t l2_tunnel;
10382 cmdline_fixed_string_t l2_tunnel_type;
10383 cmdline_fixed_string_t en_dis;
10386 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10387 TOKEN_STRING_INITIALIZER
10388 (struct cmd_config_l2_tunnel_en_dis_result,
10390 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10391 TOKEN_STRING_INITIALIZER
10392 (struct cmd_config_l2_tunnel_en_dis_result,
10394 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10395 TOKEN_STRING_INITIALIZER
10396 (struct cmd_config_l2_tunnel_en_dis_result,
10398 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10399 TOKEN_NUM_INITIALIZER
10400 (struct cmd_config_l2_tunnel_en_dis_result,
10402 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10403 TOKEN_STRING_INITIALIZER
10404 (struct cmd_config_l2_tunnel_en_dis_result,
10405 l2_tunnel, "l2-tunnel");
10406 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10407 TOKEN_STRING_INITIALIZER
10408 (struct cmd_config_l2_tunnel_en_dis_result,
10409 l2_tunnel_type, "E-tag");
10410 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10411 TOKEN_STRING_INITIALIZER
10412 (struct cmd_config_l2_tunnel_en_dis_result,
10413 en_dis, "enable#disable");
10415 /* enable/disable l2 tunnel for all ports */
10417 cmd_config_l2_tunnel_en_dis_all_parsed(
10418 void *parsed_result,
10419 __attribute__((unused)) struct cmdline *cl,
10420 __attribute__((unused)) void *data)
10422 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10423 struct rte_eth_l2_tunnel_conf entry;
10427 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10429 if (!strcmp("enable", res->en_dis))
10434 FOREACH_PORT(pid, ports) {
10435 rte_eth_dev_l2_tunnel_offload_set(pid,
10437 ETH_L2_TUNNEL_ENABLE_MASK,
10442 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10443 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10445 .help_str = "port config all l2-tunnel E-tag enable|disable",
10447 (void *)&cmd_config_l2_tunnel_en_dis_port,
10448 (void *)&cmd_config_l2_tunnel_en_dis_config,
10449 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10450 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10451 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10452 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10457 /* enable/disable l2 tunnel for a port */
10459 cmd_config_l2_tunnel_en_dis_specific_parsed(
10460 void *parsed_result,
10461 __attribute__((unused)) struct cmdline *cl,
10462 __attribute__((unused)) void *data)
10464 struct cmd_config_l2_tunnel_en_dis_result *res =
10466 struct rte_eth_l2_tunnel_conf entry;
10468 if (port_id_is_invalid(res->id, ENABLED_WARN))
10471 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10473 if (!strcmp("enable", res->en_dis))
10474 rte_eth_dev_l2_tunnel_offload_set(res->id,
10476 ETH_L2_TUNNEL_ENABLE_MASK,
10479 rte_eth_dev_l2_tunnel_offload_set(res->id,
10481 ETH_L2_TUNNEL_ENABLE_MASK,
10485 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10486 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10488 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10490 (void *)&cmd_config_l2_tunnel_en_dis_port,
10491 (void *)&cmd_config_l2_tunnel_en_dis_config,
10492 (void *)&cmd_config_l2_tunnel_en_dis_id,
10493 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10494 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10495 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10500 /* E-tag configuration */
10502 /* Common result structure for all E-tag configuration */
10503 struct cmd_config_e_tag_result {
10504 cmdline_fixed_string_t e_tag;
10505 cmdline_fixed_string_t set;
10506 cmdline_fixed_string_t insertion;
10507 cmdline_fixed_string_t stripping;
10508 cmdline_fixed_string_t forwarding;
10509 cmdline_fixed_string_t filter;
10510 cmdline_fixed_string_t add;
10511 cmdline_fixed_string_t del;
10512 cmdline_fixed_string_t on;
10513 cmdline_fixed_string_t off;
10514 cmdline_fixed_string_t on_off;
10515 cmdline_fixed_string_t port_tag_id;
10516 uint32_t port_tag_id_val;
10517 cmdline_fixed_string_t e_tag_id;
10518 uint16_t e_tag_id_val;
10519 cmdline_fixed_string_t dst_pool;
10520 uint8_t dst_pool_val;
10521 cmdline_fixed_string_t port;
10523 cmdline_fixed_string_t vf;
10527 /* Common CLI fields for all E-tag configuration */
10528 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10529 TOKEN_STRING_INITIALIZER
10530 (struct cmd_config_e_tag_result,
10532 cmdline_parse_token_string_t cmd_config_e_tag_set =
10533 TOKEN_STRING_INITIALIZER
10534 (struct cmd_config_e_tag_result,
10536 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10537 TOKEN_STRING_INITIALIZER
10538 (struct cmd_config_e_tag_result,
10539 insertion, "insertion");
10540 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10541 TOKEN_STRING_INITIALIZER
10542 (struct cmd_config_e_tag_result,
10543 stripping, "stripping");
10544 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10545 TOKEN_STRING_INITIALIZER
10546 (struct cmd_config_e_tag_result,
10547 forwarding, "forwarding");
10548 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10549 TOKEN_STRING_INITIALIZER
10550 (struct cmd_config_e_tag_result,
10552 cmdline_parse_token_string_t cmd_config_e_tag_add =
10553 TOKEN_STRING_INITIALIZER
10554 (struct cmd_config_e_tag_result,
10556 cmdline_parse_token_string_t cmd_config_e_tag_del =
10557 TOKEN_STRING_INITIALIZER
10558 (struct cmd_config_e_tag_result,
10560 cmdline_parse_token_string_t cmd_config_e_tag_on =
10561 TOKEN_STRING_INITIALIZER
10562 (struct cmd_config_e_tag_result,
10564 cmdline_parse_token_string_t cmd_config_e_tag_off =
10565 TOKEN_STRING_INITIALIZER
10566 (struct cmd_config_e_tag_result,
10568 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10569 TOKEN_STRING_INITIALIZER
10570 (struct cmd_config_e_tag_result,
10572 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10573 TOKEN_STRING_INITIALIZER
10574 (struct cmd_config_e_tag_result,
10575 port_tag_id, "port-tag-id");
10576 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10577 TOKEN_NUM_INITIALIZER
10578 (struct cmd_config_e_tag_result,
10579 port_tag_id_val, UINT32);
10580 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10581 TOKEN_STRING_INITIALIZER
10582 (struct cmd_config_e_tag_result,
10583 e_tag_id, "e-tag-id");
10584 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10585 TOKEN_NUM_INITIALIZER
10586 (struct cmd_config_e_tag_result,
10587 e_tag_id_val, UINT16);
10588 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10589 TOKEN_STRING_INITIALIZER
10590 (struct cmd_config_e_tag_result,
10591 dst_pool, "dst-pool");
10592 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10593 TOKEN_NUM_INITIALIZER
10594 (struct cmd_config_e_tag_result,
10595 dst_pool_val, UINT8);
10596 cmdline_parse_token_string_t cmd_config_e_tag_port =
10597 TOKEN_STRING_INITIALIZER
10598 (struct cmd_config_e_tag_result,
10600 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10601 TOKEN_NUM_INITIALIZER
10602 (struct cmd_config_e_tag_result,
10604 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10605 TOKEN_STRING_INITIALIZER
10606 (struct cmd_config_e_tag_result,
10608 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10609 TOKEN_NUM_INITIALIZER
10610 (struct cmd_config_e_tag_result,
10613 /* E-tag insertion configuration */
10615 cmd_config_e_tag_insertion_en_parsed(
10616 void *parsed_result,
10617 __attribute__((unused)) struct cmdline *cl,
10618 __attribute__((unused)) void *data)
10620 struct cmd_config_e_tag_result *res =
10622 struct rte_eth_l2_tunnel_conf entry;
10624 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10627 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10628 entry.tunnel_id = res->port_tag_id_val;
10629 entry.vf_id = res->vf_id;
10630 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10632 ETH_L2_TUNNEL_INSERTION_MASK,
10637 cmd_config_e_tag_insertion_dis_parsed(
10638 void *parsed_result,
10639 __attribute__((unused)) struct cmdline *cl,
10640 __attribute__((unused)) void *data)
10642 struct cmd_config_e_tag_result *res =
10644 struct rte_eth_l2_tunnel_conf entry;
10646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10649 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10650 entry.vf_id = res->vf_id;
10652 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10654 ETH_L2_TUNNEL_INSERTION_MASK,
10658 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10659 .f = cmd_config_e_tag_insertion_en_parsed,
10661 .help_str = "E-tag ... : E-tag insertion enable",
10663 (void *)&cmd_config_e_tag_e_tag,
10664 (void *)&cmd_config_e_tag_set,
10665 (void *)&cmd_config_e_tag_insertion,
10666 (void *)&cmd_config_e_tag_on,
10667 (void *)&cmd_config_e_tag_port_tag_id,
10668 (void *)&cmd_config_e_tag_port_tag_id_val,
10669 (void *)&cmd_config_e_tag_port,
10670 (void *)&cmd_config_e_tag_port_id,
10671 (void *)&cmd_config_e_tag_vf,
10672 (void *)&cmd_config_e_tag_vf_id,
10677 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10678 .f = cmd_config_e_tag_insertion_dis_parsed,
10680 .help_str = "E-tag ... : E-tag insertion disable",
10682 (void *)&cmd_config_e_tag_e_tag,
10683 (void *)&cmd_config_e_tag_set,
10684 (void *)&cmd_config_e_tag_insertion,
10685 (void *)&cmd_config_e_tag_off,
10686 (void *)&cmd_config_e_tag_port,
10687 (void *)&cmd_config_e_tag_port_id,
10688 (void *)&cmd_config_e_tag_vf,
10689 (void *)&cmd_config_e_tag_vf_id,
10694 /* E-tag stripping configuration */
10696 cmd_config_e_tag_stripping_parsed(
10697 void *parsed_result,
10698 __attribute__((unused)) struct cmdline *cl,
10699 __attribute__((unused)) void *data)
10701 struct cmd_config_e_tag_result *res =
10703 struct rte_eth_l2_tunnel_conf entry;
10705 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10708 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10710 if (!strcmp(res->on_off, "on"))
10711 rte_eth_dev_l2_tunnel_offload_set
10714 ETH_L2_TUNNEL_STRIPPING_MASK,
10717 rte_eth_dev_l2_tunnel_offload_set
10720 ETH_L2_TUNNEL_STRIPPING_MASK,
10724 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10725 .f = cmd_config_e_tag_stripping_parsed,
10727 .help_str = "E-tag ... : E-tag stripping enable/disable",
10729 (void *)&cmd_config_e_tag_e_tag,
10730 (void *)&cmd_config_e_tag_set,
10731 (void *)&cmd_config_e_tag_stripping,
10732 (void *)&cmd_config_e_tag_on_off,
10733 (void *)&cmd_config_e_tag_port,
10734 (void *)&cmd_config_e_tag_port_id,
10739 /* E-tag forwarding configuration */
10741 cmd_config_e_tag_forwarding_parsed(
10742 void *parsed_result,
10743 __attribute__((unused)) struct cmdline *cl,
10744 __attribute__((unused)) void *data)
10746 struct cmd_config_e_tag_result *res = parsed_result;
10747 struct rte_eth_l2_tunnel_conf entry;
10749 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10752 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10754 if (!strcmp(res->on_off, "on"))
10755 rte_eth_dev_l2_tunnel_offload_set
10758 ETH_L2_TUNNEL_FORWARDING_MASK,
10761 rte_eth_dev_l2_tunnel_offload_set
10764 ETH_L2_TUNNEL_FORWARDING_MASK,
10768 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10769 .f = cmd_config_e_tag_forwarding_parsed,
10771 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10773 (void *)&cmd_config_e_tag_e_tag,
10774 (void *)&cmd_config_e_tag_set,
10775 (void *)&cmd_config_e_tag_forwarding,
10776 (void *)&cmd_config_e_tag_on_off,
10777 (void *)&cmd_config_e_tag_port,
10778 (void *)&cmd_config_e_tag_port_id,
10783 /* E-tag filter configuration */
10785 cmd_config_e_tag_filter_add_parsed(
10786 void *parsed_result,
10787 __attribute__((unused)) struct cmdline *cl,
10788 __attribute__((unused)) void *data)
10790 struct cmd_config_e_tag_result *res = parsed_result;
10791 struct rte_eth_l2_tunnel_conf entry;
10794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10797 if (res->e_tag_id_val > 0x3fff) {
10798 printf("e-tag-id must be equal or less than 0x3fff.\n");
10802 ret = rte_eth_dev_filter_supported(res->port_id,
10803 RTE_ETH_FILTER_L2_TUNNEL);
10805 printf("E-tag filter is not supported on port %u.\n",
10810 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10811 entry.tunnel_id = res->e_tag_id_val;
10812 entry.pool = res->dst_pool_val;
10814 ret = rte_eth_dev_filter_ctrl(res->port_id,
10815 RTE_ETH_FILTER_L2_TUNNEL,
10816 RTE_ETH_FILTER_ADD,
10819 printf("E-tag filter programming error: (%s)\n",
10823 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10824 .f = cmd_config_e_tag_filter_add_parsed,
10826 .help_str = "E-tag ... : E-tag filter add",
10828 (void *)&cmd_config_e_tag_e_tag,
10829 (void *)&cmd_config_e_tag_set,
10830 (void *)&cmd_config_e_tag_filter,
10831 (void *)&cmd_config_e_tag_add,
10832 (void *)&cmd_config_e_tag_e_tag_id,
10833 (void *)&cmd_config_e_tag_e_tag_id_val,
10834 (void *)&cmd_config_e_tag_dst_pool,
10835 (void *)&cmd_config_e_tag_dst_pool_val,
10836 (void *)&cmd_config_e_tag_port,
10837 (void *)&cmd_config_e_tag_port_id,
10843 cmd_config_e_tag_filter_del_parsed(
10844 void *parsed_result,
10845 __attribute__((unused)) struct cmdline *cl,
10846 __attribute__((unused)) void *data)
10848 struct cmd_config_e_tag_result *res = parsed_result;
10849 struct rte_eth_l2_tunnel_conf entry;
10852 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10855 if (res->e_tag_id_val > 0x3fff) {
10856 printf("e-tag-id must be less than 0x3fff.\n");
10860 ret = rte_eth_dev_filter_supported(res->port_id,
10861 RTE_ETH_FILTER_L2_TUNNEL);
10863 printf("E-tag filter is not supported on port %u.\n",
10868 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10869 entry.tunnel_id = res->e_tag_id_val;
10871 ret = rte_eth_dev_filter_ctrl(res->port_id,
10872 RTE_ETH_FILTER_L2_TUNNEL,
10873 RTE_ETH_FILTER_DELETE,
10876 printf("E-tag filter programming error: (%s)\n",
10880 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10881 .f = cmd_config_e_tag_filter_del_parsed,
10883 .help_str = "E-tag ... : E-tag filter delete",
10885 (void *)&cmd_config_e_tag_e_tag,
10886 (void *)&cmd_config_e_tag_set,
10887 (void *)&cmd_config_e_tag_filter,
10888 (void *)&cmd_config_e_tag_del,
10889 (void *)&cmd_config_e_tag_e_tag_id,
10890 (void *)&cmd_config_e_tag_e_tag_id_val,
10891 (void *)&cmd_config_e_tag_port,
10892 (void *)&cmd_config_e_tag_port_id,
10897 /* vf vlan anti spoof configuration */
10899 /* Common result structure for vf vlan anti spoof */
10900 struct cmd_vf_vlan_anti_spoof_result {
10901 cmdline_fixed_string_t set;
10902 cmdline_fixed_string_t vf;
10903 cmdline_fixed_string_t vlan;
10904 cmdline_fixed_string_t antispoof;
10907 cmdline_fixed_string_t on_off;
10910 /* Common CLI fields for vf vlan anti spoof enable disable */
10911 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10912 TOKEN_STRING_INITIALIZER
10913 (struct cmd_vf_vlan_anti_spoof_result,
10915 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10916 TOKEN_STRING_INITIALIZER
10917 (struct cmd_vf_vlan_anti_spoof_result,
10919 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10920 TOKEN_STRING_INITIALIZER
10921 (struct cmd_vf_vlan_anti_spoof_result,
10923 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10924 TOKEN_STRING_INITIALIZER
10925 (struct cmd_vf_vlan_anti_spoof_result,
10926 antispoof, "antispoof");
10927 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10928 TOKEN_NUM_INITIALIZER
10929 (struct cmd_vf_vlan_anti_spoof_result,
10931 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10932 TOKEN_NUM_INITIALIZER
10933 (struct cmd_vf_vlan_anti_spoof_result,
10935 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10936 TOKEN_STRING_INITIALIZER
10937 (struct cmd_vf_vlan_anti_spoof_result,
10941 cmd_set_vf_vlan_anti_spoof_parsed(
10942 void *parsed_result,
10943 __attribute__((unused)) struct cmdline *cl,
10944 __attribute__((unused)) void *data)
10946 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10947 int ret = -ENOTSUP;
10949 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10951 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10954 #ifdef RTE_LIBRTE_IXGBE_PMD
10955 if (ret == -ENOTSUP)
10956 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10957 res->vf_id, is_on);
10959 #ifdef RTE_LIBRTE_I40E_PMD
10960 if (ret == -ENOTSUP)
10961 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10962 res->vf_id, is_on);
10969 printf("invalid vf_id %d\n", res->vf_id);
10972 printf("invalid port_id %d\n", res->port_id);
10975 printf("function not implemented\n");
10978 printf("programming error: (%s)\n", strerror(-ret));
10982 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10983 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10985 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10987 (void *)&cmd_vf_vlan_anti_spoof_set,
10988 (void *)&cmd_vf_vlan_anti_spoof_vf,
10989 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10990 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10991 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10992 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10993 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10998 /* vf mac anti spoof configuration */
11000 /* Common result structure for vf mac anti spoof */
11001 struct cmd_vf_mac_anti_spoof_result {
11002 cmdline_fixed_string_t set;
11003 cmdline_fixed_string_t vf;
11004 cmdline_fixed_string_t mac;
11005 cmdline_fixed_string_t antispoof;
11008 cmdline_fixed_string_t on_off;
11011 /* Common CLI fields for vf mac anti spoof enable disable */
11012 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11013 TOKEN_STRING_INITIALIZER
11014 (struct cmd_vf_mac_anti_spoof_result,
11016 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11017 TOKEN_STRING_INITIALIZER
11018 (struct cmd_vf_mac_anti_spoof_result,
11020 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11021 TOKEN_STRING_INITIALIZER
11022 (struct cmd_vf_mac_anti_spoof_result,
11024 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11025 TOKEN_STRING_INITIALIZER
11026 (struct cmd_vf_mac_anti_spoof_result,
11027 antispoof, "antispoof");
11028 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11029 TOKEN_NUM_INITIALIZER
11030 (struct cmd_vf_mac_anti_spoof_result,
11032 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11033 TOKEN_NUM_INITIALIZER
11034 (struct cmd_vf_mac_anti_spoof_result,
11036 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11037 TOKEN_STRING_INITIALIZER
11038 (struct cmd_vf_mac_anti_spoof_result,
11042 cmd_set_vf_mac_anti_spoof_parsed(
11043 void *parsed_result,
11044 __attribute__((unused)) struct cmdline *cl,
11045 __attribute__((unused)) void *data)
11047 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11048 int ret = -ENOTSUP;
11050 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11052 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11055 #ifdef RTE_LIBRTE_IXGBE_PMD
11056 if (ret == -ENOTSUP)
11057 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11058 res->vf_id, is_on);
11060 #ifdef RTE_LIBRTE_I40E_PMD
11061 if (ret == -ENOTSUP)
11062 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11063 res->vf_id, is_on);
11070 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11073 printf("invalid port_id %d\n", res->port_id);
11076 printf("function not implemented\n");
11079 printf("programming error: (%s)\n", strerror(-ret));
11083 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11084 .f = cmd_set_vf_mac_anti_spoof_parsed,
11086 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11088 (void *)&cmd_vf_mac_anti_spoof_set,
11089 (void *)&cmd_vf_mac_anti_spoof_vf,
11090 (void *)&cmd_vf_mac_anti_spoof_mac,
11091 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11092 (void *)&cmd_vf_mac_anti_spoof_port_id,
11093 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11094 (void *)&cmd_vf_mac_anti_spoof_on_off,
11099 /* vf vlan strip queue configuration */
11101 /* Common result structure for vf mac anti spoof */
11102 struct cmd_vf_vlan_stripq_result {
11103 cmdline_fixed_string_t set;
11104 cmdline_fixed_string_t vf;
11105 cmdline_fixed_string_t vlan;
11106 cmdline_fixed_string_t stripq;
11109 cmdline_fixed_string_t on_off;
11112 /* Common CLI fields for vf vlan strip enable disable */
11113 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11114 TOKEN_STRING_INITIALIZER
11115 (struct cmd_vf_vlan_stripq_result,
11117 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11118 TOKEN_STRING_INITIALIZER
11119 (struct cmd_vf_vlan_stripq_result,
11121 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11122 TOKEN_STRING_INITIALIZER
11123 (struct cmd_vf_vlan_stripq_result,
11125 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11126 TOKEN_STRING_INITIALIZER
11127 (struct cmd_vf_vlan_stripq_result,
11129 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11130 TOKEN_NUM_INITIALIZER
11131 (struct cmd_vf_vlan_stripq_result,
11133 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11134 TOKEN_NUM_INITIALIZER
11135 (struct cmd_vf_vlan_stripq_result,
11137 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11138 TOKEN_STRING_INITIALIZER
11139 (struct cmd_vf_vlan_stripq_result,
11143 cmd_set_vf_vlan_stripq_parsed(
11144 void *parsed_result,
11145 __attribute__((unused)) struct cmdline *cl,
11146 __attribute__((unused)) void *data)
11148 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11149 int ret = -ENOTSUP;
11151 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11153 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11156 #ifdef RTE_LIBRTE_IXGBE_PMD
11157 if (ret == -ENOTSUP)
11158 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11159 res->vf_id, is_on);
11161 #ifdef RTE_LIBRTE_I40E_PMD
11162 if (ret == -ENOTSUP)
11163 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11164 res->vf_id, is_on);
11171 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11174 printf("invalid port_id %d\n", res->port_id);
11177 printf("function not implemented\n");
11180 printf("programming error: (%s)\n", strerror(-ret));
11184 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11185 .f = cmd_set_vf_vlan_stripq_parsed,
11187 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11189 (void *)&cmd_vf_vlan_stripq_set,
11190 (void *)&cmd_vf_vlan_stripq_vf,
11191 (void *)&cmd_vf_vlan_stripq_vlan,
11192 (void *)&cmd_vf_vlan_stripq_stripq,
11193 (void *)&cmd_vf_vlan_stripq_port_id,
11194 (void *)&cmd_vf_vlan_stripq_vf_id,
11195 (void *)&cmd_vf_vlan_stripq_on_off,
11200 /* vf vlan insert configuration */
11202 /* Common result structure for vf vlan insert */
11203 struct cmd_vf_vlan_insert_result {
11204 cmdline_fixed_string_t set;
11205 cmdline_fixed_string_t vf;
11206 cmdline_fixed_string_t vlan;
11207 cmdline_fixed_string_t insert;
11213 /* Common CLI fields for vf vlan insert enable disable */
11214 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11215 TOKEN_STRING_INITIALIZER
11216 (struct cmd_vf_vlan_insert_result,
11218 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11219 TOKEN_STRING_INITIALIZER
11220 (struct cmd_vf_vlan_insert_result,
11222 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11223 TOKEN_STRING_INITIALIZER
11224 (struct cmd_vf_vlan_insert_result,
11226 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11227 TOKEN_STRING_INITIALIZER
11228 (struct cmd_vf_vlan_insert_result,
11230 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11231 TOKEN_NUM_INITIALIZER
11232 (struct cmd_vf_vlan_insert_result,
11234 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11235 TOKEN_NUM_INITIALIZER
11236 (struct cmd_vf_vlan_insert_result,
11238 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11239 TOKEN_NUM_INITIALIZER
11240 (struct cmd_vf_vlan_insert_result,
11244 cmd_set_vf_vlan_insert_parsed(
11245 void *parsed_result,
11246 __attribute__((unused)) struct cmdline *cl,
11247 __attribute__((unused)) void *data)
11249 struct cmd_vf_vlan_insert_result *res = parsed_result;
11250 int ret = -ENOTSUP;
11252 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11255 #ifdef RTE_LIBRTE_IXGBE_PMD
11256 if (ret == -ENOTSUP)
11257 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11260 #ifdef RTE_LIBRTE_I40E_PMD
11261 if (ret == -ENOTSUP)
11262 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11270 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11273 printf("invalid port_id %d\n", res->port_id);
11276 printf("function not implemented\n");
11279 printf("programming error: (%s)\n", strerror(-ret));
11283 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11284 .f = cmd_set_vf_vlan_insert_parsed,
11286 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11288 (void *)&cmd_vf_vlan_insert_set,
11289 (void *)&cmd_vf_vlan_insert_vf,
11290 (void *)&cmd_vf_vlan_insert_vlan,
11291 (void *)&cmd_vf_vlan_insert_insert,
11292 (void *)&cmd_vf_vlan_insert_port_id,
11293 (void *)&cmd_vf_vlan_insert_vf_id,
11294 (void *)&cmd_vf_vlan_insert_vlan_id,
11299 /* tx loopback configuration */
11301 /* Common result structure for tx loopback */
11302 struct cmd_tx_loopback_result {
11303 cmdline_fixed_string_t set;
11304 cmdline_fixed_string_t tx;
11305 cmdline_fixed_string_t loopback;
11307 cmdline_fixed_string_t on_off;
11310 /* Common CLI fields for tx loopback enable disable */
11311 cmdline_parse_token_string_t cmd_tx_loopback_set =
11312 TOKEN_STRING_INITIALIZER
11313 (struct cmd_tx_loopback_result,
11315 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11316 TOKEN_STRING_INITIALIZER
11317 (struct cmd_tx_loopback_result,
11319 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11320 TOKEN_STRING_INITIALIZER
11321 (struct cmd_tx_loopback_result,
11322 loopback, "loopback");
11323 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11324 TOKEN_NUM_INITIALIZER
11325 (struct cmd_tx_loopback_result,
11327 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11328 TOKEN_STRING_INITIALIZER
11329 (struct cmd_tx_loopback_result,
11333 cmd_set_tx_loopback_parsed(
11334 void *parsed_result,
11335 __attribute__((unused)) struct cmdline *cl,
11336 __attribute__((unused)) void *data)
11338 struct cmd_tx_loopback_result *res = parsed_result;
11339 int ret = -ENOTSUP;
11341 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11343 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11346 #ifdef RTE_LIBRTE_IXGBE_PMD
11347 if (ret == -ENOTSUP)
11348 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11350 #ifdef RTE_LIBRTE_I40E_PMD
11351 if (ret == -ENOTSUP)
11352 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11359 printf("invalid is_on %d\n", is_on);
11362 printf("invalid port_id %d\n", res->port_id);
11365 printf("function not implemented\n");
11368 printf("programming error: (%s)\n", strerror(-ret));
11372 cmdline_parse_inst_t cmd_set_tx_loopback = {
11373 .f = cmd_set_tx_loopback_parsed,
11375 .help_str = "set tx loopback <port_id> on|off",
11377 (void *)&cmd_tx_loopback_set,
11378 (void *)&cmd_tx_loopback_tx,
11379 (void *)&cmd_tx_loopback_loopback,
11380 (void *)&cmd_tx_loopback_port_id,
11381 (void *)&cmd_tx_loopback_on_off,
11386 #ifdef RTE_LIBRTE_IXGBE_PMD
11387 /* all queues drop enable configuration */
11389 /* Common result structure for all queues drop enable */
11390 struct cmd_all_queues_drop_en_result {
11391 cmdline_fixed_string_t set;
11392 cmdline_fixed_string_t all;
11393 cmdline_fixed_string_t queues;
11394 cmdline_fixed_string_t drop;
11396 cmdline_fixed_string_t on_off;
11399 /* Common CLI fields for tx loopback enable disable */
11400 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11401 TOKEN_STRING_INITIALIZER
11402 (struct cmd_all_queues_drop_en_result,
11404 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11405 TOKEN_STRING_INITIALIZER
11406 (struct cmd_all_queues_drop_en_result,
11408 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11409 TOKEN_STRING_INITIALIZER
11410 (struct cmd_all_queues_drop_en_result,
11412 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11413 TOKEN_STRING_INITIALIZER
11414 (struct cmd_all_queues_drop_en_result,
11416 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11417 TOKEN_NUM_INITIALIZER
11418 (struct cmd_all_queues_drop_en_result,
11420 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11421 TOKEN_STRING_INITIALIZER
11422 (struct cmd_all_queues_drop_en_result,
11426 cmd_set_all_queues_drop_en_parsed(
11427 void *parsed_result,
11428 __attribute__((unused)) struct cmdline *cl,
11429 __attribute__((unused)) void *data)
11431 struct cmd_all_queues_drop_en_result *res = parsed_result;
11433 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11438 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11443 printf("invalid is_on %d\n", is_on);
11446 printf("invalid port_id %d\n", res->port_id);
11449 printf("function not implemented\n");
11452 printf("programming error: (%s)\n", strerror(-ret));
11456 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11457 .f = cmd_set_all_queues_drop_en_parsed,
11459 .help_str = "set all queues drop <port_id> on|off",
11461 (void *)&cmd_all_queues_drop_en_set,
11462 (void *)&cmd_all_queues_drop_en_all,
11463 (void *)&cmd_all_queues_drop_en_queues,
11464 (void *)&cmd_all_queues_drop_en_drop,
11465 (void *)&cmd_all_queues_drop_en_port_id,
11466 (void *)&cmd_all_queues_drop_en_on_off,
11471 /* vf split drop enable configuration */
11473 /* Common result structure for vf split drop enable */
11474 struct cmd_vf_split_drop_en_result {
11475 cmdline_fixed_string_t set;
11476 cmdline_fixed_string_t vf;
11477 cmdline_fixed_string_t split;
11478 cmdline_fixed_string_t drop;
11481 cmdline_fixed_string_t on_off;
11484 /* Common CLI fields for vf split drop enable disable */
11485 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11486 TOKEN_STRING_INITIALIZER
11487 (struct cmd_vf_split_drop_en_result,
11489 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11490 TOKEN_STRING_INITIALIZER
11491 (struct cmd_vf_split_drop_en_result,
11493 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11494 TOKEN_STRING_INITIALIZER
11495 (struct cmd_vf_split_drop_en_result,
11497 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11498 TOKEN_STRING_INITIALIZER
11499 (struct cmd_vf_split_drop_en_result,
11501 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11502 TOKEN_NUM_INITIALIZER
11503 (struct cmd_vf_split_drop_en_result,
11505 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11506 TOKEN_NUM_INITIALIZER
11507 (struct cmd_vf_split_drop_en_result,
11509 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11510 TOKEN_STRING_INITIALIZER
11511 (struct cmd_vf_split_drop_en_result,
11515 cmd_set_vf_split_drop_en_parsed(
11516 void *parsed_result,
11517 __attribute__((unused)) struct cmdline *cl,
11518 __attribute__((unused)) void *data)
11520 struct cmd_vf_split_drop_en_result *res = parsed_result;
11522 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11524 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11527 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11533 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11536 printf("invalid port_id %d\n", res->port_id);
11539 printf("programming error: (%s)\n", strerror(-ret));
11543 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11544 .f = cmd_set_vf_split_drop_en_parsed,
11546 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11548 (void *)&cmd_vf_split_drop_en_set,
11549 (void *)&cmd_vf_split_drop_en_vf,
11550 (void *)&cmd_vf_split_drop_en_split,
11551 (void *)&cmd_vf_split_drop_en_drop,
11552 (void *)&cmd_vf_split_drop_en_port_id,
11553 (void *)&cmd_vf_split_drop_en_vf_id,
11554 (void *)&cmd_vf_split_drop_en_on_off,
11560 /* vf mac address configuration */
11562 /* Common result structure for vf mac address */
11563 struct cmd_set_vf_mac_addr_result {
11564 cmdline_fixed_string_t set;
11565 cmdline_fixed_string_t vf;
11566 cmdline_fixed_string_t mac;
11567 cmdline_fixed_string_t addr;
11570 struct ether_addr mac_addr;
11574 /* Common CLI fields for vf split drop enable disable */
11575 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11576 TOKEN_STRING_INITIALIZER
11577 (struct cmd_set_vf_mac_addr_result,
11579 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11580 TOKEN_STRING_INITIALIZER
11581 (struct cmd_set_vf_mac_addr_result,
11583 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11584 TOKEN_STRING_INITIALIZER
11585 (struct cmd_set_vf_mac_addr_result,
11587 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11588 TOKEN_STRING_INITIALIZER
11589 (struct cmd_set_vf_mac_addr_result,
11591 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11592 TOKEN_NUM_INITIALIZER
11593 (struct cmd_set_vf_mac_addr_result,
11595 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11596 TOKEN_NUM_INITIALIZER
11597 (struct cmd_set_vf_mac_addr_result,
11599 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11600 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11604 cmd_set_vf_mac_addr_parsed(
11605 void *parsed_result,
11606 __attribute__((unused)) struct cmdline *cl,
11607 __attribute__((unused)) void *data)
11609 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11610 int ret = -ENOTSUP;
11612 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11615 #ifdef RTE_LIBRTE_IXGBE_PMD
11616 if (ret == -ENOTSUP)
11617 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11620 #ifdef RTE_LIBRTE_I40E_PMD
11621 if (ret == -ENOTSUP)
11622 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11630 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11633 printf("invalid port_id %d\n", res->port_id);
11636 printf("function not implemented\n");
11639 printf("programming error: (%s)\n", strerror(-ret));
11643 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11644 .f = cmd_set_vf_mac_addr_parsed,
11646 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11648 (void *)&cmd_set_vf_mac_addr_set,
11649 (void *)&cmd_set_vf_mac_addr_vf,
11650 (void *)&cmd_set_vf_mac_addr_mac,
11651 (void *)&cmd_set_vf_mac_addr_addr,
11652 (void *)&cmd_set_vf_mac_addr_port_id,
11653 (void *)&cmd_set_vf_mac_addr_vf_id,
11654 (void *)&cmd_set_vf_mac_addr_mac_addr,
11659 #ifdef RTE_LIBRTE_IXGBE_PMD
11660 /* MACsec configuration */
11662 /* Common result structure for MACsec offload enable */
11663 struct cmd_macsec_offload_on_result {
11664 cmdline_fixed_string_t set;
11665 cmdline_fixed_string_t macsec;
11666 cmdline_fixed_string_t offload;
11668 cmdline_fixed_string_t on;
11669 cmdline_fixed_string_t encrypt;
11670 cmdline_fixed_string_t en_on_off;
11671 cmdline_fixed_string_t replay_protect;
11672 cmdline_fixed_string_t rp_on_off;
11675 /* Common CLI fields for MACsec offload disable */
11676 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11677 TOKEN_STRING_INITIALIZER
11678 (struct cmd_macsec_offload_on_result,
11680 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11681 TOKEN_STRING_INITIALIZER
11682 (struct cmd_macsec_offload_on_result,
11684 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11685 TOKEN_STRING_INITIALIZER
11686 (struct cmd_macsec_offload_on_result,
11687 offload, "offload");
11688 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11689 TOKEN_NUM_INITIALIZER
11690 (struct cmd_macsec_offload_on_result,
11692 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11693 TOKEN_STRING_INITIALIZER
11694 (struct cmd_macsec_offload_on_result,
11696 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11697 TOKEN_STRING_INITIALIZER
11698 (struct cmd_macsec_offload_on_result,
11699 encrypt, "encrypt");
11700 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11701 TOKEN_STRING_INITIALIZER
11702 (struct cmd_macsec_offload_on_result,
11703 en_on_off, "on#off");
11704 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11705 TOKEN_STRING_INITIALIZER
11706 (struct cmd_macsec_offload_on_result,
11707 replay_protect, "replay-protect");
11708 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11709 TOKEN_STRING_INITIALIZER
11710 (struct cmd_macsec_offload_on_result,
11711 rp_on_off, "on#off");
11714 cmd_set_macsec_offload_on_parsed(
11715 void *parsed_result,
11716 __attribute__((unused)) struct cmdline *cl,
11717 __attribute__((unused)) void *data)
11719 struct cmd_macsec_offload_on_result *res = parsed_result;
11721 portid_t port_id = res->port_id;
11722 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11723 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11725 if (port_id_is_invalid(port_id, ENABLED_WARN))
11728 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11729 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11735 printf("invalid port_id %d\n", port_id);
11738 printf("programming error: (%s)\n", strerror(-ret));
11742 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11743 .f = cmd_set_macsec_offload_on_parsed,
11745 .help_str = "set macsec offload <port_id> on "
11746 "encrypt on|off replay-protect on|off",
11748 (void *)&cmd_macsec_offload_on_set,
11749 (void *)&cmd_macsec_offload_on_macsec,
11750 (void *)&cmd_macsec_offload_on_offload,
11751 (void *)&cmd_macsec_offload_on_port_id,
11752 (void *)&cmd_macsec_offload_on_on,
11753 (void *)&cmd_macsec_offload_on_encrypt,
11754 (void *)&cmd_macsec_offload_on_en_on_off,
11755 (void *)&cmd_macsec_offload_on_replay_protect,
11756 (void *)&cmd_macsec_offload_on_rp_on_off,
11761 /* Common result structure for MACsec offload disable */
11762 struct cmd_macsec_offload_off_result {
11763 cmdline_fixed_string_t set;
11764 cmdline_fixed_string_t macsec;
11765 cmdline_fixed_string_t offload;
11767 cmdline_fixed_string_t off;
11770 /* Common CLI fields for MACsec offload disable */
11771 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11772 TOKEN_STRING_INITIALIZER
11773 (struct cmd_macsec_offload_off_result,
11775 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11776 TOKEN_STRING_INITIALIZER
11777 (struct cmd_macsec_offload_off_result,
11779 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11780 TOKEN_STRING_INITIALIZER
11781 (struct cmd_macsec_offload_off_result,
11782 offload, "offload");
11783 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11784 TOKEN_NUM_INITIALIZER
11785 (struct cmd_macsec_offload_off_result,
11787 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11788 TOKEN_STRING_INITIALIZER
11789 (struct cmd_macsec_offload_off_result,
11793 cmd_set_macsec_offload_off_parsed(
11794 void *parsed_result,
11795 __attribute__((unused)) struct cmdline *cl,
11796 __attribute__((unused)) void *data)
11798 struct cmd_macsec_offload_off_result *res = parsed_result;
11800 portid_t port_id = res->port_id;
11802 if (port_id_is_invalid(port_id, ENABLED_WARN))
11805 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11806 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11812 printf("invalid port_id %d\n", port_id);
11815 printf("programming error: (%s)\n", strerror(-ret));
11819 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11820 .f = cmd_set_macsec_offload_off_parsed,
11822 .help_str = "set macsec offload <port_id> off",
11824 (void *)&cmd_macsec_offload_off_set,
11825 (void *)&cmd_macsec_offload_off_macsec,
11826 (void *)&cmd_macsec_offload_off_offload,
11827 (void *)&cmd_macsec_offload_off_port_id,
11828 (void *)&cmd_macsec_offload_off_off,
11833 /* Common result structure for MACsec secure connection configure */
11834 struct cmd_macsec_sc_result {
11835 cmdline_fixed_string_t set;
11836 cmdline_fixed_string_t macsec;
11837 cmdline_fixed_string_t sc;
11838 cmdline_fixed_string_t tx_rx;
11840 struct ether_addr mac;
11844 /* Common CLI fields for MACsec secure connection configure */
11845 cmdline_parse_token_string_t cmd_macsec_sc_set =
11846 TOKEN_STRING_INITIALIZER
11847 (struct cmd_macsec_sc_result,
11849 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11850 TOKEN_STRING_INITIALIZER
11851 (struct cmd_macsec_sc_result,
11853 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11854 TOKEN_STRING_INITIALIZER
11855 (struct cmd_macsec_sc_result,
11857 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11858 TOKEN_STRING_INITIALIZER
11859 (struct cmd_macsec_sc_result,
11861 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11862 TOKEN_NUM_INITIALIZER
11863 (struct cmd_macsec_sc_result,
11865 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11866 TOKEN_ETHERADDR_INITIALIZER
11867 (struct cmd_macsec_sc_result,
11869 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11870 TOKEN_NUM_INITIALIZER
11871 (struct cmd_macsec_sc_result,
11875 cmd_set_macsec_sc_parsed(
11876 void *parsed_result,
11877 __attribute__((unused)) struct cmdline *cl,
11878 __attribute__((unused)) void *data)
11880 struct cmd_macsec_sc_result *res = parsed_result;
11882 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11885 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11886 res->mac.addr_bytes) :
11887 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11888 res->mac.addr_bytes, res->pi);
11893 printf("invalid port_id %d\n", res->port_id);
11896 printf("programming error: (%s)\n", strerror(-ret));
11900 cmdline_parse_inst_t cmd_set_macsec_sc = {
11901 .f = cmd_set_macsec_sc_parsed,
11903 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11905 (void *)&cmd_macsec_sc_set,
11906 (void *)&cmd_macsec_sc_macsec,
11907 (void *)&cmd_macsec_sc_sc,
11908 (void *)&cmd_macsec_sc_tx_rx,
11909 (void *)&cmd_macsec_sc_port_id,
11910 (void *)&cmd_macsec_sc_mac,
11911 (void *)&cmd_macsec_sc_pi,
11916 /* Common result structure for MACsec secure connection configure */
11917 struct cmd_macsec_sa_result {
11918 cmdline_fixed_string_t set;
11919 cmdline_fixed_string_t macsec;
11920 cmdline_fixed_string_t sa;
11921 cmdline_fixed_string_t tx_rx;
11926 cmdline_fixed_string_t key;
11929 /* Common CLI fields for MACsec secure connection configure */
11930 cmdline_parse_token_string_t cmd_macsec_sa_set =
11931 TOKEN_STRING_INITIALIZER
11932 (struct cmd_macsec_sa_result,
11934 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11935 TOKEN_STRING_INITIALIZER
11936 (struct cmd_macsec_sa_result,
11938 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11939 TOKEN_STRING_INITIALIZER
11940 (struct cmd_macsec_sa_result,
11942 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11943 TOKEN_STRING_INITIALIZER
11944 (struct cmd_macsec_sa_result,
11946 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11947 TOKEN_NUM_INITIALIZER
11948 (struct cmd_macsec_sa_result,
11950 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11951 TOKEN_NUM_INITIALIZER
11952 (struct cmd_macsec_sa_result,
11954 cmdline_parse_token_num_t cmd_macsec_sa_an =
11955 TOKEN_NUM_INITIALIZER
11956 (struct cmd_macsec_sa_result,
11958 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11959 TOKEN_NUM_INITIALIZER
11960 (struct cmd_macsec_sa_result,
11962 cmdline_parse_token_string_t cmd_macsec_sa_key =
11963 TOKEN_STRING_INITIALIZER
11964 (struct cmd_macsec_sa_result,
11968 cmd_set_macsec_sa_parsed(
11969 void *parsed_result,
11970 __attribute__((unused)) struct cmdline *cl,
11971 __attribute__((unused)) void *data)
11973 struct cmd_macsec_sa_result *res = parsed_result;
11975 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11976 uint8_t key[16] = { 0 };
11982 key_len = strlen(res->key) / 2;
11986 for (i = 0; i < key_len; i++) {
11987 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11990 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11993 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11997 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11998 res->idx, res->an, res->pn, key) :
11999 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12000 res->idx, res->an, res->pn, key);
12005 printf("invalid idx %d or an %d\n", res->idx, res->an);
12008 printf("invalid port_id %d\n", res->port_id);
12011 printf("programming error: (%s)\n", strerror(-ret));
12015 cmdline_parse_inst_t cmd_set_macsec_sa = {
12016 .f = cmd_set_macsec_sa_parsed,
12018 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12020 (void *)&cmd_macsec_sa_set,
12021 (void *)&cmd_macsec_sa_macsec,
12022 (void *)&cmd_macsec_sa_sa,
12023 (void *)&cmd_macsec_sa_tx_rx,
12024 (void *)&cmd_macsec_sa_port_id,
12025 (void *)&cmd_macsec_sa_idx,
12026 (void *)&cmd_macsec_sa_an,
12027 (void *)&cmd_macsec_sa_pn,
12028 (void *)&cmd_macsec_sa_key,
12034 /* VF unicast promiscuous mode configuration */
12036 /* Common result structure for VF unicast promiscuous mode */
12037 struct cmd_vf_promisc_result {
12038 cmdline_fixed_string_t set;
12039 cmdline_fixed_string_t vf;
12040 cmdline_fixed_string_t promisc;
12043 cmdline_fixed_string_t on_off;
12046 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12047 cmdline_parse_token_string_t cmd_vf_promisc_set =
12048 TOKEN_STRING_INITIALIZER
12049 (struct cmd_vf_promisc_result,
12051 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12052 TOKEN_STRING_INITIALIZER
12053 (struct cmd_vf_promisc_result,
12055 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12056 TOKEN_STRING_INITIALIZER
12057 (struct cmd_vf_promisc_result,
12058 promisc, "promisc");
12059 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12060 TOKEN_NUM_INITIALIZER
12061 (struct cmd_vf_promisc_result,
12063 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12064 TOKEN_NUM_INITIALIZER
12065 (struct cmd_vf_promisc_result,
12067 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12068 TOKEN_STRING_INITIALIZER
12069 (struct cmd_vf_promisc_result,
12073 cmd_set_vf_promisc_parsed(
12074 void *parsed_result,
12075 __attribute__((unused)) struct cmdline *cl,
12076 __attribute__((unused)) void *data)
12078 struct cmd_vf_promisc_result *res = parsed_result;
12079 int ret = -ENOTSUP;
12081 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12086 #ifdef RTE_LIBRTE_I40E_PMD
12087 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12088 res->vf_id, is_on);
12095 printf("invalid vf_id %d\n", res->vf_id);
12098 printf("invalid port_id %d\n", res->port_id);
12101 printf("function not implemented\n");
12104 printf("programming error: (%s)\n", strerror(-ret));
12108 cmdline_parse_inst_t cmd_set_vf_promisc = {
12109 .f = cmd_set_vf_promisc_parsed,
12111 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12112 "Set unicast promiscuous mode for a VF from the PF",
12114 (void *)&cmd_vf_promisc_set,
12115 (void *)&cmd_vf_promisc_vf,
12116 (void *)&cmd_vf_promisc_promisc,
12117 (void *)&cmd_vf_promisc_port_id,
12118 (void *)&cmd_vf_promisc_vf_id,
12119 (void *)&cmd_vf_promisc_on_off,
12124 /* VF multicast promiscuous mode configuration */
12126 /* Common result structure for VF multicast promiscuous mode */
12127 struct cmd_vf_allmulti_result {
12128 cmdline_fixed_string_t set;
12129 cmdline_fixed_string_t vf;
12130 cmdline_fixed_string_t allmulti;
12133 cmdline_fixed_string_t on_off;
12136 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12137 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12138 TOKEN_STRING_INITIALIZER
12139 (struct cmd_vf_allmulti_result,
12141 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12142 TOKEN_STRING_INITIALIZER
12143 (struct cmd_vf_allmulti_result,
12145 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12146 TOKEN_STRING_INITIALIZER
12147 (struct cmd_vf_allmulti_result,
12148 allmulti, "allmulti");
12149 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12150 TOKEN_NUM_INITIALIZER
12151 (struct cmd_vf_allmulti_result,
12153 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12154 TOKEN_NUM_INITIALIZER
12155 (struct cmd_vf_allmulti_result,
12157 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12158 TOKEN_STRING_INITIALIZER
12159 (struct cmd_vf_allmulti_result,
12163 cmd_set_vf_allmulti_parsed(
12164 void *parsed_result,
12165 __attribute__((unused)) struct cmdline *cl,
12166 __attribute__((unused)) void *data)
12168 struct cmd_vf_allmulti_result *res = parsed_result;
12169 int ret = -ENOTSUP;
12171 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12173 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12176 #ifdef RTE_LIBRTE_I40E_PMD
12177 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12178 res->vf_id, is_on);
12185 printf("invalid vf_id %d\n", res->vf_id);
12188 printf("invalid port_id %d\n", res->port_id);
12191 printf("function not implemented\n");
12194 printf("programming error: (%s)\n", strerror(-ret));
12198 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12199 .f = cmd_set_vf_allmulti_parsed,
12201 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12202 "Set multicast promiscuous mode for a VF from the PF",
12204 (void *)&cmd_vf_allmulti_set,
12205 (void *)&cmd_vf_allmulti_vf,
12206 (void *)&cmd_vf_allmulti_allmulti,
12207 (void *)&cmd_vf_allmulti_port_id,
12208 (void *)&cmd_vf_allmulti_vf_id,
12209 (void *)&cmd_vf_allmulti_on_off,
12214 /* vf broadcast mode configuration */
12216 /* Common result structure for vf broadcast */
12217 struct cmd_set_vf_broadcast_result {
12218 cmdline_fixed_string_t set;
12219 cmdline_fixed_string_t vf;
12220 cmdline_fixed_string_t broadcast;
12223 cmdline_fixed_string_t on_off;
12226 /* Common CLI fields for vf broadcast enable disable */
12227 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12228 TOKEN_STRING_INITIALIZER
12229 (struct cmd_set_vf_broadcast_result,
12231 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12232 TOKEN_STRING_INITIALIZER
12233 (struct cmd_set_vf_broadcast_result,
12235 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12236 TOKEN_STRING_INITIALIZER
12237 (struct cmd_set_vf_broadcast_result,
12238 broadcast, "broadcast");
12239 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12240 TOKEN_NUM_INITIALIZER
12241 (struct cmd_set_vf_broadcast_result,
12243 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12244 TOKEN_NUM_INITIALIZER
12245 (struct cmd_set_vf_broadcast_result,
12247 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12248 TOKEN_STRING_INITIALIZER
12249 (struct cmd_set_vf_broadcast_result,
12253 cmd_set_vf_broadcast_parsed(
12254 void *parsed_result,
12255 __attribute__((unused)) struct cmdline *cl,
12256 __attribute__((unused)) void *data)
12258 struct cmd_set_vf_broadcast_result *res = parsed_result;
12259 int ret = -ENOTSUP;
12261 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12263 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12266 #ifdef RTE_LIBRTE_I40E_PMD
12267 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12268 res->vf_id, is_on);
12275 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12278 printf("invalid port_id %d\n", res->port_id);
12281 printf("function not implemented\n");
12284 printf("programming error: (%s)\n", strerror(-ret));
12288 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12289 .f = cmd_set_vf_broadcast_parsed,
12291 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12293 (void *)&cmd_set_vf_broadcast_set,
12294 (void *)&cmd_set_vf_broadcast_vf,
12295 (void *)&cmd_set_vf_broadcast_broadcast,
12296 (void *)&cmd_set_vf_broadcast_port_id,
12297 (void *)&cmd_set_vf_broadcast_vf_id,
12298 (void *)&cmd_set_vf_broadcast_on_off,
12303 /* vf vlan tag configuration */
12305 /* Common result structure for vf vlan tag */
12306 struct cmd_set_vf_vlan_tag_result {
12307 cmdline_fixed_string_t set;
12308 cmdline_fixed_string_t vf;
12309 cmdline_fixed_string_t vlan;
12310 cmdline_fixed_string_t tag;
12313 cmdline_fixed_string_t on_off;
12316 /* Common CLI fields for vf vlan tag enable disable */
12317 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12318 TOKEN_STRING_INITIALIZER
12319 (struct cmd_set_vf_vlan_tag_result,
12321 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12322 TOKEN_STRING_INITIALIZER
12323 (struct cmd_set_vf_vlan_tag_result,
12325 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12326 TOKEN_STRING_INITIALIZER
12327 (struct cmd_set_vf_vlan_tag_result,
12329 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12330 TOKEN_STRING_INITIALIZER
12331 (struct cmd_set_vf_vlan_tag_result,
12333 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12334 TOKEN_NUM_INITIALIZER
12335 (struct cmd_set_vf_vlan_tag_result,
12337 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12338 TOKEN_NUM_INITIALIZER
12339 (struct cmd_set_vf_vlan_tag_result,
12341 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12342 TOKEN_STRING_INITIALIZER
12343 (struct cmd_set_vf_vlan_tag_result,
12347 cmd_set_vf_vlan_tag_parsed(
12348 void *parsed_result,
12349 __attribute__((unused)) struct cmdline *cl,
12350 __attribute__((unused)) void *data)
12352 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12353 int ret = -ENOTSUP;
12355 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12357 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12360 #ifdef RTE_LIBRTE_I40E_PMD
12361 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12362 res->vf_id, is_on);
12369 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12372 printf("invalid port_id %d\n", res->port_id);
12375 printf("function not implemented\n");
12378 printf("programming error: (%s)\n", strerror(-ret));
12382 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12383 .f = cmd_set_vf_vlan_tag_parsed,
12385 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12387 (void *)&cmd_set_vf_vlan_tag_set,
12388 (void *)&cmd_set_vf_vlan_tag_vf,
12389 (void *)&cmd_set_vf_vlan_tag_vlan,
12390 (void *)&cmd_set_vf_vlan_tag_tag,
12391 (void *)&cmd_set_vf_vlan_tag_port_id,
12392 (void *)&cmd_set_vf_vlan_tag_vf_id,
12393 (void *)&cmd_set_vf_vlan_tag_on_off,
12398 /* ******************************************************************************** */
12400 /* list of instructions */
12401 cmdline_parse_ctx_t main_ctx[] = {
12402 (cmdline_parse_inst_t *)&cmd_help_brief,
12403 (cmdline_parse_inst_t *)&cmd_help_long,
12404 (cmdline_parse_inst_t *)&cmd_quit,
12405 (cmdline_parse_inst_t *)&cmd_showport,
12406 (cmdline_parse_inst_t *)&cmd_showqueue,
12407 (cmdline_parse_inst_t *)&cmd_showportall,
12408 (cmdline_parse_inst_t *)&cmd_showcfg,
12409 (cmdline_parse_inst_t *)&cmd_start,
12410 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12411 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12412 (cmdline_parse_inst_t *)&cmd_set_link_up,
12413 (cmdline_parse_inst_t *)&cmd_set_link_down,
12414 (cmdline_parse_inst_t *)&cmd_reset,
12415 (cmdline_parse_inst_t *)&cmd_set_numbers,
12416 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12417 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12418 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12419 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12420 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12421 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12422 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12423 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12424 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12425 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12426 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12427 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12428 (cmdline_parse_inst_t *)&cmd_set_link_check,
12429 #ifdef RTE_NIC_BYPASS
12430 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12431 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12432 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12433 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12435 #ifdef RTE_LIBRTE_PMD_BOND
12436 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12437 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12438 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12439 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12440 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12441 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12442 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12443 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12444 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12446 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12447 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12448 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12449 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12450 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12451 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12452 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12453 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12454 (cmdline_parse_inst_t *)&cmd_csum_set,
12455 (cmdline_parse_inst_t *)&cmd_csum_show,
12456 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12457 (cmdline_parse_inst_t *)&cmd_tso_set,
12458 (cmdline_parse_inst_t *)&cmd_tso_show,
12459 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12460 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12461 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12462 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12463 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12464 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12465 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12466 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12467 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12468 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12469 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12470 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12471 (cmdline_parse_inst_t *)&cmd_config_dcb,
12472 (cmdline_parse_inst_t *)&cmd_read_reg,
12473 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12474 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12475 (cmdline_parse_inst_t *)&cmd_write_reg,
12476 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12477 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12478 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12479 (cmdline_parse_inst_t *)&cmd_stop,
12480 (cmdline_parse_inst_t *)&cmd_mac_addr,
12481 (cmdline_parse_inst_t *)&cmd_set_qmap,
12482 (cmdline_parse_inst_t *)&cmd_operate_port,
12483 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12484 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12485 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12486 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12487 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12488 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12489 (cmdline_parse_inst_t *)&cmd_config_mtu,
12490 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12491 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12492 (cmdline_parse_inst_t *)&cmd_config_rss,
12493 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12494 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12495 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12496 (cmdline_parse_inst_t *)&cmd_showport_reta,
12497 (cmdline_parse_inst_t *)&cmd_config_burst,
12498 (cmdline_parse_inst_t *)&cmd_config_thresh,
12499 (cmdline_parse_inst_t *)&cmd_config_threshold,
12500 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12501 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12502 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12503 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12504 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12505 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12506 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12507 (cmdline_parse_inst_t *)&cmd_global_config,
12508 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12509 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12510 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12511 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12512 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12513 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12514 (cmdline_parse_inst_t *)&cmd_dump,
12515 (cmdline_parse_inst_t *)&cmd_dump_one,
12516 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12517 (cmdline_parse_inst_t *)&cmd_syn_filter,
12518 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12519 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12520 (cmdline_parse_inst_t *)&cmd_flex_filter,
12521 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12522 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12523 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12524 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12525 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12526 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12527 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12528 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12529 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12530 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12531 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12532 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12533 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12534 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12535 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12536 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12537 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12538 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12539 (cmdline_parse_inst_t *)&cmd_flow,
12540 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12541 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12542 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12543 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12544 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12545 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12546 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12547 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12548 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12549 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12550 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12551 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12552 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12553 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12554 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12555 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12556 #ifdef RTE_LIBRTE_IXGBE_PMD
12557 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12558 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12559 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12560 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12561 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12562 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12563 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12564 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12565 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12567 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12568 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12569 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12570 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12571 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
12572 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
12576 /* prompt function, called from main on MASTER lcore */
12580 /* initialize non-constant commands */
12581 cmd_set_fwd_mode_init();
12582 cmd_set_fwd_retry_mode_init();
12584 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12585 if (testpmd_cl == NULL)
12587 cmdline_interact(testpmd_cl);
12588 cmdline_stdin_exit(testpmd_cl);
12594 if (testpmd_cl != NULL)
12595 cmdline_quit(testpmd_cl);
12599 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12601 if (id == (portid_t)RTE_PORT_ALL) {
12604 FOREACH_PORT(pid, ports) {
12605 /* check if need_reconfig has been set to 1 */
12606 if (ports[pid].need_reconfig == 0)
12607 ports[pid].need_reconfig = dev;
12608 /* check if need_reconfig_queues has been set to 1 */
12609 if (ports[pid].need_reconfig_queues == 0)
12610 ports[pid].need_reconfig_queues = queue;
12612 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12613 /* check if need_reconfig has been set to 1 */
12614 if (ports[id].need_reconfig == 0)
12615 ports[id].need_reconfig = dev;
12616 /* check if need_reconfig_queues has been set to 1 */
12617 if (ports[id].need_reconfig_queues == 0)
12618 ports[id].need_reconfig_queues = queue;