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 "vlan set strip (on|off) (port_id)\n"
298 " Set the VLAN strip on a port.\n\n"
300 "vlan set stripq (on|off) (port_id,queue_id)\n"
301 " Set the VLAN strip for a queue on a port.\n\n"
303 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
304 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
306 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
307 " Set VLAN insert for a VF from the PF.\n\n"
309 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
310 " Set VLAN antispoof for a VF from the PF.\n\n"
312 "vlan set filter (on|off) (port_id)\n"
313 " Set the VLAN filter on a port.\n\n"
315 "vlan set qinq (on|off) (port_id)\n"
316 " Set the VLAN QinQ (extended queue in queue)"
319 "vlan set (inner|outer) tpid (value) (port_id)\n"
320 " Set the VLAN TPID for Packet Filtering on"
323 "rx_vlan add (vlan_id|all) (port_id)\n"
324 " Add a vlan_id, or all identifiers, to the set"
325 " of VLAN identifiers filtered by port_id.\n\n"
327 "rx_vlan rm (vlan_id|all) (port_id)\n"
328 " Remove a vlan_id, or all identifiers, from the set"
329 " of VLAN identifiers filtered by port_id.\n\n"
331 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
332 " Add a vlan_id, to the set of VLAN identifiers"
333 "filtered for VF(s) from port_id.\n\n"
335 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
336 " Remove a vlan_id, to the set of VLAN identifiers"
337 "filtered for VF(s) from port_id.\n\n"
339 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
340 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
341 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
342 " add a tunnel filter of a port.\n\n"
344 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
345 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
346 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
347 " remove a tunnel filter of a port.\n\n"
349 "rx_vxlan_port add (udp_port) (port_id)\n"
350 " Add an UDP port for VXLAN packet filter on a port\n\n"
352 "rx_vxlan_port rm (udp_port) (port_id)\n"
353 " Remove an UDP port for VXLAN packet filter on a port\n\n"
355 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
356 " Set hardware insertion of VLAN IDs (single or double VLAN "
357 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
359 "tx_vlan set pvid port_id vlan_id (on|off)\n"
360 " Set port based TX VLAN insertion.\n\n"
362 "tx_vlan reset (port_id)\n"
363 " Disable hardware insertion of a VLAN header in"
364 " packets sent on a port.\n\n"
366 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
367 " Select hardware or software calculation of the"
368 " checksum when transmitting a packet using the"
369 " csum forward engine.\n"
370 " ip|udp|tcp|sctp always concern the inner layer.\n"
371 " outer-ip concerns the outer IP layer in"
372 " case the packet is recognized as a tunnel packet by"
373 " the forward engine (vxlan, gre and ipip are supported)\n"
374 " Please check the NIC datasheet for HW limits.\n\n"
376 "csum parse-tunnel (on|off) (tx_port_id)\n"
377 " If disabled, treat tunnel packets as non-tunneled"
378 " packets (treat inner headers as payload). The port\n"
379 " argument is the port used for TX in csum forward"
382 "csum show (port_id)\n"
383 " Display tx checksum offload configuration\n\n"
385 "tso set (segsize) (portid)\n"
386 " Enable TCP Segmentation Offload in csum forward"
388 " Please check the NIC datasheet for HW limits.\n\n"
391 " Display the status of TCP Segmentation Offload.\n\n"
394 " Set packet forwarding mode.\n\n"
396 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
397 " Add a MAC address on port_id.\n\n"
399 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
400 " Remove a MAC address from port_id.\n\n"
402 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
403 " Add a MAC address for a VF on the port.\n\n"
405 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
406 " Set the MAC address for a VF from the PF.\n\n"
408 "set port (port_id) uta (mac_address|all) (on|off)\n"
409 " Add/Remove a or all unicast hash filter(s)"
412 "set promisc (port_id|all) (on|off)\n"
413 " Set the promiscuous mode on port_id, or all.\n\n"
415 "set allmulti (port_id|all) (on|off)\n"
416 " Set the allmulti mode on port_id, or all.\n\n"
418 "set vf promisc (port_id) (vf_id) (on|off)\n"
419 " Set unicast promiscuous mode for a VF from the PF.\n\n"
421 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
422 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
423 " (on|off) autoneg (on|off) (port_id)\n"
424 "set flow_ctrl rx (on|off) (portid)\n"
425 "set flow_ctrl tx (on|off) (portid)\n"
426 "set flow_ctrl high_water (high_water) (portid)\n"
427 "set flow_ctrl low_water (low_water) (portid)\n"
428 "set flow_ctrl pause_time (pause_time) (portid)\n"
429 "set flow_ctrl send_xon (send_xon) (portid)\n"
430 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
431 "set flow_ctrl autoneg (on|off) (port_id)\n"
432 " Set the link flow control parameter on a port.\n\n"
434 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
435 " (low_water) (pause_time) (priority) (port_id)\n"
436 " Set the priority flow control parameter on a"
439 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
440 " Set statistics mapping (qmapping 0..15) for RX/TX"
442 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
443 " on port 0 to mapping 5.\n\n"
445 "set port (port_id) vf (vf_id) rx|tx on|off\n"
446 " Enable/Disable a VF receive/tranmit from a port\n\n"
448 "set port (port_id) vf (vf_id) (mac_addr)"
449 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
450 " Add/Remove unicast or multicast MAC addr filter"
453 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
455 " AUPE:accepts untagged VLAN;"
456 "ROPE:accept unicast hash\n\n"
457 " BAM:accepts broadcast packets;"
458 "MPE:accepts all multicast packets\n\n"
459 " Enable/Disable a VF receive mode of a port\n\n"
461 "set port (port_id) queue (queue_id) rate (rate_num)\n"
462 " Set rate limit for a queue of a port\n\n"
464 "set port (port_id) vf (vf_id) rate (rate_num) "
465 "queue_mask (queue_mask_value)\n"
466 " Set rate limit for queues in VF of a port\n\n"
468 "set port (port_id) mirror-rule (rule_id)"
469 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
470 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
471 " Set pool or vlan type mirror rule on a port.\n"
472 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
473 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
476 "set port (port_id) mirror-rule (rule_id)"
477 " (uplink-mirror|downlink-mirror) dst-pool"
478 " (pool_id) (on|off)\n"
479 " Set uplink or downlink type mirror rule on a port.\n"
480 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
481 " 0 on' enable mirror income traffic to pool 0.\n\n"
483 "reset port (port_id) mirror-rule (rule_id)\n"
484 " Reset a mirror rule.\n\n"
486 "set flush_rx (on|off)\n"
487 " Flush (default) or don't flush RX streams before"
488 " forwarding. Mainly used with PCAP drivers.\n\n"
490 #ifdef RTE_NIC_BYPASS
491 "set bypass mode (normal|bypass|isolate) (port_id)\n"
492 " Set the bypass mode for the lowest port on bypass enabled"
495 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
496 "mode (normal|bypass|isolate) (port_id)\n"
497 " Set the event required to initiate specified bypass mode for"
498 " the lowest port on a bypass enabled NIC where:\n"
499 " timeout = enable bypass after watchdog timeout.\n"
500 " os_on = enable bypass when OS/board is powered on.\n"
501 " os_off = enable bypass when OS/board is powered off.\n"
502 " power_on = enable bypass when power supply is turned on.\n"
503 " power_off = enable bypass when power supply is turned off."
506 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
507 " Set the bypass watchdog timeout to 'n' seconds"
508 " where 0 = instant.\n\n"
510 "show bypass config (port_id)\n"
511 " Show the bypass configuration for a bypass enabled NIC"
512 " using the lowest port on the NIC.\n\n"
514 #ifdef RTE_LIBRTE_PMD_BOND
515 "create bonded device (mode) (socket)\n"
516 " Create a new bonded device with specific bonding mode and socket.\n\n"
518 "add bonding slave (slave_id) (port_id)\n"
519 " Add a slave device to a bonded device.\n\n"
521 "remove bonding slave (slave_id) (port_id)\n"
522 " Remove a slave device from a bonded device.\n\n"
524 "set bonding mode (value) (port_id)\n"
525 " Set the bonding mode on a bonded device.\n\n"
527 "set bonding primary (slave_id) (port_id)\n"
528 " Set the primary slave for a bonded device.\n\n"
530 "show bonding config (port_id)\n"
531 " Show the bonding config for port_id.\n\n"
533 "set bonding mac_addr (port_id) (address)\n"
534 " Set the MAC address of a bonded device.\n\n"
536 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
537 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
539 "set bonding mon_period (port_id) (value)\n"
540 " Set the bonding link status monitoring polling period in ms.\n\n"
542 "set link-up port (port_id)\n"
543 " Set link up for a port.\n\n"
545 "set link-down port (port_id)\n"
546 " Set link down for a port.\n\n"
548 "E-tag set insertion on port-tag-id (value)"
549 " port (port_id) vf (vf_id)\n"
550 " Enable E-tag insertion for a VF on a port\n\n"
552 "E-tag set insertion off port (port_id) vf (vf_id)\n"
553 " Disable E-tag insertion for a VF on a port\n\n"
555 "E-tag set stripping (on|off) port (port_id)\n"
556 " Enable/disable E-tag stripping on a port\n\n"
558 "E-tag set forwarding (on|off) port (port_id)\n"
559 " Enable/disable E-tag based forwarding"
562 "E-tag set filter add e-tag-id (value) dst-pool"
563 " (pool_id) port (port_id)\n"
564 " Add an E-tag forwarding filter on a port\n\n"
566 "E-tag set filter del e-tag-id (value) port (port_id)\n"
567 " Delete an E-tag forwarding filter on a port\n\n"
569 , list_pkt_forwarding_modes()
573 if (show_all || !strcmp(res->section, "ports")) {
579 "----------------\n\n"
581 "port start (port_id|all)\n"
582 " Start all ports or port_id.\n\n"
584 "port stop (port_id|all)\n"
585 " Stop all ports or port_id.\n\n"
587 "port close (port_id|all)\n"
588 " Close all ports or port_id.\n\n"
590 "port attach (ident)\n"
591 " Attach physical or virtual dev by pci address or virtual device name\n\n"
593 "port detach (port_id)\n"
594 " Detach physical or virtual dev by port_id\n\n"
596 "port config (port_id|all)"
597 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
598 " duplex (half|full|auto)\n"
599 " Set speed and duplex for all ports or port_id\n\n"
601 "port config all (rxq|txq|rxd|txd) (value)\n"
602 " Set number for rxq/txq/rxd/txd.\n\n"
604 "port config all max-pkt-len (value)\n"
605 " Set the max packet length.\n\n"
607 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
608 "hw-vlan-strip|hw-vlan-extend|drop-en)"
610 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
613 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
614 " Set the RSS mode.\n\n"
616 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
617 " Set the RSS redirection table.\n\n"
619 "port config (port_id) dcb vt (on|off) (traffic_class)"
621 " Set the DCB mode.\n\n"
623 "port config all burst (value)\n"
624 " Set the number of packets per burst.\n\n"
626 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
628 " Set the ring prefetch/host/writeback threshold"
629 " for tx/rx queue.\n\n"
631 "port config all (txfreet|txrst|rxfreet) (value)\n"
632 " Set free threshold for rx/tx, or set"
633 " tx rs bit threshold.\n\n"
634 "port config mtu X value\n"
635 " Set the MTU of port X to a given value\n\n"
637 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
638 " Start/stop a rx/tx queue of port X. Only take effect"
639 " when port X is started\n\n"
641 "port config (port_id|all) l2-tunnel E-tag ether-type"
643 " Set the value of E-tag ether-type.\n\n"
645 "port config (port_id|all) l2-tunnel E-tag"
646 " (enable|disable)\n"
647 " Enable/disable the E-tag support.\n\n"
651 if (show_all || !strcmp(res->section, "registers")) {
659 "read reg (port_id) (address)\n"
660 " Display value of a port register.\n\n"
662 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
663 " Display a port register bit field.\n\n"
665 "read regbit (port_id) (address) (bit_x)\n"
666 " Display a single port register bit.\n\n"
668 "write reg (port_id) (address) (value)\n"
669 " Set value of a port register.\n\n"
671 "write regfield (port_id) (address) (bit_x) (bit_y)"
673 " Set bit field of a port register.\n\n"
675 "write regbit (port_id) (address) (bit_x) (value)\n"
676 " Set single bit value of a port register.\n\n"
679 if (show_all || !strcmp(res->section, "filters")) {
687 "ethertype_filter (port_id) (add|del)"
688 " (mac_addr|mac_ignr) (mac_address) ethertype"
689 " (ether_type) (drop|fwd) queue (queue_id)\n"
690 " Add/Del an ethertype filter.\n\n"
692 "2tuple_filter (port_id) (add|del)"
693 " dst_port (dst_port_value) protocol (protocol_value)"
694 " mask (mask_value) tcp_flags (tcp_flags_value)"
695 " priority (prio_value) queue (queue_id)\n"
696 " Add/Del a 2tuple filter.\n\n"
698 "5tuple_filter (port_id) (add|del)"
699 " dst_ip (dst_address) src_ip (src_address)"
700 " dst_port (dst_port_value) src_port (src_port_value)"
701 " protocol (protocol_value)"
702 " mask (mask_value) tcp_flags (tcp_flags_value)"
703 " priority (prio_value) queue (queue_id)\n"
704 " Add/Del a 5tuple filter.\n\n"
706 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
707 " Add/Del syn filter.\n\n"
709 "flex_filter (port_id) (add|del) len (len_value)"
710 " bytes (bytes_value) mask (mask_value)"
711 " priority (prio_value) queue (queue_id)\n"
712 " Add/Del a flex filter.\n\n"
714 "flow_director_filter (port_id) mode IP (add|del|update)"
715 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
716 " src (src_ip_address) dst (dst_ip_address)"
717 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
718 " vlan (vlan_value) flexbytes (flexbytes_value)"
719 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
720 " fd_id (fd_id_value)\n"
721 " Add/Del an IP type flow director filter.\n\n"
723 "flow_director_filter (port_id) mode IP (add|del|update)"
724 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
725 " src (src_ip_address) (src_port)"
726 " dst (dst_ip_address) (dst_port)"
727 " tos (tos_value) ttl (ttl_value)"
728 " vlan (vlan_value) flexbytes (flexbytes_value)"
729 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
730 " fd_id (fd_id_value)\n"
731 " Add/Del an UDP/TCP type flow director filter.\n\n"
733 "flow_director_filter (port_id) mode IP (add|del|update)"
734 " flow (ipv4-sctp|ipv6-sctp)"
735 " src (src_ip_address) (src_port)"
736 " dst (dst_ip_address) (dst_port)"
737 " tag (verification_tag) "
738 " tos (tos_value) ttl (ttl_value)"
740 " flexbytes (flexbytes_value) (drop|fwd)"
741 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
742 " Add/Del a SCTP type flow director filter.\n\n"
744 "flow_director_filter (port_id) mode IP (add|del|update)"
745 " flow l2_payload ether (ethertype)"
746 " flexbytes (flexbytes_value) (drop|fwd)"
747 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
748 " Add/Del a l2 payload type flow director filter.\n\n"
750 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
751 " mac (mac_address) vlan (vlan_value)"
752 " flexbytes (flexbytes_value) (drop|fwd)"
753 " queue (queue_id) fd_id (fd_id_value)\n"
754 " Add/Del a MAC-VLAN flow director filter.\n\n"
756 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
757 " mac (mac_address) vlan (vlan_value)"
758 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
759 " flexbytes (flexbytes_value) (drop|fwd)"
760 " queue (queue_id) fd_id (fd_id_value)\n"
761 " Add/Del a Tunnel flow director filter.\n\n"
763 "flush_flow_director (port_id)\n"
764 " Flush all flow director entries of a device.\n\n"
766 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
767 " src_mask (ipv4_src) (ipv6_src) (src_port)"
768 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
769 " Set flow director IP mask.\n\n"
771 "flow_director_mask (port_id) mode MAC-VLAN"
772 " vlan (vlan_value)\n"
773 " Set flow director MAC-VLAN mask.\n\n"
775 "flow_director_mask (port_id) mode Tunnel"
776 " vlan (vlan_value) mac (mac_value)"
777 " tunnel-type (tunnel_type_value)"
778 " tunnel-id (tunnel_id_value)\n"
779 " Set flow director Tunnel mask.\n\n"
781 "flow_director_flex_mask (port_id)"
782 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
783 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
785 " Configure mask of flex payload.\n\n"
787 "flow_director_flex_payload (port_id)"
788 " (raw|l2|l3|l4) (config)\n"
789 " Configure flex payload selection.\n\n"
791 "get_sym_hash_ena_per_port (port_id)\n"
792 " get symmetric hash enable configuration per port.\n\n"
794 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
795 " set symmetric hash enable configuration per port"
796 " to enable or disable.\n\n"
798 "get_hash_global_config (port_id)\n"
799 " Get the global configurations of hash filters.\n\n"
801 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
802 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
803 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
804 " (enable|disable)\n"
805 " Set the global configurations of hash filters.\n\n"
807 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
808 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
809 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
810 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
811 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
812 "ipv6-next-header|udp-src-port|udp-dst-port|"
813 "tcp-src-port|tcp-dst-port|sctp-src-port|"
814 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
815 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
816 "fld-8th|none) (select|add)\n"
817 " Set the input set for hash.\n\n"
819 "set_fdir_input_set (port_id) "
820 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
821 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
822 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
823 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
824 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
825 "udp-dst-port|tcp-src-port|tcp-dst-port|"
826 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
828 " Set the input set for FDir.\n\n"
830 "flow validate {port_id}"
831 " [group {group_id}] [priority {level}]"
832 " [ingress] [egress]"
833 " pattern {item} [/ {item} [...]] / end"
834 " actions {action} [/ {action} [...]] / end\n"
835 " Check whether a flow rule can be created.\n\n"
837 "flow create {port_id}"
838 " [group {group_id}] [priority {level}]"
839 " [ingress] [egress]"
840 " pattern {item} [/ {item} [...]] / end"
841 " actions {action} [/ {action} [...]] / end\n"
842 " Create a flow rule.\n\n"
844 "flow destroy {port_id} rule {rule_id} [...]\n"
845 " Destroy specific flow rules.\n\n"
847 "flow flush {port_id}\n"
848 " Destroy all flow rules.\n\n"
850 "flow query {port_id} {rule_id} {action}\n"
851 " Query an existing flow rule.\n\n"
853 "flow list {port_id} [group {group_id}] [...]\n"
854 " List existing flow rules sorted by priority,"
855 " filtered by group identifiers.\n\n"
860 cmdline_parse_token_string_t cmd_help_long_help =
861 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
863 cmdline_parse_token_string_t cmd_help_long_section =
864 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
865 "all#control#display#config#"
866 "ports#registers#filters");
868 cmdline_parse_inst_t cmd_help_long = {
869 .f = cmd_help_long_parsed,
871 .help_str = "help all|control|display|config|ports|register|filters: "
874 (void *)&cmd_help_long_help,
875 (void *)&cmd_help_long_section,
881 /* *** start/stop/close all ports *** */
882 struct cmd_operate_port_result {
883 cmdline_fixed_string_t keyword;
884 cmdline_fixed_string_t name;
885 cmdline_fixed_string_t value;
888 static void cmd_operate_port_parsed(void *parsed_result,
889 __attribute__((unused)) struct cmdline *cl,
890 __attribute__((unused)) void *data)
892 struct cmd_operate_port_result *res = parsed_result;
894 if (!strcmp(res->name, "start"))
895 start_port(RTE_PORT_ALL);
896 else if (!strcmp(res->name, "stop"))
897 stop_port(RTE_PORT_ALL);
898 else if (!strcmp(res->name, "close"))
899 close_port(RTE_PORT_ALL);
901 printf("Unknown parameter\n");
904 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
905 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
907 cmdline_parse_token_string_t cmd_operate_port_all_port =
908 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
910 cmdline_parse_token_string_t cmd_operate_port_all_all =
911 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
913 cmdline_parse_inst_t cmd_operate_port = {
914 .f = cmd_operate_port_parsed,
916 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
918 (void *)&cmd_operate_port_all_cmd,
919 (void *)&cmd_operate_port_all_port,
920 (void *)&cmd_operate_port_all_all,
925 /* *** start/stop/close specific port *** */
926 struct cmd_operate_specific_port_result {
927 cmdline_fixed_string_t keyword;
928 cmdline_fixed_string_t name;
932 static void cmd_operate_specific_port_parsed(void *parsed_result,
933 __attribute__((unused)) struct cmdline *cl,
934 __attribute__((unused)) void *data)
936 struct cmd_operate_specific_port_result *res = parsed_result;
938 if (!strcmp(res->name, "start"))
939 start_port(res->value);
940 else if (!strcmp(res->name, "stop"))
941 stop_port(res->value);
942 else if (!strcmp(res->name, "close"))
943 close_port(res->value);
945 printf("Unknown parameter\n");
948 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
949 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
951 cmdline_parse_token_string_t cmd_operate_specific_port_port =
952 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
953 name, "start#stop#close");
954 cmdline_parse_token_num_t cmd_operate_specific_port_id =
955 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
958 cmdline_parse_inst_t cmd_operate_specific_port = {
959 .f = cmd_operate_specific_port_parsed,
961 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
963 (void *)&cmd_operate_specific_port_cmd,
964 (void *)&cmd_operate_specific_port_port,
965 (void *)&cmd_operate_specific_port_id,
970 /* *** attach a specified port *** */
971 struct cmd_operate_attach_port_result {
972 cmdline_fixed_string_t port;
973 cmdline_fixed_string_t keyword;
974 cmdline_fixed_string_t identifier;
977 static void cmd_operate_attach_port_parsed(void *parsed_result,
978 __attribute__((unused)) struct cmdline *cl,
979 __attribute__((unused)) void *data)
981 struct cmd_operate_attach_port_result *res = parsed_result;
983 if (!strcmp(res->keyword, "attach"))
984 attach_port(res->identifier);
986 printf("Unknown parameter\n");
989 cmdline_parse_token_string_t cmd_operate_attach_port_port =
990 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
992 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
993 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
995 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
996 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
999 cmdline_parse_inst_t cmd_operate_attach_port = {
1000 .f = cmd_operate_attach_port_parsed,
1002 .help_str = "port attach <identifier>: "
1003 "(identifier: pci address or virtual dev name)",
1005 (void *)&cmd_operate_attach_port_port,
1006 (void *)&cmd_operate_attach_port_keyword,
1007 (void *)&cmd_operate_attach_port_identifier,
1012 /* *** detach a specified port *** */
1013 struct cmd_operate_detach_port_result {
1014 cmdline_fixed_string_t port;
1015 cmdline_fixed_string_t keyword;
1019 static void cmd_operate_detach_port_parsed(void *parsed_result,
1020 __attribute__((unused)) struct cmdline *cl,
1021 __attribute__((unused)) void *data)
1023 struct cmd_operate_detach_port_result *res = parsed_result;
1025 if (!strcmp(res->keyword, "detach"))
1026 detach_port(res->port_id);
1028 printf("Unknown parameter\n");
1031 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1032 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1034 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1035 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1037 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1038 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1041 cmdline_parse_inst_t cmd_operate_detach_port = {
1042 .f = cmd_operate_detach_port_parsed,
1044 .help_str = "port detach <port_id>",
1046 (void *)&cmd_operate_detach_port_port,
1047 (void *)&cmd_operate_detach_port_keyword,
1048 (void *)&cmd_operate_detach_port_port_id,
1053 /* *** configure speed for all ports *** */
1054 struct cmd_config_speed_all {
1055 cmdline_fixed_string_t port;
1056 cmdline_fixed_string_t keyword;
1057 cmdline_fixed_string_t all;
1058 cmdline_fixed_string_t item1;
1059 cmdline_fixed_string_t item2;
1060 cmdline_fixed_string_t value1;
1061 cmdline_fixed_string_t value2;
1065 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1070 if (!strcmp(duplexstr, "half")) {
1071 duplex = ETH_LINK_HALF_DUPLEX;
1072 } else if (!strcmp(duplexstr, "full")) {
1073 duplex = ETH_LINK_FULL_DUPLEX;
1074 } else if (!strcmp(duplexstr, "auto")) {
1075 duplex = ETH_LINK_FULL_DUPLEX;
1077 printf("Unknown duplex parameter\n");
1081 if (!strcmp(speedstr, "10")) {
1082 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1083 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1084 } else if (!strcmp(speedstr, "100")) {
1085 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1086 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1088 if (duplex != ETH_LINK_FULL_DUPLEX) {
1089 printf("Invalid speed/duplex parameters\n");
1092 if (!strcmp(speedstr, "1000")) {
1093 *speed = ETH_LINK_SPEED_1G;
1094 } else if (!strcmp(speedstr, "10000")) {
1095 *speed = ETH_LINK_SPEED_10G;
1096 } else if (!strcmp(speedstr, "25000")) {
1097 *speed = ETH_LINK_SPEED_25G;
1098 } else if (!strcmp(speedstr, "40000")) {
1099 *speed = ETH_LINK_SPEED_40G;
1100 } else if (!strcmp(speedstr, "50000")) {
1101 *speed = ETH_LINK_SPEED_50G;
1102 } else if (!strcmp(speedstr, "100000")) {
1103 *speed = ETH_LINK_SPEED_100G;
1104 } else if (!strcmp(speedstr, "auto")) {
1105 *speed = ETH_LINK_SPEED_AUTONEG;
1107 printf("Unknown speed parameter\n");
1116 cmd_config_speed_all_parsed(void *parsed_result,
1117 __attribute__((unused)) struct cmdline *cl,
1118 __attribute__((unused)) void *data)
1120 struct cmd_config_speed_all *res = parsed_result;
1121 uint32_t link_speed;
1124 if (!all_ports_stopped()) {
1125 printf("Please stop all ports first\n");
1129 if (parse_and_check_speed_duplex(res->value1, res->value2,
1133 FOREACH_PORT(pid, ports) {
1134 ports[pid].dev_conf.link_speeds = link_speed;
1137 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1140 cmdline_parse_token_string_t cmd_config_speed_all_port =
1141 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1142 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1143 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1145 cmdline_parse_token_string_t cmd_config_speed_all_all =
1146 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1147 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1148 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1149 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1151 "10#100#1000#10000#25000#40000#50000#100000#auto");
1152 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1154 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1155 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1158 cmdline_parse_inst_t cmd_config_speed_all = {
1159 .f = cmd_config_speed_all_parsed,
1161 .help_str = "port config all speed "
1162 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1165 (void *)&cmd_config_speed_all_port,
1166 (void *)&cmd_config_speed_all_keyword,
1167 (void *)&cmd_config_speed_all_all,
1168 (void *)&cmd_config_speed_all_item1,
1169 (void *)&cmd_config_speed_all_value1,
1170 (void *)&cmd_config_speed_all_item2,
1171 (void *)&cmd_config_speed_all_value2,
1176 /* *** configure speed for specific port *** */
1177 struct cmd_config_speed_specific {
1178 cmdline_fixed_string_t port;
1179 cmdline_fixed_string_t keyword;
1181 cmdline_fixed_string_t item1;
1182 cmdline_fixed_string_t item2;
1183 cmdline_fixed_string_t value1;
1184 cmdline_fixed_string_t value2;
1188 cmd_config_speed_specific_parsed(void *parsed_result,
1189 __attribute__((unused)) struct cmdline *cl,
1190 __attribute__((unused)) void *data)
1192 struct cmd_config_speed_specific *res = parsed_result;
1193 uint32_t link_speed;
1195 if (!all_ports_stopped()) {
1196 printf("Please stop all ports first\n");
1200 if (port_id_is_invalid(res->id, ENABLED_WARN))
1203 if (parse_and_check_speed_duplex(res->value1, res->value2,
1207 ports[res->id].dev_conf.link_speeds = link_speed;
1209 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1213 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1214 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1216 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1217 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1219 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1220 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1221 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1222 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1224 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1225 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1226 "10#100#1000#10000#25000#40000#50000#100000#auto");
1227 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1230 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1231 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1234 cmdline_parse_inst_t cmd_config_speed_specific = {
1235 .f = cmd_config_speed_specific_parsed,
1237 .help_str = "port config <port_id> speed "
1238 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1241 (void *)&cmd_config_speed_specific_port,
1242 (void *)&cmd_config_speed_specific_keyword,
1243 (void *)&cmd_config_speed_specific_id,
1244 (void *)&cmd_config_speed_specific_item1,
1245 (void *)&cmd_config_speed_specific_value1,
1246 (void *)&cmd_config_speed_specific_item2,
1247 (void *)&cmd_config_speed_specific_value2,
1252 /* *** configure txq/rxq, txd/rxd *** */
1253 struct cmd_config_rx_tx {
1254 cmdline_fixed_string_t port;
1255 cmdline_fixed_string_t keyword;
1256 cmdline_fixed_string_t all;
1257 cmdline_fixed_string_t name;
1262 cmd_config_rx_tx_parsed(void *parsed_result,
1263 __attribute__((unused)) struct cmdline *cl,
1264 __attribute__((unused)) void *data)
1266 struct cmd_config_rx_tx *res = parsed_result;
1268 if (!all_ports_stopped()) {
1269 printf("Please stop all ports first\n");
1272 if (!strcmp(res->name, "rxq")) {
1273 if (!res->value && !nb_txq) {
1274 printf("Warning: Either rx or tx queues should be non zero\n");
1277 nb_rxq = res->value;
1279 else if (!strcmp(res->name, "txq")) {
1280 if (!res->value && !nb_rxq) {
1281 printf("Warning: Either rx or tx queues should be non zero\n");
1284 nb_txq = res->value;
1286 else if (!strcmp(res->name, "rxd")) {
1287 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1288 printf("rxd %d invalid - must be > 0 && <= %d\n",
1289 res->value, RTE_TEST_RX_DESC_MAX);
1292 nb_rxd = res->value;
1293 } else if (!strcmp(res->name, "txd")) {
1294 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1295 printf("txd %d invalid - must be > 0 && <= %d\n",
1296 res->value, RTE_TEST_TX_DESC_MAX);
1299 nb_txd = res->value;
1301 printf("Unknown parameter\n");
1309 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1312 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1313 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1314 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1315 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1316 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1317 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1318 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1319 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1321 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1322 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1324 cmdline_parse_inst_t cmd_config_rx_tx = {
1325 .f = cmd_config_rx_tx_parsed,
1327 .help_str = "port config all rxq|txq|rxd|txd <value>",
1329 (void *)&cmd_config_rx_tx_port,
1330 (void *)&cmd_config_rx_tx_keyword,
1331 (void *)&cmd_config_rx_tx_all,
1332 (void *)&cmd_config_rx_tx_name,
1333 (void *)&cmd_config_rx_tx_value,
1338 /* *** config max packet length *** */
1339 struct cmd_config_max_pkt_len_result {
1340 cmdline_fixed_string_t port;
1341 cmdline_fixed_string_t keyword;
1342 cmdline_fixed_string_t all;
1343 cmdline_fixed_string_t name;
1348 cmd_config_max_pkt_len_parsed(void *parsed_result,
1349 __attribute__((unused)) struct cmdline *cl,
1350 __attribute__((unused)) void *data)
1352 struct cmd_config_max_pkt_len_result *res = parsed_result;
1354 if (!all_ports_stopped()) {
1355 printf("Please stop all ports first\n");
1359 if (!strcmp(res->name, "max-pkt-len")) {
1360 if (res->value < ETHER_MIN_LEN) {
1361 printf("max-pkt-len can not be less than %d\n",
1365 if (res->value == rx_mode.max_rx_pkt_len)
1368 rx_mode.max_rx_pkt_len = res->value;
1369 if (res->value > ETHER_MAX_LEN)
1370 rx_mode.jumbo_frame = 1;
1372 rx_mode.jumbo_frame = 0;
1374 printf("Unknown parameter\n");
1380 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1383 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1384 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1386 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1389 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1392 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1395 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1396 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1399 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1400 .f = cmd_config_max_pkt_len_parsed,
1402 .help_str = "port config all max-pkt-len <value>",
1404 (void *)&cmd_config_max_pkt_len_port,
1405 (void *)&cmd_config_max_pkt_len_keyword,
1406 (void *)&cmd_config_max_pkt_len_all,
1407 (void *)&cmd_config_max_pkt_len_name,
1408 (void *)&cmd_config_max_pkt_len_value,
1413 /* *** configure port MTU *** */
1414 struct cmd_config_mtu_result {
1415 cmdline_fixed_string_t port;
1416 cmdline_fixed_string_t keyword;
1417 cmdline_fixed_string_t mtu;
1423 cmd_config_mtu_parsed(void *parsed_result,
1424 __attribute__((unused)) struct cmdline *cl,
1425 __attribute__((unused)) void *data)
1427 struct cmd_config_mtu_result *res = parsed_result;
1429 if (res->value < ETHER_MIN_LEN) {
1430 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1433 port_mtu_set(res->port_id, res->value);
1436 cmdline_parse_token_string_t cmd_config_mtu_port =
1437 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1439 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1440 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1442 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1445 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1446 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1447 cmdline_parse_token_num_t cmd_config_mtu_value =
1448 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1450 cmdline_parse_inst_t cmd_config_mtu = {
1451 .f = cmd_config_mtu_parsed,
1453 .help_str = "port config mtu <port_id> <value>",
1455 (void *)&cmd_config_mtu_port,
1456 (void *)&cmd_config_mtu_keyword,
1457 (void *)&cmd_config_mtu_mtu,
1458 (void *)&cmd_config_mtu_port_id,
1459 (void *)&cmd_config_mtu_value,
1464 /* *** configure rx mode *** */
1465 struct cmd_config_rx_mode_flag {
1466 cmdline_fixed_string_t port;
1467 cmdline_fixed_string_t keyword;
1468 cmdline_fixed_string_t all;
1469 cmdline_fixed_string_t name;
1470 cmdline_fixed_string_t value;
1474 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1475 __attribute__((unused)) struct cmdline *cl,
1476 __attribute__((unused)) void *data)
1478 struct cmd_config_rx_mode_flag *res = parsed_result;
1480 if (!all_ports_stopped()) {
1481 printf("Please stop all ports first\n");
1485 if (!strcmp(res->name, "crc-strip")) {
1486 if (!strcmp(res->value, "on"))
1487 rx_mode.hw_strip_crc = 1;
1488 else if (!strcmp(res->value, "off"))
1489 rx_mode.hw_strip_crc = 0;
1491 printf("Unknown parameter\n");
1494 } else if (!strcmp(res->name, "scatter")) {
1495 if (!strcmp(res->value, "on"))
1496 rx_mode.enable_scatter = 1;
1497 else if (!strcmp(res->value, "off"))
1498 rx_mode.enable_scatter = 0;
1500 printf("Unknown parameter\n");
1503 } else if (!strcmp(res->name, "rx-cksum")) {
1504 if (!strcmp(res->value, "on"))
1505 rx_mode.hw_ip_checksum = 1;
1506 else if (!strcmp(res->value, "off"))
1507 rx_mode.hw_ip_checksum = 0;
1509 printf("Unknown parameter\n");
1512 } else if (!strcmp(res->name, "hw-vlan")) {
1513 if (!strcmp(res->value, "on")) {
1514 rx_mode.hw_vlan_filter = 1;
1515 rx_mode.hw_vlan_strip = 1;
1517 else if (!strcmp(res->value, "off")) {
1518 rx_mode.hw_vlan_filter = 0;
1519 rx_mode.hw_vlan_strip = 0;
1522 printf("Unknown parameter\n");
1525 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1526 if (!strcmp(res->value, "on"))
1527 rx_mode.hw_vlan_filter = 1;
1528 else if (!strcmp(res->value, "off"))
1529 rx_mode.hw_vlan_filter = 0;
1531 printf("Unknown parameter\n");
1534 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1535 if (!strcmp(res->value, "on"))
1536 rx_mode.hw_vlan_strip = 1;
1537 else if (!strcmp(res->value, "off"))
1538 rx_mode.hw_vlan_strip = 0;
1540 printf("Unknown parameter\n");
1543 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1544 if (!strcmp(res->value, "on"))
1545 rx_mode.hw_vlan_extend = 1;
1546 else if (!strcmp(res->value, "off"))
1547 rx_mode.hw_vlan_extend = 0;
1549 printf("Unknown parameter\n");
1552 } else if (!strcmp(res->name, "drop-en")) {
1553 if (!strcmp(res->value, "on"))
1555 else if (!strcmp(res->value, "off"))
1558 printf("Unknown parameter\n");
1562 printf("Unknown parameter\n");
1568 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1571 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1573 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1576 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1578 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1579 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1580 "crc-strip#scatter#rx-cksum#hw-vlan#"
1581 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1582 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1586 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1587 .f = cmd_config_rx_mode_flag_parsed,
1589 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1590 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1592 (void *)&cmd_config_rx_mode_flag_port,
1593 (void *)&cmd_config_rx_mode_flag_keyword,
1594 (void *)&cmd_config_rx_mode_flag_all,
1595 (void *)&cmd_config_rx_mode_flag_name,
1596 (void *)&cmd_config_rx_mode_flag_value,
1601 /* *** configure rss *** */
1602 struct cmd_config_rss {
1603 cmdline_fixed_string_t port;
1604 cmdline_fixed_string_t keyword;
1605 cmdline_fixed_string_t all;
1606 cmdline_fixed_string_t name;
1607 cmdline_fixed_string_t value;
1611 cmd_config_rss_parsed(void *parsed_result,
1612 __attribute__((unused)) struct cmdline *cl,
1613 __attribute__((unused)) void *data)
1615 struct cmd_config_rss *res = parsed_result;
1616 struct rte_eth_rss_conf rss_conf;
1620 if (!strcmp(res->value, "all"))
1621 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1622 ETH_RSS_UDP | ETH_RSS_SCTP |
1624 else if (!strcmp(res->value, "ip"))
1625 rss_conf.rss_hf = ETH_RSS_IP;
1626 else if (!strcmp(res->value, "udp"))
1627 rss_conf.rss_hf = ETH_RSS_UDP;
1628 else if (!strcmp(res->value, "tcp"))
1629 rss_conf.rss_hf = ETH_RSS_TCP;
1630 else if (!strcmp(res->value, "sctp"))
1631 rss_conf.rss_hf = ETH_RSS_SCTP;
1632 else if (!strcmp(res->value, "ether"))
1633 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1634 else if (!strcmp(res->value, "port"))
1635 rss_conf.rss_hf = ETH_RSS_PORT;
1636 else if (!strcmp(res->value, "vxlan"))
1637 rss_conf.rss_hf = ETH_RSS_VXLAN;
1638 else if (!strcmp(res->value, "geneve"))
1639 rss_conf.rss_hf = ETH_RSS_GENEVE;
1640 else if (!strcmp(res->value, "nvgre"))
1641 rss_conf.rss_hf = ETH_RSS_NVGRE;
1642 else if (!strcmp(res->value, "none"))
1643 rss_conf.rss_hf = 0;
1645 printf("Unknown parameter\n");
1648 rss_conf.rss_key = NULL;
1649 for (i = 0; i < rte_eth_dev_count(); i++) {
1650 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1652 printf("Configuration of RSS hash at ethernet port %d "
1653 "failed with error (%d): %s.\n",
1654 i, -diag, strerror(-diag));
1658 cmdline_parse_token_string_t cmd_config_rss_port =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1660 cmdline_parse_token_string_t cmd_config_rss_keyword =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1662 cmdline_parse_token_string_t cmd_config_rss_all =
1663 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1664 cmdline_parse_token_string_t cmd_config_rss_name =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1666 cmdline_parse_token_string_t cmd_config_rss_value =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1668 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1670 cmdline_parse_inst_t cmd_config_rss = {
1671 .f = cmd_config_rss_parsed,
1673 .help_str = "port config all rss "
1674 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1676 (void *)&cmd_config_rss_port,
1677 (void *)&cmd_config_rss_keyword,
1678 (void *)&cmd_config_rss_all,
1679 (void *)&cmd_config_rss_name,
1680 (void *)&cmd_config_rss_value,
1685 /* *** configure rss hash key *** */
1686 struct cmd_config_rss_hash_key {
1687 cmdline_fixed_string_t port;
1688 cmdline_fixed_string_t config;
1690 cmdline_fixed_string_t rss_hash_key;
1691 cmdline_fixed_string_t rss_type;
1692 cmdline_fixed_string_t key;
1696 hexa_digit_to_value(char hexa_digit)
1698 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1699 return (uint8_t) (hexa_digit - '0');
1700 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1701 return (uint8_t) ((hexa_digit - 'a') + 10);
1702 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1703 return (uint8_t) ((hexa_digit - 'A') + 10);
1704 /* Invalid hexa digit */
1709 parse_and_check_key_hexa_digit(char *key, int idx)
1713 hexa_v = hexa_digit_to_value(key[idx]);
1715 printf("invalid key: character %c at position %d is not a "
1716 "valid hexa digit\n", key[idx], idx);
1721 cmd_config_rss_hash_key_parsed(void *parsed_result,
1722 __attribute__((unused)) struct cmdline *cl,
1723 __attribute__((unused)) void *data)
1725 struct cmd_config_rss_hash_key *res = parsed_result;
1726 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1730 struct rte_eth_dev_info dev_info;
1731 uint8_t hash_key_size;
1734 memset(&dev_info, 0, sizeof(dev_info));
1735 rte_eth_dev_info_get(res->port_id, &dev_info);
1736 if (dev_info.hash_key_size > 0 &&
1737 dev_info.hash_key_size <= sizeof(hash_key))
1738 hash_key_size = dev_info.hash_key_size;
1740 printf("dev_info did not provide a valid hash key size\n");
1743 /* Check the length of the RSS hash key */
1744 key_len = strlen(res->key);
1745 if (key_len != (hash_key_size * 2)) {
1746 printf("key length: %d invalid - key must be a string of %d"
1747 " hexa-decimal numbers\n",
1748 (int) key_len, hash_key_size * 2);
1751 /* Translate RSS hash key into binary representation */
1752 for (i = 0; i < hash_key_size; i++) {
1753 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1756 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1759 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1761 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1765 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1767 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1768 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1770 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1771 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1772 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1774 rss_hash_key, "rss-hash-key");
1775 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1777 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1778 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1779 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1780 "ipv6-tcp-ex#ipv6-udp-ex");
1781 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1784 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1785 .f = cmd_config_rss_hash_key_parsed,
1787 .help_str = "port config <port_id> rss-hash-key "
1788 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1789 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1790 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1791 "<string of hex digits (variable length, NIC dependent)>",
1793 (void *)&cmd_config_rss_hash_key_port,
1794 (void *)&cmd_config_rss_hash_key_config,
1795 (void *)&cmd_config_rss_hash_key_port_id,
1796 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1797 (void *)&cmd_config_rss_hash_key_rss_type,
1798 (void *)&cmd_config_rss_hash_key_value,
1803 /* *** configure port rxq/txq start/stop *** */
1804 struct cmd_config_rxtx_queue {
1805 cmdline_fixed_string_t port;
1807 cmdline_fixed_string_t rxtxq;
1809 cmdline_fixed_string_t opname;
1813 cmd_config_rxtx_queue_parsed(void *parsed_result,
1814 __attribute__((unused)) struct cmdline *cl,
1815 __attribute__((unused)) void *data)
1817 struct cmd_config_rxtx_queue *res = parsed_result;
1822 if (test_done == 0) {
1823 printf("Please stop forwarding first\n");
1827 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1830 if (port_is_started(res->portid) != 1) {
1831 printf("Please start port %u first\n", res->portid);
1835 if (!strcmp(res->rxtxq, "rxq"))
1837 else if (!strcmp(res->rxtxq, "txq"))
1840 printf("Unknown parameter\n");
1844 if (isrx && rx_queue_id_is_invalid(res->qid))
1846 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1849 if (!strcmp(res->opname, "start"))
1851 else if (!strcmp(res->opname, "stop"))
1854 printf("Unknown parameter\n");
1858 if (isstart && isrx)
1859 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1860 else if (!isstart && isrx)
1861 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1862 else if (isstart && !isrx)
1863 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1865 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1867 if (ret == -ENOTSUP)
1868 printf("Function not supported in PMD driver\n");
1871 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1872 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1873 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1874 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1875 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1876 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1877 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1878 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1879 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1880 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1883 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1884 .f = cmd_config_rxtx_queue_parsed,
1886 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1888 (void *)&cmd_config_speed_all_port,
1889 (void *)&cmd_config_rxtx_queue_portid,
1890 (void *)&cmd_config_rxtx_queue_rxtxq,
1891 (void *)&cmd_config_rxtx_queue_qid,
1892 (void *)&cmd_config_rxtx_queue_opname,
1897 /* *** Configure RSS RETA *** */
1898 struct cmd_config_rss_reta {
1899 cmdline_fixed_string_t port;
1900 cmdline_fixed_string_t keyword;
1902 cmdline_fixed_string_t name;
1903 cmdline_fixed_string_t list_name;
1904 cmdline_fixed_string_t list_of_items;
1908 parse_reta_config(const char *str,
1909 struct rte_eth_rss_reta_entry64 *reta_conf,
1910 uint16_t nb_entries)
1914 uint16_t hash_index, idx, shift;
1917 const char *p, *p0 = str;
1924 unsigned long int_fld[_NUM_FLD];
1925 char *str_fld[_NUM_FLD];
1927 while ((p = strchr(p0,'(')) != NULL) {
1929 if((p0 = strchr(p,')')) == NULL)
1933 if(size >= sizeof(s))
1936 snprintf(s, sizeof(s), "%.*s", size, p);
1937 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1939 for (i = 0; i < _NUM_FLD; i++) {
1941 int_fld[i] = strtoul(str_fld[i], &end, 0);
1942 if (errno != 0 || end == str_fld[i] ||
1947 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1948 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1950 if (hash_index >= nb_entries) {
1951 printf("Invalid RETA hash index=%d\n", hash_index);
1955 idx = hash_index / RTE_RETA_GROUP_SIZE;
1956 shift = hash_index % RTE_RETA_GROUP_SIZE;
1957 reta_conf[idx].mask |= (1ULL << shift);
1958 reta_conf[idx].reta[shift] = nb_queue;
1965 cmd_set_rss_reta_parsed(void *parsed_result,
1966 __attribute__((unused)) struct cmdline *cl,
1967 __attribute__((unused)) void *data)
1970 struct rte_eth_dev_info dev_info;
1971 struct rte_eth_rss_reta_entry64 reta_conf[8];
1972 struct cmd_config_rss_reta *res = parsed_result;
1974 memset(&dev_info, 0, sizeof(dev_info));
1975 rte_eth_dev_info_get(res->port_id, &dev_info);
1976 if (dev_info.reta_size == 0) {
1977 printf("Redirection table size is 0 which is "
1978 "invalid for RSS\n");
1981 printf("The reta size of port %d is %u\n",
1982 res->port_id, dev_info.reta_size);
1983 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1984 printf("Currently do not support more than %u entries of "
1985 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1989 memset(reta_conf, 0, sizeof(reta_conf));
1990 if (!strcmp(res->list_name, "reta")) {
1991 if (parse_reta_config(res->list_of_items, reta_conf,
1992 dev_info.reta_size)) {
1993 printf("Invalid RSS Redirection Table "
1994 "config entered\n");
1997 ret = rte_eth_dev_rss_reta_update(res->port_id,
1998 reta_conf, dev_info.reta_size);
2000 printf("Bad redirection table parameter, "
2001 "return code = %d \n", ret);
2005 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2007 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2009 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2010 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2011 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2012 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2013 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2015 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2016 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2018 cmdline_parse_inst_t cmd_config_rss_reta = {
2019 .f = cmd_set_rss_reta_parsed,
2021 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2023 (void *)&cmd_config_rss_reta_port,
2024 (void *)&cmd_config_rss_reta_keyword,
2025 (void *)&cmd_config_rss_reta_port_id,
2026 (void *)&cmd_config_rss_reta_name,
2027 (void *)&cmd_config_rss_reta_list_name,
2028 (void *)&cmd_config_rss_reta_list_of_items,
2033 /* *** SHOW PORT RETA INFO *** */
2034 struct cmd_showport_reta {
2035 cmdline_fixed_string_t show;
2036 cmdline_fixed_string_t port;
2038 cmdline_fixed_string_t rss;
2039 cmdline_fixed_string_t reta;
2041 cmdline_fixed_string_t list_of_items;
2045 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2046 uint16_t nb_entries,
2050 const char *p, *p0 = str;
2054 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2057 p = strchr(p0, '(');
2061 p0 = strchr(p, ')');
2065 if (size >= sizeof(s)) {
2066 printf("The string size exceeds the internal buffer size\n");
2069 snprintf(s, sizeof(s), "%.*s", size, p);
2070 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2071 if (ret <= 0 || ret != num) {
2072 printf("The bits of masks do not match the number of "
2073 "reta entries: %u\n", num);
2076 for (i = 0; i < ret; i++)
2077 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2083 cmd_showport_reta_parsed(void *parsed_result,
2084 __attribute__((unused)) struct cmdline *cl,
2085 __attribute__((unused)) void *data)
2087 struct cmd_showport_reta *res = parsed_result;
2088 struct rte_eth_rss_reta_entry64 reta_conf[8];
2089 struct rte_eth_dev_info dev_info;
2091 memset(&dev_info, 0, sizeof(dev_info));
2092 rte_eth_dev_info_get(res->port_id, &dev_info);
2093 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2094 res->size > ETH_RSS_RETA_SIZE_512) {
2095 printf("Invalid redirection table size: %u\n", res->size);
2099 memset(reta_conf, 0, sizeof(reta_conf));
2100 if (showport_parse_reta_config(reta_conf, res->size,
2101 res->list_of_items) < 0) {
2102 printf("Invalid string: %s for reta masks\n",
2103 res->list_of_items);
2106 port_rss_reta_info(res->port_id, reta_conf, res->size);
2109 cmdline_parse_token_string_t cmd_showport_reta_show =
2110 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2111 cmdline_parse_token_string_t cmd_showport_reta_port =
2112 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2113 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2114 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2115 cmdline_parse_token_string_t cmd_showport_reta_rss =
2116 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2117 cmdline_parse_token_string_t cmd_showport_reta_reta =
2118 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2119 cmdline_parse_token_num_t cmd_showport_reta_size =
2120 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2121 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2122 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2123 list_of_items, NULL);
2125 cmdline_parse_inst_t cmd_showport_reta = {
2126 .f = cmd_showport_reta_parsed,
2128 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2130 (void *)&cmd_showport_reta_show,
2131 (void *)&cmd_showport_reta_port,
2132 (void *)&cmd_showport_reta_port_id,
2133 (void *)&cmd_showport_reta_rss,
2134 (void *)&cmd_showport_reta_reta,
2135 (void *)&cmd_showport_reta_size,
2136 (void *)&cmd_showport_reta_list_of_items,
2141 /* *** Show RSS hash configuration *** */
2142 struct cmd_showport_rss_hash {
2143 cmdline_fixed_string_t show;
2144 cmdline_fixed_string_t port;
2146 cmdline_fixed_string_t rss_hash;
2147 cmdline_fixed_string_t rss_type;
2148 cmdline_fixed_string_t key; /* optional argument */
2151 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2152 __attribute__((unused)) struct cmdline *cl,
2155 struct cmd_showport_rss_hash *res = parsed_result;
2157 port_rss_hash_conf_show(res->port_id, res->rss_type,
2158 show_rss_key != NULL);
2161 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2162 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2163 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2164 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2165 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2166 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2167 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2168 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2170 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2171 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2172 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2173 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2174 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2175 "ipv6-tcp-ex#ipv6-udp-ex");
2176 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2177 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2179 cmdline_parse_inst_t cmd_showport_rss_hash = {
2180 .f = cmd_showport_rss_hash_parsed,
2182 .help_str = "show port <port_id> rss-hash "
2183 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2184 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2185 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2187 (void *)&cmd_showport_rss_hash_show,
2188 (void *)&cmd_showport_rss_hash_port,
2189 (void *)&cmd_showport_rss_hash_port_id,
2190 (void *)&cmd_showport_rss_hash_rss_hash,
2191 (void *)&cmd_showport_rss_hash_rss_hash_info,
2196 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2197 .f = cmd_showport_rss_hash_parsed,
2199 .help_str = "show port <port_id> rss-hash "
2200 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2201 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2202 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2204 (void *)&cmd_showport_rss_hash_show,
2205 (void *)&cmd_showport_rss_hash_port,
2206 (void *)&cmd_showport_rss_hash_port_id,
2207 (void *)&cmd_showport_rss_hash_rss_hash,
2208 (void *)&cmd_showport_rss_hash_rss_hash_info,
2209 (void *)&cmd_showport_rss_hash_rss_key,
2214 /* *** Configure DCB *** */
2215 struct cmd_config_dcb {
2216 cmdline_fixed_string_t port;
2217 cmdline_fixed_string_t config;
2219 cmdline_fixed_string_t dcb;
2220 cmdline_fixed_string_t vt;
2221 cmdline_fixed_string_t vt_en;
2223 cmdline_fixed_string_t pfc;
2224 cmdline_fixed_string_t pfc_en;
2228 cmd_config_dcb_parsed(void *parsed_result,
2229 __attribute__((unused)) struct cmdline *cl,
2230 __attribute__((unused)) void *data)
2232 struct cmd_config_dcb *res = parsed_result;
2233 portid_t port_id = res->port_id;
2234 struct rte_port *port;
2238 port = &ports[port_id];
2239 /** Check if the port is not started **/
2240 if (port->port_status != RTE_PORT_STOPPED) {
2241 printf("Please stop port %d first\n", port_id);
2245 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2246 printf("The invalid number of traffic class,"
2247 " only 4 or 8 allowed.\n");
2251 if (nb_fwd_lcores < res->num_tcs) {
2252 printf("nb_cores shouldn't be less than number of TCs.\n");
2255 if (!strncmp(res->pfc_en, "on", 2))
2260 /* DCB in VT mode */
2261 if (!strncmp(res->vt_en, "on", 2))
2262 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2263 (enum rte_eth_nb_tcs)res->num_tcs,
2266 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2267 (enum rte_eth_nb_tcs)res->num_tcs,
2272 printf("Cannot initialize network ports.\n");
2276 cmd_reconfig_device_queue(port_id, 1, 1);
2279 cmdline_parse_token_string_t cmd_config_dcb_port =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2281 cmdline_parse_token_string_t cmd_config_dcb_config =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2283 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2284 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2285 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2287 cmdline_parse_token_string_t cmd_config_dcb_vt =
2288 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2289 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2290 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2291 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2292 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2293 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2294 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2295 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2296 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2298 cmdline_parse_inst_t cmd_config_dcb = {
2299 .f = cmd_config_dcb_parsed,
2301 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2303 (void *)&cmd_config_dcb_port,
2304 (void *)&cmd_config_dcb_config,
2305 (void *)&cmd_config_dcb_port_id,
2306 (void *)&cmd_config_dcb_dcb,
2307 (void *)&cmd_config_dcb_vt,
2308 (void *)&cmd_config_dcb_vt_en,
2309 (void *)&cmd_config_dcb_num_tcs,
2310 (void *)&cmd_config_dcb_pfc,
2311 (void *)&cmd_config_dcb_pfc_en,
2316 /* *** configure number of packets per burst *** */
2317 struct cmd_config_burst {
2318 cmdline_fixed_string_t port;
2319 cmdline_fixed_string_t keyword;
2320 cmdline_fixed_string_t all;
2321 cmdline_fixed_string_t name;
2326 cmd_config_burst_parsed(void *parsed_result,
2327 __attribute__((unused)) struct cmdline *cl,
2328 __attribute__((unused)) void *data)
2330 struct cmd_config_burst *res = parsed_result;
2332 if (!all_ports_stopped()) {
2333 printf("Please stop all ports first\n");
2337 if (!strcmp(res->name, "burst")) {
2338 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2339 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2342 nb_pkt_per_burst = res->value;
2344 printf("Unknown parameter\n");
2350 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2353 cmdline_parse_token_string_t cmd_config_burst_port =
2354 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2355 cmdline_parse_token_string_t cmd_config_burst_keyword =
2356 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2357 cmdline_parse_token_string_t cmd_config_burst_all =
2358 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2359 cmdline_parse_token_string_t cmd_config_burst_name =
2360 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2361 cmdline_parse_token_num_t cmd_config_burst_value =
2362 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2364 cmdline_parse_inst_t cmd_config_burst = {
2365 .f = cmd_config_burst_parsed,
2367 .help_str = "port config all burst <value>",
2369 (void *)&cmd_config_burst_port,
2370 (void *)&cmd_config_burst_keyword,
2371 (void *)&cmd_config_burst_all,
2372 (void *)&cmd_config_burst_name,
2373 (void *)&cmd_config_burst_value,
2378 /* *** configure rx/tx queues *** */
2379 struct cmd_config_thresh {
2380 cmdline_fixed_string_t port;
2381 cmdline_fixed_string_t keyword;
2382 cmdline_fixed_string_t all;
2383 cmdline_fixed_string_t name;
2388 cmd_config_thresh_parsed(void *parsed_result,
2389 __attribute__((unused)) struct cmdline *cl,
2390 __attribute__((unused)) void *data)
2392 struct cmd_config_thresh *res = parsed_result;
2394 if (!all_ports_stopped()) {
2395 printf("Please stop all ports first\n");
2399 if (!strcmp(res->name, "txpt"))
2400 tx_pthresh = res->value;
2401 else if(!strcmp(res->name, "txht"))
2402 tx_hthresh = res->value;
2403 else if(!strcmp(res->name, "txwt"))
2404 tx_wthresh = res->value;
2405 else if(!strcmp(res->name, "rxpt"))
2406 rx_pthresh = res->value;
2407 else if(!strcmp(res->name, "rxht"))
2408 rx_hthresh = res->value;
2409 else if(!strcmp(res->name, "rxwt"))
2410 rx_wthresh = res->value;
2412 printf("Unknown parameter\n");
2418 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2421 cmdline_parse_token_string_t cmd_config_thresh_port =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2423 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2424 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2425 cmdline_parse_token_string_t cmd_config_thresh_all =
2426 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2427 cmdline_parse_token_string_t cmd_config_thresh_name =
2428 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2429 "txpt#txht#txwt#rxpt#rxht#rxwt");
2430 cmdline_parse_token_num_t cmd_config_thresh_value =
2431 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2433 cmdline_parse_inst_t cmd_config_thresh = {
2434 .f = cmd_config_thresh_parsed,
2436 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2438 (void *)&cmd_config_thresh_port,
2439 (void *)&cmd_config_thresh_keyword,
2440 (void *)&cmd_config_thresh_all,
2441 (void *)&cmd_config_thresh_name,
2442 (void *)&cmd_config_thresh_value,
2447 /* *** configure free/rs threshold *** */
2448 struct cmd_config_threshold {
2449 cmdline_fixed_string_t port;
2450 cmdline_fixed_string_t keyword;
2451 cmdline_fixed_string_t all;
2452 cmdline_fixed_string_t name;
2457 cmd_config_threshold_parsed(void *parsed_result,
2458 __attribute__((unused)) struct cmdline *cl,
2459 __attribute__((unused)) void *data)
2461 struct cmd_config_threshold *res = parsed_result;
2463 if (!all_ports_stopped()) {
2464 printf("Please stop all ports first\n");
2468 if (!strcmp(res->name, "txfreet"))
2469 tx_free_thresh = res->value;
2470 else if (!strcmp(res->name, "txrst"))
2471 tx_rs_thresh = res->value;
2472 else if (!strcmp(res->name, "rxfreet"))
2473 rx_free_thresh = res->value;
2475 printf("Unknown parameter\n");
2481 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2484 cmdline_parse_token_string_t cmd_config_threshold_port =
2485 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2486 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2487 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2489 cmdline_parse_token_string_t cmd_config_threshold_all =
2490 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2491 cmdline_parse_token_string_t cmd_config_threshold_name =
2492 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2493 "txfreet#txrst#rxfreet");
2494 cmdline_parse_token_num_t cmd_config_threshold_value =
2495 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2497 cmdline_parse_inst_t cmd_config_threshold = {
2498 .f = cmd_config_threshold_parsed,
2500 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2502 (void *)&cmd_config_threshold_port,
2503 (void *)&cmd_config_threshold_keyword,
2504 (void *)&cmd_config_threshold_all,
2505 (void *)&cmd_config_threshold_name,
2506 (void *)&cmd_config_threshold_value,
2512 struct cmd_stop_result {
2513 cmdline_fixed_string_t stop;
2516 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2517 __attribute__((unused)) struct cmdline *cl,
2518 __attribute__((unused)) void *data)
2520 stop_packet_forwarding();
2523 cmdline_parse_token_string_t cmd_stop_stop =
2524 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2526 cmdline_parse_inst_t cmd_stop = {
2527 .f = cmd_stop_parsed,
2529 .help_str = "stop: Stop packet forwarding",
2531 (void *)&cmd_stop_stop,
2536 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2539 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2540 unsigned int *parsed_items, int check_unique_values)
2542 unsigned int nb_item;
2550 * First parse all items in the list and store their value.
2555 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2557 if ((c >= '0') && (c <= '9')) {
2558 value = (unsigned int) (value * 10 + (c - '0'));
2563 printf("character %c is not a decimal digit\n", c);
2567 printf("No valid value before comma\n");
2570 if (nb_item < max_items) {
2571 parsed_items[nb_item] = value;
2577 if (nb_item >= max_items) {
2578 printf("Number of %s = %u > %u (maximum items)\n",
2579 item_name, nb_item + 1, max_items);
2582 parsed_items[nb_item++] = value;
2583 if (! check_unique_values)
2587 * Then, check that all values in the list are differents.
2588 * No optimization here...
2590 for (i = 0; i < nb_item; i++) {
2591 for (j = i + 1; j < nb_item; j++) {
2592 if (parsed_items[j] == parsed_items[i]) {
2593 printf("duplicated %s %u at index %u and %u\n",
2594 item_name, parsed_items[i], i, j);
2602 struct cmd_set_list_result {
2603 cmdline_fixed_string_t cmd_keyword;
2604 cmdline_fixed_string_t list_name;
2605 cmdline_fixed_string_t list_of_items;
2608 static void cmd_set_list_parsed(void *parsed_result,
2609 __attribute__((unused)) struct cmdline *cl,
2610 __attribute__((unused)) void *data)
2612 struct cmd_set_list_result *res;
2614 unsigned int lcorelist[RTE_MAX_LCORE];
2615 unsigned int portlist[RTE_MAX_ETHPORTS];
2617 unsigned int nb_item;
2619 if (test_done == 0) {
2620 printf("Please stop forwarding first\n");
2624 res = parsed_result;
2625 if (!strcmp(res->list_name, "corelist")) {
2626 nb_item = parse_item_list(res->list_of_items, "core",
2628 parsed_items.lcorelist, 1);
2630 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2635 if (!strcmp(res->list_name, "portlist")) {
2636 nb_item = parse_item_list(res->list_of_items, "port",
2638 parsed_items.portlist, 1);
2640 set_fwd_ports_list(parsed_items.portlist, nb_item);
2646 cmdline_parse_token_string_t cmd_set_list_keyword =
2647 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2649 cmdline_parse_token_string_t cmd_set_list_name =
2650 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2651 "corelist#portlist");
2652 cmdline_parse_token_string_t cmd_set_list_of_items =
2653 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2656 cmdline_parse_inst_t cmd_set_fwd_list = {
2657 .f = cmd_set_list_parsed,
2659 .help_str = "set corelist|portlist <list0[,list1]*>",
2661 (void *)&cmd_set_list_keyword,
2662 (void *)&cmd_set_list_name,
2663 (void *)&cmd_set_list_of_items,
2668 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2670 struct cmd_setmask_result {
2671 cmdline_fixed_string_t set;
2672 cmdline_fixed_string_t mask;
2676 static void cmd_set_mask_parsed(void *parsed_result,
2677 __attribute__((unused)) struct cmdline *cl,
2678 __attribute__((unused)) void *data)
2680 struct cmd_setmask_result *res = parsed_result;
2682 if (test_done == 0) {
2683 printf("Please stop forwarding first\n");
2686 if (!strcmp(res->mask, "coremask")) {
2687 set_fwd_lcores_mask(res->hexavalue);
2689 } else if (!strcmp(res->mask, "portmask")) {
2690 set_fwd_ports_mask(res->hexavalue);
2695 cmdline_parse_token_string_t cmd_setmask_set =
2696 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2697 cmdline_parse_token_string_t cmd_setmask_mask =
2698 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2699 "coremask#portmask");
2700 cmdline_parse_token_num_t cmd_setmask_value =
2701 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2703 cmdline_parse_inst_t cmd_set_fwd_mask = {
2704 .f = cmd_set_mask_parsed,
2706 .help_str = "set coremask|portmask <hexadecimal value>",
2708 (void *)&cmd_setmask_set,
2709 (void *)&cmd_setmask_mask,
2710 (void *)&cmd_setmask_value,
2716 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2718 struct cmd_set_result {
2719 cmdline_fixed_string_t set;
2720 cmdline_fixed_string_t what;
2724 static void cmd_set_parsed(void *parsed_result,
2725 __attribute__((unused)) struct cmdline *cl,
2726 __attribute__((unused)) void *data)
2728 struct cmd_set_result *res = parsed_result;
2729 if (!strcmp(res->what, "nbport")) {
2730 set_fwd_ports_number(res->value);
2732 } else if (!strcmp(res->what, "nbcore")) {
2733 set_fwd_lcores_number(res->value);
2735 } else if (!strcmp(res->what, "burst"))
2736 set_nb_pkt_per_burst(res->value);
2737 else if (!strcmp(res->what, "verbose"))
2738 set_verbose_level(res->value);
2741 cmdline_parse_token_string_t cmd_set_set =
2742 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2743 cmdline_parse_token_string_t cmd_set_what =
2744 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2745 "nbport#nbcore#burst#verbose");
2746 cmdline_parse_token_num_t cmd_set_value =
2747 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2749 cmdline_parse_inst_t cmd_set_numbers = {
2750 .f = cmd_set_parsed,
2752 .help_str = "set nbport|nbcore|burst|verbose <value>",
2754 (void *)&cmd_set_set,
2755 (void *)&cmd_set_what,
2756 (void *)&cmd_set_value,
2761 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2763 struct cmd_set_txpkts_result {
2764 cmdline_fixed_string_t cmd_keyword;
2765 cmdline_fixed_string_t txpkts;
2766 cmdline_fixed_string_t seg_lengths;
2770 cmd_set_txpkts_parsed(void *parsed_result,
2771 __attribute__((unused)) struct cmdline *cl,
2772 __attribute__((unused)) void *data)
2774 struct cmd_set_txpkts_result *res;
2775 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2776 unsigned int nb_segs;
2778 res = parsed_result;
2779 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2780 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2782 set_tx_pkt_segments(seg_lengths, nb_segs);
2785 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2786 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2787 cmd_keyword, "set");
2788 cmdline_parse_token_string_t cmd_set_txpkts_name =
2789 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2791 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2792 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2795 cmdline_parse_inst_t cmd_set_txpkts = {
2796 .f = cmd_set_txpkts_parsed,
2798 .help_str = "set txpkts <len0[,len1]*>",
2800 (void *)&cmd_set_txpkts_keyword,
2801 (void *)&cmd_set_txpkts_name,
2802 (void *)&cmd_set_txpkts_lengths,
2807 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2809 struct cmd_set_txsplit_result {
2810 cmdline_fixed_string_t cmd_keyword;
2811 cmdline_fixed_string_t txsplit;
2812 cmdline_fixed_string_t mode;
2816 cmd_set_txsplit_parsed(void *parsed_result,
2817 __attribute__((unused)) struct cmdline *cl,
2818 __attribute__((unused)) void *data)
2820 struct cmd_set_txsplit_result *res;
2822 res = parsed_result;
2823 set_tx_pkt_split(res->mode);
2826 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2827 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2828 cmd_keyword, "set");
2829 cmdline_parse_token_string_t cmd_set_txsplit_name =
2830 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2831 txsplit, "txsplit");
2832 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2833 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2836 cmdline_parse_inst_t cmd_set_txsplit = {
2837 .f = cmd_set_txsplit_parsed,
2839 .help_str = "set txsplit on|off|rand",
2841 (void *)&cmd_set_txsplit_keyword,
2842 (void *)&cmd_set_txsplit_name,
2843 (void *)&cmd_set_txsplit_mode,
2848 /* *** CONFIG TX QUEUE FLAGS *** */
2850 struct cmd_config_txqflags_result {
2851 cmdline_fixed_string_t port;
2852 cmdline_fixed_string_t config;
2853 cmdline_fixed_string_t all;
2854 cmdline_fixed_string_t what;
2858 static void cmd_config_txqflags_parsed(void *parsed_result,
2859 __attribute__((unused)) struct cmdline *cl,
2860 __attribute__((unused)) void *data)
2862 struct cmd_config_txqflags_result *res = parsed_result;
2864 if (!all_ports_stopped()) {
2865 printf("Please stop all ports first\n");
2869 if (strcmp(res->what, "txqflags")) {
2870 printf("Unknown parameter\n");
2874 if (res->hexvalue >= 0) {
2875 txq_flags = res->hexvalue;
2877 printf("txqflags must be >= 0\n");
2883 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2886 cmdline_parse_token_string_t cmd_config_txqflags_port =
2887 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2889 cmdline_parse_token_string_t cmd_config_txqflags_config =
2890 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2892 cmdline_parse_token_string_t cmd_config_txqflags_all =
2893 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2895 cmdline_parse_token_string_t cmd_config_txqflags_what =
2896 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2898 cmdline_parse_token_num_t cmd_config_txqflags_value =
2899 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2902 cmdline_parse_inst_t cmd_config_txqflags = {
2903 .f = cmd_config_txqflags_parsed,
2905 .help_str = "port config all txqflags <value>",
2907 (void *)&cmd_config_txqflags_port,
2908 (void *)&cmd_config_txqflags_config,
2909 (void *)&cmd_config_txqflags_all,
2910 (void *)&cmd_config_txqflags_what,
2911 (void *)&cmd_config_txqflags_value,
2916 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2917 struct cmd_rx_vlan_filter_all_result {
2918 cmdline_fixed_string_t rx_vlan;
2919 cmdline_fixed_string_t what;
2920 cmdline_fixed_string_t all;
2925 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2926 __attribute__((unused)) struct cmdline *cl,
2927 __attribute__((unused)) void *data)
2929 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2931 if (!strcmp(res->what, "add"))
2932 rx_vlan_all_filter_set(res->port_id, 1);
2934 rx_vlan_all_filter_set(res->port_id, 0);
2937 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2938 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2939 rx_vlan, "rx_vlan");
2940 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2941 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2943 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2944 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2946 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2947 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2950 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2951 .f = cmd_rx_vlan_filter_all_parsed,
2953 .help_str = "rx_vlan add|rm all <port_id>: "
2954 "Add/Remove all identifiers to/from the set of VLAN "
2955 "identifiers filtered by a port",
2957 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2958 (void *)&cmd_rx_vlan_filter_all_what,
2959 (void *)&cmd_rx_vlan_filter_all_all,
2960 (void *)&cmd_rx_vlan_filter_all_portid,
2965 /* *** VLAN OFFLOAD SET ON A PORT *** */
2966 struct cmd_vlan_offload_result {
2967 cmdline_fixed_string_t vlan;
2968 cmdline_fixed_string_t set;
2969 cmdline_fixed_string_t vlan_type;
2970 cmdline_fixed_string_t what;
2971 cmdline_fixed_string_t on;
2972 cmdline_fixed_string_t port_id;
2976 cmd_vlan_offload_parsed(void *parsed_result,
2977 __attribute__((unused)) struct cmdline *cl,
2978 __attribute__((unused)) void *data)
2981 struct cmd_vlan_offload_result *res = parsed_result;
2984 portid_t port_id = 0;
2988 len = strnlen(str, STR_TOKEN_SIZE);
2990 /* Get port_id first */
2998 tmp = strtoul(str, NULL, 0);
2999 /* If port_id greater that what portid_t can represent, return */
3000 if(tmp >= RTE_MAX_ETHPORTS)
3002 port_id = (portid_t)tmp;
3004 if (!strcmp(res->on, "on"))
3009 if (!strcmp(res->what, "strip"))
3010 rx_vlan_strip_set(port_id, on);
3011 else if(!strcmp(res->what, "stripq")){
3012 uint16_t queue_id = 0;
3014 /* No queue_id, return */
3016 printf("must specify (port,queue_id)\n");
3019 tmp = strtoul(str + i + 1, NULL, 0);
3020 /* If queue_id greater that what 16-bits can represent, return */
3024 queue_id = (uint16_t)tmp;
3025 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3027 else if (!strcmp(res->what, "filter"))
3028 rx_vlan_filter_set(port_id, on);
3030 vlan_extend_set(port_id, on);
3035 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3036 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3038 cmdline_parse_token_string_t cmd_vlan_offload_set =
3039 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3041 cmdline_parse_token_string_t cmd_vlan_offload_what =
3042 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3043 what, "strip#filter#qinq#stripq");
3044 cmdline_parse_token_string_t cmd_vlan_offload_on =
3045 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3047 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3048 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3051 cmdline_parse_inst_t cmd_vlan_offload = {
3052 .f = cmd_vlan_offload_parsed,
3054 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3055 "<port_id[,queue_id]>: "
3056 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3058 (void *)&cmd_vlan_offload_vlan,
3059 (void *)&cmd_vlan_offload_set,
3060 (void *)&cmd_vlan_offload_what,
3061 (void *)&cmd_vlan_offload_on,
3062 (void *)&cmd_vlan_offload_portid,
3067 /* *** VLAN TPID SET ON A PORT *** */
3068 struct cmd_vlan_tpid_result {
3069 cmdline_fixed_string_t vlan;
3070 cmdline_fixed_string_t set;
3071 cmdline_fixed_string_t vlan_type;
3072 cmdline_fixed_string_t what;
3078 cmd_vlan_tpid_parsed(void *parsed_result,
3079 __attribute__((unused)) struct cmdline *cl,
3080 __attribute__((unused)) void *data)
3082 struct cmd_vlan_tpid_result *res = parsed_result;
3083 enum rte_vlan_type vlan_type;
3085 if (!strcmp(res->vlan_type, "inner"))
3086 vlan_type = ETH_VLAN_TYPE_INNER;
3087 else if (!strcmp(res->vlan_type, "outer"))
3088 vlan_type = ETH_VLAN_TYPE_OUTER;
3090 printf("Unknown vlan type\n");
3093 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3096 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3097 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3099 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3100 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3102 cmdline_parse_token_string_t cmd_vlan_type =
3103 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3104 vlan_type, "inner#outer");
3105 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3106 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3108 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3109 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3111 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3112 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3115 cmdline_parse_inst_t cmd_vlan_tpid = {
3116 .f = cmd_vlan_tpid_parsed,
3118 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3119 "Set the VLAN Ether type",
3121 (void *)&cmd_vlan_tpid_vlan,
3122 (void *)&cmd_vlan_tpid_set,
3123 (void *)&cmd_vlan_type,
3124 (void *)&cmd_vlan_tpid_what,
3125 (void *)&cmd_vlan_tpid_tpid,
3126 (void *)&cmd_vlan_tpid_portid,
3131 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3132 struct cmd_rx_vlan_filter_result {
3133 cmdline_fixed_string_t rx_vlan;
3134 cmdline_fixed_string_t what;
3140 cmd_rx_vlan_filter_parsed(void *parsed_result,
3141 __attribute__((unused)) struct cmdline *cl,
3142 __attribute__((unused)) void *data)
3144 struct cmd_rx_vlan_filter_result *res = parsed_result;
3146 if (!strcmp(res->what, "add"))
3147 rx_vft_set(res->port_id, res->vlan_id, 1);
3149 rx_vft_set(res->port_id, res->vlan_id, 0);
3152 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3153 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3154 rx_vlan, "rx_vlan");
3155 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3156 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3158 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3159 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3161 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3162 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3165 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3166 .f = cmd_rx_vlan_filter_parsed,
3168 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3169 "Add/Remove a VLAN identifier to/from the set of VLAN "
3170 "identifiers filtered by a port",
3172 (void *)&cmd_rx_vlan_filter_rx_vlan,
3173 (void *)&cmd_rx_vlan_filter_what,
3174 (void *)&cmd_rx_vlan_filter_vlanid,
3175 (void *)&cmd_rx_vlan_filter_portid,
3180 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3181 struct cmd_tx_vlan_set_result {
3182 cmdline_fixed_string_t tx_vlan;
3183 cmdline_fixed_string_t set;
3189 cmd_tx_vlan_set_parsed(void *parsed_result,
3190 __attribute__((unused)) struct cmdline *cl,
3191 __attribute__((unused)) void *data)
3193 struct cmd_tx_vlan_set_result *res = parsed_result;
3195 tx_vlan_set(res->port_id, res->vlan_id);
3198 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3199 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3200 tx_vlan, "tx_vlan");
3201 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3202 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3204 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3205 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3207 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3208 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3211 cmdline_parse_inst_t cmd_tx_vlan_set = {
3212 .f = cmd_tx_vlan_set_parsed,
3214 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3215 "Enable hardware insertion of a single VLAN header "
3216 "with a given TAG Identifier in packets sent on a port",
3218 (void *)&cmd_tx_vlan_set_tx_vlan,
3219 (void *)&cmd_tx_vlan_set_set,
3220 (void *)&cmd_tx_vlan_set_portid,
3221 (void *)&cmd_tx_vlan_set_vlanid,
3226 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3227 struct cmd_tx_vlan_set_qinq_result {
3228 cmdline_fixed_string_t tx_vlan;
3229 cmdline_fixed_string_t set;
3232 uint16_t vlan_id_outer;
3236 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3237 __attribute__((unused)) struct cmdline *cl,
3238 __attribute__((unused)) void *data)
3240 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3242 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3245 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3246 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3247 tx_vlan, "tx_vlan");
3248 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3249 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3251 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3252 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3254 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3255 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3257 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3258 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3259 vlan_id_outer, UINT16);
3261 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3262 .f = cmd_tx_vlan_set_qinq_parsed,
3264 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3265 "Enable hardware insertion of double VLAN header "
3266 "with given TAG Identifiers in packets sent on a port",
3268 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3269 (void *)&cmd_tx_vlan_set_qinq_set,
3270 (void *)&cmd_tx_vlan_set_qinq_portid,
3271 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3272 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3277 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3278 struct cmd_tx_vlan_set_pvid_result {
3279 cmdline_fixed_string_t tx_vlan;
3280 cmdline_fixed_string_t set;
3281 cmdline_fixed_string_t pvid;
3284 cmdline_fixed_string_t mode;
3288 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3289 __attribute__((unused)) struct cmdline *cl,
3290 __attribute__((unused)) void *data)
3292 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3294 if (strcmp(res->mode, "on") == 0)
3295 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3297 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3300 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3301 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3302 tx_vlan, "tx_vlan");
3303 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3304 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3306 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3307 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3309 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3310 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3312 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3313 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3315 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3316 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3319 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3320 .f = cmd_tx_vlan_set_pvid_parsed,
3322 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3324 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3325 (void *)&cmd_tx_vlan_set_pvid_set,
3326 (void *)&cmd_tx_vlan_set_pvid_pvid,
3327 (void *)&cmd_tx_vlan_set_pvid_port_id,
3328 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3329 (void *)&cmd_tx_vlan_set_pvid_mode,
3334 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3335 struct cmd_tx_vlan_reset_result {
3336 cmdline_fixed_string_t tx_vlan;
3337 cmdline_fixed_string_t reset;
3342 cmd_tx_vlan_reset_parsed(void *parsed_result,
3343 __attribute__((unused)) struct cmdline *cl,
3344 __attribute__((unused)) void *data)
3346 struct cmd_tx_vlan_reset_result *res = parsed_result;
3348 tx_vlan_reset(res->port_id);
3351 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3352 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3353 tx_vlan, "tx_vlan");
3354 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3355 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3357 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3358 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3361 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3362 .f = cmd_tx_vlan_reset_parsed,
3364 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3365 "VLAN header in packets sent on a port",
3367 (void *)&cmd_tx_vlan_reset_tx_vlan,
3368 (void *)&cmd_tx_vlan_reset_reset,
3369 (void *)&cmd_tx_vlan_reset_portid,
3375 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3376 struct cmd_csum_result {
3377 cmdline_fixed_string_t csum;
3378 cmdline_fixed_string_t mode;
3379 cmdline_fixed_string_t proto;
3380 cmdline_fixed_string_t hwsw;
3385 csum_show(int port_id)
3387 struct rte_eth_dev_info dev_info;
3390 ol_flags = ports[port_id].tx_ol_flags;
3391 printf("Parse tunnel is %s\n",
3392 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3393 printf("IP checksum offload is %s\n",
3394 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3395 printf("UDP checksum offload is %s\n",
3396 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3397 printf("TCP checksum offload is %s\n",
3398 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3399 printf("SCTP checksum offload is %s\n",
3400 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3401 printf("Outer-Ip checksum offload is %s\n",
3402 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3404 /* display warnings if configuration is not supported by the NIC */
3405 rte_eth_dev_info_get(port_id, &dev_info);
3406 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3407 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3408 printf("Warning: hardware IP checksum enabled but not "
3409 "supported by port %d\n", port_id);
3411 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3412 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3413 printf("Warning: hardware UDP checksum enabled but not "
3414 "supported by port %d\n", port_id);
3416 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3417 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3418 printf("Warning: hardware TCP checksum enabled but not "
3419 "supported by port %d\n", port_id);
3421 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3422 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3423 printf("Warning: hardware SCTP checksum enabled but not "
3424 "supported by port %d\n", port_id);
3426 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3427 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3428 printf("Warning: hardware outer IP checksum enabled but not "
3429 "supported by port %d\n", port_id);
3434 cmd_csum_parsed(void *parsed_result,
3435 __attribute__((unused)) struct cmdline *cl,
3436 __attribute__((unused)) void *data)
3438 struct cmd_csum_result *res = parsed_result;
3442 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3443 printf("invalid port %d\n", res->port_id);
3447 if (!strcmp(res->mode, "set")) {
3449 if (!strcmp(res->hwsw, "hw"))
3452 if (!strcmp(res->proto, "ip")) {
3453 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3454 } else if (!strcmp(res->proto, "udp")) {
3455 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3456 } else if (!strcmp(res->proto, "tcp")) {
3457 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3458 } else if (!strcmp(res->proto, "sctp")) {
3459 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3460 } else if (!strcmp(res->proto, "outer-ip")) {
3461 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3465 ports[res->port_id].tx_ol_flags |= mask;
3467 ports[res->port_id].tx_ol_flags &= (~mask);
3469 csum_show(res->port_id);
3472 cmdline_parse_token_string_t cmd_csum_csum =
3473 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3475 cmdline_parse_token_string_t cmd_csum_mode =
3476 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3478 cmdline_parse_token_string_t cmd_csum_proto =
3479 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3480 proto, "ip#tcp#udp#sctp#outer-ip");
3481 cmdline_parse_token_string_t cmd_csum_hwsw =
3482 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3484 cmdline_parse_token_num_t cmd_csum_portid =
3485 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3488 cmdline_parse_inst_t cmd_csum_set = {
3489 .f = cmd_csum_parsed,
3491 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3492 "Enable/Disable hardware calculation of L3/L4 checksum when "
3493 "using csum forward engine",
3495 (void *)&cmd_csum_csum,
3496 (void *)&cmd_csum_mode,
3497 (void *)&cmd_csum_proto,
3498 (void *)&cmd_csum_hwsw,
3499 (void *)&cmd_csum_portid,
3504 cmdline_parse_token_string_t cmd_csum_mode_show =
3505 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3508 cmdline_parse_inst_t cmd_csum_show = {
3509 .f = cmd_csum_parsed,
3511 .help_str = "csum show <port_id>: Show checksum offload configuration",
3513 (void *)&cmd_csum_csum,
3514 (void *)&cmd_csum_mode_show,
3515 (void *)&cmd_csum_portid,
3520 /* Enable/disable tunnel parsing */
3521 struct cmd_csum_tunnel_result {
3522 cmdline_fixed_string_t csum;
3523 cmdline_fixed_string_t parse;
3524 cmdline_fixed_string_t onoff;
3529 cmd_csum_tunnel_parsed(void *parsed_result,
3530 __attribute__((unused)) struct cmdline *cl,
3531 __attribute__((unused)) void *data)
3533 struct cmd_csum_tunnel_result *res = parsed_result;
3535 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3538 if (!strcmp(res->onoff, "on"))
3539 ports[res->port_id].tx_ol_flags |=
3540 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3542 ports[res->port_id].tx_ol_flags &=
3543 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3545 csum_show(res->port_id);
3548 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3549 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3551 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3552 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3553 parse, "parse_tunnel");
3554 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3555 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3557 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3558 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3561 cmdline_parse_inst_t cmd_csum_tunnel = {
3562 .f = cmd_csum_tunnel_parsed,
3564 .help_str = "csum parse_tunnel on|off <port_id>: "
3565 "Enable/Disable parsing of tunnels for csum engine",
3567 (void *)&cmd_csum_tunnel_csum,
3568 (void *)&cmd_csum_tunnel_parse,
3569 (void *)&cmd_csum_tunnel_onoff,
3570 (void *)&cmd_csum_tunnel_portid,
3575 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3576 struct cmd_tso_set_result {
3577 cmdline_fixed_string_t tso;
3578 cmdline_fixed_string_t mode;
3584 cmd_tso_set_parsed(void *parsed_result,
3585 __attribute__((unused)) struct cmdline *cl,
3586 __attribute__((unused)) void *data)
3588 struct cmd_tso_set_result *res = parsed_result;
3589 struct rte_eth_dev_info dev_info;
3591 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3594 if (!strcmp(res->mode, "set"))
3595 ports[res->port_id].tso_segsz = res->tso_segsz;
3597 if (ports[res->port_id].tso_segsz == 0)
3598 printf("TSO for non-tunneled packets is disabled\n");
3600 printf("TSO segment size for non-tunneled packets is %d\n",
3601 ports[res->port_id].tso_segsz);
3603 /* display warnings if configuration is not supported by the NIC */
3604 rte_eth_dev_info_get(res->port_id, &dev_info);
3605 if ((ports[res->port_id].tso_segsz != 0) &&
3606 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3607 printf("Warning: TSO enabled but not "
3608 "supported by port %d\n", res->port_id);
3612 cmdline_parse_token_string_t cmd_tso_set_tso =
3613 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3615 cmdline_parse_token_string_t cmd_tso_set_mode =
3616 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3618 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3619 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3621 cmdline_parse_token_num_t cmd_tso_set_portid =
3622 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3625 cmdline_parse_inst_t cmd_tso_set = {
3626 .f = cmd_tso_set_parsed,
3628 .help_str = "tso set <tso_segsz> <port_id>: "
3629 "Set TSO segment size of non-tunneled packets for csum engine "
3632 (void *)&cmd_tso_set_tso,
3633 (void *)&cmd_tso_set_mode,
3634 (void *)&cmd_tso_set_tso_segsz,
3635 (void *)&cmd_tso_set_portid,
3640 cmdline_parse_token_string_t cmd_tso_show_mode =
3641 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3645 cmdline_parse_inst_t cmd_tso_show = {
3646 .f = cmd_tso_set_parsed,
3648 .help_str = "tso show <port_id>: "
3649 "Show TSO segment size of non-tunneled packets for csum engine",
3651 (void *)&cmd_tso_set_tso,
3652 (void *)&cmd_tso_show_mode,
3653 (void *)&cmd_tso_set_portid,
3658 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3659 struct cmd_tunnel_tso_set_result {
3660 cmdline_fixed_string_t tso;
3661 cmdline_fixed_string_t mode;
3667 check_tunnel_tso_nic_support(uint8_t port_id)
3669 struct rte_eth_dev_info dev_info;
3671 rte_eth_dev_info_get(port_id, &dev_info);
3672 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3673 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3674 "supported by port %d\n", port_id);
3675 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3676 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3677 "supported by port %d\n", port_id);
3678 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3679 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3680 "supported by port %d\n", port_id);
3681 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3682 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3683 "supported by port %d\n", port_id);
3687 cmd_tunnel_tso_set_parsed(void *parsed_result,
3688 __attribute__((unused)) struct cmdline *cl,
3689 __attribute__((unused)) void *data)
3691 struct cmd_tunnel_tso_set_result *res = parsed_result;
3693 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3696 if (!strcmp(res->mode, "set"))
3697 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3699 if (ports[res->port_id].tunnel_tso_segsz == 0)
3700 printf("TSO for tunneled packets is disabled\n");
3702 printf("TSO segment size for tunneled packets is %d\n",
3703 ports[res->port_id].tunnel_tso_segsz);
3705 /* Below conditions are needed to make it work:
3706 * (1) tunnel TSO is supported by the NIC;
3707 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3709 * (3) for tunneled pkts with outer L3 of IPv4,
3710 * "csum set outer-ip" must be set to hw, because after tso,
3711 * total_len of outer IP header is changed, and the checksum
3712 * of outer IP header calculated by sw should be wrong; that
3713 * is not necessary for IPv6 tunneled pkts because there's no
3714 * checksum in IP header anymore.
3716 check_tunnel_tso_nic_support(res->port_id);
3718 if (!(ports[res->port_id].tx_ol_flags &
3719 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3720 printf("Warning: csum parse_tunnel must be set "
3721 "so that tunneled packets are recognized\n");
3722 if (!(ports[res->port_id].tx_ol_flags &
3723 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3724 printf("Warning: csum set outer-ip must be set to hw "
3725 "if outer L3 is IPv4; not necessary for IPv6\n");
3729 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3730 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3732 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3733 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3735 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3736 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3738 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3739 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3742 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3743 .f = cmd_tunnel_tso_set_parsed,
3745 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3746 "Set TSO segment size of tunneled packets for csum engine "
3749 (void *)&cmd_tunnel_tso_set_tso,
3750 (void *)&cmd_tunnel_tso_set_mode,
3751 (void *)&cmd_tunnel_tso_set_tso_segsz,
3752 (void *)&cmd_tunnel_tso_set_portid,
3757 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3758 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3762 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3763 .f = cmd_tunnel_tso_set_parsed,
3765 .help_str = "tunnel_tso show <port_id> "
3766 "Show TSO segment size of tunneled packets for csum engine",
3768 (void *)&cmd_tunnel_tso_set_tso,
3769 (void *)&cmd_tunnel_tso_show_mode,
3770 (void *)&cmd_tunnel_tso_set_portid,
3775 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3776 struct cmd_set_flush_rx {
3777 cmdline_fixed_string_t set;
3778 cmdline_fixed_string_t flush_rx;
3779 cmdline_fixed_string_t mode;
3783 cmd_set_flush_rx_parsed(void *parsed_result,
3784 __attribute__((unused)) struct cmdline *cl,
3785 __attribute__((unused)) void *data)
3787 struct cmd_set_flush_rx *res = parsed_result;
3788 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3791 cmdline_parse_token_string_t cmd_setflushrx_set =
3792 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3794 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3795 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3796 flush_rx, "flush_rx");
3797 cmdline_parse_token_string_t cmd_setflushrx_mode =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3802 cmdline_parse_inst_t cmd_set_flush_rx = {
3803 .f = cmd_set_flush_rx_parsed,
3804 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3807 (void *)&cmd_setflushrx_set,
3808 (void *)&cmd_setflushrx_flush_rx,
3809 (void *)&cmd_setflushrx_mode,
3814 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3815 struct cmd_set_link_check {
3816 cmdline_fixed_string_t set;
3817 cmdline_fixed_string_t link_check;
3818 cmdline_fixed_string_t mode;
3822 cmd_set_link_check_parsed(void *parsed_result,
3823 __attribute__((unused)) struct cmdline *cl,
3824 __attribute__((unused)) void *data)
3826 struct cmd_set_link_check *res = parsed_result;
3827 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3830 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3833 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3835 link_check, "link_check");
3836 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3837 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3841 cmdline_parse_inst_t cmd_set_link_check = {
3842 .f = cmd_set_link_check_parsed,
3843 .help_str = "set link_check on|off: Enable/Disable link status check "
3844 "when starting/stopping a port",
3847 (void *)&cmd_setlinkcheck_set,
3848 (void *)&cmd_setlinkcheck_link_check,
3849 (void *)&cmd_setlinkcheck_mode,
3854 #ifdef RTE_NIC_BYPASS
3855 /* *** SET NIC BYPASS MODE *** */
3856 struct cmd_set_bypass_mode_result {
3857 cmdline_fixed_string_t set;
3858 cmdline_fixed_string_t bypass;
3859 cmdline_fixed_string_t mode;
3860 cmdline_fixed_string_t value;
3865 cmd_set_bypass_mode_parsed(void *parsed_result,
3866 __attribute__((unused)) struct cmdline *cl,
3867 __attribute__((unused)) void *data)
3869 struct cmd_set_bypass_mode_result *res = parsed_result;
3870 portid_t port_id = res->port_id;
3871 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3873 if (!strcmp(res->value, "bypass"))
3874 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3875 else if (!strcmp(res->value, "isolate"))
3876 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3878 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3880 /* Set the bypass mode for the relevant port. */
3881 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3882 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3886 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3887 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3889 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3890 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3892 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3893 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3895 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3897 value, "normal#bypass#isolate");
3898 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3899 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3902 cmdline_parse_inst_t cmd_set_bypass_mode = {
3903 .f = cmd_set_bypass_mode_parsed,
3904 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3905 "Set the NIC bypass mode for port_id",
3908 (void *)&cmd_setbypass_mode_set,
3909 (void *)&cmd_setbypass_mode_bypass,
3910 (void *)&cmd_setbypass_mode_mode,
3911 (void *)&cmd_setbypass_mode_value,
3912 (void *)&cmd_setbypass_mode_port,
3917 /* *** SET NIC BYPASS EVENT *** */
3918 struct cmd_set_bypass_event_result {
3919 cmdline_fixed_string_t set;
3920 cmdline_fixed_string_t bypass;
3921 cmdline_fixed_string_t event;
3922 cmdline_fixed_string_t event_value;
3923 cmdline_fixed_string_t mode;
3924 cmdline_fixed_string_t mode_value;
3929 cmd_set_bypass_event_parsed(void *parsed_result,
3930 __attribute__((unused)) struct cmdline *cl,
3931 __attribute__((unused)) void *data)
3934 struct cmd_set_bypass_event_result *res = parsed_result;
3935 portid_t port_id = res->port_id;
3936 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3937 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3939 if (!strcmp(res->event_value, "timeout"))
3940 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3941 else if (!strcmp(res->event_value, "os_on"))
3942 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3943 else if (!strcmp(res->event_value, "os_off"))
3944 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3945 else if (!strcmp(res->event_value, "power_on"))
3946 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3947 else if (!strcmp(res->event_value, "power_off"))
3948 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3950 bypass_event = RTE_BYPASS_EVENT_NONE;
3952 if (!strcmp(res->mode_value, "bypass"))
3953 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3954 else if (!strcmp(res->mode_value, "isolate"))
3955 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3957 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3959 /* Set the watchdog timeout. */
3960 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3963 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3964 (rc = rte_eth_dev_wd_timeout_store(port_id,
3965 bypass_timeout)) != 0) {
3966 printf("Failed to set timeout value %u "
3967 "for port %d, errto code: %d.\n",
3968 bypass_timeout, port_id, rc);
3972 /* Set the bypass event to transition to bypass mode. */
3973 if (0 != rte_eth_dev_bypass_event_store(port_id,
3974 bypass_event, bypass_mode)) {
3975 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3980 cmdline_parse_token_string_t cmd_setbypass_event_set =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3983 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3986 cmdline_parse_token_string_t cmd_setbypass_event_event =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3989 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3991 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3992 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3995 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3997 mode_value, "normal#bypass#isolate");
3998 cmdline_parse_token_num_t cmd_setbypass_event_port =
3999 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4002 cmdline_parse_inst_t cmd_set_bypass_event = {
4003 .f = cmd_set_bypass_event_parsed,
4004 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4005 "power_off mode normal|bypass|isolate <port_id>: "
4006 "Set the NIC bypass event mode for port_id",
4009 (void *)&cmd_setbypass_event_set,
4010 (void *)&cmd_setbypass_event_bypass,
4011 (void *)&cmd_setbypass_event_event,
4012 (void *)&cmd_setbypass_event_event_value,
4013 (void *)&cmd_setbypass_event_mode,
4014 (void *)&cmd_setbypass_event_mode_value,
4015 (void *)&cmd_setbypass_event_port,
4021 /* *** SET NIC BYPASS TIMEOUT *** */
4022 struct cmd_set_bypass_timeout_result {
4023 cmdline_fixed_string_t set;
4024 cmdline_fixed_string_t bypass;
4025 cmdline_fixed_string_t timeout;
4026 cmdline_fixed_string_t value;
4030 cmd_set_bypass_timeout_parsed(void *parsed_result,
4031 __attribute__((unused)) struct cmdline *cl,
4032 __attribute__((unused)) void *data)
4034 struct cmd_set_bypass_timeout_result *res = parsed_result;
4036 if (!strcmp(res->value, "1.5"))
4037 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4038 else if (!strcmp(res->value, "2"))
4039 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4040 else if (!strcmp(res->value, "3"))
4041 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4042 else if (!strcmp(res->value, "4"))
4043 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4044 else if (!strcmp(res->value, "8"))
4045 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4046 else if (!strcmp(res->value, "16"))
4047 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4048 else if (!strcmp(res->value, "32"))
4049 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4051 bypass_timeout = RTE_BYPASS_TMT_OFF;
4054 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4055 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4057 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4060 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4061 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4062 timeout, "timeout");
4063 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4064 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4065 value, "0#1.5#2#3#4#8#16#32");
4067 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4068 .f = cmd_set_bypass_timeout_parsed,
4069 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4070 "Set the NIC bypass watchdog timeout in seconds",
4073 (void *)&cmd_setbypass_timeout_set,
4074 (void *)&cmd_setbypass_timeout_bypass,
4075 (void *)&cmd_setbypass_timeout_timeout,
4076 (void *)&cmd_setbypass_timeout_value,
4081 /* *** SHOW NIC BYPASS MODE *** */
4082 struct cmd_show_bypass_config_result {
4083 cmdline_fixed_string_t show;
4084 cmdline_fixed_string_t bypass;
4085 cmdline_fixed_string_t config;
4090 cmd_show_bypass_config_parsed(void *parsed_result,
4091 __attribute__((unused)) struct cmdline *cl,
4092 __attribute__((unused)) void *data)
4094 struct cmd_show_bypass_config_result *res = parsed_result;
4095 uint32_t event_mode;
4096 uint32_t bypass_mode;
4097 portid_t port_id = res->port_id;
4098 uint32_t timeout = bypass_timeout;
4101 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4102 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4103 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4104 {"UNKNOWN", "normal", "bypass", "isolate"};
4105 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4112 int num_events = (sizeof events) / (sizeof events[0]);
4114 /* Display the bypass mode.*/
4115 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4116 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4120 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4121 bypass_mode = RTE_BYPASS_MODE_NONE;
4123 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4126 /* Display the bypass timeout.*/
4127 if (!RTE_BYPASS_TMT_VALID(timeout))
4128 timeout = RTE_BYPASS_TMT_OFF;
4130 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4132 /* Display the bypass events and associated modes. */
4133 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4135 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4136 printf("\tFailed to get bypass mode for event = %s\n",
4139 if (!RTE_BYPASS_MODE_VALID(event_mode))
4140 event_mode = RTE_BYPASS_MODE_NONE;
4142 printf("\tbypass event: %-16s = %s\n", events[i],
4148 cmdline_parse_token_string_t cmd_showbypass_config_show =
4149 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4151 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4152 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4154 cmdline_parse_token_string_t cmd_showbypass_config_config =
4155 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4157 cmdline_parse_token_num_t cmd_showbypass_config_port =
4158 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4161 cmdline_parse_inst_t cmd_show_bypass_config = {
4162 .f = cmd_show_bypass_config_parsed,
4163 .help_str = "show bypass config <port_id>: "
4164 "Show the NIC bypass config for port_id",
4167 (void *)&cmd_showbypass_config_show,
4168 (void *)&cmd_showbypass_config_bypass,
4169 (void *)&cmd_showbypass_config_config,
4170 (void *)&cmd_showbypass_config_port,
4176 #ifdef RTE_LIBRTE_PMD_BOND
4177 /* *** SET BONDING MODE *** */
4178 struct cmd_set_bonding_mode_result {
4179 cmdline_fixed_string_t set;
4180 cmdline_fixed_string_t bonding;
4181 cmdline_fixed_string_t mode;
4186 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4187 __attribute__((unused)) struct cmdline *cl,
4188 __attribute__((unused)) void *data)
4190 struct cmd_set_bonding_mode_result *res = parsed_result;
4191 portid_t port_id = res->port_id;
4193 /* Set the bonding mode for the relevant port. */
4194 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4195 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4198 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4199 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4201 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4202 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4203 bonding, "bonding");
4204 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4205 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4207 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4208 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4210 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4211 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4214 cmdline_parse_inst_t cmd_set_bonding_mode = {
4215 .f = cmd_set_bonding_mode_parsed,
4216 .help_str = "set bonding mode <mode_value> <port_id>: "
4217 "Set the bonding mode for port_id",
4220 (void *) &cmd_setbonding_mode_set,
4221 (void *) &cmd_setbonding_mode_bonding,
4222 (void *) &cmd_setbonding_mode_mode,
4223 (void *) &cmd_setbonding_mode_value,
4224 (void *) &cmd_setbonding_mode_port,
4229 /* *** SET BALANCE XMIT POLICY *** */
4230 struct cmd_set_bonding_balance_xmit_policy_result {
4231 cmdline_fixed_string_t set;
4232 cmdline_fixed_string_t bonding;
4233 cmdline_fixed_string_t balance_xmit_policy;
4235 cmdline_fixed_string_t policy;
4238 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4239 __attribute__((unused)) struct cmdline *cl,
4240 __attribute__((unused)) void *data)
4242 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4243 portid_t port_id = res->port_id;
4246 if (!strcmp(res->policy, "l2")) {
4247 policy = BALANCE_XMIT_POLICY_LAYER2;
4248 } else if (!strcmp(res->policy, "l23")) {
4249 policy = BALANCE_XMIT_POLICY_LAYER23;
4250 } else if (!strcmp(res->policy, "l34")) {
4251 policy = BALANCE_XMIT_POLICY_LAYER34;
4253 printf("\t Invalid xmit policy selection");
4257 /* Set the bonding mode for the relevant port. */
4258 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4259 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4264 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4265 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4267 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4269 bonding, "bonding");
4270 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4271 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4272 balance_xmit_policy, "balance_xmit_policy");
4273 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4274 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4276 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4277 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4278 policy, "l2#l23#l34");
4280 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4281 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4282 .help_str = "set bonding balance_xmit_policy <port_id> "
4284 "Set the bonding balance_xmit_policy for port_id",
4287 (void *)&cmd_setbonding_balance_xmit_policy_set,
4288 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4289 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4290 (void *)&cmd_setbonding_balance_xmit_policy_port,
4291 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4296 /* *** SHOW NIC BONDING CONFIGURATION *** */
4297 struct cmd_show_bonding_config_result {
4298 cmdline_fixed_string_t show;
4299 cmdline_fixed_string_t bonding;
4300 cmdline_fixed_string_t config;
4304 static void cmd_show_bonding_config_parsed(void *parsed_result,
4305 __attribute__((unused)) struct cmdline *cl,
4306 __attribute__((unused)) void *data)
4308 struct cmd_show_bonding_config_result *res = parsed_result;
4310 uint8_t slaves[RTE_MAX_ETHPORTS];
4311 int num_slaves, num_active_slaves;
4314 portid_t port_id = res->port_id;
4316 /* Display the bonding mode.*/
4317 bonding_mode = rte_eth_bond_mode_get(port_id);
4318 if (bonding_mode < 0) {
4319 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4322 printf("\tBonding mode: %d\n", bonding_mode);
4324 if (bonding_mode == BONDING_MODE_BALANCE) {
4325 int balance_xmit_policy;
4327 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4328 if (balance_xmit_policy < 0) {
4329 printf("\tFailed to get balance xmit policy for port = %d\n",
4333 printf("\tBalance Xmit Policy: ");
4335 switch (balance_xmit_policy) {
4336 case BALANCE_XMIT_POLICY_LAYER2:
4337 printf("BALANCE_XMIT_POLICY_LAYER2");
4339 case BALANCE_XMIT_POLICY_LAYER23:
4340 printf("BALANCE_XMIT_POLICY_LAYER23");
4342 case BALANCE_XMIT_POLICY_LAYER34:
4343 printf("BALANCE_XMIT_POLICY_LAYER34");
4350 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4352 if (num_slaves < 0) {
4353 printf("\tFailed to get slave list for port = %d\n", port_id);
4356 if (num_slaves > 0) {
4357 printf("\tSlaves (%d): [", num_slaves);
4358 for (i = 0; i < num_slaves - 1; i++)
4359 printf("%d ", slaves[i]);
4361 printf("%d]\n", slaves[num_slaves - 1]);
4363 printf("\tSlaves: []\n");
4367 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4370 if (num_active_slaves < 0) {
4371 printf("\tFailed to get active slave list for port = %d\n", port_id);
4374 if (num_active_slaves > 0) {
4375 printf("\tActive Slaves (%d): [", num_active_slaves);
4376 for (i = 0; i < num_active_slaves - 1; i++)
4377 printf("%d ", slaves[i]);
4379 printf("%d]\n", slaves[num_active_slaves - 1]);
4382 printf("\tActive Slaves: []\n");
4386 primary_id = rte_eth_bond_primary_get(port_id);
4387 if (primary_id < 0) {
4388 printf("\tFailed to get primary slave for port = %d\n", port_id);
4391 printf("\tPrimary: [%d]\n", primary_id);
4395 cmdline_parse_token_string_t cmd_showbonding_config_show =
4396 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4398 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4399 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4400 bonding, "bonding");
4401 cmdline_parse_token_string_t cmd_showbonding_config_config =
4402 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4404 cmdline_parse_token_num_t cmd_showbonding_config_port =
4405 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4408 cmdline_parse_inst_t cmd_show_bonding_config = {
4409 .f = cmd_show_bonding_config_parsed,
4410 .help_str = "show bonding config <port_id>: "
4411 "Show the bonding config for port_id",
4414 (void *)&cmd_showbonding_config_show,
4415 (void *)&cmd_showbonding_config_bonding,
4416 (void *)&cmd_showbonding_config_config,
4417 (void *)&cmd_showbonding_config_port,
4422 /* *** SET BONDING PRIMARY *** */
4423 struct cmd_set_bonding_primary_result {
4424 cmdline_fixed_string_t set;
4425 cmdline_fixed_string_t bonding;
4426 cmdline_fixed_string_t primary;
4431 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4432 __attribute__((unused)) struct cmdline *cl,
4433 __attribute__((unused)) void *data)
4435 struct cmd_set_bonding_primary_result *res = parsed_result;
4436 portid_t master_port_id = res->port_id;
4437 portid_t slave_port_id = res->slave_id;
4439 /* Set the primary slave for a bonded device. */
4440 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4441 printf("\t Failed to set primary slave for port = %d.\n",
4448 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4449 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4451 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4452 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4453 bonding, "bonding");
4454 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4455 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4456 primary, "primary");
4457 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4458 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4460 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4461 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4464 cmdline_parse_inst_t cmd_set_bonding_primary = {
4465 .f = cmd_set_bonding_primary_parsed,
4466 .help_str = "set bonding primary <slave_id> <port_id>: "
4467 "Set the primary slave for port_id",
4470 (void *)&cmd_setbonding_primary_set,
4471 (void *)&cmd_setbonding_primary_bonding,
4472 (void *)&cmd_setbonding_primary_primary,
4473 (void *)&cmd_setbonding_primary_slave,
4474 (void *)&cmd_setbonding_primary_port,
4479 /* *** ADD SLAVE *** */
4480 struct cmd_add_bonding_slave_result {
4481 cmdline_fixed_string_t add;
4482 cmdline_fixed_string_t bonding;
4483 cmdline_fixed_string_t slave;
4488 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4489 __attribute__((unused)) struct cmdline *cl,
4490 __attribute__((unused)) void *data)
4492 struct cmd_add_bonding_slave_result *res = parsed_result;
4493 portid_t master_port_id = res->port_id;
4494 portid_t slave_port_id = res->slave_id;
4496 /* Set the primary slave for a bonded device. */
4497 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4498 printf("\t Failed to add slave %d to master port = %d.\n",
4499 slave_port_id, master_port_id);
4503 set_port_slave_flag(slave_port_id);
4506 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4507 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4509 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4510 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4511 bonding, "bonding");
4512 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4513 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4515 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4516 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4518 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4519 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4522 cmdline_parse_inst_t cmd_add_bonding_slave = {
4523 .f = cmd_add_bonding_slave_parsed,
4524 .help_str = "add bonding slave <slave_id> <port_id>: "
4525 "Add a slave device to a bonded device",
4528 (void *)&cmd_addbonding_slave_add,
4529 (void *)&cmd_addbonding_slave_bonding,
4530 (void *)&cmd_addbonding_slave_slave,
4531 (void *)&cmd_addbonding_slave_slaveid,
4532 (void *)&cmd_addbonding_slave_port,
4537 /* *** REMOVE SLAVE *** */
4538 struct cmd_remove_bonding_slave_result {
4539 cmdline_fixed_string_t remove;
4540 cmdline_fixed_string_t bonding;
4541 cmdline_fixed_string_t slave;
4546 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4547 __attribute__((unused)) struct cmdline *cl,
4548 __attribute__((unused)) void *data)
4550 struct cmd_remove_bonding_slave_result *res = parsed_result;
4551 portid_t master_port_id = res->port_id;
4552 portid_t slave_port_id = res->slave_id;
4554 /* Set the primary slave for a bonded device. */
4555 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4556 printf("\t Failed to remove slave %d from master port = %d.\n",
4557 slave_port_id, master_port_id);
4561 clear_port_slave_flag(slave_port_id);
4564 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4565 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4567 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4568 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4569 bonding, "bonding");
4570 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4571 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4573 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4574 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4576 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4577 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4580 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4581 .f = cmd_remove_bonding_slave_parsed,
4582 .help_str = "remove bonding slave <slave_id> <port_id>: "
4583 "Remove a slave device from a bonded device",
4586 (void *)&cmd_removebonding_slave_remove,
4587 (void *)&cmd_removebonding_slave_bonding,
4588 (void *)&cmd_removebonding_slave_slave,
4589 (void *)&cmd_removebonding_slave_slaveid,
4590 (void *)&cmd_removebonding_slave_port,
4595 /* *** CREATE BONDED DEVICE *** */
4596 struct cmd_create_bonded_device_result {
4597 cmdline_fixed_string_t create;
4598 cmdline_fixed_string_t bonded;
4599 cmdline_fixed_string_t device;
4604 static int bond_dev_num = 0;
4606 static void cmd_create_bonded_device_parsed(void *parsed_result,
4607 __attribute__((unused)) struct cmdline *cl,
4608 __attribute__((unused)) void *data)
4610 struct cmd_create_bonded_device_result *res = parsed_result;
4611 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4614 if (test_done == 0) {
4615 printf("Please stop forwarding first\n");
4619 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4622 /* Create a new bonded device. */
4623 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4625 printf("\t Failed to create bonded device.\n");
4628 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4631 /* Update number of ports */
4632 nb_ports = rte_eth_dev_count();
4633 reconfig(port_id, res->socket);
4634 rte_eth_promiscuous_enable(port_id);
4635 ports[port_id].enabled = 1;
4640 cmdline_parse_token_string_t cmd_createbonded_device_create =
4641 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4643 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4644 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4646 cmdline_parse_token_string_t cmd_createbonded_device_device =
4647 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4649 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4650 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4652 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4653 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4656 cmdline_parse_inst_t cmd_create_bonded_device = {
4657 .f = cmd_create_bonded_device_parsed,
4658 .help_str = "create bonded device <mode> <socket>: "
4659 "Create a new bonded device with specific bonding mode and socket",
4662 (void *)&cmd_createbonded_device_create,
4663 (void *)&cmd_createbonded_device_bonded,
4664 (void *)&cmd_createbonded_device_device,
4665 (void *)&cmd_createbonded_device_mode,
4666 (void *)&cmd_createbonded_device_socket,
4671 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4672 struct cmd_set_bond_mac_addr_result {
4673 cmdline_fixed_string_t set;
4674 cmdline_fixed_string_t bonding;
4675 cmdline_fixed_string_t mac_addr;
4677 struct ether_addr address;
4680 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4681 __attribute__((unused)) struct cmdline *cl,
4682 __attribute__((unused)) void *data)
4684 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4687 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4690 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4692 /* check the return value and print it if is < 0 */
4694 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4697 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4698 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4699 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4700 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4702 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4703 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4705 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4706 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4707 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4708 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4710 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4711 .f = cmd_set_bond_mac_addr_parsed,
4713 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4715 (void *)&cmd_set_bond_mac_addr_set,
4716 (void *)&cmd_set_bond_mac_addr_bonding,
4717 (void *)&cmd_set_bond_mac_addr_mac,
4718 (void *)&cmd_set_bond_mac_addr_portnum,
4719 (void *)&cmd_set_bond_mac_addr_addr,
4725 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4726 struct cmd_set_bond_mon_period_result {
4727 cmdline_fixed_string_t set;
4728 cmdline_fixed_string_t bonding;
4729 cmdline_fixed_string_t mon_period;
4734 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4735 __attribute__((unused)) struct cmdline *cl,
4736 __attribute__((unused)) void *data)
4738 struct cmd_set_bond_mon_period_result *res = parsed_result;
4741 if (res->port_num >= nb_ports) {
4742 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4746 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4748 /* check the return value and print it if is < 0 */
4750 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4753 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4754 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4756 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4757 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4758 bonding, "bonding");
4759 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4760 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4761 mon_period, "mon_period");
4762 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4763 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4765 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4766 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4769 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4770 .f = cmd_set_bond_mon_period_parsed,
4772 .help_str = "set bonding mon_period <port_id> <period_ms>",
4774 (void *)&cmd_set_bond_mon_period_set,
4775 (void *)&cmd_set_bond_mon_period_bonding,
4776 (void *)&cmd_set_bond_mon_period_mon_period,
4777 (void *)&cmd_set_bond_mon_period_portnum,
4778 (void *)&cmd_set_bond_mon_period_period_ms,
4783 #endif /* RTE_LIBRTE_PMD_BOND */
4785 /* *** SET FORWARDING MODE *** */
4786 struct cmd_set_fwd_mode_result {
4787 cmdline_fixed_string_t set;
4788 cmdline_fixed_string_t fwd;
4789 cmdline_fixed_string_t mode;
4792 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4793 __attribute__((unused)) struct cmdline *cl,
4794 __attribute__((unused)) void *data)
4796 struct cmd_set_fwd_mode_result *res = parsed_result;
4799 set_pkt_forwarding_mode(res->mode);
4802 cmdline_parse_token_string_t cmd_setfwd_set =
4803 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4804 cmdline_parse_token_string_t cmd_setfwd_fwd =
4805 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4806 cmdline_parse_token_string_t cmd_setfwd_mode =
4807 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4808 "" /* defined at init */);
4810 cmdline_parse_inst_t cmd_set_fwd_mode = {
4811 .f = cmd_set_fwd_mode_parsed,
4813 .help_str = NULL, /* defined at init */
4815 (void *)&cmd_setfwd_set,
4816 (void *)&cmd_setfwd_fwd,
4817 (void *)&cmd_setfwd_mode,
4822 static void cmd_set_fwd_mode_init(void)
4825 static char token[128];
4826 static char help[256];
4827 cmdline_parse_token_string_t *token_struct;
4829 modes = list_pkt_forwarding_modes();
4830 snprintf(help, sizeof(help), "set fwd %s: "
4831 "Set packet forwarding mode", modes);
4832 cmd_set_fwd_mode.help_str = help;
4834 /* string token separator is # */
4835 for (c = token; *modes != '\0'; modes++)
4840 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4841 token_struct->string_data.str = token;
4844 /* *** SET RETRY FORWARDING MODE *** */
4845 struct cmd_set_fwd_retry_mode_result {
4846 cmdline_fixed_string_t set;
4847 cmdline_fixed_string_t fwd;
4848 cmdline_fixed_string_t mode;
4849 cmdline_fixed_string_t retry;
4852 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4853 __attribute__((unused)) struct cmdline *cl,
4854 __attribute__((unused)) void *data)
4856 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4859 set_pkt_forwarding_mode(res->mode);
4862 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4865 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4866 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4868 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4869 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4871 "" /* defined at init */);
4872 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4873 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4876 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4877 .f = cmd_set_fwd_retry_mode_parsed,
4879 .help_str = NULL, /* defined at init */
4881 (void *)&cmd_setfwd_retry_set,
4882 (void *)&cmd_setfwd_retry_fwd,
4883 (void *)&cmd_setfwd_retry_mode,
4884 (void *)&cmd_setfwd_retry_retry,
4889 static void cmd_set_fwd_retry_mode_init(void)
4892 static char token[128];
4893 static char help[256];
4894 cmdline_parse_token_string_t *token_struct;
4896 modes = list_pkt_forwarding_retry_modes();
4897 snprintf(help, sizeof(help), "set fwd %s retry: "
4898 "Set packet forwarding mode with retry", modes);
4899 cmd_set_fwd_retry_mode.help_str = help;
4901 /* string token separator is # */
4902 for (c = token; *modes != '\0'; modes++)
4907 token_struct = (cmdline_parse_token_string_t *)
4908 cmd_set_fwd_retry_mode.tokens[2];
4909 token_struct->string_data.str = token;
4912 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4913 struct cmd_set_burst_tx_retry_result {
4914 cmdline_fixed_string_t set;
4915 cmdline_fixed_string_t burst;
4916 cmdline_fixed_string_t tx;
4917 cmdline_fixed_string_t delay;
4919 cmdline_fixed_string_t retry;
4923 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4924 __attribute__((unused)) struct cmdline *cl,
4925 __attribute__((unused)) void *data)
4927 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4929 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4930 && !strcmp(res->tx, "tx")) {
4931 if (!strcmp(res->delay, "delay"))
4932 burst_tx_delay_time = res->time;
4933 if (!strcmp(res->retry, "retry"))
4934 burst_tx_retry_num = res->retry_num;
4939 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4940 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4941 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4942 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4944 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4945 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4946 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4947 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4948 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4949 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4950 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4951 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4952 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4953 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4955 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4956 .f = cmd_set_burst_tx_retry_parsed,
4957 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4959 (void *)&cmd_set_burst_tx_retry_set,
4960 (void *)&cmd_set_burst_tx_retry_burst,
4961 (void *)&cmd_set_burst_tx_retry_tx,
4962 (void *)&cmd_set_burst_tx_retry_delay,
4963 (void *)&cmd_set_burst_tx_retry_time,
4964 (void *)&cmd_set_burst_tx_retry_retry,
4965 (void *)&cmd_set_burst_tx_retry_retry_num,
4970 /* *** SET PROMISC MODE *** */
4971 struct cmd_set_promisc_mode_result {
4972 cmdline_fixed_string_t set;
4973 cmdline_fixed_string_t promisc;
4974 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4975 uint8_t port_num; /* valid if "allports" argument == 0 */
4976 cmdline_fixed_string_t mode;
4979 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4980 __attribute__((unused)) struct cmdline *cl,
4983 struct cmd_set_promisc_mode_result *res = parsed_result;
4987 if (!strcmp(res->mode, "on"))
4994 FOREACH_PORT(i, ports) {
4996 rte_eth_promiscuous_enable(i);
4998 rte_eth_promiscuous_disable(i);
5003 rte_eth_promiscuous_enable(res->port_num);
5005 rte_eth_promiscuous_disable(res->port_num);
5009 cmdline_parse_token_string_t cmd_setpromisc_set =
5010 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5011 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5012 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5014 cmdline_parse_token_string_t cmd_setpromisc_portall =
5015 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5017 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5018 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5020 cmdline_parse_token_string_t cmd_setpromisc_mode =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5024 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5025 .f = cmd_set_promisc_mode_parsed,
5027 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5029 (void *)&cmd_setpromisc_set,
5030 (void *)&cmd_setpromisc_promisc,
5031 (void *)&cmd_setpromisc_portall,
5032 (void *)&cmd_setpromisc_mode,
5037 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5038 .f = cmd_set_promisc_mode_parsed,
5040 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5042 (void *)&cmd_setpromisc_set,
5043 (void *)&cmd_setpromisc_promisc,
5044 (void *)&cmd_setpromisc_portnum,
5045 (void *)&cmd_setpromisc_mode,
5050 /* *** SET ALLMULTI MODE *** */
5051 struct cmd_set_allmulti_mode_result {
5052 cmdline_fixed_string_t set;
5053 cmdline_fixed_string_t allmulti;
5054 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5055 uint8_t port_num; /* valid if "allports" argument == 0 */
5056 cmdline_fixed_string_t mode;
5059 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5060 __attribute__((unused)) struct cmdline *cl,
5063 struct cmd_set_allmulti_mode_result *res = parsed_result;
5067 if (!strcmp(res->mode, "on"))
5074 FOREACH_PORT(i, ports) {
5076 rte_eth_allmulticast_enable(i);
5078 rte_eth_allmulticast_disable(i);
5083 rte_eth_allmulticast_enable(res->port_num);
5085 rte_eth_allmulticast_disable(res->port_num);
5089 cmdline_parse_token_string_t cmd_setallmulti_set =
5090 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5091 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5092 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5094 cmdline_parse_token_string_t cmd_setallmulti_portall =
5095 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5097 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5098 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5100 cmdline_parse_token_string_t cmd_setallmulti_mode =
5101 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5104 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5105 .f = cmd_set_allmulti_mode_parsed,
5107 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5109 (void *)&cmd_setallmulti_set,
5110 (void *)&cmd_setallmulti_allmulti,
5111 (void *)&cmd_setallmulti_portall,
5112 (void *)&cmd_setallmulti_mode,
5117 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5118 .f = cmd_set_allmulti_mode_parsed,
5120 .help_str = "set allmulti <port_id> on|off: "
5121 "Set allmulti mode on port_id",
5123 (void *)&cmd_setallmulti_set,
5124 (void *)&cmd_setallmulti_allmulti,
5125 (void *)&cmd_setallmulti_portnum,
5126 (void *)&cmd_setallmulti_mode,
5131 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5132 struct cmd_link_flow_ctrl_set_result {
5133 cmdline_fixed_string_t set;
5134 cmdline_fixed_string_t flow_ctrl;
5135 cmdline_fixed_string_t rx;
5136 cmdline_fixed_string_t rx_lfc_mode;
5137 cmdline_fixed_string_t tx;
5138 cmdline_fixed_string_t tx_lfc_mode;
5139 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5140 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5141 cmdline_fixed_string_t autoneg_str;
5142 cmdline_fixed_string_t autoneg;
5143 cmdline_fixed_string_t hw_str;
5144 uint32_t high_water;
5145 cmdline_fixed_string_t lw_str;
5147 cmdline_fixed_string_t pt_str;
5148 uint16_t pause_time;
5149 cmdline_fixed_string_t xon_str;
5154 cmdline_parse_token_string_t cmd_lfc_set_set =
5155 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5157 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5158 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5159 flow_ctrl, "flow_ctrl");
5160 cmdline_parse_token_string_t cmd_lfc_set_rx =
5161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5163 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5165 rx_lfc_mode, "on#off");
5166 cmdline_parse_token_string_t cmd_lfc_set_tx =
5167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5169 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5171 tx_lfc_mode, "on#off");
5172 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5174 hw_str, "high_water");
5175 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5176 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5177 high_water, UINT32);
5178 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5180 lw_str, "low_water");
5181 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5182 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5184 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5186 pt_str, "pause_time");
5187 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5188 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5189 pause_time, UINT16);
5190 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5191 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 xon_str, "send_xon");
5193 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5194 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5196 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5197 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5199 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5200 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5201 mac_ctrl_frame_fwd_mode, "on#off");
5202 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5203 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 autoneg_str, "autoneg");
5205 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5206 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5208 cmdline_parse_token_num_t cmd_lfc_set_portid =
5209 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5212 /* forward declaration */
5214 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5217 cmdline_parse_inst_t cmd_link_flow_control_set = {
5218 .f = cmd_link_flow_ctrl_set_parsed,
5220 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5221 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5222 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5224 (void *)&cmd_lfc_set_set,
5225 (void *)&cmd_lfc_set_flow_ctrl,
5226 (void *)&cmd_lfc_set_rx,
5227 (void *)&cmd_lfc_set_rx_mode,
5228 (void *)&cmd_lfc_set_tx,
5229 (void *)&cmd_lfc_set_tx_mode,
5230 (void *)&cmd_lfc_set_high_water,
5231 (void *)&cmd_lfc_set_low_water,
5232 (void *)&cmd_lfc_set_pause_time,
5233 (void *)&cmd_lfc_set_send_xon,
5234 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5235 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5236 (void *)&cmd_lfc_set_autoneg_str,
5237 (void *)&cmd_lfc_set_autoneg,
5238 (void *)&cmd_lfc_set_portid,
5243 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5244 .f = cmd_link_flow_ctrl_set_parsed,
5245 .data = (void *)&cmd_link_flow_control_set_rx,
5246 .help_str = "set flow_ctrl rx on|off <port_id>: "
5247 "Change rx flow control parameter",
5249 (void *)&cmd_lfc_set_set,
5250 (void *)&cmd_lfc_set_flow_ctrl,
5251 (void *)&cmd_lfc_set_rx,
5252 (void *)&cmd_lfc_set_rx_mode,
5253 (void *)&cmd_lfc_set_portid,
5258 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5259 .f = cmd_link_flow_ctrl_set_parsed,
5260 .data = (void *)&cmd_link_flow_control_set_tx,
5261 .help_str = "set flow_ctrl tx on|off <port_id>: "
5262 "Change tx flow control parameter",
5264 (void *)&cmd_lfc_set_set,
5265 (void *)&cmd_lfc_set_flow_ctrl,
5266 (void *)&cmd_lfc_set_tx,
5267 (void *)&cmd_lfc_set_tx_mode,
5268 (void *)&cmd_lfc_set_portid,
5273 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5274 .f = cmd_link_flow_ctrl_set_parsed,
5275 .data = (void *)&cmd_link_flow_control_set_hw,
5276 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5277 "Change high water flow control parameter",
5279 (void *)&cmd_lfc_set_set,
5280 (void *)&cmd_lfc_set_flow_ctrl,
5281 (void *)&cmd_lfc_set_high_water_str,
5282 (void *)&cmd_lfc_set_high_water,
5283 (void *)&cmd_lfc_set_portid,
5288 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5289 .f = cmd_link_flow_ctrl_set_parsed,
5290 .data = (void *)&cmd_link_flow_control_set_lw,
5291 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5292 "Change low water flow control parameter",
5294 (void *)&cmd_lfc_set_set,
5295 (void *)&cmd_lfc_set_flow_ctrl,
5296 (void *)&cmd_lfc_set_low_water_str,
5297 (void *)&cmd_lfc_set_low_water,
5298 (void *)&cmd_lfc_set_portid,
5303 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5304 .f = cmd_link_flow_ctrl_set_parsed,
5305 .data = (void *)&cmd_link_flow_control_set_pt,
5306 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5307 "Change pause time flow control parameter",
5309 (void *)&cmd_lfc_set_set,
5310 (void *)&cmd_lfc_set_flow_ctrl,
5311 (void *)&cmd_lfc_set_pause_time_str,
5312 (void *)&cmd_lfc_set_pause_time,
5313 (void *)&cmd_lfc_set_portid,
5318 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5319 .f = cmd_link_flow_ctrl_set_parsed,
5320 .data = (void *)&cmd_link_flow_control_set_xon,
5321 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5322 "Change send_xon flow control parameter",
5324 (void *)&cmd_lfc_set_set,
5325 (void *)&cmd_lfc_set_flow_ctrl,
5326 (void *)&cmd_lfc_set_send_xon_str,
5327 (void *)&cmd_lfc_set_send_xon,
5328 (void *)&cmd_lfc_set_portid,
5333 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5334 .f = cmd_link_flow_ctrl_set_parsed,
5335 .data = (void *)&cmd_link_flow_control_set_macfwd,
5336 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5337 "Change mac ctrl fwd flow control parameter",
5339 (void *)&cmd_lfc_set_set,
5340 (void *)&cmd_lfc_set_flow_ctrl,
5341 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5342 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5343 (void *)&cmd_lfc_set_portid,
5348 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5349 .f = cmd_link_flow_ctrl_set_parsed,
5350 .data = (void *)&cmd_link_flow_control_set_autoneg,
5351 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5352 "Change autoneg flow control parameter",
5354 (void *)&cmd_lfc_set_set,
5355 (void *)&cmd_lfc_set_flow_ctrl,
5356 (void *)&cmd_lfc_set_autoneg_str,
5357 (void *)&cmd_lfc_set_autoneg,
5358 (void *)&cmd_lfc_set_portid,
5364 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5365 __attribute__((unused)) struct cmdline *cl,
5368 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5369 cmdline_parse_inst_t *cmd = data;
5370 struct rte_eth_fc_conf fc_conf;
5376 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5377 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5378 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5379 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5381 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5382 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5385 /* Partial command line, retrieve current configuration */
5387 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5389 printf("cannot get current flow ctrl parameters, return"
5390 "code = %d\n", ret);
5394 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5395 (fc_conf.mode == RTE_FC_FULL))
5397 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5398 (fc_conf.mode == RTE_FC_FULL))
5402 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5403 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5405 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5406 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5408 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5410 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5411 fc_conf.high_water = res->high_water;
5413 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5414 fc_conf.low_water = res->low_water;
5416 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5417 fc_conf.pause_time = res->pause_time;
5419 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5420 fc_conf.send_xon = res->send_xon;
5422 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5423 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5424 fc_conf.mac_ctrl_frame_fwd = 1;
5426 fc_conf.mac_ctrl_frame_fwd = 0;
5429 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5430 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5432 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5434 printf("bad flow contrl parameter, return code = %d \n", ret);
5437 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5438 struct cmd_priority_flow_ctrl_set_result {
5439 cmdline_fixed_string_t set;
5440 cmdline_fixed_string_t pfc_ctrl;
5441 cmdline_fixed_string_t rx;
5442 cmdline_fixed_string_t rx_pfc_mode;
5443 cmdline_fixed_string_t tx;
5444 cmdline_fixed_string_t tx_pfc_mode;
5445 uint32_t high_water;
5447 uint16_t pause_time;
5453 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5454 __attribute__((unused)) struct cmdline *cl,
5455 __attribute__((unused)) void *data)
5457 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5458 struct rte_eth_pfc_conf pfc_conf;
5459 int rx_fc_enable, tx_fc_enable;
5463 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5464 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5465 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5466 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5468 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5469 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5472 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5473 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5474 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5475 pfc_conf.fc.high_water = res->high_water;
5476 pfc_conf.fc.low_water = res->low_water;
5477 pfc_conf.fc.pause_time = res->pause_time;
5478 pfc_conf.priority = res->priority;
5480 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5482 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5485 cmdline_parse_token_string_t cmd_pfc_set_set =
5486 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5488 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5489 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5490 pfc_ctrl, "pfc_ctrl");
5491 cmdline_parse_token_string_t cmd_pfc_set_rx =
5492 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5494 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5495 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5496 rx_pfc_mode, "on#off");
5497 cmdline_parse_token_string_t cmd_pfc_set_tx =
5498 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5500 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5501 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5502 tx_pfc_mode, "on#off");
5503 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5504 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5505 high_water, UINT32);
5506 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5507 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5509 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5510 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5511 pause_time, UINT16);
5512 cmdline_parse_token_num_t cmd_pfc_set_priority =
5513 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5515 cmdline_parse_token_num_t cmd_pfc_set_portid =
5516 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5519 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5520 .f = cmd_priority_flow_ctrl_set_parsed,
5522 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5523 "<pause_time> <priority> <port_id>: "
5524 "Configure the Ethernet priority flow control",
5526 (void *)&cmd_pfc_set_set,
5527 (void *)&cmd_pfc_set_flow_ctrl,
5528 (void *)&cmd_pfc_set_rx,
5529 (void *)&cmd_pfc_set_rx_mode,
5530 (void *)&cmd_pfc_set_tx,
5531 (void *)&cmd_pfc_set_tx_mode,
5532 (void *)&cmd_pfc_set_high_water,
5533 (void *)&cmd_pfc_set_low_water,
5534 (void *)&cmd_pfc_set_pause_time,
5535 (void *)&cmd_pfc_set_priority,
5536 (void *)&cmd_pfc_set_portid,
5541 /* *** RESET CONFIGURATION *** */
5542 struct cmd_reset_result {
5543 cmdline_fixed_string_t reset;
5544 cmdline_fixed_string_t def;
5547 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5549 __attribute__((unused)) void *data)
5551 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5552 set_def_fwd_config();
5555 cmdline_parse_token_string_t cmd_reset_set =
5556 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5557 cmdline_parse_token_string_t cmd_reset_def =
5558 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5561 cmdline_parse_inst_t cmd_reset = {
5562 .f = cmd_reset_parsed,
5564 .help_str = "set default: Reset default forwarding configuration",
5566 (void *)&cmd_reset_set,
5567 (void *)&cmd_reset_def,
5572 /* *** START FORWARDING *** */
5573 struct cmd_start_result {
5574 cmdline_fixed_string_t start;
5577 cmdline_parse_token_string_t cmd_start_start =
5578 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5580 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5581 __attribute__((unused)) struct cmdline *cl,
5582 __attribute__((unused)) void *data)
5584 start_packet_forwarding(0);
5587 cmdline_parse_inst_t cmd_start = {
5588 .f = cmd_start_parsed,
5590 .help_str = "start: Start packet forwarding",
5592 (void *)&cmd_start_start,
5597 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5598 struct cmd_start_tx_first_result {
5599 cmdline_fixed_string_t start;
5600 cmdline_fixed_string_t tx_first;
5604 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5605 __attribute__((unused)) struct cmdline *cl,
5606 __attribute__((unused)) void *data)
5608 start_packet_forwarding(1);
5611 cmdline_parse_token_string_t cmd_start_tx_first_start =
5612 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5614 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5615 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5616 tx_first, "tx_first");
5618 cmdline_parse_inst_t cmd_start_tx_first = {
5619 .f = cmd_start_tx_first_parsed,
5621 .help_str = "start tx_first: Start packet forwarding, "
5622 "after sending 1 burst of packets",
5624 (void *)&cmd_start_tx_first_start,
5625 (void *)&cmd_start_tx_first_tx_first,
5630 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5631 struct cmd_start_tx_first_n_result {
5632 cmdline_fixed_string_t start;
5633 cmdline_fixed_string_t tx_first;
5638 cmd_start_tx_first_n_parsed(void *parsed_result,
5639 __attribute__((unused)) struct cmdline *cl,
5640 __attribute__((unused)) void *data)
5642 struct cmd_start_tx_first_n_result *res = parsed_result;
5644 start_packet_forwarding(res->tx_num);
5647 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5648 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5650 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5651 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5652 tx_first, "tx_first");
5653 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5654 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5657 cmdline_parse_inst_t cmd_start_tx_first_n = {
5658 .f = cmd_start_tx_first_n_parsed,
5660 .help_str = "start tx_first <num>: "
5661 "packet forwarding, after sending <num> bursts of packets",
5663 (void *)&cmd_start_tx_first_n_start,
5664 (void *)&cmd_start_tx_first_n_tx_first,
5665 (void *)&cmd_start_tx_first_n_tx_num,
5670 /* *** SET LINK UP *** */
5671 struct cmd_set_link_up_result {
5672 cmdline_fixed_string_t set;
5673 cmdline_fixed_string_t link_up;
5674 cmdline_fixed_string_t port;
5678 cmdline_parse_token_string_t cmd_set_link_up_set =
5679 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5680 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5683 cmdline_parse_token_string_t cmd_set_link_up_port =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5685 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5686 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5688 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5689 __attribute__((unused)) struct cmdline *cl,
5690 __attribute__((unused)) void *data)
5692 struct cmd_set_link_up_result *res = parsed_result;
5693 dev_set_link_up(res->port_id);
5696 cmdline_parse_inst_t cmd_set_link_up = {
5697 .f = cmd_set_link_up_parsed,
5699 .help_str = "set link-up port <port id>",
5701 (void *)&cmd_set_link_up_set,
5702 (void *)&cmd_set_link_up_link_up,
5703 (void *)&cmd_set_link_up_port,
5704 (void *)&cmd_set_link_up_port_id,
5709 /* *** SET LINK DOWN *** */
5710 struct cmd_set_link_down_result {
5711 cmdline_fixed_string_t set;
5712 cmdline_fixed_string_t link_down;
5713 cmdline_fixed_string_t port;
5717 cmdline_parse_token_string_t cmd_set_link_down_set =
5718 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5719 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5720 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5722 cmdline_parse_token_string_t cmd_set_link_down_port =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5724 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5725 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5727 static void cmd_set_link_down_parsed(
5728 __attribute__((unused)) void *parsed_result,
5729 __attribute__((unused)) struct cmdline *cl,
5730 __attribute__((unused)) void *data)
5732 struct cmd_set_link_down_result *res = parsed_result;
5733 dev_set_link_down(res->port_id);
5736 cmdline_parse_inst_t cmd_set_link_down = {
5737 .f = cmd_set_link_down_parsed,
5739 .help_str = "set link-down port <port id>",
5741 (void *)&cmd_set_link_down_set,
5742 (void *)&cmd_set_link_down_link_down,
5743 (void *)&cmd_set_link_down_port,
5744 (void *)&cmd_set_link_down_port_id,
5749 /* *** SHOW CFG *** */
5750 struct cmd_showcfg_result {
5751 cmdline_fixed_string_t show;
5752 cmdline_fixed_string_t cfg;
5753 cmdline_fixed_string_t what;
5756 static void cmd_showcfg_parsed(void *parsed_result,
5757 __attribute__((unused)) struct cmdline *cl,
5758 __attribute__((unused)) void *data)
5760 struct cmd_showcfg_result *res = parsed_result;
5761 if (!strcmp(res->what, "rxtx"))
5762 rxtx_config_display();
5763 else if (!strcmp(res->what, "cores"))
5764 fwd_lcores_config_display();
5765 else if (!strcmp(res->what, "fwd"))
5766 pkt_fwd_config_display(&cur_fwd_config);
5767 else if (!strcmp(res->what, "txpkts"))
5768 show_tx_pkt_segments();
5771 cmdline_parse_token_string_t cmd_showcfg_show =
5772 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5773 cmdline_parse_token_string_t cmd_showcfg_port =
5774 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5775 cmdline_parse_token_string_t cmd_showcfg_what =
5776 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5777 "rxtx#cores#fwd#txpkts");
5779 cmdline_parse_inst_t cmd_showcfg = {
5780 .f = cmd_showcfg_parsed,
5782 .help_str = "show config rxtx|cores|fwd|txpkts",
5784 (void *)&cmd_showcfg_show,
5785 (void *)&cmd_showcfg_port,
5786 (void *)&cmd_showcfg_what,
5791 /* *** SHOW ALL PORT INFO *** */
5792 struct cmd_showportall_result {
5793 cmdline_fixed_string_t show;
5794 cmdline_fixed_string_t port;
5795 cmdline_fixed_string_t what;
5796 cmdline_fixed_string_t all;
5799 static void cmd_showportall_parsed(void *parsed_result,
5800 __attribute__((unused)) struct cmdline *cl,
5801 __attribute__((unused)) void *data)
5805 struct cmd_showportall_result *res = parsed_result;
5806 if (!strcmp(res->show, "clear")) {
5807 if (!strcmp(res->what, "stats"))
5808 FOREACH_PORT(i, ports)
5810 else if (!strcmp(res->what, "xstats"))
5811 FOREACH_PORT(i, ports)
5812 nic_xstats_clear(i);
5813 } else if (!strcmp(res->what, "info"))
5814 FOREACH_PORT(i, ports)
5815 port_infos_display(i);
5816 else if (!strcmp(res->what, "stats"))
5817 FOREACH_PORT(i, ports)
5818 nic_stats_display(i);
5819 else if (!strcmp(res->what, "xstats"))
5820 FOREACH_PORT(i, ports)
5821 nic_xstats_display(i);
5822 else if (!strcmp(res->what, "fdir"))
5823 FOREACH_PORT(i, ports)
5825 else if (!strcmp(res->what, "stat_qmap"))
5826 FOREACH_PORT(i, ports)
5827 nic_stats_mapping_display(i);
5828 else if (!strcmp(res->what, "dcb_tc"))
5829 FOREACH_PORT(i, ports)
5830 port_dcb_info_display(i);
5833 cmdline_parse_token_string_t cmd_showportall_show =
5834 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5836 cmdline_parse_token_string_t cmd_showportall_port =
5837 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5838 cmdline_parse_token_string_t cmd_showportall_what =
5839 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5840 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5841 cmdline_parse_token_string_t cmd_showportall_all =
5842 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5843 cmdline_parse_inst_t cmd_showportall = {
5844 .f = cmd_showportall_parsed,
5846 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5848 (void *)&cmd_showportall_show,
5849 (void *)&cmd_showportall_port,
5850 (void *)&cmd_showportall_what,
5851 (void *)&cmd_showportall_all,
5856 /* *** SHOW PORT INFO *** */
5857 struct cmd_showport_result {
5858 cmdline_fixed_string_t show;
5859 cmdline_fixed_string_t port;
5860 cmdline_fixed_string_t what;
5864 static void cmd_showport_parsed(void *parsed_result,
5865 __attribute__((unused)) struct cmdline *cl,
5866 __attribute__((unused)) void *data)
5868 struct cmd_showport_result *res = parsed_result;
5869 if (!strcmp(res->show, "clear")) {
5870 if (!strcmp(res->what, "stats"))
5871 nic_stats_clear(res->portnum);
5872 else if (!strcmp(res->what, "xstats"))
5873 nic_xstats_clear(res->portnum);
5874 } else if (!strcmp(res->what, "info"))
5875 port_infos_display(res->portnum);
5876 else if (!strcmp(res->what, "stats"))
5877 nic_stats_display(res->portnum);
5878 else if (!strcmp(res->what, "xstats"))
5879 nic_xstats_display(res->portnum);
5880 else if (!strcmp(res->what, "fdir"))
5881 fdir_get_infos(res->portnum);
5882 else if (!strcmp(res->what, "stat_qmap"))
5883 nic_stats_mapping_display(res->portnum);
5884 else if (!strcmp(res->what, "dcb_tc"))
5885 port_dcb_info_display(res->portnum);
5888 cmdline_parse_token_string_t cmd_showport_show =
5889 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5891 cmdline_parse_token_string_t cmd_showport_port =
5892 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5893 cmdline_parse_token_string_t cmd_showport_what =
5894 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5895 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5896 cmdline_parse_token_num_t cmd_showport_portnum =
5897 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5899 cmdline_parse_inst_t cmd_showport = {
5900 .f = cmd_showport_parsed,
5902 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5905 (void *)&cmd_showport_show,
5906 (void *)&cmd_showport_port,
5907 (void *)&cmd_showport_what,
5908 (void *)&cmd_showport_portnum,
5913 /* *** SHOW QUEUE INFO *** */
5914 struct cmd_showqueue_result {
5915 cmdline_fixed_string_t show;
5916 cmdline_fixed_string_t type;
5917 cmdline_fixed_string_t what;
5923 cmd_showqueue_parsed(void *parsed_result,
5924 __attribute__((unused)) struct cmdline *cl,
5925 __attribute__((unused)) void *data)
5927 struct cmd_showqueue_result *res = parsed_result;
5929 if (!strcmp(res->type, "rxq"))
5930 rx_queue_infos_display(res->portnum, res->queuenum);
5931 else if (!strcmp(res->type, "txq"))
5932 tx_queue_infos_display(res->portnum, res->queuenum);
5935 cmdline_parse_token_string_t cmd_showqueue_show =
5936 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5937 cmdline_parse_token_string_t cmd_showqueue_type =
5938 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5939 cmdline_parse_token_string_t cmd_showqueue_what =
5940 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5941 cmdline_parse_token_num_t cmd_showqueue_portnum =
5942 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5943 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5944 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5946 cmdline_parse_inst_t cmd_showqueue = {
5947 .f = cmd_showqueue_parsed,
5949 .help_str = "show rxq|txq info <port_id> <queue_id>",
5951 (void *)&cmd_showqueue_show,
5952 (void *)&cmd_showqueue_type,
5953 (void *)&cmd_showqueue_what,
5954 (void *)&cmd_showqueue_portnum,
5955 (void *)&cmd_showqueue_queuenum,
5960 /* *** READ PORT REGISTER *** */
5961 struct cmd_read_reg_result {
5962 cmdline_fixed_string_t read;
5963 cmdline_fixed_string_t reg;
5969 cmd_read_reg_parsed(void *parsed_result,
5970 __attribute__((unused)) struct cmdline *cl,
5971 __attribute__((unused)) void *data)
5973 struct cmd_read_reg_result *res = parsed_result;
5974 port_reg_display(res->port_id, res->reg_off);
5977 cmdline_parse_token_string_t cmd_read_reg_read =
5978 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5979 cmdline_parse_token_string_t cmd_read_reg_reg =
5980 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5981 cmdline_parse_token_num_t cmd_read_reg_port_id =
5982 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5983 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5984 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5986 cmdline_parse_inst_t cmd_read_reg = {
5987 .f = cmd_read_reg_parsed,
5989 .help_str = "read reg <port_id> <reg_off>",
5991 (void *)&cmd_read_reg_read,
5992 (void *)&cmd_read_reg_reg,
5993 (void *)&cmd_read_reg_port_id,
5994 (void *)&cmd_read_reg_reg_off,
5999 /* *** READ PORT REGISTER BIT FIELD *** */
6000 struct cmd_read_reg_bit_field_result {
6001 cmdline_fixed_string_t read;
6002 cmdline_fixed_string_t regfield;
6010 cmd_read_reg_bit_field_parsed(void *parsed_result,
6011 __attribute__((unused)) struct cmdline *cl,
6012 __attribute__((unused)) void *data)
6014 struct cmd_read_reg_bit_field_result *res = parsed_result;
6015 port_reg_bit_field_display(res->port_id, res->reg_off,
6016 res->bit1_pos, res->bit2_pos);
6019 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6020 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6022 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6023 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6024 regfield, "regfield");
6025 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6026 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6028 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6029 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6031 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6032 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6034 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6035 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6038 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6039 .f = cmd_read_reg_bit_field_parsed,
6041 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6042 "Read register bit field between bit_x and bit_y included",
6044 (void *)&cmd_read_reg_bit_field_read,
6045 (void *)&cmd_read_reg_bit_field_regfield,
6046 (void *)&cmd_read_reg_bit_field_port_id,
6047 (void *)&cmd_read_reg_bit_field_reg_off,
6048 (void *)&cmd_read_reg_bit_field_bit1_pos,
6049 (void *)&cmd_read_reg_bit_field_bit2_pos,
6054 /* *** READ PORT REGISTER BIT *** */
6055 struct cmd_read_reg_bit_result {
6056 cmdline_fixed_string_t read;
6057 cmdline_fixed_string_t regbit;
6064 cmd_read_reg_bit_parsed(void *parsed_result,
6065 __attribute__((unused)) struct cmdline *cl,
6066 __attribute__((unused)) void *data)
6068 struct cmd_read_reg_bit_result *res = parsed_result;
6069 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6072 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6073 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6074 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6075 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6077 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6078 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6079 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6080 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6081 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6082 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6084 cmdline_parse_inst_t cmd_read_reg_bit = {
6085 .f = cmd_read_reg_bit_parsed,
6087 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6089 (void *)&cmd_read_reg_bit_read,
6090 (void *)&cmd_read_reg_bit_regbit,
6091 (void *)&cmd_read_reg_bit_port_id,
6092 (void *)&cmd_read_reg_bit_reg_off,
6093 (void *)&cmd_read_reg_bit_bit_pos,
6098 /* *** WRITE PORT REGISTER *** */
6099 struct cmd_write_reg_result {
6100 cmdline_fixed_string_t write;
6101 cmdline_fixed_string_t reg;
6108 cmd_write_reg_parsed(void *parsed_result,
6109 __attribute__((unused)) struct cmdline *cl,
6110 __attribute__((unused)) void *data)
6112 struct cmd_write_reg_result *res = parsed_result;
6113 port_reg_set(res->port_id, res->reg_off, res->value);
6116 cmdline_parse_token_string_t cmd_write_reg_write =
6117 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6118 cmdline_parse_token_string_t cmd_write_reg_reg =
6119 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6120 cmdline_parse_token_num_t cmd_write_reg_port_id =
6121 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6122 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6123 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6124 cmdline_parse_token_num_t cmd_write_reg_value =
6125 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6127 cmdline_parse_inst_t cmd_write_reg = {
6128 .f = cmd_write_reg_parsed,
6130 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6132 (void *)&cmd_write_reg_write,
6133 (void *)&cmd_write_reg_reg,
6134 (void *)&cmd_write_reg_port_id,
6135 (void *)&cmd_write_reg_reg_off,
6136 (void *)&cmd_write_reg_value,
6141 /* *** WRITE PORT REGISTER BIT FIELD *** */
6142 struct cmd_write_reg_bit_field_result {
6143 cmdline_fixed_string_t write;
6144 cmdline_fixed_string_t regfield;
6153 cmd_write_reg_bit_field_parsed(void *parsed_result,
6154 __attribute__((unused)) struct cmdline *cl,
6155 __attribute__((unused)) void *data)
6157 struct cmd_write_reg_bit_field_result *res = parsed_result;
6158 port_reg_bit_field_set(res->port_id, res->reg_off,
6159 res->bit1_pos, res->bit2_pos, res->value);
6162 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6163 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6165 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6166 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6167 regfield, "regfield");
6168 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6169 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6171 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6172 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6174 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6175 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6177 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6178 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6180 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6181 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6184 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6185 .f = cmd_write_reg_bit_field_parsed,
6187 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6189 "Set register bit field between bit_x and bit_y included",
6191 (void *)&cmd_write_reg_bit_field_write,
6192 (void *)&cmd_write_reg_bit_field_regfield,
6193 (void *)&cmd_write_reg_bit_field_port_id,
6194 (void *)&cmd_write_reg_bit_field_reg_off,
6195 (void *)&cmd_write_reg_bit_field_bit1_pos,
6196 (void *)&cmd_write_reg_bit_field_bit2_pos,
6197 (void *)&cmd_write_reg_bit_field_value,
6202 /* *** WRITE PORT REGISTER BIT *** */
6203 struct cmd_write_reg_bit_result {
6204 cmdline_fixed_string_t write;
6205 cmdline_fixed_string_t regbit;
6213 cmd_write_reg_bit_parsed(void *parsed_result,
6214 __attribute__((unused)) struct cmdline *cl,
6215 __attribute__((unused)) void *data)
6217 struct cmd_write_reg_bit_result *res = parsed_result;
6218 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6221 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6222 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6224 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6225 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6227 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6228 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6229 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6230 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6231 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6232 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6233 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6234 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6236 cmdline_parse_inst_t cmd_write_reg_bit = {
6237 .f = cmd_write_reg_bit_parsed,
6239 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6242 (void *)&cmd_write_reg_bit_write,
6243 (void *)&cmd_write_reg_bit_regbit,
6244 (void *)&cmd_write_reg_bit_port_id,
6245 (void *)&cmd_write_reg_bit_reg_off,
6246 (void *)&cmd_write_reg_bit_bit_pos,
6247 (void *)&cmd_write_reg_bit_value,
6252 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6253 struct cmd_read_rxd_txd_result {
6254 cmdline_fixed_string_t read;
6255 cmdline_fixed_string_t rxd_txd;
6262 cmd_read_rxd_txd_parsed(void *parsed_result,
6263 __attribute__((unused)) struct cmdline *cl,
6264 __attribute__((unused)) void *data)
6266 struct cmd_read_rxd_txd_result *res = parsed_result;
6268 if (!strcmp(res->rxd_txd, "rxd"))
6269 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6270 else if (!strcmp(res->rxd_txd, "txd"))
6271 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6274 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6275 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6276 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6277 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6279 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6280 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6281 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6282 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6283 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6284 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6286 cmdline_parse_inst_t cmd_read_rxd_txd = {
6287 .f = cmd_read_rxd_txd_parsed,
6289 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6291 (void *)&cmd_read_rxd_txd_read,
6292 (void *)&cmd_read_rxd_txd_rxd_txd,
6293 (void *)&cmd_read_rxd_txd_port_id,
6294 (void *)&cmd_read_rxd_txd_queue_id,
6295 (void *)&cmd_read_rxd_txd_desc_id,
6301 struct cmd_quit_result {
6302 cmdline_fixed_string_t quit;
6305 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6307 __attribute__((unused)) void *data)
6313 cmdline_parse_token_string_t cmd_quit_quit =
6314 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6316 cmdline_parse_inst_t cmd_quit = {
6317 .f = cmd_quit_parsed,
6319 .help_str = "quit: Exit application",
6321 (void *)&cmd_quit_quit,
6326 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6327 struct cmd_mac_addr_result {
6328 cmdline_fixed_string_t mac_addr_cmd;
6329 cmdline_fixed_string_t what;
6331 struct ether_addr address;
6334 static void cmd_mac_addr_parsed(void *parsed_result,
6335 __attribute__((unused)) struct cmdline *cl,
6336 __attribute__((unused)) void *data)
6338 struct cmd_mac_addr_result *res = parsed_result;
6341 if (strcmp(res->what, "add") == 0)
6342 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6344 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6346 /* check the return value and print it if is < 0 */
6348 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6352 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6353 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6355 cmdline_parse_token_string_t cmd_mac_addr_what =
6356 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6358 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6359 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6360 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6361 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6363 cmdline_parse_inst_t cmd_mac_addr = {
6364 .f = cmd_mac_addr_parsed,
6366 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6367 "Add/Remove MAC address on port_id",
6369 (void *)&cmd_mac_addr_cmd,
6370 (void *)&cmd_mac_addr_what,
6371 (void *)&cmd_mac_addr_portnum,
6372 (void *)&cmd_mac_addr_addr,
6378 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6379 struct cmd_set_qmap_result {
6380 cmdline_fixed_string_t set;
6381 cmdline_fixed_string_t qmap;
6382 cmdline_fixed_string_t what;
6389 cmd_set_qmap_parsed(void *parsed_result,
6390 __attribute__((unused)) struct cmdline *cl,
6391 __attribute__((unused)) void *data)
6393 struct cmd_set_qmap_result *res = parsed_result;
6394 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6396 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6399 cmdline_parse_token_string_t cmd_setqmap_set =
6400 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6402 cmdline_parse_token_string_t cmd_setqmap_qmap =
6403 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6405 cmdline_parse_token_string_t cmd_setqmap_what =
6406 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6408 cmdline_parse_token_num_t cmd_setqmap_portid =
6409 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6411 cmdline_parse_token_num_t cmd_setqmap_queueid =
6412 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6414 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6415 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6418 cmdline_parse_inst_t cmd_set_qmap = {
6419 .f = cmd_set_qmap_parsed,
6421 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6422 "Set statistics mapping value on tx|rx queue_id of port_id",
6424 (void *)&cmd_setqmap_set,
6425 (void *)&cmd_setqmap_qmap,
6426 (void *)&cmd_setqmap_what,
6427 (void *)&cmd_setqmap_portid,
6428 (void *)&cmd_setqmap_queueid,
6429 (void *)&cmd_setqmap_mapvalue,
6434 /* *** CONFIGURE UNICAST HASH TABLE *** */
6435 struct cmd_set_uc_hash_table {
6436 cmdline_fixed_string_t set;
6437 cmdline_fixed_string_t port;
6439 cmdline_fixed_string_t what;
6440 struct ether_addr address;
6441 cmdline_fixed_string_t mode;
6445 cmd_set_uc_hash_parsed(void *parsed_result,
6446 __attribute__((unused)) struct cmdline *cl,
6447 __attribute__((unused)) void *data)
6450 struct cmd_set_uc_hash_table *res = parsed_result;
6452 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6454 if (strcmp(res->what, "uta") == 0)
6455 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6456 &res->address,(uint8_t)is_on);
6458 printf("bad unicast hash table parameter, return code = %d \n", ret);
6462 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6465 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6468 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6469 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6471 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6474 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6475 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6477 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6481 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6482 .f = cmd_set_uc_hash_parsed,
6484 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6486 (void *)&cmd_set_uc_hash_set,
6487 (void *)&cmd_set_uc_hash_port,
6488 (void *)&cmd_set_uc_hash_portid,
6489 (void *)&cmd_set_uc_hash_what,
6490 (void *)&cmd_set_uc_hash_mac,
6491 (void *)&cmd_set_uc_hash_mode,
6496 struct cmd_set_uc_all_hash_table {
6497 cmdline_fixed_string_t set;
6498 cmdline_fixed_string_t port;
6500 cmdline_fixed_string_t what;
6501 cmdline_fixed_string_t value;
6502 cmdline_fixed_string_t mode;
6506 cmd_set_uc_all_hash_parsed(void *parsed_result,
6507 __attribute__((unused)) struct cmdline *cl,
6508 __attribute__((unused)) void *data)
6511 struct cmd_set_uc_all_hash_table *res = parsed_result;
6513 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6515 if ((strcmp(res->what, "uta") == 0) &&
6516 (strcmp(res->value, "all") == 0))
6517 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6519 printf("bad unicast hash table parameter,"
6520 "return code = %d \n", ret);
6523 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6524 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6526 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6527 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6529 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6530 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6532 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6533 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6535 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6536 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6538 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6539 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6542 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6543 .f = cmd_set_uc_all_hash_parsed,
6545 .help_str = "set port <port_id> uta all on|off",
6547 (void *)&cmd_set_uc_all_hash_set,
6548 (void *)&cmd_set_uc_all_hash_port,
6549 (void *)&cmd_set_uc_all_hash_portid,
6550 (void *)&cmd_set_uc_all_hash_what,
6551 (void *)&cmd_set_uc_all_hash_value,
6552 (void *)&cmd_set_uc_all_hash_mode,
6557 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6558 struct cmd_set_vf_macvlan_filter {
6559 cmdline_fixed_string_t set;
6560 cmdline_fixed_string_t port;
6562 cmdline_fixed_string_t vf;
6564 struct ether_addr address;
6565 cmdline_fixed_string_t filter_type;
6566 cmdline_fixed_string_t mode;
6570 cmd_set_vf_macvlan_parsed(void *parsed_result,
6571 __attribute__((unused)) struct cmdline *cl,
6572 __attribute__((unused)) void *data)
6575 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6576 struct rte_eth_mac_filter filter;
6578 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6580 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6582 /* set VF MAC filter */
6586 filter.dst_id = res->vf_id;
6588 if (!strcmp(res->filter_type, "exact-mac"))
6589 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6590 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6591 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6592 else if (!strcmp(res->filter_type, "hashmac"))
6593 filter.filter_type = RTE_MAC_HASH_MATCH;
6594 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6595 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6597 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6600 ret = rte_eth_dev_filter_ctrl(res->port_id,
6601 RTE_ETH_FILTER_MACVLAN,
6605 ret = rte_eth_dev_filter_ctrl(res->port_id,
6606 RTE_ETH_FILTER_MACVLAN,
6607 RTE_ETH_FILTER_DELETE,
6611 printf("bad set MAC hash parameter, return code = %d\n", ret);
6615 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6618 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6621 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6622 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6624 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6625 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6627 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6628 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6630 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6631 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6633 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6634 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6635 filter_type, "exact-mac#exact-mac-vlan"
6636 "#hashmac#hashmac-vlan");
6637 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6638 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6641 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6642 .f = cmd_set_vf_macvlan_parsed,
6644 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6645 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6646 "Exact match rule: exact match of MAC or MAC and VLAN; "
6647 "hash match rule: hash match of MAC and exact match of VLAN",
6649 (void *)&cmd_set_vf_macvlan_set,
6650 (void *)&cmd_set_vf_macvlan_port,
6651 (void *)&cmd_set_vf_macvlan_portid,
6652 (void *)&cmd_set_vf_macvlan_vf,
6653 (void *)&cmd_set_vf_macvlan_vf_id,
6654 (void *)&cmd_set_vf_macvlan_mac,
6655 (void *)&cmd_set_vf_macvlan_filter_type,
6656 (void *)&cmd_set_vf_macvlan_mode,
6661 #ifdef RTE_LIBRTE_IXGBE_PMD
6662 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6663 struct cmd_set_vf_traffic {
6664 cmdline_fixed_string_t set;
6665 cmdline_fixed_string_t port;
6667 cmdline_fixed_string_t vf;
6669 cmdline_fixed_string_t what;
6670 cmdline_fixed_string_t mode;
6674 cmd_set_vf_traffic_parsed(void *parsed_result,
6675 __attribute__((unused)) struct cmdline *cl,
6676 __attribute__((unused)) void *data)
6678 struct cmd_set_vf_traffic *res = parsed_result;
6679 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6680 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6682 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6685 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6686 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6688 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6689 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6691 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6692 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6694 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6695 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6697 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6698 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6700 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6701 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6703 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6704 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6707 cmdline_parse_inst_t cmd_set_vf_traffic = {
6708 .f = cmd_set_vf_traffic_parsed,
6710 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6712 (void *)&cmd_setvf_traffic_set,
6713 (void *)&cmd_setvf_traffic_port,
6714 (void *)&cmd_setvf_traffic_portid,
6715 (void *)&cmd_setvf_traffic_vf,
6716 (void *)&cmd_setvf_traffic_vfid,
6717 (void *)&cmd_setvf_traffic_what,
6718 (void *)&cmd_setvf_traffic_mode,
6723 /* *** CONFIGURE VF RECEIVE MODE *** */
6724 struct cmd_set_vf_rxmode {
6725 cmdline_fixed_string_t set;
6726 cmdline_fixed_string_t port;
6728 cmdline_fixed_string_t vf;
6730 cmdline_fixed_string_t what;
6731 cmdline_fixed_string_t mode;
6732 cmdline_fixed_string_t on;
6736 cmd_set_vf_rxmode_parsed(void *parsed_result,
6737 __attribute__((unused)) struct cmdline *cl,
6738 __attribute__((unused)) void *data)
6741 uint16_t rx_mode = 0;
6742 struct cmd_set_vf_rxmode *res = parsed_result;
6744 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6745 if (!strcmp(res->what,"rxmode")) {
6746 if (!strcmp(res->mode, "AUPE"))
6747 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6748 else if (!strcmp(res->mode, "ROPE"))
6749 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6750 else if (!strcmp(res->mode, "BAM"))
6751 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6752 else if (!strncmp(res->mode, "MPE",3))
6753 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6756 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6758 printf("bad VF receive mode parameter, return code = %d \n",
6762 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6765 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6768 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6769 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6771 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6774 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6775 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6777 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6778 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6780 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6781 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6782 mode, "AUPE#ROPE#BAM#MPE");
6783 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6784 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6787 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6788 .f = cmd_set_vf_rxmode_parsed,
6790 .help_str = "set port <port_id> vf <vf_id> rxmode "
6791 "AUPE|ROPE|BAM|MPE on|off",
6793 (void *)&cmd_set_vf_rxmode_set,
6794 (void *)&cmd_set_vf_rxmode_port,
6795 (void *)&cmd_set_vf_rxmode_portid,
6796 (void *)&cmd_set_vf_rxmode_vf,
6797 (void *)&cmd_set_vf_rxmode_vfid,
6798 (void *)&cmd_set_vf_rxmode_what,
6799 (void *)&cmd_set_vf_rxmode_mode,
6800 (void *)&cmd_set_vf_rxmode_on,
6806 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6807 struct cmd_vf_mac_addr_result {
6808 cmdline_fixed_string_t mac_addr_cmd;
6809 cmdline_fixed_string_t what;
6810 cmdline_fixed_string_t port;
6812 cmdline_fixed_string_t vf;
6814 struct ether_addr address;
6817 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6818 __attribute__((unused)) struct cmdline *cl,
6819 __attribute__((unused)) void *data)
6821 struct cmd_vf_mac_addr_result *res = parsed_result;
6824 if (strcmp(res->what, "add") == 0)
6825 ret = rte_eth_dev_mac_addr_add(res->port_num,
6826 &res->address, res->vf_num);
6828 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6832 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6833 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6834 mac_addr_cmd,"mac_addr");
6835 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6836 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6838 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6839 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6841 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6842 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6844 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6845 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6847 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6848 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6850 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6851 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6854 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6855 .f = cmd_vf_mac_addr_parsed,
6857 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6858 "Add MAC address filtering for a VF on port_id",
6860 (void *)&cmd_vf_mac_addr_cmd,
6861 (void *)&cmd_vf_mac_addr_what,
6862 (void *)&cmd_vf_mac_addr_port,
6863 (void *)&cmd_vf_mac_addr_portnum,
6864 (void *)&cmd_vf_mac_addr_vf,
6865 (void *)&cmd_vf_mac_addr_vfnum,
6866 (void *)&cmd_vf_mac_addr_addr,
6871 #ifdef RTE_LIBRTE_IXGBE_PMD
6872 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6873 struct cmd_vf_rx_vlan_filter {
6874 cmdline_fixed_string_t rx_vlan;
6875 cmdline_fixed_string_t what;
6877 cmdline_fixed_string_t port;
6879 cmdline_fixed_string_t vf;
6884 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6885 __attribute__((unused)) struct cmdline *cl,
6886 __attribute__((unused)) void *data)
6888 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6890 if (!strcmp(res->what, "add"))
6891 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6893 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6896 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6897 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6898 rx_vlan, "rx_vlan");
6899 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6900 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6902 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6903 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6905 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6906 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6908 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6909 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6911 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6912 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6914 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6915 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6918 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6919 .f = cmd_vf_rx_vlan_filter_parsed,
6921 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6922 "(vf_mask = hexadecimal VF mask)",
6924 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6925 (void *)&cmd_vf_rx_vlan_filter_what,
6926 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6927 (void *)&cmd_vf_rx_vlan_filter_port,
6928 (void *)&cmd_vf_rx_vlan_filter_portid,
6929 (void *)&cmd_vf_rx_vlan_filter_vf,
6930 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6936 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6937 struct cmd_queue_rate_limit_result {
6938 cmdline_fixed_string_t set;
6939 cmdline_fixed_string_t port;
6941 cmdline_fixed_string_t queue;
6943 cmdline_fixed_string_t rate;
6947 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6948 __attribute__((unused)) struct cmdline *cl,
6949 __attribute__((unused)) void *data)
6951 struct cmd_queue_rate_limit_result *res = parsed_result;
6954 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6955 && (strcmp(res->queue, "queue") == 0)
6956 && (strcmp(res->rate, "rate") == 0))
6957 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6960 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6964 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6965 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6967 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6968 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6970 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6971 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6973 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6974 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6976 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6977 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6979 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6980 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6982 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6983 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6986 cmdline_parse_inst_t cmd_queue_rate_limit = {
6987 .f = cmd_queue_rate_limit_parsed,
6989 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6990 "Set rate limit for a queue on port_id",
6992 (void *)&cmd_queue_rate_limit_set,
6993 (void *)&cmd_queue_rate_limit_port,
6994 (void *)&cmd_queue_rate_limit_portnum,
6995 (void *)&cmd_queue_rate_limit_queue,
6996 (void *)&cmd_queue_rate_limit_queuenum,
6997 (void *)&cmd_queue_rate_limit_rate,
6998 (void *)&cmd_queue_rate_limit_ratenum,
7003 #ifdef RTE_LIBRTE_IXGBE_PMD
7004 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7005 struct cmd_vf_rate_limit_result {
7006 cmdline_fixed_string_t set;
7007 cmdline_fixed_string_t port;
7009 cmdline_fixed_string_t vf;
7011 cmdline_fixed_string_t rate;
7013 cmdline_fixed_string_t q_msk;
7017 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7018 __attribute__((unused)) struct cmdline *cl,
7019 __attribute__((unused)) void *data)
7021 struct cmd_vf_rate_limit_result *res = parsed_result;
7024 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7025 && (strcmp(res->vf, "vf") == 0)
7026 && (strcmp(res->rate, "rate") == 0)
7027 && (strcmp(res->q_msk, "queue_mask") == 0))
7028 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7029 res->rate_num, res->q_msk_val);
7031 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7035 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7036 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7038 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7039 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7041 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7042 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7044 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7045 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7047 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7048 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7050 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7051 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7053 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7054 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7056 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7057 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7058 q_msk, "queue_mask");
7059 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7060 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7063 cmdline_parse_inst_t cmd_vf_rate_limit = {
7064 .f = cmd_vf_rate_limit_parsed,
7066 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7067 "queue_mask <queue_mask_value>: "
7068 "Set rate limit for queues of VF on port_id",
7070 (void *)&cmd_vf_rate_limit_set,
7071 (void *)&cmd_vf_rate_limit_port,
7072 (void *)&cmd_vf_rate_limit_portnum,
7073 (void *)&cmd_vf_rate_limit_vf,
7074 (void *)&cmd_vf_rate_limit_vfnum,
7075 (void *)&cmd_vf_rate_limit_rate,
7076 (void *)&cmd_vf_rate_limit_ratenum,
7077 (void *)&cmd_vf_rate_limit_q_msk,
7078 (void *)&cmd_vf_rate_limit_q_msk_val,
7084 /* *** ADD TUNNEL FILTER OF A PORT *** */
7085 struct cmd_tunnel_filter_result {
7086 cmdline_fixed_string_t cmd;
7087 cmdline_fixed_string_t what;
7089 struct ether_addr outer_mac;
7090 struct ether_addr inner_mac;
7091 cmdline_ipaddr_t ip_value;
7092 uint16_t inner_vlan;
7093 cmdline_fixed_string_t tunnel_type;
7094 cmdline_fixed_string_t filter_type;
7100 cmd_tunnel_filter_parsed(void *parsed_result,
7101 __attribute__((unused)) struct cmdline *cl,
7102 __attribute__((unused)) void *data)
7104 struct cmd_tunnel_filter_result *res = parsed_result;
7105 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7108 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7110 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7111 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7112 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7114 if (res->ip_value.family == AF_INET) {
7115 tunnel_filter_conf.ip_addr.ipv4_addr =
7116 res->ip_value.addr.ipv4.s_addr;
7117 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7119 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7120 &(res->ip_value.addr.ipv6),
7121 sizeof(struct in6_addr));
7122 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7125 if (!strcmp(res->filter_type, "imac-ivlan"))
7126 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7127 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7128 tunnel_filter_conf.filter_type =
7129 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7130 else if (!strcmp(res->filter_type, "imac-tenid"))
7131 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7132 else if (!strcmp(res->filter_type, "imac"))
7133 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7134 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7135 tunnel_filter_conf.filter_type =
7136 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7137 else if (!strcmp(res->filter_type, "oip"))
7138 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7139 else if (!strcmp(res->filter_type, "iip"))
7140 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7142 printf("The filter type is not supported");
7146 if (!strcmp(res->tunnel_type, "vxlan"))
7147 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7148 else if (!strcmp(res->tunnel_type, "nvgre"))
7149 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7150 else if (!strcmp(res->tunnel_type, "ipingre"))
7151 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7153 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7157 tunnel_filter_conf.tenant_id = res->tenant_id;
7158 tunnel_filter_conf.queue_id = res->queue_num;
7159 if (!strcmp(res->what, "add"))
7160 ret = rte_eth_dev_filter_ctrl(res->port_id,
7161 RTE_ETH_FILTER_TUNNEL,
7163 &tunnel_filter_conf);
7165 ret = rte_eth_dev_filter_ctrl(res->port_id,
7166 RTE_ETH_FILTER_TUNNEL,
7167 RTE_ETH_FILTER_DELETE,
7168 &tunnel_filter_conf);
7170 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7174 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7175 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7176 cmd, "tunnel_filter");
7177 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7178 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7180 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7181 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7183 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7184 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7186 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7187 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7189 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7190 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7191 inner_vlan, UINT16);
7192 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7193 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7195 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7196 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7197 tunnel_type, "vxlan#nvgre#ipingre");
7199 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7200 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7201 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7202 "imac#omac-imac-tenid");
7203 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7204 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7206 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7207 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7210 cmdline_parse_inst_t cmd_tunnel_filter = {
7211 .f = cmd_tunnel_filter_parsed,
7213 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7214 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7215 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7216 "<queue_id>: Add/Rm tunnel filter of a port",
7218 (void *)&cmd_tunnel_filter_cmd,
7219 (void *)&cmd_tunnel_filter_what,
7220 (void *)&cmd_tunnel_filter_port_id,
7221 (void *)&cmd_tunnel_filter_outer_mac,
7222 (void *)&cmd_tunnel_filter_inner_mac,
7223 (void *)&cmd_tunnel_filter_ip_value,
7224 (void *)&cmd_tunnel_filter_innner_vlan,
7225 (void *)&cmd_tunnel_filter_tunnel_type,
7226 (void *)&cmd_tunnel_filter_filter_type,
7227 (void *)&cmd_tunnel_filter_tenant_id,
7228 (void *)&cmd_tunnel_filter_queue_num,
7233 /* *** CONFIGURE TUNNEL UDP PORT *** */
7234 struct cmd_tunnel_udp_config {
7235 cmdline_fixed_string_t cmd;
7236 cmdline_fixed_string_t what;
7242 cmd_tunnel_udp_config_parsed(void *parsed_result,
7243 __attribute__((unused)) struct cmdline *cl,
7244 __attribute__((unused)) void *data)
7246 struct cmd_tunnel_udp_config *res = parsed_result;
7247 struct rte_eth_udp_tunnel tunnel_udp;
7250 tunnel_udp.udp_port = res->udp_port;
7252 if (!strcmp(res->cmd, "rx_vxlan_port"))
7253 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7255 if (!strcmp(res->what, "add"))
7256 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7259 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7263 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7266 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7267 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7268 cmd, "rx_vxlan_port");
7269 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7270 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7272 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7273 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7275 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7276 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7279 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7280 .f = cmd_tunnel_udp_config_parsed,
7282 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7283 "Add/Remove a tunneling UDP port filter",
7285 (void *)&cmd_tunnel_udp_config_cmd,
7286 (void *)&cmd_tunnel_udp_config_what,
7287 (void *)&cmd_tunnel_udp_config_udp_port,
7288 (void *)&cmd_tunnel_udp_config_port_id,
7293 /* *** GLOBAL CONFIG *** */
7294 struct cmd_global_config_result {
7295 cmdline_fixed_string_t cmd;
7297 cmdline_fixed_string_t cfg_type;
7302 cmd_global_config_parsed(void *parsed_result,
7303 __attribute__((unused)) struct cmdline *cl,
7304 __attribute__((unused)) void *data)
7306 struct cmd_global_config_result *res = parsed_result;
7307 struct rte_eth_global_cfg conf;
7310 memset(&conf, 0, sizeof(conf));
7311 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7312 conf.cfg.gre_key_len = res->len;
7313 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7314 RTE_ETH_FILTER_SET, &conf);
7316 printf("Global config error\n");
7319 cmdline_parse_token_string_t cmd_global_config_cmd =
7320 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7322 cmdline_parse_token_num_t cmd_global_config_port_id =
7323 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7324 cmdline_parse_token_string_t cmd_global_config_type =
7325 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7326 cfg_type, "gre-key-len");
7327 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7328 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7331 cmdline_parse_inst_t cmd_global_config = {
7332 .f = cmd_global_config_parsed,
7333 .data = (void *)NULL,
7334 .help_str = "global_config <port_id> gre-key-len <key_len>",
7336 (void *)&cmd_global_config_cmd,
7337 (void *)&cmd_global_config_port_id,
7338 (void *)&cmd_global_config_type,
7339 (void *)&cmd_global_config_gre_key_len,
7344 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7345 struct cmd_set_mirror_mask_result {
7346 cmdline_fixed_string_t set;
7347 cmdline_fixed_string_t port;
7349 cmdline_fixed_string_t mirror;
7351 cmdline_fixed_string_t what;
7352 cmdline_fixed_string_t value;
7353 cmdline_fixed_string_t dstpool;
7355 cmdline_fixed_string_t on;
7358 cmdline_parse_token_string_t cmd_mirror_mask_set =
7359 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7361 cmdline_parse_token_string_t cmd_mirror_mask_port =
7362 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7364 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7365 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7367 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7368 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7369 mirror, "mirror-rule");
7370 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7371 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7373 cmdline_parse_token_string_t cmd_mirror_mask_what =
7374 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7375 what, "pool-mirror-up#pool-mirror-down"
7377 cmdline_parse_token_string_t cmd_mirror_mask_value =
7378 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7380 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7381 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7382 dstpool, "dst-pool");
7383 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7384 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7386 cmdline_parse_token_string_t cmd_mirror_mask_on =
7387 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7391 cmd_set_mirror_mask_parsed(void *parsed_result,
7392 __attribute__((unused)) struct cmdline *cl,
7393 __attribute__((unused)) void *data)
7396 struct cmd_set_mirror_mask_result *res = parsed_result;
7397 struct rte_eth_mirror_conf mr_conf;
7399 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7401 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7403 mr_conf.dst_pool = res->dstpool_id;
7405 if (!strcmp(res->what, "pool-mirror-up")) {
7406 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7407 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7408 } else if (!strcmp(res->what, "pool-mirror-down")) {
7409 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7410 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7411 } else if (!strcmp(res->what, "vlan-mirror")) {
7412 mr_conf.rule_type = ETH_MIRROR_VLAN;
7413 nb_item = parse_item_list(res->value, "vlan",
7414 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7418 for (i = 0; i < nb_item; i++) {
7419 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7420 printf("Invalid vlan_id: must be < 4096\n");
7424 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7425 mr_conf.vlan.vlan_mask |= 1ULL << i;
7429 if (!strcmp(res->on, "on"))
7430 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7433 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7436 printf("mirror rule add error: (%s)\n", strerror(-ret));
7439 cmdline_parse_inst_t cmd_set_mirror_mask = {
7440 .f = cmd_set_mirror_mask_parsed,
7442 .help_str = "set port <port_id> mirror-rule <rule_id> "
7443 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7444 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7446 (void *)&cmd_mirror_mask_set,
7447 (void *)&cmd_mirror_mask_port,
7448 (void *)&cmd_mirror_mask_portid,
7449 (void *)&cmd_mirror_mask_mirror,
7450 (void *)&cmd_mirror_mask_ruleid,
7451 (void *)&cmd_mirror_mask_what,
7452 (void *)&cmd_mirror_mask_value,
7453 (void *)&cmd_mirror_mask_dstpool,
7454 (void *)&cmd_mirror_mask_poolid,
7455 (void *)&cmd_mirror_mask_on,
7460 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7461 struct cmd_set_mirror_link_result {
7462 cmdline_fixed_string_t set;
7463 cmdline_fixed_string_t port;
7465 cmdline_fixed_string_t mirror;
7467 cmdline_fixed_string_t what;
7468 cmdline_fixed_string_t dstpool;
7470 cmdline_fixed_string_t on;
7473 cmdline_parse_token_string_t cmd_mirror_link_set =
7474 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7476 cmdline_parse_token_string_t cmd_mirror_link_port =
7477 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7479 cmdline_parse_token_num_t cmd_mirror_link_portid =
7480 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7482 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7483 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7484 mirror, "mirror-rule");
7485 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7486 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7488 cmdline_parse_token_string_t cmd_mirror_link_what =
7489 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7490 what, "uplink-mirror#downlink-mirror");
7491 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7492 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7493 dstpool, "dst-pool");
7494 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7495 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7497 cmdline_parse_token_string_t cmd_mirror_link_on =
7498 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7502 cmd_set_mirror_link_parsed(void *parsed_result,
7503 __attribute__((unused)) struct cmdline *cl,
7504 __attribute__((unused)) void *data)
7507 struct cmd_set_mirror_link_result *res = parsed_result;
7508 struct rte_eth_mirror_conf mr_conf;
7510 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7511 if (!strcmp(res->what, "uplink-mirror"))
7512 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7514 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7516 mr_conf.dst_pool = res->dstpool_id;
7518 if (!strcmp(res->on, "on"))
7519 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7522 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7525 /* check the return value and print it if is < 0 */
7527 printf("mirror rule add error: (%s)\n", strerror(-ret));
7531 cmdline_parse_inst_t cmd_set_mirror_link = {
7532 .f = cmd_set_mirror_link_parsed,
7534 .help_str = "set port <port_id> mirror-rule <rule_id> "
7535 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7537 (void *)&cmd_mirror_link_set,
7538 (void *)&cmd_mirror_link_port,
7539 (void *)&cmd_mirror_link_portid,
7540 (void *)&cmd_mirror_link_mirror,
7541 (void *)&cmd_mirror_link_ruleid,
7542 (void *)&cmd_mirror_link_what,
7543 (void *)&cmd_mirror_link_dstpool,
7544 (void *)&cmd_mirror_link_poolid,
7545 (void *)&cmd_mirror_link_on,
7550 /* *** RESET VM MIRROR RULE *** */
7551 struct cmd_rm_mirror_rule_result {
7552 cmdline_fixed_string_t reset;
7553 cmdline_fixed_string_t port;
7555 cmdline_fixed_string_t mirror;
7559 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7560 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7562 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7563 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7565 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7566 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7568 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7569 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7570 mirror, "mirror-rule");
7571 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7572 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7576 cmd_reset_mirror_rule_parsed(void *parsed_result,
7577 __attribute__((unused)) struct cmdline *cl,
7578 __attribute__((unused)) void *data)
7581 struct cmd_set_mirror_link_result *res = parsed_result;
7583 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7585 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7588 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7589 .f = cmd_reset_mirror_rule_parsed,
7591 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7593 (void *)&cmd_rm_mirror_rule_reset,
7594 (void *)&cmd_rm_mirror_rule_port,
7595 (void *)&cmd_rm_mirror_rule_portid,
7596 (void *)&cmd_rm_mirror_rule_mirror,
7597 (void *)&cmd_rm_mirror_rule_ruleid,
7602 /* ******************************************************************************** */
7604 struct cmd_dump_result {
7605 cmdline_fixed_string_t dump;
7609 dump_struct_sizes(void)
7611 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7612 DUMP_SIZE(struct rte_mbuf);
7613 DUMP_SIZE(struct rte_mempool);
7614 DUMP_SIZE(struct rte_ring);
7618 static void cmd_dump_parsed(void *parsed_result,
7619 __attribute__((unused)) struct cmdline *cl,
7620 __attribute__((unused)) void *data)
7622 struct cmd_dump_result *res = parsed_result;
7624 if (!strcmp(res->dump, "dump_physmem"))
7625 rte_dump_physmem_layout(stdout);
7626 else if (!strcmp(res->dump, "dump_memzone"))
7627 rte_memzone_dump(stdout);
7628 else if (!strcmp(res->dump, "dump_struct_sizes"))
7629 dump_struct_sizes();
7630 else if (!strcmp(res->dump, "dump_ring"))
7631 rte_ring_list_dump(stdout);
7632 else if (!strcmp(res->dump, "dump_mempool"))
7633 rte_mempool_list_dump(stdout);
7634 else if (!strcmp(res->dump, "dump_devargs"))
7635 rte_eal_devargs_dump(stdout);
7638 cmdline_parse_token_string_t cmd_dump_dump =
7639 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7642 "dump_struct_sizes#"
7647 cmdline_parse_inst_t cmd_dump = {
7648 .f = cmd_dump_parsed, /* function to call */
7649 .data = NULL, /* 2nd arg of func */
7650 .help_str = "Dump status",
7651 .tokens = { /* token list, NULL terminated */
7652 (void *)&cmd_dump_dump,
7657 /* ******************************************************************************** */
7659 struct cmd_dump_one_result {
7660 cmdline_fixed_string_t dump;
7661 cmdline_fixed_string_t name;
7664 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7665 __attribute__((unused)) void *data)
7667 struct cmd_dump_one_result *res = parsed_result;
7669 if (!strcmp(res->dump, "dump_ring")) {
7671 r = rte_ring_lookup(res->name);
7673 cmdline_printf(cl, "Cannot find ring\n");
7676 rte_ring_dump(stdout, r);
7677 } else if (!strcmp(res->dump, "dump_mempool")) {
7678 struct rte_mempool *mp;
7679 mp = rte_mempool_lookup(res->name);
7681 cmdline_printf(cl, "Cannot find mempool\n");
7684 rte_mempool_dump(stdout, mp);
7688 cmdline_parse_token_string_t cmd_dump_one_dump =
7689 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7690 "dump_ring#dump_mempool");
7692 cmdline_parse_token_string_t cmd_dump_one_name =
7693 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7695 cmdline_parse_inst_t cmd_dump_one = {
7696 .f = cmd_dump_one_parsed, /* function to call */
7697 .data = NULL, /* 2nd arg of func */
7698 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7699 .tokens = { /* token list, NULL terminated */
7700 (void *)&cmd_dump_one_dump,
7701 (void *)&cmd_dump_one_name,
7706 /* *** Add/Del syn filter *** */
7707 struct cmd_syn_filter_result {
7708 cmdline_fixed_string_t filter;
7710 cmdline_fixed_string_t ops;
7711 cmdline_fixed_string_t priority;
7712 cmdline_fixed_string_t high;
7713 cmdline_fixed_string_t queue;
7718 cmd_syn_filter_parsed(void *parsed_result,
7719 __attribute__((unused)) struct cmdline *cl,
7720 __attribute__((unused)) void *data)
7722 struct cmd_syn_filter_result *res = parsed_result;
7723 struct rte_eth_syn_filter syn_filter;
7726 ret = rte_eth_dev_filter_supported(res->port_id,
7727 RTE_ETH_FILTER_SYN);
7729 printf("syn filter is not supported on port %u.\n",
7734 memset(&syn_filter, 0, sizeof(syn_filter));
7736 if (!strcmp(res->ops, "add")) {
7737 if (!strcmp(res->high, "high"))
7738 syn_filter.hig_pri = 1;
7740 syn_filter.hig_pri = 0;
7742 syn_filter.queue = res->queue_id;
7743 ret = rte_eth_dev_filter_ctrl(res->port_id,
7748 ret = rte_eth_dev_filter_ctrl(res->port_id,
7750 RTE_ETH_FILTER_DELETE,
7754 printf("syn filter programming error: (%s)\n",
7758 cmdline_parse_token_string_t cmd_syn_filter_filter =
7759 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7760 filter, "syn_filter");
7761 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7762 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7764 cmdline_parse_token_string_t cmd_syn_filter_ops =
7765 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7767 cmdline_parse_token_string_t cmd_syn_filter_priority =
7768 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7769 priority, "priority");
7770 cmdline_parse_token_string_t cmd_syn_filter_high =
7771 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7773 cmdline_parse_token_string_t cmd_syn_filter_queue =
7774 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7776 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7777 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7780 cmdline_parse_inst_t cmd_syn_filter = {
7781 .f = cmd_syn_filter_parsed,
7783 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7784 "<queue_id>: Add/Delete syn filter",
7786 (void *)&cmd_syn_filter_filter,
7787 (void *)&cmd_syn_filter_port_id,
7788 (void *)&cmd_syn_filter_ops,
7789 (void *)&cmd_syn_filter_priority,
7790 (void *)&cmd_syn_filter_high,
7791 (void *)&cmd_syn_filter_queue,
7792 (void *)&cmd_syn_filter_queue_id,
7797 /* *** ADD/REMOVE A 2tuple FILTER *** */
7798 struct cmd_2tuple_filter_result {
7799 cmdline_fixed_string_t filter;
7801 cmdline_fixed_string_t ops;
7802 cmdline_fixed_string_t dst_port;
7803 uint16_t dst_port_value;
7804 cmdline_fixed_string_t protocol;
7805 uint8_t protocol_value;
7806 cmdline_fixed_string_t mask;
7808 cmdline_fixed_string_t tcp_flags;
7809 uint8_t tcp_flags_value;
7810 cmdline_fixed_string_t priority;
7811 uint8_t priority_value;
7812 cmdline_fixed_string_t queue;
7817 cmd_2tuple_filter_parsed(void *parsed_result,
7818 __attribute__((unused)) struct cmdline *cl,
7819 __attribute__((unused)) void *data)
7821 struct rte_eth_ntuple_filter filter;
7822 struct cmd_2tuple_filter_result *res = parsed_result;
7825 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7827 printf("ntuple filter is not supported on port %u.\n",
7832 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7834 filter.flags = RTE_2TUPLE_FLAGS;
7835 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7836 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7837 filter.proto = res->protocol_value;
7838 filter.priority = res->priority_value;
7839 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7840 printf("nonzero tcp_flags is only meaningful"
7841 " when protocol is TCP.\n");
7844 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7845 printf("invalid TCP flags.\n");
7849 if (res->tcp_flags_value != 0) {
7850 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7851 filter.tcp_flags = res->tcp_flags_value;
7854 /* need convert to big endian. */
7855 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7856 filter.queue = res->queue_id;
7858 if (!strcmp(res->ops, "add"))
7859 ret = rte_eth_dev_filter_ctrl(res->port_id,
7860 RTE_ETH_FILTER_NTUPLE,
7864 ret = rte_eth_dev_filter_ctrl(res->port_id,
7865 RTE_ETH_FILTER_NTUPLE,
7866 RTE_ETH_FILTER_DELETE,
7869 printf("2tuple filter programming error: (%s)\n",
7874 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7875 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7876 filter, "2tuple_filter");
7877 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7878 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7880 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7881 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7883 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7884 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7885 dst_port, "dst_port");
7886 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7887 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7888 dst_port_value, UINT16);
7889 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7890 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7891 protocol, "protocol");
7892 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7893 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7894 protocol_value, UINT8);
7895 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7896 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7898 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7899 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7901 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7902 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7903 tcp_flags, "tcp_flags");
7904 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7905 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7906 tcp_flags_value, UINT8);
7907 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7908 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7909 priority, "priority");
7910 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7911 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7912 priority_value, UINT8);
7913 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7914 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7916 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7917 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7920 cmdline_parse_inst_t cmd_2tuple_filter = {
7921 .f = cmd_2tuple_filter_parsed,
7923 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7924 "<value> mask <value> tcp_flags <value> priority <value> queue "
7925 "<queue_id>: Add a 2tuple filter",
7927 (void *)&cmd_2tuple_filter_filter,
7928 (void *)&cmd_2tuple_filter_port_id,
7929 (void *)&cmd_2tuple_filter_ops,
7930 (void *)&cmd_2tuple_filter_dst_port,
7931 (void *)&cmd_2tuple_filter_dst_port_value,
7932 (void *)&cmd_2tuple_filter_protocol,
7933 (void *)&cmd_2tuple_filter_protocol_value,
7934 (void *)&cmd_2tuple_filter_mask,
7935 (void *)&cmd_2tuple_filter_mask_value,
7936 (void *)&cmd_2tuple_filter_tcp_flags,
7937 (void *)&cmd_2tuple_filter_tcp_flags_value,
7938 (void *)&cmd_2tuple_filter_priority,
7939 (void *)&cmd_2tuple_filter_priority_value,
7940 (void *)&cmd_2tuple_filter_queue,
7941 (void *)&cmd_2tuple_filter_queue_id,
7946 /* *** ADD/REMOVE A 5tuple FILTER *** */
7947 struct cmd_5tuple_filter_result {
7948 cmdline_fixed_string_t filter;
7950 cmdline_fixed_string_t ops;
7951 cmdline_fixed_string_t dst_ip;
7952 cmdline_ipaddr_t dst_ip_value;
7953 cmdline_fixed_string_t src_ip;
7954 cmdline_ipaddr_t src_ip_value;
7955 cmdline_fixed_string_t dst_port;
7956 uint16_t dst_port_value;
7957 cmdline_fixed_string_t src_port;
7958 uint16_t src_port_value;
7959 cmdline_fixed_string_t protocol;
7960 uint8_t protocol_value;
7961 cmdline_fixed_string_t mask;
7963 cmdline_fixed_string_t tcp_flags;
7964 uint8_t tcp_flags_value;
7965 cmdline_fixed_string_t priority;
7966 uint8_t priority_value;
7967 cmdline_fixed_string_t queue;
7972 cmd_5tuple_filter_parsed(void *parsed_result,
7973 __attribute__((unused)) struct cmdline *cl,
7974 __attribute__((unused)) void *data)
7976 struct rte_eth_ntuple_filter filter;
7977 struct cmd_5tuple_filter_result *res = parsed_result;
7980 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7982 printf("ntuple filter is not supported on port %u.\n",
7987 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7989 filter.flags = RTE_5TUPLE_FLAGS;
7990 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7991 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7992 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7993 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7994 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7995 filter.proto = res->protocol_value;
7996 filter.priority = res->priority_value;
7997 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7998 printf("nonzero tcp_flags is only meaningful"
7999 " when protocol is TCP.\n");
8002 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8003 printf("invalid TCP flags.\n");
8007 if (res->tcp_flags_value != 0) {
8008 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8009 filter.tcp_flags = res->tcp_flags_value;
8012 if (res->dst_ip_value.family == AF_INET)
8013 /* no need to convert, already big endian. */
8014 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8016 if (filter.dst_ip_mask == 0) {
8017 printf("can not support ipv6 involved compare.\n");
8023 if (res->src_ip_value.family == AF_INET)
8024 /* no need to convert, already big endian. */
8025 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8027 if (filter.src_ip_mask == 0) {
8028 printf("can not support ipv6 involved compare.\n");
8033 /* need convert to big endian. */
8034 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8035 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8036 filter.queue = res->queue_id;
8038 if (!strcmp(res->ops, "add"))
8039 ret = rte_eth_dev_filter_ctrl(res->port_id,
8040 RTE_ETH_FILTER_NTUPLE,
8044 ret = rte_eth_dev_filter_ctrl(res->port_id,
8045 RTE_ETH_FILTER_NTUPLE,
8046 RTE_ETH_FILTER_DELETE,
8049 printf("5tuple filter programming error: (%s)\n",
8053 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8054 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8055 filter, "5tuple_filter");
8056 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8057 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8059 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8060 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8062 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8063 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8065 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8066 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8068 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8069 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8071 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8072 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8074 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8075 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8076 dst_port, "dst_port");
8077 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8078 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8079 dst_port_value, UINT16);
8080 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8081 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8082 src_port, "src_port");
8083 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8084 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8085 src_port_value, UINT16);
8086 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8087 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8088 protocol, "protocol");
8089 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8090 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8091 protocol_value, UINT8);
8092 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8093 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8095 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8096 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8098 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8099 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8100 tcp_flags, "tcp_flags");
8101 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8102 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8103 tcp_flags_value, UINT8);
8104 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8105 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8106 priority, "priority");
8107 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8108 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8109 priority_value, UINT8);
8110 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8111 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8113 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8114 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8117 cmdline_parse_inst_t cmd_5tuple_filter = {
8118 .f = cmd_5tuple_filter_parsed,
8120 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8121 "src_ip <value> dst_port <value> src_port <value> "
8122 "protocol <value> mask <value> tcp_flags <value> "
8123 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8125 (void *)&cmd_5tuple_filter_filter,
8126 (void *)&cmd_5tuple_filter_port_id,
8127 (void *)&cmd_5tuple_filter_ops,
8128 (void *)&cmd_5tuple_filter_dst_ip,
8129 (void *)&cmd_5tuple_filter_dst_ip_value,
8130 (void *)&cmd_5tuple_filter_src_ip,
8131 (void *)&cmd_5tuple_filter_src_ip_value,
8132 (void *)&cmd_5tuple_filter_dst_port,
8133 (void *)&cmd_5tuple_filter_dst_port_value,
8134 (void *)&cmd_5tuple_filter_src_port,
8135 (void *)&cmd_5tuple_filter_src_port_value,
8136 (void *)&cmd_5tuple_filter_protocol,
8137 (void *)&cmd_5tuple_filter_protocol_value,
8138 (void *)&cmd_5tuple_filter_mask,
8139 (void *)&cmd_5tuple_filter_mask_value,
8140 (void *)&cmd_5tuple_filter_tcp_flags,
8141 (void *)&cmd_5tuple_filter_tcp_flags_value,
8142 (void *)&cmd_5tuple_filter_priority,
8143 (void *)&cmd_5tuple_filter_priority_value,
8144 (void *)&cmd_5tuple_filter_queue,
8145 (void *)&cmd_5tuple_filter_queue_id,
8150 /* *** ADD/REMOVE A flex FILTER *** */
8151 struct cmd_flex_filter_result {
8152 cmdline_fixed_string_t filter;
8153 cmdline_fixed_string_t ops;
8155 cmdline_fixed_string_t len;
8157 cmdline_fixed_string_t bytes;
8158 cmdline_fixed_string_t bytes_value;
8159 cmdline_fixed_string_t mask;
8160 cmdline_fixed_string_t mask_value;
8161 cmdline_fixed_string_t priority;
8162 uint8_t priority_value;
8163 cmdline_fixed_string_t queue;
8167 static int xdigit2val(unsigned char c)
8172 else if (isupper(c))
8180 cmd_flex_filter_parsed(void *parsed_result,
8181 __attribute__((unused)) struct cmdline *cl,
8182 __attribute__((unused)) void *data)
8185 struct rte_eth_flex_filter filter;
8186 struct cmd_flex_filter_result *res = parsed_result;
8187 char *bytes_ptr, *mask_ptr;
8188 uint16_t len, i, j = 0;
8193 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8194 printf("the len exceed the max length 128\n");
8197 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8198 filter.len = res->len_value;
8199 filter.priority = res->priority_value;
8200 filter.queue = res->queue_id;
8201 bytes_ptr = res->bytes_value;
8202 mask_ptr = res->mask_value;
8204 /* translate bytes string to array. */
8205 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8206 (bytes_ptr[1] == 'X')))
8208 len = strnlen(bytes_ptr, res->len_value * 2);
8209 if (len == 0 || (len % 8 != 0)) {
8210 printf("please check len and bytes input\n");
8213 for (i = 0; i < len; i++) {
8215 if (isxdigit(c) == 0) {
8216 /* invalid characters. */
8217 printf("invalid input\n");
8220 val = xdigit2val(c);
8223 filter.bytes[j] = byte;
8224 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8231 /* translate mask string to uint8_t array. */
8232 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8233 (mask_ptr[1] == 'X')))
8235 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8237 printf("invalid input\n");
8242 for (i = 0; i < len; i++) {
8244 if (isxdigit(c) == 0) {
8245 /* invalid characters. */
8246 printf("invalid input\n");
8249 val = xdigit2val(c);
8252 filter.mask[j] = byte;
8253 printf("mask[%d]:%02x ", j, filter.mask[j]);
8261 if (!strcmp(res->ops, "add"))
8262 ret = rte_eth_dev_filter_ctrl(res->port_id,
8263 RTE_ETH_FILTER_FLEXIBLE,
8267 ret = rte_eth_dev_filter_ctrl(res->port_id,
8268 RTE_ETH_FILTER_FLEXIBLE,
8269 RTE_ETH_FILTER_DELETE,
8273 printf("flex filter setting error: (%s)\n", strerror(-ret));
8276 cmdline_parse_token_string_t cmd_flex_filter_filter =
8277 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8278 filter, "flex_filter");
8279 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8280 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8282 cmdline_parse_token_string_t cmd_flex_filter_ops =
8283 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8285 cmdline_parse_token_string_t cmd_flex_filter_len =
8286 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8288 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8289 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8291 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8292 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8294 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8295 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8297 cmdline_parse_token_string_t cmd_flex_filter_mask =
8298 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8300 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8301 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8303 cmdline_parse_token_string_t cmd_flex_filter_priority =
8304 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8305 priority, "priority");
8306 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8307 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8308 priority_value, UINT8);
8309 cmdline_parse_token_string_t cmd_flex_filter_queue =
8310 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8312 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8313 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8315 cmdline_parse_inst_t cmd_flex_filter = {
8316 .f = cmd_flex_filter_parsed,
8318 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8319 "<value> mask <value> priority <value> queue <queue_id>: "
8320 "Add/Del a flex filter",
8322 (void *)&cmd_flex_filter_filter,
8323 (void *)&cmd_flex_filter_port_id,
8324 (void *)&cmd_flex_filter_ops,
8325 (void *)&cmd_flex_filter_len,
8326 (void *)&cmd_flex_filter_len_value,
8327 (void *)&cmd_flex_filter_bytes,
8328 (void *)&cmd_flex_filter_bytes_value,
8329 (void *)&cmd_flex_filter_mask,
8330 (void *)&cmd_flex_filter_mask_value,
8331 (void *)&cmd_flex_filter_priority,
8332 (void *)&cmd_flex_filter_priority_value,
8333 (void *)&cmd_flex_filter_queue,
8334 (void *)&cmd_flex_filter_queue_id,
8339 /* *** Filters Control *** */
8341 /* *** deal with ethertype filter *** */
8342 struct cmd_ethertype_filter_result {
8343 cmdline_fixed_string_t filter;
8345 cmdline_fixed_string_t ops;
8346 cmdline_fixed_string_t mac;
8347 struct ether_addr mac_addr;
8348 cmdline_fixed_string_t ethertype;
8349 uint16_t ethertype_value;
8350 cmdline_fixed_string_t drop;
8351 cmdline_fixed_string_t queue;
8355 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8356 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8357 filter, "ethertype_filter");
8358 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8359 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8361 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8362 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8364 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8365 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8366 mac, "mac_addr#mac_ignr");
8367 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8368 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8370 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8371 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8372 ethertype, "ethertype");
8373 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8374 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8375 ethertype_value, UINT16);
8376 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8377 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8379 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8380 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8382 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8383 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8387 cmd_ethertype_filter_parsed(void *parsed_result,
8388 __attribute__((unused)) struct cmdline *cl,
8389 __attribute__((unused)) void *data)
8391 struct cmd_ethertype_filter_result *res = parsed_result;
8392 struct rte_eth_ethertype_filter filter;
8395 ret = rte_eth_dev_filter_supported(res->port_id,
8396 RTE_ETH_FILTER_ETHERTYPE);
8398 printf("ethertype filter is not supported on port %u.\n",
8403 memset(&filter, 0, sizeof(filter));
8404 if (!strcmp(res->mac, "mac_addr")) {
8405 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8406 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8407 sizeof(struct ether_addr));
8409 if (!strcmp(res->drop, "drop"))
8410 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8411 filter.ether_type = res->ethertype_value;
8412 filter.queue = res->queue_id;
8414 if (!strcmp(res->ops, "add"))
8415 ret = rte_eth_dev_filter_ctrl(res->port_id,
8416 RTE_ETH_FILTER_ETHERTYPE,
8420 ret = rte_eth_dev_filter_ctrl(res->port_id,
8421 RTE_ETH_FILTER_ETHERTYPE,
8422 RTE_ETH_FILTER_DELETE,
8425 printf("ethertype filter programming error: (%s)\n",
8429 cmdline_parse_inst_t cmd_ethertype_filter = {
8430 .f = cmd_ethertype_filter_parsed,
8432 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8433 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8434 "Add or delete an ethertype filter entry",
8436 (void *)&cmd_ethertype_filter_filter,
8437 (void *)&cmd_ethertype_filter_port_id,
8438 (void *)&cmd_ethertype_filter_ops,
8439 (void *)&cmd_ethertype_filter_mac,
8440 (void *)&cmd_ethertype_filter_mac_addr,
8441 (void *)&cmd_ethertype_filter_ethertype,
8442 (void *)&cmd_ethertype_filter_ethertype_value,
8443 (void *)&cmd_ethertype_filter_drop,
8444 (void *)&cmd_ethertype_filter_queue,
8445 (void *)&cmd_ethertype_filter_queue_id,
8450 /* *** deal with flow director filter *** */
8451 struct cmd_flow_director_result {
8452 cmdline_fixed_string_t flow_director_filter;
8454 cmdline_fixed_string_t mode;
8455 cmdline_fixed_string_t mode_value;
8456 cmdline_fixed_string_t ops;
8457 cmdline_fixed_string_t flow;
8458 cmdline_fixed_string_t flow_type;
8459 cmdline_fixed_string_t ether;
8460 uint16_t ether_type;
8461 cmdline_fixed_string_t src;
8462 cmdline_ipaddr_t ip_src;
8464 cmdline_fixed_string_t dst;
8465 cmdline_ipaddr_t ip_dst;
8467 cmdline_fixed_string_t verify_tag;
8468 uint32_t verify_tag_value;
8469 cmdline_ipaddr_t tos;
8471 cmdline_ipaddr_t proto;
8472 uint8_t proto_value;
8473 cmdline_ipaddr_t ttl;
8475 cmdline_fixed_string_t vlan;
8476 uint16_t vlan_value;
8477 cmdline_fixed_string_t flexbytes;
8478 cmdline_fixed_string_t flexbytes_value;
8479 cmdline_fixed_string_t pf_vf;
8480 cmdline_fixed_string_t drop;
8481 cmdline_fixed_string_t queue;
8483 cmdline_fixed_string_t fd_id;
8484 uint32_t fd_id_value;
8485 cmdline_fixed_string_t mac;
8486 struct ether_addr mac_addr;
8487 cmdline_fixed_string_t tunnel;
8488 cmdline_fixed_string_t tunnel_type;
8489 cmdline_fixed_string_t tunnel_id;
8490 uint32_t tunnel_id_value;
8494 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8497 const char *p, *p0 = q_arg;
8499 unsigned long int_fld;
8500 char *str_fld[max_num];
8505 p = strchr(p0, '(');
8509 p0 = strchr(p, ')');
8514 if (size >= sizeof(s))
8517 snprintf(s, sizeof(s), "%.*s", size, p);
8518 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8519 if (ret < 0 || ret > max_num)
8521 for (i = 0; i < ret; i++) {
8523 int_fld = strtoul(str_fld[i], &end, 0);
8524 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8526 flexbytes[i] = (uint8_t)int_fld;
8532 str2flowtype(char *string)
8535 static const struct {
8538 } flowtype_str[] = {
8539 {"raw", RTE_ETH_FLOW_RAW},
8540 {"ipv4", RTE_ETH_FLOW_IPV4},
8541 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8542 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8543 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8544 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8545 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8546 {"ipv6", RTE_ETH_FLOW_IPV6},
8547 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8548 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8549 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8550 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8551 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8552 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8555 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8556 if (!strcmp(flowtype_str[i].str, string))
8557 return flowtype_str[i].type;
8559 return RTE_ETH_FLOW_UNKNOWN;
8562 static enum rte_eth_fdir_tunnel_type
8563 str2fdir_tunneltype(char *string)
8567 static const struct {
8569 enum rte_eth_fdir_tunnel_type type;
8570 } tunneltype_str[] = {
8571 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8572 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8575 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8576 if (!strcmp(tunneltype_str[i].str, string))
8577 return tunneltype_str[i].type;
8579 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8582 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8584 if ((ip_addr).family == AF_INET) \
8585 (ip) = (ip_addr).addr.ipv4.s_addr; \
8587 printf("invalid parameter.\n"); \
8592 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8594 if ((ip_addr).family == AF_INET6) \
8595 (void)rte_memcpy(&(ip), \
8596 &((ip_addr).addr.ipv6), \
8597 sizeof(struct in6_addr)); \
8599 printf("invalid parameter.\n"); \
8605 cmd_flow_director_filter_parsed(void *parsed_result,
8606 __attribute__((unused)) struct cmdline *cl,
8607 __attribute__((unused)) void *data)
8609 struct cmd_flow_director_result *res = parsed_result;
8610 struct rte_eth_fdir_filter entry;
8611 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8613 unsigned long vf_id;
8616 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8618 printf("flow director is not supported on port %u.\n",
8622 memset(flexbytes, 0, sizeof(flexbytes));
8623 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8625 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8626 if (strcmp(res->mode_value, "MAC-VLAN")) {
8627 printf("Please set mode to MAC-VLAN.\n");
8630 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8631 if (strcmp(res->mode_value, "Tunnel")) {
8632 printf("Please set mode to Tunnel.\n");
8636 if (strcmp(res->mode_value, "IP")) {
8637 printf("Please set mode to IP.\n");
8640 entry.input.flow_type = str2flowtype(res->flow_type);
8643 ret = parse_flexbytes(res->flexbytes_value,
8645 RTE_ETH_FDIR_MAX_FLEXLEN);
8647 printf("error: Cannot parse flexbytes input.\n");
8651 switch (entry.input.flow_type) {
8652 case RTE_ETH_FLOW_FRAG_IPV4:
8653 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8654 entry.input.flow.ip4_flow.proto = res->proto_value;
8655 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8656 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8657 IPV4_ADDR_TO_UINT(res->ip_dst,
8658 entry.input.flow.ip4_flow.dst_ip);
8659 IPV4_ADDR_TO_UINT(res->ip_src,
8660 entry.input.flow.ip4_flow.src_ip);
8661 entry.input.flow.ip4_flow.tos = res->tos_value;
8662 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8663 /* need convert to big endian. */
8664 entry.input.flow.udp4_flow.dst_port =
8665 rte_cpu_to_be_16(res->port_dst);
8666 entry.input.flow.udp4_flow.src_port =
8667 rte_cpu_to_be_16(res->port_src);
8669 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8670 IPV4_ADDR_TO_UINT(res->ip_dst,
8671 entry.input.flow.sctp4_flow.ip.dst_ip);
8672 IPV4_ADDR_TO_UINT(res->ip_src,
8673 entry.input.flow.sctp4_flow.ip.src_ip);
8674 entry.input.flow.ip4_flow.tos = res->tos_value;
8675 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8676 /* need convert to big endian. */
8677 entry.input.flow.sctp4_flow.dst_port =
8678 rte_cpu_to_be_16(res->port_dst);
8679 entry.input.flow.sctp4_flow.src_port =
8680 rte_cpu_to_be_16(res->port_src);
8681 entry.input.flow.sctp4_flow.verify_tag =
8682 rte_cpu_to_be_32(res->verify_tag_value);
8684 case RTE_ETH_FLOW_FRAG_IPV6:
8685 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8686 entry.input.flow.ipv6_flow.proto = res->proto_value;
8687 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8688 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8689 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8690 entry.input.flow.ipv6_flow.dst_ip);
8691 IPV6_ADDR_TO_ARRAY(res->ip_src,
8692 entry.input.flow.ipv6_flow.src_ip);
8693 entry.input.flow.ipv6_flow.tc = res->tos_value;
8694 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8695 /* need convert to big endian. */
8696 entry.input.flow.udp6_flow.dst_port =
8697 rte_cpu_to_be_16(res->port_dst);
8698 entry.input.flow.udp6_flow.src_port =
8699 rte_cpu_to_be_16(res->port_src);
8701 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8702 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8703 entry.input.flow.sctp6_flow.ip.dst_ip);
8704 IPV6_ADDR_TO_ARRAY(res->ip_src,
8705 entry.input.flow.sctp6_flow.ip.src_ip);
8706 entry.input.flow.ipv6_flow.tc = res->tos_value;
8707 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8708 /* need convert to big endian. */
8709 entry.input.flow.sctp6_flow.dst_port =
8710 rte_cpu_to_be_16(res->port_dst);
8711 entry.input.flow.sctp6_flow.src_port =
8712 rte_cpu_to_be_16(res->port_src);
8713 entry.input.flow.sctp6_flow.verify_tag =
8714 rte_cpu_to_be_32(res->verify_tag_value);
8716 case RTE_ETH_FLOW_L2_PAYLOAD:
8717 entry.input.flow.l2_flow.ether_type =
8718 rte_cpu_to_be_16(res->ether_type);
8724 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8725 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8727 sizeof(struct ether_addr));
8729 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8730 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8732 sizeof(struct ether_addr));
8733 entry.input.flow.tunnel_flow.tunnel_type =
8734 str2fdir_tunneltype(res->tunnel_type);
8735 entry.input.flow.tunnel_flow.tunnel_id =
8736 rte_cpu_to_be_32(res->tunnel_id_value);
8739 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8741 RTE_ETH_FDIR_MAX_FLEXLEN);
8743 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8745 entry.action.flex_off = 0; /*use 0 by default */
8746 if (!strcmp(res->drop, "drop"))
8747 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8749 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8751 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8752 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8753 if (!strcmp(res->pf_vf, "pf"))
8754 entry.input.flow_ext.is_vf = 0;
8755 else if (!strncmp(res->pf_vf, "vf", 2)) {
8756 struct rte_eth_dev_info dev_info;
8758 memset(&dev_info, 0, sizeof(dev_info));
8759 rte_eth_dev_info_get(res->port_id, &dev_info);
8761 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8762 if (errno != 0 || *end != '\0' ||
8763 vf_id >= dev_info.max_vfs) {
8764 printf("invalid parameter %s.\n", res->pf_vf);
8767 entry.input.flow_ext.is_vf = 1;
8768 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8770 printf("invalid parameter %s.\n", res->pf_vf);
8775 /* set to report FD ID by default */
8776 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8777 entry.action.rx_queue = res->queue_id;
8778 entry.soft_id = res->fd_id_value;
8779 if (!strcmp(res->ops, "add"))
8780 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8781 RTE_ETH_FILTER_ADD, &entry);
8782 else if (!strcmp(res->ops, "del"))
8783 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8784 RTE_ETH_FILTER_DELETE, &entry);
8786 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8787 RTE_ETH_FILTER_UPDATE, &entry);
8789 printf("flow director programming error: (%s)\n",
8793 cmdline_parse_token_string_t cmd_flow_director_filter =
8794 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8795 flow_director_filter, "flow_director_filter");
8796 cmdline_parse_token_num_t cmd_flow_director_port_id =
8797 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8799 cmdline_parse_token_string_t cmd_flow_director_ops =
8800 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8801 ops, "add#del#update");
8802 cmdline_parse_token_string_t cmd_flow_director_flow =
8803 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8805 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8806 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8807 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8808 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8809 cmdline_parse_token_string_t cmd_flow_director_ether =
8810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8812 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8813 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8814 ether_type, UINT16);
8815 cmdline_parse_token_string_t cmd_flow_director_src =
8816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8818 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8819 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8821 cmdline_parse_token_num_t cmd_flow_director_port_src =
8822 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8824 cmdline_parse_token_string_t cmd_flow_director_dst =
8825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8827 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8828 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8830 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8831 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8833 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8835 verify_tag, "verify_tag");
8836 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8837 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8838 verify_tag_value, UINT32);
8839 cmdline_parse_token_string_t cmd_flow_director_tos =
8840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8842 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8843 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8845 cmdline_parse_token_string_t cmd_flow_director_proto =
8846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8848 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8849 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8850 proto_value, UINT8);
8851 cmdline_parse_token_string_t cmd_flow_director_ttl =
8852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8854 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8855 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8857 cmdline_parse_token_string_t cmd_flow_director_vlan =
8858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8860 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8861 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8862 vlan_value, UINT16);
8863 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8865 flexbytes, "flexbytes");
8866 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8868 flexbytes_value, NULL);
8869 cmdline_parse_token_string_t cmd_flow_director_drop =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8872 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8875 cmdline_parse_token_string_t cmd_flow_director_queue =
8876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8878 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8879 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8881 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8884 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8885 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8886 fd_id_value, UINT32);
8888 cmdline_parse_token_string_t cmd_flow_director_mode =
8889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8891 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8894 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8896 mode_value, "MAC-VLAN");
8897 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8899 mode_value, "Tunnel");
8900 cmdline_parse_token_string_t cmd_flow_director_mac =
8901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8903 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8904 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8906 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8909 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8911 tunnel_type, "NVGRE#VxLAN");
8912 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8914 tunnel_id, "tunnel-id");
8915 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8916 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8917 tunnel_id_value, UINT32);
8919 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8920 .f = cmd_flow_director_filter_parsed,
8922 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8923 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8924 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8925 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8926 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8927 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8928 "fd_id <fd_id_value>: "
8929 "Add or delete an ip flow director entry on NIC",
8931 (void *)&cmd_flow_director_filter,
8932 (void *)&cmd_flow_director_port_id,
8933 (void *)&cmd_flow_director_mode,
8934 (void *)&cmd_flow_director_mode_ip,
8935 (void *)&cmd_flow_director_ops,
8936 (void *)&cmd_flow_director_flow,
8937 (void *)&cmd_flow_director_flow_type,
8938 (void *)&cmd_flow_director_src,
8939 (void *)&cmd_flow_director_ip_src,
8940 (void *)&cmd_flow_director_dst,
8941 (void *)&cmd_flow_director_ip_dst,
8942 (void *)&cmd_flow_director_tos,
8943 (void *)&cmd_flow_director_tos_value,
8944 (void *)&cmd_flow_director_proto,
8945 (void *)&cmd_flow_director_proto_value,
8946 (void *)&cmd_flow_director_ttl,
8947 (void *)&cmd_flow_director_ttl_value,
8948 (void *)&cmd_flow_director_vlan,
8949 (void *)&cmd_flow_director_vlan_value,
8950 (void *)&cmd_flow_director_flexbytes,
8951 (void *)&cmd_flow_director_flexbytes_value,
8952 (void *)&cmd_flow_director_drop,
8953 (void *)&cmd_flow_director_pf_vf,
8954 (void *)&cmd_flow_director_queue,
8955 (void *)&cmd_flow_director_queue_id,
8956 (void *)&cmd_flow_director_fd_id,
8957 (void *)&cmd_flow_director_fd_id_value,
8962 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8963 .f = cmd_flow_director_filter_parsed,
8965 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8966 "director entry on NIC",
8968 (void *)&cmd_flow_director_filter,
8969 (void *)&cmd_flow_director_port_id,
8970 (void *)&cmd_flow_director_mode,
8971 (void *)&cmd_flow_director_mode_ip,
8972 (void *)&cmd_flow_director_ops,
8973 (void *)&cmd_flow_director_flow,
8974 (void *)&cmd_flow_director_flow_type,
8975 (void *)&cmd_flow_director_src,
8976 (void *)&cmd_flow_director_ip_src,
8977 (void *)&cmd_flow_director_port_src,
8978 (void *)&cmd_flow_director_dst,
8979 (void *)&cmd_flow_director_ip_dst,
8980 (void *)&cmd_flow_director_port_dst,
8981 (void *)&cmd_flow_director_tos,
8982 (void *)&cmd_flow_director_tos_value,
8983 (void *)&cmd_flow_director_ttl,
8984 (void *)&cmd_flow_director_ttl_value,
8985 (void *)&cmd_flow_director_vlan,
8986 (void *)&cmd_flow_director_vlan_value,
8987 (void *)&cmd_flow_director_flexbytes,
8988 (void *)&cmd_flow_director_flexbytes_value,
8989 (void *)&cmd_flow_director_drop,
8990 (void *)&cmd_flow_director_pf_vf,
8991 (void *)&cmd_flow_director_queue,
8992 (void *)&cmd_flow_director_queue_id,
8993 (void *)&cmd_flow_director_fd_id,
8994 (void *)&cmd_flow_director_fd_id_value,
8999 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9000 .f = cmd_flow_director_filter_parsed,
9002 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9003 "director entry on NIC",
9005 (void *)&cmd_flow_director_filter,
9006 (void *)&cmd_flow_director_port_id,
9007 (void *)&cmd_flow_director_mode,
9008 (void *)&cmd_flow_director_mode_ip,
9009 (void *)&cmd_flow_director_ops,
9010 (void *)&cmd_flow_director_flow,
9011 (void *)&cmd_flow_director_flow_type,
9012 (void *)&cmd_flow_director_src,
9013 (void *)&cmd_flow_director_ip_src,
9014 (void *)&cmd_flow_director_port_dst,
9015 (void *)&cmd_flow_director_dst,
9016 (void *)&cmd_flow_director_ip_dst,
9017 (void *)&cmd_flow_director_port_dst,
9018 (void *)&cmd_flow_director_verify_tag,
9019 (void *)&cmd_flow_director_verify_tag_value,
9020 (void *)&cmd_flow_director_tos,
9021 (void *)&cmd_flow_director_tos_value,
9022 (void *)&cmd_flow_director_ttl,
9023 (void *)&cmd_flow_director_ttl_value,
9024 (void *)&cmd_flow_director_vlan,
9025 (void *)&cmd_flow_director_vlan_value,
9026 (void *)&cmd_flow_director_flexbytes,
9027 (void *)&cmd_flow_director_flexbytes_value,
9028 (void *)&cmd_flow_director_drop,
9029 (void *)&cmd_flow_director_pf_vf,
9030 (void *)&cmd_flow_director_queue,
9031 (void *)&cmd_flow_director_queue_id,
9032 (void *)&cmd_flow_director_fd_id,
9033 (void *)&cmd_flow_director_fd_id_value,
9038 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9039 .f = cmd_flow_director_filter_parsed,
9041 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9042 "director entry on NIC",
9044 (void *)&cmd_flow_director_filter,
9045 (void *)&cmd_flow_director_port_id,
9046 (void *)&cmd_flow_director_mode,
9047 (void *)&cmd_flow_director_mode_ip,
9048 (void *)&cmd_flow_director_ops,
9049 (void *)&cmd_flow_director_flow,
9050 (void *)&cmd_flow_director_flow_type,
9051 (void *)&cmd_flow_director_ether,
9052 (void *)&cmd_flow_director_ether_type,
9053 (void *)&cmd_flow_director_flexbytes,
9054 (void *)&cmd_flow_director_flexbytes_value,
9055 (void *)&cmd_flow_director_drop,
9056 (void *)&cmd_flow_director_pf_vf,
9057 (void *)&cmd_flow_director_queue,
9058 (void *)&cmd_flow_director_queue_id,
9059 (void *)&cmd_flow_director_fd_id,
9060 (void *)&cmd_flow_director_fd_id_value,
9065 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9066 .f = cmd_flow_director_filter_parsed,
9068 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9069 "director entry on NIC",
9071 (void *)&cmd_flow_director_filter,
9072 (void *)&cmd_flow_director_port_id,
9073 (void *)&cmd_flow_director_mode,
9074 (void *)&cmd_flow_director_mode_mac_vlan,
9075 (void *)&cmd_flow_director_ops,
9076 (void *)&cmd_flow_director_mac,
9077 (void *)&cmd_flow_director_mac_addr,
9078 (void *)&cmd_flow_director_vlan,
9079 (void *)&cmd_flow_director_vlan_value,
9080 (void *)&cmd_flow_director_flexbytes,
9081 (void *)&cmd_flow_director_flexbytes_value,
9082 (void *)&cmd_flow_director_drop,
9083 (void *)&cmd_flow_director_queue,
9084 (void *)&cmd_flow_director_queue_id,
9085 (void *)&cmd_flow_director_fd_id,
9086 (void *)&cmd_flow_director_fd_id_value,
9091 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9092 .f = cmd_flow_director_filter_parsed,
9094 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9095 "director entry on NIC",
9097 (void *)&cmd_flow_director_filter,
9098 (void *)&cmd_flow_director_port_id,
9099 (void *)&cmd_flow_director_mode,
9100 (void *)&cmd_flow_director_mode_tunnel,
9101 (void *)&cmd_flow_director_ops,
9102 (void *)&cmd_flow_director_mac,
9103 (void *)&cmd_flow_director_mac_addr,
9104 (void *)&cmd_flow_director_vlan,
9105 (void *)&cmd_flow_director_vlan_value,
9106 (void *)&cmd_flow_director_tunnel,
9107 (void *)&cmd_flow_director_tunnel_type,
9108 (void *)&cmd_flow_director_tunnel_id,
9109 (void *)&cmd_flow_director_tunnel_id_value,
9110 (void *)&cmd_flow_director_flexbytes,
9111 (void *)&cmd_flow_director_flexbytes_value,
9112 (void *)&cmd_flow_director_drop,
9113 (void *)&cmd_flow_director_queue,
9114 (void *)&cmd_flow_director_queue_id,
9115 (void *)&cmd_flow_director_fd_id,
9116 (void *)&cmd_flow_director_fd_id_value,
9121 struct cmd_flush_flow_director_result {
9122 cmdline_fixed_string_t flush_flow_director;
9126 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9127 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9128 flush_flow_director, "flush_flow_director");
9129 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9130 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9134 cmd_flush_flow_director_parsed(void *parsed_result,
9135 __attribute__((unused)) struct cmdline *cl,
9136 __attribute__((unused)) void *data)
9138 struct cmd_flow_director_result *res = parsed_result;
9141 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9143 printf("flow director is not supported on port %u.\n",
9148 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9149 RTE_ETH_FILTER_FLUSH, NULL);
9151 printf("flow director table flushing error: (%s)\n",
9155 cmdline_parse_inst_t cmd_flush_flow_director = {
9156 .f = cmd_flush_flow_director_parsed,
9158 .help_str = "flush_flow_director <port_id>: "
9159 "Flush all flow director entries of a device on NIC",
9161 (void *)&cmd_flush_flow_director_flush,
9162 (void *)&cmd_flush_flow_director_port_id,
9167 /* *** deal with flow director mask *** */
9168 struct cmd_flow_director_mask_result {
9169 cmdline_fixed_string_t flow_director_mask;
9171 cmdline_fixed_string_t mode;
9172 cmdline_fixed_string_t mode_value;
9173 cmdline_fixed_string_t vlan;
9175 cmdline_fixed_string_t src_mask;
9176 cmdline_ipaddr_t ipv4_src;
9177 cmdline_ipaddr_t ipv6_src;
9179 cmdline_fixed_string_t dst_mask;
9180 cmdline_ipaddr_t ipv4_dst;
9181 cmdline_ipaddr_t ipv6_dst;
9183 cmdline_fixed_string_t mac;
9184 uint8_t mac_addr_byte_mask;
9185 cmdline_fixed_string_t tunnel_id;
9186 uint32_t tunnel_id_mask;
9187 cmdline_fixed_string_t tunnel_type;
9188 uint8_t tunnel_type_mask;
9192 cmd_flow_director_mask_parsed(void *parsed_result,
9193 __attribute__((unused)) struct cmdline *cl,
9194 __attribute__((unused)) void *data)
9196 struct cmd_flow_director_mask_result *res = parsed_result;
9197 struct rte_eth_fdir_masks *mask;
9198 struct rte_port *port;
9200 if (res->port_id > nb_ports) {
9201 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9205 port = &ports[res->port_id];
9206 /** Check if the port is not started **/
9207 if (port->port_status != RTE_PORT_STOPPED) {
9208 printf("Please stop port %d first\n", res->port_id);
9212 mask = &port->dev_conf.fdir_conf.mask;
9214 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9215 if (strcmp(res->mode_value, "MAC-VLAN")) {
9216 printf("Please set mode to MAC-VLAN.\n");
9220 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9221 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9222 if (strcmp(res->mode_value, "Tunnel")) {
9223 printf("Please set mode to Tunnel.\n");
9227 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9228 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9229 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9230 mask->tunnel_type_mask = res->tunnel_type_mask;
9232 if (strcmp(res->mode_value, "IP")) {
9233 printf("Please set mode to IP.\n");
9237 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9238 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9239 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9240 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9241 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9242 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9243 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9246 cmd_reconfig_device_queue(res->port_id, 1, 1);
9249 cmdline_parse_token_string_t cmd_flow_director_mask =
9250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9251 flow_director_mask, "flow_director_mask");
9252 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9253 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9255 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9258 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9259 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9261 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9263 src_mask, "src_mask");
9264 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9265 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9267 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9268 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9270 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9271 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9273 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9275 dst_mask, "dst_mask");
9276 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9277 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9279 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9280 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9282 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9283 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9286 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9287 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9289 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9290 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9292 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9294 mode_value, "MAC-VLAN");
9295 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9297 mode_value, "Tunnel");
9298 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9301 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9302 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9303 mac_addr_byte_mask, UINT8);
9304 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9305 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9306 tunnel_type, "tunnel-type");
9307 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9308 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9309 tunnel_type_mask, UINT8);
9310 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9312 tunnel_id, "tunnel-id");
9313 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9314 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9315 tunnel_id_mask, UINT32);
9317 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9318 .f = cmd_flow_director_mask_parsed,
9320 .help_str = "flow_director_mask ... : "
9321 "Set IP mode flow director's mask on NIC",
9323 (void *)&cmd_flow_director_mask,
9324 (void *)&cmd_flow_director_mask_port_id,
9325 (void *)&cmd_flow_director_mask_mode,
9326 (void *)&cmd_flow_director_mask_mode_ip,
9327 (void *)&cmd_flow_director_mask_vlan,
9328 (void *)&cmd_flow_director_mask_vlan_value,
9329 (void *)&cmd_flow_director_mask_src,
9330 (void *)&cmd_flow_director_mask_ipv4_src,
9331 (void *)&cmd_flow_director_mask_ipv6_src,
9332 (void *)&cmd_flow_director_mask_port_src,
9333 (void *)&cmd_flow_director_mask_dst,
9334 (void *)&cmd_flow_director_mask_ipv4_dst,
9335 (void *)&cmd_flow_director_mask_ipv6_dst,
9336 (void *)&cmd_flow_director_mask_port_dst,
9341 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9342 .f = cmd_flow_director_mask_parsed,
9344 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9345 "flow director's mask on NIC",
9347 (void *)&cmd_flow_director_mask,
9348 (void *)&cmd_flow_director_mask_port_id,
9349 (void *)&cmd_flow_director_mask_mode,
9350 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9351 (void *)&cmd_flow_director_mask_vlan,
9352 (void *)&cmd_flow_director_mask_vlan_value,
9357 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9358 .f = cmd_flow_director_mask_parsed,
9360 .help_str = "flow_director_mask ... : Set tunnel mode "
9361 "flow director's mask on NIC",
9363 (void *)&cmd_flow_director_mask,
9364 (void *)&cmd_flow_director_mask_port_id,
9365 (void *)&cmd_flow_director_mask_mode,
9366 (void *)&cmd_flow_director_mask_mode_tunnel,
9367 (void *)&cmd_flow_director_mask_vlan,
9368 (void *)&cmd_flow_director_mask_vlan_value,
9369 (void *)&cmd_flow_director_mask_mac,
9370 (void *)&cmd_flow_director_mask_mac_value,
9371 (void *)&cmd_flow_director_mask_tunnel_type,
9372 (void *)&cmd_flow_director_mask_tunnel_type_value,
9373 (void *)&cmd_flow_director_mask_tunnel_id,
9374 (void *)&cmd_flow_director_mask_tunnel_id_value,
9379 /* *** deal with flow director mask on flexible payload *** */
9380 struct cmd_flow_director_flex_mask_result {
9381 cmdline_fixed_string_t flow_director_flexmask;
9383 cmdline_fixed_string_t flow;
9384 cmdline_fixed_string_t flow_type;
9385 cmdline_fixed_string_t mask;
9389 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9390 __attribute__((unused)) struct cmdline *cl,
9391 __attribute__((unused)) void *data)
9393 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9394 struct rte_eth_fdir_info fdir_info;
9395 struct rte_eth_fdir_flex_mask flex_mask;
9396 struct rte_port *port;
9397 uint32_t flow_type_mask;
9401 if (res->port_id > nb_ports) {
9402 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9406 port = &ports[res->port_id];
9407 /** Check if the port is not started **/
9408 if (port->port_status != RTE_PORT_STOPPED) {
9409 printf("Please stop port %d first\n", res->port_id);
9413 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9414 ret = parse_flexbytes(res->mask,
9416 RTE_ETH_FDIR_MAX_FLEXLEN);
9418 printf("error: Cannot parse mask input.\n");
9422 memset(&fdir_info, 0, sizeof(fdir_info));
9423 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9424 RTE_ETH_FILTER_INFO, &fdir_info);
9426 printf("Cannot get FDir filter info\n");
9430 if (!strcmp(res->flow_type, "none")) {
9431 /* means don't specify the flow type */
9432 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9433 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9434 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9435 0, sizeof(struct rte_eth_fdir_flex_mask));
9436 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9437 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9439 sizeof(struct rte_eth_fdir_flex_mask));
9440 cmd_reconfig_device_queue(res->port_id, 1, 1);
9443 flow_type_mask = fdir_info.flow_types_mask[0];
9444 if (!strcmp(res->flow_type, "all")) {
9445 if (!flow_type_mask) {
9446 printf("No flow type supported\n");
9449 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9450 if (flow_type_mask & (1 << i)) {
9451 flex_mask.flow_type = i;
9452 fdir_set_flex_mask(res->port_id, &flex_mask);
9455 cmd_reconfig_device_queue(res->port_id, 1, 1);
9458 flex_mask.flow_type = str2flowtype(res->flow_type);
9459 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9460 printf("Flow type %s not supported on port %d\n",
9461 res->flow_type, res->port_id);
9464 fdir_set_flex_mask(res->port_id, &flex_mask);
9465 cmd_reconfig_device_queue(res->port_id, 1, 1);
9468 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9469 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9470 flow_director_flexmask,
9471 "flow_director_flex_mask");
9472 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9473 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9475 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9476 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9478 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9479 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9480 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9481 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9482 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9483 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9486 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9487 .f = cmd_flow_director_flex_mask_parsed,
9489 .help_str = "flow_director_flex_mask ... : "
9490 "Set flow director's flex mask on NIC",
9492 (void *)&cmd_flow_director_flexmask,
9493 (void *)&cmd_flow_director_flexmask_port_id,
9494 (void *)&cmd_flow_director_flexmask_flow,
9495 (void *)&cmd_flow_director_flexmask_flow_type,
9496 (void *)&cmd_flow_director_flexmask_mask,
9501 /* *** deal with flow director flexible payload configuration *** */
9502 struct cmd_flow_director_flexpayload_result {
9503 cmdline_fixed_string_t flow_director_flexpayload;
9505 cmdline_fixed_string_t payload_layer;
9506 cmdline_fixed_string_t payload_cfg;
9510 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9513 const char *p, *p0 = q_arg;
9515 unsigned long int_fld;
9516 char *str_fld[max_num];
9521 p = strchr(p0, '(');
9525 p0 = strchr(p, ')');
9530 if (size >= sizeof(s))
9533 snprintf(s, sizeof(s), "%.*s", size, p);
9534 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9535 if (ret < 0 || ret > max_num)
9537 for (i = 0; i < ret; i++) {
9539 int_fld = strtoul(str_fld[i], &end, 0);
9540 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9542 offsets[i] = (uint16_t)int_fld;
9548 cmd_flow_director_flxpld_parsed(void *parsed_result,
9549 __attribute__((unused)) struct cmdline *cl,
9550 __attribute__((unused)) void *data)
9552 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9553 struct rte_eth_flex_payload_cfg flex_cfg;
9554 struct rte_port *port;
9557 if (res->port_id > nb_ports) {
9558 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9562 port = &ports[res->port_id];
9563 /** Check if the port is not started **/
9564 if (port->port_status != RTE_PORT_STOPPED) {
9565 printf("Please stop port %d first\n", res->port_id);
9569 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9571 if (!strcmp(res->payload_layer, "raw"))
9572 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9573 else if (!strcmp(res->payload_layer, "l2"))
9574 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9575 else if (!strcmp(res->payload_layer, "l3"))
9576 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9577 else if (!strcmp(res->payload_layer, "l4"))
9578 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9580 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9581 RTE_ETH_FDIR_MAX_FLEXLEN);
9583 printf("error: Cannot parse flex payload input.\n");
9587 fdir_set_flex_payload(res->port_id, &flex_cfg);
9588 cmd_reconfig_device_queue(res->port_id, 1, 1);
9591 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9592 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9593 flow_director_flexpayload,
9594 "flow_director_flex_payload");
9595 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9596 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9598 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9600 payload_layer, "raw#l2#l3#l4");
9601 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9605 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9606 .f = cmd_flow_director_flxpld_parsed,
9608 .help_str = "flow_director_flexpayload ... : "
9609 "Set flow director's flex payload on NIC",
9611 (void *)&cmd_flow_director_flexpayload,
9612 (void *)&cmd_flow_director_flexpayload_port_id,
9613 (void *)&cmd_flow_director_flexpayload_payload_layer,
9614 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9619 /* Generic flow interface command. */
9620 extern cmdline_parse_inst_t cmd_flow;
9622 /* *** Classification Filters Control *** */
9623 /* *** Get symmetric hash enable per port *** */
9624 struct cmd_get_sym_hash_ena_per_port_result {
9625 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9630 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9631 __rte_unused struct cmdline *cl,
9632 __rte_unused void *data)
9634 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9635 struct rte_eth_hash_filter_info info;
9638 if (rte_eth_dev_filter_supported(res->port_id,
9639 RTE_ETH_FILTER_HASH) < 0) {
9640 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9645 memset(&info, 0, sizeof(info));
9646 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9647 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9648 RTE_ETH_FILTER_GET, &info);
9651 printf("Cannot get symmetric hash enable per port "
9652 "on port %u\n", res->port_id);
9656 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9657 "enabled" : "disabled", res->port_id);
9660 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9661 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9662 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9663 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9664 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9667 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9668 .f = cmd_get_sym_hash_per_port_parsed,
9670 .help_str = "get_sym_hash_ena_per_port <port_id>",
9672 (void *)&cmd_get_sym_hash_ena_per_port_all,
9673 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9678 /* *** Set symmetric hash enable per port *** */
9679 struct cmd_set_sym_hash_ena_per_port_result {
9680 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9681 cmdline_fixed_string_t enable;
9686 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9687 __rte_unused struct cmdline *cl,
9688 __rte_unused void *data)
9690 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9691 struct rte_eth_hash_filter_info info;
9694 if (rte_eth_dev_filter_supported(res->port_id,
9695 RTE_ETH_FILTER_HASH) < 0) {
9696 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9701 memset(&info, 0, sizeof(info));
9702 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9703 if (!strcmp(res->enable, "enable"))
9704 info.info.enable = 1;
9705 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9706 RTE_ETH_FILTER_SET, &info);
9708 printf("Cannot set symmetric hash enable per port on "
9709 "port %u\n", res->port_id);
9712 printf("Symmetric hash has been set to %s on port %u\n",
9713 res->enable, res->port_id);
9716 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9717 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9718 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9719 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9720 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9722 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9723 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9724 enable, "enable#disable");
9726 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9727 .f = cmd_set_sym_hash_per_port_parsed,
9729 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9731 (void *)&cmd_set_sym_hash_ena_per_port_all,
9732 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9733 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9738 /* Get global config of hash function */
9739 struct cmd_get_hash_global_config_result {
9740 cmdline_fixed_string_t get_hash_global_config;
9745 flowtype_to_str(uint16_t ftype)
9752 {"ipv4", RTE_ETH_FLOW_IPV4},
9753 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9754 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9755 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9756 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9757 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9758 {"ipv6", RTE_ETH_FLOW_IPV6},
9759 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9760 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9761 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9762 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9763 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9764 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9765 {"port", RTE_ETH_FLOW_PORT},
9766 {"vxlan", RTE_ETH_FLOW_VXLAN},
9767 {"geneve", RTE_ETH_FLOW_GENEVE},
9768 {"nvgre", RTE_ETH_FLOW_NVGRE},
9771 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9772 if (ftype_table[i].ftype == ftype)
9773 return ftype_table[i].str;
9780 cmd_get_hash_global_config_parsed(void *parsed_result,
9781 __rte_unused struct cmdline *cl,
9782 __rte_unused void *data)
9784 struct cmd_get_hash_global_config_result *res = parsed_result;
9785 struct rte_eth_hash_filter_info info;
9786 uint32_t idx, offset;
9791 if (rte_eth_dev_filter_supported(res->port_id,
9792 RTE_ETH_FILTER_HASH) < 0) {
9793 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9798 memset(&info, 0, sizeof(info));
9799 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9800 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9801 RTE_ETH_FILTER_GET, &info);
9803 printf("Cannot get hash global configurations by port %d\n",
9808 switch (info.info.global_conf.hash_func) {
9809 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9810 printf("Hash function is Toeplitz\n");
9812 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9813 printf("Hash function is Simple XOR\n");
9816 printf("Unknown hash function\n");
9820 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9821 idx = i / UINT32_BIT;
9822 offset = i % UINT32_BIT;
9823 if (!(info.info.global_conf.valid_bit_mask[idx] &
9826 str = flowtype_to_str(i);
9829 printf("Symmetric hash is %s globally for flow type %s "
9831 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9832 (1UL << offset)) ? "enabled" : "disabled"), str,
9837 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9838 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9839 get_hash_global_config, "get_hash_global_config");
9840 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9841 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9844 cmdline_parse_inst_t cmd_get_hash_global_config = {
9845 .f = cmd_get_hash_global_config_parsed,
9847 .help_str = "get_hash_global_config <port_id>",
9849 (void *)&cmd_get_hash_global_config_all,
9850 (void *)&cmd_get_hash_global_config_port_id,
9855 /* Set global config of hash function */
9856 struct cmd_set_hash_global_config_result {
9857 cmdline_fixed_string_t set_hash_global_config;
9859 cmdline_fixed_string_t hash_func;
9860 cmdline_fixed_string_t flow_type;
9861 cmdline_fixed_string_t enable;
9865 cmd_set_hash_global_config_parsed(void *parsed_result,
9866 __rte_unused struct cmdline *cl,
9867 __rte_unused void *data)
9869 struct cmd_set_hash_global_config_result *res = parsed_result;
9870 struct rte_eth_hash_filter_info info;
9871 uint32_t ftype, idx, offset;
9874 if (rte_eth_dev_filter_supported(res->port_id,
9875 RTE_ETH_FILTER_HASH) < 0) {
9876 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9880 memset(&info, 0, sizeof(info));
9881 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9882 if (!strcmp(res->hash_func, "toeplitz"))
9883 info.info.global_conf.hash_func =
9884 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9885 else if (!strcmp(res->hash_func, "simple_xor"))
9886 info.info.global_conf.hash_func =
9887 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9888 else if (!strcmp(res->hash_func, "default"))
9889 info.info.global_conf.hash_func =
9890 RTE_ETH_HASH_FUNCTION_DEFAULT;
9892 ftype = str2flowtype(res->flow_type);
9893 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9894 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9895 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9896 if (!strcmp(res->enable, "enable"))
9897 info.info.global_conf.sym_hash_enable_mask[idx] |=
9899 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9900 RTE_ETH_FILTER_SET, &info);
9902 printf("Cannot set global hash configurations by port %d\n",
9905 printf("Global hash configurations have been set "
9906 "succcessfully by port %d\n", res->port_id);
9909 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9910 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9911 set_hash_global_config, "set_hash_global_config");
9912 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9913 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9915 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9916 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9917 hash_func, "toeplitz#simple_xor#default");
9918 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9919 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9921 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9922 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9923 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9924 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9925 enable, "enable#disable");
9927 cmdline_parse_inst_t cmd_set_hash_global_config = {
9928 .f = cmd_set_hash_global_config_parsed,
9930 .help_str = "set_hash_global_config <port_id> "
9931 "toeplitz|simple_xor|default "
9932 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9933 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9934 "l2_payload enable|disable",
9936 (void *)&cmd_set_hash_global_config_all,
9937 (void *)&cmd_set_hash_global_config_port_id,
9938 (void *)&cmd_set_hash_global_config_hash_func,
9939 (void *)&cmd_set_hash_global_config_flow_type,
9940 (void *)&cmd_set_hash_global_config_enable,
9945 /* Set hash input set */
9946 struct cmd_set_hash_input_set_result {
9947 cmdline_fixed_string_t set_hash_input_set;
9949 cmdline_fixed_string_t flow_type;
9950 cmdline_fixed_string_t inset_field;
9951 cmdline_fixed_string_t select;
9954 static enum rte_eth_input_set_field
9955 str2inset(char *string)
9959 static const struct {
9961 enum rte_eth_input_set_field inset;
9963 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9964 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9965 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9966 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9967 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9968 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9969 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9970 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9971 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9972 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9973 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9974 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9975 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9976 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9977 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9978 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9979 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9980 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9981 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9982 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9983 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9984 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9985 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9986 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9987 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9988 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9989 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9990 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9991 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9992 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9993 {"none", RTE_ETH_INPUT_SET_NONE},
9996 for (i = 0; i < RTE_DIM(inset_table); i++) {
9997 if (!strcmp(string, inset_table[i].str))
9998 return inset_table[i].inset;
10001 return RTE_ETH_INPUT_SET_UNKNOWN;
10005 cmd_set_hash_input_set_parsed(void *parsed_result,
10006 __rte_unused struct cmdline *cl,
10007 __rte_unused void *data)
10009 struct cmd_set_hash_input_set_result *res = parsed_result;
10010 struct rte_eth_hash_filter_info info;
10012 memset(&info, 0, sizeof(info));
10013 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10014 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10015 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10016 info.info.input_set_conf.inset_size = 1;
10017 if (!strcmp(res->select, "select"))
10018 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10019 else if (!strcmp(res->select, "add"))
10020 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10021 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10022 RTE_ETH_FILTER_SET, &info);
10025 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10026 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10027 set_hash_input_set, "set_hash_input_set");
10028 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10029 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10031 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10032 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10034 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10035 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10036 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10037 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10039 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10040 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10041 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10042 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10043 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10045 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10046 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10047 select, "select#add");
10049 cmdline_parse_inst_t cmd_set_hash_input_set = {
10050 .f = cmd_set_hash_input_set_parsed,
10052 .help_str = "set_hash_input_set <port_id> "
10053 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10054 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10055 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10056 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10057 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10058 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10059 "fld-7th|fld-8th|none select|add",
10061 (void *)&cmd_set_hash_input_set_cmd,
10062 (void *)&cmd_set_hash_input_set_port_id,
10063 (void *)&cmd_set_hash_input_set_flow_type,
10064 (void *)&cmd_set_hash_input_set_field,
10065 (void *)&cmd_set_hash_input_set_select,
10070 /* Set flow director input set */
10071 struct cmd_set_fdir_input_set_result {
10072 cmdline_fixed_string_t set_fdir_input_set;
10074 cmdline_fixed_string_t flow_type;
10075 cmdline_fixed_string_t inset_field;
10076 cmdline_fixed_string_t select;
10080 cmd_set_fdir_input_set_parsed(void *parsed_result,
10081 __rte_unused struct cmdline *cl,
10082 __rte_unused void *data)
10084 struct cmd_set_fdir_input_set_result *res = parsed_result;
10085 struct rte_eth_fdir_filter_info info;
10087 memset(&info, 0, sizeof(info));
10088 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10089 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10090 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10091 info.info.input_set_conf.inset_size = 1;
10092 if (!strcmp(res->select, "select"))
10093 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10094 else if (!strcmp(res->select, "add"))
10095 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10096 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10097 RTE_ETH_FILTER_SET, &info);
10100 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10101 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10102 set_fdir_input_set, "set_fdir_input_set");
10103 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10104 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10106 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10107 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10109 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10110 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10111 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10112 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10114 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10115 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10116 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10117 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10118 "sctp-veri-tag#none");
10119 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10120 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10121 select, "select#add");
10123 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10124 .f = cmd_set_fdir_input_set_parsed,
10126 .help_str = "set_fdir_input_set <port_id> "
10127 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10128 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10129 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10130 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10131 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10132 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10133 "sctp-veri-tag|none select|add",
10135 (void *)&cmd_set_fdir_input_set_cmd,
10136 (void *)&cmd_set_fdir_input_set_port_id,
10137 (void *)&cmd_set_fdir_input_set_flow_type,
10138 (void *)&cmd_set_fdir_input_set_field,
10139 (void *)&cmd_set_fdir_input_set_select,
10144 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10145 struct cmd_mcast_addr_result {
10146 cmdline_fixed_string_t mcast_addr_cmd;
10147 cmdline_fixed_string_t what;
10149 struct ether_addr mc_addr;
10152 static void cmd_mcast_addr_parsed(void *parsed_result,
10153 __attribute__((unused)) struct cmdline *cl,
10154 __attribute__((unused)) void *data)
10156 struct cmd_mcast_addr_result *res = parsed_result;
10158 if (!is_multicast_ether_addr(&res->mc_addr)) {
10159 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10160 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10161 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10162 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10165 if (strcmp(res->what, "add") == 0)
10166 mcast_addr_add(res->port_num, &res->mc_addr);
10168 mcast_addr_remove(res->port_num, &res->mc_addr);
10171 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10172 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10173 mcast_addr_cmd, "mcast_addr");
10174 cmdline_parse_token_string_t cmd_mcast_addr_what =
10175 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10177 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10178 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10179 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10180 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10182 cmdline_parse_inst_t cmd_mcast_addr = {
10183 .f = cmd_mcast_addr_parsed,
10185 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10186 "Add/Remove multicast MAC address on port_id",
10188 (void *)&cmd_mcast_addr_cmd,
10189 (void *)&cmd_mcast_addr_what,
10190 (void *)&cmd_mcast_addr_portnum,
10191 (void *)&cmd_mcast_addr_addr,
10196 /* l2 tunnel config
10197 * only support E-tag now.
10200 /* Ether type config */
10201 struct cmd_config_l2_tunnel_eth_type_result {
10202 cmdline_fixed_string_t port;
10203 cmdline_fixed_string_t config;
10204 cmdline_fixed_string_t all;
10206 cmdline_fixed_string_t l2_tunnel;
10207 cmdline_fixed_string_t l2_tunnel_type;
10208 cmdline_fixed_string_t eth_type;
10209 uint16_t eth_type_val;
10212 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10213 TOKEN_STRING_INITIALIZER
10214 (struct cmd_config_l2_tunnel_eth_type_result,
10216 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10217 TOKEN_STRING_INITIALIZER
10218 (struct cmd_config_l2_tunnel_eth_type_result,
10220 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10221 TOKEN_STRING_INITIALIZER
10222 (struct cmd_config_l2_tunnel_eth_type_result,
10224 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10225 TOKEN_NUM_INITIALIZER
10226 (struct cmd_config_l2_tunnel_eth_type_result,
10228 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10229 TOKEN_STRING_INITIALIZER
10230 (struct cmd_config_l2_tunnel_eth_type_result,
10231 l2_tunnel, "l2-tunnel");
10232 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10233 TOKEN_STRING_INITIALIZER
10234 (struct cmd_config_l2_tunnel_eth_type_result,
10235 l2_tunnel_type, "E-tag");
10236 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10237 TOKEN_STRING_INITIALIZER
10238 (struct cmd_config_l2_tunnel_eth_type_result,
10239 eth_type, "ether-type");
10240 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10241 TOKEN_NUM_INITIALIZER
10242 (struct cmd_config_l2_tunnel_eth_type_result,
10243 eth_type_val, UINT16);
10245 static enum rte_eth_tunnel_type
10246 str2fdir_l2_tunnel_type(char *string)
10250 static const struct {
10252 enum rte_eth_tunnel_type type;
10253 } l2_tunnel_type_str[] = {
10254 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10257 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10258 if (!strcmp(l2_tunnel_type_str[i].str, string))
10259 return l2_tunnel_type_str[i].type;
10261 return RTE_TUNNEL_TYPE_NONE;
10264 /* ether type config for all ports */
10266 cmd_config_l2_tunnel_eth_type_all_parsed
10267 (void *parsed_result,
10268 __attribute__((unused)) struct cmdline *cl,
10269 __attribute__((unused)) void *data)
10271 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10272 struct rte_eth_l2_tunnel_conf entry;
10275 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10276 entry.ether_type = res->eth_type_val;
10278 FOREACH_PORT(pid, ports) {
10279 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10283 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10284 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10286 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10288 (void *)&cmd_config_l2_tunnel_eth_type_port,
10289 (void *)&cmd_config_l2_tunnel_eth_type_config,
10290 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10291 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10292 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10293 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10294 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10299 /* ether type config for a specific port */
10301 cmd_config_l2_tunnel_eth_type_specific_parsed(
10302 void *parsed_result,
10303 __attribute__((unused)) struct cmdline *cl,
10304 __attribute__((unused)) void *data)
10306 struct cmd_config_l2_tunnel_eth_type_result *res =
10308 struct rte_eth_l2_tunnel_conf entry;
10310 if (port_id_is_invalid(res->id, ENABLED_WARN))
10313 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10314 entry.ether_type = res->eth_type_val;
10316 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10319 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10320 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10322 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10324 (void *)&cmd_config_l2_tunnel_eth_type_port,
10325 (void *)&cmd_config_l2_tunnel_eth_type_config,
10326 (void *)&cmd_config_l2_tunnel_eth_type_id,
10327 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10328 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10329 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10330 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10335 /* Enable/disable l2 tunnel */
10336 struct cmd_config_l2_tunnel_en_dis_result {
10337 cmdline_fixed_string_t port;
10338 cmdline_fixed_string_t config;
10339 cmdline_fixed_string_t all;
10341 cmdline_fixed_string_t l2_tunnel;
10342 cmdline_fixed_string_t l2_tunnel_type;
10343 cmdline_fixed_string_t en_dis;
10346 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10347 TOKEN_STRING_INITIALIZER
10348 (struct cmd_config_l2_tunnel_en_dis_result,
10350 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10351 TOKEN_STRING_INITIALIZER
10352 (struct cmd_config_l2_tunnel_en_dis_result,
10354 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10355 TOKEN_STRING_INITIALIZER
10356 (struct cmd_config_l2_tunnel_en_dis_result,
10358 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10359 TOKEN_NUM_INITIALIZER
10360 (struct cmd_config_l2_tunnel_en_dis_result,
10362 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10363 TOKEN_STRING_INITIALIZER
10364 (struct cmd_config_l2_tunnel_en_dis_result,
10365 l2_tunnel, "l2-tunnel");
10366 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10367 TOKEN_STRING_INITIALIZER
10368 (struct cmd_config_l2_tunnel_en_dis_result,
10369 l2_tunnel_type, "E-tag");
10370 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10371 TOKEN_STRING_INITIALIZER
10372 (struct cmd_config_l2_tunnel_en_dis_result,
10373 en_dis, "enable#disable");
10375 /* enable/disable l2 tunnel for all ports */
10377 cmd_config_l2_tunnel_en_dis_all_parsed(
10378 void *parsed_result,
10379 __attribute__((unused)) struct cmdline *cl,
10380 __attribute__((unused)) void *data)
10382 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10383 struct rte_eth_l2_tunnel_conf entry;
10387 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10389 if (!strcmp("enable", res->en_dis))
10394 FOREACH_PORT(pid, ports) {
10395 rte_eth_dev_l2_tunnel_offload_set(pid,
10397 ETH_L2_TUNNEL_ENABLE_MASK,
10402 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10403 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10405 .help_str = "port config all l2-tunnel E-tag enable|disable",
10407 (void *)&cmd_config_l2_tunnel_en_dis_port,
10408 (void *)&cmd_config_l2_tunnel_en_dis_config,
10409 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10410 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10411 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10412 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10417 /* enable/disable l2 tunnel for a port */
10419 cmd_config_l2_tunnel_en_dis_specific_parsed(
10420 void *parsed_result,
10421 __attribute__((unused)) struct cmdline *cl,
10422 __attribute__((unused)) void *data)
10424 struct cmd_config_l2_tunnel_en_dis_result *res =
10426 struct rte_eth_l2_tunnel_conf entry;
10428 if (port_id_is_invalid(res->id, ENABLED_WARN))
10431 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10433 if (!strcmp("enable", res->en_dis))
10434 rte_eth_dev_l2_tunnel_offload_set(res->id,
10436 ETH_L2_TUNNEL_ENABLE_MASK,
10439 rte_eth_dev_l2_tunnel_offload_set(res->id,
10441 ETH_L2_TUNNEL_ENABLE_MASK,
10445 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10446 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10448 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10450 (void *)&cmd_config_l2_tunnel_en_dis_port,
10451 (void *)&cmd_config_l2_tunnel_en_dis_config,
10452 (void *)&cmd_config_l2_tunnel_en_dis_id,
10453 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10454 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10455 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10460 /* E-tag configuration */
10462 /* Common result structure for all E-tag configuration */
10463 struct cmd_config_e_tag_result {
10464 cmdline_fixed_string_t e_tag;
10465 cmdline_fixed_string_t set;
10466 cmdline_fixed_string_t insertion;
10467 cmdline_fixed_string_t stripping;
10468 cmdline_fixed_string_t forwarding;
10469 cmdline_fixed_string_t filter;
10470 cmdline_fixed_string_t add;
10471 cmdline_fixed_string_t del;
10472 cmdline_fixed_string_t on;
10473 cmdline_fixed_string_t off;
10474 cmdline_fixed_string_t on_off;
10475 cmdline_fixed_string_t port_tag_id;
10476 uint32_t port_tag_id_val;
10477 cmdline_fixed_string_t e_tag_id;
10478 uint16_t e_tag_id_val;
10479 cmdline_fixed_string_t dst_pool;
10480 uint8_t dst_pool_val;
10481 cmdline_fixed_string_t port;
10483 cmdline_fixed_string_t vf;
10487 /* Common CLI fields for all E-tag configuration */
10488 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10489 TOKEN_STRING_INITIALIZER
10490 (struct cmd_config_e_tag_result,
10492 cmdline_parse_token_string_t cmd_config_e_tag_set =
10493 TOKEN_STRING_INITIALIZER
10494 (struct cmd_config_e_tag_result,
10496 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10497 TOKEN_STRING_INITIALIZER
10498 (struct cmd_config_e_tag_result,
10499 insertion, "insertion");
10500 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10501 TOKEN_STRING_INITIALIZER
10502 (struct cmd_config_e_tag_result,
10503 stripping, "stripping");
10504 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10505 TOKEN_STRING_INITIALIZER
10506 (struct cmd_config_e_tag_result,
10507 forwarding, "forwarding");
10508 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10509 TOKEN_STRING_INITIALIZER
10510 (struct cmd_config_e_tag_result,
10512 cmdline_parse_token_string_t cmd_config_e_tag_add =
10513 TOKEN_STRING_INITIALIZER
10514 (struct cmd_config_e_tag_result,
10516 cmdline_parse_token_string_t cmd_config_e_tag_del =
10517 TOKEN_STRING_INITIALIZER
10518 (struct cmd_config_e_tag_result,
10520 cmdline_parse_token_string_t cmd_config_e_tag_on =
10521 TOKEN_STRING_INITIALIZER
10522 (struct cmd_config_e_tag_result,
10524 cmdline_parse_token_string_t cmd_config_e_tag_off =
10525 TOKEN_STRING_INITIALIZER
10526 (struct cmd_config_e_tag_result,
10528 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10529 TOKEN_STRING_INITIALIZER
10530 (struct cmd_config_e_tag_result,
10532 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10533 TOKEN_STRING_INITIALIZER
10534 (struct cmd_config_e_tag_result,
10535 port_tag_id, "port-tag-id");
10536 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10537 TOKEN_NUM_INITIALIZER
10538 (struct cmd_config_e_tag_result,
10539 port_tag_id_val, UINT32);
10540 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10541 TOKEN_STRING_INITIALIZER
10542 (struct cmd_config_e_tag_result,
10543 e_tag_id, "e-tag-id");
10544 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10545 TOKEN_NUM_INITIALIZER
10546 (struct cmd_config_e_tag_result,
10547 e_tag_id_val, UINT16);
10548 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10549 TOKEN_STRING_INITIALIZER
10550 (struct cmd_config_e_tag_result,
10551 dst_pool, "dst-pool");
10552 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10553 TOKEN_NUM_INITIALIZER
10554 (struct cmd_config_e_tag_result,
10555 dst_pool_val, UINT8);
10556 cmdline_parse_token_string_t cmd_config_e_tag_port =
10557 TOKEN_STRING_INITIALIZER
10558 (struct cmd_config_e_tag_result,
10560 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10561 TOKEN_NUM_INITIALIZER
10562 (struct cmd_config_e_tag_result,
10564 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10565 TOKEN_STRING_INITIALIZER
10566 (struct cmd_config_e_tag_result,
10568 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10569 TOKEN_NUM_INITIALIZER
10570 (struct cmd_config_e_tag_result,
10573 /* E-tag insertion configuration */
10575 cmd_config_e_tag_insertion_en_parsed(
10576 void *parsed_result,
10577 __attribute__((unused)) struct cmdline *cl,
10578 __attribute__((unused)) void *data)
10580 struct cmd_config_e_tag_result *res =
10582 struct rte_eth_l2_tunnel_conf entry;
10584 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10587 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10588 entry.tunnel_id = res->port_tag_id_val;
10589 entry.vf_id = res->vf_id;
10590 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10592 ETH_L2_TUNNEL_INSERTION_MASK,
10597 cmd_config_e_tag_insertion_dis_parsed(
10598 void *parsed_result,
10599 __attribute__((unused)) struct cmdline *cl,
10600 __attribute__((unused)) void *data)
10602 struct cmd_config_e_tag_result *res =
10604 struct rte_eth_l2_tunnel_conf entry;
10606 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10609 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10610 entry.vf_id = res->vf_id;
10612 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10614 ETH_L2_TUNNEL_INSERTION_MASK,
10618 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10619 .f = cmd_config_e_tag_insertion_en_parsed,
10621 .help_str = "E-tag ... : E-tag insertion enable",
10623 (void *)&cmd_config_e_tag_e_tag,
10624 (void *)&cmd_config_e_tag_set,
10625 (void *)&cmd_config_e_tag_insertion,
10626 (void *)&cmd_config_e_tag_on,
10627 (void *)&cmd_config_e_tag_port_tag_id,
10628 (void *)&cmd_config_e_tag_port_tag_id_val,
10629 (void *)&cmd_config_e_tag_port,
10630 (void *)&cmd_config_e_tag_port_id,
10631 (void *)&cmd_config_e_tag_vf,
10632 (void *)&cmd_config_e_tag_vf_id,
10637 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10638 .f = cmd_config_e_tag_insertion_dis_parsed,
10640 .help_str = "E-tag ... : E-tag insertion disable",
10642 (void *)&cmd_config_e_tag_e_tag,
10643 (void *)&cmd_config_e_tag_set,
10644 (void *)&cmd_config_e_tag_insertion,
10645 (void *)&cmd_config_e_tag_off,
10646 (void *)&cmd_config_e_tag_port,
10647 (void *)&cmd_config_e_tag_port_id,
10648 (void *)&cmd_config_e_tag_vf,
10649 (void *)&cmd_config_e_tag_vf_id,
10654 /* E-tag stripping configuration */
10656 cmd_config_e_tag_stripping_parsed(
10657 void *parsed_result,
10658 __attribute__((unused)) struct cmdline *cl,
10659 __attribute__((unused)) void *data)
10661 struct cmd_config_e_tag_result *res =
10663 struct rte_eth_l2_tunnel_conf entry;
10665 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10668 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10670 if (!strcmp(res->on_off, "on"))
10671 rte_eth_dev_l2_tunnel_offload_set
10674 ETH_L2_TUNNEL_STRIPPING_MASK,
10677 rte_eth_dev_l2_tunnel_offload_set
10680 ETH_L2_TUNNEL_STRIPPING_MASK,
10684 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10685 .f = cmd_config_e_tag_stripping_parsed,
10687 .help_str = "E-tag ... : E-tag stripping enable/disable",
10689 (void *)&cmd_config_e_tag_e_tag,
10690 (void *)&cmd_config_e_tag_set,
10691 (void *)&cmd_config_e_tag_stripping,
10692 (void *)&cmd_config_e_tag_on_off,
10693 (void *)&cmd_config_e_tag_port,
10694 (void *)&cmd_config_e_tag_port_id,
10699 /* E-tag forwarding configuration */
10701 cmd_config_e_tag_forwarding_parsed(
10702 void *parsed_result,
10703 __attribute__((unused)) struct cmdline *cl,
10704 __attribute__((unused)) void *data)
10706 struct cmd_config_e_tag_result *res = parsed_result;
10707 struct rte_eth_l2_tunnel_conf entry;
10709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10712 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10714 if (!strcmp(res->on_off, "on"))
10715 rte_eth_dev_l2_tunnel_offload_set
10718 ETH_L2_TUNNEL_FORWARDING_MASK,
10721 rte_eth_dev_l2_tunnel_offload_set
10724 ETH_L2_TUNNEL_FORWARDING_MASK,
10728 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10729 .f = cmd_config_e_tag_forwarding_parsed,
10731 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10733 (void *)&cmd_config_e_tag_e_tag,
10734 (void *)&cmd_config_e_tag_set,
10735 (void *)&cmd_config_e_tag_forwarding,
10736 (void *)&cmd_config_e_tag_on_off,
10737 (void *)&cmd_config_e_tag_port,
10738 (void *)&cmd_config_e_tag_port_id,
10743 /* E-tag filter configuration */
10745 cmd_config_e_tag_filter_add_parsed(
10746 void *parsed_result,
10747 __attribute__((unused)) struct cmdline *cl,
10748 __attribute__((unused)) void *data)
10750 struct cmd_config_e_tag_result *res = parsed_result;
10751 struct rte_eth_l2_tunnel_conf entry;
10754 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10757 if (res->e_tag_id_val > 0x3fff) {
10758 printf("e-tag-id must be equal or less than 0x3fff.\n");
10762 ret = rte_eth_dev_filter_supported(res->port_id,
10763 RTE_ETH_FILTER_L2_TUNNEL);
10765 printf("E-tag filter is not supported on port %u.\n",
10770 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10771 entry.tunnel_id = res->e_tag_id_val;
10772 entry.pool = res->dst_pool_val;
10774 ret = rte_eth_dev_filter_ctrl(res->port_id,
10775 RTE_ETH_FILTER_L2_TUNNEL,
10776 RTE_ETH_FILTER_ADD,
10779 printf("E-tag filter programming error: (%s)\n",
10783 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10784 .f = cmd_config_e_tag_filter_add_parsed,
10786 .help_str = "E-tag ... : E-tag filter add",
10788 (void *)&cmd_config_e_tag_e_tag,
10789 (void *)&cmd_config_e_tag_set,
10790 (void *)&cmd_config_e_tag_filter,
10791 (void *)&cmd_config_e_tag_add,
10792 (void *)&cmd_config_e_tag_e_tag_id,
10793 (void *)&cmd_config_e_tag_e_tag_id_val,
10794 (void *)&cmd_config_e_tag_dst_pool,
10795 (void *)&cmd_config_e_tag_dst_pool_val,
10796 (void *)&cmd_config_e_tag_port,
10797 (void *)&cmd_config_e_tag_port_id,
10803 cmd_config_e_tag_filter_del_parsed(
10804 void *parsed_result,
10805 __attribute__((unused)) struct cmdline *cl,
10806 __attribute__((unused)) void *data)
10808 struct cmd_config_e_tag_result *res = parsed_result;
10809 struct rte_eth_l2_tunnel_conf entry;
10812 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10815 if (res->e_tag_id_val > 0x3fff) {
10816 printf("e-tag-id must be less than 0x3fff.\n");
10820 ret = rte_eth_dev_filter_supported(res->port_id,
10821 RTE_ETH_FILTER_L2_TUNNEL);
10823 printf("E-tag filter is not supported on port %u.\n",
10828 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10829 entry.tunnel_id = res->e_tag_id_val;
10831 ret = rte_eth_dev_filter_ctrl(res->port_id,
10832 RTE_ETH_FILTER_L2_TUNNEL,
10833 RTE_ETH_FILTER_DELETE,
10836 printf("E-tag filter programming error: (%s)\n",
10840 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10841 .f = cmd_config_e_tag_filter_del_parsed,
10843 .help_str = "E-tag ... : E-tag filter delete",
10845 (void *)&cmd_config_e_tag_e_tag,
10846 (void *)&cmd_config_e_tag_set,
10847 (void *)&cmd_config_e_tag_filter,
10848 (void *)&cmd_config_e_tag_del,
10849 (void *)&cmd_config_e_tag_e_tag_id,
10850 (void *)&cmd_config_e_tag_e_tag_id_val,
10851 (void *)&cmd_config_e_tag_port,
10852 (void *)&cmd_config_e_tag_port_id,
10857 /* vf vlan anti spoof configuration */
10859 /* Common result structure for vf vlan anti spoof */
10860 struct cmd_vf_vlan_anti_spoof_result {
10861 cmdline_fixed_string_t set;
10862 cmdline_fixed_string_t vf;
10863 cmdline_fixed_string_t vlan;
10864 cmdline_fixed_string_t antispoof;
10867 cmdline_fixed_string_t on_off;
10870 /* Common CLI fields for vf vlan anti spoof enable disable */
10871 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10872 TOKEN_STRING_INITIALIZER
10873 (struct cmd_vf_vlan_anti_spoof_result,
10875 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10876 TOKEN_STRING_INITIALIZER
10877 (struct cmd_vf_vlan_anti_spoof_result,
10879 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10880 TOKEN_STRING_INITIALIZER
10881 (struct cmd_vf_vlan_anti_spoof_result,
10883 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10884 TOKEN_STRING_INITIALIZER
10885 (struct cmd_vf_vlan_anti_spoof_result,
10886 antispoof, "antispoof");
10887 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10888 TOKEN_NUM_INITIALIZER
10889 (struct cmd_vf_vlan_anti_spoof_result,
10891 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10892 TOKEN_NUM_INITIALIZER
10893 (struct cmd_vf_vlan_anti_spoof_result,
10895 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10896 TOKEN_STRING_INITIALIZER
10897 (struct cmd_vf_vlan_anti_spoof_result,
10901 cmd_set_vf_vlan_anti_spoof_parsed(
10902 void *parsed_result,
10903 __attribute__((unused)) struct cmdline *cl,
10904 __attribute__((unused)) void *data)
10906 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10907 int ret = -ENOTSUP;
10909 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10911 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10914 #ifdef RTE_LIBRTE_IXGBE_PMD
10915 if (ret == -ENOTSUP)
10916 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10917 res->vf_id, is_on);
10919 #ifdef RTE_LIBRTE_I40E_PMD
10920 if (ret == -ENOTSUP)
10921 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10922 res->vf_id, is_on);
10929 printf("invalid vf_id %d\n", res->vf_id);
10932 printf("invalid port_id %d\n", res->port_id);
10935 printf("function not implemented\n");
10938 printf("programming error: (%s)\n", strerror(-ret));
10942 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10943 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10945 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10947 (void *)&cmd_vf_vlan_anti_spoof_set,
10948 (void *)&cmd_vf_vlan_anti_spoof_vf,
10949 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10950 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10951 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10952 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10953 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10958 /* vf mac anti spoof configuration */
10960 /* Common result structure for vf mac anti spoof */
10961 struct cmd_vf_mac_anti_spoof_result {
10962 cmdline_fixed_string_t set;
10963 cmdline_fixed_string_t vf;
10964 cmdline_fixed_string_t mac;
10965 cmdline_fixed_string_t antispoof;
10968 cmdline_fixed_string_t on_off;
10971 /* Common CLI fields for vf mac anti spoof enable disable */
10972 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10973 TOKEN_STRING_INITIALIZER
10974 (struct cmd_vf_mac_anti_spoof_result,
10976 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10977 TOKEN_STRING_INITIALIZER
10978 (struct cmd_vf_mac_anti_spoof_result,
10980 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10981 TOKEN_STRING_INITIALIZER
10982 (struct cmd_vf_mac_anti_spoof_result,
10984 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10985 TOKEN_STRING_INITIALIZER
10986 (struct cmd_vf_mac_anti_spoof_result,
10987 antispoof, "antispoof");
10988 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10989 TOKEN_NUM_INITIALIZER
10990 (struct cmd_vf_mac_anti_spoof_result,
10992 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10993 TOKEN_NUM_INITIALIZER
10994 (struct cmd_vf_mac_anti_spoof_result,
10996 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10997 TOKEN_STRING_INITIALIZER
10998 (struct cmd_vf_mac_anti_spoof_result,
11002 cmd_set_vf_mac_anti_spoof_parsed(
11003 void *parsed_result,
11004 __attribute__((unused)) struct cmdline *cl,
11005 __attribute__((unused)) void *data)
11007 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11008 int ret = -ENOTSUP;
11010 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11012 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11015 #ifdef RTE_LIBRTE_IXGBE_PMD
11016 if (ret == -ENOTSUP)
11017 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11018 res->vf_id, is_on);
11020 #ifdef RTE_LIBRTE_I40E_PMD
11021 if (ret == -ENOTSUP)
11022 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11023 res->vf_id, is_on);
11030 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11033 printf("invalid port_id %d\n", res->port_id);
11036 printf("function not implemented\n");
11039 printf("programming error: (%s)\n", strerror(-ret));
11043 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11044 .f = cmd_set_vf_mac_anti_spoof_parsed,
11046 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11048 (void *)&cmd_vf_mac_anti_spoof_set,
11049 (void *)&cmd_vf_mac_anti_spoof_vf,
11050 (void *)&cmd_vf_mac_anti_spoof_mac,
11051 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11052 (void *)&cmd_vf_mac_anti_spoof_port_id,
11053 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11054 (void *)&cmd_vf_mac_anti_spoof_on_off,
11059 /* vf vlan strip queue configuration */
11061 /* Common result structure for vf mac anti spoof */
11062 struct cmd_vf_vlan_stripq_result {
11063 cmdline_fixed_string_t set;
11064 cmdline_fixed_string_t vf;
11065 cmdline_fixed_string_t vlan;
11066 cmdline_fixed_string_t stripq;
11069 cmdline_fixed_string_t on_off;
11072 /* Common CLI fields for vf vlan strip enable disable */
11073 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11074 TOKEN_STRING_INITIALIZER
11075 (struct cmd_vf_vlan_stripq_result,
11077 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11078 TOKEN_STRING_INITIALIZER
11079 (struct cmd_vf_vlan_stripq_result,
11081 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11082 TOKEN_STRING_INITIALIZER
11083 (struct cmd_vf_vlan_stripq_result,
11085 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11086 TOKEN_STRING_INITIALIZER
11087 (struct cmd_vf_vlan_stripq_result,
11089 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11090 TOKEN_NUM_INITIALIZER
11091 (struct cmd_vf_vlan_stripq_result,
11093 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11094 TOKEN_NUM_INITIALIZER
11095 (struct cmd_vf_vlan_stripq_result,
11097 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11098 TOKEN_STRING_INITIALIZER
11099 (struct cmd_vf_vlan_stripq_result,
11103 cmd_set_vf_vlan_stripq_parsed(
11104 void *parsed_result,
11105 __attribute__((unused)) struct cmdline *cl,
11106 __attribute__((unused)) void *data)
11108 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11109 int ret = -ENOTSUP;
11111 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11113 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11116 #ifdef RTE_LIBRTE_IXGBE_PMD
11117 if (ret == -ENOTSUP)
11118 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11119 res->vf_id, is_on);
11121 #ifdef RTE_LIBRTE_I40E_PMD
11122 if (ret == -ENOTSUP)
11123 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11124 res->vf_id, is_on);
11131 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11134 printf("invalid port_id %d\n", res->port_id);
11137 printf("function not implemented\n");
11140 printf("programming error: (%s)\n", strerror(-ret));
11144 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11145 .f = cmd_set_vf_vlan_stripq_parsed,
11147 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11149 (void *)&cmd_vf_vlan_stripq_set,
11150 (void *)&cmd_vf_vlan_stripq_vf,
11151 (void *)&cmd_vf_vlan_stripq_vlan,
11152 (void *)&cmd_vf_vlan_stripq_stripq,
11153 (void *)&cmd_vf_vlan_stripq_port_id,
11154 (void *)&cmd_vf_vlan_stripq_vf_id,
11155 (void *)&cmd_vf_vlan_stripq_on_off,
11160 /* vf vlan insert configuration */
11162 /* Common result structure for vf vlan insert */
11163 struct cmd_vf_vlan_insert_result {
11164 cmdline_fixed_string_t set;
11165 cmdline_fixed_string_t vf;
11166 cmdline_fixed_string_t vlan;
11167 cmdline_fixed_string_t insert;
11173 /* Common CLI fields for vf vlan insert enable disable */
11174 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11175 TOKEN_STRING_INITIALIZER
11176 (struct cmd_vf_vlan_insert_result,
11178 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11179 TOKEN_STRING_INITIALIZER
11180 (struct cmd_vf_vlan_insert_result,
11182 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11183 TOKEN_STRING_INITIALIZER
11184 (struct cmd_vf_vlan_insert_result,
11186 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11187 TOKEN_STRING_INITIALIZER
11188 (struct cmd_vf_vlan_insert_result,
11190 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11191 TOKEN_NUM_INITIALIZER
11192 (struct cmd_vf_vlan_insert_result,
11194 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11195 TOKEN_NUM_INITIALIZER
11196 (struct cmd_vf_vlan_insert_result,
11198 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11199 TOKEN_NUM_INITIALIZER
11200 (struct cmd_vf_vlan_insert_result,
11204 cmd_set_vf_vlan_insert_parsed(
11205 void *parsed_result,
11206 __attribute__((unused)) struct cmdline *cl,
11207 __attribute__((unused)) void *data)
11209 struct cmd_vf_vlan_insert_result *res = parsed_result;
11210 int ret = -ENOTSUP;
11212 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11215 #ifdef RTE_LIBRTE_IXGBE_PMD
11216 if (ret == -ENOTSUP)
11217 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11220 #ifdef RTE_LIBRTE_I40E_PMD
11221 if (ret == -ENOTSUP)
11222 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11230 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11233 printf("invalid port_id %d\n", res->port_id);
11236 printf("function not implemented\n");
11239 printf("programming error: (%s)\n", strerror(-ret));
11243 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11244 .f = cmd_set_vf_vlan_insert_parsed,
11246 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11248 (void *)&cmd_vf_vlan_insert_set,
11249 (void *)&cmd_vf_vlan_insert_vf,
11250 (void *)&cmd_vf_vlan_insert_vlan,
11251 (void *)&cmd_vf_vlan_insert_insert,
11252 (void *)&cmd_vf_vlan_insert_port_id,
11253 (void *)&cmd_vf_vlan_insert_vf_id,
11254 (void *)&cmd_vf_vlan_insert_vlan_id,
11259 /* tx loopback configuration */
11261 /* Common result structure for tx loopback */
11262 struct cmd_tx_loopback_result {
11263 cmdline_fixed_string_t set;
11264 cmdline_fixed_string_t tx;
11265 cmdline_fixed_string_t loopback;
11267 cmdline_fixed_string_t on_off;
11270 /* Common CLI fields for tx loopback enable disable */
11271 cmdline_parse_token_string_t cmd_tx_loopback_set =
11272 TOKEN_STRING_INITIALIZER
11273 (struct cmd_tx_loopback_result,
11275 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11276 TOKEN_STRING_INITIALIZER
11277 (struct cmd_tx_loopback_result,
11279 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11280 TOKEN_STRING_INITIALIZER
11281 (struct cmd_tx_loopback_result,
11282 loopback, "loopback");
11283 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11284 TOKEN_NUM_INITIALIZER
11285 (struct cmd_tx_loopback_result,
11287 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11288 TOKEN_STRING_INITIALIZER
11289 (struct cmd_tx_loopback_result,
11293 cmd_set_tx_loopback_parsed(
11294 void *parsed_result,
11295 __attribute__((unused)) struct cmdline *cl,
11296 __attribute__((unused)) void *data)
11298 struct cmd_tx_loopback_result *res = parsed_result;
11299 int ret = -ENOTSUP;
11301 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11303 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11306 #ifdef RTE_LIBRTE_IXGBE_PMD
11307 if (ret == -ENOTSUP)
11308 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11310 #ifdef RTE_LIBRTE_I40E_PMD
11311 if (ret == -ENOTSUP)
11312 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11319 printf("invalid is_on %d\n", is_on);
11322 printf("invalid port_id %d\n", res->port_id);
11325 printf("function not implemented\n");
11328 printf("programming error: (%s)\n", strerror(-ret));
11332 cmdline_parse_inst_t cmd_set_tx_loopback = {
11333 .f = cmd_set_tx_loopback_parsed,
11335 .help_str = "set tx loopback <port_id> on|off",
11337 (void *)&cmd_tx_loopback_set,
11338 (void *)&cmd_tx_loopback_tx,
11339 (void *)&cmd_tx_loopback_loopback,
11340 (void *)&cmd_tx_loopback_port_id,
11341 (void *)&cmd_tx_loopback_on_off,
11346 #ifdef RTE_LIBRTE_IXGBE_PMD
11347 /* all queues drop enable configuration */
11349 /* Common result structure for all queues drop enable */
11350 struct cmd_all_queues_drop_en_result {
11351 cmdline_fixed_string_t set;
11352 cmdline_fixed_string_t all;
11353 cmdline_fixed_string_t queues;
11354 cmdline_fixed_string_t drop;
11356 cmdline_fixed_string_t on_off;
11359 /* Common CLI fields for tx loopback enable disable */
11360 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11361 TOKEN_STRING_INITIALIZER
11362 (struct cmd_all_queues_drop_en_result,
11364 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11365 TOKEN_STRING_INITIALIZER
11366 (struct cmd_all_queues_drop_en_result,
11368 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11369 TOKEN_STRING_INITIALIZER
11370 (struct cmd_all_queues_drop_en_result,
11372 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11373 TOKEN_STRING_INITIALIZER
11374 (struct cmd_all_queues_drop_en_result,
11376 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11377 TOKEN_NUM_INITIALIZER
11378 (struct cmd_all_queues_drop_en_result,
11380 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11381 TOKEN_STRING_INITIALIZER
11382 (struct cmd_all_queues_drop_en_result,
11386 cmd_set_all_queues_drop_en_parsed(
11387 void *parsed_result,
11388 __attribute__((unused)) struct cmdline *cl,
11389 __attribute__((unused)) void *data)
11391 struct cmd_all_queues_drop_en_result *res = parsed_result;
11393 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11395 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11398 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11403 printf("invalid is_on %d\n", is_on);
11406 printf("invalid port_id %d\n", res->port_id);
11409 printf("function not implemented\n");
11412 printf("programming error: (%s)\n", strerror(-ret));
11416 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11417 .f = cmd_set_all_queues_drop_en_parsed,
11419 .help_str = "set all queues drop <port_id> on|off",
11421 (void *)&cmd_all_queues_drop_en_set,
11422 (void *)&cmd_all_queues_drop_en_all,
11423 (void *)&cmd_all_queues_drop_en_queues,
11424 (void *)&cmd_all_queues_drop_en_drop,
11425 (void *)&cmd_all_queues_drop_en_port_id,
11426 (void *)&cmd_all_queues_drop_en_on_off,
11431 /* vf split drop enable configuration */
11433 /* Common result structure for vf split drop enable */
11434 struct cmd_vf_split_drop_en_result {
11435 cmdline_fixed_string_t set;
11436 cmdline_fixed_string_t vf;
11437 cmdline_fixed_string_t split;
11438 cmdline_fixed_string_t drop;
11441 cmdline_fixed_string_t on_off;
11444 /* Common CLI fields for vf split drop enable disable */
11445 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11446 TOKEN_STRING_INITIALIZER
11447 (struct cmd_vf_split_drop_en_result,
11449 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11450 TOKEN_STRING_INITIALIZER
11451 (struct cmd_vf_split_drop_en_result,
11453 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11454 TOKEN_STRING_INITIALIZER
11455 (struct cmd_vf_split_drop_en_result,
11457 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11458 TOKEN_STRING_INITIALIZER
11459 (struct cmd_vf_split_drop_en_result,
11461 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11462 TOKEN_NUM_INITIALIZER
11463 (struct cmd_vf_split_drop_en_result,
11465 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11466 TOKEN_NUM_INITIALIZER
11467 (struct cmd_vf_split_drop_en_result,
11469 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11470 TOKEN_STRING_INITIALIZER
11471 (struct cmd_vf_split_drop_en_result,
11475 cmd_set_vf_split_drop_en_parsed(
11476 void *parsed_result,
11477 __attribute__((unused)) struct cmdline *cl,
11478 __attribute__((unused)) void *data)
11480 struct cmd_vf_split_drop_en_result *res = parsed_result;
11482 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11487 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11493 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11496 printf("invalid port_id %d\n", res->port_id);
11499 printf("programming error: (%s)\n", strerror(-ret));
11503 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11504 .f = cmd_set_vf_split_drop_en_parsed,
11506 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11508 (void *)&cmd_vf_split_drop_en_set,
11509 (void *)&cmd_vf_split_drop_en_vf,
11510 (void *)&cmd_vf_split_drop_en_split,
11511 (void *)&cmd_vf_split_drop_en_drop,
11512 (void *)&cmd_vf_split_drop_en_port_id,
11513 (void *)&cmd_vf_split_drop_en_vf_id,
11514 (void *)&cmd_vf_split_drop_en_on_off,
11520 /* vf mac address configuration */
11522 /* Common result structure for vf mac address */
11523 struct cmd_set_vf_mac_addr_result {
11524 cmdline_fixed_string_t set;
11525 cmdline_fixed_string_t vf;
11526 cmdline_fixed_string_t mac;
11527 cmdline_fixed_string_t addr;
11530 struct ether_addr mac_addr;
11534 /* Common CLI fields for vf split drop enable disable */
11535 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11536 TOKEN_STRING_INITIALIZER
11537 (struct cmd_set_vf_mac_addr_result,
11539 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11540 TOKEN_STRING_INITIALIZER
11541 (struct cmd_set_vf_mac_addr_result,
11543 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11544 TOKEN_STRING_INITIALIZER
11545 (struct cmd_set_vf_mac_addr_result,
11547 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11548 TOKEN_STRING_INITIALIZER
11549 (struct cmd_set_vf_mac_addr_result,
11551 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11552 TOKEN_NUM_INITIALIZER
11553 (struct cmd_set_vf_mac_addr_result,
11555 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11556 TOKEN_NUM_INITIALIZER
11557 (struct cmd_set_vf_mac_addr_result,
11559 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11560 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11564 cmd_set_vf_mac_addr_parsed(
11565 void *parsed_result,
11566 __attribute__((unused)) struct cmdline *cl,
11567 __attribute__((unused)) void *data)
11569 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11570 int ret = -ENOTSUP;
11572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11575 #ifdef RTE_LIBRTE_IXGBE_PMD
11576 if (ret == -ENOTSUP)
11577 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11580 #ifdef RTE_LIBRTE_I40E_PMD
11581 if (ret == -ENOTSUP)
11582 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11590 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11593 printf("invalid port_id %d\n", res->port_id);
11596 printf("function not implemented\n");
11599 printf("programming error: (%s)\n", strerror(-ret));
11603 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11604 .f = cmd_set_vf_mac_addr_parsed,
11606 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11608 (void *)&cmd_set_vf_mac_addr_set,
11609 (void *)&cmd_set_vf_mac_addr_vf,
11610 (void *)&cmd_set_vf_mac_addr_mac,
11611 (void *)&cmd_set_vf_mac_addr_addr,
11612 (void *)&cmd_set_vf_mac_addr_port_id,
11613 (void *)&cmd_set_vf_mac_addr_vf_id,
11614 (void *)&cmd_set_vf_mac_addr_mac_addr,
11619 #ifdef RTE_LIBRTE_IXGBE_PMD
11620 /* MACsec configuration */
11622 /* Common result structure for MACsec offload enable */
11623 struct cmd_macsec_offload_on_result {
11624 cmdline_fixed_string_t set;
11625 cmdline_fixed_string_t macsec;
11626 cmdline_fixed_string_t offload;
11628 cmdline_fixed_string_t on;
11629 cmdline_fixed_string_t encrypt;
11630 cmdline_fixed_string_t en_on_off;
11631 cmdline_fixed_string_t replay_protect;
11632 cmdline_fixed_string_t rp_on_off;
11635 /* Common CLI fields for MACsec offload disable */
11636 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11637 TOKEN_STRING_INITIALIZER
11638 (struct cmd_macsec_offload_on_result,
11640 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11641 TOKEN_STRING_INITIALIZER
11642 (struct cmd_macsec_offload_on_result,
11644 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11645 TOKEN_STRING_INITIALIZER
11646 (struct cmd_macsec_offload_on_result,
11647 offload, "offload");
11648 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11649 TOKEN_NUM_INITIALIZER
11650 (struct cmd_macsec_offload_on_result,
11652 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11653 TOKEN_STRING_INITIALIZER
11654 (struct cmd_macsec_offload_on_result,
11656 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11657 TOKEN_STRING_INITIALIZER
11658 (struct cmd_macsec_offload_on_result,
11659 encrypt, "encrypt");
11660 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11661 TOKEN_STRING_INITIALIZER
11662 (struct cmd_macsec_offload_on_result,
11663 en_on_off, "on#off");
11664 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11665 TOKEN_STRING_INITIALIZER
11666 (struct cmd_macsec_offload_on_result,
11667 replay_protect, "replay-protect");
11668 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11669 TOKEN_STRING_INITIALIZER
11670 (struct cmd_macsec_offload_on_result,
11671 rp_on_off, "on#off");
11674 cmd_set_macsec_offload_on_parsed(
11675 void *parsed_result,
11676 __attribute__((unused)) struct cmdline *cl,
11677 __attribute__((unused)) void *data)
11679 struct cmd_macsec_offload_on_result *res = parsed_result;
11681 portid_t port_id = res->port_id;
11682 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11683 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11685 if (port_id_is_invalid(port_id, ENABLED_WARN))
11688 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11689 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11695 printf("invalid port_id %d\n", port_id);
11698 printf("programming error: (%s)\n", strerror(-ret));
11702 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11703 .f = cmd_set_macsec_offload_on_parsed,
11705 .help_str = "set macsec offload <port_id> on "
11706 "encrypt on|off replay-protect on|off",
11708 (void *)&cmd_macsec_offload_on_set,
11709 (void *)&cmd_macsec_offload_on_macsec,
11710 (void *)&cmd_macsec_offload_on_offload,
11711 (void *)&cmd_macsec_offload_on_port_id,
11712 (void *)&cmd_macsec_offload_on_on,
11713 (void *)&cmd_macsec_offload_on_encrypt,
11714 (void *)&cmd_macsec_offload_on_en_on_off,
11715 (void *)&cmd_macsec_offload_on_replay_protect,
11716 (void *)&cmd_macsec_offload_on_rp_on_off,
11721 /* Common result structure for MACsec offload disable */
11722 struct cmd_macsec_offload_off_result {
11723 cmdline_fixed_string_t set;
11724 cmdline_fixed_string_t macsec;
11725 cmdline_fixed_string_t offload;
11727 cmdline_fixed_string_t off;
11730 /* Common CLI fields for MACsec offload disable */
11731 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11732 TOKEN_STRING_INITIALIZER
11733 (struct cmd_macsec_offload_off_result,
11735 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11736 TOKEN_STRING_INITIALIZER
11737 (struct cmd_macsec_offload_off_result,
11739 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11740 TOKEN_STRING_INITIALIZER
11741 (struct cmd_macsec_offload_off_result,
11742 offload, "offload");
11743 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11744 TOKEN_NUM_INITIALIZER
11745 (struct cmd_macsec_offload_off_result,
11747 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11748 TOKEN_STRING_INITIALIZER
11749 (struct cmd_macsec_offload_off_result,
11753 cmd_set_macsec_offload_off_parsed(
11754 void *parsed_result,
11755 __attribute__((unused)) struct cmdline *cl,
11756 __attribute__((unused)) void *data)
11758 struct cmd_macsec_offload_off_result *res = parsed_result;
11760 portid_t port_id = res->port_id;
11762 if (port_id_is_invalid(port_id, ENABLED_WARN))
11765 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11766 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11772 printf("invalid port_id %d\n", port_id);
11775 printf("programming error: (%s)\n", strerror(-ret));
11779 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11780 .f = cmd_set_macsec_offload_off_parsed,
11782 .help_str = "set macsec offload <port_id> off",
11784 (void *)&cmd_macsec_offload_off_set,
11785 (void *)&cmd_macsec_offload_off_macsec,
11786 (void *)&cmd_macsec_offload_off_offload,
11787 (void *)&cmd_macsec_offload_off_port_id,
11788 (void *)&cmd_macsec_offload_off_off,
11793 /* Common result structure for MACsec secure connection configure */
11794 struct cmd_macsec_sc_result {
11795 cmdline_fixed_string_t set;
11796 cmdline_fixed_string_t macsec;
11797 cmdline_fixed_string_t sc;
11798 cmdline_fixed_string_t tx_rx;
11800 struct ether_addr mac;
11804 /* Common CLI fields for MACsec secure connection configure */
11805 cmdline_parse_token_string_t cmd_macsec_sc_set =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_macsec_sc_result,
11809 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_macsec_sc_result,
11813 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_macsec_sc_result,
11817 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_macsec_sc_result,
11821 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11822 TOKEN_NUM_INITIALIZER
11823 (struct cmd_macsec_sc_result,
11825 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11826 TOKEN_ETHERADDR_INITIALIZER
11827 (struct cmd_macsec_sc_result,
11829 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11830 TOKEN_NUM_INITIALIZER
11831 (struct cmd_macsec_sc_result,
11835 cmd_set_macsec_sc_parsed(
11836 void *parsed_result,
11837 __attribute__((unused)) struct cmdline *cl,
11838 __attribute__((unused)) void *data)
11840 struct cmd_macsec_sc_result *res = parsed_result;
11842 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11845 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11846 res->mac.addr_bytes) :
11847 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11848 res->mac.addr_bytes, res->pi);
11853 printf("invalid port_id %d\n", res->port_id);
11856 printf("programming error: (%s)\n", strerror(-ret));
11860 cmdline_parse_inst_t cmd_set_macsec_sc = {
11861 .f = cmd_set_macsec_sc_parsed,
11863 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11865 (void *)&cmd_macsec_sc_set,
11866 (void *)&cmd_macsec_sc_macsec,
11867 (void *)&cmd_macsec_sc_sc,
11868 (void *)&cmd_macsec_sc_tx_rx,
11869 (void *)&cmd_macsec_sc_port_id,
11870 (void *)&cmd_macsec_sc_mac,
11871 (void *)&cmd_macsec_sc_pi,
11876 /* Common result structure for MACsec secure connection configure */
11877 struct cmd_macsec_sa_result {
11878 cmdline_fixed_string_t set;
11879 cmdline_fixed_string_t macsec;
11880 cmdline_fixed_string_t sa;
11881 cmdline_fixed_string_t tx_rx;
11886 cmdline_fixed_string_t key;
11889 /* Common CLI fields for MACsec secure connection configure */
11890 cmdline_parse_token_string_t cmd_macsec_sa_set =
11891 TOKEN_STRING_INITIALIZER
11892 (struct cmd_macsec_sa_result,
11894 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11895 TOKEN_STRING_INITIALIZER
11896 (struct cmd_macsec_sa_result,
11898 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11899 TOKEN_STRING_INITIALIZER
11900 (struct cmd_macsec_sa_result,
11902 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11903 TOKEN_STRING_INITIALIZER
11904 (struct cmd_macsec_sa_result,
11906 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11907 TOKEN_NUM_INITIALIZER
11908 (struct cmd_macsec_sa_result,
11910 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11911 TOKEN_NUM_INITIALIZER
11912 (struct cmd_macsec_sa_result,
11914 cmdline_parse_token_num_t cmd_macsec_sa_an =
11915 TOKEN_NUM_INITIALIZER
11916 (struct cmd_macsec_sa_result,
11918 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11919 TOKEN_NUM_INITIALIZER
11920 (struct cmd_macsec_sa_result,
11922 cmdline_parse_token_string_t cmd_macsec_sa_key =
11923 TOKEN_STRING_INITIALIZER
11924 (struct cmd_macsec_sa_result,
11928 cmd_set_macsec_sa_parsed(
11929 void *parsed_result,
11930 __attribute__((unused)) struct cmdline *cl,
11931 __attribute__((unused)) void *data)
11933 struct cmd_macsec_sa_result *res = parsed_result;
11935 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11936 uint8_t key[16] = { 0 };
11942 key_len = strlen(res->key) / 2;
11946 for (i = 0; i < key_len; i++) {
11947 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11950 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11953 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11957 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11958 res->idx, res->an, res->pn, key) :
11959 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11960 res->idx, res->an, res->pn, key);
11965 printf("invalid idx %d or an %d\n", res->idx, res->an);
11968 printf("invalid port_id %d\n", res->port_id);
11971 printf("programming error: (%s)\n", strerror(-ret));
11975 cmdline_parse_inst_t cmd_set_macsec_sa = {
11976 .f = cmd_set_macsec_sa_parsed,
11978 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11980 (void *)&cmd_macsec_sa_set,
11981 (void *)&cmd_macsec_sa_macsec,
11982 (void *)&cmd_macsec_sa_sa,
11983 (void *)&cmd_macsec_sa_tx_rx,
11984 (void *)&cmd_macsec_sa_port_id,
11985 (void *)&cmd_macsec_sa_idx,
11986 (void *)&cmd_macsec_sa_an,
11987 (void *)&cmd_macsec_sa_pn,
11988 (void *)&cmd_macsec_sa_key,
11994 /* VF unicast promiscuous mode configuration */
11996 /* Common result structure for VF unicast promiscuous mode */
11997 struct cmd_vf_promisc_result {
11998 cmdline_fixed_string_t set;
11999 cmdline_fixed_string_t vf;
12000 cmdline_fixed_string_t promisc;
12003 cmdline_fixed_string_t on_off;
12006 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12007 cmdline_parse_token_string_t cmd_vf_promisc_set =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_vf_promisc_result,
12011 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_vf_promisc_result,
12015 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12016 TOKEN_STRING_INITIALIZER
12017 (struct cmd_vf_promisc_result,
12018 promisc, "promisc");
12019 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12020 TOKEN_NUM_INITIALIZER
12021 (struct cmd_vf_promisc_result,
12023 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12024 TOKEN_NUM_INITIALIZER
12025 (struct cmd_vf_promisc_result,
12027 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12028 TOKEN_STRING_INITIALIZER
12029 (struct cmd_vf_promisc_result,
12033 cmd_set_vf_promisc_parsed(
12034 void *parsed_result,
12035 __attribute__((unused)) struct cmdline *cl,
12036 __attribute__((unused)) void *data)
12038 struct cmd_vf_promisc_result *res = parsed_result;
12039 int ret = -ENOTSUP;
12041 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12043 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12046 #ifdef RTE_LIBRTE_I40E_PMD
12047 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12048 res->vf_id, is_on);
12055 printf("invalid vf_id %d\n", res->vf_id);
12058 printf("invalid port_id %d\n", res->port_id);
12061 printf("function not implemented\n");
12064 printf("programming error: (%s)\n", strerror(-ret));
12068 cmdline_parse_inst_t cmd_set_vf_promisc = {
12069 .f = cmd_set_vf_promisc_parsed,
12071 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12072 "Set unicast promiscuous mode for a VF from the PF",
12074 (void *)&cmd_vf_promisc_set,
12075 (void *)&cmd_vf_promisc_vf,
12076 (void *)&cmd_vf_promisc_promisc,
12077 (void *)&cmd_vf_promisc_port_id,
12078 (void *)&cmd_vf_promisc_vf_id,
12079 (void *)&cmd_vf_promisc_on_off,
12084 /* ******************************************************************************** */
12086 /* list of instructions */
12087 cmdline_parse_ctx_t main_ctx[] = {
12088 (cmdline_parse_inst_t *)&cmd_help_brief,
12089 (cmdline_parse_inst_t *)&cmd_help_long,
12090 (cmdline_parse_inst_t *)&cmd_quit,
12091 (cmdline_parse_inst_t *)&cmd_showport,
12092 (cmdline_parse_inst_t *)&cmd_showqueue,
12093 (cmdline_parse_inst_t *)&cmd_showportall,
12094 (cmdline_parse_inst_t *)&cmd_showcfg,
12095 (cmdline_parse_inst_t *)&cmd_start,
12096 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12097 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12098 (cmdline_parse_inst_t *)&cmd_set_link_up,
12099 (cmdline_parse_inst_t *)&cmd_set_link_down,
12100 (cmdline_parse_inst_t *)&cmd_reset,
12101 (cmdline_parse_inst_t *)&cmd_set_numbers,
12102 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12103 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12104 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12105 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12106 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12107 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12108 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12109 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12110 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12111 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12112 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12113 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12114 (cmdline_parse_inst_t *)&cmd_set_link_check,
12115 #ifdef RTE_NIC_BYPASS
12116 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12117 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12118 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12119 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12121 #ifdef RTE_LIBRTE_PMD_BOND
12122 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12123 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12124 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12125 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12126 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12127 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12128 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12129 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12130 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12132 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12133 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12134 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12135 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12136 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12137 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12138 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12139 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12140 (cmdline_parse_inst_t *)&cmd_csum_set,
12141 (cmdline_parse_inst_t *)&cmd_csum_show,
12142 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12143 (cmdline_parse_inst_t *)&cmd_tso_set,
12144 (cmdline_parse_inst_t *)&cmd_tso_show,
12145 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12146 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12147 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12148 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12149 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12150 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12151 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12152 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12153 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12154 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12155 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12156 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12157 (cmdline_parse_inst_t *)&cmd_config_dcb,
12158 (cmdline_parse_inst_t *)&cmd_read_reg,
12159 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12160 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12161 (cmdline_parse_inst_t *)&cmd_write_reg,
12162 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12163 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12164 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12165 (cmdline_parse_inst_t *)&cmd_stop,
12166 (cmdline_parse_inst_t *)&cmd_mac_addr,
12167 (cmdline_parse_inst_t *)&cmd_set_qmap,
12168 (cmdline_parse_inst_t *)&cmd_operate_port,
12169 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12170 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12171 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12172 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12173 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12174 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12175 (cmdline_parse_inst_t *)&cmd_config_mtu,
12176 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12177 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12178 (cmdline_parse_inst_t *)&cmd_config_rss,
12179 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12180 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12181 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12182 (cmdline_parse_inst_t *)&cmd_showport_reta,
12183 (cmdline_parse_inst_t *)&cmd_config_burst,
12184 (cmdline_parse_inst_t *)&cmd_config_thresh,
12185 (cmdline_parse_inst_t *)&cmd_config_threshold,
12186 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12187 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12188 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12189 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12190 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12191 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12192 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12193 (cmdline_parse_inst_t *)&cmd_global_config,
12194 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12195 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12196 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12197 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12198 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12199 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12200 (cmdline_parse_inst_t *)&cmd_dump,
12201 (cmdline_parse_inst_t *)&cmd_dump_one,
12202 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12203 (cmdline_parse_inst_t *)&cmd_syn_filter,
12204 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12205 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12206 (cmdline_parse_inst_t *)&cmd_flex_filter,
12207 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12208 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12209 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12210 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12211 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12212 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12213 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12214 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12215 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12216 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12217 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12218 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12219 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12220 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12221 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12222 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12223 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12224 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12225 (cmdline_parse_inst_t *)&cmd_flow,
12226 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12227 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12228 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12229 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12230 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12231 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12232 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12233 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12234 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12235 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12236 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12237 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12238 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12239 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12240 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12241 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12242 #ifdef RTE_LIBRTE_IXGBE_PMD
12243 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12244 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12245 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12246 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12247 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12248 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12249 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12250 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12251 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12252 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12254 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12255 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12259 /* prompt function, called from main on MASTER lcore */
12263 /* initialize non-constant commands */
12264 cmd_set_fwd_mode_init();
12265 cmd_set_fwd_retry_mode_init();
12267 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12268 if (testpmd_cl == NULL)
12270 cmdline_interact(testpmd_cl);
12271 cmdline_stdin_exit(testpmd_cl);
12277 if (testpmd_cl != NULL)
12278 cmdline_quit(testpmd_cl);
12282 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12284 if (id == (portid_t)RTE_PORT_ALL) {
12287 FOREACH_PORT(pid, ports) {
12288 /* check if need_reconfig has been set to 1 */
12289 if (ports[pid].need_reconfig == 0)
12290 ports[pid].need_reconfig = dev;
12291 /* check if need_reconfig_queues has been set to 1 */
12292 if (ports[pid].need_reconfig_queues == 0)
12293 ports[pid].need_reconfig_queues = queue;
12295 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12296 /* check if need_reconfig has been set to 1 */
12297 if (ports[id].need_reconfig == 0)
12298 ports[id].need_reconfig = dev;
12299 /* check if need_reconfig_queues has been set to 1 */
12300 if (ports[id].need_reconfig_queues == 0)
12301 ports[id].need_reconfig_queues = queue;