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>
96 static struct cmdline *testpmd_cl;
98 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
100 /* *** Help command with introduction. *** */
101 struct cmd_help_brief_result {
102 cmdline_fixed_string_t help;
105 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
107 __attribute__((unused)) void *data)
112 "Help is available for the following sections:\n\n"
113 " help control : Start and stop forwarding.\n"
114 " help display : Displaying port, stats and config "
116 " help config : Configuration information.\n"
117 " help ports : Configuring ports.\n"
118 " help registers : Reading and setting port registers.\n"
119 " help filters : Filters configuration help.\n"
120 " help all : All of the above sections.\n\n"
125 cmdline_parse_token_string_t cmd_help_brief_help =
126 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
128 cmdline_parse_inst_t cmd_help_brief = {
129 .f = cmd_help_brief_parsed,
131 .help_str = "help: Show help",
133 (void *)&cmd_help_brief_help,
138 /* *** Help command with help sections. *** */
139 struct cmd_help_long_result {
140 cmdline_fixed_string_t help;
141 cmdline_fixed_string_t section;
144 static void cmd_help_long_parsed(void *parsed_result,
146 __attribute__((unused)) void *data)
149 struct cmd_help_long_result *res = parsed_result;
151 if (!strcmp(res->section, "all"))
154 if (show_all || !strcmp(res->section, "control")) {
159 "Control forwarding:\n"
160 "-------------------\n\n"
163 " Start packet forwarding with current configuration.\n\n"
166 " Start packet forwarding with current config"
167 " after sending one burst of packets.\n\n"
170 " Stop packet forwarding, and display accumulated"
174 " Quit to prompt.\n\n"
178 if (show_all || !strcmp(res->section, "display")) {
186 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
187 " Display information for port_id, or all.\n\n"
189 "show port X rss reta (size) (mask0,mask1,...)\n"
190 " Display the rss redirection table entry indicated"
191 " by masks on port X. size is used to indicate the"
192 " hardware supported reta size\n\n"
194 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
195 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
196 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
197 " Display the RSS hash functions and RSS hash key"
200 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
201 " Clear information for port_id, or all.\n\n"
203 "show (rxq|txq) info (port_id) (queue_id)\n"
204 " Display information for configured RX/TX queue.\n\n"
206 "show config (rxtx|cores|fwd|txpkts)\n"
207 " Display the given configuration.\n\n"
209 "read rxd (port_id) (queue_id) (rxd_id)\n"
210 " Display an RX descriptor of a port RX queue.\n\n"
212 "read txd (port_id) (queue_id) (txd_id)\n"
213 " Display a TX descriptor of a port TX queue.\n\n"
217 if (show_all || !strcmp(res->section, "config")) {
223 "Configuration changes only become active when"
224 " forwarding is started/restarted.\n\n"
227 " Reset forwarding to the default configuration.\n\n"
229 "set verbose (level)\n"
230 " Set the debug verbosity level X.\n\n"
233 " Set number of ports.\n\n"
236 " Set number of cores.\n\n"
238 "set coremask (mask)\n"
239 " Set the forwarding cores hexadecimal mask.\n\n"
241 "set portmask (mask)\n"
242 " Set the forwarding ports hexadecimal mask.\n\n"
245 " Set number of packets per burst.\n\n"
247 "set burst tx delay (microseconds) retry (num)\n"
248 " Set the transmit delay time and number of retries,"
249 " effective when retry is enabled.\n\n"
251 "set txpkts (x[,y]*)\n"
252 " Set the length of each segment of TXONLY"
253 " and optionally CSUM packets.\n\n"
255 "set txsplit (off|on|rand)\n"
256 " Set the split policy for the TX packets."
257 " Right now only applicable for CSUM and TXONLY"
260 "set corelist (x[,y]*)\n"
261 " Set the list of forwarding cores.\n\n"
263 "set portlist (x[,y]*)\n"
264 " Set the list of forwarding ports.\n\n"
266 #ifdef RTE_LIBRTE_IXGBE_PMD
267 "set tx loopback (port_id) (on|off)\n"
268 " Enable or disable tx loopback.\n\n"
270 "set all queues drop (port_id) (on|off)\n"
271 " Set drop enable bit for all queues.\n\n"
273 "set vf split drop (port_id) (vf_id) (on|off)\n"
274 " Set split drop enable bit for a VF from the PF.\n\n"
276 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
277 " Set MAC antispoof for a VF from the PF.\n\n"
279 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
280 " Enable MACsec offload.\n\n"
282 "set macsec offload (port_id) off\n"
283 " Disable MACsec offload.\n\n"
285 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
286 " Configure MACsec secure connection (SC).\n\n"
288 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
289 " Configure MACsec secure association (SA).\n\n"
292 "vlan set strip (on|off) (port_id)\n"
293 " Set the VLAN strip on a port.\n\n"
295 "vlan set stripq (on|off) (port_id,queue_id)\n"
296 " Set the VLAN strip for a queue on a port.\n\n"
298 #ifdef RTE_LIBRTE_IXGBE_PMD
299 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
300 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
302 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
303 " Set VLAN insert for a VF from the PF.\n\n"
305 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
306 " Set VLAN antispoof for a VF from the PF.\n\n"
309 "vlan set filter (on|off) (port_id)\n"
310 " Set the VLAN filter on a port.\n\n"
312 "vlan set qinq (on|off) (port_id)\n"
313 " Set the VLAN QinQ (extended queue in queue)"
316 "vlan set (inner|outer) tpid (value) (port_id)\n"
317 " Set the VLAN TPID for Packet Filtering on"
320 "rx_vlan add (vlan_id|all) (port_id)\n"
321 " Add a vlan_id, or all identifiers, to the set"
322 " of VLAN identifiers filtered by port_id.\n\n"
324 "rx_vlan rm (vlan_id|all) (port_id)\n"
325 " Remove a vlan_id, or all identifiers, from the set"
326 " of VLAN identifiers filtered by port_id.\n\n"
328 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
329 " Add a vlan_id, to the set of VLAN identifiers"
330 "filtered for VF(s) from port_id.\n\n"
332 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
333 " Remove a vlan_id, to the set of VLAN identifiers"
334 "filtered for VF(s) from port_id.\n\n"
336 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
337 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
338 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
339 " add a tunnel filter of a port.\n\n"
341 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
342 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
343 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
344 " remove a tunnel filter of a port.\n\n"
346 "rx_vxlan_port add (udp_port) (port_id)\n"
347 " Add an UDP port for VXLAN packet filter on a port\n\n"
349 "rx_vxlan_port rm (udp_port) (port_id)\n"
350 " Remove an UDP port for VXLAN packet filter on a port\n\n"
352 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
353 " Set hardware insertion of VLAN IDs (single or double VLAN "
354 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
356 "tx_vlan set pvid port_id vlan_id (on|off)\n"
357 " Set port based TX VLAN insertion.\n\n"
359 "tx_vlan reset (port_id)\n"
360 " Disable hardware insertion of a VLAN header in"
361 " packets sent on a port.\n\n"
363 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
364 " Select hardware or software calculation of the"
365 " checksum when transmitting a packet using the"
366 " csum forward engine.\n"
367 " ip|udp|tcp|sctp always concern the inner layer.\n"
368 " outer-ip concerns the outer IP layer in"
369 " case the packet is recognized as a tunnel packet by"
370 " the forward engine (vxlan, gre and ipip are supported)\n"
371 " Please check the NIC datasheet for HW limits.\n\n"
373 "csum parse-tunnel (on|off) (tx_port_id)\n"
374 " If disabled, treat tunnel packets as non-tunneled"
375 " packets (treat inner headers as payload). The port\n"
376 " argument is the port used for TX in csum forward"
379 "csum show (port_id)\n"
380 " Display tx checksum offload configuration\n\n"
382 "tso set (segsize) (portid)\n"
383 " Enable TCP Segmentation Offload in csum forward"
385 " Please check the NIC datasheet for HW limits.\n\n"
388 " Display the status of TCP Segmentation Offload.\n\n"
391 " Set packet forwarding mode.\n\n"
393 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
394 " Add a MAC address on port_id.\n\n"
396 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
397 " Remove a MAC address from port_id.\n\n"
399 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
400 " Add a MAC address for a VF on the port.\n\n"
402 #ifdef RTE_LIBRTE_IXGBE_PMD
403 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
404 " Set the MAC address for a VF from the PF.\n\n"
407 "set port (port_id) uta (mac_address|all) (on|off)\n"
408 " Add/Remove a or all unicast hash filter(s)"
411 "set promisc (port_id|all) (on|off)\n"
412 " Set the promiscuous mode on port_id, or all.\n\n"
414 "set allmulti (port_id|all) (on|off)\n"
415 " Set the allmulti mode on port_id, or all.\n\n"
417 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
418 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
419 " (on|off) autoneg (on|off) (port_id)\n"
420 "set flow_ctrl rx (on|off) (portid)\n"
421 "set flow_ctrl tx (on|off) (portid)\n"
422 "set flow_ctrl high_water (high_water) (portid)\n"
423 "set flow_ctrl low_water (low_water) (portid)\n"
424 "set flow_ctrl pause_time (pause_time) (portid)\n"
425 "set flow_ctrl send_xon (send_xon) (portid)\n"
426 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
427 "set flow_ctrl autoneg (on|off) (port_id)\n"
428 " Set the link flow control parameter on a port.\n\n"
430 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
431 " (low_water) (pause_time) (priority) (port_id)\n"
432 " Set the priority flow control parameter on a"
435 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
436 " Set statistics mapping (qmapping 0..15) for RX/TX"
438 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
439 " on port 0 to mapping 5.\n\n"
441 "set port (port_id) vf (vf_id) rx|tx on|off\n"
442 " Enable/Disable a VF receive/tranmit from a port\n\n"
444 "set port (port_id) vf (vf_id) (mac_addr)"
445 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
446 " Add/Remove unicast or multicast MAC addr filter"
449 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
451 " AUPE:accepts untagged VLAN;"
452 "ROPE:accept unicast hash\n\n"
453 " BAM:accepts broadcast packets;"
454 "MPE:accepts all multicast packets\n\n"
455 " Enable/Disable a VF receive mode of a port\n\n"
457 "set port (port_id) queue (queue_id) rate (rate_num)\n"
458 " Set rate limit for a queue of a port\n\n"
460 "set port (port_id) vf (vf_id) rate (rate_num) "
461 "queue_mask (queue_mask_value)\n"
462 " Set rate limit for queues in VF of a port\n\n"
464 "set port (port_id) mirror-rule (rule_id)"
465 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
466 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
467 " Set pool or vlan type mirror rule on a port.\n"
468 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
469 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
472 "set port (port_id) mirror-rule (rule_id)"
473 " (uplink-mirror|downlink-mirror) dst-pool"
474 " (pool_id) (on|off)\n"
475 " Set uplink or downlink type mirror rule on a port.\n"
476 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
477 " 0 on' enable mirror income traffic to pool 0.\n\n"
479 "reset port (port_id) mirror-rule (rule_id)\n"
480 " Reset a mirror rule.\n\n"
482 "set flush_rx (on|off)\n"
483 " Flush (default) or don't flush RX streams before"
484 " forwarding. Mainly used with PCAP drivers.\n\n"
486 #ifdef RTE_NIC_BYPASS
487 "set bypass mode (normal|bypass|isolate) (port_id)\n"
488 " Set the bypass mode for the lowest port on bypass enabled"
491 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
492 "mode (normal|bypass|isolate) (port_id)\n"
493 " Set the event required to initiate specified bypass mode for"
494 " the lowest port on a bypass enabled NIC where:\n"
495 " timeout = enable bypass after watchdog timeout.\n"
496 " os_on = enable bypass when OS/board is powered on.\n"
497 " os_off = enable bypass when OS/board is powered off.\n"
498 " power_on = enable bypass when power supply is turned on.\n"
499 " power_off = enable bypass when power supply is turned off."
502 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
503 " Set the bypass watchdog timeout to 'n' seconds"
504 " where 0 = instant.\n\n"
506 "show bypass config (port_id)\n"
507 " Show the bypass configuration for a bypass enabled NIC"
508 " using the lowest port on the NIC.\n\n"
510 #ifdef RTE_LIBRTE_PMD_BOND
511 "create bonded device (mode) (socket)\n"
512 " Create a new bonded device with specific bonding mode and socket.\n\n"
514 "add bonding slave (slave_id) (port_id)\n"
515 " Add a slave device to a bonded device.\n\n"
517 "remove bonding slave (slave_id) (port_id)\n"
518 " Remove a slave device from a bonded device.\n\n"
520 "set bonding mode (value) (port_id)\n"
521 " Set the bonding mode on a bonded device.\n\n"
523 "set bonding primary (slave_id) (port_id)\n"
524 " Set the primary slave for a bonded device.\n\n"
526 "show bonding config (port_id)\n"
527 " Show the bonding config for port_id.\n\n"
529 "set bonding mac_addr (port_id) (address)\n"
530 " Set the MAC address of a bonded device.\n\n"
532 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
533 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
535 "set bonding mon_period (port_id) (value)\n"
536 " Set the bonding link status monitoring polling period in ms.\n\n"
538 "set link-up port (port_id)\n"
539 " Set link up for a port.\n\n"
541 "set link-down port (port_id)\n"
542 " Set link down for a port.\n\n"
544 "E-tag set insertion on port-tag-id (value)"
545 " port (port_id) vf (vf_id)\n"
546 " Enable E-tag insertion for a VF on a port\n\n"
548 "E-tag set insertion off port (port_id) vf (vf_id)\n"
549 " Disable E-tag insertion for a VF on a port\n\n"
551 "E-tag set stripping (on|off) port (port_id)\n"
552 " Enable/disable E-tag stripping on a port\n\n"
554 "E-tag set forwarding (on|off) port (port_id)\n"
555 " Enable/disable E-tag based forwarding"
558 "E-tag set filter add e-tag-id (value) dst-pool"
559 " (pool_id) port (port_id)\n"
560 " Add an E-tag forwarding filter on a port\n\n"
562 "E-tag set filter del e-tag-id (value) port (port_id)\n"
563 " Delete an E-tag forwarding filter on a port\n\n"
565 , list_pkt_forwarding_modes()
569 if (show_all || !strcmp(res->section, "ports")) {
575 "----------------\n\n"
577 "port start (port_id|all)\n"
578 " Start all ports or port_id.\n\n"
580 "port stop (port_id|all)\n"
581 " Stop all ports or port_id.\n\n"
583 "port close (port_id|all)\n"
584 " Close all ports or port_id.\n\n"
586 "port attach (ident)\n"
587 " Attach physical or virtual dev by pci address or virtual device name\n\n"
589 "port detach (port_id)\n"
590 " Detach physical or virtual dev by port_id\n\n"
592 "port config (port_id|all)"
593 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
594 " duplex (half|full|auto)\n"
595 " Set speed and duplex for all ports or port_id\n\n"
597 "port config all (rxq|txq|rxd|txd) (value)\n"
598 " Set number for rxq/txq/rxd/txd.\n\n"
600 "port config all max-pkt-len (value)\n"
601 " Set the max packet length.\n\n"
603 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
604 "hw-vlan-strip|hw-vlan-extend|drop-en)"
606 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
609 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
610 " Set the RSS mode.\n\n"
612 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
613 " Set the RSS redirection table.\n\n"
615 "port config (port_id) dcb vt (on|off) (traffic_class)"
617 " Set the DCB mode.\n\n"
619 "port config all burst (value)\n"
620 " Set the number of packets per burst.\n\n"
622 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
624 " Set the ring prefetch/host/writeback threshold"
625 " for tx/rx queue.\n\n"
627 "port config all (txfreet|txrst|rxfreet) (value)\n"
628 " Set free threshold for rx/tx, or set"
629 " tx rs bit threshold.\n\n"
630 "port config mtu X value\n"
631 " Set the MTU of port X to a given value\n\n"
633 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
634 " Start/stop a rx/tx queue of port X. Only take effect"
635 " when port X is started\n\n"
637 "port config (port_id|all) l2-tunnel E-tag ether-type"
639 " Set the value of E-tag ether-type.\n\n"
641 "port config (port_id|all) l2-tunnel E-tag"
642 " (enable|disable)\n"
643 " Enable/disable the E-tag support.\n\n"
647 if (show_all || !strcmp(res->section, "registers")) {
655 "read reg (port_id) (address)\n"
656 " Display value of a port register.\n\n"
658 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
659 " Display a port register bit field.\n\n"
661 "read regbit (port_id) (address) (bit_x)\n"
662 " Display a single port register bit.\n\n"
664 "write reg (port_id) (address) (value)\n"
665 " Set value of a port register.\n\n"
667 "write regfield (port_id) (address) (bit_x) (bit_y)"
669 " Set bit field of a port register.\n\n"
671 "write regbit (port_id) (address) (bit_x) (value)\n"
672 " Set single bit value of a port register.\n\n"
675 if (show_all || !strcmp(res->section, "filters")) {
683 "ethertype_filter (port_id) (add|del)"
684 " (mac_addr|mac_ignr) (mac_address) ethertype"
685 " (ether_type) (drop|fwd) queue (queue_id)\n"
686 " Add/Del an ethertype filter.\n\n"
688 "2tuple_filter (port_id) (add|del)"
689 " dst_port (dst_port_value) protocol (protocol_value)"
690 " mask (mask_value) tcp_flags (tcp_flags_value)"
691 " priority (prio_value) queue (queue_id)\n"
692 " Add/Del a 2tuple filter.\n\n"
694 "5tuple_filter (port_id) (add|del)"
695 " dst_ip (dst_address) src_ip (src_address)"
696 " dst_port (dst_port_value) src_port (src_port_value)"
697 " protocol (protocol_value)"
698 " mask (mask_value) tcp_flags (tcp_flags_value)"
699 " priority (prio_value) queue (queue_id)\n"
700 " Add/Del a 5tuple filter.\n\n"
702 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
703 " Add/Del syn filter.\n\n"
705 "flex_filter (port_id) (add|del) len (len_value)"
706 " bytes (bytes_value) mask (mask_value)"
707 " priority (prio_value) queue (queue_id)\n"
708 " Add/Del a flex filter.\n\n"
710 "flow_director_filter (port_id) mode IP (add|del|update)"
711 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
712 " src (src_ip_address) dst (dst_ip_address)"
713 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
714 " vlan (vlan_value) flexbytes (flexbytes_value)"
715 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
716 " fd_id (fd_id_value)\n"
717 " Add/Del an IP type flow director filter.\n\n"
719 "flow_director_filter (port_id) mode IP (add|del|update)"
720 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
721 " src (src_ip_address) (src_port)"
722 " dst (dst_ip_address) (dst_port)"
723 " tos (tos_value) ttl (ttl_value)"
724 " vlan (vlan_value) flexbytes (flexbytes_value)"
725 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
726 " fd_id (fd_id_value)\n"
727 " Add/Del an UDP/TCP type flow director filter.\n\n"
729 "flow_director_filter (port_id) mode IP (add|del|update)"
730 " flow (ipv4-sctp|ipv6-sctp)"
731 " src (src_ip_address) (src_port)"
732 " dst (dst_ip_address) (dst_port)"
733 " tag (verification_tag) "
734 " tos (tos_value) ttl (ttl_value)"
736 " flexbytes (flexbytes_value) (drop|fwd)"
737 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
738 " Add/Del a SCTP type flow director filter.\n\n"
740 "flow_director_filter (port_id) mode IP (add|del|update)"
741 " flow l2_payload ether (ethertype)"
742 " flexbytes (flexbytes_value) (drop|fwd)"
743 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
744 " Add/Del a l2 payload type flow director filter.\n\n"
746 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
747 " mac (mac_address) vlan (vlan_value)"
748 " flexbytes (flexbytes_value) (drop|fwd)"
749 " queue (queue_id) fd_id (fd_id_value)\n"
750 " Add/Del a MAC-VLAN flow director filter.\n\n"
752 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
753 " mac (mac_address) vlan (vlan_value)"
754 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
755 " flexbytes (flexbytes_value) (drop|fwd)"
756 " queue (queue_id) fd_id (fd_id_value)\n"
757 " Add/Del a Tunnel flow director filter.\n\n"
759 "flush_flow_director (port_id)\n"
760 " Flush all flow director entries of a device.\n\n"
762 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
763 " src_mask (ipv4_src) (ipv6_src) (src_port)"
764 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
765 " Set flow director IP mask.\n\n"
767 "flow_director_mask (port_id) mode MAC-VLAN"
768 " vlan (vlan_value)\n"
769 " Set flow director MAC-VLAN mask.\n\n"
771 "flow_director_mask (port_id) mode Tunnel"
772 " vlan (vlan_value) mac (mac_value)"
773 " tunnel-type (tunnel_type_value)"
774 " tunnel-id (tunnel_id_value)\n"
775 " Set flow director Tunnel mask.\n\n"
777 "flow_director_flex_mask (port_id)"
778 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
779 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
781 " Configure mask of flex payload.\n\n"
783 "flow_director_flex_payload (port_id)"
784 " (raw|l2|l3|l4) (config)\n"
785 " Configure flex payload selection.\n\n"
787 "get_sym_hash_ena_per_port (port_id)\n"
788 " get symmetric hash enable configuration per port.\n\n"
790 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
791 " set symmetric hash enable configuration per port"
792 " to enable or disable.\n\n"
794 "get_hash_global_config (port_id)\n"
795 " Get the global configurations of hash filters.\n\n"
797 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
798 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
799 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
800 " (enable|disable)\n"
801 " Set the global configurations of hash filters.\n\n"
803 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
804 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
805 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
806 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
807 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
808 "ipv6-next-header|udp-src-port|udp-dst-port|"
809 "tcp-src-port|tcp-dst-port|sctp-src-port|"
810 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
811 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
812 "fld-8th|none) (select|add)\n"
813 " Set the input set for hash.\n\n"
815 "set_fdir_input_set (port_id) "
816 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
817 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
818 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
819 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
820 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
821 "udp-dst-port|tcp-src-port|tcp-dst-port|"
822 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
824 " Set the input set for FDir.\n\n"
826 "flow validate {port_id}"
827 " [group {group_id}] [priority {level}]"
828 " [ingress] [egress]"
829 " pattern {item} [/ {item} [...]] / end"
830 " actions {action} [/ {action} [...]] / end\n"
831 " Check whether a flow rule can be created.\n\n"
833 "flow create {port_id}"
834 " [group {group_id}] [priority {level}]"
835 " [ingress] [egress]"
836 " pattern {item} [/ {item} [...]] / end"
837 " actions {action} [/ {action} [...]] / end\n"
838 " Create a flow rule.\n\n"
840 "flow destroy {port_id} rule {rule_id} [...]\n"
841 " Destroy specific flow rules.\n\n"
843 "flow flush {port_id}\n"
844 " Destroy all flow rules.\n\n"
846 "flow query {port_id} {rule_id} {action}\n"
847 " Query an existing flow rule.\n\n"
849 "flow list {port_id} [group {group_id}] [...]\n"
850 " List existing flow rules sorted by priority,"
851 " filtered by group identifiers.\n\n"
856 cmdline_parse_token_string_t cmd_help_long_help =
857 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
859 cmdline_parse_token_string_t cmd_help_long_section =
860 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
861 "all#control#display#config#"
862 "ports#registers#filters");
864 cmdline_parse_inst_t cmd_help_long = {
865 .f = cmd_help_long_parsed,
867 .help_str = "help all|control|display|config|ports|register|filters: "
870 (void *)&cmd_help_long_help,
871 (void *)&cmd_help_long_section,
877 /* *** start/stop/close all ports *** */
878 struct cmd_operate_port_result {
879 cmdline_fixed_string_t keyword;
880 cmdline_fixed_string_t name;
881 cmdline_fixed_string_t value;
884 static void cmd_operate_port_parsed(void *parsed_result,
885 __attribute__((unused)) struct cmdline *cl,
886 __attribute__((unused)) void *data)
888 struct cmd_operate_port_result *res = parsed_result;
890 if (!strcmp(res->name, "start"))
891 start_port(RTE_PORT_ALL);
892 else if (!strcmp(res->name, "stop"))
893 stop_port(RTE_PORT_ALL);
894 else if (!strcmp(res->name, "close"))
895 close_port(RTE_PORT_ALL);
897 printf("Unknown parameter\n");
900 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
901 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
903 cmdline_parse_token_string_t cmd_operate_port_all_port =
904 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
906 cmdline_parse_token_string_t cmd_operate_port_all_all =
907 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
909 cmdline_parse_inst_t cmd_operate_port = {
910 .f = cmd_operate_port_parsed,
912 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
914 (void *)&cmd_operate_port_all_cmd,
915 (void *)&cmd_operate_port_all_port,
916 (void *)&cmd_operate_port_all_all,
921 /* *** start/stop/close specific port *** */
922 struct cmd_operate_specific_port_result {
923 cmdline_fixed_string_t keyword;
924 cmdline_fixed_string_t name;
928 static void cmd_operate_specific_port_parsed(void *parsed_result,
929 __attribute__((unused)) struct cmdline *cl,
930 __attribute__((unused)) void *data)
932 struct cmd_operate_specific_port_result *res = parsed_result;
934 if (!strcmp(res->name, "start"))
935 start_port(res->value);
936 else if (!strcmp(res->name, "stop"))
937 stop_port(res->value);
938 else if (!strcmp(res->name, "close"))
939 close_port(res->value);
941 printf("Unknown parameter\n");
944 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
945 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
947 cmdline_parse_token_string_t cmd_operate_specific_port_port =
948 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
949 name, "start#stop#close");
950 cmdline_parse_token_num_t cmd_operate_specific_port_id =
951 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
954 cmdline_parse_inst_t cmd_operate_specific_port = {
955 .f = cmd_operate_specific_port_parsed,
957 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
959 (void *)&cmd_operate_specific_port_cmd,
960 (void *)&cmd_operate_specific_port_port,
961 (void *)&cmd_operate_specific_port_id,
966 /* *** attach a specified port *** */
967 struct cmd_operate_attach_port_result {
968 cmdline_fixed_string_t port;
969 cmdline_fixed_string_t keyword;
970 cmdline_fixed_string_t identifier;
973 static void cmd_operate_attach_port_parsed(void *parsed_result,
974 __attribute__((unused)) struct cmdline *cl,
975 __attribute__((unused)) void *data)
977 struct cmd_operate_attach_port_result *res = parsed_result;
979 if (!strcmp(res->keyword, "attach"))
980 attach_port(res->identifier);
982 printf("Unknown parameter\n");
985 cmdline_parse_token_string_t cmd_operate_attach_port_port =
986 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
988 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
989 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
991 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
992 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
995 cmdline_parse_inst_t cmd_operate_attach_port = {
996 .f = cmd_operate_attach_port_parsed,
998 .help_str = "port attach <identifier>: "
999 "(identifier: pci address or virtual dev name)",
1001 (void *)&cmd_operate_attach_port_port,
1002 (void *)&cmd_operate_attach_port_keyword,
1003 (void *)&cmd_operate_attach_port_identifier,
1008 /* *** detach a specified port *** */
1009 struct cmd_operate_detach_port_result {
1010 cmdline_fixed_string_t port;
1011 cmdline_fixed_string_t keyword;
1015 static void cmd_operate_detach_port_parsed(void *parsed_result,
1016 __attribute__((unused)) struct cmdline *cl,
1017 __attribute__((unused)) void *data)
1019 struct cmd_operate_detach_port_result *res = parsed_result;
1021 if (!strcmp(res->keyword, "detach"))
1022 detach_port(res->port_id);
1024 printf("Unknown parameter\n");
1027 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1028 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1030 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1031 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1033 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1034 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1037 cmdline_parse_inst_t cmd_operate_detach_port = {
1038 .f = cmd_operate_detach_port_parsed,
1040 .help_str = "port detach <port_id>",
1042 (void *)&cmd_operate_detach_port_port,
1043 (void *)&cmd_operate_detach_port_keyword,
1044 (void *)&cmd_operate_detach_port_port_id,
1049 /* *** configure speed for all ports *** */
1050 struct cmd_config_speed_all {
1051 cmdline_fixed_string_t port;
1052 cmdline_fixed_string_t keyword;
1053 cmdline_fixed_string_t all;
1054 cmdline_fixed_string_t item1;
1055 cmdline_fixed_string_t item2;
1056 cmdline_fixed_string_t value1;
1057 cmdline_fixed_string_t value2;
1061 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1066 if (!strcmp(duplexstr, "half")) {
1067 duplex = ETH_LINK_HALF_DUPLEX;
1068 } else if (!strcmp(duplexstr, "full")) {
1069 duplex = ETH_LINK_FULL_DUPLEX;
1070 } else if (!strcmp(duplexstr, "auto")) {
1071 duplex = ETH_LINK_FULL_DUPLEX;
1073 printf("Unknown duplex parameter\n");
1077 if (!strcmp(speedstr, "10")) {
1078 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1079 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1080 } else if (!strcmp(speedstr, "100")) {
1081 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1082 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1084 if (duplex != ETH_LINK_FULL_DUPLEX) {
1085 printf("Invalid speed/duplex parameters\n");
1088 if (!strcmp(speedstr, "1000")) {
1089 *speed = ETH_LINK_SPEED_1G;
1090 } else if (!strcmp(speedstr, "10000")) {
1091 *speed = ETH_LINK_SPEED_10G;
1092 } else if (!strcmp(speedstr, "25000")) {
1093 *speed = ETH_LINK_SPEED_25G;
1094 } else if (!strcmp(speedstr, "40000")) {
1095 *speed = ETH_LINK_SPEED_40G;
1096 } else if (!strcmp(speedstr, "50000")) {
1097 *speed = ETH_LINK_SPEED_50G;
1098 } else if (!strcmp(speedstr, "100000")) {
1099 *speed = ETH_LINK_SPEED_100G;
1100 } else if (!strcmp(speedstr, "auto")) {
1101 *speed = ETH_LINK_SPEED_AUTONEG;
1103 printf("Unknown speed parameter\n");
1112 cmd_config_speed_all_parsed(void *parsed_result,
1113 __attribute__((unused)) struct cmdline *cl,
1114 __attribute__((unused)) void *data)
1116 struct cmd_config_speed_all *res = parsed_result;
1117 uint32_t link_speed;
1120 if (!all_ports_stopped()) {
1121 printf("Please stop all ports first\n");
1125 if (parse_and_check_speed_duplex(res->value1, res->value2,
1129 FOREACH_PORT(pid, ports) {
1130 ports[pid].dev_conf.link_speeds = link_speed;
1133 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1136 cmdline_parse_token_string_t cmd_config_speed_all_port =
1137 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1138 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1139 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1141 cmdline_parse_token_string_t cmd_config_speed_all_all =
1142 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1143 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1145 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1146 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1147 "10#100#1000#10000#25000#40000#50000#100000#auto");
1148 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1150 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1154 cmdline_parse_inst_t cmd_config_speed_all = {
1155 .f = cmd_config_speed_all_parsed,
1157 .help_str = "port config all speed "
1158 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1161 (void *)&cmd_config_speed_all_port,
1162 (void *)&cmd_config_speed_all_keyword,
1163 (void *)&cmd_config_speed_all_all,
1164 (void *)&cmd_config_speed_all_item1,
1165 (void *)&cmd_config_speed_all_value1,
1166 (void *)&cmd_config_speed_all_item2,
1167 (void *)&cmd_config_speed_all_value2,
1172 /* *** configure speed for specific port *** */
1173 struct cmd_config_speed_specific {
1174 cmdline_fixed_string_t port;
1175 cmdline_fixed_string_t keyword;
1177 cmdline_fixed_string_t item1;
1178 cmdline_fixed_string_t item2;
1179 cmdline_fixed_string_t value1;
1180 cmdline_fixed_string_t value2;
1184 cmd_config_speed_specific_parsed(void *parsed_result,
1185 __attribute__((unused)) struct cmdline *cl,
1186 __attribute__((unused)) void *data)
1188 struct cmd_config_speed_specific *res = parsed_result;
1189 uint32_t link_speed;
1191 if (!all_ports_stopped()) {
1192 printf("Please stop all ports first\n");
1196 if (port_id_is_invalid(res->id, ENABLED_WARN))
1199 if (parse_and_check_speed_duplex(res->value1, res->value2,
1203 ports[res->id].dev_conf.link_speeds = link_speed;
1205 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1209 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1210 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1212 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1213 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1215 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1216 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1217 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1218 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1220 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1221 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1222 "10#100#1000#10000#25000#40000#50000#100000#auto");
1223 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1224 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1226 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1227 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1230 cmdline_parse_inst_t cmd_config_speed_specific = {
1231 .f = cmd_config_speed_specific_parsed,
1233 .help_str = "port config <port_id> speed "
1234 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1237 (void *)&cmd_config_speed_specific_port,
1238 (void *)&cmd_config_speed_specific_keyword,
1239 (void *)&cmd_config_speed_specific_id,
1240 (void *)&cmd_config_speed_specific_item1,
1241 (void *)&cmd_config_speed_specific_value1,
1242 (void *)&cmd_config_speed_specific_item2,
1243 (void *)&cmd_config_speed_specific_value2,
1248 /* *** configure txq/rxq, txd/rxd *** */
1249 struct cmd_config_rx_tx {
1250 cmdline_fixed_string_t port;
1251 cmdline_fixed_string_t keyword;
1252 cmdline_fixed_string_t all;
1253 cmdline_fixed_string_t name;
1258 cmd_config_rx_tx_parsed(void *parsed_result,
1259 __attribute__((unused)) struct cmdline *cl,
1260 __attribute__((unused)) void *data)
1262 struct cmd_config_rx_tx *res = parsed_result;
1264 if (!all_ports_stopped()) {
1265 printf("Please stop all ports first\n");
1268 if (!strcmp(res->name, "rxq")) {
1269 if (!res->value && !nb_txq) {
1270 printf("Warning: Either rx or tx queues should be non zero\n");
1273 nb_rxq = res->value;
1275 else if (!strcmp(res->name, "txq")) {
1276 if (!res->value && !nb_rxq) {
1277 printf("Warning: Either rx or tx queues should be non zero\n");
1280 nb_txq = res->value;
1282 else if (!strcmp(res->name, "rxd")) {
1283 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1284 printf("rxd %d invalid - must be > 0 && <= %d\n",
1285 res->value, RTE_TEST_RX_DESC_MAX);
1288 nb_rxd = res->value;
1289 } else if (!strcmp(res->name, "txd")) {
1290 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1291 printf("txd %d invalid - must be > 0 && <= %d\n",
1292 res->value, RTE_TEST_TX_DESC_MAX);
1295 nb_txd = res->value;
1297 printf("Unknown parameter\n");
1305 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1308 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1309 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1310 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1311 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1312 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1313 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1314 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1315 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1317 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1318 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1320 cmdline_parse_inst_t cmd_config_rx_tx = {
1321 .f = cmd_config_rx_tx_parsed,
1323 .help_str = "port config all rxq|txq|rxd|txd <value>",
1325 (void *)&cmd_config_rx_tx_port,
1326 (void *)&cmd_config_rx_tx_keyword,
1327 (void *)&cmd_config_rx_tx_all,
1328 (void *)&cmd_config_rx_tx_name,
1329 (void *)&cmd_config_rx_tx_value,
1334 /* *** config max packet length *** */
1335 struct cmd_config_max_pkt_len_result {
1336 cmdline_fixed_string_t port;
1337 cmdline_fixed_string_t keyword;
1338 cmdline_fixed_string_t all;
1339 cmdline_fixed_string_t name;
1344 cmd_config_max_pkt_len_parsed(void *parsed_result,
1345 __attribute__((unused)) struct cmdline *cl,
1346 __attribute__((unused)) void *data)
1348 struct cmd_config_max_pkt_len_result *res = parsed_result;
1350 if (!all_ports_stopped()) {
1351 printf("Please stop all ports first\n");
1355 if (!strcmp(res->name, "max-pkt-len")) {
1356 if (res->value < ETHER_MIN_LEN) {
1357 printf("max-pkt-len can not be less than %d\n",
1361 if (res->value == rx_mode.max_rx_pkt_len)
1364 rx_mode.max_rx_pkt_len = res->value;
1365 if (res->value > ETHER_MAX_LEN)
1366 rx_mode.jumbo_frame = 1;
1368 rx_mode.jumbo_frame = 0;
1370 printf("Unknown parameter\n");
1376 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1379 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1380 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1382 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1383 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1385 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1386 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1388 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1389 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1391 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1392 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1395 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1396 .f = cmd_config_max_pkt_len_parsed,
1398 .help_str = "port config all max-pkt-len <value>",
1400 (void *)&cmd_config_max_pkt_len_port,
1401 (void *)&cmd_config_max_pkt_len_keyword,
1402 (void *)&cmd_config_max_pkt_len_all,
1403 (void *)&cmd_config_max_pkt_len_name,
1404 (void *)&cmd_config_max_pkt_len_value,
1409 /* *** configure port MTU *** */
1410 struct cmd_config_mtu_result {
1411 cmdline_fixed_string_t port;
1412 cmdline_fixed_string_t keyword;
1413 cmdline_fixed_string_t mtu;
1419 cmd_config_mtu_parsed(void *parsed_result,
1420 __attribute__((unused)) struct cmdline *cl,
1421 __attribute__((unused)) void *data)
1423 struct cmd_config_mtu_result *res = parsed_result;
1425 if (res->value < ETHER_MIN_LEN) {
1426 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1429 port_mtu_set(res->port_id, res->value);
1432 cmdline_parse_token_string_t cmd_config_mtu_port =
1433 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1435 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1436 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1438 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1439 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1441 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1442 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1443 cmdline_parse_token_num_t cmd_config_mtu_value =
1444 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1446 cmdline_parse_inst_t cmd_config_mtu = {
1447 .f = cmd_config_mtu_parsed,
1449 .help_str = "port config mtu <port_id> <value>",
1451 (void *)&cmd_config_mtu_port,
1452 (void *)&cmd_config_mtu_keyword,
1453 (void *)&cmd_config_mtu_mtu,
1454 (void *)&cmd_config_mtu_port_id,
1455 (void *)&cmd_config_mtu_value,
1460 /* *** configure rx mode *** */
1461 struct cmd_config_rx_mode_flag {
1462 cmdline_fixed_string_t port;
1463 cmdline_fixed_string_t keyword;
1464 cmdline_fixed_string_t all;
1465 cmdline_fixed_string_t name;
1466 cmdline_fixed_string_t value;
1470 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1471 __attribute__((unused)) struct cmdline *cl,
1472 __attribute__((unused)) void *data)
1474 struct cmd_config_rx_mode_flag *res = parsed_result;
1476 if (!all_ports_stopped()) {
1477 printf("Please stop all ports first\n");
1481 if (!strcmp(res->name, "crc-strip")) {
1482 if (!strcmp(res->value, "on"))
1483 rx_mode.hw_strip_crc = 1;
1484 else if (!strcmp(res->value, "off"))
1485 rx_mode.hw_strip_crc = 0;
1487 printf("Unknown parameter\n");
1490 } else if (!strcmp(res->name, "scatter")) {
1491 if (!strcmp(res->value, "on"))
1492 rx_mode.enable_scatter = 1;
1493 else if (!strcmp(res->value, "off"))
1494 rx_mode.enable_scatter = 0;
1496 printf("Unknown parameter\n");
1499 } else if (!strcmp(res->name, "rx-cksum")) {
1500 if (!strcmp(res->value, "on"))
1501 rx_mode.hw_ip_checksum = 1;
1502 else if (!strcmp(res->value, "off"))
1503 rx_mode.hw_ip_checksum = 0;
1505 printf("Unknown parameter\n");
1508 } else if (!strcmp(res->name, "hw-vlan")) {
1509 if (!strcmp(res->value, "on")) {
1510 rx_mode.hw_vlan_filter = 1;
1511 rx_mode.hw_vlan_strip = 1;
1513 else if (!strcmp(res->value, "off")) {
1514 rx_mode.hw_vlan_filter = 0;
1515 rx_mode.hw_vlan_strip = 0;
1518 printf("Unknown parameter\n");
1521 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1522 if (!strcmp(res->value, "on"))
1523 rx_mode.hw_vlan_filter = 1;
1524 else if (!strcmp(res->value, "off"))
1525 rx_mode.hw_vlan_filter = 0;
1527 printf("Unknown parameter\n");
1530 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1531 if (!strcmp(res->value, "on"))
1532 rx_mode.hw_vlan_strip = 1;
1533 else if (!strcmp(res->value, "off"))
1534 rx_mode.hw_vlan_strip = 0;
1536 printf("Unknown parameter\n");
1539 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1540 if (!strcmp(res->value, "on"))
1541 rx_mode.hw_vlan_extend = 1;
1542 else if (!strcmp(res->value, "off"))
1543 rx_mode.hw_vlan_extend = 0;
1545 printf("Unknown parameter\n");
1548 } else if (!strcmp(res->name, "drop-en")) {
1549 if (!strcmp(res->value, "on"))
1551 else if (!strcmp(res->value, "off"))
1554 printf("Unknown parameter\n");
1558 printf("Unknown parameter\n");
1564 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1567 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1569 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1572 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1574 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1575 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1576 "crc-strip#scatter#rx-cksum#hw-vlan#"
1577 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1578 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1579 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1582 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1583 .f = cmd_config_rx_mode_flag_parsed,
1585 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1586 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1588 (void *)&cmd_config_rx_mode_flag_port,
1589 (void *)&cmd_config_rx_mode_flag_keyword,
1590 (void *)&cmd_config_rx_mode_flag_all,
1591 (void *)&cmd_config_rx_mode_flag_name,
1592 (void *)&cmd_config_rx_mode_flag_value,
1597 /* *** configure rss *** */
1598 struct cmd_config_rss {
1599 cmdline_fixed_string_t port;
1600 cmdline_fixed_string_t keyword;
1601 cmdline_fixed_string_t all;
1602 cmdline_fixed_string_t name;
1603 cmdline_fixed_string_t value;
1607 cmd_config_rss_parsed(void *parsed_result,
1608 __attribute__((unused)) struct cmdline *cl,
1609 __attribute__((unused)) void *data)
1611 struct cmd_config_rss *res = parsed_result;
1612 struct rte_eth_rss_conf rss_conf;
1616 if (!strcmp(res->value, "all"))
1617 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1618 ETH_RSS_UDP | ETH_RSS_SCTP |
1620 else if (!strcmp(res->value, "ip"))
1621 rss_conf.rss_hf = ETH_RSS_IP;
1622 else if (!strcmp(res->value, "udp"))
1623 rss_conf.rss_hf = ETH_RSS_UDP;
1624 else if (!strcmp(res->value, "tcp"))
1625 rss_conf.rss_hf = ETH_RSS_TCP;
1626 else if (!strcmp(res->value, "sctp"))
1627 rss_conf.rss_hf = ETH_RSS_SCTP;
1628 else if (!strcmp(res->value, "ether"))
1629 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1630 else if (!strcmp(res->value, "port"))
1631 rss_conf.rss_hf = ETH_RSS_PORT;
1632 else if (!strcmp(res->value, "vxlan"))
1633 rss_conf.rss_hf = ETH_RSS_VXLAN;
1634 else if (!strcmp(res->value, "geneve"))
1635 rss_conf.rss_hf = ETH_RSS_GENEVE;
1636 else if (!strcmp(res->value, "nvgre"))
1637 rss_conf.rss_hf = ETH_RSS_NVGRE;
1638 else if (!strcmp(res->value, "none"))
1639 rss_conf.rss_hf = 0;
1641 printf("Unknown parameter\n");
1644 rss_conf.rss_key = NULL;
1645 for (i = 0; i < rte_eth_dev_count(); i++) {
1646 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1648 printf("Configuration of RSS hash at ethernet port %d "
1649 "failed with error (%d): %s.\n",
1650 i, -diag, strerror(-diag));
1654 cmdline_parse_token_string_t cmd_config_rss_port =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1656 cmdline_parse_token_string_t cmd_config_rss_keyword =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1658 cmdline_parse_token_string_t cmd_config_rss_all =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1660 cmdline_parse_token_string_t cmd_config_rss_name =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1662 cmdline_parse_token_string_t cmd_config_rss_value =
1663 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1664 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1666 cmdline_parse_inst_t cmd_config_rss = {
1667 .f = cmd_config_rss_parsed,
1669 .help_str = "port config all rss "
1670 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1672 (void *)&cmd_config_rss_port,
1673 (void *)&cmd_config_rss_keyword,
1674 (void *)&cmd_config_rss_all,
1675 (void *)&cmd_config_rss_name,
1676 (void *)&cmd_config_rss_value,
1681 /* *** configure rss hash key *** */
1682 struct cmd_config_rss_hash_key {
1683 cmdline_fixed_string_t port;
1684 cmdline_fixed_string_t config;
1686 cmdline_fixed_string_t rss_hash_key;
1687 cmdline_fixed_string_t rss_type;
1688 cmdline_fixed_string_t key;
1692 hexa_digit_to_value(char hexa_digit)
1694 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1695 return (uint8_t) (hexa_digit - '0');
1696 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1697 return (uint8_t) ((hexa_digit - 'a') + 10);
1698 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1699 return (uint8_t) ((hexa_digit - 'A') + 10);
1700 /* Invalid hexa digit */
1705 parse_and_check_key_hexa_digit(char *key, int idx)
1709 hexa_v = hexa_digit_to_value(key[idx]);
1711 printf("invalid key: character %c at position %d is not a "
1712 "valid hexa digit\n", key[idx], idx);
1717 cmd_config_rss_hash_key_parsed(void *parsed_result,
1718 __attribute__((unused)) struct cmdline *cl,
1719 __attribute__((unused)) void *data)
1721 struct cmd_config_rss_hash_key *res = parsed_result;
1722 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1726 struct rte_eth_dev_info dev_info;
1727 uint8_t hash_key_size;
1730 memset(&dev_info, 0, sizeof(dev_info));
1731 rte_eth_dev_info_get(res->port_id, &dev_info);
1732 if (dev_info.hash_key_size > 0 &&
1733 dev_info.hash_key_size <= sizeof(hash_key))
1734 hash_key_size = dev_info.hash_key_size;
1736 printf("dev_info did not provide a valid hash key size\n");
1739 /* Check the length of the RSS hash key */
1740 key_len = strlen(res->key);
1741 if (key_len != (hash_key_size * 2)) {
1742 printf("key length: %d invalid - key must be a string of %d"
1743 " hexa-decimal numbers\n",
1744 (int) key_len, hash_key_size * 2);
1747 /* Translate RSS hash key into binary representation */
1748 for (i = 0; i < hash_key_size; i++) {
1749 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1752 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1755 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1757 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1761 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1762 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1763 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1766 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1767 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1768 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1770 rss_hash_key, "rss-hash-key");
1771 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1773 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1774 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1775 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1776 "ipv6-tcp-ex#ipv6-udp-ex");
1777 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1778 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1780 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1781 .f = cmd_config_rss_hash_key_parsed,
1783 .help_str = "port config <port_id> rss-hash-key "
1784 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1785 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1786 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1787 "<string of hex digits (variable length, NIC dependent)>",
1789 (void *)&cmd_config_rss_hash_key_port,
1790 (void *)&cmd_config_rss_hash_key_config,
1791 (void *)&cmd_config_rss_hash_key_port_id,
1792 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1793 (void *)&cmd_config_rss_hash_key_rss_type,
1794 (void *)&cmd_config_rss_hash_key_value,
1799 /* *** configure port rxq/txq start/stop *** */
1800 struct cmd_config_rxtx_queue {
1801 cmdline_fixed_string_t port;
1803 cmdline_fixed_string_t rxtxq;
1805 cmdline_fixed_string_t opname;
1809 cmd_config_rxtx_queue_parsed(void *parsed_result,
1810 __attribute__((unused)) struct cmdline *cl,
1811 __attribute__((unused)) void *data)
1813 struct cmd_config_rxtx_queue *res = parsed_result;
1818 if (test_done == 0) {
1819 printf("Please stop forwarding first\n");
1823 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1826 if (port_is_started(res->portid) != 1) {
1827 printf("Please start port %u first\n", res->portid);
1831 if (!strcmp(res->rxtxq, "rxq"))
1833 else if (!strcmp(res->rxtxq, "txq"))
1836 printf("Unknown parameter\n");
1840 if (isrx && rx_queue_id_is_invalid(res->qid))
1842 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1845 if (!strcmp(res->opname, "start"))
1847 else if (!strcmp(res->opname, "stop"))
1850 printf("Unknown parameter\n");
1854 if (isstart && isrx)
1855 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1856 else if (!isstart && isrx)
1857 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1858 else if (isstart && !isrx)
1859 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1861 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1863 if (ret == -ENOTSUP)
1864 printf("Function not supported in PMD driver\n");
1867 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1868 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1869 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1870 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1871 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1872 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1873 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1874 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1875 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1876 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1879 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1880 .f = cmd_config_rxtx_queue_parsed,
1882 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1884 (void *)&cmd_config_speed_all_port,
1885 (void *)&cmd_config_rxtx_queue_portid,
1886 (void *)&cmd_config_rxtx_queue_rxtxq,
1887 (void *)&cmd_config_rxtx_queue_qid,
1888 (void *)&cmd_config_rxtx_queue_opname,
1893 /* *** Configure RSS RETA *** */
1894 struct cmd_config_rss_reta {
1895 cmdline_fixed_string_t port;
1896 cmdline_fixed_string_t keyword;
1898 cmdline_fixed_string_t name;
1899 cmdline_fixed_string_t list_name;
1900 cmdline_fixed_string_t list_of_items;
1904 parse_reta_config(const char *str,
1905 struct rte_eth_rss_reta_entry64 *reta_conf,
1906 uint16_t nb_entries)
1910 uint16_t hash_index, idx, shift;
1913 const char *p, *p0 = str;
1920 unsigned long int_fld[_NUM_FLD];
1921 char *str_fld[_NUM_FLD];
1923 while ((p = strchr(p0,'(')) != NULL) {
1925 if((p0 = strchr(p,')')) == NULL)
1929 if(size >= sizeof(s))
1932 snprintf(s, sizeof(s), "%.*s", size, p);
1933 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1935 for (i = 0; i < _NUM_FLD; i++) {
1937 int_fld[i] = strtoul(str_fld[i], &end, 0);
1938 if (errno != 0 || end == str_fld[i] ||
1943 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1944 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1946 if (hash_index >= nb_entries) {
1947 printf("Invalid RETA hash index=%d\n", hash_index);
1951 idx = hash_index / RTE_RETA_GROUP_SIZE;
1952 shift = hash_index % RTE_RETA_GROUP_SIZE;
1953 reta_conf[idx].mask |= (1ULL << shift);
1954 reta_conf[idx].reta[shift] = nb_queue;
1961 cmd_set_rss_reta_parsed(void *parsed_result,
1962 __attribute__((unused)) struct cmdline *cl,
1963 __attribute__((unused)) void *data)
1966 struct rte_eth_dev_info dev_info;
1967 struct rte_eth_rss_reta_entry64 reta_conf[8];
1968 struct cmd_config_rss_reta *res = parsed_result;
1970 memset(&dev_info, 0, sizeof(dev_info));
1971 rte_eth_dev_info_get(res->port_id, &dev_info);
1972 if (dev_info.reta_size == 0) {
1973 printf("Redirection table size is 0 which is "
1974 "invalid for RSS\n");
1977 printf("The reta size of port %d is %u\n",
1978 res->port_id, dev_info.reta_size);
1979 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1980 printf("Currently do not support more than %u entries of "
1981 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1985 memset(reta_conf, 0, sizeof(reta_conf));
1986 if (!strcmp(res->list_name, "reta")) {
1987 if (parse_reta_config(res->list_of_items, reta_conf,
1988 dev_info.reta_size)) {
1989 printf("Invalid RSS Redirection Table "
1990 "config entered\n");
1993 ret = rte_eth_dev_rss_reta_update(res->port_id,
1994 reta_conf, dev_info.reta_size);
1996 printf("Bad redirection table parameter, "
1997 "return code = %d \n", ret);
2001 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2003 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2004 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2005 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2006 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2007 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2009 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2010 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2011 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2012 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2014 cmdline_parse_inst_t cmd_config_rss_reta = {
2015 .f = cmd_set_rss_reta_parsed,
2017 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2019 (void *)&cmd_config_rss_reta_port,
2020 (void *)&cmd_config_rss_reta_keyword,
2021 (void *)&cmd_config_rss_reta_port_id,
2022 (void *)&cmd_config_rss_reta_name,
2023 (void *)&cmd_config_rss_reta_list_name,
2024 (void *)&cmd_config_rss_reta_list_of_items,
2029 /* *** SHOW PORT RETA INFO *** */
2030 struct cmd_showport_reta {
2031 cmdline_fixed_string_t show;
2032 cmdline_fixed_string_t port;
2034 cmdline_fixed_string_t rss;
2035 cmdline_fixed_string_t reta;
2037 cmdline_fixed_string_t list_of_items;
2041 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2042 uint16_t nb_entries,
2046 const char *p, *p0 = str;
2050 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2053 p = strchr(p0, '(');
2057 p0 = strchr(p, ')');
2061 if (size >= sizeof(s)) {
2062 printf("The string size exceeds the internal buffer size\n");
2065 snprintf(s, sizeof(s), "%.*s", size, p);
2066 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2067 if (ret <= 0 || ret != num) {
2068 printf("The bits of masks do not match the number of "
2069 "reta entries: %u\n", num);
2072 for (i = 0; i < ret; i++)
2073 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2079 cmd_showport_reta_parsed(void *parsed_result,
2080 __attribute__((unused)) struct cmdline *cl,
2081 __attribute__((unused)) void *data)
2083 struct cmd_showport_reta *res = parsed_result;
2084 struct rte_eth_rss_reta_entry64 reta_conf[8];
2085 struct rte_eth_dev_info dev_info;
2087 memset(&dev_info, 0, sizeof(dev_info));
2088 rte_eth_dev_info_get(res->port_id, &dev_info);
2089 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2090 res->size > ETH_RSS_RETA_SIZE_512) {
2091 printf("Invalid redirection table size: %u\n", res->size);
2095 memset(reta_conf, 0, sizeof(reta_conf));
2096 if (showport_parse_reta_config(reta_conf, res->size,
2097 res->list_of_items) < 0) {
2098 printf("Invalid string: %s for reta masks\n",
2099 res->list_of_items);
2102 port_rss_reta_info(res->port_id, reta_conf, res->size);
2105 cmdline_parse_token_string_t cmd_showport_reta_show =
2106 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2107 cmdline_parse_token_string_t cmd_showport_reta_port =
2108 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2109 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2110 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2111 cmdline_parse_token_string_t cmd_showport_reta_rss =
2112 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2113 cmdline_parse_token_string_t cmd_showport_reta_reta =
2114 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2115 cmdline_parse_token_num_t cmd_showport_reta_size =
2116 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2117 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2118 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2119 list_of_items, NULL);
2121 cmdline_parse_inst_t cmd_showport_reta = {
2122 .f = cmd_showport_reta_parsed,
2124 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2126 (void *)&cmd_showport_reta_show,
2127 (void *)&cmd_showport_reta_port,
2128 (void *)&cmd_showport_reta_port_id,
2129 (void *)&cmd_showport_reta_rss,
2130 (void *)&cmd_showport_reta_reta,
2131 (void *)&cmd_showport_reta_size,
2132 (void *)&cmd_showport_reta_list_of_items,
2137 /* *** Show RSS hash configuration *** */
2138 struct cmd_showport_rss_hash {
2139 cmdline_fixed_string_t show;
2140 cmdline_fixed_string_t port;
2142 cmdline_fixed_string_t rss_hash;
2143 cmdline_fixed_string_t rss_type;
2144 cmdline_fixed_string_t key; /* optional argument */
2147 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2148 __attribute__((unused)) struct cmdline *cl,
2151 struct cmd_showport_rss_hash *res = parsed_result;
2153 port_rss_hash_conf_show(res->port_id, res->rss_type,
2154 show_rss_key != NULL);
2157 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2158 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2159 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2160 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2161 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2162 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2163 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2164 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2166 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2167 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2168 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2169 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2170 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2171 "ipv6-tcp-ex#ipv6-udp-ex");
2172 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2173 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2175 cmdline_parse_inst_t cmd_showport_rss_hash = {
2176 .f = cmd_showport_rss_hash_parsed,
2178 .help_str = "show port <port_id> rss-hash "
2179 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2180 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2181 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2183 (void *)&cmd_showport_rss_hash_show,
2184 (void *)&cmd_showport_rss_hash_port,
2185 (void *)&cmd_showport_rss_hash_port_id,
2186 (void *)&cmd_showport_rss_hash_rss_hash,
2187 (void *)&cmd_showport_rss_hash_rss_hash_info,
2192 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2193 .f = cmd_showport_rss_hash_parsed,
2195 .help_str = "show port <port_id> rss-hash "
2196 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2197 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2198 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2200 (void *)&cmd_showport_rss_hash_show,
2201 (void *)&cmd_showport_rss_hash_port,
2202 (void *)&cmd_showport_rss_hash_port_id,
2203 (void *)&cmd_showport_rss_hash_rss_hash,
2204 (void *)&cmd_showport_rss_hash_rss_hash_info,
2205 (void *)&cmd_showport_rss_hash_rss_key,
2210 /* *** Configure DCB *** */
2211 struct cmd_config_dcb {
2212 cmdline_fixed_string_t port;
2213 cmdline_fixed_string_t config;
2215 cmdline_fixed_string_t dcb;
2216 cmdline_fixed_string_t vt;
2217 cmdline_fixed_string_t vt_en;
2219 cmdline_fixed_string_t pfc;
2220 cmdline_fixed_string_t pfc_en;
2224 cmd_config_dcb_parsed(void *parsed_result,
2225 __attribute__((unused)) struct cmdline *cl,
2226 __attribute__((unused)) void *data)
2228 struct cmd_config_dcb *res = parsed_result;
2229 portid_t port_id = res->port_id;
2230 struct rte_port *port;
2234 port = &ports[port_id];
2235 /** Check if the port is not started **/
2236 if (port->port_status != RTE_PORT_STOPPED) {
2237 printf("Please stop port %d first\n", port_id);
2241 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2242 printf("The invalid number of traffic class,"
2243 " only 4 or 8 allowed.\n");
2247 if (nb_fwd_lcores < res->num_tcs) {
2248 printf("nb_cores shouldn't be less than number of TCs.\n");
2251 if (!strncmp(res->pfc_en, "on", 2))
2256 /* DCB in VT mode */
2257 if (!strncmp(res->vt_en, "on", 2))
2258 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2259 (enum rte_eth_nb_tcs)res->num_tcs,
2262 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2263 (enum rte_eth_nb_tcs)res->num_tcs,
2268 printf("Cannot initialize network ports.\n");
2272 cmd_reconfig_device_queue(port_id, 1, 1);
2275 cmdline_parse_token_string_t cmd_config_dcb_port =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2277 cmdline_parse_token_string_t cmd_config_dcb_config =
2278 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2279 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2280 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2281 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2283 cmdline_parse_token_string_t cmd_config_dcb_vt =
2284 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2285 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2287 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2288 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2289 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2290 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2291 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2292 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2294 cmdline_parse_inst_t cmd_config_dcb = {
2295 .f = cmd_config_dcb_parsed,
2297 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2299 (void *)&cmd_config_dcb_port,
2300 (void *)&cmd_config_dcb_config,
2301 (void *)&cmd_config_dcb_port_id,
2302 (void *)&cmd_config_dcb_dcb,
2303 (void *)&cmd_config_dcb_vt,
2304 (void *)&cmd_config_dcb_vt_en,
2305 (void *)&cmd_config_dcb_num_tcs,
2306 (void *)&cmd_config_dcb_pfc,
2307 (void *)&cmd_config_dcb_pfc_en,
2312 /* *** configure number of packets per burst *** */
2313 struct cmd_config_burst {
2314 cmdline_fixed_string_t port;
2315 cmdline_fixed_string_t keyword;
2316 cmdline_fixed_string_t all;
2317 cmdline_fixed_string_t name;
2322 cmd_config_burst_parsed(void *parsed_result,
2323 __attribute__((unused)) struct cmdline *cl,
2324 __attribute__((unused)) void *data)
2326 struct cmd_config_burst *res = parsed_result;
2328 if (!all_ports_stopped()) {
2329 printf("Please stop all ports first\n");
2333 if (!strcmp(res->name, "burst")) {
2334 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2335 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2338 nb_pkt_per_burst = res->value;
2340 printf("Unknown parameter\n");
2346 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2349 cmdline_parse_token_string_t cmd_config_burst_port =
2350 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2351 cmdline_parse_token_string_t cmd_config_burst_keyword =
2352 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2353 cmdline_parse_token_string_t cmd_config_burst_all =
2354 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2355 cmdline_parse_token_string_t cmd_config_burst_name =
2356 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2357 cmdline_parse_token_num_t cmd_config_burst_value =
2358 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2360 cmdline_parse_inst_t cmd_config_burst = {
2361 .f = cmd_config_burst_parsed,
2363 .help_str = "port config all burst <value>",
2365 (void *)&cmd_config_burst_port,
2366 (void *)&cmd_config_burst_keyword,
2367 (void *)&cmd_config_burst_all,
2368 (void *)&cmd_config_burst_name,
2369 (void *)&cmd_config_burst_value,
2374 /* *** configure rx/tx queues *** */
2375 struct cmd_config_thresh {
2376 cmdline_fixed_string_t port;
2377 cmdline_fixed_string_t keyword;
2378 cmdline_fixed_string_t all;
2379 cmdline_fixed_string_t name;
2384 cmd_config_thresh_parsed(void *parsed_result,
2385 __attribute__((unused)) struct cmdline *cl,
2386 __attribute__((unused)) void *data)
2388 struct cmd_config_thresh *res = parsed_result;
2390 if (!all_ports_stopped()) {
2391 printf("Please stop all ports first\n");
2395 if (!strcmp(res->name, "txpt"))
2396 tx_pthresh = res->value;
2397 else if(!strcmp(res->name, "txht"))
2398 tx_hthresh = res->value;
2399 else if(!strcmp(res->name, "txwt"))
2400 tx_wthresh = res->value;
2401 else if(!strcmp(res->name, "rxpt"))
2402 rx_pthresh = res->value;
2403 else if(!strcmp(res->name, "rxht"))
2404 rx_hthresh = res->value;
2405 else if(!strcmp(res->name, "rxwt"))
2406 rx_wthresh = res->value;
2408 printf("Unknown parameter\n");
2414 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2417 cmdline_parse_token_string_t cmd_config_thresh_port =
2418 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2419 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2420 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2421 cmdline_parse_token_string_t cmd_config_thresh_all =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2423 cmdline_parse_token_string_t cmd_config_thresh_name =
2424 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2425 "txpt#txht#txwt#rxpt#rxht#rxwt");
2426 cmdline_parse_token_num_t cmd_config_thresh_value =
2427 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2429 cmdline_parse_inst_t cmd_config_thresh = {
2430 .f = cmd_config_thresh_parsed,
2432 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2434 (void *)&cmd_config_thresh_port,
2435 (void *)&cmd_config_thresh_keyword,
2436 (void *)&cmd_config_thresh_all,
2437 (void *)&cmd_config_thresh_name,
2438 (void *)&cmd_config_thresh_value,
2443 /* *** configure free/rs threshold *** */
2444 struct cmd_config_threshold {
2445 cmdline_fixed_string_t port;
2446 cmdline_fixed_string_t keyword;
2447 cmdline_fixed_string_t all;
2448 cmdline_fixed_string_t name;
2453 cmd_config_threshold_parsed(void *parsed_result,
2454 __attribute__((unused)) struct cmdline *cl,
2455 __attribute__((unused)) void *data)
2457 struct cmd_config_threshold *res = parsed_result;
2459 if (!all_ports_stopped()) {
2460 printf("Please stop all ports first\n");
2464 if (!strcmp(res->name, "txfreet"))
2465 tx_free_thresh = res->value;
2466 else if (!strcmp(res->name, "txrst"))
2467 tx_rs_thresh = res->value;
2468 else if (!strcmp(res->name, "rxfreet"))
2469 rx_free_thresh = res->value;
2471 printf("Unknown parameter\n");
2477 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2480 cmdline_parse_token_string_t cmd_config_threshold_port =
2481 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2482 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2483 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2485 cmdline_parse_token_string_t cmd_config_threshold_all =
2486 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2487 cmdline_parse_token_string_t cmd_config_threshold_name =
2488 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2489 "txfreet#txrst#rxfreet");
2490 cmdline_parse_token_num_t cmd_config_threshold_value =
2491 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2493 cmdline_parse_inst_t cmd_config_threshold = {
2494 .f = cmd_config_threshold_parsed,
2496 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2498 (void *)&cmd_config_threshold_port,
2499 (void *)&cmd_config_threshold_keyword,
2500 (void *)&cmd_config_threshold_all,
2501 (void *)&cmd_config_threshold_name,
2502 (void *)&cmd_config_threshold_value,
2508 struct cmd_stop_result {
2509 cmdline_fixed_string_t stop;
2512 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2513 __attribute__((unused)) struct cmdline *cl,
2514 __attribute__((unused)) void *data)
2516 stop_packet_forwarding();
2519 cmdline_parse_token_string_t cmd_stop_stop =
2520 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2522 cmdline_parse_inst_t cmd_stop = {
2523 .f = cmd_stop_parsed,
2525 .help_str = "stop: Stop packet forwarding",
2527 (void *)&cmd_stop_stop,
2532 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2535 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2536 unsigned int *parsed_items, int check_unique_values)
2538 unsigned int nb_item;
2546 * First parse all items in the list and store their value.
2551 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2553 if ((c >= '0') && (c <= '9')) {
2554 value = (unsigned int) (value * 10 + (c - '0'));
2559 printf("character %c is not a decimal digit\n", c);
2563 printf("No valid value before comma\n");
2566 if (nb_item < max_items) {
2567 parsed_items[nb_item] = value;
2573 if (nb_item >= max_items) {
2574 printf("Number of %s = %u > %u (maximum items)\n",
2575 item_name, nb_item + 1, max_items);
2578 parsed_items[nb_item++] = value;
2579 if (! check_unique_values)
2583 * Then, check that all values in the list are differents.
2584 * No optimization here...
2586 for (i = 0; i < nb_item; i++) {
2587 for (j = i + 1; j < nb_item; j++) {
2588 if (parsed_items[j] == parsed_items[i]) {
2589 printf("duplicated %s %u at index %u and %u\n",
2590 item_name, parsed_items[i], i, j);
2598 struct cmd_set_list_result {
2599 cmdline_fixed_string_t cmd_keyword;
2600 cmdline_fixed_string_t list_name;
2601 cmdline_fixed_string_t list_of_items;
2604 static void cmd_set_list_parsed(void *parsed_result,
2605 __attribute__((unused)) struct cmdline *cl,
2606 __attribute__((unused)) void *data)
2608 struct cmd_set_list_result *res;
2610 unsigned int lcorelist[RTE_MAX_LCORE];
2611 unsigned int portlist[RTE_MAX_ETHPORTS];
2613 unsigned int nb_item;
2615 if (test_done == 0) {
2616 printf("Please stop forwarding first\n");
2620 res = parsed_result;
2621 if (!strcmp(res->list_name, "corelist")) {
2622 nb_item = parse_item_list(res->list_of_items, "core",
2624 parsed_items.lcorelist, 1);
2626 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2631 if (!strcmp(res->list_name, "portlist")) {
2632 nb_item = parse_item_list(res->list_of_items, "port",
2634 parsed_items.portlist, 1);
2636 set_fwd_ports_list(parsed_items.portlist, nb_item);
2642 cmdline_parse_token_string_t cmd_set_list_keyword =
2643 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2645 cmdline_parse_token_string_t cmd_set_list_name =
2646 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2647 "corelist#portlist");
2648 cmdline_parse_token_string_t cmd_set_list_of_items =
2649 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2652 cmdline_parse_inst_t cmd_set_fwd_list = {
2653 .f = cmd_set_list_parsed,
2655 .help_str = "set corelist|portlist <list0[,list1]*>",
2657 (void *)&cmd_set_list_keyword,
2658 (void *)&cmd_set_list_name,
2659 (void *)&cmd_set_list_of_items,
2664 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2666 struct cmd_setmask_result {
2667 cmdline_fixed_string_t set;
2668 cmdline_fixed_string_t mask;
2672 static void cmd_set_mask_parsed(void *parsed_result,
2673 __attribute__((unused)) struct cmdline *cl,
2674 __attribute__((unused)) void *data)
2676 struct cmd_setmask_result *res = parsed_result;
2678 if (test_done == 0) {
2679 printf("Please stop forwarding first\n");
2682 if (!strcmp(res->mask, "coremask")) {
2683 set_fwd_lcores_mask(res->hexavalue);
2685 } else if (!strcmp(res->mask, "portmask")) {
2686 set_fwd_ports_mask(res->hexavalue);
2691 cmdline_parse_token_string_t cmd_setmask_set =
2692 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2693 cmdline_parse_token_string_t cmd_setmask_mask =
2694 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2695 "coremask#portmask");
2696 cmdline_parse_token_num_t cmd_setmask_value =
2697 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2699 cmdline_parse_inst_t cmd_set_fwd_mask = {
2700 .f = cmd_set_mask_parsed,
2702 .help_str = "set coremask|portmask <hexadecimal value>",
2704 (void *)&cmd_setmask_set,
2705 (void *)&cmd_setmask_mask,
2706 (void *)&cmd_setmask_value,
2712 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2714 struct cmd_set_result {
2715 cmdline_fixed_string_t set;
2716 cmdline_fixed_string_t what;
2720 static void cmd_set_parsed(void *parsed_result,
2721 __attribute__((unused)) struct cmdline *cl,
2722 __attribute__((unused)) void *data)
2724 struct cmd_set_result *res = parsed_result;
2725 if (!strcmp(res->what, "nbport")) {
2726 set_fwd_ports_number(res->value);
2728 } else if (!strcmp(res->what, "nbcore")) {
2729 set_fwd_lcores_number(res->value);
2731 } else if (!strcmp(res->what, "burst"))
2732 set_nb_pkt_per_burst(res->value);
2733 else if (!strcmp(res->what, "verbose"))
2734 set_verbose_level(res->value);
2737 cmdline_parse_token_string_t cmd_set_set =
2738 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2739 cmdline_parse_token_string_t cmd_set_what =
2740 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2741 "nbport#nbcore#burst#verbose");
2742 cmdline_parse_token_num_t cmd_set_value =
2743 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2745 cmdline_parse_inst_t cmd_set_numbers = {
2746 .f = cmd_set_parsed,
2748 .help_str = "set nbport|nbcore|burst|verbose <value>",
2750 (void *)&cmd_set_set,
2751 (void *)&cmd_set_what,
2752 (void *)&cmd_set_value,
2757 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2759 struct cmd_set_txpkts_result {
2760 cmdline_fixed_string_t cmd_keyword;
2761 cmdline_fixed_string_t txpkts;
2762 cmdline_fixed_string_t seg_lengths;
2766 cmd_set_txpkts_parsed(void *parsed_result,
2767 __attribute__((unused)) struct cmdline *cl,
2768 __attribute__((unused)) void *data)
2770 struct cmd_set_txpkts_result *res;
2771 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2772 unsigned int nb_segs;
2774 res = parsed_result;
2775 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2776 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2778 set_tx_pkt_segments(seg_lengths, nb_segs);
2781 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2782 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2783 cmd_keyword, "set");
2784 cmdline_parse_token_string_t cmd_set_txpkts_name =
2785 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2787 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2788 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2791 cmdline_parse_inst_t cmd_set_txpkts = {
2792 .f = cmd_set_txpkts_parsed,
2794 .help_str = "set txpkts <len0[,len1]*>",
2796 (void *)&cmd_set_txpkts_keyword,
2797 (void *)&cmd_set_txpkts_name,
2798 (void *)&cmd_set_txpkts_lengths,
2803 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2805 struct cmd_set_txsplit_result {
2806 cmdline_fixed_string_t cmd_keyword;
2807 cmdline_fixed_string_t txsplit;
2808 cmdline_fixed_string_t mode;
2812 cmd_set_txsplit_parsed(void *parsed_result,
2813 __attribute__((unused)) struct cmdline *cl,
2814 __attribute__((unused)) void *data)
2816 struct cmd_set_txsplit_result *res;
2818 res = parsed_result;
2819 set_tx_pkt_split(res->mode);
2822 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2823 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2824 cmd_keyword, "set");
2825 cmdline_parse_token_string_t cmd_set_txsplit_name =
2826 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2827 txsplit, "txsplit");
2828 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2829 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2832 cmdline_parse_inst_t cmd_set_txsplit = {
2833 .f = cmd_set_txsplit_parsed,
2835 .help_str = "set txsplit on|off|rand",
2837 (void *)&cmd_set_txsplit_keyword,
2838 (void *)&cmd_set_txsplit_name,
2839 (void *)&cmd_set_txsplit_mode,
2844 /* *** CONFIG TX QUEUE FLAGS *** */
2846 struct cmd_config_txqflags_result {
2847 cmdline_fixed_string_t port;
2848 cmdline_fixed_string_t config;
2849 cmdline_fixed_string_t all;
2850 cmdline_fixed_string_t what;
2854 static void cmd_config_txqflags_parsed(void *parsed_result,
2855 __attribute__((unused)) struct cmdline *cl,
2856 __attribute__((unused)) void *data)
2858 struct cmd_config_txqflags_result *res = parsed_result;
2860 if (!all_ports_stopped()) {
2861 printf("Please stop all ports first\n");
2865 if (strcmp(res->what, "txqflags")) {
2866 printf("Unknown parameter\n");
2870 if (res->hexvalue >= 0) {
2871 txq_flags = res->hexvalue;
2873 printf("txqflags must be >= 0\n");
2879 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2882 cmdline_parse_token_string_t cmd_config_txqflags_port =
2883 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2885 cmdline_parse_token_string_t cmd_config_txqflags_config =
2886 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2888 cmdline_parse_token_string_t cmd_config_txqflags_all =
2889 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2891 cmdline_parse_token_string_t cmd_config_txqflags_what =
2892 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2894 cmdline_parse_token_num_t cmd_config_txqflags_value =
2895 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2898 cmdline_parse_inst_t cmd_config_txqflags = {
2899 .f = cmd_config_txqflags_parsed,
2901 .help_str = "port config all txqflags <value>",
2903 (void *)&cmd_config_txqflags_port,
2904 (void *)&cmd_config_txqflags_config,
2905 (void *)&cmd_config_txqflags_all,
2906 (void *)&cmd_config_txqflags_what,
2907 (void *)&cmd_config_txqflags_value,
2912 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2913 struct cmd_rx_vlan_filter_all_result {
2914 cmdline_fixed_string_t rx_vlan;
2915 cmdline_fixed_string_t what;
2916 cmdline_fixed_string_t all;
2921 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2922 __attribute__((unused)) struct cmdline *cl,
2923 __attribute__((unused)) void *data)
2925 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2927 if (!strcmp(res->what, "add"))
2928 rx_vlan_all_filter_set(res->port_id, 1);
2930 rx_vlan_all_filter_set(res->port_id, 0);
2933 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2934 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2935 rx_vlan, "rx_vlan");
2936 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2937 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2939 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2940 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2942 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2943 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2946 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2947 .f = cmd_rx_vlan_filter_all_parsed,
2949 .help_str = "rx_vlan add|rm all <port_id>: "
2950 "Add/Remove all identifiers to/from the set of VLAN "
2951 "identifiers filtered by a port",
2953 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2954 (void *)&cmd_rx_vlan_filter_all_what,
2955 (void *)&cmd_rx_vlan_filter_all_all,
2956 (void *)&cmd_rx_vlan_filter_all_portid,
2961 /* *** VLAN OFFLOAD SET ON A PORT *** */
2962 struct cmd_vlan_offload_result {
2963 cmdline_fixed_string_t vlan;
2964 cmdline_fixed_string_t set;
2965 cmdline_fixed_string_t vlan_type;
2966 cmdline_fixed_string_t what;
2967 cmdline_fixed_string_t on;
2968 cmdline_fixed_string_t port_id;
2972 cmd_vlan_offload_parsed(void *parsed_result,
2973 __attribute__((unused)) struct cmdline *cl,
2974 __attribute__((unused)) void *data)
2977 struct cmd_vlan_offload_result *res = parsed_result;
2980 portid_t port_id = 0;
2984 len = strnlen(str, STR_TOKEN_SIZE);
2986 /* Get port_id first */
2994 tmp = strtoul(str, NULL, 0);
2995 /* If port_id greater that what portid_t can represent, return */
2996 if(tmp >= RTE_MAX_ETHPORTS)
2998 port_id = (portid_t)tmp;
3000 if (!strcmp(res->on, "on"))
3005 if (!strcmp(res->what, "strip"))
3006 rx_vlan_strip_set(port_id, on);
3007 else if(!strcmp(res->what, "stripq")){
3008 uint16_t queue_id = 0;
3010 /* No queue_id, return */
3012 printf("must specify (port,queue_id)\n");
3015 tmp = strtoul(str + i + 1, NULL, 0);
3016 /* If queue_id greater that what 16-bits can represent, return */
3020 queue_id = (uint16_t)tmp;
3021 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3023 else if (!strcmp(res->what, "filter"))
3024 rx_vlan_filter_set(port_id, on);
3026 vlan_extend_set(port_id, on);
3031 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3032 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3034 cmdline_parse_token_string_t cmd_vlan_offload_set =
3035 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3037 cmdline_parse_token_string_t cmd_vlan_offload_what =
3038 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3039 what, "strip#filter#qinq#stripq");
3040 cmdline_parse_token_string_t cmd_vlan_offload_on =
3041 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3043 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3044 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3047 cmdline_parse_inst_t cmd_vlan_offload = {
3048 .f = cmd_vlan_offload_parsed,
3050 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3051 "<port_id[,queue_id]>: "
3052 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3054 (void *)&cmd_vlan_offload_vlan,
3055 (void *)&cmd_vlan_offload_set,
3056 (void *)&cmd_vlan_offload_what,
3057 (void *)&cmd_vlan_offload_on,
3058 (void *)&cmd_vlan_offload_portid,
3063 /* *** VLAN TPID SET ON A PORT *** */
3064 struct cmd_vlan_tpid_result {
3065 cmdline_fixed_string_t vlan;
3066 cmdline_fixed_string_t set;
3067 cmdline_fixed_string_t vlan_type;
3068 cmdline_fixed_string_t what;
3074 cmd_vlan_tpid_parsed(void *parsed_result,
3075 __attribute__((unused)) struct cmdline *cl,
3076 __attribute__((unused)) void *data)
3078 struct cmd_vlan_tpid_result *res = parsed_result;
3079 enum rte_vlan_type vlan_type;
3081 if (!strcmp(res->vlan_type, "inner"))
3082 vlan_type = ETH_VLAN_TYPE_INNER;
3083 else if (!strcmp(res->vlan_type, "outer"))
3084 vlan_type = ETH_VLAN_TYPE_OUTER;
3086 printf("Unknown vlan type\n");
3089 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3092 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3093 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3095 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3096 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3098 cmdline_parse_token_string_t cmd_vlan_type =
3099 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3100 vlan_type, "inner#outer");
3101 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3102 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3104 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3105 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3107 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3108 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3111 cmdline_parse_inst_t cmd_vlan_tpid = {
3112 .f = cmd_vlan_tpid_parsed,
3114 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3115 "Set the VLAN Ether type",
3117 (void *)&cmd_vlan_tpid_vlan,
3118 (void *)&cmd_vlan_tpid_set,
3119 (void *)&cmd_vlan_type,
3120 (void *)&cmd_vlan_tpid_what,
3121 (void *)&cmd_vlan_tpid_tpid,
3122 (void *)&cmd_vlan_tpid_portid,
3127 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3128 struct cmd_rx_vlan_filter_result {
3129 cmdline_fixed_string_t rx_vlan;
3130 cmdline_fixed_string_t what;
3136 cmd_rx_vlan_filter_parsed(void *parsed_result,
3137 __attribute__((unused)) struct cmdline *cl,
3138 __attribute__((unused)) void *data)
3140 struct cmd_rx_vlan_filter_result *res = parsed_result;
3142 if (!strcmp(res->what, "add"))
3143 rx_vft_set(res->port_id, res->vlan_id, 1);
3145 rx_vft_set(res->port_id, res->vlan_id, 0);
3148 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3149 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3150 rx_vlan, "rx_vlan");
3151 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3152 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3154 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3155 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3157 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3158 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3161 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3162 .f = cmd_rx_vlan_filter_parsed,
3164 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3165 "Add/Remove a VLAN identifier to/from the set of VLAN "
3166 "identifiers filtered by a port",
3168 (void *)&cmd_rx_vlan_filter_rx_vlan,
3169 (void *)&cmd_rx_vlan_filter_what,
3170 (void *)&cmd_rx_vlan_filter_vlanid,
3171 (void *)&cmd_rx_vlan_filter_portid,
3176 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3177 struct cmd_tx_vlan_set_result {
3178 cmdline_fixed_string_t tx_vlan;
3179 cmdline_fixed_string_t set;
3185 cmd_tx_vlan_set_parsed(void *parsed_result,
3186 __attribute__((unused)) struct cmdline *cl,
3187 __attribute__((unused)) void *data)
3189 struct cmd_tx_vlan_set_result *res = parsed_result;
3191 tx_vlan_set(res->port_id, res->vlan_id);
3194 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3195 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3196 tx_vlan, "tx_vlan");
3197 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3198 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3200 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3201 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3203 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3204 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3207 cmdline_parse_inst_t cmd_tx_vlan_set = {
3208 .f = cmd_tx_vlan_set_parsed,
3210 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3211 "Enable hardware insertion of a single VLAN header "
3212 "with a given TAG Identifier in packets sent on a port",
3214 (void *)&cmd_tx_vlan_set_tx_vlan,
3215 (void *)&cmd_tx_vlan_set_set,
3216 (void *)&cmd_tx_vlan_set_portid,
3217 (void *)&cmd_tx_vlan_set_vlanid,
3222 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3223 struct cmd_tx_vlan_set_qinq_result {
3224 cmdline_fixed_string_t tx_vlan;
3225 cmdline_fixed_string_t set;
3228 uint16_t vlan_id_outer;
3232 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3233 __attribute__((unused)) struct cmdline *cl,
3234 __attribute__((unused)) void *data)
3236 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3238 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3241 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3242 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3243 tx_vlan, "tx_vlan");
3244 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3245 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3247 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3248 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3250 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3251 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3253 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3254 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3255 vlan_id_outer, UINT16);
3257 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3258 .f = cmd_tx_vlan_set_qinq_parsed,
3260 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3261 "Enable hardware insertion of double VLAN header "
3262 "with given TAG Identifiers in packets sent on a port",
3264 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3265 (void *)&cmd_tx_vlan_set_qinq_set,
3266 (void *)&cmd_tx_vlan_set_qinq_portid,
3267 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3268 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3273 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3274 struct cmd_tx_vlan_set_pvid_result {
3275 cmdline_fixed_string_t tx_vlan;
3276 cmdline_fixed_string_t set;
3277 cmdline_fixed_string_t pvid;
3280 cmdline_fixed_string_t mode;
3284 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3285 __attribute__((unused)) struct cmdline *cl,
3286 __attribute__((unused)) void *data)
3288 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3290 if (strcmp(res->mode, "on") == 0)
3291 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3293 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3296 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3297 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3298 tx_vlan, "tx_vlan");
3299 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3300 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3302 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3303 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3305 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3306 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3308 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3309 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3311 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3312 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3315 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3316 .f = cmd_tx_vlan_set_pvid_parsed,
3318 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3320 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3321 (void *)&cmd_tx_vlan_set_pvid_set,
3322 (void *)&cmd_tx_vlan_set_pvid_pvid,
3323 (void *)&cmd_tx_vlan_set_pvid_port_id,
3324 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3325 (void *)&cmd_tx_vlan_set_pvid_mode,
3330 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3331 struct cmd_tx_vlan_reset_result {
3332 cmdline_fixed_string_t tx_vlan;
3333 cmdline_fixed_string_t reset;
3338 cmd_tx_vlan_reset_parsed(void *parsed_result,
3339 __attribute__((unused)) struct cmdline *cl,
3340 __attribute__((unused)) void *data)
3342 struct cmd_tx_vlan_reset_result *res = parsed_result;
3344 tx_vlan_reset(res->port_id);
3347 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3348 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3349 tx_vlan, "tx_vlan");
3350 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3351 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3353 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3354 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3357 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3358 .f = cmd_tx_vlan_reset_parsed,
3360 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3361 "VLAN header in packets sent on a port",
3363 (void *)&cmd_tx_vlan_reset_tx_vlan,
3364 (void *)&cmd_tx_vlan_reset_reset,
3365 (void *)&cmd_tx_vlan_reset_portid,
3371 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3372 struct cmd_csum_result {
3373 cmdline_fixed_string_t csum;
3374 cmdline_fixed_string_t mode;
3375 cmdline_fixed_string_t proto;
3376 cmdline_fixed_string_t hwsw;
3381 csum_show(int port_id)
3383 struct rte_eth_dev_info dev_info;
3386 ol_flags = ports[port_id].tx_ol_flags;
3387 printf("Parse tunnel is %s\n",
3388 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3389 printf("IP checksum offload is %s\n",
3390 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3391 printf("UDP checksum offload is %s\n",
3392 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3393 printf("TCP checksum offload is %s\n",
3394 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3395 printf("SCTP checksum offload is %s\n",
3396 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3397 printf("Outer-Ip checksum offload is %s\n",
3398 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3400 /* display warnings if configuration is not supported by the NIC */
3401 rte_eth_dev_info_get(port_id, &dev_info);
3402 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3403 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3404 printf("Warning: hardware IP checksum enabled but not "
3405 "supported by port %d\n", port_id);
3407 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3408 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3409 printf("Warning: hardware UDP checksum enabled but not "
3410 "supported by port %d\n", port_id);
3412 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3413 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3414 printf("Warning: hardware TCP checksum enabled but not "
3415 "supported by port %d\n", port_id);
3417 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3418 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3419 printf("Warning: hardware SCTP checksum enabled but not "
3420 "supported by port %d\n", port_id);
3422 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3423 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3424 printf("Warning: hardware outer IP checksum enabled but not "
3425 "supported by port %d\n", port_id);
3430 cmd_csum_parsed(void *parsed_result,
3431 __attribute__((unused)) struct cmdline *cl,
3432 __attribute__((unused)) void *data)
3434 struct cmd_csum_result *res = parsed_result;
3438 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3439 printf("invalid port %d\n", res->port_id);
3443 if (!strcmp(res->mode, "set")) {
3445 if (!strcmp(res->hwsw, "hw"))
3448 if (!strcmp(res->proto, "ip")) {
3449 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3450 } else if (!strcmp(res->proto, "udp")) {
3451 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3452 } else if (!strcmp(res->proto, "tcp")) {
3453 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3454 } else if (!strcmp(res->proto, "sctp")) {
3455 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3456 } else if (!strcmp(res->proto, "outer-ip")) {
3457 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3461 ports[res->port_id].tx_ol_flags |= mask;
3463 ports[res->port_id].tx_ol_flags &= (~mask);
3465 csum_show(res->port_id);
3468 cmdline_parse_token_string_t cmd_csum_csum =
3469 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3471 cmdline_parse_token_string_t cmd_csum_mode =
3472 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3474 cmdline_parse_token_string_t cmd_csum_proto =
3475 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3476 proto, "ip#tcp#udp#sctp#outer-ip");
3477 cmdline_parse_token_string_t cmd_csum_hwsw =
3478 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3480 cmdline_parse_token_num_t cmd_csum_portid =
3481 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3484 cmdline_parse_inst_t cmd_csum_set = {
3485 .f = cmd_csum_parsed,
3487 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3488 "Enable/Disable hardware calculation of L3/L4 checksum when "
3489 "using csum forward engine",
3491 (void *)&cmd_csum_csum,
3492 (void *)&cmd_csum_mode,
3493 (void *)&cmd_csum_proto,
3494 (void *)&cmd_csum_hwsw,
3495 (void *)&cmd_csum_portid,
3500 cmdline_parse_token_string_t cmd_csum_mode_show =
3501 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3504 cmdline_parse_inst_t cmd_csum_show = {
3505 .f = cmd_csum_parsed,
3507 .help_str = "csum show <port_id>: Show checksum offload configuration",
3509 (void *)&cmd_csum_csum,
3510 (void *)&cmd_csum_mode_show,
3511 (void *)&cmd_csum_portid,
3516 /* Enable/disable tunnel parsing */
3517 struct cmd_csum_tunnel_result {
3518 cmdline_fixed_string_t csum;
3519 cmdline_fixed_string_t parse;
3520 cmdline_fixed_string_t onoff;
3525 cmd_csum_tunnel_parsed(void *parsed_result,
3526 __attribute__((unused)) struct cmdline *cl,
3527 __attribute__((unused)) void *data)
3529 struct cmd_csum_tunnel_result *res = parsed_result;
3531 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3534 if (!strcmp(res->onoff, "on"))
3535 ports[res->port_id].tx_ol_flags |=
3536 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3538 ports[res->port_id].tx_ol_flags &=
3539 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3541 csum_show(res->port_id);
3544 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3545 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3547 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3548 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3549 parse, "parse_tunnel");
3550 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3551 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3553 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3554 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3557 cmdline_parse_inst_t cmd_csum_tunnel = {
3558 .f = cmd_csum_tunnel_parsed,
3560 .help_str = "csum parse_tunnel on|off <port_id>: "
3561 "Enable/Disable parsing of tunnels for csum engine",
3563 (void *)&cmd_csum_tunnel_csum,
3564 (void *)&cmd_csum_tunnel_parse,
3565 (void *)&cmd_csum_tunnel_onoff,
3566 (void *)&cmd_csum_tunnel_portid,
3571 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3572 struct cmd_tso_set_result {
3573 cmdline_fixed_string_t tso;
3574 cmdline_fixed_string_t mode;
3580 cmd_tso_set_parsed(void *parsed_result,
3581 __attribute__((unused)) struct cmdline *cl,
3582 __attribute__((unused)) void *data)
3584 struct cmd_tso_set_result *res = parsed_result;
3585 struct rte_eth_dev_info dev_info;
3587 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3590 if (!strcmp(res->mode, "set"))
3591 ports[res->port_id].tso_segsz = res->tso_segsz;
3593 if (ports[res->port_id].tso_segsz == 0)
3594 printf("TSO for non-tunneled packets is disabled\n");
3596 printf("TSO segment size for non-tunneled packets is %d\n",
3597 ports[res->port_id].tso_segsz);
3599 /* display warnings if configuration is not supported by the NIC */
3600 rte_eth_dev_info_get(res->port_id, &dev_info);
3601 if ((ports[res->port_id].tso_segsz != 0) &&
3602 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3603 printf("Warning: TSO enabled but not "
3604 "supported by port %d\n", res->port_id);
3608 cmdline_parse_token_string_t cmd_tso_set_tso =
3609 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3611 cmdline_parse_token_string_t cmd_tso_set_mode =
3612 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3614 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3615 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3617 cmdline_parse_token_num_t cmd_tso_set_portid =
3618 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3621 cmdline_parse_inst_t cmd_tso_set = {
3622 .f = cmd_tso_set_parsed,
3624 .help_str = "tso set <tso_segsz> <port_id>: "
3625 "Set TSO segment size of non-tunneled packets for csum engine "
3628 (void *)&cmd_tso_set_tso,
3629 (void *)&cmd_tso_set_mode,
3630 (void *)&cmd_tso_set_tso_segsz,
3631 (void *)&cmd_tso_set_portid,
3636 cmdline_parse_token_string_t cmd_tso_show_mode =
3637 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3641 cmdline_parse_inst_t cmd_tso_show = {
3642 .f = cmd_tso_set_parsed,
3644 .help_str = "tso show <port_id>: "
3645 "Show TSO segment size of non-tunneled packets for csum engine",
3647 (void *)&cmd_tso_set_tso,
3648 (void *)&cmd_tso_show_mode,
3649 (void *)&cmd_tso_set_portid,
3654 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3655 struct cmd_tunnel_tso_set_result {
3656 cmdline_fixed_string_t tso;
3657 cmdline_fixed_string_t mode;
3663 check_tunnel_tso_nic_support(uint8_t port_id)
3665 struct rte_eth_dev_info dev_info;
3667 rte_eth_dev_info_get(port_id, &dev_info);
3668 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3669 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3670 "supported by port %d\n", port_id);
3671 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3672 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3673 "supported by port %d\n", port_id);
3674 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3675 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3676 "supported by port %d\n", port_id);
3677 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3678 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3679 "supported by port %d\n", port_id);
3683 cmd_tunnel_tso_set_parsed(void *parsed_result,
3684 __attribute__((unused)) struct cmdline *cl,
3685 __attribute__((unused)) void *data)
3687 struct cmd_tunnel_tso_set_result *res = parsed_result;
3689 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3692 if (!strcmp(res->mode, "set"))
3693 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3695 if (ports[res->port_id].tunnel_tso_segsz == 0)
3696 printf("TSO for tunneled packets is disabled\n");
3698 printf("TSO segment size for tunneled packets is %d\n",
3699 ports[res->port_id].tunnel_tso_segsz);
3701 /* Below conditions are needed to make it work:
3702 * (1) tunnel TSO is supported by the NIC;
3703 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3705 * (3) for tunneled pkts with outer L3 of IPv4,
3706 * "csum set outer-ip" must be set to hw, because after tso,
3707 * total_len of outer IP header is changed, and the checksum
3708 * of outer IP header calculated by sw should be wrong; that
3709 * is not necessary for IPv6 tunneled pkts because there's no
3710 * checksum in IP header anymore.
3712 check_tunnel_tso_nic_support(res->port_id);
3714 if (!(ports[res->port_id].tx_ol_flags &
3715 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3716 printf("Warning: csum parse_tunnel must be set "
3717 "so that tunneled packets are recognized\n");
3718 if (!(ports[res->port_id].tx_ol_flags &
3719 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3720 printf("Warning: csum set outer-ip must be set to hw "
3721 "if outer L3 is IPv4; not necessary for IPv6\n");
3725 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3726 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3728 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3729 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3731 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3732 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3734 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3735 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3738 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3739 .f = cmd_tunnel_tso_set_parsed,
3741 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3742 "Set TSO segment size of tunneled packets for csum engine "
3745 (void *)&cmd_tunnel_tso_set_tso,
3746 (void *)&cmd_tunnel_tso_set_mode,
3747 (void *)&cmd_tunnel_tso_set_tso_segsz,
3748 (void *)&cmd_tunnel_tso_set_portid,
3753 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3754 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3758 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3759 .f = cmd_tunnel_tso_set_parsed,
3761 .help_str = "tunnel_tso show <port_id> "
3762 "Show TSO segment size of tunneled packets for csum engine",
3764 (void *)&cmd_tunnel_tso_set_tso,
3765 (void *)&cmd_tunnel_tso_show_mode,
3766 (void *)&cmd_tunnel_tso_set_portid,
3771 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3772 struct cmd_set_flush_rx {
3773 cmdline_fixed_string_t set;
3774 cmdline_fixed_string_t flush_rx;
3775 cmdline_fixed_string_t mode;
3779 cmd_set_flush_rx_parsed(void *parsed_result,
3780 __attribute__((unused)) struct cmdline *cl,
3781 __attribute__((unused)) void *data)
3783 struct cmd_set_flush_rx *res = parsed_result;
3784 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3787 cmdline_parse_token_string_t cmd_setflushrx_set =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3790 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3791 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3792 flush_rx, "flush_rx");
3793 cmdline_parse_token_string_t cmd_setflushrx_mode =
3794 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3798 cmdline_parse_inst_t cmd_set_flush_rx = {
3799 .f = cmd_set_flush_rx_parsed,
3800 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3803 (void *)&cmd_setflushrx_set,
3804 (void *)&cmd_setflushrx_flush_rx,
3805 (void *)&cmd_setflushrx_mode,
3810 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3811 struct cmd_set_link_check {
3812 cmdline_fixed_string_t set;
3813 cmdline_fixed_string_t link_check;
3814 cmdline_fixed_string_t mode;
3818 cmd_set_link_check_parsed(void *parsed_result,
3819 __attribute__((unused)) struct cmdline *cl,
3820 __attribute__((unused)) void *data)
3822 struct cmd_set_link_check *res = parsed_result;
3823 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3826 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3827 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3829 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3830 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3831 link_check, "link_check");
3832 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3837 cmdline_parse_inst_t cmd_set_link_check = {
3838 .f = cmd_set_link_check_parsed,
3839 .help_str = "set link_check on|off: Enable/Disable link status check "
3840 "when starting/stopping a port",
3843 (void *)&cmd_setlinkcheck_set,
3844 (void *)&cmd_setlinkcheck_link_check,
3845 (void *)&cmd_setlinkcheck_mode,
3850 #ifdef RTE_NIC_BYPASS
3851 /* *** SET NIC BYPASS MODE *** */
3852 struct cmd_set_bypass_mode_result {
3853 cmdline_fixed_string_t set;
3854 cmdline_fixed_string_t bypass;
3855 cmdline_fixed_string_t mode;
3856 cmdline_fixed_string_t value;
3861 cmd_set_bypass_mode_parsed(void *parsed_result,
3862 __attribute__((unused)) struct cmdline *cl,
3863 __attribute__((unused)) void *data)
3865 struct cmd_set_bypass_mode_result *res = parsed_result;
3866 portid_t port_id = res->port_id;
3867 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3869 if (!strcmp(res->value, "bypass"))
3870 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3871 else if (!strcmp(res->value, "isolate"))
3872 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3874 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3876 /* Set the bypass mode for the relevant port. */
3877 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3878 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3882 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3883 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3885 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3886 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3888 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3891 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3892 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3893 value, "normal#bypass#isolate");
3894 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3895 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3898 cmdline_parse_inst_t cmd_set_bypass_mode = {
3899 .f = cmd_set_bypass_mode_parsed,
3900 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3901 "Set the NIC bypass mode for port_id",
3904 (void *)&cmd_setbypass_mode_set,
3905 (void *)&cmd_setbypass_mode_bypass,
3906 (void *)&cmd_setbypass_mode_mode,
3907 (void *)&cmd_setbypass_mode_value,
3908 (void *)&cmd_setbypass_mode_port,
3913 /* *** SET NIC BYPASS EVENT *** */
3914 struct cmd_set_bypass_event_result {
3915 cmdline_fixed_string_t set;
3916 cmdline_fixed_string_t bypass;
3917 cmdline_fixed_string_t event;
3918 cmdline_fixed_string_t event_value;
3919 cmdline_fixed_string_t mode;
3920 cmdline_fixed_string_t mode_value;
3925 cmd_set_bypass_event_parsed(void *parsed_result,
3926 __attribute__((unused)) struct cmdline *cl,
3927 __attribute__((unused)) void *data)
3930 struct cmd_set_bypass_event_result *res = parsed_result;
3931 portid_t port_id = res->port_id;
3932 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3933 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3935 if (!strcmp(res->event_value, "timeout"))
3936 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3937 else if (!strcmp(res->event_value, "os_on"))
3938 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3939 else if (!strcmp(res->event_value, "os_off"))
3940 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3941 else if (!strcmp(res->event_value, "power_on"))
3942 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3943 else if (!strcmp(res->event_value, "power_off"))
3944 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3946 bypass_event = RTE_BYPASS_EVENT_NONE;
3948 if (!strcmp(res->mode_value, "bypass"))
3949 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3950 else if (!strcmp(res->mode_value, "isolate"))
3951 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3953 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3955 /* Set the watchdog timeout. */
3956 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3959 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3960 (rc = rte_eth_dev_wd_timeout_store(port_id,
3961 bypass_timeout)) != 0) {
3962 printf("Failed to set timeout value %u "
3963 "for port %d, errto code: %d.\n",
3964 bypass_timeout, port_id, rc);
3968 /* Set the bypass event to transition to bypass mode. */
3969 if (0 != rte_eth_dev_bypass_event_store(port_id,
3970 bypass_event, bypass_mode)) {
3971 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3976 cmdline_parse_token_string_t cmd_setbypass_event_set =
3977 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3979 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3980 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3982 cmdline_parse_token_string_t cmd_setbypass_event_event =
3983 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3985 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3986 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3987 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3988 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3989 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3991 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3992 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3993 mode_value, "normal#bypass#isolate");
3994 cmdline_parse_token_num_t cmd_setbypass_event_port =
3995 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3998 cmdline_parse_inst_t cmd_set_bypass_event = {
3999 .f = cmd_set_bypass_event_parsed,
4000 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4001 "power_off mode normal|bypass|isolate <port_id>: "
4002 "Set the NIC bypass event mode for port_id",
4005 (void *)&cmd_setbypass_event_set,
4006 (void *)&cmd_setbypass_event_bypass,
4007 (void *)&cmd_setbypass_event_event,
4008 (void *)&cmd_setbypass_event_event_value,
4009 (void *)&cmd_setbypass_event_mode,
4010 (void *)&cmd_setbypass_event_mode_value,
4011 (void *)&cmd_setbypass_event_port,
4017 /* *** SET NIC BYPASS TIMEOUT *** */
4018 struct cmd_set_bypass_timeout_result {
4019 cmdline_fixed_string_t set;
4020 cmdline_fixed_string_t bypass;
4021 cmdline_fixed_string_t timeout;
4022 cmdline_fixed_string_t value;
4026 cmd_set_bypass_timeout_parsed(void *parsed_result,
4027 __attribute__((unused)) struct cmdline *cl,
4028 __attribute__((unused)) void *data)
4030 struct cmd_set_bypass_timeout_result *res = parsed_result;
4032 if (!strcmp(res->value, "1.5"))
4033 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4034 else if (!strcmp(res->value, "2"))
4035 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4036 else if (!strcmp(res->value, "3"))
4037 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4038 else if (!strcmp(res->value, "4"))
4039 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4040 else if (!strcmp(res->value, "8"))
4041 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4042 else if (!strcmp(res->value, "16"))
4043 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4044 else if (!strcmp(res->value, "32"))
4045 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4047 bypass_timeout = RTE_BYPASS_TMT_OFF;
4050 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4053 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4056 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4058 timeout, "timeout");
4059 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4060 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4061 value, "0#1.5#2#3#4#8#16#32");
4063 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4064 .f = cmd_set_bypass_timeout_parsed,
4065 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4066 "Set the NIC bypass watchdog timeout in seconds",
4069 (void *)&cmd_setbypass_timeout_set,
4070 (void *)&cmd_setbypass_timeout_bypass,
4071 (void *)&cmd_setbypass_timeout_timeout,
4072 (void *)&cmd_setbypass_timeout_value,
4077 /* *** SHOW NIC BYPASS MODE *** */
4078 struct cmd_show_bypass_config_result {
4079 cmdline_fixed_string_t show;
4080 cmdline_fixed_string_t bypass;
4081 cmdline_fixed_string_t config;
4086 cmd_show_bypass_config_parsed(void *parsed_result,
4087 __attribute__((unused)) struct cmdline *cl,
4088 __attribute__((unused)) void *data)
4090 struct cmd_show_bypass_config_result *res = parsed_result;
4091 uint32_t event_mode;
4092 uint32_t bypass_mode;
4093 portid_t port_id = res->port_id;
4094 uint32_t timeout = bypass_timeout;
4097 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4098 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4099 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4100 {"UNKNOWN", "normal", "bypass", "isolate"};
4101 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4108 int num_events = (sizeof events) / (sizeof events[0]);
4110 /* Display the bypass mode.*/
4111 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4112 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4116 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4117 bypass_mode = RTE_BYPASS_MODE_NONE;
4119 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4122 /* Display the bypass timeout.*/
4123 if (!RTE_BYPASS_TMT_VALID(timeout))
4124 timeout = RTE_BYPASS_TMT_OFF;
4126 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4128 /* Display the bypass events and associated modes. */
4129 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4131 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4132 printf("\tFailed to get bypass mode for event = %s\n",
4135 if (!RTE_BYPASS_MODE_VALID(event_mode))
4136 event_mode = RTE_BYPASS_MODE_NONE;
4138 printf("\tbypass event: %-16s = %s\n", events[i],
4144 cmdline_parse_token_string_t cmd_showbypass_config_show =
4145 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4147 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4148 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4150 cmdline_parse_token_string_t cmd_showbypass_config_config =
4151 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4153 cmdline_parse_token_num_t cmd_showbypass_config_port =
4154 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4157 cmdline_parse_inst_t cmd_show_bypass_config = {
4158 .f = cmd_show_bypass_config_parsed,
4159 .help_str = "show bypass config <port_id>: "
4160 "Show the NIC bypass config for port_id",
4163 (void *)&cmd_showbypass_config_show,
4164 (void *)&cmd_showbypass_config_bypass,
4165 (void *)&cmd_showbypass_config_config,
4166 (void *)&cmd_showbypass_config_port,
4172 #ifdef RTE_LIBRTE_PMD_BOND
4173 /* *** SET BONDING MODE *** */
4174 struct cmd_set_bonding_mode_result {
4175 cmdline_fixed_string_t set;
4176 cmdline_fixed_string_t bonding;
4177 cmdline_fixed_string_t mode;
4182 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4183 __attribute__((unused)) struct cmdline *cl,
4184 __attribute__((unused)) void *data)
4186 struct cmd_set_bonding_mode_result *res = parsed_result;
4187 portid_t port_id = res->port_id;
4189 /* Set the bonding mode for the relevant port. */
4190 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4191 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4194 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4195 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4197 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4198 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4199 bonding, "bonding");
4200 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4201 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4203 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4204 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4206 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4207 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4210 cmdline_parse_inst_t cmd_set_bonding_mode = {
4211 .f = cmd_set_bonding_mode_parsed,
4212 .help_str = "set bonding mode <mode_value> <port_id>: "
4213 "Set the bonding mode for port_id",
4216 (void *) &cmd_setbonding_mode_set,
4217 (void *) &cmd_setbonding_mode_bonding,
4218 (void *) &cmd_setbonding_mode_mode,
4219 (void *) &cmd_setbonding_mode_value,
4220 (void *) &cmd_setbonding_mode_port,
4225 /* *** SET BALANCE XMIT POLICY *** */
4226 struct cmd_set_bonding_balance_xmit_policy_result {
4227 cmdline_fixed_string_t set;
4228 cmdline_fixed_string_t bonding;
4229 cmdline_fixed_string_t balance_xmit_policy;
4231 cmdline_fixed_string_t policy;
4234 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4235 __attribute__((unused)) struct cmdline *cl,
4236 __attribute__((unused)) void *data)
4238 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4239 portid_t port_id = res->port_id;
4242 if (!strcmp(res->policy, "l2")) {
4243 policy = BALANCE_XMIT_POLICY_LAYER2;
4244 } else if (!strcmp(res->policy, "l23")) {
4245 policy = BALANCE_XMIT_POLICY_LAYER23;
4246 } else if (!strcmp(res->policy, "l34")) {
4247 policy = BALANCE_XMIT_POLICY_LAYER34;
4249 printf("\t Invalid xmit policy selection");
4253 /* Set the bonding mode for the relevant port. */
4254 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4255 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4260 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4261 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4263 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4264 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4265 bonding, "bonding");
4266 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4267 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4268 balance_xmit_policy, "balance_xmit_policy");
4269 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4270 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4272 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4273 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4274 policy, "l2#l23#l34");
4276 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4277 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4278 .help_str = "set bonding balance_xmit_policy <port_id> "
4280 "Set the bonding balance_xmit_policy for port_id",
4283 (void *)&cmd_setbonding_balance_xmit_policy_set,
4284 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4285 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4286 (void *)&cmd_setbonding_balance_xmit_policy_port,
4287 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4292 /* *** SHOW NIC BONDING CONFIGURATION *** */
4293 struct cmd_show_bonding_config_result {
4294 cmdline_fixed_string_t show;
4295 cmdline_fixed_string_t bonding;
4296 cmdline_fixed_string_t config;
4300 static void cmd_show_bonding_config_parsed(void *parsed_result,
4301 __attribute__((unused)) struct cmdline *cl,
4302 __attribute__((unused)) void *data)
4304 struct cmd_show_bonding_config_result *res = parsed_result;
4306 uint8_t slaves[RTE_MAX_ETHPORTS];
4307 int num_slaves, num_active_slaves;
4310 portid_t port_id = res->port_id;
4312 /* Display the bonding mode.*/
4313 bonding_mode = rte_eth_bond_mode_get(port_id);
4314 if (bonding_mode < 0) {
4315 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4318 printf("\tBonding mode: %d\n", bonding_mode);
4320 if (bonding_mode == BONDING_MODE_BALANCE) {
4321 int balance_xmit_policy;
4323 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4324 if (balance_xmit_policy < 0) {
4325 printf("\tFailed to get balance xmit policy for port = %d\n",
4329 printf("\tBalance Xmit Policy: ");
4331 switch (balance_xmit_policy) {
4332 case BALANCE_XMIT_POLICY_LAYER2:
4333 printf("BALANCE_XMIT_POLICY_LAYER2");
4335 case BALANCE_XMIT_POLICY_LAYER23:
4336 printf("BALANCE_XMIT_POLICY_LAYER23");
4338 case BALANCE_XMIT_POLICY_LAYER34:
4339 printf("BALANCE_XMIT_POLICY_LAYER34");
4346 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4348 if (num_slaves < 0) {
4349 printf("\tFailed to get slave list for port = %d\n", port_id);
4352 if (num_slaves > 0) {
4353 printf("\tSlaves (%d): [", num_slaves);
4354 for (i = 0; i < num_slaves - 1; i++)
4355 printf("%d ", slaves[i]);
4357 printf("%d]\n", slaves[num_slaves - 1]);
4359 printf("\tSlaves: []\n");
4363 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4366 if (num_active_slaves < 0) {
4367 printf("\tFailed to get active slave list for port = %d\n", port_id);
4370 if (num_active_slaves > 0) {
4371 printf("\tActive Slaves (%d): [", num_active_slaves);
4372 for (i = 0; i < num_active_slaves - 1; i++)
4373 printf("%d ", slaves[i]);
4375 printf("%d]\n", slaves[num_active_slaves - 1]);
4378 printf("\tActive Slaves: []\n");
4382 primary_id = rte_eth_bond_primary_get(port_id);
4383 if (primary_id < 0) {
4384 printf("\tFailed to get primary slave for port = %d\n", port_id);
4387 printf("\tPrimary: [%d]\n", primary_id);
4391 cmdline_parse_token_string_t cmd_showbonding_config_show =
4392 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4394 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4395 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4396 bonding, "bonding");
4397 cmdline_parse_token_string_t cmd_showbonding_config_config =
4398 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4400 cmdline_parse_token_num_t cmd_showbonding_config_port =
4401 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4404 cmdline_parse_inst_t cmd_show_bonding_config = {
4405 .f = cmd_show_bonding_config_parsed,
4406 .help_str = "show bonding config <port_id>: "
4407 "Show the bonding config for port_id",
4410 (void *)&cmd_showbonding_config_show,
4411 (void *)&cmd_showbonding_config_bonding,
4412 (void *)&cmd_showbonding_config_config,
4413 (void *)&cmd_showbonding_config_port,
4418 /* *** SET BONDING PRIMARY *** */
4419 struct cmd_set_bonding_primary_result {
4420 cmdline_fixed_string_t set;
4421 cmdline_fixed_string_t bonding;
4422 cmdline_fixed_string_t primary;
4427 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4428 __attribute__((unused)) struct cmdline *cl,
4429 __attribute__((unused)) void *data)
4431 struct cmd_set_bonding_primary_result *res = parsed_result;
4432 portid_t master_port_id = res->port_id;
4433 portid_t slave_port_id = res->slave_id;
4435 /* Set the primary slave for a bonded device. */
4436 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4437 printf("\t Failed to set primary slave for port = %d.\n",
4444 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4445 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4447 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4448 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4449 bonding, "bonding");
4450 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4451 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4452 primary, "primary");
4453 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4454 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4456 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4457 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4460 cmdline_parse_inst_t cmd_set_bonding_primary = {
4461 .f = cmd_set_bonding_primary_parsed,
4462 .help_str = "set bonding primary <slave_id> <port_id>: "
4463 "Set the primary slave for port_id",
4466 (void *)&cmd_setbonding_primary_set,
4467 (void *)&cmd_setbonding_primary_bonding,
4468 (void *)&cmd_setbonding_primary_primary,
4469 (void *)&cmd_setbonding_primary_slave,
4470 (void *)&cmd_setbonding_primary_port,
4475 /* *** ADD SLAVE *** */
4476 struct cmd_add_bonding_slave_result {
4477 cmdline_fixed_string_t add;
4478 cmdline_fixed_string_t bonding;
4479 cmdline_fixed_string_t slave;
4484 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4485 __attribute__((unused)) struct cmdline *cl,
4486 __attribute__((unused)) void *data)
4488 struct cmd_add_bonding_slave_result *res = parsed_result;
4489 portid_t master_port_id = res->port_id;
4490 portid_t slave_port_id = res->slave_id;
4492 /* Set the primary slave for a bonded device. */
4493 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4494 printf("\t Failed to add slave %d to master port = %d.\n",
4495 slave_port_id, master_port_id);
4499 set_port_slave_flag(slave_port_id);
4502 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4503 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4505 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4506 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4507 bonding, "bonding");
4508 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4509 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4511 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4512 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4514 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4515 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4518 cmdline_parse_inst_t cmd_add_bonding_slave = {
4519 .f = cmd_add_bonding_slave_parsed,
4520 .help_str = "add bonding slave <slave_id> <port_id>: "
4521 "Add a slave device to a bonded device",
4524 (void *)&cmd_addbonding_slave_add,
4525 (void *)&cmd_addbonding_slave_bonding,
4526 (void *)&cmd_addbonding_slave_slave,
4527 (void *)&cmd_addbonding_slave_slaveid,
4528 (void *)&cmd_addbonding_slave_port,
4533 /* *** REMOVE SLAVE *** */
4534 struct cmd_remove_bonding_slave_result {
4535 cmdline_fixed_string_t remove;
4536 cmdline_fixed_string_t bonding;
4537 cmdline_fixed_string_t slave;
4542 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4543 __attribute__((unused)) struct cmdline *cl,
4544 __attribute__((unused)) void *data)
4546 struct cmd_remove_bonding_slave_result *res = parsed_result;
4547 portid_t master_port_id = res->port_id;
4548 portid_t slave_port_id = res->slave_id;
4550 /* Set the primary slave for a bonded device. */
4551 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4552 printf("\t Failed to remove slave %d from master port = %d.\n",
4553 slave_port_id, master_port_id);
4557 clear_port_slave_flag(slave_port_id);
4560 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4561 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4563 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4564 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4565 bonding, "bonding");
4566 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4567 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4569 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4570 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4572 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4573 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4576 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4577 .f = cmd_remove_bonding_slave_parsed,
4578 .help_str = "remove bonding slave <slave_id> <port_id>: "
4579 "Remove a slave device from a bonded device",
4582 (void *)&cmd_removebonding_slave_remove,
4583 (void *)&cmd_removebonding_slave_bonding,
4584 (void *)&cmd_removebonding_slave_slave,
4585 (void *)&cmd_removebonding_slave_slaveid,
4586 (void *)&cmd_removebonding_slave_port,
4591 /* *** CREATE BONDED DEVICE *** */
4592 struct cmd_create_bonded_device_result {
4593 cmdline_fixed_string_t create;
4594 cmdline_fixed_string_t bonded;
4595 cmdline_fixed_string_t device;
4600 static int bond_dev_num = 0;
4602 static void cmd_create_bonded_device_parsed(void *parsed_result,
4603 __attribute__((unused)) struct cmdline *cl,
4604 __attribute__((unused)) void *data)
4606 struct cmd_create_bonded_device_result *res = parsed_result;
4607 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4610 if (test_done == 0) {
4611 printf("Please stop forwarding first\n");
4615 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4618 /* Create a new bonded device. */
4619 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4621 printf("\t Failed to create bonded device.\n");
4624 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4627 /* Update number of ports */
4628 nb_ports = rte_eth_dev_count();
4629 reconfig(port_id, res->socket);
4630 rte_eth_promiscuous_enable(port_id);
4631 ports[port_id].enabled = 1;
4636 cmdline_parse_token_string_t cmd_createbonded_device_create =
4637 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4639 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4640 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4642 cmdline_parse_token_string_t cmd_createbonded_device_device =
4643 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4645 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4646 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4648 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4649 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4652 cmdline_parse_inst_t cmd_create_bonded_device = {
4653 .f = cmd_create_bonded_device_parsed,
4654 .help_str = "create bonded device <mode> <socket>: "
4655 "Create a new bonded device with specific bonding mode and socket",
4658 (void *)&cmd_createbonded_device_create,
4659 (void *)&cmd_createbonded_device_bonded,
4660 (void *)&cmd_createbonded_device_device,
4661 (void *)&cmd_createbonded_device_mode,
4662 (void *)&cmd_createbonded_device_socket,
4667 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4668 struct cmd_set_bond_mac_addr_result {
4669 cmdline_fixed_string_t set;
4670 cmdline_fixed_string_t bonding;
4671 cmdline_fixed_string_t mac_addr;
4673 struct ether_addr address;
4676 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4677 __attribute__((unused)) struct cmdline *cl,
4678 __attribute__((unused)) void *data)
4680 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4683 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4686 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4688 /* check the return value and print it if is < 0 */
4690 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4693 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4694 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4695 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4696 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4698 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4699 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4701 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4702 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4703 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4704 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4706 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4707 .f = cmd_set_bond_mac_addr_parsed,
4709 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4711 (void *)&cmd_set_bond_mac_addr_set,
4712 (void *)&cmd_set_bond_mac_addr_bonding,
4713 (void *)&cmd_set_bond_mac_addr_mac,
4714 (void *)&cmd_set_bond_mac_addr_portnum,
4715 (void *)&cmd_set_bond_mac_addr_addr,
4721 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4722 struct cmd_set_bond_mon_period_result {
4723 cmdline_fixed_string_t set;
4724 cmdline_fixed_string_t bonding;
4725 cmdline_fixed_string_t mon_period;
4730 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4731 __attribute__((unused)) struct cmdline *cl,
4732 __attribute__((unused)) void *data)
4734 struct cmd_set_bond_mon_period_result *res = parsed_result;
4737 if (res->port_num >= nb_ports) {
4738 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4742 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4744 /* check the return value and print it if is < 0 */
4746 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4749 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4750 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4752 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4753 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4754 bonding, "bonding");
4755 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4756 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4757 mon_period, "mon_period");
4758 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4759 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4761 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4762 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4765 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4766 .f = cmd_set_bond_mon_period_parsed,
4768 .help_str = "set bonding mon_period <port_id> <period_ms>",
4770 (void *)&cmd_set_bond_mon_period_set,
4771 (void *)&cmd_set_bond_mon_period_bonding,
4772 (void *)&cmd_set_bond_mon_period_mon_period,
4773 (void *)&cmd_set_bond_mon_period_portnum,
4774 (void *)&cmd_set_bond_mon_period_period_ms,
4779 #endif /* RTE_LIBRTE_PMD_BOND */
4781 /* *** SET FORWARDING MODE *** */
4782 struct cmd_set_fwd_mode_result {
4783 cmdline_fixed_string_t set;
4784 cmdline_fixed_string_t fwd;
4785 cmdline_fixed_string_t mode;
4788 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4789 __attribute__((unused)) struct cmdline *cl,
4790 __attribute__((unused)) void *data)
4792 struct cmd_set_fwd_mode_result *res = parsed_result;
4795 set_pkt_forwarding_mode(res->mode);
4798 cmdline_parse_token_string_t cmd_setfwd_set =
4799 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4800 cmdline_parse_token_string_t cmd_setfwd_fwd =
4801 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4802 cmdline_parse_token_string_t cmd_setfwd_mode =
4803 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4804 "" /* defined at init */);
4806 cmdline_parse_inst_t cmd_set_fwd_mode = {
4807 .f = cmd_set_fwd_mode_parsed,
4809 .help_str = NULL, /* defined at init */
4811 (void *)&cmd_setfwd_set,
4812 (void *)&cmd_setfwd_fwd,
4813 (void *)&cmd_setfwd_mode,
4818 static void cmd_set_fwd_mode_init(void)
4821 static char token[128];
4822 static char help[256];
4823 cmdline_parse_token_string_t *token_struct;
4825 modes = list_pkt_forwarding_modes();
4826 snprintf(help, sizeof(help), "set fwd %s: "
4827 "Set packet forwarding mode", modes);
4828 cmd_set_fwd_mode.help_str = help;
4830 /* string token separator is # */
4831 for (c = token; *modes != '\0'; modes++)
4836 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4837 token_struct->string_data.str = token;
4840 /* *** SET RETRY FORWARDING MODE *** */
4841 struct cmd_set_fwd_retry_mode_result {
4842 cmdline_fixed_string_t set;
4843 cmdline_fixed_string_t fwd;
4844 cmdline_fixed_string_t mode;
4845 cmdline_fixed_string_t retry;
4848 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4849 __attribute__((unused)) struct cmdline *cl,
4850 __attribute__((unused)) void *data)
4852 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4855 set_pkt_forwarding_mode(res->mode);
4858 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4859 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4861 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4862 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4864 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4865 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4867 "" /* defined at init */);
4868 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4869 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4872 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4873 .f = cmd_set_fwd_retry_mode_parsed,
4875 .help_str = NULL, /* defined at init */
4877 (void *)&cmd_setfwd_retry_set,
4878 (void *)&cmd_setfwd_retry_fwd,
4879 (void *)&cmd_setfwd_retry_mode,
4880 (void *)&cmd_setfwd_retry_retry,
4885 static void cmd_set_fwd_retry_mode_init(void)
4888 static char token[128];
4889 static char help[256];
4890 cmdline_parse_token_string_t *token_struct;
4892 modes = list_pkt_forwarding_retry_modes();
4893 snprintf(help, sizeof(help), "set fwd %s retry: "
4894 "Set packet forwarding mode with retry", modes);
4895 cmd_set_fwd_retry_mode.help_str = help;
4897 /* string token separator is # */
4898 for (c = token; *modes != '\0'; modes++)
4903 token_struct = (cmdline_parse_token_string_t *)
4904 cmd_set_fwd_retry_mode.tokens[2];
4905 token_struct->string_data.str = token;
4908 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4909 struct cmd_set_burst_tx_retry_result {
4910 cmdline_fixed_string_t set;
4911 cmdline_fixed_string_t burst;
4912 cmdline_fixed_string_t tx;
4913 cmdline_fixed_string_t delay;
4915 cmdline_fixed_string_t retry;
4919 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4920 __attribute__((unused)) struct cmdline *cl,
4921 __attribute__((unused)) void *data)
4923 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4925 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4926 && !strcmp(res->tx, "tx")) {
4927 if (!strcmp(res->delay, "delay"))
4928 burst_tx_delay_time = res->time;
4929 if (!strcmp(res->retry, "retry"))
4930 burst_tx_retry_num = res->retry_num;
4935 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4936 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4937 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4938 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4940 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4941 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4942 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4944 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4945 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4946 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4947 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4948 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4949 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4951 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4952 .f = cmd_set_burst_tx_retry_parsed,
4953 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4955 (void *)&cmd_set_burst_tx_retry_set,
4956 (void *)&cmd_set_burst_tx_retry_burst,
4957 (void *)&cmd_set_burst_tx_retry_tx,
4958 (void *)&cmd_set_burst_tx_retry_delay,
4959 (void *)&cmd_set_burst_tx_retry_time,
4960 (void *)&cmd_set_burst_tx_retry_retry,
4961 (void *)&cmd_set_burst_tx_retry_retry_num,
4966 /* *** SET PROMISC MODE *** */
4967 struct cmd_set_promisc_mode_result {
4968 cmdline_fixed_string_t set;
4969 cmdline_fixed_string_t promisc;
4970 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4971 uint8_t port_num; /* valid if "allports" argument == 0 */
4972 cmdline_fixed_string_t mode;
4975 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4976 __attribute__((unused)) struct cmdline *cl,
4979 struct cmd_set_promisc_mode_result *res = parsed_result;
4983 if (!strcmp(res->mode, "on"))
4990 FOREACH_PORT(i, ports) {
4992 rte_eth_promiscuous_enable(i);
4994 rte_eth_promiscuous_disable(i);
4999 rte_eth_promiscuous_enable(res->port_num);
5001 rte_eth_promiscuous_disable(res->port_num);
5005 cmdline_parse_token_string_t cmd_setpromisc_set =
5006 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5007 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5008 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5010 cmdline_parse_token_string_t cmd_setpromisc_portall =
5011 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5013 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5014 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5016 cmdline_parse_token_string_t cmd_setpromisc_mode =
5017 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5020 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5021 .f = cmd_set_promisc_mode_parsed,
5023 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5025 (void *)&cmd_setpromisc_set,
5026 (void *)&cmd_setpromisc_promisc,
5027 (void *)&cmd_setpromisc_portall,
5028 (void *)&cmd_setpromisc_mode,
5033 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5034 .f = cmd_set_promisc_mode_parsed,
5036 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5038 (void *)&cmd_setpromisc_set,
5039 (void *)&cmd_setpromisc_promisc,
5040 (void *)&cmd_setpromisc_portnum,
5041 (void *)&cmd_setpromisc_mode,
5046 /* *** SET ALLMULTI MODE *** */
5047 struct cmd_set_allmulti_mode_result {
5048 cmdline_fixed_string_t set;
5049 cmdline_fixed_string_t allmulti;
5050 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5051 uint8_t port_num; /* valid if "allports" argument == 0 */
5052 cmdline_fixed_string_t mode;
5055 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5056 __attribute__((unused)) struct cmdline *cl,
5059 struct cmd_set_allmulti_mode_result *res = parsed_result;
5063 if (!strcmp(res->mode, "on"))
5070 FOREACH_PORT(i, ports) {
5072 rte_eth_allmulticast_enable(i);
5074 rte_eth_allmulticast_disable(i);
5079 rte_eth_allmulticast_enable(res->port_num);
5081 rte_eth_allmulticast_disable(res->port_num);
5085 cmdline_parse_token_string_t cmd_setallmulti_set =
5086 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5087 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5088 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5090 cmdline_parse_token_string_t cmd_setallmulti_portall =
5091 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5093 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5094 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5096 cmdline_parse_token_string_t cmd_setallmulti_mode =
5097 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5100 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5101 .f = cmd_set_allmulti_mode_parsed,
5103 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5105 (void *)&cmd_setallmulti_set,
5106 (void *)&cmd_setallmulti_allmulti,
5107 (void *)&cmd_setallmulti_portall,
5108 (void *)&cmd_setallmulti_mode,
5113 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5114 .f = cmd_set_allmulti_mode_parsed,
5116 .help_str = "set allmulti <port_id> on|off: "
5117 "Set allmulti mode on port_id",
5119 (void *)&cmd_setallmulti_set,
5120 (void *)&cmd_setallmulti_allmulti,
5121 (void *)&cmd_setallmulti_portnum,
5122 (void *)&cmd_setallmulti_mode,
5127 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5128 struct cmd_link_flow_ctrl_set_result {
5129 cmdline_fixed_string_t set;
5130 cmdline_fixed_string_t flow_ctrl;
5131 cmdline_fixed_string_t rx;
5132 cmdline_fixed_string_t rx_lfc_mode;
5133 cmdline_fixed_string_t tx;
5134 cmdline_fixed_string_t tx_lfc_mode;
5135 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5136 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5137 cmdline_fixed_string_t autoneg_str;
5138 cmdline_fixed_string_t autoneg;
5139 cmdline_fixed_string_t hw_str;
5140 uint32_t high_water;
5141 cmdline_fixed_string_t lw_str;
5143 cmdline_fixed_string_t pt_str;
5144 uint16_t pause_time;
5145 cmdline_fixed_string_t xon_str;
5150 cmdline_parse_token_string_t cmd_lfc_set_set =
5151 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5153 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5154 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5155 flow_ctrl, "flow_ctrl");
5156 cmdline_parse_token_string_t cmd_lfc_set_rx =
5157 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5159 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5160 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5161 rx_lfc_mode, "on#off");
5162 cmdline_parse_token_string_t cmd_lfc_set_tx =
5163 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5165 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5166 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5167 tx_lfc_mode, "on#off");
5168 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5169 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5170 hw_str, "high_water");
5171 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5172 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5173 high_water, UINT32);
5174 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5175 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5176 lw_str, "low_water");
5177 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5178 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5180 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5181 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5182 pt_str, "pause_time");
5183 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5184 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5185 pause_time, UINT16);
5186 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5187 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5188 xon_str, "send_xon");
5189 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5190 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5193 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5194 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5195 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5196 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5197 mac_ctrl_frame_fwd_mode, "on#off");
5198 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5199 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5200 autoneg_str, "autoneg");
5201 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5202 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 cmdline_parse_token_num_t cmd_lfc_set_portid =
5205 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5208 /* forward declaration */
5210 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5213 cmdline_parse_inst_t cmd_link_flow_control_set = {
5214 .f = cmd_link_flow_ctrl_set_parsed,
5216 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5217 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5218 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5220 (void *)&cmd_lfc_set_set,
5221 (void *)&cmd_lfc_set_flow_ctrl,
5222 (void *)&cmd_lfc_set_rx,
5223 (void *)&cmd_lfc_set_rx_mode,
5224 (void *)&cmd_lfc_set_tx,
5225 (void *)&cmd_lfc_set_tx_mode,
5226 (void *)&cmd_lfc_set_high_water,
5227 (void *)&cmd_lfc_set_low_water,
5228 (void *)&cmd_lfc_set_pause_time,
5229 (void *)&cmd_lfc_set_send_xon,
5230 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5231 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5232 (void *)&cmd_lfc_set_autoneg_str,
5233 (void *)&cmd_lfc_set_autoneg,
5234 (void *)&cmd_lfc_set_portid,
5239 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5240 .f = cmd_link_flow_ctrl_set_parsed,
5241 .data = (void *)&cmd_link_flow_control_set_rx,
5242 .help_str = "set flow_ctrl rx on|off <port_id>: "
5243 "Change rx flow control parameter",
5245 (void *)&cmd_lfc_set_set,
5246 (void *)&cmd_lfc_set_flow_ctrl,
5247 (void *)&cmd_lfc_set_rx,
5248 (void *)&cmd_lfc_set_rx_mode,
5249 (void *)&cmd_lfc_set_portid,
5254 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5255 .f = cmd_link_flow_ctrl_set_parsed,
5256 .data = (void *)&cmd_link_flow_control_set_tx,
5257 .help_str = "set flow_ctrl tx on|off <port_id>: "
5258 "Change tx flow control parameter",
5260 (void *)&cmd_lfc_set_set,
5261 (void *)&cmd_lfc_set_flow_ctrl,
5262 (void *)&cmd_lfc_set_tx,
5263 (void *)&cmd_lfc_set_tx_mode,
5264 (void *)&cmd_lfc_set_portid,
5269 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5270 .f = cmd_link_flow_ctrl_set_parsed,
5271 .data = (void *)&cmd_link_flow_control_set_hw,
5272 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5273 "Change high water flow control parameter",
5275 (void *)&cmd_lfc_set_set,
5276 (void *)&cmd_lfc_set_flow_ctrl,
5277 (void *)&cmd_lfc_set_high_water_str,
5278 (void *)&cmd_lfc_set_high_water,
5279 (void *)&cmd_lfc_set_portid,
5284 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5285 .f = cmd_link_flow_ctrl_set_parsed,
5286 .data = (void *)&cmd_link_flow_control_set_lw,
5287 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5288 "Change low water flow control parameter",
5290 (void *)&cmd_lfc_set_set,
5291 (void *)&cmd_lfc_set_flow_ctrl,
5292 (void *)&cmd_lfc_set_low_water_str,
5293 (void *)&cmd_lfc_set_low_water,
5294 (void *)&cmd_lfc_set_portid,
5299 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5300 .f = cmd_link_flow_ctrl_set_parsed,
5301 .data = (void *)&cmd_link_flow_control_set_pt,
5302 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5303 "Change pause time flow control parameter",
5305 (void *)&cmd_lfc_set_set,
5306 (void *)&cmd_lfc_set_flow_ctrl,
5307 (void *)&cmd_lfc_set_pause_time_str,
5308 (void *)&cmd_lfc_set_pause_time,
5309 (void *)&cmd_lfc_set_portid,
5314 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5315 .f = cmd_link_flow_ctrl_set_parsed,
5316 .data = (void *)&cmd_link_flow_control_set_xon,
5317 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5318 "Change send_xon flow control parameter",
5320 (void *)&cmd_lfc_set_set,
5321 (void *)&cmd_lfc_set_flow_ctrl,
5322 (void *)&cmd_lfc_set_send_xon_str,
5323 (void *)&cmd_lfc_set_send_xon,
5324 (void *)&cmd_lfc_set_portid,
5329 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5330 .f = cmd_link_flow_ctrl_set_parsed,
5331 .data = (void *)&cmd_link_flow_control_set_macfwd,
5332 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5333 "Change mac ctrl fwd flow control parameter",
5335 (void *)&cmd_lfc_set_set,
5336 (void *)&cmd_lfc_set_flow_ctrl,
5337 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5338 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5339 (void *)&cmd_lfc_set_portid,
5344 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5345 .f = cmd_link_flow_ctrl_set_parsed,
5346 .data = (void *)&cmd_link_flow_control_set_autoneg,
5347 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5348 "Change autoneg flow control parameter",
5350 (void *)&cmd_lfc_set_set,
5351 (void *)&cmd_lfc_set_flow_ctrl,
5352 (void *)&cmd_lfc_set_autoneg_str,
5353 (void *)&cmd_lfc_set_autoneg,
5354 (void *)&cmd_lfc_set_portid,
5360 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5361 __attribute__((unused)) struct cmdline *cl,
5364 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5365 cmdline_parse_inst_t *cmd = data;
5366 struct rte_eth_fc_conf fc_conf;
5372 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5373 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5374 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5375 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5377 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5378 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5381 /* Partial command line, retrieve current configuration */
5383 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5385 printf("cannot get current flow ctrl parameters, return"
5386 "code = %d\n", ret);
5390 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5391 (fc_conf.mode == RTE_FC_FULL))
5393 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5394 (fc_conf.mode == RTE_FC_FULL))
5398 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5399 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5401 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5402 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5404 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5406 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5407 fc_conf.high_water = res->high_water;
5409 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5410 fc_conf.low_water = res->low_water;
5412 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5413 fc_conf.pause_time = res->pause_time;
5415 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5416 fc_conf.send_xon = res->send_xon;
5418 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5419 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5420 fc_conf.mac_ctrl_frame_fwd = 1;
5422 fc_conf.mac_ctrl_frame_fwd = 0;
5425 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5426 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5428 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5430 printf("bad flow contrl parameter, return code = %d \n", ret);
5433 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5434 struct cmd_priority_flow_ctrl_set_result {
5435 cmdline_fixed_string_t set;
5436 cmdline_fixed_string_t pfc_ctrl;
5437 cmdline_fixed_string_t rx;
5438 cmdline_fixed_string_t rx_pfc_mode;
5439 cmdline_fixed_string_t tx;
5440 cmdline_fixed_string_t tx_pfc_mode;
5441 uint32_t high_water;
5443 uint16_t pause_time;
5449 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5450 __attribute__((unused)) struct cmdline *cl,
5451 __attribute__((unused)) void *data)
5453 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5454 struct rte_eth_pfc_conf pfc_conf;
5455 int rx_fc_enable, tx_fc_enable;
5459 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5460 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5461 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5462 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5464 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5465 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5468 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5469 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5470 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5471 pfc_conf.fc.high_water = res->high_water;
5472 pfc_conf.fc.low_water = res->low_water;
5473 pfc_conf.fc.pause_time = res->pause_time;
5474 pfc_conf.priority = res->priority;
5476 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5478 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5481 cmdline_parse_token_string_t cmd_pfc_set_set =
5482 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5484 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5485 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5486 pfc_ctrl, "pfc_ctrl");
5487 cmdline_parse_token_string_t cmd_pfc_set_rx =
5488 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5490 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5491 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5492 rx_pfc_mode, "on#off");
5493 cmdline_parse_token_string_t cmd_pfc_set_tx =
5494 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5496 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5497 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5498 tx_pfc_mode, "on#off");
5499 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5500 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5501 high_water, UINT32);
5502 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5503 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5505 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5506 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5507 pause_time, UINT16);
5508 cmdline_parse_token_num_t cmd_pfc_set_priority =
5509 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5511 cmdline_parse_token_num_t cmd_pfc_set_portid =
5512 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5515 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5516 .f = cmd_priority_flow_ctrl_set_parsed,
5518 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5519 "<pause_time> <priority> <port_id>: "
5520 "Configure the Ethernet priority flow control",
5522 (void *)&cmd_pfc_set_set,
5523 (void *)&cmd_pfc_set_flow_ctrl,
5524 (void *)&cmd_pfc_set_rx,
5525 (void *)&cmd_pfc_set_rx_mode,
5526 (void *)&cmd_pfc_set_tx,
5527 (void *)&cmd_pfc_set_tx_mode,
5528 (void *)&cmd_pfc_set_high_water,
5529 (void *)&cmd_pfc_set_low_water,
5530 (void *)&cmd_pfc_set_pause_time,
5531 (void *)&cmd_pfc_set_priority,
5532 (void *)&cmd_pfc_set_portid,
5537 /* *** RESET CONFIGURATION *** */
5538 struct cmd_reset_result {
5539 cmdline_fixed_string_t reset;
5540 cmdline_fixed_string_t def;
5543 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5545 __attribute__((unused)) void *data)
5547 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5548 set_def_fwd_config();
5551 cmdline_parse_token_string_t cmd_reset_set =
5552 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5553 cmdline_parse_token_string_t cmd_reset_def =
5554 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5557 cmdline_parse_inst_t cmd_reset = {
5558 .f = cmd_reset_parsed,
5560 .help_str = "set default: Reset default forwarding configuration",
5562 (void *)&cmd_reset_set,
5563 (void *)&cmd_reset_def,
5568 /* *** START FORWARDING *** */
5569 struct cmd_start_result {
5570 cmdline_fixed_string_t start;
5573 cmdline_parse_token_string_t cmd_start_start =
5574 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5576 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5577 __attribute__((unused)) struct cmdline *cl,
5578 __attribute__((unused)) void *data)
5580 start_packet_forwarding(0);
5583 cmdline_parse_inst_t cmd_start = {
5584 .f = cmd_start_parsed,
5586 .help_str = "start: Start packet forwarding",
5588 (void *)&cmd_start_start,
5593 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5594 struct cmd_start_tx_first_result {
5595 cmdline_fixed_string_t start;
5596 cmdline_fixed_string_t tx_first;
5600 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5601 __attribute__((unused)) struct cmdline *cl,
5602 __attribute__((unused)) void *data)
5604 start_packet_forwarding(1);
5607 cmdline_parse_token_string_t cmd_start_tx_first_start =
5608 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5610 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5611 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5612 tx_first, "tx_first");
5614 cmdline_parse_inst_t cmd_start_tx_first = {
5615 .f = cmd_start_tx_first_parsed,
5617 .help_str = "start tx_first: Start packet forwarding, "
5618 "after sending 1 burst of packets",
5620 (void *)&cmd_start_tx_first_start,
5621 (void *)&cmd_start_tx_first_tx_first,
5626 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5627 struct cmd_start_tx_first_n_result {
5628 cmdline_fixed_string_t start;
5629 cmdline_fixed_string_t tx_first;
5634 cmd_start_tx_first_n_parsed(void *parsed_result,
5635 __attribute__((unused)) struct cmdline *cl,
5636 __attribute__((unused)) void *data)
5638 struct cmd_start_tx_first_n_result *res = parsed_result;
5640 start_packet_forwarding(res->tx_num);
5643 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5644 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5646 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5647 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5648 tx_first, "tx_first");
5649 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5650 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5653 cmdline_parse_inst_t cmd_start_tx_first_n = {
5654 .f = cmd_start_tx_first_n_parsed,
5656 .help_str = "start tx_first <num>: "
5657 "packet forwarding, after sending <num> bursts of packets",
5659 (void *)&cmd_start_tx_first_n_start,
5660 (void *)&cmd_start_tx_first_n_tx_first,
5661 (void *)&cmd_start_tx_first_n_tx_num,
5666 /* *** SET LINK UP *** */
5667 struct cmd_set_link_up_result {
5668 cmdline_fixed_string_t set;
5669 cmdline_fixed_string_t link_up;
5670 cmdline_fixed_string_t port;
5674 cmdline_parse_token_string_t cmd_set_link_up_set =
5675 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5676 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5677 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5679 cmdline_parse_token_string_t cmd_set_link_up_port =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5681 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5682 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5684 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5685 __attribute__((unused)) struct cmdline *cl,
5686 __attribute__((unused)) void *data)
5688 struct cmd_set_link_up_result *res = parsed_result;
5689 dev_set_link_up(res->port_id);
5692 cmdline_parse_inst_t cmd_set_link_up = {
5693 .f = cmd_set_link_up_parsed,
5695 .help_str = "set link-up port <port id>",
5697 (void *)&cmd_set_link_up_set,
5698 (void *)&cmd_set_link_up_link_up,
5699 (void *)&cmd_set_link_up_port,
5700 (void *)&cmd_set_link_up_port_id,
5705 /* *** SET LINK DOWN *** */
5706 struct cmd_set_link_down_result {
5707 cmdline_fixed_string_t set;
5708 cmdline_fixed_string_t link_down;
5709 cmdline_fixed_string_t port;
5713 cmdline_parse_token_string_t cmd_set_link_down_set =
5714 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5715 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5716 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5718 cmdline_parse_token_string_t cmd_set_link_down_port =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5720 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5721 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5723 static void cmd_set_link_down_parsed(
5724 __attribute__((unused)) void *parsed_result,
5725 __attribute__((unused)) struct cmdline *cl,
5726 __attribute__((unused)) void *data)
5728 struct cmd_set_link_down_result *res = parsed_result;
5729 dev_set_link_down(res->port_id);
5732 cmdline_parse_inst_t cmd_set_link_down = {
5733 .f = cmd_set_link_down_parsed,
5735 .help_str = "set link-down port <port id>",
5737 (void *)&cmd_set_link_down_set,
5738 (void *)&cmd_set_link_down_link_down,
5739 (void *)&cmd_set_link_down_port,
5740 (void *)&cmd_set_link_down_port_id,
5745 /* *** SHOW CFG *** */
5746 struct cmd_showcfg_result {
5747 cmdline_fixed_string_t show;
5748 cmdline_fixed_string_t cfg;
5749 cmdline_fixed_string_t what;
5752 static void cmd_showcfg_parsed(void *parsed_result,
5753 __attribute__((unused)) struct cmdline *cl,
5754 __attribute__((unused)) void *data)
5756 struct cmd_showcfg_result *res = parsed_result;
5757 if (!strcmp(res->what, "rxtx"))
5758 rxtx_config_display();
5759 else if (!strcmp(res->what, "cores"))
5760 fwd_lcores_config_display();
5761 else if (!strcmp(res->what, "fwd"))
5762 pkt_fwd_config_display(&cur_fwd_config);
5763 else if (!strcmp(res->what, "txpkts"))
5764 show_tx_pkt_segments();
5767 cmdline_parse_token_string_t cmd_showcfg_show =
5768 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5769 cmdline_parse_token_string_t cmd_showcfg_port =
5770 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5771 cmdline_parse_token_string_t cmd_showcfg_what =
5772 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5773 "rxtx#cores#fwd#txpkts");
5775 cmdline_parse_inst_t cmd_showcfg = {
5776 .f = cmd_showcfg_parsed,
5778 .help_str = "show config rxtx|cores|fwd|txpkts",
5780 (void *)&cmd_showcfg_show,
5781 (void *)&cmd_showcfg_port,
5782 (void *)&cmd_showcfg_what,
5787 /* *** SHOW ALL PORT INFO *** */
5788 struct cmd_showportall_result {
5789 cmdline_fixed_string_t show;
5790 cmdline_fixed_string_t port;
5791 cmdline_fixed_string_t what;
5792 cmdline_fixed_string_t all;
5795 static void cmd_showportall_parsed(void *parsed_result,
5796 __attribute__((unused)) struct cmdline *cl,
5797 __attribute__((unused)) void *data)
5801 struct cmd_showportall_result *res = parsed_result;
5802 if (!strcmp(res->show, "clear")) {
5803 if (!strcmp(res->what, "stats"))
5804 FOREACH_PORT(i, ports)
5806 else if (!strcmp(res->what, "xstats"))
5807 FOREACH_PORT(i, ports)
5808 nic_xstats_clear(i);
5809 } else if (!strcmp(res->what, "info"))
5810 FOREACH_PORT(i, ports)
5811 port_infos_display(i);
5812 else if (!strcmp(res->what, "stats"))
5813 FOREACH_PORT(i, ports)
5814 nic_stats_display(i);
5815 else if (!strcmp(res->what, "xstats"))
5816 FOREACH_PORT(i, ports)
5817 nic_xstats_display(i);
5818 else if (!strcmp(res->what, "fdir"))
5819 FOREACH_PORT(i, ports)
5821 else if (!strcmp(res->what, "stat_qmap"))
5822 FOREACH_PORT(i, ports)
5823 nic_stats_mapping_display(i);
5824 else if (!strcmp(res->what, "dcb_tc"))
5825 FOREACH_PORT(i, ports)
5826 port_dcb_info_display(i);
5829 cmdline_parse_token_string_t cmd_showportall_show =
5830 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5832 cmdline_parse_token_string_t cmd_showportall_port =
5833 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5834 cmdline_parse_token_string_t cmd_showportall_what =
5835 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5836 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5837 cmdline_parse_token_string_t cmd_showportall_all =
5838 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5839 cmdline_parse_inst_t cmd_showportall = {
5840 .f = cmd_showportall_parsed,
5842 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5844 (void *)&cmd_showportall_show,
5845 (void *)&cmd_showportall_port,
5846 (void *)&cmd_showportall_what,
5847 (void *)&cmd_showportall_all,
5852 /* *** SHOW PORT INFO *** */
5853 struct cmd_showport_result {
5854 cmdline_fixed_string_t show;
5855 cmdline_fixed_string_t port;
5856 cmdline_fixed_string_t what;
5860 static void cmd_showport_parsed(void *parsed_result,
5861 __attribute__((unused)) struct cmdline *cl,
5862 __attribute__((unused)) void *data)
5864 struct cmd_showport_result *res = parsed_result;
5865 if (!strcmp(res->show, "clear")) {
5866 if (!strcmp(res->what, "stats"))
5867 nic_stats_clear(res->portnum);
5868 else if (!strcmp(res->what, "xstats"))
5869 nic_xstats_clear(res->portnum);
5870 } else if (!strcmp(res->what, "info"))
5871 port_infos_display(res->portnum);
5872 else if (!strcmp(res->what, "stats"))
5873 nic_stats_display(res->portnum);
5874 else if (!strcmp(res->what, "xstats"))
5875 nic_xstats_display(res->portnum);
5876 else if (!strcmp(res->what, "fdir"))
5877 fdir_get_infos(res->portnum);
5878 else if (!strcmp(res->what, "stat_qmap"))
5879 nic_stats_mapping_display(res->portnum);
5880 else if (!strcmp(res->what, "dcb_tc"))
5881 port_dcb_info_display(res->portnum);
5884 cmdline_parse_token_string_t cmd_showport_show =
5885 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5887 cmdline_parse_token_string_t cmd_showport_port =
5888 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5889 cmdline_parse_token_string_t cmd_showport_what =
5890 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5891 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5892 cmdline_parse_token_num_t cmd_showport_portnum =
5893 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5895 cmdline_parse_inst_t cmd_showport = {
5896 .f = cmd_showport_parsed,
5898 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5901 (void *)&cmd_showport_show,
5902 (void *)&cmd_showport_port,
5903 (void *)&cmd_showport_what,
5904 (void *)&cmd_showport_portnum,
5909 /* *** SHOW QUEUE INFO *** */
5910 struct cmd_showqueue_result {
5911 cmdline_fixed_string_t show;
5912 cmdline_fixed_string_t type;
5913 cmdline_fixed_string_t what;
5919 cmd_showqueue_parsed(void *parsed_result,
5920 __attribute__((unused)) struct cmdline *cl,
5921 __attribute__((unused)) void *data)
5923 struct cmd_showqueue_result *res = parsed_result;
5925 if (!strcmp(res->type, "rxq"))
5926 rx_queue_infos_display(res->portnum, res->queuenum);
5927 else if (!strcmp(res->type, "txq"))
5928 tx_queue_infos_display(res->portnum, res->queuenum);
5931 cmdline_parse_token_string_t cmd_showqueue_show =
5932 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5933 cmdline_parse_token_string_t cmd_showqueue_type =
5934 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5935 cmdline_parse_token_string_t cmd_showqueue_what =
5936 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5937 cmdline_parse_token_num_t cmd_showqueue_portnum =
5938 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5939 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5940 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5942 cmdline_parse_inst_t cmd_showqueue = {
5943 .f = cmd_showqueue_parsed,
5945 .help_str = "show rxq|txq info <port_id> <queue_id>",
5947 (void *)&cmd_showqueue_show,
5948 (void *)&cmd_showqueue_type,
5949 (void *)&cmd_showqueue_what,
5950 (void *)&cmd_showqueue_portnum,
5951 (void *)&cmd_showqueue_queuenum,
5956 /* *** READ PORT REGISTER *** */
5957 struct cmd_read_reg_result {
5958 cmdline_fixed_string_t read;
5959 cmdline_fixed_string_t reg;
5965 cmd_read_reg_parsed(void *parsed_result,
5966 __attribute__((unused)) struct cmdline *cl,
5967 __attribute__((unused)) void *data)
5969 struct cmd_read_reg_result *res = parsed_result;
5970 port_reg_display(res->port_id, res->reg_off);
5973 cmdline_parse_token_string_t cmd_read_reg_read =
5974 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5975 cmdline_parse_token_string_t cmd_read_reg_reg =
5976 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5977 cmdline_parse_token_num_t cmd_read_reg_port_id =
5978 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5979 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5980 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5982 cmdline_parse_inst_t cmd_read_reg = {
5983 .f = cmd_read_reg_parsed,
5985 .help_str = "read reg <port_id> <reg_off>",
5987 (void *)&cmd_read_reg_read,
5988 (void *)&cmd_read_reg_reg,
5989 (void *)&cmd_read_reg_port_id,
5990 (void *)&cmd_read_reg_reg_off,
5995 /* *** READ PORT REGISTER BIT FIELD *** */
5996 struct cmd_read_reg_bit_field_result {
5997 cmdline_fixed_string_t read;
5998 cmdline_fixed_string_t regfield;
6006 cmd_read_reg_bit_field_parsed(void *parsed_result,
6007 __attribute__((unused)) struct cmdline *cl,
6008 __attribute__((unused)) void *data)
6010 struct cmd_read_reg_bit_field_result *res = parsed_result;
6011 port_reg_bit_field_display(res->port_id, res->reg_off,
6012 res->bit1_pos, res->bit2_pos);
6015 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6016 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6018 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6019 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6020 regfield, "regfield");
6021 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6022 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6024 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6025 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6027 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6028 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6030 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6031 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6034 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6035 .f = cmd_read_reg_bit_field_parsed,
6037 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6038 "Read register bit field between bit_x and bit_y included",
6040 (void *)&cmd_read_reg_bit_field_read,
6041 (void *)&cmd_read_reg_bit_field_regfield,
6042 (void *)&cmd_read_reg_bit_field_port_id,
6043 (void *)&cmd_read_reg_bit_field_reg_off,
6044 (void *)&cmd_read_reg_bit_field_bit1_pos,
6045 (void *)&cmd_read_reg_bit_field_bit2_pos,
6050 /* *** READ PORT REGISTER BIT *** */
6051 struct cmd_read_reg_bit_result {
6052 cmdline_fixed_string_t read;
6053 cmdline_fixed_string_t regbit;
6060 cmd_read_reg_bit_parsed(void *parsed_result,
6061 __attribute__((unused)) struct cmdline *cl,
6062 __attribute__((unused)) void *data)
6064 struct cmd_read_reg_bit_result *res = parsed_result;
6065 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6068 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6069 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6070 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6071 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6073 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6074 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6075 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6076 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6077 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6078 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6080 cmdline_parse_inst_t cmd_read_reg_bit = {
6081 .f = cmd_read_reg_bit_parsed,
6083 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6085 (void *)&cmd_read_reg_bit_read,
6086 (void *)&cmd_read_reg_bit_regbit,
6087 (void *)&cmd_read_reg_bit_port_id,
6088 (void *)&cmd_read_reg_bit_reg_off,
6089 (void *)&cmd_read_reg_bit_bit_pos,
6094 /* *** WRITE PORT REGISTER *** */
6095 struct cmd_write_reg_result {
6096 cmdline_fixed_string_t write;
6097 cmdline_fixed_string_t reg;
6104 cmd_write_reg_parsed(void *parsed_result,
6105 __attribute__((unused)) struct cmdline *cl,
6106 __attribute__((unused)) void *data)
6108 struct cmd_write_reg_result *res = parsed_result;
6109 port_reg_set(res->port_id, res->reg_off, res->value);
6112 cmdline_parse_token_string_t cmd_write_reg_write =
6113 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6114 cmdline_parse_token_string_t cmd_write_reg_reg =
6115 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6116 cmdline_parse_token_num_t cmd_write_reg_port_id =
6117 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6118 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6119 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6120 cmdline_parse_token_num_t cmd_write_reg_value =
6121 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6123 cmdline_parse_inst_t cmd_write_reg = {
6124 .f = cmd_write_reg_parsed,
6126 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6128 (void *)&cmd_write_reg_write,
6129 (void *)&cmd_write_reg_reg,
6130 (void *)&cmd_write_reg_port_id,
6131 (void *)&cmd_write_reg_reg_off,
6132 (void *)&cmd_write_reg_value,
6137 /* *** WRITE PORT REGISTER BIT FIELD *** */
6138 struct cmd_write_reg_bit_field_result {
6139 cmdline_fixed_string_t write;
6140 cmdline_fixed_string_t regfield;
6149 cmd_write_reg_bit_field_parsed(void *parsed_result,
6150 __attribute__((unused)) struct cmdline *cl,
6151 __attribute__((unused)) void *data)
6153 struct cmd_write_reg_bit_field_result *res = parsed_result;
6154 port_reg_bit_field_set(res->port_id, res->reg_off,
6155 res->bit1_pos, res->bit2_pos, res->value);
6158 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6159 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6161 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6162 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6163 regfield, "regfield");
6164 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6165 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6167 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6168 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6170 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6171 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6173 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6174 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6176 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6177 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6180 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6181 .f = cmd_write_reg_bit_field_parsed,
6183 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6185 "Set register bit field between bit_x and bit_y included",
6187 (void *)&cmd_write_reg_bit_field_write,
6188 (void *)&cmd_write_reg_bit_field_regfield,
6189 (void *)&cmd_write_reg_bit_field_port_id,
6190 (void *)&cmd_write_reg_bit_field_reg_off,
6191 (void *)&cmd_write_reg_bit_field_bit1_pos,
6192 (void *)&cmd_write_reg_bit_field_bit2_pos,
6193 (void *)&cmd_write_reg_bit_field_value,
6198 /* *** WRITE PORT REGISTER BIT *** */
6199 struct cmd_write_reg_bit_result {
6200 cmdline_fixed_string_t write;
6201 cmdline_fixed_string_t regbit;
6209 cmd_write_reg_bit_parsed(void *parsed_result,
6210 __attribute__((unused)) struct cmdline *cl,
6211 __attribute__((unused)) void *data)
6213 struct cmd_write_reg_bit_result *res = parsed_result;
6214 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6217 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6218 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6220 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6221 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6223 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6224 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6225 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6226 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6227 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6228 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6229 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6230 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6232 cmdline_parse_inst_t cmd_write_reg_bit = {
6233 .f = cmd_write_reg_bit_parsed,
6235 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6238 (void *)&cmd_write_reg_bit_write,
6239 (void *)&cmd_write_reg_bit_regbit,
6240 (void *)&cmd_write_reg_bit_port_id,
6241 (void *)&cmd_write_reg_bit_reg_off,
6242 (void *)&cmd_write_reg_bit_bit_pos,
6243 (void *)&cmd_write_reg_bit_value,
6248 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6249 struct cmd_read_rxd_txd_result {
6250 cmdline_fixed_string_t read;
6251 cmdline_fixed_string_t rxd_txd;
6258 cmd_read_rxd_txd_parsed(void *parsed_result,
6259 __attribute__((unused)) struct cmdline *cl,
6260 __attribute__((unused)) void *data)
6262 struct cmd_read_rxd_txd_result *res = parsed_result;
6264 if (!strcmp(res->rxd_txd, "rxd"))
6265 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6266 else if (!strcmp(res->rxd_txd, "txd"))
6267 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6270 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6271 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6272 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6273 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6275 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6276 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6277 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6278 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6279 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6280 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6282 cmdline_parse_inst_t cmd_read_rxd_txd = {
6283 .f = cmd_read_rxd_txd_parsed,
6285 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6287 (void *)&cmd_read_rxd_txd_read,
6288 (void *)&cmd_read_rxd_txd_rxd_txd,
6289 (void *)&cmd_read_rxd_txd_port_id,
6290 (void *)&cmd_read_rxd_txd_queue_id,
6291 (void *)&cmd_read_rxd_txd_desc_id,
6297 struct cmd_quit_result {
6298 cmdline_fixed_string_t quit;
6301 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6303 __attribute__((unused)) void *data)
6309 cmdline_parse_token_string_t cmd_quit_quit =
6310 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6312 cmdline_parse_inst_t cmd_quit = {
6313 .f = cmd_quit_parsed,
6315 .help_str = "quit: Exit application",
6317 (void *)&cmd_quit_quit,
6322 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6323 struct cmd_mac_addr_result {
6324 cmdline_fixed_string_t mac_addr_cmd;
6325 cmdline_fixed_string_t what;
6327 struct ether_addr address;
6330 static void cmd_mac_addr_parsed(void *parsed_result,
6331 __attribute__((unused)) struct cmdline *cl,
6332 __attribute__((unused)) void *data)
6334 struct cmd_mac_addr_result *res = parsed_result;
6337 if (strcmp(res->what, "add") == 0)
6338 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6340 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6342 /* check the return value and print it if is < 0 */
6344 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6348 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6349 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6351 cmdline_parse_token_string_t cmd_mac_addr_what =
6352 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6354 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6355 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6356 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6357 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6359 cmdline_parse_inst_t cmd_mac_addr = {
6360 .f = cmd_mac_addr_parsed,
6362 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6363 "Add/Remove MAC address on port_id",
6365 (void *)&cmd_mac_addr_cmd,
6366 (void *)&cmd_mac_addr_what,
6367 (void *)&cmd_mac_addr_portnum,
6368 (void *)&cmd_mac_addr_addr,
6374 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6375 struct cmd_set_qmap_result {
6376 cmdline_fixed_string_t set;
6377 cmdline_fixed_string_t qmap;
6378 cmdline_fixed_string_t what;
6385 cmd_set_qmap_parsed(void *parsed_result,
6386 __attribute__((unused)) struct cmdline *cl,
6387 __attribute__((unused)) void *data)
6389 struct cmd_set_qmap_result *res = parsed_result;
6390 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6392 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6395 cmdline_parse_token_string_t cmd_setqmap_set =
6396 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6398 cmdline_parse_token_string_t cmd_setqmap_qmap =
6399 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6401 cmdline_parse_token_string_t cmd_setqmap_what =
6402 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6404 cmdline_parse_token_num_t cmd_setqmap_portid =
6405 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6407 cmdline_parse_token_num_t cmd_setqmap_queueid =
6408 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6410 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6411 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6414 cmdline_parse_inst_t cmd_set_qmap = {
6415 .f = cmd_set_qmap_parsed,
6417 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6418 "Set statistics mapping value on tx|rx queue_id of port_id",
6420 (void *)&cmd_setqmap_set,
6421 (void *)&cmd_setqmap_qmap,
6422 (void *)&cmd_setqmap_what,
6423 (void *)&cmd_setqmap_portid,
6424 (void *)&cmd_setqmap_queueid,
6425 (void *)&cmd_setqmap_mapvalue,
6430 /* *** CONFIGURE UNICAST HASH TABLE *** */
6431 struct cmd_set_uc_hash_table {
6432 cmdline_fixed_string_t set;
6433 cmdline_fixed_string_t port;
6435 cmdline_fixed_string_t what;
6436 struct ether_addr address;
6437 cmdline_fixed_string_t mode;
6441 cmd_set_uc_hash_parsed(void *parsed_result,
6442 __attribute__((unused)) struct cmdline *cl,
6443 __attribute__((unused)) void *data)
6446 struct cmd_set_uc_hash_table *res = parsed_result;
6448 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6450 if (strcmp(res->what, "uta") == 0)
6451 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6452 &res->address,(uint8_t)is_on);
6454 printf("bad unicast hash table parameter, return code = %d \n", ret);
6458 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6459 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6461 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6462 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6464 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6465 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6467 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6468 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6470 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6471 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6473 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6474 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6477 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6478 .f = cmd_set_uc_hash_parsed,
6480 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6482 (void *)&cmd_set_uc_hash_set,
6483 (void *)&cmd_set_uc_hash_port,
6484 (void *)&cmd_set_uc_hash_portid,
6485 (void *)&cmd_set_uc_hash_what,
6486 (void *)&cmd_set_uc_hash_mac,
6487 (void *)&cmd_set_uc_hash_mode,
6492 struct cmd_set_uc_all_hash_table {
6493 cmdline_fixed_string_t set;
6494 cmdline_fixed_string_t port;
6496 cmdline_fixed_string_t what;
6497 cmdline_fixed_string_t value;
6498 cmdline_fixed_string_t mode;
6502 cmd_set_uc_all_hash_parsed(void *parsed_result,
6503 __attribute__((unused)) struct cmdline *cl,
6504 __attribute__((unused)) void *data)
6507 struct cmd_set_uc_all_hash_table *res = parsed_result;
6509 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6511 if ((strcmp(res->what, "uta") == 0) &&
6512 (strcmp(res->value, "all") == 0))
6513 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6515 printf("bad unicast hash table parameter,"
6516 "return code = %d \n", ret);
6519 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6520 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6522 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6523 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6525 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6526 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6528 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6531 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6532 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6534 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6535 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6538 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6539 .f = cmd_set_uc_all_hash_parsed,
6541 .help_str = "set port <port_id> uta all on|off",
6543 (void *)&cmd_set_uc_all_hash_set,
6544 (void *)&cmd_set_uc_all_hash_port,
6545 (void *)&cmd_set_uc_all_hash_portid,
6546 (void *)&cmd_set_uc_all_hash_what,
6547 (void *)&cmd_set_uc_all_hash_value,
6548 (void *)&cmd_set_uc_all_hash_mode,
6553 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6554 struct cmd_set_vf_macvlan_filter {
6555 cmdline_fixed_string_t set;
6556 cmdline_fixed_string_t port;
6558 cmdline_fixed_string_t vf;
6560 struct ether_addr address;
6561 cmdline_fixed_string_t filter_type;
6562 cmdline_fixed_string_t mode;
6566 cmd_set_vf_macvlan_parsed(void *parsed_result,
6567 __attribute__((unused)) struct cmdline *cl,
6568 __attribute__((unused)) void *data)
6571 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6572 struct rte_eth_mac_filter filter;
6574 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6576 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6578 /* set VF MAC filter */
6582 filter.dst_id = res->vf_id;
6584 if (!strcmp(res->filter_type, "exact-mac"))
6585 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6586 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6587 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6588 else if (!strcmp(res->filter_type, "hashmac"))
6589 filter.filter_type = RTE_MAC_HASH_MATCH;
6590 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6591 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6593 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6596 ret = rte_eth_dev_filter_ctrl(res->port_id,
6597 RTE_ETH_FILTER_MACVLAN,
6601 ret = rte_eth_dev_filter_ctrl(res->port_id,
6602 RTE_ETH_FILTER_MACVLAN,
6603 RTE_ETH_FILTER_DELETE,
6607 printf("bad set MAC hash parameter, return code = %d\n", ret);
6611 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6612 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6614 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6615 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6617 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6618 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6620 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6621 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6623 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6624 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6626 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6627 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6629 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6630 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6631 filter_type, "exact-mac#exact-mac-vlan"
6632 "#hashmac#hashmac-vlan");
6633 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6634 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6637 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6638 .f = cmd_set_vf_macvlan_parsed,
6640 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6641 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6642 "Exact match rule: exact match of MAC or MAC and VLAN; "
6643 "hash match rule: hash match of MAC and exact match of VLAN",
6645 (void *)&cmd_set_vf_macvlan_set,
6646 (void *)&cmd_set_vf_macvlan_port,
6647 (void *)&cmd_set_vf_macvlan_portid,
6648 (void *)&cmd_set_vf_macvlan_vf,
6649 (void *)&cmd_set_vf_macvlan_vf_id,
6650 (void *)&cmd_set_vf_macvlan_mac,
6651 (void *)&cmd_set_vf_macvlan_filter_type,
6652 (void *)&cmd_set_vf_macvlan_mode,
6657 #ifdef RTE_LIBRTE_IXGBE_PMD
6658 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6659 struct cmd_set_vf_traffic {
6660 cmdline_fixed_string_t set;
6661 cmdline_fixed_string_t port;
6663 cmdline_fixed_string_t vf;
6665 cmdline_fixed_string_t what;
6666 cmdline_fixed_string_t mode;
6670 cmd_set_vf_traffic_parsed(void *parsed_result,
6671 __attribute__((unused)) struct cmdline *cl,
6672 __attribute__((unused)) void *data)
6674 struct cmd_set_vf_traffic *res = parsed_result;
6675 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6676 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6678 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6681 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6682 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6684 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6687 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6688 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6690 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6691 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6693 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6694 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6696 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6697 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6699 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6700 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6703 cmdline_parse_inst_t cmd_set_vf_traffic = {
6704 .f = cmd_set_vf_traffic_parsed,
6706 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6708 (void *)&cmd_setvf_traffic_set,
6709 (void *)&cmd_setvf_traffic_port,
6710 (void *)&cmd_setvf_traffic_portid,
6711 (void *)&cmd_setvf_traffic_vf,
6712 (void *)&cmd_setvf_traffic_vfid,
6713 (void *)&cmd_setvf_traffic_what,
6714 (void *)&cmd_setvf_traffic_mode,
6720 #ifdef RTE_LIBRTE_IXGBE_PMD
6721 /* *** CONFIGURE VF RECEIVE MODE *** */
6722 struct cmd_set_vf_rxmode {
6723 cmdline_fixed_string_t set;
6724 cmdline_fixed_string_t port;
6726 cmdline_fixed_string_t vf;
6728 cmdline_fixed_string_t what;
6729 cmdline_fixed_string_t mode;
6730 cmdline_fixed_string_t on;
6734 cmd_set_vf_rxmode_parsed(void *parsed_result,
6735 __attribute__((unused)) struct cmdline *cl,
6736 __attribute__((unused)) void *data)
6739 uint16_t rx_mode = 0;
6740 struct cmd_set_vf_rxmode *res = parsed_result;
6742 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6743 if (!strcmp(res->what,"rxmode")) {
6744 if (!strcmp(res->mode, "AUPE"))
6745 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6746 else if (!strcmp(res->mode, "ROPE"))
6747 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6748 else if (!strcmp(res->mode, "BAM"))
6749 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6750 else if (!strncmp(res->mode, "MPE",3))
6751 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6754 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6756 printf("bad VF receive mode parameter, return code = %d \n",
6760 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6761 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6763 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6766 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6767 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6769 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6770 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6772 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6773 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6775 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6776 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6778 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6779 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6780 mode, "AUPE#ROPE#BAM#MPE");
6781 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6782 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6785 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6786 .f = cmd_set_vf_rxmode_parsed,
6788 .help_str = "set port <port_id> vf <vf_id> rxmode "
6789 "AUPE|ROPE|BAM|MPE on|off",
6791 (void *)&cmd_set_vf_rxmode_set,
6792 (void *)&cmd_set_vf_rxmode_port,
6793 (void *)&cmd_set_vf_rxmode_portid,
6794 (void *)&cmd_set_vf_rxmode_vf,
6795 (void *)&cmd_set_vf_rxmode_vfid,
6796 (void *)&cmd_set_vf_rxmode_what,
6797 (void *)&cmd_set_vf_rxmode_mode,
6798 (void *)&cmd_set_vf_rxmode_on,
6804 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6805 struct cmd_vf_mac_addr_result {
6806 cmdline_fixed_string_t mac_addr_cmd;
6807 cmdline_fixed_string_t what;
6808 cmdline_fixed_string_t port;
6810 cmdline_fixed_string_t vf;
6812 struct ether_addr address;
6815 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6816 __attribute__((unused)) struct cmdline *cl,
6817 __attribute__((unused)) void *data)
6819 struct cmd_vf_mac_addr_result *res = parsed_result;
6822 if (strcmp(res->what, "add") == 0)
6823 ret = rte_eth_dev_mac_addr_add(res->port_num,
6824 &res->address, res->vf_num);
6826 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6830 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6831 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6832 mac_addr_cmd,"mac_addr");
6833 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6834 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6836 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6837 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6839 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6840 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6842 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6843 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6845 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6846 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6848 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6849 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6852 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6853 .f = cmd_vf_mac_addr_parsed,
6855 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6856 "Add MAC address filtering for a VF on port_id",
6858 (void *)&cmd_vf_mac_addr_cmd,
6859 (void *)&cmd_vf_mac_addr_what,
6860 (void *)&cmd_vf_mac_addr_port,
6861 (void *)&cmd_vf_mac_addr_portnum,
6862 (void *)&cmd_vf_mac_addr_vf,
6863 (void *)&cmd_vf_mac_addr_vfnum,
6864 (void *)&cmd_vf_mac_addr_addr,
6869 #ifdef RTE_LIBRTE_IXGBE_PMD
6870 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6871 struct cmd_vf_rx_vlan_filter {
6872 cmdline_fixed_string_t rx_vlan;
6873 cmdline_fixed_string_t what;
6875 cmdline_fixed_string_t port;
6877 cmdline_fixed_string_t vf;
6882 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6883 __attribute__((unused)) struct cmdline *cl,
6884 __attribute__((unused)) void *data)
6886 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6888 if (!strcmp(res->what, "add"))
6889 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6891 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6894 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6895 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6896 rx_vlan, "rx_vlan");
6897 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6898 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6900 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6901 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6903 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6904 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6906 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6907 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6909 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6910 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6912 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6913 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6916 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6917 .f = cmd_vf_rx_vlan_filter_parsed,
6919 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6920 "(vf_mask = hexadecimal VF mask)",
6922 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6923 (void *)&cmd_vf_rx_vlan_filter_what,
6924 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6925 (void *)&cmd_vf_rx_vlan_filter_port,
6926 (void *)&cmd_vf_rx_vlan_filter_portid,
6927 (void *)&cmd_vf_rx_vlan_filter_vf,
6928 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6934 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6935 struct cmd_queue_rate_limit_result {
6936 cmdline_fixed_string_t set;
6937 cmdline_fixed_string_t port;
6939 cmdline_fixed_string_t queue;
6941 cmdline_fixed_string_t rate;
6945 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6946 __attribute__((unused)) struct cmdline *cl,
6947 __attribute__((unused)) void *data)
6949 struct cmd_queue_rate_limit_result *res = parsed_result;
6952 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6953 && (strcmp(res->queue, "queue") == 0)
6954 && (strcmp(res->rate, "rate") == 0))
6955 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6958 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6962 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6963 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6965 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6966 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6968 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6969 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6971 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6972 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6974 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6975 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6977 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6978 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6980 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6981 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6984 cmdline_parse_inst_t cmd_queue_rate_limit = {
6985 .f = cmd_queue_rate_limit_parsed,
6987 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6988 "Set rate limit for a queue on port_id",
6990 (void *)&cmd_queue_rate_limit_set,
6991 (void *)&cmd_queue_rate_limit_port,
6992 (void *)&cmd_queue_rate_limit_portnum,
6993 (void *)&cmd_queue_rate_limit_queue,
6994 (void *)&cmd_queue_rate_limit_queuenum,
6995 (void *)&cmd_queue_rate_limit_rate,
6996 (void *)&cmd_queue_rate_limit_ratenum,
7001 #ifdef RTE_LIBRTE_IXGBE_PMD
7002 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7003 struct cmd_vf_rate_limit_result {
7004 cmdline_fixed_string_t set;
7005 cmdline_fixed_string_t port;
7007 cmdline_fixed_string_t vf;
7009 cmdline_fixed_string_t rate;
7011 cmdline_fixed_string_t q_msk;
7015 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7016 __attribute__((unused)) struct cmdline *cl,
7017 __attribute__((unused)) void *data)
7019 struct cmd_vf_rate_limit_result *res = parsed_result;
7022 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7023 && (strcmp(res->vf, "vf") == 0)
7024 && (strcmp(res->rate, "rate") == 0)
7025 && (strcmp(res->q_msk, "queue_mask") == 0))
7026 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7027 res->rate_num, res->q_msk_val);
7029 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7033 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7034 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7036 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7037 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7039 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7040 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7042 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7043 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7045 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7046 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7048 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7049 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7051 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7052 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7054 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7055 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7056 q_msk, "queue_mask");
7057 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7058 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7061 cmdline_parse_inst_t cmd_vf_rate_limit = {
7062 .f = cmd_vf_rate_limit_parsed,
7064 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7065 "queue_mask <queue_mask_value>: "
7066 "Set rate limit for queues of VF on port_id",
7068 (void *)&cmd_vf_rate_limit_set,
7069 (void *)&cmd_vf_rate_limit_port,
7070 (void *)&cmd_vf_rate_limit_portnum,
7071 (void *)&cmd_vf_rate_limit_vf,
7072 (void *)&cmd_vf_rate_limit_vfnum,
7073 (void *)&cmd_vf_rate_limit_rate,
7074 (void *)&cmd_vf_rate_limit_ratenum,
7075 (void *)&cmd_vf_rate_limit_q_msk,
7076 (void *)&cmd_vf_rate_limit_q_msk_val,
7082 /* *** ADD TUNNEL FILTER OF A PORT *** */
7083 struct cmd_tunnel_filter_result {
7084 cmdline_fixed_string_t cmd;
7085 cmdline_fixed_string_t what;
7087 struct ether_addr outer_mac;
7088 struct ether_addr inner_mac;
7089 cmdline_ipaddr_t ip_value;
7090 uint16_t inner_vlan;
7091 cmdline_fixed_string_t tunnel_type;
7092 cmdline_fixed_string_t filter_type;
7098 cmd_tunnel_filter_parsed(void *parsed_result,
7099 __attribute__((unused)) struct cmdline *cl,
7100 __attribute__((unused)) void *data)
7102 struct cmd_tunnel_filter_result *res = parsed_result;
7103 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7106 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7108 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7109 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7110 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7112 if (res->ip_value.family == AF_INET) {
7113 tunnel_filter_conf.ip_addr.ipv4_addr =
7114 res->ip_value.addr.ipv4.s_addr;
7115 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7117 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7118 &(res->ip_value.addr.ipv6),
7119 sizeof(struct in6_addr));
7120 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7123 if (!strcmp(res->filter_type, "imac-ivlan"))
7124 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7125 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7126 tunnel_filter_conf.filter_type =
7127 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7128 else if (!strcmp(res->filter_type, "imac-tenid"))
7129 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7130 else if (!strcmp(res->filter_type, "imac"))
7131 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7132 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7133 tunnel_filter_conf.filter_type =
7134 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7135 else if (!strcmp(res->filter_type, "oip"))
7136 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7137 else if (!strcmp(res->filter_type, "iip"))
7138 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7140 printf("The filter type is not supported");
7144 if (!strcmp(res->tunnel_type, "vxlan"))
7145 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7146 else if (!strcmp(res->tunnel_type, "nvgre"))
7147 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7148 else if (!strcmp(res->tunnel_type, "ipingre"))
7149 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7151 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7155 tunnel_filter_conf.tenant_id = res->tenant_id;
7156 tunnel_filter_conf.queue_id = res->queue_num;
7157 if (!strcmp(res->what, "add"))
7158 ret = rte_eth_dev_filter_ctrl(res->port_id,
7159 RTE_ETH_FILTER_TUNNEL,
7161 &tunnel_filter_conf);
7163 ret = rte_eth_dev_filter_ctrl(res->port_id,
7164 RTE_ETH_FILTER_TUNNEL,
7165 RTE_ETH_FILTER_DELETE,
7166 &tunnel_filter_conf);
7168 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7172 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7173 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7174 cmd, "tunnel_filter");
7175 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7176 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7178 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7179 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7181 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7182 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7184 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7185 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7187 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7188 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7189 inner_vlan, UINT16);
7190 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7191 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7193 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7194 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7195 tunnel_type, "vxlan#nvgre#ipingre");
7197 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7198 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7199 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7200 "imac#omac-imac-tenid");
7201 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7202 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7204 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7205 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7208 cmdline_parse_inst_t cmd_tunnel_filter = {
7209 .f = cmd_tunnel_filter_parsed,
7211 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7212 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7213 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7214 "<queue_id>: Add/Rm tunnel filter of a port",
7216 (void *)&cmd_tunnel_filter_cmd,
7217 (void *)&cmd_tunnel_filter_what,
7218 (void *)&cmd_tunnel_filter_port_id,
7219 (void *)&cmd_tunnel_filter_outer_mac,
7220 (void *)&cmd_tunnel_filter_inner_mac,
7221 (void *)&cmd_tunnel_filter_ip_value,
7222 (void *)&cmd_tunnel_filter_innner_vlan,
7223 (void *)&cmd_tunnel_filter_tunnel_type,
7224 (void *)&cmd_tunnel_filter_filter_type,
7225 (void *)&cmd_tunnel_filter_tenant_id,
7226 (void *)&cmd_tunnel_filter_queue_num,
7231 /* *** CONFIGURE TUNNEL UDP PORT *** */
7232 struct cmd_tunnel_udp_config {
7233 cmdline_fixed_string_t cmd;
7234 cmdline_fixed_string_t what;
7240 cmd_tunnel_udp_config_parsed(void *parsed_result,
7241 __attribute__((unused)) struct cmdline *cl,
7242 __attribute__((unused)) void *data)
7244 struct cmd_tunnel_udp_config *res = parsed_result;
7245 struct rte_eth_udp_tunnel tunnel_udp;
7248 tunnel_udp.udp_port = res->udp_port;
7250 if (!strcmp(res->cmd, "rx_vxlan_port"))
7251 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7253 if (!strcmp(res->what, "add"))
7254 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7257 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7261 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7264 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7265 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7266 cmd, "rx_vxlan_port");
7267 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7268 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7270 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7271 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7273 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7274 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7277 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7278 .f = cmd_tunnel_udp_config_parsed,
7280 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7281 "Add/Remove a tunneling UDP port filter",
7283 (void *)&cmd_tunnel_udp_config_cmd,
7284 (void *)&cmd_tunnel_udp_config_what,
7285 (void *)&cmd_tunnel_udp_config_udp_port,
7286 (void *)&cmd_tunnel_udp_config_port_id,
7291 /* *** GLOBAL CONFIG *** */
7292 struct cmd_global_config_result {
7293 cmdline_fixed_string_t cmd;
7295 cmdline_fixed_string_t cfg_type;
7300 cmd_global_config_parsed(void *parsed_result,
7301 __attribute__((unused)) struct cmdline *cl,
7302 __attribute__((unused)) void *data)
7304 struct cmd_global_config_result *res = parsed_result;
7305 struct rte_eth_global_cfg conf;
7308 memset(&conf, 0, sizeof(conf));
7309 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7310 conf.cfg.gre_key_len = res->len;
7311 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7312 RTE_ETH_FILTER_SET, &conf);
7314 printf("Global config error\n");
7317 cmdline_parse_token_string_t cmd_global_config_cmd =
7318 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7320 cmdline_parse_token_num_t cmd_global_config_port_id =
7321 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7322 cmdline_parse_token_string_t cmd_global_config_type =
7323 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7324 cfg_type, "gre-key-len");
7325 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7326 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7329 cmdline_parse_inst_t cmd_global_config = {
7330 .f = cmd_global_config_parsed,
7331 .data = (void *)NULL,
7332 .help_str = "global_config <port_id> gre-key-len <key_len>",
7334 (void *)&cmd_global_config_cmd,
7335 (void *)&cmd_global_config_port_id,
7336 (void *)&cmd_global_config_type,
7337 (void *)&cmd_global_config_gre_key_len,
7342 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7343 struct cmd_set_mirror_mask_result {
7344 cmdline_fixed_string_t set;
7345 cmdline_fixed_string_t port;
7347 cmdline_fixed_string_t mirror;
7349 cmdline_fixed_string_t what;
7350 cmdline_fixed_string_t value;
7351 cmdline_fixed_string_t dstpool;
7353 cmdline_fixed_string_t on;
7356 cmdline_parse_token_string_t cmd_mirror_mask_set =
7357 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7359 cmdline_parse_token_string_t cmd_mirror_mask_port =
7360 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7362 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7363 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7365 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7366 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7367 mirror, "mirror-rule");
7368 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7369 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7371 cmdline_parse_token_string_t cmd_mirror_mask_what =
7372 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7373 what, "pool-mirror-up#pool-mirror-down"
7375 cmdline_parse_token_string_t cmd_mirror_mask_value =
7376 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7378 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7379 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7380 dstpool, "dst-pool");
7381 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7382 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7384 cmdline_parse_token_string_t cmd_mirror_mask_on =
7385 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7389 cmd_set_mirror_mask_parsed(void *parsed_result,
7390 __attribute__((unused)) struct cmdline *cl,
7391 __attribute__((unused)) void *data)
7394 struct cmd_set_mirror_mask_result *res = parsed_result;
7395 struct rte_eth_mirror_conf mr_conf;
7397 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7399 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7401 mr_conf.dst_pool = res->dstpool_id;
7403 if (!strcmp(res->what, "pool-mirror-up")) {
7404 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7405 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7406 } else if (!strcmp(res->what, "pool-mirror-down")) {
7407 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7408 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7409 } else if (!strcmp(res->what, "vlan-mirror")) {
7410 mr_conf.rule_type = ETH_MIRROR_VLAN;
7411 nb_item = parse_item_list(res->value, "vlan",
7412 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7416 for (i = 0; i < nb_item; i++) {
7417 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7418 printf("Invalid vlan_id: must be < 4096\n");
7422 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7423 mr_conf.vlan.vlan_mask |= 1ULL << i;
7427 if (!strcmp(res->on, "on"))
7428 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7431 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7434 printf("mirror rule add error: (%s)\n", strerror(-ret));
7437 cmdline_parse_inst_t cmd_set_mirror_mask = {
7438 .f = cmd_set_mirror_mask_parsed,
7440 .help_str = "set port <port_id> mirror-rule <rule_id> "
7441 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7442 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7444 (void *)&cmd_mirror_mask_set,
7445 (void *)&cmd_mirror_mask_port,
7446 (void *)&cmd_mirror_mask_portid,
7447 (void *)&cmd_mirror_mask_mirror,
7448 (void *)&cmd_mirror_mask_ruleid,
7449 (void *)&cmd_mirror_mask_what,
7450 (void *)&cmd_mirror_mask_value,
7451 (void *)&cmd_mirror_mask_dstpool,
7452 (void *)&cmd_mirror_mask_poolid,
7453 (void *)&cmd_mirror_mask_on,
7458 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7459 struct cmd_set_mirror_link_result {
7460 cmdline_fixed_string_t set;
7461 cmdline_fixed_string_t port;
7463 cmdline_fixed_string_t mirror;
7465 cmdline_fixed_string_t what;
7466 cmdline_fixed_string_t dstpool;
7468 cmdline_fixed_string_t on;
7471 cmdline_parse_token_string_t cmd_mirror_link_set =
7472 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7474 cmdline_parse_token_string_t cmd_mirror_link_port =
7475 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7477 cmdline_parse_token_num_t cmd_mirror_link_portid =
7478 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7480 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7481 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7482 mirror, "mirror-rule");
7483 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7484 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7486 cmdline_parse_token_string_t cmd_mirror_link_what =
7487 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7488 what, "uplink-mirror#downlink-mirror");
7489 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7490 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7491 dstpool, "dst-pool");
7492 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7493 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7495 cmdline_parse_token_string_t cmd_mirror_link_on =
7496 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7500 cmd_set_mirror_link_parsed(void *parsed_result,
7501 __attribute__((unused)) struct cmdline *cl,
7502 __attribute__((unused)) void *data)
7505 struct cmd_set_mirror_link_result *res = parsed_result;
7506 struct rte_eth_mirror_conf mr_conf;
7508 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7509 if (!strcmp(res->what, "uplink-mirror"))
7510 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7512 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7514 mr_conf.dst_pool = res->dstpool_id;
7516 if (!strcmp(res->on, "on"))
7517 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7520 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7523 /* check the return value and print it if is < 0 */
7525 printf("mirror rule add error: (%s)\n", strerror(-ret));
7529 cmdline_parse_inst_t cmd_set_mirror_link = {
7530 .f = cmd_set_mirror_link_parsed,
7532 .help_str = "set port <port_id> mirror-rule <rule_id> "
7533 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7535 (void *)&cmd_mirror_link_set,
7536 (void *)&cmd_mirror_link_port,
7537 (void *)&cmd_mirror_link_portid,
7538 (void *)&cmd_mirror_link_mirror,
7539 (void *)&cmd_mirror_link_ruleid,
7540 (void *)&cmd_mirror_link_what,
7541 (void *)&cmd_mirror_link_dstpool,
7542 (void *)&cmd_mirror_link_poolid,
7543 (void *)&cmd_mirror_link_on,
7548 /* *** RESET VM MIRROR RULE *** */
7549 struct cmd_rm_mirror_rule_result {
7550 cmdline_fixed_string_t reset;
7551 cmdline_fixed_string_t port;
7553 cmdline_fixed_string_t mirror;
7557 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7558 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7560 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7561 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7563 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7564 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7566 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7567 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7568 mirror, "mirror-rule");
7569 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7570 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7574 cmd_reset_mirror_rule_parsed(void *parsed_result,
7575 __attribute__((unused)) struct cmdline *cl,
7576 __attribute__((unused)) void *data)
7579 struct cmd_set_mirror_link_result *res = parsed_result;
7581 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7583 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7586 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7587 .f = cmd_reset_mirror_rule_parsed,
7589 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7591 (void *)&cmd_rm_mirror_rule_reset,
7592 (void *)&cmd_rm_mirror_rule_port,
7593 (void *)&cmd_rm_mirror_rule_portid,
7594 (void *)&cmd_rm_mirror_rule_mirror,
7595 (void *)&cmd_rm_mirror_rule_ruleid,
7600 /* ******************************************************************************** */
7602 struct cmd_dump_result {
7603 cmdline_fixed_string_t dump;
7607 dump_struct_sizes(void)
7609 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7610 DUMP_SIZE(struct rte_mbuf);
7611 DUMP_SIZE(struct rte_mempool);
7612 DUMP_SIZE(struct rte_ring);
7616 static void cmd_dump_parsed(void *parsed_result,
7617 __attribute__((unused)) struct cmdline *cl,
7618 __attribute__((unused)) void *data)
7620 struct cmd_dump_result *res = parsed_result;
7622 if (!strcmp(res->dump, "dump_physmem"))
7623 rte_dump_physmem_layout(stdout);
7624 else if (!strcmp(res->dump, "dump_memzone"))
7625 rte_memzone_dump(stdout);
7626 else if (!strcmp(res->dump, "dump_struct_sizes"))
7627 dump_struct_sizes();
7628 else if (!strcmp(res->dump, "dump_ring"))
7629 rte_ring_list_dump(stdout);
7630 else if (!strcmp(res->dump, "dump_mempool"))
7631 rte_mempool_list_dump(stdout);
7632 else if (!strcmp(res->dump, "dump_devargs"))
7633 rte_eal_devargs_dump(stdout);
7636 cmdline_parse_token_string_t cmd_dump_dump =
7637 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7640 "dump_struct_sizes#"
7645 cmdline_parse_inst_t cmd_dump = {
7646 .f = cmd_dump_parsed, /* function to call */
7647 .data = NULL, /* 2nd arg of func */
7648 .help_str = "Dump status",
7649 .tokens = { /* token list, NULL terminated */
7650 (void *)&cmd_dump_dump,
7655 /* ******************************************************************************** */
7657 struct cmd_dump_one_result {
7658 cmdline_fixed_string_t dump;
7659 cmdline_fixed_string_t name;
7662 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7663 __attribute__((unused)) void *data)
7665 struct cmd_dump_one_result *res = parsed_result;
7667 if (!strcmp(res->dump, "dump_ring")) {
7669 r = rte_ring_lookup(res->name);
7671 cmdline_printf(cl, "Cannot find ring\n");
7674 rte_ring_dump(stdout, r);
7675 } else if (!strcmp(res->dump, "dump_mempool")) {
7676 struct rte_mempool *mp;
7677 mp = rte_mempool_lookup(res->name);
7679 cmdline_printf(cl, "Cannot find mempool\n");
7682 rte_mempool_dump(stdout, mp);
7686 cmdline_parse_token_string_t cmd_dump_one_dump =
7687 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7688 "dump_ring#dump_mempool");
7690 cmdline_parse_token_string_t cmd_dump_one_name =
7691 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7693 cmdline_parse_inst_t cmd_dump_one = {
7694 .f = cmd_dump_one_parsed, /* function to call */
7695 .data = NULL, /* 2nd arg of func */
7696 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7697 .tokens = { /* token list, NULL terminated */
7698 (void *)&cmd_dump_one_dump,
7699 (void *)&cmd_dump_one_name,
7704 /* *** Add/Del syn filter *** */
7705 struct cmd_syn_filter_result {
7706 cmdline_fixed_string_t filter;
7708 cmdline_fixed_string_t ops;
7709 cmdline_fixed_string_t priority;
7710 cmdline_fixed_string_t high;
7711 cmdline_fixed_string_t queue;
7716 cmd_syn_filter_parsed(void *parsed_result,
7717 __attribute__((unused)) struct cmdline *cl,
7718 __attribute__((unused)) void *data)
7720 struct cmd_syn_filter_result *res = parsed_result;
7721 struct rte_eth_syn_filter syn_filter;
7724 ret = rte_eth_dev_filter_supported(res->port_id,
7725 RTE_ETH_FILTER_SYN);
7727 printf("syn filter is not supported on port %u.\n",
7732 memset(&syn_filter, 0, sizeof(syn_filter));
7734 if (!strcmp(res->ops, "add")) {
7735 if (!strcmp(res->high, "high"))
7736 syn_filter.hig_pri = 1;
7738 syn_filter.hig_pri = 0;
7740 syn_filter.queue = res->queue_id;
7741 ret = rte_eth_dev_filter_ctrl(res->port_id,
7746 ret = rte_eth_dev_filter_ctrl(res->port_id,
7748 RTE_ETH_FILTER_DELETE,
7752 printf("syn filter programming error: (%s)\n",
7756 cmdline_parse_token_string_t cmd_syn_filter_filter =
7757 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7758 filter, "syn_filter");
7759 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7760 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7762 cmdline_parse_token_string_t cmd_syn_filter_ops =
7763 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7765 cmdline_parse_token_string_t cmd_syn_filter_priority =
7766 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7767 priority, "priority");
7768 cmdline_parse_token_string_t cmd_syn_filter_high =
7769 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7771 cmdline_parse_token_string_t cmd_syn_filter_queue =
7772 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7774 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7775 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7778 cmdline_parse_inst_t cmd_syn_filter = {
7779 .f = cmd_syn_filter_parsed,
7781 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7782 "<queue_id>: Add/Delete syn filter",
7784 (void *)&cmd_syn_filter_filter,
7785 (void *)&cmd_syn_filter_port_id,
7786 (void *)&cmd_syn_filter_ops,
7787 (void *)&cmd_syn_filter_priority,
7788 (void *)&cmd_syn_filter_high,
7789 (void *)&cmd_syn_filter_queue,
7790 (void *)&cmd_syn_filter_queue_id,
7795 /* *** ADD/REMOVE A 2tuple FILTER *** */
7796 struct cmd_2tuple_filter_result {
7797 cmdline_fixed_string_t filter;
7799 cmdline_fixed_string_t ops;
7800 cmdline_fixed_string_t dst_port;
7801 uint16_t dst_port_value;
7802 cmdline_fixed_string_t protocol;
7803 uint8_t protocol_value;
7804 cmdline_fixed_string_t mask;
7806 cmdline_fixed_string_t tcp_flags;
7807 uint8_t tcp_flags_value;
7808 cmdline_fixed_string_t priority;
7809 uint8_t priority_value;
7810 cmdline_fixed_string_t queue;
7815 cmd_2tuple_filter_parsed(void *parsed_result,
7816 __attribute__((unused)) struct cmdline *cl,
7817 __attribute__((unused)) void *data)
7819 struct rte_eth_ntuple_filter filter;
7820 struct cmd_2tuple_filter_result *res = parsed_result;
7823 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7825 printf("ntuple filter is not supported on port %u.\n",
7830 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7832 filter.flags = RTE_2TUPLE_FLAGS;
7833 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7834 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7835 filter.proto = res->protocol_value;
7836 filter.priority = res->priority_value;
7837 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7838 printf("nonzero tcp_flags is only meaningful"
7839 " when protocol is TCP.\n");
7842 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7843 printf("invalid TCP flags.\n");
7847 if (res->tcp_flags_value != 0) {
7848 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7849 filter.tcp_flags = res->tcp_flags_value;
7852 /* need convert to big endian. */
7853 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7854 filter.queue = res->queue_id;
7856 if (!strcmp(res->ops, "add"))
7857 ret = rte_eth_dev_filter_ctrl(res->port_id,
7858 RTE_ETH_FILTER_NTUPLE,
7862 ret = rte_eth_dev_filter_ctrl(res->port_id,
7863 RTE_ETH_FILTER_NTUPLE,
7864 RTE_ETH_FILTER_DELETE,
7867 printf("2tuple filter programming error: (%s)\n",
7872 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7873 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7874 filter, "2tuple_filter");
7875 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7876 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7878 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7879 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7881 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7882 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7883 dst_port, "dst_port");
7884 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7885 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7886 dst_port_value, UINT16);
7887 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7888 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7889 protocol, "protocol");
7890 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7891 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7892 protocol_value, UINT8);
7893 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7894 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7896 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7897 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7899 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7900 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7901 tcp_flags, "tcp_flags");
7902 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7903 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7904 tcp_flags_value, UINT8);
7905 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7906 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7907 priority, "priority");
7908 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7909 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7910 priority_value, UINT8);
7911 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7912 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7914 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7915 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7918 cmdline_parse_inst_t cmd_2tuple_filter = {
7919 .f = cmd_2tuple_filter_parsed,
7921 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7922 "<value> mask <value> tcp_flags <value> priority <value> queue "
7923 "<queue_id>: Add a 2tuple filter",
7925 (void *)&cmd_2tuple_filter_filter,
7926 (void *)&cmd_2tuple_filter_port_id,
7927 (void *)&cmd_2tuple_filter_ops,
7928 (void *)&cmd_2tuple_filter_dst_port,
7929 (void *)&cmd_2tuple_filter_dst_port_value,
7930 (void *)&cmd_2tuple_filter_protocol,
7931 (void *)&cmd_2tuple_filter_protocol_value,
7932 (void *)&cmd_2tuple_filter_mask,
7933 (void *)&cmd_2tuple_filter_mask_value,
7934 (void *)&cmd_2tuple_filter_tcp_flags,
7935 (void *)&cmd_2tuple_filter_tcp_flags_value,
7936 (void *)&cmd_2tuple_filter_priority,
7937 (void *)&cmd_2tuple_filter_priority_value,
7938 (void *)&cmd_2tuple_filter_queue,
7939 (void *)&cmd_2tuple_filter_queue_id,
7944 /* *** ADD/REMOVE A 5tuple FILTER *** */
7945 struct cmd_5tuple_filter_result {
7946 cmdline_fixed_string_t filter;
7948 cmdline_fixed_string_t ops;
7949 cmdline_fixed_string_t dst_ip;
7950 cmdline_ipaddr_t dst_ip_value;
7951 cmdline_fixed_string_t src_ip;
7952 cmdline_ipaddr_t src_ip_value;
7953 cmdline_fixed_string_t dst_port;
7954 uint16_t dst_port_value;
7955 cmdline_fixed_string_t src_port;
7956 uint16_t src_port_value;
7957 cmdline_fixed_string_t protocol;
7958 uint8_t protocol_value;
7959 cmdline_fixed_string_t mask;
7961 cmdline_fixed_string_t tcp_flags;
7962 uint8_t tcp_flags_value;
7963 cmdline_fixed_string_t priority;
7964 uint8_t priority_value;
7965 cmdline_fixed_string_t queue;
7970 cmd_5tuple_filter_parsed(void *parsed_result,
7971 __attribute__((unused)) struct cmdline *cl,
7972 __attribute__((unused)) void *data)
7974 struct rte_eth_ntuple_filter filter;
7975 struct cmd_5tuple_filter_result *res = parsed_result;
7978 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7980 printf("ntuple filter is not supported on port %u.\n",
7985 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7987 filter.flags = RTE_5TUPLE_FLAGS;
7988 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7989 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7990 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7991 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7992 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7993 filter.proto = res->protocol_value;
7994 filter.priority = res->priority_value;
7995 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7996 printf("nonzero tcp_flags is only meaningful"
7997 " when protocol is TCP.\n");
8000 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8001 printf("invalid TCP flags.\n");
8005 if (res->tcp_flags_value != 0) {
8006 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8007 filter.tcp_flags = res->tcp_flags_value;
8010 if (res->dst_ip_value.family == AF_INET)
8011 /* no need to convert, already big endian. */
8012 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8014 if (filter.dst_ip_mask == 0) {
8015 printf("can not support ipv6 involved compare.\n");
8021 if (res->src_ip_value.family == AF_INET)
8022 /* no need to convert, already big endian. */
8023 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8025 if (filter.src_ip_mask == 0) {
8026 printf("can not support ipv6 involved compare.\n");
8031 /* need convert to big endian. */
8032 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8033 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8034 filter.queue = res->queue_id;
8036 if (!strcmp(res->ops, "add"))
8037 ret = rte_eth_dev_filter_ctrl(res->port_id,
8038 RTE_ETH_FILTER_NTUPLE,
8042 ret = rte_eth_dev_filter_ctrl(res->port_id,
8043 RTE_ETH_FILTER_NTUPLE,
8044 RTE_ETH_FILTER_DELETE,
8047 printf("5tuple filter programming error: (%s)\n",
8051 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8052 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8053 filter, "5tuple_filter");
8054 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8055 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8057 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8058 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8060 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8061 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8063 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8064 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8066 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8067 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8069 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8070 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8072 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8073 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8074 dst_port, "dst_port");
8075 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8076 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8077 dst_port_value, UINT16);
8078 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8079 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8080 src_port, "src_port");
8081 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8082 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8083 src_port_value, UINT16);
8084 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8085 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8086 protocol, "protocol");
8087 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8088 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8089 protocol_value, UINT8);
8090 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8091 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8093 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8094 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8096 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8097 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8098 tcp_flags, "tcp_flags");
8099 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8100 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8101 tcp_flags_value, UINT8);
8102 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8103 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8104 priority, "priority");
8105 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8106 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8107 priority_value, UINT8);
8108 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8109 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8111 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8112 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8115 cmdline_parse_inst_t cmd_5tuple_filter = {
8116 .f = cmd_5tuple_filter_parsed,
8118 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8119 "src_ip <value> dst_port <value> src_port <value> "
8120 "protocol <value> mask <value> tcp_flags <value> "
8121 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8123 (void *)&cmd_5tuple_filter_filter,
8124 (void *)&cmd_5tuple_filter_port_id,
8125 (void *)&cmd_5tuple_filter_ops,
8126 (void *)&cmd_5tuple_filter_dst_ip,
8127 (void *)&cmd_5tuple_filter_dst_ip_value,
8128 (void *)&cmd_5tuple_filter_src_ip,
8129 (void *)&cmd_5tuple_filter_src_ip_value,
8130 (void *)&cmd_5tuple_filter_dst_port,
8131 (void *)&cmd_5tuple_filter_dst_port_value,
8132 (void *)&cmd_5tuple_filter_src_port,
8133 (void *)&cmd_5tuple_filter_src_port_value,
8134 (void *)&cmd_5tuple_filter_protocol,
8135 (void *)&cmd_5tuple_filter_protocol_value,
8136 (void *)&cmd_5tuple_filter_mask,
8137 (void *)&cmd_5tuple_filter_mask_value,
8138 (void *)&cmd_5tuple_filter_tcp_flags,
8139 (void *)&cmd_5tuple_filter_tcp_flags_value,
8140 (void *)&cmd_5tuple_filter_priority,
8141 (void *)&cmd_5tuple_filter_priority_value,
8142 (void *)&cmd_5tuple_filter_queue,
8143 (void *)&cmd_5tuple_filter_queue_id,
8148 /* *** ADD/REMOVE A flex FILTER *** */
8149 struct cmd_flex_filter_result {
8150 cmdline_fixed_string_t filter;
8151 cmdline_fixed_string_t ops;
8153 cmdline_fixed_string_t len;
8155 cmdline_fixed_string_t bytes;
8156 cmdline_fixed_string_t bytes_value;
8157 cmdline_fixed_string_t mask;
8158 cmdline_fixed_string_t mask_value;
8159 cmdline_fixed_string_t priority;
8160 uint8_t priority_value;
8161 cmdline_fixed_string_t queue;
8165 static int xdigit2val(unsigned char c)
8170 else if (isupper(c))
8178 cmd_flex_filter_parsed(void *parsed_result,
8179 __attribute__((unused)) struct cmdline *cl,
8180 __attribute__((unused)) void *data)
8183 struct rte_eth_flex_filter filter;
8184 struct cmd_flex_filter_result *res = parsed_result;
8185 char *bytes_ptr, *mask_ptr;
8186 uint16_t len, i, j = 0;
8191 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8192 printf("the len exceed the max length 128\n");
8195 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8196 filter.len = res->len_value;
8197 filter.priority = res->priority_value;
8198 filter.queue = res->queue_id;
8199 bytes_ptr = res->bytes_value;
8200 mask_ptr = res->mask_value;
8202 /* translate bytes string to array. */
8203 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8204 (bytes_ptr[1] == 'X')))
8206 len = strnlen(bytes_ptr, res->len_value * 2);
8207 if (len == 0 || (len % 8 != 0)) {
8208 printf("please check len and bytes input\n");
8211 for (i = 0; i < len; i++) {
8213 if (isxdigit(c) == 0) {
8214 /* invalid characters. */
8215 printf("invalid input\n");
8218 val = xdigit2val(c);
8221 filter.bytes[j] = byte;
8222 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8229 /* translate mask string to uint8_t array. */
8230 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8231 (mask_ptr[1] == 'X')))
8233 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8235 printf("invalid input\n");
8240 for (i = 0; i < len; i++) {
8242 if (isxdigit(c) == 0) {
8243 /* invalid characters. */
8244 printf("invalid input\n");
8247 val = xdigit2val(c);
8250 filter.mask[j] = byte;
8251 printf("mask[%d]:%02x ", j, filter.mask[j]);
8259 if (!strcmp(res->ops, "add"))
8260 ret = rte_eth_dev_filter_ctrl(res->port_id,
8261 RTE_ETH_FILTER_FLEXIBLE,
8265 ret = rte_eth_dev_filter_ctrl(res->port_id,
8266 RTE_ETH_FILTER_FLEXIBLE,
8267 RTE_ETH_FILTER_DELETE,
8271 printf("flex filter setting error: (%s)\n", strerror(-ret));
8274 cmdline_parse_token_string_t cmd_flex_filter_filter =
8275 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8276 filter, "flex_filter");
8277 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8278 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8280 cmdline_parse_token_string_t cmd_flex_filter_ops =
8281 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8283 cmdline_parse_token_string_t cmd_flex_filter_len =
8284 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8286 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8287 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8289 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8290 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8292 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8293 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8295 cmdline_parse_token_string_t cmd_flex_filter_mask =
8296 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8298 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8299 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8301 cmdline_parse_token_string_t cmd_flex_filter_priority =
8302 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8303 priority, "priority");
8304 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8305 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8306 priority_value, UINT8);
8307 cmdline_parse_token_string_t cmd_flex_filter_queue =
8308 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8310 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8311 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8313 cmdline_parse_inst_t cmd_flex_filter = {
8314 .f = cmd_flex_filter_parsed,
8316 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8317 "<value> mask <value> priority <value> queue <queue_id>: "
8318 "Add/Del a flex filter",
8320 (void *)&cmd_flex_filter_filter,
8321 (void *)&cmd_flex_filter_port_id,
8322 (void *)&cmd_flex_filter_ops,
8323 (void *)&cmd_flex_filter_len,
8324 (void *)&cmd_flex_filter_len_value,
8325 (void *)&cmd_flex_filter_bytes,
8326 (void *)&cmd_flex_filter_bytes_value,
8327 (void *)&cmd_flex_filter_mask,
8328 (void *)&cmd_flex_filter_mask_value,
8329 (void *)&cmd_flex_filter_priority,
8330 (void *)&cmd_flex_filter_priority_value,
8331 (void *)&cmd_flex_filter_queue,
8332 (void *)&cmd_flex_filter_queue_id,
8337 /* *** Filters Control *** */
8339 /* *** deal with ethertype filter *** */
8340 struct cmd_ethertype_filter_result {
8341 cmdline_fixed_string_t filter;
8343 cmdline_fixed_string_t ops;
8344 cmdline_fixed_string_t mac;
8345 struct ether_addr mac_addr;
8346 cmdline_fixed_string_t ethertype;
8347 uint16_t ethertype_value;
8348 cmdline_fixed_string_t drop;
8349 cmdline_fixed_string_t queue;
8353 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8354 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8355 filter, "ethertype_filter");
8356 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8357 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8359 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8360 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8362 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8363 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8364 mac, "mac_addr#mac_ignr");
8365 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8366 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8368 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8369 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8370 ethertype, "ethertype");
8371 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8372 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8373 ethertype_value, UINT16);
8374 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8375 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8377 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8378 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8380 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8381 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8385 cmd_ethertype_filter_parsed(void *parsed_result,
8386 __attribute__((unused)) struct cmdline *cl,
8387 __attribute__((unused)) void *data)
8389 struct cmd_ethertype_filter_result *res = parsed_result;
8390 struct rte_eth_ethertype_filter filter;
8393 ret = rte_eth_dev_filter_supported(res->port_id,
8394 RTE_ETH_FILTER_ETHERTYPE);
8396 printf("ethertype filter is not supported on port %u.\n",
8401 memset(&filter, 0, sizeof(filter));
8402 if (!strcmp(res->mac, "mac_addr")) {
8403 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8404 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8405 sizeof(struct ether_addr));
8407 if (!strcmp(res->drop, "drop"))
8408 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8409 filter.ether_type = res->ethertype_value;
8410 filter.queue = res->queue_id;
8412 if (!strcmp(res->ops, "add"))
8413 ret = rte_eth_dev_filter_ctrl(res->port_id,
8414 RTE_ETH_FILTER_ETHERTYPE,
8418 ret = rte_eth_dev_filter_ctrl(res->port_id,
8419 RTE_ETH_FILTER_ETHERTYPE,
8420 RTE_ETH_FILTER_DELETE,
8423 printf("ethertype filter programming error: (%s)\n",
8427 cmdline_parse_inst_t cmd_ethertype_filter = {
8428 .f = cmd_ethertype_filter_parsed,
8430 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8431 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8432 "Add or delete an ethertype filter entry",
8434 (void *)&cmd_ethertype_filter_filter,
8435 (void *)&cmd_ethertype_filter_port_id,
8436 (void *)&cmd_ethertype_filter_ops,
8437 (void *)&cmd_ethertype_filter_mac,
8438 (void *)&cmd_ethertype_filter_mac_addr,
8439 (void *)&cmd_ethertype_filter_ethertype,
8440 (void *)&cmd_ethertype_filter_ethertype_value,
8441 (void *)&cmd_ethertype_filter_drop,
8442 (void *)&cmd_ethertype_filter_queue,
8443 (void *)&cmd_ethertype_filter_queue_id,
8448 /* *** deal with flow director filter *** */
8449 struct cmd_flow_director_result {
8450 cmdline_fixed_string_t flow_director_filter;
8452 cmdline_fixed_string_t mode;
8453 cmdline_fixed_string_t mode_value;
8454 cmdline_fixed_string_t ops;
8455 cmdline_fixed_string_t flow;
8456 cmdline_fixed_string_t flow_type;
8457 cmdline_fixed_string_t ether;
8458 uint16_t ether_type;
8459 cmdline_fixed_string_t src;
8460 cmdline_ipaddr_t ip_src;
8462 cmdline_fixed_string_t dst;
8463 cmdline_ipaddr_t ip_dst;
8465 cmdline_fixed_string_t verify_tag;
8466 uint32_t verify_tag_value;
8467 cmdline_ipaddr_t tos;
8469 cmdline_ipaddr_t proto;
8470 uint8_t proto_value;
8471 cmdline_ipaddr_t ttl;
8473 cmdline_fixed_string_t vlan;
8474 uint16_t vlan_value;
8475 cmdline_fixed_string_t flexbytes;
8476 cmdline_fixed_string_t flexbytes_value;
8477 cmdline_fixed_string_t pf_vf;
8478 cmdline_fixed_string_t drop;
8479 cmdline_fixed_string_t queue;
8481 cmdline_fixed_string_t fd_id;
8482 uint32_t fd_id_value;
8483 cmdline_fixed_string_t mac;
8484 struct ether_addr mac_addr;
8485 cmdline_fixed_string_t tunnel;
8486 cmdline_fixed_string_t tunnel_type;
8487 cmdline_fixed_string_t tunnel_id;
8488 uint32_t tunnel_id_value;
8492 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8495 const char *p, *p0 = q_arg;
8497 unsigned long int_fld;
8498 char *str_fld[max_num];
8503 p = strchr(p0, '(');
8507 p0 = strchr(p, ')');
8512 if (size >= sizeof(s))
8515 snprintf(s, sizeof(s), "%.*s", size, p);
8516 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8517 if (ret < 0 || ret > max_num)
8519 for (i = 0; i < ret; i++) {
8521 int_fld = strtoul(str_fld[i], &end, 0);
8522 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8524 flexbytes[i] = (uint8_t)int_fld;
8530 str2flowtype(char *string)
8533 static const struct {
8536 } flowtype_str[] = {
8537 {"raw", RTE_ETH_FLOW_RAW},
8538 {"ipv4", RTE_ETH_FLOW_IPV4},
8539 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8540 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8541 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8542 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8543 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8544 {"ipv6", RTE_ETH_FLOW_IPV6},
8545 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8546 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8547 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8548 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8549 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8550 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8553 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8554 if (!strcmp(flowtype_str[i].str, string))
8555 return flowtype_str[i].type;
8557 return RTE_ETH_FLOW_UNKNOWN;
8560 static enum rte_eth_fdir_tunnel_type
8561 str2fdir_tunneltype(char *string)
8565 static const struct {
8567 enum rte_eth_fdir_tunnel_type type;
8568 } tunneltype_str[] = {
8569 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8570 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8573 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8574 if (!strcmp(tunneltype_str[i].str, string))
8575 return tunneltype_str[i].type;
8577 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8580 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8582 if ((ip_addr).family == AF_INET) \
8583 (ip) = (ip_addr).addr.ipv4.s_addr; \
8585 printf("invalid parameter.\n"); \
8590 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8592 if ((ip_addr).family == AF_INET6) \
8593 (void)rte_memcpy(&(ip), \
8594 &((ip_addr).addr.ipv6), \
8595 sizeof(struct in6_addr)); \
8597 printf("invalid parameter.\n"); \
8603 cmd_flow_director_filter_parsed(void *parsed_result,
8604 __attribute__((unused)) struct cmdline *cl,
8605 __attribute__((unused)) void *data)
8607 struct cmd_flow_director_result *res = parsed_result;
8608 struct rte_eth_fdir_filter entry;
8609 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8611 unsigned long vf_id;
8614 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8616 printf("flow director is not supported on port %u.\n",
8620 memset(flexbytes, 0, sizeof(flexbytes));
8621 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8623 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8624 if (strcmp(res->mode_value, "MAC-VLAN")) {
8625 printf("Please set mode to MAC-VLAN.\n");
8628 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8629 if (strcmp(res->mode_value, "Tunnel")) {
8630 printf("Please set mode to Tunnel.\n");
8634 if (strcmp(res->mode_value, "IP")) {
8635 printf("Please set mode to IP.\n");
8638 entry.input.flow_type = str2flowtype(res->flow_type);
8641 ret = parse_flexbytes(res->flexbytes_value,
8643 RTE_ETH_FDIR_MAX_FLEXLEN);
8645 printf("error: Cannot parse flexbytes input.\n");
8649 switch (entry.input.flow_type) {
8650 case RTE_ETH_FLOW_FRAG_IPV4:
8651 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8652 entry.input.flow.ip4_flow.proto = res->proto_value;
8653 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8654 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8655 IPV4_ADDR_TO_UINT(res->ip_dst,
8656 entry.input.flow.ip4_flow.dst_ip);
8657 IPV4_ADDR_TO_UINT(res->ip_src,
8658 entry.input.flow.ip4_flow.src_ip);
8659 entry.input.flow.ip4_flow.tos = res->tos_value;
8660 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8661 /* need convert to big endian. */
8662 entry.input.flow.udp4_flow.dst_port =
8663 rte_cpu_to_be_16(res->port_dst);
8664 entry.input.flow.udp4_flow.src_port =
8665 rte_cpu_to_be_16(res->port_src);
8667 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8668 IPV4_ADDR_TO_UINT(res->ip_dst,
8669 entry.input.flow.sctp4_flow.ip.dst_ip);
8670 IPV4_ADDR_TO_UINT(res->ip_src,
8671 entry.input.flow.sctp4_flow.ip.src_ip);
8672 entry.input.flow.ip4_flow.tos = res->tos_value;
8673 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8674 /* need convert to big endian. */
8675 entry.input.flow.sctp4_flow.dst_port =
8676 rte_cpu_to_be_16(res->port_dst);
8677 entry.input.flow.sctp4_flow.src_port =
8678 rte_cpu_to_be_16(res->port_src);
8679 entry.input.flow.sctp4_flow.verify_tag =
8680 rte_cpu_to_be_32(res->verify_tag_value);
8682 case RTE_ETH_FLOW_FRAG_IPV6:
8683 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8684 entry.input.flow.ipv6_flow.proto = res->proto_value;
8685 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8686 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8687 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8688 entry.input.flow.ipv6_flow.dst_ip);
8689 IPV6_ADDR_TO_ARRAY(res->ip_src,
8690 entry.input.flow.ipv6_flow.src_ip);
8691 entry.input.flow.ipv6_flow.tc = res->tos_value;
8692 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8693 /* need convert to big endian. */
8694 entry.input.flow.udp6_flow.dst_port =
8695 rte_cpu_to_be_16(res->port_dst);
8696 entry.input.flow.udp6_flow.src_port =
8697 rte_cpu_to_be_16(res->port_src);
8699 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8700 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8701 entry.input.flow.sctp6_flow.ip.dst_ip);
8702 IPV6_ADDR_TO_ARRAY(res->ip_src,
8703 entry.input.flow.sctp6_flow.ip.src_ip);
8704 entry.input.flow.ipv6_flow.tc = res->tos_value;
8705 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8706 /* need convert to big endian. */
8707 entry.input.flow.sctp6_flow.dst_port =
8708 rte_cpu_to_be_16(res->port_dst);
8709 entry.input.flow.sctp6_flow.src_port =
8710 rte_cpu_to_be_16(res->port_src);
8711 entry.input.flow.sctp6_flow.verify_tag =
8712 rte_cpu_to_be_32(res->verify_tag_value);
8714 case RTE_ETH_FLOW_L2_PAYLOAD:
8715 entry.input.flow.l2_flow.ether_type =
8716 rte_cpu_to_be_16(res->ether_type);
8722 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8723 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8725 sizeof(struct ether_addr));
8727 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8728 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8730 sizeof(struct ether_addr));
8731 entry.input.flow.tunnel_flow.tunnel_type =
8732 str2fdir_tunneltype(res->tunnel_type);
8733 entry.input.flow.tunnel_flow.tunnel_id =
8734 rte_cpu_to_be_32(res->tunnel_id_value);
8737 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8739 RTE_ETH_FDIR_MAX_FLEXLEN);
8741 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8743 entry.action.flex_off = 0; /*use 0 by default */
8744 if (!strcmp(res->drop, "drop"))
8745 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8747 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8749 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8750 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8751 if (!strcmp(res->pf_vf, "pf"))
8752 entry.input.flow_ext.is_vf = 0;
8753 else if (!strncmp(res->pf_vf, "vf", 2)) {
8754 struct rte_eth_dev_info dev_info;
8756 memset(&dev_info, 0, sizeof(dev_info));
8757 rte_eth_dev_info_get(res->port_id, &dev_info);
8759 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8760 if (errno != 0 || *end != '\0' ||
8761 vf_id >= dev_info.max_vfs) {
8762 printf("invalid parameter %s.\n", res->pf_vf);
8765 entry.input.flow_ext.is_vf = 1;
8766 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8768 printf("invalid parameter %s.\n", res->pf_vf);
8773 /* set to report FD ID by default */
8774 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8775 entry.action.rx_queue = res->queue_id;
8776 entry.soft_id = res->fd_id_value;
8777 if (!strcmp(res->ops, "add"))
8778 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8779 RTE_ETH_FILTER_ADD, &entry);
8780 else if (!strcmp(res->ops, "del"))
8781 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8782 RTE_ETH_FILTER_DELETE, &entry);
8784 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8785 RTE_ETH_FILTER_UPDATE, &entry);
8787 printf("flow director programming error: (%s)\n",
8791 cmdline_parse_token_string_t cmd_flow_director_filter =
8792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8793 flow_director_filter, "flow_director_filter");
8794 cmdline_parse_token_num_t cmd_flow_director_port_id =
8795 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8797 cmdline_parse_token_string_t cmd_flow_director_ops =
8798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8799 ops, "add#del#update");
8800 cmdline_parse_token_string_t cmd_flow_director_flow =
8801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8803 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8804 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8805 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8806 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8807 cmdline_parse_token_string_t cmd_flow_director_ether =
8808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8810 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8811 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8812 ether_type, UINT16);
8813 cmdline_parse_token_string_t cmd_flow_director_src =
8814 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8816 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8817 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8819 cmdline_parse_token_num_t cmd_flow_director_port_src =
8820 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8822 cmdline_parse_token_string_t cmd_flow_director_dst =
8823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8825 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8826 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8828 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8829 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8831 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8833 verify_tag, "verify_tag");
8834 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8835 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8836 verify_tag_value, UINT32);
8837 cmdline_parse_token_string_t cmd_flow_director_tos =
8838 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8840 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8841 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8843 cmdline_parse_token_string_t cmd_flow_director_proto =
8844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8846 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8847 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8848 proto_value, UINT8);
8849 cmdline_parse_token_string_t cmd_flow_director_ttl =
8850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8852 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8853 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8855 cmdline_parse_token_string_t cmd_flow_director_vlan =
8856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8858 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8859 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8860 vlan_value, UINT16);
8861 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8863 flexbytes, "flexbytes");
8864 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8866 flexbytes_value, NULL);
8867 cmdline_parse_token_string_t cmd_flow_director_drop =
8868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8870 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8873 cmdline_parse_token_string_t cmd_flow_director_queue =
8874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8876 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8877 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8879 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8882 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8883 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8884 fd_id_value, UINT32);
8886 cmdline_parse_token_string_t cmd_flow_director_mode =
8887 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8889 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8890 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8892 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8893 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8894 mode_value, "MAC-VLAN");
8895 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8896 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8897 mode_value, "Tunnel");
8898 cmdline_parse_token_string_t cmd_flow_director_mac =
8899 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8901 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8902 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8904 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8905 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8907 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8908 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8909 tunnel_type, "NVGRE#VxLAN");
8910 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8911 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8912 tunnel_id, "tunnel-id");
8913 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8914 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8915 tunnel_id_value, UINT32);
8917 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8918 .f = cmd_flow_director_filter_parsed,
8920 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8921 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8922 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8923 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8924 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8925 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8926 "fd_id <fd_id_value>: "
8927 "Add or delete an ip flow director entry on NIC",
8929 (void *)&cmd_flow_director_filter,
8930 (void *)&cmd_flow_director_port_id,
8931 (void *)&cmd_flow_director_mode,
8932 (void *)&cmd_flow_director_mode_ip,
8933 (void *)&cmd_flow_director_ops,
8934 (void *)&cmd_flow_director_flow,
8935 (void *)&cmd_flow_director_flow_type,
8936 (void *)&cmd_flow_director_src,
8937 (void *)&cmd_flow_director_ip_src,
8938 (void *)&cmd_flow_director_dst,
8939 (void *)&cmd_flow_director_ip_dst,
8940 (void *)&cmd_flow_director_tos,
8941 (void *)&cmd_flow_director_tos_value,
8942 (void *)&cmd_flow_director_proto,
8943 (void *)&cmd_flow_director_proto_value,
8944 (void *)&cmd_flow_director_ttl,
8945 (void *)&cmd_flow_director_ttl_value,
8946 (void *)&cmd_flow_director_vlan,
8947 (void *)&cmd_flow_director_vlan_value,
8948 (void *)&cmd_flow_director_flexbytes,
8949 (void *)&cmd_flow_director_flexbytes_value,
8950 (void *)&cmd_flow_director_drop,
8951 (void *)&cmd_flow_director_pf_vf,
8952 (void *)&cmd_flow_director_queue,
8953 (void *)&cmd_flow_director_queue_id,
8954 (void *)&cmd_flow_director_fd_id,
8955 (void *)&cmd_flow_director_fd_id_value,
8960 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8961 .f = cmd_flow_director_filter_parsed,
8963 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8964 "director entry on NIC",
8966 (void *)&cmd_flow_director_filter,
8967 (void *)&cmd_flow_director_port_id,
8968 (void *)&cmd_flow_director_mode,
8969 (void *)&cmd_flow_director_mode_ip,
8970 (void *)&cmd_flow_director_ops,
8971 (void *)&cmd_flow_director_flow,
8972 (void *)&cmd_flow_director_flow_type,
8973 (void *)&cmd_flow_director_src,
8974 (void *)&cmd_flow_director_ip_src,
8975 (void *)&cmd_flow_director_port_src,
8976 (void *)&cmd_flow_director_dst,
8977 (void *)&cmd_flow_director_ip_dst,
8978 (void *)&cmd_flow_director_port_dst,
8979 (void *)&cmd_flow_director_tos,
8980 (void *)&cmd_flow_director_tos_value,
8981 (void *)&cmd_flow_director_ttl,
8982 (void *)&cmd_flow_director_ttl_value,
8983 (void *)&cmd_flow_director_vlan,
8984 (void *)&cmd_flow_director_vlan_value,
8985 (void *)&cmd_flow_director_flexbytes,
8986 (void *)&cmd_flow_director_flexbytes_value,
8987 (void *)&cmd_flow_director_drop,
8988 (void *)&cmd_flow_director_pf_vf,
8989 (void *)&cmd_flow_director_queue,
8990 (void *)&cmd_flow_director_queue_id,
8991 (void *)&cmd_flow_director_fd_id,
8992 (void *)&cmd_flow_director_fd_id_value,
8997 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8998 .f = cmd_flow_director_filter_parsed,
9000 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9001 "director entry on NIC",
9003 (void *)&cmd_flow_director_filter,
9004 (void *)&cmd_flow_director_port_id,
9005 (void *)&cmd_flow_director_mode,
9006 (void *)&cmd_flow_director_mode_ip,
9007 (void *)&cmd_flow_director_ops,
9008 (void *)&cmd_flow_director_flow,
9009 (void *)&cmd_flow_director_flow_type,
9010 (void *)&cmd_flow_director_src,
9011 (void *)&cmd_flow_director_ip_src,
9012 (void *)&cmd_flow_director_port_dst,
9013 (void *)&cmd_flow_director_dst,
9014 (void *)&cmd_flow_director_ip_dst,
9015 (void *)&cmd_flow_director_port_dst,
9016 (void *)&cmd_flow_director_verify_tag,
9017 (void *)&cmd_flow_director_verify_tag_value,
9018 (void *)&cmd_flow_director_tos,
9019 (void *)&cmd_flow_director_tos_value,
9020 (void *)&cmd_flow_director_ttl,
9021 (void *)&cmd_flow_director_ttl_value,
9022 (void *)&cmd_flow_director_vlan,
9023 (void *)&cmd_flow_director_vlan_value,
9024 (void *)&cmd_flow_director_flexbytes,
9025 (void *)&cmd_flow_director_flexbytes_value,
9026 (void *)&cmd_flow_director_drop,
9027 (void *)&cmd_flow_director_pf_vf,
9028 (void *)&cmd_flow_director_queue,
9029 (void *)&cmd_flow_director_queue_id,
9030 (void *)&cmd_flow_director_fd_id,
9031 (void *)&cmd_flow_director_fd_id_value,
9036 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9037 .f = cmd_flow_director_filter_parsed,
9039 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9040 "director entry on NIC",
9042 (void *)&cmd_flow_director_filter,
9043 (void *)&cmd_flow_director_port_id,
9044 (void *)&cmd_flow_director_mode,
9045 (void *)&cmd_flow_director_mode_ip,
9046 (void *)&cmd_flow_director_ops,
9047 (void *)&cmd_flow_director_flow,
9048 (void *)&cmd_flow_director_flow_type,
9049 (void *)&cmd_flow_director_ether,
9050 (void *)&cmd_flow_director_ether_type,
9051 (void *)&cmd_flow_director_flexbytes,
9052 (void *)&cmd_flow_director_flexbytes_value,
9053 (void *)&cmd_flow_director_drop,
9054 (void *)&cmd_flow_director_pf_vf,
9055 (void *)&cmd_flow_director_queue,
9056 (void *)&cmd_flow_director_queue_id,
9057 (void *)&cmd_flow_director_fd_id,
9058 (void *)&cmd_flow_director_fd_id_value,
9063 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9064 .f = cmd_flow_director_filter_parsed,
9066 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9067 "director entry on NIC",
9069 (void *)&cmd_flow_director_filter,
9070 (void *)&cmd_flow_director_port_id,
9071 (void *)&cmd_flow_director_mode,
9072 (void *)&cmd_flow_director_mode_mac_vlan,
9073 (void *)&cmd_flow_director_ops,
9074 (void *)&cmd_flow_director_mac,
9075 (void *)&cmd_flow_director_mac_addr,
9076 (void *)&cmd_flow_director_vlan,
9077 (void *)&cmd_flow_director_vlan_value,
9078 (void *)&cmd_flow_director_flexbytes,
9079 (void *)&cmd_flow_director_flexbytes_value,
9080 (void *)&cmd_flow_director_drop,
9081 (void *)&cmd_flow_director_queue,
9082 (void *)&cmd_flow_director_queue_id,
9083 (void *)&cmd_flow_director_fd_id,
9084 (void *)&cmd_flow_director_fd_id_value,
9089 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9090 .f = cmd_flow_director_filter_parsed,
9092 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9093 "director entry on NIC",
9095 (void *)&cmd_flow_director_filter,
9096 (void *)&cmd_flow_director_port_id,
9097 (void *)&cmd_flow_director_mode,
9098 (void *)&cmd_flow_director_mode_tunnel,
9099 (void *)&cmd_flow_director_ops,
9100 (void *)&cmd_flow_director_mac,
9101 (void *)&cmd_flow_director_mac_addr,
9102 (void *)&cmd_flow_director_vlan,
9103 (void *)&cmd_flow_director_vlan_value,
9104 (void *)&cmd_flow_director_tunnel,
9105 (void *)&cmd_flow_director_tunnel_type,
9106 (void *)&cmd_flow_director_tunnel_id,
9107 (void *)&cmd_flow_director_tunnel_id_value,
9108 (void *)&cmd_flow_director_flexbytes,
9109 (void *)&cmd_flow_director_flexbytes_value,
9110 (void *)&cmd_flow_director_drop,
9111 (void *)&cmd_flow_director_queue,
9112 (void *)&cmd_flow_director_queue_id,
9113 (void *)&cmd_flow_director_fd_id,
9114 (void *)&cmd_flow_director_fd_id_value,
9119 struct cmd_flush_flow_director_result {
9120 cmdline_fixed_string_t flush_flow_director;
9124 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9125 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9126 flush_flow_director, "flush_flow_director");
9127 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9128 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9132 cmd_flush_flow_director_parsed(void *parsed_result,
9133 __attribute__((unused)) struct cmdline *cl,
9134 __attribute__((unused)) void *data)
9136 struct cmd_flow_director_result *res = parsed_result;
9139 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9141 printf("flow director is not supported on port %u.\n",
9146 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9147 RTE_ETH_FILTER_FLUSH, NULL);
9149 printf("flow director table flushing error: (%s)\n",
9153 cmdline_parse_inst_t cmd_flush_flow_director = {
9154 .f = cmd_flush_flow_director_parsed,
9156 .help_str = "flush_flow_director <port_id>: "
9157 "Flush all flow director entries of a device on NIC",
9159 (void *)&cmd_flush_flow_director_flush,
9160 (void *)&cmd_flush_flow_director_port_id,
9165 /* *** deal with flow director mask *** */
9166 struct cmd_flow_director_mask_result {
9167 cmdline_fixed_string_t flow_director_mask;
9169 cmdline_fixed_string_t mode;
9170 cmdline_fixed_string_t mode_value;
9171 cmdline_fixed_string_t vlan;
9173 cmdline_fixed_string_t src_mask;
9174 cmdline_ipaddr_t ipv4_src;
9175 cmdline_ipaddr_t ipv6_src;
9177 cmdline_fixed_string_t dst_mask;
9178 cmdline_ipaddr_t ipv4_dst;
9179 cmdline_ipaddr_t ipv6_dst;
9181 cmdline_fixed_string_t mac;
9182 uint8_t mac_addr_byte_mask;
9183 cmdline_fixed_string_t tunnel_id;
9184 uint32_t tunnel_id_mask;
9185 cmdline_fixed_string_t tunnel_type;
9186 uint8_t tunnel_type_mask;
9190 cmd_flow_director_mask_parsed(void *parsed_result,
9191 __attribute__((unused)) struct cmdline *cl,
9192 __attribute__((unused)) void *data)
9194 struct cmd_flow_director_mask_result *res = parsed_result;
9195 struct rte_eth_fdir_masks *mask;
9196 struct rte_port *port;
9198 if (res->port_id > nb_ports) {
9199 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9203 port = &ports[res->port_id];
9204 /** Check if the port is not started **/
9205 if (port->port_status != RTE_PORT_STOPPED) {
9206 printf("Please stop port %d first\n", res->port_id);
9210 mask = &port->dev_conf.fdir_conf.mask;
9212 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9213 if (strcmp(res->mode_value, "MAC-VLAN")) {
9214 printf("Please set mode to MAC-VLAN.\n");
9218 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9219 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9220 if (strcmp(res->mode_value, "Tunnel")) {
9221 printf("Please set mode to Tunnel.\n");
9225 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9226 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9227 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9228 mask->tunnel_type_mask = res->tunnel_type_mask;
9230 if (strcmp(res->mode_value, "IP")) {
9231 printf("Please set mode to IP.\n");
9235 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9236 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9237 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9238 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9239 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9240 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9241 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9244 cmd_reconfig_device_queue(res->port_id, 1, 1);
9247 cmdline_parse_token_string_t cmd_flow_director_mask =
9248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9249 flow_director_mask, "flow_director_mask");
9250 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9251 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9253 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9256 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9257 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9259 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9261 src_mask, "src_mask");
9262 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9263 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9265 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9266 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9268 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9269 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9271 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9273 dst_mask, "dst_mask");
9274 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9275 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9277 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9278 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9280 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9281 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9284 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9287 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9288 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9290 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9292 mode_value, "MAC-VLAN");
9293 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9295 mode_value, "Tunnel");
9296 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9299 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9300 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9301 mac_addr_byte_mask, UINT8);
9302 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9304 tunnel_type, "tunnel-type");
9305 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9306 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9307 tunnel_type_mask, UINT8);
9308 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9310 tunnel_id, "tunnel-id");
9311 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9313 tunnel_id_mask, UINT32);
9315 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9316 .f = cmd_flow_director_mask_parsed,
9318 .help_str = "flow_director_mask ... : "
9319 "Set IP mode flow director's mask on NIC",
9321 (void *)&cmd_flow_director_mask,
9322 (void *)&cmd_flow_director_mask_port_id,
9323 (void *)&cmd_flow_director_mask_mode,
9324 (void *)&cmd_flow_director_mask_mode_ip,
9325 (void *)&cmd_flow_director_mask_vlan,
9326 (void *)&cmd_flow_director_mask_vlan_value,
9327 (void *)&cmd_flow_director_mask_src,
9328 (void *)&cmd_flow_director_mask_ipv4_src,
9329 (void *)&cmd_flow_director_mask_ipv6_src,
9330 (void *)&cmd_flow_director_mask_port_src,
9331 (void *)&cmd_flow_director_mask_dst,
9332 (void *)&cmd_flow_director_mask_ipv4_dst,
9333 (void *)&cmd_flow_director_mask_ipv6_dst,
9334 (void *)&cmd_flow_director_mask_port_dst,
9339 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9340 .f = cmd_flow_director_mask_parsed,
9342 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9343 "flow director's mask on NIC",
9345 (void *)&cmd_flow_director_mask,
9346 (void *)&cmd_flow_director_mask_port_id,
9347 (void *)&cmd_flow_director_mask_mode,
9348 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9349 (void *)&cmd_flow_director_mask_vlan,
9350 (void *)&cmd_flow_director_mask_vlan_value,
9355 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9356 .f = cmd_flow_director_mask_parsed,
9358 .help_str = "flow_director_mask ... : Set tunnel mode "
9359 "flow director's mask on NIC",
9361 (void *)&cmd_flow_director_mask,
9362 (void *)&cmd_flow_director_mask_port_id,
9363 (void *)&cmd_flow_director_mask_mode,
9364 (void *)&cmd_flow_director_mask_mode_tunnel,
9365 (void *)&cmd_flow_director_mask_vlan,
9366 (void *)&cmd_flow_director_mask_vlan_value,
9367 (void *)&cmd_flow_director_mask_mac,
9368 (void *)&cmd_flow_director_mask_mac_value,
9369 (void *)&cmd_flow_director_mask_tunnel_type,
9370 (void *)&cmd_flow_director_mask_tunnel_type_value,
9371 (void *)&cmd_flow_director_mask_tunnel_id,
9372 (void *)&cmd_flow_director_mask_tunnel_id_value,
9377 /* *** deal with flow director mask on flexible payload *** */
9378 struct cmd_flow_director_flex_mask_result {
9379 cmdline_fixed_string_t flow_director_flexmask;
9381 cmdline_fixed_string_t flow;
9382 cmdline_fixed_string_t flow_type;
9383 cmdline_fixed_string_t mask;
9387 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9388 __attribute__((unused)) struct cmdline *cl,
9389 __attribute__((unused)) void *data)
9391 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9392 struct rte_eth_fdir_info fdir_info;
9393 struct rte_eth_fdir_flex_mask flex_mask;
9394 struct rte_port *port;
9395 uint32_t flow_type_mask;
9399 if (res->port_id > nb_ports) {
9400 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9404 port = &ports[res->port_id];
9405 /** Check if the port is not started **/
9406 if (port->port_status != RTE_PORT_STOPPED) {
9407 printf("Please stop port %d first\n", res->port_id);
9411 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9412 ret = parse_flexbytes(res->mask,
9414 RTE_ETH_FDIR_MAX_FLEXLEN);
9416 printf("error: Cannot parse mask input.\n");
9420 memset(&fdir_info, 0, sizeof(fdir_info));
9421 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9422 RTE_ETH_FILTER_INFO, &fdir_info);
9424 printf("Cannot get FDir filter info\n");
9428 if (!strcmp(res->flow_type, "none")) {
9429 /* means don't specify the flow type */
9430 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9431 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9432 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9433 0, sizeof(struct rte_eth_fdir_flex_mask));
9434 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9435 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9437 sizeof(struct rte_eth_fdir_flex_mask));
9438 cmd_reconfig_device_queue(res->port_id, 1, 1);
9441 flow_type_mask = fdir_info.flow_types_mask[0];
9442 if (!strcmp(res->flow_type, "all")) {
9443 if (!flow_type_mask) {
9444 printf("No flow type supported\n");
9447 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9448 if (flow_type_mask & (1 << i)) {
9449 flex_mask.flow_type = i;
9450 fdir_set_flex_mask(res->port_id, &flex_mask);
9453 cmd_reconfig_device_queue(res->port_id, 1, 1);
9456 flex_mask.flow_type = str2flowtype(res->flow_type);
9457 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9458 printf("Flow type %s not supported on port %d\n",
9459 res->flow_type, res->port_id);
9462 fdir_set_flex_mask(res->port_id, &flex_mask);
9463 cmd_reconfig_device_queue(res->port_id, 1, 1);
9466 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9468 flow_director_flexmask,
9469 "flow_director_flex_mask");
9470 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9471 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9473 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9474 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9476 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9477 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9478 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9479 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9480 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9481 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9484 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9485 .f = cmd_flow_director_flex_mask_parsed,
9487 .help_str = "flow_director_flex_mask ... : "
9488 "Set flow director's flex mask on NIC",
9490 (void *)&cmd_flow_director_flexmask,
9491 (void *)&cmd_flow_director_flexmask_port_id,
9492 (void *)&cmd_flow_director_flexmask_flow,
9493 (void *)&cmd_flow_director_flexmask_flow_type,
9494 (void *)&cmd_flow_director_flexmask_mask,
9499 /* *** deal with flow director flexible payload configuration *** */
9500 struct cmd_flow_director_flexpayload_result {
9501 cmdline_fixed_string_t flow_director_flexpayload;
9503 cmdline_fixed_string_t payload_layer;
9504 cmdline_fixed_string_t payload_cfg;
9508 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9511 const char *p, *p0 = q_arg;
9513 unsigned long int_fld;
9514 char *str_fld[max_num];
9519 p = strchr(p0, '(');
9523 p0 = strchr(p, ')');
9528 if (size >= sizeof(s))
9531 snprintf(s, sizeof(s), "%.*s", size, p);
9532 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9533 if (ret < 0 || ret > max_num)
9535 for (i = 0; i < ret; i++) {
9537 int_fld = strtoul(str_fld[i], &end, 0);
9538 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9540 offsets[i] = (uint16_t)int_fld;
9546 cmd_flow_director_flxpld_parsed(void *parsed_result,
9547 __attribute__((unused)) struct cmdline *cl,
9548 __attribute__((unused)) void *data)
9550 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9551 struct rte_eth_flex_payload_cfg flex_cfg;
9552 struct rte_port *port;
9555 if (res->port_id > nb_ports) {
9556 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9560 port = &ports[res->port_id];
9561 /** Check if the port is not started **/
9562 if (port->port_status != RTE_PORT_STOPPED) {
9563 printf("Please stop port %d first\n", res->port_id);
9567 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9569 if (!strcmp(res->payload_layer, "raw"))
9570 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9571 else if (!strcmp(res->payload_layer, "l2"))
9572 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9573 else if (!strcmp(res->payload_layer, "l3"))
9574 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9575 else if (!strcmp(res->payload_layer, "l4"))
9576 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9578 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9579 RTE_ETH_FDIR_MAX_FLEXLEN);
9581 printf("error: Cannot parse flex payload input.\n");
9585 fdir_set_flex_payload(res->port_id, &flex_cfg);
9586 cmd_reconfig_device_queue(res->port_id, 1, 1);
9589 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9590 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9591 flow_director_flexpayload,
9592 "flow_director_flex_payload");
9593 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9594 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9596 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9597 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9598 payload_layer, "raw#l2#l3#l4");
9599 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9600 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9603 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9604 .f = cmd_flow_director_flxpld_parsed,
9606 .help_str = "flow_director_flexpayload ... : "
9607 "Set flow director's flex payload on NIC",
9609 (void *)&cmd_flow_director_flexpayload,
9610 (void *)&cmd_flow_director_flexpayload_port_id,
9611 (void *)&cmd_flow_director_flexpayload_payload_layer,
9612 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9617 /* Generic flow interface command. */
9618 extern cmdline_parse_inst_t cmd_flow;
9620 /* *** Classification Filters Control *** */
9621 /* *** Get symmetric hash enable per port *** */
9622 struct cmd_get_sym_hash_ena_per_port_result {
9623 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9628 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9629 __rte_unused struct cmdline *cl,
9630 __rte_unused void *data)
9632 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9633 struct rte_eth_hash_filter_info info;
9636 if (rte_eth_dev_filter_supported(res->port_id,
9637 RTE_ETH_FILTER_HASH) < 0) {
9638 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9643 memset(&info, 0, sizeof(info));
9644 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9645 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9646 RTE_ETH_FILTER_GET, &info);
9649 printf("Cannot get symmetric hash enable per port "
9650 "on port %u\n", res->port_id);
9654 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9655 "enabled" : "disabled", res->port_id);
9658 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9659 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9660 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9661 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9662 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9665 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9666 .f = cmd_get_sym_hash_per_port_parsed,
9668 .help_str = "get_sym_hash_ena_per_port <port_id>",
9670 (void *)&cmd_get_sym_hash_ena_per_port_all,
9671 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9676 /* *** Set symmetric hash enable per port *** */
9677 struct cmd_set_sym_hash_ena_per_port_result {
9678 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9679 cmdline_fixed_string_t enable;
9684 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9685 __rte_unused struct cmdline *cl,
9686 __rte_unused void *data)
9688 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9689 struct rte_eth_hash_filter_info info;
9692 if (rte_eth_dev_filter_supported(res->port_id,
9693 RTE_ETH_FILTER_HASH) < 0) {
9694 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9699 memset(&info, 0, sizeof(info));
9700 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9701 if (!strcmp(res->enable, "enable"))
9702 info.info.enable = 1;
9703 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9704 RTE_ETH_FILTER_SET, &info);
9706 printf("Cannot set symmetric hash enable per port on "
9707 "port %u\n", res->port_id);
9710 printf("Symmetric hash has been set to %s on port %u\n",
9711 res->enable, res->port_id);
9714 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9715 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9716 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9717 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9718 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9720 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9721 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9722 enable, "enable#disable");
9724 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9725 .f = cmd_set_sym_hash_per_port_parsed,
9727 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9729 (void *)&cmd_set_sym_hash_ena_per_port_all,
9730 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9731 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9736 /* Get global config of hash function */
9737 struct cmd_get_hash_global_config_result {
9738 cmdline_fixed_string_t get_hash_global_config;
9743 flowtype_to_str(uint16_t ftype)
9750 {"ipv4", RTE_ETH_FLOW_IPV4},
9751 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9752 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9753 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9754 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9755 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9756 {"ipv6", RTE_ETH_FLOW_IPV6},
9757 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9758 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9759 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9760 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9761 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9762 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9763 {"port", RTE_ETH_FLOW_PORT},
9764 {"vxlan", RTE_ETH_FLOW_VXLAN},
9765 {"geneve", RTE_ETH_FLOW_GENEVE},
9766 {"nvgre", RTE_ETH_FLOW_NVGRE},
9769 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9770 if (ftype_table[i].ftype == ftype)
9771 return ftype_table[i].str;
9778 cmd_get_hash_global_config_parsed(void *parsed_result,
9779 __rte_unused struct cmdline *cl,
9780 __rte_unused void *data)
9782 struct cmd_get_hash_global_config_result *res = parsed_result;
9783 struct rte_eth_hash_filter_info info;
9784 uint32_t idx, offset;
9789 if (rte_eth_dev_filter_supported(res->port_id,
9790 RTE_ETH_FILTER_HASH) < 0) {
9791 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9796 memset(&info, 0, sizeof(info));
9797 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9798 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9799 RTE_ETH_FILTER_GET, &info);
9801 printf("Cannot get hash global configurations by port %d\n",
9806 switch (info.info.global_conf.hash_func) {
9807 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9808 printf("Hash function is Toeplitz\n");
9810 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9811 printf("Hash function is Simple XOR\n");
9814 printf("Unknown hash function\n");
9818 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9819 idx = i / UINT32_BIT;
9820 offset = i % UINT32_BIT;
9821 if (!(info.info.global_conf.valid_bit_mask[idx] &
9824 str = flowtype_to_str(i);
9827 printf("Symmetric hash is %s globally for flow type %s "
9829 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9830 (1UL << offset)) ? "enabled" : "disabled"), str,
9835 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9836 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9837 get_hash_global_config, "get_hash_global_config");
9838 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9839 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9842 cmdline_parse_inst_t cmd_get_hash_global_config = {
9843 .f = cmd_get_hash_global_config_parsed,
9845 .help_str = "get_hash_global_config <port_id>",
9847 (void *)&cmd_get_hash_global_config_all,
9848 (void *)&cmd_get_hash_global_config_port_id,
9853 /* Set global config of hash function */
9854 struct cmd_set_hash_global_config_result {
9855 cmdline_fixed_string_t set_hash_global_config;
9857 cmdline_fixed_string_t hash_func;
9858 cmdline_fixed_string_t flow_type;
9859 cmdline_fixed_string_t enable;
9863 cmd_set_hash_global_config_parsed(void *parsed_result,
9864 __rte_unused struct cmdline *cl,
9865 __rte_unused void *data)
9867 struct cmd_set_hash_global_config_result *res = parsed_result;
9868 struct rte_eth_hash_filter_info info;
9869 uint32_t ftype, idx, offset;
9872 if (rte_eth_dev_filter_supported(res->port_id,
9873 RTE_ETH_FILTER_HASH) < 0) {
9874 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9878 memset(&info, 0, sizeof(info));
9879 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9880 if (!strcmp(res->hash_func, "toeplitz"))
9881 info.info.global_conf.hash_func =
9882 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9883 else if (!strcmp(res->hash_func, "simple_xor"))
9884 info.info.global_conf.hash_func =
9885 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9886 else if (!strcmp(res->hash_func, "default"))
9887 info.info.global_conf.hash_func =
9888 RTE_ETH_HASH_FUNCTION_DEFAULT;
9890 ftype = str2flowtype(res->flow_type);
9891 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9892 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9893 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9894 if (!strcmp(res->enable, "enable"))
9895 info.info.global_conf.sym_hash_enable_mask[idx] |=
9897 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9898 RTE_ETH_FILTER_SET, &info);
9900 printf("Cannot set global hash configurations by port %d\n",
9903 printf("Global hash configurations have been set "
9904 "succcessfully by port %d\n", res->port_id);
9907 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9908 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9909 set_hash_global_config, "set_hash_global_config");
9910 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9911 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9913 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9914 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9915 hash_func, "toeplitz#simple_xor#default");
9916 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9917 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9919 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9920 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9921 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9922 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9923 enable, "enable#disable");
9925 cmdline_parse_inst_t cmd_set_hash_global_config = {
9926 .f = cmd_set_hash_global_config_parsed,
9928 .help_str = "set_hash_global_config <port_id> "
9929 "toeplitz|simple_xor|default "
9930 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9931 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9932 "l2_payload enable|disable",
9934 (void *)&cmd_set_hash_global_config_all,
9935 (void *)&cmd_set_hash_global_config_port_id,
9936 (void *)&cmd_set_hash_global_config_hash_func,
9937 (void *)&cmd_set_hash_global_config_flow_type,
9938 (void *)&cmd_set_hash_global_config_enable,
9943 /* Set hash input set */
9944 struct cmd_set_hash_input_set_result {
9945 cmdline_fixed_string_t set_hash_input_set;
9947 cmdline_fixed_string_t flow_type;
9948 cmdline_fixed_string_t inset_field;
9949 cmdline_fixed_string_t select;
9952 static enum rte_eth_input_set_field
9953 str2inset(char *string)
9957 static const struct {
9959 enum rte_eth_input_set_field inset;
9961 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9962 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9963 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9964 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9965 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9966 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9967 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9968 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9969 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9970 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9971 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9972 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9973 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9974 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9975 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9976 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9977 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9978 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9979 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9980 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9981 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9982 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9983 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9984 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9985 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9986 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9987 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9988 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9989 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9990 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9991 {"none", RTE_ETH_INPUT_SET_NONE},
9994 for (i = 0; i < RTE_DIM(inset_table); i++) {
9995 if (!strcmp(string, inset_table[i].str))
9996 return inset_table[i].inset;
9999 return RTE_ETH_INPUT_SET_UNKNOWN;
10003 cmd_set_hash_input_set_parsed(void *parsed_result,
10004 __rte_unused struct cmdline *cl,
10005 __rte_unused void *data)
10007 struct cmd_set_hash_input_set_result *res = parsed_result;
10008 struct rte_eth_hash_filter_info info;
10010 memset(&info, 0, sizeof(info));
10011 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10012 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10013 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10014 info.info.input_set_conf.inset_size = 1;
10015 if (!strcmp(res->select, "select"))
10016 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10017 else if (!strcmp(res->select, "add"))
10018 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10019 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10020 RTE_ETH_FILTER_SET, &info);
10023 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10024 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10025 set_hash_input_set, "set_hash_input_set");
10026 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10027 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10029 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10030 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10032 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10033 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10034 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10035 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10037 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10038 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10039 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10040 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10041 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10043 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10044 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10045 select, "select#add");
10047 cmdline_parse_inst_t cmd_set_hash_input_set = {
10048 .f = cmd_set_hash_input_set_parsed,
10050 .help_str = "set_hash_input_set <port_id> "
10051 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10052 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10053 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10054 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10055 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10056 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10057 "fld-7th|fld-8th|none select|add",
10059 (void *)&cmd_set_hash_input_set_cmd,
10060 (void *)&cmd_set_hash_input_set_port_id,
10061 (void *)&cmd_set_hash_input_set_flow_type,
10062 (void *)&cmd_set_hash_input_set_field,
10063 (void *)&cmd_set_hash_input_set_select,
10068 /* Set flow director input set */
10069 struct cmd_set_fdir_input_set_result {
10070 cmdline_fixed_string_t set_fdir_input_set;
10072 cmdline_fixed_string_t flow_type;
10073 cmdline_fixed_string_t inset_field;
10074 cmdline_fixed_string_t select;
10078 cmd_set_fdir_input_set_parsed(void *parsed_result,
10079 __rte_unused struct cmdline *cl,
10080 __rte_unused void *data)
10082 struct cmd_set_fdir_input_set_result *res = parsed_result;
10083 struct rte_eth_fdir_filter_info info;
10085 memset(&info, 0, sizeof(info));
10086 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10087 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10088 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10089 info.info.input_set_conf.inset_size = 1;
10090 if (!strcmp(res->select, "select"))
10091 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10092 else if (!strcmp(res->select, "add"))
10093 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10094 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10095 RTE_ETH_FILTER_SET, &info);
10098 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10099 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10100 set_fdir_input_set, "set_fdir_input_set");
10101 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10102 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10104 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10105 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10107 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10108 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10109 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10110 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10112 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10113 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10114 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10115 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10116 "sctp-veri-tag#none");
10117 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10118 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10119 select, "select#add");
10121 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10122 .f = cmd_set_fdir_input_set_parsed,
10124 .help_str = "set_fdir_input_set <port_id> "
10125 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10126 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10127 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10128 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10129 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10130 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10131 "sctp-veri-tag|none select|add",
10133 (void *)&cmd_set_fdir_input_set_cmd,
10134 (void *)&cmd_set_fdir_input_set_port_id,
10135 (void *)&cmd_set_fdir_input_set_flow_type,
10136 (void *)&cmd_set_fdir_input_set_field,
10137 (void *)&cmd_set_fdir_input_set_select,
10142 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10143 struct cmd_mcast_addr_result {
10144 cmdline_fixed_string_t mcast_addr_cmd;
10145 cmdline_fixed_string_t what;
10147 struct ether_addr mc_addr;
10150 static void cmd_mcast_addr_parsed(void *parsed_result,
10151 __attribute__((unused)) struct cmdline *cl,
10152 __attribute__((unused)) void *data)
10154 struct cmd_mcast_addr_result *res = parsed_result;
10156 if (!is_multicast_ether_addr(&res->mc_addr)) {
10157 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10158 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10159 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10160 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10163 if (strcmp(res->what, "add") == 0)
10164 mcast_addr_add(res->port_num, &res->mc_addr);
10166 mcast_addr_remove(res->port_num, &res->mc_addr);
10169 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10170 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10171 mcast_addr_cmd, "mcast_addr");
10172 cmdline_parse_token_string_t cmd_mcast_addr_what =
10173 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10175 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10176 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10177 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10178 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10180 cmdline_parse_inst_t cmd_mcast_addr = {
10181 .f = cmd_mcast_addr_parsed,
10183 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10184 "Add/Remove multicast MAC address on port_id",
10186 (void *)&cmd_mcast_addr_cmd,
10187 (void *)&cmd_mcast_addr_what,
10188 (void *)&cmd_mcast_addr_portnum,
10189 (void *)&cmd_mcast_addr_addr,
10194 /* l2 tunnel config
10195 * only support E-tag now.
10198 /* Ether type config */
10199 struct cmd_config_l2_tunnel_eth_type_result {
10200 cmdline_fixed_string_t port;
10201 cmdline_fixed_string_t config;
10202 cmdline_fixed_string_t all;
10204 cmdline_fixed_string_t l2_tunnel;
10205 cmdline_fixed_string_t l2_tunnel_type;
10206 cmdline_fixed_string_t eth_type;
10207 uint16_t eth_type_val;
10210 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10211 TOKEN_STRING_INITIALIZER
10212 (struct cmd_config_l2_tunnel_eth_type_result,
10214 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10215 TOKEN_STRING_INITIALIZER
10216 (struct cmd_config_l2_tunnel_eth_type_result,
10218 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10219 TOKEN_STRING_INITIALIZER
10220 (struct cmd_config_l2_tunnel_eth_type_result,
10222 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10223 TOKEN_NUM_INITIALIZER
10224 (struct cmd_config_l2_tunnel_eth_type_result,
10226 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10227 TOKEN_STRING_INITIALIZER
10228 (struct cmd_config_l2_tunnel_eth_type_result,
10229 l2_tunnel, "l2-tunnel");
10230 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10231 TOKEN_STRING_INITIALIZER
10232 (struct cmd_config_l2_tunnel_eth_type_result,
10233 l2_tunnel_type, "E-tag");
10234 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10235 TOKEN_STRING_INITIALIZER
10236 (struct cmd_config_l2_tunnel_eth_type_result,
10237 eth_type, "ether-type");
10238 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10239 TOKEN_NUM_INITIALIZER
10240 (struct cmd_config_l2_tunnel_eth_type_result,
10241 eth_type_val, UINT16);
10243 static enum rte_eth_tunnel_type
10244 str2fdir_l2_tunnel_type(char *string)
10248 static const struct {
10250 enum rte_eth_tunnel_type type;
10251 } l2_tunnel_type_str[] = {
10252 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10255 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10256 if (!strcmp(l2_tunnel_type_str[i].str, string))
10257 return l2_tunnel_type_str[i].type;
10259 return RTE_TUNNEL_TYPE_NONE;
10262 /* ether type config for all ports */
10264 cmd_config_l2_tunnel_eth_type_all_parsed
10265 (void *parsed_result,
10266 __attribute__((unused)) struct cmdline *cl,
10267 __attribute__((unused)) void *data)
10269 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10270 struct rte_eth_l2_tunnel_conf entry;
10273 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10274 entry.ether_type = res->eth_type_val;
10276 FOREACH_PORT(pid, ports) {
10277 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10281 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10282 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10284 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10286 (void *)&cmd_config_l2_tunnel_eth_type_port,
10287 (void *)&cmd_config_l2_tunnel_eth_type_config,
10288 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10289 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10290 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10291 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10292 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10297 /* ether type config for a specific port */
10299 cmd_config_l2_tunnel_eth_type_specific_parsed(
10300 void *parsed_result,
10301 __attribute__((unused)) struct cmdline *cl,
10302 __attribute__((unused)) void *data)
10304 struct cmd_config_l2_tunnel_eth_type_result *res =
10306 struct rte_eth_l2_tunnel_conf entry;
10308 if (port_id_is_invalid(res->id, ENABLED_WARN))
10311 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10312 entry.ether_type = res->eth_type_val;
10314 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10317 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10318 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10320 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10322 (void *)&cmd_config_l2_tunnel_eth_type_port,
10323 (void *)&cmd_config_l2_tunnel_eth_type_config,
10324 (void *)&cmd_config_l2_tunnel_eth_type_id,
10325 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10326 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10327 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10328 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10333 /* Enable/disable l2 tunnel */
10334 struct cmd_config_l2_tunnel_en_dis_result {
10335 cmdline_fixed_string_t port;
10336 cmdline_fixed_string_t config;
10337 cmdline_fixed_string_t all;
10339 cmdline_fixed_string_t l2_tunnel;
10340 cmdline_fixed_string_t l2_tunnel_type;
10341 cmdline_fixed_string_t en_dis;
10344 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10345 TOKEN_STRING_INITIALIZER
10346 (struct cmd_config_l2_tunnel_en_dis_result,
10348 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10349 TOKEN_STRING_INITIALIZER
10350 (struct cmd_config_l2_tunnel_en_dis_result,
10352 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10353 TOKEN_STRING_INITIALIZER
10354 (struct cmd_config_l2_tunnel_en_dis_result,
10356 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10357 TOKEN_NUM_INITIALIZER
10358 (struct cmd_config_l2_tunnel_en_dis_result,
10360 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10361 TOKEN_STRING_INITIALIZER
10362 (struct cmd_config_l2_tunnel_en_dis_result,
10363 l2_tunnel, "l2-tunnel");
10364 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10365 TOKEN_STRING_INITIALIZER
10366 (struct cmd_config_l2_tunnel_en_dis_result,
10367 l2_tunnel_type, "E-tag");
10368 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10369 TOKEN_STRING_INITIALIZER
10370 (struct cmd_config_l2_tunnel_en_dis_result,
10371 en_dis, "enable#disable");
10373 /* enable/disable l2 tunnel for all ports */
10375 cmd_config_l2_tunnel_en_dis_all_parsed(
10376 void *parsed_result,
10377 __attribute__((unused)) struct cmdline *cl,
10378 __attribute__((unused)) void *data)
10380 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10381 struct rte_eth_l2_tunnel_conf entry;
10385 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10387 if (!strcmp("enable", res->en_dis))
10392 FOREACH_PORT(pid, ports) {
10393 rte_eth_dev_l2_tunnel_offload_set(pid,
10395 ETH_L2_TUNNEL_ENABLE_MASK,
10400 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10401 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10403 .help_str = "port config all l2-tunnel E-tag enable|disable",
10405 (void *)&cmd_config_l2_tunnel_en_dis_port,
10406 (void *)&cmd_config_l2_tunnel_en_dis_config,
10407 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10408 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10409 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10410 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10415 /* enable/disable l2 tunnel for a port */
10417 cmd_config_l2_tunnel_en_dis_specific_parsed(
10418 void *parsed_result,
10419 __attribute__((unused)) struct cmdline *cl,
10420 __attribute__((unused)) void *data)
10422 struct cmd_config_l2_tunnel_en_dis_result *res =
10424 struct rte_eth_l2_tunnel_conf entry;
10426 if (port_id_is_invalid(res->id, ENABLED_WARN))
10429 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10431 if (!strcmp("enable", res->en_dis))
10432 rte_eth_dev_l2_tunnel_offload_set(res->id,
10434 ETH_L2_TUNNEL_ENABLE_MASK,
10437 rte_eth_dev_l2_tunnel_offload_set(res->id,
10439 ETH_L2_TUNNEL_ENABLE_MASK,
10443 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10444 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10446 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10448 (void *)&cmd_config_l2_tunnel_en_dis_port,
10449 (void *)&cmd_config_l2_tunnel_en_dis_config,
10450 (void *)&cmd_config_l2_tunnel_en_dis_id,
10451 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10452 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10453 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10458 /* E-tag configuration */
10460 /* Common result structure for all E-tag configuration */
10461 struct cmd_config_e_tag_result {
10462 cmdline_fixed_string_t e_tag;
10463 cmdline_fixed_string_t set;
10464 cmdline_fixed_string_t insertion;
10465 cmdline_fixed_string_t stripping;
10466 cmdline_fixed_string_t forwarding;
10467 cmdline_fixed_string_t filter;
10468 cmdline_fixed_string_t add;
10469 cmdline_fixed_string_t del;
10470 cmdline_fixed_string_t on;
10471 cmdline_fixed_string_t off;
10472 cmdline_fixed_string_t on_off;
10473 cmdline_fixed_string_t port_tag_id;
10474 uint32_t port_tag_id_val;
10475 cmdline_fixed_string_t e_tag_id;
10476 uint16_t e_tag_id_val;
10477 cmdline_fixed_string_t dst_pool;
10478 uint8_t dst_pool_val;
10479 cmdline_fixed_string_t port;
10481 cmdline_fixed_string_t vf;
10485 /* Common CLI fields for all E-tag configuration */
10486 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10487 TOKEN_STRING_INITIALIZER
10488 (struct cmd_config_e_tag_result,
10490 cmdline_parse_token_string_t cmd_config_e_tag_set =
10491 TOKEN_STRING_INITIALIZER
10492 (struct cmd_config_e_tag_result,
10494 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10495 TOKEN_STRING_INITIALIZER
10496 (struct cmd_config_e_tag_result,
10497 insertion, "insertion");
10498 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10499 TOKEN_STRING_INITIALIZER
10500 (struct cmd_config_e_tag_result,
10501 stripping, "stripping");
10502 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10503 TOKEN_STRING_INITIALIZER
10504 (struct cmd_config_e_tag_result,
10505 forwarding, "forwarding");
10506 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10507 TOKEN_STRING_INITIALIZER
10508 (struct cmd_config_e_tag_result,
10510 cmdline_parse_token_string_t cmd_config_e_tag_add =
10511 TOKEN_STRING_INITIALIZER
10512 (struct cmd_config_e_tag_result,
10514 cmdline_parse_token_string_t cmd_config_e_tag_del =
10515 TOKEN_STRING_INITIALIZER
10516 (struct cmd_config_e_tag_result,
10518 cmdline_parse_token_string_t cmd_config_e_tag_on =
10519 TOKEN_STRING_INITIALIZER
10520 (struct cmd_config_e_tag_result,
10522 cmdline_parse_token_string_t cmd_config_e_tag_off =
10523 TOKEN_STRING_INITIALIZER
10524 (struct cmd_config_e_tag_result,
10526 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10527 TOKEN_STRING_INITIALIZER
10528 (struct cmd_config_e_tag_result,
10530 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10531 TOKEN_STRING_INITIALIZER
10532 (struct cmd_config_e_tag_result,
10533 port_tag_id, "port-tag-id");
10534 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10535 TOKEN_NUM_INITIALIZER
10536 (struct cmd_config_e_tag_result,
10537 port_tag_id_val, UINT32);
10538 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10539 TOKEN_STRING_INITIALIZER
10540 (struct cmd_config_e_tag_result,
10541 e_tag_id, "e-tag-id");
10542 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10543 TOKEN_NUM_INITIALIZER
10544 (struct cmd_config_e_tag_result,
10545 e_tag_id_val, UINT16);
10546 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10547 TOKEN_STRING_INITIALIZER
10548 (struct cmd_config_e_tag_result,
10549 dst_pool, "dst-pool");
10550 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10551 TOKEN_NUM_INITIALIZER
10552 (struct cmd_config_e_tag_result,
10553 dst_pool_val, UINT8);
10554 cmdline_parse_token_string_t cmd_config_e_tag_port =
10555 TOKEN_STRING_INITIALIZER
10556 (struct cmd_config_e_tag_result,
10558 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10559 TOKEN_NUM_INITIALIZER
10560 (struct cmd_config_e_tag_result,
10562 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10563 TOKEN_STRING_INITIALIZER
10564 (struct cmd_config_e_tag_result,
10566 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10567 TOKEN_NUM_INITIALIZER
10568 (struct cmd_config_e_tag_result,
10571 /* E-tag insertion configuration */
10573 cmd_config_e_tag_insertion_en_parsed(
10574 void *parsed_result,
10575 __attribute__((unused)) struct cmdline *cl,
10576 __attribute__((unused)) void *data)
10578 struct cmd_config_e_tag_result *res =
10580 struct rte_eth_l2_tunnel_conf entry;
10582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10585 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10586 entry.tunnel_id = res->port_tag_id_val;
10587 entry.vf_id = res->vf_id;
10588 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10590 ETH_L2_TUNNEL_INSERTION_MASK,
10595 cmd_config_e_tag_insertion_dis_parsed(
10596 void *parsed_result,
10597 __attribute__((unused)) struct cmdline *cl,
10598 __attribute__((unused)) void *data)
10600 struct cmd_config_e_tag_result *res =
10602 struct rte_eth_l2_tunnel_conf entry;
10604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10607 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10608 entry.vf_id = res->vf_id;
10610 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10612 ETH_L2_TUNNEL_INSERTION_MASK,
10616 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10617 .f = cmd_config_e_tag_insertion_en_parsed,
10619 .help_str = "E-tag ... : E-tag insertion enable",
10621 (void *)&cmd_config_e_tag_e_tag,
10622 (void *)&cmd_config_e_tag_set,
10623 (void *)&cmd_config_e_tag_insertion,
10624 (void *)&cmd_config_e_tag_on,
10625 (void *)&cmd_config_e_tag_port_tag_id,
10626 (void *)&cmd_config_e_tag_port_tag_id_val,
10627 (void *)&cmd_config_e_tag_port,
10628 (void *)&cmd_config_e_tag_port_id,
10629 (void *)&cmd_config_e_tag_vf,
10630 (void *)&cmd_config_e_tag_vf_id,
10635 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10636 .f = cmd_config_e_tag_insertion_dis_parsed,
10638 .help_str = "E-tag ... : E-tag insertion disable",
10640 (void *)&cmd_config_e_tag_e_tag,
10641 (void *)&cmd_config_e_tag_set,
10642 (void *)&cmd_config_e_tag_insertion,
10643 (void *)&cmd_config_e_tag_off,
10644 (void *)&cmd_config_e_tag_port,
10645 (void *)&cmd_config_e_tag_port_id,
10646 (void *)&cmd_config_e_tag_vf,
10647 (void *)&cmd_config_e_tag_vf_id,
10652 /* E-tag stripping configuration */
10654 cmd_config_e_tag_stripping_parsed(
10655 void *parsed_result,
10656 __attribute__((unused)) struct cmdline *cl,
10657 __attribute__((unused)) void *data)
10659 struct cmd_config_e_tag_result *res =
10661 struct rte_eth_l2_tunnel_conf entry;
10663 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10666 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10668 if (!strcmp(res->on_off, "on"))
10669 rte_eth_dev_l2_tunnel_offload_set
10672 ETH_L2_TUNNEL_STRIPPING_MASK,
10675 rte_eth_dev_l2_tunnel_offload_set
10678 ETH_L2_TUNNEL_STRIPPING_MASK,
10682 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10683 .f = cmd_config_e_tag_stripping_parsed,
10685 .help_str = "E-tag ... : E-tag stripping enable/disable",
10687 (void *)&cmd_config_e_tag_e_tag,
10688 (void *)&cmd_config_e_tag_set,
10689 (void *)&cmd_config_e_tag_stripping,
10690 (void *)&cmd_config_e_tag_on_off,
10691 (void *)&cmd_config_e_tag_port,
10692 (void *)&cmd_config_e_tag_port_id,
10697 /* E-tag forwarding configuration */
10699 cmd_config_e_tag_forwarding_parsed(
10700 void *parsed_result,
10701 __attribute__((unused)) struct cmdline *cl,
10702 __attribute__((unused)) void *data)
10704 struct cmd_config_e_tag_result *res = parsed_result;
10705 struct rte_eth_l2_tunnel_conf entry;
10707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10710 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10712 if (!strcmp(res->on_off, "on"))
10713 rte_eth_dev_l2_tunnel_offload_set
10716 ETH_L2_TUNNEL_FORWARDING_MASK,
10719 rte_eth_dev_l2_tunnel_offload_set
10722 ETH_L2_TUNNEL_FORWARDING_MASK,
10726 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10727 .f = cmd_config_e_tag_forwarding_parsed,
10729 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10731 (void *)&cmd_config_e_tag_e_tag,
10732 (void *)&cmd_config_e_tag_set,
10733 (void *)&cmd_config_e_tag_forwarding,
10734 (void *)&cmd_config_e_tag_on_off,
10735 (void *)&cmd_config_e_tag_port,
10736 (void *)&cmd_config_e_tag_port_id,
10741 /* E-tag filter configuration */
10743 cmd_config_e_tag_filter_add_parsed(
10744 void *parsed_result,
10745 __attribute__((unused)) struct cmdline *cl,
10746 __attribute__((unused)) void *data)
10748 struct cmd_config_e_tag_result *res = parsed_result;
10749 struct rte_eth_l2_tunnel_conf entry;
10752 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10755 if (res->e_tag_id_val > 0x3fff) {
10756 printf("e-tag-id must be equal or less than 0x3fff.\n");
10760 ret = rte_eth_dev_filter_supported(res->port_id,
10761 RTE_ETH_FILTER_L2_TUNNEL);
10763 printf("E-tag filter is not supported on port %u.\n",
10768 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10769 entry.tunnel_id = res->e_tag_id_val;
10770 entry.pool = res->dst_pool_val;
10772 ret = rte_eth_dev_filter_ctrl(res->port_id,
10773 RTE_ETH_FILTER_L2_TUNNEL,
10774 RTE_ETH_FILTER_ADD,
10777 printf("E-tag filter programming error: (%s)\n",
10781 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10782 .f = cmd_config_e_tag_filter_add_parsed,
10784 .help_str = "E-tag ... : E-tag filter add",
10786 (void *)&cmd_config_e_tag_e_tag,
10787 (void *)&cmd_config_e_tag_set,
10788 (void *)&cmd_config_e_tag_filter,
10789 (void *)&cmd_config_e_tag_add,
10790 (void *)&cmd_config_e_tag_e_tag_id,
10791 (void *)&cmd_config_e_tag_e_tag_id_val,
10792 (void *)&cmd_config_e_tag_dst_pool,
10793 (void *)&cmd_config_e_tag_dst_pool_val,
10794 (void *)&cmd_config_e_tag_port,
10795 (void *)&cmd_config_e_tag_port_id,
10801 cmd_config_e_tag_filter_del_parsed(
10802 void *parsed_result,
10803 __attribute__((unused)) struct cmdline *cl,
10804 __attribute__((unused)) void *data)
10806 struct cmd_config_e_tag_result *res = parsed_result;
10807 struct rte_eth_l2_tunnel_conf entry;
10810 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10813 if (res->e_tag_id_val > 0x3fff) {
10814 printf("e-tag-id must be less than 0x3fff.\n");
10818 ret = rte_eth_dev_filter_supported(res->port_id,
10819 RTE_ETH_FILTER_L2_TUNNEL);
10821 printf("E-tag filter is not supported on port %u.\n",
10826 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10827 entry.tunnel_id = res->e_tag_id_val;
10829 ret = rte_eth_dev_filter_ctrl(res->port_id,
10830 RTE_ETH_FILTER_L2_TUNNEL,
10831 RTE_ETH_FILTER_DELETE,
10834 printf("E-tag filter programming error: (%s)\n",
10838 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10839 .f = cmd_config_e_tag_filter_del_parsed,
10841 .help_str = "E-tag ... : E-tag filter delete",
10843 (void *)&cmd_config_e_tag_e_tag,
10844 (void *)&cmd_config_e_tag_set,
10845 (void *)&cmd_config_e_tag_filter,
10846 (void *)&cmd_config_e_tag_del,
10847 (void *)&cmd_config_e_tag_e_tag_id,
10848 (void *)&cmd_config_e_tag_e_tag_id_val,
10849 (void *)&cmd_config_e_tag_port,
10850 (void *)&cmd_config_e_tag_port_id,
10854 #ifdef RTE_LIBRTE_IXGBE_PMD
10856 /* vf vlan anti spoof configuration */
10858 /* Common result structure for vf vlan anti spoof */
10859 struct cmd_vf_vlan_anti_spoof_result {
10860 cmdline_fixed_string_t set;
10861 cmdline_fixed_string_t vf;
10862 cmdline_fixed_string_t vlan;
10863 cmdline_fixed_string_t antispoof;
10866 cmdline_fixed_string_t on_off;
10869 /* Common CLI fields for vf vlan anti spoof enable disable */
10870 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10871 TOKEN_STRING_INITIALIZER
10872 (struct cmd_vf_vlan_anti_spoof_result,
10874 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10875 TOKEN_STRING_INITIALIZER
10876 (struct cmd_vf_vlan_anti_spoof_result,
10878 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10879 TOKEN_STRING_INITIALIZER
10880 (struct cmd_vf_vlan_anti_spoof_result,
10882 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10883 TOKEN_STRING_INITIALIZER
10884 (struct cmd_vf_vlan_anti_spoof_result,
10885 antispoof, "antispoof");
10886 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10887 TOKEN_NUM_INITIALIZER
10888 (struct cmd_vf_vlan_anti_spoof_result,
10890 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10891 TOKEN_NUM_INITIALIZER
10892 (struct cmd_vf_vlan_anti_spoof_result,
10894 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10895 TOKEN_STRING_INITIALIZER
10896 (struct cmd_vf_vlan_anti_spoof_result,
10900 cmd_set_vf_vlan_anti_spoof_parsed(
10901 void *parsed_result,
10902 __attribute__((unused)) struct cmdline *cl,
10903 __attribute__((unused)) void *data)
10905 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10907 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10909 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10912 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
10918 printf("invalid vf_id %d\n", res->vf_id);
10921 printf("invalid port_id %d\n", res->port_id);
10924 printf("programming error: (%s)\n", strerror(-ret));
10928 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10929 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10931 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10933 (void *)&cmd_vf_vlan_anti_spoof_set,
10934 (void *)&cmd_vf_vlan_anti_spoof_vf,
10935 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10936 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10937 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10938 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10939 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10944 /* vf mac anti spoof configuration */
10946 /* Common result structure for vf mac anti spoof */
10947 struct cmd_vf_mac_anti_spoof_result {
10948 cmdline_fixed_string_t set;
10949 cmdline_fixed_string_t vf;
10950 cmdline_fixed_string_t mac;
10951 cmdline_fixed_string_t antispoof;
10954 cmdline_fixed_string_t on_off;
10957 /* Common CLI fields for vf mac anti spoof enable disable */
10958 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10959 TOKEN_STRING_INITIALIZER
10960 (struct cmd_vf_mac_anti_spoof_result,
10962 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10963 TOKEN_STRING_INITIALIZER
10964 (struct cmd_vf_mac_anti_spoof_result,
10966 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10967 TOKEN_STRING_INITIALIZER
10968 (struct cmd_vf_mac_anti_spoof_result,
10970 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10971 TOKEN_STRING_INITIALIZER
10972 (struct cmd_vf_mac_anti_spoof_result,
10973 antispoof, "antispoof");
10974 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10975 TOKEN_NUM_INITIALIZER
10976 (struct cmd_vf_mac_anti_spoof_result,
10978 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10979 TOKEN_NUM_INITIALIZER
10980 (struct cmd_vf_mac_anti_spoof_result,
10982 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10983 TOKEN_STRING_INITIALIZER
10984 (struct cmd_vf_mac_anti_spoof_result,
10988 cmd_set_vf_mac_anti_spoof_parsed(
10989 void *parsed_result,
10990 __attribute__((unused)) struct cmdline *cl,
10991 __attribute__((unused)) void *data)
10993 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10995 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10997 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11000 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
11006 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11009 printf("invalid port_id %d\n", res->port_id);
11012 printf("programming error: (%s)\n", strerror(-ret));
11016 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11017 .f = cmd_set_vf_mac_anti_spoof_parsed,
11019 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11021 (void *)&cmd_vf_mac_anti_spoof_set,
11022 (void *)&cmd_vf_mac_anti_spoof_vf,
11023 (void *)&cmd_vf_mac_anti_spoof_mac,
11024 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11025 (void *)&cmd_vf_mac_anti_spoof_port_id,
11026 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11027 (void *)&cmd_vf_mac_anti_spoof_on_off,
11032 /* vf vlan strip queue configuration */
11034 /* Common result structure for vf mac anti spoof */
11035 struct cmd_vf_vlan_stripq_result {
11036 cmdline_fixed_string_t set;
11037 cmdline_fixed_string_t vf;
11038 cmdline_fixed_string_t vlan;
11039 cmdline_fixed_string_t stripq;
11042 cmdline_fixed_string_t on_off;
11045 /* Common CLI fields for vf vlan strip enable disable */
11046 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11047 TOKEN_STRING_INITIALIZER
11048 (struct cmd_vf_vlan_stripq_result,
11050 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11051 TOKEN_STRING_INITIALIZER
11052 (struct cmd_vf_vlan_stripq_result,
11054 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11055 TOKEN_STRING_INITIALIZER
11056 (struct cmd_vf_vlan_stripq_result,
11058 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11059 TOKEN_STRING_INITIALIZER
11060 (struct cmd_vf_vlan_stripq_result,
11062 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11063 TOKEN_NUM_INITIALIZER
11064 (struct cmd_vf_vlan_stripq_result,
11066 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11067 TOKEN_NUM_INITIALIZER
11068 (struct cmd_vf_vlan_stripq_result,
11070 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11071 TOKEN_STRING_INITIALIZER
11072 (struct cmd_vf_vlan_stripq_result,
11076 cmd_set_vf_vlan_stripq_parsed(
11077 void *parsed_result,
11078 __attribute__((unused)) struct cmdline *cl,
11079 __attribute__((unused)) void *data)
11081 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11083 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11085 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11088 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
11093 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11096 printf("invalid port_id %d\n", res->port_id);
11099 printf("programming error: (%s)\n", strerror(-ret));
11103 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11104 .f = cmd_set_vf_vlan_stripq_parsed,
11106 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11108 (void *)&cmd_vf_vlan_stripq_set,
11109 (void *)&cmd_vf_vlan_stripq_vf,
11110 (void *)&cmd_vf_vlan_stripq_vlan,
11111 (void *)&cmd_vf_vlan_stripq_stripq,
11112 (void *)&cmd_vf_vlan_stripq_port_id,
11113 (void *)&cmd_vf_vlan_stripq_vf_id,
11114 (void *)&cmd_vf_vlan_stripq_on_off,
11119 /* vf vlan insert configuration */
11121 /* Common result structure for vf vlan insert */
11122 struct cmd_vf_vlan_insert_result {
11123 cmdline_fixed_string_t set;
11124 cmdline_fixed_string_t vf;
11125 cmdline_fixed_string_t vlan;
11126 cmdline_fixed_string_t insert;
11132 /* Common CLI fields for vf vlan insert enable disable */
11133 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11134 TOKEN_STRING_INITIALIZER
11135 (struct cmd_vf_vlan_insert_result,
11137 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11138 TOKEN_STRING_INITIALIZER
11139 (struct cmd_vf_vlan_insert_result,
11141 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11142 TOKEN_STRING_INITIALIZER
11143 (struct cmd_vf_vlan_insert_result,
11145 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11146 TOKEN_STRING_INITIALIZER
11147 (struct cmd_vf_vlan_insert_result,
11149 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11150 TOKEN_NUM_INITIALIZER
11151 (struct cmd_vf_vlan_insert_result,
11153 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11154 TOKEN_NUM_INITIALIZER
11155 (struct cmd_vf_vlan_insert_result,
11157 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11158 TOKEN_NUM_INITIALIZER
11159 (struct cmd_vf_vlan_insert_result,
11163 cmd_set_vf_vlan_insert_parsed(
11164 void *parsed_result,
11165 __attribute__((unused)) struct cmdline *cl,
11166 __attribute__((unused)) void *data)
11168 struct cmd_vf_vlan_insert_result *res = parsed_result;
11171 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11174 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
11179 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11182 printf("invalid port_id %d\n", res->port_id);
11185 printf("programming error: (%s)\n", strerror(-ret));
11189 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11190 .f = cmd_set_vf_vlan_insert_parsed,
11192 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11194 (void *)&cmd_vf_vlan_insert_set,
11195 (void *)&cmd_vf_vlan_insert_vf,
11196 (void *)&cmd_vf_vlan_insert_vlan,
11197 (void *)&cmd_vf_vlan_insert_insert,
11198 (void *)&cmd_vf_vlan_insert_port_id,
11199 (void *)&cmd_vf_vlan_insert_vf_id,
11200 (void *)&cmd_vf_vlan_insert_vlan_id,
11205 /* tx loopback configuration */
11207 /* Common result structure for tx loopback */
11208 struct cmd_tx_loopback_result {
11209 cmdline_fixed_string_t set;
11210 cmdline_fixed_string_t tx;
11211 cmdline_fixed_string_t loopback;
11213 cmdline_fixed_string_t on_off;
11216 /* Common CLI fields for tx loopback enable disable */
11217 cmdline_parse_token_string_t cmd_tx_loopback_set =
11218 TOKEN_STRING_INITIALIZER
11219 (struct cmd_tx_loopback_result,
11221 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11222 TOKEN_STRING_INITIALIZER
11223 (struct cmd_tx_loopback_result,
11225 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11226 TOKEN_STRING_INITIALIZER
11227 (struct cmd_tx_loopback_result,
11228 loopback, "loopback");
11229 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11230 TOKEN_NUM_INITIALIZER
11231 (struct cmd_tx_loopback_result,
11233 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11234 TOKEN_STRING_INITIALIZER
11235 (struct cmd_tx_loopback_result,
11239 cmd_set_tx_loopback_parsed(
11240 void *parsed_result,
11241 __attribute__((unused)) struct cmdline *cl,
11242 __attribute__((unused)) void *data)
11244 struct cmd_tx_loopback_result *res = parsed_result;
11246 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11248 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11251 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11256 printf("invalid is_on %d\n", is_on);
11259 printf("invalid port_id %d\n", res->port_id);
11262 printf("programming error: (%s)\n", strerror(-ret));
11266 cmdline_parse_inst_t cmd_set_tx_loopback = {
11267 .f = cmd_set_tx_loopback_parsed,
11269 .help_str = "set tx loopback <port_id> on|off",
11271 (void *)&cmd_tx_loopback_set,
11272 (void *)&cmd_tx_loopback_tx,
11273 (void *)&cmd_tx_loopback_loopback,
11274 (void *)&cmd_tx_loopback_port_id,
11275 (void *)&cmd_tx_loopback_on_off,
11280 /* all queues drop enable configuration */
11282 /* Common result structure for all queues drop enable */
11283 struct cmd_all_queues_drop_en_result {
11284 cmdline_fixed_string_t set;
11285 cmdline_fixed_string_t all;
11286 cmdline_fixed_string_t queues;
11287 cmdline_fixed_string_t drop;
11289 cmdline_fixed_string_t on_off;
11292 /* Common CLI fields for tx loopback enable disable */
11293 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11294 TOKEN_STRING_INITIALIZER
11295 (struct cmd_all_queues_drop_en_result,
11297 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11298 TOKEN_STRING_INITIALIZER
11299 (struct cmd_all_queues_drop_en_result,
11301 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11302 TOKEN_STRING_INITIALIZER
11303 (struct cmd_all_queues_drop_en_result,
11305 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11306 TOKEN_STRING_INITIALIZER
11307 (struct cmd_all_queues_drop_en_result,
11309 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11310 TOKEN_NUM_INITIALIZER
11311 (struct cmd_all_queues_drop_en_result,
11313 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11314 TOKEN_STRING_INITIALIZER
11315 (struct cmd_all_queues_drop_en_result,
11319 cmd_set_all_queues_drop_en_parsed(
11320 void *parsed_result,
11321 __attribute__((unused)) struct cmdline *cl,
11322 __attribute__((unused)) void *data)
11324 struct cmd_all_queues_drop_en_result *res = parsed_result;
11326 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11328 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11331 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11336 printf("invalid is_on %d\n", is_on);
11339 printf("invalid port_id %d\n", res->port_id);
11342 printf("programming error: (%s)\n", strerror(-ret));
11346 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11347 .f = cmd_set_all_queues_drop_en_parsed,
11349 .help_str = "set all queues drop <port_id> on|off",
11351 (void *)&cmd_all_queues_drop_en_set,
11352 (void *)&cmd_all_queues_drop_en_all,
11353 (void *)&cmd_all_queues_drop_en_queues,
11354 (void *)&cmd_all_queues_drop_en_drop,
11355 (void *)&cmd_all_queues_drop_en_port_id,
11356 (void *)&cmd_all_queues_drop_en_on_off,
11361 /* vf split drop enable configuration */
11363 /* Common result structure for vf split drop enable */
11364 struct cmd_vf_split_drop_en_result {
11365 cmdline_fixed_string_t set;
11366 cmdline_fixed_string_t vf;
11367 cmdline_fixed_string_t split;
11368 cmdline_fixed_string_t drop;
11371 cmdline_fixed_string_t on_off;
11374 /* Common CLI fields for vf split drop enable disable */
11375 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11376 TOKEN_STRING_INITIALIZER
11377 (struct cmd_vf_split_drop_en_result,
11379 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11380 TOKEN_STRING_INITIALIZER
11381 (struct cmd_vf_split_drop_en_result,
11383 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11384 TOKEN_STRING_INITIALIZER
11385 (struct cmd_vf_split_drop_en_result,
11387 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11388 TOKEN_STRING_INITIALIZER
11389 (struct cmd_vf_split_drop_en_result,
11391 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11392 TOKEN_NUM_INITIALIZER
11393 (struct cmd_vf_split_drop_en_result,
11395 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11396 TOKEN_NUM_INITIALIZER
11397 (struct cmd_vf_split_drop_en_result,
11399 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11400 TOKEN_STRING_INITIALIZER
11401 (struct cmd_vf_split_drop_en_result,
11405 cmd_set_vf_split_drop_en_parsed(
11406 void *parsed_result,
11407 __attribute__((unused)) struct cmdline *cl,
11408 __attribute__((unused)) void *data)
11410 struct cmd_vf_split_drop_en_result *res = parsed_result;
11412 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11417 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11423 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11426 printf("invalid port_id %d\n", res->port_id);
11429 printf("programming error: (%s)\n", strerror(-ret));
11433 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11434 .f = cmd_set_vf_split_drop_en_parsed,
11436 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11438 (void *)&cmd_vf_split_drop_en_set,
11439 (void *)&cmd_vf_split_drop_en_vf,
11440 (void *)&cmd_vf_split_drop_en_split,
11441 (void *)&cmd_vf_split_drop_en_drop,
11442 (void *)&cmd_vf_split_drop_en_port_id,
11443 (void *)&cmd_vf_split_drop_en_vf_id,
11444 (void *)&cmd_vf_split_drop_en_on_off,
11449 /* vf mac address configuration */
11451 /* Common result structure for vf mac address */
11452 struct cmd_set_vf_mac_addr_result {
11453 cmdline_fixed_string_t set;
11454 cmdline_fixed_string_t vf;
11455 cmdline_fixed_string_t mac;
11456 cmdline_fixed_string_t addr;
11459 struct ether_addr mac_addr;
11463 /* Common CLI fields for vf split drop enable disable */
11464 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11465 TOKEN_STRING_INITIALIZER
11466 (struct cmd_set_vf_mac_addr_result,
11468 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11469 TOKEN_STRING_INITIALIZER
11470 (struct cmd_set_vf_mac_addr_result,
11472 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11473 TOKEN_STRING_INITIALIZER
11474 (struct cmd_set_vf_mac_addr_result,
11476 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11477 TOKEN_STRING_INITIALIZER
11478 (struct cmd_set_vf_mac_addr_result,
11480 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11481 TOKEN_NUM_INITIALIZER
11482 (struct cmd_set_vf_mac_addr_result,
11484 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11485 TOKEN_NUM_INITIALIZER
11486 (struct cmd_set_vf_mac_addr_result,
11488 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11489 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11493 cmd_set_vf_mac_addr_parsed(
11494 void *parsed_result,
11495 __attribute__((unused)) struct cmdline *cl,
11496 __attribute__((unused)) void *data)
11498 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11501 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11504 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11510 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11513 printf("invalid port_id %d\n", res->port_id);
11516 printf("programming error: (%s)\n", strerror(-ret));
11520 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11521 .f = cmd_set_vf_mac_addr_parsed,
11523 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11525 (void *)&cmd_set_vf_mac_addr_set,
11526 (void *)&cmd_set_vf_mac_addr_vf,
11527 (void *)&cmd_set_vf_mac_addr_mac,
11528 (void *)&cmd_set_vf_mac_addr_addr,
11529 (void *)&cmd_set_vf_mac_addr_port_id,
11530 (void *)&cmd_set_vf_mac_addr_vf_id,
11531 (void *)&cmd_set_vf_mac_addr_mac_addr,
11536 /* MACsec configuration */
11538 /* Common result structure for MACsec offload enable */
11539 struct cmd_macsec_offload_on_result {
11540 cmdline_fixed_string_t set;
11541 cmdline_fixed_string_t macsec;
11542 cmdline_fixed_string_t offload;
11544 cmdline_fixed_string_t on;
11545 cmdline_fixed_string_t encrypt;
11546 cmdline_fixed_string_t en_on_off;
11547 cmdline_fixed_string_t replay_protect;
11548 cmdline_fixed_string_t rp_on_off;
11551 /* Common CLI fields for MACsec offload disable */
11552 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11553 TOKEN_STRING_INITIALIZER
11554 (struct cmd_macsec_offload_on_result,
11556 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11557 TOKEN_STRING_INITIALIZER
11558 (struct cmd_macsec_offload_on_result,
11560 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11561 TOKEN_STRING_INITIALIZER
11562 (struct cmd_macsec_offload_on_result,
11563 offload, "offload");
11564 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11565 TOKEN_NUM_INITIALIZER
11566 (struct cmd_macsec_offload_on_result,
11568 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11569 TOKEN_STRING_INITIALIZER
11570 (struct cmd_macsec_offload_on_result,
11572 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11573 TOKEN_STRING_INITIALIZER
11574 (struct cmd_macsec_offload_on_result,
11575 encrypt, "encrypt");
11576 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11577 TOKEN_STRING_INITIALIZER
11578 (struct cmd_macsec_offload_on_result,
11579 en_on_off, "on#off");
11580 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11581 TOKEN_STRING_INITIALIZER
11582 (struct cmd_macsec_offload_on_result,
11583 replay_protect, "replay-protect");
11584 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11585 TOKEN_STRING_INITIALIZER
11586 (struct cmd_macsec_offload_on_result,
11587 rp_on_off, "on#off");
11590 cmd_set_macsec_offload_on_parsed(
11591 void *parsed_result,
11592 __attribute__((unused)) struct cmdline *cl,
11593 __attribute__((unused)) void *data)
11595 struct cmd_macsec_offload_on_result *res = parsed_result;
11597 portid_t port_id = res->port_id;
11598 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11599 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11601 if (port_id_is_invalid(port_id, ENABLED_WARN))
11604 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11605 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11611 printf("invalid port_id %d\n", port_id);
11614 printf("programming error: (%s)\n", strerror(-ret));
11618 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11619 .f = cmd_set_macsec_offload_on_parsed,
11621 .help_str = "set macsec offload <port_id> on "
11622 "encrypt on|off replay-protect on|off",
11624 (void *)&cmd_macsec_offload_on_set,
11625 (void *)&cmd_macsec_offload_on_macsec,
11626 (void *)&cmd_macsec_offload_on_offload,
11627 (void *)&cmd_macsec_offload_on_port_id,
11628 (void *)&cmd_macsec_offload_on_on,
11629 (void *)&cmd_macsec_offload_on_encrypt,
11630 (void *)&cmd_macsec_offload_on_en_on_off,
11631 (void *)&cmd_macsec_offload_on_replay_protect,
11632 (void *)&cmd_macsec_offload_on_rp_on_off,
11637 /* Common result structure for MACsec offload disable */
11638 struct cmd_macsec_offload_off_result {
11639 cmdline_fixed_string_t set;
11640 cmdline_fixed_string_t macsec;
11641 cmdline_fixed_string_t offload;
11643 cmdline_fixed_string_t off;
11646 /* Common CLI fields for MACsec offload disable */
11647 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11648 TOKEN_STRING_INITIALIZER
11649 (struct cmd_macsec_offload_off_result,
11651 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11652 TOKEN_STRING_INITIALIZER
11653 (struct cmd_macsec_offload_off_result,
11655 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11656 TOKEN_STRING_INITIALIZER
11657 (struct cmd_macsec_offload_off_result,
11658 offload, "offload");
11659 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11660 TOKEN_NUM_INITIALIZER
11661 (struct cmd_macsec_offload_off_result,
11663 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11664 TOKEN_STRING_INITIALIZER
11665 (struct cmd_macsec_offload_off_result,
11669 cmd_set_macsec_offload_off_parsed(
11670 void *parsed_result,
11671 __attribute__((unused)) struct cmdline *cl,
11672 __attribute__((unused)) void *data)
11674 struct cmd_macsec_offload_off_result *res = parsed_result;
11676 portid_t port_id = res->port_id;
11678 if (port_id_is_invalid(port_id, ENABLED_WARN))
11681 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11682 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11688 printf("invalid port_id %d\n", port_id);
11691 printf("programming error: (%s)\n", strerror(-ret));
11695 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11696 .f = cmd_set_macsec_offload_off_parsed,
11698 .help_str = "set macsec offload <port_id> off",
11700 (void *)&cmd_macsec_offload_off_set,
11701 (void *)&cmd_macsec_offload_off_macsec,
11702 (void *)&cmd_macsec_offload_off_offload,
11703 (void *)&cmd_macsec_offload_off_port_id,
11704 (void *)&cmd_macsec_offload_off_off,
11709 /* Common result structure for MACsec secure connection configure */
11710 struct cmd_macsec_sc_result {
11711 cmdline_fixed_string_t set;
11712 cmdline_fixed_string_t macsec;
11713 cmdline_fixed_string_t sc;
11714 cmdline_fixed_string_t tx_rx;
11716 struct ether_addr mac;
11720 /* Common CLI fields for MACsec secure connection configure */
11721 cmdline_parse_token_string_t cmd_macsec_sc_set =
11722 TOKEN_STRING_INITIALIZER
11723 (struct cmd_macsec_sc_result,
11725 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11726 TOKEN_STRING_INITIALIZER
11727 (struct cmd_macsec_sc_result,
11729 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11730 TOKEN_STRING_INITIALIZER
11731 (struct cmd_macsec_sc_result,
11733 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11734 TOKEN_STRING_INITIALIZER
11735 (struct cmd_macsec_sc_result,
11737 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11738 TOKEN_NUM_INITIALIZER
11739 (struct cmd_macsec_sc_result,
11741 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11742 TOKEN_ETHERADDR_INITIALIZER
11743 (struct cmd_macsec_sc_result,
11745 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11746 TOKEN_NUM_INITIALIZER
11747 (struct cmd_macsec_sc_result,
11751 cmd_set_macsec_sc_parsed(
11752 void *parsed_result,
11753 __attribute__((unused)) struct cmdline *cl,
11754 __attribute__((unused)) void *data)
11756 struct cmd_macsec_sc_result *res = parsed_result;
11758 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11761 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11762 res->mac.addr_bytes) :
11763 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11764 res->mac.addr_bytes, res->pi);
11769 printf("invalid port_id %d\n", res->port_id);
11772 printf("programming error: (%s)\n", strerror(-ret));
11776 cmdline_parse_inst_t cmd_set_macsec_sc = {
11777 .f = cmd_set_macsec_sc_parsed,
11779 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11781 (void *)&cmd_macsec_sc_set,
11782 (void *)&cmd_macsec_sc_macsec,
11783 (void *)&cmd_macsec_sc_sc,
11784 (void *)&cmd_macsec_sc_tx_rx,
11785 (void *)&cmd_macsec_sc_port_id,
11786 (void *)&cmd_macsec_sc_mac,
11787 (void *)&cmd_macsec_sc_pi,
11792 /* Common result structure for MACsec secure connection configure */
11793 struct cmd_macsec_sa_result {
11794 cmdline_fixed_string_t set;
11795 cmdline_fixed_string_t macsec;
11796 cmdline_fixed_string_t sa;
11797 cmdline_fixed_string_t tx_rx;
11802 cmdline_fixed_string_t key;
11805 /* Common CLI fields for MACsec secure connection configure */
11806 cmdline_parse_token_string_t cmd_macsec_sa_set =
11807 TOKEN_STRING_INITIALIZER
11808 (struct cmd_macsec_sa_result,
11810 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11811 TOKEN_STRING_INITIALIZER
11812 (struct cmd_macsec_sa_result,
11814 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11815 TOKEN_STRING_INITIALIZER
11816 (struct cmd_macsec_sa_result,
11818 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11819 TOKEN_STRING_INITIALIZER
11820 (struct cmd_macsec_sa_result,
11822 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11823 TOKEN_NUM_INITIALIZER
11824 (struct cmd_macsec_sa_result,
11826 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11827 TOKEN_NUM_INITIALIZER
11828 (struct cmd_macsec_sa_result,
11830 cmdline_parse_token_num_t cmd_macsec_sa_an =
11831 TOKEN_NUM_INITIALIZER
11832 (struct cmd_macsec_sa_result,
11834 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11835 TOKEN_NUM_INITIALIZER
11836 (struct cmd_macsec_sa_result,
11838 cmdline_parse_token_string_t cmd_macsec_sa_key =
11839 TOKEN_STRING_INITIALIZER
11840 (struct cmd_macsec_sa_result,
11844 cmd_set_macsec_sa_parsed(
11845 void *parsed_result,
11846 __attribute__((unused)) struct cmdline *cl,
11847 __attribute__((unused)) void *data)
11849 struct cmd_macsec_sa_result *res = parsed_result;
11851 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11852 uint8_t key[16] = { 0 };
11858 key_len = strlen(res->key) / 2;
11862 for (i = 0; i < key_len; i++) {
11863 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11866 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11869 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11873 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11874 res->idx, res->an, res->pn, key) :
11875 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11876 res->idx, res->an, res->pn, key);
11881 printf("invalid idx %d or an %d\n", res->idx, res->an);
11884 printf("invalid port_id %d\n", res->port_id);
11887 printf("programming error: (%s)\n", strerror(-ret));
11891 cmdline_parse_inst_t cmd_set_macsec_sa = {
11892 .f = cmd_set_macsec_sa_parsed,
11894 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11896 (void *)&cmd_macsec_sa_set,
11897 (void *)&cmd_macsec_sa_macsec,
11898 (void *)&cmd_macsec_sa_sa,
11899 (void *)&cmd_macsec_sa_tx_rx,
11900 (void *)&cmd_macsec_sa_port_id,
11901 (void *)&cmd_macsec_sa_idx,
11902 (void *)&cmd_macsec_sa_an,
11903 (void *)&cmd_macsec_sa_pn,
11904 (void *)&cmd_macsec_sa_key,
11910 /* ******************************************************************************** */
11912 /* list of instructions */
11913 cmdline_parse_ctx_t main_ctx[] = {
11914 (cmdline_parse_inst_t *)&cmd_help_brief,
11915 (cmdline_parse_inst_t *)&cmd_help_long,
11916 (cmdline_parse_inst_t *)&cmd_quit,
11917 (cmdline_parse_inst_t *)&cmd_showport,
11918 (cmdline_parse_inst_t *)&cmd_showqueue,
11919 (cmdline_parse_inst_t *)&cmd_showportall,
11920 (cmdline_parse_inst_t *)&cmd_showcfg,
11921 (cmdline_parse_inst_t *)&cmd_start,
11922 (cmdline_parse_inst_t *)&cmd_start_tx_first,
11923 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
11924 (cmdline_parse_inst_t *)&cmd_set_link_up,
11925 (cmdline_parse_inst_t *)&cmd_set_link_down,
11926 (cmdline_parse_inst_t *)&cmd_reset,
11927 (cmdline_parse_inst_t *)&cmd_set_numbers,
11928 (cmdline_parse_inst_t *)&cmd_set_txpkts,
11929 (cmdline_parse_inst_t *)&cmd_set_txsplit,
11930 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
11931 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
11932 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
11933 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
11934 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
11935 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
11936 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
11937 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
11938 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
11939 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
11940 (cmdline_parse_inst_t *)&cmd_set_link_check,
11941 #ifdef RTE_NIC_BYPASS
11942 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
11943 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
11944 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
11945 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
11947 #ifdef RTE_LIBRTE_PMD_BOND
11948 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
11949 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
11950 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
11951 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
11952 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
11953 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
11954 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
11955 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
11956 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
11958 (cmdline_parse_inst_t *)&cmd_vlan_offload,
11959 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
11960 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
11961 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
11962 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
11963 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
11964 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
11965 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
11966 (cmdline_parse_inst_t *)&cmd_csum_set,
11967 (cmdline_parse_inst_t *)&cmd_csum_show,
11968 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
11969 (cmdline_parse_inst_t *)&cmd_tso_set,
11970 (cmdline_parse_inst_t *)&cmd_tso_show,
11971 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
11972 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
11973 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
11974 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
11975 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
11976 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
11977 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
11978 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
11979 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
11980 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
11981 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
11982 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
11983 (cmdline_parse_inst_t *)&cmd_config_dcb,
11984 (cmdline_parse_inst_t *)&cmd_read_reg,
11985 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
11986 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
11987 (cmdline_parse_inst_t *)&cmd_write_reg,
11988 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
11989 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
11990 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
11991 (cmdline_parse_inst_t *)&cmd_stop,
11992 (cmdline_parse_inst_t *)&cmd_mac_addr,
11993 (cmdline_parse_inst_t *)&cmd_set_qmap,
11994 (cmdline_parse_inst_t *)&cmd_operate_port,
11995 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
11996 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
11997 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
11998 (cmdline_parse_inst_t *)&cmd_config_speed_all,
11999 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12000 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12001 (cmdline_parse_inst_t *)&cmd_config_mtu,
12002 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12003 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12004 (cmdline_parse_inst_t *)&cmd_config_rss,
12005 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12006 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12007 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12008 (cmdline_parse_inst_t *)&cmd_showport_reta,
12009 (cmdline_parse_inst_t *)&cmd_config_burst,
12010 (cmdline_parse_inst_t *)&cmd_config_thresh,
12011 (cmdline_parse_inst_t *)&cmd_config_threshold,
12012 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12013 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12014 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12015 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12016 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12017 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12018 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12019 (cmdline_parse_inst_t *)&cmd_global_config,
12020 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12021 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12022 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12023 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12024 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12025 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12026 (cmdline_parse_inst_t *)&cmd_dump,
12027 (cmdline_parse_inst_t *)&cmd_dump_one,
12028 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12029 (cmdline_parse_inst_t *)&cmd_syn_filter,
12030 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12031 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12032 (cmdline_parse_inst_t *)&cmd_flex_filter,
12033 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12034 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12035 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12036 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12037 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12038 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12039 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12040 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12041 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12042 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12043 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12044 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12045 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12046 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12047 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12048 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12049 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12050 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12051 (cmdline_parse_inst_t *)&cmd_flow,
12052 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12053 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12054 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12055 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12056 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12057 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12058 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12059 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12060 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12061 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12062 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12063 #ifdef RTE_LIBRTE_IXGBE_PMD
12064 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12065 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12066 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12067 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12068 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12069 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12070 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12071 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12072 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12073 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12074 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12075 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12076 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12077 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12078 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12079 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12084 /* prompt function, called from main on MASTER lcore */
12088 /* initialize non-constant commands */
12089 cmd_set_fwd_mode_init();
12090 cmd_set_fwd_retry_mode_init();
12092 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12093 if (testpmd_cl == NULL)
12095 cmdline_interact(testpmd_cl);
12096 cmdline_stdin_exit(testpmd_cl);
12102 if (testpmd_cl != NULL)
12103 cmdline_quit(testpmd_cl);
12107 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12109 if (id == (portid_t)RTE_PORT_ALL) {
12112 FOREACH_PORT(pid, ports) {
12113 /* check if need_reconfig has been set to 1 */
12114 if (ports[pid].need_reconfig == 0)
12115 ports[pid].need_reconfig = dev;
12116 /* check if need_reconfig_queues has been set to 1 */
12117 if (ports[pid].need_reconfig_queues == 0)
12118 ports[pid].need_reconfig_queues = queue;
12120 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12121 /* check if need_reconfig has been set to 1 */
12122 if (ports[id].need_reconfig == 0)
12123 ports[id].need_reconfig = dev;
12124 /* check if need_reconfig_queues has been set to 1 */
12125 if (ports[id].need_reconfig_queues == 0)
12126 ports[id].need_reconfig_queues = queue;