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>
93 static struct cmdline *testpmd_cl;
95 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
97 /* *** Help command with introduction. *** */
98 struct cmd_help_brief_result {
99 cmdline_fixed_string_t help;
102 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
104 __attribute__((unused)) void *data)
109 "Help is available for the following sections:\n\n"
110 " help control : Start and stop forwarding.\n"
111 " help display : Displaying port, stats and config "
113 " help config : Configuration information.\n"
114 " help ports : Configuring ports.\n"
115 " help registers : Reading and setting port registers.\n"
116 " help filters : Filters configuration help.\n"
117 " help all : All of the above sections.\n\n"
122 cmdline_parse_token_string_t cmd_help_brief_help =
123 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
125 cmdline_parse_inst_t cmd_help_brief = {
126 .f = cmd_help_brief_parsed,
128 .help_str = "show help",
130 (void *)&cmd_help_brief_help,
135 /* *** Help command with help sections. *** */
136 struct cmd_help_long_result {
137 cmdline_fixed_string_t help;
138 cmdline_fixed_string_t section;
141 static void cmd_help_long_parsed(void *parsed_result,
143 __attribute__((unused)) void *data)
146 struct cmd_help_long_result *res = parsed_result;
148 if (!strcmp(res->section, "all"))
151 if (show_all || !strcmp(res->section, "control")) {
156 "Control forwarding:\n"
157 "-------------------\n\n"
160 " Start packet forwarding with current configuration.\n\n"
163 " Start packet forwarding with current config"
164 " after sending one burst of packets.\n\n"
167 " Stop packet forwarding, and display accumulated"
171 " Quit to prompt.\n\n"
175 if (show_all || !strcmp(res->section, "display")) {
183 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
184 " Display information for port_id, or all.\n\n"
186 "show port X rss reta (size) (mask0,mask1,...)\n"
187 " Display the rss redirection table entry indicated"
188 " by masks on port X. size is used to indicate the"
189 " hardware supported reta size\n\n"
191 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
192 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
193 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
194 " Display the RSS hash functions and RSS hash key"
197 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
198 " Clear information for port_id, or all.\n\n"
200 "show (rxq|txq) info (port_id) (queue_id)\n"
201 " Display information for configured RX/TX queue.\n\n"
203 "show config (rxtx|cores|fwd|txpkts)\n"
204 " Display the given configuration.\n\n"
206 "read rxd (port_id) (queue_id) (rxd_id)\n"
207 " Display an RX descriptor of a port RX queue.\n\n"
209 "read txd (port_id) (queue_id) (txd_id)\n"
210 " Display a TX descriptor of a port TX queue.\n\n"
214 if (show_all || !strcmp(res->section, "config")) {
220 "Configuration changes only become active when"
221 " forwarding is started/restarted.\n\n"
224 " Reset forwarding to the default configuration.\n\n"
226 "set verbose (level)\n"
227 " Set the debug verbosity level X.\n\n"
230 " Set number of ports.\n\n"
233 " Set number of cores.\n\n"
235 "set coremask (mask)\n"
236 " Set the forwarding cores hexadecimal mask.\n\n"
238 "set portmask (mask)\n"
239 " Set the forwarding ports hexadecimal mask.\n\n"
242 " Set number of packets per burst.\n\n"
244 "set burst tx delay (microseconds) retry (num)\n"
245 " Set the transmit delay time and number of retries,"
246 " effective when retry is enabled.\n\n"
248 "set txpkts (x[,y]*)\n"
249 " Set the length of each segment of TXONLY"
250 " and optionally CSUM packets.\n\n"
252 "set txsplit (off|on|rand)\n"
253 " Set the split policy for the TX packets."
254 " Right now only applicable for CSUM and TXONLY"
257 "set corelist (x[,y]*)\n"
258 " Set the list of forwarding cores.\n\n"
260 "set portlist (x[,y]*)\n"
261 " Set the list of forwarding ports.\n\n"
263 "vlan set strip (on|off) (port_id)\n"
264 " Set the VLAN strip on a port.\n\n"
266 "vlan set stripq (on|off) (port_id,queue_id)\n"
267 " Set the VLAN strip for a queue on a port.\n\n"
269 "vlan set filter (on|off) (port_id)\n"
270 " Set the VLAN filter on a port.\n\n"
272 "vlan set qinq (on|off) (port_id)\n"
273 " Set the VLAN QinQ (extended queue in queue)"
276 "vlan set (inner|outer) tpid (value) (port_id)\n"
277 " Set the VLAN TPID for Packet Filtering on"
280 "rx_vlan add (vlan_id|all) (port_id)\n"
281 " Add a vlan_id, or all identifiers, to the set"
282 " of VLAN identifiers filtered by port_id.\n\n"
284 "rx_vlan rm (vlan_id|all) (port_id)\n"
285 " Remove a vlan_id, or all identifiers, from the set"
286 " of VLAN identifiers filtered by port_id.\n\n"
288 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
289 " Add a vlan_id, to the set of VLAN identifiers"
290 "filtered for VF(s) from port_id.\n\n"
292 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
293 " Remove a vlan_id, to the set of VLAN identifiers"
294 "filtered for VF(s) from port_id.\n\n"
296 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
297 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
298 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
299 " add a tunnel filter of a port.\n\n"
301 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
302 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
303 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
304 " remove a tunnel filter of a port.\n\n"
306 "rx_vxlan_port add (udp_port) (port_id)\n"
307 " Add an UDP port for VXLAN packet filter on a port\n\n"
309 "rx_vxlan_port rm (udp_port) (port_id)\n"
310 " Remove an UDP port for VXLAN packet filter on a port\n\n"
312 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
313 " Set hardware insertion of VLAN IDs (single or double VLAN "
314 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
316 "tx_vlan set pvid port_id vlan_id (on|off)\n"
317 " Set port based TX VLAN insertion.\n\n"
319 "tx_vlan reset (port_id)\n"
320 " Disable hardware insertion of a VLAN header in"
321 " packets sent on a port.\n\n"
323 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
324 " Select hardware or software calculation of the"
325 " checksum when transmitting a packet using the"
326 " csum forward engine.\n"
327 " ip|udp|tcp|sctp always concern the inner layer.\n"
328 " outer-ip concerns the outer IP layer in"
329 " case the packet is recognized as a tunnel packet by"
330 " the forward engine (vxlan, gre and ipip are supported)\n"
331 " Please check the NIC datasheet for HW limits.\n\n"
333 "csum parse-tunnel (on|off) (tx_port_id)\n"
334 " If disabled, treat tunnel packets as non-tunneled"
335 " packets (treat inner headers as payload). The port\n"
336 " argument is the port used for TX in csum forward"
339 "csum show (port_id)\n"
340 " Display tx checksum offload configuration\n\n"
342 "tso set (segsize) (portid)\n"
343 " Enable TCP Segmentation Offload in csum forward"
345 " Please check the NIC datasheet for HW limits.\n\n"
348 " Display the status of TCP Segmentation Offload.\n\n"
351 " Set packet forwarding mode.\n\n"
353 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
354 " Add a MAC address on port_id.\n\n"
356 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
357 " Remove a MAC address from port_id.\n\n"
359 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
360 " Add a MAC address for a VF on the port.\n\n"
362 "set port (port_id) uta (mac_address|all) (on|off)\n"
363 " Add/Remove a or all unicast hash filter(s)"
366 "set promisc (port_id|all) (on|off)\n"
367 " Set the promiscuous mode on port_id, or all.\n\n"
369 "set allmulti (port_id|all) (on|off)\n"
370 " Set the allmulti mode on port_id, or all.\n\n"
372 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
373 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
374 " (on|off) autoneg (on|off) (port_id)\n"
375 "set flow_ctrl rx (on|off) (portid)\n"
376 "set flow_ctrl tx (on|off) (portid)\n"
377 "set flow_ctrl high_water (high_water) (portid)\n"
378 "set flow_ctrl low_water (low_water) (portid)\n"
379 "set flow_ctrl pause_time (pause_time) (portid)\n"
380 "set flow_ctrl send_xon (send_xon) (portid)\n"
381 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
382 "set flow_ctrl autoneg (on|off) (port_id)\n"
383 " Set the link flow control parameter on a port.\n\n"
385 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
386 " (low_water) (pause_time) (priority) (port_id)\n"
387 " Set the priority flow control parameter on a"
390 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
391 " Set statistics mapping (qmapping 0..15) for RX/TX"
393 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
394 " on port 0 to mapping 5.\n\n"
396 "set port (port_id) vf (vf_id) rx|tx on|off\n"
397 " Enable/Disable a VF receive/tranmit from a port\n\n"
399 "set port (port_id) vf (vf_id) (mac_addr)"
400 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
401 " Add/Remove unicast or multicast MAC addr filter"
404 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
406 " AUPE:accepts untagged VLAN;"
407 "ROPE:accept unicast hash\n\n"
408 " BAM:accepts broadcast packets;"
409 "MPE:accepts all multicast packets\n\n"
410 " Enable/Disable a VF receive mode of a port\n\n"
412 "set port (port_id) queue (queue_id) rate (rate_num)\n"
413 " Set rate limit for a queue of a port\n\n"
415 "set port (port_id) vf (vf_id) rate (rate_num) "
416 "queue_mask (queue_mask_value)\n"
417 " Set rate limit for queues in VF of a port\n\n"
419 "set port (port_id) mirror-rule (rule_id)"
420 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
421 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
422 " Set pool or vlan type mirror rule on a port.\n"
423 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
424 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
427 "set port (port_id) mirror-rule (rule_id)"
428 " (uplink-mirror|downlink-mirror) dst-pool"
429 " (pool_id) (on|off)\n"
430 " Set uplink or downlink type mirror rule on a port.\n"
431 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
432 " 0 on' enable mirror income traffic to pool 0.\n\n"
434 "reset port (port_id) mirror-rule (rule_id)\n"
435 " Reset a mirror rule.\n\n"
437 "set flush_rx (on|off)\n"
438 " Flush (default) or don't flush RX streams before"
439 " forwarding. Mainly used with PCAP drivers.\n\n"
441 #ifdef RTE_NIC_BYPASS
442 "set bypass mode (normal|bypass|isolate) (port_id)\n"
443 " Set the bypass mode for the lowest port on bypass enabled"
446 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
447 "mode (normal|bypass|isolate) (port_id)\n"
448 " Set the event required to initiate specified bypass mode for"
449 " the lowest port on a bypass enabled NIC where:\n"
450 " timeout = enable bypass after watchdog timeout.\n"
451 " os_on = enable bypass when OS/board is powered on.\n"
452 " os_off = enable bypass when OS/board is powered off.\n"
453 " power_on = enable bypass when power supply is turned on.\n"
454 " power_off = enable bypass when power supply is turned off."
457 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
458 " Set the bypass watchdog timeout to 'n' seconds"
459 " where 0 = instant.\n\n"
461 "show bypass config (port_id)\n"
462 " Show the bypass configuration for a bypass enabled NIC"
463 " using the lowest port on the NIC.\n\n"
465 #ifdef RTE_LIBRTE_PMD_BOND
466 "create bonded device (mode) (socket)\n"
467 " Create a new bonded device with specific bonding mode and socket.\n\n"
469 "add bonding slave (slave_id) (port_id)\n"
470 " Add a slave device to a bonded device.\n\n"
472 "remove bonding slave (slave_id) (port_id)\n"
473 " Remove a slave device from a bonded device.\n\n"
475 "set bonding mode (value) (port_id)\n"
476 " Set the bonding mode on a bonded device.\n\n"
478 "set bonding primary (slave_id) (port_id)\n"
479 " Set the primary slave for a bonded device.\n\n"
481 "show bonding config (port_id)\n"
482 " Show the bonding config for port_id.\n\n"
484 "set bonding mac_addr (port_id) (address)\n"
485 " Set the MAC address of a bonded device.\n\n"
487 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
488 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
490 "set bonding mon_period (port_id) (value)\n"
491 " Set the bonding link status monitoring polling period in ms.\n\n"
493 "set link-up port (port_id)\n"
494 " Set link up for a port.\n\n"
496 "set link-down port (port_id)\n"
497 " Set link down for a port.\n\n"
499 "E-tag set insertion on port-tag-id (value)"
500 " port (port_id) vf (vf_id)\n"
501 " Enable E-tag insertion for a VF on a port\n\n"
503 "E-tag set insertion off port (port_id) vf (vf_id)\n"
504 " Disable E-tag insertion for a VF on a port\n\n"
506 "E-tag set stripping (on|off) port (port_id)\n"
507 " Enable/disable E-tag stripping on a port\n\n"
509 "E-tag set forwarding (on|off) port (port_id)\n"
510 " Enable/disable E-tag based forwarding"
513 "E-tag set filter add e-tag-id (value) dst-pool"
514 " (pool_id) port (port_id)\n"
515 " Add an E-tag forwarding filter on a port\n\n"
517 "E-tag set filter del e-tag-id (value) port (port_id)\n"
518 " Delete an E-tag forwarding filter on a port\n\n"
520 , list_pkt_forwarding_modes()
524 if (show_all || !strcmp(res->section, "ports")) {
530 "----------------\n\n"
532 "port start (port_id|all)\n"
533 " Start all ports or port_id.\n\n"
535 "port stop (port_id|all)\n"
536 " Stop all ports or port_id.\n\n"
538 "port close (port_id|all)\n"
539 " Close all ports or port_id.\n\n"
541 "port attach (ident)\n"
542 " Attach physical or virtual dev by pci address or virtual device name\n\n"
544 "port detach (port_id)\n"
545 " Detach physical or virtual dev by port_id\n\n"
547 "port config (port_id|all)"
548 " speed (10|100|1000|10000|40000|100000|auto)"
549 " duplex (half|full|auto)\n"
550 " Set speed and duplex for all ports or port_id\n\n"
552 "port config all (rxq|txq|rxd|txd) (value)\n"
553 " Set number for rxq/txq/rxd/txd.\n\n"
555 "port config all max-pkt-len (value)\n"
556 " Set the max packet length.\n\n"
558 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
559 "hw-vlan-strip|hw-vlan-extend|drop-en)"
561 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
564 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
565 " Set the RSS mode.\n\n"
567 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
568 " Set the RSS redirection table.\n\n"
570 "port config (port_id) dcb vt (on|off) (traffic_class)"
572 " Set the DCB mode.\n\n"
574 "port config all burst (value)\n"
575 " Set the number of packets per burst.\n\n"
577 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
579 " Set the ring prefetch/host/writeback threshold"
580 " for tx/rx queue.\n\n"
582 "port config all (txfreet|txrst|rxfreet) (value)\n"
583 " Set free threshold for rx/tx, or set"
584 " tx rs bit threshold.\n\n"
585 "port config mtu X value\n"
586 " Set the MTU of port X to a given value\n\n"
588 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
589 " Start/stop a rx/tx queue of port X. Only take effect"
590 " when port X is started\n\n"
592 "port config (port_id|all) l2-tunnel E-tag ether-type"
594 " Set the value of E-tag ether-type.\n\n"
596 "port config (port_id|all) l2-tunnel E-tag"
597 " (enable|disable)\n"
598 " Enable/disable the E-tag support.\n\n"
602 if (show_all || !strcmp(res->section, "registers")) {
610 "read reg (port_id) (address)\n"
611 " Display value of a port register.\n\n"
613 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
614 " Display a port register bit field.\n\n"
616 "read regbit (port_id) (address) (bit_x)\n"
617 " Display a single port register bit.\n\n"
619 "write reg (port_id) (address) (value)\n"
620 " Set value of a port register.\n\n"
622 "write regfield (port_id) (address) (bit_x) (bit_y)"
624 " Set bit field of a port register.\n\n"
626 "write regbit (port_id) (address) (bit_x) (value)\n"
627 " Set single bit value of a port register.\n\n"
630 if (show_all || !strcmp(res->section, "filters")) {
638 "ethertype_filter (port_id) (add|del)"
639 " (mac_addr|mac_ignr) (mac_address) ethertype"
640 " (ether_type) (drop|fwd) queue (queue_id)\n"
641 " Add/Del an ethertype filter.\n\n"
643 "2tuple_filter (port_id) (add|del)"
644 " dst_port (dst_port_value) protocol (protocol_value)"
645 " mask (mask_value) tcp_flags (tcp_flags_value)"
646 " priority (prio_value) queue (queue_id)\n"
647 " Add/Del a 2tuple filter.\n\n"
649 "5tuple_filter (port_id) (add|del)"
650 " dst_ip (dst_address) src_ip (src_address)"
651 " dst_port (dst_port_value) src_port (src_port_value)"
652 " protocol (protocol_value)"
653 " mask (mask_value) tcp_flags (tcp_flags_value)"
654 " priority (prio_value) queue (queue_id)\n"
655 " Add/Del a 5tuple filter.\n\n"
657 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
658 " Add/Del syn filter.\n\n"
660 "flex_filter (port_id) (add|del) len (len_value)"
661 " bytes (bytes_value) mask (mask_value)"
662 " priority (prio_value) queue (queue_id)\n"
663 " Add/Del a flex filter.\n\n"
665 "flow_director_filter (port_id) mode IP (add|del|update)"
666 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
667 " src (src_ip_address) dst (dst_ip_address)"
668 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
669 " vlan (vlan_value) flexbytes (flexbytes_value)"
670 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
671 " fd_id (fd_id_value)\n"
672 " Add/Del an IP type flow director filter.\n\n"
674 "flow_director_filter (port_id) mode IP (add|del|update)"
675 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
676 " src (src_ip_address) (src_port)"
677 " dst (dst_ip_address) (dst_port)"
678 " tos (tos_value) ttl (ttl_value)"
679 " vlan (vlan_value) flexbytes (flexbytes_value)"
680 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
681 " fd_id (fd_id_value)\n"
682 " Add/Del an UDP/TCP type flow director filter.\n\n"
684 "flow_director_filter (port_id) mode IP (add|del|update)"
685 " flow (ipv4-sctp|ipv6-sctp)"
686 " src (src_ip_address) (src_port)"
687 " dst (dst_ip_address) (dst_port)"
688 " tag (verification_tag) "
689 " tos (tos_value) ttl (ttl_value)"
691 " flexbytes (flexbytes_value) (drop|fwd)"
692 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
693 " Add/Del a SCTP type flow director filter.\n\n"
695 "flow_director_filter (port_id) mode IP (add|del|update)"
696 " flow l2_payload ether (ethertype)"
697 " flexbytes (flexbytes_value) (drop|fwd)"
698 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
699 " Add/Del a l2 payload type flow director filter.\n\n"
701 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
702 " mac (mac_address) vlan (vlan_value)"
703 " flexbytes (flexbytes_value) (drop|fwd)"
704 " queue (queue_id) fd_id (fd_id_value)\n"
705 " Add/Del a MAC-VLAN flow director filter.\n\n"
707 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
708 " mac (mac_address) vlan (vlan_value)"
709 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
710 " flexbytes (flexbytes_value) (drop|fwd)"
711 " queue (queue_id) fd_id (fd_id_value)\n"
712 " Add/Del a Tunnel flow director filter.\n\n"
714 "flush_flow_director (port_id)\n"
715 " Flush all flow director entries of a device.\n\n"
717 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
718 " src_mask (ipv4_src) (ipv6_src) (src_port)"
719 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
720 " Set flow director IP mask.\n\n"
722 "flow_director_mask (port_id) mode MAC-VLAN"
723 " vlan (vlan_value) mac (mac_value)\n"
724 " Set flow director MAC-VLAN mask.\n\n"
726 "flow_director_mask (port_id) mode Tunnel"
727 " vlan (vlan_value) mac (mac_value)"
728 " tunnel-type (tunnel_type_value)"
729 " tunnel-id (tunnel_id_value)\n"
730 " Set flow director Tunnel mask.\n\n"
732 "flow_director_flex_mask (port_id)"
733 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
734 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
736 " Configure mask of flex payload.\n\n"
738 "flow_director_flex_payload (port_id)"
739 " (raw|l2|l3|l4) (config)\n"
740 " Configure flex payload selection.\n\n"
742 "get_sym_hash_ena_per_port (port_id)\n"
743 " get symmetric hash enable configuration per port.\n\n"
745 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
746 " set symmetric hash enable configuration per port"
747 " to enable or disable.\n\n"
749 "get_hash_global_config (port_id)\n"
750 " Get the global configurations of hash filters.\n\n"
752 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
753 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
754 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
755 " (enable|disable)\n"
756 " Set the global configurations of hash filters.\n\n"
758 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
759 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
760 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
761 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
762 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
763 "ipv6-next-header|udp-src-port|udp-dst-port|"
764 "tcp-src-port|tcp-dst-port|sctp-src-port|"
765 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
766 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
767 "fld-8th|none) (select|add)\n"
768 " Set the input set for hash.\n\n"
770 "set_fdir_input_set (port_id) "
771 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
772 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
773 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
774 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
775 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
776 "udp-dst-port|tcp-src-port|tcp-dst-port|"
777 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
779 " Set the input set for FDir.\n\n"
784 cmdline_parse_token_string_t cmd_help_long_help =
785 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
787 cmdline_parse_token_string_t cmd_help_long_section =
788 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
789 "all#control#display#config#"
790 "ports#registers#filters");
792 cmdline_parse_inst_t cmd_help_long = {
793 .f = cmd_help_long_parsed,
795 .help_str = "show help",
797 (void *)&cmd_help_long_help,
798 (void *)&cmd_help_long_section,
804 /* *** start/stop/close all ports *** */
805 struct cmd_operate_port_result {
806 cmdline_fixed_string_t keyword;
807 cmdline_fixed_string_t name;
808 cmdline_fixed_string_t value;
811 static void cmd_operate_port_parsed(void *parsed_result,
812 __attribute__((unused)) struct cmdline *cl,
813 __attribute__((unused)) void *data)
815 struct cmd_operate_port_result *res = parsed_result;
817 if (!strcmp(res->name, "start"))
818 start_port(RTE_PORT_ALL);
819 else if (!strcmp(res->name, "stop"))
820 stop_port(RTE_PORT_ALL);
821 else if (!strcmp(res->name, "close"))
822 close_port(RTE_PORT_ALL);
824 printf("Unknown parameter\n");
827 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
828 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
830 cmdline_parse_token_string_t cmd_operate_port_all_port =
831 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
833 cmdline_parse_token_string_t cmd_operate_port_all_all =
834 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
836 cmdline_parse_inst_t cmd_operate_port = {
837 .f = cmd_operate_port_parsed,
839 .help_str = "port start|stop|close all: start/stop/close all ports",
841 (void *)&cmd_operate_port_all_cmd,
842 (void *)&cmd_operate_port_all_port,
843 (void *)&cmd_operate_port_all_all,
848 /* *** start/stop/close specific port *** */
849 struct cmd_operate_specific_port_result {
850 cmdline_fixed_string_t keyword;
851 cmdline_fixed_string_t name;
855 static void cmd_operate_specific_port_parsed(void *parsed_result,
856 __attribute__((unused)) struct cmdline *cl,
857 __attribute__((unused)) void *data)
859 struct cmd_operate_specific_port_result *res = parsed_result;
861 if (!strcmp(res->name, "start"))
862 start_port(res->value);
863 else if (!strcmp(res->name, "stop"))
864 stop_port(res->value);
865 else if (!strcmp(res->name, "close"))
866 close_port(res->value);
868 printf("Unknown parameter\n");
871 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
872 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
874 cmdline_parse_token_string_t cmd_operate_specific_port_port =
875 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
876 name, "start#stop#close");
877 cmdline_parse_token_num_t cmd_operate_specific_port_id =
878 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
881 cmdline_parse_inst_t cmd_operate_specific_port = {
882 .f = cmd_operate_specific_port_parsed,
884 .help_str = "port start|stop|close X: start/stop/close port X",
886 (void *)&cmd_operate_specific_port_cmd,
887 (void *)&cmd_operate_specific_port_port,
888 (void *)&cmd_operate_specific_port_id,
893 /* *** attach a specified port *** */
894 struct cmd_operate_attach_port_result {
895 cmdline_fixed_string_t port;
896 cmdline_fixed_string_t keyword;
897 cmdline_fixed_string_t identifier;
900 static void cmd_operate_attach_port_parsed(void *parsed_result,
901 __attribute__((unused)) struct cmdline *cl,
902 __attribute__((unused)) void *data)
904 struct cmd_operate_attach_port_result *res = parsed_result;
906 if (!strcmp(res->keyword, "attach"))
907 attach_port(res->identifier);
909 printf("Unknown parameter\n");
912 cmdline_parse_token_string_t cmd_operate_attach_port_port =
913 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
915 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
916 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
918 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
919 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
922 cmdline_parse_inst_t cmd_operate_attach_port = {
923 .f = cmd_operate_attach_port_parsed,
925 .help_str = "port attach identifier, "
926 "identifier: pci address or virtual dev name",
928 (void *)&cmd_operate_attach_port_port,
929 (void *)&cmd_operate_attach_port_keyword,
930 (void *)&cmd_operate_attach_port_identifier,
935 /* *** detach a specified port *** */
936 struct cmd_operate_detach_port_result {
937 cmdline_fixed_string_t port;
938 cmdline_fixed_string_t keyword;
942 static void cmd_operate_detach_port_parsed(void *parsed_result,
943 __attribute__((unused)) struct cmdline *cl,
944 __attribute__((unused)) void *data)
946 struct cmd_operate_detach_port_result *res = parsed_result;
948 if (!strcmp(res->keyword, "detach"))
949 detach_port(res->port_id);
951 printf("Unknown parameter\n");
954 cmdline_parse_token_string_t cmd_operate_detach_port_port =
955 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
957 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
958 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
960 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
961 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
964 cmdline_parse_inst_t cmd_operate_detach_port = {
965 .f = cmd_operate_detach_port_parsed,
967 .help_str = "port detach port_id",
969 (void *)&cmd_operate_detach_port_port,
970 (void *)&cmd_operate_detach_port_keyword,
971 (void *)&cmd_operate_detach_port_port_id,
976 /* *** configure speed for all ports *** */
977 struct cmd_config_speed_all {
978 cmdline_fixed_string_t port;
979 cmdline_fixed_string_t keyword;
980 cmdline_fixed_string_t all;
981 cmdline_fixed_string_t item1;
982 cmdline_fixed_string_t item2;
983 cmdline_fixed_string_t value1;
984 cmdline_fixed_string_t value2;
988 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
993 if (!strcmp(duplexstr, "half")) {
994 duplex = ETH_LINK_HALF_DUPLEX;
995 } else if (!strcmp(duplexstr, "full")) {
996 duplex = ETH_LINK_FULL_DUPLEX;
997 } else if (!strcmp(duplexstr, "auto")) {
998 duplex = ETH_LINK_FULL_DUPLEX;
1000 printf("Unknown duplex parameter\n");
1004 if (!strcmp(speedstr, "10")) {
1005 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1006 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1007 } else if (!strcmp(speedstr, "100")) {
1008 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1009 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1011 if (duplex != ETH_LINK_FULL_DUPLEX) {
1012 printf("Invalid speed/duplex parameters\n");
1015 if (!strcmp(speedstr, "1000")) {
1016 *speed = ETH_LINK_SPEED_1G;
1017 } else if (!strcmp(speedstr, "10000")) {
1018 *speed = ETH_LINK_SPEED_10G;
1019 } else if (!strcmp(speedstr, "40000")) {
1020 *speed = ETH_LINK_SPEED_40G;
1021 } else if (!strcmp(speedstr, "100000")) {
1022 *speed = ETH_LINK_SPEED_100G;
1023 } else if (!strcmp(speedstr, "auto")) {
1024 *speed = ETH_LINK_SPEED_AUTONEG;
1026 printf("Unknown speed parameter\n");
1035 cmd_config_speed_all_parsed(void *parsed_result,
1036 __attribute__((unused)) struct cmdline *cl,
1037 __attribute__((unused)) void *data)
1039 struct cmd_config_speed_all *res = parsed_result;
1040 uint32_t link_speed;
1043 if (!all_ports_stopped()) {
1044 printf("Please stop all ports first\n");
1048 if (parse_and_check_speed_duplex(res->value1, res->value2,
1052 FOREACH_PORT(pid, ports) {
1053 ports[pid].dev_conf.link_speeds = link_speed;
1056 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1059 cmdline_parse_token_string_t cmd_config_speed_all_port =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1061 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1062 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1064 cmdline_parse_token_string_t cmd_config_speed_all_all =
1065 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1066 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1067 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1068 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1069 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1070 "10#100#1000#10000#40000#100000#auto");
1071 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1072 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1073 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1074 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1077 cmdline_parse_inst_t cmd_config_speed_all = {
1078 .f = cmd_config_speed_all_parsed,
1080 .help_str = "port config all speed 10|100|1000|10000|40000|100000|auto duplex "
1083 (void *)&cmd_config_speed_all_port,
1084 (void *)&cmd_config_speed_all_keyword,
1085 (void *)&cmd_config_speed_all_all,
1086 (void *)&cmd_config_speed_all_item1,
1087 (void *)&cmd_config_speed_all_value1,
1088 (void *)&cmd_config_speed_all_item2,
1089 (void *)&cmd_config_speed_all_value2,
1094 /* *** configure speed for specific port *** */
1095 struct cmd_config_speed_specific {
1096 cmdline_fixed_string_t port;
1097 cmdline_fixed_string_t keyword;
1099 cmdline_fixed_string_t item1;
1100 cmdline_fixed_string_t item2;
1101 cmdline_fixed_string_t value1;
1102 cmdline_fixed_string_t value2;
1106 cmd_config_speed_specific_parsed(void *parsed_result,
1107 __attribute__((unused)) struct cmdline *cl,
1108 __attribute__((unused)) void *data)
1110 struct cmd_config_speed_specific *res = parsed_result;
1111 uint32_t link_speed;
1113 if (!all_ports_stopped()) {
1114 printf("Please stop all ports first\n");
1118 if (port_id_is_invalid(res->id, ENABLED_WARN))
1121 if (parse_and_check_speed_duplex(res->value1, res->value2,
1125 ports[res->id].dev_conf.link_speeds = link_speed;
1127 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1131 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1132 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1134 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1135 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1137 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1138 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1139 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1140 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1142 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1143 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1144 "10#100#1000#10000#40000#100000#auto");
1145 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1146 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1148 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1152 cmdline_parse_inst_t cmd_config_speed_specific = {
1153 .f = cmd_config_speed_specific_parsed,
1155 .help_str = "port config X speed 10|100|1000|10000|40000|100000|auto duplex "
1158 (void *)&cmd_config_speed_specific_port,
1159 (void *)&cmd_config_speed_specific_keyword,
1160 (void *)&cmd_config_speed_specific_id,
1161 (void *)&cmd_config_speed_specific_item1,
1162 (void *)&cmd_config_speed_specific_value1,
1163 (void *)&cmd_config_speed_specific_item2,
1164 (void *)&cmd_config_speed_specific_value2,
1169 /* *** configure txq/rxq, txd/rxd *** */
1170 struct cmd_config_rx_tx {
1171 cmdline_fixed_string_t port;
1172 cmdline_fixed_string_t keyword;
1173 cmdline_fixed_string_t all;
1174 cmdline_fixed_string_t name;
1179 cmd_config_rx_tx_parsed(void *parsed_result,
1180 __attribute__((unused)) struct cmdline *cl,
1181 __attribute__((unused)) void *data)
1183 struct cmd_config_rx_tx *res = parsed_result;
1185 if (!all_ports_stopped()) {
1186 printf("Please stop all ports first\n");
1189 if (!strcmp(res->name, "rxq")) {
1190 if (!res->value && !nb_txq) {
1191 printf("Warning: Either rx or tx queues should be non zero\n");
1194 nb_rxq = res->value;
1196 else if (!strcmp(res->name, "txq")) {
1197 if (!res->value && !nb_rxq) {
1198 printf("Warning: Either rx or tx queues should be non zero\n");
1201 nb_txq = res->value;
1203 else if (!strcmp(res->name, "rxd")) {
1204 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1205 printf("rxd %d invalid - must be > 0 && <= %d\n",
1206 res->value, RTE_TEST_RX_DESC_MAX);
1209 nb_rxd = res->value;
1210 } else if (!strcmp(res->name, "txd")) {
1211 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1212 printf("txd %d invalid - must be > 0 && <= %d\n",
1213 res->value, RTE_TEST_TX_DESC_MAX);
1216 nb_txd = res->value;
1218 printf("Unknown parameter\n");
1226 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1229 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1230 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1231 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1233 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1235 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1236 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1238 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1239 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1241 cmdline_parse_inst_t cmd_config_rx_tx = {
1242 .f = cmd_config_rx_tx_parsed,
1244 .help_str = "port config all rxq|txq|rxd|txd value",
1246 (void *)&cmd_config_rx_tx_port,
1247 (void *)&cmd_config_rx_tx_keyword,
1248 (void *)&cmd_config_rx_tx_all,
1249 (void *)&cmd_config_rx_tx_name,
1250 (void *)&cmd_config_rx_tx_value,
1255 /* *** config max packet length *** */
1256 struct cmd_config_max_pkt_len_result {
1257 cmdline_fixed_string_t port;
1258 cmdline_fixed_string_t keyword;
1259 cmdline_fixed_string_t all;
1260 cmdline_fixed_string_t name;
1265 cmd_config_max_pkt_len_parsed(void *parsed_result,
1266 __attribute__((unused)) struct cmdline *cl,
1267 __attribute__((unused)) void *data)
1269 struct cmd_config_max_pkt_len_result *res = parsed_result;
1271 if (!all_ports_stopped()) {
1272 printf("Please stop all ports first\n");
1276 if (!strcmp(res->name, "max-pkt-len")) {
1277 if (res->value < ETHER_MIN_LEN) {
1278 printf("max-pkt-len can not be less than %d\n",
1282 if (res->value == rx_mode.max_rx_pkt_len)
1285 rx_mode.max_rx_pkt_len = res->value;
1286 if (res->value > ETHER_MAX_LEN)
1287 rx_mode.jumbo_frame = 1;
1289 rx_mode.jumbo_frame = 0;
1291 printf("Unknown parameter\n");
1297 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1300 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1301 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1303 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1304 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1306 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1307 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1309 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1310 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1312 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1313 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1316 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1317 .f = cmd_config_max_pkt_len_parsed,
1319 .help_str = "port config all max-pkt-len value",
1321 (void *)&cmd_config_max_pkt_len_port,
1322 (void *)&cmd_config_max_pkt_len_keyword,
1323 (void *)&cmd_config_max_pkt_len_all,
1324 (void *)&cmd_config_max_pkt_len_name,
1325 (void *)&cmd_config_max_pkt_len_value,
1330 /* *** configure port MTU *** */
1331 struct cmd_config_mtu_result {
1332 cmdline_fixed_string_t port;
1333 cmdline_fixed_string_t keyword;
1334 cmdline_fixed_string_t mtu;
1340 cmd_config_mtu_parsed(void *parsed_result,
1341 __attribute__((unused)) struct cmdline *cl,
1342 __attribute__((unused)) void *data)
1344 struct cmd_config_mtu_result *res = parsed_result;
1346 if (res->value < ETHER_MIN_LEN) {
1347 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1350 port_mtu_set(res->port_id, res->value);
1353 cmdline_parse_token_string_t cmd_config_mtu_port =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1356 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1357 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1359 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1360 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1362 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1363 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1364 cmdline_parse_token_num_t cmd_config_mtu_value =
1365 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1367 cmdline_parse_inst_t cmd_config_mtu = {
1368 .f = cmd_config_mtu_parsed,
1370 .help_str = "port config mtu port_id value",
1372 (void *)&cmd_config_mtu_port,
1373 (void *)&cmd_config_mtu_keyword,
1374 (void *)&cmd_config_mtu_mtu,
1375 (void *)&cmd_config_mtu_port_id,
1376 (void *)&cmd_config_mtu_value,
1381 /* *** configure rx mode *** */
1382 struct cmd_config_rx_mode_flag {
1383 cmdline_fixed_string_t port;
1384 cmdline_fixed_string_t keyword;
1385 cmdline_fixed_string_t all;
1386 cmdline_fixed_string_t name;
1387 cmdline_fixed_string_t value;
1391 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1392 __attribute__((unused)) struct cmdline *cl,
1393 __attribute__((unused)) void *data)
1395 struct cmd_config_rx_mode_flag *res = parsed_result;
1397 if (!all_ports_stopped()) {
1398 printf("Please stop all ports first\n");
1402 if (!strcmp(res->name, "crc-strip")) {
1403 if (!strcmp(res->value, "on"))
1404 rx_mode.hw_strip_crc = 1;
1405 else if (!strcmp(res->value, "off"))
1406 rx_mode.hw_strip_crc = 0;
1408 printf("Unknown parameter\n");
1411 } else if (!strcmp(res->name, "scatter")) {
1412 if (!strcmp(res->value, "on"))
1413 rx_mode.enable_scatter = 1;
1414 else if (!strcmp(res->value, "off"))
1415 rx_mode.enable_scatter = 0;
1417 printf("Unknown parameter\n");
1420 } else if (!strcmp(res->name, "rx-cksum")) {
1421 if (!strcmp(res->value, "on"))
1422 rx_mode.hw_ip_checksum = 1;
1423 else if (!strcmp(res->value, "off"))
1424 rx_mode.hw_ip_checksum = 0;
1426 printf("Unknown parameter\n");
1429 } else if (!strcmp(res->name, "hw-vlan")) {
1430 if (!strcmp(res->value, "on")) {
1431 rx_mode.hw_vlan_filter = 1;
1432 rx_mode.hw_vlan_strip = 1;
1434 else if (!strcmp(res->value, "off")) {
1435 rx_mode.hw_vlan_filter = 0;
1436 rx_mode.hw_vlan_strip = 0;
1439 printf("Unknown parameter\n");
1442 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1443 if (!strcmp(res->value, "on"))
1444 rx_mode.hw_vlan_filter = 1;
1445 else if (!strcmp(res->value, "off"))
1446 rx_mode.hw_vlan_filter = 0;
1448 printf("Unknown parameter\n");
1451 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1452 if (!strcmp(res->value, "on"))
1453 rx_mode.hw_vlan_strip = 1;
1454 else if (!strcmp(res->value, "off"))
1455 rx_mode.hw_vlan_strip = 0;
1457 printf("Unknown parameter\n");
1460 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1461 if (!strcmp(res->value, "on"))
1462 rx_mode.hw_vlan_extend = 1;
1463 else if (!strcmp(res->value, "off"))
1464 rx_mode.hw_vlan_extend = 0;
1466 printf("Unknown parameter\n");
1469 } else if (!strcmp(res->name, "drop-en")) {
1470 if (!strcmp(res->value, "on"))
1472 else if (!strcmp(res->value, "off"))
1475 printf("Unknown parameter\n");
1479 printf("Unknown parameter\n");
1485 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1488 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1489 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1490 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1491 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1493 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1495 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1497 "crc-strip#scatter#rx-cksum#hw-vlan#"
1498 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1499 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1503 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1504 .f = cmd_config_rx_mode_flag_parsed,
1506 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1507 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1509 (void *)&cmd_config_rx_mode_flag_port,
1510 (void *)&cmd_config_rx_mode_flag_keyword,
1511 (void *)&cmd_config_rx_mode_flag_all,
1512 (void *)&cmd_config_rx_mode_flag_name,
1513 (void *)&cmd_config_rx_mode_flag_value,
1518 /* *** configure rss *** */
1519 struct cmd_config_rss {
1520 cmdline_fixed_string_t port;
1521 cmdline_fixed_string_t keyword;
1522 cmdline_fixed_string_t all;
1523 cmdline_fixed_string_t name;
1524 cmdline_fixed_string_t value;
1528 cmd_config_rss_parsed(void *parsed_result,
1529 __attribute__((unused)) struct cmdline *cl,
1530 __attribute__((unused)) void *data)
1532 struct cmd_config_rss *res = parsed_result;
1533 struct rte_eth_rss_conf rss_conf;
1537 if (!strcmp(res->value, "all"))
1538 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1539 ETH_RSS_UDP | ETH_RSS_SCTP |
1541 else if (!strcmp(res->value, "ip"))
1542 rss_conf.rss_hf = ETH_RSS_IP;
1543 else if (!strcmp(res->value, "udp"))
1544 rss_conf.rss_hf = ETH_RSS_UDP;
1545 else if (!strcmp(res->value, "tcp"))
1546 rss_conf.rss_hf = ETH_RSS_TCP;
1547 else if (!strcmp(res->value, "sctp"))
1548 rss_conf.rss_hf = ETH_RSS_SCTP;
1549 else if (!strcmp(res->value, "ether"))
1550 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1551 else if (!strcmp(res->value, "port"))
1552 rss_conf.rss_hf = ETH_RSS_PORT;
1553 else if (!strcmp(res->value, "vxlan"))
1554 rss_conf.rss_hf = ETH_RSS_VXLAN;
1555 else if (!strcmp(res->value, "geneve"))
1556 rss_conf.rss_hf = ETH_RSS_GENEVE;
1557 else if (!strcmp(res->value, "nvgre"))
1558 rss_conf.rss_hf = ETH_RSS_NVGRE;
1559 else if (!strcmp(res->value, "none"))
1560 rss_conf.rss_hf = 0;
1562 printf("Unknown parameter\n");
1565 rss_conf.rss_key = NULL;
1566 for (i = 0; i < rte_eth_dev_count(); i++) {
1567 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1569 printf("Configuration of RSS hash at ethernet port %d "
1570 "failed with error (%d): %s.\n",
1571 i, -diag, strerror(-diag));
1575 cmdline_parse_token_string_t cmd_config_rss_port =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1577 cmdline_parse_token_string_t cmd_config_rss_keyword =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1579 cmdline_parse_token_string_t cmd_config_rss_all =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1581 cmdline_parse_token_string_t cmd_config_rss_name =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1583 cmdline_parse_token_string_t cmd_config_rss_value =
1584 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1585 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1587 cmdline_parse_inst_t cmd_config_rss = {
1588 .f = cmd_config_rss_parsed,
1590 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1592 (void *)&cmd_config_rss_port,
1593 (void *)&cmd_config_rss_keyword,
1594 (void *)&cmd_config_rss_all,
1595 (void *)&cmd_config_rss_name,
1596 (void *)&cmd_config_rss_value,
1601 /* *** configure rss hash key *** */
1602 struct cmd_config_rss_hash_key {
1603 cmdline_fixed_string_t port;
1604 cmdline_fixed_string_t config;
1606 cmdline_fixed_string_t rss_hash_key;
1607 cmdline_fixed_string_t rss_type;
1608 cmdline_fixed_string_t key;
1611 #define RSS_HASH_KEY_LENGTH 40
1613 hexa_digit_to_value(char hexa_digit)
1615 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1616 return (uint8_t) (hexa_digit - '0');
1617 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1618 return (uint8_t) ((hexa_digit - 'a') + 10);
1619 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1620 return (uint8_t) ((hexa_digit - 'A') + 10);
1621 /* Invalid hexa digit */
1626 parse_and_check_key_hexa_digit(char *key, int idx)
1630 hexa_v = hexa_digit_to_value(key[idx]);
1632 printf("invalid key: character %c at position %d is not a "
1633 "valid hexa digit\n", key[idx], idx);
1638 cmd_config_rss_hash_key_parsed(void *parsed_result,
1639 __attribute__((unused)) struct cmdline *cl,
1640 __attribute__((unused)) void *data)
1642 struct cmd_config_rss_hash_key *res = parsed_result;
1643 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1648 /* Check the length of the RSS hash key */
1649 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1650 printf("key length: %d invalid - key must be a string of %d"
1651 "hexa-decimal numbers\n", (int) strlen(res->key),
1652 RSS_HASH_KEY_LENGTH * 2);
1655 /* Translate RSS hash key into binary representation */
1656 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1657 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1660 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1663 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1665 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1666 RSS_HASH_KEY_LENGTH);
1669 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1671 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1674 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1675 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1676 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1678 rss_hash_key, "rss-hash-key");
1679 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1681 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1682 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1683 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1684 "ipv6-tcp-ex#ipv6-udp-ex");
1685 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1686 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1688 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1689 .f = cmd_config_rss_hash_key_parsed,
1692 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1693 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1694 "ipv6-sctp|ipv6-other|l2-payload|"
1695 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1697 (void *)&cmd_config_rss_hash_key_port,
1698 (void *)&cmd_config_rss_hash_key_config,
1699 (void *)&cmd_config_rss_hash_key_port_id,
1700 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1701 (void *)&cmd_config_rss_hash_key_rss_type,
1702 (void *)&cmd_config_rss_hash_key_value,
1707 /* *** configure port rxq/txq start/stop *** */
1708 struct cmd_config_rxtx_queue {
1709 cmdline_fixed_string_t port;
1711 cmdline_fixed_string_t rxtxq;
1713 cmdline_fixed_string_t opname;
1717 cmd_config_rxtx_queue_parsed(void *parsed_result,
1718 __attribute__((unused)) struct cmdline *cl,
1719 __attribute__((unused)) void *data)
1721 struct cmd_config_rxtx_queue *res = parsed_result;
1726 if (test_done == 0) {
1727 printf("Please stop forwarding first\n");
1731 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1734 if (port_is_started(res->portid) != 1) {
1735 printf("Please start port %u first\n", res->portid);
1739 if (!strcmp(res->rxtxq, "rxq"))
1741 else if (!strcmp(res->rxtxq, "txq"))
1744 printf("Unknown parameter\n");
1748 if (isrx && rx_queue_id_is_invalid(res->qid))
1750 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1753 if (!strcmp(res->opname, "start"))
1755 else if (!strcmp(res->opname, "stop"))
1758 printf("Unknown parameter\n");
1762 if (isstart && isrx)
1763 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1764 else if (!isstart && isrx)
1765 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1766 else if (isstart && !isrx)
1767 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1769 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1771 if (ret == -ENOTSUP)
1772 printf("Function not supported in PMD driver\n");
1775 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1777 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1778 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1779 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1780 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1781 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1782 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1783 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1784 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1787 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1788 .f = cmd_config_rxtx_queue_parsed,
1790 .help_str = "port X rxq|txq ID start|stop",
1792 (void *)&cmd_config_speed_all_port,
1793 (void *)&cmd_config_rxtx_queue_portid,
1794 (void *)&cmd_config_rxtx_queue_rxtxq,
1795 (void *)&cmd_config_rxtx_queue_qid,
1796 (void *)&cmd_config_rxtx_queue_opname,
1801 /* *** Configure RSS RETA *** */
1802 struct cmd_config_rss_reta {
1803 cmdline_fixed_string_t port;
1804 cmdline_fixed_string_t keyword;
1806 cmdline_fixed_string_t name;
1807 cmdline_fixed_string_t list_name;
1808 cmdline_fixed_string_t list_of_items;
1812 parse_reta_config(const char *str,
1813 struct rte_eth_rss_reta_entry64 *reta_conf,
1814 uint16_t nb_entries)
1818 uint16_t hash_index, idx, shift;
1821 const char *p, *p0 = str;
1828 unsigned long int_fld[_NUM_FLD];
1829 char *str_fld[_NUM_FLD];
1831 while ((p = strchr(p0,'(')) != NULL) {
1833 if((p0 = strchr(p,')')) == NULL)
1837 if(size >= sizeof(s))
1840 snprintf(s, sizeof(s), "%.*s", size, p);
1841 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1843 for (i = 0; i < _NUM_FLD; i++) {
1845 int_fld[i] = strtoul(str_fld[i], &end, 0);
1846 if (errno != 0 || end == str_fld[i] ||
1851 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1852 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1854 if (hash_index >= nb_entries) {
1855 printf("Invalid RETA hash index=%d\n", hash_index);
1859 idx = hash_index / RTE_RETA_GROUP_SIZE;
1860 shift = hash_index % RTE_RETA_GROUP_SIZE;
1861 reta_conf[idx].mask |= (1ULL << shift);
1862 reta_conf[idx].reta[shift] = nb_queue;
1869 cmd_set_rss_reta_parsed(void *parsed_result,
1870 __attribute__((unused)) struct cmdline *cl,
1871 __attribute__((unused)) void *data)
1874 struct rte_eth_dev_info dev_info;
1875 struct rte_eth_rss_reta_entry64 reta_conf[8];
1876 struct cmd_config_rss_reta *res = parsed_result;
1878 memset(&dev_info, 0, sizeof(dev_info));
1879 rte_eth_dev_info_get(res->port_id, &dev_info);
1880 if (dev_info.reta_size == 0) {
1881 printf("Redirection table size is 0 which is "
1882 "invalid for RSS\n");
1885 printf("The reta size of port %d is %u\n",
1886 res->port_id, dev_info.reta_size);
1887 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1888 printf("Currently do not support more than %u entries of "
1889 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1893 memset(reta_conf, 0, sizeof(reta_conf));
1894 if (!strcmp(res->list_name, "reta")) {
1895 if (parse_reta_config(res->list_of_items, reta_conf,
1896 dev_info.reta_size)) {
1897 printf("Invalid RSS Redirection Table "
1898 "config entered\n");
1901 ret = rte_eth_dev_rss_reta_update(res->port_id,
1902 reta_conf, dev_info.reta_size);
1904 printf("Bad redirection table parameter, "
1905 "return code = %d \n", ret);
1909 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1910 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1911 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1912 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1913 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1914 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1915 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1916 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1917 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1918 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1919 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1922 cmdline_parse_inst_t cmd_config_rss_reta = {
1923 .f = cmd_set_rss_reta_parsed,
1925 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1927 (void *)&cmd_config_rss_reta_port,
1928 (void *)&cmd_config_rss_reta_keyword,
1929 (void *)&cmd_config_rss_reta_port_id,
1930 (void *)&cmd_config_rss_reta_name,
1931 (void *)&cmd_config_rss_reta_list_name,
1932 (void *)&cmd_config_rss_reta_list_of_items,
1937 /* *** SHOW PORT RETA INFO *** */
1938 struct cmd_showport_reta {
1939 cmdline_fixed_string_t show;
1940 cmdline_fixed_string_t port;
1942 cmdline_fixed_string_t rss;
1943 cmdline_fixed_string_t reta;
1945 cmdline_fixed_string_t list_of_items;
1949 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1950 uint16_t nb_entries,
1954 const char *p, *p0 = str;
1958 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1961 p = strchr(p0, '(');
1965 p0 = strchr(p, ')');
1969 if (size >= sizeof(s)) {
1970 printf("The string size exceeds the internal buffer size\n");
1973 snprintf(s, sizeof(s), "%.*s", size, p);
1974 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1975 if (ret <= 0 || ret != num) {
1976 printf("The bits of masks do not match the number of "
1977 "reta entries: %u\n", num);
1980 for (i = 0; i < ret; i++)
1981 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1987 cmd_showport_reta_parsed(void *parsed_result,
1988 __attribute__((unused)) struct cmdline *cl,
1989 __attribute__((unused)) void *data)
1991 struct cmd_showport_reta *res = parsed_result;
1992 struct rte_eth_rss_reta_entry64 reta_conf[8];
1993 struct rte_eth_dev_info dev_info;
1995 memset(&dev_info, 0, sizeof(dev_info));
1996 rte_eth_dev_info_get(res->port_id, &dev_info);
1997 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1998 res->size > ETH_RSS_RETA_SIZE_512) {
1999 printf("Invalid redirection table size: %u\n", res->size);
2003 memset(reta_conf, 0, sizeof(reta_conf));
2004 if (showport_parse_reta_config(reta_conf, res->size,
2005 res->list_of_items) < 0) {
2006 printf("Invalid string: %s for reta masks\n",
2007 res->list_of_items);
2010 port_rss_reta_info(res->port_id, reta_conf, res->size);
2013 cmdline_parse_token_string_t cmd_showport_reta_show =
2014 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2015 cmdline_parse_token_string_t cmd_showport_reta_port =
2016 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2017 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2018 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2019 cmdline_parse_token_string_t cmd_showport_reta_rss =
2020 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2021 cmdline_parse_token_string_t cmd_showport_reta_reta =
2022 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2023 cmdline_parse_token_num_t cmd_showport_reta_size =
2024 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2025 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2026 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2027 list_of_items, NULL);
2029 cmdline_parse_inst_t cmd_showport_reta = {
2030 .f = cmd_showport_reta_parsed,
2032 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2034 (void *)&cmd_showport_reta_show,
2035 (void *)&cmd_showport_reta_port,
2036 (void *)&cmd_showport_reta_port_id,
2037 (void *)&cmd_showport_reta_rss,
2038 (void *)&cmd_showport_reta_reta,
2039 (void *)&cmd_showport_reta_size,
2040 (void *)&cmd_showport_reta_list_of_items,
2045 /* *** Show RSS hash configuration *** */
2046 struct cmd_showport_rss_hash {
2047 cmdline_fixed_string_t show;
2048 cmdline_fixed_string_t port;
2050 cmdline_fixed_string_t rss_hash;
2051 cmdline_fixed_string_t rss_type;
2052 cmdline_fixed_string_t key; /* optional argument */
2055 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2056 __attribute__((unused)) struct cmdline *cl,
2059 struct cmd_showport_rss_hash *res = parsed_result;
2061 port_rss_hash_conf_show(res->port_id, res->rss_type,
2062 show_rss_key != NULL);
2065 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2066 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2067 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2068 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2069 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2070 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2071 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2072 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2074 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2075 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2076 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2077 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2078 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2079 "ipv6-tcp-ex#ipv6-udp-ex");
2080 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2081 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2083 cmdline_parse_inst_t cmd_showport_rss_hash = {
2084 .f = cmd_showport_rss_hash_parsed,
2087 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2088 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2089 "ipv6-sctp|ipv6-other|l2-payload|"
2090 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2092 (void *)&cmd_showport_rss_hash_show,
2093 (void *)&cmd_showport_rss_hash_port,
2094 (void *)&cmd_showport_rss_hash_port_id,
2095 (void *)&cmd_showport_rss_hash_rss_hash,
2096 (void *)&cmd_showport_rss_hash_rss_hash_info,
2101 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2102 .f = cmd_showport_rss_hash_parsed,
2105 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2106 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2107 "ipv6-sctp|ipv6-other|l2-payload|"
2108 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2110 (void *)&cmd_showport_rss_hash_show,
2111 (void *)&cmd_showport_rss_hash_port,
2112 (void *)&cmd_showport_rss_hash_port_id,
2113 (void *)&cmd_showport_rss_hash_rss_hash,
2114 (void *)&cmd_showport_rss_hash_rss_hash_info,
2115 (void *)&cmd_showport_rss_hash_rss_key,
2120 /* *** Configure DCB *** */
2121 struct cmd_config_dcb {
2122 cmdline_fixed_string_t port;
2123 cmdline_fixed_string_t config;
2125 cmdline_fixed_string_t dcb;
2126 cmdline_fixed_string_t vt;
2127 cmdline_fixed_string_t vt_en;
2129 cmdline_fixed_string_t pfc;
2130 cmdline_fixed_string_t pfc_en;
2134 cmd_config_dcb_parsed(void *parsed_result,
2135 __attribute__((unused)) struct cmdline *cl,
2136 __attribute__((unused)) void *data)
2138 struct cmd_config_dcb *res = parsed_result;
2139 portid_t port_id = res->port_id;
2140 struct rte_port *port;
2144 port = &ports[port_id];
2145 /** Check if the port is not started **/
2146 if (port->port_status != RTE_PORT_STOPPED) {
2147 printf("Please stop port %d first\n", port_id);
2151 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2152 printf("The invalid number of traffic class,"
2153 " only 4 or 8 allowed.\n");
2157 if (nb_fwd_lcores < res->num_tcs) {
2158 printf("nb_cores shouldn't be less than number of TCs.\n");
2161 if (!strncmp(res->pfc_en, "on", 2))
2166 /* DCB in VT mode */
2167 if (!strncmp(res->vt_en, "on", 2))
2168 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2169 (enum rte_eth_nb_tcs)res->num_tcs,
2172 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2173 (enum rte_eth_nb_tcs)res->num_tcs,
2178 printf("Cannot initialize network ports.\n");
2182 cmd_reconfig_device_queue(port_id, 1, 1);
2185 cmdline_parse_token_string_t cmd_config_dcb_port =
2186 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2187 cmdline_parse_token_string_t cmd_config_dcb_config =
2188 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2189 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2190 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2191 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2192 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2193 cmdline_parse_token_string_t cmd_config_dcb_vt =
2194 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2195 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2196 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2197 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2198 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2199 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2200 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2201 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2202 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2204 cmdline_parse_inst_t cmd_config_dcb = {
2205 .f = cmd_config_dcb_parsed,
2207 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2209 (void *)&cmd_config_dcb_port,
2210 (void *)&cmd_config_dcb_config,
2211 (void *)&cmd_config_dcb_port_id,
2212 (void *)&cmd_config_dcb_dcb,
2213 (void *)&cmd_config_dcb_vt,
2214 (void *)&cmd_config_dcb_vt_en,
2215 (void *)&cmd_config_dcb_num_tcs,
2216 (void *)&cmd_config_dcb_pfc,
2217 (void *)&cmd_config_dcb_pfc_en,
2222 /* *** configure number of packets per burst *** */
2223 struct cmd_config_burst {
2224 cmdline_fixed_string_t port;
2225 cmdline_fixed_string_t keyword;
2226 cmdline_fixed_string_t all;
2227 cmdline_fixed_string_t name;
2232 cmd_config_burst_parsed(void *parsed_result,
2233 __attribute__((unused)) struct cmdline *cl,
2234 __attribute__((unused)) void *data)
2236 struct cmd_config_burst *res = parsed_result;
2238 if (!all_ports_stopped()) {
2239 printf("Please stop all ports first\n");
2243 if (!strcmp(res->name, "burst")) {
2244 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2245 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2248 nb_pkt_per_burst = res->value;
2250 printf("Unknown parameter\n");
2256 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2259 cmdline_parse_token_string_t cmd_config_burst_port =
2260 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2261 cmdline_parse_token_string_t cmd_config_burst_keyword =
2262 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2263 cmdline_parse_token_string_t cmd_config_burst_all =
2264 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2265 cmdline_parse_token_string_t cmd_config_burst_name =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2267 cmdline_parse_token_num_t cmd_config_burst_value =
2268 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2270 cmdline_parse_inst_t cmd_config_burst = {
2271 .f = cmd_config_burst_parsed,
2273 .help_str = "port config all burst value",
2275 (void *)&cmd_config_burst_port,
2276 (void *)&cmd_config_burst_keyword,
2277 (void *)&cmd_config_burst_all,
2278 (void *)&cmd_config_burst_name,
2279 (void *)&cmd_config_burst_value,
2284 /* *** configure rx/tx queues *** */
2285 struct cmd_config_thresh {
2286 cmdline_fixed_string_t port;
2287 cmdline_fixed_string_t keyword;
2288 cmdline_fixed_string_t all;
2289 cmdline_fixed_string_t name;
2294 cmd_config_thresh_parsed(void *parsed_result,
2295 __attribute__((unused)) struct cmdline *cl,
2296 __attribute__((unused)) void *data)
2298 struct cmd_config_thresh *res = parsed_result;
2300 if (!all_ports_stopped()) {
2301 printf("Please stop all ports first\n");
2305 if (!strcmp(res->name, "txpt"))
2306 tx_pthresh = res->value;
2307 else if(!strcmp(res->name, "txht"))
2308 tx_hthresh = res->value;
2309 else if(!strcmp(res->name, "txwt"))
2310 tx_wthresh = res->value;
2311 else if(!strcmp(res->name, "rxpt"))
2312 rx_pthresh = res->value;
2313 else if(!strcmp(res->name, "rxht"))
2314 rx_hthresh = res->value;
2315 else if(!strcmp(res->name, "rxwt"))
2316 rx_wthresh = res->value;
2318 printf("Unknown parameter\n");
2324 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2327 cmdline_parse_token_string_t cmd_config_thresh_port =
2328 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2329 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2330 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2331 cmdline_parse_token_string_t cmd_config_thresh_all =
2332 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2333 cmdline_parse_token_string_t cmd_config_thresh_name =
2334 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2335 "txpt#txht#txwt#rxpt#rxht#rxwt");
2336 cmdline_parse_token_num_t cmd_config_thresh_value =
2337 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2339 cmdline_parse_inst_t cmd_config_thresh = {
2340 .f = cmd_config_thresh_parsed,
2342 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2344 (void *)&cmd_config_thresh_port,
2345 (void *)&cmd_config_thresh_keyword,
2346 (void *)&cmd_config_thresh_all,
2347 (void *)&cmd_config_thresh_name,
2348 (void *)&cmd_config_thresh_value,
2353 /* *** configure free/rs threshold *** */
2354 struct cmd_config_threshold {
2355 cmdline_fixed_string_t port;
2356 cmdline_fixed_string_t keyword;
2357 cmdline_fixed_string_t all;
2358 cmdline_fixed_string_t name;
2363 cmd_config_threshold_parsed(void *parsed_result,
2364 __attribute__((unused)) struct cmdline *cl,
2365 __attribute__((unused)) void *data)
2367 struct cmd_config_threshold *res = parsed_result;
2369 if (!all_ports_stopped()) {
2370 printf("Please stop all ports first\n");
2374 if (!strcmp(res->name, "txfreet"))
2375 tx_free_thresh = res->value;
2376 else if (!strcmp(res->name, "txrst"))
2377 tx_rs_thresh = res->value;
2378 else if (!strcmp(res->name, "rxfreet"))
2379 rx_free_thresh = res->value;
2381 printf("Unknown parameter\n");
2387 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2390 cmdline_parse_token_string_t cmd_config_threshold_port =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2392 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2393 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2395 cmdline_parse_token_string_t cmd_config_threshold_all =
2396 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2397 cmdline_parse_token_string_t cmd_config_threshold_name =
2398 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2399 "txfreet#txrst#rxfreet");
2400 cmdline_parse_token_num_t cmd_config_threshold_value =
2401 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2403 cmdline_parse_inst_t cmd_config_threshold = {
2404 .f = cmd_config_threshold_parsed,
2406 .help_str = "port config all txfreet|txrst|rxfreet value",
2408 (void *)&cmd_config_threshold_port,
2409 (void *)&cmd_config_threshold_keyword,
2410 (void *)&cmd_config_threshold_all,
2411 (void *)&cmd_config_threshold_name,
2412 (void *)&cmd_config_threshold_value,
2418 struct cmd_stop_result {
2419 cmdline_fixed_string_t stop;
2422 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2423 __attribute__((unused)) struct cmdline *cl,
2424 __attribute__((unused)) void *data)
2426 stop_packet_forwarding();
2429 cmdline_parse_token_string_t cmd_stop_stop =
2430 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2432 cmdline_parse_inst_t cmd_stop = {
2433 .f = cmd_stop_parsed,
2435 .help_str = "stop - stop packet forwarding",
2437 (void *)&cmd_stop_stop,
2442 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2445 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2446 unsigned int *parsed_items, int check_unique_values)
2448 unsigned int nb_item;
2456 * First parse all items in the list and store their value.
2461 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2463 if ((c >= '0') && (c <= '9')) {
2464 value = (unsigned int) (value * 10 + (c - '0'));
2469 printf("character %c is not a decimal digit\n", c);
2473 printf("No valid value before comma\n");
2476 if (nb_item < max_items) {
2477 parsed_items[nb_item] = value;
2483 if (nb_item >= max_items) {
2484 printf("Number of %s = %u > %u (maximum items)\n",
2485 item_name, nb_item + 1, max_items);
2488 parsed_items[nb_item++] = value;
2489 if (! check_unique_values)
2493 * Then, check that all values in the list are differents.
2494 * No optimization here...
2496 for (i = 0; i < nb_item; i++) {
2497 for (j = i + 1; j < nb_item; j++) {
2498 if (parsed_items[j] == parsed_items[i]) {
2499 printf("duplicated %s %u at index %u and %u\n",
2500 item_name, parsed_items[i], i, j);
2508 struct cmd_set_list_result {
2509 cmdline_fixed_string_t cmd_keyword;
2510 cmdline_fixed_string_t list_name;
2511 cmdline_fixed_string_t list_of_items;
2514 static void cmd_set_list_parsed(void *parsed_result,
2515 __attribute__((unused)) struct cmdline *cl,
2516 __attribute__((unused)) void *data)
2518 struct cmd_set_list_result *res;
2520 unsigned int lcorelist[RTE_MAX_LCORE];
2521 unsigned int portlist[RTE_MAX_ETHPORTS];
2523 unsigned int nb_item;
2525 if (test_done == 0) {
2526 printf("Please stop forwarding first\n");
2530 res = parsed_result;
2531 if (!strcmp(res->list_name, "corelist")) {
2532 nb_item = parse_item_list(res->list_of_items, "core",
2534 parsed_items.lcorelist, 1);
2536 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2541 if (!strcmp(res->list_name, "portlist")) {
2542 nb_item = parse_item_list(res->list_of_items, "port",
2544 parsed_items.portlist, 1);
2546 set_fwd_ports_list(parsed_items.portlist, nb_item);
2552 cmdline_parse_token_string_t cmd_set_list_keyword =
2553 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2555 cmdline_parse_token_string_t cmd_set_list_name =
2556 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2557 "corelist#portlist");
2558 cmdline_parse_token_string_t cmd_set_list_of_items =
2559 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2562 cmdline_parse_inst_t cmd_set_fwd_list = {
2563 .f = cmd_set_list_parsed,
2565 .help_str = "set corelist|portlist x[,y]*",
2567 (void *)&cmd_set_list_keyword,
2568 (void *)&cmd_set_list_name,
2569 (void *)&cmd_set_list_of_items,
2574 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2576 struct cmd_setmask_result {
2577 cmdline_fixed_string_t set;
2578 cmdline_fixed_string_t mask;
2582 static void cmd_set_mask_parsed(void *parsed_result,
2583 __attribute__((unused)) struct cmdline *cl,
2584 __attribute__((unused)) void *data)
2586 struct cmd_setmask_result *res = parsed_result;
2588 if (test_done == 0) {
2589 printf("Please stop forwarding first\n");
2592 if (!strcmp(res->mask, "coremask")) {
2593 set_fwd_lcores_mask(res->hexavalue);
2595 } else if (!strcmp(res->mask, "portmask")) {
2596 set_fwd_ports_mask(res->hexavalue);
2601 cmdline_parse_token_string_t cmd_setmask_set =
2602 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2603 cmdline_parse_token_string_t cmd_setmask_mask =
2604 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2605 "coremask#portmask");
2606 cmdline_parse_token_num_t cmd_setmask_value =
2607 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2609 cmdline_parse_inst_t cmd_set_fwd_mask = {
2610 .f = cmd_set_mask_parsed,
2612 .help_str = "set coremask|portmask hexadecimal value",
2614 (void *)&cmd_setmask_set,
2615 (void *)&cmd_setmask_mask,
2616 (void *)&cmd_setmask_value,
2622 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2624 struct cmd_set_result {
2625 cmdline_fixed_string_t set;
2626 cmdline_fixed_string_t what;
2630 static void cmd_set_parsed(void *parsed_result,
2631 __attribute__((unused)) struct cmdline *cl,
2632 __attribute__((unused)) void *data)
2634 struct cmd_set_result *res = parsed_result;
2635 if (!strcmp(res->what, "nbport")) {
2636 set_fwd_ports_number(res->value);
2638 } else if (!strcmp(res->what, "nbcore")) {
2639 set_fwd_lcores_number(res->value);
2641 } else if (!strcmp(res->what, "burst"))
2642 set_nb_pkt_per_burst(res->value);
2643 else if (!strcmp(res->what, "verbose"))
2644 set_verbose_level(res->value);
2647 cmdline_parse_token_string_t cmd_set_set =
2648 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2649 cmdline_parse_token_string_t cmd_set_what =
2650 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2651 "nbport#nbcore#burst#verbose");
2652 cmdline_parse_token_num_t cmd_set_value =
2653 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2655 cmdline_parse_inst_t cmd_set_numbers = {
2656 .f = cmd_set_parsed,
2658 .help_str = "set nbport|nbcore|burst|verbose value",
2660 (void *)&cmd_set_set,
2661 (void *)&cmd_set_what,
2662 (void *)&cmd_set_value,
2667 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2669 struct cmd_set_txpkts_result {
2670 cmdline_fixed_string_t cmd_keyword;
2671 cmdline_fixed_string_t txpkts;
2672 cmdline_fixed_string_t seg_lengths;
2676 cmd_set_txpkts_parsed(void *parsed_result,
2677 __attribute__((unused)) struct cmdline *cl,
2678 __attribute__((unused)) void *data)
2680 struct cmd_set_txpkts_result *res;
2681 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2682 unsigned int nb_segs;
2684 res = parsed_result;
2685 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2686 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2688 set_tx_pkt_segments(seg_lengths, nb_segs);
2691 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2692 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2693 cmd_keyword, "set");
2694 cmdline_parse_token_string_t cmd_set_txpkts_name =
2695 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2697 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2698 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2701 cmdline_parse_inst_t cmd_set_txpkts = {
2702 .f = cmd_set_txpkts_parsed,
2704 .help_str = "set txpkts x[,y]*",
2706 (void *)&cmd_set_txpkts_keyword,
2707 (void *)&cmd_set_txpkts_name,
2708 (void *)&cmd_set_txpkts_lengths,
2713 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2715 struct cmd_set_txsplit_result {
2716 cmdline_fixed_string_t cmd_keyword;
2717 cmdline_fixed_string_t txsplit;
2718 cmdline_fixed_string_t mode;
2722 cmd_set_txsplit_parsed(void *parsed_result,
2723 __attribute__((unused)) struct cmdline *cl,
2724 __attribute__((unused)) void *data)
2726 struct cmd_set_txsplit_result *res;
2728 res = parsed_result;
2729 set_tx_pkt_split(res->mode);
2732 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2733 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2734 cmd_keyword, "set");
2735 cmdline_parse_token_string_t cmd_set_txsplit_name =
2736 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2737 txsplit, "txsplit");
2738 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2739 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2742 cmdline_parse_inst_t cmd_set_txsplit = {
2743 .f = cmd_set_txsplit_parsed,
2745 .help_str = "set txsplit on|off|rand",
2747 (void *)&cmd_set_txsplit_keyword,
2748 (void *)&cmd_set_txsplit_name,
2749 (void *)&cmd_set_txsplit_mode,
2754 /* *** CONFIG TX QUEUE FLAGS *** */
2756 struct cmd_config_txqflags_result {
2757 cmdline_fixed_string_t port;
2758 cmdline_fixed_string_t config;
2759 cmdline_fixed_string_t all;
2760 cmdline_fixed_string_t what;
2764 static void cmd_config_txqflags_parsed(void *parsed_result,
2765 __attribute__((unused)) struct cmdline *cl,
2766 __attribute__((unused)) void *data)
2768 struct cmd_config_txqflags_result *res = parsed_result;
2770 if (!all_ports_stopped()) {
2771 printf("Please stop all ports first\n");
2775 if (strcmp(res->what, "txqflags")) {
2776 printf("Unknown parameter\n");
2780 if (res->hexvalue >= 0) {
2781 txq_flags = res->hexvalue;
2783 printf("txqflags must be >= 0\n");
2789 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2792 cmdline_parse_token_string_t cmd_config_txqflags_port =
2793 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2795 cmdline_parse_token_string_t cmd_config_txqflags_config =
2796 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2798 cmdline_parse_token_string_t cmd_config_txqflags_all =
2799 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2801 cmdline_parse_token_string_t cmd_config_txqflags_what =
2802 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2804 cmdline_parse_token_num_t cmd_config_txqflags_value =
2805 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2808 cmdline_parse_inst_t cmd_config_txqflags = {
2809 .f = cmd_config_txqflags_parsed,
2811 .help_str = "port config all txqflags value",
2813 (void *)&cmd_config_txqflags_port,
2814 (void *)&cmd_config_txqflags_config,
2815 (void *)&cmd_config_txqflags_all,
2816 (void *)&cmd_config_txqflags_what,
2817 (void *)&cmd_config_txqflags_value,
2822 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2823 struct cmd_rx_vlan_filter_all_result {
2824 cmdline_fixed_string_t rx_vlan;
2825 cmdline_fixed_string_t what;
2826 cmdline_fixed_string_t all;
2831 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2832 __attribute__((unused)) struct cmdline *cl,
2833 __attribute__((unused)) void *data)
2835 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2837 if (!strcmp(res->what, "add"))
2838 rx_vlan_all_filter_set(res->port_id, 1);
2840 rx_vlan_all_filter_set(res->port_id, 0);
2843 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2844 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2845 rx_vlan, "rx_vlan");
2846 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2847 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2849 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2850 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2852 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2853 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2856 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2857 .f = cmd_rx_vlan_filter_all_parsed,
2859 .help_str = "add/remove all identifiers to/from the set of VLAN "
2860 "Identifiers filtered by a port",
2862 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2863 (void *)&cmd_rx_vlan_filter_all_what,
2864 (void *)&cmd_rx_vlan_filter_all_all,
2865 (void *)&cmd_rx_vlan_filter_all_portid,
2870 /* *** VLAN OFFLOAD SET ON A PORT *** */
2871 struct cmd_vlan_offload_result {
2872 cmdline_fixed_string_t vlan;
2873 cmdline_fixed_string_t set;
2874 cmdline_fixed_string_t vlan_type;
2875 cmdline_fixed_string_t what;
2876 cmdline_fixed_string_t on;
2877 cmdline_fixed_string_t port_id;
2881 cmd_vlan_offload_parsed(void *parsed_result,
2882 __attribute__((unused)) struct cmdline *cl,
2883 __attribute__((unused)) void *data)
2886 struct cmd_vlan_offload_result *res = parsed_result;
2889 portid_t port_id = 0;
2893 len = strnlen(str, STR_TOKEN_SIZE);
2895 /* Get port_id first */
2903 tmp = strtoul(str, NULL, 0);
2904 /* If port_id greater that what portid_t can represent, return */
2905 if(tmp >= RTE_MAX_ETHPORTS)
2907 port_id = (portid_t)tmp;
2909 if (!strcmp(res->on, "on"))
2914 if (!strcmp(res->what, "strip"))
2915 rx_vlan_strip_set(port_id, on);
2916 else if(!strcmp(res->what, "stripq")){
2917 uint16_t queue_id = 0;
2919 /* No queue_id, return */
2921 printf("must specify (port,queue_id)\n");
2924 tmp = strtoul(str + i + 1, NULL, 0);
2925 /* If queue_id greater that what 16-bits can represent, return */
2929 queue_id = (uint16_t)tmp;
2930 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2932 else if (!strcmp(res->what, "filter"))
2933 rx_vlan_filter_set(port_id, on);
2935 vlan_extend_set(port_id, on);
2940 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2941 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2943 cmdline_parse_token_string_t cmd_vlan_offload_set =
2944 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2946 cmdline_parse_token_string_t cmd_vlan_offload_what =
2947 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2948 what, "strip#filter#qinq#stripq");
2949 cmdline_parse_token_string_t cmd_vlan_offload_on =
2950 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2952 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2953 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2956 cmdline_parse_inst_t cmd_vlan_offload = {
2957 .f = cmd_vlan_offload_parsed,
2959 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2960 " qinq(extended) for both rx/tx sides ",
2962 (void *)&cmd_vlan_offload_vlan,
2963 (void *)&cmd_vlan_offload_set,
2964 (void *)&cmd_vlan_offload_what,
2965 (void *)&cmd_vlan_offload_on,
2966 (void *)&cmd_vlan_offload_portid,
2971 /* *** VLAN TPID SET ON A PORT *** */
2972 struct cmd_vlan_tpid_result {
2973 cmdline_fixed_string_t vlan;
2974 cmdline_fixed_string_t set;
2975 cmdline_fixed_string_t vlan_type;
2976 cmdline_fixed_string_t what;
2982 cmd_vlan_tpid_parsed(void *parsed_result,
2983 __attribute__((unused)) struct cmdline *cl,
2984 __attribute__((unused)) void *data)
2986 struct cmd_vlan_tpid_result *res = parsed_result;
2987 enum rte_vlan_type vlan_type;
2989 if (!strcmp(res->vlan_type, "inner"))
2990 vlan_type = ETH_VLAN_TYPE_INNER;
2991 else if (!strcmp(res->vlan_type, "outer"))
2992 vlan_type = ETH_VLAN_TYPE_OUTER;
2994 printf("Unknown vlan type\n");
2997 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3000 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3001 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3003 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3004 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3006 cmdline_parse_token_string_t cmd_vlan_type =
3007 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3008 vlan_type, "inner#outer");
3009 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3010 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3012 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3013 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3015 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3016 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3019 cmdline_parse_inst_t cmd_vlan_tpid = {
3020 .f = cmd_vlan_tpid_parsed,
3022 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
3025 (void *)&cmd_vlan_tpid_vlan,
3026 (void *)&cmd_vlan_tpid_set,
3027 (void *)&cmd_vlan_type,
3028 (void *)&cmd_vlan_tpid_what,
3029 (void *)&cmd_vlan_tpid_tpid,
3030 (void *)&cmd_vlan_tpid_portid,
3035 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3036 struct cmd_rx_vlan_filter_result {
3037 cmdline_fixed_string_t rx_vlan;
3038 cmdline_fixed_string_t what;
3044 cmd_rx_vlan_filter_parsed(void *parsed_result,
3045 __attribute__((unused)) struct cmdline *cl,
3046 __attribute__((unused)) void *data)
3048 struct cmd_rx_vlan_filter_result *res = parsed_result;
3050 if (!strcmp(res->what, "add"))
3051 rx_vft_set(res->port_id, res->vlan_id, 1);
3053 rx_vft_set(res->port_id, res->vlan_id, 0);
3056 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3057 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3058 rx_vlan, "rx_vlan");
3059 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3060 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3062 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3063 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3065 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3066 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3069 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3070 .f = cmd_rx_vlan_filter_parsed,
3072 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
3073 "Identifiers filtered by a port",
3075 (void *)&cmd_rx_vlan_filter_rx_vlan,
3076 (void *)&cmd_rx_vlan_filter_what,
3077 (void *)&cmd_rx_vlan_filter_vlanid,
3078 (void *)&cmd_rx_vlan_filter_portid,
3083 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3084 struct cmd_tx_vlan_set_result {
3085 cmdline_fixed_string_t tx_vlan;
3086 cmdline_fixed_string_t set;
3092 cmd_tx_vlan_set_parsed(void *parsed_result,
3093 __attribute__((unused)) struct cmdline *cl,
3094 __attribute__((unused)) void *data)
3096 struct cmd_tx_vlan_set_result *res = parsed_result;
3098 tx_vlan_set(res->port_id, res->vlan_id);
3101 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3102 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3103 tx_vlan, "tx_vlan");
3104 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3105 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3107 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3108 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3110 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3111 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3114 cmdline_parse_inst_t cmd_tx_vlan_set = {
3115 .f = cmd_tx_vlan_set_parsed,
3117 .help_str = "enable hardware insertion of a single VLAN header "
3118 "with a given TAG Identifier in packets sent on a port",
3120 (void *)&cmd_tx_vlan_set_tx_vlan,
3121 (void *)&cmd_tx_vlan_set_set,
3122 (void *)&cmd_tx_vlan_set_portid,
3123 (void *)&cmd_tx_vlan_set_vlanid,
3128 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3129 struct cmd_tx_vlan_set_qinq_result {
3130 cmdline_fixed_string_t tx_vlan;
3131 cmdline_fixed_string_t set;
3134 uint16_t vlan_id_outer;
3138 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3139 __attribute__((unused)) struct cmdline *cl,
3140 __attribute__((unused)) void *data)
3142 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3144 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3147 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3148 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3149 tx_vlan, "tx_vlan");
3150 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3151 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3153 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3154 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3156 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3157 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3159 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3160 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3161 vlan_id_outer, UINT16);
3163 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3164 .f = cmd_tx_vlan_set_qinq_parsed,
3166 .help_str = "enable hardware insertion of double VLAN header "
3167 "with given TAG Identifiers in packets sent on a port",
3169 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3170 (void *)&cmd_tx_vlan_set_qinq_set,
3171 (void *)&cmd_tx_vlan_set_qinq_portid,
3172 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3173 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3178 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3179 struct cmd_tx_vlan_set_pvid_result {
3180 cmdline_fixed_string_t tx_vlan;
3181 cmdline_fixed_string_t set;
3182 cmdline_fixed_string_t pvid;
3185 cmdline_fixed_string_t mode;
3189 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3190 __attribute__((unused)) struct cmdline *cl,
3191 __attribute__((unused)) void *data)
3193 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3195 if (strcmp(res->mode, "on") == 0)
3196 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3198 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3201 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3202 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3203 tx_vlan, "tx_vlan");
3204 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3205 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3207 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3208 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3210 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3211 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3213 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3214 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3216 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3217 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3220 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3221 .f = cmd_tx_vlan_set_pvid_parsed,
3223 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3225 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3226 (void *)&cmd_tx_vlan_set_pvid_set,
3227 (void *)&cmd_tx_vlan_set_pvid_pvid,
3228 (void *)&cmd_tx_vlan_set_pvid_port_id,
3229 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3230 (void *)&cmd_tx_vlan_set_pvid_mode,
3235 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3236 struct cmd_tx_vlan_reset_result {
3237 cmdline_fixed_string_t tx_vlan;
3238 cmdline_fixed_string_t reset;
3243 cmd_tx_vlan_reset_parsed(void *parsed_result,
3244 __attribute__((unused)) struct cmdline *cl,
3245 __attribute__((unused)) void *data)
3247 struct cmd_tx_vlan_reset_result *res = parsed_result;
3249 tx_vlan_reset(res->port_id);
3252 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3253 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3254 tx_vlan, "tx_vlan");
3255 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3256 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3258 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3259 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3262 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3263 .f = cmd_tx_vlan_reset_parsed,
3265 .help_str = "disable hardware insertion of a VLAN header in packets "
3268 (void *)&cmd_tx_vlan_reset_tx_vlan,
3269 (void *)&cmd_tx_vlan_reset_reset,
3270 (void *)&cmd_tx_vlan_reset_portid,
3276 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3277 struct cmd_csum_result {
3278 cmdline_fixed_string_t csum;
3279 cmdline_fixed_string_t mode;
3280 cmdline_fixed_string_t proto;
3281 cmdline_fixed_string_t hwsw;
3286 csum_show(int port_id)
3288 struct rte_eth_dev_info dev_info;
3291 ol_flags = ports[port_id].tx_ol_flags;
3292 printf("Parse tunnel is %s\n",
3293 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3294 printf("IP checksum offload is %s\n",
3295 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3296 printf("UDP checksum offload is %s\n",
3297 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3298 printf("TCP checksum offload is %s\n",
3299 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3300 printf("SCTP checksum offload is %s\n",
3301 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3302 printf("Outer-Ip checksum offload is %s\n",
3303 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3305 /* display warnings if configuration is not supported by the NIC */
3306 rte_eth_dev_info_get(port_id, &dev_info);
3307 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3308 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3309 printf("Warning: hardware IP checksum enabled but not "
3310 "supported by port %d\n", port_id);
3312 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3313 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3314 printf("Warning: hardware UDP checksum enabled but not "
3315 "supported by port %d\n", port_id);
3317 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3318 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3319 printf("Warning: hardware TCP checksum enabled but not "
3320 "supported by port %d\n", port_id);
3322 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3323 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3324 printf("Warning: hardware SCTP checksum enabled but not "
3325 "supported by port %d\n", port_id);
3327 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3328 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3329 printf("Warning: hardware outer IP checksum enabled but not "
3330 "supported by port %d\n", port_id);
3335 cmd_csum_parsed(void *parsed_result,
3336 __attribute__((unused)) struct cmdline *cl,
3337 __attribute__((unused)) void *data)
3339 struct cmd_csum_result *res = parsed_result;
3343 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3344 printf("invalid port %d\n", res->port_id);
3348 if (!strcmp(res->mode, "set")) {
3350 if (!strcmp(res->hwsw, "hw"))
3353 if (!strcmp(res->proto, "ip")) {
3354 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3355 } else if (!strcmp(res->proto, "udp")) {
3356 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3357 } else if (!strcmp(res->proto, "tcp")) {
3358 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3359 } else if (!strcmp(res->proto, "sctp")) {
3360 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3361 } else if (!strcmp(res->proto, "outer-ip")) {
3362 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3366 ports[res->port_id].tx_ol_flags |= mask;
3368 ports[res->port_id].tx_ol_flags &= (~mask);
3370 csum_show(res->port_id);
3373 cmdline_parse_token_string_t cmd_csum_csum =
3374 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3376 cmdline_parse_token_string_t cmd_csum_mode =
3377 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3379 cmdline_parse_token_string_t cmd_csum_proto =
3380 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3381 proto, "ip#tcp#udp#sctp#outer-ip");
3382 cmdline_parse_token_string_t cmd_csum_hwsw =
3383 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3385 cmdline_parse_token_num_t cmd_csum_portid =
3386 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3389 cmdline_parse_inst_t cmd_csum_set = {
3390 .f = cmd_csum_parsed,
3392 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3393 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3395 (void *)&cmd_csum_csum,
3396 (void *)&cmd_csum_mode,
3397 (void *)&cmd_csum_proto,
3398 (void *)&cmd_csum_hwsw,
3399 (void *)&cmd_csum_portid,
3404 cmdline_parse_token_string_t cmd_csum_mode_show =
3405 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3408 cmdline_parse_inst_t cmd_csum_show = {
3409 .f = cmd_csum_parsed,
3411 .help_str = "show checksum offload configuration: csum show <port>",
3413 (void *)&cmd_csum_csum,
3414 (void *)&cmd_csum_mode_show,
3415 (void *)&cmd_csum_portid,
3420 /* Enable/disable tunnel parsing */
3421 struct cmd_csum_tunnel_result {
3422 cmdline_fixed_string_t csum;
3423 cmdline_fixed_string_t parse;
3424 cmdline_fixed_string_t onoff;
3429 cmd_csum_tunnel_parsed(void *parsed_result,
3430 __attribute__((unused)) struct cmdline *cl,
3431 __attribute__((unused)) void *data)
3433 struct cmd_csum_tunnel_result *res = parsed_result;
3435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3438 if (!strcmp(res->onoff, "on"))
3439 ports[res->port_id].tx_ol_flags |=
3440 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3442 ports[res->port_id].tx_ol_flags &=
3443 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3445 csum_show(res->port_id);
3448 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3449 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3451 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3452 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3453 parse, "parse_tunnel");
3454 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3455 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3457 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3458 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3461 cmdline_parse_inst_t cmd_csum_tunnel = {
3462 .f = cmd_csum_tunnel_parsed,
3464 .help_str = "enable/disable parsing of tunnels for csum engine: "
3465 "csum parse_tunnel on|off <tx-port>",
3467 (void *)&cmd_csum_tunnel_csum,
3468 (void *)&cmd_csum_tunnel_parse,
3469 (void *)&cmd_csum_tunnel_onoff,
3470 (void *)&cmd_csum_tunnel_portid,
3475 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3476 struct cmd_tso_set_result {
3477 cmdline_fixed_string_t tso;
3478 cmdline_fixed_string_t mode;
3484 cmd_tso_set_parsed(void *parsed_result,
3485 __attribute__((unused)) struct cmdline *cl,
3486 __attribute__((unused)) void *data)
3488 struct cmd_tso_set_result *res = parsed_result;
3489 struct rte_eth_dev_info dev_info;
3491 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3494 if (!strcmp(res->mode, "set"))
3495 ports[res->port_id].tso_segsz = res->tso_segsz;
3497 if (ports[res->port_id].tso_segsz == 0)
3498 printf("TSO for non-tunneled packets is disabled\n");
3500 printf("TSO segment size for non-tunneled packets is %d\n",
3501 ports[res->port_id].tso_segsz);
3503 /* display warnings if configuration is not supported by the NIC */
3504 rte_eth_dev_info_get(res->port_id, &dev_info);
3505 if ((ports[res->port_id].tso_segsz != 0) &&
3506 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3507 printf("Warning: TSO enabled but not "
3508 "supported by port %d\n", res->port_id);
3512 cmdline_parse_token_string_t cmd_tso_set_tso =
3513 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3515 cmdline_parse_token_string_t cmd_tso_set_mode =
3516 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3518 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3519 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3521 cmdline_parse_token_num_t cmd_tso_set_portid =
3522 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3525 cmdline_parse_inst_t cmd_tso_set = {
3526 .f = cmd_tso_set_parsed,
3528 .help_str = "Set TSO segment size of non-tunneled packets "
3529 "for csum engine (0 to disable): tso set <tso_segsz> <port>",
3531 (void *)&cmd_tso_set_tso,
3532 (void *)&cmd_tso_set_mode,
3533 (void *)&cmd_tso_set_tso_segsz,
3534 (void *)&cmd_tso_set_portid,
3539 cmdline_parse_token_string_t cmd_tso_show_mode =
3540 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3544 cmdline_parse_inst_t cmd_tso_show = {
3545 .f = cmd_tso_set_parsed,
3547 .help_str = "Show TSO segment size of non-tunneled packets "
3548 "for csum engine: tso show <port>",
3550 (void *)&cmd_tso_set_tso,
3551 (void *)&cmd_tso_show_mode,
3552 (void *)&cmd_tso_set_portid,
3557 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3558 struct cmd_tunnel_tso_set_result {
3559 cmdline_fixed_string_t tso;
3560 cmdline_fixed_string_t mode;
3566 check_tunnel_tso_nic_support(uint8_t port_id)
3568 struct rte_eth_dev_info dev_info;
3570 rte_eth_dev_info_get(port_id, &dev_info);
3571 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3572 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3573 "supported by port %d\n", port_id);
3574 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3575 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3576 "supported by port %d\n", port_id);
3577 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3578 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3579 "supported by port %d\n", port_id);
3580 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3581 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3582 "supported by port %d\n", port_id);
3586 cmd_tunnel_tso_set_parsed(void *parsed_result,
3587 __attribute__((unused)) struct cmdline *cl,
3588 __attribute__((unused)) void *data)
3590 struct cmd_tunnel_tso_set_result *res = parsed_result;
3592 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3595 if (!strcmp(res->mode, "set"))
3596 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3598 if (ports[res->port_id].tunnel_tso_segsz == 0)
3599 printf("TSO for tunneled packets is disabled\n");
3601 printf("TSO segment size for tunneled packets is %d\n",
3602 ports[res->port_id].tunnel_tso_segsz);
3604 /* Below conditions are needed to make it work:
3605 * (1) tunnel TSO is supported by the NIC;
3606 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3608 * (3) for tunneled pkts with outer L3 of IPv4,
3609 * "csum set outer-ip" must be set to hw, because after tso,
3610 * total_len of outer IP header is changed, and the checksum
3611 * of outer IP header calculated by sw should be wrong; that
3612 * is not necessary for IPv6 tunneled pkts because there's no
3613 * checksum in IP header anymore.
3615 check_tunnel_tso_nic_support(res->port_id);
3617 if (!(ports[res->port_id].tx_ol_flags &
3618 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3619 printf("Warning: csum parse_tunnel must be set "
3620 "so that tunneled packets are recognized\n");
3621 if (!(ports[res->port_id].tx_ol_flags &
3622 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3623 printf("Warning: csum set outer-ip must be set to hw "
3624 "if outer L3 is IPv4; not necessary for IPv6\n");
3628 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3629 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3631 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3632 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3634 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3635 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3637 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3638 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3641 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3642 .f = cmd_tunnel_tso_set_parsed,
3644 .help_str = "Set TSO segment size of tunneled packets for csum engine "
3645 "(0 to disable): tunnel_tso set <tso_segsz> <port>",
3647 (void *)&cmd_tunnel_tso_set_tso,
3648 (void *)&cmd_tunnel_tso_set_mode,
3649 (void *)&cmd_tunnel_tso_set_tso_segsz,
3650 (void *)&cmd_tunnel_tso_set_portid,
3655 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3656 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3660 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3661 .f = cmd_tunnel_tso_set_parsed,
3663 .help_str = "Show TSO segment size of tunneled packets "
3664 "for csum engine: tunnel_tso show <port>",
3666 (void *)&cmd_tunnel_tso_set_tso,
3667 (void *)&cmd_tunnel_tso_show_mode,
3668 (void *)&cmd_tunnel_tso_set_portid,
3673 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3674 struct cmd_set_flush_rx {
3675 cmdline_fixed_string_t set;
3676 cmdline_fixed_string_t flush_rx;
3677 cmdline_fixed_string_t mode;
3681 cmd_set_flush_rx_parsed(void *parsed_result,
3682 __attribute__((unused)) struct cmdline *cl,
3683 __attribute__((unused)) void *data)
3685 struct cmd_set_flush_rx *res = parsed_result;
3686 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3689 cmdline_parse_token_string_t cmd_setflushrx_set =
3690 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3692 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3693 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3694 flush_rx, "flush_rx");
3695 cmdline_parse_token_string_t cmd_setflushrx_mode =
3696 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3700 cmdline_parse_inst_t cmd_set_flush_rx = {
3701 .f = cmd_set_flush_rx_parsed,
3702 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3705 (void *)&cmd_setflushrx_set,
3706 (void *)&cmd_setflushrx_flush_rx,
3707 (void *)&cmd_setflushrx_mode,
3712 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3713 struct cmd_set_link_check {
3714 cmdline_fixed_string_t set;
3715 cmdline_fixed_string_t link_check;
3716 cmdline_fixed_string_t mode;
3720 cmd_set_link_check_parsed(void *parsed_result,
3721 __attribute__((unused)) struct cmdline *cl,
3722 __attribute__((unused)) void *data)
3724 struct cmd_set_link_check *res = parsed_result;
3725 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3728 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3729 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3731 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3732 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3733 link_check, "link_check");
3734 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3735 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3739 cmdline_parse_inst_t cmd_set_link_check = {
3740 .f = cmd_set_link_check_parsed,
3741 .help_str = "set link_check on|off: enable/disable link status check "
3742 "when starting/stopping a port",
3745 (void *)&cmd_setlinkcheck_set,
3746 (void *)&cmd_setlinkcheck_link_check,
3747 (void *)&cmd_setlinkcheck_mode,
3752 #ifdef RTE_NIC_BYPASS
3753 /* *** SET NIC BYPASS MODE *** */
3754 struct cmd_set_bypass_mode_result {
3755 cmdline_fixed_string_t set;
3756 cmdline_fixed_string_t bypass;
3757 cmdline_fixed_string_t mode;
3758 cmdline_fixed_string_t value;
3763 cmd_set_bypass_mode_parsed(void *parsed_result,
3764 __attribute__((unused)) struct cmdline *cl,
3765 __attribute__((unused)) void *data)
3767 struct cmd_set_bypass_mode_result *res = parsed_result;
3768 portid_t port_id = res->port_id;
3769 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3771 if (!strcmp(res->value, "bypass"))
3772 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3773 else if (!strcmp(res->value, "isolate"))
3774 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3776 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3778 /* Set the bypass mode for the relevant port. */
3779 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3780 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3784 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3785 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3787 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3790 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3791 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3793 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3794 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3795 value, "normal#bypass#isolate");
3796 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3797 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3800 cmdline_parse_inst_t cmd_set_bypass_mode = {
3801 .f = cmd_set_bypass_mode_parsed,
3802 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3803 "Set the NIC bypass mode for port_id",
3806 (void *)&cmd_setbypass_mode_set,
3807 (void *)&cmd_setbypass_mode_bypass,
3808 (void *)&cmd_setbypass_mode_mode,
3809 (void *)&cmd_setbypass_mode_value,
3810 (void *)&cmd_setbypass_mode_port,
3815 /* *** SET NIC BYPASS EVENT *** */
3816 struct cmd_set_bypass_event_result {
3817 cmdline_fixed_string_t set;
3818 cmdline_fixed_string_t bypass;
3819 cmdline_fixed_string_t event;
3820 cmdline_fixed_string_t event_value;
3821 cmdline_fixed_string_t mode;
3822 cmdline_fixed_string_t mode_value;
3827 cmd_set_bypass_event_parsed(void *parsed_result,
3828 __attribute__((unused)) struct cmdline *cl,
3829 __attribute__((unused)) void *data)
3832 struct cmd_set_bypass_event_result *res = parsed_result;
3833 portid_t port_id = res->port_id;
3834 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3835 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3837 if (!strcmp(res->event_value, "timeout"))
3838 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3839 else if (!strcmp(res->event_value, "os_on"))
3840 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3841 else if (!strcmp(res->event_value, "os_off"))
3842 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3843 else if (!strcmp(res->event_value, "power_on"))
3844 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3845 else if (!strcmp(res->event_value, "power_off"))
3846 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3848 bypass_event = RTE_BYPASS_EVENT_NONE;
3850 if (!strcmp(res->mode_value, "bypass"))
3851 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3852 else if (!strcmp(res->mode_value, "isolate"))
3853 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3855 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3857 /* Set the watchdog timeout. */
3858 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3861 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3862 (rc = rte_eth_dev_wd_timeout_store(port_id,
3863 bypass_timeout)) != 0) {
3864 printf("Failed to set timeout value %u "
3865 "for port %d, errto code: %d.\n",
3866 bypass_timeout, port_id, rc);
3870 /* Set the bypass event to transition to bypass mode. */
3871 if (0 != rte_eth_dev_bypass_event_store(port_id,
3872 bypass_event, bypass_mode)) {
3873 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3878 cmdline_parse_token_string_t cmd_setbypass_event_set =
3879 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3881 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3882 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3884 cmdline_parse_token_string_t cmd_setbypass_event_event =
3885 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3887 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3888 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3889 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3890 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3893 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3894 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3895 mode_value, "normal#bypass#isolate");
3896 cmdline_parse_token_num_t cmd_setbypass_event_port =
3897 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3900 cmdline_parse_inst_t cmd_set_bypass_event = {
3901 .f = cmd_set_bypass_event_parsed,
3902 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3903 "mode (normal|bypass|isolate) (port_id): "
3904 "Set the NIC bypass event mode for port_id",
3907 (void *)&cmd_setbypass_event_set,
3908 (void *)&cmd_setbypass_event_bypass,
3909 (void *)&cmd_setbypass_event_event,
3910 (void *)&cmd_setbypass_event_event_value,
3911 (void *)&cmd_setbypass_event_mode,
3912 (void *)&cmd_setbypass_event_mode_value,
3913 (void *)&cmd_setbypass_event_port,
3919 /* *** SET NIC BYPASS TIMEOUT *** */
3920 struct cmd_set_bypass_timeout_result {
3921 cmdline_fixed_string_t set;
3922 cmdline_fixed_string_t bypass;
3923 cmdline_fixed_string_t timeout;
3924 cmdline_fixed_string_t value;
3928 cmd_set_bypass_timeout_parsed(void *parsed_result,
3929 __attribute__((unused)) struct cmdline *cl,
3930 __attribute__((unused)) void *data)
3932 struct cmd_set_bypass_timeout_result *res = parsed_result;
3934 if (!strcmp(res->value, "1.5"))
3935 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3936 else if (!strcmp(res->value, "2"))
3937 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3938 else if (!strcmp(res->value, "3"))
3939 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3940 else if (!strcmp(res->value, "4"))
3941 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3942 else if (!strcmp(res->value, "8"))
3943 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3944 else if (!strcmp(res->value, "16"))
3945 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3946 else if (!strcmp(res->value, "32"))
3947 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3949 bypass_timeout = RTE_BYPASS_TMT_OFF;
3952 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3953 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3955 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3956 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3958 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3959 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3960 timeout, "timeout");
3961 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3962 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3963 value, "0#1.5#2#3#4#8#16#32");
3965 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3966 .f = cmd_set_bypass_timeout_parsed,
3967 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3968 "Set the NIC bypass watchdog timeout",
3971 (void *)&cmd_setbypass_timeout_set,
3972 (void *)&cmd_setbypass_timeout_bypass,
3973 (void *)&cmd_setbypass_timeout_timeout,
3974 (void *)&cmd_setbypass_timeout_value,
3979 /* *** SHOW NIC BYPASS MODE *** */
3980 struct cmd_show_bypass_config_result {
3981 cmdline_fixed_string_t show;
3982 cmdline_fixed_string_t bypass;
3983 cmdline_fixed_string_t config;
3988 cmd_show_bypass_config_parsed(void *parsed_result,
3989 __attribute__((unused)) struct cmdline *cl,
3990 __attribute__((unused)) void *data)
3992 struct cmd_show_bypass_config_result *res = parsed_result;
3993 uint32_t event_mode;
3994 uint32_t bypass_mode;
3995 portid_t port_id = res->port_id;
3996 uint32_t timeout = bypass_timeout;
3999 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4000 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4001 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4002 {"UNKNOWN", "normal", "bypass", "isolate"};
4003 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4010 int num_events = (sizeof events) / (sizeof events[0]);
4012 /* Display the bypass mode.*/
4013 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4014 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4018 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4019 bypass_mode = RTE_BYPASS_MODE_NONE;
4021 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4024 /* Display the bypass timeout.*/
4025 if (!RTE_BYPASS_TMT_VALID(timeout))
4026 timeout = RTE_BYPASS_TMT_OFF;
4028 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4030 /* Display the bypass events and associated modes. */
4031 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4033 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4034 printf("\tFailed to get bypass mode for event = %s\n",
4037 if (!RTE_BYPASS_MODE_VALID(event_mode))
4038 event_mode = RTE_BYPASS_MODE_NONE;
4040 printf("\tbypass event: %-16s = %s\n", events[i],
4046 cmdline_parse_token_string_t cmd_showbypass_config_show =
4047 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4049 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4050 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4052 cmdline_parse_token_string_t cmd_showbypass_config_config =
4053 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4055 cmdline_parse_token_num_t cmd_showbypass_config_port =
4056 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4059 cmdline_parse_inst_t cmd_show_bypass_config = {
4060 .f = cmd_show_bypass_config_parsed,
4061 .help_str = "show bypass config (port_id): "
4062 "Show the NIC bypass config for port_id",
4065 (void *)&cmd_showbypass_config_show,
4066 (void *)&cmd_showbypass_config_bypass,
4067 (void *)&cmd_showbypass_config_config,
4068 (void *)&cmd_showbypass_config_port,
4074 #ifdef RTE_LIBRTE_PMD_BOND
4075 /* *** SET BONDING MODE *** */
4076 struct cmd_set_bonding_mode_result {
4077 cmdline_fixed_string_t set;
4078 cmdline_fixed_string_t bonding;
4079 cmdline_fixed_string_t mode;
4084 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4085 __attribute__((unused)) struct cmdline *cl,
4086 __attribute__((unused)) void *data)
4088 struct cmd_set_bonding_mode_result *res = parsed_result;
4089 portid_t port_id = res->port_id;
4091 /* Set the bonding mode for the relevant port. */
4092 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4093 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4096 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4097 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4099 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4100 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4101 bonding, "bonding");
4102 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4103 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4105 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4106 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4108 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4109 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4112 cmdline_parse_inst_t cmd_set_bonding_mode = {
4113 .f = cmd_set_bonding_mode_parsed,
4114 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
4117 (void *) &cmd_setbonding_mode_set,
4118 (void *) &cmd_setbonding_mode_bonding,
4119 (void *) &cmd_setbonding_mode_mode,
4120 (void *) &cmd_setbonding_mode_value,
4121 (void *) &cmd_setbonding_mode_port,
4126 /* *** SET BALANCE XMIT POLICY *** */
4127 struct cmd_set_bonding_balance_xmit_policy_result {
4128 cmdline_fixed_string_t set;
4129 cmdline_fixed_string_t bonding;
4130 cmdline_fixed_string_t balance_xmit_policy;
4132 cmdline_fixed_string_t policy;
4135 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4136 __attribute__((unused)) struct cmdline *cl,
4137 __attribute__((unused)) void *data)
4139 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4140 portid_t port_id = res->port_id;
4143 if (!strcmp(res->policy, "l2")) {
4144 policy = BALANCE_XMIT_POLICY_LAYER2;
4145 } else if (!strcmp(res->policy, "l23")) {
4146 policy = BALANCE_XMIT_POLICY_LAYER23;
4147 } else if (!strcmp(res->policy, "l34")) {
4148 policy = BALANCE_XMIT_POLICY_LAYER34;
4150 printf("\t Invalid xmit policy selection");
4154 /* Set the bonding mode for the relevant port. */
4155 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4156 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4161 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4162 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4164 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4165 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4166 bonding, "bonding");
4167 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4168 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4169 balance_xmit_policy, "balance_xmit_policy");
4170 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4171 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4173 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4174 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4175 policy, "l2#l23#l34");
4177 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4178 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4179 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
4182 (void *)&cmd_setbonding_balance_xmit_policy_set,
4183 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4184 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4185 (void *)&cmd_setbonding_balance_xmit_policy_port,
4186 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4191 /* *** SHOW NIC BONDING CONFIGURATION *** */
4192 struct cmd_show_bonding_config_result {
4193 cmdline_fixed_string_t show;
4194 cmdline_fixed_string_t bonding;
4195 cmdline_fixed_string_t config;
4199 static void cmd_show_bonding_config_parsed(void *parsed_result,
4200 __attribute__((unused)) struct cmdline *cl,
4201 __attribute__((unused)) void *data)
4203 struct cmd_show_bonding_config_result *res = parsed_result;
4205 uint8_t slaves[RTE_MAX_ETHPORTS];
4206 int num_slaves, num_active_slaves;
4209 portid_t port_id = res->port_id;
4211 /* Display the bonding mode.*/
4212 bonding_mode = rte_eth_bond_mode_get(port_id);
4213 if (bonding_mode < 0) {
4214 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4217 printf("\tBonding mode: %d\n", bonding_mode);
4219 if (bonding_mode == BONDING_MODE_BALANCE) {
4220 int balance_xmit_policy;
4222 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4223 if (balance_xmit_policy < 0) {
4224 printf("\tFailed to get balance xmit policy for port = %d\n",
4228 printf("\tBalance Xmit Policy: ");
4230 switch (balance_xmit_policy) {
4231 case BALANCE_XMIT_POLICY_LAYER2:
4232 printf("BALANCE_XMIT_POLICY_LAYER2");
4234 case BALANCE_XMIT_POLICY_LAYER23:
4235 printf("BALANCE_XMIT_POLICY_LAYER23");
4237 case BALANCE_XMIT_POLICY_LAYER34:
4238 printf("BALANCE_XMIT_POLICY_LAYER34");
4245 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4247 if (num_slaves < 0) {
4248 printf("\tFailed to get slave list for port = %d\n", port_id);
4251 if (num_slaves > 0) {
4252 printf("\tSlaves (%d): [", num_slaves);
4253 for (i = 0; i < num_slaves - 1; i++)
4254 printf("%d ", slaves[i]);
4256 printf("%d]\n", slaves[num_slaves - 1]);
4258 printf("\tSlaves: []\n");
4262 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4265 if (num_active_slaves < 0) {
4266 printf("\tFailed to get active slave list for port = %d\n", port_id);
4269 if (num_active_slaves > 0) {
4270 printf("\tActive Slaves (%d): [", num_active_slaves);
4271 for (i = 0; i < num_active_slaves - 1; i++)
4272 printf("%d ", slaves[i]);
4274 printf("%d]\n", slaves[num_active_slaves - 1]);
4277 printf("\tActive Slaves: []\n");
4281 primary_id = rte_eth_bond_primary_get(port_id);
4282 if (primary_id < 0) {
4283 printf("\tFailed to get primary slave for port = %d\n", port_id);
4286 printf("\tPrimary: [%d]\n", primary_id);
4290 cmdline_parse_token_string_t cmd_showbonding_config_show =
4291 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4293 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4294 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4295 bonding, "bonding");
4296 cmdline_parse_token_string_t cmd_showbonding_config_config =
4297 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4299 cmdline_parse_token_num_t cmd_showbonding_config_port =
4300 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4303 cmdline_parse_inst_t cmd_show_bonding_config = {
4304 .f = cmd_show_bonding_config_parsed,
4305 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4308 (void *)&cmd_showbonding_config_show,
4309 (void *)&cmd_showbonding_config_bonding,
4310 (void *)&cmd_showbonding_config_config,
4311 (void *)&cmd_showbonding_config_port,
4316 /* *** SET BONDING PRIMARY *** */
4317 struct cmd_set_bonding_primary_result {
4318 cmdline_fixed_string_t set;
4319 cmdline_fixed_string_t bonding;
4320 cmdline_fixed_string_t primary;
4325 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4326 __attribute__((unused)) struct cmdline *cl,
4327 __attribute__((unused)) void *data)
4329 struct cmd_set_bonding_primary_result *res = parsed_result;
4330 portid_t master_port_id = res->port_id;
4331 portid_t slave_port_id = res->slave_id;
4333 /* Set the primary slave for a bonded device. */
4334 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4335 printf("\t Failed to set primary slave for port = %d.\n",
4342 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4343 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4345 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4346 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4347 bonding, "bonding");
4348 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4349 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4350 primary, "primary");
4351 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4352 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4354 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4355 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4358 cmdline_parse_inst_t cmd_set_bonding_primary = {
4359 .f = cmd_set_bonding_primary_parsed,
4360 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4363 (void *)&cmd_setbonding_primary_set,
4364 (void *)&cmd_setbonding_primary_bonding,
4365 (void *)&cmd_setbonding_primary_primary,
4366 (void *)&cmd_setbonding_primary_slave,
4367 (void *)&cmd_setbonding_primary_port,
4372 /* *** ADD SLAVE *** */
4373 struct cmd_add_bonding_slave_result {
4374 cmdline_fixed_string_t add;
4375 cmdline_fixed_string_t bonding;
4376 cmdline_fixed_string_t slave;
4381 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4382 __attribute__((unused)) struct cmdline *cl,
4383 __attribute__((unused)) void *data)
4385 struct cmd_add_bonding_slave_result *res = parsed_result;
4386 portid_t master_port_id = res->port_id;
4387 portid_t slave_port_id = res->slave_id;
4389 /* Set the primary slave for a bonded device. */
4390 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4391 printf("\t Failed to add slave %d to master port = %d.\n",
4392 slave_port_id, master_port_id);
4396 set_port_slave_flag(slave_port_id);
4399 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4400 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4402 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4403 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4404 bonding, "bonding");
4405 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4406 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4408 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4409 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4411 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4412 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4415 cmdline_parse_inst_t cmd_add_bonding_slave = {
4416 .f = cmd_add_bonding_slave_parsed,
4417 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4420 (void *)&cmd_addbonding_slave_add,
4421 (void *)&cmd_addbonding_slave_bonding,
4422 (void *)&cmd_addbonding_slave_slave,
4423 (void *)&cmd_addbonding_slave_slaveid,
4424 (void *)&cmd_addbonding_slave_port,
4429 /* *** REMOVE SLAVE *** */
4430 struct cmd_remove_bonding_slave_result {
4431 cmdline_fixed_string_t remove;
4432 cmdline_fixed_string_t bonding;
4433 cmdline_fixed_string_t slave;
4438 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4439 __attribute__((unused)) struct cmdline *cl,
4440 __attribute__((unused)) void *data)
4442 struct cmd_remove_bonding_slave_result *res = parsed_result;
4443 portid_t master_port_id = res->port_id;
4444 portid_t slave_port_id = res->slave_id;
4446 /* Set the primary slave for a bonded device. */
4447 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4448 printf("\t Failed to remove slave %d from master port = %d.\n",
4449 slave_port_id, master_port_id);
4453 clear_port_slave_flag(slave_port_id);
4456 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4457 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4459 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4460 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4461 bonding, "bonding");
4462 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4463 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4465 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4466 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4468 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4469 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4472 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4473 .f = cmd_remove_bonding_slave_parsed,
4474 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4477 (void *)&cmd_removebonding_slave_remove,
4478 (void *)&cmd_removebonding_slave_bonding,
4479 (void *)&cmd_removebonding_slave_slave,
4480 (void *)&cmd_removebonding_slave_slaveid,
4481 (void *)&cmd_removebonding_slave_port,
4486 /* *** CREATE BONDED DEVICE *** */
4487 struct cmd_create_bonded_device_result {
4488 cmdline_fixed_string_t create;
4489 cmdline_fixed_string_t bonded;
4490 cmdline_fixed_string_t device;
4495 static int bond_dev_num = 0;
4497 static void cmd_create_bonded_device_parsed(void *parsed_result,
4498 __attribute__((unused)) struct cmdline *cl,
4499 __attribute__((unused)) void *data)
4501 struct cmd_create_bonded_device_result *res = parsed_result;
4502 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4505 if (test_done == 0) {
4506 printf("Please stop forwarding first\n");
4510 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4513 /* Create a new bonded device. */
4514 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4516 printf("\t Failed to create bonded device.\n");
4519 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4522 /* Update number of ports */
4523 nb_ports = rte_eth_dev_count();
4524 reconfig(port_id, res->socket);
4525 rte_eth_promiscuous_enable(port_id);
4526 ports[port_id].enabled = 1;
4531 cmdline_parse_token_string_t cmd_createbonded_device_create =
4532 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4534 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4535 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4537 cmdline_parse_token_string_t cmd_createbonded_device_device =
4538 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4540 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4541 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4543 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4544 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4547 cmdline_parse_inst_t cmd_create_bonded_device = {
4548 .f = cmd_create_bonded_device_parsed,
4549 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4552 (void *)&cmd_createbonded_device_create,
4553 (void *)&cmd_createbonded_device_bonded,
4554 (void *)&cmd_createbonded_device_device,
4555 (void *)&cmd_createbonded_device_mode,
4556 (void *)&cmd_createbonded_device_socket,
4561 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4562 struct cmd_set_bond_mac_addr_result {
4563 cmdline_fixed_string_t set;
4564 cmdline_fixed_string_t bonding;
4565 cmdline_fixed_string_t mac_addr;
4567 struct ether_addr address;
4570 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4571 __attribute__((unused)) struct cmdline *cl,
4572 __attribute__((unused)) void *data)
4574 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4577 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4580 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4582 /* check the return value and print it if is < 0 */
4584 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4587 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4588 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4589 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4590 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4592 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4593 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4595 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4596 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4597 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4598 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4600 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4601 .f = cmd_set_bond_mac_addr_parsed,
4603 .help_str = "set bonding mac_addr (port_id) (address): ",
4605 (void *)&cmd_set_bond_mac_addr_set,
4606 (void *)&cmd_set_bond_mac_addr_bonding,
4607 (void *)&cmd_set_bond_mac_addr_mac,
4608 (void *)&cmd_set_bond_mac_addr_portnum,
4609 (void *)&cmd_set_bond_mac_addr_addr,
4615 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4616 struct cmd_set_bond_mon_period_result {
4617 cmdline_fixed_string_t set;
4618 cmdline_fixed_string_t bonding;
4619 cmdline_fixed_string_t mon_period;
4624 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4625 __attribute__((unused)) struct cmdline *cl,
4626 __attribute__((unused)) void *data)
4628 struct cmd_set_bond_mon_period_result *res = parsed_result;
4631 if (res->port_num >= nb_ports) {
4632 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4636 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4638 /* check the return value and print it if is < 0 */
4640 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4643 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4644 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4646 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4647 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4648 bonding, "bonding");
4649 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4650 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4651 mon_period, "mon_period");
4652 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4653 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4655 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4656 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4659 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4660 .f = cmd_set_bond_mon_period_parsed,
4662 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4664 (void *)&cmd_set_bond_mon_period_set,
4665 (void *)&cmd_set_bond_mon_period_bonding,
4666 (void *)&cmd_set_bond_mon_period_mon_period,
4667 (void *)&cmd_set_bond_mon_period_portnum,
4668 (void *)&cmd_set_bond_mon_period_period_ms,
4673 #endif /* RTE_LIBRTE_PMD_BOND */
4675 /* *** SET FORWARDING MODE *** */
4676 struct cmd_set_fwd_mode_result {
4677 cmdline_fixed_string_t set;
4678 cmdline_fixed_string_t fwd;
4679 cmdline_fixed_string_t mode;
4682 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4683 __attribute__((unused)) struct cmdline *cl,
4684 __attribute__((unused)) void *data)
4686 struct cmd_set_fwd_mode_result *res = parsed_result;
4689 set_pkt_forwarding_mode(res->mode);
4692 cmdline_parse_token_string_t cmd_setfwd_set =
4693 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4694 cmdline_parse_token_string_t cmd_setfwd_fwd =
4695 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4696 cmdline_parse_token_string_t cmd_setfwd_mode =
4697 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4698 "" /* defined at init */);
4700 cmdline_parse_inst_t cmd_set_fwd_mode = {
4701 .f = cmd_set_fwd_mode_parsed,
4703 .help_str = NULL, /* defined at init */
4705 (void *)&cmd_setfwd_set,
4706 (void *)&cmd_setfwd_fwd,
4707 (void *)&cmd_setfwd_mode,
4712 static void cmd_set_fwd_mode_init(void)
4715 static char token[128];
4716 static char help[256];
4717 cmdline_parse_token_string_t *token_struct;
4719 modes = list_pkt_forwarding_modes();
4720 snprintf(help, sizeof help, "set fwd %s - "
4721 "set packet forwarding mode", modes);
4722 cmd_set_fwd_mode.help_str = help;
4724 /* string token separator is # */
4725 for (c = token; *modes != '\0'; modes++)
4730 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4731 token_struct->string_data.str = token;
4734 /* *** SET RETRY FORWARDING MODE *** */
4735 struct cmd_set_fwd_retry_mode_result {
4736 cmdline_fixed_string_t set;
4737 cmdline_fixed_string_t fwd;
4738 cmdline_fixed_string_t mode;
4739 cmdline_fixed_string_t retry;
4742 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4743 __attribute__((unused)) struct cmdline *cl,
4744 __attribute__((unused)) void *data)
4746 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4749 set_pkt_forwarding_mode(res->mode);
4752 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4753 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4755 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4756 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4758 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4759 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4761 "" /* defined at init */);
4762 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4763 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4766 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4767 .f = cmd_set_fwd_retry_mode_parsed,
4769 .help_str = NULL, /* defined at init */
4771 (void *)&cmd_setfwd_retry_set,
4772 (void *)&cmd_setfwd_retry_fwd,
4773 (void *)&cmd_setfwd_retry_mode,
4774 (void *)&cmd_setfwd_retry_retry,
4779 static void cmd_set_fwd_retry_mode_init(void)
4782 static char token[128];
4783 static char help[256];
4784 cmdline_parse_token_string_t *token_struct;
4786 modes = list_pkt_forwarding_retry_modes();
4787 snprintf(help, sizeof(help), "set fwd %s retry - "
4788 "set packet forwarding mode with retry", modes);
4789 cmd_set_fwd_retry_mode.help_str = help;
4791 /* string token separator is # */
4792 for (c = token; *modes != '\0'; modes++)
4797 token_struct = (cmdline_parse_token_string_t *)
4798 cmd_set_fwd_retry_mode.tokens[2];
4799 token_struct->string_data.str = token;
4802 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4803 struct cmd_set_burst_tx_retry_result {
4804 cmdline_fixed_string_t set;
4805 cmdline_fixed_string_t burst;
4806 cmdline_fixed_string_t tx;
4807 cmdline_fixed_string_t delay;
4809 cmdline_fixed_string_t retry;
4813 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4814 __attribute__((unused)) struct cmdline *cl,
4815 __attribute__((unused)) void *data)
4817 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4819 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4820 && !strcmp(res->tx, "tx")) {
4821 if (!strcmp(res->delay, "delay"))
4822 burst_tx_delay_time = res->time;
4823 if (!strcmp(res->retry, "retry"))
4824 burst_tx_retry_num = res->retry_num;
4829 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4830 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4831 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4832 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4834 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4835 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4836 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4837 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4838 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4839 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4840 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4841 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4842 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4843 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4845 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4846 .f = cmd_set_burst_tx_retry_parsed,
4847 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4849 (void *)&cmd_set_burst_tx_retry_set,
4850 (void *)&cmd_set_burst_tx_retry_burst,
4851 (void *)&cmd_set_burst_tx_retry_tx,
4852 (void *)&cmd_set_burst_tx_retry_delay,
4853 (void *)&cmd_set_burst_tx_retry_time,
4854 (void *)&cmd_set_burst_tx_retry_retry,
4855 (void *)&cmd_set_burst_tx_retry_retry_num,
4860 /* *** SET PROMISC MODE *** */
4861 struct cmd_set_promisc_mode_result {
4862 cmdline_fixed_string_t set;
4863 cmdline_fixed_string_t promisc;
4864 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4865 uint8_t port_num; /* valid if "allports" argument == 0 */
4866 cmdline_fixed_string_t mode;
4869 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4870 __attribute__((unused)) struct cmdline *cl,
4873 struct cmd_set_promisc_mode_result *res = parsed_result;
4877 if (!strcmp(res->mode, "on"))
4884 FOREACH_PORT(i, ports) {
4886 rte_eth_promiscuous_enable(i);
4888 rte_eth_promiscuous_disable(i);
4893 rte_eth_promiscuous_enable(res->port_num);
4895 rte_eth_promiscuous_disable(res->port_num);
4899 cmdline_parse_token_string_t cmd_setpromisc_set =
4900 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4901 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4902 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4904 cmdline_parse_token_string_t cmd_setpromisc_portall =
4905 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4907 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4908 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4910 cmdline_parse_token_string_t cmd_setpromisc_mode =
4911 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4914 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4915 .f = cmd_set_promisc_mode_parsed,
4917 .help_str = "set promisc all on|off: set promisc mode for all ports",
4919 (void *)&cmd_setpromisc_set,
4920 (void *)&cmd_setpromisc_promisc,
4921 (void *)&cmd_setpromisc_portall,
4922 (void *)&cmd_setpromisc_mode,
4927 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4928 .f = cmd_set_promisc_mode_parsed,
4930 .help_str = "set promisc X on|off: set promisc mode on port X",
4932 (void *)&cmd_setpromisc_set,
4933 (void *)&cmd_setpromisc_promisc,
4934 (void *)&cmd_setpromisc_portnum,
4935 (void *)&cmd_setpromisc_mode,
4940 /* *** SET ALLMULTI MODE *** */
4941 struct cmd_set_allmulti_mode_result {
4942 cmdline_fixed_string_t set;
4943 cmdline_fixed_string_t allmulti;
4944 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4945 uint8_t port_num; /* valid if "allports" argument == 0 */
4946 cmdline_fixed_string_t mode;
4949 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4950 __attribute__((unused)) struct cmdline *cl,
4953 struct cmd_set_allmulti_mode_result *res = parsed_result;
4957 if (!strcmp(res->mode, "on"))
4964 FOREACH_PORT(i, ports) {
4966 rte_eth_allmulticast_enable(i);
4968 rte_eth_allmulticast_disable(i);
4973 rte_eth_allmulticast_enable(res->port_num);
4975 rte_eth_allmulticast_disable(res->port_num);
4979 cmdline_parse_token_string_t cmd_setallmulti_set =
4980 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4981 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4984 cmdline_parse_token_string_t cmd_setallmulti_portall =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4987 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4988 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4990 cmdline_parse_token_string_t cmd_setallmulti_mode =
4991 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4994 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4995 .f = cmd_set_allmulti_mode_parsed,
4997 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4999 (void *)&cmd_setallmulti_set,
5000 (void *)&cmd_setallmulti_allmulti,
5001 (void *)&cmd_setallmulti_portall,
5002 (void *)&cmd_setallmulti_mode,
5007 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5008 .f = cmd_set_allmulti_mode_parsed,
5010 .help_str = "set allmulti X on|off: set allmulti mode on port X",
5012 (void *)&cmd_setallmulti_set,
5013 (void *)&cmd_setallmulti_allmulti,
5014 (void *)&cmd_setallmulti_portnum,
5015 (void *)&cmd_setallmulti_mode,
5020 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5021 struct cmd_link_flow_ctrl_set_result {
5022 cmdline_fixed_string_t set;
5023 cmdline_fixed_string_t flow_ctrl;
5024 cmdline_fixed_string_t rx;
5025 cmdline_fixed_string_t rx_lfc_mode;
5026 cmdline_fixed_string_t tx;
5027 cmdline_fixed_string_t tx_lfc_mode;
5028 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5029 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5030 cmdline_fixed_string_t autoneg_str;
5031 cmdline_fixed_string_t autoneg;
5032 cmdline_fixed_string_t hw_str;
5033 uint32_t high_water;
5034 cmdline_fixed_string_t lw_str;
5036 cmdline_fixed_string_t pt_str;
5037 uint16_t pause_time;
5038 cmdline_fixed_string_t xon_str;
5043 cmdline_parse_token_string_t cmd_lfc_set_set =
5044 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5046 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5047 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5048 flow_ctrl, "flow_ctrl");
5049 cmdline_parse_token_string_t cmd_lfc_set_rx =
5050 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5052 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5053 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5054 rx_lfc_mode, "on#off");
5055 cmdline_parse_token_string_t cmd_lfc_set_tx =
5056 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5058 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5059 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5060 tx_lfc_mode, "on#off");
5061 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5062 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5063 hw_str, "high_water");
5064 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5065 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5066 high_water, UINT32);
5067 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5068 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5069 lw_str, "low_water");
5070 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5071 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5073 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5074 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5075 pt_str, "pause_time");
5076 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5077 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5078 pause_time, UINT16);
5079 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5080 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5081 xon_str, "send_xon");
5082 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5083 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5085 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5086 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5087 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5088 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5089 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5090 mac_ctrl_frame_fwd_mode, "on#off");
5091 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5092 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5093 autoneg_str, "autoneg");
5094 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5095 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5097 cmdline_parse_token_num_t cmd_lfc_set_portid =
5098 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5101 /* forward declaration */
5103 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5106 cmdline_parse_inst_t cmd_link_flow_control_set = {
5107 .f = cmd_link_flow_ctrl_set_parsed,
5109 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
5110 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
5111 autoneg on|off port_id",
5113 (void *)&cmd_lfc_set_set,
5114 (void *)&cmd_lfc_set_flow_ctrl,
5115 (void *)&cmd_lfc_set_rx,
5116 (void *)&cmd_lfc_set_rx_mode,
5117 (void *)&cmd_lfc_set_tx,
5118 (void *)&cmd_lfc_set_tx_mode,
5119 (void *)&cmd_lfc_set_high_water,
5120 (void *)&cmd_lfc_set_low_water,
5121 (void *)&cmd_lfc_set_pause_time,
5122 (void *)&cmd_lfc_set_send_xon,
5123 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5124 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5125 (void *)&cmd_lfc_set_autoneg_str,
5126 (void *)&cmd_lfc_set_autoneg,
5127 (void *)&cmd_lfc_set_portid,
5132 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5133 .f = cmd_link_flow_ctrl_set_parsed,
5134 .data = (void *)&cmd_link_flow_control_set_rx,
5135 .help_str = "Change rx flow control parameter: set flow_ctrl "
5136 "rx on|off port_id",
5138 (void *)&cmd_lfc_set_set,
5139 (void *)&cmd_lfc_set_flow_ctrl,
5140 (void *)&cmd_lfc_set_rx,
5141 (void *)&cmd_lfc_set_rx_mode,
5142 (void *)&cmd_lfc_set_portid,
5147 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5148 .f = cmd_link_flow_ctrl_set_parsed,
5149 .data = (void *)&cmd_link_flow_control_set_tx,
5150 .help_str = "Change tx flow control parameter: set flow_ctrl "
5151 "tx on|off port_id",
5153 (void *)&cmd_lfc_set_set,
5154 (void *)&cmd_lfc_set_flow_ctrl,
5155 (void *)&cmd_lfc_set_tx,
5156 (void *)&cmd_lfc_set_tx_mode,
5157 (void *)&cmd_lfc_set_portid,
5162 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5163 .f = cmd_link_flow_ctrl_set_parsed,
5164 .data = (void *)&cmd_link_flow_control_set_hw,
5165 .help_str = "Change high water flow control parameter: set flow_ctrl "
5166 "high_water value port_id",
5168 (void *)&cmd_lfc_set_set,
5169 (void *)&cmd_lfc_set_flow_ctrl,
5170 (void *)&cmd_lfc_set_high_water_str,
5171 (void *)&cmd_lfc_set_high_water,
5172 (void *)&cmd_lfc_set_portid,
5177 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5178 .f = cmd_link_flow_ctrl_set_parsed,
5179 .data = (void *)&cmd_link_flow_control_set_lw,
5180 .help_str = "Change low water flow control parameter: set flow_ctrl "
5181 "low_water value port_id",
5183 (void *)&cmd_lfc_set_set,
5184 (void *)&cmd_lfc_set_flow_ctrl,
5185 (void *)&cmd_lfc_set_low_water_str,
5186 (void *)&cmd_lfc_set_low_water,
5187 (void *)&cmd_lfc_set_portid,
5192 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5193 .f = cmd_link_flow_ctrl_set_parsed,
5194 .data = (void *)&cmd_link_flow_control_set_pt,
5195 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5196 "pause_time value port_id",
5198 (void *)&cmd_lfc_set_set,
5199 (void *)&cmd_lfc_set_flow_ctrl,
5200 (void *)&cmd_lfc_set_pause_time_str,
5201 (void *)&cmd_lfc_set_pause_time,
5202 (void *)&cmd_lfc_set_portid,
5207 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5208 .f = cmd_link_flow_ctrl_set_parsed,
5209 .data = (void *)&cmd_link_flow_control_set_xon,
5210 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5211 "send_xon value port_id",
5213 (void *)&cmd_lfc_set_set,
5214 (void *)&cmd_lfc_set_flow_ctrl,
5215 (void *)&cmd_lfc_set_send_xon_str,
5216 (void *)&cmd_lfc_set_send_xon,
5217 (void *)&cmd_lfc_set_portid,
5222 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5223 .f = cmd_link_flow_ctrl_set_parsed,
5224 .data = (void *)&cmd_link_flow_control_set_macfwd,
5225 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5226 "mac_ctrl_frame_fwd on|off port_id",
5228 (void *)&cmd_lfc_set_set,
5229 (void *)&cmd_lfc_set_flow_ctrl,
5230 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5231 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5232 (void *)&cmd_lfc_set_portid,
5237 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5238 .f = cmd_link_flow_ctrl_set_parsed,
5239 .data = (void *)&cmd_link_flow_control_set_autoneg,
5240 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5241 "autoneg on|off port_id",
5243 (void *)&cmd_lfc_set_set,
5244 (void *)&cmd_lfc_set_flow_ctrl,
5245 (void *)&cmd_lfc_set_autoneg_str,
5246 (void *)&cmd_lfc_set_autoneg,
5247 (void *)&cmd_lfc_set_portid,
5253 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5254 __attribute__((unused)) struct cmdline *cl,
5257 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5258 cmdline_parse_inst_t *cmd = data;
5259 struct rte_eth_fc_conf fc_conf;
5265 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5266 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5267 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5268 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5270 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5271 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5274 /* Partial command line, retrieve current configuration */
5276 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5278 printf("cannot get current flow ctrl parameters, return"
5279 "code = %d\n", ret);
5283 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5284 (fc_conf.mode == RTE_FC_FULL))
5286 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5287 (fc_conf.mode == RTE_FC_FULL))
5291 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5292 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5294 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5295 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5297 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5299 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5300 fc_conf.high_water = res->high_water;
5302 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5303 fc_conf.low_water = res->low_water;
5305 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5306 fc_conf.pause_time = res->pause_time;
5308 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5309 fc_conf.send_xon = res->send_xon;
5311 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5312 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5313 fc_conf.mac_ctrl_frame_fwd = 1;
5315 fc_conf.mac_ctrl_frame_fwd = 0;
5318 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5319 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5321 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5323 printf("bad flow contrl parameter, return code = %d \n", ret);
5326 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5327 struct cmd_priority_flow_ctrl_set_result {
5328 cmdline_fixed_string_t set;
5329 cmdline_fixed_string_t pfc_ctrl;
5330 cmdline_fixed_string_t rx;
5331 cmdline_fixed_string_t rx_pfc_mode;
5332 cmdline_fixed_string_t tx;
5333 cmdline_fixed_string_t tx_pfc_mode;
5334 uint32_t high_water;
5336 uint16_t pause_time;
5342 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5343 __attribute__((unused)) struct cmdline *cl,
5344 __attribute__((unused)) void *data)
5346 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5347 struct rte_eth_pfc_conf pfc_conf;
5348 int rx_fc_enable, tx_fc_enable;
5352 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5353 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5354 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5355 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5357 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5358 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5361 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5362 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5363 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5364 pfc_conf.fc.high_water = res->high_water;
5365 pfc_conf.fc.low_water = res->low_water;
5366 pfc_conf.fc.pause_time = res->pause_time;
5367 pfc_conf.priority = res->priority;
5369 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5371 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5374 cmdline_parse_token_string_t cmd_pfc_set_set =
5375 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5377 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5378 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5379 pfc_ctrl, "pfc_ctrl");
5380 cmdline_parse_token_string_t cmd_pfc_set_rx =
5381 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5383 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5384 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5385 rx_pfc_mode, "on#off");
5386 cmdline_parse_token_string_t cmd_pfc_set_tx =
5387 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5389 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5390 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5391 tx_pfc_mode, "on#off");
5392 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5393 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5394 high_water, UINT32);
5395 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5396 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5398 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5399 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5400 pause_time, UINT16);
5401 cmdline_parse_token_num_t cmd_pfc_set_priority =
5402 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5404 cmdline_parse_token_num_t cmd_pfc_set_portid =
5405 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5408 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5409 .f = cmd_priority_flow_ctrl_set_parsed,
5411 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5412 tx on|off high_water low_water pause_time priority port_id",
5414 (void *)&cmd_pfc_set_set,
5415 (void *)&cmd_pfc_set_flow_ctrl,
5416 (void *)&cmd_pfc_set_rx,
5417 (void *)&cmd_pfc_set_rx_mode,
5418 (void *)&cmd_pfc_set_tx,
5419 (void *)&cmd_pfc_set_tx_mode,
5420 (void *)&cmd_pfc_set_high_water,
5421 (void *)&cmd_pfc_set_low_water,
5422 (void *)&cmd_pfc_set_pause_time,
5423 (void *)&cmd_pfc_set_priority,
5424 (void *)&cmd_pfc_set_portid,
5429 /* *** RESET CONFIGURATION *** */
5430 struct cmd_reset_result {
5431 cmdline_fixed_string_t reset;
5432 cmdline_fixed_string_t def;
5435 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5437 __attribute__((unused)) void *data)
5439 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5440 set_def_fwd_config();
5443 cmdline_parse_token_string_t cmd_reset_set =
5444 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5445 cmdline_parse_token_string_t cmd_reset_def =
5446 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5449 cmdline_parse_inst_t cmd_reset = {
5450 .f = cmd_reset_parsed,
5452 .help_str = "set default: reset default forwarding configuration",
5454 (void *)&cmd_reset_set,
5455 (void *)&cmd_reset_def,
5460 /* *** START FORWARDING *** */
5461 struct cmd_start_result {
5462 cmdline_fixed_string_t start;
5465 cmdline_parse_token_string_t cmd_start_start =
5466 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5468 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5469 __attribute__((unused)) struct cmdline *cl,
5470 __attribute__((unused)) void *data)
5472 start_packet_forwarding(0);
5475 cmdline_parse_inst_t cmd_start = {
5476 .f = cmd_start_parsed,
5478 .help_str = "start packet forwarding",
5480 (void *)&cmd_start_start,
5485 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5486 struct cmd_start_tx_first_result {
5487 cmdline_fixed_string_t start;
5488 cmdline_fixed_string_t tx_first;
5492 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5493 __attribute__((unused)) struct cmdline *cl,
5494 __attribute__((unused)) void *data)
5496 start_packet_forwarding(1);
5499 cmdline_parse_token_string_t cmd_start_tx_first_start =
5500 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5502 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5503 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5504 tx_first, "tx_first");
5506 cmdline_parse_inst_t cmd_start_tx_first = {
5507 .f = cmd_start_tx_first_parsed,
5509 .help_str = "start packet forwarding, after sending 1 burst of packets",
5511 (void *)&cmd_start_tx_first_start,
5512 (void *)&cmd_start_tx_first_tx_first,
5517 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5518 struct cmd_start_tx_first_n_result {
5519 cmdline_fixed_string_t start;
5520 cmdline_fixed_string_t tx_first;
5525 cmd_start_tx_first_n_parsed(void *parsed_result,
5526 __attribute__((unused)) struct cmdline *cl,
5527 __attribute__((unused)) void *data)
5529 struct cmd_start_tx_first_n_result *res = parsed_result;
5531 start_packet_forwarding(res->tx_num);
5534 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5535 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5537 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5538 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5539 tx_first, "tx_first");
5540 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5541 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5544 cmdline_parse_inst_t cmd_start_tx_first_n = {
5545 .f = cmd_start_tx_first_n_parsed,
5547 .help_str = "start packet forwarding, after sending <num> "
5548 "bursts of packets",
5550 (void *)&cmd_start_tx_first_n_start,
5551 (void *)&cmd_start_tx_first_n_tx_first,
5552 (void *)&cmd_start_tx_first_n_tx_num,
5557 /* *** SET LINK UP *** */
5558 struct cmd_set_link_up_result {
5559 cmdline_fixed_string_t set;
5560 cmdline_fixed_string_t link_up;
5561 cmdline_fixed_string_t port;
5565 cmdline_parse_token_string_t cmd_set_link_up_set =
5566 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5567 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5570 cmdline_parse_token_string_t cmd_set_link_up_port =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5572 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5573 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5575 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5576 __attribute__((unused)) struct cmdline *cl,
5577 __attribute__((unused)) void *data)
5579 struct cmd_set_link_up_result *res = parsed_result;
5580 dev_set_link_up(res->port_id);
5583 cmdline_parse_inst_t cmd_set_link_up = {
5584 .f = cmd_set_link_up_parsed,
5586 .help_str = "set link-up port (port id)",
5588 (void *)&cmd_set_link_up_set,
5589 (void *)&cmd_set_link_up_link_up,
5590 (void *)&cmd_set_link_up_port,
5591 (void *)&cmd_set_link_up_port_id,
5596 /* *** SET LINK DOWN *** */
5597 struct cmd_set_link_down_result {
5598 cmdline_fixed_string_t set;
5599 cmdline_fixed_string_t link_down;
5600 cmdline_fixed_string_t port;
5604 cmdline_parse_token_string_t cmd_set_link_down_set =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5606 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5607 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5609 cmdline_parse_token_string_t cmd_set_link_down_port =
5610 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5611 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5612 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5614 static void cmd_set_link_down_parsed(
5615 __attribute__((unused)) void *parsed_result,
5616 __attribute__((unused)) struct cmdline *cl,
5617 __attribute__((unused)) void *data)
5619 struct cmd_set_link_down_result *res = parsed_result;
5620 dev_set_link_down(res->port_id);
5623 cmdline_parse_inst_t cmd_set_link_down = {
5624 .f = cmd_set_link_down_parsed,
5626 .help_str = "set link-down port (port id)",
5628 (void *)&cmd_set_link_down_set,
5629 (void *)&cmd_set_link_down_link_down,
5630 (void *)&cmd_set_link_down_port,
5631 (void *)&cmd_set_link_down_port_id,
5636 /* *** SHOW CFG *** */
5637 struct cmd_showcfg_result {
5638 cmdline_fixed_string_t show;
5639 cmdline_fixed_string_t cfg;
5640 cmdline_fixed_string_t what;
5643 static void cmd_showcfg_parsed(void *parsed_result,
5644 __attribute__((unused)) struct cmdline *cl,
5645 __attribute__((unused)) void *data)
5647 struct cmd_showcfg_result *res = parsed_result;
5648 if (!strcmp(res->what, "rxtx"))
5649 rxtx_config_display();
5650 else if (!strcmp(res->what, "cores"))
5651 fwd_lcores_config_display();
5652 else if (!strcmp(res->what, "fwd"))
5653 pkt_fwd_config_display(&cur_fwd_config);
5654 else if (!strcmp(res->what, "txpkts"))
5655 show_tx_pkt_segments();
5658 cmdline_parse_token_string_t cmd_showcfg_show =
5659 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5660 cmdline_parse_token_string_t cmd_showcfg_port =
5661 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5662 cmdline_parse_token_string_t cmd_showcfg_what =
5663 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5664 "rxtx#cores#fwd#txpkts");
5666 cmdline_parse_inst_t cmd_showcfg = {
5667 .f = cmd_showcfg_parsed,
5669 .help_str = "show config rxtx|cores|fwd|txpkts",
5671 (void *)&cmd_showcfg_show,
5672 (void *)&cmd_showcfg_port,
5673 (void *)&cmd_showcfg_what,
5678 /* *** SHOW ALL PORT INFO *** */
5679 struct cmd_showportall_result {
5680 cmdline_fixed_string_t show;
5681 cmdline_fixed_string_t port;
5682 cmdline_fixed_string_t what;
5683 cmdline_fixed_string_t all;
5686 static void cmd_showportall_parsed(void *parsed_result,
5687 __attribute__((unused)) struct cmdline *cl,
5688 __attribute__((unused)) void *data)
5692 struct cmd_showportall_result *res = parsed_result;
5693 if (!strcmp(res->show, "clear")) {
5694 if (!strcmp(res->what, "stats"))
5695 FOREACH_PORT(i, ports)
5697 else if (!strcmp(res->what, "xstats"))
5698 FOREACH_PORT(i, ports)
5699 nic_xstats_clear(i);
5700 } else if (!strcmp(res->what, "info"))
5701 FOREACH_PORT(i, ports)
5702 port_infos_display(i);
5703 else if (!strcmp(res->what, "stats"))
5704 FOREACH_PORT(i, ports)
5705 nic_stats_display(i);
5706 else if (!strcmp(res->what, "xstats"))
5707 FOREACH_PORT(i, ports)
5708 nic_xstats_display(i);
5709 else if (!strcmp(res->what, "fdir"))
5710 FOREACH_PORT(i, ports)
5712 else if (!strcmp(res->what, "stat_qmap"))
5713 FOREACH_PORT(i, ports)
5714 nic_stats_mapping_display(i);
5715 else if (!strcmp(res->what, "dcb_tc"))
5716 FOREACH_PORT(i, ports)
5717 port_dcb_info_display(i);
5720 cmdline_parse_token_string_t cmd_showportall_show =
5721 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5723 cmdline_parse_token_string_t cmd_showportall_port =
5724 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5725 cmdline_parse_token_string_t cmd_showportall_what =
5726 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5727 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5728 cmdline_parse_token_string_t cmd_showportall_all =
5729 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5730 cmdline_parse_inst_t cmd_showportall = {
5731 .f = cmd_showportall_parsed,
5733 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5735 (void *)&cmd_showportall_show,
5736 (void *)&cmd_showportall_port,
5737 (void *)&cmd_showportall_what,
5738 (void *)&cmd_showportall_all,
5743 /* *** SHOW PORT INFO *** */
5744 struct cmd_showport_result {
5745 cmdline_fixed_string_t show;
5746 cmdline_fixed_string_t port;
5747 cmdline_fixed_string_t what;
5751 static void cmd_showport_parsed(void *parsed_result,
5752 __attribute__((unused)) struct cmdline *cl,
5753 __attribute__((unused)) void *data)
5755 struct cmd_showport_result *res = parsed_result;
5756 if (!strcmp(res->show, "clear")) {
5757 if (!strcmp(res->what, "stats"))
5758 nic_stats_clear(res->portnum);
5759 else if (!strcmp(res->what, "xstats"))
5760 nic_xstats_clear(res->portnum);
5761 } else if (!strcmp(res->what, "info"))
5762 port_infos_display(res->portnum);
5763 else if (!strcmp(res->what, "stats"))
5764 nic_stats_display(res->portnum);
5765 else if (!strcmp(res->what, "xstats"))
5766 nic_xstats_display(res->portnum);
5767 else if (!strcmp(res->what, "fdir"))
5768 fdir_get_infos(res->portnum);
5769 else if (!strcmp(res->what, "stat_qmap"))
5770 nic_stats_mapping_display(res->portnum);
5771 else if (!strcmp(res->what, "dcb_tc"))
5772 port_dcb_info_display(res->portnum);
5775 cmdline_parse_token_string_t cmd_showport_show =
5776 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5778 cmdline_parse_token_string_t cmd_showport_port =
5779 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5780 cmdline_parse_token_string_t cmd_showport_what =
5781 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5782 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5783 cmdline_parse_token_num_t cmd_showport_portnum =
5784 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5786 cmdline_parse_inst_t cmd_showport = {
5787 .f = cmd_showport_parsed,
5789 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5791 (void *)&cmd_showport_show,
5792 (void *)&cmd_showport_port,
5793 (void *)&cmd_showport_what,
5794 (void *)&cmd_showport_portnum,
5799 /* *** SHOW QUEUE INFO *** */
5800 struct cmd_showqueue_result {
5801 cmdline_fixed_string_t show;
5802 cmdline_fixed_string_t type;
5803 cmdline_fixed_string_t what;
5809 cmd_showqueue_parsed(void *parsed_result,
5810 __attribute__((unused)) struct cmdline *cl,
5811 __attribute__((unused)) void *data)
5813 struct cmd_showqueue_result *res = parsed_result;
5815 if (!strcmp(res->type, "rxq"))
5816 rx_queue_infos_display(res->portnum, res->queuenum);
5817 else if (!strcmp(res->type, "txq"))
5818 tx_queue_infos_display(res->portnum, res->queuenum);
5821 cmdline_parse_token_string_t cmd_showqueue_show =
5822 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5823 cmdline_parse_token_string_t cmd_showqueue_type =
5824 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5825 cmdline_parse_token_string_t cmd_showqueue_what =
5826 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5827 cmdline_parse_token_num_t cmd_showqueue_portnum =
5828 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5829 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5830 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5832 cmdline_parse_inst_t cmd_showqueue = {
5833 .f = cmd_showqueue_parsed,
5835 .help_str = "show rxq|txq info <port number> <queue_number>",
5837 (void *)&cmd_showqueue_show,
5838 (void *)&cmd_showqueue_type,
5839 (void *)&cmd_showqueue_what,
5840 (void *)&cmd_showqueue_portnum,
5841 (void *)&cmd_showqueue_queuenum,
5846 /* *** READ PORT REGISTER *** */
5847 struct cmd_read_reg_result {
5848 cmdline_fixed_string_t read;
5849 cmdline_fixed_string_t reg;
5855 cmd_read_reg_parsed(void *parsed_result,
5856 __attribute__((unused)) struct cmdline *cl,
5857 __attribute__((unused)) void *data)
5859 struct cmd_read_reg_result *res = parsed_result;
5860 port_reg_display(res->port_id, res->reg_off);
5863 cmdline_parse_token_string_t cmd_read_reg_read =
5864 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5865 cmdline_parse_token_string_t cmd_read_reg_reg =
5866 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5867 cmdline_parse_token_num_t cmd_read_reg_port_id =
5868 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5869 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5870 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5872 cmdline_parse_inst_t cmd_read_reg = {
5873 .f = cmd_read_reg_parsed,
5875 .help_str = "read reg port_id reg_off",
5877 (void *)&cmd_read_reg_read,
5878 (void *)&cmd_read_reg_reg,
5879 (void *)&cmd_read_reg_port_id,
5880 (void *)&cmd_read_reg_reg_off,
5885 /* *** READ PORT REGISTER BIT FIELD *** */
5886 struct cmd_read_reg_bit_field_result {
5887 cmdline_fixed_string_t read;
5888 cmdline_fixed_string_t regfield;
5896 cmd_read_reg_bit_field_parsed(void *parsed_result,
5897 __attribute__((unused)) struct cmdline *cl,
5898 __attribute__((unused)) void *data)
5900 struct cmd_read_reg_bit_field_result *res = parsed_result;
5901 port_reg_bit_field_display(res->port_id, res->reg_off,
5902 res->bit1_pos, res->bit2_pos);
5905 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5906 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5908 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5909 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5910 regfield, "regfield");
5911 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5912 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5914 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5915 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5917 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5918 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5920 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5921 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5924 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5925 .f = cmd_read_reg_bit_field_parsed,
5927 .help_str = "read regfield port_id reg_off bit_x bit_y "
5928 "(read register bit field between bit_x and bit_y included)",
5930 (void *)&cmd_read_reg_bit_field_read,
5931 (void *)&cmd_read_reg_bit_field_regfield,
5932 (void *)&cmd_read_reg_bit_field_port_id,
5933 (void *)&cmd_read_reg_bit_field_reg_off,
5934 (void *)&cmd_read_reg_bit_field_bit1_pos,
5935 (void *)&cmd_read_reg_bit_field_bit2_pos,
5940 /* *** READ PORT REGISTER BIT *** */
5941 struct cmd_read_reg_bit_result {
5942 cmdline_fixed_string_t read;
5943 cmdline_fixed_string_t regbit;
5950 cmd_read_reg_bit_parsed(void *parsed_result,
5951 __attribute__((unused)) struct cmdline *cl,
5952 __attribute__((unused)) void *data)
5954 struct cmd_read_reg_bit_result *res = parsed_result;
5955 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5958 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5959 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5960 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5961 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5963 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5964 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5965 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5966 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5967 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5968 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5970 cmdline_parse_inst_t cmd_read_reg_bit = {
5971 .f = cmd_read_reg_bit_parsed,
5973 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5975 (void *)&cmd_read_reg_bit_read,
5976 (void *)&cmd_read_reg_bit_regbit,
5977 (void *)&cmd_read_reg_bit_port_id,
5978 (void *)&cmd_read_reg_bit_reg_off,
5979 (void *)&cmd_read_reg_bit_bit_pos,
5984 /* *** WRITE PORT REGISTER *** */
5985 struct cmd_write_reg_result {
5986 cmdline_fixed_string_t write;
5987 cmdline_fixed_string_t reg;
5994 cmd_write_reg_parsed(void *parsed_result,
5995 __attribute__((unused)) struct cmdline *cl,
5996 __attribute__((unused)) void *data)
5998 struct cmd_write_reg_result *res = parsed_result;
5999 port_reg_set(res->port_id, res->reg_off, res->value);
6002 cmdline_parse_token_string_t cmd_write_reg_write =
6003 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6004 cmdline_parse_token_string_t cmd_write_reg_reg =
6005 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6006 cmdline_parse_token_num_t cmd_write_reg_port_id =
6007 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6008 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6009 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6010 cmdline_parse_token_num_t cmd_write_reg_value =
6011 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6013 cmdline_parse_inst_t cmd_write_reg = {
6014 .f = cmd_write_reg_parsed,
6016 .help_str = "write reg port_id reg_off reg_value",
6018 (void *)&cmd_write_reg_write,
6019 (void *)&cmd_write_reg_reg,
6020 (void *)&cmd_write_reg_port_id,
6021 (void *)&cmd_write_reg_reg_off,
6022 (void *)&cmd_write_reg_value,
6027 /* *** WRITE PORT REGISTER BIT FIELD *** */
6028 struct cmd_write_reg_bit_field_result {
6029 cmdline_fixed_string_t write;
6030 cmdline_fixed_string_t regfield;
6039 cmd_write_reg_bit_field_parsed(void *parsed_result,
6040 __attribute__((unused)) struct cmdline *cl,
6041 __attribute__((unused)) void *data)
6043 struct cmd_write_reg_bit_field_result *res = parsed_result;
6044 port_reg_bit_field_set(res->port_id, res->reg_off,
6045 res->bit1_pos, res->bit2_pos, res->value);
6048 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6049 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6051 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6052 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6053 regfield, "regfield");
6054 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6055 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6057 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6058 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6060 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6061 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6063 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6064 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6066 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6067 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6070 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6071 .f = cmd_write_reg_bit_field_parsed,
6073 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
6074 "(set register bit field between bit_x and bit_y included)",
6076 (void *)&cmd_write_reg_bit_field_write,
6077 (void *)&cmd_write_reg_bit_field_regfield,
6078 (void *)&cmd_write_reg_bit_field_port_id,
6079 (void *)&cmd_write_reg_bit_field_reg_off,
6080 (void *)&cmd_write_reg_bit_field_bit1_pos,
6081 (void *)&cmd_write_reg_bit_field_bit2_pos,
6082 (void *)&cmd_write_reg_bit_field_value,
6087 /* *** WRITE PORT REGISTER BIT *** */
6088 struct cmd_write_reg_bit_result {
6089 cmdline_fixed_string_t write;
6090 cmdline_fixed_string_t regbit;
6098 cmd_write_reg_bit_parsed(void *parsed_result,
6099 __attribute__((unused)) struct cmdline *cl,
6100 __attribute__((unused)) void *data)
6102 struct cmd_write_reg_bit_result *res = parsed_result;
6103 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6106 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6107 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6109 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6110 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6112 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6113 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6114 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6115 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6116 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6117 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6118 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6119 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6121 cmdline_parse_inst_t cmd_write_reg_bit = {
6122 .f = cmd_write_reg_bit_parsed,
6124 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
6126 (void *)&cmd_write_reg_bit_write,
6127 (void *)&cmd_write_reg_bit_regbit,
6128 (void *)&cmd_write_reg_bit_port_id,
6129 (void *)&cmd_write_reg_bit_reg_off,
6130 (void *)&cmd_write_reg_bit_bit_pos,
6131 (void *)&cmd_write_reg_bit_value,
6136 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6137 struct cmd_read_rxd_txd_result {
6138 cmdline_fixed_string_t read;
6139 cmdline_fixed_string_t rxd_txd;
6146 cmd_read_rxd_txd_parsed(void *parsed_result,
6147 __attribute__((unused)) struct cmdline *cl,
6148 __attribute__((unused)) void *data)
6150 struct cmd_read_rxd_txd_result *res = parsed_result;
6152 if (!strcmp(res->rxd_txd, "rxd"))
6153 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6154 else if (!strcmp(res->rxd_txd, "txd"))
6155 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6158 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6159 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6160 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6161 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6163 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6164 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6165 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6166 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6167 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6168 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6170 cmdline_parse_inst_t cmd_read_rxd_txd = {
6171 .f = cmd_read_rxd_txd_parsed,
6173 .help_str = "read rxd|txd port_id queue_id rxd_id",
6175 (void *)&cmd_read_rxd_txd_read,
6176 (void *)&cmd_read_rxd_txd_rxd_txd,
6177 (void *)&cmd_read_rxd_txd_port_id,
6178 (void *)&cmd_read_rxd_txd_queue_id,
6179 (void *)&cmd_read_rxd_txd_desc_id,
6185 struct cmd_quit_result {
6186 cmdline_fixed_string_t quit;
6189 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6191 __attribute__((unused)) void *data)
6197 cmdline_parse_token_string_t cmd_quit_quit =
6198 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6200 cmdline_parse_inst_t cmd_quit = {
6201 .f = cmd_quit_parsed,
6203 .help_str = "exit application",
6205 (void *)&cmd_quit_quit,
6210 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6211 struct cmd_mac_addr_result {
6212 cmdline_fixed_string_t mac_addr_cmd;
6213 cmdline_fixed_string_t what;
6215 struct ether_addr address;
6218 static void cmd_mac_addr_parsed(void *parsed_result,
6219 __attribute__((unused)) struct cmdline *cl,
6220 __attribute__((unused)) void *data)
6222 struct cmd_mac_addr_result *res = parsed_result;
6225 if (strcmp(res->what, "add") == 0)
6226 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6228 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6230 /* check the return value and print it if is < 0 */
6232 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6236 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6237 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6239 cmdline_parse_token_string_t cmd_mac_addr_what =
6240 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6242 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6243 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6244 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6245 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6247 cmdline_parse_inst_t cmd_mac_addr = {
6248 .f = cmd_mac_addr_parsed,
6250 .help_str = "mac_addr add|remove X <address>: "
6251 "add/remove MAC address on port X",
6253 (void *)&cmd_mac_addr_cmd,
6254 (void *)&cmd_mac_addr_what,
6255 (void *)&cmd_mac_addr_portnum,
6256 (void *)&cmd_mac_addr_addr,
6262 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6263 struct cmd_set_qmap_result {
6264 cmdline_fixed_string_t set;
6265 cmdline_fixed_string_t qmap;
6266 cmdline_fixed_string_t what;
6273 cmd_set_qmap_parsed(void *parsed_result,
6274 __attribute__((unused)) struct cmdline *cl,
6275 __attribute__((unused)) void *data)
6277 struct cmd_set_qmap_result *res = parsed_result;
6278 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6280 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6283 cmdline_parse_token_string_t cmd_setqmap_set =
6284 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6286 cmdline_parse_token_string_t cmd_setqmap_qmap =
6287 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6289 cmdline_parse_token_string_t cmd_setqmap_what =
6290 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6292 cmdline_parse_token_num_t cmd_setqmap_portid =
6293 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6295 cmdline_parse_token_num_t cmd_setqmap_queueid =
6296 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6298 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6299 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6302 cmdline_parse_inst_t cmd_set_qmap = {
6303 .f = cmd_set_qmap_parsed,
6305 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6307 (void *)&cmd_setqmap_set,
6308 (void *)&cmd_setqmap_qmap,
6309 (void *)&cmd_setqmap_what,
6310 (void *)&cmd_setqmap_portid,
6311 (void *)&cmd_setqmap_queueid,
6312 (void *)&cmd_setqmap_mapvalue,
6317 /* *** CONFIGURE UNICAST HASH TABLE *** */
6318 struct cmd_set_uc_hash_table {
6319 cmdline_fixed_string_t set;
6320 cmdline_fixed_string_t port;
6322 cmdline_fixed_string_t what;
6323 struct ether_addr address;
6324 cmdline_fixed_string_t mode;
6328 cmd_set_uc_hash_parsed(void *parsed_result,
6329 __attribute__((unused)) struct cmdline *cl,
6330 __attribute__((unused)) void *data)
6333 struct cmd_set_uc_hash_table *res = parsed_result;
6335 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6337 if (strcmp(res->what, "uta") == 0)
6338 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6339 &res->address,(uint8_t)is_on);
6341 printf("bad unicast hash table parameter, return code = %d \n", ret);
6345 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6346 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6348 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6349 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6351 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6352 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6354 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6355 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6357 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6358 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6360 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6364 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6365 .f = cmd_set_uc_hash_parsed,
6367 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6369 (void *)&cmd_set_uc_hash_set,
6370 (void *)&cmd_set_uc_hash_port,
6371 (void *)&cmd_set_uc_hash_portid,
6372 (void *)&cmd_set_uc_hash_what,
6373 (void *)&cmd_set_uc_hash_mac,
6374 (void *)&cmd_set_uc_hash_mode,
6379 struct cmd_set_uc_all_hash_table {
6380 cmdline_fixed_string_t set;
6381 cmdline_fixed_string_t port;
6383 cmdline_fixed_string_t what;
6384 cmdline_fixed_string_t value;
6385 cmdline_fixed_string_t mode;
6389 cmd_set_uc_all_hash_parsed(void *parsed_result,
6390 __attribute__((unused)) struct cmdline *cl,
6391 __attribute__((unused)) void *data)
6394 struct cmd_set_uc_all_hash_table *res = parsed_result;
6396 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6398 if ((strcmp(res->what, "uta") == 0) &&
6399 (strcmp(res->value, "all") == 0))
6400 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6402 printf("bad unicast hash table parameter,"
6403 "return code = %d \n", ret);
6406 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6407 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6409 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6410 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6412 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6413 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6415 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6416 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6418 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6421 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6425 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6426 .f = cmd_set_uc_all_hash_parsed,
6428 .help_str = "set port X uta all on|off (X = port number)",
6430 (void *)&cmd_set_uc_all_hash_set,
6431 (void *)&cmd_set_uc_all_hash_port,
6432 (void *)&cmd_set_uc_all_hash_portid,
6433 (void *)&cmd_set_uc_all_hash_what,
6434 (void *)&cmd_set_uc_all_hash_value,
6435 (void *)&cmd_set_uc_all_hash_mode,
6440 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6441 struct cmd_set_vf_macvlan_filter {
6442 cmdline_fixed_string_t set;
6443 cmdline_fixed_string_t port;
6445 cmdline_fixed_string_t vf;
6447 struct ether_addr address;
6448 cmdline_fixed_string_t filter_type;
6449 cmdline_fixed_string_t mode;
6453 cmd_set_vf_macvlan_parsed(void *parsed_result,
6454 __attribute__((unused)) struct cmdline *cl,
6455 __attribute__((unused)) void *data)
6458 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6459 struct rte_eth_mac_filter filter;
6461 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6463 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6465 /* set VF MAC filter */
6469 filter.dst_id = res->vf_id;
6471 if (!strcmp(res->filter_type, "exact-mac"))
6472 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6473 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6474 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6475 else if (!strcmp(res->filter_type, "hashmac"))
6476 filter.filter_type = RTE_MAC_HASH_MATCH;
6477 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6478 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6480 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6483 ret = rte_eth_dev_filter_ctrl(res->port_id,
6484 RTE_ETH_FILTER_MACVLAN,
6488 ret = rte_eth_dev_filter_ctrl(res->port_id,
6489 RTE_ETH_FILTER_MACVLAN,
6490 RTE_ETH_FILTER_DELETE,
6494 printf("bad set MAC hash parameter, return code = %d\n", ret);
6498 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6499 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6501 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6502 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6504 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6505 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6507 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6510 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6511 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6513 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6514 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6516 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6517 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6518 filter_type, "exact-mac#exact-mac-vlan"
6519 "#hashmac#hashmac-vlan");
6520 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6521 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6524 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6525 .f = cmd_set_vf_macvlan_parsed,
6527 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6528 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6530 "exact match rule:exact match of MAC or MAC and VLAN; "
6531 "hash match rule: hash match of MAC and exact match "
6534 (void *)&cmd_set_vf_macvlan_set,
6535 (void *)&cmd_set_vf_macvlan_port,
6536 (void *)&cmd_set_vf_macvlan_portid,
6537 (void *)&cmd_set_vf_macvlan_vf,
6538 (void *)&cmd_set_vf_macvlan_vf_id,
6539 (void *)&cmd_set_vf_macvlan_mac,
6540 (void *)&cmd_set_vf_macvlan_filter_type,
6541 (void *)&cmd_set_vf_macvlan_mode,
6546 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6547 struct cmd_set_vf_traffic {
6548 cmdline_fixed_string_t set;
6549 cmdline_fixed_string_t port;
6551 cmdline_fixed_string_t vf;
6553 cmdline_fixed_string_t what;
6554 cmdline_fixed_string_t mode;
6558 cmd_set_vf_traffic_parsed(void *parsed_result,
6559 __attribute__((unused)) struct cmdline *cl,
6560 __attribute__((unused)) void *data)
6562 struct cmd_set_vf_traffic *res = parsed_result;
6563 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6564 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6566 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6569 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6572 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6575 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6576 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6578 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6579 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6581 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6582 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6584 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6585 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6587 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6588 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6591 cmdline_parse_inst_t cmd_set_vf_traffic = {
6592 .f = cmd_set_vf_traffic_parsed,
6594 .help_str = "set port X vf Y rx|tx on|off"
6595 "(X = port number,Y = vf id)",
6597 (void *)&cmd_setvf_traffic_set,
6598 (void *)&cmd_setvf_traffic_port,
6599 (void *)&cmd_setvf_traffic_portid,
6600 (void *)&cmd_setvf_traffic_vf,
6601 (void *)&cmd_setvf_traffic_vfid,
6602 (void *)&cmd_setvf_traffic_what,
6603 (void *)&cmd_setvf_traffic_mode,
6608 /* *** CONFIGURE VF RECEIVE MODE *** */
6609 struct cmd_set_vf_rxmode {
6610 cmdline_fixed_string_t set;
6611 cmdline_fixed_string_t port;
6613 cmdline_fixed_string_t vf;
6615 cmdline_fixed_string_t what;
6616 cmdline_fixed_string_t mode;
6617 cmdline_fixed_string_t on;
6621 cmd_set_vf_rxmode_parsed(void *parsed_result,
6622 __attribute__((unused)) struct cmdline *cl,
6623 __attribute__((unused)) void *data)
6626 uint16_t rx_mode = 0;
6627 struct cmd_set_vf_rxmode *res = parsed_result;
6629 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6630 if (!strcmp(res->what,"rxmode")) {
6631 if (!strcmp(res->mode, "AUPE"))
6632 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6633 else if (!strcmp(res->mode, "ROPE"))
6634 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6635 else if (!strcmp(res->mode, "BAM"))
6636 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6637 else if (!strncmp(res->mode, "MPE",3))
6638 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6641 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6643 printf("bad VF receive mode parameter, return code = %d \n",
6647 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6648 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6650 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6651 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6653 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6654 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6656 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6657 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6659 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6660 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6662 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6663 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6665 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6666 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6667 mode, "AUPE#ROPE#BAM#MPE");
6668 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6672 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6673 .f = cmd_set_vf_rxmode_parsed,
6675 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6677 (void *)&cmd_set_vf_rxmode_set,
6678 (void *)&cmd_set_vf_rxmode_port,
6679 (void *)&cmd_set_vf_rxmode_portid,
6680 (void *)&cmd_set_vf_rxmode_vf,
6681 (void *)&cmd_set_vf_rxmode_vfid,
6682 (void *)&cmd_set_vf_rxmode_what,
6683 (void *)&cmd_set_vf_rxmode_mode,
6684 (void *)&cmd_set_vf_rxmode_on,
6689 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6690 struct cmd_vf_mac_addr_result {
6691 cmdline_fixed_string_t mac_addr_cmd;
6692 cmdline_fixed_string_t what;
6693 cmdline_fixed_string_t port;
6695 cmdline_fixed_string_t vf;
6697 struct ether_addr address;
6700 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6701 __attribute__((unused)) struct cmdline *cl,
6702 __attribute__((unused)) void *data)
6704 struct cmd_vf_mac_addr_result *res = parsed_result;
6707 if (strcmp(res->what, "add") == 0)
6708 ret = rte_eth_dev_mac_addr_add(res->port_num,
6709 &res->address, res->vf_num);
6711 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6715 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6716 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6717 mac_addr_cmd,"mac_addr");
6718 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6719 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6721 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6722 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6724 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6725 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6727 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6728 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6730 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6731 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6733 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6734 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6737 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6738 .f = cmd_vf_mac_addr_parsed,
6740 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6741 "Y = VF number)add MAC address filtering for a VF on port X",
6743 (void *)&cmd_vf_mac_addr_cmd,
6744 (void *)&cmd_vf_mac_addr_what,
6745 (void *)&cmd_vf_mac_addr_port,
6746 (void *)&cmd_vf_mac_addr_portnum,
6747 (void *)&cmd_vf_mac_addr_vf,
6748 (void *)&cmd_vf_mac_addr_vfnum,
6749 (void *)&cmd_vf_mac_addr_addr,
6754 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6755 struct cmd_vf_rx_vlan_filter {
6756 cmdline_fixed_string_t rx_vlan;
6757 cmdline_fixed_string_t what;
6759 cmdline_fixed_string_t port;
6761 cmdline_fixed_string_t vf;
6766 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6767 __attribute__((unused)) struct cmdline *cl,
6768 __attribute__((unused)) void *data)
6770 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6772 if (!strcmp(res->what, "add"))
6773 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6775 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6778 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6779 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6780 rx_vlan, "rx_vlan");
6781 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6782 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6784 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6785 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6787 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6788 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6790 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6791 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6793 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6794 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6796 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6797 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6800 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6801 .f = cmd_vf_rx_vlan_filter_parsed,
6803 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6804 "Y = port number,Z = hexadecimal VF mask)",
6806 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6807 (void *)&cmd_vf_rx_vlan_filter_what,
6808 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6809 (void *)&cmd_vf_rx_vlan_filter_port,
6810 (void *)&cmd_vf_rx_vlan_filter_portid,
6811 (void *)&cmd_vf_rx_vlan_filter_vf,
6812 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6817 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6818 struct cmd_queue_rate_limit_result {
6819 cmdline_fixed_string_t set;
6820 cmdline_fixed_string_t port;
6822 cmdline_fixed_string_t queue;
6824 cmdline_fixed_string_t rate;
6828 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6829 __attribute__((unused)) struct cmdline *cl,
6830 __attribute__((unused)) void *data)
6832 struct cmd_queue_rate_limit_result *res = parsed_result;
6835 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6836 && (strcmp(res->queue, "queue") == 0)
6837 && (strcmp(res->rate, "rate") == 0))
6838 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6841 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6845 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6846 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6848 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6849 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6851 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6852 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6854 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6855 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6857 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6858 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6860 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6861 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6863 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6864 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6867 cmdline_parse_inst_t cmd_queue_rate_limit = {
6868 .f = cmd_queue_rate_limit_parsed,
6870 .help_str = "set port X queue Y rate Z:(X = port number,"
6871 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6873 (void *)&cmd_queue_rate_limit_set,
6874 (void *)&cmd_queue_rate_limit_port,
6875 (void *)&cmd_queue_rate_limit_portnum,
6876 (void *)&cmd_queue_rate_limit_queue,
6877 (void *)&cmd_queue_rate_limit_queuenum,
6878 (void *)&cmd_queue_rate_limit_rate,
6879 (void *)&cmd_queue_rate_limit_ratenum,
6884 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6885 struct cmd_vf_rate_limit_result {
6886 cmdline_fixed_string_t set;
6887 cmdline_fixed_string_t port;
6889 cmdline_fixed_string_t vf;
6891 cmdline_fixed_string_t rate;
6893 cmdline_fixed_string_t q_msk;
6897 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6898 __attribute__((unused)) struct cmdline *cl,
6899 __attribute__((unused)) void *data)
6901 struct cmd_vf_rate_limit_result *res = parsed_result;
6904 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6905 && (strcmp(res->vf, "vf") == 0)
6906 && (strcmp(res->rate, "rate") == 0)
6907 && (strcmp(res->q_msk, "queue_mask") == 0))
6908 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6909 res->rate_num, res->q_msk_val);
6911 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6915 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6916 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6918 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6919 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6921 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6922 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6924 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6925 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6927 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6928 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6930 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6931 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6933 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6934 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6936 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6937 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6938 q_msk, "queue_mask");
6939 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6940 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6943 cmdline_parse_inst_t cmd_vf_rate_limit = {
6944 .f = cmd_vf_rate_limit_parsed,
6946 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6947 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6948 "for queues of VF on port X",
6950 (void *)&cmd_vf_rate_limit_set,
6951 (void *)&cmd_vf_rate_limit_port,
6952 (void *)&cmd_vf_rate_limit_portnum,
6953 (void *)&cmd_vf_rate_limit_vf,
6954 (void *)&cmd_vf_rate_limit_vfnum,
6955 (void *)&cmd_vf_rate_limit_rate,
6956 (void *)&cmd_vf_rate_limit_ratenum,
6957 (void *)&cmd_vf_rate_limit_q_msk,
6958 (void *)&cmd_vf_rate_limit_q_msk_val,
6963 /* *** ADD TUNNEL FILTER OF A PORT *** */
6964 struct cmd_tunnel_filter_result {
6965 cmdline_fixed_string_t cmd;
6966 cmdline_fixed_string_t what;
6968 struct ether_addr outer_mac;
6969 struct ether_addr inner_mac;
6970 cmdline_ipaddr_t ip_value;
6971 uint16_t inner_vlan;
6972 cmdline_fixed_string_t tunnel_type;
6973 cmdline_fixed_string_t filter_type;
6979 cmd_tunnel_filter_parsed(void *parsed_result,
6980 __attribute__((unused)) struct cmdline *cl,
6981 __attribute__((unused)) void *data)
6983 struct cmd_tunnel_filter_result *res = parsed_result;
6984 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6987 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
6989 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
6990 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
6991 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6993 if (res->ip_value.family == AF_INET) {
6994 tunnel_filter_conf.ip_addr.ipv4_addr =
6995 res->ip_value.addr.ipv4.s_addr;
6996 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6998 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6999 &(res->ip_value.addr.ipv6),
7000 sizeof(struct in6_addr));
7001 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7004 if (!strcmp(res->filter_type, "imac-ivlan"))
7005 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7006 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7007 tunnel_filter_conf.filter_type =
7008 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7009 else if (!strcmp(res->filter_type, "imac-tenid"))
7010 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7011 else if (!strcmp(res->filter_type, "imac"))
7012 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7013 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7014 tunnel_filter_conf.filter_type =
7015 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7016 else if (!strcmp(res->filter_type, "oip"))
7017 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7018 else if (!strcmp(res->filter_type, "iip"))
7019 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7021 printf("The filter type is not supported");
7025 if (!strcmp(res->tunnel_type, "vxlan"))
7026 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7027 else if (!strcmp(res->tunnel_type, "nvgre"))
7028 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7029 else if (!strcmp(res->tunnel_type, "ipingre"))
7030 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7032 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7036 tunnel_filter_conf.tenant_id = res->tenant_id;
7037 tunnel_filter_conf.queue_id = res->queue_num;
7038 if (!strcmp(res->what, "add"))
7039 ret = rte_eth_dev_filter_ctrl(res->port_id,
7040 RTE_ETH_FILTER_TUNNEL,
7042 &tunnel_filter_conf);
7044 ret = rte_eth_dev_filter_ctrl(res->port_id,
7045 RTE_ETH_FILTER_TUNNEL,
7046 RTE_ETH_FILTER_DELETE,
7047 &tunnel_filter_conf);
7049 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7053 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7054 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7055 cmd, "tunnel_filter");
7056 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7057 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7059 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7060 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7062 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7063 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7065 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7066 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7068 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7069 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7070 inner_vlan, UINT16);
7071 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7072 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7074 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7075 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7076 tunnel_type, "vxlan#nvgre#ipingre");
7078 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7079 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7080 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7081 "imac#omac-imac-tenid");
7082 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7083 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7085 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7086 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7089 cmdline_parse_inst_t cmd_tunnel_filter = {
7090 .f = cmd_tunnel_filter_parsed,
7092 .help_str = "add/rm tunnel filter of a port: "
7093 "tunnel_filter add port_id outer_mac inner_mac ip "
7094 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
7095 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
7096 "imac|omac-imac-tenid) "
7097 "tenant_id queue_num",
7099 (void *)&cmd_tunnel_filter_cmd,
7100 (void *)&cmd_tunnel_filter_what,
7101 (void *)&cmd_tunnel_filter_port_id,
7102 (void *)&cmd_tunnel_filter_outer_mac,
7103 (void *)&cmd_tunnel_filter_inner_mac,
7104 (void *)&cmd_tunnel_filter_ip_value,
7105 (void *)&cmd_tunnel_filter_innner_vlan,
7106 (void *)&cmd_tunnel_filter_tunnel_type,
7107 (void *)&cmd_tunnel_filter_filter_type,
7108 (void *)&cmd_tunnel_filter_tenant_id,
7109 (void *)&cmd_tunnel_filter_queue_num,
7114 /* *** CONFIGURE TUNNEL UDP PORT *** */
7115 struct cmd_tunnel_udp_config {
7116 cmdline_fixed_string_t cmd;
7117 cmdline_fixed_string_t what;
7123 cmd_tunnel_udp_config_parsed(void *parsed_result,
7124 __attribute__((unused)) struct cmdline *cl,
7125 __attribute__((unused)) void *data)
7127 struct cmd_tunnel_udp_config *res = parsed_result;
7128 struct rte_eth_udp_tunnel tunnel_udp;
7131 tunnel_udp.udp_port = res->udp_port;
7133 if (!strcmp(res->cmd, "rx_vxlan_port"))
7134 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7136 if (!strcmp(res->what, "add"))
7137 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7140 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7144 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7147 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7148 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7149 cmd, "rx_vxlan_port");
7150 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7151 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7153 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7154 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7156 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7157 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7160 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7161 .f = cmd_tunnel_udp_config_parsed,
7163 .help_str = "add/rm an tunneling UDP port filter: "
7164 "rx_vxlan_port add udp_port port_id",
7166 (void *)&cmd_tunnel_udp_config_cmd,
7167 (void *)&cmd_tunnel_udp_config_what,
7168 (void *)&cmd_tunnel_udp_config_udp_port,
7169 (void *)&cmd_tunnel_udp_config_port_id,
7174 /* *** GLOBAL CONFIG *** */
7175 struct cmd_global_config_result {
7176 cmdline_fixed_string_t cmd;
7178 cmdline_fixed_string_t cfg_type;
7183 cmd_global_config_parsed(void *parsed_result,
7184 __attribute__((unused)) struct cmdline *cl,
7185 __attribute__((unused)) void *data)
7187 struct cmd_global_config_result *res = parsed_result;
7188 struct rte_eth_global_cfg conf;
7191 memset(&conf, 0, sizeof(conf));
7192 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7193 conf.cfg.gre_key_len = res->len;
7194 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7195 RTE_ETH_FILTER_SET, &conf);
7197 printf("Global config error\n");
7200 cmdline_parse_token_string_t cmd_global_config_cmd =
7201 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7203 cmdline_parse_token_num_t cmd_global_config_port_id =
7204 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7205 cmdline_parse_token_string_t cmd_global_config_type =
7206 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7207 cfg_type, "gre-key-len");
7208 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7209 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7212 cmdline_parse_inst_t cmd_global_config = {
7213 .f = cmd_global_config_parsed,
7214 .data = (void *)NULL,
7215 .help_str = "global_config <port_id> gre-key-len <number>",
7217 (void *)&cmd_global_config_cmd,
7218 (void *)&cmd_global_config_port_id,
7219 (void *)&cmd_global_config_type,
7220 (void *)&cmd_global_config_gre_key_len,
7225 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7226 struct cmd_set_mirror_mask_result {
7227 cmdline_fixed_string_t set;
7228 cmdline_fixed_string_t port;
7230 cmdline_fixed_string_t mirror;
7232 cmdline_fixed_string_t what;
7233 cmdline_fixed_string_t value;
7234 cmdline_fixed_string_t dstpool;
7236 cmdline_fixed_string_t on;
7239 cmdline_parse_token_string_t cmd_mirror_mask_set =
7240 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7242 cmdline_parse_token_string_t cmd_mirror_mask_port =
7243 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7245 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7246 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7248 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7249 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7250 mirror, "mirror-rule");
7251 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7252 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7254 cmdline_parse_token_string_t cmd_mirror_mask_what =
7255 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7256 what, "pool-mirror-up#pool-mirror-down"
7258 cmdline_parse_token_string_t cmd_mirror_mask_value =
7259 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7261 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7262 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7263 dstpool, "dst-pool");
7264 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7265 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7267 cmdline_parse_token_string_t cmd_mirror_mask_on =
7268 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7272 cmd_set_mirror_mask_parsed(void *parsed_result,
7273 __attribute__((unused)) struct cmdline *cl,
7274 __attribute__((unused)) void *data)
7277 struct cmd_set_mirror_mask_result *res = parsed_result;
7278 struct rte_eth_mirror_conf mr_conf;
7280 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7282 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7284 mr_conf.dst_pool = res->dstpool_id;
7286 if (!strcmp(res->what, "pool-mirror-up")) {
7287 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7288 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7289 } else if (!strcmp(res->what, "pool-mirror-down")) {
7290 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7291 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7292 } else if (!strcmp(res->what, "vlan-mirror")) {
7293 mr_conf.rule_type = ETH_MIRROR_VLAN;
7294 nb_item = parse_item_list(res->value, "vlan",
7295 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7299 for (i = 0; i < nb_item; i++) {
7300 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7301 printf("Invalid vlan_id: must be < 4096\n");
7305 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7306 mr_conf.vlan.vlan_mask |= 1ULL << i;
7310 if (!strcmp(res->on, "on"))
7311 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7314 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7317 printf("mirror rule add error: (%s)\n", strerror(-ret));
7320 cmdline_parse_inst_t cmd_set_mirror_mask = {
7321 .f = cmd_set_mirror_mask_parsed,
7323 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7324 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7326 (void *)&cmd_mirror_mask_set,
7327 (void *)&cmd_mirror_mask_port,
7328 (void *)&cmd_mirror_mask_portid,
7329 (void *)&cmd_mirror_mask_mirror,
7330 (void *)&cmd_mirror_mask_ruleid,
7331 (void *)&cmd_mirror_mask_what,
7332 (void *)&cmd_mirror_mask_value,
7333 (void *)&cmd_mirror_mask_dstpool,
7334 (void *)&cmd_mirror_mask_poolid,
7335 (void *)&cmd_mirror_mask_on,
7340 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7341 struct cmd_set_mirror_link_result {
7342 cmdline_fixed_string_t set;
7343 cmdline_fixed_string_t port;
7345 cmdline_fixed_string_t mirror;
7347 cmdline_fixed_string_t what;
7348 cmdline_fixed_string_t dstpool;
7350 cmdline_fixed_string_t on;
7353 cmdline_parse_token_string_t cmd_mirror_link_set =
7354 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7356 cmdline_parse_token_string_t cmd_mirror_link_port =
7357 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7359 cmdline_parse_token_num_t cmd_mirror_link_portid =
7360 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7362 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7363 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7364 mirror, "mirror-rule");
7365 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7366 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7368 cmdline_parse_token_string_t cmd_mirror_link_what =
7369 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7370 what, "uplink-mirror#downlink-mirror");
7371 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7372 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7373 dstpool, "dst-pool");
7374 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7375 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7377 cmdline_parse_token_string_t cmd_mirror_link_on =
7378 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7382 cmd_set_mirror_link_parsed(void *parsed_result,
7383 __attribute__((unused)) struct cmdline *cl,
7384 __attribute__((unused)) void *data)
7387 struct cmd_set_mirror_link_result *res = parsed_result;
7388 struct rte_eth_mirror_conf mr_conf;
7390 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7391 if (!strcmp(res->what, "uplink-mirror"))
7392 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7394 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7396 mr_conf.dst_pool = res->dstpool_id;
7398 if (!strcmp(res->on, "on"))
7399 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7402 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7405 /* check the return value and print it if is < 0 */
7407 printf("mirror rule add error: (%s)\n", strerror(-ret));
7411 cmdline_parse_inst_t cmd_set_mirror_link = {
7412 .f = cmd_set_mirror_link_parsed,
7414 .help_str = "set port X mirror-rule Y uplink-mirror|"
7415 "downlink-mirror dst-pool Z on|off",
7417 (void *)&cmd_mirror_link_set,
7418 (void *)&cmd_mirror_link_port,
7419 (void *)&cmd_mirror_link_portid,
7420 (void *)&cmd_mirror_link_mirror,
7421 (void *)&cmd_mirror_link_ruleid,
7422 (void *)&cmd_mirror_link_what,
7423 (void *)&cmd_mirror_link_dstpool,
7424 (void *)&cmd_mirror_link_poolid,
7425 (void *)&cmd_mirror_link_on,
7430 /* *** RESET VM MIRROR RULE *** */
7431 struct cmd_rm_mirror_rule_result {
7432 cmdline_fixed_string_t reset;
7433 cmdline_fixed_string_t port;
7435 cmdline_fixed_string_t mirror;
7439 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7440 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7442 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7443 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7445 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7446 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7448 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7449 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7450 mirror, "mirror-rule");
7451 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7452 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7456 cmd_reset_mirror_rule_parsed(void *parsed_result,
7457 __attribute__((unused)) struct cmdline *cl,
7458 __attribute__((unused)) void *data)
7461 struct cmd_set_mirror_link_result *res = parsed_result;
7463 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7465 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7468 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7469 .f = cmd_reset_mirror_rule_parsed,
7471 .help_str = "reset port X mirror-rule Y",
7473 (void *)&cmd_rm_mirror_rule_reset,
7474 (void *)&cmd_rm_mirror_rule_port,
7475 (void *)&cmd_rm_mirror_rule_portid,
7476 (void *)&cmd_rm_mirror_rule_mirror,
7477 (void *)&cmd_rm_mirror_rule_ruleid,
7482 /* ******************************************************************************** */
7484 struct cmd_dump_result {
7485 cmdline_fixed_string_t dump;
7489 dump_struct_sizes(void)
7491 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7492 DUMP_SIZE(struct rte_mbuf);
7493 DUMP_SIZE(struct rte_mempool);
7494 DUMP_SIZE(struct rte_ring);
7498 static void cmd_dump_parsed(void *parsed_result,
7499 __attribute__((unused)) struct cmdline *cl,
7500 __attribute__((unused)) void *data)
7502 struct cmd_dump_result *res = parsed_result;
7504 if (!strcmp(res->dump, "dump_physmem"))
7505 rte_dump_physmem_layout(stdout);
7506 else if (!strcmp(res->dump, "dump_memzone"))
7507 rte_memzone_dump(stdout);
7508 else if (!strcmp(res->dump, "dump_struct_sizes"))
7509 dump_struct_sizes();
7510 else if (!strcmp(res->dump, "dump_ring"))
7511 rte_ring_list_dump(stdout);
7512 else if (!strcmp(res->dump, "dump_mempool"))
7513 rte_mempool_list_dump(stdout);
7514 else if (!strcmp(res->dump, "dump_devargs"))
7515 rte_eal_devargs_dump(stdout);
7518 cmdline_parse_token_string_t cmd_dump_dump =
7519 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7522 "dump_struct_sizes#"
7527 cmdline_parse_inst_t cmd_dump = {
7528 .f = cmd_dump_parsed, /* function to call */
7529 .data = NULL, /* 2nd arg of func */
7530 .help_str = "dump status",
7531 .tokens = { /* token list, NULL terminated */
7532 (void *)&cmd_dump_dump,
7537 /* ******************************************************************************** */
7539 struct cmd_dump_one_result {
7540 cmdline_fixed_string_t dump;
7541 cmdline_fixed_string_t name;
7544 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7545 __attribute__((unused)) void *data)
7547 struct cmd_dump_one_result *res = parsed_result;
7549 if (!strcmp(res->dump, "dump_ring")) {
7551 r = rte_ring_lookup(res->name);
7553 cmdline_printf(cl, "Cannot find ring\n");
7556 rte_ring_dump(stdout, r);
7557 } else if (!strcmp(res->dump, "dump_mempool")) {
7558 struct rte_mempool *mp;
7559 mp = rte_mempool_lookup(res->name);
7561 cmdline_printf(cl, "Cannot find mempool\n");
7564 rte_mempool_dump(stdout, mp);
7568 cmdline_parse_token_string_t cmd_dump_one_dump =
7569 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7570 "dump_ring#dump_mempool");
7572 cmdline_parse_token_string_t cmd_dump_one_name =
7573 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7575 cmdline_parse_inst_t cmd_dump_one = {
7576 .f = cmd_dump_one_parsed, /* function to call */
7577 .data = NULL, /* 2nd arg of func */
7578 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7579 .tokens = { /* token list, NULL terminated */
7580 (void *)&cmd_dump_one_dump,
7581 (void *)&cmd_dump_one_name,
7586 /* *** Add/Del syn filter *** */
7587 struct cmd_syn_filter_result {
7588 cmdline_fixed_string_t filter;
7590 cmdline_fixed_string_t ops;
7591 cmdline_fixed_string_t priority;
7592 cmdline_fixed_string_t high;
7593 cmdline_fixed_string_t queue;
7598 cmd_syn_filter_parsed(void *parsed_result,
7599 __attribute__((unused)) struct cmdline *cl,
7600 __attribute__((unused)) void *data)
7602 struct cmd_syn_filter_result *res = parsed_result;
7603 struct rte_eth_syn_filter syn_filter;
7606 ret = rte_eth_dev_filter_supported(res->port_id,
7607 RTE_ETH_FILTER_SYN);
7609 printf("syn filter is not supported on port %u.\n",
7614 memset(&syn_filter, 0, sizeof(syn_filter));
7616 if (!strcmp(res->ops, "add")) {
7617 if (!strcmp(res->high, "high"))
7618 syn_filter.hig_pri = 1;
7620 syn_filter.hig_pri = 0;
7622 syn_filter.queue = res->queue_id;
7623 ret = rte_eth_dev_filter_ctrl(res->port_id,
7628 ret = rte_eth_dev_filter_ctrl(res->port_id,
7630 RTE_ETH_FILTER_DELETE,
7634 printf("syn filter programming error: (%s)\n",
7638 cmdline_parse_token_string_t cmd_syn_filter_filter =
7639 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7640 filter, "syn_filter");
7641 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7642 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7644 cmdline_parse_token_string_t cmd_syn_filter_ops =
7645 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7647 cmdline_parse_token_string_t cmd_syn_filter_priority =
7648 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7649 priority, "priority");
7650 cmdline_parse_token_string_t cmd_syn_filter_high =
7651 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7653 cmdline_parse_token_string_t cmd_syn_filter_queue =
7654 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7656 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7657 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7660 cmdline_parse_inst_t cmd_syn_filter = {
7661 .f = cmd_syn_filter_parsed,
7663 .help_str = "add/delete syn filter",
7665 (void *)&cmd_syn_filter_filter,
7666 (void *)&cmd_syn_filter_port_id,
7667 (void *)&cmd_syn_filter_ops,
7668 (void *)&cmd_syn_filter_priority,
7669 (void *)&cmd_syn_filter_high,
7670 (void *)&cmd_syn_filter_queue,
7671 (void *)&cmd_syn_filter_queue_id,
7676 /* *** ADD/REMOVE A 2tuple FILTER *** */
7677 struct cmd_2tuple_filter_result {
7678 cmdline_fixed_string_t filter;
7680 cmdline_fixed_string_t ops;
7681 cmdline_fixed_string_t dst_port;
7682 uint16_t dst_port_value;
7683 cmdline_fixed_string_t protocol;
7684 uint8_t protocol_value;
7685 cmdline_fixed_string_t mask;
7687 cmdline_fixed_string_t tcp_flags;
7688 uint8_t tcp_flags_value;
7689 cmdline_fixed_string_t priority;
7690 uint8_t priority_value;
7691 cmdline_fixed_string_t queue;
7696 cmd_2tuple_filter_parsed(void *parsed_result,
7697 __attribute__((unused)) struct cmdline *cl,
7698 __attribute__((unused)) void *data)
7700 struct rte_eth_ntuple_filter filter;
7701 struct cmd_2tuple_filter_result *res = parsed_result;
7704 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7706 printf("ntuple filter is not supported on port %u.\n",
7711 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7713 filter.flags = RTE_2TUPLE_FLAGS;
7714 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7715 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7716 filter.proto = res->protocol_value;
7717 filter.priority = res->priority_value;
7718 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7719 printf("nonzero tcp_flags is only meaningful"
7720 " when protocol is TCP.\n");
7723 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7724 printf("invalid TCP flags.\n");
7728 if (res->tcp_flags_value != 0) {
7729 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7730 filter.tcp_flags = res->tcp_flags_value;
7733 /* need convert to big endian. */
7734 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7735 filter.queue = res->queue_id;
7737 if (!strcmp(res->ops, "add"))
7738 ret = rte_eth_dev_filter_ctrl(res->port_id,
7739 RTE_ETH_FILTER_NTUPLE,
7743 ret = rte_eth_dev_filter_ctrl(res->port_id,
7744 RTE_ETH_FILTER_NTUPLE,
7745 RTE_ETH_FILTER_DELETE,
7748 printf("2tuple filter programming error: (%s)\n",
7753 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7754 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7755 filter, "2tuple_filter");
7756 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7757 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7759 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7760 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7762 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7763 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7764 dst_port, "dst_port");
7765 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7766 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7767 dst_port_value, UINT16);
7768 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7769 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7770 protocol, "protocol");
7771 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7772 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7773 protocol_value, UINT8);
7774 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7775 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7777 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7778 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7780 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7781 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7782 tcp_flags, "tcp_flags");
7783 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7784 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7785 tcp_flags_value, UINT8);
7786 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7787 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7788 priority, "priority");
7789 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7790 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7791 priority_value, UINT8);
7792 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7793 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7795 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7796 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7799 cmdline_parse_inst_t cmd_2tuple_filter = {
7800 .f = cmd_2tuple_filter_parsed,
7802 .help_str = "add a 2tuple filter",
7804 (void *)&cmd_2tuple_filter_filter,
7805 (void *)&cmd_2tuple_filter_port_id,
7806 (void *)&cmd_2tuple_filter_ops,
7807 (void *)&cmd_2tuple_filter_dst_port,
7808 (void *)&cmd_2tuple_filter_dst_port_value,
7809 (void *)&cmd_2tuple_filter_protocol,
7810 (void *)&cmd_2tuple_filter_protocol_value,
7811 (void *)&cmd_2tuple_filter_mask,
7812 (void *)&cmd_2tuple_filter_mask_value,
7813 (void *)&cmd_2tuple_filter_tcp_flags,
7814 (void *)&cmd_2tuple_filter_tcp_flags_value,
7815 (void *)&cmd_2tuple_filter_priority,
7816 (void *)&cmd_2tuple_filter_priority_value,
7817 (void *)&cmd_2tuple_filter_queue,
7818 (void *)&cmd_2tuple_filter_queue_id,
7823 /* *** ADD/REMOVE A 5tuple FILTER *** */
7824 struct cmd_5tuple_filter_result {
7825 cmdline_fixed_string_t filter;
7827 cmdline_fixed_string_t ops;
7828 cmdline_fixed_string_t dst_ip;
7829 cmdline_ipaddr_t dst_ip_value;
7830 cmdline_fixed_string_t src_ip;
7831 cmdline_ipaddr_t src_ip_value;
7832 cmdline_fixed_string_t dst_port;
7833 uint16_t dst_port_value;
7834 cmdline_fixed_string_t src_port;
7835 uint16_t src_port_value;
7836 cmdline_fixed_string_t protocol;
7837 uint8_t protocol_value;
7838 cmdline_fixed_string_t mask;
7840 cmdline_fixed_string_t tcp_flags;
7841 uint8_t tcp_flags_value;
7842 cmdline_fixed_string_t priority;
7843 uint8_t priority_value;
7844 cmdline_fixed_string_t queue;
7849 cmd_5tuple_filter_parsed(void *parsed_result,
7850 __attribute__((unused)) struct cmdline *cl,
7851 __attribute__((unused)) void *data)
7853 struct rte_eth_ntuple_filter filter;
7854 struct cmd_5tuple_filter_result *res = parsed_result;
7857 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7859 printf("ntuple filter is not supported on port %u.\n",
7864 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7866 filter.flags = RTE_5TUPLE_FLAGS;
7867 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7868 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7869 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7870 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7871 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7872 filter.proto = res->protocol_value;
7873 filter.priority = res->priority_value;
7874 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7875 printf("nonzero tcp_flags is only meaningful"
7876 " when protocol is TCP.\n");
7879 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7880 printf("invalid TCP flags.\n");
7884 if (res->tcp_flags_value != 0) {
7885 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7886 filter.tcp_flags = res->tcp_flags_value;
7889 if (res->dst_ip_value.family == AF_INET)
7890 /* no need to convert, already big endian. */
7891 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7893 if (filter.dst_ip_mask == 0) {
7894 printf("can not support ipv6 involved compare.\n");
7900 if (res->src_ip_value.family == AF_INET)
7901 /* no need to convert, already big endian. */
7902 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7904 if (filter.src_ip_mask == 0) {
7905 printf("can not support ipv6 involved compare.\n");
7910 /* need convert to big endian. */
7911 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7912 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7913 filter.queue = res->queue_id;
7915 if (!strcmp(res->ops, "add"))
7916 ret = rte_eth_dev_filter_ctrl(res->port_id,
7917 RTE_ETH_FILTER_NTUPLE,
7921 ret = rte_eth_dev_filter_ctrl(res->port_id,
7922 RTE_ETH_FILTER_NTUPLE,
7923 RTE_ETH_FILTER_DELETE,
7926 printf("5tuple filter programming error: (%s)\n",
7930 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7931 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7932 filter, "5tuple_filter");
7933 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7934 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7936 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7937 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7939 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7940 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7942 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7943 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7945 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7946 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7948 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7949 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7951 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7952 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7953 dst_port, "dst_port");
7954 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7955 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7956 dst_port_value, UINT16);
7957 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7958 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7959 src_port, "src_port");
7960 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7961 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7962 src_port_value, UINT16);
7963 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7964 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7965 protocol, "protocol");
7966 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7967 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7968 protocol_value, UINT8);
7969 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7970 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7972 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7973 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7975 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7976 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7977 tcp_flags, "tcp_flags");
7978 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7979 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7980 tcp_flags_value, UINT8);
7981 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7982 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7983 priority, "priority");
7984 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7985 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7986 priority_value, UINT8);
7987 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7988 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7990 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7991 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7994 cmdline_parse_inst_t cmd_5tuple_filter = {
7995 .f = cmd_5tuple_filter_parsed,
7997 .help_str = "add/del a 5tuple filter",
7999 (void *)&cmd_5tuple_filter_filter,
8000 (void *)&cmd_5tuple_filter_port_id,
8001 (void *)&cmd_5tuple_filter_ops,
8002 (void *)&cmd_5tuple_filter_dst_ip,
8003 (void *)&cmd_5tuple_filter_dst_ip_value,
8004 (void *)&cmd_5tuple_filter_src_ip,
8005 (void *)&cmd_5tuple_filter_src_ip_value,
8006 (void *)&cmd_5tuple_filter_dst_port,
8007 (void *)&cmd_5tuple_filter_dst_port_value,
8008 (void *)&cmd_5tuple_filter_src_port,
8009 (void *)&cmd_5tuple_filter_src_port_value,
8010 (void *)&cmd_5tuple_filter_protocol,
8011 (void *)&cmd_5tuple_filter_protocol_value,
8012 (void *)&cmd_5tuple_filter_mask,
8013 (void *)&cmd_5tuple_filter_mask_value,
8014 (void *)&cmd_5tuple_filter_tcp_flags,
8015 (void *)&cmd_5tuple_filter_tcp_flags_value,
8016 (void *)&cmd_5tuple_filter_priority,
8017 (void *)&cmd_5tuple_filter_priority_value,
8018 (void *)&cmd_5tuple_filter_queue,
8019 (void *)&cmd_5tuple_filter_queue_id,
8024 /* *** ADD/REMOVE A flex FILTER *** */
8025 struct cmd_flex_filter_result {
8026 cmdline_fixed_string_t filter;
8027 cmdline_fixed_string_t ops;
8029 cmdline_fixed_string_t len;
8031 cmdline_fixed_string_t bytes;
8032 cmdline_fixed_string_t bytes_value;
8033 cmdline_fixed_string_t mask;
8034 cmdline_fixed_string_t mask_value;
8035 cmdline_fixed_string_t priority;
8036 uint8_t priority_value;
8037 cmdline_fixed_string_t queue;
8041 static int xdigit2val(unsigned char c)
8046 else if (isupper(c))
8054 cmd_flex_filter_parsed(void *parsed_result,
8055 __attribute__((unused)) struct cmdline *cl,
8056 __attribute__((unused)) void *data)
8059 struct rte_eth_flex_filter filter;
8060 struct cmd_flex_filter_result *res = parsed_result;
8061 char *bytes_ptr, *mask_ptr;
8062 uint16_t len, i, j = 0;
8067 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8068 printf("the len exceed the max length 128\n");
8071 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8072 filter.len = res->len_value;
8073 filter.priority = res->priority_value;
8074 filter.queue = res->queue_id;
8075 bytes_ptr = res->bytes_value;
8076 mask_ptr = res->mask_value;
8078 /* translate bytes string to array. */
8079 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8080 (bytes_ptr[1] == 'X')))
8082 len = strnlen(bytes_ptr, res->len_value * 2);
8083 if (len == 0 || (len % 8 != 0)) {
8084 printf("please check len and bytes input\n");
8087 for (i = 0; i < len; i++) {
8089 if (isxdigit(c) == 0) {
8090 /* invalid characters. */
8091 printf("invalid input\n");
8094 val = xdigit2val(c);
8097 filter.bytes[j] = byte;
8098 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8105 /* translate mask string to uint8_t array. */
8106 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8107 (mask_ptr[1] == 'X')))
8109 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8111 printf("invalid input\n");
8116 for (i = 0; i < len; i++) {
8118 if (isxdigit(c) == 0) {
8119 /* invalid characters. */
8120 printf("invalid input\n");
8123 val = xdigit2val(c);
8126 filter.mask[j] = byte;
8127 printf("mask[%d]:%02x ", j, filter.mask[j]);
8135 if (!strcmp(res->ops, "add"))
8136 ret = rte_eth_dev_filter_ctrl(res->port_id,
8137 RTE_ETH_FILTER_FLEXIBLE,
8141 ret = rte_eth_dev_filter_ctrl(res->port_id,
8142 RTE_ETH_FILTER_FLEXIBLE,
8143 RTE_ETH_FILTER_DELETE,
8147 printf("flex filter setting error: (%s)\n", strerror(-ret));
8150 cmdline_parse_token_string_t cmd_flex_filter_filter =
8151 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8152 filter, "flex_filter");
8153 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8154 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8156 cmdline_parse_token_string_t cmd_flex_filter_ops =
8157 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8159 cmdline_parse_token_string_t cmd_flex_filter_len =
8160 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8162 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8163 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8165 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8166 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8168 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8169 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8171 cmdline_parse_token_string_t cmd_flex_filter_mask =
8172 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8174 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8175 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8177 cmdline_parse_token_string_t cmd_flex_filter_priority =
8178 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8179 priority, "priority");
8180 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8181 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8182 priority_value, UINT8);
8183 cmdline_parse_token_string_t cmd_flex_filter_queue =
8184 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8186 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8187 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8189 cmdline_parse_inst_t cmd_flex_filter = {
8190 .f = cmd_flex_filter_parsed,
8192 .help_str = "add/del a flex filter",
8194 (void *)&cmd_flex_filter_filter,
8195 (void *)&cmd_flex_filter_port_id,
8196 (void *)&cmd_flex_filter_ops,
8197 (void *)&cmd_flex_filter_len,
8198 (void *)&cmd_flex_filter_len_value,
8199 (void *)&cmd_flex_filter_bytes,
8200 (void *)&cmd_flex_filter_bytes_value,
8201 (void *)&cmd_flex_filter_mask,
8202 (void *)&cmd_flex_filter_mask_value,
8203 (void *)&cmd_flex_filter_priority,
8204 (void *)&cmd_flex_filter_priority_value,
8205 (void *)&cmd_flex_filter_queue,
8206 (void *)&cmd_flex_filter_queue_id,
8211 /* *** Filters Control *** */
8213 /* *** deal with ethertype filter *** */
8214 struct cmd_ethertype_filter_result {
8215 cmdline_fixed_string_t filter;
8217 cmdline_fixed_string_t ops;
8218 cmdline_fixed_string_t mac;
8219 struct ether_addr mac_addr;
8220 cmdline_fixed_string_t ethertype;
8221 uint16_t ethertype_value;
8222 cmdline_fixed_string_t drop;
8223 cmdline_fixed_string_t queue;
8227 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8228 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8229 filter, "ethertype_filter");
8230 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8231 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8233 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8234 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8236 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8237 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8238 mac, "mac_addr#mac_ignr");
8239 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8240 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8242 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8243 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8244 ethertype, "ethertype");
8245 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8246 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8247 ethertype_value, UINT16);
8248 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8249 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8251 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8252 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8254 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8255 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8259 cmd_ethertype_filter_parsed(void *parsed_result,
8260 __attribute__((unused)) struct cmdline *cl,
8261 __attribute__((unused)) void *data)
8263 struct cmd_ethertype_filter_result *res = parsed_result;
8264 struct rte_eth_ethertype_filter filter;
8267 ret = rte_eth_dev_filter_supported(res->port_id,
8268 RTE_ETH_FILTER_ETHERTYPE);
8270 printf("ethertype filter is not supported on port %u.\n",
8275 memset(&filter, 0, sizeof(filter));
8276 if (!strcmp(res->mac, "mac_addr")) {
8277 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8278 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8279 sizeof(struct ether_addr));
8281 if (!strcmp(res->drop, "drop"))
8282 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8283 filter.ether_type = res->ethertype_value;
8284 filter.queue = res->queue_id;
8286 if (!strcmp(res->ops, "add"))
8287 ret = rte_eth_dev_filter_ctrl(res->port_id,
8288 RTE_ETH_FILTER_ETHERTYPE,
8292 ret = rte_eth_dev_filter_ctrl(res->port_id,
8293 RTE_ETH_FILTER_ETHERTYPE,
8294 RTE_ETH_FILTER_DELETE,
8297 printf("ethertype filter programming error: (%s)\n",
8301 cmdline_parse_inst_t cmd_ethertype_filter = {
8302 .f = cmd_ethertype_filter_parsed,
8304 .help_str = "add or delete an ethertype filter entry",
8306 (void *)&cmd_ethertype_filter_filter,
8307 (void *)&cmd_ethertype_filter_port_id,
8308 (void *)&cmd_ethertype_filter_ops,
8309 (void *)&cmd_ethertype_filter_mac,
8310 (void *)&cmd_ethertype_filter_mac_addr,
8311 (void *)&cmd_ethertype_filter_ethertype,
8312 (void *)&cmd_ethertype_filter_ethertype_value,
8313 (void *)&cmd_ethertype_filter_drop,
8314 (void *)&cmd_ethertype_filter_queue,
8315 (void *)&cmd_ethertype_filter_queue_id,
8320 /* *** deal with flow director filter *** */
8321 struct cmd_flow_director_result {
8322 cmdline_fixed_string_t flow_director_filter;
8324 cmdline_fixed_string_t mode;
8325 cmdline_fixed_string_t mode_value;
8326 cmdline_fixed_string_t ops;
8327 cmdline_fixed_string_t flow;
8328 cmdline_fixed_string_t flow_type;
8329 cmdline_fixed_string_t ether;
8330 uint16_t ether_type;
8331 cmdline_fixed_string_t src;
8332 cmdline_ipaddr_t ip_src;
8334 cmdline_fixed_string_t dst;
8335 cmdline_ipaddr_t ip_dst;
8337 cmdline_fixed_string_t verify_tag;
8338 uint32_t verify_tag_value;
8339 cmdline_ipaddr_t tos;
8341 cmdline_ipaddr_t proto;
8342 uint8_t proto_value;
8343 cmdline_ipaddr_t ttl;
8345 cmdline_fixed_string_t vlan;
8346 uint16_t vlan_value;
8347 cmdline_fixed_string_t flexbytes;
8348 cmdline_fixed_string_t flexbytes_value;
8349 cmdline_fixed_string_t pf_vf;
8350 cmdline_fixed_string_t drop;
8351 cmdline_fixed_string_t queue;
8353 cmdline_fixed_string_t fd_id;
8354 uint32_t fd_id_value;
8355 cmdline_fixed_string_t mac;
8356 struct ether_addr mac_addr;
8357 cmdline_fixed_string_t tunnel;
8358 cmdline_fixed_string_t tunnel_type;
8359 cmdline_fixed_string_t tunnel_id;
8360 uint32_t tunnel_id_value;
8364 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8367 const char *p, *p0 = q_arg;
8369 unsigned long int_fld;
8370 char *str_fld[max_num];
8375 p = strchr(p0, '(');
8379 p0 = strchr(p, ')');
8384 if (size >= sizeof(s))
8387 snprintf(s, sizeof(s), "%.*s", size, p);
8388 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8389 if (ret < 0 || ret > max_num)
8391 for (i = 0; i < ret; i++) {
8393 int_fld = strtoul(str_fld[i], &end, 0);
8394 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8396 flexbytes[i] = (uint8_t)int_fld;
8402 str2flowtype(char *string)
8405 static const struct {
8408 } flowtype_str[] = {
8409 {"raw", RTE_ETH_FLOW_RAW},
8410 {"ipv4", RTE_ETH_FLOW_IPV4},
8411 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8412 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8413 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8414 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8415 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8416 {"ipv6", RTE_ETH_FLOW_IPV6},
8417 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8418 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8419 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8420 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8421 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8422 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8425 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8426 if (!strcmp(flowtype_str[i].str, string))
8427 return flowtype_str[i].type;
8429 return RTE_ETH_FLOW_UNKNOWN;
8432 static enum rte_eth_fdir_tunnel_type
8433 str2fdir_tunneltype(char *string)
8437 static const struct {
8439 enum rte_eth_fdir_tunnel_type type;
8440 } tunneltype_str[] = {
8441 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8442 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8445 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8446 if (!strcmp(tunneltype_str[i].str, string))
8447 return tunneltype_str[i].type;
8449 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8452 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8454 if ((ip_addr).family == AF_INET) \
8455 (ip) = (ip_addr).addr.ipv4.s_addr; \
8457 printf("invalid parameter.\n"); \
8462 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8464 if ((ip_addr).family == AF_INET6) \
8465 (void)rte_memcpy(&(ip), \
8466 &((ip_addr).addr.ipv6), \
8467 sizeof(struct in6_addr)); \
8469 printf("invalid parameter.\n"); \
8475 cmd_flow_director_filter_parsed(void *parsed_result,
8476 __attribute__((unused)) struct cmdline *cl,
8477 __attribute__((unused)) void *data)
8479 struct cmd_flow_director_result *res = parsed_result;
8480 struct rte_eth_fdir_filter entry;
8481 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8483 unsigned long vf_id;
8486 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8488 printf("flow director is not supported on port %u.\n",
8492 memset(flexbytes, 0, sizeof(flexbytes));
8493 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8495 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8496 if (strcmp(res->mode_value, "MAC-VLAN")) {
8497 printf("Please set mode to MAC-VLAN.\n");
8500 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8501 if (strcmp(res->mode_value, "Tunnel")) {
8502 printf("Please set mode to Tunnel.\n");
8506 if (strcmp(res->mode_value, "IP")) {
8507 printf("Please set mode to IP.\n");
8510 entry.input.flow_type = str2flowtype(res->flow_type);
8513 ret = parse_flexbytes(res->flexbytes_value,
8515 RTE_ETH_FDIR_MAX_FLEXLEN);
8517 printf("error: Cannot parse flexbytes input.\n");
8521 switch (entry.input.flow_type) {
8522 case RTE_ETH_FLOW_FRAG_IPV4:
8523 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8524 entry.input.flow.ip4_flow.proto = res->proto_value;
8525 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8526 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8527 IPV4_ADDR_TO_UINT(res->ip_dst,
8528 entry.input.flow.ip4_flow.dst_ip);
8529 IPV4_ADDR_TO_UINT(res->ip_src,
8530 entry.input.flow.ip4_flow.src_ip);
8531 entry.input.flow.ip4_flow.tos = res->tos_value;
8532 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8533 /* need convert to big endian. */
8534 entry.input.flow.udp4_flow.dst_port =
8535 rte_cpu_to_be_16(res->port_dst);
8536 entry.input.flow.udp4_flow.src_port =
8537 rte_cpu_to_be_16(res->port_src);
8539 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8540 IPV4_ADDR_TO_UINT(res->ip_dst,
8541 entry.input.flow.sctp4_flow.ip.dst_ip);
8542 IPV4_ADDR_TO_UINT(res->ip_src,
8543 entry.input.flow.sctp4_flow.ip.src_ip);
8544 entry.input.flow.ip4_flow.tos = res->tos_value;
8545 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8546 /* need convert to big endian. */
8547 entry.input.flow.sctp4_flow.dst_port =
8548 rte_cpu_to_be_16(res->port_dst);
8549 entry.input.flow.sctp4_flow.src_port =
8550 rte_cpu_to_be_16(res->port_src);
8551 entry.input.flow.sctp4_flow.verify_tag =
8552 rte_cpu_to_be_32(res->verify_tag_value);
8554 case RTE_ETH_FLOW_FRAG_IPV6:
8555 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8556 entry.input.flow.ipv6_flow.proto = res->proto_value;
8557 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8558 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8559 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8560 entry.input.flow.ipv6_flow.dst_ip);
8561 IPV6_ADDR_TO_ARRAY(res->ip_src,
8562 entry.input.flow.ipv6_flow.src_ip);
8563 entry.input.flow.ipv6_flow.tc = res->tos_value;
8564 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8565 /* need convert to big endian. */
8566 entry.input.flow.udp6_flow.dst_port =
8567 rte_cpu_to_be_16(res->port_dst);
8568 entry.input.flow.udp6_flow.src_port =
8569 rte_cpu_to_be_16(res->port_src);
8571 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8572 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8573 entry.input.flow.sctp6_flow.ip.dst_ip);
8574 IPV6_ADDR_TO_ARRAY(res->ip_src,
8575 entry.input.flow.sctp6_flow.ip.src_ip);
8576 entry.input.flow.ipv6_flow.tc = res->tos_value;
8577 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8578 /* need convert to big endian. */
8579 entry.input.flow.sctp6_flow.dst_port =
8580 rte_cpu_to_be_16(res->port_dst);
8581 entry.input.flow.sctp6_flow.src_port =
8582 rte_cpu_to_be_16(res->port_src);
8583 entry.input.flow.sctp6_flow.verify_tag =
8584 rte_cpu_to_be_32(res->verify_tag_value);
8586 case RTE_ETH_FLOW_L2_PAYLOAD:
8587 entry.input.flow.l2_flow.ether_type =
8588 rte_cpu_to_be_16(res->ether_type);
8594 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8595 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8597 sizeof(struct ether_addr));
8599 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8600 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8602 sizeof(struct ether_addr));
8603 entry.input.flow.tunnel_flow.tunnel_type =
8604 str2fdir_tunneltype(res->tunnel_type);
8605 entry.input.flow.tunnel_flow.tunnel_id =
8606 rte_cpu_to_be_32(res->tunnel_id_value);
8609 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8611 RTE_ETH_FDIR_MAX_FLEXLEN);
8613 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8615 entry.action.flex_off = 0; /*use 0 by default */
8616 if (!strcmp(res->drop, "drop"))
8617 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8619 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8621 if (!strcmp(res->pf_vf, "pf"))
8622 entry.input.flow_ext.is_vf = 0;
8623 else if (!strncmp(res->pf_vf, "vf", 2)) {
8624 struct rte_eth_dev_info dev_info;
8626 memset(&dev_info, 0, sizeof(dev_info));
8627 rte_eth_dev_info_get(res->port_id, &dev_info);
8629 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8630 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8631 printf("invalid parameter %s.\n", res->pf_vf);
8634 entry.input.flow_ext.is_vf = 1;
8635 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8637 printf("invalid parameter %s.\n", res->pf_vf);
8641 /* set to report FD ID by default */
8642 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8643 entry.action.rx_queue = res->queue_id;
8644 entry.soft_id = res->fd_id_value;
8645 if (!strcmp(res->ops, "add"))
8646 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8647 RTE_ETH_FILTER_ADD, &entry);
8648 else if (!strcmp(res->ops, "del"))
8649 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8650 RTE_ETH_FILTER_DELETE, &entry);
8652 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8653 RTE_ETH_FILTER_UPDATE, &entry);
8655 printf("flow director programming error: (%s)\n",
8659 cmdline_parse_token_string_t cmd_flow_director_filter =
8660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8661 flow_director_filter, "flow_director_filter");
8662 cmdline_parse_token_num_t cmd_flow_director_port_id =
8663 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8665 cmdline_parse_token_string_t cmd_flow_director_ops =
8666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8667 ops, "add#del#update");
8668 cmdline_parse_token_string_t cmd_flow_director_flow =
8669 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8671 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8673 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8674 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8675 cmdline_parse_token_string_t cmd_flow_director_ether =
8676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8678 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8679 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8680 ether_type, UINT16);
8681 cmdline_parse_token_string_t cmd_flow_director_src =
8682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8684 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8685 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8687 cmdline_parse_token_num_t cmd_flow_director_port_src =
8688 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8690 cmdline_parse_token_string_t cmd_flow_director_dst =
8691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8693 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8694 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8696 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8697 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8699 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8701 verify_tag, "verify_tag");
8702 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8703 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8704 verify_tag_value, UINT32);
8705 cmdline_parse_token_string_t cmd_flow_director_tos =
8706 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8708 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8709 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8711 cmdline_parse_token_string_t cmd_flow_director_proto =
8712 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8714 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8715 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8716 proto_value, UINT8);
8717 cmdline_parse_token_string_t cmd_flow_director_ttl =
8718 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8720 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8721 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8723 cmdline_parse_token_string_t cmd_flow_director_vlan =
8724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8726 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8727 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8728 vlan_value, UINT16);
8729 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8730 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8731 flexbytes, "flexbytes");
8732 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8734 flexbytes_value, NULL);
8735 cmdline_parse_token_string_t cmd_flow_director_drop =
8736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8738 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8739 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8741 cmdline_parse_token_string_t cmd_flow_director_queue =
8742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8744 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8745 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8747 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8750 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8751 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8752 fd_id_value, UINT32);
8754 cmdline_parse_token_string_t cmd_flow_director_mode =
8755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8757 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8758 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8760 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8762 mode_value, "MAC-VLAN");
8763 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8764 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8765 mode_value, "Tunnel");
8766 cmdline_parse_token_string_t cmd_flow_director_mac =
8767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8769 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8770 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8772 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8775 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8777 tunnel_type, "NVGRE#VxLAN");
8778 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8780 tunnel_id, "tunnel-id");
8781 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8782 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8783 tunnel_id_value, UINT32);
8785 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8786 .f = cmd_flow_director_filter_parsed,
8788 .help_str = "add or delete an ip flow director entry on NIC",
8790 (void *)&cmd_flow_director_filter,
8791 (void *)&cmd_flow_director_port_id,
8792 (void *)&cmd_flow_director_mode,
8793 (void *)&cmd_flow_director_mode_ip,
8794 (void *)&cmd_flow_director_ops,
8795 (void *)&cmd_flow_director_flow,
8796 (void *)&cmd_flow_director_flow_type,
8797 (void *)&cmd_flow_director_src,
8798 (void *)&cmd_flow_director_ip_src,
8799 (void *)&cmd_flow_director_dst,
8800 (void *)&cmd_flow_director_ip_dst,
8801 (void *)&cmd_flow_director_tos,
8802 (void *)&cmd_flow_director_tos_value,
8803 (void *)&cmd_flow_director_proto,
8804 (void *)&cmd_flow_director_proto_value,
8805 (void *)&cmd_flow_director_ttl,
8806 (void *)&cmd_flow_director_ttl_value,
8807 (void *)&cmd_flow_director_vlan,
8808 (void *)&cmd_flow_director_vlan_value,
8809 (void *)&cmd_flow_director_flexbytes,
8810 (void *)&cmd_flow_director_flexbytes_value,
8811 (void *)&cmd_flow_director_drop,
8812 (void *)&cmd_flow_director_pf_vf,
8813 (void *)&cmd_flow_director_queue,
8814 (void *)&cmd_flow_director_queue_id,
8815 (void *)&cmd_flow_director_fd_id,
8816 (void *)&cmd_flow_director_fd_id_value,
8821 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8822 .f = cmd_flow_director_filter_parsed,
8824 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8826 (void *)&cmd_flow_director_filter,
8827 (void *)&cmd_flow_director_port_id,
8828 (void *)&cmd_flow_director_mode,
8829 (void *)&cmd_flow_director_mode_ip,
8830 (void *)&cmd_flow_director_ops,
8831 (void *)&cmd_flow_director_flow,
8832 (void *)&cmd_flow_director_flow_type,
8833 (void *)&cmd_flow_director_src,
8834 (void *)&cmd_flow_director_ip_src,
8835 (void *)&cmd_flow_director_port_src,
8836 (void *)&cmd_flow_director_dst,
8837 (void *)&cmd_flow_director_ip_dst,
8838 (void *)&cmd_flow_director_port_dst,
8839 (void *)&cmd_flow_director_tos,
8840 (void *)&cmd_flow_director_tos_value,
8841 (void *)&cmd_flow_director_ttl,
8842 (void *)&cmd_flow_director_ttl_value,
8843 (void *)&cmd_flow_director_vlan,
8844 (void *)&cmd_flow_director_vlan_value,
8845 (void *)&cmd_flow_director_flexbytes,
8846 (void *)&cmd_flow_director_flexbytes_value,
8847 (void *)&cmd_flow_director_drop,
8848 (void *)&cmd_flow_director_pf_vf,
8849 (void *)&cmd_flow_director_queue,
8850 (void *)&cmd_flow_director_queue_id,
8851 (void *)&cmd_flow_director_fd_id,
8852 (void *)&cmd_flow_director_fd_id_value,
8857 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8858 .f = cmd_flow_director_filter_parsed,
8860 .help_str = "add or delete a sctp flow director entry on NIC",
8862 (void *)&cmd_flow_director_filter,
8863 (void *)&cmd_flow_director_port_id,
8864 (void *)&cmd_flow_director_mode,
8865 (void *)&cmd_flow_director_mode_ip,
8866 (void *)&cmd_flow_director_ops,
8867 (void *)&cmd_flow_director_flow,
8868 (void *)&cmd_flow_director_flow_type,
8869 (void *)&cmd_flow_director_src,
8870 (void *)&cmd_flow_director_ip_src,
8871 (void *)&cmd_flow_director_port_dst,
8872 (void *)&cmd_flow_director_dst,
8873 (void *)&cmd_flow_director_ip_dst,
8874 (void *)&cmd_flow_director_port_dst,
8875 (void *)&cmd_flow_director_verify_tag,
8876 (void *)&cmd_flow_director_verify_tag_value,
8877 (void *)&cmd_flow_director_tos,
8878 (void *)&cmd_flow_director_tos_value,
8879 (void *)&cmd_flow_director_ttl,
8880 (void *)&cmd_flow_director_ttl_value,
8881 (void *)&cmd_flow_director_vlan,
8882 (void *)&cmd_flow_director_vlan_value,
8883 (void *)&cmd_flow_director_flexbytes,
8884 (void *)&cmd_flow_director_flexbytes_value,
8885 (void *)&cmd_flow_director_drop,
8886 (void *)&cmd_flow_director_pf_vf,
8887 (void *)&cmd_flow_director_queue,
8888 (void *)&cmd_flow_director_queue_id,
8889 (void *)&cmd_flow_director_fd_id,
8890 (void *)&cmd_flow_director_fd_id_value,
8895 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8896 .f = cmd_flow_director_filter_parsed,
8898 .help_str = "add or delete a L2 flow director entry on NIC",
8900 (void *)&cmd_flow_director_filter,
8901 (void *)&cmd_flow_director_port_id,
8902 (void *)&cmd_flow_director_mode,
8903 (void *)&cmd_flow_director_mode_ip,
8904 (void *)&cmd_flow_director_ops,
8905 (void *)&cmd_flow_director_flow,
8906 (void *)&cmd_flow_director_flow_type,
8907 (void *)&cmd_flow_director_ether,
8908 (void *)&cmd_flow_director_ether_type,
8909 (void *)&cmd_flow_director_flexbytes,
8910 (void *)&cmd_flow_director_flexbytes_value,
8911 (void *)&cmd_flow_director_drop,
8912 (void *)&cmd_flow_director_pf_vf,
8913 (void *)&cmd_flow_director_queue,
8914 (void *)&cmd_flow_director_queue_id,
8915 (void *)&cmd_flow_director_fd_id,
8916 (void *)&cmd_flow_director_fd_id_value,
8921 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8922 .f = cmd_flow_director_filter_parsed,
8924 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8926 (void *)&cmd_flow_director_filter,
8927 (void *)&cmd_flow_director_port_id,
8928 (void *)&cmd_flow_director_mode,
8929 (void *)&cmd_flow_director_mode_mac_vlan,
8930 (void *)&cmd_flow_director_ops,
8931 (void *)&cmd_flow_director_mac,
8932 (void *)&cmd_flow_director_mac_addr,
8933 (void *)&cmd_flow_director_vlan,
8934 (void *)&cmd_flow_director_vlan_value,
8935 (void *)&cmd_flow_director_flexbytes,
8936 (void *)&cmd_flow_director_flexbytes_value,
8937 (void *)&cmd_flow_director_drop,
8938 (void *)&cmd_flow_director_queue,
8939 (void *)&cmd_flow_director_queue_id,
8940 (void *)&cmd_flow_director_fd_id,
8941 (void *)&cmd_flow_director_fd_id_value,
8946 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8947 .f = cmd_flow_director_filter_parsed,
8949 .help_str = "add or delete a tunnel flow director entry on NIC",
8951 (void *)&cmd_flow_director_filter,
8952 (void *)&cmd_flow_director_port_id,
8953 (void *)&cmd_flow_director_mode,
8954 (void *)&cmd_flow_director_mode_tunnel,
8955 (void *)&cmd_flow_director_ops,
8956 (void *)&cmd_flow_director_mac,
8957 (void *)&cmd_flow_director_mac_addr,
8958 (void *)&cmd_flow_director_vlan,
8959 (void *)&cmd_flow_director_vlan_value,
8960 (void *)&cmd_flow_director_tunnel,
8961 (void *)&cmd_flow_director_tunnel_type,
8962 (void *)&cmd_flow_director_tunnel_id,
8963 (void *)&cmd_flow_director_tunnel_id_value,
8964 (void *)&cmd_flow_director_flexbytes,
8965 (void *)&cmd_flow_director_flexbytes_value,
8966 (void *)&cmd_flow_director_drop,
8967 (void *)&cmd_flow_director_queue,
8968 (void *)&cmd_flow_director_queue_id,
8969 (void *)&cmd_flow_director_fd_id,
8970 (void *)&cmd_flow_director_fd_id_value,
8975 struct cmd_flush_flow_director_result {
8976 cmdline_fixed_string_t flush_flow_director;
8980 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8981 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8982 flush_flow_director, "flush_flow_director");
8983 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8984 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8988 cmd_flush_flow_director_parsed(void *parsed_result,
8989 __attribute__((unused)) struct cmdline *cl,
8990 __attribute__((unused)) void *data)
8992 struct cmd_flow_director_result *res = parsed_result;
8995 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8997 printf("flow director is not supported on port %u.\n",
9002 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9003 RTE_ETH_FILTER_FLUSH, NULL);
9005 printf("flow director table flushing error: (%s)\n",
9009 cmdline_parse_inst_t cmd_flush_flow_director = {
9010 .f = cmd_flush_flow_director_parsed,
9012 .help_str = "flush all flow director entries of a device on NIC",
9014 (void *)&cmd_flush_flow_director_flush,
9015 (void *)&cmd_flush_flow_director_port_id,
9020 /* *** deal with flow director mask *** */
9021 struct cmd_flow_director_mask_result {
9022 cmdline_fixed_string_t flow_director_mask;
9024 cmdline_fixed_string_t mode;
9025 cmdline_fixed_string_t mode_value;
9026 cmdline_fixed_string_t vlan;
9028 cmdline_fixed_string_t src_mask;
9029 cmdline_ipaddr_t ipv4_src;
9030 cmdline_ipaddr_t ipv6_src;
9032 cmdline_fixed_string_t dst_mask;
9033 cmdline_ipaddr_t ipv4_dst;
9034 cmdline_ipaddr_t ipv6_dst;
9036 cmdline_fixed_string_t mac;
9037 uint8_t mac_addr_byte_mask;
9038 cmdline_fixed_string_t tunnel_id;
9039 uint32_t tunnel_id_mask;
9040 cmdline_fixed_string_t tunnel_type;
9041 uint8_t tunnel_type_mask;
9045 cmd_flow_director_mask_parsed(void *parsed_result,
9046 __attribute__((unused)) struct cmdline *cl,
9047 __attribute__((unused)) void *data)
9049 struct cmd_flow_director_mask_result *res = parsed_result;
9050 struct rte_eth_fdir_masks *mask;
9051 struct rte_port *port;
9053 if (res->port_id > nb_ports) {
9054 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9058 port = &ports[res->port_id];
9059 /** Check if the port is not started **/
9060 if (port->port_status != RTE_PORT_STOPPED) {
9061 printf("Please stop port %d first\n", res->port_id);
9065 mask = &port->dev_conf.fdir_conf.mask;
9067 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9068 if (strcmp(res->mode_value, "MAC-VLAN")) {
9069 printf("Please set mode to MAC-VLAN.\n");
9073 mask->vlan_tci_mask = res->vlan_mask;
9074 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9075 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9076 if (strcmp(res->mode_value, "Tunnel")) {
9077 printf("Please set mode to Tunnel.\n");
9081 mask->vlan_tci_mask = res->vlan_mask;
9082 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9083 mask->tunnel_id_mask = res->tunnel_id_mask;
9084 mask->tunnel_type_mask = res->tunnel_type_mask;
9086 if (strcmp(res->mode_value, "IP")) {
9087 printf("Please set mode to IP.\n");
9091 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9092 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9093 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9094 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9095 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9096 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9097 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9100 cmd_reconfig_device_queue(res->port_id, 1, 1);
9103 cmdline_parse_token_string_t cmd_flow_director_mask =
9104 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9105 flow_director_mask, "flow_director_mask");
9106 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9107 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9109 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9110 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9112 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9113 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9115 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9116 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9117 src_mask, "src_mask");
9118 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9119 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9121 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9122 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9124 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9125 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9127 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9128 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9129 dst_mask, "dst_mask");
9130 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9131 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9133 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9134 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9136 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9137 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9140 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9143 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9144 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9146 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9147 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9148 mode_value, "MAC-VLAN");
9149 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9150 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9151 mode_value, "Tunnel");
9152 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9153 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9155 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9156 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9157 mac_addr_byte_mask, UINT8);
9158 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9159 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9160 tunnel_type, "tunnel-type");
9161 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9162 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9163 tunnel_type_mask, UINT8);
9164 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9166 tunnel_id, "tunnel-id");
9167 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9168 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9169 tunnel_id_mask, UINT32);
9171 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9172 .f = cmd_flow_director_mask_parsed,
9174 .help_str = "set IP mode flow director's mask on NIC",
9176 (void *)&cmd_flow_director_mask,
9177 (void *)&cmd_flow_director_mask_port_id,
9178 (void *)&cmd_flow_director_mask_mode,
9179 (void *)&cmd_flow_director_mask_mode_ip,
9180 (void *)&cmd_flow_director_mask_vlan,
9181 (void *)&cmd_flow_director_mask_vlan_value,
9182 (void *)&cmd_flow_director_mask_src,
9183 (void *)&cmd_flow_director_mask_ipv4_src,
9184 (void *)&cmd_flow_director_mask_ipv6_src,
9185 (void *)&cmd_flow_director_mask_port_src,
9186 (void *)&cmd_flow_director_mask_dst,
9187 (void *)&cmd_flow_director_mask_ipv4_dst,
9188 (void *)&cmd_flow_director_mask_ipv6_dst,
9189 (void *)&cmd_flow_director_mask_port_dst,
9194 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9195 .f = cmd_flow_director_mask_parsed,
9197 .help_str = "set MAC VLAN mode flow director's mask on NIC",
9199 (void *)&cmd_flow_director_mask,
9200 (void *)&cmd_flow_director_mask_port_id,
9201 (void *)&cmd_flow_director_mask_mode,
9202 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9203 (void *)&cmd_flow_director_mask_vlan,
9204 (void *)&cmd_flow_director_mask_vlan_value,
9205 (void *)&cmd_flow_director_mask_mac,
9206 (void *)&cmd_flow_director_mask_mac_value,
9211 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9212 .f = cmd_flow_director_mask_parsed,
9214 .help_str = "set tunnel mode flow director's mask on NIC",
9216 (void *)&cmd_flow_director_mask,
9217 (void *)&cmd_flow_director_mask_port_id,
9218 (void *)&cmd_flow_director_mask_mode,
9219 (void *)&cmd_flow_director_mask_mode_tunnel,
9220 (void *)&cmd_flow_director_mask_vlan,
9221 (void *)&cmd_flow_director_mask_vlan_value,
9222 (void *)&cmd_flow_director_mask_mac,
9223 (void *)&cmd_flow_director_mask_mac_value,
9224 (void *)&cmd_flow_director_mask_tunnel_type,
9225 (void *)&cmd_flow_director_mask_tunnel_type_value,
9226 (void *)&cmd_flow_director_mask_tunnel_id,
9227 (void *)&cmd_flow_director_mask_tunnel_id_value,
9232 /* *** deal with flow director mask on flexible payload *** */
9233 struct cmd_flow_director_flex_mask_result {
9234 cmdline_fixed_string_t flow_director_flexmask;
9236 cmdline_fixed_string_t flow;
9237 cmdline_fixed_string_t flow_type;
9238 cmdline_fixed_string_t mask;
9242 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9243 __attribute__((unused)) struct cmdline *cl,
9244 __attribute__((unused)) void *data)
9246 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9247 struct rte_eth_fdir_info fdir_info;
9248 struct rte_eth_fdir_flex_mask flex_mask;
9249 struct rte_port *port;
9250 uint32_t flow_type_mask;
9254 if (res->port_id > nb_ports) {
9255 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9259 port = &ports[res->port_id];
9260 /** Check if the port is not started **/
9261 if (port->port_status != RTE_PORT_STOPPED) {
9262 printf("Please stop port %d first\n", res->port_id);
9266 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9267 ret = parse_flexbytes(res->mask,
9269 RTE_ETH_FDIR_MAX_FLEXLEN);
9271 printf("error: Cannot parse mask input.\n");
9275 memset(&fdir_info, 0, sizeof(fdir_info));
9276 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9277 RTE_ETH_FILTER_INFO, &fdir_info);
9279 printf("Cannot get FDir filter info\n");
9283 if (!strcmp(res->flow_type, "none")) {
9284 /* means don't specify the flow type */
9285 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9286 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9287 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9288 0, sizeof(struct rte_eth_fdir_flex_mask));
9289 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9290 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9292 sizeof(struct rte_eth_fdir_flex_mask));
9293 cmd_reconfig_device_queue(res->port_id, 1, 1);
9296 flow_type_mask = fdir_info.flow_types_mask[0];
9297 if (!strcmp(res->flow_type, "all")) {
9298 if (!flow_type_mask) {
9299 printf("No flow type supported\n");
9302 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9303 if (flow_type_mask & (1 << i)) {
9304 flex_mask.flow_type = i;
9305 fdir_set_flex_mask(res->port_id, &flex_mask);
9308 cmd_reconfig_device_queue(res->port_id, 1, 1);
9311 flex_mask.flow_type = str2flowtype(res->flow_type);
9312 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9313 printf("Flow type %s not supported on port %d\n",
9314 res->flow_type, res->port_id);
9317 fdir_set_flex_mask(res->port_id, &flex_mask);
9318 cmd_reconfig_device_queue(res->port_id, 1, 1);
9321 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9323 flow_director_flexmask,
9324 "flow_director_flex_mask");
9325 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9326 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9328 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9331 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9333 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9334 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9335 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9339 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9340 .f = cmd_flow_director_flex_mask_parsed,
9342 .help_str = "set flow director's flex mask on NIC",
9344 (void *)&cmd_flow_director_flexmask,
9345 (void *)&cmd_flow_director_flexmask_port_id,
9346 (void *)&cmd_flow_director_flexmask_flow,
9347 (void *)&cmd_flow_director_flexmask_flow_type,
9348 (void *)&cmd_flow_director_flexmask_mask,
9353 /* *** deal with flow director flexible payload configuration *** */
9354 struct cmd_flow_director_flexpayload_result {
9355 cmdline_fixed_string_t flow_director_flexpayload;
9357 cmdline_fixed_string_t payload_layer;
9358 cmdline_fixed_string_t payload_cfg;
9362 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9365 const char *p, *p0 = q_arg;
9367 unsigned long int_fld;
9368 char *str_fld[max_num];
9373 p = strchr(p0, '(');
9377 p0 = strchr(p, ')');
9382 if (size >= sizeof(s))
9385 snprintf(s, sizeof(s), "%.*s", size, p);
9386 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9387 if (ret < 0 || ret > max_num)
9389 for (i = 0; i < ret; i++) {
9391 int_fld = strtoul(str_fld[i], &end, 0);
9392 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9394 offsets[i] = (uint16_t)int_fld;
9400 cmd_flow_director_flxpld_parsed(void *parsed_result,
9401 __attribute__((unused)) struct cmdline *cl,
9402 __attribute__((unused)) void *data)
9404 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9405 struct rte_eth_flex_payload_cfg flex_cfg;
9406 struct rte_port *port;
9409 if (res->port_id > nb_ports) {
9410 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9414 port = &ports[res->port_id];
9415 /** Check if the port is not started **/
9416 if (port->port_status != RTE_PORT_STOPPED) {
9417 printf("Please stop port %d first\n", res->port_id);
9421 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9423 if (!strcmp(res->payload_layer, "raw"))
9424 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9425 else if (!strcmp(res->payload_layer, "l2"))
9426 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9427 else if (!strcmp(res->payload_layer, "l3"))
9428 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9429 else if (!strcmp(res->payload_layer, "l4"))
9430 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9432 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9433 RTE_ETH_FDIR_MAX_FLEXLEN);
9435 printf("error: Cannot parse flex payload input.\n");
9439 fdir_set_flex_payload(res->port_id, &flex_cfg);
9440 cmd_reconfig_device_queue(res->port_id, 1, 1);
9443 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9444 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9445 flow_director_flexpayload,
9446 "flow_director_flex_payload");
9447 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9448 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9450 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9452 payload_layer, "raw#l2#l3#l4");
9453 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9457 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9458 .f = cmd_flow_director_flxpld_parsed,
9460 .help_str = "set flow director's flex payload on NIC",
9462 (void *)&cmd_flow_director_flexpayload,
9463 (void *)&cmd_flow_director_flexpayload_port_id,
9464 (void *)&cmd_flow_director_flexpayload_payload_layer,
9465 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9470 /* *** Classification Filters Control *** */
9471 /* *** Get symmetric hash enable per port *** */
9472 struct cmd_get_sym_hash_ena_per_port_result {
9473 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9478 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9479 __rte_unused struct cmdline *cl,
9480 __rte_unused void *data)
9482 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9483 struct rte_eth_hash_filter_info info;
9486 if (rte_eth_dev_filter_supported(res->port_id,
9487 RTE_ETH_FILTER_HASH) < 0) {
9488 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9493 memset(&info, 0, sizeof(info));
9494 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9495 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9496 RTE_ETH_FILTER_GET, &info);
9499 printf("Cannot get symmetric hash enable per port "
9500 "on port %u\n", res->port_id);
9504 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9505 "enabled" : "disabled", res->port_id);
9508 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9509 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9510 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9511 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9512 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9515 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9516 .f = cmd_get_sym_hash_per_port_parsed,
9518 .help_str = "get_sym_hash_ena_per_port port_id",
9520 (void *)&cmd_get_sym_hash_ena_per_port_all,
9521 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9526 /* *** Set symmetric hash enable per port *** */
9527 struct cmd_set_sym_hash_ena_per_port_result {
9528 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9529 cmdline_fixed_string_t enable;
9534 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9535 __rte_unused struct cmdline *cl,
9536 __rte_unused void *data)
9538 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9539 struct rte_eth_hash_filter_info info;
9542 if (rte_eth_dev_filter_supported(res->port_id,
9543 RTE_ETH_FILTER_HASH) < 0) {
9544 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9549 memset(&info, 0, sizeof(info));
9550 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9551 if (!strcmp(res->enable, "enable"))
9552 info.info.enable = 1;
9553 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9554 RTE_ETH_FILTER_SET, &info);
9556 printf("Cannot set symmetric hash enable per port on "
9557 "port %u\n", res->port_id);
9560 printf("Symmetric hash has been set to %s on port %u\n",
9561 res->enable, res->port_id);
9564 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9565 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9566 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9567 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9568 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9570 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9571 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9572 enable, "enable#disable");
9574 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9575 .f = cmd_set_sym_hash_per_port_parsed,
9577 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9579 (void *)&cmd_set_sym_hash_ena_per_port_all,
9580 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9581 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9586 /* Get global config of hash function */
9587 struct cmd_get_hash_global_config_result {
9588 cmdline_fixed_string_t get_hash_global_config;
9593 flowtype_to_str(uint16_t ftype)
9600 {"ipv4", RTE_ETH_FLOW_IPV4},
9601 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9602 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9603 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9604 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9605 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9606 {"ipv6", RTE_ETH_FLOW_IPV6},
9607 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9608 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9609 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9610 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9611 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9612 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9613 {"port", RTE_ETH_FLOW_PORT},
9614 {"vxlan", RTE_ETH_FLOW_VXLAN},
9615 {"geneve", RTE_ETH_FLOW_GENEVE},
9616 {"nvgre", RTE_ETH_FLOW_NVGRE},
9619 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9620 if (ftype_table[i].ftype == ftype)
9621 return ftype_table[i].str;
9628 cmd_get_hash_global_config_parsed(void *parsed_result,
9629 __rte_unused struct cmdline *cl,
9630 __rte_unused void *data)
9632 struct cmd_get_hash_global_config_result *res = parsed_result;
9633 struct rte_eth_hash_filter_info info;
9634 uint32_t idx, offset;
9639 if (rte_eth_dev_filter_supported(res->port_id,
9640 RTE_ETH_FILTER_HASH) < 0) {
9641 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9646 memset(&info, 0, sizeof(info));
9647 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9648 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9649 RTE_ETH_FILTER_GET, &info);
9651 printf("Cannot get hash global configurations by port %d\n",
9656 switch (info.info.global_conf.hash_func) {
9657 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9658 printf("Hash function is Toeplitz\n");
9660 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9661 printf("Hash function is Simple XOR\n");
9664 printf("Unknown hash function\n");
9668 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9669 idx = i / UINT32_BIT;
9670 offset = i % UINT32_BIT;
9671 if (!(info.info.global_conf.valid_bit_mask[idx] &
9674 str = flowtype_to_str(i);
9677 printf("Symmetric hash is %s globally for flow type %s "
9679 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9680 (1UL << offset)) ? "enabled" : "disabled"), str,
9685 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9686 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9687 get_hash_global_config, "get_hash_global_config");
9688 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9689 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9692 cmdline_parse_inst_t cmd_get_hash_global_config = {
9693 .f = cmd_get_hash_global_config_parsed,
9695 .help_str = "get_hash_global_config port_id",
9697 (void *)&cmd_get_hash_global_config_all,
9698 (void *)&cmd_get_hash_global_config_port_id,
9703 /* Set global config of hash function */
9704 struct cmd_set_hash_global_config_result {
9705 cmdline_fixed_string_t set_hash_global_config;
9707 cmdline_fixed_string_t hash_func;
9708 cmdline_fixed_string_t flow_type;
9709 cmdline_fixed_string_t enable;
9713 cmd_set_hash_global_config_parsed(void *parsed_result,
9714 __rte_unused struct cmdline *cl,
9715 __rte_unused void *data)
9717 struct cmd_set_hash_global_config_result *res = parsed_result;
9718 struct rte_eth_hash_filter_info info;
9719 uint32_t ftype, idx, offset;
9722 if (rte_eth_dev_filter_supported(res->port_id,
9723 RTE_ETH_FILTER_HASH) < 0) {
9724 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9728 memset(&info, 0, sizeof(info));
9729 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9730 if (!strcmp(res->hash_func, "toeplitz"))
9731 info.info.global_conf.hash_func =
9732 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9733 else if (!strcmp(res->hash_func, "simple_xor"))
9734 info.info.global_conf.hash_func =
9735 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9736 else if (!strcmp(res->hash_func, "default"))
9737 info.info.global_conf.hash_func =
9738 RTE_ETH_HASH_FUNCTION_DEFAULT;
9740 ftype = str2flowtype(res->flow_type);
9741 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9742 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9743 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9744 if (!strcmp(res->enable, "enable"))
9745 info.info.global_conf.sym_hash_enable_mask[idx] |=
9747 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9748 RTE_ETH_FILTER_SET, &info);
9750 printf("Cannot set global hash configurations by port %d\n",
9753 printf("Global hash configurations have been set "
9754 "succcessfully by port %d\n", res->port_id);
9757 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9758 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9759 set_hash_global_config, "set_hash_global_config");
9760 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9761 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9763 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9764 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9765 hash_func, "toeplitz#simple_xor#default");
9766 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9767 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9769 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9770 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9771 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9772 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9773 enable, "enable#disable");
9775 cmdline_parse_inst_t cmd_set_hash_global_config = {
9776 .f = cmd_set_hash_global_config_parsed,
9778 .help_str = "set_hash_global_config port_id "
9779 "toeplitz|simple_xor|default "
9780 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9781 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9784 (void *)&cmd_set_hash_global_config_all,
9785 (void *)&cmd_set_hash_global_config_port_id,
9786 (void *)&cmd_set_hash_global_config_hash_func,
9787 (void *)&cmd_set_hash_global_config_flow_type,
9788 (void *)&cmd_set_hash_global_config_enable,
9793 /* Set hash input set */
9794 struct cmd_set_hash_input_set_result {
9795 cmdline_fixed_string_t set_hash_input_set;
9797 cmdline_fixed_string_t flow_type;
9798 cmdline_fixed_string_t inset_field;
9799 cmdline_fixed_string_t select;
9802 static enum rte_eth_input_set_field
9803 str2inset(char *string)
9807 static const struct {
9809 enum rte_eth_input_set_field inset;
9811 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9812 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9813 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9814 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9815 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9816 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9817 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9818 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9819 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9820 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9821 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9822 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9823 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9824 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9825 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9826 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9827 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9828 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9829 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9830 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9831 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9832 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9833 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9834 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9835 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9836 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9837 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9838 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9839 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9840 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9841 {"none", RTE_ETH_INPUT_SET_NONE},
9844 for (i = 0; i < RTE_DIM(inset_table); i++) {
9845 if (!strcmp(string, inset_table[i].str))
9846 return inset_table[i].inset;
9849 return RTE_ETH_INPUT_SET_UNKNOWN;
9853 cmd_set_hash_input_set_parsed(void *parsed_result,
9854 __rte_unused struct cmdline *cl,
9855 __rte_unused void *data)
9857 struct cmd_set_hash_input_set_result *res = parsed_result;
9858 struct rte_eth_hash_filter_info info;
9860 memset(&info, 0, sizeof(info));
9861 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9862 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9863 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9864 info.info.input_set_conf.inset_size = 1;
9865 if (!strcmp(res->select, "select"))
9866 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9867 else if (!strcmp(res->select, "add"))
9868 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9869 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9870 RTE_ETH_FILTER_SET, &info);
9873 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9874 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9875 set_hash_input_set, "set_hash_input_set");
9876 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9877 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9879 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9880 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9882 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9883 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9884 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9885 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9887 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9888 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9889 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9890 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9891 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9893 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9894 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9895 select, "select#add");
9897 cmdline_parse_inst_t cmd_set_hash_input_set = {
9898 .f = cmd_set_hash_input_set_parsed,
9900 .help_str = "set_hash_input_set <port_id> "
9901 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9902 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9903 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9904 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9905 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9906 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9907 "fld-7th|fld-8th|none select|add",
9909 (void *)&cmd_set_hash_input_set_cmd,
9910 (void *)&cmd_set_hash_input_set_port_id,
9911 (void *)&cmd_set_hash_input_set_flow_type,
9912 (void *)&cmd_set_hash_input_set_field,
9913 (void *)&cmd_set_hash_input_set_select,
9918 /* Set flow director input set */
9919 struct cmd_set_fdir_input_set_result {
9920 cmdline_fixed_string_t set_fdir_input_set;
9922 cmdline_fixed_string_t flow_type;
9923 cmdline_fixed_string_t inset_field;
9924 cmdline_fixed_string_t select;
9928 cmd_set_fdir_input_set_parsed(void *parsed_result,
9929 __rte_unused struct cmdline *cl,
9930 __rte_unused void *data)
9932 struct cmd_set_fdir_input_set_result *res = parsed_result;
9933 struct rte_eth_fdir_filter_info info;
9935 memset(&info, 0, sizeof(info));
9936 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9937 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9938 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9939 info.info.input_set_conf.inset_size = 1;
9940 if (!strcmp(res->select, "select"))
9941 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9942 else if (!strcmp(res->select, "add"))
9943 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9944 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9945 RTE_ETH_FILTER_SET, &info);
9948 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9949 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9950 set_fdir_input_set, "set_fdir_input_set");
9951 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9952 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9954 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9955 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9957 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9958 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9959 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9960 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9962 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9963 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9964 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9965 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9966 "sctp-veri-tag#none");
9967 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9968 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9969 select, "select#add");
9971 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9972 .f = cmd_set_fdir_input_set_parsed,
9974 .help_str = "set_fdir_input_set <port_id> "
9975 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9976 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9977 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
9978 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
9979 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
9980 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
9981 "sctp-veri-tag|none select|add",
9983 (void *)&cmd_set_fdir_input_set_cmd,
9984 (void *)&cmd_set_fdir_input_set_port_id,
9985 (void *)&cmd_set_fdir_input_set_flow_type,
9986 (void *)&cmd_set_fdir_input_set_field,
9987 (void *)&cmd_set_fdir_input_set_select,
9992 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9993 struct cmd_mcast_addr_result {
9994 cmdline_fixed_string_t mcast_addr_cmd;
9995 cmdline_fixed_string_t what;
9997 struct ether_addr mc_addr;
10000 static void cmd_mcast_addr_parsed(void *parsed_result,
10001 __attribute__((unused)) struct cmdline *cl,
10002 __attribute__((unused)) void *data)
10004 struct cmd_mcast_addr_result *res = parsed_result;
10006 if (!is_multicast_ether_addr(&res->mc_addr)) {
10007 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10008 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10009 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10010 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10013 if (strcmp(res->what, "add") == 0)
10014 mcast_addr_add(res->port_num, &res->mc_addr);
10016 mcast_addr_remove(res->port_num, &res->mc_addr);
10019 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10020 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10021 mcast_addr_cmd, "mcast_addr");
10022 cmdline_parse_token_string_t cmd_mcast_addr_what =
10023 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10025 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10026 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10027 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10028 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10030 cmdline_parse_inst_t cmd_mcast_addr = {
10031 .f = cmd_mcast_addr_parsed,
10033 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
10035 (void *)&cmd_mcast_addr_cmd,
10036 (void *)&cmd_mcast_addr_what,
10037 (void *)&cmd_mcast_addr_portnum,
10038 (void *)&cmd_mcast_addr_addr,
10043 /* l2 tunnel config
10044 * only support E-tag now.
10047 /* Ether type config */
10048 struct cmd_config_l2_tunnel_eth_type_result {
10049 cmdline_fixed_string_t port;
10050 cmdline_fixed_string_t config;
10051 cmdline_fixed_string_t all;
10053 cmdline_fixed_string_t l2_tunnel;
10054 cmdline_fixed_string_t l2_tunnel_type;
10055 cmdline_fixed_string_t eth_type;
10056 uint16_t eth_type_val;
10059 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10060 TOKEN_STRING_INITIALIZER
10061 (struct cmd_config_l2_tunnel_eth_type_result,
10063 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10064 TOKEN_STRING_INITIALIZER
10065 (struct cmd_config_l2_tunnel_eth_type_result,
10067 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10068 TOKEN_STRING_INITIALIZER
10069 (struct cmd_config_l2_tunnel_eth_type_result,
10071 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10072 TOKEN_NUM_INITIALIZER
10073 (struct cmd_config_l2_tunnel_eth_type_result,
10075 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10076 TOKEN_STRING_INITIALIZER
10077 (struct cmd_config_l2_tunnel_eth_type_result,
10078 l2_tunnel, "l2-tunnel");
10079 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10080 TOKEN_STRING_INITIALIZER
10081 (struct cmd_config_l2_tunnel_eth_type_result,
10082 l2_tunnel_type, "E-tag");
10083 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10084 TOKEN_STRING_INITIALIZER
10085 (struct cmd_config_l2_tunnel_eth_type_result,
10086 eth_type, "ether-type");
10087 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10088 TOKEN_NUM_INITIALIZER
10089 (struct cmd_config_l2_tunnel_eth_type_result,
10090 eth_type_val, UINT16);
10092 static enum rte_eth_tunnel_type
10093 str2fdir_l2_tunnel_type(char *string)
10097 static const struct {
10099 enum rte_eth_tunnel_type type;
10100 } l2_tunnel_type_str[] = {
10101 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10104 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10105 if (!strcmp(l2_tunnel_type_str[i].str, string))
10106 return l2_tunnel_type_str[i].type;
10108 return RTE_TUNNEL_TYPE_NONE;
10111 /* ether type config for all ports */
10113 cmd_config_l2_tunnel_eth_type_all_parsed
10114 (void *parsed_result,
10115 __attribute__((unused)) struct cmdline *cl,
10116 __attribute__((unused)) void *data)
10118 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10119 struct rte_eth_l2_tunnel_conf entry;
10122 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10123 entry.ether_type = res->eth_type_val;
10125 FOREACH_PORT(pid, ports) {
10126 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10130 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10131 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10133 .help_str = "port config all l2-tunnel ether-type",
10135 (void *)&cmd_config_l2_tunnel_eth_type_port,
10136 (void *)&cmd_config_l2_tunnel_eth_type_config,
10137 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10138 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10139 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10140 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10141 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10146 /* ether type config for a specific port */
10148 cmd_config_l2_tunnel_eth_type_specific_parsed(
10149 void *parsed_result,
10150 __attribute__((unused)) struct cmdline *cl,
10151 __attribute__((unused)) void *data)
10153 struct cmd_config_l2_tunnel_eth_type_result *res =
10155 struct rte_eth_l2_tunnel_conf entry;
10157 if (port_id_is_invalid(res->id, ENABLED_WARN))
10160 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10161 entry.ether_type = res->eth_type_val;
10163 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10166 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10167 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10169 .help_str = "port config l2-tunnel ether-type",
10171 (void *)&cmd_config_l2_tunnel_eth_type_port,
10172 (void *)&cmd_config_l2_tunnel_eth_type_config,
10173 (void *)&cmd_config_l2_tunnel_eth_type_id,
10174 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10175 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10176 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10177 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10182 /* Enable/disable l2 tunnel */
10183 struct cmd_config_l2_tunnel_en_dis_result {
10184 cmdline_fixed_string_t port;
10185 cmdline_fixed_string_t config;
10186 cmdline_fixed_string_t all;
10188 cmdline_fixed_string_t l2_tunnel;
10189 cmdline_fixed_string_t l2_tunnel_type;
10190 cmdline_fixed_string_t en_dis;
10193 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10194 TOKEN_STRING_INITIALIZER
10195 (struct cmd_config_l2_tunnel_en_dis_result,
10197 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10198 TOKEN_STRING_INITIALIZER
10199 (struct cmd_config_l2_tunnel_en_dis_result,
10201 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10202 TOKEN_STRING_INITIALIZER
10203 (struct cmd_config_l2_tunnel_en_dis_result,
10205 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10206 TOKEN_NUM_INITIALIZER
10207 (struct cmd_config_l2_tunnel_en_dis_result,
10209 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10210 TOKEN_STRING_INITIALIZER
10211 (struct cmd_config_l2_tunnel_en_dis_result,
10212 l2_tunnel, "l2-tunnel");
10213 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10214 TOKEN_STRING_INITIALIZER
10215 (struct cmd_config_l2_tunnel_en_dis_result,
10216 l2_tunnel_type, "E-tag");
10217 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10218 TOKEN_STRING_INITIALIZER
10219 (struct cmd_config_l2_tunnel_en_dis_result,
10220 en_dis, "enable#disable");
10222 /* enable/disable l2 tunnel for all ports */
10224 cmd_config_l2_tunnel_en_dis_all_parsed(
10225 void *parsed_result,
10226 __attribute__((unused)) struct cmdline *cl,
10227 __attribute__((unused)) void *data)
10229 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10230 struct rte_eth_l2_tunnel_conf entry;
10234 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10236 if (!strcmp("enable", res->en_dis))
10241 FOREACH_PORT(pid, ports) {
10242 rte_eth_dev_l2_tunnel_offload_set(pid,
10244 ETH_L2_TUNNEL_ENABLE_MASK,
10249 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10250 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10252 .help_str = "port config all l2-tunnel enable/disable",
10254 (void *)&cmd_config_l2_tunnel_en_dis_port,
10255 (void *)&cmd_config_l2_tunnel_en_dis_config,
10256 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10257 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10258 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10259 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10264 /* enable/disable l2 tunnel for a port */
10266 cmd_config_l2_tunnel_en_dis_specific_parsed(
10267 void *parsed_result,
10268 __attribute__((unused)) struct cmdline *cl,
10269 __attribute__((unused)) void *data)
10271 struct cmd_config_l2_tunnel_en_dis_result *res =
10273 struct rte_eth_l2_tunnel_conf entry;
10275 if (port_id_is_invalid(res->id, ENABLED_WARN))
10278 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10280 if (!strcmp("enable", res->en_dis))
10281 rte_eth_dev_l2_tunnel_offload_set(res->id,
10283 ETH_L2_TUNNEL_ENABLE_MASK,
10286 rte_eth_dev_l2_tunnel_offload_set(res->id,
10288 ETH_L2_TUNNEL_ENABLE_MASK,
10292 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10293 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10295 .help_str = "port config l2-tunnel enable/disable",
10297 (void *)&cmd_config_l2_tunnel_en_dis_port,
10298 (void *)&cmd_config_l2_tunnel_en_dis_config,
10299 (void *)&cmd_config_l2_tunnel_en_dis_id,
10300 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10301 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10302 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10307 /* E-tag configuration */
10309 /* Common result structure for all E-tag configuration */
10310 struct cmd_config_e_tag_result {
10311 cmdline_fixed_string_t e_tag;
10312 cmdline_fixed_string_t set;
10313 cmdline_fixed_string_t insertion;
10314 cmdline_fixed_string_t stripping;
10315 cmdline_fixed_string_t forwarding;
10316 cmdline_fixed_string_t filter;
10317 cmdline_fixed_string_t add;
10318 cmdline_fixed_string_t del;
10319 cmdline_fixed_string_t on;
10320 cmdline_fixed_string_t off;
10321 cmdline_fixed_string_t on_off;
10322 cmdline_fixed_string_t port_tag_id;
10323 uint32_t port_tag_id_val;
10324 cmdline_fixed_string_t e_tag_id;
10325 uint16_t e_tag_id_val;
10326 cmdline_fixed_string_t dst_pool;
10327 uint8_t dst_pool_val;
10328 cmdline_fixed_string_t port;
10330 cmdline_fixed_string_t vf;
10334 /* Common CLI fields for all E-tag configuration */
10335 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10336 TOKEN_STRING_INITIALIZER
10337 (struct cmd_config_e_tag_result,
10339 cmdline_parse_token_string_t cmd_config_e_tag_set =
10340 TOKEN_STRING_INITIALIZER
10341 (struct cmd_config_e_tag_result,
10343 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10344 TOKEN_STRING_INITIALIZER
10345 (struct cmd_config_e_tag_result,
10346 insertion, "insertion");
10347 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10348 TOKEN_STRING_INITIALIZER
10349 (struct cmd_config_e_tag_result,
10350 stripping, "stripping");
10351 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10352 TOKEN_STRING_INITIALIZER
10353 (struct cmd_config_e_tag_result,
10354 forwarding, "forwarding");
10355 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10356 TOKEN_STRING_INITIALIZER
10357 (struct cmd_config_e_tag_result,
10359 cmdline_parse_token_string_t cmd_config_e_tag_add =
10360 TOKEN_STRING_INITIALIZER
10361 (struct cmd_config_e_tag_result,
10363 cmdline_parse_token_string_t cmd_config_e_tag_del =
10364 TOKEN_STRING_INITIALIZER
10365 (struct cmd_config_e_tag_result,
10367 cmdline_parse_token_string_t cmd_config_e_tag_on =
10368 TOKEN_STRING_INITIALIZER
10369 (struct cmd_config_e_tag_result,
10371 cmdline_parse_token_string_t cmd_config_e_tag_off =
10372 TOKEN_STRING_INITIALIZER
10373 (struct cmd_config_e_tag_result,
10375 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10376 TOKEN_STRING_INITIALIZER
10377 (struct cmd_config_e_tag_result,
10379 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10380 TOKEN_STRING_INITIALIZER
10381 (struct cmd_config_e_tag_result,
10382 port_tag_id, "port-tag-id");
10383 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10384 TOKEN_NUM_INITIALIZER
10385 (struct cmd_config_e_tag_result,
10386 port_tag_id_val, UINT32);
10387 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10388 TOKEN_STRING_INITIALIZER
10389 (struct cmd_config_e_tag_result,
10390 e_tag_id, "e-tag-id");
10391 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10392 TOKEN_NUM_INITIALIZER
10393 (struct cmd_config_e_tag_result,
10394 e_tag_id_val, UINT16);
10395 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10396 TOKEN_STRING_INITIALIZER
10397 (struct cmd_config_e_tag_result,
10398 dst_pool, "dst-pool");
10399 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10400 TOKEN_NUM_INITIALIZER
10401 (struct cmd_config_e_tag_result,
10402 dst_pool_val, UINT8);
10403 cmdline_parse_token_string_t cmd_config_e_tag_port =
10404 TOKEN_STRING_INITIALIZER
10405 (struct cmd_config_e_tag_result,
10407 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10408 TOKEN_NUM_INITIALIZER
10409 (struct cmd_config_e_tag_result,
10411 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10412 TOKEN_STRING_INITIALIZER
10413 (struct cmd_config_e_tag_result,
10415 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10416 TOKEN_NUM_INITIALIZER
10417 (struct cmd_config_e_tag_result,
10420 /* E-tag insertion configuration */
10422 cmd_config_e_tag_insertion_en_parsed(
10423 void *parsed_result,
10424 __attribute__((unused)) struct cmdline *cl,
10425 __attribute__((unused)) void *data)
10427 struct cmd_config_e_tag_result *res =
10429 struct rte_eth_l2_tunnel_conf entry;
10431 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10434 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10435 entry.tunnel_id = res->port_tag_id_val;
10436 entry.vf_id = res->vf_id;
10437 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10439 ETH_L2_TUNNEL_INSERTION_MASK,
10444 cmd_config_e_tag_insertion_dis_parsed(
10445 void *parsed_result,
10446 __attribute__((unused)) struct cmdline *cl,
10447 __attribute__((unused)) void *data)
10449 struct cmd_config_e_tag_result *res =
10451 struct rte_eth_l2_tunnel_conf entry;
10453 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10456 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10457 entry.vf_id = res->vf_id;
10459 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10461 ETH_L2_TUNNEL_INSERTION_MASK,
10465 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10466 .f = cmd_config_e_tag_insertion_en_parsed,
10468 .help_str = "E-tag insertion enable",
10470 (void *)&cmd_config_e_tag_e_tag,
10471 (void *)&cmd_config_e_tag_set,
10472 (void *)&cmd_config_e_tag_insertion,
10473 (void *)&cmd_config_e_tag_on,
10474 (void *)&cmd_config_e_tag_port_tag_id,
10475 (void *)&cmd_config_e_tag_port_tag_id_val,
10476 (void *)&cmd_config_e_tag_port,
10477 (void *)&cmd_config_e_tag_port_id,
10478 (void *)&cmd_config_e_tag_vf,
10479 (void *)&cmd_config_e_tag_vf_id,
10484 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10485 .f = cmd_config_e_tag_insertion_dis_parsed,
10487 .help_str = "E-tag insertion disable",
10489 (void *)&cmd_config_e_tag_e_tag,
10490 (void *)&cmd_config_e_tag_set,
10491 (void *)&cmd_config_e_tag_insertion,
10492 (void *)&cmd_config_e_tag_off,
10493 (void *)&cmd_config_e_tag_port,
10494 (void *)&cmd_config_e_tag_port_id,
10495 (void *)&cmd_config_e_tag_vf,
10496 (void *)&cmd_config_e_tag_vf_id,
10501 /* E-tag stripping configuration */
10503 cmd_config_e_tag_stripping_parsed(
10504 void *parsed_result,
10505 __attribute__((unused)) struct cmdline *cl,
10506 __attribute__((unused)) void *data)
10508 struct cmd_config_e_tag_result *res =
10510 struct rte_eth_l2_tunnel_conf entry;
10512 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10515 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10517 if (!strcmp(res->on_off, "on"))
10518 rte_eth_dev_l2_tunnel_offload_set
10521 ETH_L2_TUNNEL_STRIPPING_MASK,
10524 rte_eth_dev_l2_tunnel_offload_set
10527 ETH_L2_TUNNEL_STRIPPING_MASK,
10531 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10532 .f = cmd_config_e_tag_stripping_parsed,
10534 .help_str = "E-tag stripping enable/disable",
10536 (void *)&cmd_config_e_tag_e_tag,
10537 (void *)&cmd_config_e_tag_set,
10538 (void *)&cmd_config_e_tag_stripping,
10539 (void *)&cmd_config_e_tag_on_off,
10540 (void *)&cmd_config_e_tag_port,
10541 (void *)&cmd_config_e_tag_port_id,
10546 /* E-tag forwarding configuration */
10548 cmd_config_e_tag_forwarding_parsed(
10549 void *parsed_result,
10550 __attribute__((unused)) struct cmdline *cl,
10551 __attribute__((unused)) void *data)
10553 struct cmd_config_e_tag_result *res = parsed_result;
10554 struct rte_eth_l2_tunnel_conf entry;
10556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10559 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10561 if (!strcmp(res->on_off, "on"))
10562 rte_eth_dev_l2_tunnel_offload_set
10565 ETH_L2_TUNNEL_FORWARDING_MASK,
10568 rte_eth_dev_l2_tunnel_offload_set
10571 ETH_L2_TUNNEL_FORWARDING_MASK,
10575 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10576 .f = cmd_config_e_tag_forwarding_parsed,
10578 .help_str = "E-tag forwarding enable/disable",
10580 (void *)&cmd_config_e_tag_e_tag,
10581 (void *)&cmd_config_e_tag_set,
10582 (void *)&cmd_config_e_tag_forwarding,
10583 (void *)&cmd_config_e_tag_on_off,
10584 (void *)&cmd_config_e_tag_port,
10585 (void *)&cmd_config_e_tag_port_id,
10590 /* E-tag filter configuration */
10592 cmd_config_e_tag_filter_add_parsed(
10593 void *parsed_result,
10594 __attribute__((unused)) struct cmdline *cl,
10595 __attribute__((unused)) void *data)
10597 struct cmd_config_e_tag_result *res = parsed_result;
10598 struct rte_eth_l2_tunnel_conf entry;
10601 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10604 if (res->e_tag_id_val > 0x3fff) {
10605 printf("e-tag-id must be equal or less than 0x3fff.\n");
10609 ret = rte_eth_dev_filter_supported(res->port_id,
10610 RTE_ETH_FILTER_L2_TUNNEL);
10612 printf("E-tag filter is not supported on port %u.\n",
10617 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10618 entry.tunnel_id = res->e_tag_id_val;
10619 entry.pool = res->dst_pool_val;
10621 ret = rte_eth_dev_filter_ctrl(res->port_id,
10622 RTE_ETH_FILTER_L2_TUNNEL,
10623 RTE_ETH_FILTER_ADD,
10626 printf("E-tag filter programming error: (%s)\n",
10630 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10631 .f = cmd_config_e_tag_filter_add_parsed,
10633 .help_str = "E-tag filter add",
10635 (void *)&cmd_config_e_tag_e_tag,
10636 (void *)&cmd_config_e_tag_set,
10637 (void *)&cmd_config_e_tag_filter,
10638 (void *)&cmd_config_e_tag_add,
10639 (void *)&cmd_config_e_tag_e_tag_id,
10640 (void *)&cmd_config_e_tag_e_tag_id_val,
10641 (void *)&cmd_config_e_tag_dst_pool,
10642 (void *)&cmd_config_e_tag_dst_pool_val,
10643 (void *)&cmd_config_e_tag_port,
10644 (void *)&cmd_config_e_tag_port_id,
10650 cmd_config_e_tag_filter_del_parsed(
10651 void *parsed_result,
10652 __attribute__((unused)) struct cmdline *cl,
10653 __attribute__((unused)) void *data)
10655 struct cmd_config_e_tag_result *res = parsed_result;
10656 struct rte_eth_l2_tunnel_conf entry;
10659 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10662 if (res->e_tag_id_val > 0x3fff) {
10663 printf("e-tag-id must be less than 0x3fff.\n");
10667 ret = rte_eth_dev_filter_supported(res->port_id,
10668 RTE_ETH_FILTER_L2_TUNNEL);
10670 printf("E-tag filter is not supported on port %u.\n",
10675 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10676 entry.tunnel_id = res->e_tag_id_val;
10678 ret = rte_eth_dev_filter_ctrl(res->port_id,
10679 RTE_ETH_FILTER_L2_TUNNEL,
10680 RTE_ETH_FILTER_DELETE,
10683 printf("E-tag filter programming error: (%s)\n",
10687 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10688 .f = cmd_config_e_tag_filter_del_parsed,
10690 .help_str = "E-tag filter delete",
10692 (void *)&cmd_config_e_tag_e_tag,
10693 (void *)&cmd_config_e_tag_set,
10694 (void *)&cmd_config_e_tag_filter,
10695 (void *)&cmd_config_e_tag_del,
10696 (void *)&cmd_config_e_tag_e_tag_id,
10697 (void *)&cmd_config_e_tag_e_tag_id_val,
10698 (void *)&cmd_config_e_tag_port,
10699 (void *)&cmd_config_e_tag_port_id,
10704 /* ******************************************************************************** */
10706 /* list of instructions */
10707 cmdline_parse_ctx_t main_ctx[] = {
10708 (cmdline_parse_inst_t *)&cmd_help_brief,
10709 (cmdline_parse_inst_t *)&cmd_help_long,
10710 (cmdline_parse_inst_t *)&cmd_quit,
10711 (cmdline_parse_inst_t *)&cmd_showport,
10712 (cmdline_parse_inst_t *)&cmd_showqueue,
10713 (cmdline_parse_inst_t *)&cmd_showportall,
10714 (cmdline_parse_inst_t *)&cmd_showcfg,
10715 (cmdline_parse_inst_t *)&cmd_start,
10716 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10717 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
10718 (cmdline_parse_inst_t *)&cmd_set_link_up,
10719 (cmdline_parse_inst_t *)&cmd_set_link_down,
10720 (cmdline_parse_inst_t *)&cmd_reset,
10721 (cmdline_parse_inst_t *)&cmd_set_numbers,
10722 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10723 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10724 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10725 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10726 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10727 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
10728 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10729 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10730 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10731 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10732 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10733 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10734 (cmdline_parse_inst_t *)&cmd_set_link_check,
10735 #ifdef RTE_NIC_BYPASS
10736 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10737 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10738 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10739 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10741 #ifdef RTE_LIBRTE_PMD_BOND
10742 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10743 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10744 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10745 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10746 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10747 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10748 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10749 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10750 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10752 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10753 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10754 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10755 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10756 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10757 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10758 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10759 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10760 (cmdline_parse_inst_t *)&cmd_csum_set,
10761 (cmdline_parse_inst_t *)&cmd_csum_show,
10762 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10763 (cmdline_parse_inst_t *)&cmd_tso_set,
10764 (cmdline_parse_inst_t *)&cmd_tso_show,
10765 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
10766 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
10767 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10768 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10769 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10770 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10771 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10772 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10773 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10774 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10775 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10776 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10777 (cmdline_parse_inst_t *)&cmd_config_dcb,
10778 (cmdline_parse_inst_t *)&cmd_read_reg,
10779 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10780 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10781 (cmdline_parse_inst_t *)&cmd_write_reg,
10782 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10783 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10784 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10785 (cmdline_parse_inst_t *)&cmd_stop,
10786 (cmdline_parse_inst_t *)&cmd_mac_addr,
10787 (cmdline_parse_inst_t *)&cmd_set_qmap,
10788 (cmdline_parse_inst_t *)&cmd_operate_port,
10789 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10790 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10791 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10792 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10793 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10794 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10795 (cmdline_parse_inst_t *)&cmd_config_mtu,
10796 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10797 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10798 (cmdline_parse_inst_t *)&cmd_config_rss,
10799 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10800 (cmdline_parse_inst_t *)&cmd_config_txqflags,
10801 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10802 (cmdline_parse_inst_t *)&cmd_showport_reta,
10803 (cmdline_parse_inst_t *)&cmd_config_burst,
10804 (cmdline_parse_inst_t *)&cmd_config_thresh,
10805 (cmdline_parse_inst_t *)&cmd_config_threshold,
10806 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10807 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10808 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10809 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10810 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10811 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10812 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10813 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10814 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10815 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10816 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10817 (cmdline_parse_inst_t *)&cmd_global_config,
10818 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10819 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10820 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10821 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10822 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10823 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10824 (cmdline_parse_inst_t *)&cmd_dump,
10825 (cmdline_parse_inst_t *)&cmd_dump_one,
10826 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10827 (cmdline_parse_inst_t *)&cmd_syn_filter,
10828 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10829 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10830 (cmdline_parse_inst_t *)&cmd_flex_filter,
10831 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10832 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10833 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10834 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10835 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10836 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10837 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10838 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10839 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10840 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10841 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10842 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10843 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10844 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10845 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10846 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10847 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10848 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10849 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10850 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10851 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10852 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10853 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10854 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10855 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10856 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10857 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10858 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10859 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10863 /* prompt function, called from main on MASTER lcore */
10867 /* initialize non-constant commands */
10868 cmd_set_fwd_mode_init();
10869 cmd_set_fwd_retry_mode_init();
10871 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10872 if (testpmd_cl == NULL)
10874 cmdline_interact(testpmd_cl);
10875 cmdline_stdin_exit(testpmd_cl);
10881 if (testpmd_cl != NULL)
10882 cmdline_quit(testpmd_cl);
10886 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10888 if (id == (portid_t)RTE_PORT_ALL) {
10891 FOREACH_PORT(pid, ports) {
10892 /* check if need_reconfig has been set to 1 */
10893 if (ports[pid].need_reconfig == 0)
10894 ports[pid].need_reconfig = dev;
10895 /* check if need_reconfig_queues has been set to 1 */
10896 if (ports[pid].need_reconfig_queues == 0)
10897 ports[pid].need_reconfig_queues = queue;
10899 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10900 /* check if need_reconfig has been set to 1 */
10901 if (ports[id].need_reconfig == 0)
10902 ports[id].need_reconfig = dev;
10903 /* check if need_reconfig_queues has been set to 1 */
10904 if (ports[id].need_reconfig_queues == 0)
10905 ports[id].need_reconfig_queues = queue;