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 #ifdef RTE_LIBRTE_IXGBE_PMD
6881 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6882 struct cmd_vf_rx_vlan_filter {
6883 cmdline_fixed_string_t rx_vlan;
6884 cmdline_fixed_string_t what;
6886 cmdline_fixed_string_t port;
6888 cmdline_fixed_string_t vf;
6893 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6894 __attribute__((unused)) struct cmdline *cl,
6895 __attribute__((unused)) void *data)
6897 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6899 if (!strcmp(res->what, "add"))
6900 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6902 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6905 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6906 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6907 rx_vlan, "rx_vlan");
6908 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6909 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6911 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6912 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6914 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6915 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6917 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6918 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6920 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6921 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6923 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6924 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6927 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6928 .f = cmd_vf_rx_vlan_filter_parsed,
6930 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6931 "(vf_mask = hexadecimal VF mask)",
6933 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6934 (void *)&cmd_vf_rx_vlan_filter_what,
6935 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6936 (void *)&cmd_vf_rx_vlan_filter_port,
6937 (void *)&cmd_vf_rx_vlan_filter_portid,
6938 (void *)&cmd_vf_rx_vlan_filter_vf,
6939 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6945 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6946 struct cmd_queue_rate_limit_result {
6947 cmdline_fixed_string_t set;
6948 cmdline_fixed_string_t port;
6950 cmdline_fixed_string_t queue;
6952 cmdline_fixed_string_t rate;
6956 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6957 __attribute__((unused)) struct cmdline *cl,
6958 __attribute__((unused)) void *data)
6960 struct cmd_queue_rate_limit_result *res = parsed_result;
6963 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6964 && (strcmp(res->queue, "queue") == 0)
6965 && (strcmp(res->rate, "rate") == 0))
6966 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6969 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6973 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6974 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6976 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6977 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6979 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6980 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6982 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6983 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6985 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6986 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6988 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6989 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6991 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6992 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6995 cmdline_parse_inst_t cmd_queue_rate_limit = {
6996 .f = cmd_queue_rate_limit_parsed,
6998 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6999 "Set rate limit for a queue on port_id",
7001 (void *)&cmd_queue_rate_limit_set,
7002 (void *)&cmd_queue_rate_limit_port,
7003 (void *)&cmd_queue_rate_limit_portnum,
7004 (void *)&cmd_queue_rate_limit_queue,
7005 (void *)&cmd_queue_rate_limit_queuenum,
7006 (void *)&cmd_queue_rate_limit_rate,
7007 (void *)&cmd_queue_rate_limit_ratenum,
7012 #ifdef RTE_LIBRTE_IXGBE_PMD
7013 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7014 struct cmd_vf_rate_limit_result {
7015 cmdline_fixed_string_t set;
7016 cmdline_fixed_string_t port;
7018 cmdline_fixed_string_t vf;
7020 cmdline_fixed_string_t rate;
7022 cmdline_fixed_string_t q_msk;
7026 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7027 __attribute__((unused)) struct cmdline *cl,
7028 __attribute__((unused)) void *data)
7030 struct cmd_vf_rate_limit_result *res = parsed_result;
7033 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7034 && (strcmp(res->vf, "vf") == 0)
7035 && (strcmp(res->rate, "rate") == 0)
7036 && (strcmp(res->q_msk, "queue_mask") == 0))
7037 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7038 res->rate_num, res->q_msk_val);
7040 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7044 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7045 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7047 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7048 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7050 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7051 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7053 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7054 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7056 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7057 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7059 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7060 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7062 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7063 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7065 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7066 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7067 q_msk, "queue_mask");
7068 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7069 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7072 cmdline_parse_inst_t cmd_vf_rate_limit = {
7073 .f = cmd_vf_rate_limit_parsed,
7075 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7076 "queue_mask <queue_mask_value>: "
7077 "Set rate limit for queues of VF on port_id",
7079 (void *)&cmd_vf_rate_limit_set,
7080 (void *)&cmd_vf_rate_limit_port,
7081 (void *)&cmd_vf_rate_limit_portnum,
7082 (void *)&cmd_vf_rate_limit_vf,
7083 (void *)&cmd_vf_rate_limit_vfnum,
7084 (void *)&cmd_vf_rate_limit_rate,
7085 (void *)&cmd_vf_rate_limit_ratenum,
7086 (void *)&cmd_vf_rate_limit_q_msk,
7087 (void *)&cmd_vf_rate_limit_q_msk_val,
7093 /* *** ADD TUNNEL FILTER OF A PORT *** */
7094 struct cmd_tunnel_filter_result {
7095 cmdline_fixed_string_t cmd;
7096 cmdline_fixed_string_t what;
7098 struct ether_addr outer_mac;
7099 struct ether_addr inner_mac;
7100 cmdline_ipaddr_t ip_value;
7101 uint16_t inner_vlan;
7102 cmdline_fixed_string_t tunnel_type;
7103 cmdline_fixed_string_t filter_type;
7109 cmd_tunnel_filter_parsed(void *parsed_result,
7110 __attribute__((unused)) struct cmdline *cl,
7111 __attribute__((unused)) void *data)
7113 struct cmd_tunnel_filter_result *res = parsed_result;
7114 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7117 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7119 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7120 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7121 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7123 if (res->ip_value.family == AF_INET) {
7124 tunnel_filter_conf.ip_addr.ipv4_addr =
7125 res->ip_value.addr.ipv4.s_addr;
7126 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7128 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7129 &(res->ip_value.addr.ipv6),
7130 sizeof(struct in6_addr));
7131 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7134 if (!strcmp(res->filter_type, "imac-ivlan"))
7135 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7136 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7137 tunnel_filter_conf.filter_type =
7138 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7139 else if (!strcmp(res->filter_type, "imac-tenid"))
7140 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7141 else if (!strcmp(res->filter_type, "imac"))
7142 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7143 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7144 tunnel_filter_conf.filter_type =
7145 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7146 else if (!strcmp(res->filter_type, "oip"))
7147 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7148 else if (!strcmp(res->filter_type, "iip"))
7149 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7151 printf("The filter type is not supported");
7155 if (!strcmp(res->tunnel_type, "vxlan"))
7156 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7157 else if (!strcmp(res->tunnel_type, "nvgre"))
7158 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7159 else if (!strcmp(res->tunnel_type, "ipingre"))
7160 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7162 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7166 tunnel_filter_conf.tenant_id = res->tenant_id;
7167 tunnel_filter_conf.queue_id = res->queue_num;
7168 if (!strcmp(res->what, "add"))
7169 ret = rte_eth_dev_filter_ctrl(res->port_id,
7170 RTE_ETH_FILTER_TUNNEL,
7172 &tunnel_filter_conf);
7174 ret = rte_eth_dev_filter_ctrl(res->port_id,
7175 RTE_ETH_FILTER_TUNNEL,
7176 RTE_ETH_FILTER_DELETE,
7177 &tunnel_filter_conf);
7179 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7183 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7184 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7185 cmd, "tunnel_filter");
7186 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7187 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7189 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7190 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7192 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7193 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7195 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7196 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7198 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7199 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7200 inner_vlan, UINT16);
7201 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7202 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7204 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7205 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7206 tunnel_type, "vxlan#nvgre#ipingre");
7208 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7209 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7210 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7211 "imac#omac-imac-tenid");
7212 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7213 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7215 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7216 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7219 cmdline_parse_inst_t cmd_tunnel_filter = {
7220 .f = cmd_tunnel_filter_parsed,
7222 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7223 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7224 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7225 "<queue_id>: Add/Rm tunnel filter of a port",
7227 (void *)&cmd_tunnel_filter_cmd,
7228 (void *)&cmd_tunnel_filter_what,
7229 (void *)&cmd_tunnel_filter_port_id,
7230 (void *)&cmd_tunnel_filter_outer_mac,
7231 (void *)&cmd_tunnel_filter_inner_mac,
7232 (void *)&cmd_tunnel_filter_ip_value,
7233 (void *)&cmd_tunnel_filter_innner_vlan,
7234 (void *)&cmd_tunnel_filter_tunnel_type,
7235 (void *)&cmd_tunnel_filter_filter_type,
7236 (void *)&cmd_tunnel_filter_tenant_id,
7237 (void *)&cmd_tunnel_filter_queue_num,
7242 /* *** CONFIGURE TUNNEL UDP PORT *** */
7243 struct cmd_tunnel_udp_config {
7244 cmdline_fixed_string_t cmd;
7245 cmdline_fixed_string_t what;
7251 cmd_tunnel_udp_config_parsed(void *parsed_result,
7252 __attribute__((unused)) struct cmdline *cl,
7253 __attribute__((unused)) void *data)
7255 struct cmd_tunnel_udp_config *res = parsed_result;
7256 struct rte_eth_udp_tunnel tunnel_udp;
7259 tunnel_udp.udp_port = res->udp_port;
7261 if (!strcmp(res->cmd, "rx_vxlan_port"))
7262 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7264 if (!strcmp(res->what, "add"))
7265 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7268 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7272 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7275 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7276 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7277 cmd, "rx_vxlan_port");
7278 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7279 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7281 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7282 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7284 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7285 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7288 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7289 .f = cmd_tunnel_udp_config_parsed,
7291 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7292 "Add/Remove a tunneling UDP port filter",
7294 (void *)&cmd_tunnel_udp_config_cmd,
7295 (void *)&cmd_tunnel_udp_config_what,
7296 (void *)&cmd_tunnel_udp_config_udp_port,
7297 (void *)&cmd_tunnel_udp_config_port_id,
7302 /* *** GLOBAL CONFIG *** */
7303 struct cmd_global_config_result {
7304 cmdline_fixed_string_t cmd;
7306 cmdline_fixed_string_t cfg_type;
7311 cmd_global_config_parsed(void *parsed_result,
7312 __attribute__((unused)) struct cmdline *cl,
7313 __attribute__((unused)) void *data)
7315 struct cmd_global_config_result *res = parsed_result;
7316 struct rte_eth_global_cfg conf;
7319 memset(&conf, 0, sizeof(conf));
7320 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7321 conf.cfg.gre_key_len = res->len;
7322 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7323 RTE_ETH_FILTER_SET, &conf);
7325 printf("Global config error\n");
7328 cmdline_parse_token_string_t cmd_global_config_cmd =
7329 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7331 cmdline_parse_token_num_t cmd_global_config_port_id =
7332 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7333 cmdline_parse_token_string_t cmd_global_config_type =
7334 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7335 cfg_type, "gre-key-len");
7336 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7337 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7340 cmdline_parse_inst_t cmd_global_config = {
7341 .f = cmd_global_config_parsed,
7342 .data = (void *)NULL,
7343 .help_str = "global_config <port_id> gre-key-len <key_len>",
7345 (void *)&cmd_global_config_cmd,
7346 (void *)&cmd_global_config_port_id,
7347 (void *)&cmd_global_config_type,
7348 (void *)&cmd_global_config_gre_key_len,
7353 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7354 struct cmd_set_mirror_mask_result {
7355 cmdline_fixed_string_t set;
7356 cmdline_fixed_string_t port;
7358 cmdline_fixed_string_t mirror;
7360 cmdline_fixed_string_t what;
7361 cmdline_fixed_string_t value;
7362 cmdline_fixed_string_t dstpool;
7364 cmdline_fixed_string_t on;
7367 cmdline_parse_token_string_t cmd_mirror_mask_set =
7368 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7370 cmdline_parse_token_string_t cmd_mirror_mask_port =
7371 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7373 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7374 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7376 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7378 mirror, "mirror-rule");
7379 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7380 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7382 cmdline_parse_token_string_t cmd_mirror_mask_what =
7383 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7384 what, "pool-mirror-up#pool-mirror-down"
7386 cmdline_parse_token_string_t cmd_mirror_mask_value =
7387 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7389 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7390 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7391 dstpool, "dst-pool");
7392 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7393 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7395 cmdline_parse_token_string_t cmd_mirror_mask_on =
7396 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7400 cmd_set_mirror_mask_parsed(void *parsed_result,
7401 __attribute__((unused)) struct cmdline *cl,
7402 __attribute__((unused)) void *data)
7405 struct cmd_set_mirror_mask_result *res = parsed_result;
7406 struct rte_eth_mirror_conf mr_conf;
7408 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7410 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7412 mr_conf.dst_pool = res->dstpool_id;
7414 if (!strcmp(res->what, "pool-mirror-up")) {
7415 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7416 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7417 } else if (!strcmp(res->what, "pool-mirror-down")) {
7418 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7419 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7420 } else if (!strcmp(res->what, "vlan-mirror")) {
7421 mr_conf.rule_type = ETH_MIRROR_VLAN;
7422 nb_item = parse_item_list(res->value, "vlan",
7423 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7427 for (i = 0; i < nb_item; i++) {
7428 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7429 printf("Invalid vlan_id: must be < 4096\n");
7433 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7434 mr_conf.vlan.vlan_mask |= 1ULL << i;
7438 if (!strcmp(res->on, "on"))
7439 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7442 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7445 printf("mirror rule add error: (%s)\n", strerror(-ret));
7448 cmdline_parse_inst_t cmd_set_mirror_mask = {
7449 .f = cmd_set_mirror_mask_parsed,
7451 .help_str = "set port <port_id> mirror-rule <rule_id> "
7452 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7453 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7455 (void *)&cmd_mirror_mask_set,
7456 (void *)&cmd_mirror_mask_port,
7457 (void *)&cmd_mirror_mask_portid,
7458 (void *)&cmd_mirror_mask_mirror,
7459 (void *)&cmd_mirror_mask_ruleid,
7460 (void *)&cmd_mirror_mask_what,
7461 (void *)&cmd_mirror_mask_value,
7462 (void *)&cmd_mirror_mask_dstpool,
7463 (void *)&cmd_mirror_mask_poolid,
7464 (void *)&cmd_mirror_mask_on,
7469 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7470 struct cmd_set_mirror_link_result {
7471 cmdline_fixed_string_t set;
7472 cmdline_fixed_string_t port;
7474 cmdline_fixed_string_t mirror;
7476 cmdline_fixed_string_t what;
7477 cmdline_fixed_string_t dstpool;
7479 cmdline_fixed_string_t on;
7482 cmdline_parse_token_string_t cmd_mirror_link_set =
7483 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7485 cmdline_parse_token_string_t cmd_mirror_link_port =
7486 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7488 cmdline_parse_token_num_t cmd_mirror_link_portid =
7489 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7491 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7492 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7493 mirror, "mirror-rule");
7494 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7495 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7497 cmdline_parse_token_string_t cmd_mirror_link_what =
7498 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7499 what, "uplink-mirror#downlink-mirror");
7500 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7502 dstpool, "dst-pool");
7503 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7504 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7506 cmdline_parse_token_string_t cmd_mirror_link_on =
7507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7511 cmd_set_mirror_link_parsed(void *parsed_result,
7512 __attribute__((unused)) struct cmdline *cl,
7513 __attribute__((unused)) void *data)
7516 struct cmd_set_mirror_link_result *res = parsed_result;
7517 struct rte_eth_mirror_conf mr_conf;
7519 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7520 if (!strcmp(res->what, "uplink-mirror"))
7521 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7523 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7525 mr_conf.dst_pool = res->dstpool_id;
7527 if (!strcmp(res->on, "on"))
7528 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7531 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7534 /* check the return value and print it if is < 0 */
7536 printf("mirror rule add error: (%s)\n", strerror(-ret));
7540 cmdline_parse_inst_t cmd_set_mirror_link = {
7541 .f = cmd_set_mirror_link_parsed,
7543 .help_str = "set port <port_id> mirror-rule <rule_id> "
7544 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7546 (void *)&cmd_mirror_link_set,
7547 (void *)&cmd_mirror_link_port,
7548 (void *)&cmd_mirror_link_portid,
7549 (void *)&cmd_mirror_link_mirror,
7550 (void *)&cmd_mirror_link_ruleid,
7551 (void *)&cmd_mirror_link_what,
7552 (void *)&cmd_mirror_link_dstpool,
7553 (void *)&cmd_mirror_link_poolid,
7554 (void *)&cmd_mirror_link_on,
7559 /* *** RESET VM MIRROR RULE *** */
7560 struct cmd_rm_mirror_rule_result {
7561 cmdline_fixed_string_t reset;
7562 cmdline_fixed_string_t port;
7564 cmdline_fixed_string_t mirror;
7568 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7569 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7571 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7572 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7574 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7575 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7577 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7578 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7579 mirror, "mirror-rule");
7580 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7581 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7585 cmd_reset_mirror_rule_parsed(void *parsed_result,
7586 __attribute__((unused)) struct cmdline *cl,
7587 __attribute__((unused)) void *data)
7590 struct cmd_set_mirror_link_result *res = parsed_result;
7592 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7594 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7597 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7598 .f = cmd_reset_mirror_rule_parsed,
7600 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7602 (void *)&cmd_rm_mirror_rule_reset,
7603 (void *)&cmd_rm_mirror_rule_port,
7604 (void *)&cmd_rm_mirror_rule_portid,
7605 (void *)&cmd_rm_mirror_rule_mirror,
7606 (void *)&cmd_rm_mirror_rule_ruleid,
7611 /* ******************************************************************************** */
7613 struct cmd_dump_result {
7614 cmdline_fixed_string_t dump;
7618 dump_struct_sizes(void)
7620 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7621 DUMP_SIZE(struct rte_mbuf);
7622 DUMP_SIZE(struct rte_mempool);
7623 DUMP_SIZE(struct rte_ring);
7627 static void cmd_dump_parsed(void *parsed_result,
7628 __attribute__((unused)) struct cmdline *cl,
7629 __attribute__((unused)) void *data)
7631 struct cmd_dump_result *res = parsed_result;
7633 if (!strcmp(res->dump, "dump_physmem"))
7634 rte_dump_physmem_layout(stdout);
7635 else if (!strcmp(res->dump, "dump_memzone"))
7636 rte_memzone_dump(stdout);
7637 else if (!strcmp(res->dump, "dump_struct_sizes"))
7638 dump_struct_sizes();
7639 else if (!strcmp(res->dump, "dump_ring"))
7640 rte_ring_list_dump(stdout);
7641 else if (!strcmp(res->dump, "dump_mempool"))
7642 rte_mempool_list_dump(stdout);
7643 else if (!strcmp(res->dump, "dump_devargs"))
7644 rte_eal_devargs_dump(stdout);
7647 cmdline_parse_token_string_t cmd_dump_dump =
7648 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7651 "dump_struct_sizes#"
7656 cmdline_parse_inst_t cmd_dump = {
7657 .f = cmd_dump_parsed, /* function to call */
7658 .data = NULL, /* 2nd arg of func */
7659 .help_str = "Dump status",
7660 .tokens = { /* token list, NULL terminated */
7661 (void *)&cmd_dump_dump,
7666 /* ******************************************************************************** */
7668 struct cmd_dump_one_result {
7669 cmdline_fixed_string_t dump;
7670 cmdline_fixed_string_t name;
7673 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7674 __attribute__((unused)) void *data)
7676 struct cmd_dump_one_result *res = parsed_result;
7678 if (!strcmp(res->dump, "dump_ring")) {
7680 r = rte_ring_lookup(res->name);
7682 cmdline_printf(cl, "Cannot find ring\n");
7685 rte_ring_dump(stdout, r);
7686 } else if (!strcmp(res->dump, "dump_mempool")) {
7687 struct rte_mempool *mp;
7688 mp = rte_mempool_lookup(res->name);
7690 cmdline_printf(cl, "Cannot find mempool\n");
7693 rte_mempool_dump(stdout, mp);
7697 cmdline_parse_token_string_t cmd_dump_one_dump =
7698 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7699 "dump_ring#dump_mempool");
7701 cmdline_parse_token_string_t cmd_dump_one_name =
7702 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7704 cmdline_parse_inst_t cmd_dump_one = {
7705 .f = cmd_dump_one_parsed, /* function to call */
7706 .data = NULL, /* 2nd arg of func */
7707 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7708 .tokens = { /* token list, NULL terminated */
7709 (void *)&cmd_dump_one_dump,
7710 (void *)&cmd_dump_one_name,
7715 /* *** Add/Del syn filter *** */
7716 struct cmd_syn_filter_result {
7717 cmdline_fixed_string_t filter;
7719 cmdline_fixed_string_t ops;
7720 cmdline_fixed_string_t priority;
7721 cmdline_fixed_string_t high;
7722 cmdline_fixed_string_t queue;
7727 cmd_syn_filter_parsed(void *parsed_result,
7728 __attribute__((unused)) struct cmdline *cl,
7729 __attribute__((unused)) void *data)
7731 struct cmd_syn_filter_result *res = parsed_result;
7732 struct rte_eth_syn_filter syn_filter;
7735 ret = rte_eth_dev_filter_supported(res->port_id,
7736 RTE_ETH_FILTER_SYN);
7738 printf("syn filter is not supported on port %u.\n",
7743 memset(&syn_filter, 0, sizeof(syn_filter));
7745 if (!strcmp(res->ops, "add")) {
7746 if (!strcmp(res->high, "high"))
7747 syn_filter.hig_pri = 1;
7749 syn_filter.hig_pri = 0;
7751 syn_filter.queue = res->queue_id;
7752 ret = rte_eth_dev_filter_ctrl(res->port_id,
7757 ret = rte_eth_dev_filter_ctrl(res->port_id,
7759 RTE_ETH_FILTER_DELETE,
7763 printf("syn filter programming error: (%s)\n",
7767 cmdline_parse_token_string_t cmd_syn_filter_filter =
7768 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7769 filter, "syn_filter");
7770 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7771 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7773 cmdline_parse_token_string_t cmd_syn_filter_ops =
7774 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7776 cmdline_parse_token_string_t cmd_syn_filter_priority =
7777 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7778 priority, "priority");
7779 cmdline_parse_token_string_t cmd_syn_filter_high =
7780 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7782 cmdline_parse_token_string_t cmd_syn_filter_queue =
7783 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7785 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7786 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7789 cmdline_parse_inst_t cmd_syn_filter = {
7790 .f = cmd_syn_filter_parsed,
7792 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7793 "<queue_id>: Add/Delete syn filter",
7795 (void *)&cmd_syn_filter_filter,
7796 (void *)&cmd_syn_filter_port_id,
7797 (void *)&cmd_syn_filter_ops,
7798 (void *)&cmd_syn_filter_priority,
7799 (void *)&cmd_syn_filter_high,
7800 (void *)&cmd_syn_filter_queue,
7801 (void *)&cmd_syn_filter_queue_id,
7806 /* *** ADD/REMOVE A 2tuple FILTER *** */
7807 struct cmd_2tuple_filter_result {
7808 cmdline_fixed_string_t filter;
7810 cmdline_fixed_string_t ops;
7811 cmdline_fixed_string_t dst_port;
7812 uint16_t dst_port_value;
7813 cmdline_fixed_string_t protocol;
7814 uint8_t protocol_value;
7815 cmdline_fixed_string_t mask;
7817 cmdline_fixed_string_t tcp_flags;
7818 uint8_t tcp_flags_value;
7819 cmdline_fixed_string_t priority;
7820 uint8_t priority_value;
7821 cmdline_fixed_string_t queue;
7826 cmd_2tuple_filter_parsed(void *parsed_result,
7827 __attribute__((unused)) struct cmdline *cl,
7828 __attribute__((unused)) void *data)
7830 struct rte_eth_ntuple_filter filter;
7831 struct cmd_2tuple_filter_result *res = parsed_result;
7834 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7836 printf("ntuple filter is not supported on port %u.\n",
7841 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7843 filter.flags = RTE_2TUPLE_FLAGS;
7844 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7845 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7846 filter.proto = res->protocol_value;
7847 filter.priority = res->priority_value;
7848 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7849 printf("nonzero tcp_flags is only meaningful"
7850 " when protocol is TCP.\n");
7853 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7854 printf("invalid TCP flags.\n");
7858 if (res->tcp_flags_value != 0) {
7859 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7860 filter.tcp_flags = res->tcp_flags_value;
7863 /* need convert to big endian. */
7864 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7865 filter.queue = res->queue_id;
7867 if (!strcmp(res->ops, "add"))
7868 ret = rte_eth_dev_filter_ctrl(res->port_id,
7869 RTE_ETH_FILTER_NTUPLE,
7873 ret = rte_eth_dev_filter_ctrl(res->port_id,
7874 RTE_ETH_FILTER_NTUPLE,
7875 RTE_ETH_FILTER_DELETE,
7878 printf("2tuple filter programming error: (%s)\n",
7883 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7884 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7885 filter, "2tuple_filter");
7886 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7887 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7889 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7890 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7892 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7893 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7894 dst_port, "dst_port");
7895 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7896 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7897 dst_port_value, UINT16);
7898 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7899 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7900 protocol, "protocol");
7901 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7902 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7903 protocol_value, UINT8);
7904 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7905 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7907 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7908 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7910 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7911 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7912 tcp_flags, "tcp_flags");
7913 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7914 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7915 tcp_flags_value, UINT8);
7916 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7917 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7918 priority, "priority");
7919 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7920 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7921 priority_value, UINT8);
7922 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7923 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7925 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7926 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7929 cmdline_parse_inst_t cmd_2tuple_filter = {
7930 .f = cmd_2tuple_filter_parsed,
7932 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7933 "<value> mask <value> tcp_flags <value> priority <value> queue "
7934 "<queue_id>: Add a 2tuple filter",
7936 (void *)&cmd_2tuple_filter_filter,
7937 (void *)&cmd_2tuple_filter_port_id,
7938 (void *)&cmd_2tuple_filter_ops,
7939 (void *)&cmd_2tuple_filter_dst_port,
7940 (void *)&cmd_2tuple_filter_dst_port_value,
7941 (void *)&cmd_2tuple_filter_protocol,
7942 (void *)&cmd_2tuple_filter_protocol_value,
7943 (void *)&cmd_2tuple_filter_mask,
7944 (void *)&cmd_2tuple_filter_mask_value,
7945 (void *)&cmd_2tuple_filter_tcp_flags,
7946 (void *)&cmd_2tuple_filter_tcp_flags_value,
7947 (void *)&cmd_2tuple_filter_priority,
7948 (void *)&cmd_2tuple_filter_priority_value,
7949 (void *)&cmd_2tuple_filter_queue,
7950 (void *)&cmd_2tuple_filter_queue_id,
7955 /* *** ADD/REMOVE A 5tuple FILTER *** */
7956 struct cmd_5tuple_filter_result {
7957 cmdline_fixed_string_t filter;
7959 cmdline_fixed_string_t ops;
7960 cmdline_fixed_string_t dst_ip;
7961 cmdline_ipaddr_t dst_ip_value;
7962 cmdline_fixed_string_t src_ip;
7963 cmdline_ipaddr_t src_ip_value;
7964 cmdline_fixed_string_t dst_port;
7965 uint16_t dst_port_value;
7966 cmdline_fixed_string_t src_port;
7967 uint16_t src_port_value;
7968 cmdline_fixed_string_t protocol;
7969 uint8_t protocol_value;
7970 cmdline_fixed_string_t mask;
7972 cmdline_fixed_string_t tcp_flags;
7973 uint8_t tcp_flags_value;
7974 cmdline_fixed_string_t priority;
7975 uint8_t priority_value;
7976 cmdline_fixed_string_t queue;
7981 cmd_5tuple_filter_parsed(void *parsed_result,
7982 __attribute__((unused)) struct cmdline *cl,
7983 __attribute__((unused)) void *data)
7985 struct rte_eth_ntuple_filter filter;
7986 struct cmd_5tuple_filter_result *res = parsed_result;
7989 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7991 printf("ntuple filter is not supported on port %u.\n",
7996 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7998 filter.flags = RTE_5TUPLE_FLAGS;
7999 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8000 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8001 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8002 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8003 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8004 filter.proto = res->protocol_value;
8005 filter.priority = res->priority_value;
8006 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8007 printf("nonzero tcp_flags is only meaningful"
8008 " when protocol is TCP.\n");
8011 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8012 printf("invalid TCP flags.\n");
8016 if (res->tcp_flags_value != 0) {
8017 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8018 filter.tcp_flags = res->tcp_flags_value;
8021 if (res->dst_ip_value.family == AF_INET)
8022 /* no need to convert, already big endian. */
8023 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8025 if (filter.dst_ip_mask == 0) {
8026 printf("can not support ipv6 involved compare.\n");
8032 if (res->src_ip_value.family == AF_INET)
8033 /* no need to convert, already big endian. */
8034 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8036 if (filter.src_ip_mask == 0) {
8037 printf("can not support ipv6 involved compare.\n");
8042 /* need convert to big endian. */
8043 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8044 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8045 filter.queue = res->queue_id;
8047 if (!strcmp(res->ops, "add"))
8048 ret = rte_eth_dev_filter_ctrl(res->port_id,
8049 RTE_ETH_FILTER_NTUPLE,
8053 ret = rte_eth_dev_filter_ctrl(res->port_id,
8054 RTE_ETH_FILTER_NTUPLE,
8055 RTE_ETH_FILTER_DELETE,
8058 printf("5tuple filter programming error: (%s)\n",
8062 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8063 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8064 filter, "5tuple_filter");
8065 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8066 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8068 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8069 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8071 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8072 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8074 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8075 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8077 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8078 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8080 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8081 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8083 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8084 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8085 dst_port, "dst_port");
8086 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8087 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8088 dst_port_value, UINT16);
8089 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8090 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8091 src_port, "src_port");
8092 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8093 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8094 src_port_value, UINT16);
8095 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8096 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8097 protocol, "protocol");
8098 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8099 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8100 protocol_value, UINT8);
8101 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8102 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8104 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8105 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8107 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8108 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8109 tcp_flags, "tcp_flags");
8110 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8111 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8112 tcp_flags_value, UINT8);
8113 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8114 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8115 priority, "priority");
8116 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8117 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8118 priority_value, UINT8);
8119 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8120 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8122 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8123 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8126 cmdline_parse_inst_t cmd_5tuple_filter = {
8127 .f = cmd_5tuple_filter_parsed,
8129 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8130 "src_ip <value> dst_port <value> src_port <value> "
8131 "protocol <value> mask <value> tcp_flags <value> "
8132 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8134 (void *)&cmd_5tuple_filter_filter,
8135 (void *)&cmd_5tuple_filter_port_id,
8136 (void *)&cmd_5tuple_filter_ops,
8137 (void *)&cmd_5tuple_filter_dst_ip,
8138 (void *)&cmd_5tuple_filter_dst_ip_value,
8139 (void *)&cmd_5tuple_filter_src_ip,
8140 (void *)&cmd_5tuple_filter_src_ip_value,
8141 (void *)&cmd_5tuple_filter_dst_port,
8142 (void *)&cmd_5tuple_filter_dst_port_value,
8143 (void *)&cmd_5tuple_filter_src_port,
8144 (void *)&cmd_5tuple_filter_src_port_value,
8145 (void *)&cmd_5tuple_filter_protocol,
8146 (void *)&cmd_5tuple_filter_protocol_value,
8147 (void *)&cmd_5tuple_filter_mask,
8148 (void *)&cmd_5tuple_filter_mask_value,
8149 (void *)&cmd_5tuple_filter_tcp_flags,
8150 (void *)&cmd_5tuple_filter_tcp_flags_value,
8151 (void *)&cmd_5tuple_filter_priority,
8152 (void *)&cmd_5tuple_filter_priority_value,
8153 (void *)&cmd_5tuple_filter_queue,
8154 (void *)&cmd_5tuple_filter_queue_id,
8159 /* *** ADD/REMOVE A flex FILTER *** */
8160 struct cmd_flex_filter_result {
8161 cmdline_fixed_string_t filter;
8162 cmdline_fixed_string_t ops;
8164 cmdline_fixed_string_t len;
8166 cmdline_fixed_string_t bytes;
8167 cmdline_fixed_string_t bytes_value;
8168 cmdline_fixed_string_t mask;
8169 cmdline_fixed_string_t mask_value;
8170 cmdline_fixed_string_t priority;
8171 uint8_t priority_value;
8172 cmdline_fixed_string_t queue;
8176 static int xdigit2val(unsigned char c)
8181 else if (isupper(c))
8189 cmd_flex_filter_parsed(void *parsed_result,
8190 __attribute__((unused)) struct cmdline *cl,
8191 __attribute__((unused)) void *data)
8194 struct rte_eth_flex_filter filter;
8195 struct cmd_flex_filter_result *res = parsed_result;
8196 char *bytes_ptr, *mask_ptr;
8197 uint16_t len, i, j = 0;
8202 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8203 printf("the len exceed the max length 128\n");
8206 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8207 filter.len = res->len_value;
8208 filter.priority = res->priority_value;
8209 filter.queue = res->queue_id;
8210 bytes_ptr = res->bytes_value;
8211 mask_ptr = res->mask_value;
8213 /* translate bytes string to array. */
8214 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8215 (bytes_ptr[1] == 'X')))
8217 len = strnlen(bytes_ptr, res->len_value * 2);
8218 if (len == 0 || (len % 8 != 0)) {
8219 printf("please check len and bytes input\n");
8222 for (i = 0; i < len; i++) {
8224 if (isxdigit(c) == 0) {
8225 /* invalid characters. */
8226 printf("invalid input\n");
8229 val = xdigit2val(c);
8232 filter.bytes[j] = byte;
8233 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8240 /* translate mask string to uint8_t array. */
8241 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8242 (mask_ptr[1] == 'X')))
8244 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8246 printf("invalid input\n");
8251 for (i = 0; i < len; i++) {
8253 if (isxdigit(c) == 0) {
8254 /* invalid characters. */
8255 printf("invalid input\n");
8258 val = xdigit2val(c);
8261 filter.mask[j] = byte;
8262 printf("mask[%d]:%02x ", j, filter.mask[j]);
8270 if (!strcmp(res->ops, "add"))
8271 ret = rte_eth_dev_filter_ctrl(res->port_id,
8272 RTE_ETH_FILTER_FLEXIBLE,
8276 ret = rte_eth_dev_filter_ctrl(res->port_id,
8277 RTE_ETH_FILTER_FLEXIBLE,
8278 RTE_ETH_FILTER_DELETE,
8282 printf("flex filter setting error: (%s)\n", strerror(-ret));
8285 cmdline_parse_token_string_t cmd_flex_filter_filter =
8286 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8287 filter, "flex_filter");
8288 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8289 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8291 cmdline_parse_token_string_t cmd_flex_filter_ops =
8292 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8294 cmdline_parse_token_string_t cmd_flex_filter_len =
8295 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8297 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8298 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8300 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8301 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8303 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8304 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8306 cmdline_parse_token_string_t cmd_flex_filter_mask =
8307 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8309 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8310 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8312 cmdline_parse_token_string_t cmd_flex_filter_priority =
8313 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8314 priority, "priority");
8315 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8316 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8317 priority_value, UINT8);
8318 cmdline_parse_token_string_t cmd_flex_filter_queue =
8319 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8321 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8322 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8324 cmdline_parse_inst_t cmd_flex_filter = {
8325 .f = cmd_flex_filter_parsed,
8327 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8328 "<value> mask <value> priority <value> queue <queue_id>: "
8329 "Add/Del a flex filter",
8331 (void *)&cmd_flex_filter_filter,
8332 (void *)&cmd_flex_filter_port_id,
8333 (void *)&cmd_flex_filter_ops,
8334 (void *)&cmd_flex_filter_len,
8335 (void *)&cmd_flex_filter_len_value,
8336 (void *)&cmd_flex_filter_bytes,
8337 (void *)&cmd_flex_filter_bytes_value,
8338 (void *)&cmd_flex_filter_mask,
8339 (void *)&cmd_flex_filter_mask_value,
8340 (void *)&cmd_flex_filter_priority,
8341 (void *)&cmd_flex_filter_priority_value,
8342 (void *)&cmd_flex_filter_queue,
8343 (void *)&cmd_flex_filter_queue_id,
8348 /* *** Filters Control *** */
8350 /* *** deal with ethertype filter *** */
8351 struct cmd_ethertype_filter_result {
8352 cmdline_fixed_string_t filter;
8354 cmdline_fixed_string_t ops;
8355 cmdline_fixed_string_t mac;
8356 struct ether_addr mac_addr;
8357 cmdline_fixed_string_t ethertype;
8358 uint16_t ethertype_value;
8359 cmdline_fixed_string_t drop;
8360 cmdline_fixed_string_t queue;
8364 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8365 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8366 filter, "ethertype_filter");
8367 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8368 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8370 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8371 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8373 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8374 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8375 mac, "mac_addr#mac_ignr");
8376 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8377 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8379 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8380 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8381 ethertype, "ethertype");
8382 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8383 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8384 ethertype_value, UINT16);
8385 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8386 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8388 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8389 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8391 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8392 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8396 cmd_ethertype_filter_parsed(void *parsed_result,
8397 __attribute__((unused)) struct cmdline *cl,
8398 __attribute__((unused)) void *data)
8400 struct cmd_ethertype_filter_result *res = parsed_result;
8401 struct rte_eth_ethertype_filter filter;
8404 ret = rte_eth_dev_filter_supported(res->port_id,
8405 RTE_ETH_FILTER_ETHERTYPE);
8407 printf("ethertype filter is not supported on port %u.\n",
8412 memset(&filter, 0, sizeof(filter));
8413 if (!strcmp(res->mac, "mac_addr")) {
8414 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8415 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8416 sizeof(struct ether_addr));
8418 if (!strcmp(res->drop, "drop"))
8419 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8420 filter.ether_type = res->ethertype_value;
8421 filter.queue = res->queue_id;
8423 if (!strcmp(res->ops, "add"))
8424 ret = rte_eth_dev_filter_ctrl(res->port_id,
8425 RTE_ETH_FILTER_ETHERTYPE,
8429 ret = rte_eth_dev_filter_ctrl(res->port_id,
8430 RTE_ETH_FILTER_ETHERTYPE,
8431 RTE_ETH_FILTER_DELETE,
8434 printf("ethertype filter programming error: (%s)\n",
8438 cmdline_parse_inst_t cmd_ethertype_filter = {
8439 .f = cmd_ethertype_filter_parsed,
8441 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8442 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8443 "Add or delete an ethertype filter entry",
8445 (void *)&cmd_ethertype_filter_filter,
8446 (void *)&cmd_ethertype_filter_port_id,
8447 (void *)&cmd_ethertype_filter_ops,
8448 (void *)&cmd_ethertype_filter_mac,
8449 (void *)&cmd_ethertype_filter_mac_addr,
8450 (void *)&cmd_ethertype_filter_ethertype,
8451 (void *)&cmd_ethertype_filter_ethertype_value,
8452 (void *)&cmd_ethertype_filter_drop,
8453 (void *)&cmd_ethertype_filter_queue,
8454 (void *)&cmd_ethertype_filter_queue_id,
8459 /* *** deal with flow director filter *** */
8460 struct cmd_flow_director_result {
8461 cmdline_fixed_string_t flow_director_filter;
8463 cmdline_fixed_string_t mode;
8464 cmdline_fixed_string_t mode_value;
8465 cmdline_fixed_string_t ops;
8466 cmdline_fixed_string_t flow;
8467 cmdline_fixed_string_t flow_type;
8468 cmdline_fixed_string_t ether;
8469 uint16_t ether_type;
8470 cmdline_fixed_string_t src;
8471 cmdline_ipaddr_t ip_src;
8473 cmdline_fixed_string_t dst;
8474 cmdline_ipaddr_t ip_dst;
8476 cmdline_fixed_string_t verify_tag;
8477 uint32_t verify_tag_value;
8478 cmdline_ipaddr_t tos;
8480 cmdline_ipaddr_t proto;
8481 uint8_t proto_value;
8482 cmdline_ipaddr_t ttl;
8484 cmdline_fixed_string_t vlan;
8485 uint16_t vlan_value;
8486 cmdline_fixed_string_t flexbytes;
8487 cmdline_fixed_string_t flexbytes_value;
8488 cmdline_fixed_string_t pf_vf;
8489 cmdline_fixed_string_t drop;
8490 cmdline_fixed_string_t queue;
8492 cmdline_fixed_string_t fd_id;
8493 uint32_t fd_id_value;
8494 cmdline_fixed_string_t mac;
8495 struct ether_addr mac_addr;
8496 cmdline_fixed_string_t tunnel;
8497 cmdline_fixed_string_t tunnel_type;
8498 cmdline_fixed_string_t tunnel_id;
8499 uint32_t tunnel_id_value;
8503 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8506 const char *p, *p0 = q_arg;
8508 unsigned long int_fld;
8509 char *str_fld[max_num];
8514 p = strchr(p0, '(');
8518 p0 = strchr(p, ')');
8523 if (size >= sizeof(s))
8526 snprintf(s, sizeof(s), "%.*s", size, p);
8527 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8528 if (ret < 0 || ret > max_num)
8530 for (i = 0; i < ret; i++) {
8532 int_fld = strtoul(str_fld[i], &end, 0);
8533 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8535 flexbytes[i] = (uint8_t)int_fld;
8541 str2flowtype(char *string)
8544 static const struct {
8547 } flowtype_str[] = {
8548 {"raw", RTE_ETH_FLOW_RAW},
8549 {"ipv4", RTE_ETH_FLOW_IPV4},
8550 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8551 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8552 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8553 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8554 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8555 {"ipv6", RTE_ETH_FLOW_IPV6},
8556 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8557 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8558 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8559 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8560 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8561 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8564 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8565 if (!strcmp(flowtype_str[i].str, string))
8566 return flowtype_str[i].type;
8568 return RTE_ETH_FLOW_UNKNOWN;
8571 static enum rte_eth_fdir_tunnel_type
8572 str2fdir_tunneltype(char *string)
8576 static const struct {
8578 enum rte_eth_fdir_tunnel_type type;
8579 } tunneltype_str[] = {
8580 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8581 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8584 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8585 if (!strcmp(tunneltype_str[i].str, string))
8586 return tunneltype_str[i].type;
8588 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8591 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8593 if ((ip_addr).family == AF_INET) \
8594 (ip) = (ip_addr).addr.ipv4.s_addr; \
8596 printf("invalid parameter.\n"); \
8601 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8603 if ((ip_addr).family == AF_INET6) \
8604 (void)rte_memcpy(&(ip), \
8605 &((ip_addr).addr.ipv6), \
8606 sizeof(struct in6_addr)); \
8608 printf("invalid parameter.\n"); \
8614 cmd_flow_director_filter_parsed(void *parsed_result,
8615 __attribute__((unused)) struct cmdline *cl,
8616 __attribute__((unused)) void *data)
8618 struct cmd_flow_director_result *res = parsed_result;
8619 struct rte_eth_fdir_filter entry;
8620 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8622 unsigned long vf_id;
8625 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8627 printf("flow director is not supported on port %u.\n",
8631 memset(flexbytes, 0, sizeof(flexbytes));
8632 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8634 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8635 if (strcmp(res->mode_value, "MAC-VLAN")) {
8636 printf("Please set mode to MAC-VLAN.\n");
8639 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8640 if (strcmp(res->mode_value, "Tunnel")) {
8641 printf("Please set mode to Tunnel.\n");
8645 if (strcmp(res->mode_value, "IP")) {
8646 printf("Please set mode to IP.\n");
8649 entry.input.flow_type = str2flowtype(res->flow_type);
8652 ret = parse_flexbytes(res->flexbytes_value,
8654 RTE_ETH_FDIR_MAX_FLEXLEN);
8656 printf("error: Cannot parse flexbytes input.\n");
8660 switch (entry.input.flow_type) {
8661 case RTE_ETH_FLOW_FRAG_IPV4:
8662 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8663 entry.input.flow.ip4_flow.proto = res->proto_value;
8664 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8665 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8666 IPV4_ADDR_TO_UINT(res->ip_dst,
8667 entry.input.flow.ip4_flow.dst_ip);
8668 IPV4_ADDR_TO_UINT(res->ip_src,
8669 entry.input.flow.ip4_flow.src_ip);
8670 entry.input.flow.ip4_flow.tos = res->tos_value;
8671 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8672 /* need convert to big endian. */
8673 entry.input.flow.udp4_flow.dst_port =
8674 rte_cpu_to_be_16(res->port_dst);
8675 entry.input.flow.udp4_flow.src_port =
8676 rte_cpu_to_be_16(res->port_src);
8678 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8679 IPV4_ADDR_TO_UINT(res->ip_dst,
8680 entry.input.flow.sctp4_flow.ip.dst_ip);
8681 IPV4_ADDR_TO_UINT(res->ip_src,
8682 entry.input.flow.sctp4_flow.ip.src_ip);
8683 entry.input.flow.ip4_flow.tos = res->tos_value;
8684 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8685 /* need convert to big endian. */
8686 entry.input.flow.sctp4_flow.dst_port =
8687 rte_cpu_to_be_16(res->port_dst);
8688 entry.input.flow.sctp4_flow.src_port =
8689 rte_cpu_to_be_16(res->port_src);
8690 entry.input.flow.sctp4_flow.verify_tag =
8691 rte_cpu_to_be_32(res->verify_tag_value);
8693 case RTE_ETH_FLOW_FRAG_IPV6:
8694 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8695 entry.input.flow.ipv6_flow.proto = res->proto_value;
8696 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8697 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8698 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8699 entry.input.flow.ipv6_flow.dst_ip);
8700 IPV6_ADDR_TO_ARRAY(res->ip_src,
8701 entry.input.flow.ipv6_flow.src_ip);
8702 entry.input.flow.ipv6_flow.tc = res->tos_value;
8703 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8704 /* need convert to big endian. */
8705 entry.input.flow.udp6_flow.dst_port =
8706 rte_cpu_to_be_16(res->port_dst);
8707 entry.input.flow.udp6_flow.src_port =
8708 rte_cpu_to_be_16(res->port_src);
8710 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8711 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8712 entry.input.flow.sctp6_flow.ip.dst_ip);
8713 IPV6_ADDR_TO_ARRAY(res->ip_src,
8714 entry.input.flow.sctp6_flow.ip.src_ip);
8715 entry.input.flow.ipv6_flow.tc = res->tos_value;
8716 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8717 /* need convert to big endian. */
8718 entry.input.flow.sctp6_flow.dst_port =
8719 rte_cpu_to_be_16(res->port_dst);
8720 entry.input.flow.sctp6_flow.src_port =
8721 rte_cpu_to_be_16(res->port_src);
8722 entry.input.flow.sctp6_flow.verify_tag =
8723 rte_cpu_to_be_32(res->verify_tag_value);
8725 case RTE_ETH_FLOW_L2_PAYLOAD:
8726 entry.input.flow.l2_flow.ether_type =
8727 rte_cpu_to_be_16(res->ether_type);
8733 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8734 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8736 sizeof(struct ether_addr));
8738 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8739 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8741 sizeof(struct ether_addr));
8742 entry.input.flow.tunnel_flow.tunnel_type =
8743 str2fdir_tunneltype(res->tunnel_type);
8744 entry.input.flow.tunnel_flow.tunnel_id =
8745 rte_cpu_to_be_32(res->tunnel_id_value);
8748 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8750 RTE_ETH_FDIR_MAX_FLEXLEN);
8752 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8754 entry.action.flex_off = 0; /*use 0 by default */
8755 if (!strcmp(res->drop, "drop"))
8756 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8758 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8760 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8761 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8762 if (!strcmp(res->pf_vf, "pf"))
8763 entry.input.flow_ext.is_vf = 0;
8764 else if (!strncmp(res->pf_vf, "vf", 2)) {
8765 struct rte_eth_dev_info dev_info;
8767 memset(&dev_info, 0, sizeof(dev_info));
8768 rte_eth_dev_info_get(res->port_id, &dev_info);
8770 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8771 if (errno != 0 || *end != '\0' ||
8772 vf_id >= dev_info.max_vfs) {
8773 printf("invalid parameter %s.\n", res->pf_vf);
8776 entry.input.flow_ext.is_vf = 1;
8777 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8779 printf("invalid parameter %s.\n", res->pf_vf);
8784 /* set to report FD ID by default */
8785 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8786 entry.action.rx_queue = res->queue_id;
8787 entry.soft_id = res->fd_id_value;
8788 if (!strcmp(res->ops, "add"))
8789 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8790 RTE_ETH_FILTER_ADD, &entry);
8791 else if (!strcmp(res->ops, "del"))
8792 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8793 RTE_ETH_FILTER_DELETE, &entry);
8795 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8796 RTE_ETH_FILTER_UPDATE, &entry);
8798 printf("flow director programming error: (%s)\n",
8802 cmdline_parse_token_string_t cmd_flow_director_filter =
8803 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8804 flow_director_filter, "flow_director_filter");
8805 cmdline_parse_token_num_t cmd_flow_director_port_id =
8806 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8808 cmdline_parse_token_string_t cmd_flow_director_ops =
8809 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8810 ops, "add#del#update");
8811 cmdline_parse_token_string_t cmd_flow_director_flow =
8812 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8814 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8815 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8816 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8817 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8818 cmdline_parse_token_string_t cmd_flow_director_ether =
8819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8821 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8822 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8823 ether_type, UINT16);
8824 cmdline_parse_token_string_t cmd_flow_director_src =
8825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8827 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8828 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8830 cmdline_parse_token_num_t cmd_flow_director_port_src =
8831 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8833 cmdline_parse_token_string_t cmd_flow_director_dst =
8834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8836 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8837 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8839 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8840 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8842 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8844 verify_tag, "verify_tag");
8845 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8846 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8847 verify_tag_value, UINT32);
8848 cmdline_parse_token_string_t cmd_flow_director_tos =
8849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8851 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8852 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8854 cmdline_parse_token_string_t cmd_flow_director_proto =
8855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8857 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8858 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8859 proto_value, UINT8);
8860 cmdline_parse_token_string_t cmd_flow_director_ttl =
8861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8863 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8864 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8866 cmdline_parse_token_string_t cmd_flow_director_vlan =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8869 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8870 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8871 vlan_value, UINT16);
8872 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8874 flexbytes, "flexbytes");
8875 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8877 flexbytes_value, NULL);
8878 cmdline_parse_token_string_t cmd_flow_director_drop =
8879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8881 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8884 cmdline_parse_token_string_t cmd_flow_director_queue =
8885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8887 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8888 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8890 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8891 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8893 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8894 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8895 fd_id_value, UINT32);
8897 cmdline_parse_token_string_t cmd_flow_director_mode =
8898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8900 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8903 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8905 mode_value, "MAC-VLAN");
8906 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8908 mode_value, "Tunnel");
8909 cmdline_parse_token_string_t cmd_flow_director_mac =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8912 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8913 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8915 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8918 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8920 tunnel_type, "NVGRE#VxLAN");
8921 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8923 tunnel_id, "tunnel-id");
8924 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8925 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8926 tunnel_id_value, UINT32);
8928 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8929 .f = cmd_flow_director_filter_parsed,
8931 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8932 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8933 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8934 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8935 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8936 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8937 "fd_id <fd_id_value>: "
8938 "Add or delete an ip flow director entry on NIC",
8940 (void *)&cmd_flow_director_filter,
8941 (void *)&cmd_flow_director_port_id,
8942 (void *)&cmd_flow_director_mode,
8943 (void *)&cmd_flow_director_mode_ip,
8944 (void *)&cmd_flow_director_ops,
8945 (void *)&cmd_flow_director_flow,
8946 (void *)&cmd_flow_director_flow_type,
8947 (void *)&cmd_flow_director_src,
8948 (void *)&cmd_flow_director_ip_src,
8949 (void *)&cmd_flow_director_dst,
8950 (void *)&cmd_flow_director_ip_dst,
8951 (void *)&cmd_flow_director_tos,
8952 (void *)&cmd_flow_director_tos_value,
8953 (void *)&cmd_flow_director_proto,
8954 (void *)&cmd_flow_director_proto_value,
8955 (void *)&cmd_flow_director_ttl,
8956 (void *)&cmd_flow_director_ttl_value,
8957 (void *)&cmd_flow_director_vlan,
8958 (void *)&cmd_flow_director_vlan_value,
8959 (void *)&cmd_flow_director_flexbytes,
8960 (void *)&cmd_flow_director_flexbytes_value,
8961 (void *)&cmd_flow_director_drop,
8962 (void *)&cmd_flow_director_pf_vf,
8963 (void *)&cmd_flow_director_queue,
8964 (void *)&cmd_flow_director_queue_id,
8965 (void *)&cmd_flow_director_fd_id,
8966 (void *)&cmd_flow_director_fd_id_value,
8971 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8972 .f = cmd_flow_director_filter_parsed,
8974 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8975 "director entry on NIC",
8977 (void *)&cmd_flow_director_filter,
8978 (void *)&cmd_flow_director_port_id,
8979 (void *)&cmd_flow_director_mode,
8980 (void *)&cmd_flow_director_mode_ip,
8981 (void *)&cmd_flow_director_ops,
8982 (void *)&cmd_flow_director_flow,
8983 (void *)&cmd_flow_director_flow_type,
8984 (void *)&cmd_flow_director_src,
8985 (void *)&cmd_flow_director_ip_src,
8986 (void *)&cmd_flow_director_port_src,
8987 (void *)&cmd_flow_director_dst,
8988 (void *)&cmd_flow_director_ip_dst,
8989 (void *)&cmd_flow_director_port_dst,
8990 (void *)&cmd_flow_director_tos,
8991 (void *)&cmd_flow_director_tos_value,
8992 (void *)&cmd_flow_director_ttl,
8993 (void *)&cmd_flow_director_ttl_value,
8994 (void *)&cmd_flow_director_vlan,
8995 (void *)&cmd_flow_director_vlan_value,
8996 (void *)&cmd_flow_director_flexbytes,
8997 (void *)&cmd_flow_director_flexbytes_value,
8998 (void *)&cmd_flow_director_drop,
8999 (void *)&cmd_flow_director_pf_vf,
9000 (void *)&cmd_flow_director_queue,
9001 (void *)&cmd_flow_director_queue_id,
9002 (void *)&cmd_flow_director_fd_id,
9003 (void *)&cmd_flow_director_fd_id_value,
9008 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9009 .f = cmd_flow_director_filter_parsed,
9011 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9012 "director entry on NIC",
9014 (void *)&cmd_flow_director_filter,
9015 (void *)&cmd_flow_director_port_id,
9016 (void *)&cmd_flow_director_mode,
9017 (void *)&cmd_flow_director_mode_ip,
9018 (void *)&cmd_flow_director_ops,
9019 (void *)&cmd_flow_director_flow,
9020 (void *)&cmd_flow_director_flow_type,
9021 (void *)&cmd_flow_director_src,
9022 (void *)&cmd_flow_director_ip_src,
9023 (void *)&cmd_flow_director_port_dst,
9024 (void *)&cmd_flow_director_dst,
9025 (void *)&cmd_flow_director_ip_dst,
9026 (void *)&cmd_flow_director_port_dst,
9027 (void *)&cmd_flow_director_verify_tag,
9028 (void *)&cmd_flow_director_verify_tag_value,
9029 (void *)&cmd_flow_director_tos,
9030 (void *)&cmd_flow_director_tos_value,
9031 (void *)&cmd_flow_director_ttl,
9032 (void *)&cmd_flow_director_ttl_value,
9033 (void *)&cmd_flow_director_vlan,
9034 (void *)&cmd_flow_director_vlan_value,
9035 (void *)&cmd_flow_director_flexbytes,
9036 (void *)&cmd_flow_director_flexbytes_value,
9037 (void *)&cmd_flow_director_drop,
9038 (void *)&cmd_flow_director_pf_vf,
9039 (void *)&cmd_flow_director_queue,
9040 (void *)&cmd_flow_director_queue_id,
9041 (void *)&cmd_flow_director_fd_id,
9042 (void *)&cmd_flow_director_fd_id_value,
9047 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9048 .f = cmd_flow_director_filter_parsed,
9050 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9051 "director entry on NIC",
9053 (void *)&cmd_flow_director_filter,
9054 (void *)&cmd_flow_director_port_id,
9055 (void *)&cmd_flow_director_mode,
9056 (void *)&cmd_flow_director_mode_ip,
9057 (void *)&cmd_flow_director_ops,
9058 (void *)&cmd_flow_director_flow,
9059 (void *)&cmd_flow_director_flow_type,
9060 (void *)&cmd_flow_director_ether,
9061 (void *)&cmd_flow_director_ether_type,
9062 (void *)&cmd_flow_director_flexbytes,
9063 (void *)&cmd_flow_director_flexbytes_value,
9064 (void *)&cmd_flow_director_drop,
9065 (void *)&cmd_flow_director_pf_vf,
9066 (void *)&cmd_flow_director_queue,
9067 (void *)&cmd_flow_director_queue_id,
9068 (void *)&cmd_flow_director_fd_id,
9069 (void *)&cmd_flow_director_fd_id_value,
9074 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9075 .f = cmd_flow_director_filter_parsed,
9077 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9078 "director entry on NIC",
9080 (void *)&cmd_flow_director_filter,
9081 (void *)&cmd_flow_director_port_id,
9082 (void *)&cmd_flow_director_mode,
9083 (void *)&cmd_flow_director_mode_mac_vlan,
9084 (void *)&cmd_flow_director_ops,
9085 (void *)&cmd_flow_director_mac,
9086 (void *)&cmd_flow_director_mac_addr,
9087 (void *)&cmd_flow_director_vlan,
9088 (void *)&cmd_flow_director_vlan_value,
9089 (void *)&cmd_flow_director_flexbytes,
9090 (void *)&cmd_flow_director_flexbytes_value,
9091 (void *)&cmd_flow_director_drop,
9092 (void *)&cmd_flow_director_queue,
9093 (void *)&cmd_flow_director_queue_id,
9094 (void *)&cmd_flow_director_fd_id,
9095 (void *)&cmd_flow_director_fd_id_value,
9100 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9101 .f = cmd_flow_director_filter_parsed,
9103 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9104 "director entry on NIC",
9106 (void *)&cmd_flow_director_filter,
9107 (void *)&cmd_flow_director_port_id,
9108 (void *)&cmd_flow_director_mode,
9109 (void *)&cmd_flow_director_mode_tunnel,
9110 (void *)&cmd_flow_director_ops,
9111 (void *)&cmd_flow_director_mac,
9112 (void *)&cmd_flow_director_mac_addr,
9113 (void *)&cmd_flow_director_vlan,
9114 (void *)&cmd_flow_director_vlan_value,
9115 (void *)&cmd_flow_director_tunnel,
9116 (void *)&cmd_flow_director_tunnel_type,
9117 (void *)&cmd_flow_director_tunnel_id,
9118 (void *)&cmd_flow_director_tunnel_id_value,
9119 (void *)&cmd_flow_director_flexbytes,
9120 (void *)&cmd_flow_director_flexbytes_value,
9121 (void *)&cmd_flow_director_drop,
9122 (void *)&cmd_flow_director_queue,
9123 (void *)&cmd_flow_director_queue_id,
9124 (void *)&cmd_flow_director_fd_id,
9125 (void *)&cmd_flow_director_fd_id_value,
9130 struct cmd_flush_flow_director_result {
9131 cmdline_fixed_string_t flush_flow_director;
9135 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9136 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9137 flush_flow_director, "flush_flow_director");
9138 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9139 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9143 cmd_flush_flow_director_parsed(void *parsed_result,
9144 __attribute__((unused)) struct cmdline *cl,
9145 __attribute__((unused)) void *data)
9147 struct cmd_flow_director_result *res = parsed_result;
9150 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9152 printf("flow director is not supported on port %u.\n",
9157 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9158 RTE_ETH_FILTER_FLUSH, NULL);
9160 printf("flow director table flushing error: (%s)\n",
9164 cmdline_parse_inst_t cmd_flush_flow_director = {
9165 .f = cmd_flush_flow_director_parsed,
9167 .help_str = "flush_flow_director <port_id>: "
9168 "Flush all flow director entries of a device on NIC",
9170 (void *)&cmd_flush_flow_director_flush,
9171 (void *)&cmd_flush_flow_director_port_id,
9176 /* *** deal with flow director mask *** */
9177 struct cmd_flow_director_mask_result {
9178 cmdline_fixed_string_t flow_director_mask;
9180 cmdline_fixed_string_t mode;
9181 cmdline_fixed_string_t mode_value;
9182 cmdline_fixed_string_t vlan;
9184 cmdline_fixed_string_t src_mask;
9185 cmdline_ipaddr_t ipv4_src;
9186 cmdline_ipaddr_t ipv6_src;
9188 cmdline_fixed_string_t dst_mask;
9189 cmdline_ipaddr_t ipv4_dst;
9190 cmdline_ipaddr_t ipv6_dst;
9192 cmdline_fixed_string_t mac;
9193 uint8_t mac_addr_byte_mask;
9194 cmdline_fixed_string_t tunnel_id;
9195 uint32_t tunnel_id_mask;
9196 cmdline_fixed_string_t tunnel_type;
9197 uint8_t tunnel_type_mask;
9201 cmd_flow_director_mask_parsed(void *parsed_result,
9202 __attribute__((unused)) struct cmdline *cl,
9203 __attribute__((unused)) void *data)
9205 struct cmd_flow_director_mask_result *res = parsed_result;
9206 struct rte_eth_fdir_masks *mask;
9207 struct rte_port *port;
9209 if (res->port_id > nb_ports) {
9210 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9214 port = &ports[res->port_id];
9215 /** Check if the port is not started **/
9216 if (port->port_status != RTE_PORT_STOPPED) {
9217 printf("Please stop port %d first\n", res->port_id);
9221 mask = &port->dev_conf.fdir_conf.mask;
9223 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9224 if (strcmp(res->mode_value, "MAC-VLAN")) {
9225 printf("Please set mode to MAC-VLAN.\n");
9229 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9230 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9231 if (strcmp(res->mode_value, "Tunnel")) {
9232 printf("Please set mode to Tunnel.\n");
9236 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9237 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9238 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9239 mask->tunnel_type_mask = res->tunnel_type_mask;
9241 if (strcmp(res->mode_value, "IP")) {
9242 printf("Please set mode to IP.\n");
9246 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9247 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9248 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9249 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9250 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9251 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9252 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9255 cmd_reconfig_device_queue(res->port_id, 1, 1);
9258 cmdline_parse_token_string_t cmd_flow_director_mask =
9259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9260 flow_director_mask, "flow_director_mask");
9261 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9262 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9264 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9267 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9268 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9270 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9272 src_mask, "src_mask");
9273 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9274 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9276 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9277 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9279 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9282 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9284 dst_mask, "dst_mask");
9285 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9286 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9288 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9289 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9291 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9295 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9298 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9301 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9303 mode_value, "MAC-VLAN");
9304 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9305 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9306 mode_value, "Tunnel");
9307 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9308 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9310 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9311 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9312 mac_addr_byte_mask, UINT8);
9313 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9314 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9315 tunnel_type, "tunnel-type");
9316 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9317 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9318 tunnel_type_mask, UINT8);
9319 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9321 tunnel_id, "tunnel-id");
9322 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9323 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9324 tunnel_id_mask, UINT32);
9326 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9327 .f = cmd_flow_director_mask_parsed,
9329 .help_str = "flow_director_mask ... : "
9330 "Set IP mode flow director's mask on NIC",
9332 (void *)&cmd_flow_director_mask,
9333 (void *)&cmd_flow_director_mask_port_id,
9334 (void *)&cmd_flow_director_mask_mode,
9335 (void *)&cmd_flow_director_mask_mode_ip,
9336 (void *)&cmd_flow_director_mask_vlan,
9337 (void *)&cmd_flow_director_mask_vlan_value,
9338 (void *)&cmd_flow_director_mask_src,
9339 (void *)&cmd_flow_director_mask_ipv4_src,
9340 (void *)&cmd_flow_director_mask_ipv6_src,
9341 (void *)&cmd_flow_director_mask_port_src,
9342 (void *)&cmd_flow_director_mask_dst,
9343 (void *)&cmd_flow_director_mask_ipv4_dst,
9344 (void *)&cmd_flow_director_mask_ipv6_dst,
9345 (void *)&cmd_flow_director_mask_port_dst,
9350 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9351 .f = cmd_flow_director_mask_parsed,
9353 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9354 "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_mac_vlan,
9360 (void *)&cmd_flow_director_mask_vlan,
9361 (void *)&cmd_flow_director_mask_vlan_value,
9366 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9367 .f = cmd_flow_director_mask_parsed,
9369 .help_str = "flow_director_mask ... : Set tunnel mode "
9370 "flow director's mask on NIC",
9372 (void *)&cmd_flow_director_mask,
9373 (void *)&cmd_flow_director_mask_port_id,
9374 (void *)&cmd_flow_director_mask_mode,
9375 (void *)&cmd_flow_director_mask_mode_tunnel,
9376 (void *)&cmd_flow_director_mask_vlan,
9377 (void *)&cmd_flow_director_mask_vlan_value,
9378 (void *)&cmd_flow_director_mask_mac,
9379 (void *)&cmd_flow_director_mask_mac_value,
9380 (void *)&cmd_flow_director_mask_tunnel_type,
9381 (void *)&cmd_flow_director_mask_tunnel_type_value,
9382 (void *)&cmd_flow_director_mask_tunnel_id,
9383 (void *)&cmd_flow_director_mask_tunnel_id_value,
9388 /* *** deal with flow director mask on flexible payload *** */
9389 struct cmd_flow_director_flex_mask_result {
9390 cmdline_fixed_string_t flow_director_flexmask;
9392 cmdline_fixed_string_t flow;
9393 cmdline_fixed_string_t flow_type;
9394 cmdline_fixed_string_t mask;
9398 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9399 __attribute__((unused)) struct cmdline *cl,
9400 __attribute__((unused)) void *data)
9402 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9403 struct rte_eth_fdir_info fdir_info;
9404 struct rte_eth_fdir_flex_mask flex_mask;
9405 struct rte_port *port;
9406 uint32_t flow_type_mask;
9410 if (res->port_id > nb_ports) {
9411 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9415 port = &ports[res->port_id];
9416 /** Check if the port is not started **/
9417 if (port->port_status != RTE_PORT_STOPPED) {
9418 printf("Please stop port %d first\n", res->port_id);
9422 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9423 ret = parse_flexbytes(res->mask,
9425 RTE_ETH_FDIR_MAX_FLEXLEN);
9427 printf("error: Cannot parse mask input.\n");
9431 memset(&fdir_info, 0, sizeof(fdir_info));
9432 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9433 RTE_ETH_FILTER_INFO, &fdir_info);
9435 printf("Cannot get FDir filter info\n");
9439 if (!strcmp(res->flow_type, "none")) {
9440 /* means don't specify the flow type */
9441 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9442 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9443 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9444 0, sizeof(struct rte_eth_fdir_flex_mask));
9445 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9446 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9448 sizeof(struct rte_eth_fdir_flex_mask));
9449 cmd_reconfig_device_queue(res->port_id, 1, 1);
9452 flow_type_mask = fdir_info.flow_types_mask[0];
9453 if (!strcmp(res->flow_type, "all")) {
9454 if (!flow_type_mask) {
9455 printf("No flow type supported\n");
9458 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9459 if (flow_type_mask & (1 << i)) {
9460 flex_mask.flow_type = i;
9461 fdir_set_flex_mask(res->port_id, &flex_mask);
9464 cmd_reconfig_device_queue(res->port_id, 1, 1);
9467 flex_mask.flow_type = str2flowtype(res->flow_type);
9468 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9469 printf("Flow type %s not supported on port %d\n",
9470 res->flow_type, res->port_id);
9473 fdir_set_flex_mask(res->port_id, &flex_mask);
9474 cmd_reconfig_device_queue(res->port_id, 1, 1);
9477 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9478 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9479 flow_director_flexmask,
9480 "flow_director_flex_mask");
9481 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9482 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9484 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9487 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9488 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9489 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9490 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9491 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9492 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9495 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9496 .f = cmd_flow_director_flex_mask_parsed,
9498 .help_str = "flow_director_flex_mask ... : "
9499 "Set flow director's flex mask on NIC",
9501 (void *)&cmd_flow_director_flexmask,
9502 (void *)&cmd_flow_director_flexmask_port_id,
9503 (void *)&cmd_flow_director_flexmask_flow,
9504 (void *)&cmd_flow_director_flexmask_flow_type,
9505 (void *)&cmd_flow_director_flexmask_mask,
9510 /* *** deal with flow director flexible payload configuration *** */
9511 struct cmd_flow_director_flexpayload_result {
9512 cmdline_fixed_string_t flow_director_flexpayload;
9514 cmdline_fixed_string_t payload_layer;
9515 cmdline_fixed_string_t payload_cfg;
9519 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9522 const char *p, *p0 = q_arg;
9524 unsigned long int_fld;
9525 char *str_fld[max_num];
9530 p = strchr(p0, '(');
9534 p0 = strchr(p, ')');
9539 if (size >= sizeof(s))
9542 snprintf(s, sizeof(s), "%.*s", size, p);
9543 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9544 if (ret < 0 || ret > max_num)
9546 for (i = 0; i < ret; i++) {
9548 int_fld = strtoul(str_fld[i], &end, 0);
9549 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9551 offsets[i] = (uint16_t)int_fld;
9557 cmd_flow_director_flxpld_parsed(void *parsed_result,
9558 __attribute__((unused)) struct cmdline *cl,
9559 __attribute__((unused)) void *data)
9561 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9562 struct rte_eth_flex_payload_cfg flex_cfg;
9563 struct rte_port *port;
9566 if (res->port_id > nb_ports) {
9567 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9571 port = &ports[res->port_id];
9572 /** Check if the port is not started **/
9573 if (port->port_status != RTE_PORT_STOPPED) {
9574 printf("Please stop port %d first\n", res->port_id);
9578 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9580 if (!strcmp(res->payload_layer, "raw"))
9581 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9582 else if (!strcmp(res->payload_layer, "l2"))
9583 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9584 else if (!strcmp(res->payload_layer, "l3"))
9585 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9586 else if (!strcmp(res->payload_layer, "l4"))
9587 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9589 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9590 RTE_ETH_FDIR_MAX_FLEXLEN);
9592 printf("error: Cannot parse flex payload input.\n");
9596 fdir_set_flex_payload(res->port_id, &flex_cfg);
9597 cmd_reconfig_device_queue(res->port_id, 1, 1);
9600 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9601 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9602 flow_director_flexpayload,
9603 "flow_director_flex_payload");
9604 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9605 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9607 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9609 payload_layer, "raw#l2#l3#l4");
9610 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9611 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9614 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9615 .f = cmd_flow_director_flxpld_parsed,
9617 .help_str = "flow_director_flexpayload ... : "
9618 "Set flow director's flex payload on NIC",
9620 (void *)&cmd_flow_director_flexpayload,
9621 (void *)&cmd_flow_director_flexpayload_port_id,
9622 (void *)&cmd_flow_director_flexpayload_payload_layer,
9623 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9628 /* Generic flow interface command. */
9629 extern cmdline_parse_inst_t cmd_flow;
9631 /* *** Classification Filters Control *** */
9632 /* *** Get symmetric hash enable per port *** */
9633 struct cmd_get_sym_hash_ena_per_port_result {
9634 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9639 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9640 __rte_unused struct cmdline *cl,
9641 __rte_unused void *data)
9643 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9644 struct rte_eth_hash_filter_info info;
9647 if (rte_eth_dev_filter_supported(res->port_id,
9648 RTE_ETH_FILTER_HASH) < 0) {
9649 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9654 memset(&info, 0, sizeof(info));
9655 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9656 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9657 RTE_ETH_FILTER_GET, &info);
9660 printf("Cannot get symmetric hash enable per port "
9661 "on port %u\n", res->port_id);
9665 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9666 "enabled" : "disabled", res->port_id);
9669 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9670 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9671 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9672 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9673 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9676 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9677 .f = cmd_get_sym_hash_per_port_parsed,
9679 .help_str = "get_sym_hash_ena_per_port <port_id>",
9681 (void *)&cmd_get_sym_hash_ena_per_port_all,
9682 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9687 /* *** Set symmetric hash enable per port *** */
9688 struct cmd_set_sym_hash_ena_per_port_result {
9689 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9690 cmdline_fixed_string_t enable;
9695 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9696 __rte_unused struct cmdline *cl,
9697 __rte_unused void *data)
9699 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9700 struct rte_eth_hash_filter_info info;
9703 if (rte_eth_dev_filter_supported(res->port_id,
9704 RTE_ETH_FILTER_HASH) < 0) {
9705 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9710 memset(&info, 0, sizeof(info));
9711 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9712 if (!strcmp(res->enable, "enable"))
9713 info.info.enable = 1;
9714 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9715 RTE_ETH_FILTER_SET, &info);
9717 printf("Cannot set symmetric hash enable per port on "
9718 "port %u\n", res->port_id);
9721 printf("Symmetric hash has been set to %s on port %u\n",
9722 res->enable, res->port_id);
9725 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9726 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9727 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9728 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9729 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9731 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9732 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9733 enable, "enable#disable");
9735 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9736 .f = cmd_set_sym_hash_per_port_parsed,
9738 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9740 (void *)&cmd_set_sym_hash_ena_per_port_all,
9741 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9742 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9747 /* Get global config of hash function */
9748 struct cmd_get_hash_global_config_result {
9749 cmdline_fixed_string_t get_hash_global_config;
9754 flowtype_to_str(uint16_t ftype)
9761 {"ipv4", RTE_ETH_FLOW_IPV4},
9762 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9763 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9764 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9765 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9766 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9767 {"ipv6", RTE_ETH_FLOW_IPV6},
9768 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9769 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9770 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9771 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9772 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9773 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9774 {"port", RTE_ETH_FLOW_PORT},
9775 {"vxlan", RTE_ETH_FLOW_VXLAN},
9776 {"geneve", RTE_ETH_FLOW_GENEVE},
9777 {"nvgre", RTE_ETH_FLOW_NVGRE},
9780 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9781 if (ftype_table[i].ftype == ftype)
9782 return ftype_table[i].str;
9789 cmd_get_hash_global_config_parsed(void *parsed_result,
9790 __rte_unused struct cmdline *cl,
9791 __rte_unused void *data)
9793 struct cmd_get_hash_global_config_result *res = parsed_result;
9794 struct rte_eth_hash_filter_info info;
9795 uint32_t idx, offset;
9800 if (rte_eth_dev_filter_supported(res->port_id,
9801 RTE_ETH_FILTER_HASH) < 0) {
9802 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9807 memset(&info, 0, sizeof(info));
9808 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9809 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9810 RTE_ETH_FILTER_GET, &info);
9812 printf("Cannot get hash global configurations by port %d\n",
9817 switch (info.info.global_conf.hash_func) {
9818 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9819 printf("Hash function is Toeplitz\n");
9821 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9822 printf("Hash function is Simple XOR\n");
9825 printf("Unknown hash function\n");
9829 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9830 idx = i / UINT32_BIT;
9831 offset = i % UINT32_BIT;
9832 if (!(info.info.global_conf.valid_bit_mask[idx] &
9835 str = flowtype_to_str(i);
9838 printf("Symmetric hash is %s globally for flow type %s "
9840 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9841 (1UL << offset)) ? "enabled" : "disabled"), str,
9846 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9847 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9848 get_hash_global_config, "get_hash_global_config");
9849 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9850 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9853 cmdline_parse_inst_t cmd_get_hash_global_config = {
9854 .f = cmd_get_hash_global_config_parsed,
9856 .help_str = "get_hash_global_config <port_id>",
9858 (void *)&cmd_get_hash_global_config_all,
9859 (void *)&cmd_get_hash_global_config_port_id,
9864 /* Set global config of hash function */
9865 struct cmd_set_hash_global_config_result {
9866 cmdline_fixed_string_t set_hash_global_config;
9868 cmdline_fixed_string_t hash_func;
9869 cmdline_fixed_string_t flow_type;
9870 cmdline_fixed_string_t enable;
9874 cmd_set_hash_global_config_parsed(void *parsed_result,
9875 __rte_unused struct cmdline *cl,
9876 __rte_unused void *data)
9878 struct cmd_set_hash_global_config_result *res = parsed_result;
9879 struct rte_eth_hash_filter_info info;
9880 uint32_t ftype, idx, offset;
9883 if (rte_eth_dev_filter_supported(res->port_id,
9884 RTE_ETH_FILTER_HASH) < 0) {
9885 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9889 memset(&info, 0, sizeof(info));
9890 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9891 if (!strcmp(res->hash_func, "toeplitz"))
9892 info.info.global_conf.hash_func =
9893 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9894 else if (!strcmp(res->hash_func, "simple_xor"))
9895 info.info.global_conf.hash_func =
9896 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9897 else if (!strcmp(res->hash_func, "default"))
9898 info.info.global_conf.hash_func =
9899 RTE_ETH_HASH_FUNCTION_DEFAULT;
9901 ftype = str2flowtype(res->flow_type);
9902 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9903 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9904 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9905 if (!strcmp(res->enable, "enable"))
9906 info.info.global_conf.sym_hash_enable_mask[idx] |=
9908 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9909 RTE_ETH_FILTER_SET, &info);
9911 printf("Cannot set global hash configurations by port %d\n",
9914 printf("Global hash configurations have been set "
9915 "succcessfully by port %d\n", res->port_id);
9918 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9919 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9920 set_hash_global_config, "set_hash_global_config");
9921 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9922 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9924 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9925 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9926 hash_func, "toeplitz#simple_xor#default");
9927 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9928 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9930 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9931 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9932 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9933 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9934 enable, "enable#disable");
9936 cmdline_parse_inst_t cmd_set_hash_global_config = {
9937 .f = cmd_set_hash_global_config_parsed,
9939 .help_str = "set_hash_global_config <port_id> "
9940 "toeplitz|simple_xor|default "
9941 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9942 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9943 "l2_payload enable|disable",
9945 (void *)&cmd_set_hash_global_config_all,
9946 (void *)&cmd_set_hash_global_config_port_id,
9947 (void *)&cmd_set_hash_global_config_hash_func,
9948 (void *)&cmd_set_hash_global_config_flow_type,
9949 (void *)&cmd_set_hash_global_config_enable,
9954 /* Set hash input set */
9955 struct cmd_set_hash_input_set_result {
9956 cmdline_fixed_string_t set_hash_input_set;
9958 cmdline_fixed_string_t flow_type;
9959 cmdline_fixed_string_t inset_field;
9960 cmdline_fixed_string_t select;
9963 static enum rte_eth_input_set_field
9964 str2inset(char *string)
9968 static const struct {
9970 enum rte_eth_input_set_field inset;
9972 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9973 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9974 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9975 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9976 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9977 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9978 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9979 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9980 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9981 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9982 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9983 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9984 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9985 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9986 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9987 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9988 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9989 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9990 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9991 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9992 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9993 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9994 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9995 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9996 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9997 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9998 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9999 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10000 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10001 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10002 {"none", RTE_ETH_INPUT_SET_NONE},
10005 for (i = 0; i < RTE_DIM(inset_table); i++) {
10006 if (!strcmp(string, inset_table[i].str))
10007 return inset_table[i].inset;
10010 return RTE_ETH_INPUT_SET_UNKNOWN;
10014 cmd_set_hash_input_set_parsed(void *parsed_result,
10015 __rte_unused struct cmdline *cl,
10016 __rte_unused void *data)
10018 struct cmd_set_hash_input_set_result *res = parsed_result;
10019 struct rte_eth_hash_filter_info info;
10021 memset(&info, 0, sizeof(info));
10022 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10023 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10024 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10025 info.info.input_set_conf.inset_size = 1;
10026 if (!strcmp(res->select, "select"))
10027 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10028 else if (!strcmp(res->select, "add"))
10029 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10030 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10031 RTE_ETH_FILTER_SET, &info);
10034 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10035 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10036 set_hash_input_set, "set_hash_input_set");
10037 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10038 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10040 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10041 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10043 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10044 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10045 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10046 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10048 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10049 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10050 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10051 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10052 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10054 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10055 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10056 select, "select#add");
10058 cmdline_parse_inst_t cmd_set_hash_input_set = {
10059 .f = cmd_set_hash_input_set_parsed,
10061 .help_str = "set_hash_input_set <port_id> "
10062 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10063 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10064 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10065 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10066 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10067 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10068 "fld-7th|fld-8th|none select|add",
10070 (void *)&cmd_set_hash_input_set_cmd,
10071 (void *)&cmd_set_hash_input_set_port_id,
10072 (void *)&cmd_set_hash_input_set_flow_type,
10073 (void *)&cmd_set_hash_input_set_field,
10074 (void *)&cmd_set_hash_input_set_select,
10079 /* Set flow director input set */
10080 struct cmd_set_fdir_input_set_result {
10081 cmdline_fixed_string_t set_fdir_input_set;
10083 cmdline_fixed_string_t flow_type;
10084 cmdline_fixed_string_t inset_field;
10085 cmdline_fixed_string_t select;
10089 cmd_set_fdir_input_set_parsed(void *parsed_result,
10090 __rte_unused struct cmdline *cl,
10091 __rte_unused void *data)
10093 struct cmd_set_fdir_input_set_result *res = parsed_result;
10094 struct rte_eth_fdir_filter_info info;
10096 memset(&info, 0, sizeof(info));
10097 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10098 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10099 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10100 info.info.input_set_conf.inset_size = 1;
10101 if (!strcmp(res->select, "select"))
10102 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10103 else if (!strcmp(res->select, "add"))
10104 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10105 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10106 RTE_ETH_FILTER_SET, &info);
10109 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10110 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10111 set_fdir_input_set, "set_fdir_input_set");
10112 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10113 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10115 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10116 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10118 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10119 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10120 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10121 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10123 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10124 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10125 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10126 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10127 "sctp-veri-tag#none");
10128 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10129 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10130 select, "select#add");
10132 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10133 .f = cmd_set_fdir_input_set_parsed,
10135 .help_str = "set_fdir_input_set <port_id> "
10136 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10137 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10138 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10139 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10140 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10141 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10142 "sctp-veri-tag|none select|add",
10144 (void *)&cmd_set_fdir_input_set_cmd,
10145 (void *)&cmd_set_fdir_input_set_port_id,
10146 (void *)&cmd_set_fdir_input_set_flow_type,
10147 (void *)&cmd_set_fdir_input_set_field,
10148 (void *)&cmd_set_fdir_input_set_select,
10153 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10154 struct cmd_mcast_addr_result {
10155 cmdline_fixed_string_t mcast_addr_cmd;
10156 cmdline_fixed_string_t what;
10158 struct ether_addr mc_addr;
10161 static void cmd_mcast_addr_parsed(void *parsed_result,
10162 __attribute__((unused)) struct cmdline *cl,
10163 __attribute__((unused)) void *data)
10165 struct cmd_mcast_addr_result *res = parsed_result;
10167 if (!is_multicast_ether_addr(&res->mc_addr)) {
10168 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10169 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10170 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10171 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10174 if (strcmp(res->what, "add") == 0)
10175 mcast_addr_add(res->port_num, &res->mc_addr);
10177 mcast_addr_remove(res->port_num, &res->mc_addr);
10180 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10181 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10182 mcast_addr_cmd, "mcast_addr");
10183 cmdline_parse_token_string_t cmd_mcast_addr_what =
10184 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10186 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10187 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10188 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10189 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10191 cmdline_parse_inst_t cmd_mcast_addr = {
10192 .f = cmd_mcast_addr_parsed,
10194 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10195 "Add/Remove multicast MAC address on port_id",
10197 (void *)&cmd_mcast_addr_cmd,
10198 (void *)&cmd_mcast_addr_what,
10199 (void *)&cmd_mcast_addr_portnum,
10200 (void *)&cmd_mcast_addr_addr,
10205 /* l2 tunnel config
10206 * only support E-tag now.
10209 /* Ether type config */
10210 struct cmd_config_l2_tunnel_eth_type_result {
10211 cmdline_fixed_string_t port;
10212 cmdline_fixed_string_t config;
10213 cmdline_fixed_string_t all;
10215 cmdline_fixed_string_t l2_tunnel;
10216 cmdline_fixed_string_t l2_tunnel_type;
10217 cmdline_fixed_string_t eth_type;
10218 uint16_t eth_type_val;
10221 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10222 TOKEN_STRING_INITIALIZER
10223 (struct cmd_config_l2_tunnel_eth_type_result,
10225 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10226 TOKEN_STRING_INITIALIZER
10227 (struct cmd_config_l2_tunnel_eth_type_result,
10229 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10230 TOKEN_STRING_INITIALIZER
10231 (struct cmd_config_l2_tunnel_eth_type_result,
10233 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10234 TOKEN_NUM_INITIALIZER
10235 (struct cmd_config_l2_tunnel_eth_type_result,
10237 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10238 TOKEN_STRING_INITIALIZER
10239 (struct cmd_config_l2_tunnel_eth_type_result,
10240 l2_tunnel, "l2-tunnel");
10241 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10242 TOKEN_STRING_INITIALIZER
10243 (struct cmd_config_l2_tunnel_eth_type_result,
10244 l2_tunnel_type, "E-tag");
10245 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10246 TOKEN_STRING_INITIALIZER
10247 (struct cmd_config_l2_tunnel_eth_type_result,
10248 eth_type, "ether-type");
10249 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10250 TOKEN_NUM_INITIALIZER
10251 (struct cmd_config_l2_tunnel_eth_type_result,
10252 eth_type_val, UINT16);
10254 static enum rte_eth_tunnel_type
10255 str2fdir_l2_tunnel_type(char *string)
10259 static const struct {
10261 enum rte_eth_tunnel_type type;
10262 } l2_tunnel_type_str[] = {
10263 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10266 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10267 if (!strcmp(l2_tunnel_type_str[i].str, string))
10268 return l2_tunnel_type_str[i].type;
10270 return RTE_TUNNEL_TYPE_NONE;
10273 /* ether type config for all ports */
10275 cmd_config_l2_tunnel_eth_type_all_parsed
10276 (void *parsed_result,
10277 __attribute__((unused)) struct cmdline *cl,
10278 __attribute__((unused)) void *data)
10280 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10281 struct rte_eth_l2_tunnel_conf entry;
10284 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10285 entry.ether_type = res->eth_type_val;
10287 FOREACH_PORT(pid, ports) {
10288 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10292 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10293 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10295 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10297 (void *)&cmd_config_l2_tunnel_eth_type_port,
10298 (void *)&cmd_config_l2_tunnel_eth_type_config,
10299 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10300 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10301 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10302 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10303 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10308 /* ether type config for a specific port */
10310 cmd_config_l2_tunnel_eth_type_specific_parsed(
10311 void *parsed_result,
10312 __attribute__((unused)) struct cmdline *cl,
10313 __attribute__((unused)) void *data)
10315 struct cmd_config_l2_tunnel_eth_type_result *res =
10317 struct rte_eth_l2_tunnel_conf entry;
10319 if (port_id_is_invalid(res->id, ENABLED_WARN))
10322 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10323 entry.ether_type = res->eth_type_val;
10325 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10328 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10329 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10331 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10333 (void *)&cmd_config_l2_tunnel_eth_type_port,
10334 (void *)&cmd_config_l2_tunnel_eth_type_config,
10335 (void *)&cmd_config_l2_tunnel_eth_type_id,
10336 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10337 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10338 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10339 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10344 /* Enable/disable l2 tunnel */
10345 struct cmd_config_l2_tunnel_en_dis_result {
10346 cmdline_fixed_string_t port;
10347 cmdline_fixed_string_t config;
10348 cmdline_fixed_string_t all;
10350 cmdline_fixed_string_t l2_tunnel;
10351 cmdline_fixed_string_t l2_tunnel_type;
10352 cmdline_fixed_string_t en_dis;
10355 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10356 TOKEN_STRING_INITIALIZER
10357 (struct cmd_config_l2_tunnel_en_dis_result,
10359 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10360 TOKEN_STRING_INITIALIZER
10361 (struct cmd_config_l2_tunnel_en_dis_result,
10363 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10364 TOKEN_STRING_INITIALIZER
10365 (struct cmd_config_l2_tunnel_en_dis_result,
10367 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10368 TOKEN_NUM_INITIALIZER
10369 (struct cmd_config_l2_tunnel_en_dis_result,
10371 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10372 TOKEN_STRING_INITIALIZER
10373 (struct cmd_config_l2_tunnel_en_dis_result,
10374 l2_tunnel, "l2-tunnel");
10375 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10376 TOKEN_STRING_INITIALIZER
10377 (struct cmd_config_l2_tunnel_en_dis_result,
10378 l2_tunnel_type, "E-tag");
10379 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10380 TOKEN_STRING_INITIALIZER
10381 (struct cmd_config_l2_tunnel_en_dis_result,
10382 en_dis, "enable#disable");
10384 /* enable/disable l2 tunnel for all ports */
10386 cmd_config_l2_tunnel_en_dis_all_parsed(
10387 void *parsed_result,
10388 __attribute__((unused)) struct cmdline *cl,
10389 __attribute__((unused)) void *data)
10391 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10392 struct rte_eth_l2_tunnel_conf entry;
10396 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10398 if (!strcmp("enable", res->en_dis))
10403 FOREACH_PORT(pid, ports) {
10404 rte_eth_dev_l2_tunnel_offload_set(pid,
10406 ETH_L2_TUNNEL_ENABLE_MASK,
10411 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10412 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10414 .help_str = "port config all l2-tunnel E-tag enable|disable",
10416 (void *)&cmd_config_l2_tunnel_en_dis_port,
10417 (void *)&cmd_config_l2_tunnel_en_dis_config,
10418 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10419 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10420 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10421 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10426 /* enable/disable l2 tunnel for a port */
10428 cmd_config_l2_tunnel_en_dis_specific_parsed(
10429 void *parsed_result,
10430 __attribute__((unused)) struct cmdline *cl,
10431 __attribute__((unused)) void *data)
10433 struct cmd_config_l2_tunnel_en_dis_result *res =
10435 struct rte_eth_l2_tunnel_conf entry;
10437 if (port_id_is_invalid(res->id, ENABLED_WARN))
10440 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10442 if (!strcmp("enable", res->en_dis))
10443 rte_eth_dev_l2_tunnel_offload_set(res->id,
10445 ETH_L2_TUNNEL_ENABLE_MASK,
10448 rte_eth_dev_l2_tunnel_offload_set(res->id,
10450 ETH_L2_TUNNEL_ENABLE_MASK,
10454 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10455 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10457 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10459 (void *)&cmd_config_l2_tunnel_en_dis_port,
10460 (void *)&cmd_config_l2_tunnel_en_dis_config,
10461 (void *)&cmd_config_l2_tunnel_en_dis_id,
10462 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10463 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10464 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10469 /* E-tag configuration */
10471 /* Common result structure for all E-tag configuration */
10472 struct cmd_config_e_tag_result {
10473 cmdline_fixed_string_t e_tag;
10474 cmdline_fixed_string_t set;
10475 cmdline_fixed_string_t insertion;
10476 cmdline_fixed_string_t stripping;
10477 cmdline_fixed_string_t forwarding;
10478 cmdline_fixed_string_t filter;
10479 cmdline_fixed_string_t add;
10480 cmdline_fixed_string_t del;
10481 cmdline_fixed_string_t on;
10482 cmdline_fixed_string_t off;
10483 cmdline_fixed_string_t on_off;
10484 cmdline_fixed_string_t port_tag_id;
10485 uint32_t port_tag_id_val;
10486 cmdline_fixed_string_t e_tag_id;
10487 uint16_t e_tag_id_val;
10488 cmdline_fixed_string_t dst_pool;
10489 uint8_t dst_pool_val;
10490 cmdline_fixed_string_t port;
10492 cmdline_fixed_string_t vf;
10496 /* Common CLI fields for all E-tag configuration */
10497 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10498 TOKEN_STRING_INITIALIZER
10499 (struct cmd_config_e_tag_result,
10501 cmdline_parse_token_string_t cmd_config_e_tag_set =
10502 TOKEN_STRING_INITIALIZER
10503 (struct cmd_config_e_tag_result,
10505 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10506 TOKEN_STRING_INITIALIZER
10507 (struct cmd_config_e_tag_result,
10508 insertion, "insertion");
10509 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10510 TOKEN_STRING_INITIALIZER
10511 (struct cmd_config_e_tag_result,
10512 stripping, "stripping");
10513 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10514 TOKEN_STRING_INITIALIZER
10515 (struct cmd_config_e_tag_result,
10516 forwarding, "forwarding");
10517 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10518 TOKEN_STRING_INITIALIZER
10519 (struct cmd_config_e_tag_result,
10521 cmdline_parse_token_string_t cmd_config_e_tag_add =
10522 TOKEN_STRING_INITIALIZER
10523 (struct cmd_config_e_tag_result,
10525 cmdline_parse_token_string_t cmd_config_e_tag_del =
10526 TOKEN_STRING_INITIALIZER
10527 (struct cmd_config_e_tag_result,
10529 cmdline_parse_token_string_t cmd_config_e_tag_on =
10530 TOKEN_STRING_INITIALIZER
10531 (struct cmd_config_e_tag_result,
10533 cmdline_parse_token_string_t cmd_config_e_tag_off =
10534 TOKEN_STRING_INITIALIZER
10535 (struct cmd_config_e_tag_result,
10537 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10538 TOKEN_STRING_INITIALIZER
10539 (struct cmd_config_e_tag_result,
10541 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10542 TOKEN_STRING_INITIALIZER
10543 (struct cmd_config_e_tag_result,
10544 port_tag_id, "port-tag-id");
10545 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10546 TOKEN_NUM_INITIALIZER
10547 (struct cmd_config_e_tag_result,
10548 port_tag_id_val, UINT32);
10549 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10550 TOKEN_STRING_INITIALIZER
10551 (struct cmd_config_e_tag_result,
10552 e_tag_id, "e-tag-id");
10553 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10554 TOKEN_NUM_INITIALIZER
10555 (struct cmd_config_e_tag_result,
10556 e_tag_id_val, UINT16);
10557 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10558 TOKEN_STRING_INITIALIZER
10559 (struct cmd_config_e_tag_result,
10560 dst_pool, "dst-pool");
10561 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10562 TOKEN_NUM_INITIALIZER
10563 (struct cmd_config_e_tag_result,
10564 dst_pool_val, UINT8);
10565 cmdline_parse_token_string_t cmd_config_e_tag_port =
10566 TOKEN_STRING_INITIALIZER
10567 (struct cmd_config_e_tag_result,
10569 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10570 TOKEN_NUM_INITIALIZER
10571 (struct cmd_config_e_tag_result,
10573 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10574 TOKEN_STRING_INITIALIZER
10575 (struct cmd_config_e_tag_result,
10577 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10578 TOKEN_NUM_INITIALIZER
10579 (struct cmd_config_e_tag_result,
10582 /* E-tag insertion configuration */
10584 cmd_config_e_tag_insertion_en_parsed(
10585 void *parsed_result,
10586 __attribute__((unused)) struct cmdline *cl,
10587 __attribute__((unused)) void *data)
10589 struct cmd_config_e_tag_result *res =
10591 struct rte_eth_l2_tunnel_conf entry;
10593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10596 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10597 entry.tunnel_id = res->port_tag_id_val;
10598 entry.vf_id = res->vf_id;
10599 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10601 ETH_L2_TUNNEL_INSERTION_MASK,
10606 cmd_config_e_tag_insertion_dis_parsed(
10607 void *parsed_result,
10608 __attribute__((unused)) struct cmdline *cl,
10609 __attribute__((unused)) void *data)
10611 struct cmd_config_e_tag_result *res =
10613 struct rte_eth_l2_tunnel_conf entry;
10615 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10618 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10619 entry.vf_id = res->vf_id;
10621 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10623 ETH_L2_TUNNEL_INSERTION_MASK,
10627 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10628 .f = cmd_config_e_tag_insertion_en_parsed,
10630 .help_str = "E-tag ... : E-tag insertion enable",
10632 (void *)&cmd_config_e_tag_e_tag,
10633 (void *)&cmd_config_e_tag_set,
10634 (void *)&cmd_config_e_tag_insertion,
10635 (void *)&cmd_config_e_tag_on,
10636 (void *)&cmd_config_e_tag_port_tag_id,
10637 (void *)&cmd_config_e_tag_port_tag_id_val,
10638 (void *)&cmd_config_e_tag_port,
10639 (void *)&cmd_config_e_tag_port_id,
10640 (void *)&cmd_config_e_tag_vf,
10641 (void *)&cmd_config_e_tag_vf_id,
10646 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10647 .f = cmd_config_e_tag_insertion_dis_parsed,
10649 .help_str = "E-tag ... : E-tag insertion disable",
10651 (void *)&cmd_config_e_tag_e_tag,
10652 (void *)&cmd_config_e_tag_set,
10653 (void *)&cmd_config_e_tag_insertion,
10654 (void *)&cmd_config_e_tag_off,
10655 (void *)&cmd_config_e_tag_port,
10656 (void *)&cmd_config_e_tag_port_id,
10657 (void *)&cmd_config_e_tag_vf,
10658 (void *)&cmd_config_e_tag_vf_id,
10663 /* E-tag stripping configuration */
10665 cmd_config_e_tag_stripping_parsed(
10666 void *parsed_result,
10667 __attribute__((unused)) struct cmdline *cl,
10668 __attribute__((unused)) void *data)
10670 struct cmd_config_e_tag_result *res =
10672 struct rte_eth_l2_tunnel_conf entry;
10674 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10677 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10679 if (!strcmp(res->on_off, "on"))
10680 rte_eth_dev_l2_tunnel_offload_set
10683 ETH_L2_TUNNEL_STRIPPING_MASK,
10686 rte_eth_dev_l2_tunnel_offload_set
10689 ETH_L2_TUNNEL_STRIPPING_MASK,
10693 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10694 .f = cmd_config_e_tag_stripping_parsed,
10696 .help_str = "E-tag ... : E-tag stripping enable/disable",
10698 (void *)&cmd_config_e_tag_e_tag,
10699 (void *)&cmd_config_e_tag_set,
10700 (void *)&cmd_config_e_tag_stripping,
10701 (void *)&cmd_config_e_tag_on_off,
10702 (void *)&cmd_config_e_tag_port,
10703 (void *)&cmd_config_e_tag_port_id,
10708 /* E-tag forwarding configuration */
10710 cmd_config_e_tag_forwarding_parsed(
10711 void *parsed_result,
10712 __attribute__((unused)) struct cmdline *cl,
10713 __attribute__((unused)) void *data)
10715 struct cmd_config_e_tag_result *res = parsed_result;
10716 struct rte_eth_l2_tunnel_conf entry;
10718 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10721 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10723 if (!strcmp(res->on_off, "on"))
10724 rte_eth_dev_l2_tunnel_offload_set
10727 ETH_L2_TUNNEL_FORWARDING_MASK,
10730 rte_eth_dev_l2_tunnel_offload_set
10733 ETH_L2_TUNNEL_FORWARDING_MASK,
10737 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10738 .f = cmd_config_e_tag_forwarding_parsed,
10740 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10742 (void *)&cmd_config_e_tag_e_tag,
10743 (void *)&cmd_config_e_tag_set,
10744 (void *)&cmd_config_e_tag_forwarding,
10745 (void *)&cmd_config_e_tag_on_off,
10746 (void *)&cmd_config_e_tag_port,
10747 (void *)&cmd_config_e_tag_port_id,
10752 /* E-tag filter configuration */
10754 cmd_config_e_tag_filter_add_parsed(
10755 void *parsed_result,
10756 __attribute__((unused)) struct cmdline *cl,
10757 __attribute__((unused)) void *data)
10759 struct cmd_config_e_tag_result *res = parsed_result;
10760 struct rte_eth_l2_tunnel_conf entry;
10763 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10766 if (res->e_tag_id_val > 0x3fff) {
10767 printf("e-tag-id must be equal or less than 0x3fff.\n");
10771 ret = rte_eth_dev_filter_supported(res->port_id,
10772 RTE_ETH_FILTER_L2_TUNNEL);
10774 printf("E-tag filter is not supported on port %u.\n",
10779 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10780 entry.tunnel_id = res->e_tag_id_val;
10781 entry.pool = res->dst_pool_val;
10783 ret = rte_eth_dev_filter_ctrl(res->port_id,
10784 RTE_ETH_FILTER_L2_TUNNEL,
10785 RTE_ETH_FILTER_ADD,
10788 printf("E-tag filter programming error: (%s)\n",
10792 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10793 .f = cmd_config_e_tag_filter_add_parsed,
10795 .help_str = "E-tag ... : E-tag filter add",
10797 (void *)&cmd_config_e_tag_e_tag,
10798 (void *)&cmd_config_e_tag_set,
10799 (void *)&cmd_config_e_tag_filter,
10800 (void *)&cmd_config_e_tag_add,
10801 (void *)&cmd_config_e_tag_e_tag_id,
10802 (void *)&cmd_config_e_tag_e_tag_id_val,
10803 (void *)&cmd_config_e_tag_dst_pool,
10804 (void *)&cmd_config_e_tag_dst_pool_val,
10805 (void *)&cmd_config_e_tag_port,
10806 (void *)&cmd_config_e_tag_port_id,
10812 cmd_config_e_tag_filter_del_parsed(
10813 void *parsed_result,
10814 __attribute__((unused)) struct cmdline *cl,
10815 __attribute__((unused)) void *data)
10817 struct cmd_config_e_tag_result *res = parsed_result;
10818 struct rte_eth_l2_tunnel_conf entry;
10821 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10824 if (res->e_tag_id_val > 0x3fff) {
10825 printf("e-tag-id must be less than 0x3fff.\n");
10829 ret = rte_eth_dev_filter_supported(res->port_id,
10830 RTE_ETH_FILTER_L2_TUNNEL);
10832 printf("E-tag filter is not supported on port %u.\n",
10837 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10838 entry.tunnel_id = res->e_tag_id_val;
10840 ret = rte_eth_dev_filter_ctrl(res->port_id,
10841 RTE_ETH_FILTER_L2_TUNNEL,
10842 RTE_ETH_FILTER_DELETE,
10845 printf("E-tag filter programming error: (%s)\n",
10849 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10850 .f = cmd_config_e_tag_filter_del_parsed,
10852 .help_str = "E-tag ... : E-tag filter delete",
10854 (void *)&cmd_config_e_tag_e_tag,
10855 (void *)&cmd_config_e_tag_set,
10856 (void *)&cmd_config_e_tag_filter,
10857 (void *)&cmd_config_e_tag_del,
10858 (void *)&cmd_config_e_tag_e_tag_id,
10859 (void *)&cmd_config_e_tag_e_tag_id_val,
10860 (void *)&cmd_config_e_tag_port,
10861 (void *)&cmd_config_e_tag_port_id,
10866 /* vf vlan anti spoof configuration */
10868 /* Common result structure for vf vlan anti spoof */
10869 struct cmd_vf_vlan_anti_spoof_result {
10870 cmdline_fixed_string_t set;
10871 cmdline_fixed_string_t vf;
10872 cmdline_fixed_string_t vlan;
10873 cmdline_fixed_string_t antispoof;
10876 cmdline_fixed_string_t on_off;
10879 /* Common CLI fields for vf vlan anti spoof enable disable */
10880 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10881 TOKEN_STRING_INITIALIZER
10882 (struct cmd_vf_vlan_anti_spoof_result,
10884 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10885 TOKEN_STRING_INITIALIZER
10886 (struct cmd_vf_vlan_anti_spoof_result,
10888 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10889 TOKEN_STRING_INITIALIZER
10890 (struct cmd_vf_vlan_anti_spoof_result,
10892 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10893 TOKEN_STRING_INITIALIZER
10894 (struct cmd_vf_vlan_anti_spoof_result,
10895 antispoof, "antispoof");
10896 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10897 TOKEN_NUM_INITIALIZER
10898 (struct cmd_vf_vlan_anti_spoof_result,
10900 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10901 TOKEN_NUM_INITIALIZER
10902 (struct cmd_vf_vlan_anti_spoof_result,
10904 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10905 TOKEN_STRING_INITIALIZER
10906 (struct cmd_vf_vlan_anti_spoof_result,
10910 cmd_set_vf_vlan_anti_spoof_parsed(
10911 void *parsed_result,
10912 __attribute__((unused)) struct cmdline *cl,
10913 __attribute__((unused)) void *data)
10915 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10916 int ret = -ENOTSUP;
10918 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10920 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10923 #ifdef RTE_LIBRTE_IXGBE_PMD
10924 if (ret == -ENOTSUP)
10925 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10926 res->vf_id, is_on);
10928 #ifdef RTE_LIBRTE_I40E_PMD
10929 if (ret == -ENOTSUP)
10930 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10931 res->vf_id, is_on);
10938 printf("invalid vf_id %d\n", res->vf_id);
10941 printf("invalid port_id %d\n", res->port_id);
10944 printf("function not implemented\n");
10947 printf("programming error: (%s)\n", strerror(-ret));
10951 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10952 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10954 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10956 (void *)&cmd_vf_vlan_anti_spoof_set,
10957 (void *)&cmd_vf_vlan_anti_spoof_vf,
10958 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10959 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10960 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10961 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10962 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10967 /* vf mac anti spoof configuration */
10969 /* Common result structure for vf mac anti spoof */
10970 struct cmd_vf_mac_anti_spoof_result {
10971 cmdline_fixed_string_t set;
10972 cmdline_fixed_string_t vf;
10973 cmdline_fixed_string_t mac;
10974 cmdline_fixed_string_t antispoof;
10977 cmdline_fixed_string_t on_off;
10980 /* Common CLI fields for vf mac anti spoof enable disable */
10981 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10982 TOKEN_STRING_INITIALIZER
10983 (struct cmd_vf_mac_anti_spoof_result,
10985 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10986 TOKEN_STRING_INITIALIZER
10987 (struct cmd_vf_mac_anti_spoof_result,
10989 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10990 TOKEN_STRING_INITIALIZER
10991 (struct cmd_vf_mac_anti_spoof_result,
10993 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10994 TOKEN_STRING_INITIALIZER
10995 (struct cmd_vf_mac_anti_spoof_result,
10996 antispoof, "antispoof");
10997 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10998 TOKEN_NUM_INITIALIZER
10999 (struct cmd_vf_mac_anti_spoof_result,
11001 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11002 TOKEN_NUM_INITIALIZER
11003 (struct cmd_vf_mac_anti_spoof_result,
11005 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11006 TOKEN_STRING_INITIALIZER
11007 (struct cmd_vf_mac_anti_spoof_result,
11011 cmd_set_vf_mac_anti_spoof_parsed(
11012 void *parsed_result,
11013 __attribute__((unused)) struct cmdline *cl,
11014 __attribute__((unused)) void *data)
11016 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11017 int ret = -ENOTSUP;
11019 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11021 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11024 #ifdef RTE_LIBRTE_IXGBE_PMD
11025 if (ret == -ENOTSUP)
11026 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11027 res->vf_id, is_on);
11029 #ifdef RTE_LIBRTE_I40E_PMD
11030 if (ret == -ENOTSUP)
11031 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11032 res->vf_id, is_on);
11039 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11042 printf("invalid port_id %d\n", res->port_id);
11045 printf("function not implemented\n");
11048 printf("programming error: (%s)\n", strerror(-ret));
11052 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11053 .f = cmd_set_vf_mac_anti_spoof_parsed,
11055 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11057 (void *)&cmd_vf_mac_anti_spoof_set,
11058 (void *)&cmd_vf_mac_anti_spoof_vf,
11059 (void *)&cmd_vf_mac_anti_spoof_mac,
11060 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11061 (void *)&cmd_vf_mac_anti_spoof_port_id,
11062 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11063 (void *)&cmd_vf_mac_anti_spoof_on_off,
11068 /* vf vlan strip queue configuration */
11070 /* Common result structure for vf mac anti spoof */
11071 struct cmd_vf_vlan_stripq_result {
11072 cmdline_fixed_string_t set;
11073 cmdline_fixed_string_t vf;
11074 cmdline_fixed_string_t vlan;
11075 cmdline_fixed_string_t stripq;
11078 cmdline_fixed_string_t on_off;
11081 /* Common CLI fields for vf vlan strip enable disable */
11082 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11083 TOKEN_STRING_INITIALIZER
11084 (struct cmd_vf_vlan_stripq_result,
11086 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11087 TOKEN_STRING_INITIALIZER
11088 (struct cmd_vf_vlan_stripq_result,
11090 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11091 TOKEN_STRING_INITIALIZER
11092 (struct cmd_vf_vlan_stripq_result,
11094 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11095 TOKEN_STRING_INITIALIZER
11096 (struct cmd_vf_vlan_stripq_result,
11098 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11099 TOKEN_NUM_INITIALIZER
11100 (struct cmd_vf_vlan_stripq_result,
11102 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11103 TOKEN_NUM_INITIALIZER
11104 (struct cmd_vf_vlan_stripq_result,
11106 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11107 TOKEN_STRING_INITIALIZER
11108 (struct cmd_vf_vlan_stripq_result,
11112 cmd_set_vf_vlan_stripq_parsed(
11113 void *parsed_result,
11114 __attribute__((unused)) struct cmdline *cl,
11115 __attribute__((unused)) void *data)
11117 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11118 int ret = -ENOTSUP;
11120 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11122 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11125 #ifdef RTE_LIBRTE_IXGBE_PMD
11126 if (ret == -ENOTSUP)
11127 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11128 res->vf_id, is_on);
11130 #ifdef RTE_LIBRTE_I40E_PMD
11131 if (ret == -ENOTSUP)
11132 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11133 res->vf_id, is_on);
11140 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11143 printf("invalid port_id %d\n", res->port_id);
11146 printf("function not implemented\n");
11149 printf("programming error: (%s)\n", strerror(-ret));
11153 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11154 .f = cmd_set_vf_vlan_stripq_parsed,
11156 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11158 (void *)&cmd_vf_vlan_stripq_set,
11159 (void *)&cmd_vf_vlan_stripq_vf,
11160 (void *)&cmd_vf_vlan_stripq_vlan,
11161 (void *)&cmd_vf_vlan_stripq_stripq,
11162 (void *)&cmd_vf_vlan_stripq_port_id,
11163 (void *)&cmd_vf_vlan_stripq_vf_id,
11164 (void *)&cmd_vf_vlan_stripq_on_off,
11169 /* vf vlan insert configuration */
11171 /* Common result structure for vf vlan insert */
11172 struct cmd_vf_vlan_insert_result {
11173 cmdline_fixed_string_t set;
11174 cmdline_fixed_string_t vf;
11175 cmdline_fixed_string_t vlan;
11176 cmdline_fixed_string_t insert;
11182 /* Common CLI fields for vf vlan insert enable disable */
11183 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11184 TOKEN_STRING_INITIALIZER
11185 (struct cmd_vf_vlan_insert_result,
11187 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11188 TOKEN_STRING_INITIALIZER
11189 (struct cmd_vf_vlan_insert_result,
11191 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11192 TOKEN_STRING_INITIALIZER
11193 (struct cmd_vf_vlan_insert_result,
11195 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11196 TOKEN_STRING_INITIALIZER
11197 (struct cmd_vf_vlan_insert_result,
11199 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11200 TOKEN_NUM_INITIALIZER
11201 (struct cmd_vf_vlan_insert_result,
11203 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11204 TOKEN_NUM_INITIALIZER
11205 (struct cmd_vf_vlan_insert_result,
11207 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11208 TOKEN_NUM_INITIALIZER
11209 (struct cmd_vf_vlan_insert_result,
11213 cmd_set_vf_vlan_insert_parsed(
11214 void *parsed_result,
11215 __attribute__((unused)) struct cmdline *cl,
11216 __attribute__((unused)) void *data)
11218 struct cmd_vf_vlan_insert_result *res = parsed_result;
11219 int ret = -ENOTSUP;
11221 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11224 #ifdef RTE_LIBRTE_IXGBE_PMD
11225 if (ret == -ENOTSUP)
11226 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11229 #ifdef RTE_LIBRTE_I40E_PMD
11230 if (ret == -ENOTSUP)
11231 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11239 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11242 printf("invalid port_id %d\n", res->port_id);
11245 printf("function not implemented\n");
11248 printf("programming error: (%s)\n", strerror(-ret));
11252 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11253 .f = cmd_set_vf_vlan_insert_parsed,
11255 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11257 (void *)&cmd_vf_vlan_insert_set,
11258 (void *)&cmd_vf_vlan_insert_vf,
11259 (void *)&cmd_vf_vlan_insert_vlan,
11260 (void *)&cmd_vf_vlan_insert_insert,
11261 (void *)&cmd_vf_vlan_insert_port_id,
11262 (void *)&cmd_vf_vlan_insert_vf_id,
11263 (void *)&cmd_vf_vlan_insert_vlan_id,
11268 /* tx loopback configuration */
11270 /* Common result structure for tx loopback */
11271 struct cmd_tx_loopback_result {
11272 cmdline_fixed_string_t set;
11273 cmdline_fixed_string_t tx;
11274 cmdline_fixed_string_t loopback;
11276 cmdline_fixed_string_t on_off;
11279 /* Common CLI fields for tx loopback enable disable */
11280 cmdline_parse_token_string_t cmd_tx_loopback_set =
11281 TOKEN_STRING_INITIALIZER
11282 (struct cmd_tx_loopback_result,
11284 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11285 TOKEN_STRING_INITIALIZER
11286 (struct cmd_tx_loopback_result,
11288 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11289 TOKEN_STRING_INITIALIZER
11290 (struct cmd_tx_loopback_result,
11291 loopback, "loopback");
11292 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11293 TOKEN_NUM_INITIALIZER
11294 (struct cmd_tx_loopback_result,
11296 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11297 TOKEN_STRING_INITIALIZER
11298 (struct cmd_tx_loopback_result,
11302 cmd_set_tx_loopback_parsed(
11303 void *parsed_result,
11304 __attribute__((unused)) struct cmdline *cl,
11305 __attribute__((unused)) void *data)
11307 struct cmd_tx_loopback_result *res = parsed_result;
11308 int ret = -ENOTSUP;
11310 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11315 #ifdef RTE_LIBRTE_IXGBE_PMD
11316 if (ret == -ENOTSUP)
11317 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11319 #ifdef RTE_LIBRTE_I40E_PMD
11320 if (ret == -ENOTSUP)
11321 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11328 printf("invalid is_on %d\n", is_on);
11331 printf("invalid port_id %d\n", res->port_id);
11334 printf("function not implemented\n");
11337 printf("programming error: (%s)\n", strerror(-ret));
11341 cmdline_parse_inst_t cmd_set_tx_loopback = {
11342 .f = cmd_set_tx_loopback_parsed,
11344 .help_str = "set tx loopback <port_id> on|off",
11346 (void *)&cmd_tx_loopback_set,
11347 (void *)&cmd_tx_loopback_tx,
11348 (void *)&cmd_tx_loopback_loopback,
11349 (void *)&cmd_tx_loopback_port_id,
11350 (void *)&cmd_tx_loopback_on_off,
11355 #ifdef RTE_LIBRTE_IXGBE_PMD
11356 /* all queues drop enable configuration */
11358 /* Common result structure for all queues drop enable */
11359 struct cmd_all_queues_drop_en_result {
11360 cmdline_fixed_string_t set;
11361 cmdline_fixed_string_t all;
11362 cmdline_fixed_string_t queues;
11363 cmdline_fixed_string_t drop;
11365 cmdline_fixed_string_t on_off;
11368 /* Common CLI fields for tx loopback enable disable */
11369 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11370 TOKEN_STRING_INITIALIZER
11371 (struct cmd_all_queues_drop_en_result,
11373 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11374 TOKEN_STRING_INITIALIZER
11375 (struct cmd_all_queues_drop_en_result,
11377 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11378 TOKEN_STRING_INITIALIZER
11379 (struct cmd_all_queues_drop_en_result,
11381 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11382 TOKEN_STRING_INITIALIZER
11383 (struct cmd_all_queues_drop_en_result,
11385 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11386 TOKEN_NUM_INITIALIZER
11387 (struct cmd_all_queues_drop_en_result,
11389 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11390 TOKEN_STRING_INITIALIZER
11391 (struct cmd_all_queues_drop_en_result,
11395 cmd_set_all_queues_drop_en_parsed(
11396 void *parsed_result,
11397 __attribute__((unused)) struct cmdline *cl,
11398 __attribute__((unused)) void *data)
11400 struct cmd_all_queues_drop_en_result *res = parsed_result;
11402 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11404 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11407 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11412 printf("invalid is_on %d\n", is_on);
11415 printf("invalid port_id %d\n", res->port_id);
11418 printf("function not implemented\n");
11421 printf("programming error: (%s)\n", strerror(-ret));
11425 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11426 .f = cmd_set_all_queues_drop_en_parsed,
11428 .help_str = "set all queues drop <port_id> on|off",
11430 (void *)&cmd_all_queues_drop_en_set,
11431 (void *)&cmd_all_queues_drop_en_all,
11432 (void *)&cmd_all_queues_drop_en_queues,
11433 (void *)&cmd_all_queues_drop_en_drop,
11434 (void *)&cmd_all_queues_drop_en_port_id,
11435 (void *)&cmd_all_queues_drop_en_on_off,
11440 /* vf split drop enable configuration */
11442 /* Common result structure for vf split drop enable */
11443 struct cmd_vf_split_drop_en_result {
11444 cmdline_fixed_string_t set;
11445 cmdline_fixed_string_t vf;
11446 cmdline_fixed_string_t split;
11447 cmdline_fixed_string_t drop;
11450 cmdline_fixed_string_t on_off;
11453 /* Common CLI fields for vf split drop enable disable */
11454 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11455 TOKEN_STRING_INITIALIZER
11456 (struct cmd_vf_split_drop_en_result,
11458 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11459 TOKEN_STRING_INITIALIZER
11460 (struct cmd_vf_split_drop_en_result,
11462 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11463 TOKEN_STRING_INITIALIZER
11464 (struct cmd_vf_split_drop_en_result,
11466 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11467 TOKEN_STRING_INITIALIZER
11468 (struct cmd_vf_split_drop_en_result,
11470 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11471 TOKEN_NUM_INITIALIZER
11472 (struct cmd_vf_split_drop_en_result,
11474 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11475 TOKEN_NUM_INITIALIZER
11476 (struct cmd_vf_split_drop_en_result,
11478 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11479 TOKEN_STRING_INITIALIZER
11480 (struct cmd_vf_split_drop_en_result,
11484 cmd_set_vf_split_drop_en_parsed(
11485 void *parsed_result,
11486 __attribute__((unused)) struct cmdline *cl,
11487 __attribute__((unused)) void *data)
11489 struct cmd_vf_split_drop_en_result *res = parsed_result;
11491 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11493 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11496 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11502 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11505 printf("invalid port_id %d\n", res->port_id);
11508 printf("programming error: (%s)\n", strerror(-ret));
11512 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11513 .f = cmd_set_vf_split_drop_en_parsed,
11515 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11517 (void *)&cmd_vf_split_drop_en_set,
11518 (void *)&cmd_vf_split_drop_en_vf,
11519 (void *)&cmd_vf_split_drop_en_split,
11520 (void *)&cmd_vf_split_drop_en_drop,
11521 (void *)&cmd_vf_split_drop_en_port_id,
11522 (void *)&cmd_vf_split_drop_en_vf_id,
11523 (void *)&cmd_vf_split_drop_en_on_off,
11529 /* vf mac address configuration */
11531 /* Common result structure for vf mac address */
11532 struct cmd_set_vf_mac_addr_result {
11533 cmdline_fixed_string_t set;
11534 cmdline_fixed_string_t vf;
11535 cmdline_fixed_string_t mac;
11536 cmdline_fixed_string_t addr;
11539 struct ether_addr mac_addr;
11543 /* Common CLI fields for vf split drop enable disable */
11544 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11545 TOKEN_STRING_INITIALIZER
11546 (struct cmd_set_vf_mac_addr_result,
11548 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11549 TOKEN_STRING_INITIALIZER
11550 (struct cmd_set_vf_mac_addr_result,
11552 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11553 TOKEN_STRING_INITIALIZER
11554 (struct cmd_set_vf_mac_addr_result,
11556 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11557 TOKEN_STRING_INITIALIZER
11558 (struct cmd_set_vf_mac_addr_result,
11560 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11561 TOKEN_NUM_INITIALIZER
11562 (struct cmd_set_vf_mac_addr_result,
11564 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11565 TOKEN_NUM_INITIALIZER
11566 (struct cmd_set_vf_mac_addr_result,
11568 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11569 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11573 cmd_set_vf_mac_addr_parsed(
11574 void *parsed_result,
11575 __attribute__((unused)) struct cmdline *cl,
11576 __attribute__((unused)) void *data)
11578 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11579 int ret = -ENOTSUP;
11581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11584 #ifdef RTE_LIBRTE_IXGBE_PMD
11585 if (ret == -ENOTSUP)
11586 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11589 #ifdef RTE_LIBRTE_I40E_PMD
11590 if (ret == -ENOTSUP)
11591 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11599 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11602 printf("invalid port_id %d\n", res->port_id);
11605 printf("function not implemented\n");
11608 printf("programming error: (%s)\n", strerror(-ret));
11612 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11613 .f = cmd_set_vf_mac_addr_parsed,
11615 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11617 (void *)&cmd_set_vf_mac_addr_set,
11618 (void *)&cmd_set_vf_mac_addr_vf,
11619 (void *)&cmd_set_vf_mac_addr_mac,
11620 (void *)&cmd_set_vf_mac_addr_addr,
11621 (void *)&cmd_set_vf_mac_addr_port_id,
11622 (void *)&cmd_set_vf_mac_addr_vf_id,
11623 (void *)&cmd_set_vf_mac_addr_mac_addr,
11628 #ifdef RTE_LIBRTE_IXGBE_PMD
11629 /* MACsec configuration */
11631 /* Common result structure for MACsec offload enable */
11632 struct cmd_macsec_offload_on_result {
11633 cmdline_fixed_string_t set;
11634 cmdline_fixed_string_t macsec;
11635 cmdline_fixed_string_t offload;
11637 cmdline_fixed_string_t on;
11638 cmdline_fixed_string_t encrypt;
11639 cmdline_fixed_string_t en_on_off;
11640 cmdline_fixed_string_t replay_protect;
11641 cmdline_fixed_string_t rp_on_off;
11644 /* Common CLI fields for MACsec offload disable */
11645 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11646 TOKEN_STRING_INITIALIZER
11647 (struct cmd_macsec_offload_on_result,
11649 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11650 TOKEN_STRING_INITIALIZER
11651 (struct cmd_macsec_offload_on_result,
11653 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11654 TOKEN_STRING_INITIALIZER
11655 (struct cmd_macsec_offload_on_result,
11656 offload, "offload");
11657 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11658 TOKEN_NUM_INITIALIZER
11659 (struct cmd_macsec_offload_on_result,
11661 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11662 TOKEN_STRING_INITIALIZER
11663 (struct cmd_macsec_offload_on_result,
11665 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11666 TOKEN_STRING_INITIALIZER
11667 (struct cmd_macsec_offload_on_result,
11668 encrypt, "encrypt");
11669 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11670 TOKEN_STRING_INITIALIZER
11671 (struct cmd_macsec_offload_on_result,
11672 en_on_off, "on#off");
11673 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11674 TOKEN_STRING_INITIALIZER
11675 (struct cmd_macsec_offload_on_result,
11676 replay_protect, "replay-protect");
11677 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11678 TOKEN_STRING_INITIALIZER
11679 (struct cmd_macsec_offload_on_result,
11680 rp_on_off, "on#off");
11683 cmd_set_macsec_offload_on_parsed(
11684 void *parsed_result,
11685 __attribute__((unused)) struct cmdline *cl,
11686 __attribute__((unused)) void *data)
11688 struct cmd_macsec_offload_on_result *res = parsed_result;
11690 portid_t port_id = res->port_id;
11691 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11692 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11694 if (port_id_is_invalid(port_id, ENABLED_WARN))
11697 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11698 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11704 printf("invalid port_id %d\n", port_id);
11707 printf("programming error: (%s)\n", strerror(-ret));
11711 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11712 .f = cmd_set_macsec_offload_on_parsed,
11714 .help_str = "set macsec offload <port_id> on "
11715 "encrypt on|off replay-protect on|off",
11717 (void *)&cmd_macsec_offload_on_set,
11718 (void *)&cmd_macsec_offload_on_macsec,
11719 (void *)&cmd_macsec_offload_on_offload,
11720 (void *)&cmd_macsec_offload_on_port_id,
11721 (void *)&cmd_macsec_offload_on_on,
11722 (void *)&cmd_macsec_offload_on_encrypt,
11723 (void *)&cmd_macsec_offload_on_en_on_off,
11724 (void *)&cmd_macsec_offload_on_replay_protect,
11725 (void *)&cmd_macsec_offload_on_rp_on_off,
11730 /* Common result structure for MACsec offload disable */
11731 struct cmd_macsec_offload_off_result {
11732 cmdline_fixed_string_t set;
11733 cmdline_fixed_string_t macsec;
11734 cmdline_fixed_string_t offload;
11736 cmdline_fixed_string_t off;
11739 /* Common CLI fields for MACsec offload disable */
11740 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11741 TOKEN_STRING_INITIALIZER
11742 (struct cmd_macsec_offload_off_result,
11744 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11745 TOKEN_STRING_INITIALIZER
11746 (struct cmd_macsec_offload_off_result,
11748 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11749 TOKEN_STRING_INITIALIZER
11750 (struct cmd_macsec_offload_off_result,
11751 offload, "offload");
11752 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11753 TOKEN_NUM_INITIALIZER
11754 (struct cmd_macsec_offload_off_result,
11756 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11757 TOKEN_STRING_INITIALIZER
11758 (struct cmd_macsec_offload_off_result,
11762 cmd_set_macsec_offload_off_parsed(
11763 void *parsed_result,
11764 __attribute__((unused)) struct cmdline *cl,
11765 __attribute__((unused)) void *data)
11767 struct cmd_macsec_offload_off_result *res = parsed_result;
11769 portid_t port_id = res->port_id;
11771 if (port_id_is_invalid(port_id, ENABLED_WARN))
11774 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11775 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11781 printf("invalid port_id %d\n", port_id);
11784 printf("programming error: (%s)\n", strerror(-ret));
11788 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11789 .f = cmd_set_macsec_offload_off_parsed,
11791 .help_str = "set macsec offload <port_id> off",
11793 (void *)&cmd_macsec_offload_off_set,
11794 (void *)&cmd_macsec_offload_off_macsec,
11795 (void *)&cmd_macsec_offload_off_offload,
11796 (void *)&cmd_macsec_offload_off_port_id,
11797 (void *)&cmd_macsec_offload_off_off,
11802 /* Common result structure for MACsec secure connection configure */
11803 struct cmd_macsec_sc_result {
11804 cmdline_fixed_string_t set;
11805 cmdline_fixed_string_t macsec;
11806 cmdline_fixed_string_t sc;
11807 cmdline_fixed_string_t tx_rx;
11809 struct ether_addr mac;
11813 /* Common CLI fields for MACsec secure connection configure */
11814 cmdline_parse_token_string_t cmd_macsec_sc_set =
11815 TOKEN_STRING_INITIALIZER
11816 (struct cmd_macsec_sc_result,
11818 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11819 TOKEN_STRING_INITIALIZER
11820 (struct cmd_macsec_sc_result,
11822 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11823 TOKEN_STRING_INITIALIZER
11824 (struct cmd_macsec_sc_result,
11826 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11827 TOKEN_STRING_INITIALIZER
11828 (struct cmd_macsec_sc_result,
11830 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11831 TOKEN_NUM_INITIALIZER
11832 (struct cmd_macsec_sc_result,
11834 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11835 TOKEN_ETHERADDR_INITIALIZER
11836 (struct cmd_macsec_sc_result,
11838 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11839 TOKEN_NUM_INITIALIZER
11840 (struct cmd_macsec_sc_result,
11844 cmd_set_macsec_sc_parsed(
11845 void *parsed_result,
11846 __attribute__((unused)) struct cmdline *cl,
11847 __attribute__((unused)) void *data)
11849 struct cmd_macsec_sc_result *res = parsed_result;
11851 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11854 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11855 res->mac.addr_bytes) :
11856 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11857 res->mac.addr_bytes, res->pi);
11862 printf("invalid port_id %d\n", res->port_id);
11865 printf("programming error: (%s)\n", strerror(-ret));
11869 cmdline_parse_inst_t cmd_set_macsec_sc = {
11870 .f = cmd_set_macsec_sc_parsed,
11872 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11874 (void *)&cmd_macsec_sc_set,
11875 (void *)&cmd_macsec_sc_macsec,
11876 (void *)&cmd_macsec_sc_sc,
11877 (void *)&cmd_macsec_sc_tx_rx,
11878 (void *)&cmd_macsec_sc_port_id,
11879 (void *)&cmd_macsec_sc_mac,
11880 (void *)&cmd_macsec_sc_pi,
11885 /* Common result structure for MACsec secure connection configure */
11886 struct cmd_macsec_sa_result {
11887 cmdline_fixed_string_t set;
11888 cmdline_fixed_string_t macsec;
11889 cmdline_fixed_string_t sa;
11890 cmdline_fixed_string_t tx_rx;
11895 cmdline_fixed_string_t key;
11898 /* Common CLI fields for MACsec secure connection configure */
11899 cmdline_parse_token_string_t cmd_macsec_sa_set =
11900 TOKEN_STRING_INITIALIZER
11901 (struct cmd_macsec_sa_result,
11903 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11904 TOKEN_STRING_INITIALIZER
11905 (struct cmd_macsec_sa_result,
11907 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11908 TOKEN_STRING_INITIALIZER
11909 (struct cmd_macsec_sa_result,
11911 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11912 TOKEN_STRING_INITIALIZER
11913 (struct cmd_macsec_sa_result,
11915 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11916 TOKEN_NUM_INITIALIZER
11917 (struct cmd_macsec_sa_result,
11919 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11920 TOKEN_NUM_INITIALIZER
11921 (struct cmd_macsec_sa_result,
11923 cmdline_parse_token_num_t cmd_macsec_sa_an =
11924 TOKEN_NUM_INITIALIZER
11925 (struct cmd_macsec_sa_result,
11927 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11928 TOKEN_NUM_INITIALIZER
11929 (struct cmd_macsec_sa_result,
11931 cmdline_parse_token_string_t cmd_macsec_sa_key =
11932 TOKEN_STRING_INITIALIZER
11933 (struct cmd_macsec_sa_result,
11937 cmd_set_macsec_sa_parsed(
11938 void *parsed_result,
11939 __attribute__((unused)) struct cmdline *cl,
11940 __attribute__((unused)) void *data)
11942 struct cmd_macsec_sa_result *res = parsed_result;
11944 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11945 uint8_t key[16] = { 0 };
11951 key_len = strlen(res->key) / 2;
11955 for (i = 0; i < key_len; i++) {
11956 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11959 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11962 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11966 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11967 res->idx, res->an, res->pn, key) :
11968 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11969 res->idx, res->an, res->pn, key);
11974 printf("invalid idx %d or an %d\n", res->idx, res->an);
11977 printf("invalid port_id %d\n", res->port_id);
11980 printf("programming error: (%s)\n", strerror(-ret));
11984 cmdline_parse_inst_t cmd_set_macsec_sa = {
11985 .f = cmd_set_macsec_sa_parsed,
11987 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11989 (void *)&cmd_macsec_sa_set,
11990 (void *)&cmd_macsec_sa_macsec,
11991 (void *)&cmd_macsec_sa_sa,
11992 (void *)&cmd_macsec_sa_tx_rx,
11993 (void *)&cmd_macsec_sa_port_id,
11994 (void *)&cmd_macsec_sa_idx,
11995 (void *)&cmd_macsec_sa_an,
11996 (void *)&cmd_macsec_sa_pn,
11997 (void *)&cmd_macsec_sa_key,
12003 /* VF unicast promiscuous mode configuration */
12005 /* Common result structure for VF unicast promiscuous mode */
12006 struct cmd_vf_promisc_result {
12007 cmdline_fixed_string_t set;
12008 cmdline_fixed_string_t vf;
12009 cmdline_fixed_string_t promisc;
12012 cmdline_fixed_string_t on_off;
12015 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12016 cmdline_parse_token_string_t cmd_vf_promisc_set =
12017 TOKEN_STRING_INITIALIZER
12018 (struct cmd_vf_promisc_result,
12020 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12021 TOKEN_STRING_INITIALIZER
12022 (struct cmd_vf_promisc_result,
12024 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12025 TOKEN_STRING_INITIALIZER
12026 (struct cmd_vf_promisc_result,
12027 promisc, "promisc");
12028 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12029 TOKEN_NUM_INITIALIZER
12030 (struct cmd_vf_promisc_result,
12032 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12033 TOKEN_NUM_INITIALIZER
12034 (struct cmd_vf_promisc_result,
12036 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12037 TOKEN_STRING_INITIALIZER
12038 (struct cmd_vf_promisc_result,
12042 cmd_set_vf_promisc_parsed(
12043 void *parsed_result,
12044 __attribute__((unused)) struct cmdline *cl,
12045 __attribute__((unused)) void *data)
12047 struct cmd_vf_promisc_result *res = parsed_result;
12048 int ret = -ENOTSUP;
12050 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12052 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12055 #ifdef RTE_LIBRTE_I40E_PMD
12056 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12057 res->vf_id, is_on);
12064 printf("invalid vf_id %d\n", res->vf_id);
12067 printf("invalid port_id %d\n", res->port_id);
12070 printf("function not implemented\n");
12073 printf("programming error: (%s)\n", strerror(-ret));
12077 cmdline_parse_inst_t cmd_set_vf_promisc = {
12078 .f = cmd_set_vf_promisc_parsed,
12080 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12081 "Set unicast promiscuous mode for a VF from the PF",
12083 (void *)&cmd_vf_promisc_set,
12084 (void *)&cmd_vf_promisc_vf,
12085 (void *)&cmd_vf_promisc_promisc,
12086 (void *)&cmd_vf_promisc_port_id,
12087 (void *)&cmd_vf_promisc_vf_id,
12088 (void *)&cmd_vf_promisc_on_off,
12093 /* VF multicast promiscuous mode configuration */
12095 /* Common result structure for VF multicast promiscuous mode */
12096 struct cmd_vf_allmulti_result {
12097 cmdline_fixed_string_t set;
12098 cmdline_fixed_string_t vf;
12099 cmdline_fixed_string_t allmulti;
12102 cmdline_fixed_string_t on_off;
12105 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12106 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12107 TOKEN_STRING_INITIALIZER
12108 (struct cmd_vf_allmulti_result,
12110 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12111 TOKEN_STRING_INITIALIZER
12112 (struct cmd_vf_allmulti_result,
12114 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12115 TOKEN_STRING_INITIALIZER
12116 (struct cmd_vf_allmulti_result,
12117 allmulti, "allmulti");
12118 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12119 TOKEN_NUM_INITIALIZER
12120 (struct cmd_vf_allmulti_result,
12122 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12123 TOKEN_NUM_INITIALIZER
12124 (struct cmd_vf_allmulti_result,
12126 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12127 TOKEN_STRING_INITIALIZER
12128 (struct cmd_vf_allmulti_result,
12132 cmd_set_vf_allmulti_parsed(
12133 void *parsed_result,
12134 __attribute__((unused)) struct cmdline *cl,
12135 __attribute__((unused)) void *data)
12137 struct cmd_vf_allmulti_result *res = parsed_result;
12138 int ret = -ENOTSUP;
12140 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12145 #ifdef RTE_LIBRTE_I40E_PMD
12146 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12147 res->vf_id, is_on);
12154 printf("invalid vf_id %d\n", res->vf_id);
12157 printf("invalid port_id %d\n", res->port_id);
12160 printf("function not implemented\n");
12163 printf("programming error: (%s)\n", strerror(-ret));
12167 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12168 .f = cmd_set_vf_allmulti_parsed,
12170 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12171 "Set multicast promiscuous mode for a VF from the PF",
12173 (void *)&cmd_vf_allmulti_set,
12174 (void *)&cmd_vf_allmulti_vf,
12175 (void *)&cmd_vf_allmulti_allmulti,
12176 (void *)&cmd_vf_allmulti_port_id,
12177 (void *)&cmd_vf_allmulti_vf_id,
12178 (void *)&cmd_vf_allmulti_on_off,
12183 /* vf broadcast mode configuration */
12185 /* Common result structure for vf broadcast */
12186 struct cmd_set_vf_broadcast_result {
12187 cmdline_fixed_string_t set;
12188 cmdline_fixed_string_t vf;
12189 cmdline_fixed_string_t broadcast;
12192 cmdline_fixed_string_t on_off;
12195 /* Common CLI fields for vf broadcast enable disable */
12196 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12197 TOKEN_STRING_INITIALIZER
12198 (struct cmd_set_vf_broadcast_result,
12200 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12201 TOKEN_STRING_INITIALIZER
12202 (struct cmd_set_vf_broadcast_result,
12204 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12205 TOKEN_STRING_INITIALIZER
12206 (struct cmd_set_vf_broadcast_result,
12207 broadcast, "broadcast");
12208 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12209 TOKEN_NUM_INITIALIZER
12210 (struct cmd_set_vf_broadcast_result,
12212 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12213 TOKEN_NUM_INITIALIZER
12214 (struct cmd_set_vf_broadcast_result,
12216 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12217 TOKEN_STRING_INITIALIZER
12218 (struct cmd_set_vf_broadcast_result,
12222 cmd_set_vf_broadcast_parsed(
12223 void *parsed_result,
12224 __attribute__((unused)) struct cmdline *cl,
12225 __attribute__((unused)) void *data)
12227 struct cmd_set_vf_broadcast_result *res = parsed_result;
12228 int ret = -ENOTSUP;
12230 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12232 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12235 #ifdef RTE_LIBRTE_I40E_PMD
12236 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12237 res->vf_id, is_on);
12244 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12247 printf("invalid port_id %d\n", res->port_id);
12250 printf("function not implemented\n");
12253 printf("programming error: (%s)\n", strerror(-ret));
12257 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12258 .f = cmd_set_vf_broadcast_parsed,
12260 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12262 (void *)&cmd_set_vf_broadcast_set,
12263 (void *)&cmd_set_vf_broadcast_vf,
12264 (void *)&cmd_set_vf_broadcast_broadcast,
12265 (void *)&cmd_set_vf_broadcast_port_id,
12266 (void *)&cmd_set_vf_broadcast_vf_id,
12267 (void *)&cmd_set_vf_broadcast_on_off,
12272 /* vf vlan tag configuration */
12274 /* Common result structure for vf vlan tag */
12275 struct cmd_set_vf_vlan_tag_result {
12276 cmdline_fixed_string_t set;
12277 cmdline_fixed_string_t vf;
12278 cmdline_fixed_string_t vlan;
12279 cmdline_fixed_string_t tag;
12282 cmdline_fixed_string_t on_off;
12285 /* Common CLI fields for vf vlan tag enable disable */
12286 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12287 TOKEN_STRING_INITIALIZER
12288 (struct cmd_set_vf_vlan_tag_result,
12290 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12291 TOKEN_STRING_INITIALIZER
12292 (struct cmd_set_vf_vlan_tag_result,
12294 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12295 TOKEN_STRING_INITIALIZER
12296 (struct cmd_set_vf_vlan_tag_result,
12298 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12299 TOKEN_STRING_INITIALIZER
12300 (struct cmd_set_vf_vlan_tag_result,
12302 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12303 TOKEN_NUM_INITIALIZER
12304 (struct cmd_set_vf_vlan_tag_result,
12306 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12307 TOKEN_NUM_INITIALIZER
12308 (struct cmd_set_vf_vlan_tag_result,
12310 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12311 TOKEN_STRING_INITIALIZER
12312 (struct cmd_set_vf_vlan_tag_result,
12316 cmd_set_vf_vlan_tag_parsed(
12317 void *parsed_result,
12318 __attribute__((unused)) struct cmdline *cl,
12319 __attribute__((unused)) void *data)
12321 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12322 int ret = -ENOTSUP;
12324 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12326 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12329 #ifdef RTE_LIBRTE_I40E_PMD
12330 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12331 res->vf_id, is_on);
12338 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12341 printf("invalid port_id %d\n", res->port_id);
12344 printf("function not implemented\n");
12347 printf("programming error: (%s)\n", strerror(-ret));
12351 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12352 .f = cmd_set_vf_vlan_tag_parsed,
12354 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12356 (void *)&cmd_set_vf_vlan_tag_set,
12357 (void *)&cmd_set_vf_vlan_tag_vf,
12358 (void *)&cmd_set_vf_vlan_tag_vlan,
12359 (void *)&cmd_set_vf_vlan_tag_tag,
12360 (void *)&cmd_set_vf_vlan_tag_port_id,
12361 (void *)&cmd_set_vf_vlan_tag_vf_id,
12362 (void *)&cmd_set_vf_vlan_tag_on_off,
12367 /* ******************************************************************************** */
12369 /* list of instructions */
12370 cmdline_parse_ctx_t main_ctx[] = {
12371 (cmdline_parse_inst_t *)&cmd_help_brief,
12372 (cmdline_parse_inst_t *)&cmd_help_long,
12373 (cmdline_parse_inst_t *)&cmd_quit,
12374 (cmdline_parse_inst_t *)&cmd_showport,
12375 (cmdline_parse_inst_t *)&cmd_showqueue,
12376 (cmdline_parse_inst_t *)&cmd_showportall,
12377 (cmdline_parse_inst_t *)&cmd_showcfg,
12378 (cmdline_parse_inst_t *)&cmd_start,
12379 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12380 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12381 (cmdline_parse_inst_t *)&cmd_set_link_up,
12382 (cmdline_parse_inst_t *)&cmd_set_link_down,
12383 (cmdline_parse_inst_t *)&cmd_reset,
12384 (cmdline_parse_inst_t *)&cmd_set_numbers,
12385 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12386 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12387 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12388 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12389 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12390 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12391 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12392 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12393 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12394 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12395 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12396 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12397 (cmdline_parse_inst_t *)&cmd_set_link_check,
12398 #ifdef RTE_NIC_BYPASS
12399 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12400 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12401 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12402 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12404 #ifdef RTE_LIBRTE_PMD_BOND
12405 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12406 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12407 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12408 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12409 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12410 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12411 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12412 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12413 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12415 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12416 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12417 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12418 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12419 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12420 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12421 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12422 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12423 (cmdline_parse_inst_t *)&cmd_csum_set,
12424 (cmdline_parse_inst_t *)&cmd_csum_show,
12425 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12426 (cmdline_parse_inst_t *)&cmd_tso_set,
12427 (cmdline_parse_inst_t *)&cmd_tso_show,
12428 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12429 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12430 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12431 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12432 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12433 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12434 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12435 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12436 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12437 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12438 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12439 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12440 (cmdline_parse_inst_t *)&cmd_config_dcb,
12441 (cmdline_parse_inst_t *)&cmd_read_reg,
12442 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12443 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12444 (cmdline_parse_inst_t *)&cmd_write_reg,
12445 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12446 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12447 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12448 (cmdline_parse_inst_t *)&cmd_stop,
12449 (cmdline_parse_inst_t *)&cmd_mac_addr,
12450 (cmdline_parse_inst_t *)&cmd_set_qmap,
12451 (cmdline_parse_inst_t *)&cmd_operate_port,
12452 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12453 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12454 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12455 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12456 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12457 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12458 (cmdline_parse_inst_t *)&cmd_config_mtu,
12459 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12460 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12461 (cmdline_parse_inst_t *)&cmd_config_rss,
12462 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12463 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12464 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12465 (cmdline_parse_inst_t *)&cmd_showport_reta,
12466 (cmdline_parse_inst_t *)&cmd_config_burst,
12467 (cmdline_parse_inst_t *)&cmd_config_thresh,
12468 (cmdline_parse_inst_t *)&cmd_config_threshold,
12469 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12470 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12471 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12472 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12473 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12474 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12475 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12476 (cmdline_parse_inst_t *)&cmd_global_config,
12477 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12478 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12479 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12480 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12481 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12482 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12483 (cmdline_parse_inst_t *)&cmd_dump,
12484 (cmdline_parse_inst_t *)&cmd_dump_one,
12485 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12486 (cmdline_parse_inst_t *)&cmd_syn_filter,
12487 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12488 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12489 (cmdline_parse_inst_t *)&cmd_flex_filter,
12490 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12491 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12492 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12493 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12494 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12495 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12496 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12497 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12498 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12499 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12500 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12501 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12502 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12503 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12504 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12505 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12506 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12507 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12508 (cmdline_parse_inst_t *)&cmd_flow,
12509 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12510 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12511 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12512 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12513 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12514 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12515 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12516 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12517 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12518 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12519 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12520 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12521 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12522 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12523 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12524 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12525 #ifdef RTE_LIBRTE_IXGBE_PMD
12526 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12527 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12528 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12529 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12530 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12531 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12532 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12533 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12534 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12535 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12537 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12538 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12539 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12540 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
12541 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
12545 /* prompt function, called from main on MASTER lcore */
12549 /* initialize non-constant commands */
12550 cmd_set_fwd_mode_init();
12551 cmd_set_fwd_retry_mode_init();
12553 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12554 if (testpmd_cl == NULL)
12556 cmdline_interact(testpmd_cl);
12557 cmdline_stdin_exit(testpmd_cl);
12563 if (testpmd_cl != NULL)
12564 cmdline_quit(testpmd_cl);
12568 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12570 if (id == (portid_t)RTE_PORT_ALL) {
12573 FOREACH_PORT(pid, ports) {
12574 /* check if need_reconfig has been set to 1 */
12575 if (ports[pid].need_reconfig == 0)
12576 ports[pid].need_reconfig = dev;
12577 /* check if need_reconfig_queues has been set to 1 */
12578 if (ports[pid].need_reconfig_queues == 0)
12579 ports[pid].need_reconfig_queues = queue;
12581 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12582 /* check if need_reconfig has been set to 1 */
12583 if (ports[id].need_reconfig == 0)
12584 ports[id].need_reconfig = dev;
12585 /* check if need_reconfig_queues has been set to 1 */
12586 if (ports[id].need_reconfig_queues == 0)
12587 ports[id].need_reconfig_queues = queue;