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>
79 #include <cmdline_rdline.h>
80 #include <cmdline_parse.h>
81 #include <cmdline_parse_num.h>
82 #include <cmdline_parse_string.h>
83 #include <cmdline_parse_ipaddr.h>
84 #include <cmdline_parse_etheraddr.h>
85 #include <cmdline_socket.h>
87 #ifdef RTE_LIBRTE_PMD_BOND
88 #include <rte_eth_bond.h>
90 #ifdef RTE_LIBRTE_IXGBE_PMD
91 #include <rte_pmd_ixgbe.h>
95 static struct cmdline *testpmd_cl;
97 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
99 /* *** Help command with introduction. *** */
100 struct cmd_help_brief_result {
101 cmdline_fixed_string_t help;
104 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
106 __attribute__((unused)) void *data)
111 "Help is available for the following sections:\n\n"
112 " help control : Start and stop forwarding.\n"
113 " help display : Displaying port, stats and config "
115 " help config : Configuration information.\n"
116 " help ports : Configuring ports.\n"
117 " help registers : Reading and setting port registers.\n"
118 " help filters : Filters configuration help.\n"
119 " help all : All of the above sections.\n\n"
124 cmdline_parse_token_string_t cmd_help_brief_help =
125 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
127 cmdline_parse_inst_t cmd_help_brief = {
128 .f = cmd_help_brief_parsed,
130 .help_str = "show help",
132 (void *)&cmd_help_brief_help,
137 /* *** Help command with help sections. *** */
138 struct cmd_help_long_result {
139 cmdline_fixed_string_t help;
140 cmdline_fixed_string_t section;
143 static void cmd_help_long_parsed(void *parsed_result,
145 __attribute__((unused)) void *data)
148 struct cmd_help_long_result *res = parsed_result;
150 if (!strcmp(res->section, "all"))
153 if (show_all || !strcmp(res->section, "control")) {
158 "Control forwarding:\n"
159 "-------------------\n\n"
162 " Start packet forwarding with current configuration.\n\n"
165 " Start packet forwarding with current config"
166 " after sending one burst of packets.\n\n"
169 " Stop packet forwarding, and display accumulated"
173 " Quit to prompt.\n\n"
177 if (show_all || !strcmp(res->section, "display")) {
185 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
186 " Display information for port_id, or all.\n\n"
188 "show port X rss reta (size) (mask0,mask1,...)\n"
189 " Display the rss redirection table entry indicated"
190 " by masks on port X. size is used to indicate the"
191 " hardware supported reta size\n\n"
193 "show port (port_id) rss-hash [key]\n"
194 " Display the RSS hash functions and RSS hash key of port\n\n"
196 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
197 " Clear information for port_id, or all.\n\n"
199 "show (rxq|txq) info (port_id) (queue_id)\n"
200 " Display information for configured RX/TX queue.\n\n"
202 "show config (rxtx|cores|fwd|txpkts)\n"
203 " Display the given configuration.\n\n"
205 "read rxd (port_id) (queue_id) (rxd_id)\n"
206 " Display an RX descriptor of a port RX queue.\n\n"
208 "read txd (port_id) (queue_id) (txd_id)\n"
209 " Display a TX descriptor of a port TX queue.\n\n"
213 if (show_all || !strcmp(res->section, "config")) {
219 "Configuration changes only become active when"
220 " forwarding is started/restarted.\n\n"
223 " Reset forwarding to the default configuration.\n\n"
225 "set verbose (level)\n"
226 " Set the debug verbosity level X.\n\n"
229 " Set number of ports.\n\n"
232 " Set number of cores.\n\n"
234 "set coremask (mask)\n"
235 " Set the forwarding cores hexadecimal mask.\n\n"
237 "set portmask (mask)\n"
238 " Set the forwarding ports hexadecimal mask.\n\n"
241 " Set number of packets per burst.\n\n"
243 "set burst tx delay (microseconds) retry (num)\n"
244 " Set the transmit delay time and number of retries,"
245 " effective when retry is enabled.\n\n"
247 "set txpkts (x[,y]*)\n"
248 " Set the length of each segment of TXONLY"
249 " and optionally CSUM packets.\n\n"
251 "set txsplit (off|on|rand)\n"
252 " Set the split policy for the TX packets."
253 " Right now only applicable for CSUM and TXONLY"
256 "set corelist (x[,y]*)\n"
257 " Set the list of forwarding cores.\n\n"
259 "set portlist (x[,y]*)\n"
260 " Set the list of forwarding ports.\n\n"
262 #ifdef RTE_LIBRTE_IXGBE_PMD
263 "set tx loopback (port_id) (on|off)\n"
264 " Enable or disable tx loopback.\n\n"
266 "set all queues drop (port_id) (on|off)\n"
267 " Set drop enable bit for all queues.\n\n"
269 "set vf split drop (port_id) (vf_id) (on|off)\n"
270 " Set split drop enable bit for a VF from the PF.\n\n"
272 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
273 " Set MAC antispoof for a VF from the PF.\n\n"
276 "vlan set strip (on|off) (port_id)\n"
277 " Set the VLAN strip on a port.\n\n"
279 "vlan set stripq (on|off) (port_id,queue_id)\n"
280 " Set the VLAN strip for a queue on a port.\n\n"
282 #ifdef RTE_LIBRTE_IXGBE_PMD
283 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
284 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
286 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
287 " Set VLAN insert for a VF from the PF.\n\n"
289 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
290 " Set VLAN antispoof for a VF from the PF.\n\n"
293 "vlan set filter (on|off) (port_id)\n"
294 " Set the VLAN filter on a port.\n\n"
296 "vlan set qinq (on|off) (port_id)\n"
297 " Set the VLAN QinQ (extended queue in queue)"
300 "vlan set (inner|outer) tpid (value) (port_id)\n"
301 " Set the VLAN TPID for Packet Filtering on"
304 "rx_vlan add (vlan_id|all) (port_id)\n"
305 " Add a vlan_id, or all identifiers, to the set"
306 " of VLAN identifiers filtered by port_id.\n\n"
308 "rx_vlan rm (vlan_id|all) (port_id)\n"
309 " Remove a vlan_id, or all identifiers, from the set"
310 " of VLAN identifiers filtered by port_id.\n\n"
312 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
313 " Add a vlan_id, to the set of VLAN identifiers"
314 "filtered for VF(s) from port_id.\n\n"
316 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
317 " Remove a vlan_id, to the set of VLAN identifiers"
318 "filtered for VF(s) from port_id.\n\n"
320 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
321 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
322 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
323 " add a tunnel filter of a port.\n\n"
325 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
326 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
327 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
328 " remove a tunnel filter of a port.\n\n"
330 "rx_vxlan_port add (udp_port) (port_id)\n"
331 " Add an UDP port for VXLAN packet filter on a port\n\n"
333 "rx_vxlan_port rm (udp_port) (port_id)\n"
334 " Remove an UDP port for VXLAN packet filter on a port\n\n"
336 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
337 " Set hardware insertion of VLAN IDs (single or double VLAN "
338 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
340 "tx_vlan set pvid port_id vlan_id (on|off)\n"
341 " Set port based TX VLAN insertion.\n\n"
343 "tx_vlan reset (port_id)\n"
344 " Disable hardware insertion of a VLAN header in"
345 " packets sent on a port.\n\n"
347 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
348 " Select hardware or software calculation of the"
349 " checksum when transmitting a packet using the"
350 " csum forward engine.\n"
351 " ip|udp|tcp|sctp always concern the inner layer.\n"
352 " outer-ip concerns the outer IP layer in"
353 " case the packet is recognized as a tunnel packet by"
354 " the forward engine (vxlan, gre and ipip are supported)\n"
355 " Please check the NIC datasheet for HW limits.\n\n"
357 "csum parse-tunnel (on|off) (tx_port_id)\n"
358 " If disabled, treat tunnel packets as non-tunneled"
359 " packets (treat inner headers as payload). The port\n"
360 " argument is the port used for TX in csum forward"
363 "csum show (port_id)\n"
364 " Display tx checksum offload configuration\n\n"
366 "tso set (segsize) (portid)\n"
367 " Enable TCP Segmentation Offload in csum forward"
369 " Please check the NIC datasheet for HW limits.\n\n"
372 " Display the status of TCP Segmentation Offload.\n\n"
375 " Set packet forwarding mode.\n\n"
377 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
378 " Add a MAC address on port_id.\n\n"
380 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
381 " Remove a MAC address from port_id.\n\n"
383 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
384 " Add a MAC address for a VF on the port.\n\n"
386 #ifdef RTE_LIBRTE_IXGBE_PMD
387 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
388 " Set the MAC address for a VF from the PF.\n\n"
391 "set port (port_id) uta (mac_address|all) (on|off)\n"
392 " Add/Remove a or all unicast hash filter(s)"
395 "set promisc (port_id|all) (on|off)\n"
396 " Set the promiscuous mode on port_id, or all.\n\n"
398 "set allmulti (port_id|all) (on|off)\n"
399 " Set the allmulti mode on port_id, or all.\n\n"
401 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
402 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
403 " (on|off) autoneg (on|off) (port_id)\n"
404 "set flow_ctrl rx (on|off) (portid)\n"
405 "set flow_ctrl tx (on|off) (portid)\n"
406 "set flow_ctrl high_water (high_water) (portid)\n"
407 "set flow_ctrl low_water (low_water) (portid)\n"
408 "set flow_ctrl pause_time (pause_time) (portid)\n"
409 "set flow_ctrl send_xon (send_xon) (portid)\n"
410 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
411 "set flow_ctrl autoneg (on|off) (port_id)\n"
412 " Set the link flow control parameter on a port.\n\n"
414 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
415 " (low_water) (pause_time) (priority) (port_id)\n"
416 " Set the priority flow control parameter on a"
419 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
420 " Set statistics mapping (qmapping 0..15) for RX/TX"
422 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
423 " on port 0 to mapping 5.\n\n"
425 "set port (port_id) vf (vf_id) rx|tx on|off\n"
426 " Enable/Disable a VF receive/tranmit from a port\n\n"
428 "set port (port_id) vf (vf_id) (mac_addr)"
429 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
430 " Add/Remove unicast or multicast MAC addr filter"
433 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
435 " AUPE:accepts untagged VLAN;"
436 "ROPE:accept unicast hash\n\n"
437 " BAM:accepts broadcast packets;"
438 "MPE:accepts all multicast packets\n\n"
439 " Enable/Disable a VF receive mode of a port\n\n"
441 "set port (port_id) queue (queue_id) rate (rate_num)\n"
442 " Set rate limit for a queue of a port\n\n"
444 "set port (port_id) vf (vf_id) rate (rate_num) "
445 "queue_mask (queue_mask_value)\n"
446 " Set rate limit for queues in VF of a port\n\n"
448 "set port (port_id) mirror-rule (rule_id)"
449 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
450 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
451 " Set pool or vlan type mirror rule on a port.\n"
452 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
453 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
456 "set port (port_id) mirror-rule (rule_id)"
457 " (uplink-mirror|downlink-mirror) dst-pool"
458 " (pool_id) (on|off)\n"
459 " Set uplink or downlink type mirror rule on a port.\n"
460 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
461 " 0 on' enable mirror income traffic to pool 0.\n\n"
463 "reset port (port_id) mirror-rule (rule_id)\n"
464 " Reset a mirror rule.\n\n"
466 "set flush_rx (on|off)\n"
467 " Flush (default) or don't flush RX streams before"
468 " forwarding. Mainly used with PCAP drivers.\n\n"
470 #ifdef RTE_NIC_BYPASS
471 "set bypass mode (normal|bypass|isolate) (port_id)\n"
472 " Set the bypass mode for the lowest port on bypass enabled"
475 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
476 "mode (normal|bypass|isolate) (port_id)\n"
477 " Set the event required to initiate specified bypass mode for"
478 " the lowest port on a bypass enabled NIC where:\n"
479 " timeout = enable bypass after watchdog timeout.\n"
480 " os_on = enable bypass when OS/board is powered on.\n"
481 " os_off = enable bypass when OS/board is powered off.\n"
482 " power_on = enable bypass when power supply is turned on.\n"
483 " power_off = enable bypass when power supply is turned off."
486 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
487 " Set the bypass watchdog timeout to 'n' seconds"
488 " where 0 = instant.\n\n"
490 "show bypass config (port_id)\n"
491 " Show the bypass configuration for a bypass enabled NIC"
492 " using the lowest port on the NIC.\n\n"
494 #ifdef RTE_LIBRTE_PMD_BOND
495 "create bonded device (mode) (socket)\n"
496 " Create a new bonded device with specific bonding mode and socket.\n\n"
498 "add bonding slave (slave_id) (port_id)\n"
499 " Add a slave device to a bonded device.\n\n"
501 "remove bonding slave (slave_id) (port_id)\n"
502 " Remove a slave device from a bonded device.\n\n"
504 "set bonding mode (value) (port_id)\n"
505 " Set the bonding mode on a bonded device.\n\n"
507 "set bonding primary (slave_id) (port_id)\n"
508 " Set the primary slave for a bonded device.\n\n"
510 "show bonding config (port_id)\n"
511 " Show the bonding config for port_id.\n\n"
513 "set bonding mac_addr (port_id) (address)\n"
514 " Set the MAC address of a bonded device.\n\n"
516 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
517 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
519 "set bonding mon_period (port_id) (value)\n"
520 " Set the bonding link status monitoring polling period in ms.\n\n"
522 "set link-up port (port_id)\n"
523 " Set link up for a port.\n\n"
525 "set link-down port (port_id)\n"
526 " Set link down for a port.\n\n"
528 "E-tag set insertion on port-tag-id (value)"
529 " port (port_id) vf (vf_id)\n"
530 " Enable E-tag insertion for a VF on a port\n\n"
532 "E-tag set insertion off port (port_id) vf (vf_id)\n"
533 " Disable E-tag insertion for a VF on a port\n\n"
535 "E-tag set stripping (on|off) port (port_id)\n"
536 " Enable/disable E-tag stripping on a port\n\n"
538 "E-tag set forwarding (on|off) port (port_id)\n"
539 " Enable/disable E-tag based forwarding"
542 "E-tag set filter add e-tag-id (value) dst-pool"
543 " (pool_id) port (port_id)\n"
544 " Add an E-tag forwarding filter on a port\n\n"
546 "E-tag set filter del e-tag-id (value) port (port_id)\n"
547 " Delete an E-tag forwarding filter on a port\n\n"
549 , list_pkt_forwarding_modes()
553 if (show_all || !strcmp(res->section, "ports")) {
559 "----------------\n\n"
561 "port start (port_id|all)\n"
562 " Start all ports or port_id.\n\n"
564 "port stop (port_id|all)\n"
565 " Stop all ports or port_id.\n\n"
567 "port close (port_id|all)\n"
568 " Close all ports or port_id.\n\n"
570 "port attach (ident)\n"
571 " Attach physical or virtual dev by pci address or virtual device name\n\n"
573 "port detach (port_id)\n"
574 " Detach physical or virtual dev by port_id\n\n"
576 "port config (port_id|all)"
577 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
578 " duplex (half|full|auto)\n"
579 " Set speed and duplex for all ports or port_id\n\n"
581 "port config all (rxq|txq|rxd|txd) (value)\n"
582 " Set number for rxq/txq/rxd/txd.\n\n"
584 "port config all max-pkt-len (value)\n"
585 " Set the max packet length.\n\n"
587 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
588 "hw-vlan-strip|hw-vlan-extend|drop-en)"
590 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
593 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
594 " Set the RSS mode.\n\n"
596 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
597 " Set the RSS redirection table.\n\n"
599 "port config (port_id) dcb vt (on|off) (traffic_class)"
601 " Set the DCB mode.\n\n"
603 "port config all burst (value)\n"
604 " Set the number of packets per burst.\n\n"
606 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
608 " Set the ring prefetch/host/writeback threshold"
609 " for tx/rx queue.\n\n"
611 "port config all (txfreet|txrst|rxfreet) (value)\n"
612 " Set free threshold for rx/tx, or set"
613 " tx rs bit threshold.\n\n"
614 "port config mtu X value\n"
615 " Set the MTU of port X to a given value\n\n"
617 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
618 " Start/stop a rx/tx queue of port X. Only take effect"
619 " when port X is started\n\n"
621 "port config (port_id|all) l2-tunnel E-tag ether-type"
623 " Set the value of E-tag ether-type.\n\n"
625 "port config (port_id|all) l2-tunnel E-tag"
626 " (enable|disable)\n"
627 " Enable/disable the E-tag support.\n\n"
631 if (show_all || !strcmp(res->section, "registers")) {
639 "read reg (port_id) (address)\n"
640 " Display value of a port register.\n\n"
642 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
643 " Display a port register bit field.\n\n"
645 "read regbit (port_id) (address) (bit_x)\n"
646 " Display a single port register bit.\n\n"
648 "write reg (port_id) (address) (value)\n"
649 " Set value of a port register.\n\n"
651 "write regfield (port_id) (address) (bit_x) (bit_y)"
653 " Set bit field of a port register.\n\n"
655 "write regbit (port_id) (address) (bit_x) (value)\n"
656 " Set single bit value of a port register.\n\n"
659 if (show_all || !strcmp(res->section, "filters")) {
667 "ethertype_filter (port_id) (add|del)"
668 " (mac_addr|mac_ignr) (mac_address) ethertype"
669 " (ether_type) (drop|fwd) queue (queue_id)\n"
670 " Add/Del an ethertype filter.\n\n"
672 "2tuple_filter (port_id) (add|del)"
673 " dst_port (dst_port_value) protocol (protocol_value)"
674 " mask (mask_value) tcp_flags (tcp_flags_value)"
675 " priority (prio_value) queue (queue_id)\n"
676 " Add/Del a 2tuple filter.\n\n"
678 "5tuple_filter (port_id) (add|del)"
679 " dst_ip (dst_address) src_ip (src_address)"
680 " dst_port (dst_port_value) src_port (src_port_value)"
681 " protocol (protocol_value)"
682 " mask (mask_value) tcp_flags (tcp_flags_value)"
683 " priority (prio_value) queue (queue_id)\n"
684 " Add/Del a 5tuple filter.\n\n"
686 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
687 " Add/Del syn filter.\n\n"
689 "flex_filter (port_id) (add|del) len (len_value)"
690 " bytes (bytes_value) mask (mask_value)"
691 " priority (prio_value) queue (queue_id)\n"
692 " Add/Del a flex filter.\n\n"
694 "flow_director_filter (port_id) mode IP (add|del|update)"
695 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
696 " src (src_ip_address) dst (dst_ip_address)"
697 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
698 " vlan (vlan_value) flexbytes (flexbytes_value)"
699 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
700 " fd_id (fd_id_value)\n"
701 " Add/Del an IP type flow director filter.\n\n"
703 "flow_director_filter (port_id) mode IP (add|del|update)"
704 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
705 " src (src_ip_address) (src_port)"
706 " dst (dst_ip_address) (dst_port)"
707 " tos (tos_value) ttl (ttl_value)"
708 " vlan (vlan_value) flexbytes (flexbytes_value)"
709 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
710 " fd_id (fd_id_value)\n"
711 " Add/Del an UDP/TCP type flow director filter.\n\n"
713 "flow_director_filter (port_id) mode IP (add|del|update)"
714 " flow (ipv4-sctp|ipv6-sctp)"
715 " src (src_ip_address) (src_port)"
716 " dst (dst_ip_address) (dst_port)"
717 " tag (verification_tag) "
718 " tos (tos_value) ttl (ttl_value)"
720 " flexbytes (flexbytes_value) (drop|fwd)"
721 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
722 " Add/Del a SCTP type flow director filter.\n\n"
724 "flow_director_filter (port_id) mode IP (add|del|update)"
725 " flow l2_payload ether (ethertype)"
726 " flexbytes (flexbytes_value) (drop|fwd)"
727 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
728 " Add/Del a l2 payload type flow director filter.\n\n"
730 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
731 " mac (mac_address) vlan (vlan_value)"
732 " flexbytes (flexbytes_value) (drop|fwd)"
733 " queue (queue_id) fd_id (fd_id_value)\n"
734 " Add/Del a MAC-VLAN flow director filter.\n\n"
736 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
737 " mac (mac_address) vlan (vlan_value)"
738 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
739 " flexbytes (flexbytes_value) (drop|fwd)"
740 " queue (queue_id) fd_id (fd_id_value)\n"
741 " Add/Del a Tunnel flow director filter.\n\n"
743 "flush_flow_director (port_id)\n"
744 " Flush all flow director entries of a device.\n\n"
746 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
747 " src_mask (ipv4_src) (ipv6_src) (src_port)"
748 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
749 " Set flow director IP mask.\n\n"
751 "flow_director_mask (port_id) mode MAC-VLAN"
752 " vlan (vlan_value)\n"
753 " Set flow director MAC-VLAN mask.\n\n"
755 "flow_director_mask (port_id) mode Tunnel"
756 " vlan (vlan_value) mac (mac_value)"
757 " tunnel-type (tunnel_type_value)"
758 " tunnel-id (tunnel_id_value)\n"
759 " Set flow director Tunnel mask.\n\n"
761 "flow_director_flex_mask (port_id)"
762 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
763 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
765 " Configure mask of flex payload.\n\n"
767 "flow_director_flex_payload (port_id)"
768 " (raw|l2|l3|l4) (config)\n"
769 " Configure flex payload selection.\n\n"
771 "get_sym_hash_ena_per_port (port_id)\n"
772 " get symmetric hash enable configuration per port.\n\n"
774 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
775 " set symmetric hash enable configuration per port"
776 " to enable or disable.\n\n"
778 "get_hash_global_config (port_id)\n"
779 " Get the global configurations of hash filters.\n\n"
781 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
782 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
783 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
784 " (enable|disable)\n"
785 " Set the global configurations of hash filters.\n\n"
787 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
788 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
789 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
790 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
791 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
792 "ipv6-next-header|udp-src-port|udp-dst-port|"
793 "tcp-src-port|tcp-dst-port|sctp-src-port|"
794 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
795 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
796 "fld-8th|none) (select|add)\n"
797 " Set the input set for hash.\n\n"
799 "set_fdir_input_set (port_id) "
800 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
801 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
802 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
803 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
804 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
805 "udp-dst-port|tcp-src-port|tcp-dst-port|"
806 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
808 " Set the input set for FDir.\n\n"
813 cmdline_parse_token_string_t cmd_help_long_help =
814 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
816 cmdline_parse_token_string_t cmd_help_long_section =
817 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
818 "all#control#display#config#"
819 "ports#registers#filters");
821 cmdline_parse_inst_t cmd_help_long = {
822 .f = cmd_help_long_parsed,
824 .help_str = "show help",
826 (void *)&cmd_help_long_help,
827 (void *)&cmd_help_long_section,
833 /* *** start/stop/close all ports *** */
834 struct cmd_operate_port_result {
835 cmdline_fixed_string_t keyword;
836 cmdline_fixed_string_t name;
837 cmdline_fixed_string_t value;
840 static void cmd_operate_port_parsed(void *parsed_result,
841 __attribute__((unused)) struct cmdline *cl,
842 __attribute__((unused)) void *data)
844 struct cmd_operate_port_result *res = parsed_result;
846 if (!strcmp(res->name, "start"))
847 start_port(RTE_PORT_ALL);
848 else if (!strcmp(res->name, "stop"))
849 stop_port(RTE_PORT_ALL);
850 else if (!strcmp(res->name, "close"))
851 close_port(RTE_PORT_ALL);
853 printf("Unknown parameter\n");
856 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
857 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
859 cmdline_parse_token_string_t cmd_operate_port_all_port =
860 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
862 cmdline_parse_token_string_t cmd_operate_port_all_all =
863 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
865 cmdline_parse_inst_t cmd_operate_port = {
866 .f = cmd_operate_port_parsed,
868 .help_str = "port start|stop|close all: start/stop/close all ports",
870 (void *)&cmd_operate_port_all_cmd,
871 (void *)&cmd_operate_port_all_port,
872 (void *)&cmd_operate_port_all_all,
877 /* *** start/stop/close specific port *** */
878 struct cmd_operate_specific_port_result {
879 cmdline_fixed_string_t keyword;
880 cmdline_fixed_string_t name;
884 static void cmd_operate_specific_port_parsed(void *parsed_result,
885 __attribute__((unused)) struct cmdline *cl,
886 __attribute__((unused)) void *data)
888 struct cmd_operate_specific_port_result *res = parsed_result;
890 if (!strcmp(res->name, "start"))
891 start_port(res->value);
892 else if (!strcmp(res->name, "stop"))
893 stop_port(res->value);
894 else if (!strcmp(res->name, "close"))
895 close_port(res->value);
897 printf("Unknown parameter\n");
900 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
901 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
903 cmdline_parse_token_string_t cmd_operate_specific_port_port =
904 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
905 name, "start#stop#close");
906 cmdline_parse_token_num_t cmd_operate_specific_port_id =
907 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
910 cmdline_parse_inst_t cmd_operate_specific_port = {
911 .f = cmd_operate_specific_port_parsed,
913 .help_str = "port start|stop|close X: start/stop/close port X",
915 (void *)&cmd_operate_specific_port_cmd,
916 (void *)&cmd_operate_specific_port_port,
917 (void *)&cmd_operate_specific_port_id,
922 /* *** attach a specified port *** */
923 struct cmd_operate_attach_port_result {
924 cmdline_fixed_string_t port;
925 cmdline_fixed_string_t keyword;
926 cmdline_fixed_string_t identifier;
929 static void cmd_operate_attach_port_parsed(void *parsed_result,
930 __attribute__((unused)) struct cmdline *cl,
931 __attribute__((unused)) void *data)
933 struct cmd_operate_attach_port_result *res = parsed_result;
935 if (!strcmp(res->keyword, "attach"))
936 attach_port(res->identifier);
938 printf("Unknown parameter\n");
941 cmdline_parse_token_string_t cmd_operate_attach_port_port =
942 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
944 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
945 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
947 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
948 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
951 cmdline_parse_inst_t cmd_operate_attach_port = {
952 .f = cmd_operate_attach_port_parsed,
954 .help_str = "port attach identifier, "
955 "identifier: pci address or virtual dev name",
957 (void *)&cmd_operate_attach_port_port,
958 (void *)&cmd_operate_attach_port_keyword,
959 (void *)&cmd_operate_attach_port_identifier,
964 /* *** detach a specified port *** */
965 struct cmd_operate_detach_port_result {
966 cmdline_fixed_string_t port;
967 cmdline_fixed_string_t keyword;
971 static void cmd_operate_detach_port_parsed(void *parsed_result,
972 __attribute__((unused)) struct cmdline *cl,
973 __attribute__((unused)) void *data)
975 struct cmd_operate_detach_port_result *res = parsed_result;
977 if (!strcmp(res->keyword, "detach"))
978 detach_port(res->port_id);
980 printf("Unknown parameter\n");
983 cmdline_parse_token_string_t cmd_operate_detach_port_port =
984 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
986 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
987 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
989 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
990 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
993 cmdline_parse_inst_t cmd_operate_detach_port = {
994 .f = cmd_operate_detach_port_parsed,
996 .help_str = "port detach port_id",
998 (void *)&cmd_operate_detach_port_port,
999 (void *)&cmd_operate_detach_port_keyword,
1000 (void *)&cmd_operate_detach_port_port_id,
1005 /* *** configure speed for all ports *** */
1006 struct cmd_config_speed_all {
1007 cmdline_fixed_string_t port;
1008 cmdline_fixed_string_t keyword;
1009 cmdline_fixed_string_t all;
1010 cmdline_fixed_string_t item1;
1011 cmdline_fixed_string_t item2;
1012 cmdline_fixed_string_t value1;
1013 cmdline_fixed_string_t value2;
1017 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1022 if (!strcmp(duplexstr, "half")) {
1023 duplex = ETH_LINK_HALF_DUPLEX;
1024 } else if (!strcmp(duplexstr, "full")) {
1025 duplex = ETH_LINK_FULL_DUPLEX;
1026 } else if (!strcmp(duplexstr, "auto")) {
1027 duplex = ETH_LINK_FULL_DUPLEX;
1029 printf("Unknown duplex parameter\n");
1033 if (!strcmp(speedstr, "10")) {
1034 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1035 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1036 } else if (!strcmp(speedstr, "100")) {
1037 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1038 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1040 if (duplex != ETH_LINK_FULL_DUPLEX) {
1041 printf("Invalid speed/duplex parameters\n");
1044 if (!strcmp(speedstr, "1000")) {
1045 *speed = ETH_LINK_SPEED_1G;
1046 } else if (!strcmp(speedstr, "10000")) {
1047 *speed = ETH_LINK_SPEED_10G;
1048 } else if (!strcmp(speedstr, "25000")) {
1049 *speed = ETH_LINK_SPEED_25G;
1050 } else if (!strcmp(speedstr, "40000")) {
1051 *speed = ETH_LINK_SPEED_40G;
1052 } else if (!strcmp(speedstr, "50000")) {
1053 *speed = ETH_LINK_SPEED_50G;
1054 } else if (!strcmp(speedstr, "100000")) {
1055 *speed = ETH_LINK_SPEED_100G;
1056 } else if (!strcmp(speedstr, "auto")) {
1057 *speed = ETH_LINK_SPEED_AUTONEG;
1059 printf("Unknown speed parameter\n");
1068 cmd_config_speed_all_parsed(void *parsed_result,
1069 __attribute__((unused)) struct cmdline *cl,
1070 __attribute__((unused)) void *data)
1072 struct cmd_config_speed_all *res = parsed_result;
1073 uint32_t link_speed;
1076 if (!all_ports_stopped()) {
1077 printf("Please stop all ports first\n");
1081 if (parse_and_check_speed_duplex(res->value1, res->value2,
1085 FOREACH_PORT(pid, ports) {
1086 ports[pid].dev_conf.link_speeds = link_speed;
1089 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1092 cmdline_parse_token_string_t cmd_config_speed_all_port =
1093 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1094 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1095 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1097 cmdline_parse_token_string_t cmd_config_speed_all_all =
1098 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1099 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1100 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1101 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1102 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1103 "10#100#1000#10000#25000#40000#50000#100000#auto");
1104 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1105 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1106 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1107 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1110 cmdline_parse_inst_t cmd_config_speed_all = {
1111 .f = cmd_config_speed_all_parsed,
1113 .help_str = "port config all speed "
1114 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1117 (void *)&cmd_config_speed_all_port,
1118 (void *)&cmd_config_speed_all_keyword,
1119 (void *)&cmd_config_speed_all_all,
1120 (void *)&cmd_config_speed_all_item1,
1121 (void *)&cmd_config_speed_all_value1,
1122 (void *)&cmd_config_speed_all_item2,
1123 (void *)&cmd_config_speed_all_value2,
1128 /* *** configure speed for specific port *** */
1129 struct cmd_config_speed_specific {
1130 cmdline_fixed_string_t port;
1131 cmdline_fixed_string_t keyword;
1133 cmdline_fixed_string_t item1;
1134 cmdline_fixed_string_t item2;
1135 cmdline_fixed_string_t value1;
1136 cmdline_fixed_string_t value2;
1140 cmd_config_speed_specific_parsed(void *parsed_result,
1141 __attribute__((unused)) struct cmdline *cl,
1142 __attribute__((unused)) void *data)
1144 struct cmd_config_speed_specific *res = parsed_result;
1145 uint32_t link_speed;
1147 if (!all_ports_stopped()) {
1148 printf("Please stop all ports first\n");
1152 if (port_id_is_invalid(res->id, ENABLED_WARN))
1155 if (parse_and_check_speed_duplex(res->value1, res->value2,
1159 ports[res->id].dev_conf.link_speeds = link_speed;
1161 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1165 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1166 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1168 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1169 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1171 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1172 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1173 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1174 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1176 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1177 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1178 "10#100#1000#10000#25000#40000#50000#100000#auto");
1179 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1182 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1186 cmdline_parse_inst_t cmd_config_speed_specific = {
1187 .f = cmd_config_speed_specific_parsed,
1189 .help_str = "port config X speed "
1190 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1193 (void *)&cmd_config_speed_specific_port,
1194 (void *)&cmd_config_speed_specific_keyword,
1195 (void *)&cmd_config_speed_specific_id,
1196 (void *)&cmd_config_speed_specific_item1,
1197 (void *)&cmd_config_speed_specific_value1,
1198 (void *)&cmd_config_speed_specific_item2,
1199 (void *)&cmd_config_speed_specific_value2,
1204 /* *** configure txq/rxq, txd/rxd *** */
1205 struct cmd_config_rx_tx {
1206 cmdline_fixed_string_t port;
1207 cmdline_fixed_string_t keyword;
1208 cmdline_fixed_string_t all;
1209 cmdline_fixed_string_t name;
1214 cmd_config_rx_tx_parsed(void *parsed_result,
1215 __attribute__((unused)) struct cmdline *cl,
1216 __attribute__((unused)) void *data)
1218 struct cmd_config_rx_tx *res = parsed_result;
1220 if (!all_ports_stopped()) {
1221 printf("Please stop all ports first\n");
1224 if (!strcmp(res->name, "rxq")) {
1225 if (!res->value && !nb_txq) {
1226 printf("Warning: Either rx or tx queues should be non zero\n");
1229 nb_rxq = res->value;
1231 else if (!strcmp(res->name, "txq")) {
1232 if (!res->value && !nb_rxq) {
1233 printf("Warning: Either rx or tx queues should be non zero\n");
1236 nb_txq = res->value;
1238 else if (!strcmp(res->name, "rxd")) {
1239 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1240 printf("rxd %d invalid - must be > 0 && <= %d\n",
1241 res->value, RTE_TEST_RX_DESC_MAX);
1244 nb_rxd = res->value;
1245 } else if (!strcmp(res->name, "txd")) {
1246 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1247 printf("txd %d invalid - must be > 0 && <= %d\n",
1248 res->value, RTE_TEST_TX_DESC_MAX);
1251 nb_txd = res->value;
1253 printf("Unknown parameter\n");
1261 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1264 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1265 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1266 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1268 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1269 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1270 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1271 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1273 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1274 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1276 cmdline_parse_inst_t cmd_config_rx_tx = {
1277 .f = cmd_config_rx_tx_parsed,
1279 .help_str = "port config all rxq|txq|rxd|txd value",
1281 (void *)&cmd_config_rx_tx_port,
1282 (void *)&cmd_config_rx_tx_keyword,
1283 (void *)&cmd_config_rx_tx_all,
1284 (void *)&cmd_config_rx_tx_name,
1285 (void *)&cmd_config_rx_tx_value,
1290 /* *** config max packet length *** */
1291 struct cmd_config_max_pkt_len_result {
1292 cmdline_fixed_string_t port;
1293 cmdline_fixed_string_t keyword;
1294 cmdline_fixed_string_t all;
1295 cmdline_fixed_string_t name;
1300 cmd_config_max_pkt_len_parsed(void *parsed_result,
1301 __attribute__((unused)) struct cmdline *cl,
1302 __attribute__((unused)) void *data)
1304 struct cmd_config_max_pkt_len_result *res = parsed_result;
1306 if (!all_ports_stopped()) {
1307 printf("Please stop all ports first\n");
1311 if (!strcmp(res->name, "max-pkt-len")) {
1312 if (res->value < ETHER_MIN_LEN) {
1313 printf("max-pkt-len can not be less than %d\n",
1317 if (res->value == rx_mode.max_rx_pkt_len)
1320 rx_mode.max_rx_pkt_len = res->value;
1321 if (res->value > ETHER_MAX_LEN)
1322 rx_mode.jumbo_frame = 1;
1324 rx_mode.jumbo_frame = 0;
1326 printf("Unknown parameter\n");
1332 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1335 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1336 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1338 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1339 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1341 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1342 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1344 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1345 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1347 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1348 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1351 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1352 .f = cmd_config_max_pkt_len_parsed,
1354 .help_str = "port config all max-pkt-len value",
1356 (void *)&cmd_config_max_pkt_len_port,
1357 (void *)&cmd_config_max_pkt_len_keyword,
1358 (void *)&cmd_config_max_pkt_len_all,
1359 (void *)&cmd_config_max_pkt_len_name,
1360 (void *)&cmd_config_max_pkt_len_value,
1365 /* *** configure port MTU *** */
1366 struct cmd_config_mtu_result {
1367 cmdline_fixed_string_t port;
1368 cmdline_fixed_string_t keyword;
1369 cmdline_fixed_string_t mtu;
1375 cmd_config_mtu_parsed(void *parsed_result,
1376 __attribute__((unused)) struct cmdline *cl,
1377 __attribute__((unused)) void *data)
1379 struct cmd_config_mtu_result *res = parsed_result;
1381 if (res->value < ETHER_MIN_LEN) {
1382 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1385 port_mtu_set(res->port_id, res->value);
1388 cmdline_parse_token_string_t cmd_config_mtu_port =
1389 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1391 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1394 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1395 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1397 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1398 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1399 cmdline_parse_token_num_t cmd_config_mtu_value =
1400 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1402 cmdline_parse_inst_t cmd_config_mtu = {
1403 .f = cmd_config_mtu_parsed,
1405 .help_str = "port config mtu port_id value",
1407 (void *)&cmd_config_mtu_port,
1408 (void *)&cmd_config_mtu_keyword,
1409 (void *)&cmd_config_mtu_mtu,
1410 (void *)&cmd_config_mtu_port_id,
1411 (void *)&cmd_config_mtu_value,
1416 /* *** configure rx mode *** */
1417 struct cmd_config_rx_mode_flag {
1418 cmdline_fixed_string_t port;
1419 cmdline_fixed_string_t keyword;
1420 cmdline_fixed_string_t all;
1421 cmdline_fixed_string_t name;
1422 cmdline_fixed_string_t value;
1426 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1427 __attribute__((unused)) struct cmdline *cl,
1428 __attribute__((unused)) void *data)
1430 struct cmd_config_rx_mode_flag *res = parsed_result;
1432 if (!all_ports_stopped()) {
1433 printf("Please stop all ports first\n");
1437 if (!strcmp(res->name, "crc-strip")) {
1438 if (!strcmp(res->value, "on"))
1439 rx_mode.hw_strip_crc = 1;
1440 else if (!strcmp(res->value, "off"))
1441 rx_mode.hw_strip_crc = 0;
1443 printf("Unknown parameter\n");
1446 } else if (!strcmp(res->name, "scatter")) {
1447 if (!strcmp(res->value, "on"))
1448 rx_mode.enable_scatter = 1;
1449 else if (!strcmp(res->value, "off"))
1450 rx_mode.enable_scatter = 0;
1452 printf("Unknown parameter\n");
1455 } else if (!strcmp(res->name, "rx-cksum")) {
1456 if (!strcmp(res->value, "on"))
1457 rx_mode.hw_ip_checksum = 1;
1458 else if (!strcmp(res->value, "off"))
1459 rx_mode.hw_ip_checksum = 0;
1461 printf("Unknown parameter\n");
1464 } else if (!strcmp(res->name, "hw-vlan")) {
1465 if (!strcmp(res->value, "on")) {
1466 rx_mode.hw_vlan_filter = 1;
1467 rx_mode.hw_vlan_strip = 1;
1469 else if (!strcmp(res->value, "off")) {
1470 rx_mode.hw_vlan_filter = 0;
1471 rx_mode.hw_vlan_strip = 0;
1474 printf("Unknown parameter\n");
1477 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1478 if (!strcmp(res->value, "on"))
1479 rx_mode.hw_vlan_filter = 1;
1480 else if (!strcmp(res->value, "off"))
1481 rx_mode.hw_vlan_filter = 0;
1483 printf("Unknown parameter\n");
1486 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1487 if (!strcmp(res->value, "on"))
1488 rx_mode.hw_vlan_strip = 1;
1489 else if (!strcmp(res->value, "off"))
1490 rx_mode.hw_vlan_strip = 0;
1492 printf("Unknown parameter\n");
1495 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1496 if (!strcmp(res->value, "on"))
1497 rx_mode.hw_vlan_extend = 1;
1498 else if (!strcmp(res->value, "off"))
1499 rx_mode.hw_vlan_extend = 0;
1501 printf("Unknown parameter\n");
1504 } else if (!strcmp(res->name, "drop-en")) {
1505 if (!strcmp(res->value, "on"))
1507 else if (!strcmp(res->value, "off"))
1510 printf("Unknown parameter\n");
1514 printf("Unknown parameter\n");
1520 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1523 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1524 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1525 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1526 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1528 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1529 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1530 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1531 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1532 "crc-strip#scatter#rx-cksum#hw-vlan#"
1533 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1534 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1535 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1538 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1539 .f = cmd_config_rx_mode_flag_parsed,
1541 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1542 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1544 (void *)&cmd_config_rx_mode_flag_port,
1545 (void *)&cmd_config_rx_mode_flag_keyword,
1546 (void *)&cmd_config_rx_mode_flag_all,
1547 (void *)&cmd_config_rx_mode_flag_name,
1548 (void *)&cmd_config_rx_mode_flag_value,
1553 /* *** configure rss *** */
1554 struct cmd_config_rss {
1555 cmdline_fixed_string_t port;
1556 cmdline_fixed_string_t keyword;
1557 cmdline_fixed_string_t all;
1558 cmdline_fixed_string_t name;
1559 cmdline_fixed_string_t value;
1563 cmd_config_rss_parsed(void *parsed_result,
1564 __attribute__((unused)) struct cmdline *cl,
1565 __attribute__((unused)) void *data)
1567 struct cmd_config_rss *res = parsed_result;
1568 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1572 if (!strcmp(res->value, "all"))
1573 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1574 ETH_RSS_UDP | ETH_RSS_SCTP |
1576 else if (!strcmp(res->value, "ip"))
1577 rss_conf.rss_hf = ETH_RSS_IP;
1578 else if (!strcmp(res->value, "udp"))
1579 rss_conf.rss_hf = ETH_RSS_UDP;
1580 else if (!strcmp(res->value, "tcp"))
1581 rss_conf.rss_hf = ETH_RSS_TCP;
1582 else if (!strcmp(res->value, "sctp"))
1583 rss_conf.rss_hf = ETH_RSS_SCTP;
1584 else if (!strcmp(res->value, "ether"))
1585 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1586 else if (!strcmp(res->value, "port"))
1587 rss_conf.rss_hf = ETH_RSS_PORT;
1588 else if (!strcmp(res->value, "vxlan"))
1589 rss_conf.rss_hf = ETH_RSS_VXLAN;
1590 else if (!strcmp(res->value, "geneve"))
1591 rss_conf.rss_hf = ETH_RSS_GENEVE;
1592 else if (!strcmp(res->value, "nvgre"))
1593 rss_conf.rss_hf = ETH_RSS_NVGRE;
1594 else if (!strcmp(res->value, "none"))
1595 rss_conf.rss_hf = 0;
1597 printf("Unknown parameter\n");
1600 rss_conf.rss_key = NULL;
1601 for (i = 0; i < rte_eth_dev_count(); i++) {
1602 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1604 printf("Configuration of RSS hash at ethernet port %d "
1605 "failed with error (%d): %s.\n",
1606 i, -diag, strerror(-diag));
1610 cmdline_parse_token_string_t cmd_config_rss_port =
1611 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1612 cmdline_parse_token_string_t cmd_config_rss_keyword =
1613 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1614 cmdline_parse_token_string_t cmd_config_rss_all =
1615 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1616 cmdline_parse_token_string_t cmd_config_rss_name =
1617 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1618 cmdline_parse_token_string_t cmd_config_rss_value =
1619 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1620 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1622 cmdline_parse_inst_t cmd_config_rss = {
1623 .f = cmd_config_rss_parsed,
1625 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1627 (void *)&cmd_config_rss_port,
1628 (void *)&cmd_config_rss_keyword,
1629 (void *)&cmd_config_rss_all,
1630 (void *)&cmd_config_rss_name,
1631 (void *)&cmd_config_rss_value,
1636 /* *** configure rss hash key *** */
1637 struct cmd_config_rss_hash_key {
1638 cmdline_fixed_string_t port;
1639 cmdline_fixed_string_t config;
1641 cmdline_fixed_string_t rss_hash_key;
1642 cmdline_fixed_string_t rss_type;
1643 cmdline_fixed_string_t key;
1647 hexa_digit_to_value(char hexa_digit)
1649 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1650 return (uint8_t) (hexa_digit - '0');
1651 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1652 return (uint8_t) ((hexa_digit - 'a') + 10);
1653 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1654 return (uint8_t) ((hexa_digit - 'A') + 10);
1655 /* Invalid hexa digit */
1660 parse_and_check_key_hexa_digit(char *key, int idx)
1664 hexa_v = hexa_digit_to_value(key[idx]);
1666 printf("invalid key: character %c at position %d is not a "
1667 "valid hexa digit\n", key[idx], idx);
1672 cmd_config_rss_hash_key_parsed(void *parsed_result,
1673 __attribute__((unused)) struct cmdline *cl,
1674 __attribute__((unused)) void *data)
1676 struct cmd_config_rss_hash_key *res = parsed_result;
1677 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1681 struct rte_eth_dev_info dev_info;
1682 uint8_t hash_key_size;
1685 memset(&dev_info, 0, sizeof(dev_info));
1686 rte_eth_dev_info_get(res->port_id, &dev_info);
1687 if (dev_info.hash_key_size > 0 &&
1688 dev_info.hash_key_size <= sizeof(hash_key))
1689 hash_key_size = dev_info.hash_key_size;
1691 printf("dev_info did not provide a valid hash key size\n");
1694 /* Check the length of the RSS hash key */
1695 key_len = strlen(res->key);
1696 if (key_len != (hash_key_size * 2)) {
1697 printf("key length: %d invalid - key must be a string of %d"
1698 " hexa-decimal numbers\n",
1699 (int) key_len, hash_key_size * 2);
1702 /* Translate RSS hash key into binary representation */
1703 for (i = 0; i < hash_key_size; i++) {
1704 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1707 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1710 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1712 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1716 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1718 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1719 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1721 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1722 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1723 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1724 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1725 rss_hash_key, "rss-hash-key");
1726 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1727 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1728 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1729 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1730 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1731 "ipv6-tcp-ex#ipv6-udp-ex");
1732 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1735 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1736 .f = cmd_config_rss_hash_key_parsed,
1739 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1740 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1741 "ipv6-sctp|ipv6-other|l2-payload|"
1742 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1743 "<string of hexa digits (variable length, NIC dependent)>\n",
1745 (void *)&cmd_config_rss_hash_key_port,
1746 (void *)&cmd_config_rss_hash_key_config,
1747 (void *)&cmd_config_rss_hash_key_port_id,
1748 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1749 (void *)&cmd_config_rss_hash_key_rss_type,
1750 (void *)&cmd_config_rss_hash_key_value,
1755 /* *** configure port rxq/txq start/stop *** */
1756 struct cmd_config_rxtx_queue {
1757 cmdline_fixed_string_t port;
1759 cmdline_fixed_string_t rxtxq;
1761 cmdline_fixed_string_t opname;
1765 cmd_config_rxtx_queue_parsed(void *parsed_result,
1766 __attribute__((unused)) struct cmdline *cl,
1767 __attribute__((unused)) void *data)
1769 struct cmd_config_rxtx_queue *res = parsed_result;
1774 if (test_done == 0) {
1775 printf("Please stop forwarding first\n");
1779 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1782 if (port_is_started(res->portid) != 1) {
1783 printf("Please start port %u first\n", res->portid);
1787 if (!strcmp(res->rxtxq, "rxq"))
1789 else if (!strcmp(res->rxtxq, "txq"))
1792 printf("Unknown parameter\n");
1796 if (isrx && rx_queue_id_is_invalid(res->qid))
1798 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1801 if (!strcmp(res->opname, "start"))
1803 else if (!strcmp(res->opname, "stop"))
1806 printf("Unknown parameter\n");
1810 if (isstart && isrx)
1811 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1812 else if (!isstart && isrx)
1813 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1814 else if (isstart && !isrx)
1815 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1817 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1819 if (ret == -ENOTSUP)
1820 printf("Function not supported in PMD driver\n");
1823 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1824 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1825 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1826 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1827 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1828 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1829 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1830 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1831 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1835 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1836 .f = cmd_config_rxtx_queue_parsed,
1838 .help_str = "port X rxq|txq ID start|stop",
1840 (void *)&cmd_config_rxtx_queue_port,
1841 (void *)&cmd_config_rxtx_queue_portid,
1842 (void *)&cmd_config_rxtx_queue_rxtxq,
1843 (void *)&cmd_config_rxtx_queue_qid,
1844 (void *)&cmd_config_rxtx_queue_opname,
1849 /* *** Configure RSS RETA *** */
1850 struct cmd_config_rss_reta {
1851 cmdline_fixed_string_t port;
1852 cmdline_fixed_string_t keyword;
1854 cmdline_fixed_string_t name;
1855 cmdline_fixed_string_t list_name;
1856 cmdline_fixed_string_t list_of_items;
1860 parse_reta_config(const char *str,
1861 struct rte_eth_rss_reta_entry64 *reta_conf,
1862 uint16_t nb_entries)
1866 uint16_t hash_index, idx, shift;
1869 const char *p, *p0 = str;
1876 unsigned long int_fld[_NUM_FLD];
1877 char *str_fld[_NUM_FLD];
1879 while ((p = strchr(p0,'(')) != NULL) {
1881 if((p0 = strchr(p,')')) == NULL)
1885 if(size >= sizeof(s))
1888 snprintf(s, sizeof(s), "%.*s", size, p);
1889 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1891 for (i = 0; i < _NUM_FLD; i++) {
1893 int_fld[i] = strtoul(str_fld[i], &end, 0);
1894 if (errno != 0 || end == str_fld[i] ||
1899 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1900 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1902 if (hash_index >= nb_entries) {
1903 printf("Invalid RETA hash index=%d\n", hash_index);
1907 idx = hash_index / RTE_RETA_GROUP_SIZE;
1908 shift = hash_index % RTE_RETA_GROUP_SIZE;
1909 reta_conf[idx].mask |= (1ULL << shift);
1910 reta_conf[idx].reta[shift] = nb_queue;
1917 cmd_set_rss_reta_parsed(void *parsed_result,
1918 __attribute__((unused)) struct cmdline *cl,
1919 __attribute__((unused)) void *data)
1922 struct rte_eth_dev_info dev_info;
1923 struct rte_eth_rss_reta_entry64 reta_conf[8];
1924 struct cmd_config_rss_reta *res = parsed_result;
1926 memset(&dev_info, 0, sizeof(dev_info));
1927 rte_eth_dev_info_get(res->port_id, &dev_info);
1928 if (dev_info.reta_size == 0) {
1929 printf("Redirection table size is 0 which is "
1930 "invalid for RSS\n");
1933 printf("The reta size of port %d is %u\n",
1934 res->port_id, dev_info.reta_size);
1935 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1936 printf("Currently do not support more than %u entries of "
1937 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1941 memset(reta_conf, 0, sizeof(reta_conf));
1942 if (!strcmp(res->list_name, "reta")) {
1943 if (parse_reta_config(res->list_of_items, reta_conf,
1944 dev_info.reta_size)) {
1945 printf("Invalid RSS Redirection Table "
1946 "config entered\n");
1949 ret = rte_eth_dev_rss_reta_update(res->port_id,
1950 reta_conf, dev_info.reta_size);
1952 printf("Bad redirection table parameter, "
1953 "return code = %d \n", ret);
1957 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1959 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1960 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1961 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1962 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1963 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1965 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1966 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1967 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1968 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1970 cmdline_parse_inst_t cmd_config_rss_reta = {
1971 .f = cmd_set_rss_reta_parsed,
1973 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1975 (void *)&cmd_config_rss_reta_port,
1976 (void *)&cmd_config_rss_reta_keyword,
1977 (void *)&cmd_config_rss_reta_port_id,
1978 (void *)&cmd_config_rss_reta_name,
1979 (void *)&cmd_config_rss_reta_list_name,
1980 (void *)&cmd_config_rss_reta_list_of_items,
1985 /* *** SHOW PORT RETA INFO *** */
1986 struct cmd_showport_reta {
1987 cmdline_fixed_string_t show;
1988 cmdline_fixed_string_t port;
1990 cmdline_fixed_string_t rss;
1991 cmdline_fixed_string_t reta;
1993 cmdline_fixed_string_t list_of_items;
1997 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1998 uint16_t nb_entries,
2002 const char *p, *p0 = str;
2006 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2009 p = strchr(p0, '(');
2013 p0 = strchr(p, ')');
2017 if (size >= sizeof(s)) {
2018 printf("The string size exceeds the internal buffer size\n");
2021 snprintf(s, sizeof(s), "%.*s", size, p);
2022 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2023 if (ret <= 0 || ret != num) {
2024 printf("The bits of masks do not match the number of "
2025 "reta entries: %u\n", num);
2028 for (i = 0; i < ret; i++)
2029 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2035 cmd_showport_reta_parsed(void *parsed_result,
2036 __attribute__((unused)) struct cmdline *cl,
2037 __attribute__((unused)) void *data)
2039 struct cmd_showport_reta *res = parsed_result;
2040 struct rte_eth_rss_reta_entry64 reta_conf[8];
2041 struct rte_eth_dev_info dev_info;
2043 memset(&dev_info, 0, sizeof(dev_info));
2044 rte_eth_dev_info_get(res->port_id, &dev_info);
2045 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2046 res->size > ETH_RSS_RETA_SIZE_512) {
2047 printf("Invalid redirection table size: %u\n", res->size);
2051 memset(reta_conf, 0, sizeof(reta_conf));
2052 if (showport_parse_reta_config(reta_conf, res->size,
2053 res->list_of_items) < 0) {
2054 printf("Invalid string: %s for reta masks\n",
2055 res->list_of_items);
2058 port_rss_reta_info(res->port_id, reta_conf, res->size);
2061 cmdline_parse_token_string_t cmd_showport_reta_show =
2062 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2063 cmdline_parse_token_string_t cmd_showport_reta_port =
2064 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2065 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2066 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2067 cmdline_parse_token_string_t cmd_showport_reta_rss =
2068 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2069 cmdline_parse_token_string_t cmd_showport_reta_reta =
2070 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2071 cmdline_parse_token_num_t cmd_showport_reta_size =
2072 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2073 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2074 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2075 list_of_items, NULL);
2077 cmdline_parse_inst_t cmd_showport_reta = {
2078 .f = cmd_showport_reta_parsed,
2080 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2082 (void *)&cmd_showport_reta_show,
2083 (void *)&cmd_showport_reta_port,
2084 (void *)&cmd_showport_reta_port_id,
2085 (void *)&cmd_showport_reta_rss,
2086 (void *)&cmd_showport_reta_reta,
2087 (void *)&cmd_showport_reta_size,
2088 (void *)&cmd_showport_reta_list_of_items,
2093 /* *** Show RSS hash configuration *** */
2094 struct cmd_showport_rss_hash {
2095 cmdline_fixed_string_t show;
2096 cmdline_fixed_string_t port;
2098 cmdline_fixed_string_t rss_hash;
2099 cmdline_fixed_string_t rss_type;
2100 cmdline_fixed_string_t key; /* optional argument */
2103 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2104 __attribute__((unused)) struct cmdline *cl,
2107 struct cmd_showport_rss_hash *res = parsed_result;
2109 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
2112 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2113 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2114 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2115 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2116 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2117 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2118 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2119 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2121 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2122 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2124 cmdline_parse_inst_t cmd_showport_rss_hash = {
2125 .f = cmd_showport_rss_hash_parsed,
2127 .help_str = "show port <port_id> rss-hash",
2129 (void *)&cmd_showport_rss_hash_show,
2130 (void *)&cmd_showport_rss_hash_port,
2131 (void *)&cmd_showport_rss_hash_port_id,
2132 (void *)&cmd_showport_rss_hash_rss_hash,
2137 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2138 .f = cmd_showport_rss_hash_parsed,
2140 .help_str = "show port <port_id> rss-hash key",
2142 (void *)&cmd_showport_rss_hash_show,
2143 (void *)&cmd_showport_rss_hash_port,
2144 (void *)&cmd_showport_rss_hash_port_id,
2145 (void *)&cmd_showport_rss_hash_rss_hash,
2146 (void *)&cmd_showport_rss_hash_rss_key,
2151 /* *** Configure DCB *** */
2152 struct cmd_config_dcb {
2153 cmdline_fixed_string_t port;
2154 cmdline_fixed_string_t config;
2156 cmdline_fixed_string_t dcb;
2157 cmdline_fixed_string_t vt;
2158 cmdline_fixed_string_t vt_en;
2160 cmdline_fixed_string_t pfc;
2161 cmdline_fixed_string_t pfc_en;
2165 cmd_config_dcb_parsed(void *parsed_result,
2166 __attribute__((unused)) struct cmdline *cl,
2167 __attribute__((unused)) void *data)
2169 struct cmd_config_dcb *res = parsed_result;
2170 portid_t port_id = res->port_id;
2171 struct rte_port *port;
2175 port = &ports[port_id];
2176 /** Check if the port is not started **/
2177 if (port->port_status != RTE_PORT_STOPPED) {
2178 printf("Please stop port %d first\n", port_id);
2182 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2183 printf("The invalid number of traffic class,"
2184 " only 4 or 8 allowed.\n");
2188 if (nb_fwd_lcores < res->num_tcs) {
2189 printf("nb_cores shouldn't be less than number of TCs.\n");
2192 if (!strncmp(res->pfc_en, "on", 2))
2197 /* DCB in VT mode */
2198 if (!strncmp(res->vt_en, "on", 2))
2199 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2200 (enum rte_eth_nb_tcs)res->num_tcs,
2203 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2204 (enum rte_eth_nb_tcs)res->num_tcs,
2209 printf("Cannot initialize network ports.\n");
2213 cmd_reconfig_device_queue(port_id, 1, 1);
2216 cmdline_parse_token_string_t cmd_config_dcb_port =
2217 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2218 cmdline_parse_token_string_t cmd_config_dcb_config =
2219 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2220 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2221 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2222 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2223 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2224 cmdline_parse_token_string_t cmd_config_dcb_vt =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2226 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2227 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2228 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2229 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2230 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2231 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2232 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2233 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2235 cmdline_parse_inst_t cmd_config_dcb = {
2236 .f = cmd_config_dcb_parsed,
2238 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2240 (void *)&cmd_config_dcb_port,
2241 (void *)&cmd_config_dcb_config,
2242 (void *)&cmd_config_dcb_port_id,
2243 (void *)&cmd_config_dcb_dcb,
2244 (void *)&cmd_config_dcb_vt,
2245 (void *)&cmd_config_dcb_vt_en,
2246 (void *)&cmd_config_dcb_num_tcs,
2247 (void *)&cmd_config_dcb_pfc,
2248 (void *)&cmd_config_dcb_pfc_en,
2253 /* *** configure number of packets per burst *** */
2254 struct cmd_config_burst {
2255 cmdline_fixed_string_t port;
2256 cmdline_fixed_string_t keyword;
2257 cmdline_fixed_string_t all;
2258 cmdline_fixed_string_t name;
2263 cmd_config_burst_parsed(void *parsed_result,
2264 __attribute__((unused)) struct cmdline *cl,
2265 __attribute__((unused)) void *data)
2267 struct cmd_config_burst *res = parsed_result;
2269 if (!all_ports_stopped()) {
2270 printf("Please stop all ports first\n");
2274 if (!strcmp(res->name, "burst")) {
2275 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2276 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2279 nb_pkt_per_burst = res->value;
2281 printf("Unknown parameter\n");
2287 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2290 cmdline_parse_token_string_t cmd_config_burst_port =
2291 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2292 cmdline_parse_token_string_t cmd_config_burst_keyword =
2293 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2294 cmdline_parse_token_string_t cmd_config_burst_all =
2295 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2296 cmdline_parse_token_string_t cmd_config_burst_name =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2298 cmdline_parse_token_num_t cmd_config_burst_value =
2299 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2301 cmdline_parse_inst_t cmd_config_burst = {
2302 .f = cmd_config_burst_parsed,
2304 .help_str = "port config all burst value",
2306 (void *)&cmd_config_burst_port,
2307 (void *)&cmd_config_burst_keyword,
2308 (void *)&cmd_config_burst_all,
2309 (void *)&cmd_config_burst_name,
2310 (void *)&cmd_config_burst_value,
2315 /* *** configure rx/tx queues *** */
2316 struct cmd_config_thresh {
2317 cmdline_fixed_string_t port;
2318 cmdline_fixed_string_t keyword;
2319 cmdline_fixed_string_t all;
2320 cmdline_fixed_string_t name;
2325 cmd_config_thresh_parsed(void *parsed_result,
2326 __attribute__((unused)) struct cmdline *cl,
2327 __attribute__((unused)) void *data)
2329 struct cmd_config_thresh *res = parsed_result;
2331 if (!all_ports_stopped()) {
2332 printf("Please stop all ports first\n");
2336 if (!strcmp(res->name, "txpt"))
2337 tx_pthresh = res->value;
2338 else if(!strcmp(res->name, "txht"))
2339 tx_hthresh = res->value;
2340 else if(!strcmp(res->name, "txwt"))
2341 tx_wthresh = res->value;
2342 else if(!strcmp(res->name, "rxpt"))
2343 rx_pthresh = res->value;
2344 else if(!strcmp(res->name, "rxht"))
2345 rx_hthresh = res->value;
2346 else if(!strcmp(res->name, "rxwt"))
2347 rx_wthresh = res->value;
2349 printf("Unknown parameter\n");
2355 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2358 cmdline_parse_token_string_t cmd_config_thresh_port =
2359 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2360 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2361 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2362 cmdline_parse_token_string_t cmd_config_thresh_all =
2363 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2364 cmdline_parse_token_string_t cmd_config_thresh_name =
2365 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2366 "txpt#txht#txwt#rxpt#rxht#rxwt");
2367 cmdline_parse_token_num_t cmd_config_thresh_value =
2368 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2370 cmdline_parse_inst_t cmd_config_thresh = {
2371 .f = cmd_config_thresh_parsed,
2373 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2375 (void *)&cmd_config_thresh_port,
2376 (void *)&cmd_config_thresh_keyword,
2377 (void *)&cmd_config_thresh_all,
2378 (void *)&cmd_config_thresh_name,
2379 (void *)&cmd_config_thresh_value,
2384 /* *** configure free/rs threshold *** */
2385 struct cmd_config_threshold {
2386 cmdline_fixed_string_t port;
2387 cmdline_fixed_string_t keyword;
2388 cmdline_fixed_string_t all;
2389 cmdline_fixed_string_t name;
2394 cmd_config_threshold_parsed(void *parsed_result,
2395 __attribute__((unused)) struct cmdline *cl,
2396 __attribute__((unused)) void *data)
2398 struct cmd_config_threshold *res = parsed_result;
2400 if (!all_ports_stopped()) {
2401 printf("Please stop all ports first\n");
2405 if (!strcmp(res->name, "txfreet"))
2406 tx_free_thresh = res->value;
2407 else if (!strcmp(res->name, "txrst"))
2408 tx_rs_thresh = res->value;
2409 else if (!strcmp(res->name, "rxfreet"))
2410 rx_free_thresh = res->value;
2412 printf("Unknown parameter\n");
2418 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2421 cmdline_parse_token_string_t cmd_config_threshold_port =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2423 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2424 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2426 cmdline_parse_token_string_t cmd_config_threshold_all =
2427 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2428 cmdline_parse_token_string_t cmd_config_threshold_name =
2429 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2430 "txfreet#txrst#rxfreet");
2431 cmdline_parse_token_num_t cmd_config_threshold_value =
2432 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2434 cmdline_parse_inst_t cmd_config_threshold = {
2435 .f = cmd_config_threshold_parsed,
2437 .help_str = "port config all txfreet|txrst|rxfreet value",
2439 (void *)&cmd_config_threshold_port,
2440 (void *)&cmd_config_threshold_keyword,
2441 (void *)&cmd_config_threshold_all,
2442 (void *)&cmd_config_threshold_name,
2443 (void *)&cmd_config_threshold_value,
2449 struct cmd_stop_result {
2450 cmdline_fixed_string_t stop;
2453 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2454 __attribute__((unused)) struct cmdline *cl,
2455 __attribute__((unused)) void *data)
2457 stop_packet_forwarding();
2460 cmdline_parse_token_string_t cmd_stop_stop =
2461 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2463 cmdline_parse_inst_t cmd_stop = {
2464 .f = cmd_stop_parsed,
2466 .help_str = "stop - stop packet forwarding",
2468 (void *)&cmd_stop_stop,
2473 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2476 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2477 unsigned int *parsed_items, int check_unique_values)
2479 unsigned int nb_item;
2487 * First parse all items in the list and store their value.
2492 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2494 if ((c >= '0') && (c <= '9')) {
2495 value = (unsigned int) (value * 10 + (c - '0'));
2500 printf("character %c is not a decimal digit\n", c);
2504 printf("No valid value before comma\n");
2507 if (nb_item < max_items) {
2508 parsed_items[nb_item] = value;
2514 if (nb_item >= max_items) {
2515 printf("Number of %s = %u > %u (maximum items)\n",
2516 item_name, nb_item + 1, max_items);
2519 parsed_items[nb_item++] = value;
2520 if (! check_unique_values)
2524 * Then, check that all values in the list are differents.
2525 * No optimization here...
2527 for (i = 0; i < nb_item; i++) {
2528 for (j = i + 1; j < nb_item; j++) {
2529 if (parsed_items[j] == parsed_items[i]) {
2530 printf("duplicated %s %u at index %u and %u\n",
2531 item_name, parsed_items[i], i, j);
2539 struct cmd_set_list_result {
2540 cmdline_fixed_string_t cmd_keyword;
2541 cmdline_fixed_string_t list_name;
2542 cmdline_fixed_string_t list_of_items;
2545 static void cmd_set_list_parsed(void *parsed_result,
2546 __attribute__((unused)) struct cmdline *cl,
2547 __attribute__((unused)) void *data)
2549 struct cmd_set_list_result *res;
2551 unsigned int lcorelist[RTE_MAX_LCORE];
2552 unsigned int portlist[RTE_MAX_ETHPORTS];
2554 unsigned int nb_item;
2556 if (test_done == 0) {
2557 printf("Please stop forwarding first\n");
2561 res = parsed_result;
2562 if (!strcmp(res->list_name, "corelist")) {
2563 nb_item = parse_item_list(res->list_of_items, "core",
2565 parsed_items.lcorelist, 1);
2567 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2572 if (!strcmp(res->list_name, "portlist")) {
2573 nb_item = parse_item_list(res->list_of_items, "port",
2575 parsed_items.portlist, 1);
2577 set_fwd_ports_list(parsed_items.portlist, nb_item);
2583 cmdline_parse_token_string_t cmd_set_list_keyword =
2584 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2586 cmdline_parse_token_string_t cmd_set_list_name =
2587 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2588 "corelist#portlist");
2589 cmdline_parse_token_string_t cmd_set_list_of_items =
2590 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2593 cmdline_parse_inst_t cmd_set_fwd_list = {
2594 .f = cmd_set_list_parsed,
2596 .help_str = "set corelist|portlist x[,y]*",
2598 (void *)&cmd_set_list_keyword,
2599 (void *)&cmd_set_list_name,
2600 (void *)&cmd_set_list_of_items,
2605 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2607 struct cmd_setmask_result {
2608 cmdline_fixed_string_t set;
2609 cmdline_fixed_string_t mask;
2613 static void cmd_set_mask_parsed(void *parsed_result,
2614 __attribute__((unused)) struct cmdline *cl,
2615 __attribute__((unused)) void *data)
2617 struct cmd_setmask_result *res = parsed_result;
2619 if (test_done == 0) {
2620 printf("Please stop forwarding first\n");
2623 if (!strcmp(res->mask, "coremask")) {
2624 set_fwd_lcores_mask(res->hexavalue);
2626 } else if (!strcmp(res->mask, "portmask")) {
2627 set_fwd_ports_mask(res->hexavalue);
2632 cmdline_parse_token_string_t cmd_setmask_set =
2633 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2634 cmdline_parse_token_string_t cmd_setmask_mask =
2635 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2636 "coremask#portmask");
2637 cmdline_parse_token_num_t cmd_setmask_value =
2638 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2640 cmdline_parse_inst_t cmd_set_fwd_mask = {
2641 .f = cmd_set_mask_parsed,
2643 .help_str = "set coremask|portmask hexadecimal value",
2645 (void *)&cmd_setmask_set,
2646 (void *)&cmd_setmask_mask,
2647 (void *)&cmd_setmask_value,
2653 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2655 struct cmd_set_result {
2656 cmdline_fixed_string_t set;
2657 cmdline_fixed_string_t what;
2661 static void cmd_set_parsed(void *parsed_result,
2662 __attribute__((unused)) struct cmdline *cl,
2663 __attribute__((unused)) void *data)
2665 struct cmd_set_result *res = parsed_result;
2666 if (!strcmp(res->what, "nbport")) {
2667 set_fwd_ports_number(res->value);
2669 } else if (!strcmp(res->what, "nbcore")) {
2670 set_fwd_lcores_number(res->value);
2672 } else if (!strcmp(res->what, "burst"))
2673 set_nb_pkt_per_burst(res->value);
2674 else if (!strcmp(res->what, "verbose"))
2675 set_verbose_level(res->value);
2678 cmdline_parse_token_string_t cmd_set_set =
2679 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2680 cmdline_parse_token_string_t cmd_set_what =
2681 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2682 "nbport#nbcore#burst#verbose");
2683 cmdline_parse_token_num_t cmd_set_value =
2684 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2686 cmdline_parse_inst_t cmd_set_numbers = {
2687 .f = cmd_set_parsed,
2689 .help_str = "set nbport|nbcore|burst|verbose value",
2691 (void *)&cmd_set_set,
2692 (void *)&cmd_set_what,
2693 (void *)&cmd_set_value,
2698 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2700 struct cmd_set_txpkts_result {
2701 cmdline_fixed_string_t cmd_keyword;
2702 cmdline_fixed_string_t txpkts;
2703 cmdline_fixed_string_t seg_lengths;
2707 cmd_set_txpkts_parsed(void *parsed_result,
2708 __attribute__((unused)) struct cmdline *cl,
2709 __attribute__((unused)) void *data)
2711 struct cmd_set_txpkts_result *res;
2712 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2713 unsigned int nb_segs;
2715 res = parsed_result;
2716 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2717 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2719 set_tx_pkt_segments(seg_lengths, nb_segs);
2722 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2723 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2724 cmd_keyword, "set");
2725 cmdline_parse_token_string_t cmd_set_txpkts_name =
2726 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2728 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2729 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2732 cmdline_parse_inst_t cmd_set_txpkts = {
2733 .f = cmd_set_txpkts_parsed,
2735 .help_str = "set txpkts x[,y]*",
2737 (void *)&cmd_set_txpkts_keyword,
2738 (void *)&cmd_set_txpkts_name,
2739 (void *)&cmd_set_txpkts_lengths,
2744 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2746 struct cmd_set_txsplit_result {
2747 cmdline_fixed_string_t cmd_keyword;
2748 cmdline_fixed_string_t txsplit;
2749 cmdline_fixed_string_t mode;
2753 cmd_set_txsplit_parsed(void *parsed_result,
2754 __attribute__((unused)) struct cmdline *cl,
2755 __attribute__((unused)) void *data)
2757 struct cmd_set_txsplit_result *res;
2759 res = parsed_result;
2760 set_tx_pkt_split(res->mode);
2763 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2764 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2765 cmd_keyword, "set");
2766 cmdline_parse_token_string_t cmd_set_txsplit_name =
2767 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2768 txsplit, "txsplit");
2769 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2770 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2773 cmdline_parse_inst_t cmd_set_txsplit = {
2774 .f = cmd_set_txsplit_parsed,
2776 .help_str = "set txsplit on|off|rand",
2778 (void *)&cmd_set_txsplit_keyword,
2779 (void *)&cmd_set_txsplit_name,
2780 (void *)&cmd_set_txsplit_mode,
2785 /* *** CONFIG TX QUEUE FLAGS *** */
2787 struct cmd_config_txqflags_result {
2788 cmdline_fixed_string_t port;
2789 cmdline_fixed_string_t config;
2790 cmdline_fixed_string_t all;
2791 cmdline_fixed_string_t what;
2795 static void cmd_config_txqflags_parsed(void *parsed_result,
2796 __attribute__((unused)) struct cmdline *cl,
2797 __attribute__((unused)) void *data)
2799 struct cmd_config_txqflags_result *res = parsed_result;
2801 if (!all_ports_stopped()) {
2802 printf("Please stop all ports first\n");
2806 if (strcmp(res->what, "txqflags")) {
2807 printf("Unknown parameter\n");
2811 if (res->hexvalue >= 0) {
2812 txq_flags = res->hexvalue;
2814 printf("txqflags must be >= 0\n");
2820 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2823 cmdline_parse_token_string_t cmd_config_txqflags_port =
2824 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2826 cmdline_parse_token_string_t cmd_config_txqflags_config =
2827 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2829 cmdline_parse_token_string_t cmd_config_txqflags_all =
2830 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2832 cmdline_parse_token_string_t cmd_config_txqflags_what =
2833 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2835 cmdline_parse_token_num_t cmd_config_txqflags_value =
2836 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2839 cmdline_parse_inst_t cmd_config_txqflags = {
2840 .f = cmd_config_txqflags_parsed,
2842 .help_str = "port config all txqflags value",
2844 (void *)&cmd_config_txqflags_port,
2845 (void *)&cmd_config_txqflags_config,
2846 (void *)&cmd_config_txqflags_all,
2847 (void *)&cmd_config_txqflags_what,
2848 (void *)&cmd_config_txqflags_value,
2853 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2854 struct cmd_rx_vlan_filter_all_result {
2855 cmdline_fixed_string_t rx_vlan;
2856 cmdline_fixed_string_t what;
2857 cmdline_fixed_string_t all;
2862 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2863 __attribute__((unused)) struct cmdline *cl,
2864 __attribute__((unused)) void *data)
2866 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2868 if (!strcmp(res->what, "add"))
2869 rx_vlan_all_filter_set(res->port_id, 1);
2871 rx_vlan_all_filter_set(res->port_id, 0);
2874 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2875 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2876 rx_vlan, "rx_vlan");
2877 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2878 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2880 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2881 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2883 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2884 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2887 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2888 .f = cmd_rx_vlan_filter_all_parsed,
2890 .help_str = "add/remove all identifiers to/from the set of VLAN "
2891 "Identifiers filtered by a port",
2893 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2894 (void *)&cmd_rx_vlan_filter_all_what,
2895 (void *)&cmd_rx_vlan_filter_all_all,
2896 (void *)&cmd_rx_vlan_filter_all_portid,
2901 /* *** VLAN OFFLOAD SET ON A PORT *** */
2902 struct cmd_vlan_offload_result {
2903 cmdline_fixed_string_t vlan;
2904 cmdline_fixed_string_t set;
2905 cmdline_fixed_string_t vlan_type;
2906 cmdline_fixed_string_t what;
2907 cmdline_fixed_string_t on;
2908 cmdline_fixed_string_t port_id;
2912 cmd_vlan_offload_parsed(void *parsed_result,
2913 __attribute__((unused)) struct cmdline *cl,
2914 __attribute__((unused)) void *data)
2917 struct cmd_vlan_offload_result *res = parsed_result;
2920 portid_t port_id = 0;
2924 len = strnlen(str, STR_TOKEN_SIZE);
2926 /* Get port_id first */
2934 tmp = strtoul(str, NULL, 0);
2935 /* If port_id greater that what portid_t can represent, return */
2936 if(tmp >= RTE_MAX_ETHPORTS)
2938 port_id = (portid_t)tmp;
2940 if (!strcmp(res->on, "on"))
2945 if (!strcmp(res->what, "strip"))
2946 rx_vlan_strip_set(port_id, on);
2947 else if(!strcmp(res->what, "stripq")){
2948 uint16_t queue_id = 0;
2950 /* No queue_id, return */
2952 printf("must specify (port,queue_id)\n");
2955 tmp = strtoul(str + i + 1, NULL, 0);
2956 /* If queue_id greater that what 16-bits can represent, return */
2960 queue_id = (uint16_t)tmp;
2961 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2963 else if (!strcmp(res->what, "filter"))
2964 rx_vlan_filter_set(port_id, on);
2966 vlan_extend_set(port_id, on);
2971 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2972 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2974 cmdline_parse_token_string_t cmd_vlan_offload_set =
2975 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2977 cmdline_parse_token_string_t cmd_vlan_offload_what =
2978 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2979 what, "strip#filter#qinq#stripq");
2980 cmdline_parse_token_string_t cmd_vlan_offload_on =
2981 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2983 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2984 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2987 cmdline_parse_inst_t cmd_vlan_offload = {
2988 .f = cmd_vlan_offload_parsed,
2990 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2991 " qinq(extended) for both rx/tx sides ",
2993 (void *)&cmd_vlan_offload_vlan,
2994 (void *)&cmd_vlan_offload_set,
2995 (void *)&cmd_vlan_offload_what,
2996 (void *)&cmd_vlan_offload_on,
2997 (void *)&cmd_vlan_offload_portid,
3002 /* *** VLAN TPID SET ON A PORT *** */
3003 struct cmd_vlan_tpid_result {
3004 cmdline_fixed_string_t vlan;
3005 cmdline_fixed_string_t set;
3006 cmdline_fixed_string_t vlan_type;
3007 cmdline_fixed_string_t what;
3013 cmd_vlan_tpid_parsed(void *parsed_result,
3014 __attribute__((unused)) struct cmdline *cl,
3015 __attribute__((unused)) void *data)
3017 struct cmd_vlan_tpid_result *res = parsed_result;
3018 enum rte_vlan_type vlan_type;
3020 if (!strcmp(res->vlan_type, "inner"))
3021 vlan_type = ETH_VLAN_TYPE_INNER;
3022 else if (!strcmp(res->vlan_type, "outer"))
3023 vlan_type = ETH_VLAN_TYPE_OUTER;
3025 printf("Unknown vlan type\n");
3028 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3031 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3032 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3034 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3035 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3037 cmdline_parse_token_string_t cmd_vlan_type =
3038 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3039 vlan_type, "inner#outer");
3040 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3041 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3043 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3044 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3046 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3047 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3050 cmdline_parse_inst_t cmd_vlan_tpid = {
3051 .f = cmd_vlan_tpid_parsed,
3053 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
3056 (void *)&cmd_vlan_tpid_vlan,
3057 (void *)&cmd_vlan_tpid_set,
3058 (void *)&cmd_vlan_type,
3059 (void *)&cmd_vlan_tpid_what,
3060 (void *)&cmd_vlan_tpid_tpid,
3061 (void *)&cmd_vlan_tpid_portid,
3066 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3067 struct cmd_rx_vlan_filter_result {
3068 cmdline_fixed_string_t rx_vlan;
3069 cmdline_fixed_string_t what;
3075 cmd_rx_vlan_filter_parsed(void *parsed_result,
3076 __attribute__((unused)) struct cmdline *cl,
3077 __attribute__((unused)) void *data)
3079 struct cmd_rx_vlan_filter_result *res = parsed_result;
3081 if (!strcmp(res->what, "add"))
3082 rx_vft_set(res->port_id, res->vlan_id, 1);
3084 rx_vft_set(res->port_id, res->vlan_id, 0);
3087 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3088 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3089 rx_vlan, "rx_vlan");
3090 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3091 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3093 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3094 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3096 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3097 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3100 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3101 .f = cmd_rx_vlan_filter_parsed,
3103 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
3104 "Identifiers filtered by a port",
3106 (void *)&cmd_rx_vlan_filter_rx_vlan,
3107 (void *)&cmd_rx_vlan_filter_what,
3108 (void *)&cmd_rx_vlan_filter_vlanid,
3109 (void *)&cmd_rx_vlan_filter_portid,
3114 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3115 struct cmd_tx_vlan_set_result {
3116 cmdline_fixed_string_t tx_vlan;
3117 cmdline_fixed_string_t set;
3123 cmd_tx_vlan_set_parsed(void *parsed_result,
3124 __attribute__((unused)) struct cmdline *cl,
3125 __attribute__((unused)) void *data)
3127 struct cmd_tx_vlan_set_result *res = parsed_result;
3129 tx_vlan_set(res->port_id, res->vlan_id);
3132 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3133 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3134 tx_vlan, "tx_vlan");
3135 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3136 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3138 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3139 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3141 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3142 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3145 cmdline_parse_inst_t cmd_tx_vlan_set = {
3146 .f = cmd_tx_vlan_set_parsed,
3148 .help_str = "enable hardware insertion of a single VLAN header "
3149 "with a given TAG Identifier in packets sent on a port",
3151 (void *)&cmd_tx_vlan_set_tx_vlan,
3152 (void *)&cmd_tx_vlan_set_set,
3153 (void *)&cmd_tx_vlan_set_portid,
3154 (void *)&cmd_tx_vlan_set_vlanid,
3159 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3160 struct cmd_tx_vlan_set_qinq_result {
3161 cmdline_fixed_string_t tx_vlan;
3162 cmdline_fixed_string_t set;
3165 uint16_t vlan_id_outer;
3169 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3170 __attribute__((unused)) struct cmdline *cl,
3171 __attribute__((unused)) void *data)
3173 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3175 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3178 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3179 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3180 tx_vlan, "tx_vlan");
3181 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3182 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3184 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3185 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3187 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3188 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3190 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3191 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3192 vlan_id_outer, UINT16);
3194 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3195 .f = cmd_tx_vlan_set_qinq_parsed,
3197 .help_str = "enable hardware insertion of double VLAN header "
3198 "with given TAG Identifiers in packets sent on a port",
3200 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3201 (void *)&cmd_tx_vlan_set_qinq_set,
3202 (void *)&cmd_tx_vlan_set_qinq_portid,
3203 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3204 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3209 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3210 struct cmd_tx_vlan_set_pvid_result {
3211 cmdline_fixed_string_t tx_vlan;
3212 cmdline_fixed_string_t set;
3213 cmdline_fixed_string_t pvid;
3216 cmdline_fixed_string_t mode;
3220 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3221 __attribute__((unused)) struct cmdline *cl,
3222 __attribute__((unused)) void *data)
3224 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3226 if (strcmp(res->mode, "on") == 0)
3227 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3229 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3232 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3233 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3234 tx_vlan, "tx_vlan");
3235 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3236 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3238 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3239 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3241 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3242 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3244 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3245 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3247 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3248 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3251 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3252 .f = cmd_tx_vlan_set_pvid_parsed,
3254 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3256 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3257 (void *)&cmd_tx_vlan_set_pvid_set,
3258 (void *)&cmd_tx_vlan_set_pvid_pvid,
3259 (void *)&cmd_tx_vlan_set_pvid_port_id,
3260 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3261 (void *)&cmd_tx_vlan_set_pvid_mode,
3266 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3267 struct cmd_tx_vlan_reset_result {
3268 cmdline_fixed_string_t tx_vlan;
3269 cmdline_fixed_string_t reset;
3274 cmd_tx_vlan_reset_parsed(void *parsed_result,
3275 __attribute__((unused)) struct cmdline *cl,
3276 __attribute__((unused)) void *data)
3278 struct cmd_tx_vlan_reset_result *res = parsed_result;
3280 tx_vlan_reset(res->port_id);
3283 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3284 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3285 tx_vlan, "tx_vlan");
3286 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3287 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3289 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3290 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3293 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3294 .f = cmd_tx_vlan_reset_parsed,
3296 .help_str = "disable hardware insertion of a VLAN header in packets "
3299 (void *)&cmd_tx_vlan_reset_tx_vlan,
3300 (void *)&cmd_tx_vlan_reset_reset,
3301 (void *)&cmd_tx_vlan_reset_portid,
3307 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3308 struct cmd_csum_result {
3309 cmdline_fixed_string_t csum;
3310 cmdline_fixed_string_t mode;
3311 cmdline_fixed_string_t proto;
3312 cmdline_fixed_string_t hwsw;
3317 csum_show(int port_id)
3319 struct rte_eth_dev_info dev_info;
3322 ol_flags = ports[port_id].tx_ol_flags;
3323 printf("Parse tunnel is %s\n",
3324 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3325 printf("IP checksum offload is %s\n",
3326 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3327 printf("UDP checksum offload is %s\n",
3328 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3329 printf("TCP checksum offload is %s\n",
3330 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3331 printf("SCTP checksum offload is %s\n",
3332 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3333 printf("Outer-Ip checksum offload is %s\n",
3334 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3336 /* display warnings if configuration is not supported by the NIC */
3337 rte_eth_dev_info_get(port_id, &dev_info);
3338 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3339 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3340 printf("Warning: hardware IP checksum enabled but not "
3341 "supported by port %d\n", port_id);
3343 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3344 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3345 printf("Warning: hardware UDP checksum enabled but not "
3346 "supported by port %d\n", port_id);
3348 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3349 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3350 printf("Warning: hardware TCP checksum enabled but not "
3351 "supported by port %d\n", port_id);
3353 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3354 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3355 printf("Warning: hardware SCTP checksum enabled but not "
3356 "supported by port %d\n", port_id);
3358 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3359 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3360 printf("Warning: hardware outer IP checksum enabled but not "
3361 "supported by port %d\n", port_id);
3366 cmd_csum_parsed(void *parsed_result,
3367 __attribute__((unused)) struct cmdline *cl,
3368 __attribute__((unused)) void *data)
3370 struct cmd_csum_result *res = parsed_result;
3374 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3375 printf("invalid port %d\n", res->port_id);
3379 if (!strcmp(res->mode, "set")) {
3381 if (!strcmp(res->hwsw, "hw"))
3384 if (!strcmp(res->proto, "ip")) {
3385 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3386 } else if (!strcmp(res->proto, "udp")) {
3387 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3388 } else if (!strcmp(res->proto, "tcp")) {
3389 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3390 } else if (!strcmp(res->proto, "sctp")) {
3391 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3392 } else if (!strcmp(res->proto, "outer-ip")) {
3393 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3397 ports[res->port_id].tx_ol_flags |= mask;
3399 ports[res->port_id].tx_ol_flags &= (~mask);
3401 csum_show(res->port_id);
3404 cmdline_parse_token_string_t cmd_csum_csum =
3405 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3407 cmdline_parse_token_string_t cmd_csum_mode =
3408 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3410 cmdline_parse_token_string_t cmd_csum_proto =
3411 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3412 proto, "ip#tcp#udp#sctp#outer-ip");
3413 cmdline_parse_token_string_t cmd_csum_hwsw =
3414 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3416 cmdline_parse_token_num_t cmd_csum_portid =
3417 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3420 cmdline_parse_inst_t cmd_csum_set = {
3421 .f = cmd_csum_parsed,
3423 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3424 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3426 (void *)&cmd_csum_csum,
3427 (void *)&cmd_csum_mode,
3428 (void *)&cmd_csum_proto,
3429 (void *)&cmd_csum_hwsw,
3430 (void *)&cmd_csum_portid,
3435 cmdline_parse_token_string_t cmd_csum_mode_show =
3436 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3439 cmdline_parse_inst_t cmd_csum_show = {
3440 .f = cmd_csum_parsed,
3442 .help_str = "show checksum offload configuration: csum show <port>",
3444 (void *)&cmd_csum_csum,
3445 (void *)&cmd_csum_mode_show,
3446 (void *)&cmd_csum_portid,
3451 /* Enable/disable tunnel parsing */
3452 struct cmd_csum_tunnel_result {
3453 cmdline_fixed_string_t csum;
3454 cmdline_fixed_string_t parse;
3455 cmdline_fixed_string_t onoff;
3460 cmd_csum_tunnel_parsed(void *parsed_result,
3461 __attribute__((unused)) struct cmdline *cl,
3462 __attribute__((unused)) void *data)
3464 struct cmd_csum_tunnel_result *res = parsed_result;
3466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3469 if (!strcmp(res->onoff, "on"))
3470 ports[res->port_id].tx_ol_flags |=
3471 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3473 ports[res->port_id].tx_ol_flags &=
3474 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3476 csum_show(res->port_id);
3479 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3480 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3482 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3483 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3484 parse, "parse-tunnel");
3485 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3486 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3488 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3489 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3492 cmdline_parse_inst_t cmd_csum_tunnel = {
3493 .f = cmd_csum_tunnel_parsed,
3495 .help_str = "enable/disable parsing of tunnels for csum engine: "
3496 "csum parse-tunnel on|off <tx-port>",
3498 (void *)&cmd_csum_tunnel_csum,
3499 (void *)&cmd_csum_tunnel_parse,
3500 (void *)&cmd_csum_tunnel_onoff,
3501 (void *)&cmd_csum_tunnel_portid,
3506 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3507 struct cmd_tso_set_result {
3508 cmdline_fixed_string_t tso;
3509 cmdline_fixed_string_t mode;
3515 cmd_tso_set_parsed(void *parsed_result,
3516 __attribute__((unused)) struct cmdline *cl,
3517 __attribute__((unused)) void *data)
3519 struct cmd_tso_set_result *res = parsed_result;
3520 struct rte_eth_dev_info dev_info;
3522 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3525 if (!strcmp(res->mode, "set"))
3526 ports[res->port_id].tso_segsz = res->tso_segsz;
3528 if (ports[res->port_id].tso_segsz == 0)
3529 printf("TSO for non-tunneled packets is disabled\n");
3531 printf("TSO segment size for non-tunneled packets is %d\n",
3532 ports[res->port_id].tso_segsz);
3534 /* display warnings if configuration is not supported by the NIC */
3535 rte_eth_dev_info_get(res->port_id, &dev_info);
3536 if ((ports[res->port_id].tso_segsz != 0) &&
3537 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3538 printf("Warning: TSO enabled but not "
3539 "supported by port %d\n", res->port_id);
3543 cmdline_parse_token_string_t cmd_tso_set_tso =
3544 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3546 cmdline_parse_token_string_t cmd_tso_set_mode =
3547 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3549 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3550 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3552 cmdline_parse_token_num_t cmd_tso_set_portid =
3553 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3556 cmdline_parse_inst_t cmd_tso_set = {
3557 .f = cmd_tso_set_parsed,
3559 .help_str = "Set TSO segment size of non-tunneled packets "
3560 "for csum engine (0 to disable): tso set <tso_segsz> <port>",
3562 (void *)&cmd_tso_set_tso,
3563 (void *)&cmd_tso_set_mode,
3564 (void *)&cmd_tso_set_tso_segsz,
3565 (void *)&cmd_tso_set_portid,
3570 cmdline_parse_token_string_t cmd_tso_show_mode =
3571 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3575 cmdline_parse_inst_t cmd_tso_show = {
3576 .f = cmd_tso_set_parsed,
3578 .help_str = "Show TSO segment size of non-tunneled packets "
3579 "for csum engine: tso show <port>",
3581 (void *)&cmd_tso_set_tso,
3582 (void *)&cmd_tso_show_mode,
3583 (void *)&cmd_tso_set_portid,
3588 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3589 struct cmd_tunnel_tso_set_result {
3590 cmdline_fixed_string_t tso;
3591 cmdline_fixed_string_t mode;
3597 check_tunnel_tso_nic_support(uint8_t port_id)
3599 struct rte_eth_dev_info dev_info;
3601 rte_eth_dev_info_get(port_id, &dev_info);
3602 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3603 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3604 "supported by port %d\n", port_id);
3605 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3606 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3607 "supported by port %d\n", port_id);
3608 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3609 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3610 "supported by port %d\n", port_id);
3611 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3612 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3613 "supported by port %d\n", port_id);
3617 cmd_tunnel_tso_set_parsed(void *parsed_result,
3618 __attribute__((unused)) struct cmdline *cl,
3619 __attribute__((unused)) void *data)
3621 struct cmd_tunnel_tso_set_result *res = parsed_result;
3623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3626 if (!strcmp(res->mode, "set"))
3627 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3629 if (ports[res->port_id].tunnel_tso_segsz == 0)
3630 printf("TSO for tunneled packets is disabled\n");
3632 printf("TSO segment size for tunneled packets is %d\n",
3633 ports[res->port_id].tunnel_tso_segsz);
3635 /* Below conditions are needed to make it work:
3636 * (1) tunnel TSO is supported by the NIC;
3637 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3639 * (3) for tunneled pkts with outer L3 of IPv4,
3640 * "csum set outer-ip" must be set to hw, because after tso,
3641 * total_len of outer IP header is changed, and the checksum
3642 * of outer IP header calculated by sw should be wrong; that
3643 * is not necessary for IPv6 tunneled pkts because there's no
3644 * checksum in IP header anymore.
3646 check_tunnel_tso_nic_support(res->port_id);
3648 if (!(ports[res->port_id].tx_ol_flags &
3649 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3650 printf("Warning: csum parse_tunnel must be set "
3651 "so that tunneled packets are recognized\n");
3652 if (!(ports[res->port_id].tx_ol_flags &
3653 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3654 printf("Warning: csum set outer-ip must be set to hw "
3655 "if outer L3 is IPv4; not necessary for IPv6\n");
3659 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3660 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3662 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3663 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3665 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3666 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3668 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3669 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3672 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3673 .f = cmd_tunnel_tso_set_parsed,
3675 .help_str = "Set TSO segment size of tunneled packets for csum engine "
3676 "(0 to disable): tunnel_tso set <tso_segsz> <port>",
3678 (void *)&cmd_tunnel_tso_set_tso,
3679 (void *)&cmd_tunnel_tso_set_mode,
3680 (void *)&cmd_tunnel_tso_set_tso_segsz,
3681 (void *)&cmd_tunnel_tso_set_portid,
3686 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3687 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3691 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3692 .f = cmd_tunnel_tso_set_parsed,
3694 .help_str = "Show TSO segment size of tunneled packets "
3695 "for csum engine: tunnel_tso show <port>",
3697 (void *)&cmd_tunnel_tso_set_tso,
3698 (void *)&cmd_tunnel_tso_show_mode,
3699 (void *)&cmd_tunnel_tso_set_portid,
3704 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3705 struct cmd_set_flush_rx {
3706 cmdline_fixed_string_t set;
3707 cmdline_fixed_string_t flush_rx;
3708 cmdline_fixed_string_t mode;
3712 cmd_set_flush_rx_parsed(void *parsed_result,
3713 __attribute__((unused)) struct cmdline *cl,
3714 __attribute__((unused)) void *data)
3716 struct cmd_set_flush_rx *res = parsed_result;
3717 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3720 cmdline_parse_token_string_t cmd_setflushrx_set =
3721 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3723 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3724 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3725 flush_rx, "flush_rx");
3726 cmdline_parse_token_string_t cmd_setflushrx_mode =
3727 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3731 cmdline_parse_inst_t cmd_set_flush_rx = {
3732 .f = cmd_set_flush_rx_parsed,
3733 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3736 (void *)&cmd_setflushrx_set,
3737 (void *)&cmd_setflushrx_flush_rx,
3738 (void *)&cmd_setflushrx_mode,
3743 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3744 struct cmd_set_link_check {
3745 cmdline_fixed_string_t set;
3746 cmdline_fixed_string_t link_check;
3747 cmdline_fixed_string_t mode;
3751 cmd_set_link_check_parsed(void *parsed_result,
3752 __attribute__((unused)) struct cmdline *cl,
3753 __attribute__((unused)) void *data)
3755 struct cmd_set_link_check *res = parsed_result;
3756 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3759 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3760 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3762 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3763 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3764 link_check, "link_check");
3765 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3766 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3770 cmdline_parse_inst_t cmd_set_link_check = {
3771 .f = cmd_set_link_check_parsed,
3772 .help_str = "set link_check on|off: enable/disable link status check "
3773 "when starting/stopping a port",
3776 (void *)&cmd_setlinkcheck_set,
3777 (void *)&cmd_setlinkcheck_link_check,
3778 (void *)&cmd_setlinkcheck_mode,
3783 #ifdef RTE_NIC_BYPASS
3784 /* *** SET NIC BYPASS MODE *** */
3785 struct cmd_set_bypass_mode_result {
3786 cmdline_fixed_string_t set;
3787 cmdline_fixed_string_t bypass;
3788 cmdline_fixed_string_t mode;
3789 cmdline_fixed_string_t value;
3794 cmd_set_bypass_mode_parsed(void *parsed_result,
3795 __attribute__((unused)) struct cmdline *cl,
3796 __attribute__((unused)) void *data)
3798 struct cmd_set_bypass_mode_result *res = parsed_result;
3799 portid_t port_id = res->port_id;
3800 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3802 if (!strcmp(res->value, "bypass"))
3803 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3804 else if (!strcmp(res->value, "isolate"))
3805 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3807 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3809 /* Set the bypass mode for the relevant port. */
3810 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3811 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3815 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3816 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3818 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3819 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3821 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3822 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3824 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3826 value, "normal#bypass#isolate");
3827 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3828 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3831 cmdline_parse_inst_t cmd_set_bypass_mode = {
3832 .f = cmd_set_bypass_mode_parsed,
3833 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3834 "Set the NIC bypass mode for port_id",
3837 (void *)&cmd_setbypass_mode_set,
3838 (void *)&cmd_setbypass_mode_bypass,
3839 (void *)&cmd_setbypass_mode_mode,
3840 (void *)&cmd_setbypass_mode_value,
3841 (void *)&cmd_setbypass_mode_port,
3846 /* *** SET NIC BYPASS EVENT *** */
3847 struct cmd_set_bypass_event_result {
3848 cmdline_fixed_string_t set;
3849 cmdline_fixed_string_t bypass;
3850 cmdline_fixed_string_t event;
3851 cmdline_fixed_string_t event_value;
3852 cmdline_fixed_string_t mode;
3853 cmdline_fixed_string_t mode_value;
3858 cmd_set_bypass_event_parsed(void *parsed_result,
3859 __attribute__((unused)) struct cmdline *cl,
3860 __attribute__((unused)) void *data)
3863 struct cmd_set_bypass_event_result *res = parsed_result;
3864 portid_t port_id = res->port_id;
3865 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3866 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3868 if (!strcmp(res->event_value, "timeout"))
3869 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3870 else if (!strcmp(res->event_value, "os_on"))
3871 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3872 else if (!strcmp(res->event_value, "os_off"))
3873 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3874 else if (!strcmp(res->event_value, "power_on"))
3875 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3876 else if (!strcmp(res->event_value, "power_off"))
3877 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3879 bypass_event = RTE_BYPASS_EVENT_NONE;
3881 if (!strcmp(res->mode_value, "bypass"))
3882 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3883 else if (!strcmp(res->mode_value, "isolate"))
3884 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3886 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3888 /* Set the watchdog timeout. */
3889 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3892 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3893 (rc = rte_eth_dev_wd_timeout_store(port_id,
3894 bypass_timeout)) != 0) {
3895 printf("Failed to set timeout value %u "
3896 "for port %d, errto code: %d.\n",
3897 bypass_timeout, port_id, rc);
3901 /* Set the bypass event to transition to bypass mode. */
3902 if (0 != rte_eth_dev_bypass_event_store(port_id,
3903 bypass_event, bypass_mode)) {
3904 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3909 cmdline_parse_token_string_t cmd_setbypass_event_set =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3912 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3913 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3915 cmdline_parse_token_string_t cmd_setbypass_event_event =
3916 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3918 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3919 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3920 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3921 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3922 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3924 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3925 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3926 mode_value, "normal#bypass#isolate");
3927 cmdline_parse_token_num_t cmd_setbypass_event_port =
3928 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3931 cmdline_parse_inst_t cmd_set_bypass_event = {
3932 .f = cmd_set_bypass_event_parsed,
3933 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3934 "mode (normal|bypass|isolate) (port_id): "
3935 "Set the NIC bypass event mode for port_id",
3938 (void *)&cmd_setbypass_event_set,
3939 (void *)&cmd_setbypass_event_bypass,
3940 (void *)&cmd_setbypass_event_event,
3941 (void *)&cmd_setbypass_event_event_value,
3942 (void *)&cmd_setbypass_event_mode,
3943 (void *)&cmd_setbypass_event_mode_value,
3944 (void *)&cmd_setbypass_event_port,
3950 /* *** SET NIC BYPASS TIMEOUT *** */
3951 struct cmd_set_bypass_timeout_result {
3952 cmdline_fixed_string_t set;
3953 cmdline_fixed_string_t bypass;
3954 cmdline_fixed_string_t timeout;
3955 cmdline_fixed_string_t value;
3959 cmd_set_bypass_timeout_parsed(void *parsed_result,
3960 __attribute__((unused)) struct cmdline *cl,
3961 __attribute__((unused)) void *data)
3963 struct cmd_set_bypass_timeout_result *res = parsed_result;
3965 if (!strcmp(res->value, "1.5"))
3966 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3967 else if (!strcmp(res->value, "2"))
3968 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3969 else if (!strcmp(res->value, "3"))
3970 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3971 else if (!strcmp(res->value, "4"))
3972 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3973 else if (!strcmp(res->value, "8"))
3974 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3975 else if (!strcmp(res->value, "16"))
3976 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3977 else if (!strcmp(res->value, "32"))
3978 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3980 bypass_timeout = RTE_BYPASS_TMT_OFF;
3983 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3986 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3989 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3991 timeout, "timeout");
3992 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3994 value, "0#1.5#2#3#4#8#16#32");
3996 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3997 .f = cmd_set_bypass_timeout_parsed,
3998 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3999 "Set the NIC bypass watchdog timeout",
4002 (void *)&cmd_setbypass_timeout_set,
4003 (void *)&cmd_setbypass_timeout_bypass,
4004 (void *)&cmd_setbypass_timeout_timeout,
4005 (void *)&cmd_setbypass_timeout_value,
4010 /* *** SHOW NIC BYPASS MODE *** */
4011 struct cmd_show_bypass_config_result {
4012 cmdline_fixed_string_t show;
4013 cmdline_fixed_string_t bypass;
4014 cmdline_fixed_string_t config;
4019 cmd_show_bypass_config_parsed(void *parsed_result,
4020 __attribute__((unused)) struct cmdline *cl,
4021 __attribute__((unused)) void *data)
4023 struct cmd_show_bypass_config_result *res = parsed_result;
4024 uint32_t event_mode;
4025 uint32_t bypass_mode;
4026 portid_t port_id = res->port_id;
4027 uint32_t timeout = bypass_timeout;
4030 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4031 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4032 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4033 {"UNKNOWN", "normal", "bypass", "isolate"};
4034 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4041 int num_events = (sizeof events) / (sizeof events[0]);
4043 /* Display the bypass mode.*/
4044 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4045 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4049 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4050 bypass_mode = RTE_BYPASS_MODE_NONE;
4052 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4055 /* Display the bypass timeout.*/
4056 if (!RTE_BYPASS_TMT_VALID(timeout))
4057 timeout = RTE_BYPASS_TMT_OFF;
4059 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4061 /* Display the bypass events and associated modes. */
4062 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4064 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4065 printf("\tFailed to get bypass mode for event = %s\n",
4068 if (!RTE_BYPASS_MODE_VALID(event_mode))
4069 event_mode = RTE_BYPASS_MODE_NONE;
4071 printf("\tbypass event: %-16s = %s\n", events[i],
4077 cmdline_parse_token_string_t cmd_showbypass_config_show =
4078 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4080 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4081 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4083 cmdline_parse_token_string_t cmd_showbypass_config_config =
4084 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4086 cmdline_parse_token_num_t cmd_showbypass_config_port =
4087 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4090 cmdline_parse_inst_t cmd_show_bypass_config = {
4091 .f = cmd_show_bypass_config_parsed,
4092 .help_str = "show bypass config (port_id): "
4093 "Show the NIC bypass config for port_id",
4096 (void *)&cmd_showbypass_config_show,
4097 (void *)&cmd_showbypass_config_bypass,
4098 (void *)&cmd_showbypass_config_config,
4099 (void *)&cmd_showbypass_config_port,
4105 #ifdef RTE_LIBRTE_PMD_BOND
4106 /* *** SET BONDING MODE *** */
4107 struct cmd_set_bonding_mode_result {
4108 cmdline_fixed_string_t set;
4109 cmdline_fixed_string_t bonding;
4110 cmdline_fixed_string_t mode;
4115 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4116 __attribute__((unused)) struct cmdline *cl,
4117 __attribute__((unused)) void *data)
4119 struct cmd_set_bonding_mode_result *res = parsed_result;
4120 portid_t port_id = res->port_id;
4122 /* Set the bonding mode for the relevant port. */
4123 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4124 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4127 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4128 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4130 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4131 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4132 bonding, "bonding");
4133 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4134 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4136 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4137 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4139 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4140 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4143 cmdline_parse_inst_t cmd_set_bonding_mode = {
4144 .f = cmd_set_bonding_mode_parsed,
4145 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
4148 (void *) &cmd_setbonding_mode_set,
4149 (void *) &cmd_setbonding_mode_bonding,
4150 (void *) &cmd_setbonding_mode_mode,
4151 (void *) &cmd_setbonding_mode_value,
4152 (void *) &cmd_setbonding_mode_port,
4157 /* *** SET BALANCE XMIT POLICY *** */
4158 struct cmd_set_bonding_balance_xmit_policy_result {
4159 cmdline_fixed_string_t set;
4160 cmdline_fixed_string_t bonding;
4161 cmdline_fixed_string_t balance_xmit_policy;
4163 cmdline_fixed_string_t policy;
4166 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4167 __attribute__((unused)) struct cmdline *cl,
4168 __attribute__((unused)) void *data)
4170 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4171 portid_t port_id = res->port_id;
4174 if (!strcmp(res->policy, "l2")) {
4175 policy = BALANCE_XMIT_POLICY_LAYER2;
4176 } else if (!strcmp(res->policy, "l23")) {
4177 policy = BALANCE_XMIT_POLICY_LAYER23;
4178 } else if (!strcmp(res->policy, "l34")) {
4179 policy = BALANCE_XMIT_POLICY_LAYER34;
4181 printf("\t Invalid xmit policy selection");
4185 /* Set the bonding mode for the relevant port. */
4186 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4187 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4192 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4193 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4195 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4196 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4197 bonding, "bonding");
4198 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4199 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4200 balance_xmit_policy, "balance_xmit_policy");
4201 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4202 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4204 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4205 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4206 policy, "l2#l23#l34");
4208 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4209 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4210 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
4213 (void *)&cmd_setbonding_balance_xmit_policy_set,
4214 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4215 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4216 (void *)&cmd_setbonding_balance_xmit_policy_port,
4217 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4222 /* *** SHOW NIC BONDING CONFIGURATION *** */
4223 struct cmd_show_bonding_config_result {
4224 cmdline_fixed_string_t show;
4225 cmdline_fixed_string_t bonding;
4226 cmdline_fixed_string_t config;
4230 static void cmd_show_bonding_config_parsed(void *parsed_result,
4231 __attribute__((unused)) struct cmdline *cl,
4232 __attribute__((unused)) void *data)
4234 struct cmd_show_bonding_config_result *res = parsed_result;
4236 uint8_t slaves[RTE_MAX_ETHPORTS];
4237 int num_slaves, num_active_slaves;
4240 portid_t port_id = res->port_id;
4242 /* Display the bonding mode.*/
4243 bonding_mode = rte_eth_bond_mode_get(port_id);
4244 if (bonding_mode < 0) {
4245 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4248 printf("\tBonding mode: %d\n", bonding_mode);
4250 if (bonding_mode == BONDING_MODE_BALANCE) {
4251 int balance_xmit_policy;
4253 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4254 if (balance_xmit_policy < 0) {
4255 printf("\tFailed to get balance xmit policy for port = %d\n",
4259 printf("\tBalance Xmit Policy: ");
4261 switch (balance_xmit_policy) {
4262 case BALANCE_XMIT_POLICY_LAYER2:
4263 printf("BALANCE_XMIT_POLICY_LAYER2");
4265 case BALANCE_XMIT_POLICY_LAYER23:
4266 printf("BALANCE_XMIT_POLICY_LAYER23");
4268 case BALANCE_XMIT_POLICY_LAYER34:
4269 printf("BALANCE_XMIT_POLICY_LAYER34");
4276 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4278 if (num_slaves < 0) {
4279 printf("\tFailed to get slave list for port = %d\n", port_id);
4282 if (num_slaves > 0) {
4283 printf("\tSlaves (%d): [", num_slaves);
4284 for (i = 0; i < num_slaves - 1; i++)
4285 printf("%d ", slaves[i]);
4287 printf("%d]\n", slaves[num_slaves - 1]);
4289 printf("\tSlaves: []\n");
4293 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4296 if (num_active_slaves < 0) {
4297 printf("\tFailed to get active slave list for port = %d\n", port_id);
4300 if (num_active_slaves > 0) {
4301 printf("\tActive Slaves (%d): [", num_active_slaves);
4302 for (i = 0; i < num_active_slaves - 1; i++)
4303 printf("%d ", slaves[i]);
4305 printf("%d]\n", slaves[num_active_slaves - 1]);
4308 printf("\tActive Slaves: []\n");
4312 primary_id = rte_eth_bond_primary_get(port_id);
4313 if (primary_id < 0) {
4314 printf("\tFailed to get primary slave for port = %d\n", port_id);
4317 printf("\tPrimary: [%d]\n", primary_id);
4321 cmdline_parse_token_string_t cmd_showbonding_config_show =
4322 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4324 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4325 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4326 bonding, "bonding");
4327 cmdline_parse_token_string_t cmd_showbonding_config_config =
4328 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4330 cmdline_parse_token_num_t cmd_showbonding_config_port =
4331 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4334 cmdline_parse_inst_t cmd_show_bonding_config = {
4335 .f = cmd_show_bonding_config_parsed,
4336 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4339 (void *)&cmd_showbonding_config_show,
4340 (void *)&cmd_showbonding_config_bonding,
4341 (void *)&cmd_showbonding_config_config,
4342 (void *)&cmd_showbonding_config_port,
4347 /* *** SET BONDING PRIMARY *** */
4348 struct cmd_set_bonding_primary_result {
4349 cmdline_fixed_string_t set;
4350 cmdline_fixed_string_t bonding;
4351 cmdline_fixed_string_t primary;
4356 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4357 __attribute__((unused)) struct cmdline *cl,
4358 __attribute__((unused)) void *data)
4360 struct cmd_set_bonding_primary_result *res = parsed_result;
4361 portid_t master_port_id = res->port_id;
4362 portid_t slave_port_id = res->slave_id;
4364 /* Set the primary slave for a bonded device. */
4365 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4366 printf("\t Failed to set primary slave for port = %d.\n",
4373 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4374 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4376 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4377 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4378 bonding, "bonding");
4379 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4380 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4381 primary, "primary");
4382 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4383 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4385 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4386 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4389 cmdline_parse_inst_t cmd_set_bonding_primary = {
4390 .f = cmd_set_bonding_primary_parsed,
4391 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4394 (void *)&cmd_setbonding_primary_set,
4395 (void *)&cmd_setbonding_primary_bonding,
4396 (void *)&cmd_setbonding_primary_primary,
4397 (void *)&cmd_setbonding_primary_slave,
4398 (void *)&cmd_setbonding_primary_port,
4403 /* *** ADD SLAVE *** */
4404 struct cmd_add_bonding_slave_result {
4405 cmdline_fixed_string_t add;
4406 cmdline_fixed_string_t bonding;
4407 cmdline_fixed_string_t slave;
4412 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4413 __attribute__((unused)) struct cmdline *cl,
4414 __attribute__((unused)) void *data)
4416 struct cmd_add_bonding_slave_result *res = parsed_result;
4417 portid_t master_port_id = res->port_id;
4418 portid_t slave_port_id = res->slave_id;
4420 /* Set the primary slave for a bonded device. */
4421 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4422 printf("\t Failed to add slave %d to master port = %d.\n",
4423 slave_port_id, master_port_id);
4427 set_port_slave_flag(slave_port_id);
4430 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4431 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4433 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4434 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4435 bonding, "bonding");
4436 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4437 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4439 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4440 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4442 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4443 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4446 cmdline_parse_inst_t cmd_add_bonding_slave = {
4447 .f = cmd_add_bonding_slave_parsed,
4448 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4451 (void *)&cmd_addbonding_slave_add,
4452 (void *)&cmd_addbonding_slave_bonding,
4453 (void *)&cmd_addbonding_slave_slave,
4454 (void *)&cmd_addbonding_slave_slaveid,
4455 (void *)&cmd_addbonding_slave_port,
4460 /* *** REMOVE SLAVE *** */
4461 struct cmd_remove_bonding_slave_result {
4462 cmdline_fixed_string_t remove;
4463 cmdline_fixed_string_t bonding;
4464 cmdline_fixed_string_t slave;
4469 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4470 __attribute__((unused)) struct cmdline *cl,
4471 __attribute__((unused)) void *data)
4473 struct cmd_remove_bonding_slave_result *res = parsed_result;
4474 portid_t master_port_id = res->port_id;
4475 portid_t slave_port_id = res->slave_id;
4477 /* Set the primary slave for a bonded device. */
4478 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4479 printf("\t Failed to remove slave %d from master port = %d.\n",
4480 slave_port_id, master_port_id);
4484 clear_port_slave_flag(slave_port_id);
4487 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4488 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4490 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4491 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4492 bonding, "bonding");
4493 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4494 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4496 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4497 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4499 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4500 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4503 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4504 .f = cmd_remove_bonding_slave_parsed,
4505 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4508 (void *)&cmd_removebonding_slave_remove,
4509 (void *)&cmd_removebonding_slave_bonding,
4510 (void *)&cmd_removebonding_slave_slave,
4511 (void *)&cmd_removebonding_slave_slaveid,
4512 (void *)&cmd_removebonding_slave_port,
4517 /* *** CREATE BONDED DEVICE *** */
4518 struct cmd_create_bonded_device_result {
4519 cmdline_fixed_string_t create;
4520 cmdline_fixed_string_t bonded;
4521 cmdline_fixed_string_t device;
4526 static int bond_dev_num = 0;
4528 static void cmd_create_bonded_device_parsed(void *parsed_result,
4529 __attribute__((unused)) struct cmdline *cl,
4530 __attribute__((unused)) void *data)
4532 struct cmd_create_bonded_device_result *res = parsed_result;
4533 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4536 if (test_done == 0) {
4537 printf("Please stop forwarding first\n");
4541 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4544 /* Create a new bonded device. */
4545 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4547 printf("\t Failed to create bonded device.\n");
4550 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4553 /* Update number of ports */
4554 nb_ports = rte_eth_dev_count();
4555 reconfig(port_id, res->socket);
4556 rte_eth_promiscuous_enable(port_id);
4557 ports[port_id].enabled = 1;
4562 cmdline_parse_token_string_t cmd_createbonded_device_create =
4563 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4565 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4566 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4568 cmdline_parse_token_string_t cmd_createbonded_device_device =
4569 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4571 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4572 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4574 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4575 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4578 cmdline_parse_inst_t cmd_create_bonded_device = {
4579 .f = cmd_create_bonded_device_parsed,
4580 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4583 (void *)&cmd_createbonded_device_create,
4584 (void *)&cmd_createbonded_device_bonded,
4585 (void *)&cmd_createbonded_device_device,
4586 (void *)&cmd_createbonded_device_mode,
4587 (void *)&cmd_createbonded_device_socket,
4592 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4593 struct cmd_set_bond_mac_addr_result {
4594 cmdline_fixed_string_t set;
4595 cmdline_fixed_string_t bonding;
4596 cmdline_fixed_string_t mac_addr;
4598 struct ether_addr address;
4601 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4602 __attribute__((unused)) struct cmdline *cl,
4603 __attribute__((unused)) void *data)
4605 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4608 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4611 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4613 /* check the return value and print it if is < 0 */
4615 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4618 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4619 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4620 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4621 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4623 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4624 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4626 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4627 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4628 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4629 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4631 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4632 .f = cmd_set_bond_mac_addr_parsed,
4634 .help_str = "set bonding mac_addr (port_id) (address): ",
4636 (void *)&cmd_set_bond_mac_addr_set,
4637 (void *)&cmd_set_bond_mac_addr_bonding,
4638 (void *)&cmd_set_bond_mac_addr_mac,
4639 (void *)&cmd_set_bond_mac_addr_portnum,
4640 (void *)&cmd_set_bond_mac_addr_addr,
4646 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4647 struct cmd_set_bond_mon_period_result {
4648 cmdline_fixed_string_t set;
4649 cmdline_fixed_string_t bonding;
4650 cmdline_fixed_string_t mon_period;
4655 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4656 __attribute__((unused)) struct cmdline *cl,
4657 __attribute__((unused)) void *data)
4659 struct cmd_set_bond_mon_period_result *res = parsed_result;
4662 if (res->port_num >= nb_ports) {
4663 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4667 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4669 /* check the return value and print it if is < 0 */
4671 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4674 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4675 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4677 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4678 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4679 bonding, "bonding");
4680 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4681 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4682 mon_period, "mon_period");
4683 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4684 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4686 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4687 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4690 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4691 .f = cmd_set_bond_mon_period_parsed,
4693 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4695 (void *)&cmd_set_bond_mon_period_set,
4696 (void *)&cmd_set_bond_mon_period_bonding,
4697 (void *)&cmd_set_bond_mon_period_mon_period,
4698 (void *)&cmd_set_bond_mon_period_portnum,
4699 (void *)&cmd_set_bond_mon_period_period_ms,
4704 #endif /* RTE_LIBRTE_PMD_BOND */
4706 /* *** SET FORWARDING MODE *** */
4707 struct cmd_set_fwd_mode_result {
4708 cmdline_fixed_string_t set;
4709 cmdline_fixed_string_t fwd;
4710 cmdline_fixed_string_t mode;
4713 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4714 __attribute__((unused)) struct cmdline *cl,
4715 __attribute__((unused)) void *data)
4717 struct cmd_set_fwd_mode_result *res = parsed_result;
4720 set_pkt_forwarding_mode(res->mode);
4723 cmdline_parse_token_string_t cmd_setfwd_set =
4724 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4725 cmdline_parse_token_string_t cmd_setfwd_fwd =
4726 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4727 cmdline_parse_token_string_t cmd_setfwd_mode =
4728 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4729 "" /* defined at init */);
4731 cmdline_parse_inst_t cmd_set_fwd_mode = {
4732 .f = cmd_set_fwd_mode_parsed,
4734 .help_str = NULL, /* defined at init */
4736 (void *)&cmd_setfwd_set,
4737 (void *)&cmd_setfwd_fwd,
4738 (void *)&cmd_setfwd_mode,
4743 static void cmd_set_fwd_mode_init(void)
4746 static char token[128];
4747 static char help[256];
4748 cmdline_parse_token_string_t *token_struct;
4750 modes = list_pkt_forwarding_modes();
4751 snprintf(help, sizeof help, "set fwd %s - "
4752 "set packet forwarding mode", modes);
4753 cmd_set_fwd_mode.help_str = help;
4755 /* string token separator is # */
4756 for (c = token; *modes != '\0'; modes++)
4761 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4762 token_struct->string_data.str = token;
4765 /* *** SET RETRY FORWARDING MODE *** */
4766 struct cmd_set_fwd_retry_mode_result {
4767 cmdline_fixed_string_t set;
4768 cmdline_fixed_string_t fwd;
4769 cmdline_fixed_string_t mode;
4770 cmdline_fixed_string_t retry;
4773 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4774 __attribute__((unused)) struct cmdline *cl,
4775 __attribute__((unused)) void *data)
4777 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4780 set_pkt_forwarding_mode(res->mode);
4783 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4784 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4786 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4787 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4789 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4790 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4792 "" /* defined at init */);
4793 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4794 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4797 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4798 .f = cmd_set_fwd_retry_mode_parsed,
4800 .help_str = NULL, /* defined at init */
4802 (void *)&cmd_setfwd_retry_set,
4803 (void *)&cmd_setfwd_retry_fwd,
4804 (void *)&cmd_setfwd_retry_mode,
4805 (void *)&cmd_setfwd_retry_retry,
4810 static void cmd_set_fwd_retry_mode_init(void)
4813 static char token[128];
4814 static char help[256];
4815 cmdline_parse_token_string_t *token_struct;
4817 modes = list_pkt_forwarding_retry_modes();
4818 snprintf(help, sizeof(help), "set fwd %s retry - "
4819 "set packet forwarding mode with retry", modes);
4820 cmd_set_fwd_retry_mode.help_str = help;
4822 /* string token separator is # */
4823 for (c = token; *modes != '\0'; modes++)
4828 token_struct = (cmdline_parse_token_string_t *)
4829 cmd_set_fwd_retry_mode.tokens[2];
4830 token_struct->string_data.str = token;
4833 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4834 struct cmd_set_burst_tx_retry_result {
4835 cmdline_fixed_string_t set;
4836 cmdline_fixed_string_t burst;
4837 cmdline_fixed_string_t tx;
4838 cmdline_fixed_string_t delay;
4840 cmdline_fixed_string_t retry;
4844 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4845 __attribute__((unused)) struct cmdline *cl,
4846 __attribute__((unused)) void *data)
4848 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4850 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4851 && !strcmp(res->tx, "tx")) {
4852 if (!strcmp(res->delay, "delay"))
4853 burst_tx_delay_time = res->time;
4854 if (!strcmp(res->retry, "retry"))
4855 burst_tx_retry_num = res->retry_num;
4860 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4861 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4862 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4865 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4866 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4867 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4868 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4869 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4870 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4871 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4872 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4873 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4874 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4876 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4877 .f = cmd_set_burst_tx_retry_parsed,
4878 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4880 (void *)&cmd_set_burst_tx_retry_set,
4881 (void *)&cmd_set_burst_tx_retry_burst,
4882 (void *)&cmd_set_burst_tx_retry_tx,
4883 (void *)&cmd_set_burst_tx_retry_delay,
4884 (void *)&cmd_set_burst_tx_retry_time,
4885 (void *)&cmd_set_burst_tx_retry_retry,
4886 (void *)&cmd_set_burst_tx_retry_retry_num,
4891 /* *** SET PROMISC MODE *** */
4892 struct cmd_set_promisc_mode_result {
4893 cmdline_fixed_string_t set;
4894 cmdline_fixed_string_t promisc;
4895 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4896 uint8_t port_num; /* valid if "allports" argument == 0 */
4897 cmdline_fixed_string_t mode;
4900 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4901 __attribute__((unused)) struct cmdline *cl,
4904 struct cmd_set_promisc_mode_result *res = parsed_result;
4908 if (!strcmp(res->mode, "on"))
4915 FOREACH_PORT(i, ports) {
4917 rte_eth_promiscuous_enable(i);
4919 rte_eth_promiscuous_disable(i);
4924 rte_eth_promiscuous_enable(res->port_num);
4926 rte_eth_promiscuous_disable(res->port_num);
4930 cmdline_parse_token_string_t cmd_setpromisc_set =
4931 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4932 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4935 cmdline_parse_token_string_t cmd_setpromisc_portall =
4936 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4938 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4939 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4941 cmdline_parse_token_string_t cmd_setpromisc_mode =
4942 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4945 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4946 .f = cmd_set_promisc_mode_parsed,
4948 .help_str = "set promisc all on|off: set promisc mode for all ports",
4950 (void *)&cmd_setpromisc_set,
4951 (void *)&cmd_setpromisc_promisc,
4952 (void *)&cmd_setpromisc_portall,
4953 (void *)&cmd_setpromisc_mode,
4958 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4959 .f = cmd_set_promisc_mode_parsed,
4961 .help_str = "set promisc X on|off: set promisc mode on port X",
4963 (void *)&cmd_setpromisc_set,
4964 (void *)&cmd_setpromisc_promisc,
4965 (void *)&cmd_setpromisc_portnum,
4966 (void *)&cmd_setpromisc_mode,
4971 /* *** SET ALLMULTI MODE *** */
4972 struct cmd_set_allmulti_mode_result {
4973 cmdline_fixed_string_t set;
4974 cmdline_fixed_string_t allmulti;
4975 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4976 uint8_t port_num; /* valid if "allports" argument == 0 */
4977 cmdline_fixed_string_t mode;
4980 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4981 __attribute__((unused)) struct cmdline *cl,
4984 struct cmd_set_allmulti_mode_result *res = parsed_result;
4988 if (!strcmp(res->mode, "on"))
4995 FOREACH_PORT(i, ports) {
4997 rte_eth_allmulticast_enable(i);
4999 rte_eth_allmulticast_disable(i);
5004 rte_eth_allmulticast_enable(res->port_num);
5006 rte_eth_allmulticast_disable(res->port_num);
5010 cmdline_parse_token_string_t cmd_setallmulti_set =
5011 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5012 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5013 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5015 cmdline_parse_token_string_t cmd_setallmulti_portall =
5016 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5018 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5019 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5021 cmdline_parse_token_string_t cmd_setallmulti_mode =
5022 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5025 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5026 .f = cmd_set_allmulti_mode_parsed,
5028 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
5030 (void *)&cmd_setallmulti_set,
5031 (void *)&cmd_setallmulti_allmulti,
5032 (void *)&cmd_setallmulti_portall,
5033 (void *)&cmd_setallmulti_mode,
5038 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5039 .f = cmd_set_allmulti_mode_parsed,
5041 .help_str = "set allmulti X on|off: set allmulti mode on port X",
5043 (void *)&cmd_setallmulti_set,
5044 (void *)&cmd_setallmulti_allmulti,
5045 (void *)&cmd_setallmulti_portnum,
5046 (void *)&cmd_setallmulti_mode,
5051 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5052 struct cmd_link_flow_ctrl_set_result {
5053 cmdline_fixed_string_t set;
5054 cmdline_fixed_string_t flow_ctrl;
5055 cmdline_fixed_string_t rx;
5056 cmdline_fixed_string_t rx_lfc_mode;
5057 cmdline_fixed_string_t tx;
5058 cmdline_fixed_string_t tx_lfc_mode;
5059 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5060 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5061 cmdline_fixed_string_t autoneg_str;
5062 cmdline_fixed_string_t autoneg;
5063 cmdline_fixed_string_t hw_str;
5064 uint32_t high_water;
5065 cmdline_fixed_string_t lw_str;
5067 cmdline_fixed_string_t pt_str;
5068 uint16_t pause_time;
5069 cmdline_fixed_string_t xon_str;
5074 cmdline_parse_token_string_t cmd_lfc_set_set =
5075 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5077 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5078 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5079 flow_ctrl, "flow_ctrl");
5080 cmdline_parse_token_string_t cmd_lfc_set_rx =
5081 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5083 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5084 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5085 rx_lfc_mode, "on#off");
5086 cmdline_parse_token_string_t cmd_lfc_set_tx =
5087 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5089 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5090 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5091 tx_lfc_mode, "on#off");
5092 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5093 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5094 hw_str, "high_water");
5095 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5096 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5097 high_water, UINT32);
5098 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5099 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5100 lw_str, "low_water");
5101 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5102 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5104 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5105 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5106 pt_str, "pause_time");
5107 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5108 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5109 pause_time, UINT16);
5110 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5111 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5112 xon_str, "send_xon");
5113 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5114 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5116 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5117 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5118 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5119 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5120 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5121 mac_ctrl_frame_fwd_mode, "on#off");
5122 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5123 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5124 autoneg_str, "autoneg");
5125 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5126 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5128 cmdline_parse_token_num_t cmd_lfc_set_portid =
5129 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5132 /* forward declaration */
5134 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5137 cmdline_parse_inst_t cmd_link_flow_control_set = {
5138 .f = cmd_link_flow_ctrl_set_parsed,
5140 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
5141 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
5142 autoneg on|off port_id",
5144 (void *)&cmd_lfc_set_set,
5145 (void *)&cmd_lfc_set_flow_ctrl,
5146 (void *)&cmd_lfc_set_rx,
5147 (void *)&cmd_lfc_set_rx_mode,
5148 (void *)&cmd_lfc_set_tx,
5149 (void *)&cmd_lfc_set_tx_mode,
5150 (void *)&cmd_lfc_set_high_water,
5151 (void *)&cmd_lfc_set_low_water,
5152 (void *)&cmd_lfc_set_pause_time,
5153 (void *)&cmd_lfc_set_send_xon,
5154 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5155 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5156 (void *)&cmd_lfc_set_autoneg_str,
5157 (void *)&cmd_lfc_set_autoneg,
5158 (void *)&cmd_lfc_set_portid,
5163 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5164 .f = cmd_link_flow_ctrl_set_parsed,
5165 .data = (void *)&cmd_link_flow_control_set_rx,
5166 .help_str = "Change rx flow control parameter: set flow_ctrl "
5167 "rx on|off port_id",
5169 (void *)&cmd_lfc_set_set,
5170 (void *)&cmd_lfc_set_flow_ctrl,
5171 (void *)&cmd_lfc_set_rx,
5172 (void *)&cmd_lfc_set_rx_mode,
5173 (void *)&cmd_lfc_set_portid,
5178 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5179 .f = cmd_link_flow_ctrl_set_parsed,
5180 .data = (void *)&cmd_link_flow_control_set_tx,
5181 .help_str = "Change tx flow control parameter: set flow_ctrl "
5182 "tx on|off port_id",
5184 (void *)&cmd_lfc_set_set,
5185 (void *)&cmd_lfc_set_flow_ctrl,
5186 (void *)&cmd_lfc_set_tx,
5187 (void *)&cmd_lfc_set_tx_mode,
5188 (void *)&cmd_lfc_set_portid,
5193 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5194 .f = cmd_link_flow_ctrl_set_parsed,
5195 .data = (void *)&cmd_link_flow_control_set_hw,
5196 .help_str = "Change high water flow control parameter: set flow_ctrl "
5197 "high_water value port_id",
5199 (void *)&cmd_lfc_set_set,
5200 (void *)&cmd_lfc_set_flow_ctrl,
5201 (void *)&cmd_lfc_set_high_water_str,
5202 (void *)&cmd_lfc_set_high_water,
5203 (void *)&cmd_lfc_set_portid,
5208 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5209 .f = cmd_link_flow_ctrl_set_parsed,
5210 .data = (void *)&cmd_link_flow_control_set_lw,
5211 .help_str = "Change low water flow control parameter: set flow_ctrl "
5212 "low_water value port_id",
5214 (void *)&cmd_lfc_set_set,
5215 (void *)&cmd_lfc_set_flow_ctrl,
5216 (void *)&cmd_lfc_set_low_water_str,
5217 (void *)&cmd_lfc_set_low_water,
5218 (void *)&cmd_lfc_set_portid,
5223 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5224 .f = cmd_link_flow_ctrl_set_parsed,
5225 .data = (void *)&cmd_link_flow_control_set_pt,
5226 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5227 "pause_time value port_id",
5229 (void *)&cmd_lfc_set_set,
5230 (void *)&cmd_lfc_set_flow_ctrl,
5231 (void *)&cmd_lfc_set_pause_time_str,
5232 (void *)&cmd_lfc_set_pause_time,
5233 (void *)&cmd_lfc_set_portid,
5238 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5239 .f = cmd_link_flow_ctrl_set_parsed,
5240 .data = (void *)&cmd_link_flow_control_set_xon,
5241 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5242 "send_xon value port_id",
5244 (void *)&cmd_lfc_set_set,
5245 (void *)&cmd_lfc_set_flow_ctrl,
5246 (void *)&cmd_lfc_set_send_xon_str,
5247 (void *)&cmd_lfc_set_send_xon,
5248 (void *)&cmd_lfc_set_portid,
5253 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5254 .f = cmd_link_flow_ctrl_set_parsed,
5255 .data = (void *)&cmd_link_flow_control_set_macfwd,
5256 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5257 "mac_ctrl_frame_fwd on|off port_id",
5259 (void *)&cmd_lfc_set_set,
5260 (void *)&cmd_lfc_set_flow_ctrl,
5261 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5262 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5263 (void *)&cmd_lfc_set_portid,
5268 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5269 .f = cmd_link_flow_ctrl_set_parsed,
5270 .data = (void *)&cmd_link_flow_control_set_autoneg,
5271 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5272 "autoneg on|off port_id",
5274 (void *)&cmd_lfc_set_set,
5275 (void *)&cmd_lfc_set_flow_ctrl,
5276 (void *)&cmd_lfc_set_autoneg_str,
5277 (void *)&cmd_lfc_set_autoneg,
5278 (void *)&cmd_lfc_set_portid,
5284 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5285 __attribute__((unused)) struct cmdline *cl,
5288 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5289 cmdline_parse_inst_t *cmd = data;
5290 struct rte_eth_fc_conf fc_conf;
5296 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5297 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5298 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5299 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5301 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5302 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5305 /* Partial command line, retrieve current configuration */
5307 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5309 printf("cannot get current flow ctrl parameters, return"
5310 "code = %d\n", ret);
5314 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5315 (fc_conf.mode == RTE_FC_FULL))
5317 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5318 (fc_conf.mode == RTE_FC_FULL))
5322 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5323 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5325 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5326 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5328 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5330 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5331 fc_conf.high_water = res->high_water;
5333 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5334 fc_conf.low_water = res->low_water;
5336 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5337 fc_conf.pause_time = res->pause_time;
5339 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5340 fc_conf.send_xon = res->send_xon;
5342 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5343 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5344 fc_conf.mac_ctrl_frame_fwd = 1;
5346 fc_conf.mac_ctrl_frame_fwd = 0;
5349 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5350 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5352 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5354 printf("bad flow contrl parameter, return code = %d \n", ret);
5357 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5358 struct cmd_priority_flow_ctrl_set_result {
5359 cmdline_fixed_string_t set;
5360 cmdline_fixed_string_t pfc_ctrl;
5361 cmdline_fixed_string_t rx;
5362 cmdline_fixed_string_t rx_pfc_mode;
5363 cmdline_fixed_string_t tx;
5364 cmdline_fixed_string_t tx_pfc_mode;
5365 uint32_t high_water;
5367 uint16_t pause_time;
5373 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5374 __attribute__((unused)) struct cmdline *cl,
5375 __attribute__((unused)) void *data)
5377 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5378 struct rte_eth_pfc_conf pfc_conf;
5379 int rx_fc_enable, tx_fc_enable;
5383 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5384 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5385 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5386 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5388 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5389 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5392 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5393 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5394 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5395 pfc_conf.fc.high_water = res->high_water;
5396 pfc_conf.fc.low_water = res->low_water;
5397 pfc_conf.fc.pause_time = res->pause_time;
5398 pfc_conf.priority = res->priority;
5400 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5402 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5405 cmdline_parse_token_string_t cmd_pfc_set_set =
5406 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5408 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5409 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5410 pfc_ctrl, "pfc_ctrl");
5411 cmdline_parse_token_string_t cmd_pfc_set_rx =
5412 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5414 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5415 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5416 rx_pfc_mode, "on#off");
5417 cmdline_parse_token_string_t cmd_pfc_set_tx =
5418 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5420 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5421 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5422 tx_pfc_mode, "on#off");
5423 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5424 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5425 high_water, UINT32);
5426 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5427 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5429 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5430 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5431 pause_time, UINT16);
5432 cmdline_parse_token_num_t cmd_pfc_set_priority =
5433 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5435 cmdline_parse_token_num_t cmd_pfc_set_portid =
5436 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5439 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5440 .f = cmd_priority_flow_ctrl_set_parsed,
5442 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5443 tx on|off high_water low_water pause_time priority port_id",
5445 (void *)&cmd_pfc_set_set,
5446 (void *)&cmd_pfc_set_flow_ctrl,
5447 (void *)&cmd_pfc_set_rx,
5448 (void *)&cmd_pfc_set_rx_mode,
5449 (void *)&cmd_pfc_set_tx,
5450 (void *)&cmd_pfc_set_tx_mode,
5451 (void *)&cmd_pfc_set_high_water,
5452 (void *)&cmd_pfc_set_low_water,
5453 (void *)&cmd_pfc_set_pause_time,
5454 (void *)&cmd_pfc_set_priority,
5455 (void *)&cmd_pfc_set_portid,
5460 /* *** RESET CONFIGURATION *** */
5461 struct cmd_reset_result {
5462 cmdline_fixed_string_t reset;
5463 cmdline_fixed_string_t def;
5466 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5468 __attribute__((unused)) void *data)
5470 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5471 set_def_fwd_config();
5474 cmdline_parse_token_string_t cmd_reset_set =
5475 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5476 cmdline_parse_token_string_t cmd_reset_def =
5477 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5480 cmdline_parse_inst_t cmd_reset = {
5481 .f = cmd_reset_parsed,
5483 .help_str = "set default: reset default forwarding configuration",
5485 (void *)&cmd_reset_set,
5486 (void *)&cmd_reset_def,
5491 /* *** START FORWARDING *** */
5492 struct cmd_start_result {
5493 cmdline_fixed_string_t start;
5496 cmdline_parse_token_string_t cmd_start_start =
5497 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5499 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5500 __attribute__((unused)) struct cmdline *cl,
5501 __attribute__((unused)) void *data)
5503 start_packet_forwarding(0);
5506 cmdline_parse_inst_t cmd_start = {
5507 .f = cmd_start_parsed,
5509 .help_str = "start packet forwarding",
5511 (void *)&cmd_start_start,
5516 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5517 struct cmd_start_tx_first_result {
5518 cmdline_fixed_string_t start;
5519 cmdline_fixed_string_t tx_first;
5523 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5524 __attribute__((unused)) struct cmdline *cl,
5525 __attribute__((unused)) void *data)
5527 start_packet_forwarding(1);
5530 cmdline_parse_token_string_t cmd_start_tx_first_start =
5531 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5533 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5534 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5535 tx_first, "tx_first");
5537 cmdline_parse_inst_t cmd_start_tx_first = {
5538 .f = cmd_start_tx_first_parsed,
5540 .help_str = "start packet forwarding, after sending 1 burst of packets",
5542 (void *)&cmd_start_tx_first_start,
5543 (void *)&cmd_start_tx_first_tx_first,
5548 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5549 struct cmd_start_tx_first_n_result {
5550 cmdline_fixed_string_t start;
5551 cmdline_fixed_string_t tx_first;
5556 cmd_start_tx_first_n_parsed(void *parsed_result,
5557 __attribute__((unused)) struct cmdline *cl,
5558 __attribute__((unused)) void *data)
5560 struct cmd_start_tx_first_n_result *res = parsed_result;
5562 start_packet_forwarding(res->tx_num);
5565 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5566 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5568 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5569 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5570 tx_first, "tx_first");
5571 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5572 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5575 cmdline_parse_inst_t cmd_start_tx_first_n = {
5576 .f = cmd_start_tx_first_n_parsed,
5578 .help_str = "start packet forwarding, after sending <num> "
5579 "bursts of packets",
5581 (void *)&cmd_start_tx_first_n_start,
5582 (void *)&cmd_start_tx_first_n_tx_first,
5583 (void *)&cmd_start_tx_first_n_tx_num,
5588 /* *** SET LINK UP *** */
5589 struct cmd_set_link_up_result {
5590 cmdline_fixed_string_t set;
5591 cmdline_fixed_string_t link_up;
5592 cmdline_fixed_string_t port;
5596 cmdline_parse_token_string_t cmd_set_link_up_set =
5597 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5598 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5599 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5601 cmdline_parse_token_string_t cmd_set_link_up_port =
5602 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5603 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5604 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5606 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5607 __attribute__((unused)) struct cmdline *cl,
5608 __attribute__((unused)) void *data)
5610 struct cmd_set_link_up_result *res = parsed_result;
5611 dev_set_link_up(res->port_id);
5614 cmdline_parse_inst_t cmd_set_link_up = {
5615 .f = cmd_set_link_up_parsed,
5617 .help_str = "set link-up port (port id)",
5619 (void *)&cmd_set_link_up_set,
5620 (void *)&cmd_set_link_up_link_up,
5621 (void *)&cmd_set_link_up_port,
5622 (void *)&cmd_set_link_up_port_id,
5627 /* *** SET LINK DOWN *** */
5628 struct cmd_set_link_down_result {
5629 cmdline_fixed_string_t set;
5630 cmdline_fixed_string_t link_down;
5631 cmdline_fixed_string_t port;
5635 cmdline_parse_token_string_t cmd_set_link_down_set =
5636 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5637 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5638 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5640 cmdline_parse_token_string_t cmd_set_link_down_port =
5641 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5642 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5643 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5645 static void cmd_set_link_down_parsed(
5646 __attribute__((unused)) void *parsed_result,
5647 __attribute__((unused)) struct cmdline *cl,
5648 __attribute__((unused)) void *data)
5650 struct cmd_set_link_down_result *res = parsed_result;
5651 dev_set_link_down(res->port_id);
5654 cmdline_parse_inst_t cmd_set_link_down = {
5655 .f = cmd_set_link_down_parsed,
5657 .help_str = "set link-down port (port id)",
5659 (void *)&cmd_set_link_down_set,
5660 (void *)&cmd_set_link_down_link_down,
5661 (void *)&cmd_set_link_down_port,
5662 (void *)&cmd_set_link_down_port_id,
5667 /* *** SHOW CFG *** */
5668 struct cmd_showcfg_result {
5669 cmdline_fixed_string_t show;
5670 cmdline_fixed_string_t cfg;
5671 cmdline_fixed_string_t what;
5674 static void cmd_showcfg_parsed(void *parsed_result,
5675 __attribute__((unused)) struct cmdline *cl,
5676 __attribute__((unused)) void *data)
5678 struct cmd_showcfg_result *res = parsed_result;
5679 if (!strcmp(res->what, "rxtx"))
5680 rxtx_config_display();
5681 else if (!strcmp(res->what, "cores"))
5682 fwd_lcores_config_display();
5683 else if (!strcmp(res->what, "fwd"))
5684 pkt_fwd_config_display(&cur_fwd_config);
5685 else if (!strcmp(res->what, "txpkts"))
5686 show_tx_pkt_segments();
5689 cmdline_parse_token_string_t cmd_showcfg_show =
5690 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5691 cmdline_parse_token_string_t cmd_showcfg_port =
5692 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5693 cmdline_parse_token_string_t cmd_showcfg_what =
5694 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5695 "rxtx#cores#fwd#txpkts");
5697 cmdline_parse_inst_t cmd_showcfg = {
5698 .f = cmd_showcfg_parsed,
5700 .help_str = "show config rxtx|cores|fwd|txpkts",
5702 (void *)&cmd_showcfg_show,
5703 (void *)&cmd_showcfg_port,
5704 (void *)&cmd_showcfg_what,
5709 /* *** SHOW ALL PORT INFO *** */
5710 struct cmd_showportall_result {
5711 cmdline_fixed_string_t show;
5712 cmdline_fixed_string_t port;
5713 cmdline_fixed_string_t what;
5714 cmdline_fixed_string_t all;
5717 static void cmd_showportall_parsed(void *parsed_result,
5718 __attribute__((unused)) struct cmdline *cl,
5719 __attribute__((unused)) void *data)
5723 struct cmd_showportall_result *res = parsed_result;
5724 if (!strcmp(res->show, "clear")) {
5725 if (!strcmp(res->what, "stats"))
5726 FOREACH_PORT(i, ports)
5728 else if (!strcmp(res->what, "xstats"))
5729 FOREACH_PORT(i, ports)
5730 nic_xstats_clear(i);
5731 } else if (!strcmp(res->what, "info"))
5732 FOREACH_PORT(i, ports)
5733 port_infos_display(i);
5734 else if (!strcmp(res->what, "stats"))
5735 FOREACH_PORT(i, ports)
5736 nic_stats_display(i);
5737 else if (!strcmp(res->what, "xstats"))
5738 FOREACH_PORT(i, ports)
5739 nic_xstats_display(i);
5740 else if (!strcmp(res->what, "fdir"))
5741 FOREACH_PORT(i, ports)
5743 else if (!strcmp(res->what, "stat_qmap"))
5744 FOREACH_PORT(i, ports)
5745 nic_stats_mapping_display(i);
5746 else if (!strcmp(res->what, "dcb_tc"))
5747 FOREACH_PORT(i, ports)
5748 port_dcb_info_display(i);
5751 cmdline_parse_token_string_t cmd_showportall_show =
5752 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5754 cmdline_parse_token_string_t cmd_showportall_port =
5755 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5756 cmdline_parse_token_string_t cmd_showportall_what =
5757 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5758 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5759 cmdline_parse_token_string_t cmd_showportall_all =
5760 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5761 cmdline_parse_inst_t cmd_showportall = {
5762 .f = cmd_showportall_parsed,
5764 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5766 (void *)&cmd_showportall_show,
5767 (void *)&cmd_showportall_port,
5768 (void *)&cmd_showportall_what,
5769 (void *)&cmd_showportall_all,
5774 /* *** SHOW PORT INFO *** */
5775 struct cmd_showport_result {
5776 cmdline_fixed_string_t show;
5777 cmdline_fixed_string_t port;
5778 cmdline_fixed_string_t what;
5782 static void cmd_showport_parsed(void *parsed_result,
5783 __attribute__((unused)) struct cmdline *cl,
5784 __attribute__((unused)) void *data)
5786 struct cmd_showport_result *res = parsed_result;
5787 if (!strcmp(res->show, "clear")) {
5788 if (!strcmp(res->what, "stats"))
5789 nic_stats_clear(res->portnum);
5790 else if (!strcmp(res->what, "xstats"))
5791 nic_xstats_clear(res->portnum);
5792 } else if (!strcmp(res->what, "info"))
5793 port_infos_display(res->portnum);
5794 else if (!strcmp(res->what, "stats"))
5795 nic_stats_display(res->portnum);
5796 else if (!strcmp(res->what, "xstats"))
5797 nic_xstats_display(res->portnum);
5798 else if (!strcmp(res->what, "fdir"))
5799 fdir_get_infos(res->portnum);
5800 else if (!strcmp(res->what, "stat_qmap"))
5801 nic_stats_mapping_display(res->portnum);
5802 else if (!strcmp(res->what, "dcb_tc"))
5803 port_dcb_info_display(res->portnum);
5806 cmdline_parse_token_string_t cmd_showport_show =
5807 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5809 cmdline_parse_token_string_t cmd_showport_port =
5810 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5811 cmdline_parse_token_string_t cmd_showport_what =
5812 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5813 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5814 cmdline_parse_token_num_t cmd_showport_portnum =
5815 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5817 cmdline_parse_inst_t cmd_showport = {
5818 .f = cmd_showport_parsed,
5820 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5822 (void *)&cmd_showport_show,
5823 (void *)&cmd_showport_port,
5824 (void *)&cmd_showport_what,
5825 (void *)&cmd_showport_portnum,
5830 /* *** SHOW QUEUE INFO *** */
5831 struct cmd_showqueue_result {
5832 cmdline_fixed_string_t show;
5833 cmdline_fixed_string_t type;
5834 cmdline_fixed_string_t what;
5840 cmd_showqueue_parsed(void *parsed_result,
5841 __attribute__((unused)) struct cmdline *cl,
5842 __attribute__((unused)) void *data)
5844 struct cmd_showqueue_result *res = parsed_result;
5846 if (!strcmp(res->type, "rxq"))
5847 rx_queue_infos_display(res->portnum, res->queuenum);
5848 else if (!strcmp(res->type, "txq"))
5849 tx_queue_infos_display(res->portnum, res->queuenum);
5852 cmdline_parse_token_string_t cmd_showqueue_show =
5853 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5854 cmdline_parse_token_string_t cmd_showqueue_type =
5855 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5856 cmdline_parse_token_string_t cmd_showqueue_what =
5857 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5858 cmdline_parse_token_num_t cmd_showqueue_portnum =
5859 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5860 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5861 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5863 cmdline_parse_inst_t cmd_showqueue = {
5864 .f = cmd_showqueue_parsed,
5866 .help_str = "show rxq|txq info <port number> <queue_number>",
5868 (void *)&cmd_showqueue_show,
5869 (void *)&cmd_showqueue_type,
5870 (void *)&cmd_showqueue_what,
5871 (void *)&cmd_showqueue_portnum,
5872 (void *)&cmd_showqueue_queuenum,
5877 /* *** READ PORT REGISTER *** */
5878 struct cmd_read_reg_result {
5879 cmdline_fixed_string_t read;
5880 cmdline_fixed_string_t reg;
5886 cmd_read_reg_parsed(void *parsed_result,
5887 __attribute__((unused)) struct cmdline *cl,
5888 __attribute__((unused)) void *data)
5890 struct cmd_read_reg_result *res = parsed_result;
5891 port_reg_display(res->port_id, res->reg_off);
5894 cmdline_parse_token_string_t cmd_read_reg_read =
5895 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5896 cmdline_parse_token_string_t cmd_read_reg_reg =
5897 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5898 cmdline_parse_token_num_t cmd_read_reg_port_id =
5899 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5900 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5901 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5903 cmdline_parse_inst_t cmd_read_reg = {
5904 .f = cmd_read_reg_parsed,
5906 .help_str = "read reg port_id reg_off",
5908 (void *)&cmd_read_reg_read,
5909 (void *)&cmd_read_reg_reg,
5910 (void *)&cmd_read_reg_port_id,
5911 (void *)&cmd_read_reg_reg_off,
5916 /* *** READ PORT REGISTER BIT FIELD *** */
5917 struct cmd_read_reg_bit_field_result {
5918 cmdline_fixed_string_t read;
5919 cmdline_fixed_string_t regfield;
5927 cmd_read_reg_bit_field_parsed(void *parsed_result,
5928 __attribute__((unused)) struct cmdline *cl,
5929 __attribute__((unused)) void *data)
5931 struct cmd_read_reg_bit_field_result *res = parsed_result;
5932 port_reg_bit_field_display(res->port_id, res->reg_off,
5933 res->bit1_pos, res->bit2_pos);
5936 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5937 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5939 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5940 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5941 regfield, "regfield");
5942 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5943 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5945 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5946 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5948 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5949 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5951 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5952 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5955 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5956 .f = cmd_read_reg_bit_field_parsed,
5958 .help_str = "read regfield port_id reg_off bit_x bit_y "
5959 "(read register bit field between bit_x and bit_y included)",
5961 (void *)&cmd_read_reg_bit_field_read,
5962 (void *)&cmd_read_reg_bit_field_regfield,
5963 (void *)&cmd_read_reg_bit_field_port_id,
5964 (void *)&cmd_read_reg_bit_field_reg_off,
5965 (void *)&cmd_read_reg_bit_field_bit1_pos,
5966 (void *)&cmd_read_reg_bit_field_bit2_pos,
5971 /* *** READ PORT REGISTER BIT *** */
5972 struct cmd_read_reg_bit_result {
5973 cmdline_fixed_string_t read;
5974 cmdline_fixed_string_t regbit;
5981 cmd_read_reg_bit_parsed(void *parsed_result,
5982 __attribute__((unused)) struct cmdline *cl,
5983 __attribute__((unused)) void *data)
5985 struct cmd_read_reg_bit_result *res = parsed_result;
5986 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5989 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5990 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5991 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5992 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5994 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5995 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5996 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5997 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5998 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5999 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6001 cmdline_parse_inst_t cmd_read_reg_bit = {
6002 .f = cmd_read_reg_bit_parsed,
6004 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
6006 (void *)&cmd_read_reg_bit_read,
6007 (void *)&cmd_read_reg_bit_regbit,
6008 (void *)&cmd_read_reg_bit_port_id,
6009 (void *)&cmd_read_reg_bit_reg_off,
6010 (void *)&cmd_read_reg_bit_bit_pos,
6015 /* *** WRITE PORT REGISTER *** */
6016 struct cmd_write_reg_result {
6017 cmdline_fixed_string_t write;
6018 cmdline_fixed_string_t reg;
6025 cmd_write_reg_parsed(void *parsed_result,
6026 __attribute__((unused)) struct cmdline *cl,
6027 __attribute__((unused)) void *data)
6029 struct cmd_write_reg_result *res = parsed_result;
6030 port_reg_set(res->port_id, res->reg_off, res->value);
6033 cmdline_parse_token_string_t cmd_write_reg_write =
6034 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6035 cmdline_parse_token_string_t cmd_write_reg_reg =
6036 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6037 cmdline_parse_token_num_t cmd_write_reg_port_id =
6038 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6039 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6040 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6041 cmdline_parse_token_num_t cmd_write_reg_value =
6042 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6044 cmdline_parse_inst_t cmd_write_reg = {
6045 .f = cmd_write_reg_parsed,
6047 .help_str = "write reg port_id reg_off reg_value",
6049 (void *)&cmd_write_reg_write,
6050 (void *)&cmd_write_reg_reg,
6051 (void *)&cmd_write_reg_port_id,
6052 (void *)&cmd_write_reg_reg_off,
6053 (void *)&cmd_write_reg_value,
6058 /* *** WRITE PORT REGISTER BIT FIELD *** */
6059 struct cmd_write_reg_bit_field_result {
6060 cmdline_fixed_string_t write;
6061 cmdline_fixed_string_t regfield;
6070 cmd_write_reg_bit_field_parsed(void *parsed_result,
6071 __attribute__((unused)) struct cmdline *cl,
6072 __attribute__((unused)) void *data)
6074 struct cmd_write_reg_bit_field_result *res = parsed_result;
6075 port_reg_bit_field_set(res->port_id, res->reg_off,
6076 res->bit1_pos, res->bit2_pos, res->value);
6079 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6080 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6082 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6083 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6084 regfield, "regfield");
6085 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6086 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6088 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6089 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6091 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6092 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6094 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6095 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6097 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6098 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6101 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6102 .f = cmd_write_reg_bit_field_parsed,
6104 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
6105 "(set register bit field between bit_x and bit_y included)",
6107 (void *)&cmd_write_reg_bit_field_write,
6108 (void *)&cmd_write_reg_bit_field_regfield,
6109 (void *)&cmd_write_reg_bit_field_port_id,
6110 (void *)&cmd_write_reg_bit_field_reg_off,
6111 (void *)&cmd_write_reg_bit_field_bit1_pos,
6112 (void *)&cmd_write_reg_bit_field_bit2_pos,
6113 (void *)&cmd_write_reg_bit_field_value,
6118 /* *** WRITE PORT REGISTER BIT *** */
6119 struct cmd_write_reg_bit_result {
6120 cmdline_fixed_string_t write;
6121 cmdline_fixed_string_t regbit;
6129 cmd_write_reg_bit_parsed(void *parsed_result,
6130 __attribute__((unused)) struct cmdline *cl,
6131 __attribute__((unused)) void *data)
6133 struct cmd_write_reg_bit_result *res = parsed_result;
6134 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6137 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6138 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6140 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6141 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6143 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6144 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6145 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6146 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6147 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6148 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6149 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6150 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6152 cmdline_parse_inst_t cmd_write_reg_bit = {
6153 .f = cmd_write_reg_bit_parsed,
6155 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
6157 (void *)&cmd_write_reg_bit_write,
6158 (void *)&cmd_write_reg_bit_regbit,
6159 (void *)&cmd_write_reg_bit_port_id,
6160 (void *)&cmd_write_reg_bit_reg_off,
6161 (void *)&cmd_write_reg_bit_bit_pos,
6162 (void *)&cmd_write_reg_bit_value,
6167 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6168 struct cmd_read_rxd_txd_result {
6169 cmdline_fixed_string_t read;
6170 cmdline_fixed_string_t rxd_txd;
6177 cmd_read_rxd_txd_parsed(void *parsed_result,
6178 __attribute__((unused)) struct cmdline *cl,
6179 __attribute__((unused)) void *data)
6181 struct cmd_read_rxd_txd_result *res = parsed_result;
6183 if (!strcmp(res->rxd_txd, "rxd"))
6184 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6185 else if (!strcmp(res->rxd_txd, "txd"))
6186 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6189 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6190 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6191 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6192 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6194 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6195 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6196 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6197 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6198 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6199 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6201 cmdline_parse_inst_t cmd_read_rxd_txd = {
6202 .f = cmd_read_rxd_txd_parsed,
6204 .help_str = "read rxd|txd port_id queue_id rxd_id",
6206 (void *)&cmd_read_rxd_txd_read,
6207 (void *)&cmd_read_rxd_txd_rxd_txd,
6208 (void *)&cmd_read_rxd_txd_port_id,
6209 (void *)&cmd_read_rxd_txd_queue_id,
6210 (void *)&cmd_read_rxd_txd_desc_id,
6216 struct cmd_quit_result {
6217 cmdline_fixed_string_t quit;
6220 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6222 __attribute__((unused)) void *data)
6227 cmdline_parse_token_string_t cmd_quit_quit =
6228 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6230 cmdline_parse_inst_t cmd_quit = {
6231 .f = cmd_quit_parsed,
6233 .help_str = "exit application",
6235 (void *)&cmd_quit_quit,
6240 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6241 struct cmd_mac_addr_result {
6242 cmdline_fixed_string_t mac_addr_cmd;
6243 cmdline_fixed_string_t what;
6245 struct ether_addr address;
6248 static void cmd_mac_addr_parsed(void *parsed_result,
6249 __attribute__((unused)) struct cmdline *cl,
6250 __attribute__((unused)) void *data)
6252 struct cmd_mac_addr_result *res = parsed_result;
6255 if (strcmp(res->what, "add") == 0)
6256 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6258 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6260 /* check the return value and print it if is < 0 */
6262 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6266 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6267 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6269 cmdline_parse_token_string_t cmd_mac_addr_what =
6270 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6272 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6273 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6274 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6275 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6277 cmdline_parse_inst_t cmd_mac_addr = {
6278 .f = cmd_mac_addr_parsed,
6280 .help_str = "mac_addr add|remove X <address>: "
6281 "add/remove MAC address on port X",
6283 (void *)&cmd_mac_addr_cmd,
6284 (void *)&cmd_mac_addr_what,
6285 (void *)&cmd_mac_addr_portnum,
6286 (void *)&cmd_mac_addr_addr,
6292 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6293 struct cmd_set_qmap_result {
6294 cmdline_fixed_string_t set;
6295 cmdline_fixed_string_t qmap;
6296 cmdline_fixed_string_t what;
6303 cmd_set_qmap_parsed(void *parsed_result,
6304 __attribute__((unused)) struct cmdline *cl,
6305 __attribute__((unused)) void *data)
6307 struct cmd_set_qmap_result *res = parsed_result;
6308 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6310 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6313 cmdline_parse_token_string_t cmd_setqmap_set =
6314 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6316 cmdline_parse_token_string_t cmd_setqmap_qmap =
6317 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6319 cmdline_parse_token_string_t cmd_setqmap_what =
6320 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6322 cmdline_parse_token_num_t cmd_setqmap_portid =
6323 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6325 cmdline_parse_token_num_t cmd_setqmap_queueid =
6326 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6328 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6329 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6332 cmdline_parse_inst_t cmd_set_qmap = {
6333 .f = cmd_set_qmap_parsed,
6335 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6337 (void *)&cmd_setqmap_set,
6338 (void *)&cmd_setqmap_qmap,
6339 (void *)&cmd_setqmap_what,
6340 (void *)&cmd_setqmap_portid,
6341 (void *)&cmd_setqmap_queueid,
6342 (void *)&cmd_setqmap_mapvalue,
6347 /* *** CONFIGURE UNICAST HASH TABLE *** */
6348 struct cmd_set_uc_hash_table {
6349 cmdline_fixed_string_t set;
6350 cmdline_fixed_string_t port;
6352 cmdline_fixed_string_t what;
6353 struct ether_addr address;
6354 cmdline_fixed_string_t mode;
6358 cmd_set_uc_hash_parsed(void *parsed_result,
6359 __attribute__((unused)) struct cmdline *cl,
6360 __attribute__((unused)) void *data)
6363 struct cmd_set_uc_hash_table *res = parsed_result;
6365 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6367 if (strcmp(res->what, "uta") == 0)
6368 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6369 &res->address,(uint8_t)is_on);
6371 printf("bad unicast hash table parameter, return code = %d \n", ret);
6375 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6376 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6378 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6379 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6381 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6382 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6384 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6385 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6387 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6388 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6390 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6391 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6394 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6395 .f = cmd_set_uc_hash_parsed,
6397 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6399 (void *)&cmd_set_uc_hash_set,
6400 (void *)&cmd_set_uc_hash_port,
6401 (void *)&cmd_set_uc_hash_portid,
6402 (void *)&cmd_set_uc_hash_what,
6403 (void *)&cmd_set_uc_hash_mac,
6404 (void *)&cmd_set_uc_hash_mode,
6409 struct cmd_set_uc_all_hash_table {
6410 cmdline_fixed_string_t set;
6411 cmdline_fixed_string_t port;
6413 cmdline_fixed_string_t what;
6414 cmdline_fixed_string_t value;
6415 cmdline_fixed_string_t mode;
6419 cmd_set_uc_all_hash_parsed(void *parsed_result,
6420 __attribute__((unused)) struct cmdline *cl,
6421 __attribute__((unused)) void *data)
6424 struct cmd_set_uc_all_hash_table *res = parsed_result;
6426 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6428 if ((strcmp(res->what, "uta") == 0) &&
6429 (strcmp(res->value, "all") == 0))
6430 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6432 printf("bad unicast hash table parameter,"
6433 "return code = %d \n", ret);
6436 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6437 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6439 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6440 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6442 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6443 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6445 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6446 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6448 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6449 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6451 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6452 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6455 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6456 .f = cmd_set_uc_all_hash_parsed,
6458 .help_str = "set port X uta all on|off (X = port number)",
6460 (void *)&cmd_set_uc_all_hash_set,
6461 (void *)&cmd_set_uc_all_hash_port,
6462 (void *)&cmd_set_uc_all_hash_portid,
6463 (void *)&cmd_set_uc_all_hash_what,
6464 (void *)&cmd_set_uc_all_hash_value,
6465 (void *)&cmd_set_uc_all_hash_mode,
6470 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6471 struct cmd_set_vf_macvlan_filter {
6472 cmdline_fixed_string_t set;
6473 cmdline_fixed_string_t port;
6475 cmdline_fixed_string_t vf;
6477 struct ether_addr address;
6478 cmdline_fixed_string_t filter_type;
6479 cmdline_fixed_string_t mode;
6483 cmd_set_vf_macvlan_parsed(void *parsed_result,
6484 __attribute__((unused)) struct cmdline *cl,
6485 __attribute__((unused)) void *data)
6488 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6489 struct rte_eth_mac_filter filter;
6491 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6493 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6495 /* set VF MAC filter */
6499 filter.dst_id = res->vf_id;
6501 if (!strcmp(res->filter_type, "exact-mac"))
6502 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6503 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6504 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6505 else if (!strcmp(res->filter_type, "hashmac"))
6506 filter.filter_type = RTE_MAC_HASH_MATCH;
6507 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6508 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6510 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6513 ret = rte_eth_dev_filter_ctrl(res->port_id,
6514 RTE_ETH_FILTER_MACVLAN,
6518 ret = rte_eth_dev_filter_ctrl(res->port_id,
6519 RTE_ETH_FILTER_MACVLAN,
6520 RTE_ETH_FILTER_DELETE,
6524 printf("bad set MAC hash parameter, return code = %d\n", ret);
6528 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6531 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6532 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6534 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6535 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6537 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6538 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6540 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6541 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6543 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6544 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6546 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6547 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6548 filter_type, "exact-mac#exact-mac-vlan"
6549 "#hashmac#hashmac-vlan");
6550 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6551 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6554 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6555 .f = cmd_set_vf_macvlan_parsed,
6557 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6558 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6560 "exact match rule:exact match of MAC or MAC and VLAN; "
6561 "hash match rule: hash match of MAC and exact match "
6564 (void *)&cmd_set_vf_macvlan_set,
6565 (void *)&cmd_set_vf_macvlan_port,
6566 (void *)&cmd_set_vf_macvlan_portid,
6567 (void *)&cmd_set_vf_macvlan_vf,
6568 (void *)&cmd_set_vf_macvlan_vf_id,
6569 (void *)&cmd_set_vf_macvlan_mac,
6570 (void *)&cmd_set_vf_macvlan_filter_type,
6571 (void *)&cmd_set_vf_macvlan_mode,
6576 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6577 struct cmd_set_vf_traffic {
6578 cmdline_fixed_string_t set;
6579 cmdline_fixed_string_t port;
6581 cmdline_fixed_string_t vf;
6583 cmdline_fixed_string_t what;
6584 cmdline_fixed_string_t mode;
6588 cmd_set_vf_traffic_parsed(void *parsed_result,
6589 __attribute__((unused)) struct cmdline *cl,
6590 __attribute__((unused)) void *data)
6592 struct cmd_set_vf_traffic *res = parsed_result;
6593 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6594 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6596 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6599 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6600 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6602 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6603 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6605 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6606 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6608 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6609 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6611 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6612 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6614 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6615 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6617 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6618 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6621 cmdline_parse_inst_t cmd_set_vf_traffic = {
6622 .f = cmd_set_vf_traffic_parsed,
6624 .help_str = "set port X vf Y rx|tx on|off"
6625 "(X = port number,Y = vf id)",
6627 (void *)&cmd_setvf_traffic_set,
6628 (void *)&cmd_setvf_traffic_port,
6629 (void *)&cmd_setvf_traffic_portid,
6630 (void *)&cmd_setvf_traffic_vf,
6631 (void *)&cmd_setvf_traffic_vfid,
6632 (void *)&cmd_setvf_traffic_what,
6633 (void *)&cmd_setvf_traffic_mode,
6638 /* *** CONFIGURE VF RECEIVE MODE *** */
6639 struct cmd_set_vf_rxmode {
6640 cmdline_fixed_string_t set;
6641 cmdline_fixed_string_t port;
6643 cmdline_fixed_string_t vf;
6645 cmdline_fixed_string_t what;
6646 cmdline_fixed_string_t mode;
6647 cmdline_fixed_string_t on;
6651 cmd_set_vf_rxmode_parsed(void *parsed_result,
6652 __attribute__((unused)) struct cmdline *cl,
6653 __attribute__((unused)) void *data)
6656 uint16_t rx_mode = 0;
6657 struct cmd_set_vf_rxmode *res = parsed_result;
6659 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6660 if (!strcmp(res->what,"rxmode")) {
6661 if (!strcmp(res->mode, "AUPE"))
6662 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6663 else if (!strcmp(res->mode, "ROPE"))
6664 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6665 else if (!strcmp(res->mode, "BAM"))
6666 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6667 else if (!strncmp(res->mode, "MPE",3))
6668 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6671 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6673 printf("bad VF receive mode parameter, return code = %d \n",
6677 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6678 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6680 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6681 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6683 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6684 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6686 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6687 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6689 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6690 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6692 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6693 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6695 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6697 mode, "AUPE#ROPE#BAM#MPE");
6698 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6699 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6702 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6703 .f = cmd_set_vf_rxmode_parsed,
6705 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6707 (void *)&cmd_set_vf_rxmode_set,
6708 (void *)&cmd_set_vf_rxmode_port,
6709 (void *)&cmd_set_vf_rxmode_portid,
6710 (void *)&cmd_set_vf_rxmode_vf,
6711 (void *)&cmd_set_vf_rxmode_vfid,
6712 (void *)&cmd_set_vf_rxmode_what,
6713 (void *)&cmd_set_vf_rxmode_mode,
6714 (void *)&cmd_set_vf_rxmode_on,
6719 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6720 struct cmd_vf_mac_addr_result {
6721 cmdline_fixed_string_t mac_addr_cmd;
6722 cmdline_fixed_string_t what;
6723 cmdline_fixed_string_t port;
6725 cmdline_fixed_string_t vf;
6727 struct ether_addr address;
6730 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6731 __attribute__((unused)) struct cmdline *cl,
6732 __attribute__((unused)) void *data)
6734 struct cmd_vf_mac_addr_result *res = parsed_result;
6737 if (strcmp(res->what, "add") == 0)
6738 ret = rte_eth_dev_mac_addr_add(res->port_num,
6739 &res->address, res->vf_num);
6741 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6745 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6746 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6747 mac_addr_cmd,"mac_addr");
6748 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6749 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6751 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6752 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6754 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6755 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6757 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6758 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6760 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6761 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6763 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6764 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6767 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6768 .f = cmd_vf_mac_addr_parsed,
6770 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6771 "Y = VF number)add MAC address filtering for a VF on port X",
6773 (void *)&cmd_vf_mac_addr_cmd,
6774 (void *)&cmd_vf_mac_addr_what,
6775 (void *)&cmd_vf_mac_addr_port,
6776 (void *)&cmd_vf_mac_addr_portnum,
6777 (void *)&cmd_vf_mac_addr_vf,
6778 (void *)&cmd_vf_mac_addr_vfnum,
6779 (void *)&cmd_vf_mac_addr_addr,
6784 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6785 struct cmd_vf_rx_vlan_filter {
6786 cmdline_fixed_string_t rx_vlan;
6787 cmdline_fixed_string_t what;
6789 cmdline_fixed_string_t port;
6791 cmdline_fixed_string_t vf;
6796 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6797 __attribute__((unused)) struct cmdline *cl,
6798 __attribute__((unused)) void *data)
6800 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6802 if (!strcmp(res->what, "add"))
6803 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6805 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6808 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6809 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6810 rx_vlan, "rx_vlan");
6811 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6812 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6814 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6815 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6817 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6818 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6820 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6821 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6823 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6824 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6826 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6827 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6830 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6831 .f = cmd_vf_rx_vlan_filter_parsed,
6833 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6834 "Y = port number,Z = hexadecimal VF mask)",
6836 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6837 (void *)&cmd_vf_rx_vlan_filter_what,
6838 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6839 (void *)&cmd_vf_rx_vlan_filter_port,
6840 (void *)&cmd_vf_rx_vlan_filter_portid,
6841 (void *)&cmd_vf_rx_vlan_filter_vf,
6842 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6847 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6848 struct cmd_queue_rate_limit_result {
6849 cmdline_fixed_string_t set;
6850 cmdline_fixed_string_t port;
6852 cmdline_fixed_string_t queue;
6854 cmdline_fixed_string_t rate;
6858 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6859 __attribute__((unused)) struct cmdline *cl,
6860 __attribute__((unused)) void *data)
6862 struct cmd_queue_rate_limit_result *res = parsed_result;
6865 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6866 && (strcmp(res->queue, "queue") == 0)
6867 && (strcmp(res->rate, "rate") == 0))
6868 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6871 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6875 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6876 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6878 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6879 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6881 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6882 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6884 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6885 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6887 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6888 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6890 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6891 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6893 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6894 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6897 cmdline_parse_inst_t cmd_queue_rate_limit = {
6898 .f = cmd_queue_rate_limit_parsed,
6900 .help_str = "set port X queue Y rate Z:(X = port number,"
6901 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6903 (void *)&cmd_queue_rate_limit_set,
6904 (void *)&cmd_queue_rate_limit_port,
6905 (void *)&cmd_queue_rate_limit_portnum,
6906 (void *)&cmd_queue_rate_limit_queue,
6907 (void *)&cmd_queue_rate_limit_queuenum,
6908 (void *)&cmd_queue_rate_limit_rate,
6909 (void *)&cmd_queue_rate_limit_ratenum,
6914 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6915 struct cmd_vf_rate_limit_result {
6916 cmdline_fixed_string_t set;
6917 cmdline_fixed_string_t port;
6919 cmdline_fixed_string_t vf;
6921 cmdline_fixed_string_t rate;
6923 cmdline_fixed_string_t q_msk;
6927 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6928 __attribute__((unused)) struct cmdline *cl,
6929 __attribute__((unused)) void *data)
6931 struct cmd_vf_rate_limit_result *res = parsed_result;
6934 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6935 && (strcmp(res->vf, "vf") == 0)
6936 && (strcmp(res->rate, "rate") == 0)
6937 && (strcmp(res->q_msk, "queue_mask") == 0))
6938 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6939 res->rate_num, res->q_msk_val);
6941 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6945 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6946 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6948 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6949 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6951 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6952 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6954 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6955 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6957 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6958 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6960 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6961 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6963 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6964 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6966 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6967 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6968 q_msk, "queue_mask");
6969 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6970 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6973 cmdline_parse_inst_t cmd_vf_rate_limit = {
6974 .f = cmd_vf_rate_limit_parsed,
6976 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6977 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6978 "for queues of VF on port X",
6980 (void *)&cmd_vf_rate_limit_set,
6981 (void *)&cmd_vf_rate_limit_port,
6982 (void *)&cmd_vf_rate_limit_portnum,
6983 (void *)&cmd_vf_rate_limit_vf,
6984 (void *)&cmd_vf_rate_limit_vfnum,
6985 (void *)&cmd_vf_rate_limit_rate,
6986 (void *)&cmd_vf_rate_limit_ratenum,
6987 (void *)&cmd_vf_rate_limit_q_msk,
6988 (void *)&cmd_vf_rate_limit_q_msk_val,
6993 /* *** ADD TUNNEL FILTER OF A PORT *** */
6994 struct cmd_tunnel_filter_result {
6995 cmdline_fixed_string_t cmd;
6996 cmdline_fixed_string_t what;
6998 struct ether_addr outer_mac;
6999 struct ether_addr inner_mac;
7000 cmdline_ipaddr_t ip_value;
7001 uint16_t inner_vlan;
7002 cmdline_fixed_string_t tunnel_type;
7003 cmdline_fixed_string_t filter_type;
7009 cmd_tunnel_filter_parsed(void *parsed_result,
7010 __attribute__((unused)) struct cmdline *cl,
7011 __attribute__((unused)) void *data)
7013 struct cmd_tunnel_filter_result *res = parsed_result;
7014 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7017 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7019 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7020 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7021 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7023 if (res->ip_value.family == AF_INET) {
7024 tunnel_filter_conf.ip_addr.ipv4_addr =
7025 res->ip_value.addr.ipv4.s_addr;
7026 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7028 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7029 &(res->ip_value.addr.ipv6),
7030 sizeof(struct in6_addr));
7031 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7034 if (!strcmp(res->filter_type, "imac-ivlan"))
7035 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7036 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7037 tunnel_filter_conf.filter_type =
7038 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7039 else if (!strcmp(res->filter_type, "imac-tenid"))
7040 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7041 else if (!strcmp(res->filter_type, "imac"))
7042 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7043 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7044 tunnel_filter_conf.filter_type =
7045 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7046 else if (!strcmp(res->filter_type, "oip"))
7047 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7048 else if (!strcmp(res->filter_type, "iip"))
7049 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7051 printf("The filter type is not supported");
7055 if (!strcmp(res->tunnel_type, "vxlan"))
7056 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7057 else if (!strcmp(res->tunnel_type, "nvgre"))
7058 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7059 else if (!strcmp(res->tunnel_type, "ipingre"))
7060 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7062 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7066 tunnel_filter_conf.tenant_id = res->tenant_id;
7067 tunnel_filter_conf.queue_id = res->queue_num;
7068 if (!strcmp(res->what, "add"))
7069 ret = rte_eth_dev_filter_ctrl(res->port_id,
7070 RTE_ETH_FILTER_TUNNEL,
7072 &tunnel_filter_conf);
7074 ret = rte_eth_dev_filter_ctrl(res->port_id,
7075 RTE_ETH_FILTER_TUNNEL,
7076 RTE_ETH_FILTER_DELETE,
7077 &tunnel_filter_conf);
7079 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7083 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7084 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7085 cmd, "tunnel_filter");
7086 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7087 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7089 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7090 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7092 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7093 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7095 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7096 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7098 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7099 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7100 inner_vlan, UINT16);
7101 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7102 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7104 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7105 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7106 tunnel_type, "vxlan#nvgre#ipingre");
7108 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7109 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7110 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7111 "imac#omac-imac-tenid");
7112 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7113 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7115 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7116 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7119 cmdline_parse_inst_t cmd_tunnel_filter = {
7120 .f = cmd_tunnel_filter_parsed,
7122 .help_str = "add/rm tunnel filter of a port: "
7123 "tunnel_filter add port_id outer_mac inner_mac ip "
7124 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
7125 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
7126 "imac|omac-imac-tenid) "
7127 "tenant_id queue_num",
7129 (void *)&cmd_tunnel_filter_cmd,
7130 (void *)&cmd_tunnel_filter_what,
7131 (void *)&cmd_tunnel_filter_port_id,
7132 (void *)&cmd_tunnel_filter_outer_mac,
7133 (void *)&cmd_tunnel_filter_inner_mac,
7134 (void *)&cmd_tunnel_filter_ip_value,
7135 (void *)&cmd_tunnel_filter_innner_vlan,
7136 (void *)&cmd_tunnel_filter_tunnel_type,
7137 (void *)&cmd_tunnel_filter_filter_type,
7138 (void *)&cmd_tunnel_filter_tenant_id,
7139 (void *)&cmd_tunnel_filter_queue_num,
7144 /* *** CONFIGURE TUNNEL UDP PORT *** */
7145 struct cmd_tunnel_udp_config {
7146 cmdline_fixed_string_t cmd;
7147 cmdline_fixed_string_t what;
7153 cmd_tunnel_udp_config_parsed(void *parsed_result,
7154 __attribute__((unused)) struct cmdline *cl,
7155 __attribute__((unused)) void *data)
7157 struct cmd_tunnel_udp_config *res = parsed_result;
7158 struct rte_eth_udp_tunnel tunnel_udp;
7161 tunnel_udp.udp_port = res->udp_port;
7163 if (!strcmp(res->cmd, "rx_vxlan_port"))
7164 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7166 if (!strcmp(res->what, "add"))
7167 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7170 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7174 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7177 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7178 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7179 cmd, "rx_vxlan_port");
7180 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7181 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7183 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7184 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7186 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7187 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7190 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7191 .f = cmd_tunnel_udp_config_parsed,
7193 .help_str = "add/rm an tunneling UDP port filter: "
7194 "rx_vxlan_port add udp_port port_id",
7196 (void *)&cmd_tunnel_udp_config_cmd,
7197 (void *)&cmd_tunnel_udp_config_what,
7198 (void *)&cmd_tunnel_udp_config_udp_port,
7199 (void *)&cmd_tunnel_udp_config_port_id,
7204 /* *** GLOBAL CONFIG *** */
7205 struct cmd_global_config_result {
7206 cmdline_fixed_string_t cmd;
7208 cmdline_fixed_string_t cfg_type;
7213 cmd_global_config_parsed(void *parsed_result,
7214 __attribute__((unused)) struct cmdline *cl,
7215 __attribute__((unused)) void *data)
7217 struct cmd_global_config_result *res = parsed_result;
7218 struct rte_eth_global_cfg conf;
7221 memset(&conf, 0, sizeof(conf));
7222 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7223 conf.cfg.gre_key_len = res->len;
7224 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7225 RTE_ETH_FILTER_SET, &conf);
7227 printf("Global config error\n");
7230 cmdline_parse_token_string_t cmd_global_config_cmd =
7231 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7233 cmdline_parse_token_num_t cmd_global_config_port_id =
7234 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7235 cmdline_parse_token_string_t cmd_global_config_type =
7236 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7237 cfg_type, "gre-key-len");
7238 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7239 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7242 cmdline_parse_inst_t cmd_global_config = {
7243 .f = cmd_global_config_parsed,
7244 .data = (void *)NULL,
7245 .help_str = "global_config <port_id> gre-key-len <number>",
7247 (void *)&cmd_global_config_cmd,
7248 (void *)&cmd_global_config_port_id,
7249 (void *)&cmd_global_config_type,
7250 (void *)&cmd_global_config_gre_key_len,
7255 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7256 struct cmd_set_mirror_mask_result {
7257 cmdline_fixed_string_t set;
7258 cmdline_fixed_string_t port;
7260 cmdline_fixed_string_t mirror;
7262 cmdline_fixed_string_t what;
7263 cmdline_fixed_string_t value;
7264 cmdline_fixed_string_t dstpool;
7266 cmdline_fixed_string_t on;
7269 cmdline_parse_token_string_t cmd_mirror_mask_set =
7270 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7272 cmdline_parse_token_string_t cmd_mirror_mask_port =
7273 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7275 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7276 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7278 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7279 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7280 mirror, "mirror-rule");
7281 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7282 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7284 cmdline_parse_token_string_t cmd_mirror_mask_what =
7285 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7286 what, "pool-mirror-up#pool-mirror-down"
7288 cmdline_parse_token_string_t cmd_mirror_mask_value =
7289 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7291 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7292 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7293 dstpool, "dst-pool");
7294 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7295 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7297 cmdline_parse_token_string_t cmd_mirror_mask_on =
7298 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7302 cmd_set_mirror_mask_parsed(void *parsed_result,
7303 __attribute__((unused)) struct cmdline *cl,
7304 __attribute__((unused)) void *data)
7307 struct cmd_set_mirror_mask_result *res = parsed_result;
7308 struct rte_eth_mirror_conf mr_conf;
7310 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7312 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7314 mr_conf.dst_pool = res->dstpool_id;
7316 if (!strcmp(res->what, "pool-mirror-up")) {
7317 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7318 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7319 } else if (!strcmp(res->what, "pool-mirror-down")) {
7320 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7321 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7322 } else if (!strcmp(res->what, "vlan-mirror")) {
7323 mr_conf.rule_type = ETH_MIRROR_VLAN;
7324 nb_item = parse_item_list(res->value, "vlan",
7325 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7329 for (i = 0; i < nb_item; i++) {
7330 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7331 printf("Invalid vlan_id: must be < 4096\n");
7335 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7336 mr_conf.vlan.vlan_mask |= 1ULL << i;
7340 if (!strcmp(res->on, "on"))
7341 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7344 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7347 printf("mirror rule add error: (%s)\n", strerror(-ret));
7350 cmdline_parse_inst_t cmd_set_mirror_mask = {
7351 .f = cmd_set_mirror_mask_parsed,
7353 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7354 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7356 (void *)&cmd_mirror_mask_set,
7357 (void *)&cmd_mirror_mask_port,
7358 (void *)&cmd_mirror_mask_portid,
7359 (void *)&cmd_mirror_mask_mirror,
7360 (void *)&cmd_mirror_mask_ruleid,
7361 (void *)&cmd_mirror_mask_what,
7362 (void *)&cmd_mirror_mask_value,
7363 (void *)&cmd_mirror_mask_dstpool,
7364 (void *)&cmd_mirror_mask_poolid,
7365 (void *)&cmd_mirror_mask_on,
7370 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7371 struct cmd_set_mirror_link_result {
7372 cmdline_fixed_string_t set;
7373 cmdline_fixed_string_t port;
7375 cmdline_fixed_string_t mirror;
7377 cmdline_fixed_string_t what;
7378 cmdline_fixed_string_t dstpool;
7380 cmdline_fixed_string_t on;
7383 cmdline_parse_token_string_t cmd_mirror_link_set =
7384 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7386 cmdline_parse_token_string_t cmd_mirror_link_port =
7387 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7389 cmdline_parse_token_num_t cmd_mirror_link_portid =
7390 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7392 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7393 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7394 mirror, "mirror-rule");
7395 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7396 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7398 cmdline_parse_token_string_t cmd_mirror_link_what =
7399 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7400 what, "uplink-mirror#downlink-mirror");
7401 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7402 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7403 dstpool, "dst-pool");
7404 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7405 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7407 cmdline_parse_token_string_t cmd_mirror_link_on =
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7412 cmd_set_mirror_link_parsed(void *parsed_result,
7413 __attribute__((unused)) struct cmdline *cl,
7414 __attribute__((unused)) void *data)
7417 struct cmd_set_mirror_link_result *res = parsed_result;
7418 struct rte_eth_mirror_conf mr_conf;
7420 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7421 if (!strcmp(res->what, "uplink-mirror"))
7422 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7424 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7426 mr_conf.dst_pool = res->dstpool_id;
7428 if (!strcmp(res->on, "on"))
7429 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7432 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7435 /* check the return value and print it if is < 0 */
7437 printf("mirror rule add error: (%s)\n", strerror(-ret));
7441 cmdline_parse_inst_t cmd_set_mirror_link = {
7442 .f = cmd_set_mirror_link_parsed,
7444 .help_str = "set port X mirror-rule Y uplink-mirror|"
7445 "downlink-mirror dst-pool Z on|off",
7447 (void *)&cmd_mirror_link_set,
7448 (void *)&cmd_mirror_link_port,
7449 (void *)&cmd_mirror_link_portid,
7450 (void *)&cmd_mirror_link_mirror,
7451 (void *)&cmd_mirror_link_ruleid,
7452 (void *)&cmd_mirror_link_what,
7453 (void *)&cmd_mirror_link_dstpool,
7454 (void *)&cmd_mirror_link_poolid,
7455 (void *)&cmd_mirror_link_on,
7460 /* *** RESET VM MIRROR RULE *** */
7461 struct cmd_rm_mirror_rule_result {
7462 cmdline_fixed_string_t reset;
7463 cmdline_fixed_string_t port;
7465 cmdline_fixed_string_t mirror;
7469 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7470 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7472 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7473 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7475 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7476 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7478 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7479 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7480 mirror, "mirror-rule");
7481 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7482 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7486 cmd_reset_mirror_rule_parsed(void *parsed_result,
7487 __attribute__((unused)) struct cmdline *cl,
7488 __attribute__((unused)) void *data)
7491 struct cmd_set_mirror_link_result *res = parsed_result;
7493 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7495 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7498 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7499 .f = cmd_reset_mirror_rule_parsed,
7501 .help_str = "reset port X mirror-rule Y",
7503 (void *)&cmd_rm_mirror_rule_reset,
7504 (void *)&cmd_rm_mirror_rule_port,
7505 (void *)&cmd_rm_mirror_rule_portid,
7506 (void *)&cmd_rm_mirror_rule_mirror,
7507 (void *)&cmd_rm_mirror_rule_ruleid,
7512 /* ******************************************************************************** */
7514 struct cmd_dump_result {
7515 cmdline_fixed_string_t dump;
7519 dump_struct_sizes(void)
7521 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7522 DUMP_SIZE(struct rte_mbuf);
7523 DUMP_SIZE(struct rte_mempool);
7524 DUMP_SIZE(struct rte_ring);
7528 static void cmd_dump_parsed(void *parsed_result,
7529 __attribute__((unused)) struct cmdline *cl,
7530 __attribute__((unused)) void *data)
7532 struct cmd_dump_result *res = parsed_result;
7534 if (!strcmp(res->dump, "dump_physmem"))
7535 rte_dump_physmem_layout(stdout);
7536 else if (!strcmp(res->dump, "dump_memzone"))
7537 rte_memzone_dump(stdout);
7538 else if (!strcmp(res->dump, "dump_struct_sizes"))
7539 dump_struct_sizes();
7540 else if (!strcmp(res->dump, "dump_ring"))
7541 rte_ring_list_dump(stdout);
7542 else if (!strcmp(res->dump, "dump_mempool"))
7543 rte_mempool_list_dump(stdout);
7544 else if (!strcmp(res->dump, "dump_devargs"))
7545 rte_eal_devargs_dump(stdout);
7548 cmdline_parse_token_string_t cmd_dump_dump =
7549 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7552 "dump_struct_sizes#"
7557 cmdline_parse_inst_t cmd_dump = {
7558 .f = cmd_dump_parsed, /* function to call */
7559 .data = NULL, /* 2nd arg of func */
7560 .help_str = "dump status",
7561 .tokens = { /* token list, NULL terminated */
7562 (void *)&cmd_dump_dump,
7567 /* ******************************************************************************** */
7569 struct cmd_dump_one_result {
7570 cmdline_fixed_string_t dump;
7571 cmdline_fixed_string_t name;
7574 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7575 __attribute__((unused)) void *data)
7577 struct cmd_dump_one_result *res = parsed_result;
7579 if (!strcmp(res->dump, "dump_ring")) {
7581 r = rte_ring_lookup(res->name);
7583 cmdline_printf(cl, "Cannot find ring\n");
7586 rte_ring_dump(stdout, r);
7587 } else if (!strcmp(res->dump, "dump_mempool")) {
7588 struct rte_mempool *mp;
7589 mp = rte_mempool_lookup(res->name);
7591 cmdline_printf(cl, "Cannot find mempool\n");
7594 rte_mempool_dump(stdout, mp);
7598 cmdline_parse_token_string_t cmd_dump_one_dump =
7599 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7600 "dump_ring#dump_mempool");
7602 cmdline_parse_token_string_t cmd_dump_one_name =
7603 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7605 cmdline_parse_inst_t cmd_dump_one = {
7606 .f = cmd_dump_one_parsed, /* function to call */
7607 .data = NULL, /* 2nd arg of func */
7608 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7609 .tokens = { /* token list, NULL terminated */
7610 (void *)&cmd_dump_one_dump,
7611 (void *)&cmd_dump_one_name,
7616 /* *** Add/Del syn filter *** */
7617 struct cmd_syn_filter_result {
7618 cmdline_fixed_string_t filter;
7620 cmdline_fixed_string_t ops;
7621 cmdline_fixed_string_t priority;
7622 cmdline_fixed_string_t high;
7623 cmdline_fixed_string_t queue;
7628 cmd_syn_filter_parsed(void *parsed_result,
7629 __attribute__((unused)) struct cmdline *cl,
7630 __attribute__((unused)) void *data)
7632 struct cmd_syn_filter_result *res = parsed_result;
7633 struct rte_eth_syn_filter syn_filter;
7636 ret = rte_eth_dev_filter_supported(res->port_id,
7637 RTE_ETH_FILTER_SYN);
7639 printf("syn filter is not supported on port %u.\n",
7644 memset(&syn_filter, 0, sizeof(syn_filter));
7646 if (!strcmp(res->ops, "add")) {
7647 if (!strcmp(res->high, "high"))
7648 syn_filter.hig_pri = 1;
7650 syn_filter.hig_pri = 0;
7652 syn_filter.queue = res->queue_id;
7653 ret = rte_eth_dev_filter_ctrl(res->port_id,
7658 ret = rte_eth_dev_filter_ctrl(res->port_id,
7660 RTE_ETH_FILTER_DELETE,
7664 printf("syn filter programming error: (%s)\n",
7668 cmdline_parse_token_string_t cmd_syn_filter_filter =
7669 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7670 filter, "syn_filter");
7671 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7672 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7674 cmdline_parse_token_string_t cmd_syn_filter_ops =
7675 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7677 cmdline_parse_token_string_t cmd_syn_filter_priority =
7678 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7679 priority, "priority");
7680 cmdline_parse_token_string_t cmd_syn_filter_high =
7681 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7683 cmdline_parse_token_string_t cmd_syn_filter_queue =
7684 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7686 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7687 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7690 cmdline_parse_inst_t cmd_syn_filter = {
7691 .f = cmd_syn_filter_parsed,
7693 .help_str = "add/delete syn filter",
7695 (void *)&cmd_syn_filter_filter,
7696 (void *)&cmd_syn_filter_port_id,
7697 (void *)&cmd_syn_filter_ops,
7698 (void *)&cmd_syn_filter_priority,
7699 (void *)&cmd_syn_filter_high,
7700 (void *)&cmd_syn_filter_queue,
7701 (void *)&cmd_syn_filter_queue_id,
7706 /* *** ADD/REMOVE A 2tuple FILTER *** */
7707 struct cmd_2tuple_filter_result {
7708 cmdline_fixed_string_t filter;
7710 cmdline_fixed_string_t ops;
7711 cmdline_fixed_string_t dst_port;
7712 uint16_t dst_port_value;
7713 cmdline_fixed_string_t protocol;
7714 uint8_t protocol_value;
7715 cmdline_fixed_string_t mask;
7717 cmdline_fixed_string_t tcp_flags;
7718 uint8_t tcp_flags_value;
7719 cmdline_fixed_string_t priority;
7720 uint8_t priority_value;
7721 cmdline_fixed_string_t queue;
7726 cmd_2tuple_filter_parsed(void *parsed_result,
7727 __attribute__((unused)) struct cmdline *cl,
7728 __attribute__((unused)) void *data)
7730 struct rte_eth_ntuple_filter filter;
7731 struct cmd_2tuple_filter_result *res = parsed_result;
7734 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7736 printf("ntuple filter is not supported on port %u.\n",
7741 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7743 filter.flags = RTE_2TUPLE_FLAGS;
7744 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7745 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7746 filter.proto = res->protocol_value;
7747 filter.priority = res->priority_value;
7748 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7749 printf("nonzero tcp_flags is only meaningful"
7750 " when protocol is TCP.\n");
7753 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7754 printf("invalid TCP flags.\n");
7758 if (res->tcp_flags_value != 0) {
7759 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7760 filter.tcp_flags = res->tcp_flags_value;
7763 /* need convert to big endian. */
7764 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7765 filter.queue = res->queue_id;
7767 if (!strcmp(res->ops, "add"))
7768 ret = rte_eth_dev_filter_ctrl(res->port_id,
7769 RTE_ETH_FILTER_NTUPLE,
7773 ret = rte_eth_dev_filter_ctrl(res->port_id,
7774 RTE_ETH_FILTER_NTUPLE,
7775 RTE_ETH_FILTER_DELETE,
7778 printf("2tuple filter programming error: (%s)\n",
7783 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7784 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7785 filter, "2tuple_filter");
7786 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7787 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7789 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7790 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7792 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7793 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7794 dst_port, "dst_port");
7795 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7796 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7797 dst_port_value, UINT16);
7798 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7799 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7800 protocol, "protocol");
7801 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7802 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7803 protocol_value, UINT8);
7804 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7805 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7807 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7808 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7810 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7811 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7812 tcp_flags, "tcp_flags");
7813 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7814 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7815 tcp_flags_value, UINT8);
7816 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7817 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7818 priority, "priority");
7819 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7820 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7821 priority_value, UINT8);
7822 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7823 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7825 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7826 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7829 cmdline_parse_inst_t cmd_2tuple_filter = {
7830 .f = cmd_2tuple_filter_parsed,
7832 .help_str = "add a 2tuple filter",
7834 (void *)&cmd_2tuple_filter_filter,
7835 (void *)&cmd_2tuple_filter_port_id,
7836 (void *)&cmd_2tuple_filter_ops,
7837 (void *)&cmd_2tuple_filter_dst_port,
7838 (void *)&cmd_2tuple_filter_dst_port_value,
7839 (void *)&cmd_2tuple_filter_protocol,
7840 (void *)&cmd_2tuple_filter_protocol_value,
7841 (void *)&cmd_2tuple_filter_mask,
7842 (void *)&cmd_2tuple_filter_mask_value,
7843 (void *)&cmd_2tuple_filter_tcp_flags,
7844 (void *)&cmd_2tuple_filter_tcp_flags_value,
7845 (void *)&cmd_2tuple_filter_priority,
7846 (void *)&cmd_2tuple_filter_priority_value,
7847 (void *)&cmd_2tuple_filter_queue,
7848 (void *)&cmd_2tuple_filter_queue_id,
7853 /* *** ADD/REMOVE A 5tuple FILTER *** */
7854 struct cmd_5tuple_filter_result {
7855 cmdline_fixed_string_t filter;
7857 cmdline_fixed_string_t ops;
7858 cmdline_fixed_string_t dst_ip;
7859 cmdline_ipaddr_t dst_ip_value;
7860 cmdline_fixed_string_t src_ip;
7861 cmdline_ipaddr_t src_ip_value;
7862 cmdline_fixed_string_t dst_port;
7863 uint16_t dst_port_value;
7864 cmdline_fixed_string_t src_port;
7865 uint16_t src_port_value;
7866 cmdline_fixed_string_t protocol;
7867 uint8_t protocol_value;
7868 cmdline_fixed_string_t mask;
7870 cmdline_fixed_string_t tcp_flags;
7871 uint8_t tcp_flags_value;
7872 cmdline_fixed_string_t priority;
7873 uint8_t priority_value;
7874 cmdline_fixed_string_t queue;
7879 cmd_5tuple_filter_parsed(void *parsed_result,
7880 __attribute__((unused)) struct cmdline *cl,
7881 __attribute__((unused)) void *data)
7883 struct rte_eth_ntuple_filter filter;
7884 struct cmd_5tuple_filter_result *res = parsed_result;
7887 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7889 printf("ntuple filter is not supported on port %u.\n",
7894 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7896 filter.flags = RTE_5TUPLE_FLAGS;
7897 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7898 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7899 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7900 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7901 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7902 filter.proto = res->protocol_value;
7903 filter.priority = res->priority_value;
7904 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7905 printf("nonzero tcp_flags is only meaningful"
7906 " when protocol is TCP.\n");
7909 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7910 printf("invalid TCP flags.\n");
7914 if (res->tcp_flags_value != 0) {
7915 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7916 filter.tcp_flags = res->tcp_flags_value;
7919 if (res->dst_ip_value.family == AF_INET)
7920 /* no need to convert, already big endian. */
7921 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7923 if (filter.dst_ip_mask == 0) {
7924 printf("can not support ipv6 involved compare.\n");
7930 if (res->src_ip_value.family == AF_INET)
7931 /* no need to convert, already big endian. */
7932 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7934 if (filter.src_ip_mask == 0) {
7935 printf("can not support ipv6 involved compare.\n");
7940 /* need convert to big endian. */
7941 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7942 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7943 filter.queue = res->queue_id;
7945 if (!strcmp(res->ops, "add"))
7946 ret = rte_eth_dev_filter_ctrl(res->port_id,
7947 RTE_ETH_FILTER_NTUPLE,
7951 ret = rte_eth_dev_filter_ctrl(res->port_id,
7952 RTE_ETH_FILTER_NTUPLE,
7953 RTE_ETH_FILTER_DELETE,
7956 printf("5tuple filter programming error: (%s)\n",
7960 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7961 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7962 filter, "5tuple_filter");
7963 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7964 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7966 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7967 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7969 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7970 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7972 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7973 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7975 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7976 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7978 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7979 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7981 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7982 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7983 dst_port, "dst_port");
7984 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7985 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7986 dst_port_value, UINT16);
7987 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7988 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7989 src_port, "src_port");
7990 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7991 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7992 src_port_value, UINT16);
7993 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7994 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7995 protocol, "protocol");
7996 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7997 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7998 protocol_value, UINT8);
7999 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8000 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8002 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8003 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8005 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8006 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8007 tcp_flags, "tcp_flags");
8008 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8009 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8010 tcp_flags_value, UINT8);
8011 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8012 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8013 priority, "priority");
8014 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8015 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8016 priority_value, UINT8);
8017 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8018 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8020 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8021 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8024 cmdline_parse_inst_t cmd_5tuple_filter = {
8025 .f = cmd_5tuple_filter_parsed,
8027 .help_str = "add/del a 5tuple filter",
8029 (void *)&cmd_5tuple_filter_filter,
8030 (void *)&cmd_5tuple_filter_port_id,
8031 (void *)&cmd_5tuple_filter_ops,
8032 (void *)&cmd_5tuple_filter_dst_ip,
8033 (void *)&cmd_5tuple_filter_dst_ip_value,
8034 (void *)&cmd_5tuple_filter_src_ip,
8035 (void *)&cmd_5tuple_filter_src_ip_value,
8036 (void *)&cmd_5tuple_filter_dst_port,
8037 (void *)&cmd_5tuple_filter_dst_port_value,
8038 (void *)&cmd_5tuple_filter_src_port,
8039 (void *)&cmd_5tuple_filter_src_port_value,
8040 (void *)&cmd_5tuple_filter_protocol,
8041 (void *)&cmd_5tuple_filter_protocol_value,
8042 (void *)&cmd_5tuple_filter_mask,
8043 (void *)&cmd_5tuple_filter_mask_value,
8044 (void *)&cmd_5tuple_filter_tcp_flags,
8045 (void *)&cmd_5tuple_filter_tcp_flags_value,
8046 (void *)&cmd_5tuple_filter_priority,
8047 (void *)&cmd_5tuple_filter_priority_value,
8048 (void *)&cmd_5tuple_filter_queue,
8049 (void *)&cmd_5tuple_filter_queue_id,
8054 /* *** ADD/REMOVE A flex FILTER *** */
8055 struct cmd_flex_filter_result {
8056 cmdline_fixed_string_t filter;
8057 cmdline_fixed_string_t ops;
8059 cmdline_fixed_string_t len;
8061 cmdline_fixed_string_t bytes;
8062 cmdline_fixed_string_t bytes_value;
8063 cmdline_fixed_string_t mask;
8064 cmdline_fixed_string_t mask_value;
8065 cmdline_fixed_string_t priority;
8066 uint8_t priority_value;
8067 cmdline_fixed_string_t queue;
8071 static int xdigit2val(unsigned char c)
8076 else if (isupper(c))
8084 cmd_flex_filter_parsed(void *parsed_result,
8085 __attribute__((unused)) struct cmdline *cl,
8086 __attribute__((unused)) void *data)
8089 struct rte_eth_flex_filter filter;
8090 struct cmd_flex_filter_result *res = parsed_result;
8091 char *bytes_ptr, *mask_ptr;
8092 uint16_t len, i, j = 0;
8097 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8098 printf("the len exceed the max length 128\n");
8101 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8102 filter.len = res->len_value;
8103 filter.priority = res->priority_value;
8104 filter.queue = res->queue_id;
8105 bytes_ptr = res->bytes_value;
8106 mask_ptr = res->mask_value;
8108 /* translate bytes string to array. */
8109 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8110 (bytes_ptr[1] == 'X')))
8112 len = strnlen(bytes_ptr, res->len_value * 2);
8113 if (len == 0 || (len % 8 != 0)) {
8114 printf("please check len and bytes input\n");
8117 for (i = 0; i < len; i++) {
8119 if (isxdigit(c) == 0) {
8120 /* invalid characters. */
8121 printf("invalid input\n");
8124 val = xdigit2val(c);
8127 filter.bytes[j] = byte;
8128 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8135 /* translate mask string to uint8_t array. */
8136 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8137 (mask_ptr[1] == 'X')))
8139 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8141 printf("invalid input\n");
8146 for (i = 0; i < len; i++) {
8148 if (isxdigit(c) == 0) {
8149 /* invalid characters. */
8150 printf("invalid input\n");
8153 val = xdigit2val(c);
8156 filter.mask[j] = byte;
8157 printf("mask[%d]:%02x ", j, filter.mask[j]);
8165 if (!strcmp(res->ops, "add"))
8166 ret = rte_eth_dev_filter_ctrl(res->port_id,
8167 RTE_ETH_FILTER_FLEXIBLE,
8171 ret = rte_eth_dev_filter_ctrl(res->port_id,
8172 RTE_ETH_FILTER_FLEXIBLE,
8173 RTE_ETH_FILTER_DELETE,
8177 printf("flex filter setting error: (%s)\n", strerror(-ret));
8180 cmdline_parse_token_string_t cmd_flex_filter_filter =
8181 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8182 filter, "flex_filter");
8183 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8184 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8186 cmdline_parse_token_string_t cmd_flex_filter_ops =
8187 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8189 cmdline_parse_token_string_t cmd_flex_filter_len =
8190 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8192 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8193 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8195 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8196 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8198 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8199 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8201 cmdline_parse_token_string_t cmd_flex_filter_mask =
8202 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8204 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8205 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8207 cmdline_parse_token_string_t cmd_flex_filter_priority =
8208 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8209 priority, "priority");
8210 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8211 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8212 priority_value, UINT8);
8213 cmdline_parse_token_string_t cmd_flex_filter_queue =
8214 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8216 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8217 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8219 cmdline_parse_inst_t cmd_flex_filter = {
8220 .f = cmd_flex_filter_parsed,
8222 .help_str = "add/del a flex filter",
8224 (void *)&cmd_flex_filter_filter,
8225 (void *)&cmd_flex_filter_port_id,
8226 (void *)&cmd_flex_filter_ops,
8227 (void *)&cmd_flex_filter_len,
8228 (void *)&cmd_flex_filter_len_value,
8229 (void *)&cmd_flex_filter_bytes,
8230 (void *)&cmd_flex_filter_bytes_value,
8231 (void *)&cmd_flex_filter_mask,
8232 (void *)&cmd_flex_filter_mask_value,
8233 (void *)&cmd_flex_filter_priority,
8234 (void *)&cmd_flex_filter_priority_value,
8235 (void *)&cmd_flex_filter_queue,
8236 (void *)&cmd_flex_filter_queue_id,
8241 /* *** Filters Control *** */
8243 /* *** deal with ethertype filter *** */
8244 struct cmd_ethertype_filter_result {
8245 cmdline_fixed_string_t filter;
8247 cmdline_fixed_string_t ops;
8248 cmdline_fixed_string_t mac;
8249 struct ether_addr mac_addr;
8250 cmdline_fixed_string_t ethertype;
8251 uint16_t ethertype_value;
8252 cmdline_fixed_string_t drop;
8253 cmdline_fixed_string_t queue;
8257 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8258 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8259 filter, "ethertype_filter");
8260 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8261 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8263 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8264 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8266 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8267 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8268 mac, "mac_addr#mac_ignr");
8269 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8270 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8272 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8273 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8274 ethertype, "ethertype");
8275 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8276 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8277 ethertype_value, UINT16);
8278 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8279 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8281 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8282 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8284 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8285 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8289 cmd_ethertype_filter_parsed(void *parsed_result,
8290 __attribute__((unused)) struct cmdline *cl,
8291 __attribute__((unused)) void *data)
8293 struct cmd_ethertype_filter_result *res = parsed_result;
8294 struct rte_eth_ethertype_filter filter;
8297 ret = rte_eth_dev_filter_supported(res->port_id,
8298 RTE_ETH_FILTER_ETHERTYPE);
8300 printf("ethertype filter is not supported on port %u.\n",
8305 memset(&filter, 0, sizeof(filter));
8306 if (!strcmp(res->mac, "mac_addr")) {
8307 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8308 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8309 sizeof(struct ether_addr));
8311 if (!strcmp(res->drop, "drop"))
8312 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8313 filter.ether_type = res->ethertype_value;
8314 filter.queue = res->queue_id;
8316 if (!strcmp(res->ops, "add"))
8317 ret = rte_eth_dev_filter_ctrl(res->port_id,
8318 RTE_ETH_FILTER_ETHERTYPE,
8322 ret = rte_eth_dev_filter_ctrl(res->port_id,
8323 RTE_ETH_FILTER_ETHERTYPE,
8324 RTE_ETH_FILTER_DELETE,
8327 printf("ethertype filter programming error: (%s)\n",
8331 cmdline_parse_inst_t cmd_ethertype_filter = {
8332 .f = cmd_ethertype_filter_parsed,
8334 .help_str = "add or delete an ethertype filter entry",
8336 (void *)&cmd_ethertype_filter_filter,
8337 (void *)&cmd_ethertype_filter_port_id,
8338 (void *)&cmd_ethertype_filter_ops,
8339 (void *)&cmd_ethertype_filter_mac,
8340 (void *)&cmd_ethertype_filter_mac_addr,
8341 (void *)&cmd_ethertype_filter_ethertype,
8342 (void *)&cmd_ethertype_filter_ethertype_value,
8343 (void *)&cmd_ethertype_filter_drop,
8344 (void *)&cmd_ethertype_filter_queue,
8345 (void *)&cmd_ethertype_filter_queue_id,
8350 /* *** deal with flow director filter *** */
8351 struct cmd_flow_director_result {
8352 cmdline_fixed_string_t flow_director_filter;
8354 cmdline_fixed_string_t mode;
8355 cmdline_fixed_string_t mode_value;
8356 cmdline_fixed_string_t ops;
8357 cmdline_fixed_string_t flow;
8358 cmdline_fixed_string_t flow_type;
8359 cmdline_fixed_string_t ether;
8360 uint16_t ether_type;
8361 cmdline_fixed_string_t src;
8362 cmdline_ipaddr_t ip_src;
8364 cmdline_fixed_string_t dst;
8365 cmdline_ipaddr_t ip_dst;
8367 cmdline_fixed_string_t verify_tag;
8368 uint32_t verify_tag_value;
8369 cmdline_fixed_string_t tos;
8371 cmdline_fixed_string_t proto;
8372 uint8_t proto_value;
8373 cmdline_fixed_string_t ttl;
8375 cmdline_fixed_string_t vlan;
8376 uint16_t vlan_value;
8377 cmdline_fixed_string_t flexbytes;
8378 cmdline_fixed_string_t flexbytes_value;
8379 cmdline_fixed_string_t pf_vf;
8380 cmdline_fixed_string_t drop;
8381 cmdline_fixed_string_t queue;
8383 cmdline_fixed_string_t fd_id;
8384 uint32_t fd_id_value;
8385 cmdline_fixed_string_t mac;
8386 struct ether_addr mac_addr;
8387 cmdline_fixed_string_t tunnel;
8388 cmdline_fixed_string_t tunnel_type;
8389 cmdline_fixed_string_t tunnel_id;
8390 uint32_t tunnel_id_value;
8394 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8397 const char *p, *p0 = q_arg;
8399 unsigned long int_fld;
8400 char *str_fld[max_num];
8405 p = strchr(p0, '(');
8409 p0 = strchr(p, ')');
8414 if (size >= sizeof(s))
8417 snprintf(s, sizeof(s), "%.*s", size, p);
8418 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8419 if (ret < 0 || ret > max_num)
8421 for (i = 0; i < ret; i++) {
8423 int_fld = strtoul(str_fld[i], &end, 0);
8424 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8426 flexbytes[i] = (uint8_t)int_fld;
8432 str2flowtype(char *string)
8435 static const struct {
8438 } flowtype_str[] = {
8439 {"raw", RTE_ETH_FLOW_RAW},
8440 {"ipv4", RTE_ETH_FLOW_IPV4},
8441 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8442 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8443 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8444 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8445 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8446 {"ipv6", RTE_ETH_FLOW_IPV6},
8447 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8448 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8449 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8450 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8451 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8452 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8455 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8456 if (!strcmp(flowtype_str[i].str, string))
8457 return flowtype_str[i].type;
8459 return RTE_ETH_FLOW_UNKNOWN;
8462 static enum rte_eth_fdir_tunnel_type
8463 str2fdir_tunneltype(char *string)
8467 static const struct {
8469 enum rte_eth_fdir_tunnel_type type;
8470 } tunneltype_str[] = {
8471 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8472 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8475 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8476 if (!strcmp(tunneltype_str[i].str, string))
8477 return tunneltype_str[i].type;
8479 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8482 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8484 if ((ip_addr).family == AF_INET) \
8485 (ip) = (ip_addr).addr.ipv4.s_addr; \
8487 printf("invalid parameter.\n"); \
8492 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8494 if ((ip_addr).family == AF_INET6) \
8495 (void)rte_memcpy(&(ip), \
8496 &((ip_addr).addr.ipv6), \
8497 sizeof(struct in6_addr)); \
8499 printf("invalid parameter.\n"); \
8505 cmd_flow_director_filter_parsed(void *parsed_result,
8506 __attribute__((unused)) struct cmdline *cl,
8507 __attribute__((unused)) void *data)
8509 struct cmd_flow_director_result *res = parsed_result;
8510 struct rte_eth_fdir_filter entry;
8511 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8513 unsigned long vf_id;
8516 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8518 printf("flow director is not supported on port %u.\n",
8522 memset(flexbytes, 0, sizeof(flexbytes));
8523 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8525 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8526 if (strcmp(res->mode_value, "MAC-VLAN")) {
8527 printf("Please set mode to MAC-VLAN.\n");
8530 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8531 if (strcmp(res->mode_value, "Tunnel")) {
8532 printf("Please set mode to Tunnel.\n");
8536 if (strcmp(res->mode_value, "IP")) {
8537 printf("Please set mode to IP.\n");
8540 entry.input.flow_type = str2flowtype(res->flow_type);
8543 ret = parse_flexbytes(res->flexbytes_value,
8545 RTE_ETH_FDIR_MAX_FLEXLEN);
8547 printf("error: Cannot parse flexbytes input.\n");
8551 switch (entry.input.flow_type) {
8552 case RTE_ETH_FLOW_FRAG_IPV4:
8553 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8554 entry.input.flow.ip4_flow.proto = res->proto_value;
8555 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8556 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8557 IPV4_ADDR_TO_UINT(res->ip_dst,
8558 entry.input.flow.ip4_flow.dst_ip);
8559 IPV4_ADDR_TO_UINT(res->ip_src,
8560 entry.input.flow.ip4_flow.src_ip);
8561 entry.input.flow.ip4_flow.tos = res->tos_value;
8562 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8563 /* need convert to big endian. */
8564 entry.input.flow.udp4_flow.dst_port =
8565 rte_cpu_to_be_16(res->port_dst);
8566 entry.input.flow.udp4_flow.src_port =
8567 rte_cpu_to_be_16(res->port_src);
8569 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8570 IPV4_ADDR_TO_UINT(res->ip_dst,
8571 entry.input.flow.sctp4_flow.ip.dst_ip);
8572 IPV4_ADDR_TO_UINT(res->ip_src,
8573 entry.input.flow.sctp4_flow.ip.src_ip);
8574 entry.input.flow.ip4_flow.tos = res->tos_value;
8575 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8576 /* need convert to big endian. */
8577 entry.input.flow.sctp4_flow.dst_port =
8578 rte_cpu_to_be_16(res->port_dst);
8579 entry.input.flow.sctp4_flow.src_port =
8580 rte_cpu_to_be_16(res->port_src);
8581 entry.input.flow.sctp4_flow.verify_tag =
8582 rte_cpu_to_be_32(res->verify_tag_value);
8584 case RTE_ETH_FLOW_FRAG_IPV6:
8585 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8586 entry.input.flow.ipv6_flow.proto = res->proto_value;
8587 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8588 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8589 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8590 entry.input.flow.ipv6_flow.dst_ip);
8591 IPV6_ADDR_TO_ARRAY(res->ip_src,
8592 entry.input.flow.ipv6_flow.src_ip);
8593 entry.input.flow.ipv6_flow.tc = res->tos_value;
8594 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8595 /* need convert to big endian. */
8596 entry.input.flow.udp6_flow.dst_port =
8597 rte_cpu_to_be_16(res->port_dst);
8598 entry.input.flow.udp6_flow.src_port =
8599 rte_cpu_to_be_16(res->port_src);
8601 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8602 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8603 entry.input.flow.sctp6_flow.ip.dst_ip);
8604 IPV6_ADDR_TO_ARRAY(res->ip_src,
8605 entry.input.flow.sctp6_flow.ip.src_ip);
8606 entry.input.flow.ipv6_flow.tc = res->tos_value;
8607 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8608 /* need convert to big endian. */
8609 entry.input.flow.sctp6_flow.dst_port =
8610 rte_cpu_to_be_16(res->port_dst);
8611 entry.input.flow.sctp6_flow.src_port =
8612 rte_cpu_to_be_16(res->port_src);
8613 entry.input.flow.sctp6_flow.verify_tag =
8614 rte_cpu_to_be_32(res->verify_tag_value);
8616 case RTE_ETH_FLOW_L2_PAYLOAD:
8617 entry.input.flow.l2_flow.ether_type =
8618 rte_cpu_to_be_16(res->ether_type);
8624 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8625 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8627 sizeof(struct ether_addr));
8629 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8630 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8632 sizeof(struct ether_addr));
8633 entry.input.flow.tunnel_flow.tunnel_type =
8634 str2fdir_tunneltype(res->tunnel_type);
8635 entry.input.flow.tunnel_flow.tunnel_id =
8636 rte_cpu_to_be_32(res->tunnel_id_value);
8639 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8641 RTE_ETH_FDIR_MAX_FLEXLEN);
8643 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8645 entry.action.flex_off = 0; /*use 0 by default */
8646 if (!strcmp(res->drop, "drop"))
8647 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8649 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8651 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8652 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8653 if (!strcmp(res->pf_vf, "pf"))
8654 entry.input.flow_ext.is_vf = 0;
8655 else if (!strncmp(res->pf_vf, "vf", 2)) {
8656 struct rte_eth_dev_info dev_info;
8658 memset(&dev_info, 0, sizeof(dev_info));
8659 rte_eth_dev_info_get(res->port_id, &dev_info);
8661 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8662 if (errno != 0 || *end != '\0' ||
8663 vf_id >= dev_info.max_vfs) {
8664 printf("invalid parameter %s.\n", res->pf_vf);
8667 entry.input.flow_ext.is_vf = 1;
8668 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8670 printf("invalid parameter %s.\n", res->pf_vf);
8675 /* set to report FD ID by default */
8676 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8677 entry.action.rx_queue = res->queue_id;
8678 entry.soft_id = res->fd_id_value;
8679 if (!strcmp(res->ops, "add"))
8680 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8681 RTE_ETH_FILTER_ADD, &entry);
8682 else if (!strcmp(res->ops, "del"))
8683 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8684 RTE_ETH_FILTER_DELETE, &entry);
8686 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8687 RTE_ETH_FILTER_UPDATE, &entry);
8689 printf("flow director programming error: (%s)\n",
8693 cmdline_parse_token_string_t cmd_flow_director_filter =
8694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8695 flow_director_filter, "flow_director_filter");
8696 cmdline_parse_token_num_t cmd_flow_director_port_id =
8697 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8699 cmdline_parse_token_string_t cmd_flow_director_ops =
8700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8701 ops, "add#del#update");
8702 cmdline_parse_token_string_t cmd_flow_director_flow =
8703 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8705 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8706 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8707 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8708 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8709 cmdline_parse_token_string_t cmd_flow_director_ether =
8710 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8712 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8713 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8714 ether_type, UINT16);
8715 cmdline_parse_token_string_t cmd_flow_director_src =
8716 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8718 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8719 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8721 cmdline_parse_token_num_t cmd_flow_director_port_src =
8722 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8724 cmdline_parse_token_string_t cmd_flow_director_dst =
8725 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8727 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8728 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8730 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8731 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8733 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8734 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8735 verify_tag, "verify_tag");
8736 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8737 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8738 verify_tag_value, UINT32);
8739 cmdline_parse_token_string_t cmd_flow_director_tos =
8740 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8742 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8743 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8745 cmdline_parse_token_string_t cmd_flow_director_proto =
8746 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8748 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8749 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8750 proto_value, UINT8);
8751 cmdline_parse_token_string_t cmd_flow_director_ttl =
8752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8754 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8755 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8757 cmdline_parse_token_string_t cmd_flow_director_vlan =
8758 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8760 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8761 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8762 vlan_value, UINT16);
8763 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8764 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8765 flexbytes, "flexbytes");
8766 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8768 flexbytes_value, NULL);
8769 cmdline_parse_token_string_t cmd_flow_director_drop =
8770 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8772 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8775 cmdline_parse_token_string_t cmd_flow_director_queue =
8776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8778 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8779 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8781 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8784 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8785 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8786 fd_id_value, UINT32);
8788 cmdline_parse_token_string_t cmd_flow_director_mode =
8789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8791 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8794 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8796 mode_value, "MAC-VLAN");
8797 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8799 mode_value, "Tunnel");
8800 cmdline_parse_token_string_t cmd_flow_director_mac =
8801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8803 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8804 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8806 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8807 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8809 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8811 tunnel_type, "NVGRE#VxLAN");
8812 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8814 tunnel_id, "tunnel-id");
8815 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8817 tunnel_id_value, UINT32);
8819 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8820 .f = cmd_flow_director_filter_parsed,
8822 .help_str = "add or delete an ip flow director entry on NIC",
8824 (void *)&cmd_flow_director_filter,
8825 (void *)&cmd_flow_director_port_id,
8826 (void *)&cmd_flow_director_mode,
8827 (void *)&cmd_flow_director_mode_ip,
8828 (void *)&cmd_flow_director_ops,
8829 (void *)&cmd_flow_director_flow,
8830 (void *)&cmd_flow_director_flow_type,
8831 (void *)&cmd_flow_director_src,
8832 (void *)&cmd_flow_director_ip_src,
8833 (void *)&cmd_flow_director_dst,
8834 (void *)&cmd_flow_director_ip_dst,
8835 (void *)&cmd_flow_director_tos,
8836 (void *)&cmd_flow_director_tos_value,
8837 (void *)&cmd_flow_director_proto,
8838 (void *)&cmd_flow_director_proto_value,
8839 (void *)&cmd_flow_director_ttl,
8840 (void *)&cmd_flow_director_ttl_value,
8841 (void *)&cmd_flow_director_vlan,
8842 (void *)&cmd_flow_director_vlan_value,
8843 (void *)&cmd_flow_director_flexbytes,
8844 (void *)&cmd_flow_director_flexbytes_value,
8845 (void *)&cmd_flow_director_drop,
8846 (void *)&cmd_flow_director_pf_vf,
8847 (void *)&cmd_flow_director_queue,
8848 (void *)&cmd_flow_director_queue_id,
8849 (void *)&cmd_flow_director_fd_id,
8850 (void *)&cmd_flow_director_fd_id_value,
8855 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8856 .f = cmd_flow_director_filter_parsed,
8858 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8860 (void *)&cmd_flow_director_filter,
8861 (void *)&cmd_flow_director_port_id,
8862 (void *)&cmd_flow_director_mode,
8863 (void *)&cmd_flow_director_mode_ip,
8864 (void *)&cmd_flow_director_ops,
8865 (void *)&cmd_flow_director_flow,
8866 (void *)&cmd_flow_director_flow_type,
8867 (void *)&cmd_flow_director_src,
8868 (void *)&cmd_flow_director_ip_src,
8869 (void *)&cmd_flow_director_port_src,
8870 (void *)&cmd_flow_director_dst,
8871 (void *)&cmd_flow_director_ip_dst,
8872 (void *)&cmd_flow_director_port_dst,
8873 (void *)&cmd_flow_director_tos,
8874 (void *)&cmd_flow_director_tos_value,
8875 (void *)&cmd_flow_director_ttl,
8876 (void *)&cmd_flow_director_ttl_value,
8877 (void *)&cmd_flow_director_vlan,
8878 (void *)&cmd_flow_director_vlan_value,
8879 (void *)&cmd_flow_director_flexbytes,
8880 (void *)&cmd_flow_director_flexbytes_value,
8881 (void *)&cmd_flow_director_drop,
8882 (void *)&cmd_flow_director_pf_vf,
8883 (void *)&cmd_flow_director_queue,
8884 (void *)&cmd_flow_director_queue_id,
8885 (void *)&cmd_flow_director_fd_id,
8886 (void *)&cmd_flow_director_fd_id_value,
8891 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8892 .f = cmd_flow_director_filter_parsed,
8894 .help_str = "add or delete a sctp flow director entry on NIC",
8896 (void *)&cmd_flow_director_filter,
8897 (void *)&cmd_flow_director_port_id,
8898 (void *)&cmd_flow_director_mode,
8899 (void *)&cmd_flow_director_mode_ip,
8900 (void *)&cmd_flow_director_ops,
8901 (void *)&cmd_flow_director_flow,
8902 (void *)&cmd_flow_director_flow_type,
8903 (void *)&cmd_flow_director_src,
8904 (void *)&cmd_flow_director_ip_src,
8905 (void *)&cmd_flow_director_port_src,
8906 (void *)&cmd_flow_director_dst,
8907 (void *)&cmd_flow_director_ip_dst,
8908 (void *)&cmd_flow_director_port_dst,
8909 (void *)&cmd_flow_director_verify_tag,
8910 (void *)&cmd_flow_director_verify_tag_value,
8911 (void *)&cmd_flow_director_tos,
8912 (void *)&cmd_flow_director_tos_value,
8913 (void *)&cmd_flow_director_ttl,
8914 (void *)&cmd_flow_director_ttl_value,
8915 (void *)&cmd_flow_director_vlan,
8916 (void *)&cmd_flow_director_vlan_value,
8917 (void *)&cmd_flow_director_flexbytes,
8918 (void *)&cmd_flow_director_flexbytes_value,
8919 (void *)&cmd_flow_director_drop,
8920 (void *)&cmd_flow_director_pf_vf,
8921 (void *)&cmd_flow_director_queue,
8922 (void *)&cmd_flow_director_queue_id,
8923 (void *)&cmd_flow_director_fd_id,
8924 (void *)&cmd_flow_director_fd_id_value,
8929 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8930 .f = cmd_flow_director_filter_parsed,
8932 .help_str = "add or delete a L2 flow director entry on NIC",
8934 (void *)&cmd_flow_director_filter,
8935 (void *)&cmd_flow_director_port_id,
8936 (void *)&cmd_flow_director_mode,
8937 (void *)&cmd_flow_director_mode_ip,
8938 (void *)&cmd_flow_director_ops,
8939 (void *)&cmd_flow_director_flow,
8940 (void *)&cmd_flow_director_flow_type,
8941 (void *)&cmd_flow_director_ether,
8942 (void *)&cmd_flow_director_ether_type,
8943 (void *)&cmd_flow_director_flexbytes,
8944 (void *)&cmd_flow_director_flexbytes_value,
8945 (void *)&cmd_flow_director_drop,
8946 (void *)&cmd_flow_director_pf_vf,
8947 (void *)&cmd_flow_director_queue,
8948 (void *)&cmd_flow_director_queue_id,
8949 (void *)&cmd_flow_director_fd_id,
8950 (void *)&cmd_flow_director_fd_id_value,
8955 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8956 .f = cmd_flow_director_filter_parsed,
8958 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8960 (void *)&cmd_flow_director_filter,
8961 (void *)&cmd_flow_director_port_id,
8962 (void *)&cmd_flow_director_mode,
8963 (void *)&cmd_flow_director_mode_mac_vlan,
8964 (void *)&cmd_flow_director_ops,
8965 (void *)&cmd_flow_director_mac,
8966 (void *)&cmd_flow_director_mac_addr,
8967 (void *)&cmd_flow_director_vlan,
8968 (void *)&cmd_flow_director_vlan_value,
8969 (void *)&cmd_flow_director_flexbytes,
8970 (void *)&cmd_flow_director_flexbytes_value,
8971 (void *)&cmd_flow_director_drop,
8972 (void *)&cmd_flow_director_queue,
8973 (void *)&cmd_flow_director_queue_id,
8974 (void *)&cmd_flow_director_fd_id,
8975 (void *)&cmd_flow_director_fd_id_value,
8980 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8981 .f = cmd_flow_director_filter_parsed,
8983 .help_str = "add or delete a tunnel flow director entry on NIC",
8985 (void *)&cmd_flow_director_filter,
8986 (void *)&cmd_flow_director_port_id,
8987 (void *)&cmd_flow_director_mode,
8988 (void *)&cmd_flow_director_mode_tunnel,
8989 (void *)&cmd_flow_director_ops,
8990 (void *)&cmd_flow_director_mac,
8991 (void *)&cmd_flow_director_mac_addr,
8992 (void *)&cmd_flow_director_vlan,
8993 (void *)&cmd_flow_director_vlan_value,
8994 (void *)&cmd_flow_director_tunnel,
8995 (void *)&cmd_flow_director_tunnel_type,
8996 (void *)&cmd_flow_director_tunnel_id,
8997 (void *)&cmd_flow_director_tunnel_id_value,
8998 (void *)&cmd_flow_director_flexbytes,
8999 (void *)&cmd_flow_director_flexbytes_value,
9000 (void *)&cmd_flow_director_drop,
9001 (void *)&cmd_flow_director_queue,
9002 (void *)&cmd_flow_director_queue_id,
9003 (void *)&cmd_flow_director_fd_id,
9004 (void *)&cmd_flow_director_fd_id_value,
9009 struct cmd_flush_flow_director_result {
9010 cmdline_fixed_string_t flush_flow_director;
9014 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9015 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9016 flush_flow_director, "flush_flow_director");
9017 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9018 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9022 cmd_flush_flow_director_parsed(void *parsed_result,
9023 __attribute__((unused)) struct cmdline *cl,
9024 __attribute__((unused)) void *data)
9026 struct cmd_flow_director_result *res = parsed_result;
9029 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9031 printf("flow director is not supported on port %u.\n",
9036 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9037 RTE_ETH_FILTER_FLUSH, NULL);
9039 printf("flow director table flushing error: (%s)\n",
9043 cmdline_parse_inst_t cmd_flush_flow_director = {
9044 .f = cmd_flush_flow_director_parsed,
9046 .help_str = "flush all flow director entries of a device on NIC",
9048 (void *)&cmd_flush_flow_director_flush,
9049 (void *)&cmd_flush_flow_director_port_id,
9054 /* *** deal with flow director mask *** */
9055 struct cmd_flow_director_mask_result {
9056 cmdline_fixed_string_t flow_director_mask;
9058 cmdline_fixed_string_t mode;
9059 cmdline_fixed_string_t mode_value;
9060 cmdline_fixed_string_t vlan;
9062 cmdline_fixed_string_t src_mask;
9063 cmdline_ipaddr_t ipv4_src;
9064 cmdline_ipaddr_t ipv6_src;
9066 cmdline_fixed_string_t dst_mask;
9067 cmdline_ipaddr_t ipv4_dst;
9068 cmdline_ipaddr_t ipv6_dst;
9070 cmdline_fixed_string_t mac;
9071 uint8_t mac_addr_byte_mask;
9072 cmdline_fixed_string_t tunnel_id;
9073 uint32_t tunnel_id_mask;
9074 cmdline_fixed_string_t tunnel_type;
9075 uint8_t tunnel_type_mask;
9079 cmd_flow_director_mask_parsed(void *parsed_result,
9080 __attribute__((unused)) struct cmdline *cl,
9081 __attribute__((unused)) void *data)
9083 struct cmd_flow_director_mask_result *res = parsed_result;
9084 struct rte_eth_fdir_masks *mask;
9085 struct rte_port *port;
9087 if (res->port_id > nb_ports) {
9088 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9092 port = &ports[res->port_id];
9093 /** Check if the port is not started **/
9094 if (port->port_status != RTE_PORT_STOPPED) {
9095 printf("Please stop port %d first\n", res->port_id);
9099 mask = &port->dev_conf.fdir_conf.mask;
9101 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9102 if (strcmp(res->mode_value, "MAC-VLAN")) {
9103 printf("Please set mode to MAC-VLAN.\n");
9107 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9108 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9109 if (strcmp(res->mode_value, "Tunnel")) {
9110 printf("Please set mode to Tunnel.\n");
9114 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9115 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9116 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9117 mask->tunnel_type_mask = res->tunnel_type_mask;
9119 if (strcmp(res->mode_value, "IP")) {
9120 printf("Please set mode to IP.\n");
9124 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9125 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9126 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9127 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9128 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9129 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9130 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9133 cmd_reconfig_device_queue(res->port_id, 1, 1);
9136 cmdline_parse_token_string_t cmd_flow_director_mask =
9137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9138 flow_director_mask, "flow_director_mask");
9139 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9140 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9142 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9145 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9148 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9150 src_mask, "src_mask");
9151 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9152 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9154 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9155 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9157 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9158 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9160 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9161 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9162 dst_mask, "dst_mask");
9163 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9164 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9166 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9167 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9169 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9170 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9173 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9174 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9176 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9179 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9181 mode_value, "MAC-VLAN");
9182 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9184 mode_value, "Tunnel");
9185 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9188 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9189 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9190 mac_addr_byte_mask, UINT8);
9191 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9192 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9193 tunnel_type, "tunnel-type");
9194 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9195 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9196 tunnel_type_mask, UINT8);
9197 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9198 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9199 tunnel_id, "tunnel-id");
9200 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9201 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9202 tunnel_id_mask, UINT32);
9204 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9205 .f = cmd_flow_director_mask_parsed,
9207 .help_str = "set IP mode flow director's mask on NIC",
9209 (void *)&cmd_flow_director_mask,
9210 (void *)&cmd_flow_director_mask_port_id,
9211 (void *)&cmd_flow_director_mask_mode,
9212 (void *)&cmd_flow_director_mask_mode_ip,
9213 (void *)&cmd_flow_director_mask_vlan,
9214 (void *)&cmd_flow_director_mask_vlan_value,
9215 (void *)&cmd_flow_director_mask_src,
9216 (void *)&cmd_flow_director_mask_ipv4_src,
9217 (void *)&cmd_flow_director_mask_ipv6_src,
9218 (void *)&cmd_flow_director_mask_port_src,
9219 (void *)&cmd_flow_director_mask_dst,
9220 (void *)&cmd_flow_director_mask_ipv4_dst,
9221 (void *)&cmd_flow_director_mask_ipv6_dst,
9222 (void *)&cmd_flow_director_mask_port_dst,
9227 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9228 .f = cmd_flow_director_mask_parsed,
9230 .help_str = "set MAC VLAN mode flow director's mask on NIC",
9232 (void *)&cmd_flow_director_mask,
9233 (void *)&cmd_flow_director_mask_port_id,
9234 (void *)&cmd_flow_director_mask_mode,
9235 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9236 (void *)&cmd_flow_director_mask_vlan,
9237 (void *)&cmd_flow_director_mask_vlan_value,
9242 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9243 .f = cmd_flow_director_mask_parsed,
9245 .help_str = "set tunnel mode flow director's mask on NIC",
9247 (void *)&cmd_flow_director_mask,
9248 (void *)&cmd_flow_director_mask_port_id,
9249 (void *)&cmd_flow_director_mask_mode,
9250 (void *)&cmd_flow_director_mask_mode_tunnel,
9251 (void *)&cmd_flow_director_mask_vlan,
9252 (void *)&cmd_flow_director_mask_vlan_value,
9253 (void *)&cmd_flow_director_mask_mac,
9254 (void *)&cmd_flow_director_mask_mac_value,
9255 (void *)&cmd_flow_director_mask_tunnel_type,
9256 (void *)&cmd_flow_director_mask_tunnel_type_value,
9257 (void *)&cmd_flow_director_mask_tunnel_id,
9258 (void *)&cmd_flow_director_mask_tunnel_id_value,
9263 /* *** deal with flow director mask on flexible payload *** */
9264 struct cmd_flow_director_flex_mask_result {
9265 cmdline_fixed_string_t flow_director_flexmask;
9267 cmdline_fixed_string_t flow;
9268 cmdline_fixed_string_t flow_type;
9269 cmdline_fixed_string_t mask;
9273 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9274 __attribute__((unused)) struct cmdline *cl,
9275 __attribute__((unused)) void *data)
9277 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9278 struct rte_eth_fdir_info fdir_info;
9279 struct rte_eth_fdir_flex_mask flex_mask;
9280 struct rte_port *port;
9281 uint32_t flow_type_mask;
9285 if (res->port_id > nb_ports) {
9286 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9290 port = &ports[res->port_id];
9291 /** Check if the port is not started **/
9292 if (port->port_status != RTE_PORT_STOPPED) {
9293 printf("Please stop port %d first\n", res->port_id);
9297 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9298 ret = parse_flexbytes(res->mask,
9300 RTE_ETH_FDIR_MAX_FLEXLEN);
9302 printf("error: Cannot parse mask input.\n");
9306 memset(&fdir_info, 0, sizeof(fdir_info));
9307 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9308 RTE_ETH_FILTER_INFO, &fdir_info);
9310 printf("Cannot get FDir filter info\n");
9314 if (!strcmp(res->flow_type, "none")) {
9315 /* means don't specify the flow type */
9316 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9317 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9318 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9319 0, sizeof(struct rte_eth_fdir_flex_mask));
9320 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9321 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9323 sizeof(struct rte_eth_fdir_flex_mask));
9324 cmd_reconfig_device_queue(res->port_id, 1, 1);
9327 flow_type_mask = fdir_info.flow_types_mask[0];
9328 if (!strcmp(res->flow_type, "all")) {
9329 if (!flow_type_mask) {
9330 printf("No flow type supported\n");
9333 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9334 if (flow_type_mask & (1 << i)) {
9335 flex_mask.flow_type = i;
9336 fdir_set_flex_mask(res->port_id, &flex_mask);
9339 cmd_reconfig_device_queue(res->port_id, 1, 1);
9342 flex_mask.flow_type = str2flowtype(res->flow_type);
9343 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9344 printf("Flow type %s not supported on port %d\n",
9345 res->flow_type, res->port_id);
9348 fdir_set_flex_mask(res->port_id, &flex_mask);
9349 cmd_reconfig_device_queue(res->port_id, 1, 1);
9352 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9354 flow_director_flexmask,
9355 "flow_director_flex_mask");
9356 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9357 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9359 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9362 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9364 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9365 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9366 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9370 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9371 .f = cmd_flow_director_flex_mask_parsed,
9373 .help_str = "set flow director's flex mask on NIC",
9375 (void *)&cmd_flow_director_flexmask,
9376 (void *)&cmd_flow_director_flexmask_port_id,
9377 (void *)&cmd_flow_director_flexmask_flow,
9378 (void *)&cmd_flow_director_flexmask_flow_type,
9379 (void *)&cmd_flow_director_flexmask_mask,
9384 /* *** deal with flow director flexible payload configuration *** */
9385 struct cmd_flow_director_flexpayload_result {
9386 cmdline_fixed_string_t flow_director_flexpayload;
9388 cmdline_fixed_string_t payload_layer;
9389 cmdline_fixed_string_t payload_cfg;
9393 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9396 const char *p, *p0 = q_arg;
9398 unsigned long int_fld;
9399 char *str_fld[max_num];
9404 p = strchr(p0, '(');
9408 p0 = strchr(p, ')');
9413 if (size >= sizeof(s))
9416 snprintf(s, sizeof(s), "%.*s", size, p);
9417 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9418 if (ret < 0 || ret > max_num)
9420 for (i = 0; i < ret; i++) {
9422 int_fld = strtoul(str_fld[i], &end, 0);
9423 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9425 offsets[i] = (uint16_t)int_fld;
9431 cmd_flow_director_flxpld_parsed(void *parsed_result,
9432 __attribute__((unused)) struct cmdline *cl,
9433 __attribute__((unused)) void *data)
9435 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9436 struct rte_eth_flex_payload_cfg flex_cfg;
9437 struct rte_port *port;
9440 if (res->port_id > nb_ports) {
9441 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9445 port = &ports[res->port_id];
9446 /** Check if the port is not started **/
9447 if (port->port_status != RTE_PORT_STOPPED) {
9448 printf("Please stop port %d first\n", res->port_id);
9452 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9454 if (!strcmp(res->payload_layer, "raw"))
9455 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9456 else if (!strcmp(res->payload_layer, "l2"))
9457 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9458 else if (!strcmp(res->payload_layer, "l3"))
9459 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9460 else if (!strcmp(res->payload_layer, "l4"))
9461 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9463 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9464 RTE_ETH_FDIR_MAX_FLEXLEN);
9466 printf("error: Cannot parse flex payload input.\n");
9470 fdir_set_flex_payload(res->port_id, &flex_cfg);
9471 cmd_reconfig_device_queue(res->port_id, 1, 1);
9474 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9476 flow_director_flexpayload,
9477 "flow_director_flex_payload");
9478 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9479 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9481 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9483 payload_layer, "raw#l2#l3#l4");
9484 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9488 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9489 .f = cmd_flow_director_flxpld_parsed,
9491 .help_str = "set flow director's flex payload on NIC",
9493 (void *)&cmd_flow_director_flexpayload,
9494 (void *)&cmd_flow_director_flexpayload_port_id,
9495 (void *)&cmd_flow_director_flexpayload_payload_layer,
9496 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9501 /* *** Classification Filters Control *** */
9502 /* *** Get symmetric hash enable per port *** */
9503 struct cmd_get_sym_hash_ena_per_port_result {
9504 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9509 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9510 __rte_unused struct cmdline *cl,
9511 __rte_unused void *data)
9513 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9514 struct rte_eth_hash_filter_info info;
9517 if (rte_eth_dev_filter_supported(res->port_id,
9518 RTE_ETH_FILTER_HASH) < 0) {
9519 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9524 memset(&info, 0, sizeof(info));
9525 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9526 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9527 RTE_ETH_FILTER_GET, &info);
9530 printf("Cannot get symmetric hash enable per port "
9531 "on port %u\n", res->port_id);
9535 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9536 "enabled" : "disabled", res->port_id);
9539 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9540 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9541 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9542 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9543 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9546 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9547 .f = cmd_get_sym_hash_per_port_parsed,
9549 .help_str = "get_sym_hash_ena_per_port port_id",
9551 (void *)&cmd_get_sym_hash_ena_per_port_all,
9552 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9557 /* *** Set symmetric hash enable per port *** */
9558 struct cmd_set_sym_hash_ena_per_port_result {
9559 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9560 cmdline_fixed_string_t enable;
9565 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9566 __rte_unused struct cmdline *cl,
9567 __rte_unused void *data)
9569 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9570 struct rte_eth_hash_filter_info info;
9573 if (rte_eth_dev_filter_supported(res->port_id,
9574 RTE_ETH_FILTER_HASH) < 0) {
9575 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9580 memset(&info, 0, sizeof(info));
9581 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9582 if (!strcmp(res->enable, "enable"))
9583 info.info.enable = 1;
9584 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9585 RTE_ETH_FILTER_SET, &info);
9587 printf("Cannot set symmetric hash enable per port on "
9588 "port %u\n", res->port_id);
9591 printf("Symmetric hash has been set to %s on port %u\n",
9592 res->enable, res->port_id);
9595 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9596 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9597 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9598 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9599 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9601 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9602 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9603 enable, "enable#disable");
9605 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9606 .f = cmd_set_sym_hash_per_port_parsed,
9608 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9610 (void *)&cmd_set_sym_hash_ena_per_port_all,
9611 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9612 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9617 /* Get global config of hash function */
9618 struct cmd_get_hash_global_config_result {
9619 cmdline_fixed_string_t get_hash_global_config;
9624 flowtype_to_str(uint16_t ftype)
9631 {"ipv4", RTE_ETH_FLOW_IPV4},
9632 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9633 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9634 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9635 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9636 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9637 {"ipv6", RTE_ETH_FLOW_IPV6},
9638 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9639 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9640 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9641 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9642 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9643 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9644 {"port", RTE_ETH_FLOW_PORT},
9645 {"vxlan", RTE_ETH_FLOW_VXLAN},
9646 {"geneve", RTE_ETH_FLOW_GENEVE},
9647 {"nvgre", RTE_ETH_FLOW_NVGRE},
9650 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9651 if (ftype_table[i].ftype == ftype)
9652 return ftype_table[i].str;
9659 cmd_get_hash_global_config_parsed(void *parsed_result,
9660 __rte_unused struct cmdline *cl,
9661 __rte_unused void *data)
9663 struct cmd_get_hash_global_config_result *res = parsed_result;
9664 struct rte_eth_hash_filter_info info;
9665 uint32_t idx, offset;
9670 if (rte_eth_dev_filter_supported(res->port_id,
9671 RTE_ETH_FILTER_HASH) < 0) {
9672 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9677 memset(&info, 0, sizeof(info));
9678 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9679 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9680 RTE_ETH_FILTER_GET, &info);
9682 printf("Cannot get hash global configurations by port %d\n",
9687 switch (info.info.global_conf.hash_func) {
9688 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9689 printf("Hash function is Toeplitz\n");
9691 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9692 printf("Hash function is Simple XOR\n");
9695 printf("Unknown hash function\n");
9699 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9700 idx = i / UINT32_BIT;
9701 offset = i % UINT32_BIT;
9702 if (!(info.info.global_conf.valid_bit_mask[idx] &
9705 str = flowtype_to_str(i);
9708 printf("Symmetric hash is %s globally for flow type %s "
9710 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9711 (1UL << offset)) ? "enabled" : "disabled"), str,
9716 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9717 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9718 get_hash_global_config, "get_hash_global_config");
9719 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9720 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9723 cmdline_parse_inst_t cmd_get_hash_global_config = {
9724 .f = cmd_get_hash_global_config_parsed,
9726 .help_str = "get_hash_global_config port_id",
9728 (void *)&cmd_get_hash_global_config_all,
9729 (void *)&cmd_get_hash_global_config_port_id,
9734 /* Set global config of hash function */
9735 struct cmd_set_hash_global_config_result {
9736 cmdline_fixed_string_t set_hash_global_config;
9738 cmdline_fixed_string_t hash_func;
9739 cmdline_fixed_string_t flow_type;
9740 cmdline_fixed_string_t enable;
9744 cmd_set_hash_global_config_parsed(void *parsed_result,
9745 __rte_unused struct cmdline *cl,
9746 __rte_unused void *data)
9748 struct cmd_set_hash_global_config_result *res = parsed_result;
9749 struct rte_eth_hash_filter_info info;
9750 uint32_t ftype, idx, offset;
9753 if (rte_eth_dev_filter_supported(res->port_id,
9754 RTE_ETH_FILTER_HASH) < 0) {
9755 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9759 memset(&info, 0, sizeof(info));
9760 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9761 if (!strcmp(res->hash_func, "toeplitz"))
9762 info.info.global_conf.hash_func =
9763 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9764 else if (!strcmp(res->hash_func, "simple_xor"))
9765 info.info.global_conf.hash_func =
9766 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9767 else if (!strcmp(res->hash_func, "default"))
9768 info.info.global_conf.hash_func =
9769 RTE_ETH_HASH_FUNCTION_DEFAULT;
9771 ftype = str2flowtype(res->flow_type);
9772 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9773 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9774 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9775 if (!strcmp(res->enable, "enable"))
9776 info.info.global_conf.sym_hash_enable_mask[idx] |=
9778 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9779 RTE_ETH_FILTER_SET, &info);
9781 printf("Cannot set global hash configurations by port %d\n",
9784 printf("Global hash configurations have been set "
9785 "succcessfully by port %d\n", res->port_id);
9788 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9789 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9790 set_hash_global_config, "set_hash_global_config");
9791 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9792 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9794 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9795 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9796 hash_func, "toeplitz#simple_xor#default");
9797 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9798 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9800 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9801 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9802 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9803 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9804 enable, "enable#disable");
9806 cmdline_parse_inst_t cmd_set_hash_global_config = {
9807 .f = cmd_set_hash_global_config_parsed,
9809 .help_str = "set_hash_global_config port_id "
9810 "toeplitz|simple_xor|default "
9811 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9812 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9815 (void *)&cmd_set_hash_global_config_all,
9816 (void *)&cmd_set_hash_global_config_port_id,
9817 (void *)&cmd_set_hash_global_config_hash_func,
9818 (void *)&cmd_set_hash_global_config_flow_type,
9819 (void *)&cmd_set_hash_global_config_enable,
9824 /* Set hash input set */
9825 struct cmd_set_hash_input_set_result {
9826 cmdline_fixed_string_t set_hash_input_set;
9828 cmdline_fixed_string_t flow_type;
9829 cmdline_fixed_string_t inset_field;
9830 cmdline_fixed_string_t select;
9833 static enum rte_eth_input_set_field
9834 str2inset(char *string)
9838 static const struct {
9840 enum rte_eth_input_set_field inset;
9842 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9843 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9844 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9845 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9846 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9847 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9848 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9849 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9850 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9851 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9852 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9853 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9854 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9855 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9856 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9857 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9858 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9859 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9860 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9861 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9862 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9863 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9864 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9865 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9866 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9867 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9868 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9869 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9870 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9871 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9872 {"none", RTE_ETH_INPUT_SET_NONE},
9875 for (i = 0; i < RTE_DIM(inset_table); i++) {
9876 if (!strcmp(string, inset_table[i].str))
9877 return inset_table[i].inset;
9880 return RTE_ETH_INPUT_SET_UNKNOWN;
9884 cmd_set_hash_input_set_parsed(void *parsed_result,
9885 __rte_unused struct cmdline *cl,
9886 __rte_unused void *data)
9888 struct cmd_set_hash_input_set_result *res = parsed_result;
9889 struct rte_eth_hash_filter_info info;
9891 memset(&info, 0, sizeof(info));
9892 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9893 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9894 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9895 info.info.input_set_conf.inset_size = 1;
9896 if (!strcmp(res->select, "select"))
9897 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9898 else if (!strcmp(res->select, "add"))
9899 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9900 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9901 RTE_ETH_FILTER_SET, &info);
9904 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9905 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9906 set_hash_input_set, "set_hash_input_set");
9907 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9908 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9910 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9911 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9913 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9914 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9915 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9916 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9918 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9919 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9920 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9921 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9922 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9924 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9925 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9926 select, "select#add");
9928 cmdline_parse_inst_t cmd_set_hash_input_set = {
9929 .f = cmd_set_hash_input_set_parsed,
9931 .help_str = "set_hash_input_set <port_id> "
9932 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9933 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9934 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9935 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9936 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9937 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9938 "fld-7th|fld-8th|none select|add",
9940 (void *)&cmd_set_hash_input_set_cmd,
9941 (void *)&cmd_set_hash_input_set_port_id,
9942 (void *)&cmd_set_hash_input_set_flow_type,
9943 (void *)&cmd_set_hash_input_set_field,
9944 (void *)&cmd_set_hash_input_set_select,
9949 /* Set flow director input set */
9950 struct cmd_set_fdir_input_set_result {
9951 cmdline_fixed_string_t set_fdir_input_set;
9953 cmdline_fixed_string_t flow_type;
9954 cmdline_fixed_string_t inset_field;
9955 cmdline_fixed_string_t select;
9959 cmd_set_fdir_input_set_parsed(void *parsed_result,
9960 __rte_unused struct cmdline *cl,
9961 __rte_unused void *data)
9963 struct cmd_set_fdir_input_set_result *res = parsed_result;
9964 struct rte_eth_fdir_filter_info info;
9966 memset(&info, 0, sizeof(info));
9967 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9968 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9969 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9970 info.info.input_set_conf.inset_size = 1;
9971 if (!strcmp(res->select, "select"))
9972 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9973 else if (!strcmp(res->select, "add"))
9974 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9975 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9976 RTE_ETH_FILTER_SET, &info);
9979 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9980 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9981 set_fdir_input_set, "set_fdir_input_set");
9982 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9983 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9985 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9986 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9988 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9989 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9990 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9991 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9993 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9994 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9995 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9996 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9997 "sctp-veri-tag#none");
9998 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9999 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10000 select, "select#add");
10002 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10003 .f = cmd_set_fdir_input_set_parsed,
10005 .help_str = "set_fdir_input_set <port_id> "
10006 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10007 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10008 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10009 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10010 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10011 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10012 "sctp-veri-tag|none select|add",
10014 (void *)&cmd_set_fdir_input_set_cmd,
10015 (void *)&cmd_set_fdir_input_set_port_id,
10016 (void *)&cmd_set_fdir_input_set_flow_type,
10017 (void *)&cmd_set_fdir_input_set_field,
10018 (void *)&cmd_set_fdir_input_set_select,
10023 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10024 struct cmd_mcast_addr_result {
10025 cmdline_fixed_string_t mcast_addr_cmd;
10026 cmdline_fixed_string_t what;
10028 struct ether_addr mc_addr;
10031 static void cmd_mcast_addr_parsed(void *parsed_result,
10032 __attribute__((unused)) struct cmdline *cl,
10033 __attribute__((unused)) void *data)
10035 struct cmd_mcast_addr_result *res = parsed_result;
10037 if (!is_multicast_ether_addr(&res->mc_addr)) {
10038 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10039 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10040 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10041 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10044 if (strcmp(res->what, "add") == 0)
10045 mcast_addr_add(res->port_num, &res->mc_addr);
10047 mcast_addr_remove(res->port_num, &res->mc_addr);
10050 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10051 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10052 mcast_addr_cmd, "mcast_addr");
10053 cmdline_parse_token_string_t cmd_mcast_addr_what =
10054 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10056 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10057 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10058 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10059 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10061 cmdline_parse_inst_t cmd_mcast_addr = {
10062 .f = cmd_mcast_addr_parsed,
10064 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
10066 (void *)&cmd_mcast_addr_cmd,
10067 (void *)&cmd_mcast_addr_what,
10068 (void *)&cmd_mcast_addr_portnum,
10069 (void *)&cmd_mcast_addr_addr,
10074 /* l2 tunnel config
10075 * only support E-tag now.
10078 /* Ether type config */
10079 struct cmd_config_l2_tunnel_eth_type_result {
10080 cmdline_fixed_string_t port;
10081 cmdline_fixed_string_t config;
10082 cmdline_fixed_string_t all;
10084 cmdline_fixed_string_t l2_tunnel;
10085 cmdline_fixed_string_t l2_tunnel_type;
10086 cmdline_fixed_string_t eth_type;
10087 uint16_t eth_type_val;
10090 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10091 TOKEN_STRING_INITIALIZER
10092 (struct cmd_config_l2_tunnel_eth_type_result,
10094 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10095 TOKEN_STRING_INITIALIZER
10096 (struct cmd_config_l2_tunnel_eth_type_result,
10098 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10099 TOKEN_STRING_INITIALIZER
10100 (struct cmd_config_l2_tunnel_eth_type_result,
10102 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10103 TOKEN_NUM_INITIALIZER
10104 (struct cmd_config_l2_tunnel_eth_type_result,
10106 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10107 TOKEN_STRING_INITIALIZER
10108 (struct cmd_config_l2_tunnel_eth_type_result,
10109 l2_tunnel, "l2-tunnel");
10110 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10111 TOKEN_STRING_INITIALIZER
10112 (struct cmd_config_l2_tunnel_eth_type_result,
10113 l2_tunnel_type, "E-tag");
10114 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10115 TOKEN_STRING_INITIALIZER
10116 (struct cmd_config_l2_tunnel_eth_type_result,
10117 eth_type, "ether-type");
10118 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10119 TOKEN_NUM_INITIALIZER
10120 (struct cmd_config_l2_tunnel_eth_type_result,
10121 eth_type_val, UINT16);
10123 static enum rte_eth_tunnel_type
10124 str2fdir_l2_tunnel_type(char *string)
10128 static const struct {
10130 enum rte_eth_tunnel_type type;
10131 } l2_tunnel_type_str[] = {
10132 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10135 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10136 if (!strcmp(l2_tunnel_type_str[i].str, string))
10137 return l2_tunnel_type_str[i].type;
10139 return RTE_TUNNEL_TYPE_NONE;
10142 /* ether type config for all ports */
10144 cmd_config_l2_tunnel_eth_type_all_parsed
10145 (void *parsed_result,
10146 __attribute__((unused)) struct cmdline *cl,
10147 __attribute__((unused)) void *data)
10149 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10150 struct rte_eth_l2_tunnel_conf entry;
10153 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10154 entry.ether_type = res->eth_type_val;
10156 FOREACH_PORT(pid, ports) {
10157 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10161 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10162 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10164 .help_str = "port config all l2-tunnel ether-type",
10166 (void *)&cmd_config_l2_tunnel_eth_type_port,
10167 (void *)&cmd_config_l2_tunnel_eth_type_config,
10168 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10169 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10170 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10171 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10172 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10177 /* ether type config for a specific port */
10179 cmd_config_l2_tunnel_eth_type_specific_parsed(
10180 void *parsed_result,
10181 __attribute__((unused)) struct cmdline *cl,
10182 __attribute__((unused)) void *data)
10184 struct cmd_config_l2_tunnel_eth_type_result *res =
10186 struct rte_eth_l2_tunnel_conf entry;
10188 if (port_id_is_invalid(res->id, ENABLED_WARN))
10191 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10192 entry.ether_type = res->eth_type_val;
10194 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10197 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10198 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10200 .help_str = "port config l2-tunnel ether-type",
10202 (void *)&cmd_config_l2_tunnel_eth_type_port,
10203 (void *)&cmd_config_l2_tunnel_eth_type_config,
10204 (void *)&cmd_config_l2_tunnel_eth_type_id,
10205 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10206 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10207 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10208 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10213 /* Enable/disable l2 tunnel */
10214 struct cmd_config_l2_tunnel_en_dis_result {
10215 cmdline_fixed_string_t port;
10216 cmdline_fixed_string_t config;
10217 cmdline_fixed_string_t all;
10219 cmdline_fixed_string_t l2_tunnel;
10220 cmdline_fixed_string_t l2_tunnel_type;
10221 cmdline_fixed_string_t en_dis;
10224 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10225 TOKEN_STRING_INITIALIZER
10226 (struct cmd_config_l2_tunnel_en_dis_result,
10228 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10229 TOKEN_STRING_INITIALIZER
10230 (struct cmd_config_l2_tunnel_en_dis_result,
10232 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10233 TOKEN_STRING_INITIALIZER
10234 (struct cmd_config_l2_tunnel_en_dis_result,
10236 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10237 TOKEN_NUM_INITIALIZER
10238 (struct cmd_config_l2_tunnel_en_dis_result,
10240 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10241 TOKEN_STRING_INITIALIZER
10242 (struct cmd_config_l2_tunnel_en_dis_result,
10243 l2_tunnel, "l2-tunnel");
10244 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10245 TOKEN_STRING_INITIALIZER
10246 (struct cmd_config_l2_tunnel_en_dis_result,
10247 l2_tunnel_type, "E-tag");
10248 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10249 TOKEN_STRING_INITIALIZER
10250 (struct cmd_config_l2_tunnel_en_dis_result,
10251 en_dis, "enable#disable");
10253 /* enable/disable l2 tunnel for all ports */
10255 cmd_config_l2_tunnel_en_dis_all_parsed(
10256 void *parsed_result,
10257 __attribute__((unused)) struct cmdline *cl,
10258 __attribute__((unused)) void *data)
10260 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10261 struct rte_eth_l2_tunnel_conf entry;
10265 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10267 if (!strcmp("enable", res->en_dis))
10272 FOREACH_PORT(pid, ports) {
10273 rte_eth_dev_l2_tunnel_offload_set(pid,
10275 ETH_L2_TUNNEL_ENABLE_MASK,
10280 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10281 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10283 .help_str = "port config all l2-tunnel enable/disable",
10285 (void *)&cmd_config_l2_tunnel_en_dis_port,
10286 (void *)&cmd_config_l2_tunnel_en_dis_config,
10287 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10288 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10289 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10290 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10295 /* enable/disable l2 tunnel for a port */
10297 cmd_config_l2_tunnel_en_dis_specific_parsed(
10298 void *parsed_result,
10299 __attribute__((unused)) struct cmdline *cl,
10300 __attribute__((unused)) void *data)
10302 struct cmd_config_l2_tunnel_en_dis_result *res =
10304 struct rte_eth_l2_tunnel_conf entry;
10306 if (port_id_is_invalid(res->id, ENABLED_WARN))
10309 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10311 if (!strcmp("enable", res->en_dis))
10312 rte_eth_dev_l2_tunnel_offload_set(res->id,
10314 ETH_L2_TUNNEL_ENABLE_MASK,
10317 rte_eth_dev_l2_tunnel_offload_set(res->id,
10319 ETH_L2_TUNNEL_ENABLE_MASK,
10323 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10324 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10326 .help_str = "port config l2-tunnel enable/disable",
10328 (void *)&cmd_config_l2_tunnel_en_dis_port,
10329 (void *)&cmd_config_l2_tunnel_en_dis_config,
10330 (void *)&cmd_config_l2_tunnel_en_dis_id,
10331 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10332 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10333 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10338 /* E-tag configuration */
10340 /* Common result structure for all E-tag configuration */
10341 struct cmd_config_e_tag_result {
10342 cmdline_fixed_string_t e_tag;
10343 cmdline_fixed_string_t set;
10344 cmdline_fixed_string_t insertion;
10345 cmdline_fixed_string_t stripping;
10346 cmdline_fixed_string_t forwarding;
10347 cmdline_fixed_string_t filter;
10348 cmdline_fixed_string_t add;
10349 cmdline_fixed_string_t del;
10350 cmdline_fixed_string_t on;
10351 cmdline_fixed_string_t off;
10352 cmdline_fixed_string_t on_off;
10353 cmdline_fixed_string_t port_tag_id;
10354 uint32_t port_tag_id_val;
10355 cmdline_fixed_string_t e_tag_id;
10356 uint16_t e_tag_id_val;
10357 cmdline_fixed_string_t dst_pool;
10358 uint8_t dst_pool_val;
10359 cmdline_fixed_string_t port;
10361 cmdline_fixed_string_t vf;
10365 /* Common CLI fields for all E-tag configuration */
10366 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10367 TOKEN_STRING_INITIALIZER
10368 (struct cmd_config_e_tag_result,
10370 cmdline_parse_token_string_t cmd_config_e_tag_set =
10371 TOKEN_STRING_INITIALIZER
10372 (struct cmd_config_e_tag_result,
10374 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10375 TOKEN_STRING_INITIALIZER
10376 (struct cmd_config_e_tag_result,
10377 insertion, "insertion");
10378 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10379 TOKEN_STRING_INITIALIZER
10380 (struct cmd_config_e_tag_result,
10381 stripping, "stripping");
10382 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10383 TOKEN_STRING_INITIALIZER
10384 (struct cmd_config_e_tag_result,
10385 forwarding, "forwarding");
10386 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10387 TOKEN_STRING_INITIALIZER
10388 (struct cmd_config_e_tag_result,
10390 cmdline_parse_token_string_t cmd_config_e_tag_add =
10391 TOKEN_STRING_INITIALIZER
10392 (struct cmd_config_e_tag_result,
10394 cmdline_parse_token_string_t cmd_config_e_tag_del =
10395 TOKEN_STRING_INITIALIZER
10396 (struct cmd_config_e_tag_result,
10398 cmdline_parse_token_string_t cmd_config_e_tag_on =
10399 TOKEN_STRING_INITIALIZER
10400 (struct cmd_config_e_tag_result,
10402 cmdline_parse_token_string_t cmd_config_e_tag_off =
10403 TOKEN_STRING_INITIALIZER
10404 (struct cmd_config_e_tag_result,
10406 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10407 TOKEN_STRING_INITIALIZER
10408 (struct cmd_config_e_tag_result,
10410 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10411 TOKEN_STRING_INITIALIZER
10412 (struct cmd_config_e_tag_result,
10413 port_tag_id, "port-tag-id");
10414 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10415 TOKEN_NUM_INITIALIZER
10416 (struct cmd_config_e_tag_result,
10417 port_tag_id_val, UINT32);
10418 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10419 TOKEN_STRING_INITIALIZER
10420 (struct cmd_config_e_tag_result,
10421 e_tag_id, "e-tag-id");
10422 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10423 TOKEN_NUM_INITIALIZER
10424 (struct cmd_config_e_tag_result,
10425 e_tag_id_val, UINT16);
10426 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10427 TOKEN_STRING_INITIALIZER
10428 (struct cmd_config_e_tag_result,
10429 dst_pool, "dst-pool");
10430 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10431 TOKEN_NUM_INITIALIZER
10432 (struct cmd_config_e_tag_result,
10433 dst_pool_val, UINT8);
10434 cmdline_parse_token_string_t cmd_config_e_tag_port =
10435 TOKEN_STRING_INITIALIZER
10436 (struct cmd_config_e_tag_result,
10438 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10439 TOKEN_NUM_INITIALIZER
10440 (struct cmd_config_e_tag_result,
10442 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10443 TOKEN_STRING_INITIALIZER
10444 (struct cmd_config_e_tag_result,
10446 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10447 TOKEN_NUM_INITIALIZER
10448 (struct cmd_config_e_tag_result,
10451 /* E-tag insertion configuration */
10453 cmd_config_e_tag_insertion_en_parsed(
10454 void *parsed_result,
10455 __attribute__((unused)) struct cmdline *cl,
10456 __attribute__((unused)) void *data)
10458 struct cmd_config_e_tag_result *res =
10460 struct rte_eth_l2_tunnel_conf entry;
10462 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10465 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10466 entry.tunnel_id = res->port_tag_id_val;
10467 entry.vf_id = res->vf_id;
10468 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10470 ETH_L2_TUNNEL_INSERTION_MASK,
10475 cmd_config_e_tag_insertion_dis_parsed(
10476 void *parsed_result,
10477 __attribute__((unused)) struct cmdline *cl,
10478 __attribute__((unused)) void *data)
10480 struct cmd_config_e_tag_result *res =
10482 struct rte_eth_l2_tunnel_conf entry;
10484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10487 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10488 entry.vf_id = res->vf_id;
10490 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10492 ETH_L2_TUNNEL_INSERTION_MASK,
10496 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10497 .f = cmd_config_e_tag_insertion_en_parsed,
10499 .help_str = "E-tag insertion enable",
10501 (void *)&cmd_config_e_tag_e_tag,
10502 (void *)&cmd_config_e_tag_set,
10503 (void *)&cmd_config_e_tag_insertion,
10504 (void *)&cmd_config_e_tag_on,
10505 (void *)&cmd_config_e_tag_port_tag_id,
10506 (void *)&cmd_config_e_tag_port_tag_id_val,
10507 (void *)&cmd_config_e_tag_port,
10508 (void *)&cmd_config_e_tag_port_id,
10509 (void *)&cmd_config_e_tag_vf,
10510 (void *)&cmd_config_e_tag_vf_id,
10515 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10516 .f = cmd_config_e_tag_insertion_dis_parsed,
10518 .help_str = "E-tag insertion disable",
10520 (void *)&cmd_config_e_tag_e_tag,
10521 (void *)&cmd_config_e_tag_set,
10522 (void *)&cmd_config_e_tag_insertion,
10523 (void *)&cmd_config_e_tag_off,
10524 (void *)&cmd_config_e_tag_port,
10525 (void *)&cmd_config_e_tag_port_id,
10526 (void *)&cmd_config_e_tag_vf,
10527 (void *)&cmd_config_e_tag_vf_id,
10532 /* E-tag stripping configuration */
10534 cmd_config_e_tag_stripping_parsed(
10535 void *parsed_result,
10536 __attribute__((unused)) struct cmdline *cl,
10537 __attribute__((unused)) void *data)
10539 struct cmd_config_e_tag_result *res =
10541 struct rte_eth_l2_tunnel_conf entry;
10543 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10546 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10548 if (!strcmp(res->on_off, "on"))
10549 rte_eth_dev_l2_tunnel_offload_set
10552 ETH_L2_TUNNEL_STRIPPING_MASK,
10555 rte_eth_dev_l2_tunnel_offload_set
10558 ETH_L2_TUNNEL_STRIPPING_MASK,
10562 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10563 .f = cmd_config_e_tag_stripping_parsed,
10565 .help_str = "E-tag stripping enable/disable",
10567 (void *)&cmd_config_e_tag_e_tag,
10568 (void *)&cmd_config_e_tag_set,
10569 (void *)&cmd_config_e_tag_stripping,
10570 (void *)&cmd_config_e_tag_on_off,
10571 (void *)&cmd_config_e_tag_port,
10572 (void *)&cmd_config_e_tag_port_id,
10577 /* E-tag forwarding configuration */
10579 cmd_config_e_tag_forwarding_parsed(
10580 void *parsed_result,
10581 __attribute__((unused)) struct cmdline *cl,
10582 __attribute__((unused)) void *data)
10584 struct cmd_config_e_tag_result *res = parsed_result;
10585 struct rte_eth_l2_tunnel_conf entry;
10587 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10590 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10592 if (!strcmp(res->on_off, "on"))
10593 rte_eth_dev_l2_tunnel_offload_set
10596 ETH_L2_TUNNEL_FORWARDING_MASK,
10599 rte_eth_dev_l2_tunnel_offload_set
10602 ETH_L2_TUNNEL_FORWARDING_MASK,
10606 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10607 .f = cmd_config_e_tag_forwarding_parsed,
10609 .help_str = "E-tag forwarding enable/disable",
10611 (void *)&cmd_config_e_tag_e_tag,
10612 (void *)&cmd_config_e_tag_set,
10613 (void *)&cmd_config_e_tag_forwarding,
10614 (void *)&cmd_config_e_tag_on_off,
10615 (void *)&cmd_config_e_tag_port,
10616 (void *)&cmd_config_e_tag_port_id,
10621 /* E-tag filter configuration */
10623 cmd_config_e_tag_filter_add_parsed(
10624 void *parsed_result,
10625 __attribute__((unused)) struct cmdline *cl,
10626 __attribute__((unused)) void *data)
10628 struct cmd_config_e_tag_result *res = parsed_result;
10629 struct rte_eth_l2_tunnel_conf entry;
10632 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10635 if (res->e_tag_id_val > 0x3fff) {
10636 printf("e-tag-id must be equal or less than 0x3fff.\n");
10640 ret = rte_eth_dev_filter_supported(res->port_id,
10641 RTE_ETH_FILTER_L2_TUNNEL);
10643 printf("E-tag filter is not supported on port %u.\n",
10648 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10649 entry.tunnel_id = res->e_tag_id_val;
10650 entry.pool = res->dst_pool_val;
10652 ret = rte_eth_dev_filter_ctrl(res->port_id,
10653 RTE_ETH_FILTER_L2_TUNNEL,
10654 RTE_ETH_FILTER_ADD,
10657 printf("E-tag filter programming error: (%s)\n",
10661 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10662 .f = cmd_config_e_tag_filter_add_parsed,
10664 .help_str = "E-tag filter add",
10666 (void *)&cmd_config_e_tag_e_tag,
10667 (void *)&cmd_config_e_tag_set,
10668 (void *)&cmd_config_e_tag_filter,
10669 (void *)&cmd_config_e_tag_add,
10670 (void *)&cmd_config_e_tag_e_tag_id,
10671 (void *)&cmd_config_e_tag_e_tag_id_val,
10672 (void *)&cmd_config_e_tag_dst_pool,
10673 (void *)&cmd_config_e_tag_dst_pool_val,
10674 (void *)&cmd_config_e_tag_port,
10675 (void *)&cmd_config_e_tag_port_id,
10681 cmd_config_e_tag_filter_del_parsed(
10682 void *parsed_result,
10683 __attribute__((unused)) struct cmdline *cl,
10684 __attribute__((unused)) void *data)
10686 struct cmd_config_e_tag_result *res = parsed_result;
10687 struct rte_eth_l2_tunnel_conf entry;
10690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10693 if (res->e_tag_id_val > 0x3fff) {
10694 printf("e-tag-id must be less than 0x3fff.\n");
10698 ret = rte_eth_dev_filter_supported(res->port_id,
10699 RTE_ETH_FILTER_L2_TUNNEL);
10701 printf("E-tag filter is not supported on port %u.\n",
10706 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10707 entry.tunnel_id = res->e_tag_id_val;
10709 ret = rte_eth_dev_filter_ctrl(res->port_id,
10710 RTE_ETH_FILTER_L2_TUNNEL,
10711 RTE_ETH_FILTER_DELETE,
10714 printf("E-tag filter programming error: (%s)\n",
10718 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10719 .f = cmd_config_e_tag_filter_del_parsed,
10721 .help_str = "E-tag filter delete",
10723 (void *)&cmd_config_e_tag_e_tag,
10724 (void *)&cmd_config_e_tag_set,
10725 (void *)&cmd_config_e_tag_filter,
10726 (void *)&cmd_config_e_tag_del,
10727 (void *)&cmd_config_e_tag_e_tag_id,
10728 (void *)&cmd_config_e_tag_e_tag_id_val,
10729 (void *)&cmd_config_e_tag_port,
10730 (void *)&cmd_config_e_tag_port_id,
10734 #ifdef RTE_LIBRTE_IXGBE_PMD
10736 /* vf vlan anti spoof configuration */
10738 /* Common result structure for vf vlan anti spoof */
10739 struct cmd_vf_vlan_anti_spoof_result {
10740 cmdline_fixed_string_t set;
10741 cmdline_fixed_string_t vf;
10742 cmdline_fixed_string_t vlan;
10743 cmdline_fixed_string_t antispoof;
10746 cmdline_fixed_string_t on_off;
10749 /* Common CLI fields for vf vlan anti spoof enable disable */
10750 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10751 TOKEN_STRING_INITIALIZER
10752 (struct cmd_vf_vlan_anti_spoof_result,
10754 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10755 TOKEN_STRING_INITIALIZER
10756 (struct cmd_vf_vlan_anti_spoof_result,
10758 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10759 TOKEN_STRING_INITIALIZER
10760 (struct cmd_vf_vlan_anti_spoof_result,
10762 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10763 TOKEN_STRING_INITIALIZER
10764 (struct cmd_vf_vlan_anti_spoof_result,
10765 antispoof, "antispoof");
10766 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10767 TOKEN_NUM_INITIALIZER
10768 (struct cmd_vf_vlan_anti_spoof_result,
10770 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10771 TOKEN_NUM_INITIALIZER
10772 (struct cmd_vf_vlan_anti_spoof_result,
10774 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10775 TOKEN_STRING_INITIALIZER
10776 (struct cmd_vf_vlan_anti_spoof_result,
10780 cmd_set_vf_vlan_anti_spoof_parsed(
10781 void *parsed_result,
10782 __attribute__((unused)) struct cmdline *cl,
10783 __attribute__((unused)) void *data)
10785 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10787 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10789 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10792 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
10798 printf("invalid vf_id %d\n", res->vf_id);
10801 printf("invalid port_id %d\n", res->port_id);
10804 printf("programming error: (%s)\n", strerror(-ret));
10808 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10809 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10811 .help_str = "set vf vlan antispoof port_id vf_id on|off",
10813 (void *)&cmd_vf_vlan_anti_spoof_set,
10814 (void *)&cmd_vf_vlan_anti_spoof_vf,
10815 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10816 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10817 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10818 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10819 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10824 /* vf mac anti spoof configuration */
10826 /* Common result structure for vf mac anti spoof */
10827 struct cmd_vf_mac_anti_spoof_result {
10828 cmdline_fixed_string_t set;
10829 cmdline_fixed_string_t vf;
10830 cmdline_fixed_string_t mac;
10831 cmdline_fixed_string_t antispoof;
10834 cmdline_fixed_string_t on_off;
10837 /* Common CLI fields for vf mac anti spoof enable disable */
10838 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10839 TOKEN_STRING_INITIALIZER
10840 (struct cmd_vf_mac_anti_spoof_result,
10842 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10843 TOKEN_STRING_INITIALIZER
10844 (struct cmd_vf_mac_anti_spoof_result,
10846 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10847 TOKEN_STRING_INITIALIZER
10848 (struct cmd_vf_mac_anti_spoof_result,
10850 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10851 TOKEN_STRING_INITIALIZER
10852 (struct cmd_vf_mac_anti_spoof_result,
10853 antispoof, "antispoof");
10854 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10855 TOKEN_NUM_INITIALIZER
10856 (struct cmd_vf_mac_anti_spoof_result,
10858 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10859 TOKEN_NUM_INITIALIZER
10860 (struct cmd_vf_mac_anti_spoof_result,
10862 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10863 TOKEN_STRING_INITIALIZER
10864 (struct cmd_vf_mac_anti_spoof_result,
10868 cmd_set_vf_mac_anti_spoof_parsed(
10869 void *parsed_result,
10870 __attribute__((unused)) struct cmdline *cl,
10871 __attribute__((unused)) void *data)
10873 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10875 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10877 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10880 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
10886 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10889 printf("invalid port_id %d\n", res->port_id);
10892 printf("programming error: (%s)\n", strerror(-ret));
10896 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10897 .f = cmd_set_vf_mac_anti_spoof_parsed,
10899 .help_str = "set vf mac antispoof port_id vf_id on|off",
10901 (void *)&cmd_vf_mac_anti_spoof_set,
10902 (void *)&cmd_vf_mac_anti_spoof_vf,
10903 (void *)&cmd_vf_mac_anti_spoof_mac,
10904 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10905 (void *)&cmd_vf_mac_anti_spoof_port_id,
10906 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10907 (void *)&cmd_vf_mac_anti_spoof_on_off,
10912 /* vf vlan strip queue configuration */
10914 /* Common result structure for vf mac anti spoof */
10915 struct cmd_vf_vlan_stripq_result {
10916 cmdline_fixed_string_t set;
10917 cmdline_fixed_string_t vf;
10918 cmdline_fixed_string_t vlan;
10919 cmdline_fixed_string_t stripq;
10922 cmdline_fixed_string_t on_off;
10925 /* Common CLI fields for vf vlan strip enable disable */
10926 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10927 TOKEN_STRING_INITIALIZER
10928 (struct cmd_vf_vlan_stripq_result,
10930 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10931 TOKEN_STRING_INITIALIZER
10932 (struct cmd_vf_vlan_stripq_result,
10934 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10935 TOKEN_STRING_INITIALIZER
10936 (struct cmd_vf_vlan_stripq_result,
10938 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10939 TOKEN_STRING_INITIALIZER
10940 (struct cmd_vf_vlan_stripq_result,
10942 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10943 TOKEN_NUM_INITIALIZER
10944 (struct cmd_vf_vlan_stripq_result,
10946 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10947 TOKEN_NUM_INITIALIZER
10948 (struct cmd_vf_vlan_stripq_result,
10950 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10951 TOKEN_STRING_INITIALIZER
10952 (struct cmd_vf_vlan_stripq_result,
10956 cmd_set_vf_vlan_stripq_parsed(
10957 void *parsed_result,
10958 __attribute__((unused)) struct cmdline *cl,
10959 __attribute__((unused)) void *data)
10961 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10963 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10968 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
10973 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10976 printf("invalid port_id %d\n", res->port_id);
10979 printf("programming error: (%s)\n", strerror(-ret));
10983 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10984 .f = cmd_set_vf_vlan_stripq_parsed,
10986 .help_str = "set vf vlan stripq port_id vf_id on|off",
10988 (void *)&cmd_vf_vlan_stripq_set,
10989 (void *)&cmd_vf_vlan_stripq_vf,
10990 (void *)&cmd_vf_vlan_stripq_vlan,
10991 (void *)&cmd_vf_vlan_stripq_stripq,
10992 (void *)&cmd_vf_vlan_stripq_port_id,
10993 (void *)&cmd_vf_vlan_stripq_vf_id,
10994 (void *)&cmd_vf_vlan_stripq_on_off,
10999 /* vf vlan insert configuration */
11001 /* Common result structure for vf vlan insert */
11002 struct cmd_vf_vlan_insert_result {
11003 cmdline_fixed_string_t set;
11004 cmdline_fixed_string_t vf;
11005 cmdline_fixed_string_t vlan;
11006 cmdline_fixed_string_t insert;
11012 /* Common CLI fields for vf vlan insert enable disable */
11013 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11014 TOKEN_STRING_INITIALIZER
11015 (struct cmd_vf_vlan_insert_result,
11017 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11018 TOKEN_STRING_INITIALIZER
11019 (struct cmd_vf_vlan_insert_result,
11021 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11022 TOKEN_STRING_INITIALIZER
11023 (struct cmd_vf_vlan_insert_result,
11025 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11026 TOKEN_STRING_INITIALIZER
11027 (struct cmd_vf_vlan_insert_result,
11029 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11030 TOKEN_NUM_INITIALIZER
11031 (struct cmd_vf_vlan_insert_result,
11033 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11034 TOKEN_NUM_INITIALIZER
11035 (struct cmd_vf_vlan_insert_result,
11037 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11038 TOKEN_NUM_INITIALIZER
11039 (struct cmd_vf_vlan_insert_result,
11043 cmd_set_vf_vlan_insert_parsed(
11044 void *parsed_result,
11045 __attribute__((unused)) struct cmdline *cl,
11046 __attribute__((unused)) void *data)
11048 struct cmd_vf_vlan_insert_result *res = parsed_result;
11051 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11054 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
11059 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11062 printf("invalid port_id %d\n", res->port_id);
11065 printf("programming error: (%s)\n", strerror(-ret));
11069 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11070 .f = cmd_set_vf_vlan_insert_parsed,
11072 .help_str = "set vf vlan insert port_id vf_id vlan_id",
11074 (void *)&cmd_vf_vlan_insert_set,
11075 (void *)&cmd_vf_vlan_insert_vf,
11076 (void *)&cmd_vf_vlan_insert_vlan,
11077 (void *)&cmd_vf_vlan_insert_insert,
11078 (void *)&cmd_vf_vlan_insert_port_id,
11079 (void *)&cmd_vf_vlan_insert_vf_id,
11080 (void *)&cmd_vf_vlan_insert_vlan_id,
11085 /* tx loopback configuration */
11087 /* Common result structure for tx loopback */
11088 struct cmd_tx_loopback_result {
11089 cmdline_fixed_string_t set;
11090 cmdline_fixed_string_t tx;
11091 cmdline_fixed_string_t loopback;
11093 cmdline_fixed_string_t on_off;
11096 /* Common CLI fields for tx loopback enable disable */
11097 cmdline_parse_token_string_t cmd_tx_loopback_set =
11098 TOKEN_STRING_INITIALIZER
11099 (struct cmd_tx_loopback_result,
11101 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11102 TOKEN_STRING_INITIALIZER
11103 (struct cmd_tx_loopback_result,
11105 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11106 TOKEN_STRING_INITIALIZER
11107 (struct cmd_tx_loopback_result,
11108 loopback, "loopback");
11109 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11110 TOKEN_NUM_INITIALIZER
11111 (struct cmd_tx_loopback_result,
11113 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11114 TOKEN_STRING_INITIALIZER
11115 (struct cmd_tx_loopback_result,
11119 cmd_set_tx_loopback_parsed(
11120 void *parsed_result,
11121 __attribute__((unused)) struct cmdline *cl,
11122 __attribute__((unused)) void *data)
11124 struct cmd_tx_loopback_result *res = parsed_result;
11126 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11128 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11131 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11136 printf("invalid is_on %d\n", is_on);
11139 printf("invalid port_id %d\n", res->port_id);
11142 printf("programming error: (%s)\n", strerror(-ret));
11146 cmdline_parse_inst_t cmd_set_tx_loopback = {
11147 .f = cmd_set_tx_loopback_parsed,
11149 .help_str = "set tx loopback port_id on|off",
11151 (void *)&cmd_tx_loopback_set,
11152 (void *)&cmd_tx_loopback_tx,
11153 (void *)&cmd_tx_loopback_loopback,
11154 (void *)&cmd_tx_loopback_port_id,
11155 (void *)&cmd_tx_loopback_on_off,
11160 /* all queues drop enable configuration */
11162 /* Common result structure for all queues drop enable */
11163 struct cmd_all_queues_drop_en_result {
11164 cmdline_fixed_string_t set;
11165 cmdline_fixed_string_t all;
11166 cmdline_fixed_string_t queues;
11167 cmdline_fixed_string_t drop;
11169 cmdline_fixed_string_t on_off;
11172 /* Common CLI fields for tx loopback enable disable */
11173 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11174 TOKEN_STRING_INITIALIZER
11175 (struct cmd_all_queues_drop_en_result,
11177 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11178 TOKEN_STRING_INITIALIZER
11179 (struct cmd_all_queues_drop_en_result,
11181 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11182 TOKEN_STRING_INITIALIZER
11183 (struct cmd_all_queues_drop_en_result,
11185 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11186 TOKEN_STRING_INITIALIZER
11187 (struct cmd_all_queues_drop_en_result,
11189 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11190 TOKEN_NUM_INITIALIZER
11191 (struct cmd_all_queues_drop_en_result,
11193 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11194 TOKEN_STRING_INITIALIZER
11195 (struct cmd_all_queues_drop_en_result,
11199 cmd_set_all_queues_drop_en_parsed(
11200 void *parsed_result,
11201 __attribute__((unused)) struct cmdline *cl,
11202 __attribute__((unused)) void *data)
11204 struct cmd_all_queues_drop_en_result *res = parsed_result;
11206 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11208 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11211 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11216 printf("invalid is_on %d\n", is_on);
11219 printf("invalid port_id %d\n", res->port_id);
11222 printf("programming error: (%s)\n", strerror(-ret));
11226 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11227 .f = cmd_set_all_queues_drop_en_parsed,
11229 .help_str = "set all queues drop port_id on|off",
11231 (void *)&cmd_all_queues_drop_en_set,
11232 (void *)&cmd_all_queues_drop_en_all,
11233 (void *)&cmd_all_queues_drop_en_queues,
11234 (void *)&cmd_all_queues_drop_en_drop,
11235 (void *)&cmd_all_queues_drop_en_port_id,
11236 (void *)&cmd_all_queues_drop_en_on_off,
11241 /* vf split drop enable configuration */
11243 /* Common result structure for vf split drop enable */
11244 struct cmd_vf_split_drop_en_result {
11245 cmdline_fixed_string_t set;
11246 cmdline_fixed_string_t vf;
11247 cmdline_fixed_string_t split;
11248 cmdline_fixed_string_t drop;
11251 cmdline_fixed_string_t on_off;
11254 /* Common CLI fields for vf split drop enable disable */
11255 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11256 TOKEN_STRING_INITIALIZER
11257 (struct cmd_vf_split_drop_en_result,
11259 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11260 TOKEN_STRING_INITIALIZER
11261 (struct cmd_vf_split_drop_en_result,
11263 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11264 TOKEN_STRING_INITIALIZER
11265 (struct cmd_vf_split_drop_en_result,
11267 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11268 TOKEN_STRING_INITIALIZER
11269 (struct cmd_vf_split_drop_en_result,
11271 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11272 TOKEN_NUM_INITIALIZER
11273 (struct cmd_vf_split_drop_en_result,
11275 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11276 TOKEN_NUM_INITIALIZER
11277 (struct cmd_vf_split_drop_en_result,
11279 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11280 TOKEN_STRING_INITIALIZER
11281 (struct cmd_vf_split_drop_en_result,
11285 cmd_set_vf_split_drop_en_parsed(
11286 void *parsed_result,
11287 __attribute__((unused)) struct cmdline *cl,
11288 __attribute__((unused)) void *data)
11290 struct cmd_vf_split_drop_en_result *res = parsed_result;
11292 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11294 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11297 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11303 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11306 printf("invalid port_id %d\n", res->port_id);
11309 printf("programming error: (%s)\n", strerror(-ret));
11313 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11314 .f = cmd_set_vf_split_drop_en_parsed,
11316 .help_str = "set vf split drop port_id vf_id on|off",
11318 (void *)&cmd_vf_split_drop_en_set,
11319 (void *)&cmd_vf_split_drop_en_vf,
11320 (void *)&cmd_vf_split_drop_en_split,
11321 (void *)&cmd_vf_split_drop_en_drop,
11322 (void *)&cmd_vf_split_drop_en_port_id,
11323 (void *)&cmd_vf_split_drop_en_vf_id,
11324 (void *)&cmd_vf_split_drop_en_on_off,
11329 /* vf mac address configuration */
11331 /* Common result structure for vf mac address */
11332 struct cmd_set_vf_mac_addr_result {
11333 cmdline_fixed_string_t set;
11334 cmdline_fixed_string_t vf;
11335 cmdline_fixed_string_t mac;
11336 cmdline_fixed_string_t addr;
11339 struct ether_addr mac_addr;
11343 /* Common CLI fields for vf split drop enable disable */
11344 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11345 TOKEN_STRING_INITIALIZER
11346 (struct cmd_set_vf_mac_addr_result,
11348 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11349 TOKEN_STRING_INITIALIZER
11350 (struct cmd_set_vf_mac_addr_result,
11352 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11353 TOKEN_STRING_INITIALIZER
11354 (struct cmd_set_vf_mac_addr_result,
11356 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11357 TOKEN_STRING_INITIALIZER
11358 (struct cmd_set_vf_mac_addr_result,
11360 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11361 TOKEN_NUM_INITIALIZER
11362 (struct cmd_set_vf_mac_addr_result,
11364 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11365 TOKEN_NUM_INITIALIZER
11366 (struct cmd_set_vf_mac_addr_result,
11368 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11369 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11373 cmd_set_vf_mac_addr_parsed(
11374 void *parsed_result,
11375 __attribute__((unused)) struct cmdline *cl,
11376 __attribute__((unused)) void *data)
11378 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11381 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11384 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11390 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11393 printf("invalid port_id %d\n", res->port_id);
11396 printf("programming error: (%s)\n", strerror(-ret));
11400 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11401 .f = cmd_set_vf_mac_addr_parsed,
11403 .help_str = "set vf mac addr port_id vf_id xx:xx:xx:xx:xx:xx",
11405 (void *)&cmd_set_vf_mac_addr_set,
11406 (void *)&cmd_set_vf_mac_addr_vf,
11407 (void *)&cmd_set_vf_mac_addr_mac,
11408 (void *)&cmd_set_vf_mac_addr_addr,
11409 (void *)&cmd_set_vf_mac_addr_port_id,
11410 (void *)&cmd_set_vf_mac_addr_vf_id,
11411 (void *)&cmd_set_vf_mac_addr_mac_addr,
11417 /* ******************************************************************************** */
11419 /* list of instructions */
11420 cmdline_parse_ctx_t main_ctx[] = {
11421 (cmdline_parse_inst_t *)&cmd_help_brief,
11422 (cmdline_parse_inst_t *)&cmd_help_long,
11423 (cmdline_parse_inst_t *)&cmd_quit,
11424 (cmdline_parse_inst_t *)&cmd_showport,
11425 (cmdline_parse_inst_t *)&cmd_showqueue,
11426 (cmdline_parse_inst_t *)&cmd_showportall,
11427 (cmdline_parse_inst_t *)&cmd_showcfg,
11428 (cmdline_parse_inst_t *)&cmd_start,
11429 (cmdline_parse_inst_t *)&cmd_start_tx_first,
11430 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
11431 (cmdline_parse_inst_t *)&cmd_set_link_up,
11432 (cmdline_parse_inst_t *)&cmd_set_link_down,
11433 (cmdline_parse_inst_t *)&cmd_reset,
11434 (cmdline_parse_inst_t *)&cmd_set_numbers,
11435 (cmdline_parse_inst_t *)&cmd_set_txpkts,
11436 (cmdline_parse_inst_t *)&cmd_set_txsplit,
11437 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
11438 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
11439 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
11440 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
11441 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
11442 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
11443 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
11444 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
11445 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
11446 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
11447 (cmdline_parse_inst_t *)&cmd_set_link_check,
11448 #ifdef RTE_NIC_BYPASS
11449 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
11450 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
11451 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
11452 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
11454 #ifdef RTE_LIBRTE_PMD_BOND
11455 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
11456 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
11457 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
11458 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
11459 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
11460 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
11461 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
11462 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
11463 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
11465 (cmdline_parse_inst_t *)&cmd_vlan_offload,
11466 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
11467 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
11468 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
11469 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
11470 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
11471 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
11472 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
11473 (cmdline_parse_inst_t *)&cmd_csum_set,
11474 (cmdline_parse_inst_t *)&cmd_csum_show,
11475 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
11476 (cmdline_parse_inst_t *)&cmd_tso_set,
11477 (cmdline_parse_inst_t *)&cmd_tso_show,
11478 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
11479 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
11480 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
11481 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
11482 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
11483 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
11484 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
11485 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
11486 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
11487 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
11488 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
11489 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
11490 (cmdline_parse_inst_t *)&cmd_config_dcb,
11491 (cmdline_parse_inst_t *)&cmd_read_reg,
11492 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
11493 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
11494 (cmdline_parse_inst_t *)&cmd_write_reg,
11495 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
11496 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
11497 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
11498 (cmdline_parse_inst_t *)&cmd_stop,
11499 (cmdline_parse_inst_t *)&cmd_mac_addr,
11500 (cmdline_parse_inst_t *)&cmd_set_qmap,
11501 (cmdline_parse_inst_t *)&cmd_operate_port,
11502 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
11503 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
11504 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
11505 (cmdline_parse_inst_t *)&cmd_config_speed_all,
11506 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
11507 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
11508 (cmdline_parse_inst_t *)&cmd_config_mtu,
11509 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
11510 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
11511 (cmdline_parse_inst_t *)&cmd_config_rss,
11512 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
11513 (cmdline_parse_inst_t *)&cmd_config_txqflags,
11514 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
11515 (cmdline_parse_inst_t *)&cmd_showport_reta,
11516 (cmdline_parse_inst_t *)&cmd_config_burst,
11517 (cmdline_parse_inst_t *)&cmd_config_thresh,
11518 (cmdline_parse_inst_t *)&cmd_config_threshold,
11519 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
11520 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
11521 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
11522 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
11523 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
11524 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
11525 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
11526 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
11527 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
11528 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
11529 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
11530 (cmdline_parse_inst_t *)&cmd_global_config,
11531 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
11532 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
11533 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
11534 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
11535 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
11536 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
11537 (cmdline_parse_inst_t *)&cmd_dump,
11538 (cmdline_parse_inst_t *)&cmd_dump_one,
11539 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
11540 (cmdline_parse_inst_t *)&cmd_syn_filter,
11541 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
11542 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
11543 (cmdline_parse_inst_t *)&cmd_flex_filter,
11544 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
11545 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
11546 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
11547 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
11548 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
11549 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
11550 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
11551 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
11552 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
11553 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
11554 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
11555 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
11556 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
11557 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
11558 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
11559 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
11560 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
11561 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
11562 (cmdline_parse_inst_t *)&cmd_mcast_addr,
11563 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
11564 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
11565 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
11566 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
11567 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
11568 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
11569 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
11570 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
11571 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
11572 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
11573 #ifdef RTE_LIBRTE_IXGBE_PMD
11574 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
11575 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
11576 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
11577 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
11578 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
11579 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
11580 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
11581 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
11586 /* prompt function, called from main on MASTER lcore */
11590 /* initialize non-constant commands */
11591 cmd_set_fwd_mode_init();
11592 cmd_set_fwd_retry_mode_init();
11594 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
11595 if (testpmd_cl == NULL)
11597 cmdline_interact(testpmd_cl);
11598 cmdline_stdin_exit(testpmd_cl);
11604 if (testpmd_cl != NULL)
11605 cmdline_quit(testpmd_cl);
11609 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
11611 if (id == (portid_t)RTE_PORT_ALL) {
11614 FOREACH_PORT(pid, ports) {
11615 /* check if need_reconfig has been set to 1 */
11616 if (ports[pid].need_reconfig == 0)
11617 ports[pid].need_reconfig = dev;
11618 /* check if need_reconfig_queues has been set to 1 */
11619 if (ports[pid].need_reconfig_queues == 0)
11620 ports[pid].need_reconfig_queues = queue;
11622 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
11623 /* check if need_reconfig has been set to 1 */
11624 if (ports[id].need_reconfig == 0)
11625 ports[id].need_reconfig = dev;
11626 /* check if need_reconfig_queues has been set to 1 */
11627 if (ports[id].need_reconfig_queues == 0)
11628 ports[id].need_reconfig_queues = queue;