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) (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);
5842 cmdline_parse_token_string_t cmd_showportall_show =
5843 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5845 cmdline_parse_token_string_t cmd_showportall_port =
5846 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5847 cmdline_parse_token_string_t cmd_showportall_what =
5848 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5849 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5850 cmdline_parse_token_string_t cmd_showportall_all =
5851 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5852 cmdline_parse_inst_t cmd_showportall = {
5853 .f = cmd_showportall_parsed,
5855 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5857 (void *)&cmd_showportall_show,
5858 (void *)&cmd_showportall_port,
5859 (void *)&cmd_showportall_what,
5860 (void *)&cmd_showportall_all,
5865 /* *** SHOW PORT INFO *** */
5866 struct cmd_showport_result {
5867 cmdline_fixed_string_t show;
5868 cmdline_fixed_string_t port;
5869 cmdline_fixed_string_t what;
5873 static void cmd_showport_parsed(void *parsed_result,
5874 __attribute__((unused)) struct cmdline *cl,
5875 __attribute__((unused)) void *data)
5877 struct cmd_showport_result *res = parsed_result;
5878 if (!strcmp(res->show, "clear")) {
5879 if (!strcmp(res->what, "stats"))
5880 nic_stats_clear(res->portnum);
5881 else if (!strcmp(res->what, "xstats"))
5882 nic_xstats_clear(res->portnum);
5883 } else if (!strcmp(res->what, "info"))
5884 port_infos_display(res->portnum);
5885 else if (!strcmp(res->what, "stats"))
5886 nic_stats_display(res->portnum);
5887 else if (!strcmp(res->what, "xstats"))
5888 nic_xstats_display(res->portnum);
5889 else if (!strcmp(res->what, "fdir"))
5890 fdir_get_infos(res->portnum);
5891 else if (!strcmp(res->what, "stat_qmap"))
5892 nic_stats_mapping_display(res->portnum);
5893 else if (!strcmp(res->what, "dcb_tc"))
5894 port_dcb_info_display(res->portnum);
5897 cmdline_parse_token_string_t cmd_showport_show =
5898 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5900 cmdline_parse_token_string_t cmd_showport_port =
5901 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5902 cmdline_parse_token_string_t cmd_showport_what =
5903 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5904 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5905 cmdline_parse_token_num_t cmd_showport_portnum =
5906 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5908 cmdline_parse_inst_t cmd_showport = {
5909 .f = cmd_showport_parsed,
5911 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5914 (void *)&cmd_showport_show,
5915 (void *)&cmd_showport_port,
5916 (void *)&cmd_showport_what,
5917 (void *)&cmd_showport_portnum,
5922 /* *** SHOW QUEUE INFO *** */
5923 struct cmd_showqueue_result {
5924 cmdline_fixed_string_t show;
5925 cmdline_fixed_string_t type;
5926 cmdline_fixed_string_t what;
5932 cmd_showqueue_parsed(void *parsed_result,
5933 __attribute__((unused)) struct cmdline *cl,
5934 __attribute__((unused)) void *data)
5936 struct cmd_showqueue_result *res = parsed_result;
5938 if (!strcmp(res->type, "rxq"))
5939 rx_queue_infos_display(res->portnum, res->queuenum);
5940 else if (!strcmp(res->type, "txq"))
5941 tx_queue_infos_display(res->portnum, res->queuenum);
5944 cmdline_parse_token_string_t cmd_showqueue_show =
5945 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5946 cmdline_parse_token_string_t cmd_showqueue_type =
5947 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5948 cmdline_parse_token_string_t cmd_showqueue_what =
5949 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5950 cmdline_parse_token_num_t cmd_showqueue_portnum =
5951 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5952 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5953 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5955 cmdline_parse_inst_t cmd_showqueue = {
5956 .f = cmd_showqueue_parsed,
5958 .help_str = "show rxq|txq info <port_id> <queue_id>",
5960 (void *)&cmd_showqueue_show,
5961 (void *)&cmd_showqueue_type,
5962 (void *)&cmd_showqueue_what,
5963 (void *)&cmd_showqueue_portnum,
5964 (void *)&cmd_showqueue_queuenum,
5969 /* *** READ PORT REGISTER *** */
5970 struct cmd_read_reg_result {
5971 cmdline_fixed_string_t read;
5972 cmdline_fixed_string_t reg;
5978 cmd_read_reg_parsed(void *parsed_result,
5979 __attribute__((unused)) struct cmdline *cl,
5980 __attribute__((unused)) void *data)
5982 struct cmd_read_reg_result *res = parsed_result;
5983 port_reg_display(res->port_id, res->reg_off);
5986 cmdline_parse_token_string_t cmd_read_reg_read =
5987 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5988 cmdline_parse_token_string_t cmd_read_reg_reg =
5989 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5990 cmdline_parse_token_num_t cmd_read_reg_port_id =
5991 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5992 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5993 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5995 cmdline_parse_inst_t cmd_read_reg = {
5996 .f = cmd_read_reg_parsed,
5998 .help_str = "read reg <port_id> <reg_off>",
6000 (void *)&cmd_read_reg_read,
6001 (void *)&cmd_read_reg_reg,
6002 (void *)&cmd_read_reg_port_id,
6003 (void *)&cmd_read_reg_reg_off,
6008 /* *** READ PORT REGISTER BIT FIELD *** */
6009 struct cmd_read_reg_bit_field_result {
6010 cmdline_fixed_string_t read;
6011 cmdline_fixed_string_t regfield;
6019 cmd_read_reg_bit_field_parsed(void *parsed_result,
6020 __attribute__((unused)) struct cmdline *cl,
6021 __attribute__((unused)) void *data)
6023 struct cmd_read_reg_bit_field_result *res = parsed_result;
6024 port_reg_bit_field_display(res->port_id, res->reg_off,
6025 res->bit1_pos, res->bit2_pos);
6028 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6029 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6031 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6032 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6033 regfield, "regfield");
6034 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6035 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6037 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6038 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6040 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6041 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6043 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6044 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6047 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6048 .f = cmd_read_reg_bit_field_parsed,
6050 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6051 "Read register bit field between bit_x and bit_y included",
6053 (void *)&cmd_read_reg_bit_field_read,
6054 (void *)&cmd_read_reg_bit_field_regfield,
6055 (void *)&cmd_read_reg_bit_field_port_id,
6056 (void *)&cmd_read_reg_bit_field_reg_off,
6057 (void *)&cmd_read_reg_bit_field_bit1_pos,
6058 (void *)&cmd_read_reg_bit_field_bit2_pos,
6063 /* *** READ PORT REGISTER BIT *** */
6064 struct cmd_read_reg_bit_result {
6065 cmdline_fixed_string_t read;
6066 cmdline_fixed_string_t regbit;
6073 cmd_read_reg_bit_parsed(void *parsed_result,
6074 __attribute__((unused)) struct cmdline *cl,
6075 __attribute__((unused)) void *data)
6077 struct cmd_read_reg_bit_result *res = parsed_result;
6078 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6081 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6082 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6083 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6084 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6086 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6087 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6088 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6089 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6090 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6091 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6093 cmdline_parse_inst_t cmd_read_reg_bit = {
6094 .f = cmd_read_reg_bit_parsed,
6096 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6098 (void *)&cmd_read_reg_bit_read,
6099 (void *)&cmd_read_reg_bit_regbit,
6100 (void *)&cmd_read_reg_bit_port_id,
6101 (void *)&cmd_read_reg_bit_reg_off,
6102 (void *)&cmd_read_reg_bit_bit_pos,
6107 /* *** WRITE PORT REGISTER *** */
6108 struct cmd_write_reg_result {
6109 cmdline_fixed_string_t write;
6110 cmdline_fixed_string_t reg;
6117 cmd_write_reg_parsed(void *parsed_result,
6118 __attribute__((unused)) struct cmdline *cl,
6119 __attribute__((unused)) void *data)
6121 struct cmd_write_reg_result *res = parsed_result;
6122 port_reg_set(res->port_id, res->reg_off, res->value);
6125 cmdline_parse_token_string_t cmd_write_reg_write =
6126 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6127 cmdline_parse_token_string_t cmd_write_reg_reg =
6128 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6129 cmdline_parse_token_num_t cmd_write_reg_port_id =
6130 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6131 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6132 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6133 cmdline_parse_token_num_t cmd_write_reg_value =
6134 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6136 cmdline_parse_inst_t cmd_write_reg = {
6137 .f = cmd_write_reg_parsed,
6139 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6141 (void *)&cmd_write_reg_write,
6142 (void *)&cmd_write_reg_reg,
6143 (void *)&cmd_write_reg_port_id,
6144 (void *)&cmd_write_reg_reg_off,
6145 (void *)&cmd_write_reg_value,
6150 /* *** WRITE PORT REGISTER BIT FIELD *** */
6151 struct cmd_write_reg_bit_field_result {
6152 cmdline_fixed_string_t write;
6153 cmdline_fixed_string_t regfield;
6162 cmd_write_reg_bit_field_parsed(void *parsed_result,
6163 __attribute__((unused)) struct cmdline *cl,
6164 __attribute__((unused)) void *data)
6166 struct cmd_write_reg_bit_field_result *res = parsed_result;
6167 port_reg_bit_field_set(res->port_id, res->reg_off,
6168 res->bit1_pos, res->bit2_pos, res->value);
6171 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6172 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6174 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6175 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6176 regfield, "regfield");
6177 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6178 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6180 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6181 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6183 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6184 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6186 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6187 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6189 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6190 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6193 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6194 .f = cmd_write_reg_bit_field_parsed,
6196 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6198 "Set register bit field between bit_x and bit_y included",
6200 (void *)&cmd_write_reg_bit_field_write,
6201 (void *)&cmd_write_reg_bit_field_regfield,
6202 (void *)&cmd_write_reg_bit_field_port_id,
6203 (void *)&cmd_write_reg_bit_field_reg_off,
6204 (void *)&cmd_write_reg_bit_field_bit1_pos,
6205 (void *)&cmd_write_reg_bit_field_bit2_pos,
6206 (void *)&cmd_write_reg_bit_field_value,
6211 /* *** WRITE PORT REGISTER BIT *** */
6212 struct cmd_write_reg_bit_result {
6213 cmdline_fixed_string_t write;
6214 cmdline_fixed_string_t regbit;
6222 cmd_write_reg_bit_parsed(void *parsed_result,
6223 __attribute__((unused)) struct cmdline *cl,
6224 __attribute__((unused)) void *data)
6226 struct cmd_write_reg_bit_result *res = parsed_result;
6227 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6230 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6231 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6233 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6234 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6236 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6237 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6238 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6239 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6240 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6241 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6242 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6243 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6245 cmdline_parse_inst_t cmd_write_reg_bit = {
6246 .f = cmd_write_reg_bit_parsed,
6248 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6251 (void *)&cmd_write_reg_bit_write,
6252 (void *)&cmd_write_reg_bit_regbit,
6253 (void *)&cmd_write_reg_bit_port_id,
6254 (void *)&cmd_write_reg_bit_reg_off,
6255 (void *)&cmd_write_reg_bit_bit_pos,
6256 (void *)&cmd_write_reg_bit_value,
6261 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6262 struct cmd_read_rxd_txd_result {
6263 cmdline_fixed_string_t read;
6264 cmdline_fixed_string_t rxd_txd;
6271 cmd_read_rxd_txd_parsed(void *parsed_result,
6272 __attribute__((unused)) struct cmdline *cl,
6273 __attribute__((unused)) void *data)
6275 struct cmd_read_rxd_txd_result *res = parsed_result;
6277 if (!strcmp(res->rxd_txd, "rxd"))
6278 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6279 else if (!strcmp(res->rxd_txd, "txd"))
6280 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6283 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6284 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6285 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6286 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6288 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6289 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6290 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6291 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6292 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6293 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6295 cmdline_parse_inst_t cmd_read_rxd_txd = {
6296 .f = cmd_read_rxd_txd_parsed,
6298 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6300 (void *)&cmd_read_rxd_txd_read,
6301 (void *)&cmd_read_rxd_txd_rxd_txd,
6302 (void *)&cmd_read_rxd_txd_port_id,
6303 (void *)&cmd_read_rxd_txd_queue_id,
6304 (void *)&cmd_read_rxd_txd_desc_id,
6310 struct cmd_quit_result {
6311 cmdline_fixed_string_t quit;
6314 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6316 __attribute__((unused)) void *data)
6322 cmdline_parse_token_string_t cmd_quit_quit =
6323 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6325 cmdline_parse_inst_t cmd_quit = {
6326 .f = cmd_quit_parsed,
6328 .help_str = "quit: Exit application",
6330 (void *)&cmd_quit_quit,
6335 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6336 struct cmd_mac_addr_result {
6337 cmdline_fixed_string_t mac_addr_cmd;
6338 cmdline_fixed_string_t what;
6340 struct ether_addr address;
6343 static void cmd_mac_addr_parsed(void *parsed_result,
6344 __attribute__((unused)) struct cmdline *cl,
6345 __attribute__((unused)) void *data)
6347 struct cmd_mac_addr_result *res = parsed_result;
6350 if (strcmp(res->what, "add") == 0)
6351 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6353 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6355 /* check the return value and print it if is < 0 */
6357 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6361 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6362 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6364 cmdline_parse_token_string_t cmd_mac_addr_what =
6365 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6367 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6368 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6369 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6370 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6372 cmdline_parse_inst_t cmd_mac_addr = {
6373 .f = cmd_mac_addr_parsed,
6375 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6376 "Add/Remove MAC address on port_id",
6378 (void *)&cmd_mac_addr_cmd,
6379 (void *)&cmd_mac_addr_what,
6380 (void *)&cmd_mac_addr_portnum,
6381 (void *)&cmd_mac_addr_addr,
6387 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6388 struct cmd_set_qmap_result {
6389 cmdline_fixed_string_t set;
6390 cmdline_fixed_string_t qmap;
6391 cmdline_fixed_string_t what;
6398 cmd_set_qmap_parsed(void *parsed_result,
6399 __attribute__((unused)) struct cmdline *cl,
6400 __attribute__((unused)) void *data)
6402 struct cmd_set_qmap_result *res = parsed_result;
6403 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6405 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6408 cmdline_parse_token_string_t cmd_setqmap_set =
6409 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6411 cmdline_parse_token_string_t cmd_setqmap_qmap =
6412 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6414 cmdline_parse_token_string_t cmd_setqmap_what =
6415 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6417 cmdline_parse_token_num_t cmd_setqmap_portid =
6418 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6420 cmdline_parse_token_num_t cmd_setqmap_queueid =
6421 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6423 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6424 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6427 cmdline_parse_inst_t cmd_set_qmap = {
6428 .f = cmd_set_qmap_parsed,
6430 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6431 "Set statistics mapping value on tx|rx queue_id of port_id",
6433 (void *)&cmd_setqmap_set,
6434 (void *)&cmd_setqmap_qmap,
6435 (void *)&cmd_setqmap_what,
6436 (void *)&cmd_setqmap_portid,
6437 (void *)&cmd_setqmap_queueid,
6438 (void *)&cmd_setqmap_mapvalue,
6443 /* *** CONFIGURE UNICAST HASH TABLE *** */
6444 struct cmd_set_uc_hash_table {
6445 cmdline_fixed_string_t set;
6446 cmdline_fixed_string_t port;
6448 cmdline_fixed_string_t what;
6449 struct ether_addr address;
6450 cmdline_fixed_string_t mode;
6454 cmd_set_uc_hash_parsed(void *parsed_result,
6455 __attribute__((unused)) struct cmdline *cl,
6456 __attribute__((unused)) void *data)
6459 struct cmd_set_uc_hash_table *res = parsed_result;
6461 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6463 if (strcmp(res->what, "uta") == 0)
6464 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6465 &res->address,(uint8_t)is_on);
6467 printf("bad unicast hash table parameter, return code = %d \n", ret);
6471 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6474 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6477 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6478 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6480 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6481 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6483 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6484 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6486 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6487 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6490 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6491 .f = cmd_set_uc_hash_parsed,
6493 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6495 (void *)&cmd_set_uc_hash_set,
6496 (void *)&cmd_set_uc_hash_port,
6497 (void *)&cmd_set_uc_hash_portid,
6498 (void *)&cmd_set_uc_hash_what,
6499 (void *)&cmd_set_uc_hash_mac,
6500 (void *)&cmd_set_uc_hash_mode,
6505 struct cmd_set_uc_all_hash_table {
6506 cmdline_fixed_string_t set;
6507 cmdline_fixed_string_t port;
6509 cmdline_fixed_string_t what;
6510 cmdline_fixed_string_t value;
6511 cmdline_fixed_string_t mode;
6515 cmd_set_uc_all_hash_parsed(void *parsed_result,
6516 __attribute__((unused)) struct cmdline *cl,
6517 __attribute__((unused)) void *data)
6520 struct cmd_set_uc_all_hash_table *res = parsed_result;
6522 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6524 if ((strcmp(res->what, "uta") == 0) &&
6525 (strcmp(res->value, "all") == 0))
6526 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6528 printf("bad unicast hash table parameter,"
6529 "return code = %d \n", ret);
6532 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6533 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6535 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6536 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6538 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6539 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6541 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6542 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6544 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6547 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6548 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6551 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6552 .f = cmd_set_uc_all_hash_parsed,
6554 .help_str = "set port <port_id> uta all on|off",
6556 (void *)&cmd_set_uc_all_hash_set,
6557 (void *)&cmd_set_uc_all_hash_port,
6558 (void *)&cmd_set_uc_all_hash_portid,
6559 (void *)&cmd_set_uc_all_hash_what,
6560 (void *)&cmd_set_uc_all_hash_value,
6561 (void *)&cmd_set_uc_all_hash_mode,
6566 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6567 struct cmd_set_vf_macvlan_filter {
6568 cmdline_fixed_string_t set;
6569 cmdline_fixed_string_t port;
6571 cmdline_fixed_string_t vf;
6573 struct ether_addr address;
6574 cmdline_fixed_string_t filter_type;
6575 cmdline_fixed_string_t mode;
6579 cmd_set_vf_macvlan_parsed(void *parsed_result,
6580 __attribute__((unused)) struct cmdline *cl,
6581 __attribute__((unused)) void *data)
6584 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6585 struct rte_eth_mac_filter filter;
6587 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6589 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6591 /* set VF MAC filter */
6595 filter.dst_id = res->vf_id;
6597 if (!strcmp(res->filter_type, "exact-mac"))
6598 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6599 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6600 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6601 else if (!strcmp(res->filter_type, "hashmac"))
6602 filter.filter_type = RTE_MAC_HASH_MATCH;
6603 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6604 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6606 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6609 ret = rte_eth_dev_filter_ctrl(res->port_id,
6610 RTE_ETH_FILTER_MACVLAN,
6614 ret = rte_eth_dev_filter_ctrl(res->port_id,
6615 RTE_ETH_FILTER_MACVLAN,
6616 RTE_ETH_FILTER_DELETE,
6620 printf("bad set MAC hash parameter, return code = %d\n", ret);
6624 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6625 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6627 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6628 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6630 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6631 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6633 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6634 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6636 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6637 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6639 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6640 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6642 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6643 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6644 filter_type, "exact-mac#exact-mac-vlan"
6645 "#hashmac#hashmac-vlan");
6646 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6650 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6651 .f = cmd_set_vf_macvlan_parsed,
6653 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6654 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6655 "Exact match rule: exact match of MAC or MAC and VLAN; "
6656 "hash match rule: hash match of MAC and exact match of VLAN",
6658 (void *)&cmd_set_vf_macvlan_set,
6659 (void *)&cmd_set_vf_macvlan_port,
6660 (void *)&cmd_set_vf_macvlan_portid,
6661 (void *)&cmd_set_vf_macvlan_vf,
6662 (void *)&cmd_set_vf_macvlan_vf_id,
6663 (void *)&cmd_set_vf_macvlan_mac,
6664 (void *)&cmd_set_vf_macvlan_filter_type,
6665 (void *)&cmd_set_vf_macvlan_mode,
6670 #ifdef RTE_LIBRTE_IXGBE_PMD
6671 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6672 struct cmd_set_vf_traffic {
6673 cmdline_fixed_string_t set;
6674 cmdline_fixed_string_t port;
6676 cmdline_fixed_string_t vf;
6678 cmdline_fixed_string_t what;
6679 cmdline_fixed_string_t mode;
6683 cmd_set_vf_traffic_parsed(void *parsed_result,
6684 __attribute__((unused)) struct cmdline *cl,
6685 __attribute__((unused)) void *data)
6687 struct cmd_set_vf_traffic *res = parsed_result;
6688 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6689 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6691 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6694 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6695 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6697 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6698 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6700 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6701 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6703 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6704 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6706 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6707 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6709 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6710 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6712 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6713 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6716 cmdline_parse_inst_t cmd_set_vf_traffic = {
6717 .f = cmd_set_vf_traffic_parsed,
6719 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6721 (void *)&cmd_setvf_traffic_set,
6722 (void *)&cmd_setvf_traffic_port,
6723 (void *)&cmd_setvf_traffic_portid,
6724 (void *)&cmd_setvf_traffic_vf,
6725 (void *)&cmd_setvf_traffic_vfid,
6726 (void *)&cmd_setvf_traffic_what,
6727 (void *)&cmd_setvf_traffic_mode,
6732 /* *** CONFIGURE VF RECEIVE MODE *** */
6733 struct cmd_set_vf_rxmode {
6734 cmdline_fixed_string_t set;
6735 cmdline_fixed_string_t port;
6737 cmdline_fixed_string_t vf;
6739 cmdline_fixed_string_t what;
6740 cmdline_fixed_string_t mode;
6741 cmdline_fixed_string_t on;
6745 cmd_set_vf_rxmode_parsed(void *parsed_result,
6746 __attribute__((unused)) struct cmdline *cl,
6747 __attribute__((unused)) void *data)
6750 uint16_t rx_mode = 0;
6751 struct cmd_set_vf_rxmode *res = parsed_result;
6753 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6754 if (!strcmp(res->what,"rxmode")) {
6755 if (!strcmp(res->mode, "AUPE"))
6756 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6757 else if (!strcmp(res->mode, "ROPE"))
6758 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6759 else if (!strcmp(res->mode, "BAM"))
6760 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6761 else if (!strncmp(res->mode, "MPE",3))
6762 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6765 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6767 printf("bad VF receive mode parameter, return code = %d \n",
6771 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6774 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6775 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6777 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6778 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6780 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6781 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6783 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6784 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6786 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6787 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6789 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6790 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6791 mode, "AUPE#ROPE#BAM#MPE");
6792 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6793 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6796 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6797 .f = cmd_set_vf_rxmode_parsed,
6799 .help_str = "set port <port_id> vf <vf_id> rxmode "
6800 "AUPE|ROPE|BAM|MPE on|off",
6802 (void *)&cmd_set_vf_rxmode_set,
6803 (void *)&cmd_set_vf_rxmode_port,
6804 (void *)&cmd_set_vf_rxmode_portid,
6805 (void *)&cmd_set_vf_rxmode_vf,
6806 (void *)&cmd_set_vf_rxmode_vfid,
6807 (void *)&cmd_set_vf_rxmode_what,
6808 (void *)&cmd_set_vf_rxmode_mode,
6809 (void *)&cmd_set_vf_rxmode_on,
6815 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6816 struct cmd_vf_mac_addr_result {
6817 cmdline_fixed_string_t mac_addr_cmd;
6818 cmdline_fixed_string_t what;
6819 cmdline_fixed_string_t port;
6821 cmdline_fixed_string_t vf;
6823 struct ether_addr address;
6826 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6827 __attribute__((unused)) struct cmdline *cl,
6828 __attribute__((unused)) void *data)
6830 struct cmd_vf_mac_addr_result *res = parsed_result;
6833 if (strcmp(res->what, "add") == 0)
6834 ret = rte_eth_dev_mac_addr_add(res->port_num,
6835 &res->address, res->vf_num);
6837 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6841 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6842 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6843 mac_addr_cmd,"mac_addr");
6844 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6845 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6847 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6848 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6850 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6851 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6853 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6854 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6856 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6857 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6859 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6860 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6863 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6864 .f = cmd_vf_mac_addr_parsed,
6866 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6867 "Add MAC address filtering for a VF on port_id",
6869 (void *)&cmd_vf_mac_addr_cmd,
6870 (void *)&cmd_vf_mac_addr_what,
6871 (void *)&cmd_vf_mac_addr_port,
6872 (void *)&cmd_vf_mac_addr_portnum,
6873 (void *)&cmd_vf_mac_addr_vf,
6874 (void *)&cmd_vf_mac_addr_vfnum,
6875 (void *)&cmd_vf_mac_addr_addr,
6880 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6881 struct cmd_vf_rx_vlan_filter {
6882 cmdline_fixed_string_t rx_vlan;
6883 cmdline_fixed_string_t what;
6885 cmdline_fixed_string_t port;
6887 cmdline_fixed_string_t vf;
6892 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6893 __attribute__((unused)) struct cmdline *cl,
6894 __attribute__((unused)) void *data)
6896 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6899 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6901 #ifdef RTE_LIBRTE_IXGBE_PMD
6902 if (ret == -ENOTSUP)
6903 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6904 res->vlan_id, res->vf_mask, is_add);
6906 #ifdef RTE_LIBRTE_I40E_PMD
6907 if (ret == -ENOTSUP)
6908 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6909 res->vlan_id, res->vf_mask, is_add);
6916 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6917 res->vlan_id, res->vf_mask);
6920 printf("invalid port_id %d\n", res->port_id);
6923 printf("function not implemented or supported\n");
6926 printf("programming error: (%s)\n", strerror(-ret));
6930 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6931 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6932 rx_vlan, "rx_vlan");
6933 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6934 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6936 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6937 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6939 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6940 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6942 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6943 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6945 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6946 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6948 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6949 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6952 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6953 .f = cmd_vf_rx_vlan_filter_parsed,
6955 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6956 "(vf_mask = hexadecimal VF mask)",
6958 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6959 (void *)&cmd_vf_rx_vlan_filter_what,
6960 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6961 (void *)&cmd_vf_rx_vlan_filter_port,
6962 (void *)&cmd_vf_rx_vlan_filter_portid,
6963 (void *)&cmd_vf_rx_vlan_filter_vf,
6964 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6969 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6970 struct cmd_queue_rate_limit_result {
6971 cmdline_fixed_string_t set;
6972 cmdline_fixed_string_t port;
6974 cmdline_fixed_string_t queue;
6976 cmdline_fixed_string_t rate;
6980 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6981 __attribute__((unused)) struct cmdline *cl,
6982 __attribute__((unused)) void *data)
6984 struct cmd_queue_rate_limit_result *res = parsed_result;
6987 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6988 && (strcmp(res->queue, "queue") == 0)
6989 && (strcmp(res->rate, "rate") == 0))
6990 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6993 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6997 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6998 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7000 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7001 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7003 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7004 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7006 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7007 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7009 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7010 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7012 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7013 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7015 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7016 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7019 cmdline_parse_inst_t cmd_queue_rate_limit = {
7020 .f = cmd_queue_rate_limit_parsed,
7022 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7023 "Set rate limit for a queue on port_id",
7025 (void *)&cmd_queue_rate_limit_set,
7026 (void *)&cmd_queue_rate_limit_port,
7027 (void *)&cmd_queue_rate_limit_portnum,
7028 (void *)&cmd_queue_rate_limit_queue,
7029 (void *)&cmd_queue_rate_limit_queuenum,
7030 (void *)&cmd_queue_rate_limit_rate,
7031 (void *)&cmd_queue_rate_limit_ratenum,
7036 #ifdef RTE_LIBRTE_IXGBE_PMD
7037 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7038 struct cmd_vf_rate_limit_result {
7039 cmdline_fixed_string_t set;
7040 cmdline_fixed_string_t port;
7042 cmdline_fixed_string_t vf;
7044 cmdline_fixed_string_t rate;
7046 cmdline_fixed_string_t q_msk;
7050 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7051 __attribute__((unused)) struct cmdline *cl,
7052 __attribute__((unused)) void *data)
7054 struct cmd_vf_rate_limit_result *res = parsed_result;
7057 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7058 && (strcmp(res->vf, "vf") == 0)
7059 && (strcmp(res->rate, "rate") == 0)
7060 && (strcmp(res->q_msk, "queue_mask") == 0))
7061 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7062 res->rate_num, res->q_msk_val);
7064 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7068 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7069 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7071 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7072 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7074 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7075 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7077 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7078 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7080 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7081 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7083 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7084 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7086 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7087 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7089 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7090 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7091 q_msk, "queue_mask");
7092 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7093 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7096 cmdline_parse_inst_t cmd_vf_rate_limit = {
7097 .f = cmd_vf_rate_limit_parsed,
7099 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7100 "queue_mask <queue_mask_value>: "
7101 "Set rate limit for queues of VF on port_id",
7103 (void *)&cmd_vf_rate_limit_set,
7104 (void *)&cmd_vf_rate_limit_port,
7105 (void *)&cmd_vf_rate_limit_portnum,
7106 (void *)&cmd_vf_rate_limit_vf,
7107 (void *)&cmd_vf_rate_limit_vfnum,
7108 (void *)&cmd_vf_rate_limit_rate,
7109 (void *)&cmd_vf_rate_limit_ratenum,
7110 (void *)&cmd_vf_rate_limit_q_msk,
7111 (void *)&cmd_vf_rate_limit_q_msk_val,
7117 /* *** ADD TUNNEL FILTER OF A PORT *** */
7118 struct cmd_tunnel_filter_result {
7119 cmdline_fixed_string_t cmd;
7120 cmdline_fixed_string_t what;
7122 struct ether_addr outer_mac;
7123 struct ether_addr inner_mac;
7124 cmdline_ipaddr_t ip_value;
7125 uint16_t inner_vlan;
7126 cmdline_fixed_string_t tunnel_type;
7127 cmdline_fixed_string_t filter_type;
7133 cmd_tunnel_filter_parsed(void *parsed_result,
7134 __attribute__((unused)) struct cmdline *cl,
7135 __attribute__((unused)) void *data)
7137 struct cmd_tunnel_filter_result *res = parsed_result;
7138 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7141 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7143 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7144 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7145 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7147 if (res->ip_value.family == AF_INET) {
7148 tunnel_filter_conf.ip_addr.ipv4_addr =
7149 res->ip_value.addr.ipv4.s_addr;
7150 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7152 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7153 &(res->ip_value.addr.ipv6),
7154 sizeof(struct in6_addr));
7155 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7158 if (!strcmp(res->filter_type, "imac-ivlan"))
7159 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7160 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7161 tunnel_filter_conf.filter_type =
7162 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7163 else if (!strcmp(res->filter_type, "imac-tenid"))
7164 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7165 else if (!strcmp(res->filter_type, "imac"))
7166 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7167 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7168 tunnel_filter_conf.filter_type =
7169 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7170 else if (!strcmp(res->filter_type, "oip"))
7171 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7172 else if (!strcmp(res->filter_type, "iip"))
7173 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7175 printf("The filter type is not supported");
7179 if (!strcmp(res->tunnel_type, "vxlan"))
7180 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7181 else if (!strcmp(res->tunnel_type, "nvgre"))
7182 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7183 else if (!strcmp(res->tunnel_type, "ipingre"))
7184 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7186 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7190 tunnel_filter_conf.tenant_id = res->tenant_id;
7191 tunnel_filter_conf.queue_id = res->queue_num;
7192 if (!strcmp(res->what, "add"))
7193 ret = rte_eth_dev_filter_ctrl(res->port_id,
7194 RTE_ETH_FILTER_TUNNEL,
7196 &tunnel_filter_conf);
7198 ret = rte_eth_dev_filter_ctrl(res->port_id,
7199 RTE_ETH_FILTER_TUNNEL,
7200 RTE_ETH_FILTER_DELETE,
7201 &tunnel_filter_conf);
7203 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7207 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7208 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7209 cmd, "tunnel_filter");
7210 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7211 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7213 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7214 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7216 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7217 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7219 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7220 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7222 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7223 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7224 inner_vlan, UINT16);
7225 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7226 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7228 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7229 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7230 tunnel_type, "vxlan#nvgre#ipingre");
7232 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7233 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7234 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7235 "imac#omac-imac-tenid");
7236 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7237 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7239 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7240 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7243 cmdline_parse_inst_t cmd_tunnel_filter = {
7244 .f = cmd_tunnel_filter_parsed,
7246 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7247 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7248 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7249 "<queue_id>: Add/Rm tunnel filter of a port",
7251 (void *)&cmd_tunnel_filter_cmd,
7252 (void *)&cmd_tunnel_filter_what,
7253 (void *)&cmd_tunnel_filter_port_id,
7254 (void *)&cmd_tunnel_filter_outer_mac,
7255 (void *)&cmd_tunnel_filter_inner_mac,
7256 (void *)&cmd_tunnel_filter_ip_value,
7257 (void *)&cmd_tunnel_filter_innner_vlan,
7258 (void *)&cmd_tunnel_filter_tunnel_type,
7259 (void *)&cmd_tunnel_filter_filter_type,
7260 (void *)&cmd_tunnel_filter_tenant_id,
7261 (void *)&cmd_tunnel_filter_queue_num,
7266 /* *** CONFIGURE TUNNEL UDP PORT *** */
7267 struct cmd_tunnel_udp_config {
7268 cmdline_fixed_string_t cmd;
7269 cmdline_fixed_string_t what;
7275 cmd_tunnel_udp_config_parsed(void *parsed_result,
7276 __attribute__((unused)) struct cmdline *cl,
7277 __attribute__((unused)) void *data)
7279 struct cmd_tunnel_udp_config *res = parsed_result;
7280 struct rte_eth_udp_tunnel tunnel_udp;
7283 tunnel_udp.udp_port = res->udp_port;
7285 if (!strcmp(res->cmd, "rx_vxlan_port"))
7286 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7288 if (!strcmp(res->what, "add"))
7289 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7292 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7296 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7299 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7300 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7301 cmd, "rx_vxlan_port");
7302 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7303 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7305 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7306 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7308 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7309 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7312 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7313 .f = cmd_tunnel_udp_config_parsed,
7315 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7316 "Add/Remove a tunneling UDP port filter",
7318 (void *)&cmd_tunnel_udp_config_cmd,
7319 (void *)&cmd_tunnel_udp_config_what,
7320 (void *)&cmd_tunnel_udp_config_udp_port,
7321 (void *)&cmd_tunnel_udp_config_port_id,
7326 /* *** GLOBAL CONFIG *** */
7327 struct cmd_global_config_result {
7328 cmdline_fixed_string_t cmd;
7330 cmdline_fixed_string_t cfg_type;
7335 cmd_global_config_parsed(void *parsed_result,
7336 __attribute__((unused)) struct cmdline *cl,
7337 __attribute__((unused)) void *data)
7339 struct cmd_global_config_result *res = parsed_result;
7340 struct rte_eth_global_cfg conf;
7343 memset(&conf, 0, sizeof(conf));
7344 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7345 conf.cfg.gre_key_len = res->len;
7346 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7347 RTE_ETH_FILTER_SET, &conf);
7349 printf("Global config error\n");
7352 cmdline_parse_token_string_t cmd_global_config_cmd =
7353 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7355 cmdline_parse_token_num_t cmd_global_config_port_id =
7356 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7357 cmdline_parse_token_string_t cmd_global_config_type =
7358 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7359 cfg_type, "gre-key-len");
7360 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7361 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7364 cmdline_parse_inst_t cmd_global_config = {
7365 .f = cmd_global_config_parsed,
7366 .data = (void *)NULL,
7367 .help_str = "global_config <port_id> gre-key-len <key_len>",
7369 (void *)&cmd_global_config_cmd,
7370 (void *)&cmd_global_config_port_id,
7371 (void *)&cmd_global_config_type,
7372 (void *)&cmd_global_config_gre_key_len,
7377 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7378 struct cmd_set_mirror_mask_result {
7379 cmdline_fixed_string_t set;
7380 cmdline_fixed_string_t port;
7382 cmdline_fixed_string_t mirror;
7384 cmdline_fixed_string_t what;
7385 cmdline_fixed_string_t value;
7386 cmdline_fixed_string_t dstpool;
7388 cmdline_fixed_string_t on;
7391 cmdline_parse_token_string_t cmd_mirror_mask_set =
7392 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7394 cmdline_parse_token_string_t cmd_mirror_mask_port =
7395 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7397 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7398 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7400 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7401 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7402 mirror, "mirror-rule");
7403 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7404 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7406 cmdline_parse_token_string_t cmd_mirror_mask_what =
7407 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7408 what, "pool-mirror-up#pool-mirror-down"
7410 cmdline_parse_token_string_t cmd_mirror_mask_value =
7411 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7413 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7415 dstpool, "dst-pool");
7416 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7417 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7419 cmdline_parse_token_string_t cmd_mirror_mask_on =
7420 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7424 cmd_set_mirror_mask_parsed(void *parsed_result,
7425 __attribute__((unused)) struct cmdline *cl,
7426 __attribute__((unused)) void *data)
7429 struct cmd_set_mirror_mask_result *res = parsed_result;
7430 struct rte_eth_mirror_conf mr_conf;
7432 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7434 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7436 mr_conf.dst_pool = res->dstpool_id;
7438 if (!strcmp(res->what, "pool-mirror-up")) {
7439 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7440 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7441 } else if (!strcmp(res->what, "pool-mirror-down")) {
7442 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7443 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7444 } else if (!strcmp(res->what, "vlan-mirror")) {
7445 mr_conf.rule_type = ETH_MIRROR_VLAN;
7446 nb_item = parse_item_list(res->value, "vlan",
7447 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7451 for (i = 0; i < nb_item; i++) {
7452 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7453 printf("Invalid vlan_id: must be < 4096\n");
7457 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7458 mr_conf.vlan.vlan_mask |= 1ULL << i;
7462 if (!strcmp(res->on, "on"))
7463 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7466 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7469 printf("mirror rule add error: (%s)\n", strerror(-ret));
7472 cmdline_parse_inst_t cmd_set_mirror_mask = {
7473 .f = cmd_set_mirror_mask_parsed,
7475 .help_str = "set port <port_id> mirror-rule <rule_id> "
7476 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7477 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7479 (void *)&cmd_mirror_mask_set,
7480 (void *)&cmd_mirror_mask_port,
7481 (void *)&cmd_mirror_mask_portid,
7482 (void *)&cmd_mirror_mask_mirror,
7483 (void *)&cmd_mirror_mask_ruleid,
7484 (void *)&cmd_mirror_mask_what,
7485 (void *)&cmd_mirror_mask_value,
7486 (void *)&cmd_mirror_mask_dstpool,
7487 (void *)&cmd_mirror_mask_poolid,
7488 (void *)&cmd_mirror_mask_on,
7493 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7494 struct cmd_set_mirror_link_result {
7495 cmdline_fixed_string_t set;
7496 cmdline_fixed_string_t port;
7498 cmdline_fixed_string_t mirror;
7500 cmdline_fixed_string_t what;
7501 cmdline_fixed_string_t dstpool;
7503 cmdline_fixed_string_t on;
7506 cmdline_parse_token_string_t cmd_mirror_link_set =
7507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7509 cmdline_parse_token_string_t cmd_mirror_link_port =
7510 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7512 cmdline_parse_token_num_t cmd_mirror_link_portid =
7513 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7515 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7516 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7517 mirror, "mirror-rule");
7518 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7519 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7521 cmdline_parse_token_string_t cmd_mirror_link_what =
7522 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7523 what, "uplink-mirror#downlink-mirror");
7524 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7525 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7526 dstpool, "dst-pool");
7527 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7528 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7530 cmdline_parse_token_string_t cmd_mirror_link_on =
7531 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7535 cmd_set_mirror_link_parsed(void *parsed_result,
7536 __attribute__((unused)) struct cmdline *cl,
7537 __attribute__((unused)) void *data)
7540 struct cmd_set_mirror_link_result *res = parsed_result;
7541 struct rte_eth_mirror_conf mr_conf;
7543 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7544 if (!strcmp(res->what, "uplink-mirror"))
7545 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7547 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7549 mr_conf.dst_pool = res->dstpool_id;
7551 if (!strcmp(res->on, "on"))
7552 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7555 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7558 /* check the return value and print it if is < 0 */
7560 printf("mirror rule add error: (%s)\n", strerror(-ret));
7564 cmdline_parse_inst_t cmd_set_mirror_link = {
7565 .f = cmd_set_mirror_link_parsed,
7567 .help_str = "set port <port_id> mirror-rule <rule_id> "
7568 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7570 (void *)&cmd_mirror_link_set,
7571 (void *)&cmd_mirror_link_port,
7572 (void *)&cmd_mirror_link_portid,
7573 (void *)&cmd_mirror_link_mirror,
7574 (void *)&cmd_mirror_link_ruleid,
7575 (void *)&cmd_mirror_link_what,
7576 (void *)&cmd_mirror_link_dstpool,
7577 (void *)&cmd_mirror_link_poolid,
7578 (void *)&cmd_mirror_link_on,
7583 /* *** RESET VM MIRROR RULE *** */
7584 struct cmd_rm_mirror_rule_result {
7585 cmdline_fixed_string_t reset;
7586 cmdline_fixed_string_t port;
7588 cmdline_fixed_string_t mirror;
7592 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7593 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7595 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7596 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7598 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7599 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7601 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7602 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7603 mirror, "mirror-rule");
7604 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7605 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7609 cmd_reset_mirror_rule_parsed(void *parsed_result,
7610 __attribute__((unused)) struct cmdline *cl,
7611 __attribute__((unused)) void *data)
7614 struct cmd_set_mirror_link_result *res = parsed_result;
7616 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7618 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7621 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7622 .f = cmd_reset_mirror_rule_parsed,
7624 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7626 (void *)&cmd_rm_mirror_rule_reset,
7627 (void *)&cmd_rm_mirror_rule_port,
7628 (void *)&cmd_rm_mirror_rule_portid,
7629 (void *)&cmd_rm_mirror_rule_mirror,
7630 (void *)&cmd_rm_mirror_rule_ruleid,
7635 /* ******************************************************************************** */
7637 struct cmd_dump_result {
7638 cmdline_fixed_string_t dump;
7642 dump_struct_sizes(void)
7644 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7645 DUMP_SIZE(struct rte_mbuf);
7646 DUMP_SIZE(struct rte_mempool);
7647 DUMP_SIZE(struct rte_ring);
7651 static void cmd_dump_parsed(void *parsed_result,
7652 __attribute__((unused)) struct cmdline *cl,
7653 __attribute__((unused)) void *data)
7655 struct cmd_dump_result *res = parsed_result;
7657 if (!strcmp(res->dump, "dump_physmem"))
7658 rte_dump_physmem_layout(stdout);
7659 else if (!strcmp(res->dump, "dump_memzone"))
7660 rte_memzone_dump(stdout);
7661 else if (!strcmp(res->dump, "dump_struct_sizes"))
7662 dump_struct_sizes();
7663 else if (!strcmp(res->dump, "dump_ring"))
7664 rte_ring_list_dump(stdout);
7665 else if (!strcmp(res->dump, "dump_mempool"))
7666 rte_mempool_list_dump(stdout);
7667 else if (!strcmp(res->dump, "dump_devargs"))
7668 rte_eal_devargs_dump(stdout);
7671 cmdline_parse_token_string_t cmd_dump_dump =
7672 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7675 "dump_struct_sizes#"
7680 cmdline_parse_inst_t cmd_dump = {
7681 .f = cmd_dump_parsed, /* function to call */
7682 .data = NULL, /* 2nd arg of func */
7683 .help_str = "Dump status",
7684 .tokens = { /* token list, NULL terminated */
7685 (void *)&cmd_dump_dump,
7690 /* ******************************************************************************** */
7692 struct cmd_dump_one_result {
7693 cmdline_fixed_string_t dump;
7694 cmdline_fixed_string_t name;
7697 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7698 __attribute__((unused)) void *data)
7700 struct cmd_dump_one_result *res = parsed_result;
7702 if (!strcmp(res->dump, "dump_ring")) {
7704 r = rte_ring_lookup(res->name);
7706 cmdline_printf(cl, "Cannot find ring\n");
7709 rte_ring_dump(stdout, r);
7710 } else if (!strcmp(res->dump, "dump_mempool")) {
7711 struct rte_mempool *mp;
7712 mp = rte_mempool_lookup(res->name);
7714 cmdline_printf(cl, "Cannot find mempool\n");
7717 rte_mempool_dump(stdout, mp);
7721 cmdline_parse_token_string_t cmd_dump_one_dump =
7722 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7723 "dump_ring#dump_mempool");
7725 cmdline_parse_token_string_t cmd_dump_one_name =
7726 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7728 cmdline_parse_inst_t cmd_dump_one = {
7729 .f = cmd_dump_one_parsed, /* function to call */
7730 .data = NULL, /* 2nd arg of func */
7731 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7732 .tokens = { /* token list, NULL terminated */
7733 (void *)&cmd_dump_one_dump,
7734 (void *)&cmd_dump_one_name,
7739 /* *** Add/Del syn filter *** */
7740 struct cmd_syn_filter_result {
7741 cmdline_fixed_string_t filter;
7743 cmdline_fixed_string_t ops;
7744 cmdline_fixed_string_t priority;
7745 cmdline_fixed_string_t high;
7746 cmdline_fixed_string_t queue;
7751 cmd_syn_filter_parsed(void *parsed_result,
7752 __attribute__((unused)) struct cmdline *cl,
7753 __attribute__((unused)) void *data)
7755 struct cmd_syn_filter_result *res = parsed_result;
7756 struct rte_eth_syn_filter syn_filter;
7759 ret = rte_eth_dev_filter_supported(res->port_id,
7760 RTE_ETH_FILTER_SYN);
7762 printf("syn filter is not supported on port %u.\n",
7767 memset(&syn_filter, 0, sizeof(syn_filter));
7769 if (!strcmp(res->ops, "add")) {
7770 if (!strcmp(res->high, "high"))
7771 syn_filter.hig_pri = 1;
7773 syn_filter.hig_pri = 0;
7775 syn_filter.queue = res->queue_id;
7776 ret = rte_eth_dev_filter_ctrl(res->port_id,
7781 ret = rte_eth_dev_filter_ctrl(res->port_id,
7783 RTE_ETH_FILTER_DELETE,
7787 printf("syn filter programming error: (%s)\n",
7791 cmdline_parse_token_string_t cmd_syn_filter_filter =
7792 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7793 filter, "syn_filter");
7794 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7795 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7797 cmdline_parse_token_string_t cmd_syn_filter_ops =
7798 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7800 cmdline_parse_token_string_t cmd_syn_filter_priority =
7801 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7802 priority, "priority");
7803 cmdline_parse_token_string_t cmd_syn_filter_high =
7804 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7806 cmdline_parse_token_string_t cmd_syn_filter_queue =
7807 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7809 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7810 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7813 cmdline_parse_inst_t cmd_syn_filter = {
7814 .f = cmd_syn_filter_parsed,
7816 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7817 "<queue_id>: Add/Delete syn filter",
7819 (void *)&cmd_syn_filter_filter,
7820 (void *)&cmd_syn_filter_port_id,
7821 (void *)&cmd_syn_filter_ops,
7822 (void *)&cmd_syn_filter_priority,
7823 (void *)&cmd_syn_filter_high,
7824 (void *)&cmd_syn_filter_queue,
7825 (void *)&cmd_syn_filter_queue_id,
7830 /* *** ADD/REMOVE A 2tuple FILTER *** */
7831 struct cmd_2tuple_filter_result {
7832 cmdline_fixed_string_t filter;
7834 cmdline_fixed_string_t ops;
7835 cmdline_fixed_string_t dst_port;
7836 uint16_t dst_port_value;
7837 cmdline_fixed_string_t protocol;
7838 uint8_t protocol_value;
7839 cmdline_fixed_string_t mask;
7841 cmdline_fixed_string_t tcp_flags;
7842 uint8_t tcp_flags_value;
7843 cmdline_fixed_string_t priority;
7844 uint8_t priority_value;
7845 cmdline_fixed_string_t queue;
7850 cmd_2tuple_filter_parsed(void *parsed_result,
7851 __attribute__((unused)) struct cmdline *cl,
7852 __attribute__((unused)) void *data)
7854 struct rte_eth_ntuple_filter filter;
7855 struct cmd_2tuple_filter_result *res = parsed_result;
7858 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7860 printf("ntuple filter is not supported on port %u.\n",
7865 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7867 filter.flags = RTE_2TUPLE_FLAGS;
7868 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7869 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7870 filter.proto = res->protocol_value;
7871 filter.priority = res->priority_value;
7872 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7873 printf("nonzero tcp_flags is only meaningful"
7874 " when protocol is TCP.\n");
7877 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7878 printf("invalid TCP flags.\n");
7882 if (res->tcp_flags_value != 0) {
7883 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7884 filter.tcp_flags = res->tcp_flags_value;
7887 /* need convert to big endian. */
7888 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7889 filter.queue = res->queue_id;
7891 if (!strcmp(res->ops, "add"))
7892 ret = rte_eth_dev_filter_ctrl(res->port_id,
7893 RTE_ETH_FILTER_NTUPLE,
7897 ret = rte_eth_dev_filter_ctrl(res->port_id,
7898 RTE_ETH_FILTER_NTUPLE,
7899 RTE_ETH_FILTER_DELETE,
7902 printf("2tuple filter programming error: (%s)\n",
7907 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7908 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7909 filter, "2tuple_filter");
7910 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7911 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7913 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7914 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7916 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7917 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7918 dst_port, "dst_port");
7919 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7920 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7921 dst_port_value, UINT16);
7922 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7923 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7924 protocol, "protocol");
7925 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7926 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7927 protocol_value, UINT8);
7928 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7929 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7931 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7932 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7934 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7935 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7936 tcp_flags, "tcp_flags");
7937 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7938 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7939 tcp_flags_value, UINT8);
7940 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7941 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7942 priority, "priority");
7943 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7944 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7945 priority_value, UINT8);
7946 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7947 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7949 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7950 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7953 cmdline_parse_inst_t cmd_2tuple_filter = {
7954 .f = cmd_2tuple_filter_parsed,
7956 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7957 "<value> mask <value> tcp_flags <value> priority <value> queue "
7958 "<queue_id>: Add a 2tuple filter",
7960 (void *)&cmd_2tuple_filter_filter,
7961 (void *)&cmd_2tuple_filter_port_id,
7962 (void *)&cmd_2tuple_filter_ops,
7963 (void *)&cmd_2tuple_filter_dst_port,
7964 (void *)&cmd_2tuple_filter_dst_port_value,
7965 (void *)&cmd_2tuple_filter_protocol,
7966 (void *)&cmd_2tuple_filter_protocol_value,
7967 (void *)&cmd_2tuple_filter_mask,
7968 (void *)&cmd_2tuple_filter_mask_value,
7969 (void *)&cmd_2tuple_filter_tcp_flags,
7970 (void *)&cmd_2tuple_filter_tcp_flags_value,
7971 (void *)&cmd_2tuple_filter_priority,
7972 (void *)&cmd_2tuple_filter_priority_value,
7973 (void *)&cmd_2tuple_filter_queue,
7974 (void *)&cmd_2tuple_filter_queue_id,
7979 /* *** ADD/REMOVE A 5tuple FILTER *** */
7980 struct cmd_5tuple_filter_result {
7981 cmdline_fixed_string_t filter;
7983 cmdline_fixed_string_t ops;
7984 cmdline_fixed_string_t dst_ip;
7985 cmdline_ipaddr_t dst_ip_value;
7986 cmdline_fixed_string_t src_ip;
7987 cmdline_ipaddr_t src_ip_value;
7988 cmdline_fixed_string_t dst_port;
7989 uint16_t dst_port_value;
7990 cmdline_fixed_string_t src_port;
7991 uint16_t src_port_value;
7992 cmdline_fixed_string_t protocol;
7993 uint8_t protocol_value;
7994 cmdline_fixed_string_t mask;
7996 cmdline_fixed_string_t tcp_flags;
7997 uint8_t tcp_flags_value;
7998 cmdline_fixed_string_t priority;
7999 uint8_t priority_value;
8000 cmdline_fixed_string_t queue;
8005 cmd_5tuple_filter_parsed(void *parsed_result,
8006 __attribute__((unused)) struct cmdline *cl,
8007 __attribute__((unused)) void *data)
8009 struct rte_eth_ntuple_filter filter;
8010 struct cmd_5tuple_filter_result *res = parsed_result;
8013 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8015 printf("ntuple filter is not supported on port %u.\n",
8020 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8022 filter.flags = RTE_5TUPLE_FLAGS;
8023 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8024 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8025 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8026 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8027 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8028 filter.proto = res->protocol_value;
8029 filter.priority = res->priority_value;
8030 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8031 printf("nonzero tcp_flags is only meaningful"
8032 " when protocol is TCP.\n");
8035 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8036 printf("invalid TCP flags.\n");
8040 if (res->tcp_flags_value != 0) {
8041 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8042 filter.tcp_flags = res->tcp_flags_value;
8045 if (res->dst_ip_value.family == AF_INET)
8046 /* no need to convert, already big endian. */
8047 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8049 if (filter.dst_ip_mask == 0) {
8050 printf("can not support ipv6 involved compare.\n");
8056 if (res->src_ip_value.family == AF_INET)
8057 /* no need to convert, already big endian. */
8058 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8060 if (filter.src_ip_mask == 0) {
8061 printf("can not support ipv6 involved compare.\n");
8066 /* need convert to big endian. */
8067 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8068 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8069 filter.queue = res->queue_id;
8071 if (!strcmp(res->ops, "add"))
8072 ret = rte_eth_dev_filter_ctrl(res->port_id,
8073 RTE_ETH_FILTER_NTUPLE,
8077 ret = rte_eth_dev_filter_ctrl(res->port_id,
8078 RTE_ETH_FILTER_NTUPLE,
8079 RTE_ETH_FILTER_DELETE,
8082 printf("5tuple filter programming error: (%s)\n",
8086 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8087 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8088 filter, "5tuple_filter");
8089 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8090 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8092 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8093 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8095 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8096 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8098 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8099 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8101 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8102 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8104 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8105 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8107 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8108 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8109 dst_port, "dst_port");
8110 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8111 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8112 dst_port_value, UINT16);
8113 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8114 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8115 src_port, "src_port");
8116 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8117 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8118 src_port_value, UINT16);
8119 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8120 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8121 protocol, "protocol");
8122 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8123 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8124 protocol_value, UINT8);
8125 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8126 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8128 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8129 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8131 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8132 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8133 tcp_flags, "tcp_flags");
8134 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8135 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8136 tcp_flags_value, UINT8);
8137 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8138 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8139 priority, "priority");
8140 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8141 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8142 priority_value, UINT8);
8143 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8144 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8146 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8147 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8150 cmdline_parse_inst_t cmd_5tuple_filter = {
8151 .f = cmd_5tuple_filter_parsed,
8153 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8154 "src_ip <value> dst_port <value> src_port <value> "
8155 "protocol <value> mask <value> tcp_flags <value> "
8156 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8158 (void *)&cmd_5tuple_filter_filter,
8159 (void *)&cmd_5tuple_filter_port_id,
8160 (void *)&cmd_5tuple_filter_ops,
8161 (void *)&cmd_5tuple_filter_dst_ip,
8162 (void *)&cmd_5tuple_filter_dst_ip_value,
8163 (void *)&cmd_5tuple_filter_src_ip,
8164 (void *)&cmd_5tuple_filter_src_ip_value,
8165 (void *)&cmd_5tuple_filter_dst_port,
8166 (void *)&cmd_5tuple_filter_dst_port_value,
8167 (void *)&cmd_5tuple_filter_src_port,
8168 (void *)&cmd_5tuple_filter_src_port_value,
8169 (void *)&cmd_5tuple_filter_protocol,
8170 (void *)&cmd_5tuple_filter_protocol_value,
8171 (void *)&cmd_5tuple_filter_mask,
8172 (void *)&cmd_5tuple_filter_mask_value,
8173 (void *)&cmd_5tuple_filter_tcp_flags,
8174 (void *)&cmd_5tuple_filter_tcp_flags_value,
8175 (void *)&cmd_5tuple_filter_priority,
8176 (void *)&cmd_5tuple_filter_priority_value,
8177 (void *)&cmd_5tuple_filter_queue,
8178 (void *)&cmd_5tuple_filter_queue_id,
8183 /* *** ADD/REMOVE A flex FILTER *** */
8184 struct cmd_flex_filter_result {
8185 cmdline_fixed_string_t filter;
8186 cmdline_fixed_string_t ops;
8188 cmdline_fixed_string_t len;
8190 cmdline_fixed_string_t bytes;
8191 cmdline_fixed_string_t bytes_value;
8192 cmdline_fixed_string_t mask;
8193 cmdline_fixed_string_t mask_value;
8194 cmdline_fixed_string_t priority;
8195 uint8_t priority_value;
8196 cmdline_fixed_string_t queue;
8200 static int xdigit2val(unsigned char c)
8205 else if (isupper(c))
8213 cmd_flex_filter_parsed(void *parsed_result,
8214 __attribute__((unused)) struct cmdline *cl,
8215 __attribute__((unused)) void *data)
8218 struct rte_eth_flex_filter filter;
8219 struct cmd_flex_filter_result *res = parsed_result;
8220 char *bytes_ptr, *mask_ptr;
8221 uint16_t len, i, j = 0;
8226 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8227 printf("the len exceed the max length 128\n");
8230 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8231 filter.len = res->len_value;
8232 filter.priority = res->priority_value;
8233 filter.queue = res->queue_id;
8234 bytes_ptr = res->bytes_value;
8235 mask_ptr = res->mask_value;
8237 /* translate bytes string to array. */
8238 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8239 (bytes_ptr[1] == 'X')))
8241 len = strnlen(bytes_ptr, res->len_value * 2);
8242 if (len == 0 || (len % 8 != 0)) {
8243 printf("please check len and bytes input\n");
8246 for (i = 0; i < len; i++) {
8248 if (isxdigit(c) == 0) {
8249 /* invalid characters. */
8250 printf("invalid input\n");
8253 val = xdigit2val(c);
8256 filter.bytes[j] = byte;
8257 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8264 /* translate mask string to uint8_t array. */
8265 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8266 (mask_ptr[1] == 'X')))
8268 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8270 printf("invalid input\n");
8275 for (i = 0; i < len; i++) {
8277 if (isxdigit(c) == 0) {
8278 /* invalid characters. */
8279 printf("invalid input\n");
8282 val = xdigit2val(c);
8285 filter.mask[j] = byte;
8286 printf("mask[%d]:%02x ", j, filter.mask[j]);
8294 if (!strcmp(res->ops, "add"))
8295 ret = rte_eth_dev_filter_ctrl(res->port_id,
8296 RTE_ETH_FILTER_FLEXIBLE,
8300 ret = rte_eth_dev_filter_ctrl(res->port_id,
8301 RTE_ETH_FILTER_FLEXIBLE,
8302 RTE_ETH_FILTER_DELETE,
8306 printf("flex filter setting error: (%s)\n", strerror(-ret));
8309 cmdline_parse_token_string_t cmd_flex_filter_filter =
8310 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8311 filter, "flex_filter");
8312 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8313 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8315 cmdline_parse_token_string_t cmd_flex_filter_ops =
8316 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8318 cmdline_parse_token_string_t cmd_flex_filter_len =
8319 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8321 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8322 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8324 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8325 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8327 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8328 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8330 cmdline_parse_token_string_t cmd_flex_filter_mask =
8331 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8333 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8334 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8336 cmdline_parse_token_string_t cmd_flex_filter_priority =
8337 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8338 priority, "priority");
8339 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8340 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8341 priority_value, UINT8);
8342 cmdline_parse_token_string_t cmd_flex_filter_queue =
8343 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8345 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8346 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8348 cmdline_parse_inst_t cmd_flex_filter = {
8349 .f = cmd_flex_filter_parsed,
8351 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8352 "<value> mask <value> priority <value> queue <queue_id>: "
8353 "Add/Del a flex filter",
8355 (void *)&cmd_flex_filter_filter,
8356 (void *)&cmd_flex_filter_port_id,
8357 (void *)&cmd_flex_filter_ops,
8358 (void *)&cmd_flex_filter_len,
8359 (void *)&cmd_flex_filter_len_value,
8360 (void *)&cmd_flex_filter_bytes,
8361 (void *)&cmd_flex_filter_bytes_value,
8362 (void *)&cmd_flex_filter_mask,
8363 (void *)&cmd_flex_filter_mask_value,
8364 (void *)&cmd_flex_filter_priority,
8365 (void *)&cmd_flex_filter_priority_value,
8366 (void *)&cmd_flex_filter_queue,
8367 (void *)&cmd_flex_filter_queue_id,
8372 /* *** Filters Control *** */
8374 /* *** deal with ethertype filter *** */
8375 struct cmd_ethertype_filter_result {
8376 cmdline_fixed_string_t filter;
8378 cmdline_fixed_string_t ops;
8379 cmdline_fixed_string_t mac;
8380 struct ether_addr mac_addr;
8381 cmdline_fixed_string_t ethertype;
8382 uint16_t ethertype_value;
8383 cmdline_fixed_string_t drop;
8384 cmdline_fixed_string_t queue;
8388 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8389 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8390 filter, "ethertype_filter");
8391 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8392 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8394 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8395 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8397 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8398 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8399 mac, "mac_addr#mac_ignr");
8400 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8401 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8403 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8404 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8405 ethertype, "ethertype");
8406 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8407 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8408 ethertype_value, UINT16);
8409 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8410 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8412 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8413 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8415 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8416 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8420 cmd_ethertype_filter_parsed(void *parsed_result,
8421 __attribute__((unused)) struct cmdline *cl,
8422 __attribute__((unused)) void *data)
8424 struct cmd_ethertype_filter_result *res = parsed_result;
8425 struct rte_eth_ethertype_filter filter;
8428 ret = rte_eth_dev_filter_supported(res->port_id,
8429 RTE_ETH_FILTER_ETHERTYPE);
8431 printf("ethertype filter is not supported on port %u.\n",
8436 memset(&filter, 0, sizeof(filter));
8437 if (!strcmp(res->mac, "mac_addr")) {
8438 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8439 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8440 sizeof(struct ether_addr));
8442 if (!strcmp(res->drop, "drop"))
8443 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8444 filter.ether_type = res->ethertype_value;
8445 filter.queue = res->queue_id;
8447 if (!strcmp(res->ops, "add"))
8448 ret = rte_eth_dev_filter_ctrl(res->port_id,
8449 RTE_ETH_FILTER_ETHERTYPE,
8453 ret = rte_eth_dev_filter_ctrl(res->port_id,
8454 RTE_ETH_FILTER_ETHERTYPE,
8455 RTE_ETH_FILTER_DELETE,
8458 printf("ethertype filter programming error: (%s)\n",
8462 cmdline_parse_inst_t cmd_ethertype_filter = {
8463 .f = cmd_ethertype_filter_parsed,
8465 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8466 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8467 "Add or delete an ethertype filter entry",
8469 (void *)&cmd_ethertype_filter_filter,
8470 (void *)&cmd_ethertype_filter_port_id,
8471 (void *)&cmd_ethertype_filter_ops,
8472 (void *)&cmd_ethertype_filter_mac,
8473 (void *)&cmd_ethertype_filter_mac_addr,
8474 (void *)&cmd_ethertype_filter_ethertype,
8475 (void *)&cmd_ethertype_filter_ethertype_value,
8476 (void *)&cmd_ethertype_filter_drop,
8477 (void *)&cmd_ethertype_filter_queue,
8478 (void *)&cmd_ethertype_filter_queue_id,
8483 /* *** deal with flow director filter *** */
8484 struct cmd_flow_director_result {
8485 cmdline_fixed_string_t flow_director_filter;
8487 cmdline_fixed_string_t mode;
8488 cmdline_fixed_string_t mode_value;
8489 cmdline_fixed_string_t ops;
8490 cmdline_fixed_string_t flow;
8491 cmdline_fixed_string_t flow_type;
8492 cmdline_fixed_string_t ether;
8493 uint16_t ether_type;
8494 cmdline_fixed_string_t src;
8495 cmdline_ipaddr_t ip_src;
8497 cmdline_fixed_string_t dst;
8498 cmdline_ipaddr_t ip_dst;
8500 cmdline_fixed_string_t verify_tag;
8501 uint32_t verify_tag_value;
8502 cmdline_ipaddr_t tos;
8504 cmdline_ipaddr_t proto;
8505 uint8_t proto_value;
8506 cmdline_ipaddr_t ttl;
8508 cmdline_fixed_string_t vlan;
8509 uint16_t vlan_value;
8510 cmdline_fixed_string_t flexbytes;
8511 cmdline_fixed_string_t flexbytes_value;
8512 cmdline_fixed_string_t pf_vf;
8513 cmdline_fixed_string_t drop;
8514 cmdline_fixed_string_t queue;
8516 cmdline_fixed_string_t fd_id;
8517 uint32_t fd_id_value;
8518 cmdline_fixed_string_t mac;
8519 struct ether_addr mac_addr;
8520 cmdline_fixed_string_t tunnel;
8521 cmdline_fixed_string_t tunnel_type;
8522 cmdline_fixed_string_t tunnel_id;
8523 uint32_t tunnel_id_value;
8527 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8530 const char *p, *p0 = q_arg;
8532 unsigned long int_fld;
8533 char *str_fld[max_num];
8538 p = strchr(p0, '(');
8542 p0 = strchr(p, ')');
8547 if (size >= sizeof(s))
8550 snprintf(s, sizeof(s), "%.*s", size, p);
8551 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8552 if (ret < 0 || ret > max_num)
8554 for (i = 0; i < ret; i++) {
8556 int_fld = strtoul(str_fld[i], &end, 0);
8557 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8559 flexbytes[i] = (uint8_t)int_fld;
8565 str2flowtype(char *string)
8568 static const struct {
8571 } flowtype_str[] = {
8572 {"raw", RTE_ETH_FLOW_RAW},
8573 {"ipv4", RTE_ETH_FLOW_IPV4},
8574 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8575 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8576 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8577 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8578 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8579 {"ipv6", RTE_ETH_FLOW_IPV6},
8580 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8581 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8582 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8583 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8584 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8585 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8588 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8589 if (!strcmp(flowtype_str[i].str, string))
8590 return flowtype_str[i].type;
8592 return RTE_ETH_FLOW_UNKNOWN;
8595 static enum rte_eth_fdir_tunnel_type
8596 str2fdir_tunneltype(char *string)
8600 static const struct {
8602 enum rte_eth_fdir_tunnel_type type;
8603 } tunneltype_str[] = {
8604 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8605 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8608 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8609 if (!strcmp(tunneltype_str[i].str, string))
8610 return tunneltype_str[i].type;
8612 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8615 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8617 if ((ip_addr).family == AF_INET) \
8618 (ip) = (ip_addr).addr.ipv4.s_addr; \
8620 printf("invalid parameter.\n"); \
8625 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8627 if ((ip_addr).family == AF_INET6) \
8628 (void)rte_memcpy(&(ip), \
8629 &((ip_addr).addr.ipv6), \
8630 sizeof(struct in6_addr)); \
8632 printf("invalid parameter.\n"); \
8638 cmd_flow_director_filter_parsed(void *parsed_result,
8639 __attribute__((unused)) struct cmdline *cl,
8640 __attribute__((unused)) void *data)
8642 struct cmd_flow_director_result *res = parsed_result;
8643 struct rte_eth_fdir_filter entry;
8644 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8646 unsigned long vf_id;
8649 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8651 printf("flow director is not supported on port %u.\n",
8655 memset(flexbytes, 0, sizeof(flexbytes));
8656 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8658 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8659 if (strcmp(res->mode_value, "MAC-VLAN")) {
8660 printf("Please set mode to MAC-VLAN.\n");
8663 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8664 if (strcmp(res->mode_value, "Tunnel")) {
8665 printf("Please set mode to Tunnel.\n");
8669 if (strcmp(res->mode_value, "IP")) {
8670 printf("Please set mode to IP.\n");
8673 entry.input.flow_type = str2flowtype(res->flow_type);
8676 ret = parse_flexbytes(res->flexbytes_value,
8678 RTE_ETH_FDIR_MAX_FLEXLEN);
8680 printf("error: Cannot parse flexbytes input.\n");
8684 switch (entry.input.flow_type) {
8685 case RTE_ETH_FLOW_FRAG_IPV4:
8686 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8687 entry.input.flow.ip4_flow.proto = res->proto_value;
8688 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8689 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8690 IPV4_ADDR_TO_UINT(res->ip_dst,
8691 entry.input.flow.ip4_flow.dst_ip);
8692 IPV4_ADDR_TO_UINT(res->ip_src,
8693 entry.input.flow.ip4_flow.src_ip);
8694 entry.input.flow.ip4_flow.tos = res->tos_value;
8695 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8696 /* need convert to big endian. */
8697 entry.input.flow.udp4_flow.dst_port =
8698 rte_cpu_to_be_16(res->port_dst);
8699 entry.input.flow.udp4_flow.src_port =
8700 rte_cpu_to_be_16(res->port_src);
8702 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8703 IPV4_ADDR_TO_UINT(res->ip_dst,
8704 entry.input.flow.sctp4_flow.ip.dst_ip);
8705 IPV4_ADDR_TO_UINT(res->ip_src,
8706 entry.input.flow.sctp4_flow.ip.src_ip);
8707 entry.input.flow.ip4_flow.tos = res->tos_value;
8708 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8709 /* need convert to big endian. */
8710 entry.input.flow.sctp4_flow.dst_port =
8711 rte_cpu_to_be_16(res->port_dst);
8712 entry.input.flow.sctp4_flow.src_port =
8713 rte_cpu_to_be_16(res->port_src);
8714 entry.input.flow.sctp4_flow.verify_tag =
8715 rte_cpu_to_be_32(res->verify_tag_value);
8717 case RTE_ETH_FLOW_FRAG_IPV6:
8718 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8719 entry.input.flow.ipv6_flow.proto = res->proto_value;
8720 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8721 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8722 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8723 entry.input.flow.ipv6_flow.dst_ip);
8724 IPV6_ADDR_TO_ARRAY(res->ip_src,
8725 entry.input.flow.ipv6_flow.src_ip);
8726 entry.input.flow.ipv6_flow.tc = res->tos_value;
8727 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8728 /* need convert to big endian. */
8729 entry.input.flow.udp6_flow.dst_port =
8730 rte_cpu_to_be_16(res->port_dst);
8731 entry.input.flow.udp6_flow.src_port =
8732 rte_cpu_to_be_16(res->port_src);
8734 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8735 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8736 entry.input.flow.sctp6_flow.ip.dst_ip);
8737 IPV6_ADDR_TO_ARRAY(res->ip_src,
8738 entry.input.flow.sctp6_flow.ip.src_ip);
8739 entry.input.flow.ipv6_flow.tc = res->tos_value;
8740 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8741 /* need convert to big endian. */
8742 entry.input.flow.sctp6_flow.dst_port =
8743 rte_cpu_to_be_16(res->port_dst);
8744 entry.input.flow.sctp6_flow.src_port =
8745 rte_cpu_to_be_16(res->port_src);
8746 entry.input.flow.sctp6_flow.verify_tag =
8747 rte_cpu_to_be_32(res->verify_tag_value);
8749 case RTE_ETH_FLOW_L2_PAYLOAD:
8750 entry.input.flow.l2_flow.ether_type =
8751 rte_cpu_to_be_16(res->ether_type);
8757 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8758 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8760 sizeof(struct ether_addr));
8762 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8763 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8765 sizeof(struct ether_addr));
8766 entry.input.flow.tunnel_flow.tunnel_type =
8767 str2fdir_tunneltype(res->tunnel_type);
8768 entry.input.flow.tunnel_flow.tunnel_id =
8769 rte_cpu_to_be_32(res->tunnel_id_value);
8772 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8774 RTE_ETH_FDIR_MAX_FLEXLEN);
8776 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8778 entry.action.flex_off = 0; /*use 0 by default */
8779 if (!strcmp(res->drop, "drop"))
8780 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8782 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8784 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8785 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8786 if (!strcmp(res->pf_vf, "pf"))
8787 entry.input.flow_ext.is_vf = 0;
8788 else if (!strncmp(res->pf_vf, "vf", 2)) {
8789 struct rte_eth_dev_info dev_info;
8791 memset(&dev_info, 0, sizeof(dev_info));
8792 rte_eth_dev_info_get(res->port_id, &dev_info);
8794 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8795 if (errno != 0 || *end != '\0' ||
8796 vf_id >= dev_info.max_vfs) {
8797 printf("invalid parameter %s.\n", res->pf_vf);
8800 entry.input.flow_ext.is_vf = 1;
8801 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8803 printf("invalid parameter %s.\n", res->pf_vf);
8808 /* set to report FD ID by default */
8809 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8810 entry.action.rx_queue = res->queue_id;
8811 entry.soft_id = res->fd_id_value;
8812 if (!strcmp(res->ops, "add"))
8813 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8814 RTE_ETH_FILTER_ADD, &entry);
8815 else if (!strcmp(res->ops, "del"))
8816 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8817 RTE_ETH_FILTER_DELETE, &entry);
8819 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8820 RTE_ETH_FILTER_UPDATE, &entry);
8822 printf("flow director programming error: (%s)\n",
8826 cmdline_parse_token_string_t cmd_flow_director_filter =
8827 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8828 flow_director_filter, "flow_director_filter");
8829 cmdline_parse_token_num_t cmd_flow_director_port_id =
8830 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8832 cmdline_parse_token_string_t cmd_flow_director_ops =
8833 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8834 ops, "add#del#update");
8835 cmdline_parse_token_string_t cmd_flow_director_flow =
8836 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8838 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8840 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8841 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8842 cmdline_parse_token_string_t cmd_flow_director_ether =
8843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8845 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8846 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8847 ether_type, UINT16);
8848 cmdline_parse_token_string_t cmd_flow_director_src =
8849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8851 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8852 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8854 cmdline_parse_token_num_t cmd_flow_director_port_src =
8855 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8857 cmdline_parse_token_string_t cmd_flow_director_dst =
8858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8860 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8861 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8863 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8864 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8866 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8868 verify_tag, "verify_tag");
8869 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8870 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8871 verify_tag_value, UINT32);
8872 cmdline_parse_token_string_t cmd_flow_director_tos =
8873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8875 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8876 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8878 cmdline_parse_token_string_t cmd_flow_director_proto =
8879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8881 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8882 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8883 proto_value, UINT8);
8884 cmdline_parse_token_string_t cmd_flow_director_ttl =
8885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8887 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8888 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8890 cmdline_parse_token_string_t cmd_flow_director_vlan =
8891 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8893 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8894 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8895 vlan_value, UINT16);
8896 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8897 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8898 flexbytes, "flexbytes");
8899 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8900 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8901 flexbytes_value, NULL);
8902 cmdline_parse_token_string_t cmd_flow_director_drop =
8903 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8905 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8906 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8908 cmdline_parse_token_string_t cmd_flow_director_queue =
8909 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8911 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8912 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8914 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8915 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8917 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8918 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8919 fd_id_value, UINT32);
8921 cmdline_parse_token_string_t cmd_flow_director_mode =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8927 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8929 mode_value, "MAC-VLAN");
8930 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8932 mode_value, "Tunnel");
8933 cmdline_parse_token_string_t cmd_flow_director_mac =
8934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8936 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8937 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8939 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8940 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8942 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8944 tunnel_type, "NVGRE#VxLAN");
8945 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8947 tunnel_id, "tunnel-id");
8948 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8949 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8950 tunnel_id_value, UINT32);
8952 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8953 .f = cmd_flow_director_filter_parsed,
8955 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8956 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8957 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8958 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8959 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8960 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8961 "fd_id <fd_id_value>: "
8962 "Add or delete an ip flow director entry on NIC",
8964 (void *)&cmd_flow_director_filter,
8965 (void *)&cmd_flow_director_port_id,
8966 (void *)&cmd_flow_director_mode,
8967 (void *)&cmd_flow_director_mode_ip,
8968 (void *)&cmd_flow_director_ops,
8969 (void *)&cmd_flow_director_flow,
8970 (void *)&cmd_flow_director_flow_type,
8971 (void *)&cmd_flow_director_src,
8972 (void *)&cmd_flow_director_ip_src,
8973 (void *)&cmd_flow_director_dst,
8974 (void *)&cmd_flow_director_ip_dst,
8975 (void *)&cmd_flow_director_tos,
8976 (void *)&cmd_flow_director_tos_value,
8977 (void *)&cmd_flow_director_proto,
8978 (void *)&cmd_flow_director_proto_value,
8979 (void *)&cmd_flow_director_ttl,
8980 (void *)&cmd_flow_director_ttl_value,
8981 (void *)&cmd_flow_director_vlan,
8982 (void *)&cmd_flow_director_vlan_value,
8983 (void *)&cmd_flow_director_flexbytes,
8984 (void *)&cmd_flow_director_flexbytes_value,
8985 (void *)&cmd_flow_director_drop,
8986 (void *)&cmd_flow_director_pf_vf,
8987 (void *)&cmd_flow_director_queue,
8988 (void *)&cmd_flow_director_queue_id,
8989 (void *)&cmd_flow_director_fd_id,
8990 (void *)&cmd_flow_director_fd_id_value,
8995 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8996 .f = cmd_flow_director_filter_parsed,
8998 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8999 "director entry on NIC",
9001 (void *)&cmd_flow_director_filter,
9002 (void *)&cmd_flow_director_port_id,
9003 (void *)&cmd_flow_director_mode,
9004 (void *)&cmd_flow_director_mode_ip,
9005 (void *)&cmd_flow_director_ops,
9006 (void *)&cmd_flow_director_flow,
9007 (void *)&cmd_flow_director_flow_type,
9008 (void *)&cmd_flow_director_src,
9009 (void *)&cmd_flow_director_ip_src,
9010 (void *)&cmd_flow_director_port_src,
9011 (void *)&cmd_flow_director_dst,
9012 (void *)&cmd_flow_director_ip_dst,
9013 (void *)&cmd_flow_director_port_dst,
9014 (void *)&cmd_flow_director_tos,
9015 (void *)&cmd_flow_director_tos_value,
9016 (void *)&cmd_flow_director_ttl,
9017 (void *)&cmd_flow_director_ttl_value,
9018 (void *)&cmd_flow_director_vlan,
9019 (void *)&cmd_flow_director_vlan_value,
9020 (void *)&cmd_flow_director_flexbytes,
9021 (void *)&cmd_flow_director_flexbytes_value,
9022 (void *)&cmd_flow_director_drop,
9023 (void *)&cmd_flow_director_pf_vf,
9024 (void *)&cmd_flow_director_queue,
9025 (void *)&cmd_flow_director_queue_id,
9026 (void *)&cmd_flow_director_fd_id,
9027 (void *)&cmd_flow_director_fd_id_value,
9032 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9033 .f = cmd_flow_director_filter_parsed,
9035 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9036 "director entry on NIC",
9038 (void *)&cmd_flow_director_filter,
9039 (void *)&cmd_flow_director_port_id,
9040 (void *)&cmd_flow_director_mode,
9041 (void *)&cmd_flow_director_mode_ip,
9042 (void *)&cmd_flow_director_ops,
9043 (void *)&cmd_flow_director_flow,
9044 (void *)&cmd_flow_director_flow_type,
9045 (void *)&cmd_flow_director_src,
9046 (void *)&cmd_flow_director_ip_src,
9047 (void *)&cmd_flow_director_port_dst,
9048 (void *)&cmd_flow_director_dst,
9049 (void *)&cmd_flow_director_ip_dst,
9050 (void *)&cmd_flow_director_port_dst,
9051 (void *)&cmd_flow_director_verify_tag,
9052 (void *)&cmd_flow_director_verify_tag_value,
9053 (void *)&cmd_flow_director_tos,
9054 (void *)&cmd_flow_director_tos_value,
9055 (void *)&cmd_flow_director_ttl,
9056 (void *)&cmd_flow_director_ttl_value,
9057 (void *)&cmd_flow_director_vlan,
9058 (void *)&cmd_flow_director_vlan_value,
9059 (void *)&cmd_flow_director_flexbytes,
9060 (void *)&cmd_flow_director_flexbytes_value,
9061 (void *)&cmd_flow_director_drop,
9062 (void *)&cmd_flow_director_pf_vf,
9063 (void *)&cmd_flow_director_queue,
9064 (void *)&cmd_flow_director_queue_id,
9065 (void *)&cmd_flow_director_fd_id,
9066 (void *)&cmd_flow_director_fd_id_value,
9071 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9072 .f = cmd_flow_director_filter_parsed,
9074 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9075 "director entry on NIC",
9077 (void *)&cmd_flow_director_filter,
9078 (void *)&cmd_flow_director_port_id,
9079 (void *)&cmd_flow_director_mode,
9080 (void *)&cmd_flow_director_mode_ip,
9081 (void *)&cmd_flow_director_ops,
9082 (void *)&cmd_flow_director_flow,
9083 (void *)&cmd_flow_director_flow_type,
9084 (void *)&cmd_flow_director_ether,
9085 (void *)&cmd_flow_director_ether_type,
9086 (void *)&cmd_flow_director_flexbytes,
9087 (void *)&cmd_flow_director_flexbytes_value,
9088 (void *)&cmd_flow_director_drop,
9089 (void *)&cmd_flow_director_pf_vf,
9090 (void *)&cmd_flow_director_queue,
9091 (void *)&cmd_flow_director_queue_id,
9092 (void *)&cmd_flow_director_fd_id,
9093 (void *)&cmd_flow_director_fd_id_value,
9098 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9099 .f = cmd_flow_director_filter_parsed,
9101 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9102 "director entry on NIC",
9104 (void *)&cmd_flow_director_filter,
9105 (void *)&cmd_flow_director_port_id,
9106 (void *)&cmd_flow_director_mode,
9107 (void *)&cmd_flow_director_mode_mac_vlan,
9108 (void *)&cmd_flow_director_ops,
9109 (void *)&cmd_flow_director_mac,
9110 (void *)&cmd_flow_director_mac_addr,
9111 (void *)&cmd_flow_director_vlan,
9112 (void *)&cmd_flow_director_vlan_value,
9113 (void *)&cmd_flow_director_flexbytes,
9114 (void *)&cmd_flow_director_flexbytes_value,
9115 (void *)&cmd_flow_director_drop,
9116 (void *)&cmd_flow_director_queue,
9117 (void *)&cmd_flow_director_queue_id,
9118 (void *)&cmd_flow_director_fd_id,
9119 (void *)&cmd_flow_director_fd_id_value,
9124 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9125 .f = cmd_flow_director_filter_parsed,
9127 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9128 "director entry on NIC",
9130 (void *)&cmd_flow_director_filter,
9131 (void *)&cmd_flow_director_port_id,
9132 (void *)&cmd_flow_director_mode,
9133 (void *)&cmd_flow_director_mode_tunnel,
9134 (void *)&cmd_flow_director_ops,
9135 (void *)&cmd_flow_director_mac,
9136 (void *)&cmd_flow_director_mac_addr,
9137 (void *)&cmd_flow_director_vlan,
9138 (void *)&cmd_flow_director_vlan_value,
9139 (void *)&cmd_flow_director_tunnel,
9140 (void *)&cmd_flow_director_tunnel_type,
9141 (void *)&cmd_flow_director_tunnel_id,
9142 (void *)&cmd_flow_director_tunnel_id_value,
9143 (void *)&cmd_flow_director_flexbytes,
9144 (void *)&cmd_flow_director_flexbytes_value,
9145 (void *)&cmd_flow_director_drop,
9146 (void *)&cmd_flow_director_queue,
9147 (void *)&cmd_flow_director_queue_id,
9148 (void *)&cmd_flow_director_fd_id,
9149 (void *)&cmd_flow_director_fd_id_value,
9154 struct cmd_flush_flow_director_result {
9155 cmdline_fixed_string_t flush_flow_director;
9159 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9160 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9161 flush_flow_director, "flush_flow_director");
9162 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9163 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9167 cmd_flush_flow_director_parsed(void *parsed_result,
9168 __attribute__((unused)) struct cmdline *cl,
9169 __attribute__((unused)) void *data)
9171 struct cmd_flow_director_result *res = parsed_result;
9174 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9176 printf("flow director is not supported on port %u.\n",
9181 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9182 RTE_ETH_FILTER_FLUSH, NULL);
9184 printf("flow director table flushing error: (%s)\n",
9188 cmdline_parse_inst_t cmd_flush_flow_director = {
9189 .f = cmd_flush_flow_director_parsed,
9191 .help_str = "flush_flow_director <port_id>: "
9192 "Flush all flow director entries of a device on NIC",
9194 (void *)&cmd_flush_flow_director_flush,
9195 (void *)&cmd_flush_flow_director_port_id,
9200 /* *** deal with flow director mask *** */
9201 struct cmd_flow_director_mask_result {
9202 cmdline_fixed_string_t flow_director_mask;
9204 cmdline_fixed_string_t mode;
9205 cmdline_fixed_string_t mode_value;
9206 cmdline_fixed_string_t vlan;
9208 cmdline_fixed_string_t src_mask;
9209 cmdline_ipaddr_t ipv4_src;
9210 cmdline_ipaddr_t ipv6_src;
9212 cmdline_fixed_string_t dst_mask;
9213 cmdline_ipaddr_t ipv4_dst;
9214 cmdline_ipaddr_t ipv6_dst;
9216 cmdline_fixed_string_t mac;
9217 uint8_t mac_addr_byte_mask;
9218 cmdline_fixed_string_t tunnel_id;
9219 uint32_t tunnel_id_mask;
9220 cmdline_fixed_string_t tunnel_type;
9221 uint8_t tunnel_type_mask;
9225 cmd_flow_director_mask_parsed(void *parsed_result,
9226 __attribute__((unused)) struct cmdline *cl,
9227 __attribute__((unused)) void *data)
9229 struct cmd_flow_director_mask_result *res = parsed_result;
9230 struct rte_eth_fdir_masks *mask;
9231 struct rte_port *port;
9233 if (res->port_id > nb_ports) {
9234 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9238 port = &ports[res->port_id];
9239 /** Check if the port is not started **/
9240 if (port->port_status != RTE_PORT_STOPPED) {
9241 printf("Please stop port %d first\n", res->port_id);
9245 mask = &port->dev_conf.fdir_conf.mask;
9247 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9248 if (strcmp(res->mode_value, "MAC-VLAN")) {
9249 printf("Please set mode to MAC-VLAN.\n");
9253 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9254 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9255 if (strcmp(res->mode_value, "Tunnel")) {
9256 printf("Please set mode to Tunnel.\n");
9260 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9261 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9262 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9263 mask->tunnel_type_mask = res->tunnel_type_mask;
9265 if (strcmp(res->mode_value, "IP")) {
9266 printf("Please set mode to IP.\n");
9270 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9271 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9272 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9273 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9274 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9275 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9276 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9279 cmd_reconfig_device_queue(res->port_id, 1, 1);
9282 cmdline_parse_token_string_t cmd_flow_director_mask =
9283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9284 flow_director_mask, "flow_director_mask");
9285 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9286 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9288 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9291 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9294 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9296 src_mask, "src_mask");
9297 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9298 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9300 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9301 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9303 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9304 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9306 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9307 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9308 dst_mask, "dst_mask");
9309 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9310 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9312 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9313 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9315 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9316 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9319 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9322 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9325 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9327 mode_value, "MAC-VLAN");
9328 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9330 mode_value, "Tunnel");
9331 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9334 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9335 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9336 mac_addr_byte_mask, UINT8);
9337 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9339 tunnel_type, "tunnel-type");
9340 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9341 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9342 tunnel_type_mask, UINT8);
9343 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9345 tunnel_id, "tunnel-id");
9346 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9347 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9348 tunnel_id_mask, UINT32);
9350 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9351 .f = cmd_flow_director_mask_parsed,
9353 .help_str = "flow_director_mask ... : "
9354 "Set IP mode flow director's mask on NIC",
9356 (void *)&cmd_flow_director_mask,
9357 (void *)&cmd_flow_director_mask_port_id,
9358 (void *)&cmd_flow_director_mask_mode,
9359 (void *)&cmd_flow_director_mask_mode_ip,
9360 (void *)&cmd_flow_director_mask_vlan,
9361 (void *)&cmd_flow_director_mask_vlan_value,
9362 (void *)&cmd_flow_director_mask_src,
9363 (void *)&cmd_flow_director_mask_ipv4_src,
9364 (void *)&cmd_flow_director_mask_ipv6_src,
9365 (void *)&cmd_flow_director_mask_port_src,
9366 (void *)&cmd_flow_director_mask_dst,
9367 (void *)&cmd_flow_director_mask_ipv4_dst,
9368 (void *)&cmd_flow_director_mask_ipv6_dst,
9369 (void *)&cmd_flow_director_mask_port_dst,
9374 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9375 .f = cmd_flow_director_mask_parsed,
9377 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9378 "flow director's mask on NIC",
9380 (void *)&cmd_flow_director_mask,
9381 (void *)&cmd_flow_director_mask_port_id,
9382 (void *)&cmd_flow_director_mask_mode,
9383 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9384 (void *)&cmd_flow_director_mask_vlan,
9385 (void *)&cmd_flow_director_mask_vlan_value,
9390 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9391 .f = cmd_flow_director_mask_parsed,
9393 .help_str = "flow_director_mask ... : Set tunnel mode "
9394 "flow director's mask on NIC",
9396 (void *)&cmd_flow_director_mask,
9397 (void *)&cmd_flow_director_mask_port_id,
9398 (void *)&cmd_flow_director_mask_mode,
9399 (void *)&cmd_flow_director_mask_mode_tunnel,
9400 (void *)&cmd_flow_director_mask_vlan,
9401 (void *)&cmd_flow_director_mask_vlan_value,
9402 (void *)&cmd_flow_director_mask_mac,
9403 (void *)&cmd_flow_director_mask_mac_value,
9404 (void *)&cmd_flow_director_mask_tunnel_type,
9405 (void *)&cmd_flow_director_mask_tunnel_type_value,
9406 (void *)&cmd_flow_director_mask_tunnel_id,
9407 (void *)&cmd_flow_director_mask_tunnel_id_value,
9412 /* *** deal with flow director mask on flexible payload *** */
9413 struct cmd_flow_director_flex_mask_result {
9414 cmdline_fixed_string_t flow_director_flexmask;
9416 cmdline_fixed_string_t flow;
9417 cmdline_fixed_string_t flow_type;
9418 cmdline_fixed_string_t mask;
9422 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9423 __attribute__((unused)) struct cmdline *cl,
9424 __attribute__((unused)) void *data)
9426 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9427 struct rte_eth_fdir_info fdir_info;
9428 struct rte_eth_fdir_flex_mask flex_mask;
9429 struct rte_port *port;
9430 uint32_t flow_type_mask;
9434 if (res->port_id > nb_ports) {
9435 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9439 port = &ports[res->port_id];
9440 /** Check if the port is not started **/
9441 if (port->port_status != RTE_PORT_STOPPED) {
9442 printf("Please stop port %d first\n", res->port_id);
9446 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9447 ret = parse_flexbytes(res->mask,
9449 RTE_ETH_FDIR_MAX_FLEXLEN);
9451 printf("error: Cannot parse mask input.\n");
9455 memset(&fdir_info, 0, sizeof(fdir_info));
9456 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9457 RTE_ETH_FILTER_INFO, &fdir_info);
9459 printf("Cannot get FDir filter info\n");
9463 if (!strcmp(res->flow_type, "none")) {
9464 /* means don't specify the flow type */
9465 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9466 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9467 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9468 0, sizeof(struct rte_eth_fdir_flex_mask));
9469 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9470 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9472 sizeof(struct rte_eth_fdir_flex_mask));
9473 cmd_reconfig_device_queue(res->port_id, 1, 1);
9476 flow_type_mask = fdir_info.flow_types_mask[0];
9477 if (!strcmp(res->flow_type, "all")) {
9478 if (!flow_type_mask) {
9479 printf("No flow type supported\n");
9482 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9483 if (flow_type_mask & (1 << i)) {
9484 flex_mask.flow_type = i;
9485 fdir_set_flex_mask(res->port_id, &flex_mask);
9488 cmd_reconfig_device_queue(res->port_id, 1, 1);
9491 flex_mask.flow_type = str2flowtype(res->flow_type);
9492 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9493 printf("Flow type %s not supported on port %d\n",
9494 res->flow_type, res->port_id);
9497 fdir_set_flex_mask(res->port_id, &flex_mask);
9498 cmd_reconfig_device_queue(res->port_id, 1, 1);
9501 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9502 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9503 flow_director_flexmask,
9504 "flow_director_flex_mask");
9505 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9506 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9508 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9511 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9513 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9514 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9515 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9516 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9519 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9520 .f = cmd_flow_director_flex_mask_parsed,
9522 .help_str = "flow_director_flex_mask ... : "
9523 "Set flow director's flex mask on NIC",
9525 (void *)&cmd_flow_director_flexmask,
9526 (void *)&cmd_flow_director_flexmask_port_id,
9527 (void *)&cmd_flow_director_flexmask_flow,
9528 (void *)&cmd_flow_director_flexmask_flow_type,
9529 (void *)&cmd_flow_director_flexmask_mask,
9534 /* *** deal with flow director flexible payload configuration *** */
9535 struct cmd_flow_director_flexpayload_result {
9536 cmdline_fixed_string_t flow_director_flexpayload;
9538 cmdline_fixed_string_t payload_layer;
9539 cmdline_fixed_string_t payload_cfg;
9543 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9546 const char *p, *p0 = q_arg;
9548 unsigned long int_fld;
9549 char *str_fld[max_num];
9554 p = strchr(p0, '(');
9558 p0 = strchr(p, ')');
9563 if (size >= sizeof(s))
9566 snprintf(s, sizeof(s), "%.*s", size, p);
9567 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9568 if (ret < 0 || ret > max_num)
9570 for (i = 0; i < ret; i++) {
9572 int_fld = strtoul(str_fld[i], &end, 0);
9573 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9575 offsets[i] = (uint16_t)int_fld;
9581 cmd_flow_director_flxpld_parsed(void *parsed_result,
9582 __attribute__((unused)) struct cmdline *cl,
9583 __attribute__((unused)) void *data)
9585 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9586 struct rte_eth_flex_payload_cfg flex_cfg;
9587 struct rte_port *port;
9590 if (res->port_id > nb_ports) {
9591 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9595 port = &ports[res->port_id];
9596 /** Check if the port is not started **/
9597 if (port->port_status != RTE_PORT_STOPPED) {
9598 printf("Please stop port %d first\n", res->port_id);
9602 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9604 if (!strcmp(res->payload_layer, "raw"))
9605 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9606 else if (!strcmp(res->payload_layer, "l2"))
9607 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9608 else if (!strcmp(res->payload_layer, "l3"))
9609 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9610 else if (!strcmp(res->payload_layer, "l4"))
9611 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9613 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9614 RTE_ETH_FDIR_MAX_FLEXLEN);
9616 printf("error: Cannot parse flex payload input.\n");
9620 fdir_set_flex_payload(res->port_id, &flex_cfg);
9621 cmd_reconfig_device_queue(res->port_id, 1, 1);
9624 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9626 flow_director_flexpayload,
9627 "flow_director_flex_payload");
9628 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9629 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9631 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9632 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9633 payload_layer, "raw#l2#l3#l4");
9634 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9635 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9638 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9639 .f = cmd_flow_director_flxpld_parsed,
9641 .help_str = "flow_director_flexpayload ... : "
9642 "Set flow director's flex payload on NIC",
9644 (void *)&cmd_flow_director_flexpayload,
9645 (void *)&cmd_flow_director_flexpayload_port_id,
9646 (void *)&cmd_flow_director_flexpayload_payload_layer,
9647 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9652 /* Generic flow interface command. */
9653 extern cmdline_parse_inst_t cmd_flow;
9655 /* *** Classification Filters Control *** */
9656 /* *** Get symmetric hash enable per port *** */
9657 struct cmd_get_sym_hash_ena_per_port_result {
9658 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9663 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9664 __rte_unused struct cmdline *cl,
9665 __rte_unused void *data)
9667 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9668 struct rte_eth_hash_filter_info info;
9671 if (rte_eth_dev_filter_supported(res->port_id,
9672 RTE_ETH_FILTER_HASH) < 0) {
9673 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9678 memset(&info, 0, sizeof(info));
9679 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9680 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9681 RTE_ETH_FILTER_GET, &info);
9684 printf("Cannot get symmetric hash enable per port "
9685 "on port %u\n", res->port_id);
9689 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9690 "enabled" : "disabled", res->port_id);
9693 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9694 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9695 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9696 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9697 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9700 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9701 .f = cmd_get_sym_hash_per_port_parsed,
9703 .help_str = "get_sym_hash_ena_per_port <port_id>",
9705 (void *)&cmd_get_sym_hash_ena_per_port_all,
9706 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9711 /* *** Set symmetric hash enable per port *** */
9712 struct cmd_set_sym_hash_ena_per_port_result {
9713 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9714 cmdline_fixed_string_t enable;
9719 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9720 __rte_unused struct cmdline *cl,
9721 __rte_unused void *data)
9723 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9724 struct rte_eth_hash_filter_info info;
9727 if (rte_eth_dev_filter_supported(res->port_id,
9728 RTE_ETH_FILTER_HASH) < 0) {
9729 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9734 memset(&info, 0, sizeof(info));
9735 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9736 if (!strcmp(res->enable, "enable"))
9737 info.info.enable = 1;
9738 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9739 RTE_ETH_FILTER_SET, &info);
9741 printf("Cannot set symmetric hash enable per port on "
9742 "port %u\n", res->port_id);
9745 printf("Symmetric hash has been set to %s on port %u\n",
9746 res->enable, res->port_id);
9749 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9750 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9751 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9752 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9753 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9755 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9756 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9757 enable, "enable#disable");
9759 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9760 .f = cmd_set_sym_hash_per_port_parsed,
9762 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9764 (void *)&cmd_set_sym_hash_ena_per_port_all,
9765 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9766 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9771 /* Get global config of hash function */
9772 struct cmd_get_hash_global_config_result {
9773 cmdline_fixed_string_t get_hash_global_config;
9778 flowtype_to_str(uint16_t ftype)
9785 {"ipv4", RTE_ETH_FLOW_IPV4},
9786 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9787 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9788 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9789 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9790 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9791 {"ipv6", RTE_ETH_FLOW_IPV6},
9792 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9793 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9794 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9795 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9796 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9797 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9798 {"port", RTE_ETH_FLOW_PORT},
9799 {"vxlan", RTE_ETH_FLOW_VXLAN},
9800 {"geneve", RTE_ETH_FLOW_GENEVE},
9801 {"nvgre", RTE_ETH_FLOW_NVGRE},
9804 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9805 if (ftype_table[i].ftype == ftype)
9806 return ftype_table[i].str;
9813 cmd_get_hash_global_config_parsed(void *parsed_result,
9814 __rte_unused struct cmdline *cl,
9815 __rte_unused void *data)
9817 struct cmd_get_hash_global_config_result *res = parsed_result;
9818 struct rte_eth_hash_filter_info info;
9819 uint32_t idx, offset;
9824 if (rte_eth_dev_filter_supported(res->port_id,
9825 RTE_ETH_FILTER_HASH) < 0) {
9826 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9831 memset(&info, 0, sizeof(info));
9832 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9833 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9834 RTE_ETH_FILTER_GET, &info);
9836 printf("Cannot get hash global configurations by port %d\n",
9841 switch (info.info.global_conf.hash_func) {
9842 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9843 printf("Hash function is Toeplitz\n");
9845 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9846 printf("Hash function is Simple XOR\n");
9849 printf("Unknown hash function\n");
9853 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9854 idx = i / UINT32_BIT;
9855 offset = i % UINT32_BIT;
9856 if (!(info.info.global_conf.valid_bit_mask[idx] &
9859 str = flowtype_to_str(i);
9862 printf("Symmetric hash is %s globally for flow type %s "
9864 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9865 (1UL << offset)) ? "enabled" : "disabled"), str,
9870 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9871 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9872 get_hash_global_config, "get_hash_global_config");
9873 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9874 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9877 cmdline_parse_inst_t cmd_get_hash_global_config = {
9878 .f = cmd_get_hash_global_config_parsed,
9880 .help_str = "get_hash_global_config <port_id>",
9882 (void *)&cmd_get_hash_global_config_all,
9883 (void *)&cmd_get_hash_global_config_port_id,
9888 /* Set global config of hash function */
9889 struct cmd_set_hash_global_config_result {
9890 cmdline_fixed_string_t set_hash_global_config;
9892 cmdline_fixed_string_t hash_func;
9893 cmdline_fixed_string_t flow_type;
9894 cmdline_fixed_string_t enable;
9898 cmd_set_hash_global_config_parsed(void *parsed_result,
9899 __rte_unused struct cmdline *cl,
9900 __rte_unused void *data)
9902 struct cmd_set_hash_global_config_result *res = parsed_result;
9903 struct rte_eth_hash_filter_info info;
9904 uint32_t ftype, idx, offset;
9907 if (rte_eth_dev_filter_supported(res->port_id,
9908 RTE_ETH_FILTER_HASH) < 0) {
9909 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9913 memset(&info, 0, sizeof(info));
9914 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9915 if (!strcmp(res->hash_func, "toeplitz"))
9916 info.info.global_conf.hash_func =
9917 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9918 else if (!strcmp(res->hash_func, "simple_xor"))
9919 info.info.global_conf.hash_func =
9920 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9921 else if (!strcmp(res->hash_func, "default"))
9922 info.info.global_conf.hash_func =
9923 RTE_ETH_HASH_FUNCTION_DEFAULT;
9925 ftype = str2flowtype(res->flow_type);
9926 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9927 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9928 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9929 if (!strcmp(res->enable, "enable"))
9930 info.info.global_conf.sym_hash_enable_mask[idx] |=
9932 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9933 RTE_ETH_FILTER_SET, &info);
9935 printf("Cannot set global hash configurations by port %d\n",
9938 printf("Global hash configurations have been set "
9939 "succcessfully by port %d\n", res->port_id);
9942 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9943 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9944 set_hash_global_config, "set_hash_global_config");
9945 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9946 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9948 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9949 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9950 hash_func, "toeplitz#simple_xor#default");
9951 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9952 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9954 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9955 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9956 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9957 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9958 enable, "enable#disable");
9960 cmdline_parse_inst_t cmd_set_hash_global_config = {
9961 .f = cmd_set_hash_global_config_parsed,
9963 .help_str = "set_hash_global_config <port_id> "
9964 "toeplitz|simple_xor|default "
9965 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9966 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9967 "l2_payload enable|disable",
9969 (void *)&cmd_set_hash_global_config_all,
9970 (void *)&cmd_set_hash_global_config_port_id,
9971 (void *)&cmd_set_hash_global_config_hash_func,
9972 (void *)&cmd_set_hash_global_config_flow_type,
9973 (void *)&cmd_set_hash_global_config_enable,
9978 /* Set hash input set */
9979 struct cmd_set_hash_input_set_result {
9980 cmdline_fixed_string_t set_hash_input_set;
9982 cmdline_fixed_string_t flow_type;
9983 cmdline_fixed_string_t inset_field;
9984 cmdline_fixed_string_t select;
9987 static enum rte_eth_input_set_field
9988 str2inset(char *string)
9992 static const struct {
9994 enum rte_eth_input_set_field inset;
9996 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9997 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9998 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9999 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10000 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10001 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10002 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10003 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10004 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10005 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10006 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10007 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10008 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10009 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10010 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10011 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10012 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10013 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10014 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10015 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10016 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10017 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10018 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10019 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10020 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10021 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10022 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10023 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10024 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10025 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10026 {"none", RTE_ETH_INPUT_SET_NONE},
10029 for (i = 0; i < RTE_DIM(inset_table); i++) {
10030 if (!strcmp(string, inset_table[i].str))
10031 return inset_table[i].inset;
10034 return RTE_ETH_INPUT_SET_UNKNOWN;
10038 cmd_set_hash_input_set_parsed(void *parsed_result,
10039 __rte_unused struct cmdline *cl,
10040 __rte_unused void *data)
10042 struct cmd_set_hash_input_set_result *res = parsed_result;
10043 struct rte_eth_hash_filter_info info;
10045 memset(&info, 0, sizeof(info));
10046 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10047 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10048 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10049 info.info.input_set_conf.inset_size = 1;
10050 if (!strcmp(res->select, "select"))
10051 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10052 else if (!strcmp(res->select, "add"))
10053 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10054 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10055 RTE_ETH_FILTER_SET, &info);
10058 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10059 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10060 set_hash_input_set, "set_hash_input_set");
10061 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10062 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10064 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10065 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10067 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10068 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10069 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10070 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10072 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10073 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10074 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10075 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10076 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10078 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10079 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10080 select, "select#add");
10082 cmdline_parse_inst_t cmd_set_hash_input_set = {
10083 .f = cmd_set_hash_input_set_parsed,
10085 .help_str = "set_hash_input_set <port_id> "
10086 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10087 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10088 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10089 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10090 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10091 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10092 "fld-7th|fld-8th|none select|add",
10094 (void *)&cmd_set_hash_input_set_cmd,
10095 (void *)&cmd_set_hash_input_set_port_id,
10096 (void *)&cmd_set_hash_input_set_flow_type,
10097 (void *)&cmd_set_hash_input_set_field,
10098 (void *)&cmd_set_hash_input_set_select,
10103 /* Set flow director input set */
10104 struct cmd_set_fdir_input_set_result {
10105 cmdline_fixed_string_t set_fdir_input_set;
10107 cmdline_fixed_string_t flow_type;
10108 cmdline_fixed_string_t inset_field;
10109 cmdline_fixed_string_t select;
10113 cmd_set_fdir_input_set_parsed(void *parsed_result,
10114 __rte_unused struct cmdline *cl,
10115 __rte_unused void *data)
10117 struct cmd_set_fdir_input_set_result *res = parsed_result;
10118 struct rte_eth_fdir_filter_info info;
10120 memset(&info, 0, sizeof(info));
10121 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10122 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10123 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10124 info.info.input_set_conf.inset_size = 1;
10125 if (!strcmp(res->select, "select"))
10126 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10127 else if (!strcmp(res->select, "add"))
10128 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10129 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10130 RTE_ETH_FILTER_SET, &info);
10133 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10134 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10135 set_fdir_input_set, "set_fdir_input_set");
10136 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10137 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10139 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10140 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10142 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10143 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10144 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10145 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10147 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10148 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10149 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10150 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10151 "sctp-veri-tag#none");
10152 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10153 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10154 select, "select#add");
10156 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10157 .f = cmd_set_fdir_input_set_parsed,
10159 .help_str = "set_fdir_input_set <port_id> "
10160 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10161 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10162 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10163 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10164 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10165 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10166 "sctp-veri-tag|none select|add",
10168 (void *)&cmd_set_fdir_input_set_cmd,
10169 (void *)&cmd_set_fdir_input_set_port_id,
10170 (void *)&cmd_set_fdir_input_set_flow_type,
10171 (void *)&cmd_set_fdir_input_set_field,
10172 (void *)&cmd_set_fdir_input_set_select,
10177 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10178 struct cmd_mcast_addr_result {
10179 cmdline_fixed_string_t mcast_addr_cmd;
10180 cmdline_fixed_string_t what;
10182 struct ether_addr mc_addr;
10185 static void cmd_mcast_addr_parsed(void *parsed_result,
10186 __attribute__((unused)) struct cmdline *cl,
10187 __attribute__((unused)) void *data)
10189 struct cmd_mcast_addr_result *res = parsed_result;
10191 if (!is_multicast_ether_addr(&res->mc_addr)) {
10192 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10193 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10194 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10195 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10198 if (strcmp(res->what, "add") == 0)
10199 mcast_addr_add(res->port_num, &res->mc_addr);
10201 mcast_addr_remove(res->port_num, &res->mc_addr);
10204 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10205 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10206 mcast_addr_cmd, "mcast_addr");
10207 cmdline_parse_token_string_t cmd_mcast_addr_what =
10208 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10210 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10211 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10212 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10213 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10215 cmdline_parse_inst_t cmd_mcast_addr = {
10216 .f = cmd_mcast_addr_parsed,
10218 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10219 "Add/Remove multicast MAC address on port_id",
10221 (void *)&cmd_mcast_addr_cmd,
10222 (void *)&cmd_mcast_addr_what,
10223 (void *)&cmd_mcast_addr_portnum,
10224 (void *)&cmd_mcast_addr_addr,
10229 /* l2 tunnel config
10230 * only support E-tag now.
10233 /* Ether type config */
10234 struct cmd_config_l2_tunnel_eth_type_result {
10235 cmdline_fixed_string_t port;
10236 cmdline_fixed_string_t config;
10237 cmdline_fixed_string_t all;
10239 cmdline_fixed_string_t l2_tunnel;
10240 cmdline_fixed_string_t l2_tunnel_type;
10241 cmdline_fixed_string_t eth_type;
10242 uint16_t eth_type_val;
10245 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10246 TOKEN_STRING_INITIALIZER
10247 (struct cmd_config_l2_tunnel_eth_type_result,
10249 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10250 TOKEN_STRING_INITIALIZER
10251 (struct cmd_config_l2_tunnel_eth_type_result,
10253 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10254 TOKEN_STRING_INITIALIZER
10255 (struct cmd_config_l2_tunnel_eth_type_result,
10257 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10258 TOKEN_NUM_INITIALIZER
10259 (struct cmd_config_l2_tunnel_eth_type_result,
10261 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10262 TOKEN_STRING_INITIALIZER
10263 (struct cmd_config_l2_tunnel_eth_type_result,
10264 l2_tunnel, "l2-tunnel");
10265 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10266 TOKEN_STRING_INITIALIZER
10267 (struct cmd_config_l2_tunnel_eth_type_result,
10268 l2_tunnel_type, "E-tag");
10269 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10270 TOKEN_STRING_INITIALIZER
10271 (struct cmd_config_l2_tunnel_eth_type_result,
10272 eth_type, "ether-type");
10273 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10274 TOKEN_NUM_INITIALIZER
10275 (struct cmd_config_l2_tunnel_eth_type_result,
10276 eth_type_val, UINT16);
10278 static enum rte_eth_tunnel_type
10279 str2fdir_l2_tunnel_type(char *string)
10283 static const struct {
10285 enum rte_eth_tunnel_type type;
10286 } l2_tunnel_type_str[] = {
10287 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10290 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10291 if (!strcmp(l2_tunnel_type_str[i].str, string))
10292 return l2_tunnel_type_str[i].type;
10294 return RTE_TUNNEL_TYPE_NONE;
10297 /* ether type config for all ports */
10299 cmd_config_l2_tunnel_eth_type_all_parsed
10300 (void *parsed_result,
10301 __attribute__((unused)) struct cmdline *cl,
10302 __attribute__((unused)) void *data)
10304 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10305 struct rte_eth_l2_tunnel_conf entry;
10308 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10309 entry.ether_type = res->eth_type_val;
10311 FOREACH_PORT(pid, ports) {
10312 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10316 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10317 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10319 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10321 (void *)&cmd_config_l2_tunnel_eth_type_port,
10322 (void *)&cmd_config_l2_tunnel_eth_type_config,
10323 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10324 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10325 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10326 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10327 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10332 /* ether type config for a specific port */
10334 cmd_config_l2_tunnel_eth_type_specific_parsed(
10335 void *parsed_result,
10336 __attribute__((unused)) struct cmdline *cl,
10337 __attribute__((unused)) void *data)
10339 struct cmd_config_l2_tunnel_eth_type_result *res =
10341 struct rte_eth_l2_tunnel_conf entry;
10343 if (port_id_is_invalid(res->id, ENABLED_WARN))
10346 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10347 entry.ether_type = res->eth_type_val;
10349 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10352 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10353 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10355 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10357 (void *)&cmd_config_l2_tunnel_eth_type_port,
10358 (void *)&cmd_config_l2_tunnel_eth_type_config,
10359 (void *)&cmd_config_l2_tunnel_eth_type_id,
10360 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10361 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10362 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10363 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10368 /* Enable/disable l2 tunnel */
10369 struct cmd_config_l2_tunnel_en_dis_result {
10370 cmdline_fixed_string_t port;
10371 cmdline_fixed_string_t config;
10372 cmdline_fixed_string_t all;
10374 cmdline_fixed_string_t l2_tunnel;
10375 cmdline_fixed_string_t l2_tunnel_type;
10376 cmdline_fixed_string_t en_dis;
10379 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10380 TOKEN_STRING_INITIALIZER
10381 (struct cmd_config_l2_tunnel_en_dis_result,
10383 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10384 TOKEN_STRING_INITIALIZER
10385 (struct cmd_config_l2_tunnel_en_dis_result,
10387 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10388 TOKEN_STRING_INITIALIZER
10389 (struct cmd_config_l2_tunnel_en_dis_result,
10391 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10392 TOKEN_NUM_INITIALIZER
10393 (struct cmd_config_l2_tunnel_en_dis_result,
10395 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10396 TOKEN_STRING_INITIALIZER
10397 (struct cmd_config_l2_tunnel_en_dis_result,
10398 l2_tunnel, "l2-tunnel");
10399 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10400 TOKEN_STRING_INITIALIZER
10401 (struct cmd_config_l2_tunnel_en_dis_result,
10402 l2_tunnel_type, "E-tag");
10403 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10404 TOKEN_STRING_INITIALIZER
10405 (struct cmd_config_l2_tunnel_en_dis_result,
10406 en_dis, "enable#disable");
10408 /* enable/disable l2 tunnel for all ports */
10410 cmd_config_l2_tunnel_en_dis_all_parsed(
10411 void *parsed_result,
10412 __attribute__((unused)) struct cmdline *cl,
10413 __attribute__((unused)) void *data)
10415 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10416 struct rte_eth_l2_tunnel_conf entry;
10420 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10422 if (!strcmp("enable", res->en_dis))
10427 FOREACH_PORT(pid, ports) {
10428 rte_eth_dev_l2_tunnel_offload_set(pid,
10430 ETH_L2_TUNNEL_ENABLE_MASK,
10435 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10436 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10438 .help_str = "port config all l2-tunnel E-tag enable|disable",
10440 (void *)&cmd_config_l2_tunnel_en_dis_port,
10441 (void *)&cmd_config_l2_tunnel_en_dis_config,
10442 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10443 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10444 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10445 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10450 /* enable/disable l2 tunnel for a port */
10452 cmd_config_l2_tunnel_en_dis_specific_parsed(
10453 void *parsed_result,
10454 __attribute__((unused)) struct cmdline *cl,
10455 __attribute__((unused)) void *data)
10457 struct cmd_config_l2_tunnel_en_dis_result *res =
10459 struct rte_eth_l2_tunnel_conf entry;
10461 if (port_id_is_invalid(res->id, ENABLED_WARN))
10464 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10466 if (!strcmp("enable", res->en_dis))
10467 rte_eth_dev_l2_tunnel_offload_set(res->id,
10469 ETH_L2_TUNNEL_ENABLE_MASK,
10472 rte_eth_dev_l2_tunnel_offload_set(res->id,
10474 ETH_L2_TUNNEL_ENABLE_MASK,
10478 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10479 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10481 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10483 (void *)&cmd_config_l2_tunnel_en_dis_port,
10484 (void *)&cmd_config_l2_tunnel_en_dis_config,
10485 (void *)&cmd_config_l2_tunnel_en_dis_id,
10486 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10487 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10488 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10493 /* E-tag configuration */
10495 /* Common result structure for all E-tag configuration */
10496 struct cmd_config_e_tag_result {
10497 cmdline_fixed_string_t e_tag;
10498 cmdline_fixed_string_t set;
10499 cmdline_fixed_string_t insertion;
10500 cmdline_fixed_string_t stripping;
10501 cmdline_fixed_string_t forwarding;
10502 cmdline_fixed_string_t filter;
10503 cmdline_fixed_string_t add;
10504 cmdline_fixed_string_t del;
10505 cmdline_fixed_string_t on;
10506 cmdline_fixed_string_t off;
10507 cmdline_fixed_string_t on_off;
10508 cmdline_fixed_string_t port_tag_id;
10509 uint32_t port_tag_id_val;
10510 cmdline_fixed_string_t e_tag_id;
10511 uint16_t e_tag_id_val;
10512 cmdline_fixed_string_t dst_pool;
10513 uint8_t dst_pool_val;
10514 cmdline_fixed_string_t port;
10516 cmdline_fixed_string_t vf;
10520 /* Common CLI fields for all E-tag configuration */
10521 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10522 TOKEN_STRING_INITIALIZER
10523 (struct cmd_config_e_tag_result,
10525 cmdline_parse_token_string_t cmd_config_e_tag_set =
10526 TOKEN_STRING_INITIALIZER
10527 (struct cmd_config_e_tag_result,
10529 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10530 TOKEN_STRING_INITIALIZER
10531 (struct cmd_config_e_tag_result,
10532 insertion, "insertion");
10533 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10534 TOKEN_STRING_INITIALIZER
10535 (struct cmd_config_e_tag_result,
10536 stripping, "stripping");
10537 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10538 TOKEN_STRING_INITIALIZER
10539 (struct cmd_config_e_tag_result,
10540 forwarding, "forwarding");
10541 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10542 TOKEN_STRING_INITIALIZER
10543 (struct cmd_config_e_tag_result,
10545 cmdline_parse_token_string_t cmd_config_e_tag_add =
10546 TOKEN_STRING_INITIALIZER
10547 (struct cmd_config_e_tag_result,
10549 cmdline_parse_token_string_t cmd_config_e_tag_del =
10550 TOKEN_STRING_INITIALIZER
10551 (struct cmd_config_e_tag_result,
10553 cmdline_parse_token_string_t cmd_config_e_tag_on =
10554 TOKEN_STRING_INITIALIZER
10555 (struct cmd_config_e_tag_result,
10557 cmdline_parse_token_string_t cmd_config_e_tag_off =
10558 TOKEN_STRING_INITIALIZER
10559 (struct cmd_config_e_tag_result,
10561 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10562 TOKEN_STRING_INITIALIZER
10563 (struct cmd_config_e_tag_result,
10565 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10566 TOKEN_STRING_INITIALIZER
10567 (struct cmd_config_e_tag_result,
10568 port_tag_id, "port-tag-id");
10569 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10570 TOKEN_NUM_INITIALIZER
10571 (struct cmd_config_e_tag_result,
10572 port_tag_id_val, UINT32);
10573 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10574 TOKEN_STRING_INITIALIZER
10575 (struct cmd_config_e_tag_result,
10576 e_tag_id, "e-tag-id");
10577 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10578 TOKEN_NUM_INITIALIZER
10579 (struct cmd_config_e_tag_result,
10580 e_tag_id_val, UINT16);
10581 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10582 TOKEN_STRING_INITIALIZER
10583 (struct cmd_config_e_tag_result,
10584 dst_pool, "dst-pool");
10585 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10586 TOKEN_NUM_INITIALIZER
10587 (struct cmd_config_e_tag_result,
10588 dst_pool_val, UINT8);
10589 cmdline_parse_token_string_t cmd_config_e_tag_port =
10590 TOKEN_STRING_INITIALIZER
10591 (struct cmd_config_e_tag_result,
10593 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10594 TOKEN_NUM_INITIALIZER
10595 (struct cmd_config_e_tag_result,
10597 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10598 TOKEN_STRING_INITIALIZER
10599 (struct cmd_config_e_tag_result,
10601 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10602 TOKEN_NUM_INITIALIZER
10603 (struct cmd_config_e_tag_result,
10606 /* E-tag insertion configuration */
10608 cmd_config_e_tag_insertion_en_parsed(
10609 void *parsed_result,
10610 __attribute__((unused)) struct cmdline *cl,
10611 __attribute__((unused)) void *data)
10613 struct cmd_config_e_tag_result *res =
10615 struct rte_eth_l2_tunnel_conf entry;
10617 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10620 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10621 entry.tunnel_id = res->port_tag_id_val;
10622 entry.vf_id = res->vf_id;
10623 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10625 ETH_L2_TUNNEL_INSERTION_MASK,
10630 cmd_config_e_tag_insertion_dis_parsed(
10631 void *parsed_result,
10632 __attribute__((unused)) struct cmdline *cl,
10633 __attribute__((unused)) void *data)
10635 struct cmd_config_e_tag_result *res =
10637 struct rte_eth_l2_tunnel_conf entry;
10639 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10642 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10643 entry.vf_id = res->vf_id;
10645 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10647 ETH_L2_TUNNEL_INSERTION_MASK,
10651 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10652 .f = cmd_config_e_tag_insertion_en_parsed,
10654 .help_str = "E-tag ... : E-tag insertion enable",
10656 (void *)&cmd_config_e_tag_e_tag,
10657 (void *)&cmd_config_e_tag_set,
10658 (void *)&cmd_config_e_tag_insertion,
10659 (void *)&cmd_config_e_tag_on,
10660 (void *)&cmd_config_e_tag_port_tag_id,
10661 (void *)&cmd_config_e_tag_port_tag_id_val,
10662 (void *)&cmd_config_e_tag_port,
10663 (void *)&cmd_config_e_tag_port_id,
10664 (void *)&cmd_config_e_tag_vf,
10665 (void *)&cmd_config_e_tag_vf_id,
10670 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10671 .f = cmd_config_e_tag_insertion_dis_parsed,
10673 .help_str = "E-tag ... : E-tag insertion disable",
10675 (void *)&cmd_config_e_tag_e_tag,
10676 (void *)&cmd_config_e_tag_set,
10677 (void *)&cmd_config_e_tag_insertion,
10678 (void *)&cmd_config_e_tag_off,
10679 (void *)&cmd_config_e_tag_port,
10680 (void *)&cmd_config_e_tag_port_id,
10681 (void *)&cmd_config_e_tag_vf,
10682 (void *)&cmd_config_e_tag_vf_id,
10687 /* E-tag stripping configuration */
10689 cmd_config_e_tag_stripping_parsed(
10690 void *parsed_result,
10691 __attribute__((unused)) struct cmdline *cl,
10692 __attribute__((unused)) void *data)
10694 struct cmd_config_e_tag_result *res =
10696 struct rte_eth_l2_tunnel_conf entry;
10698 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10701 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10703 if (!strcmp(res->on_off, "on"))
10704 rte_eth_dev_l2_tunnel_offload_set
10707 ETH_L2_TUNNEL_STRIPPING_MASK,
10710 rte_eth_dev_l2_tunnel_offload_set
10713 ETH_L2_TUNNEL_STRIPPING_MASK,
10717 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10718 .f = cmd_config_e_tag_stripping_parsed,
10720 .help_str = "E-tag ... : E-tag stripping enable/disable",
10722 (void *)&cmd_config_e_tag_e_tag,
10723 (void *)&cmd_config_e_tag_set,
10724 (void *)&cmd_config_e_tag_stripping,
10725 (void *)&cmd_config_e_tag_on_off,
10726 (void *)&cmd_config_e_tag_port,
10727 (void *)&cmd_config_e_tag_port_id,
10732 /* E-tag forwarding configuration */
10734 cmd_config_e_tag_forwarding_parsed(
10735 void *parsed_result,
10736 __attribute__((unused)) struct cmdline *cl,
10737 __attribute__((unused)) void *data)
10739 struct cmd_config_e_tag_result *res = parsed_result;
10740 struct rte_eth_l2_tunnel_conf entry;
10742 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10745 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10747 if (!strcmp(res->on_off, "on"))
10748 rte_eth_dev_l2_tunnel_offload_set
10751 ETH_L2_TUNNEL_FORWARDING_MASK,
10754 rte_eth_dev_l2_tunnel_offload_set
10757 ETH_L2_TUNNEL_FORWARDING_MASK,
10761 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10762 .f = cmd_config_e_tag_forwarding_parsed,
10764 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10766 (void *)&cmd_config_e_tag_e_tag,
10767 (void *)&cmd_config_e_tag_set,
10768 (void *)&cmd_config_e_tag_forwarding,
10769 (void *)&cmd_config_e_tag_on_off,
10770 (void *)&cmd_config_e_tag_port,
10771 (void *)&cmd_config_e_tag_port_id,
10776 /* E-tag filter configuration */
10778 cmd_config_e_tag_filter_add_parsed(
10779 void *parsed_result,
10780 __attribute__((unused)) struct cmdline *cl,
10781 __attribute__((unused)) void *data)
10783 struct cmd_config_e_tag_result *res = parsed_result;
10784 struct rte_eth_l2_tunnel_conf entry;
10787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10790 if (res->e_tag_id_val > 0x3fff) {
10791 printf("e-tag-id must be equal or less than 0x3fff.\n");
10795 ret = rte_eth_dev_filter_supported(res->port_id,
10796 RTE_ETH_FILTER_L2_TUNNEL);
10798 printf("E-tag filter is not supported on port %u.\n",
10803 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10804 entry.tunnel_id = res->e_tag_id_val;
10805 entry.pool = res->dst_pool_val;
10807 ret = rte_eth_dev_filter_ctrl(res->port_id,
10808 RTE_ETH_FILTER_L2_TUNNEL,
10809 RTE_ETH_FILTER_ADD,
10812 printf("E-tag filter programming error: (%s)\n",
10816 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10817 .f = cmd_config_e_tag_filter_add_parsed,
10819 .help_str = "E-tag ... : E-tag filter add",
10821 (void *)&cmd_config_e_tag_e_tag,
10822 (void *)&cmd_config_e_tag_set,
10823 (void *)&cmd_config_e_tag_filter,
10824 (void *)&cmd_config_e_tag_add,
10825 (void *)&cmd_config_e_tag_e_tag_id,
10826 (void *)&cmd_config_e_tag_e_tag_id_val,
10827 (void *)&cmd_config_e_tag_dst_pool,
10828 (void *)&cmd_config_e_tag_dst_pool_val,
10829 (void *)&cmd_config_e_tag_port,
10830 (void *)&cmd_config_e_tag_port_id,
10836 cmd_config_e_tag_filter_del_parsed(
10837 void *parsed_result,
10838 __attribute__((unused)) struct cmdline *cl,
10839 __attribute__((unused)) void *data)
10841 struct cmd_config_e_tag_result *res = parsed_result;
10842 struct rte_eth_l2_tunnel_conf entry;
10845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10848 if (res->e_tag_id_val > 0x3fff) {
10849 printf("e-tag-id must be less than 0x3fff.\n");
10853 ret = rte_eth_dev_filter_supported(res->port_id,
10854 RTE_ETH_FILTER_L2_TUNNEL);
10856 printf("E-tag filter is not supported on port %u.\n",
10861 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10862 entry.tunnel_id = res->e_tag_id_val;
10864 ret = rte_eth_dev_filter_ctrl(res->port_id,
10865 RTE_ETH_FILTER_L2_TUNNEL,
10866 RTE_ETH_FILTER_DELETE,
10869 printf("E-tag filter programming error: (%s)\n",
10873 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10874 .f = cmd_config_e_tag_filter_del_parsed,
10876 .help_str = "E-tag ... : E-tag filter delete",
10878 (void *)&cmd_config_e_tag_e_tag,
10879 (void *)&cmd_config_e_tag_set,
10880 (void *)&cmd_config_e_tag_filter,
10881 (void *)&cmd_config_e_tag_del,
10882 (void *)&cmd_config_e_tag_e_tag_id,
10883 (void *)&cmd_config_e_tag_e_tag_id_val,
10884 (void *)&cmd_config_e_tag_port,
10885 (void *)&cmd_config_e_tag_port_id,
10890 /* vf vlan anti spoof configuration */
10892 /* Common result structure for vf vlan anti spoof */
10893 struct cmd_vf_vlan_anti_spoof_result {
10894 cmdline_fixed_string_t set;
10895 cmdline_fixed_string_t vf;
10896 cmdline_fixed_string_t vlan;
10897 cmdline_fixed_string_t antispoof;
10900 cmdline_fixed_string_t on_off;
10903 /* Common CLI fields for vf vlan anti spoof enable disable */
10904 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10905 TOKEN_STRING_INITIALIZER
10906 (struct cmd_vf_vlan_anti_spoof_result,
10908 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10909 TOKEN_STRING_INITIALIZER
10910 (struct cmd_vf_vlan_anti_spoof_result,
10912 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10913 TOKEN_STRING_INITIALIZER
10914 (struct cmd_vf_vlan_anti_spoof_result,
10916 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10917 TOKEN_STRING_INITIALIZER
10918 (struct cmd_vf_vlan_anti_spoof_result,
10919 antispoof, "antispoof");
10920 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10921 TOKEN_NUM_INITIALIZER
10922 (struct cmd_vf_vlan_anti_spoof_result,
10924 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10925 TOKEN_NUM_INITIALIZER
10926 (struct cmd_vf_vlan_anti_spoof_result,
10928 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10929 TOKEN_STRING_INITIALIZER
10930 (struct cmd_vf_vlan_anti_spoof_result,
10934 cmd_set_vf_vlan_anti_spoof_parsed(
10935 void *parsed_result,
10936 __attribute__((unused)) struct cmdline *cl,
10937 __attribute__((unused)) void *data)
10939 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10940 int ret = -ENOTSUP;
10942 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10944 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10947 #ifdef RTE_LIBRTE_IXGBE_PMD
10948 if (ret == -ENOTSUP)
10949 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10950 res->vf_id, is_on);
10952 #ifdef RTE_LIBRTE_I40E_PMD
10953 if (ret == -ENOTSUP)
10954 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10955 res->vf_id, is_on);
10962 printf("invalid vf_id %d\n", res->vf_id);
10965 printf("invalid port_id %d\n", res->port_id);
10968 printf("function not implemented\n");
10971 printf("programming error: (%s)\n", strerror(-ret));
10975 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10976 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10978 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10980 (void *)&cmd_vf_vlan_anti_spoof_set,
10981 (void *)&cmd_vf_vlan_anti_spoof_vf,
10982 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10983 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10984 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10985 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10986 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10991 /* vf mac anti spoof configuration */
10993 /* Common result structure for vf mac anti spoof */
10994 struct cmd_vf_mac_anti_spoof_result {
10995 cmdline_fixed_string_t set;
10996 cmdline_fixed_string_t vf;
10997 cmdline_fixed_string_t mac;
10998 cmdline_fixed_string_t antispoof;
11001 cmdline_fixed_string_t on_off;
11004 /* Common CLI fields for vf mac anti spoof enable disable */
11005 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11006 TOKEN_STRING_INITIALIZER
11007 (struct cmd_vf_mac_anti_spoof_result,
11009 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11010 TOKEN_STRING_INITIALIZER
11011 (struct cmd_vf_mac_anti_spoof_result,
11013 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11014 TOKEN_STRING_INITIALIZER
11015 (struct cmd_vf_mac_anti_spoof_result,
11017 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11018 TOKEN_STRING_INITIALIZER
11019 (struct cmd_vf_mac_anti_spoof_result,
11020 antispoof, "antispoof");
11021 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11022 TOKEN_NUM_INITIALIZER
11023 (struct cmd_vf_mac_anti_spoof_result,
11025 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11026 TOKEN_NUM_INITIALIZER
11027 (struct cmd_vf_mac_anti_spoof_result,
11029 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11030 TOKEN_STRING_INITIALIZER
11031 (struct cmd_vf_mac_anti_spoof_result,
11035 cmd_set_vf_mac_anti_spoof_parsed(
11036 void *parsed_result,
11037 __attribute__((unused)) struct cmdline *cl,
11038 __attribute__((unused)) void *data)
11040 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11041 int ret = -ENOTSUP;
11043 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11045 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11048 #ifdef RTE_LIBRTE_IXGBE_PMD
11049 if (ret == -ENOTSUP)
11050 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11051 res->vf_id, is_on);
11053 #ifdef RTE_LIBRTE_I40E_PMD
11054 if (ret == -ENOTSUP)
11055 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11056 res->vf_id, is_on);
11063 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11066 printf("invalid port_id %d\n", res->port_id);
11069 printf("function not implemented\n");
11072 printf("programming error: (%s)\n", strerror(-ret));
11076 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11077 .f = cmd_set_vf_mac_anti_spoof_parsed,
11079 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11081 (void *)&cmd_vf_mac_anti_spoof_set,
11082 (void *)&cmd_vf_mac_anti_spoof_vf,
11083 (void *)&cmd_vf_mac_anti_spoof_mac,
11084 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11085 (void *)&cmd_vf_mac_anti_spoof_port_id,
11086 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11087 (void *)&cmd_vf_mac_anti_spoof_on_off,
11092 /* vf vlan strip queue configuration */
11094 /* Common result structure for vf mac anti spoof */
11095 struct cmd_vf_vlan_stripq_result {
11096 cmdline_fixed_string_t set;
11097 cmdline_fixed_string_t vf;
11098 cmdline_fixed_string_t vlan;
11099 cmdline_fixed_string_t stripq;
11102 cmdline_fixed_string_t on_off;
11105 /* Common CLI fields for vf vlan strip enable disable */
11106 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11107 TOKEN_STRING_INITIALIZER
11108 (struct cmd_vf_vlan_stripq_result,
11110 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11111 TOKEN_STRING_INITIALIZER
11112 (struct cmd_vf_vlan_stripq_result,
11114 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11115 TOKEN_STRING_INITIALIZER
11116 (struct cmd_vf_vlan_stripq_result,
11118 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11119 TOKEN_STRING_INITIALIZER
11120 (struct cmd_vf_vlan_stripq_result,
11122 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11123 TOKEN_NUM_INITIALIZER
11124 (struct cmd_vf_vlan_stripq_result,
11126 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11127 TOKEN_NUM_INITIALIZER
11128 (struct cmd_vf_vlan_stripq_result,
11130 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11131 TOKEN_STRING_INITIALIZER
11132 (struct cmd_vf_vlan_stripq_result,
11136 cmd_set_vf_vlan_stripq_parsed(
11137 void *parsed_result,
11138 __attribute__((unused)) struct cmdline *cl,
11139 __attribute__((unused)) void *data)
11141 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11142 int ret = -ENOTSUP;
11144 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11146 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11149 #ifdef RTE_LIBRTE_IXGBE_PMD
11150 if (ret == -ENOTSUP)
11151 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11152 res->vf_id, is_on);
11154 #ifdef RTE_LIBRTE_I40E_PMD
11155 if (ret == -ENOTSUP)
11156 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11157 res->vf_id, is_on);
11164 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11167 printf("invalid port_id %d\n", res->port_id);
11170 printf("function not implemented\n");
11173 printf("programming error: (%s)\n", strerror(-ret));
11177 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11178 .f = cmd_set_vf_vlan_stripq_parsed,
11180 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11182 (void *)&cmd_vf_vlan_stripq_set,
11183 (void *)&cmd_vf_vlan_stripq_vf,
11184 (void *)&cmd_vf_vlan_stripq_vlan,
11185 (void *)&cmd_vf_vlan_stripq_stripq,
11186 (void *)&cmd_vf_vlan_stripq_port_id,
11187 (void *)&cmd_vf_vlan_stripq_vf_id,
11188 (void *)&cmd_vf_vlan_stripq_on_off,
11193 /* vf vlan insert configuration */
11195 /* Common result structure for vf vlan insert */
11196 struct cmd_vf_vlan_insert_result {
11197 cmdline_fixed_string_t set;
11198 cmdline_fixed_string_t vf;
11199 cmdline_fixed_string_t vlan;
11200 cmdline_fixed_string_t insert;
11206 /* Common CLI fields for vf vlan insert enable disable */
11207 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11208 TOKEN_STRING_INITIALIZER
11209 (struct cmd_vf_vlan_insert_result,
11211 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11212 TOKEN_STRING_INITIALIZER
11213 (struct cmd_vf_vlan_insert_result,
11215 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11216 TOKEN_STRING_INITIALIZER
11217 (struct cmd_vf_vlan_insert_result,
11219 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11220 TOKEN_STRING_INITIALIZER
11221 (struct cmd_vf_vlan_insert_result,
11223 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11224 TOKEN_NUM_INITIALIZER
11225 (struct cmd_vf_vlan_insert_result,
11227 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11228 TOKEN_NUM_INITIALIZER
11229 (struct cmd_vf_vlan_insert_result,
11231 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11232 TOKEN_NUM_INITIALIZER
11233 (struct cmd_vf_vlan_insert_result,
11237 cmd_set_vf_vlan_insert_parsed(
11238 void *parsed_result,
11239 __attribute__((unused)) struct cmdline *cl,
11240 __attribute__((unused)) void *data)
11242 struct cmd_vf_vlan_insert_result *res = parsed_result;
11243 int ret = -ENOTSUP;
11245 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11248 #ifdef RTE_LIBRTE_IXGBE_PMD
11249 if (ret == -ENOTSUP)
11250 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11253 #ifdef RTE_LIBRTE_I40E_PMD
11254 if (ret == -ENOTSUP)
11255 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11263 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11266 printf("invalid port_id %d\n", res->port_id);
11269 printf("function not implemented\n");
11272 printf("programming error: (%s)\n", strerror(-ret));
11276 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11277 .f = cmd_set_vf_vlan_insert_parsed,
11279 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11281 (void *)&cmd_vf_vlan_insert_set,
11282 (void *)&cmd_vf_vlan_insert_vf,
11283 (void *)&cmd_vf_vlan_insert_vlan,
11284 (void *)&cmd_vf_vlan_insert_insert,
11285 (void *)&cmd_vf_vlan_insert_port_id,
11286 (void *)&cmd_vf_vlan_insert_vf_id,
11287 (void *)&cmd_vf_vlan_insert_vlan_id,
11292 /* tx loopback configuration */
11294 /* Common result structure for tx loopback */
11295 struct cmd_tx_loopback_result {
11296 cmdline_fixed_string_t set;
11297 cmdline_fixed_string_t tx;
11298 cmdline_fixed_string_t loopback;
11300 cmdline_fixed_string_t on_off;
11303 /* Common CLI fields for tx loopback enable disable */
11304 cmdline_parse_token_string_t cmd_tx_loopback_set =
11305 TOKEN_STRING_INITIALIZER
11306 (struct cmd_tx_loopback_result,
11308 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11309 TOKEN_STRING_INITIALIZER
11310 (struct cmd_tx_loopback_result,
11312 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11313 TOKEN_STRING_INITIALIZER
11314 (struct cmd_tx_loopback_result,
11315 loopback, "loopback");
11316 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11317 TOKEN_NUM_INITIALIZER
11318 (struct cmd_tx_loopback_result,
11320 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11321 TOKEN_STRING_INITIALIZER
11322 (struct cmd_tx_loopback_result,
11326 cmd_set_tx_loopback_parsed(
11327 void *parsed_result,
11328 __attribute__((unused)) struct cmdline *cl,
11329 __attribute__((unused)) void *data)
11331 struct cmd_tx_loopback_result *res = parsed_result;
11332 int ret = -ENOTSUP;
11334 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11336 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11339 #ifdef RTE_LIBRTE_IXGBE_PMD
11340 if (ret == -ENOTSUP)
11341 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11343 #ifdef RTE_LIBRTE_I40E_PMD
11344 if (ret == -ENOTSUP)
11345 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11352 printf("invalid is_on %d\n", is_on);
11355 printf("invalid port_id %d\n", res->port_id);
11358 printf("function not implemented\n");
11361 printf("programming error: (%s)\n", strerror(-ret));
11365 cmdline_parse_inst_t cmd_set_tx_loopback = {
11366 .f = cmd_set_tx_loopback_parsed,
11368 .help_str = "set tx loopback <port_id> on|off",
11370 (void *)&cmd_tx_loopback_set,
11371 (void *)&cmd_tx_loopback_tx,
11372 (void *)&cmd_tx_loopback_loopback,
11373 (void *)&cmd_tx_loopback_port_id,
11374 (void *)&cmd_tx_loopback_on_off,
11379 #ifdef RTE_LIBRTE_IXGBE_PMD
11380 /* all queues drop enable configuration */
11382 /* Common result structure for all queues drop enable */
11383 struct cmd_all_queues_drop_en_result {
11384 cmdline_fixed_string_t set;
11385 cmdline_fixed_string_t all;
11386 cmdline_fixed_string_t queues;
11387 cmdline_fixed_string_t drop;
11389 cmdline_fixed_string_t on_off;
11392 /* Common CLI fields for tx loopback enable disable */
11393 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11394 TOKEN_STRING_INITIALIZER
11395 (struct cmd_all_queues_drop_en_result,
11397 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11398 TOKEN_STRING_INITIALIZER
11399 (struct cmd_all_queues_drop_en_result,
11401 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11402 TOKEN_STRING_INITIALIZER
11403 (struct cmd_all_queues_drop_en_result,
11405 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11406 TOKEN_STRING_INITIALIZER
11407 (struct cmd_all_queues_drop_en_result,
11409 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11410 TOKEN_NUM_INITIALIZER
11411 (struct cmd_all_queues_drop_en_result,
11413 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11414 TOKEN_STRING_INITIALIZER
11415 (struct cmd_all_queues_drop_en_result,
11419 cmd_set_all_queues_drop_en_parsed(
11420 void *parsed_result,
11421 __attribute__((unused)) struct cmdline *cl,
11422 __attribute__((unused)) void *data)
11424 struct cmd_all_queues_drop_en_result *res = parsed_result;
11426 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11428 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11431 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11436 printf("invalid is_on %d\n", is_on);
11439 printf("invalid port_id %d\n", res->port_id);
11442 printf("function not implemented\n");
11445 printf("programming error: (%s)\n", strerror(-ret));
11449 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11450 .f = cmd_set_all_queues_drop_en_parsed,
11452 .help_str = "set all queues drop <port_id> on|off",
11454 (void *)&cmd_all_queues_drop_en_set,
11455 (void *)&cmd_all_queues_drop_en_all,
11456 (void *)&cmd_all_queues_drop_en_queues,
11457 (void *)&cmd_all_queues_drop_en_drop,
11458 (void *)&cmd_all_queues_drop_en_port_id,
11459 (void *)&cmd_all_queues_drop_en_on_off,
11464 /* vf split drop enable configuration */
11466 /* Common result structure for vf split drop enable */
11467 struct cmd_vf_split_drop_en_result {
11468 cmdline_fixed_string_t set;
11469 cmdline_fixed_string_t vf;
11470 cmdline_fixed_string_t split;
11471 cmdline_fixed_string_t drop;
11474 cmdline_fixed_string_t on_off;
11477 /* Common CLI fields for vf split drop enable disable */
11478 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11479 TOKEN_STRING_INITIALIZER
11480 (struct cmd_vf_split_drop_en_result,
11482 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11483 TOKEN_STRING_INITIALIZER
11484 (struct cmd_vf_split_drop_en_result,
11486 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11487 TOKEN_STRING_INITIALIZER
11488 (struct cmd_vf_split_drop_en_result,
11490 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11491 TOKEN_STRING_INITIALIZER
11492 (struct cmd_vf_split_drop_en_result,
11494 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11495 TOKEN_NUM_INITIALIZER
11496 (struct cmd_vf_split_drop_en_result,
11498 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11499 TOKEN_NUM_INITIALIZER
11500 (struct cmd_vf_split_drop_en_result,
11502 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11503 TOKEN_STRING_INITIALIZER
11504 (struct cmd_vf_split_drop_en_result,
11508 cmd_set_vf_split_drop_en_parsed(
11509 void *parsed_result,
11510 __attribute__((unused)) struct cmdline *cl,
11511 __attribute__((unused)) void *data)
11513 struct cmd_vf_split_drop_en_result *res = parsed_result;
11515 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11517 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11520 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11526 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11529 printf("invalid port_id %d\n", res->port_id);
11532 printf("programming error: (%s)\n", strerror(-ret));
11536 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11537 .f = cmd_set_vf_split_drop_en_parsed,
11539 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11541 (void *)&cmd_vf_split_drop_en_set,
11542 (void *)&cmd_vf_split_drop_en_vf,
11543 (void *)&cmd_vf_split_drop_en_split,
11544 (void *)&cmd_vf_split_drop_en_drop,
11545 (void *)&cmd_vf_split_drop_en_port_id,
11546 (void *)&cmd_vf_split_drop_en_vf_id,
11547 (void *)&cmd_vf_split_drop_en_on_off,
11553 /* vf mac address configuration */
11555 /* Common result structure for vf mac address */
11556 struct cmd_set_vf_mac_addr_result {
11557 cmdline_fixed_string_t set;
11558 cmdline_fixed_string_t vf;
11559 cmdline_fixed_string_t mac;
11560 cmdline_fixed_string_t addr;
11563 struct ether_addr mac_addr;
11567 /* Common CLI fields for vf split drop enable disable */
11568 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11569 TOKEN_STRING_INITIALIZER
11570 (struct cmd_set_vf_mac_addr_result,
11572 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11573 TOKEN_STRING_INITIALIZER
11574 (struct cmd_set_vf_mac_addr_result,
11576 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11577 TOKEN_STRING_INITIALIZER
11578 (struct cmd_set_vf_mac_addr_result,
11580 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11581 TOKEN_STRING_INITIALIZER
11582 (struct cmd_set_vf_mac_addr_result,
11584 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11585 TOKEN_NUM_INITIALIZER
11586 (struct cmd_set_vf_mac_addr_result,
11588 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11589 TOKEN_NUM_INITIALIZER
11590 (struct cmd_set_vf_mac_addr_result,
11592 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11593 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11597 cmd_set_vf_mac_addr_parsed(
11598 void *parsed_result,
11599 __attribute__((unused)) struct cmdline *cl,
11600 __attribute__((unused)) void *data)
11602 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11603 int ret = -ENOTSUP;
11605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11608 #ifdef RTE_LIBRTE_IXGBE_PMD
11609 if (ret == -ENOTSUP)
11610 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11613 #ifdef RTE_LIBRTE_I40E_PMD
11614 if (ret == -ENOTSUP)
11615 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11623 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11626 printf("invalid port_id %d\n", res->port_id);
11629 printf("function not implemented\n");
11632 printf("programming error: (%s)\n", strerror(-ret));
11636 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11637 .f = cmd_set_vf_mac_addr_parsed,
11639 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11641 (void *)&cmd_set_vf_mac_addr_set,
11642 (void *)&cmd_set_vf_mac_addr_vf,
11643 (void *)&cmd_set_vf_mac_addr_mac,
11644 (void *)&cmd_set_vf_mac_addr_addr,
11645 (void *)&cmd_set_vf_mac_addr_port_id,
11646 (void *)&cmd_set_vf_mac_addr_vf_id,
11647 (void *)&cmd_set_vf_mac_addr_mac_addr,
11652 #ifdef RTE_LIBRTE_IXGBE_PMD
11653 /* MACsec configuration */
11655 /* Common result structure for MACsec offload enable */
11656 struct cmd_macsec_offload_on_result {
11657 cmdline_fixed_string_t set;
11658 cmdline_fixed_string_t macsec;
11659 cmdline_fixed_string_t offload;
11661 cmdline_fixed_string_t on;
11662 cmdline_fixed_string_t encrypt;
11663 cmdline_fixed_string_t en_on_off;
11664 cmdline_fixed_string_t replay_protect;
11665 cmdline_fixed_string_t rp_on_off;
11668 /* Common CLI fields for MACsec offload disable */
11669 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11670 TOKEN_STRING_INITIALIZER
11671 (struct cmd_macsec_offload_on_result,
11673 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11674 TOKEN_STRING_INITIALIZER
11675 (struct cmd_macsec_offload_on_result,
11677 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11678 TOKEN_STRING_INITIALIZER
11679 (struct cmd_macsec_offload_on_result,
11680 offload, "offload");
11681 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11682 TOKEN_NUM_INITIALIZER
11683 (struct cmd_macsec_offload_on_result,
11685 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11686 TOKEN_STRING_INITIALIZER
11687 (struct cmd_macsec_offload_on_result,
11689 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11690 TOKEN_STRING_INITIALIZER
11691 (struct cmd_macsec_offload_on_result,
11692 encrypt, "encrypt");
11693 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11694 TOKEN_STRING_INITIALIZER
11695 (struct cmd_macsec_offload_on_result,
11696 en_on_off, "on#off");
11697 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11698 TOKEN_STRING_INITIALIZER
11699 (struct cmd_macsec_offload_on_result,
11700 replay_protect, "replay-protect");
11701 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11702 TOKEN_STRING_INITIALIZER
11703 (struct cmd_macsec_offload_on_result,
11704 rp_on_off, "on#off");
11707 cmd_set_macsec_offload_on_parsed(
11708 void *parsed_result,
11709 __attribute__((unused)) struct cmdline *cl,
11710 __attribute__((unused)) void *data)
11712 struct cmd_macsec_offload_on_result *res = parsed_result;
11714 portid_t port_id = res->port_id;
11715 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11716 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11718 if (port_id_is_invalid(port_id, ENABLED_WARN))
11721 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11722 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11728 printf("invalid port_id %d\n", port_id);
11731 printf("programming error: (%s)\n", strerror(-ret));
11735 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11736 .f = cmd_set_macsec_offload_on_parsed,
11738 .help_str = "set macsec offload <port_id> on "
11739 "encrypt on|off replay-protect on|off",
11741 (void *)&cmd_macsec_offload_on_set,
11742 (void *)&cmd_macsec_offload_on_macsec,
11743 (void *)&cmd_macsec_offload_on_offload,
11744 (void *)&cmd_macsec_offload_on_port_id,
11745 (void *)&cmd_macsec_offload_on_on,
11746 (void *)&cmd_macsec_offload_on_encrypt,
11747 (void *)&cmd_macsec_offload_on_en_on_off,
11748 (void *)&cmd_macsec_offload_on_replay_protect,
11749 (void *)&cmd_macsec_offload_on_rp_on_off,
11754 /* Common result structure for MACsec offload disable */
11755 struct cmd_macsec_offload_off_result {
11756 cmdline_fixed_string_t set;
11757 cmdline_fixed_string_t macsec;
11758 cmdline_fixed_string_t offload;
11760 cmdline_fixed_string_t off;
11763 /* Common CLI fields for MACsec offload disable */
11764 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11765 TOKEN_STRING_INITIALIZER
11766 (struct cmd_macsec_offload_off_result,
11768 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11769 TOKEN_STRING_INITIALIZER
11770 (struct cmd_macsec_offload_off_result,
11772 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11773 TOKEN_STRING_INITIALIZER
11774 (struct cmd_macsec_offload_off_result,
11775 offload, "offload");
11776 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11777 TOKEN_NUM_INITIALIZER
11778 (struct cmd_macsec_offload_off_result,
11780 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11781 TOKEN_STRING_INITIALIZER
11782 (struct cmd_macsec_offload_off_result,
11786 cmd_set_macsec_offload_off_parsed(
11787 void *parsed_result,
11788 __attribute__((unused)) struct cmdline *cl,
11789 __attribute__((unused)) void *data)
11791 struct cmd_macsec_offload_off_result *res = parsed_result;
11793 portid_t port_id = res->port_id;
11795 if (port_id_is_invalid(port_id, ENABLED_WARN))
11798 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11799 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11805 printf("invalid port_id %d\n", port_id);
11808 printf("programming error: (%s)\n", strerror(-ret));
11812 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11813 .f = cmd_set_macsec_offload_off_parsed,
11815 .help_str = "set macsec offload <port_id> off",
11817 (void *)&cmd_macsec_offload_off_set,
11818 (void *)&cmd_macsec_offload_off_macsec,
11819 (void *)&cmd_macsec_offload_off_offload,
11820 (void *)&cmd_macsec_offload_off_port_id,
11821 (void *)&cmd_macsec_offload_off_off,
11826 /* Common result structure for MACsec secure connection configure */
11827 struct cmd_macsec_sc_result {
11828 cmdline_fixed_string_t set;
11829 cmdline_fixed_string_t macsec;
11830 cmdline_fixed_string_t sc;
11831 cmdline_fixed_string_t tx_rx;
11833 struct ether_addr mac;
11837 /* Common CLI fields for MACsec secure connection configure */
11838 cmdline_parse_token_string_t cmd_macsec_sc_set =
11839 TOKEN_STRING_INITIALIZER
11840 (struct cmd_macsec_sc_result,
11842 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11843 TOKEN_STRING_INITIALIZER
11844 (struct cmd_macsec_sc_result,
11846 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11847 TOKEN_STRING_INITIALIZER
11848 (struct cmd_macsec_sc_result,
11850 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11851 TOKEN_STRING_INITIALIZER
11852 (struct cmd_macsec_sc_result,
11854 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11855 TOKEN_NUM_INITIALIZER
11856 (struct cmd_macsec_sc_result,
11858 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11859 TOKEN_ETHERADDR_INITIALIZER
11860 (struct cmd_macsec_sc_result,
11862 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11863 TOKEN_NUM_INITIALIZER
11864 (struct cmd_macsec_sc_result,
11868 cmd_set_macsec_sc_parsed(
11869 void *parsed_result,
11870 __attribute__((unused)) struct cmdline *cl,
11871 __attribute__((unused)) void *data)
11873 struct cmd_macsec_sc_result *res = parsed_result;
11875 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11878 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11879 res->mac.addr_bytes) :
11880 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11881 res->mac.addr_bytes, res->pi);
11886 printf("invalid port_id %d\n", res->port_id);
11889 printf("programming error: (%s)\n", strerror(-ret));
11893 cmdline_parse_inst_t cmd_set_macsec_sc = {
11894 .f = cmd_set_macsec_sc_parsed,
11896 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11898 (void *)&cmd_macsec_sc_set,
11899 (void *)&cmd_macsec_sc_macsec,
11900 (void *)&cmd_macsec_sc_sc,
11901 (void *)&cmd_macsec_sc_tx_rx,
11902 (void *)&cmd_macsec_sc_port_id,
11903 (void *)&cmd_macsec_sc_mac,
11904 (void *)&cmd_macsec_sc_pi,
11909 /* Common result structure for MACsec secure connection configure */
11910 struct cmd_macsec_sa_result {
11911 cmdline_fixed_string_t set;
11912 cmdline_fixed_string_t macsec;
11913 cmdline_fixed_string_t sa;
11914 cmdline_fixed_string_t tx_rx;
11919 cmdline_fixed_string_t key;
11922 /* Common CLI fields for MACsec secure connection configure */
11923 cmdline_parse_token_string_t cmd_macsec_sa_set =
11924 TOKEN_STRING_INITIALIZER
11925 (struct cmd_macsec_sa_result,
11927 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11928 TOKEN_STRING_INITIALIZER
11929 (struct cmd_macsec_sa_result,
11931 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11932 TOKEN_STRING_INITIALIZER
11933 (struct cmd_macsec_sa_result,
11935 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11936 TOKEN_STRING_INITIALIZER
11937 (struct cmd_macsec_sa_result,
11939 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11940 TOKEN_NUM_INITIALIZER
11941 (struct cmd_macsec_sa_result,
11943 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11944 TOKEN_NUM_INITIALIZER
11945 (struct cmd_macsec_sa_result,
11947 cmdline_parse_token_num_t cmd_macsec_sa_an =
11948 TOKEN_NUM_INITIALIZER
11949 (struct cmd_macsec_sa_result,
11951 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11952 TOKEN_NUM_INITIALIZER
11953 (struct cmd_macsec_sa_result,
11955 cmdline_parse_token_string_t cmd_macsec_sa_key =
11956 TOKEN_STRING_INITIALIZER
11957 (struct cmd_macsec_sa_result,
11961 cmd_set_macsec_sa_parsed(
11962 void *parsed_result,
11963 __attribute__((unused)) struct cmdline *cl,
11964 __attribute__((unused)) void *data)
11966 struct cmd_macsec_sa_result *res = parsed_result;
11968 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11969 uint8_t key[16] = { 0 };
11975 key_len = strlen(res->key) / 2;
11979 for (i = 0; i < key_len; i++) {
11980 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11983 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11986 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11990 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11991 res->idx, res->an, res->pn, key) :
11992 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11993 res->idx, res->an, res->pn, key);
11998 printf("invalid idx %d or an %d\n", res->idx, res->an);
12001 printf("invalid port_id %d\n", res->port_id);
12004 printf("programming error: (%s)\n", strerror(-ret));
12008 cmdline_parse_inst_t cmd_set_macsec_sa = {
12009 .f = cmd_set_macsec_sa_parsed,
12011 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12013 (void *)&cmd_macsec_sa_set,
12014 (void *)&cmd_macsec_sa_macsec,
12015 (void *)&cmd_macsec_sa_sa,
12016 (void *)&cmd_macsec_sa_tx_rx,
12017 (void *)&cmd_macsec_sa_port_id,
12018 (void *)&cmd_macsec_sa_idx,
12019 (void *)&cmd_macsec_sa_an,
12020 (void *)&cmd_macsec_sa_pn,
12021 (void *)&cmd_macsec_sa_key,
12027 /* VF unicast promiscuous mode configuration */
12029 /* Common result structure for VF unicast promiscuous mode */
12030 struct cmd_vf_promisc_result {
12031 cmdline_fixed_string_t set;
12032 cmdline_fixed_string_t vf;
12033 cmdline_fixed_string_t promisc;
12036 cmdline_fixed_string_t on_off;
12039 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12040 cmdline_parse_token_string_t cmd_vf_promisc_set =
12041 TOKEN_STRING_INITIALIZER
12042 (struct cmd_vf_promisc_result,
12044 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12045 TOKEN_STRING_INITIALIZER
12046 (struct cmd_vf_promisc_result,
12048 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12049 TOKEN_STRING_INITIALIZER
12050 (struct cmd_vf_promisc_result,
12051 promisc, "promisc");
12052 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12053 TOKEN_NUM_INITIALIZER
12054 (struct cmd_vf_promisc_result,
12056 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12057 TOKEN_NUM_INITIALIZER
12058 (struct cmd_vf_promisc_result,
12060 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12061 TOKEN_STRING_INITIALIZER
12062 (struct cmd_vf_promisc_result,
12066 cmd_set_vf_promisc_parsed(
12067 void *parsed_result,
12068 __attribute__((unused)) struct cmdline *cl,
12069 __attribute__((unused)) void *data)
12071 struct cmd_vf_promisc_result *res = parsed_result;
12072 int ret = -ENOTSUP;
12074 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12076 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12079 #ifdef RTE_LIBRTE_I40E_PMD
12080 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12081 res->vf_id, is_on);
12088 printf("invalid vf_id %d\n", res->vf_id);
12091 printf("invalid port_id %d\n", res->port_id);
12094 printf("function not implemented\n");
12097 printf("programming error: (%s)\n", strerror(-ret));
12101 cmdline_parse_inst_t cmd_set_vf_promisc = {
12102 .f = cmd_set_vf_promisc_parsed,
12104 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12105 "Set unicast promiscuous mode for a VF from the PF",
12107 (void *)&cmd_vf_promisc_set,
12108 (void *)&cmd_vf_promisc_vf,
12109 (void *)&cmd_vf_promisc_promisc,
12110 (void *)&cmd_vf_promisc_port_id,
12111 (void *)&cmd_vf_promisc_vf_id,
12112 (void *)&cmd_vf_promisc_on_off,
12117 /* VF multicast promiscuous mode configuration */
12119 /* Common result structure for VF multicast promiscuous mode */
12120 struct cmd_vf_allmulti_result {
12121 cmdline_fixed_string_t set;
12122 cmdline_fixed_string_t vf;
12123 cmdline_fixed_string_t allmulti;
12126 cmdline_fixed_string_t on_off;
12129 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12130 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12131 TOKEN_STRING_INITIALIZER
12132 (struct cmd_vf_allmulti_result,
12134 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12135 TOKEN_STRING_INITIALIZER
12136 (struct cmd_vf_allmulti_result,
12138 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12139 TOKEN_STRING_INITIALIZER
12140 (struct cmd_vf_allmulti_result,
12141 allmulti, "allmulti");
12142 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12143 TOKEN_NUM_INITIALIZER
12144 (struct cmd_vf_allmulti_result,
12146 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12147 TOKEN_NUM_INITIALIZER
12148 (struct cmd_vf_allmulti_result,
12150 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12151 TOKEN_STRING_INITIALIZER
12152 (struct cmd_vf_allmulti_result,
12156 cmd_set_vf_allmulti_parsed(
12157 void *parsed_result,
12158 __attribute__((unused)) struct cmdline *cl,
12159 __attribute__((unused)) void *data)
12161 struct cmd_vf_allmulti_result *res = parsed_result;
12162 int ret = -ENOTSUP;
12164 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12169 #ifdef RTE_LIBRTE_I40E_PMD
12170 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12171 res->vf_id, is_on);
12178 printf("invalid vf_id %d\n", res->vf_id);
12181 printf("invalid port_id %d\n", res->port_id);
12184 printf("function not implemented\n");
12187 printf("programming error: (%s)\n", strerror(-ret));
12191 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12192 .f = cmd_set_vf_allmulti_parsed,
12194 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12195 "Set multicast promiscuous mode for a VF from the PF",
12197 (void *)&cmd_vf_allmulti_set,
12198 (void *)&cmd_vf_allmulti_vf,
12199 (void *)&cmd_vf_allmulti_allmulti,
12200 (void *)&cmd_vf_allmulti_port_id,
12201 (void *)&cmd_vf_allmulti_vf_id,
12202 (void *)&cmd_vf_allmulti_on_off,
12207 /* vf broadcast mode configuration */
12209 /* Common result structure for vf broadcast */
12210 struct cmd_set_vf_broadcast_result {
12211 cmdline_fixed_string_t set;
12212 cmdline_fixed_string_t vf;
12213 cmdline_fixed_string_t broadcast;
12216 cmdline_fixed_string_t on_off;
12219 /* Common CLI fields for vf broadcast enable disable */
12220 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12221 TOKEN_STRING_INITIALIZER
12222 (struct cmd_set_vf_broadcast_result,
12224 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12225 TOKEN_STRING_INITIALIZER
12226 (struct cmd_set_vf_broadcast_result,
12228 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12229 TOKEN_STRING_INITIALIZER
12230 (struct cmd_set_vf_broadcast_result,
12231 broadcast, "broadcast");
12232 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12233 TOKEN_NUM_INITIALIZER
12234 (struct cmd_set_vf_broadcast_result,
12236 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12237 TOKEN_NUM_INITIALIZER
12238 (struct cmd_set_vf_broadcast_result,
12240 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12241 TOKEN_STRING_INITIALIZER
12242 (struct cmd_set_vf_broadcast_result,
12246 cmd_set_vf_broadcast_parsed(
12247 void *parsed_result,
12248 __attribute__((unused)) struct cmdline *cl,
12249 __attribute__((unused)) void *data)
12251 struct cmd_set_vf_broadcast_result *res = parsed_result;
12252 int ret = -ENOTSUP;
12254 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12256 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12259 #ifdef RTE_LIBRTE_I40E_PMD
12260 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12261 res->vf_id, is_on);
12268 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12271 printf("invalid port_id %d\n", res->port_id);
12274 printf("function not implemented\n");
12277 printf("programming error: (%s)\n", strerror(-ret));
12281 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12282 .f = cmd_set_vf_broadcast_parsed,
12284 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12286 (void *)&cmd_set_vf_broadcast_set,
12287 (void *)&cmd_set_vf_broadcast_vf,
12288 (void *)&cmd_set_vf_broadcast_broadcast,
12289 (void *)&cmd_set_vf_broadcast_port_id,
12290 (void *)&cmd_set_vf_broadcast_vf_id,
12291 (void *)&cmd_set_vf_broadcast_on_off,
12296 /* vf vlan tag configuration */
12298 /* Common result structure for vf vlan tag */
12299 struct cmd_set_vf_vlan_tag_result {
12300 cmdline_fixed_string_t set;
12301 cmdline_fixed_string_t vf;
12302 cmdline_fixed_string_t vlan;
12303 cmdline_fixed_string_t tag;
12306 cmdline_fixed_string_t on_off;
12309 /* Common CLI fields for vf vlan tag enable disable */
12310 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12311 TOKEN_STRING_INITIALIZER
12312 (struct cmd_set_vf_vlan_tag_result,
12314 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12315 TOKEN_STRING_INITIALIZER
12316 (struct cmd_set_vf_vlan_tag_result,
12318 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12319 TOKEN_STRING_INITIALIZER
12320 (struct cmd_set_vf_vlan_tag_result,
12322 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12323 TOKEN_STRING_INITIALIZER
12324 (struct cmd_set_vf_vlan_tag_result,
12326 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12327 TOKEN_NUM_INITIALIZER
12328 (struct cmd_set_vf_vlan_tag_result,
12330 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12331 TOKEN_NUM_INITIALIZER
12332 (struct cmd_set_vf_vlan_tag_result,
12334 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12335 TOKEN_STRING_INITIALIZER
12336 (struct cmd_set_vf_vlan_tag_result,
12340 cmd_set_vf_vlan_tag_parsed(
12341 void *parsed_result,
12342 __attribute__((unused)) struct cmdline *cl,
12343 __attribute__((unused)) void *data)
12345 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12346 int ret = -ENOTSUP;
12348 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12353 #ifdef RTE_LIBRTE_I40E_PMD
12354 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12355 res->vf_id, is_on);
12362 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12365 printf("invalid port_id %d\n", res->port_id);
12368 printf("function not implemented\n");
12371 printf("programming error: (%s)\n", strerror(-ret));
12375 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12376 .f = cmd_set_vf_vlan_tag_parsed,
12378 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12380 (void *)&cmd_set_vf_vlan_tag_set,
12381 (void *)&cmd_set_vf_vlan_tag_vf,
12382 (void *)&cmd_set_vf_vlan_tag_vlan,
12383 (void *)&cmd_set_vf_vlan_tag_tag,
12384 (void *)&cmd_set_vf_vlan_tag_port_id,
12385 (void *)&cmd_set_vf_vlan_tag_vf_id,
12386 (void *)&cmd_set_vf_vlan_tag_on_off,
12391 /* ******************************************************************************** */
12393 /* list of instructions */
12394 cmdline_parse_ctx_t main_ctx[] = {
12395 (cmdline_parse_inst_t *)&cmd_help_brief,
12396 (cmdline_parse_inst_t *)&cmd_help_long,
12397 (cmdline_parse_inst_t *)&cmd_quit,
12398 (cmdline_parse_inst_t *)&cmd_showport,
12399 (cmdline_parse_inst_t *)&cmd_showqueue,
12400 (cmdline_parse_inst_t *)&cmd_showportall,
12401 (cmdline_parse_inst_t *)&cmd_showcfg,
12402 (cmdline_parse_inst_t *)&cmd_start,
12403 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12404 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12405 (cmdline_parse_inst_t *)&cmd_set_link_up,
12406 (cmdline_parse_inst_t *)&cmd_set_link_down,
12407 (cmdline_parse_inst_t *)&cmd_reset,
12408 (cmdline_parse_inst_t *)&cmd_set_numbers,
12409 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12410 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12411 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12412 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12413 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12414 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12415 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12416 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12417 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12418 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12419 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12420 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12421 (cmdline_parse_inst_t *)&cmd_set_link_check,
12422 #ifdef RTE_NIC_BYPASS
12423 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12424 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12425 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12426 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12428 #ifdef RTE_LIBRTE_PMD_BOND
12429 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12430 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12431 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12432 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12433 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12434 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12435 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12436 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12437 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12439 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12440 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12441 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12442 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12443 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12444 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12445 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12446 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12447 (cmdline_parse_inst_t *)&cmd_csum_set,
12448 (cmdline_parse_inst_t *)&cmd_csum_show,
12449 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12450 (cmdline_parse_inst_t *)&cmd_tso_set,
12451 (cmdline_parse_inst_t *)&cmd_tso_show,
12452 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12453 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12454 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12455 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12456 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12457 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12458 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12459 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12460 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12461 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12462 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12463 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12464 (cmdline_parse_inst_t *)&cmd_config_dcb,
12465 (cmdline_parse_inst_t *)&cmd_read_reg,
12466 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12467 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12468 (cmdline_parse_inst_t *)&cmd_write_reg,
12469 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12470 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12471 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12472 (cmdline_parse_inst_t *)&cmd_stop,
12473 (cmdline_parse_inst_t *)&cmd_mac_addr,
12474 (cmdline_parse_inst_t *)&cmd_set_qmap,
12475 (cmdline_parse_inst_t *)&cmd_operate_port,
12476 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12477 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12478 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12479 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12480 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12481 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12482 (cmdline_parse_inst_t *)&cmd_config_mtu,
12483 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12484 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12485 (cmdline_parse_inst_t *)&cmd_config_rss,
12486 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12487 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12488 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12489 (cmdline_parse_inst_t *)&cmd_showport_reta,
12490 (cmdline_parse_inst_t *)&cmd_config_burst,
12491 (cmdline_parse_inst_t *)&cmd_config_thresh,
12492 (cmdline_parse_inst_t *)&cmd_config_threshold,
12493 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12494 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12495 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12496 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12497 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12498 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12499 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12500 (cmdline_parse_inst_t *)&cmd_global_config,
12501 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12502 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12503 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12504 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12505 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12506 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12507 (cmdline_parse_inst_t *)&cmd_dump,
12508 (cmdline_parse_inst_t *)&cmd_dump_one,
12509 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12510 (cmdline_parse_inst_t *)&cmd_syn_filter,
12511 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12512 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12513 (cmdline_parse_inst_t *)&cmd_flex_filter,
12514 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12515 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12516 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12517 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12518 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12519 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12520 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12521 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12522 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12523 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12524 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12525 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12526 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12527 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12528 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12529 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12530 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12531 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12532 (cmdline_parse_inst_t *)&cmd_flow,
12533 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12534 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12535 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12536 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12537 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12538 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12539 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12540 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12541 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12542 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12543 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12544 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12545 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12546 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12547 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12548 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12549 #ifdef RTE_LIBRTE_IXGBE_PMD
12550 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12551 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12552 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12553 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12554 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12555 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12556 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12557 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12558 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12560 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12561 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12562 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12563 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12564 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
12565 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
12569 /* prompt function, called from main on MASTER lcore */
12573 /* initialize non-constant commands */
12574 cmd_set_fwd_mode_init();
12575 cmd_set_fwd_retry_mode_init();
12577 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12578 if (testpmd_cl == NULL)
12580 cmdline_interact(testpmd_cl);
12581 cmdline_stdin_exit(testpmd_cl);
12587 if (testpmd_cl != NULL)
12588 cmdline_quit(testpmd_cl);
12592 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12594 if (id == (portid_t)RTE_PORT_ALL) {
12597 FOREACH_PORT(pid, ports) {
12598 /* check if need_reconfig has been set to 1 */
12599 if (ports[pid].need_reconfig == 0)
12600 ports[pid].need_reconfig = dev;
12601 /* check if need_reconfig_queues has been set to 1 */
12602 if (ports[pid].need_reconfig_queues == 0)
12603 ports[pid].need_reconfig_queues = queue;
12605 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12606 /* check if need_reconfig has been set to 1 */
12607 if (ports[id].need_reconfig == 0)
12608 ports[id].need_reconfig = dev;
12609 /* check if need_reconfig_queues has been set to 1 */
12610 if (ports[id].need_reconfig_queues == 0)
12611 ports[id].need_reconfig_queues = queue;