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 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 is disabled\n");
3500 printf("TSO segment size 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 for csum engine (0 to disable): "
3529 "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 for csum engine: "
3550 (void *)&cmd_tso_set_tso,
3551 (void *)&cmd_tso_show_mode,
3552 (void *)&cmd_tso_set_portid,
3557 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3558 struct cmd_set_flush_rx {
3559 cmdline_fixed_string_t set;
3560 cmdline_fixed_string_t flush_rx;
3561 cmdline_fixed_string_t mode;
3565 cmd_set_flush_rx_parsed(void *parsed_result,
3566 __attribute__((unused)) struct cmdline *cl,
3567 __attribute__((unused)) void *data)
3569 struct cmd_set_flush_rx *res = parsed_result;
3570 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3573 cmdline_parse_token_string_t cmd_setflushrx_set =
3574 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3576 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3577 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3578 flush_rx, "flush_rx");
3579 cmdline_parse_token_string_t cmd_setflushrx_mode =
3580 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3584 cmdline_parse_inst_t cmd_set_flush_rx = {
3585 .f = cmd_set_flush_rx_parsed,
3586 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3589 (void *)&cmd_setflushrx_set,
3590 (void *)&cmd_setflushrx_flush_rx,
3591 (void *)&cmd_setflushrx_mode,
3596 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3597 struct cmd_set_link_check {
3598 cmdline_fixed_string_t set;
3599 cmdline_fixed_string_t link_check;
3600 cmdline_fixed_string_t mode;
3604 cmd_set_link_check_parsed(void *parsed_result,
3605 __attribute__((unused)) struct cmdline *cl,
3606 __attribute__((unused)) void *data)
3608 struct cmd_set_link_check *res = parsed_result;
3609 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3612 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3613 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3615 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3616 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3617 link_check, "link_check");
3618 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3619 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3623 cmdline_parse_inst_t cmd_set_link_check = {
3624 .f = cmd_set_link_check_parsed,
3625 .help_str = "set link_check on|off: enable/disable link status check "
3626 "when starting/stopping a port",
3629 (void *)&cmd_setlinkcheck_set,
3630 (void *)&cmd_setlinkcheck_link_check,
3631 (void *)&cmd_setlinkcheck_mode,
3636 #ifdef RTE_NIC_BYPASS
3637 /* *** SET NIC BYPASS MODE *** */
3638 struct cmd_set_bypass_mode_result {
3639 cmdline_fixed_string_t set;
3640 cmdline_fixed_string_t bypass;
3641 cmdline_fixed_string_t mode;
3642 cmdline_fixed_string_t value;
3647 cmd_set_bypass_mode_parsed(void *parsed_result,
3648 __attribute__((unused)) struct cmdline *cl,
3649 __attribute__((unused)) void *data)
3651 struct cmd_set_bypass_mode_result *res = parsed_result;
3652 portid_t port_id = res->port_id;
3653 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3655 if (!strcmp(res->value, "bypass"))
3656 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3657 else if (!strcmp(res->value, "isolate"))
3658 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3660 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3662 /* Set the bypass mode for the relevant port. */
3663 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3664 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3668 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3669 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3671 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3672 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3674 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3675 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3677 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3678 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3679 value, "normal#bypass#isolate");
3680 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3681 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3684 cmdline_parse_inst_t cmd_set_bypass_mode = {
3685 .f = cmd_set_bypass_mode_parsed,
3686 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3687 "Set the NIC bypass mode for port_id",
3690 (void *)&cmd_setbypass_mode_set,
3691 (void *)&cmd_setbypass_mode_bypass,
3692 (void *)&cmd_setbypass_mode_mode,
3693 (void *)&cmd_setbypass_mode_value,
3694 (void *)&cmd_setbypass_mode_port,
3699 /* *** SET NIC BYPASS EVENT *** */
3700 struct cmd_set_bypass_event_result {
3701 cmdline_fixed_string_t set;
3702 cmdline_fixed_string_t bypass;
3703 cmdline_fixed_string_t event;
3704 cmdline_fixed_string_t event_value;
3705 cmdline_fixed_string_t mode;
3706 cmdline_fixed_string_t mode_value;
3711 cmd_set_bypass_event_parsed(void *parsed_result,
3712 __attribute__((unused)) struct cmdline *cl,
3713 __attribute__((unused)) void *data)
3716 struct cmd_set_bypass_event_result *res = parsed_result;
3717 portid_t port_id = res->port_id;
3718 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3719 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3721 if (!strcmp(res->event_value, "timeout"))
3722 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3723 else if (!strcmp(res->event_value, "os_on"))
3724 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3725 else if (!strcmp(res->event_value, "os_off"))
3726 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3727 else if (!strcmp(res->event_value, "power_on"))
3728 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3729 else if (!strcmp(res->event_value, "power_off"))
3730 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3732 bypass_event = RTE_BYPASS_EVENT_NONE;
3734 if (!strcmp(res->mode_value, "bypass"))
3735 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3736 else if (!strcmp(res->mode_value, "isolate"))
3737 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3739 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3741 /* Set the watchdog timeout. */
3742 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3745 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3746 (rc = rte_eth_dev_wd_timeout_store(port_id,
3747 bypass_timeout)) != 0) {
3748 printf("Failed to set timeout value %u "
3749 "for port %d, errto code: %d.\n",
3750 bypass_timeout, port_id, rc);
3754 /* Set the bypass event to transition to bypass mode. */
3755 if (0 != rte_eth_dev_bypass_event_store(port_id,
3756 bypass_event, bypass_mode)) {
3757 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3762 cmdline_parse_token_string_t cmd_setbypass_event_set =
3763 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3765 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3766 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3768 cmdline_parse_token_string_t cmd_setbypass_event_event =
3769 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3771 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3772 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3773 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3774 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3775 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3777 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3778 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3779 mode_value, "normal#bypass#isolate");
3780 cmdline_parse_token_num_t cmd_setbypass_event_port =
3781 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3784 cmdline_parse_inst_t cmd_set_bypass_event = {
3785 .f = cmd_set_bypass_event_parsed,
3786 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3787 "mode (normal|bypass|isolate) (port_id): "
3788 "Set the NIC bypass event mode for port_id",
3791 (void *)&cmd_setbypass_event_set,
3792 (void *)&cmd_setbypass_event_bypass,
3793 (void *)&cmd_setbypass_event_event,
3794 (void *)&cmd_setbypass_event_event_value,
3795 (void *)&cmd_setbypass_event_mode,
3796 (void *)&cmd_setbypass_event_mode_value,
3797 (void *)&cmd_setbypass_event_port,
3803 /* *** SET NIC BYPASS TIMEOUT *** */
3804 struct cmd_set_bypass_timeout_result {
3805 cmdline_fixed_string_t set;
3806 cmdline_fixed_string_t bypass;
3807 cmdline_fixed_string_t timeout;
3808 cmdline_fixed_string_t value;
3812 cmd_set_bypass_timeout_parsed(void *parsed_result,
3813 __attribute__((unused)) struct cmdline *cl,
3814 __attribute__((unused)) void *data)
3816 struct cmd_set_bypass_timeout_result *res = parsed_result;
3818 if (!strcmp(res->value, "1.5"))
3819 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3820 else if (!strcmp(res->value, "2"))
3821 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3822 else if (!strcmp(res->value, "3"))
3823 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3824 else if (!strcmp(res->value, "4"))
3825 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3826 else if (!strcmp(res->value, "8"))
3827 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3828 else if (!strcmp(res->value, "16"))
3829 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3830 else if (!strcmp(res->value, "32"))
3831 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3833 bypass_timeout = RTE_BYPASS_TMT_OFF;
3836 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3837 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3839 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3840 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3842 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3843 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3844 timeout, "timeout");
3845 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3847 value, "0#1.5#2#3#4#8#16#32");
3849 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3850 .f = cmd_set_bypass_timeout_parsed,
3851 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3852 "Set the NIC bypass watchdog timeout",
3855 (void *)&cmd_setbypass_timeout_set,
3856 (void *)&cmd_setbypass_timeout_bypass,
3857 (void *)&cmd_setbypass_timeout_timeout,
3858 (void *)&cmd_setbypass_timeout_value,
3863 /* *** SHOW NIC BYPASS MODE *** */
3864 struct cmd_show_bypass_config_result {
3865 cmdline_fixed_string_t show;
3866 cmdline_fixed_string_t bypass;
3867 cmdline_fixed_string_t config;
3872 cmd_show_bypass_config_parsed(void *parsed_result,
3873 __attribute__((unused)) struct cmdline *cl,
3874 __attribute__((unused)) void *data)
3876 struct cmd_show_bypass_config_result *res = parsed_result;
3877 uint32_t event_mode;
3878 uint32_t bypass_mode;
3879 portid_t port_id = res->port_id;
3880 uint32_t timeout = bypass_timeout;
3883 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3884 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3885 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3886 {"UNKNOWN", "normal", "bypass", "isolate"};
3887 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3894 int num_events = (sizeof events) / (sizeof events[0]);
3896 /* Display the bypass mode.*/
3897 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3898 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3902 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3903 bypass_mode = RTE_BYPASS_MODE_NONE;
3905 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3908 /* Display the bypass timeout.*/
3909 if (!RTE_BYPASS_TMT_VALID(timeout))
3910 timeout = RTE_BYPASS_TMT_OFF;
3912 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3914 /* Display the bypass events and associated modes. */
3915 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3917 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3918 printf("\tFailed to get bypass mode for event = %s\n",
3921 if (!RTE_BYPASS_MODE_VALID(event_mode))
3922 event_mode = RTE_BYPASS_MODE_NONE;
3924 printf("\tbypass event: %-16s = %s\n", events[i],
3930 cmdline_parse_token_string_t cmd_showbypass_config_show =
3931 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3933 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3934 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3936 cmdline_parse_token_string_t cmd_showbypass_config_config =
3937 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3939 cmdline_parse_token_num_t cmd_showbypass_config_port =
3940 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3943 cmdline_parse_inst_t cmd_show_bypass_config = {
3944 .f = cmd_show_bypass_config_parsed,
3945 .help_str = "show bypass config (port_id): "
3946 "Show the NIC bypass config for port_id",
3949 (void *)&cmd_showbypass_config_show,
3950 (void *)&cmd_showbypass_config_bypass,
3951 (void *)&cmd_showbypass_config_config,
3952 (void *)&cmd_showbypass_config_port,
3958 #ifdef RTE_LIBRTE_PMD_BOND
3959 /* *** SET BONDING MODE *** */
3960 struct cmd_set_bonding_mode_result {
3961 cmdline_fixed_string_t set;
3962 cmdline_fixed_string_t bonding;
3963 cmdline_fixed_string_t mode;
3968 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3969 __attribute__((unused)) struct cmdline *cl,
3970 __attribute__((unused)) void *data)
3972 struct cmd_set_bonding_mode_result *res = parsed_result;
3973 portid_t port_id = res->port_id;
3975 /* Set the bonding mode for the relevant port. */
3976 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3977 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3980 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3983 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3985 bonding, "bonding");
3986 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3989 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3990 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3992 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3993 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3996 cmdline_parse_inst_t cmd_set_bonding_mode = {
3997 .f = cmd_set_bonding_mode_parsed,
3998 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
4001 (void *) &cmd_setbonding_mode_set,
4002 (void *) &cmd_setbonding_mode_bonding,
4003 (void *) &cmd_setbonding_mode_mode,
4004 (void *) &cmd_setbonding_mode_value,
4005 (void *) &cmd_setbonding_mode_port,
4010 /* *** SET BALANCE XMIT POLICY *** */
4011 struct cmd_set_bonding_balance_xmit_policy_result {
4012 cmdline_fixed_string_t set;
4013 cmdline_fixed_string_t bonding;
4014 cmdline_fixed_string_t balance_xmit_policy;
4016 cmdline_fixed_string_t policy;
4019 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4020 __attribute__((unused)) struct cmdline *cl,
4021 __attribute__((unused)) void *data)
4023 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4024 portid_t port_id = res->port_id;
4027 if (!strcmp(res->policy, "l2")) {
4028 policy = BALANCE_XMIT_POLICY_LAYER2;
4029 } else if (!strcmp(res->policy, "l23")) {
4030 policy = BALANCE_XMIT_POLICY_LAYER23;
4031 } else if (!strcmp(res->policy, "l34")) {
4032 policy = BALANCE_XMIT_POLICY_LAYER34;
4034 printf("\t Invalid xmit policy selection");
4038 /* Set the bonding mode for the relevant port. */
4039 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4040 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4045 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4046 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4048 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4049 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4050 bonding, "bonding");
4051 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4052 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4053 balance_xmit_policy, "balance_xmit_policy");
4054 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4055 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4057 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4058 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4059 policy, "l2#l23#l34");
4061 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4062 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4063 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
4066 (void *)&cmd_setbonding_balance_xmit_policy_set,
4067 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4068 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4069 (void *)&cmd_setbonding_balance_xmit_policy_port,
4070 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4075 /* *** SHOW NIC BONDING CONFIGURATION *** */
4076 struct cmd_show_bonding_config_result {
4077 cmdline_fixed_string_t show;
4078 cmdline_fixed_string_t bonding;
4079 cmdline_fixed_string_t config;
4083 static void cmd_show_bonding_config_parsed(void *parsed_result,
4084 __attribute__((unused)) struct cmdline *cl,
4085 __attribute__((unused)) void *data)
4087 struct cmd_show_bonding_config_result *res = parsed_result;
4089 uint8_t slaves[RTE_MAX_ETHPORTS];
4090 int num_slaves, num_active_slaves;
4093 portid_t port_id = res->port_id;
4095 /* Display the bonding mode.*/
4096 bonding_mode = rte_eth_bond_mode_get(port_id);
4097 if (bonding_mode < 0) {
4098 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4101 printf("\tBonding mode: %d\n", bonding_mode);
4103 if (bonding_mode == BONDING_MODE_BALANCE) {
4104 int balance_xmit_policy;
4106 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4107 if (balance_xmit_policy < 0) {
4108 printf("\tFailed to get balance xmit policy for port = %d\n",
4112 printf("\tBalance Xmit Policy: ");
4114 switch (balance_xmit_policy) {
4115 case BALANCE_XMIT_POLICY_LAYER2:
4116 printf("BALANCE_XMIT_POLICY_LAYER2");
4118 case BALANCE_XMIT_POLICY_LAYER23:
4119 printf("BALANCE_XMIT_POLICY_LAYER23");
4121 case BALANCE_XMIT_POLICY_LAYER34:
4122 printf("BALANCE_XMIT_POLICY_LAYER34");
4129 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4131 if (num_slaves < 0) {
4132 printf("\tFailed to get slave list for port = %d\n", port_id);
4135 if (num_slaves > 0) {
4136 printf("\tSlaves (%d): [", num_slaves);
4137 for (i = 0; i < num_slaves - 1; i++)
4138 printf("%d ", slaves[i]);
4140 printf("%d]\n", slaves[num_slaves - 1]);
4142 printf("\tSlaves: []\n");
4146 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4149 if (num_active_slaves < 0) {
4150 printf("\tFailed to get active slave list for port = %d\n", port_id);
4153 if (num_active_slaves > 0) {
4154 printf("\tActive Slaves (%d): [", num_active_slaves);
4155 for (i = 0; i < num_active_slaves - 1; i++)
4156 printf("%d ", slaves[i]);
4158 printf("%d]\n", slaves[num_active_slaves - 1]);
4161 printf("\tActive Slaves: []\n");
4165 primary_id = rte_eth_bond_primary_get(port_id);
4166 if (primary_id < 0) {
4167 printf("\tFailed to get primary slave for port = %d\n", port_id);
4170 printf("\tPrimary: [%d]\n", primary_id);
4174 cmdline_parse_token_string_t cmd_showbonding_config_show =
4175 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4177 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4178 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4179 bonding, "bonding");
4180 cmdline_parse_token_string_t cmd_showbonding_config_config =
4181 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4183 cmdline_parse_token_num_t cmd_showbonding_config_port =
4184 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4187 cmdline_parse_inst_t cmd_show_bonding_config = {
4188 .f = cmd_show_bonding_config_parsed,
4189 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4192 (void *)&cmd_showbonding_config_show,
4193 (void *)&cmd_showbonding_config_bonding,
4194 (void *)&cmd_showbonding_config_config,
4195 (void *)&cmd_showbonding_config_port,
4200 /* *** SET BONDING PRIMARY *** */
4201 struct cmd_set_bonding_primary_result {
4202 cmdline_fixed_string_t set;
4203 cmdline_fixed_string_t bonding;
4204 cmdline_fixed_string_t primary;
4209 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4210 __attribute__((unused)) struct cmdline *cl,
4211 __attribute__((unused)) void *data)
4213 struct cmd_set_bonding_primary_result *res = parsed_result;
4214 portid_t master_port_id = res->port_id;
4215 portid_t slave_port_id = res->slave_id;
4217 /* Set the primary slave for a bonded device. */
4218 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4219 printf("\t Failed to set primary slave for port = %d.\n",
4226 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4227 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4229 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4230 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4231 bonding, "bonding");
4232 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4233 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4234 primary, "primary");
4235 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4236 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4238 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4239 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4242 cmdline_parse_inst_t cmd_set_bonding_primary = {
4243 .f = cmd_set_bonding_primary_parsed,
4244 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4247 (void *)&cmd_setbonding_primary_set,
4248 (void *)&cmd_setbonding_primary_bonding,
4249 (void *)&cmd_setbonding_primary_primary,
4250 (void *)&cmd_setbonding_primary_slave,
4251 (void *)&cmd_setbonding_primary_port,
4256 /* *** ADD SLAVE *** */
4257 struct cmd_add_bonding_slave_result {
4258 cmdline_fixed_string_t add;
4259 cmdline_fixed_string_t bonding;
4260 cmdline_fixed_string_t slave;
4265 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4266 __attribute__((unused)) struct cmdline *cl,
4267 __attribute__((unused)) void *data)
4269 struct cmd_add_bonding_slave_result *res = parsed_result;
4270 portid_t master_port_id = res->port_id;
4271 portid_t slave_port_id = res->slave_id;
4273 /* Set the primary slave for a bonded device. */
4274 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4275 printf("\t Failed to add slave %d to master port = %d.\n",
4276 slave_port_id, master_port_id);
4280 set_port_slave_flag(slave_port_id);
4283 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4284 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4286 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4287 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4288 bonding, "bonding");
4289 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4290 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4292 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4293 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4295 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4296 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4299 cmdline_parse_inst_t cmd_add_bonding_slave = {
4300 .f = cmd_add_bonding_slave_parsed,
4301 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4304 (void *)&cmd_addbonding_slave_add,
4305 (void *)&cmd_addbonding_slave_bonding,
4306 (void *)&cmd_addbonding_slave_slave,
4307 (void *)&cmd_addbonding_slave_slaveid,
4308 (void *)&cmd_addbonding_slave_port,
4313 /* *** REMOVE SLAVE *** */
4314 struct cmd_remove_bonding_slave_result {
4315 cmdline_fixed_string_t remove;
4316 cmdline_fixed_string_t bonding;
4317 cmdline_fixed_string_t slave;
4322 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4323 __attribute__((unused)) struct cmdline *cl,
4324 __attribute__((unused)) void *data)
4326 struct cmd_remove_bonding_slave_result *res = parsed_result;
4327 portid_t master_port_id = res->port_id;
4328 portid_t slave_port_id = res->slave_id;
4330 /* Set the primary slave for a bonded device. */
4331 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4332 printf("\t Failed to remove slave %d from master port = %d.\n",
4333 slave_port_id, master_port_id);
4337 clear_port_slave_flag(slave_port_id);
4340 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4341 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4343 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4344 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4345 bonding, "bonding");
4346 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4347 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4349 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4350 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4352 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4353 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4356 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4357 .f = cmd_remove_bonding_slave_parsed,
4358 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4361 (void *)&cmd_removebonding_slave_remove,
4362 (void *)&cmd_removebonding_slave_bonding,
4363 (void *)&cmd_removebonding_slave_slave,
4364 (void *)&cmd_removebonding_slave_slaveid,
4365 (void *)&cmd_removebonding_slave_port,
4370 /* *** CREATE BONDED DEVICE *** */
4371 struct cmd_create_bonded_device_result {
4372 cmdline_fixed_string_t create;
4373 cmdline_fixed_string_t bonded;
4374 cmdline_fixed_string_t device;
4379 static int bond_dev_num = 0;
4381 static void cmd_create_bonded_device_parsed(void *parsed_result,
4382 __attribute__((unused)) struct cmdline *cl,
4383 __attribute__((unused)) void *data)
4385 struct cmd_create_bonded_device_result *res = parsed_result;
4386 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4389 if (test_done == 0) {
4390 printf("Please stop forwarding first\n");
4394 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4397 /* Create a new bonded device. */
4398 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4400 printf("\t Failed to create bonded device.\n");
4403 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4406 /* Update number of ports */
4407 nb_ports = rte_eth_dev_count();
4408 reconfig(port_id, res->socket);
4409 rte_eth_promiscuous_enable(port_id);
4410 ports[port_id].enabled = 1;
4415 cmdline_parse_token_string_t cmd_createbonded_device_create =
4416 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4418 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4419 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4421 cmdline_parse_token_string_t cmd_createbonded_device_device =
4422 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4424 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4425 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4427 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4428 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4431 cmdline_parse_inst_t cmd_create_bonded_device = {
4432 .f = cmd_create_bonded_device_parsed,
4433 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4436 (void *)&cmd_createbonded_device_create,
4437 (void *)&cmd_createbonded_device_bonded,
4438 (void *)&cmd_createbonded_device_device,
4439 (void *)&cmd_createbonded_device_mode,
4440 (void *)&cmd_createbonded_device_socket,
4445 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4446 struct cmd_set_bond_mac_addr_result {
4447 cmdline_fixed_string_t set;
4448 cmdline_fixed_string_t bonding;
4449 cmdline_fixed_string_t mac_addr;
4451 struct ether_addr address;
4454 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4455 __attribute__((unused)) struct cmdline *cl,
4456 __attribute__((unused)) void *data)
4458 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4461 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4464 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4466 /* check the return value and print it if is < 0 */
4468 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4471 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4472 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4473 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4474 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4476 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4477 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4479 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4480 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4481 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4484 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4485 .f = cmd_set_bond_mac_addr_parsed,
4487 .help_str = "set bonding mac_addr (port_id) (address): ",
4489 (void *)&cmd_set_bond_mac_addr_set,
4490 (void *)&cmd_set_bond_mac_addr_bonding,
4491 (void *)&cmd_set_bond_mac_addr_mac,
4492 (void *)&cmd_set_bond_mac_addr_portnum,
4493 (void *)&cmd_set_bond_mac_addr_addr,
4499 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4500 struct cmd_set_bond_mon_period_result {
4501 cmdline_fixed_string_t set;
4502 cmdline_fixed_string_t bonding;
4503 cmdline_fixed_string_t mon_period;
4508 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4509 __attribute__((unused)) struct cmdline *cl,
4510 __attribute__((unused)) void *data)
4512 struct cmd_set_bond_mon_period_result *res = parsed_result;
4515 if (res->port_num >= nb_ports) {
4516 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4520 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4522 /* check the return value and print it if is < 0 */
4524 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4527 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4528 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4530 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4531 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4532 bonding, "bonding");
4533 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4534 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4535 mon_period, "mon_period");
4536 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4537 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4539 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4540 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4543 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4544 .f = cmd_set_bond_mon_period_parsed,
4546 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4548 (void *)&cmd_set_bond_mon_period_set,
4549 (void *)&cmd_set_bond_mon_period_bonding,
4550 (void *)&cmd_set_bond_mon_period_mon_period,
4551 (void *)&cmd_set_bond_mon_period_portnum,
4552 (void *)&cmd_set_bond_mon_period_period_ms,
4557 #endif /* RTE_LIBRTE_PMD_BOND */
4559 /* *** SET FORWARDING MODE *** */
4560 struct cmd_set_fwd_mode_result {
4561 cmdline_fixed_string_t set;
4562 cmdline_fixed_string_t fwd;
4563 cmdline_fixed_string_t mode;
4566 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4567 __attribute__((unused)) struct cmdline *cl,
4568 __attribute__((unused)) void *data)
4570 struct cmd_set_fwd_mode_result *res = parsed_result;
4573 set_pkt_forwarding_mode(res->mode);
4576 cmdline_parse_token_string_t cmd_setfwd_set =
4577 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4578 cmdline_parse_token_string_t cmd_setfwd_fwd =
4579 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4580 cmdline_parse_token_string_t cmd_setfwd_mode =
4581 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4582 "" /* defined at init */);
4584 cmdline_parse_inst_t cmd_set_fwd_mode = {
4585 .f = cmd_set_fwd_mode_parsed,
4587 .help_str = NULL, /* defined at init */
4589 (void *)&cmd_setfwd_set,
4590 (void *)&cmd_setfwd_fwd,
4591 (void *)&cmd_setfwd_mode,
4596 static void cmd_set_fwd_mode_init(void)
4599 static char token[128];
4600 static char help[256];
4601 cmdline_parse_token_string_t *token_struct;
4603 modes = list_pkt_forwarding_modes();
4604 snprintf(help, sizeof help, "set fwd %s - "
4605 "set packet forwarding mode", modes);
4606 cmd_set_fwd_mode.help_str = help;
4608 /* string token separator is # */
4609 for (c = token; *modes != '\0'; modes++)
4614 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4615 token_struct->string_data.str = token;
4618 /* *** SET RETRY FORWARDING MODE *** */
4619 struct cmd_set_fwd_retry_mode_result {
4620 cmdline_fixed_string_t set;
4621 cmdline_fixed_string_t fwd;
4622 cmdline_fixed_string_t mode;
4623 cmdline_fixed_string_t retry;
4626 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4627 __attribute__((unused)) struct cmdline *cl,
4628 __attribute__((unused)) void *data)
4630 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4633 set_pkt_forwarding_mode(res->mode);
4636 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4637 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4639 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4640 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4642 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4643 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4645 "" /* defined at init */);
4646 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4647 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4650 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4651 .f = cmd_set_fwd_retry_mode_parsed,
4653 .help_str = NULL, /* defined at init */
4655 (void *)&cmd_setfwd_retry_set,
4656 (void *)&cmd_setfwd_retry_fwd,
4657 (void *)&cmd_setfwd_retry_mode,
4658 (void *)&cmd_setfwd_retry_retry,
4663 static void cmd_set_fwd_retry_mode_init(void)
4666 static char token[128];
4667 static char help[256];
4668 cmdline_parse_token_string_t *token_struct;
4670 modes = list_pkt_forwarding_retry_modes();
4671 snprintf(help, sizeof(help), "set fwd %s retry - "
4672 "set packet forwarding mode with retry", modes);
4673 cmd_set_fwd_retry_mode.help_str = help;
4675 /* string token separator is # */
4676 for (c = token; *modes != '\0'; modes++)
4681 token_struct = (cmdline_parse_token_string_t *)
4682 cmd_set_fwd_retry_mode.tokens[2];
4683 token_struct->string_data.str = token;
4686 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4687 struct cmd_set_burst_tx_retry_result {
4688 cmdline_fixed_string_t set;
4689 cmdline_fixed_string_t burst;
4690 cmdline_fixed_string_t tx;
4691 cmdline_fixed_string_t delay;
4693 cmdline_fixed_string_t retry;
4697 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4698 __attribute__((unused)) struct cmdline *cl,
4699 __attribute__((unused)) void *data)
4701 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4703 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4704 && !strcmp(res->tx, "tx")) {
4705 if (!strcmp(res->delay, "delay"))
4706 burst_tx_delay_time = res->time;
4707 if (!strcmp(res->retry, "retry"))
4708 burst_tx_retry_num = res->retry_num;
4713 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4714 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4715 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4716 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4718 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4719 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4720 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4721 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4722 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4723 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4724 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4725 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4726 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4727 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4729 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4730 .f = cmd_set_burst_tx_retry_parsed,
4731 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4733 (void *)&cmd_set_burst_tx_retry_set,
4734 (void *)&cmd_set_burst_tx_retry_burst,
4735 (void *)&cmd_set_burst_tx_retry_tx,
4736 (void *)&cmd_set_burst_tx_retry_delay,
4737 (void *)&cmd_set_burst_tx_retry_time,
4738 (void *)&cmd_set_burst_tx_retry_retry,
4739 (void *)&cmd_set_burst_tx_retry_retry_num,
4744 /* *** SET PROMISC MODE *** */
4745 struct cmd_set_promisc_mode_result {
4746 cmdline_fixed_string_t set;
4747 cmdline_fixed_string_t promisc;
4748 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4749 uint8_t port_num; /* valid if "allports" argument == 0 */
4750 cmdline_fixed_string_t mode;
4753 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4754 __attribute__((unused)) struct cmdline *cl,
4757 struct cmd_set_promisc_mode_result *res = parsed_result;
4761 if (!strcmp(res->mode, "on"))
4768 FOREACH_PORT(i, ports) {
4770 rte_eth_promiscuous_enable(i);
4772 rte_eth_promiscuous_disable(i);
4777 rte_eth_promiscuous_enable(res->port_num);
4779 rte_eth_promiscuous_disable(res->port_num);
4783 cmdline_parse_token_string_t cmd_setpromisc_set =
4784 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4785 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4786 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4788 cmdline_parse_token_string_t cmd_setpromisc_portall =
4789 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4791 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4792 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4794 cmdline_parse_token_string_t cmd_setpromisc_mode =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4798 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4799 .f = cmd_set_promisc_mode_parsed,
4801 .help_str = "set promisc all on|off: set promisc mode for all ports",
4803 (void *)&cmd_setpromisc_set,
4804 (void *)&cmd_setpromisc_promisc,
4805 (void *)&cmd_setpromisc_portall,
4806 (void *)&cmd_setpromisc_mode,
4811 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4812 .f = cmd_set_promisc_mode_parsed,
4814 .help_str = "set promisc X on|off: set promisc mode on port X",
4816 (void *)&cmd_setpromisc_set,
4817 (void *)&cmd_setpromisc_promisc,
4818 (void *)&cmd_setpromisc_portnum,
4819 (void *)&cmd_setpromisc_mode,
4824 /* *** SET ALLMULTI MODE *** */
4825 struct cmd_set_allmulti_mode_result {
4826 cmdline_fixed_string_t set;
4827 cmdline_fixed_string_t allmulti;
4828 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4829 uint8_t port_num; /* valid if "allports" argument == 0 */
4830 cmdline_fixed_string_t mode;
4833 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4834 __attribute__((unused)) struct cmdline *cl,
4837 struct cmd_set_allmulti_mode_result *res = parsed_result;
4841 if (!strcmp(res->mode, "on"))
4848 FOREACH_PORT(i, ports) {
4850 rte_eth_allmulticast_enable(i);
4852 rte_eth_allmulticast_disable(i);
4857 rte_eth_allmulticast_enable(res->port_num);
4859 rte_eth_allmulticast_disable(res->port_num);
4863 cmdline_parse_token_string_t cmd_setallmulti_set =
4864 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4865 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4866 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4868 cmdline_parse_token_string_t cmd_setallmulti_portall =
4869 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4871 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4872 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4874 cmdline_parse_token_string_t cmd_setallmulti_mode =
4875 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4878 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4879 .f = cmd_set_allmulti_mode_parsed,
4881 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4883 (void *)&cmd_setallmulti_set,
4884 (void *)&cmd_setallmulti_allmulti,
4885 (void *)&cmd_setallmulti_portall,
4886 (void *)&cmd_setallmulti_mode,
4891 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4892 .f = cmd_set_allmulti_mode_parsed,
4894 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4896 (void *)&cmd_setallmulti_set,
4897 (void *)&cmd_setallmulti_allmulti,
4898 (void *)&cmd_setallmulti_portnum,
4899 (void *)&cmd_setallmulti_mode,
4904 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4905 struct cmd_link_flow_ctrl_set_result {
4906 cmdline_fixed_string_t set;
4907 cmdline_fixed_string_t flow_ctrl;
4908 cmdline_fixed_string_t rx;
4909 cmdline_fixed_string_t rx_lfc_mode;
4910 cmdline_fixed_string_t tx;
4911 cmdline_fixed_string_t tx_lfc_mode;
4912 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4913 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4914 cmdline_fixed_string_t autoneg_str;
4915 cmdline_fixed_string_t autoneg;
4916 cmdline_fixed_string_t hw_str;
4917 uint32_t high_water;
4918 cmdline_fixed_string_t lw_str;
4920 cmdline_fixed_string_t pt_str;
4921 uint16_t pause_time;
4922 cmdline_fixed_string_t xon_str;
4927 cmdline_parse_token_string_t cmd_lfc_set_set =
4928 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4930 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4931 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4932 flow_ctrl, "flow_ctrl");
4933 cmdline_parse_token_string_t cmd_lfc_set_rx =
4934 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4936 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4937 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4938 rx_lfc_mode, "on#off");
4939 cmdline_parse_token_string_t cmd_lfc_set_tx =
4940 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4942 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4943 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4944 tx_lfc_mode, "on#off");
4945 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4946 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4947 hw_str, "high_water");
4948 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4949 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4950 high_water, UINT32);
4951 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4952 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4953 lw_str, "low_water");
4954 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4955 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4957 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4958 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4959 pt_str, "pause_time");
4960 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4961 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4962 pause_time, UINT16);
4963 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4964 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4965 xon_str, "send_xon");
4966 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4967 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4969 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4970 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4971 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4972 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4973 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4974 mac_ctrl_frame_fwd_mode, "on#off");
4975 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4976 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4977 autoneg_str, "autoneg");
4978 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4979 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4981 cmdline_parse_token_num_t cmd_lfc_set_portid =
4982 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4985 /* forward declaration */
4987 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4990 cmdline_parse_inst_t cmd_link_flow_control_set = {
4991 .f = cmd_link_flow_ctrl_set_parsed,
4993 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4994 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4995 autoneg on|off port_id",
4997 (void *)&cmd_lfc_set_set,
4998 (void *)&cmd_lfc_set_flow_ctrl,
4999 (void *)&cmd_lfc_set_rx,
5000 (void *)&cmd_lfc_set_rx_mode,
5001 (void *)&cmd_lfc_set_tx,
5002 (void *)&cmd_lfc_set_tx_mode,
5003 (void *)&cmd_lfc_set_high_water,
5004 (void *)&cmd_lfc_set_low_water,
5005 (void *)&cmd_lfc_set_pause_time,
5006 (void *)&cmd_lfc_set_send_xon,
5007 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5008 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5009 (void *)&cmd_lfc_set_autoneg_str,
5010 (void *)&cmd_lfc_set_autoneg,
5011 (void *)&cmd_lfc_set_portid,
5016 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5017 .f = cmd_link_flow_ctrl_set_parsed,
5018 .data = (void *)&cmd_link_flow_control_set_rx,
5019 .help_str = "Change rx flow control parameter: set flow_ctrl "
5020 "rx on|off port_id",
5022 (void *)&cmd_lfc_set_set,
5023 (void *)&cmd_lfc_set_flow_ctrl,
5024 (void *)&cmd_lfc_set_rx,
5025 (void *)&cmd_lfc_set_rx_mode,
5026 (void *)&cmd_lfc_set_portid,
5031 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5032 .f = cmd_link_flow_ctrl_set_parsed,
5033 .data = (void *)&cmd_link_flow_control_set_tx,
5034 .help_str = "Change tx flow control parameter: set flow_ctrl "
5035 "tx on|off port_id",
5037 (void *)&cmd_lfc_set_set,
5038 (void *)&cmd_lfc_set_flow_ctrl,
5039 (void *)&cmd_lfc_set_tx,
5040 (void *)&cmd_lfc_set_tx_mode,
5041 (void *)&cmd_lfc_set_portid,
5046 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5047 .f = cmd_link_flow_ctrl_set_parsed,
5048 .data = (void *)&cmd_link_flow_control_set_hw,
5049 .help_str = "Change high water flow control parameter: set flow_ctrl "
5050 "high_water value port_id",
5052 (void *)&cmd_lfc_set_set,
5053 (void *)&cmd_lfc_set_flow_ctrl,
5054 (void *)&cmd_lfc_set_high_water_str,
5055 (void *)&cmd_lfc_set_high_water,
5056 (void *)&cmd_lfc_set_portid,
5061 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5062 .f = cmd_link_flow_ctrl_set_parsed,
5063 .data = (void *)&cmd_link_flow_control_set_lw,
5064 .help_str = "Change low water flow control parameter: set flow_ctrl "
5065 "low_water value port_id",
5067 (void *)&cmd_lfc_set_set,
5068 (void *)&cmd_lfc_set_flow_ctrl,
5069 (void *)&cmd_lfc_set_low_water_str,
5070 (void *)&cmd_lfc_set_low_water,
5071 (void *)&cmd_lfc_set_portid,
5076 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5077 .f = cmd_link_flow_ctrl_set_parsed,
5078 .data = (void *)&cmd_link_flow_control_set_pt,
5079 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5080 "pause_time value port_id",
5082 (void *)&cmd_lfc_set_set,
5083 (void *)&cmd_lfc_set_flow_ctrl,
5084 (void *)&cmd_lfc_set_pause_time_str,
5085 (void *)&cmd_lfc_set_pause_time,
5086 (void *)&cmd_lfc_set_portid,
5091 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5092 .f = cmd_link_flow_ctrl_set_parsed,
5093 .data = (void *)&cmd_link_flow_control_set_xon,
5094 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5095 "send_xon value port_id",
5097 (void *)&cmd_lfc_set_set,
5098 (void *)&cmd_lfc_set_flow_ctrl,
5099 (void *)&cmd_lfc_set_send_xon_str,
5100 (void *)&cmd_lfc_set_send_xon,
5101 (void *)&cmd_lfc_set_portid,
5106 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5107 .f = cmd_link_flow_ctrl_set_parsed,
5108 .data = (void *)&cmd_link_flow_control_set_macfwd,
5109 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5110 "mac_ctrl_frame_fwd on|off port_id",
5112 (void *)&cmd_lfc_set_set,
5113 (void *)&cmd_lfc_set_flow_ctrl,
5114 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5115 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5116 (void *)&cmd_lfc_set_portid,
5121 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5122 .f = cmd_link_flow_ctrl_set_parsed,
5123 .data = (void *)&cmd_link_flow_control_set_autoneg,
5124 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5125 "autoneg on|off port_id",
5127 (void *)&cmd_lfc_set_set,
5128 (void *)&cmd_lfc_set_flow_ctrl,
5129 (void *)&cmd_lfc_set_autoneg_str,
5130 (void *)&cmd_lfc_set_autoneg,
5131 (void *)&cmd_lfc_set_portid,
5137 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5138 __attribute__((unused)) struct cmdline *cl,
5141 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5142 cmdline_parse_inst_t *cmd = data;
5143 struct rte_eth_fc_conf fc_conf;
5149 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5150 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5151 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5152 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5154 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5155 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5158 /* Partial command line, retrieve current configuration */
5160 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5162 printf("cannot get current flow ctrl parameters, return"
5163 "code = %d\n", ret);
5167 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5168 (fc_conf.mode == RTE_FC_FULL))
5170 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5171 (fc_conf.mode == RTE_FC_FULL))
5175 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5176 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5178 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5179 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5181 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5183 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5184 fc_conf.high_water = res->high_water;
5186 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5187 fc_conf.low_water = res->low_water;
5189 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5190 fc_conf.pause_time = res->pause_time;
5192 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5193 fc_conf.send_xon = res->send_xon;
5195 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5196 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5197 fc_conf.mac_ctrl_frame_fwd = 1;
5199 fc_conf.mac_ctrl_frame_fwd = 0;
5202 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5203 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5205 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5207 printf("bad flow contrl parameter, return code = %d \n", ret);
5210 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5211 struct cmd_priority_flow_ctrl_set_result {
5212 cmdline_fixed_string_t set;
5213 cmdline_fixed_string_t pfc_ctrl;
5214 cmdline_fixed_string_t rx;
5215 cmdline_fixed_string_t rx_pfc_mode;
5216 cmdline_fixed_string_t tx;
5217 cmdline_fixed_string_t tx_pfc_mode;
5218 uint32_t high_water;
5220 uint16_t pause_time;
5226 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5227 __attribute__((unused)) struct cmdline *cl,
5228 __attribute__((unused)) void *data)
5230 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5231 struct rte_eth_pfc_conf pfc_conf;
5232 int rx_fc_enable, tx_fc_enable;
5236 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5237 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5238 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5239 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5241 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5242 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5245 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5246 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5247 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5248 pfc_conf.fc.high_water = res->high_water;
5249 pfc_conf.fc.low_water = res->low_water;
5250 pfc_conf.fc.pause_time = res->pause_time;
5251 pfc_conf.priority = res->priority;
5253 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5255 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5258 cmdline_parse_token_string_t cmd_pfc_set_set =
5259 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5261 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5262 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5263 pfc_ctrl, "pfc_ctrl");
5264 cmdline_parse_token_string_t cmd_pfc_set_rx =
5265 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5267 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5268 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5269 rx_pfc_mode, "on#off");
5270 cmdline_parse_token_string_t cmd_pfc_set_tx =
5271 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5273 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5274 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5275 tx_pfc_mode, "on#off");
5276 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5277 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5278 high_water, UINT32);
5279 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5280 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5282 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5283 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5284 pause_time, UINT16);
5285 cmdline_parse_token_num_t cmd_pfc_set_priority =
5286 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5288 cmdline_parse_token_num_t cmd_pfc_set_portid =
5289 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5292 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5293 .f = cmd_priority_flow_ctrl_set_parsed,
5295 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5296 tx on|off high_water low_water pause_time priority port_id",
5298 (void *)&cmd_pfc_set_set,
5299 (void *)&cmd_pfc_set_flow_ctrl,
5300 (void *)&cmd_pfc_set_rx,
5301 (void *)&cmd_pfc_set_rx_mode,
5302 (void *)&cmd_pfc_set_tx,
5303 (void *)&cmd_pfc_set_tx_mode,
5304 (void *)&cmd_pfc_set_high_water,
5305 (void *)&cmd_pfc_set_low_water,
5306 (void *)&cmd_pfc_set_pause_time,
5307 (void *)&cmd_pfc_set_priority,
5308 (void *)&cmd_pfc_set_portid,
5313 /* *** RESET CONFIGURATION *** */
5314 struct cmd_reset_result {
5315 cmdline_fixed_string_t reset;
5316 cmdline_fixed_string_t def;
5319 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5321 __attribute__((unused)) void *data)
5323 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5324 set_def_fwd_config();
5327 cmdline_parse_token_string_t cmd_reset_set =
5328 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5329 cmdline_parse_token_string_t cmd_reset_def =
5330 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5333 cmdline_parse_inst_t cmd_reset = {
5334 .f = cmd_reset_parsed,
5336 .help_str = "set default: reset default forwarding configuration",
5338 (void *)&cmd_reset_set,
5339 (void *)&cmd_reset_def,
5344 /* *** START FORWARDING *** */
5345 struct cmd_start_result {
5346 cmdline_fixed_string_t start;
5349 cmdline_parse_token_string_t cmd_start_start =
5350 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5352 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5353 __attribute__((unused)) struct cmdline *cl,
5354 __attribute__((unused)) void *data)
5356 start_packet_forwarding(0);
5359 cmdline_parse_inst_t cmd_start = {
5360 .f = cmd_start_parsed,
5362 .help_str = "start packet forwarding",
5364 (void *)&cmd_start_start,
5369 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5370 struct cmd_start_tx_first_result {
5371 cmdline_fixed_string_t start;
5372 cmdline_fixed_string_t tx_first;
5376 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5377 __attribute__((unused)) struct cmdline *cl,
5378 __attribute__((unused)) void *data)
5380 start_packet_forwarding(1);
5383 cmdline_parse_token_string_t cmd_start_tx_first_start =
5384 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5386 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5387 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5388 tx_first, "tx_first");
5390 cmdline_parse_inst_t cmd_start_tx_first = {
5391 .f = cmd_start_tx_first_parsed,
5393 .help_str = "start packet forwarding, after sending 1 burst of packets",
5395 (void *)&cmd_start_tx_first_start,
5396 (void *)&cmd_start_tx_first_tx_first,
5401 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5402 struct cmd_start_tx_first_n_result {
5403 cmdline_fixed_string_t start;
5404 cmdline_fixed_string_t tx_first;
5409 cmd_start_tx_first_n_parsed(void *parsed_result,
5410 __attribute__((unused)) struct cmdline *cl,
5411 __attribute__((unused)) void *data)
5413 struct cmd_start_tx_first_n_result *res = parsed_result;
5415 start_packet_forwarding(res->tx_num);
5418 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5419 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5421 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5422 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5423 tx_first, "tx_first");
5424 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5425 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5428 cmdline_parse_inst_t cmd_start_tx_first_n = {
5429 .f = cmd_start_tx_first_n_parsed,
5431 .help_str = "start packet forwarding, after sending <num> "
5432 "bursts of packets",
5434 (void *)&cmd_start_tx_first_n_start,
5435 (void *)&cmd_start_tx_first_n_tx_first,
5436 (void *)&cmd_start_tx_first_n_tx_num,
5441 /* *** SET LINK UP *** */
5442 struct cmd_set_link_up_result {
5443 cmdline_fixed_string_t set;
5444 cmdline_fixed_string_t link_up;
5445 cmdline_fixed_string_t port;
5449 cmdline_parse_token_string_t cmd_set_link_up_set =
5450 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5451 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5454 cmdline_parse_token_string_t cmd_set_link_up_port =
5455 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5456 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5457 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5459 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5460 __attribute__((unused)) struct cmdline *cl,
5461 __attribute__((unused)) void *data)
5463 struct cmd_set_link_up_result *res = parsed_result;
5464 dev_set_link_up(res->port_id);
5467 cmdline_parse_inst_t cmd_set_link_up = {
5468 .f = cmd_set_link_up_parsed,
5470 .help_str = "set link-up port (port id)",
5472 (void *)&cmd_set_link_up_set,
5473 (void *)&cmd_set_link_up_link_up,
5474 (void *)&cmd_set_link_up_port,
5475 (void *)&cmd_set_link_up_port_id,
5480 /* *** SET LINK DOWN *** */
5481 struct cmd_set_link_down_result {
5482 cmdline_fixed_string_t set;
5483 cmdline_fixed_string_t link_down;
5484 cmdline_fixed_string_t port;
5488 cmdline_parse_token_string_t cmd_set_link_down_set =
5489 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5490 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5491 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5493 cmdline_parse_token_string_t cmd_set_link_down_port =
5494 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5495 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5496 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5498 static void cmd_set_link_down_parsed(
5499 __attribute__((unused)) void *parsed_result,
5500 __attribute__((unused)) struct cmdline *cl,
5501 __attribute__((unused)) void *data)
5503 struct cmd_set_link_down_result *res = parsed_result;
5504 dev_set_link_down(res->port_id);
5507 cmdline_parse_inst_t cmd_set_link_down = {
5508 .f = cmd_set_link_down_parsed,
5510 .help_str = "set link-down port (port id)",
5512 (void *)&cmd_set_link_down_set,
5513 (void *)&cmd_set_link_down_link_down,
5514 (void *)&cmd_set_link_down_port,
5515 (void *)&cmd_set_link_down_port_id,
5520 /* *** SHOW CFG *** */
5521 struct cmd_showcfg_result {
5522 cmdline_fixed_string_t show;
5523 cmdline_fixed_string_t cfg;
5524 cmdline_fixed_string_t what;
5527 static void cmd_showcfg_parsed(void *parsed_result,
5528 __attribute__((unused)) struct cmdline *cl,
5529 __attribute__((unused)) void *data)
5531 struct cmd_showcfg_result *res = parsed_result;
5532 if (!strcmp(res->what, "rxtx"))
5533 rxtx_config_display();
5534 else if (!strcmp(res->what, "cores"))
5535 fwd_lcores_config_display();
5536 else if (!strcmp(res->what, "fwd"))
5537 pkt_fwd_config_display(&cur_fwd_config);
5538 else if (!strcmp(res->what, "txpkts"))
5539 show_tx_pkt_segments();
5542 cmdline_parse_token_string_t cmd_showcfg_show =
5543 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5544 cmdline_parse_token_string_t cmd_showcfg_port =
5545 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5546 cmdline_parse_token_string_t cmd_showcfg_what =
5547 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5548 "rxtx#cores#fwd#txpkts");
5550 cmdline_parse_inst_t cmd_showcfg = {
5551 .f = cmd_showcfg_parsed,
5553 .help_str = "show config rxtx|cores|fwd|txpkts",
5555 (void *)&cmd_showcfg_show,
5556 (void *)&cmd_showcfg_port,
5557 (void *)&cmd_showcfg_what,
5562 /* *** SHOW ALL PORT INFO *** */
5563 struct cmd_showportall_result {
5564 cmdline_fixed_string_t show;
5565 cmdline_fixed_string_t port;
5566 cmdline_fixed_string_t what;
5567 cmdline_fixed_string_t all;
5570 static void cmd_showportall_parsed(void *parsed_result,
5571 __attribute__((unused)) struct cmdline *cl,
5572 __attribute__((unused)) void *data)
5576 struct cmd_showportall_result *res = parsed_result;
5577 if (!strcmp(res->show, "clear")) {
5578 if (!strcmp(res->what, "stats"))
5579 FOREACH_PORT(i, ports)
5581 else if (!strcmp(res->what, "xstats"))
5582 FOREACH_PORT(i, ports)
5583 nic_xstats_clear(i);
5584 } else if (!strcmp(res->what, "info"))
5585 FOREACH_PORT(i, ports)
5586 port_infos_display(i);
5587 else if (!strcmp(res->what, "stats"))
5588 FOREACH_PORT(i, ports)
5589 nic_stats_display(i);
5590 else if (!strcmp(res->what, "xstats"))
5591 FOREACH_PORT(i, ports)
5592 nic_xstats_display(i);
5593 else if (!strcmp(res->what, "fdir"))
5594 FOREACH_PORT(i, ports)
5596 else if (!strcmp(res->what, "stat_qmap"))
5597 FOREACH_PORT(i, ports)
5598 nic_stats_mapping_display(i);
5599 else if (!strcmp(res->what, "dcb_tc"))
5600 FOREACH_PORT(i, ports)
5601 port_dcb_info_display(i);
5604 cmdline_parse_token_string_t cmd_showportall_show =
5605 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5607 cmdline_parse_token_string_t cmd_showportall_port =
5608 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5609 cmdline_parse_token_string_t cmd_showportall_what =
5610 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5611 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5612 cmdline_parse_token_string_t cmd_showportall_all =
5613 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5614 cmdline_parse_inst_t cmd_showportall = {
5615 .f = cmd_showportall_parsed,
5617 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5619 (void *)&cmd_showportall_show,
5620 (void *)&cmd_showportall_port,
5621 (void *)&cmd_showportall_what,
5622 (void *)&cmd_showportall_all,
5627 /* *** SHOW PORT INFO *** */
5628 struct cmd_showport_result {
5629 cmdline_fixed_string_t show;
5630 cmdline_fixed_string_t port;
5631 cmdline_fixed_string_t what;
5635 static void cmd_showport_parsed(void *parsed_result,
5636 __attribute__((unused)) struct cmdline *cl,
5637 __attribute__((unused)) void *data)
5639 struct cmd_showport_result *res = parsed_result;
5640 if (!strcmp(res->show, "clear")) {
5641 if (!strcmp(res->what, "stats"))
5642 nic_stats_clear(res->portnum);
5643 else if (!strcmp(res->what, "xstats"))
5644 nic_xstats_clear(res->portnum);
5645 } else if (!strcmp(res->what, "info"))
5646 port_infos_display(res->portnum);
5647 else if (!strcmp(res->what, "stats"))
5648 nic_stats_display(res->portnum);
5649 else if (!strcmp(res->what, "xstats"))
5650 nic_xstats_display(res->portnum);
5651 else if (!strcmp(res->what, "fdir"))
5652 fdir_get_infos(res->portnum);
5653 else if (!strcmp(res->what, "stat_qmap"))
5654 nic_stats_mapping_display(res->portnum);
5655 else if (!strcmp(res->what, "dcb_tc"))
5656 port_dcb_info_display(res->portnum);
5659 cmdline_parse_token_string_t cmd_showport_show =
5660 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5662 cmdline_parse_token_string_t cmd_showport_port =
5663 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5664 cmdline_parse_token_string_t cmd_showport_what =
5665 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5666 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5667 cmdline_parse_token_num_t cmd_showport_portnum =
5668 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5670 cmdline_parse_inst_t cmd_showport = {
5671 .f = cmd_showport_parsed,
5673 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5675 (void *)&cmd_showport_show,
5676 (void *)&cmd_showport_port,
5677 (void *)&cmd_showport_what,
5678 (void *)&cmd_showport_portnum,
5683 /* *** SHOW QUEUE INFO *** */
5684 struct cmd_showqueue_result {
5685 cmdline_fixed_string_t show;
5686 cmdline_fixed_string_t type;
5687 cmdline_fixed_string_t what;
5693 cmd_showqueue_parsed(void *parsed_result,
5694 __attribute__((unused)) struct cmdline *cl,
5695 __attribute__((unused)) void *data)
5697 struct cmd_showqueue_result *res = parsed_result;
5699 if (!strcmp(res->type, "rxq"))
5700 rx_queue_infos_display(res->portnum, res->queuenum);
5701 else if (!strcmp(res->type, "txq"))
5702 tx_queue_infos_display(res->portnum, res->queuenum);
5705 cmdline_parse_token_string_t cmd_showqueue_show =
5706 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5707 cmdline_parse_token_string_t cmd_showqueue_type =
5708 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5709 cmdline_parse_token_string_t cmd_showqueue_what =
5710 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5711 cmdline_parse_token_num_t cmd_showqueue_portnum =
5712 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5713 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5714 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5716 cmdline_parse_inst_t cmd_showqueue = {
5717 .f = cmd_showqueue_parsed,
5719 .help_str = "show rxq|txq info <port number> <queue_number>",
5721 (void *)&cmd_showqueue_show,
5722 (void *)&cmd_showqueue_type,
5723 (void *)&cmd_showqueue_what,
5724 (void *)&cmd_showqueue_portnum,
5725 (void *)&cmd_showqueue_queuenum,
5730 /* *** READ PORT REGISTER *** */
5731 struct cmd_read_reg_result {
5732 cmdline_fixed_string_t read;
5733 cmdline_fixed_string_t reg;
5739 cmd_read_reg_parsed(void *parsed_result,
5740 __attribute__((unused)) struct cmdline *cl,
5741 __attribute__((unused)) void *data)
5743 struct cmd_read_reg_result *res = parsed_result;
5744 port_reg_display(res->port_id, res->reg_off);
5747 cmdline_parse_token_string_t cmd_read_reg_read =
5748 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5749 cmdline_parse_token_string_t cmd_read_reg_reg =
5750 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5751 cmdline_parse_token_num_t cmd_read_reg_port_id =
5752 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5753 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5754 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5756 cmdline_parse_inst_t cmd_read_reg = {
5757 .f = cmd_read_reg_parsed,
5759 .help_str = "read reg port_id reg_off",
5761 (void *)&cmd_read_reg_read,
5762 (void *)&cmd_read_reg_reg,
5763 (void *)&cmd_read_reg_port_id,
5764 (void *)&cmd_read_reg_reg_off,
5769 /* *** READ PORT REGISTER BIT FIELD *** */
5770 struct cmd_read_reg_bit_field_result {
5771 cmdline_fixed_string_t read;
5772 cmdline_fixed_string_t regfield;
5780 cmd_read_reg_bit_field_parsed(void *parsed_result,
5781 __attribute__((unused)) struct cmdline *cl,
5782 __attribute__((unused)) void *data)
5784 struct cmd_read_reg_bit_field_result *res = parsed_result;
5785 port_reg_bit_field_display(res->port_id, res->reg_off,
5786 res->bit1_pos, res->bit2_pos);
5789 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5790 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5792 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5793 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5794 regfield, "regfield");
5795 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5796 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5798 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5799 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5801 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5802 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5804 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5805 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5808 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5809 .f = cmd_read_reg_bit_field_parsed,
5811 .help_str = "read regfield port_id reg_off bit_x bit_y "
5812 "(read register bit field between bit_x and bit_y included)",
5814 (void *)&cmd_read_reg_bit_field_read,
5815 (void *)&cmd_read_reg_bit_field_regfield,
5816 (void *)&cmd_read_reg_bit_field_port_id,
5817 (void *)&cmd_read_reg_bit_field_reg_off,
5818 (void *)&cmd_read_reg_bit_field_bit1_pos,
5819 (void *)&cmd_read_reg_bit_field_bit2_pos,
5824 /* *** READ PORT REGISTER BIT *** */
5825 struct cmd_read_reg_bit_result {
5826 cmdline_fixed_string_t read;
5827 cmdline_fixed_string_t regbit;
5834 cmd_read_reg_bit_parsed(void *parsed_result,
5835 __attribute__((unused)) struct cmdline *cl,
5836 __attribute__((unused)) void *data)
5838 struct cmd_read_reg_bit_result *res = parsed_result;
5839 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5842 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5843 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5844 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5845 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5847 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5848 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5849 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5851 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5852 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5854 cmdline_parse_inst_t cmd_read_reg_bit = {
5855 .f = cmd_read_reg_bit_parsed,
5857 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5859 (void *)&cmd_read_reg_bit_read,
5860 (void *)&cmd_read_reg_bit_regbit,
5861 (void *)&cmd_read_reg_bit_port_id,
5862 (void *)&cmd_read_reg_bit_reg_off,
5863 (void *)&cmd_read_reg_bit_bit_pos,
5868 /* *** WRITE PORT REGISTER *** */
5869 struct cmd_write_reg_result {
5870 cmdline_fixed_string_t write;
5871 cmdline_fixed_string_t reg;
5878 cmd_write_reg_parsed(void *parsed_result,
5879 __attribute__((unused)) struct cmdline *cl,
5880 __attribute__((unused)) void *data)
5882 struct cmd_write_reg_result *res = parsed_result;
5883 port_reg_set(res->port_id, res->reg_off, res->value);
5886 cmdline_parse_token_string_t cmd_write_reg_write =
5887 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5888 cmdline_parse_token_string_t cmd_write_reg_reg =
5889 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5890 cmdline_parse_token_num_t cmd_write_reg_port_id =
5891 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5892 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5893 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5894 cmdline_parse_token_num_t cmd_write_reg_value =
5895 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5897 cmdline_parse_inst_t cmd_write_reg = {
5898 .f = cmd_write_reg_parsed,
5900 .help_str = "write reg port_id reg_off reg_value",
5902 (void *)&cmd_write_reg_write,
5903 (void *)&cmd_write_reg_reg,
5904 (void *)&cmd_write_reg_port_id,
5905 (void *)&cmd_write_reg_reg_off,
5906 (void *)&cmd_write_reg_value,
5911 /* *** WRITE PORT REGISTER BIT FIELD *** */
5912 struct cmd_write_reg_bit_field_result {
5913 cmdline_fixed_string_t write;
5914 cmdline_fixed_string_t regfield;
5923 cmd_write_reg_bit_field_parsed(void *parsed_result,
5924 __attribute__((unused)) struct cmdline *cl,
5925 __attribute__((unused)) void *data)
5927 struct cmd_write_reg_bit_field_result *res = parsed_result;
5928 port_reg_bit_field_set(res->port_id, res->reg_off,
5929 res->bit1_pos, res->bit2_pos, res->value);
5932 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5933 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5935 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5936 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5937 regfield, "regfield");
5938 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5939 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5941 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5942 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5944 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5945 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5947 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5948 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5950 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5951 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5954 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5955 .f = cmd_write_reg_bit_field_parsed,
5957 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5958 "(set register bit field between bit_x and bit_y included)",
5960 (void *)&cmd_write_reg_bit_field_write,
5961 (void *)&cmd_write_reg_bit_field_regfield,
5962 (void *)&cmd_write_reg_bit_field_port_id,
5963 (void *)&cmd_write_reg_bit_field_reg_off,
5964 (void *)&cmd_write_reg_bit_field_bit1_pos,
5965 (void *)&cmd_write_reg_bit_field_bit2_pos,
5966 (void *)&cmd_write_reg_bit_field_value,
5971 /* *** WRITE PORT REGISTER BIT *** */
5972 struct cmd_write_reg_bit_result {
5973 cmdline_fixed_string_t write;
5974 cmdline_fixed_string_t regbit;
5982 cmd_write_reg_bit_parsed(void *parsed_result,
5983 __attribute__((unused)) struct cmdline *cl,
5984 __attribute__((unused)) void *data)
5986 struct cmd_write_reg_bit_result *res = parsed_result;
5987 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5990 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5991 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5993 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5994 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5996 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5997 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5998 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6000 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6001 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6002 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6003 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6005 cmdline_parse_inst_t cmd_write_reg_bit = {
6006 .f = cmd_write_reg_bit_parsed,
6008 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
6010 (void *)&cmd_write_reg_bit_write,
6011 (void *)&cmd_write_reg_bit_regbit,
6012 (void *)&cmd_write_reg_bit_port_id,
6013 (void *)&cmd_write_reg_bit_reg_off,
6014 (void *)&cmd_write_reg_bit_bit_pos,
6015 (void *)&cmd_write_reg_bit_value,
6020 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6021 struct cmd_read_rxd_txd_result {
6022 cmdline_fixed_string_t read;
6023 cmdline_fixed_string_t rxd_txd;
6030 cmd_read_rxd_txd_parsed(void *parsed_result,
6031 __attribute__((unused)) struct cmdline *cl,
6032 __attribute__((unused)) void *data)
6034 struct cmd_read_rxd_txd_result *res = parsed_result;
6036 if (!strcmp(res->rxd_txd, "rxd"))
6037 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6038 else if (!strcmp(res->rxd_txd, "txd"))
6039 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6042 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6043 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6044 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6045 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6047 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6048 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6049 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6050 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6051 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6052 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6054 cmdline_parse_inst_t cmd_read_rxd_txd = {
6055 .f = cmd_read_rxd_txd_parsed,
6057 .help_str = "read rxd|txd port_id queue_id rxd_id",
6059 (void *)&cmd_read_rxd_txd_read,
6060 (void *)&cmd_read_rxd_txd_rxd_txd,
6061 (void *)&cmd_read_rxd_txd_port_id,
6062 (void *)&cmd_read_rxd_txd_queue_id,
6063 (void *)&cmd_read_rxd_txd_desc_id,
6069 struct cmd_quit_result {
6070 cmdline_fixed_string_t quit;
6073 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6075 __attribute__((unused)) void *data)
6081 cmdline_parse_token_string_t cmd_quit_quit =
6082 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6084 cmdline_parse_inst_t cmd_quit = {
6085 .f = cmd_quit_parsed,
6087 .help_str = "exit application",
6089 (void *)&cmd_quit_quit,
6094 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6095 struct cmd_mac_addr_result {
6096 cmdline_fixed_string_t mac_addr_cmd;
6097 cmdline_fixed_string_t what;
6099 struct ether_addr address;
6102 static void cmd_mac_addr_parsed(void *parsed_result,
6103 __attribute__((unused)) struct cmdline *cl,
6104 __attribute__((unused)) void *data)
6106 struct cmd_mac_addr_result *res = parsed_result;
6109 if (strcmp(res->what, "add") == 0)
6110 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6112 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6114 /* check the return value and print it if is < 0 */
6116 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6120 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6121 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6123 cmdline_parse_token_string_t cmd_mac_addr_what =
6124 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6126 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6127 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6128 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6129 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6131 cmdline_parse_inst_t cmd_mac_addr = {
6132 .f = cmd_mac_addr_parsed,
6134 .help_str = "mac_addr add|remove X <address>: "
6135 "add/remove MAC address on port X",
6137 (void *)&cmd_mac_addr_cmd,
6138 (void *)&cmd_mac_addr_what,
6139 (void *)&cmd_mac_addr_portnum,
6140 (void *)&cmd_mac_addr_addr,
6146 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6147 struct cmd_set_qmap_result {
6148 cmdline_fixed_string_t set;
6149 cmdline_fixed_string_t qmap;
6150 cmdline_fixed_string_t what;
6157 cmd_set_qmap_parsed(void *parsed_result,
6158 __attribute__((unused)) struct cmdline *cl,
6159 __attribute__((unused)) void *data)
6161 struct cmd_set_qmap_result *res = parsed_result;
6162 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6164 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6167 cmdline_parse_token_string_t cmd_setqmap_set =
6168 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6170 cmdline_parse_token_string_t cmd_setqmap_qmap =
6171 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6173 cmdline_parse_token_string_t cmd_setqmap_what =
6174 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6176 cmdline_parse_token_num_t cmd_setqmap_portid =
6177 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6179 cmdline_parse_token_num_t cmd_setqmap_queueid =
6180 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6182 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6183 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6186 cmdline_parse_inst_t cmd_set_qmap = {
6187 .f = cmd_set_qmap_parsed,
6189 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6191 (void *)&cmd_setqmap_set,
6192 (void *)&cmd_setqmap_qmap,
6193 (void *)&cmd_setqmap_what,
6194 (void *)&cmd_setqmap_portid,
6195 (void *)&cmd_setqmap_queueid,
6196 (void *)&cmd_setqmap_mapvalue,
6201 /* *** CONFIGURE UNICAST HASH TABLE *** */
6202 struct cmd_set_uc_hash_table {
6203 cmdline_fixed_string_t set;
6204 cmdline_fixed_string_t port;
6206 cmdline_fixed_string_t what;
6207 struct ether_addr address;
6208 cmdline_fixed_string_t mode;
6212 cmd_set_uc_hash_parsed(void *parsed_result,
6213 __attribute__((unused)) struct cmdline *cl,
6214 __attribute__((unused)) void *data)
6217 struct cmd_set_uc_hash_table *res = parsed_result;
6219 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6221 if (strcmp(res->what, "uta") == 0)
6222 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6223 &res->address,(uint8_t)is_on);
6225 printf("bad unicast hash table parameter, return code = %d \n", ret);
6229 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6230 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6232 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6233 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6235 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6236 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6238 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6239 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6241 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6244 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6245 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6248 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6249 .f = cmd_set_uc_hash_parsed,
6251 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6253 (void *)&cmd_set_uc_hash_set,
6254 (void *)&cmd_set_uc_hash_port,
6255 (void *)&cmd_set_uc_hash_portid,
6256 (void *)&cmd_set_uc_hash_what,
6257 (void *)&cmd_set_uc_hash_mac,
6258 (void *)&cmd_set_uc_hash_mode,
6263 struct cmd_set_uc_all_hash_table {
6264 cmdline_fixed_string_t set;
6265 cmdline_fixed_string_t port;
6267 cmdline_fixed_string_t what;
6268 cmdline_fixed_string_t value;
6269 cmdline_fixed_string_t mode;
6273 cmd_set_uc_all_hash_parsed(void *parsed_result,
6274 __attribute__((unused)) struct cmdline *cl,
6275 __attribute__((unused)) void *data)
6278 struct cmd_set_uc_all_hash_table *res = parsed_result;
6280 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6282 if ((strcmp(res->what, "uta") == 0) &&
6283 (strcmp(res->value, "all") == 0))
6284 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6286 printf("bad unicast hash table parameter,"
6287 "return code = %d \n", ret);
6290 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6291 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6293 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6294 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6296 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6297 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6299 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6300 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6302 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6303 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6305 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6306 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6309 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6310 .f = cmd_set_uc_all_hash_parsed,
6312 .help_str = "set port X uta all on|off (X = port number)",
6314 (void *)&cmd_set_uc_all_hash_set,
6315 (void *)&cmd_set_uc_all_hash_port,
6316 (void *)&cmd_set_uc_all_hash_portid,
6317 (void *)&cmd_set_uc_all_hash_what,
6318 (void *)&cmd_set_uc_all_hash_value,
6319 (void *)&cmd_set_uc_all_hash_mode,
6324 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6325 struct cmd_set_vf_macvlan_filter {
6326 cmdline_fixed_string_t set;
6327 cmdline_fixed_string_t port;
6329 cmdline_fixed_string_t vf;
6331 struct ether_addr address;
6332 cmdline_fixed_string_t filter_type;
6333 cmdline_fixed_string_t mode;
6337 cmd_set_vf_macvlan_parsed(void *parsed_result,
6338 __attribute__((unused)) struct cmdline *cl,
6339 __attribute__((unused)) void *data)
6342 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6343 struct rte_eth_mac_filter filter;
6345 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6347 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6349 /* set VF MAC filter */
6353 filter.dst_id = res->vf_id;
6355 if (!strcmp(res->filter_type, "exact-mac"))
6356 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6357 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6358 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6359 else if (!strcmp(res->filter_type, "hashmac"))
6360 filter.filter_type = RTE_MAC_HASH_MATCH;
6361 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6362 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6364 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6367 ret = rte_eth_dev_filter_ctrl(res->port_id,
6368 RTE_ETH_FILTER_MACVLAN,
6372 ret = rte_eth_dev_filter_ctrl(res->port_id,
6373 RTE_ETH_FILTER_MACVLAN,
6374 RTE_ETH_FILTER_DELETE,
6378 printf("bad set MAC hash parameter, return code = %d\n", ret);
6382 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6383 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6385 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6386 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6388 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6389 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6391 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6392 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6394 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6395 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6397 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6398 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6400 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6401 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6402 filter_type, "exact-mac#exact-mac-vlan"
6403 "#hashmac#hashmac-vlan");
6404 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6405 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6408 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6409 .f = cmd_set_vf_macvlan_parsed,
6411 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6412 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6414 "exact match rule:exact match of MAC or MAC and VLAN; "
6415 "hash match rule: hash match of MAC and exact match "
6418 (void *)&cmd_set_vf_macvlan_set,
6419 (void *)&cmd_set_vf_macvlan_port,
6420 (void *)&cmd_set_vf_macvlan_portid,
6421 (void *)&cmd_set_vf_macvlan_vf,
6422 (void *)&cmd_set_vf_macvlan_vf_id,
6423 (void *)&cmd_set_vf_macvlan_mac,
6424 (void *)&cmd_set_vf_macvlan_filter_type,
6425 (void *)&cmd_set_vf_macvlan_mode,
6430 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6431 struct cmd_set_vf_traffic {
6432 cmdline_fixed_string_t set;
6433 cmdline_fixed_string_t port;
6435 cmdline_fixed_string_t vf;
6437 cmdline_fixed_string_t what;
6438 cmdline_fixed_string_t mode;
6442 cmd_set_vf_traffic_parsed(void *parsed_result,
6443 __attribute__((unused)) struct cmdline *cl,
6444 __attribute__((unused)) void *data)
6446 struct cmd_set_vf_traffic *res = parsed_result;
6447 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6448 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6450 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6453 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6454 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6456 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6459 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6460 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6462 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6465 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6466 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6468 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6469 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6471 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6475 cmdline_parse_inst_t cmd_set_vf_traffic = {
6476 .f = cmd_set_vf_traffic_parsed,
6478 .help_str = "set port X vf Y rx|tx on|off"
6479 "(X = port number,Y = vf id)",
6481 (void *)&cmd_setvf_traffic_set,
6482 (void *)&cmd_setvf_traffic_port,
6483 (void *)&cmd_setvf_traffic_portid,
6484 (void *)&cmd_setvf_traffic_vf,
6485 (void *)&cmd_setvf_traffic_vfid,
6486 (void *)&cmd_setvf_traffic_what,
6487 (void *)&cmd_setvf_traffic_mode,
6492 /* *** CONFIGURE VF RECEIVE MODE *** */
6493 struct cmd_set_vf_rxmode {
6494 cmdline_fixed_string_t set;
6495 cmdline_fixed_string_t port;
6497 cmdline_fixed_string_t vf;
6499 cmdline_fixed_string_t what;
6500 cmdline_fixed_string_t mode;
6501 cmdline_fixed_string_t on;
6505 cmd_set_vf_rxmode_parsed(void *parsed_result,
6506 __attribute__((unused)) struct cmdline *cl,
6507 __attribute__((unused)) void *data)
6510 uint16_t rx_mode = 0;
6511 struct cmd_set_vf_rxmode *res = parsed_result;
6513 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6514 if (!strcmp(res->what,"rxmode")) {
6515 if (!strcmp(res->mode, "AUPE"))
6516 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6517 else if (!strcmp(res->mode, "ROPE"))
6518 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6519 else if (!strcmp(res->mode, "BAM"))
6520 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6521 else if (!strncmp(res->mode, "MPE",3))
6522 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6525 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6527 printf("bad VF receive mode parameter, return code = %d \n",
6531 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6532 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6534 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6535 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6537 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6538 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6540 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6543 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6544 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6546 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6547 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6549 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6550 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6551 mode, "AUPE#ROPE#BAM#MPE");
6552 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6553 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6556 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6557 .f = cmd_set_vf_rxmode_parsed,
6559 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6561 (void *)&cmd_set_vf_rxmode_set,
6562 (void *)&cmd_set_vf_rxmode_port,
6563 (void *)&cmd_set_vf_rxmode_portid,
6564 (void *)&cmd_set_vf_rxmode_vf,
6565 (void *)&cmd_set_vf_rxmode_vfid,
6566 (void *)&cmd_set_vf_rxmode_what,
6567 (void *)&cmd_set_vf_rxmode_mode,
6568 (void *)&cmd_set_vf_rxmode_on,
6573 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6574 struct cmd_vf_mac_addr_result {
6575 cmdline_fixed_string_t mac_addr_cmd;
6576 cmdline_fixed_string_t what;
6577 cmdline_fixed_string_t port;
6579 cmdline_fixed_string_t vf;
6581 struct ether_addr address;
6584 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6585 __attribute__((unused)) struct cmdline *cl,
6586 __attribute__((unused)) void *data)
6588 struct cmd_vf_mac_addr_result *res = parsed_result;
6591 if (strcmp(res->what, "add") == 0)
6592 ret = rte_eth_dev_mac_addr_add(res->port_num,
6593 &res->address, res->vf_num);
6595 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6599 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6600 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6601 mac_addr_cmd,"mac_addr");
6602 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6603 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6605 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6606 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6608 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6609 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6611 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6612 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6614 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6615 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6617 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6618 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6621 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6622 .f = cmd_vf_mac_addr_parsed,
6624 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6625 "Y = VF number)add MAC address filtering for a VF on port X",
6627 (void *)&cmd_vf_mac_addr_cmd,
6628 (void *)&cmd_vf_mac_addr_what,
6629 (void *)&cmd_vf_mac_addr_port,
6630 (void *)&cmd_vf_mac_addr_portnum,
6631 (void *)&cmd_vf_mac_addr_vf,
6632 (void *)&cmd_vf_mac_addr_vfnum,
6633 (void *)&cmd_vf_mac_addr_addr,
6638 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6639 struct cmd_vf_rx_vlan_filter {
6640 cmdline_fixed_string_t rx_vlan;
6641 cmdline_fixed_string_t what;
6643 cmdline_fixed_string_t port;
6645 cmdline_fixed_string_t vf;
6650 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6651 __attribute__((unused)) struct cmdline *cl,
6652 __attribute__((unused)) void *data)
6654 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6656 if (!strcmp(res->what, "add"))
6657 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6659 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6662 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6663 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6664 rx_vlan, "rx_vlan");
6665 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6666 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6668 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6669 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6671 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6672 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6674 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6675 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6677 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6678 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6680 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6681 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6684 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6685 .f = cmd_vf_rx_vlan_filter_parsed,
6687 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6688 "Y = port number,Z = hexadecimal VF mask)",
6690 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6691 (void *)&cmd_vf_rx_vlan_filter_what,
6692 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6693 (void *)&cmd_vf_rx_vlan_filter_port,
6694 (void *)&cmd_vf_rx_vlan_filter_portid,
6695 (void *)&cmd_vf_rx_vlan_filter_vf,
6696 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6701 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6702 struct cmd_queue_rate_limit_result {
6703 cmdline_fixed_string_t set;
6704 cmdline_fixed_string_t port;
6706 cmdline_fixed_string_t queue;
6708 cmdline_fixed_string_t rate;
6712 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6713 __attribute__((unused)) struct cmdline *cl,
6714 __attribute__((unused)) void *data)
6716 struct cmd_queue_rate_limit_result *res = parsed_result;
6719 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6720 && (strcmp(res->queue, "queue") == 0)
6721 && (strcmp(res->rate, "rate") == 0))
6722 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6725 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6729 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6730 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6732 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6733 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6735 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6736 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6738 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6739 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6741 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6742 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6744 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6745 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6747 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6748 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6751 cmdline_parse_inst_t cmd_queue_rate_limit = {
6752 .f = cmd_queue_rate_limit_parsed,
6754 .help_str = "set port X queue Y rate Z:(X = port number,"
6755 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6757 (void *)&cmd_queue_rate_limit_set,
6758 (void *)&cmd_queue_rate_limit_port,
6759 (void *)&cmd_queue_rate_limit_portnum,
6760 (void *)&cmd_queue_rate_limit_queue,
6761 (void *)&cmd_queue_rate_limit_queuenum,
6762 (void *)&cmd_queue_rate_limit_rate,
6763 (void *)&cmd_queue_rate_limit_ratenum,
6768 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6769 struct cmd_vf_rate_limit_result {
6770 cmdline_fixed_string_t set;
6771 cmdline_fixed_string_t port;
6773 cmdline_fixed_string_t vf;
6775 cmdline_fixed_string_t rate;
6777 cmdline_fixed_string_t q_msk;
6781 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6782 __attribute__((unused)) struct cmdline *cl,
6783 __attribute__((unused)) void *data)
6785 struct cmd_vf_rate_limit_result *res = parsed_result;
6788 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6789 && (strcmp(res->vf, "vf") == 0)
6790 && (strcmp(res->rate, "rate") == 0)
6791 && (strcmp(res->q_msk, "queue_mask") == 0))
6792 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6793 res->rate_num, res->q_msk_val);
6795 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6799 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6800 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6802 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6803 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6805 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6806 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6808 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6809 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6811 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6812 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6814 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6815 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6817 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6818 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6820 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6821 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6822 q_msk, "queue_mask");
6823 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6824 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6827 cmdline_parse_inst_t cmd_vf_rate_limit = {
6828 .f = cmd_vf_rate_limit_parsed,
6830 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6831 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6832 "for queues of VF on port X",
6834 (void *)&cmd_vf_rate_limit_set,
6835 (void *)&cmd_vf_rate_limit_port,
6836 (void *)&cmd_vf_rate_limit_portnum,
6837 (void *)&cmd_vf_rate_limit_vf,
6838 (void *)&cmd_vf_rate_limit_vfnum,
6839 (void *)&cmd_vf_rate_limit_rate,
6840 (void *)&cmd_vf_rate_limit_ratenum,
6841 (void *)&cmd_vf_rate_limit_q_msk,
6842 (void *)&cmd_vf_rate_limit_q_msk_val,
6847 /* *** ADD TUNNEL FILTER OF A PORT *** */
6848 struct cmd_tunnel_filter_result {
6849 cmdline_fixed_string_t cmd;
6850 cmdline_fixed_string_t what;
6852 struct ether_addr outer_mac;
6853 struct ether_addr inner_mac;
6854 cmdline_ipaddr_t ip_value;
6855 uint16_t inner_vlan;
6856 cmdline_fixed_string_t tunnel_type;
6857 cmdline_fixed_string_t filter_type;
6863 cmd_tunnel_filter_parsed(void *parsed_result,
6864 __attribute__((unused)) struct cmdline *cl,
6865 __attribute__((unused)) void *data)
6867 struct cmd_tunnel_filter_result *res = parsed_result;
6868 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6871 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
6873 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
6874 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
6875 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6877 if (res->ip_value.family == AF_INET) {
6878 tunnel_filter_conf.ip_addr.ipv4_addr =
6879 res->ip_value.addr.ipv4.s_addr;
6880 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6882 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6883 &(res->ip_value.addr.ipv6),
6884 sizeof(struct in6_addr));
6885 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6888 if (!strcmp(res->filter_type, "imac-ivlan"))
6889 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6890 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6891 tunnel_filter_conf.filter_type =
6892 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6893 else if (!strcmp(res->filter_type, "imac-tenid"))
6894 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6895 else if (!strcmp(res->filter_type, "imac"))
6896 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6897 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6898 tunnel_filter_conf.filter_type =
6899 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6900 else if (!strcmp(res->filter_type, "oip"))
6901 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
6902 else if (!strcmp(res->filter_type, "iip"))
6903 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
6905 printf("The filter type is not supported");
6909 if (!strcmp(res->tunnel_type, "vxlan"))
6910 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6911 else if (!strcmp(res->tunnel_type, "nvgre"))
6912 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6913 else if (!strcmp(res->tunnel_type, "ipingre"))
6914 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
6916 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6920 tunnel_filter_conf.tenant_id = res->tenant_id;
6921 tunnel_filter_conf.queue_id = res->queue_num;
6922 if (!strcmp(res->what, "add"))
6923 ret = rte_eth_dev_filter_ctrl(res->port_id,
6924 RTE_ETH_FILTER_TUNNEL,
6926 &tunnel_filter_conf);
6928 ret = rte_eth_dev_filter_ctrl(res->port_id,
6929 RTE_ETH_FILTER_TUNNEL,
6930 RTE_ETH_FILTER_DELETE,
6931 &tunnel_filter_conf);
6933 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6937 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6938 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6939 cmd, "tunnel_filter");
6940 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6941 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6943 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6944 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6946 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6947 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6949 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6950 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6952 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6953 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6954 inner_vlan, UINT16);
6955 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6956 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6958 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6959 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6960 tunnel_type, "vxlan#nvgre#ipingre");
6962 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6963 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6964 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6965 "imac#omac-imac-tenid");
6966 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6967 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6969 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6970 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6973 cmdline_parse_inst_t cmd_tunnel_filter = {
6974 .f = cmd_tunnel_filter_parsed,
6976 .help_str = "add/rm tunnel filter of a port: "
6977 "tunnel_filter add port_id outer_mac inner_mac ip "
6978 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
6979 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6980 "imac|omac-imac-tenid) "
6981 "tenant_id queue_num",
6983 (void *)&cmd_tunnel_filter_cmd,
6984 (void *)&cmd_tunnel_filter_what,
6985 (void *)&cmd_tunnel_filter_port_id,
6986 (void *)&cmd_tunnel_filter_outer_mac,
6987 (void *)&cmd_tunnel_filter_inner_mac,
6988 (void *)&cmd_tunnel_filter_ip_value,
6989 (void *)&cmd_tunnel_filter_innner_vlan,
6990 (void *)&cmd_tunnel_filter_tunnel_type,
6991 (void *)&cmd_tunnel_filter_filter_type,
6992 (void *)&cmd_tunnel_filter_tenant_id,
6993 (void *)&cmd_tunnel_filter_queue_num,
6998 /* *** CONFIGURE TUNNEL UDP PORT *** */
6999 struct cmd_tunnel_udp_config {
7000 cmdline_fixed_string_t cmd;
7001 cmdline_fixed_string_t what;
7007 cmd_tunnel_udp_config_parsed(void *parsed_result,
7008 __attribute__((unused)) struct cmdline *cl,
7009 __attribute__((unused)) void *data)
7011 struct cmd_tunnel_udp_config *res = parsed_result;
7012 struct rte_eth_udp_tunnel tunnel_udp;
7015 tunnel_udp.udp_port = res->udp_port;
7017 if (!strcmp(res->cmd, "rx_vxlan_port"))
7018 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7020 if (!strcmp(res->what, "add"))
7021 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7024 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7028 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7031 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7032 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7033 cmd, "rx_vxlan_port");
7034 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7037 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7038 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7040 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7041 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7044 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7045 .f = cmd_tunnel_udp_config_parsed,
7047 .help_str = "add/rm an tunneling UDP port filter: "
7048 "rx_vxlan_port add udp_port port_id",
7050 (void *)&cmd_tunnel_udp_config_cmd,
7051 (void *)&cmd_tunnel_udp_config_what,
7052 (void *)&cmd_tunnel_udp_config_udp_port,
7053 (void *)&cmd_tunnel_udp_config_port_id,
7058 /* *** GLOBAL CONFIG *** */
7059 struct cmd_global_config_result {
7060 cmdline_fixed_string_t cmd;
7062 cmdline_fixed_string_t cfg_type;
7067 cmd_global_config_parsed(void *parsed_result,
7068 __attribute__((unused)) struct cmdline *cl,
7069 __attribute__((unused)) void *data)
7071 struct cmd_global_config_result *res = parsed_result;
7072 struct rte_eth_global_cfg conf;
7075 memset(&conf, 0, sizeof(conf));
7076 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7077 conf.cfg.gre_key_len = res->len;
7078 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7079 RTE_ETH_FILTER_SET, &conf);
7081 printf("Global config error\n");
7084 cmdline_parse_token_string_t cmd_global_config_cmd =
7085 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7087 cmdline_parse_token_num_t cmd_global_config_port_id =
7088 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7089 cmdline_parse_token_string_t cmd_global_config_type =
7090 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7091 cfg_type, "gre-key-len");
7092 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7093 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7096 cmdline_parse_inst_t cmd_global_config = {
7097 .f = cmd_global_config_parsed,
7098 .data = (void *)NULL,
7099 .help_str = "global_config <port_id> gre-key-len <number>",
7101 (void *)&cmd_global_config_cmd,
7102 (void *)&cmd_global_config_port_id,
7103 (void *)&cmd_global_config_type,
7104 (void *)&cmd_global_config_gre_key_len,
7109 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7110 struct cmd_set_mirror_mask_result {
7111 cmdline_fixed_string_t set;
7112 cmdline_fixed_string_t port;
7114 cmdline_fixed_string_t mirror;
7116 cmdline_fixed_string_t what;
7117 cmdline_fixed_string_t value;
7118 cmdline_fixed_string_t dstpool;
7120 cmdline_fixed_string_t on;
7123 cmdline_parse_token_string_t cmd_mirror_mask_set =
7124 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7126 cmdline_parse_token_string_t cmd_mirror_mask_port =
7127 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7129 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7130 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7132 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7133 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7134 mirror, "mirror-rule");
7135 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7136 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7138 cmdline_parse_token_string_t cmd_mirror_mask_what =
7139 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7140 what, "pool-mirror-up#pool-mirror-down"
7142 cmdline_parse_token_string_t cmd_mirror_mask_value =
7143 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7145 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7146 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7147 dstpool, "dst-pool");
7148 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7149 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7151 cmdline_parse_token_string_t cmd_mirror_mask_on =
7152 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7156 cmd_set_mirror_mask_parsed(void *parsed_result,
7157 __attribute__((unused)) struct cmdline *cl,
7158 __attribute__((unused)) void *data)
7161 struct cmd_set_mirror_mask_result *res = parsed_result;
7162 struct rte_eth_mirror_conf mr_conf;
7164 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7166 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7168 mr_conf.dst_pool = res->dstpool_id;
7170 if (!strcmp(res->what, "pool-mirror-up")) {
7171 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7172 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7173 } else if (!strcmp(res->what, "pool-mirror-down")) {
7174 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7175 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7176 } else if (!strcmp(res->what, "vlan-mirror")) {
7177 mr_conf.rule_type = ETH_MIRROR_VLAN;
7178 nb_item = parse_item_list(res->value, "vlan",
7179 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7183 for (i = 0; i < nb_item; i++) {
7184 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7185 printf("Invalid vlan_id: must be < 4096\n");
7189 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7190 mr_conf.vlan.vlan_mask |= 1ULL << i;
7194 if (!strcmp(res->on, "on"))
7195 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7198 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7201 printf("mirror rule add error: (%s)\n", strerror(-ret));
7204 cmdline_parse_inst_t cmd_set_mirror_mask = {
7205 .f = cmd_set_mirror_mask_parsed,
7207 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7208 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7210 (void *)&cmd_mirror_mask_set,
7211 (void *)&cmd_mirror_mask_port,
7212 (void *)&cmd_mirror_mask_portid,
7213 (void *)&cmd_mirror_mask_mirror,
7214 (void *)&cmd_mirror_mask_ruleid,
7215 (void *)&cmd_mirror_mask_what,
7216 (void *)&cmd_mirror_mask_value,
7217 (void *)&cmd_mirror_mask_dstpool,
7218 (void *)&cmd_mirror_mask_poolid,
7219 (void *)&cmd_mirror_mask_on,
7224 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7225 struct cmd_set_mirror_link_result {
7226 cmdline_fixed_string_t set;
7227 cmdline_fixed_string_t port;
7229 cmdline_fixed_string_t mirror;
7231 cmdline_fixed_string_t what;
7232 cmdline_fixed_string_t dstpool;
7234 cmdline_fixed_string_t on;
7237 cmdline_parse_token_string_t cmd_mirror_link_set =
7238 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7240 cmdline_parse_token_string_t cmd_mirror_link_port =
7241 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7243 cmdline_parse_token_num_t cmd_mirror_link_portid =
7244 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7246 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7247 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7248 mirror, "mirror-rule");
7249 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7250 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7252 cmdline_parse_token_string_t cmd_mirror_link_what =
7253 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7254 what, "uplink-mirror#downlink-mirror");
7255 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7256 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7257 dstpool, "dst-pool");
7258 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7259 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7261 cmdline_parse_token_string_t cmd_mirror_link_on =
7262 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7266 cmd_set_mirror_link_parsed(void *parsed_result,
7267 __attribute__((unused)) struct cmdline *cl,
7268 __attribute__((unused)) void *data)
7271 struct cmd_set_mirror_link_result *res = parsed_result;
7272 struct rte_eth_mirror_conf mr_conf;
7274 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7275 if (!strcmp(res->what, "uplink-mirror"))
7276 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7278 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7280 mr_conf.dst_pool = res->dstpool_id;
7282 if (!strcmp(res->on, "on"))
7283 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7286 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7289 /* check the return value and print it if is < 0 */
7291 printf("mirror rule add error: (%s)\n", strerror(-ret));
7295 cmdline_parse_inst_t cmd_set_mirror_link = {
7296 .f = cmd_set_mirror_link_parsed,
7298 .help_str = "set port X mirror-rule Y uplink-mirror|"
7299 "downlink-mirror dst-pool Z on|off",
7301 (void *)&cmd_mirror_link_set,
7302 (void *)&cmd_mirror_link_port,
7303 (void *)&cmd_mirror_link_portid,
7304 (void *)&cmd_mirror_link_mirror,
7305 (void *)&cmd_mirror_link_ruleid,
7306 (void *)&cmd_mirror_link_what,
7307 (void *)&cmd_mirror_link_dstpool,
7308 (void *)&cmd_mirror_link_poolid,
7309 (void *)&cmd_mirror_link_on,
7314 /* *** RESET VM MIRROR RULE *** */
7315 struct cmd_rm_mirror_rule_result {
7316 cmdline_fixed_string_t reset;
7317 cmdline_fixed_string_t port;
7319 cmdline_fixed_string_t mirror;
7323 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7324 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7326 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7327 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7329 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7330 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7332 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7333 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7334 mirror, "mirror-rule");
7335 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7336 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7340 cmd_reset_mirror_rule_parsed(void *parsed_result,
7341 __attribute__((unused)) struct cmdline *cl,
7342 __attribute__((unused)) void *data)
7345 struct cmd_set_mirror_link_result *res = parsed_result;
7347 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7349 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7352 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7353 .f = cmd_reset_mirror_rule_parsed,
7355 .help_str = "reset port X mirror-rule Y",
7357 (void *)&cmd_rm_mirror_rule_reset,
7358 (void *)&cmd_rm_mirror_rule_port,
7359 (void *)&cmd_rm_mirror_rule_portid,
7360 (void *)&cmd_rm_mirror_rule_mirror,
7361 (void *)&cmd_rm_mirror_rule_ruleid,
7366 /* ******************************************************************************** */
7368 struct cmd_dump_result {
7369 cmdline_fixed_string_t dump;
7373 dump_struct_sizes(void)
7375 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7376 DUMP_SIZE(struct rte_mbuf);
7377 DUMP_SIZE(struct rte_mempool);
7378 DUMP_SIZE(struct rte_ring);
7382 static void cmd_dump_parsed(void *parsed_result,
7383 __attribute__((unused)) struct cmdline *cl,
7384 __attribute__((unused)) void *data)
7386 struct cmd_dump_result *res = parsed_result;
7388 if (!strcmp(res->dump, "dump_physmem"))
7389 rte_dump_physmem_layout(stdout);
7390 else if (!strcmp(res->dump, "dump_memzone"))
7391 rte_memzone_dump(stdout);
7392 else if (!strcmp(res->dump, "dump_struct_sizes"))
7393 dump_struct_sizes();
7394 else if (!strcmp(res->dump, "dump_ring"))
7395 rte_ring_list_dump(stdout);
7396 else if (!strcmp(res->dump, "dump_mempool"))
7397 rte_mempool_list_dump(stdout);
7398 else if (!strcmp(res->dump, "dump_devargs"))
7399 rte_eal_devargs_dump(stdout);
7402 cmdline_parse_token_string_t cmd_dump_dump =
7403 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7406 "dump_struct_sizes#"
7411 cmdline_parse_inst_t cmd_dump = {
7412 .f = cmd_dump_parsed, /* function to call */
7413 .data = NULL, /* 2nd arg of func */
7414 .help_str = "dump status",
7415 .tokens = { /* token list, NULL terminated */
7416 (void *)&cmd_dump_dump,
7421 /* ******************************************************************************** */
7423 struct cmd_dump_one_result {
7424 cmdline_fixed_string_t dump;
7425 cmdline_fixed_string_t name;
7428 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7429 __attribute__((unused)) void *data)
7431 struct cmd_dump_one_result *res = parsed_result;
7433 if (!strcmp(res->dump, "dump_ring")) {
7435 r = rte_ring_lookup(res->name);
7437 cmdline_printf(cl, "Cannot find ring\n");
7440 rte_ring_dump(stdout, r);
7441 } else if (!strcmp(res->dump, "dump_mempool")) {
7442 struct rte_mempool *mp;
7443 mp = rte_mempool_lookup(res->name);
7445 cmdline_printf(cl, "Cannot find mempool\n");
7448 rte_mempool_dump(stdout, mp);
7452 cmdline_parse_token_string_t cmd_dump_one_dump =
7453 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7454 "dump_ring#dump_mempool");
7456 cmdline_parse_token_string_t cmd_dump_one_name =
7457 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7459 cmdline_parse_inst_t cmd_dump_one = {
7460 .f = cmd_dump_one_parsed, /* function to call */
7461 .data = NULL, /* 2nd arg of func */
7462 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7463 .tokens = { /* token list, NULL terminated */
7464 (void *)&cmd_dump_one_dump,
7465 (void *)&cmd_dump_one_name,
7470 /* *** Add/Del syn filter *** */
7471 struct cmd_syn_filter_result {
7472 cmdline_fixed_string_t filter;
7474 cmdline_fixed_string_t ops;
7475 cmdline_fixed_string_t priority;
7476 cmdline_fixed_string_t high;
7477 cmdline_fixed_string_t queue;
7482 cmd_syn_filter_parsed(void *parsed_result,
7483 __attribute__((unused)) struct cmdline *cl,
7484 __attribute__((unused)) void *data)
7486 struct cmd_syn_filter_result *res = parsed_result;
7487 struct rte_eth_syn_filter syn_filter;
7490 ret = rte_eth_dev_filter_supported(res->port_id,
7491 RTE_ETH_FILTER_SYN);
7493 printf("syn filter is not supported on port %u.\n",
7498 memset(&syn_filter, 0, sizeof(syn_filter));
7500 if (!strcmp(res->ops, "add")) {
7501 if (!strcmp(res->high, "high"))
7502 syn_filter.hig_pri = 1;
7504 syn_filter.hig_pri = 0;
7506 syn_filter.queue = res->queue_id;
7507 ret = rte_eth_dev_filter_ctrl(res->port_id,
7512 ret = rte_eth_dev_filter_ctrl(res->port_id,
7514 RTE_ETH_FILTER_DELETE,
7518 printf("syn filter programming error: (%s)\n",
7522 cmdline_parse_token_string_t cmd_syn_filter_filter =
7523 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7524 filter, "syn_filter");
7525 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7526 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7528 cmdline_parse_token_string_t cmd_syn_filter_ops =
7529 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7531 cmdline_parse_token_string_t cmd_syn_filter_priority =
7532 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7533 priority, "priority");
7534 cmdline_parse_token_string_t cmd_syn_filter_high =
7535 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7537 cmdline_parse_token_string_t cmd_syn_filter_queue =
7538 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7540 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7541 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7544 cmdline_parse_inst_t cmd_syn_filter = {
7545 .f = cmd_syn_filter_parsed,
7547 .help_str = "add/delete syn filter",
7549 (void *)&cmd_syn_filter_filter,
7550 (void *)&cmd_syn_filter_port_id,
7551 (void *)&cmd_syn_filter_ops,
7552 (void *)&cmd_syn_filter_priority,
7553 (void *)&cmd_syn_filter_high,
7554 (void *)&cmd_syn_filter_queue,
7555 (void *)&cmd_syn_filter_queue_id,
7560 /* *** ADD/REMOVE A 2tuple FILTER *** */
7561 struct cmd_2tuple_filter_result {
7562 cmdline_fixed_string_t filter;
7564 cmdline_fixed_string_t ops;
7565 cmdline_fixed_string_t dst_port;
7566 uint16_t dst_port_value;
7567 cmdline_fixed_string_t protocol;
7568 uint8_t protocol_value;
7569 cmdline_fixed_string_t mask;
7571 cmdline_fixed_string_t tcp_flags;
7572 uint8_t tcp_flags_value;
7573 cmdline_fixed_string_t priority;
7574 uint8_t priority_value;
7575 cmdline_fixed_string_t queue;
7580 cmd_2tuple_filter_parsed(void *parsed_result,
7581 __attribute__((unused)) struct cmdline *cl,
7582 __attribute__((unused)) void *data)
7584 struct rte_eth_ntuple_filter filter;
7585 struct cmd_2tuple_filter_result *res = parsed_result;
7588 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7590 printf("ntuple filter is not supported on port %u.\n",
7595 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7597 filter.flags = RTE_2TUPLE_FLAGS;
7598 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7599 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7600 filter.proto = res->protocol_value;
7601 filter.priority = res->priority_value;
7602 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7603 printf("nonzero tcp_flags is only meaningful"
7604 " when protocol is TCP.\n");
7607 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7608 printf("invalid TCP flags.\n");
7612 if (res->tcp_flags_value != 0) {
7613 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7614 filter.tcp_flags = res->tcp_flags_value;
7617 /* need convert to big endian. */
7618 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7619 filter.queue = res->queue_id;
7621 if (!strcmp(res->ops, "add"))
7622 ret = rte_eth_dev_filter_ctrl(res->port_id,
7623 RTE_ETH_FILTER_NTUPLE,
7627 ret = rte_eth_dev_filter_ctrl(res->port_id,
7628 RTE_ETH_FILTER_NTUPLE,
7629 RTE_ETH_FILTER_DELETE,
7632 printf("2tuple filter programming error: (%s)\n",
7637 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7638 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7639 filter, "2tuple_filter");
7640 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7641 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7643 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7644 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7646 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7647 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7648 dst_port, "dst_port");
7649 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7650 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7651 dst_port_value, UINT16);
7652 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7653 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7654 protocol, "protocol");
7655 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7656 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7657 protocol_value, UINT8);
7658 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7659 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7661 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7662 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7664 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7665 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7666 tcp_flags, "tcp_flags");
7667 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7668 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7669 tcp_flags_value, UINT8);
7670 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7671 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7672 priority, "priority");
7673 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7674 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7675 priority_value, UINT8);
7676 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7677 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7679 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7680 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7683 cmdline_parse_inst_t cmd_2tuple_filter = {
7684 .f = cmd_2tuple_filter_parsed,
7686 .help_str = "add a 2tuple filter",
7688 (void *)&cmd_2tuple_filter_filter,
7689 (void *)&cmd_2tuple_filter_port_id,
7690 (void *)&cmd_2tuple_filter_ops,
7691 (void *)&cmd_2tuple_filter_dst_port,
7692 (void *)&cmd_2tuple_filter_dst_port_value,
7693 (void *)&cmd_2tuple_filter_protocol,
7694 (void *)&cmd_2tuple_filter_protocol_value,
7695 (void *)&cmd_2tuple_filter_mask,
7696 (void *)&cmd_2tuple_filter_mask_value,
7697 (void *)&cmd_2tuple_filter_tcp_flags,
7698 (void *)&cmd_2tuple_filter_tcp_flags_value,
7699 (void *)&cmd_2tuple_filter_priority,
7700 (void *)&cmd_2tuple_filter_priority_value,
7701 (void *)&cmd_2tuple_filter_queue,
7702 (void *)&cmd_2tuple_filter_queue_id,
7707 /* *** ADD/REMOVE A 5tuple FILTER *** */
7708 struct cmd_5tuple_filter_result {
7709 cmdline_fixed_string_t filter;
7711 cmdline_fixed_string_t ops;
7712 cmdline_fixed_string_t dst_ip;
7713 cmdline_ipaddr_t dst_ip_value;
7714 cmdline_fixed_string_t src_ip;
7715 cmdline_ipaddr_t src_ip_value;
7716 cmdline_fixed_string_t dst_port;
7717 uint16_t dst_port_value;
7718 cmdline_fixed_string_t src_port;
7719 uint16_t src_port_value;
7720 cmdline_fixed_string_t protocol;
7721 uint8_t protocol_value;
7722 cmdline_fixed_string_t mask;
7724 cmdline_fixed_string_t tcp_flags;
7725 uint8_t tcp_flags_value;
7726 cmdline_fixed_string_t priority;
7727 uint8_t priority_value;
7728 cmdline_fixed_string_t queue;
7733 cmd_5tuple_filter_parsed(void *parsed_result,
7734 __attribute__((unused)) struct cmdline *cl,
7735 __attribute__((unused)) void *data)
7737 struct rte_eth_ntuple_filter filter;
7738 struct cmd_5tuple_filter_result *res = parsed_result;
7741 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7743 printf("ntuple filter is not supported on port %u.\n",
7748 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7750 filter.flags = RTE_5TUPLE_FLAGS;
7751 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7752 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7753 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7754 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7755 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7756 filter.proto = res->protocol_value;
7757 filter.priority = res->priority_value;
7758 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7759 printf("nonzero tcp_flags is only meaningful"
7760 " when protocol is TCP.\n");
7763 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7764 printf("invalid TCP flags.\n");
7768 if (res->tcp_flags_value != 0) {
7769 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7770 filter.tcp_flags = res->tcp_flags_value;
7773 if (res->dst_ip_value.family == AF_INET)
7774 /* no need to convert, already big endian. */
7775 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7777 if (filter.dst_ip_mask == 0) {
7778 printf("can not support ipv6 involved compare.\n");
7784 if (res->src_ip_value.family == AF_INET)
7785 /* no need to convert, already big endian. */
7786 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7788 if (filter.src_ip_mask == 0) {
7789 printf("can not support ipv6 involved compare.\n");
7794 /* need convert to big endian. */
7795 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7796 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7797 filter.queue = res->queue_id;
7799 if (!strcmp(res->ops, "add"))
7800 ret = rte_eth_dev_filter_ctrl(res->port_id,
7801 RTE_ETH_FILTER_NTUPLE,
7805 ret = rte_eth_dev_filter_ctrl(res->port_id,
7806 RTE_ETH_FILTER_NTUPLE,
7807 RTE_ETH_FILTER_DELETE,
7810 printf("5tuple filter programming error: (%s)\n",
7814 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7815 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7816 filter, "5tuple_filter");
7817 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7818 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7820 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7821 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7823 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7824 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7826 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7827 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7829 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7830 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7832 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7833 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7835 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7836 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7837 dst_port, "dst_port");
7838 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7839 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7840 dst_port_value, UINT16);
7841 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7842 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7843 src_port, "src_port");
7844 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7845 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7846 src_port_value, UINT16);
7847 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7848 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7849 protocol, "protocol");
7850 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7851 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7852 protocol_value, UINT8);
7853 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7854 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7856 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7857 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7859 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7860 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7861 tcp_flags, "tcp_flags");
7862 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7863 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7864 tcp_flags_value, UINT8);
7865 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7866 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7867 priority, "priority");
7868 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7869 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7870 priority_value, UINT8);
7871 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7872 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7874 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7875 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7878 cmdline_parse_inst_t cmd_5tuple_filter = {
7879 .f = cmd_5tuple_filter_parsed,
7881 .help_str = "add/del a 5tuple filter",
7883 (void *)&cmd_5tuple_filter_filter,
7884 (void *)&cmd_5tuple_filter_port_id,
7885 (void *)&cmd_5tuple_filter_ops,
7886 (void *)&cmd_5tuple_filter_dst_ip,
7887 (void *)&cmd_5tuple_filter_dst_ip_value,
7888 (void *)&cmd_5tuple_filter_src_ip,
7889 (void *)&cmd_5tuple_filter_src_ip_value,
7890 (void *)&cmd_5tuple_filter_dst_port,
7891 (void *)&cmd_5tuple_filter_dst_port_value,
7892 (void *)&cmd_5tuple_filter_src_port,
7893 (void *)&cmd_5tuple_filter_src_port_value,
7894 (void *)&cmd_5tuple_filter_protocol,
7895 (void *)&cmd_5tuple_filter_protocol_value,
7896 (void *)&cmd_5tuple_filter_mask,
7897 (void *)&cmd_5tuple_filter_mask_value,
7898 (void *)&cmd_5tuple_filter_tcp_flags,
7899 (void *)&cmd_5tuple_filter_tcp_flags_value,
7900 (void *)&cmd_5tuple_filter_priority,
7901 (void *)&cmd_5tuple_filter_priority_value,
7902 (void *)&cmd_5tuple_filter_queue,
7903 (void *)&cmd_5tuple_filter_queue_id,
7908 /* *** ADD/REMOVE A flex FILTER *** */
7909 struct cmd_flex_filter_result {
7910 cmdline_fixed_string_t filter;
7911 cmdline_fixed_string_t ops;
7913 cmdline_fixed_string_t len;
7915 cmdline_fixed_string_t bytes;
7916 cmdline_fixed_string_t bytes_value;
7917 cmdline_fixed_string_t mask;
7918 cmdline_fixed_string_t mask_value;
7919 cmdline_fixed_string_t priority;
7920 uint8_t priority_value;
7921 cmdline_fixed_string_t queue;
7925 static int xdigit2val(unsigned char c)
7930 else if (isupper(c))
7938 cmd_flex_filter_parsed(void *parsed_result,
7939 __attribute__((unused)) struct cmdline *cl,
7940 __attribute__((unused)) void *data)
7943 struct rte_eth_flex_filter filter;
7944 struct cmd_flex_filter_result *res = parsed_result;
7945 char *bytes_ptr, *mask_ptr;
7946 uint16_t len, i, j = 0;
7951 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7952 printf("the len exceed the max length 128\n");
7955 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7956 filter.len = res->len_value;
7957 filter.priority = res->priority_value;
7958 filter.queue = res->queue_id;
7959 bytes_ptr = res->bytes_value;
7960 mask_ptr = res->mask_value;
7962 /* translate bytes string to array. */
7963 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7964 (bytes_ptr[1] == 'X')))
7966 len = strnlen(bytes_ptr, res->len_value * 2);
7967 if (len == 0 || (len % 8 != 0)) {
7968 printf("please check len and bytes input\n");
7971 for (i = 0; i < len; i++) {
7973 if (isxdigit(c) == 0) {
7974 /* invalid characters. */
7975 printf("invalid input\n");
7978 val = xdigit2val(c);
7981 filter.bytes[j] = byte;
7982 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7989 /* translate mask string to uint8_t array. */
7990 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7991 (mask_ptr[1] == 'X')))
7993 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7995 printf("invalid input\n");
8000 for (i = 0; i < len; i++) {
8002 if (isxdigit(c) == 0) {
8003 /* invalid characters. */
8004 printf("invalid input\n");
8007 val = xdigit2val(c);
8010 filter.mask[j] = byte;
8011 printf("mask[%d]:%02x ", j, filter.mask[j]);
8019 if (!strcmp(res->ops, "add"))
8020 ret = rte_eth_dev_filter_ctrl(res->port_id,
8021 RTE_ETH_FILTER_FLEXIBLE,
8025 ret = rte_eth_dev_filter_ctrl(res->port_id,
8026 RTE_ETH_FILTER_FLEXIBLE,
8027 RTE_ETH_FILTER_DELETE,
8031 printf("flex filter setting error: (%s)\n", strerror(-ret));
8034 cmdline_parse_token_string_t cmd_flex_filter_filter =
8035 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8036 filter, "flex_filter");
8037 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8038 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8040 cmdline_parse_token_string_t cmd_flex_filter_ops =
8041 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8043 cmdline_parse_token_string_t cmd_flex_filter_len =
8044 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8046 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8047 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8049 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8050 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8052 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8053 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8055 cmdline_parse_token_string_t cmd_flex_filter_mask =
8056 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8058 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8059 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8061 cmdline_parse_token_string_t cmd_flex_filter_priority =
8062 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8063 priority, "priority");
8064 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8065 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8066 priority_value, UINT8);
8067 cmdline_parse_token_string_t cmd_flex_filter_queue =
8068 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8070 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8071 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8073 cmdline_parse_inst_t cmd_flex_filter = {
8074 .f = cmd_flex_filter_parsed,
8076 .help_str = "add/del a flex filter",
8078 (void *)&cmd_flex_filter_filter,
8079 (void *)&cmd_flex_filter_port_id,
8080 (void *)&cmd_flex_filter_ops,
8081 (void *)&cmd_flex_filter_len,
8082 (void *)&cmd_flex_filter_len_value,
8083 (void *)&cmd_flex_filter_bytes,
8084 (void *)&cmd_flex_filter_bytes_value,
8085 (void *)&cmd_flex_filter_mask,
8086 (void *)&cmd_flex_filter_mask_value,
8087 (void *)&cmd_flex_filter_priority,
8088 (void *)&cmd_flex_filter_priority_value,
8089 (void *)&cmd_flex_filter_queue,
8090 (void *)&cmd_flex_filter_queue_id,
8095 /* *** Filters Control *** */
8097 /* *** deal with ethertype filter *** */
8098 struct cmd_ethertype_filter_result {
8099 cmdline_fixed_string_t filter;
8101 cmdline_fixed_string_t ops;
8102 cmdline_fixed_string_t mac;
8103 struct ether_addr mac_addr;
8104 cmdline_fixed_string_t ethertype;
8105 uint16_t ethertype_value;
8106 cmdline_fixed_string_t drop;
8107 cmdline_fixed_string_t queue;
8111 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8112 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8113 filter, "ethertype_filter");
8114 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8115 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8117 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8118 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8120 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8121 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8122 mac, "mac_addr#mac_ignr");
8123 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8124 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8126 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8127 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8128 ethertype, "ethertype");
8129 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8130 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8131 ethertype_value, UINT16);
8132 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8133 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8135 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8136 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8138 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8139 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8143 cmd_ethertype_filter_parsed(void *parsed_result,
8144 __attribute__((unused)) struct cmdline *cl,
8145 __attribute__((unused)) void *data)
8147 struct cmd_ethertype_filter_result *res = parsed_result;
8148 struct rte_eth_ethertype_filter filter;
8151 ret = rte_eth_dev_filter_supported(res->port_id,
8152 RTE_ETH_FILTER_ETHERTYPE);
8154 printf("ethertype filter is not supported on port %u.\n",
8159 memset(&filter, 0, sizeof(filter));
8160 if (!strcmp(res->mac, "mac_addr")) {
8161 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8162 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8163 sizeof(struct ether_addr));
8165 if (!strcmp(res->drop, "drop"))
8166 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8167 filter.ether_type = res->ethertype_value;
8168 filter.queue = res->queue_id;
8170 if (!strcmp(res->ops, "add"))
8171 ret = rte_eth_dev_filter_ctrl(res->port_id,
8172 RTE_ETH_FILTER_ETHERTYPE,
8176 ret = rte_eth_dev_filter_ctrl(res->port_id,
8177 RTE_ETH_FILTER_ETHERTYPE,
8178 RTE_ETH_FILTER_DELETE,
8181 printf("ethertype filter programming error: (%s)\n",
8185 cmdline_parse_inst_t cmd_ethertype_filter = {
8186 .f = cmd_ethertype_filter_parsed,
8188 .help_str = "add or delete an ethertype filter entry",
8190 (void *)&cmd_ethertype_filter_filter,
8191 (void *)&cmd_ethertype_filter_port_id,
8192 (void *)&cmd_ethertype_filter_ops,
8193 (void *)&cmd_ethertype_filter_mac,
8194 (void *)&cmd_ethertype_filter_mac_addr,
8195 (void *)&cmd_ethertype_filter_ethertype,
8196 (void *)&cmd_ethertype_filter_ethertype_value,
8197 (void *)&cmd_ethertype_filter_drop,
8198 (void *)&cmd_ethertype_filter_queue,
8199 (void *)&cmd_ethertype_filter_queue_id,
8204 /* *** deal with flow director filter *** */
8205 struct cmd_flow_director_result {
8206 cmdline_fixed_string_t flow_director_filter;
8208 cmdline_fixed_string_t mode;
8209 cmdline_fixed_string_t mode_value;
8210 cmdline_fixed_string_t ops;
8211 cmdline_fixed_string_t flow;
8212 cmdline_fixed_string_t flow_type;
8213 cmdline_fixed_string_t ether;
8214 uint16_t ether_type;
8215 cmdline_fixed_string_t src;
8216 cmdline_ipaddr_t ip_src;
8218 cmdline_fixed_string_t dst;
8219 cmdline_ipaddr_t ip_dst;
8221 cmdline_fixed_string_t verify_tag;
8222 uint32_t verify_tag_value;
8223 cmdline_ipaddr_t tos;
8225 cmdline_ipaddr_t proto;
8226 uint8_t proto_value;
8227 cmdline_ipaddr_t ttl;
8229 cmdline_fixed_string_t vlan;
8230 uint16_t vlan_value;
8231 cmdline_fixed_string_t flexbytes;
8232 cmdline_fixed_string_t flexbytes_value;
8233 cmdline_fixed_string_t pf_vf;
8234 cmdline_fixed_string_t drop;
8235 cmdline_fixed_string_t queue;
8237 cmdline_fixed_string_t fd_id;
8238 uint32_t fd_id_value;
8239 cmdline_fixed_string_t mac;
8240 struct ether_addr mac_addr;
8241 cmdline_fixed_string_t tunnel;
8242 cmdline_fixed_string_t tunnel_type;
8243 cmdline_fixed_string_t tunnel_id;
8244 uint32_t tunnel_id_value;
8248 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8251 const char *p, *p0 = q_arg;
8253 unsigned long int_fld;
8254 char *str_fld[max_num];
8259 p = strchr(p0, '(');
8263 p0 = strchr(p, ')');
8268 if (size >= sizeof(s))
8271 snprintf(s, sizeof(s), "%.*s", size, p);
8272 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8273 if (ret < 0 || ret > max_num)
8275 for (i = 0; i < ret; i++) {
8277 int_fld = strtoul(str_fld[i], &end, 0);
8278 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8280 flexbytes[i] = (uint8_t)int_fld;
8286 str2flowtype(char *string)
8289 static const struct {
8292 } flowtype_str[] = {
8293 {"raw", RTE_ETH_FLOW_RAW},
8294 {"ipv4", RTE_ETH_FLOW_IPV4},
8295 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8296 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8297 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8298 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8299 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8300 {"ipv6", RTE_ETH_FLOW_IPV6},
8301 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8302 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8303 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8304 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8305 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8306 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8309 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8310 if (!strcmp(flowtype_str[i].str, string))
8311 return flowtype_str[i].type;
8313 return RTE_ETH_FLOW_UNKNOWN;
8316 static enum rte_eth_fdir_tunnel_type
8317 str2fdir_tunneltype(char *string)
8321 static const struct {
8323 enum rte_eth_fdir_tunnel_type type;
8324 } tunneltype_str[] = {
8325 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8326 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8329 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8330 if (!strcmp(tunneltype_str[i].str, string))
8331 return tunneltype_str[i].type;
8333 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8336 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8338 if ((ip_addr).family == AF_INET) \
8339 (ip) = (ip_addr).addr.ipv4.s_addr; \
8341 printf("invalid parameter.\n"); \
8346 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8348 if ((ip_addr).family == AF_INET6) \
8349 (void)rte_memcpy(&(ip), \
8350 &((ip_addr).addr.ipv6), \
8351 sizeof(struct in6_addr)); \
8353 printf("invalid parameter.\n"); \
8359 cmd_flow_director_filter_parsed(void *parsed_result,
8360 __attribute__((unused)) struct cmdline *cl,
8361 __attribute__((unused)) void *data)
8363 struct cmd_flow_director_result *res = parsed_result;
8364 struct rte_eth_fdir_filter entry;
8365 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8367 unsigned long vf_id;
8370 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8372 printf("flow director is not supported on port %u.\n",
8376 memset(flexbytes, 0, sizeof(flexbytes));
8377 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8379 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8380 if (strcmp(res->mode_value, "MAC-VLAN")) {
8381 printf("Please set mode to MAC-VLAN.\n");
8384 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8385 if (strcmp(res->mode_value, "Tunnel")) {
8386 printf("Please set mode to Tunnel.\n");
8390 if (strcmp(res->mode_value, "IP")) {
8391 printf("Please set mode to IP.\n");
8394 entry.input.flow_type = str2flowtype(res->flow_type);
8397 ret = parse_flexbytes(res->flexbytes_value,
8399 RTE_ETH_FDIR_MAX_FLEXLEN);
8401 printf("error: Cannot parse flexbytes input.\n");
8405 switch (entry.input.flow_type) {
8406 case RTE_ETH_FLOW_FRAG_IPV4:
8407 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8408 entry.input.flow.ip4_flow.proto = res->proto_value;
8409 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8410 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8411 IPV4_ADDR_TO_UINT(res->ip_dst,
8412 entry.input.flow.ip4_flow.dst_ip);
8413 IPV4_ADDR_TO_UINT(res->ip_src,
8414 entry.input.flow.ip4_flow.src_ip);
8415 entry.input.flow.ip4_flow.tos = res->tos_value;
8416 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8417 /* need convert to big endian. */
8418 entry.input.flow.udp4_flow.dst_port =
8419 rte_cpu_to_be_16(res->port_dst);
8420 entry.input.flow.udp4_flow.src_port =
8421 rte_cpu_to_be_16(res->port_src);
8423 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8424 IPV4_ADDR_TO_UINT(res->ip_dst,
8425 entry.input.flow.sctp4_flow.ip.dst_ip);
8426 IPV4_ADDR_TO_UINT(res->ip_src,
8427 entry.input.flow.sctp4_flow.ip.src_ip);
8428 entry.input.flow.ip4_flow.tos = res->tos_value;
8429 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8430 /* need convert to big endian. */
8431 entry.input.flow.sctp4_flow.dst_port =
8432 rte_cpu_to_be_16(res->port_dst);
8433 entry.input.flow.sctp4_flow.src_port =
8434 rte_cpu_to_be_16(res->port_src);
8435 entry.input.flow.sctp4_flow.verify_tag =
8436 rte_cpu_to_be_32(res->verify_tag_value);
8438 case RTE_ETH_FLOW_FRAG_IPV6:
8439 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8440 entry.input.flow.ipv6_flow.proto = res->proto_value;
8441 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8442 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8443 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8444 entry.input.flow.ipv6_flow.dst_ip);
8445 IPV6_ADDR_TO_ARRAY(res->ip_src,
8446 entry.input.flow.ipv6_flow.src_ip);
8447 entry.input.flow.ipv6_flow.tc = res->tos_value;
8448 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8449 /* need convert to big endian. */
8450 entry.input.flow.udp6_flow.dst_port =
8451 rte_cpu_to_be_16(res->port_dst);
8452 entry.input.flow.udp6_flow.src_port =
8453 rte_cpu_to_be_16(res->port_src);
8455 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8456 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8457 entry.input.flow.sctp6_flow.ip.dst_ip);
8458 IPV6_ADDR_TO_ARRAY(res->ip_src,
8459 entry.input.flow.sctp6_flow.ip.src_ip);
8460 entry.input.flow.ipv6_flow.tc = res->tos_value;
8461 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8462 /* need convert to big endian. */
8463 entry.input.flow.sctp6_flow.dst_port =
8464 rte_cpu_to_be_16(res->port_dst);
8465 entry.input.flow.sctp6_flow.src_port =
8466 rte_cpu_to_be_16(res->port_src);
8467 entry.input.flow.sctp6_flow.verify_tag =
8468 rte_cpu_to_be_32(res->verify_tag_value);
8470 case RTE_ETH_FLOW_L2_PAYLOAD:
8471 entry.input.flow.l2_flow.ether_type =
8472 rte_cpu_to_be_16(res->ether_type);
8478 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8479 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8481 sizeof(struct ether_addr));
8483 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8484 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8486 sizeof(struct ether_addr));
8487 entry.input.flow.tunnel_flow.tunnel_type =
8488 str2fdir_tunneltype(res->tunnel_type);
8489 entry.input.flow.tunnel_flow.tunnel_id =
8490 rte_cpu_to_be_32(res->tunnel_id_value);
8493 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8495 RTE_ETH_FDIR_MAX_FLEXLEN);
8497 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8499 entry.action.flex_off = 0; /*use 0 by default */
8500 if (!strcmp(res->drop, "drop"))
8501 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8503 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8505 if (!strcmp(res->pf_vf, "pf"))
8506 entry.input.flow_ext.is_vf = 0;
8507 else if (!strncmp(res->pf_vf, "vf", 2)) {
8508 struct rte_eth_dev_info dev_info;
8510 memset(&dev_info, 0, sizeof(dev_info));
8511 rte_eth_dev_info_get(res->port_id, &dev_info);
8513 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8514 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8515 printf("invalid parameter %s.\n", res->pf_vf);
8518 entry.input.flow_ext.is_vf = 1;
8519 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8521 printf("invalid parameter %s.\n", res->pf_vf);
8525 /* set to report FD ID by default */
8526 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8527 entry.action.rx_queue = res->queue_id;
8528 entry.soft_id = res->fd_id_value;
8529 if (!strcmp(res->ops, "add"))
8530 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8531 RTE_ETH_FILTER_ADD, &entry);
8532 else if (!strcmp(res->ops, "del"))
8533 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8534 RTE_ETH_FILTER_DELETE, &entry);
8536 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8537 RTE_ETH_FILTER_UPDATE, &entry);
8539 printf("flow director programming error: (%s)\n",
8543 cmdline_parse_token_string_t cmd_flow_director_filter =
8544 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8545 flow_director_filter, "flow_director_filter");
8546 cmdline_parse_token_num_t cmd_flow_director_port_id =
8547 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8549 cmdline_parse_token_string_t cmd_flow_director_ops =
8550 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8551 ops, "add#del#update");
8552 cmdline_parse_token_string_t cmd_flow_director_flow =
8553 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8555 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8556 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8557 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8558 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8559 cmdline_parse_token_string_t cmd_flow_director_ether =
8560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8562 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8563 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8564 ether_type, UINT16);
8565 cmdline_parse_token_string_t cmd_flow_director_src =
8566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8568 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8569 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8571 cmdline_parse_token_num_t cmd_flow_director_port_src =
8572 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8574 cmdline_parse_token_string_t cmd_flow_director_dst =
8575 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8577 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8578 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8580 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8581 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8583 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8585 verify_tag, "verify_tag");
8586 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8587 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8588 verify_tag_value, UINT32);
8589 cmdline_parse_token_string_t cmd_flow_director_tos =
8590 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8592 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8593 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8595 cmdline_parse_token_string_t cmd_flow_director_proto =
8596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8598 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8599 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8600 proto_value, UINT8);
8601 cmdline_parse_token_string_t cmd_flow_director_ttl =
8602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8604 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8605 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8607 cmdline_parse_token_string_t cmd_flow_director_vlan =
8608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8610 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8611 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8612 vlan_value, UINT16);
8613 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8614 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8615 flexbytes, "flexbytes");
8616 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8617 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8618 flexbytes_value, NULL);
8619 cmdline_parse_token_string_t cmd_flow_director_drop =
8620 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8622 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8623 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8625 cmdline_parse_token_string_t cmd_flow_director_queue =
8626 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8628 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8629 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8631 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8632 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8634 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8635 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8636 fd_id_value, UINT32);
8638 cmdline_parse_token_string_t cmd_flow_director_mode =
8639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8641 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8642 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8644 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8646 mode_value, "MAC-VLAN");
8647 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8649 mode_value, "Tunnel");
8650 cmdline_parse_token_string_t cmd_flow_director_mac =
8651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8653 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8654 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8656 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8657 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8659 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8661 tunnel_type, "NVGRE#VxLAN");
8662 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8664 tunnel_id, "tunnel-id");
8665 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8666 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8667 tunnel_id_value, UINT32);
8669 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8670 .f = cmd_flow_director_filter_parsed,
8672 .help_str = "add or delete an ip flow director entry on NIC",
8674 (void *)&cmd_flow_director_filter,
8675 (void *)&cmd_flow_director_port_id,
8676 (void *)&cmd_flow_director_mode,
8677 (void *)&cmd_flow_director_mode_ip,
8678 (void *)&cmd_flow_director_ops,
8679 (void *)&cmd_flow_director_flow,
8680 (void *)&cmd_flow_director_flow_type,
8681 (void *)&cmd_flow_director_src,
8682 (void *)&cmd_flow_director_ip_src,
8683 (void *)&cmd_flow_director_dst,
8684 (void *)&cmd_flow_director_ip_dst,
8685 (void *)&cmd_flow_director_tos,
8686 (void *)&cmd_flow_director_tos_value,
8687 (void *)&cmd_flow_director_proto,
8688 (void *)&cmd_flow_director_proto_value,
8689 (void *)&cmd_flow_director_ttl,
8690 (void *)&cmd_flow_director_ttl_value,
8691 (void *)&cmd_flow_director_vlan,
8692 (void *)&cmd_flow_director_vlan_value,
8693 (void *)&cmd_flow_director_flexbytes,
8694 (void *)&cmd_flow_director_flexbytes_value,
8695 (void *)&cmd_flow_director_drop,
8696 (void *)&cmd_flow_director_pf_vf,
8697 (void *)&cmd_flow_director_queue,
8698 (void *)&cmd_flow_director_queue_id,
8699 (void *)&cmd_flow_director_fd_id,
8700 (void *)&cmd_flow_director_fd_id_value,
8705 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8706 .f = cmd_flow_director_filter_parsed,
8708 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8710 (void *)&cmd_flow_director_filter,
8711 (void *)&cmd_flow_director_port_id,
8712 (void *)&cmd_flow_director_mode,
8713 (void *)&cmd_flow_director_mode_ip,
8714 (void *)&cmd_flow_director_ops,
8715 (void *)&cmd_flow_director_flow,
8716 (void *)&cmd_flow_director_flow_type,
8717 (void *)&cmd_flow_director_src,
8718 (void *)&cmd_flow_director_ip_src,
8719 (void *)&cmd_flow_director_port_src,
8720 (void *)&cmd_flow_director_dst,
8721 (void *)&cmd_flow_director_ip_dst,
8722 (void *)&cmd_flow_director_port_dst,
8723 (void *)&cmd_flow_director_tos,
8724 (void *)&cmd_flow_director_tos_value,
8725 (void *)&cmd_flow_director_ttl,
8726 (void *)&cmd_flow_director_ttl_value,
8727 (void *)&cmd_flow_director_vlan,
8728 (void *)&cmd_flow_director_vlan_value,
8729 (void *)&cmd_flow_director_flexbytes,
8730 (void *)&cmd_flow_director_flexbytes_value,
8731 (void *)&cmd_flow_director_drop,
8732 (void *)&cmd_flow_director_pf_vf,
8733 (void *)&cmd_flow_director_queue,
8734 (void *)&cmd_flow_director_queue_id,
8735 (void *)&cmd_flow_director_fd_id,
8736 (void *)&cmd_flow_director_fd_id_value,
8741 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8742 .f = cmd_flow_director_filter_parsed,
8744 .help_str = "add or delete a sctp flow director entry on NIC",
8746 (void *)&cmd_flow_director_filter,
8747 (void *)&cmd_flow_director_port_id,
8748 (void *)&cmd_flow_director_mode,
8749 (void *)&cmd_flow_director_mode_ip,
8750 (void *)&cmd_flow_director_ops,
8751 (void *)&cmd_flow_director_flow,
8752 (void *)&cmd_flow_director_flow_type,
8753 (void *)&cmd_flow_director_src,
8754 (void *)&cmd_flow_director_ip_src,
8755 (void *)&cmd_flow_director_port_dst,
8756 (void *)&cmd_flow_director_dst,
8757 (void *)&cmd_flow_director_ip_dst,
8758 (void *)&cmd_flow_director_port_dst,
8759 (void *)&cmd_flow_director_verify_tag,
8760 (void *)&cmd_flow_director_verify_tag_value,
8761 (void *)&cmd_flow_director_tos,
8762 (void *)&cmd_flow_director_tos_value,
8763 (void *)&cmd_flow_director_ttl,
8764 (void *)&cmd_flow_director_ttl_value,
8765 (void *)&cmd_flow_director_vlan,
8766 (void *)&cmd_flow_director_vlan_value,
8767 (void *)&cmd_flow_director_flexbytes,
8768 (void *)&cmd_flow_director_flexbytes_value,
8769 (void *)&cmd_flow_director_drop,
8770 (void *)&cmd_flow_director_pf_vf,
8771 (void *)&cmd_flow_director_queue,
8772 (void *)&cmd_flow_director_queue_id,
8773 (void *)&cmd_flow_director_fd_id,
8774 (void *)&cmd_flow_director_fd_id_value,
8779 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8780 .f = cmd_flow_director_filter_parsed,
8782 .help_str = "add or delete a L2 flow director entry on NIC",
8784 (void *)&cmd_flow_director_filter,
8785 (void *)&cmd_flow_director_port_id,
8786 (void *)&cmd_flow_director_mode,
8787 (void *)&cmd_flow_director_mode_ip,
8788 (void *)&cmd_flow_director_ops,
8789 (void *)&cmd_flow_director_flow,
8790 (void *)&cmd_flow_director_flow_type,
8791 (void *)&cmd_flow_director_ether,
8792 (void *)&cmd_flow_director_ether_type,
8793 (void *)&cmd_flow_director_flexbytes,
8794 (void *)&cmd_flow_director_flexbytes_value,
8795 (void *)&cmd_flow_director_drop,
8796 (void *)&cmd_flow_director_pf_vf,
8797 (void *)&cmd_flow_director_queue,
8798 (void *)&cmd_flow_director_queue_id,
8799 (void *)&cmd_flow_director_fd_id,
8800 (void *)&cmd_flow_director_fd_id_value,
8805 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8806 .f = cmd_flow_director_filter_parsed,
8808 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8810 (void *)&cmd_flow_director_filter,
8811 (void *)&cmd_flow_director_port_id,
8812 (void *)&cmd_flow_director_mode,
8813 (void *)&cmd_flow_director_mode_mac_vlan,
8814 (void *)&cmd_flow_director_ops,
8815 (void *)&cmd_flow_director_mac,
8816 (void *)&cmd_flow_director_mac_addr,
8817 (void *)&cmd_flow_director_vlan,
8818 (void *)&cmd_flow_director_vlan_value,
8819 (void *)&cmd_flow_director_flexbytes,
8820 (void *)&cmd_flow_director_flexbytes_value,
8821 (void *)&cmd_flow_director_drop,
8822 (void *)&cmd_flow_director_queue,
8823 (void *)&cmd_flow_director_queue_id,
8824 (void *)&cmd_flow_director_fd_id,
8825 (void *)&cmd_flow_director_fd_id_value,
8830 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8831 .f = cmd_flow_director_filter_parsed,
8833 .help_str = "add or delete a tunnel flow director entry on NIC",
8835 (void *)&cmd_flow_director_filter,
8836 (void *)&cmd_flow_director_port_id,
8837 (void *)&cmd_flow_director_mode,
8838 (void *)&cmd_flow_director_mode_tunnel,
8839 (void *)&cmd_flow_director_ops,
8840 (void *)&cmd_flow_director_mac,
8841 (void *)&cmd_flow_director_mac_addr,
8842 (void *)&cmd_flow_director_vlan,
8843 (void *)&cmd_flow_director_vlan_value,
8844 (void *)&cmd_flow_director_tunnel,
8845 (void *)&cmd_flow_director_tunnel_type,
8846 (void *)&cmd_flow_director_tunnel_id,
8847 (void *)&cmd_flow_director_tunnel_id_value,
8848 (void *)&cmd_flow_director_flexbytes,
8849 (void *)&cmd_flow_director_flexbytes_value,
8850 (void *)&cmd_flow_director_drop,
8851 (void *)&cmd_flow_director_queue,
8852 (void *)&cmd_flow_director_queue_id,
8853 (void *)&cmd_flow_director_fd_id,
8854 (void *)&cmd_flow_director_fd_id_value,
8859 struct cmd_flush_flow_director_result {
8860 cmdline_fixed_string_t flush_flow_director;
8864 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8865 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8866 flush_flow_director, "flush_flow_director");
8867 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8868 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8872 cmd_flush_flow_director_parsed(void *parsed_result,
8873 __attribute__((unused)) struct cmdline *cl,
8874 __attribute__((unused)) void *data)
8876 struct cmd_flow_director_result *res = parsed_result;
8879 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8881 printf("flow director is not supported on port %u.\n",
8886 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8887 RTE_ETH_FILTER_FLUSH, NULL);
8889 printf("flow director table flushing error: (%s)\n",
8893 cmdline_parse_inst_t cmd_flush_flow_director = {
8894 .f = cmd_flush_flow_director_parsed,
8896 .help_str = "flush all flow director entries of a device on NIC",
8898 (void *)&cmd_flush_flow_director_flush,
8899 (void *)&cmd_flush_flow_director_port_id,
8904 /* *** deal with flow director mask *** */
8905 struct cmd_flow_director_mask_result {
8906 cmdline_fixed_string_t flow_director_mask;
8908 cmdline_fixed_string_t mode;
8909 cmdline_fixed_string_t mode_value;
8910 cmdline_fixed_string_t vlan;
8912 cmdline_fixed_string_t src_mask;
8913 cmdline_ipaddr_t ipv4_src;
8914 cmdline_ipaddr_t ipv6_src;
8916 cmdline_fixed_string_t dst_mask;
8917 cmdline_ipaddr_t ipv4_dst;
8918 cmdline_ipaddr_t ipv6_dst;
8920 cmdline_fixed_string_t mac;
8921 uint8_t mac_addr_byte_mask;
8922 cmdline_fixed_string_t tunnel_id;
8923 uint32_t tunnel_id_mask;
8924 cmdline_fixed_string_t tunnel_type;
8925 uint8_t tunnel_type_mask;
8929 cmd_flow_director_mask_parsed(void *parsed_result,
8930 __attribute__((unused)) struct cmdline *cl,
8931 __attribute__((unused)) void *data)
8933 struct cmd_flow_director_mask_result *res = parsed_result;
8934 struct rte_eth_fdir_masks *mask;
8935 struct rte_port *port;
8937 if (res->port_id > nb_ports) {
8938 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8942 port = &ports[res->port_id];
8943 /** Check if the port is not started **/
8944 if (port->port_status != RTE_PORT_STOPPED) {
8945 printf("Please stop port %d first\n", res->port_id);
8949 mask = &port->dev_conf.fdir_conf.mask;
8951 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8952 if (strcmp(res->mode_value, "MAC-VLAN")) {
8953 printf("Please set mode to MAC-VLAN.\n");
8957 mask->vlan_tci_mask = res->vlan_mask;
8958 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8959 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8960 if (strcmp(res->mode_value, "Tunnel")) {
8961 printf("Please set mode to Tunnel.\n");
8965 mask->vlan_tci_mask = res->vlan_mask;
8966 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8967 mask->tunnel_id_mask = res->tunnel_id_mask;
8968 mask->tunnel_type_mask = res->tunnel_type_mask;
8970 if (strcmp(res->mode_value, "IP")) {
8971 printf("Please set mode to IP.\n");
8975 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8976 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8977 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8978 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8979 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8980 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8981 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8984 cmd_reconfig_device_queue(res->port_id, 1, 1);
8987 cmdline_parse_token_string_t cmd_flow_director_mask =
8988 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8989 flow_director_mask, "flow_director_mask");
8990 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8991 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8993 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8994 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8996 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8997 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8999 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9000 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9001 src_mask, "src_mask");
9002 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9003 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9005 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9006 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9008 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9009 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9011 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9012 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9013 dst_mask, "dst_mask");
9014 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9015 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9017 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9018 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9020 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9021 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9024 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9025 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9027 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9030 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9031 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9032 mode_value, "MAC-VLAN");
9033 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9034 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9035 mode_value, "Tunnel");
9036 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9037 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9039 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9040 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9041 mac_addr_byte_mask, UINT8);
9042 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9043 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9044 tunnel_type, "tunnel-type");
9045 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9046 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9047 tunnel_type_mask, UINT8);
9048 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9049 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9050 tunnel_id, "tunnel-id");
9051 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9052 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9053 tunnel_id_mask, UINT32);
9055 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9056 .f = cmd_flow_director_mask_parsed,
9058 .help_str = "set IP mode flow director's mask on NIC",
9060 (void *)&cmd_flow_director_mask,
9061 (void *)&cmd_flow_director_mask_port_id,
9062 (void *)&cmd_flow_director_mask_mode,
9063 (void *)&cmd_flow_director_mask_mode_ip,
9064 (void *)&cmd_flow_director_mask_vlan,
9065 (void *)&cmd_flow_director_mask_vlan_value,
9066 (void *)&cmd_flow_director_mask_src,
9067 (void *)&cmd_flow_director_mask_ipv4_src,
9068 (void *)&cmd_flow_director_mask_ipv6_src,
9069 (void *)&cmd_flow_director_mask_port_src,
9070 (void *)&cmd_flow_director_mask_dst,
9071 (void *)&cmd_flow_director_mask_ipv4_dst,
9072 (void *)&cmd_flow_director_mask_ipv6_dst,
9073 (void *)&cmd_flow_director_mask_port_dst,
9078 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9079 .f = cmd_flow_director_mask_parsed,
9081 .help_str = "set MAC VLAN mode flow director's mask on NIC",
9083 (void *)&cmd_flow_director_mask,
9084 (void *)&cmd_flow_director_mask_port_id,
9085 (void *)&cmd_flow_director_mask_mode,
9086 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9087 (void *)&cmd_flow_director_mask_vlan,
9088 (void *)&cmd_flow_director_mask_vlan_value,
9089 (void *)&cmd_flow_director_mask_mac,
9090 (void *)&cmd_flow_director_mask_mac_value,
9095 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9096 .f = cmd_flow_director_mask_parsed,
9098 .help_str = "set tunnel mode flow director's mask on NIC",
9100 (void *)&cmd_flow_director_mask,
9101 (void *)&cmd_flow_director_mask_port_id,
9102 (void *)&cmd_flow_director_mask_mode,
9103 (void *)&cmd_flow_director_mask_mode_tunnel,
9104 (void *)&cmd_flow_director_mask_vlan,
9105 (void *)&cmd_flow_director_mask_vlan_value,
9106 (void *)&cmd_flow_director_mask_mac,
9107 (void *)&cmd_flow_director_mask_mac_value,
9108 (void *)&cmd_flow_director_mask_tunnel_type,
9109 (void *)&cmd_flow_director_mask_tunnel_type_value,
9110 (void *)&cmd_flow_director_mask_tunnel_id,
9111 (void *)&cmd_flow_director_mask_tunnel_id_value,
9116 /* *** deal with flow director mask on flexible payload *** */
9117 struct cmd_flow_director_flex_mask_result {
9118 cmdline_fixed_string_t flow_director_flexmask;
9120 cmdline_fixed_string_t flow;
9121 cmdline_fixed_string_t flow_type;
9122 cmdline_fixed_string_t mask;
9126 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9127 __attribute__((unused)) struct cmdline *cl,
9128 __attribute__((unused)) void *data)
9130 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9131 struct rte_eth_fdir_info fdir_info;
9132 struct rte_eth_fdir_flex_mask flex_mask;
9133 struct rte_port *port;
9134 uint32_t flow_type_mask;
9138 if (res->port_id > nb_ports) {
9139 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9143 port = &ports[res->port_id];
9144 /** Check if the port is not started **/
9145 if (port->port_status != RTE_PORT_STOPPED) {
9146 printf("Please stop port %d first\n", res->port_id);
9150 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9151 ret = parse_flexbytes(res->mask,
9153 RTE_ETH_FDIR_MAX_FLEXLEN);
9155 printf("error: Cannot parse mask input.\n");
9159 memset(&fdir_info, 0, sizeof(fdir_info));
9160 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9161 RTE_ETH_FILTER_INFO, &fdir_info);
9163 printf("Cannot get FDir filter info\n");
9167 if (!strcmp(res->flow_type, "none")) {
9168 /* means don't specify the flow type */
9169 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9170 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9171 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9172 0, sizeof(struct rte_eth_fdir_flex_mask));
9173 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9174 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9176 sizeof(struct rte_eth_fdir_flex_mask));
9177 cmd_reconfig_device_queue(res->port_id, 1, 1);
9180 flow_type_mask = fdir_info.flow_types_mask[0];
9181 if (!strcmp(res->flow_type, "all")) {
9182 if (!flow_type_mask) {
9183 printf("No flow type supported\n");
9186 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9187 if (flow_type_mask & (1 << i)) {
9188 flex_mask.flow_type = i;
9189 fdir_set_flex_mask(res->port_id, &flex_mask);
9192 cmd_reconfig_device_queue(res->port_id, 1, 1);
9195 flex_mask.flow_type = str2flowtype(res->flow_type);
9196 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9197 printf("Flow type %s not supported on port %d\n",
9198 res->flow_type, res->port_id);
9201 fdir_set_flex_mask(res->port_id, &flex_mask);
9202 cmd_reconfig_device_queue(res->port_id, 1, 1);
9205 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9206 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9207 flow_director_flexmask,
9208 "flow_director_flex_mask");
9209 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9210 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9212 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9213 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9215 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9216 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9217 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9218 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9219 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9220 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9223 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9224 .f = cmd_flow_director_flex_mask_parsed,
9226 .help_str = "set flow director's flex mask on NIC",
9228 (void *)&cmd_flow_director_flexmask,
9229 (void *)&cmd_flow_director_flexmask_port_id,
9230 (void *)&cmd_flow_director_flexmask_flow,
9231 (void *)&cmd_flow_director_flexmask_flow_type,
9232 (void *)&cmd_flow_director_flexmask_mask,
9237 /* *** deal with flow director flexible payload configuration *** */
9238 struct cmd_flow_director_flexpayload_result {
9239 cmdline_fixed_string_t flow_director_flexpayload;
9241 cmdline_fixed_string_t payload_layer;
9242 cmdline_fixed_string_t payload_cfg;
9246 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9249 const char *p, *p0 = q_arg;
9251 unsigned long int_fld;
9252 char *str_fld[max_num];
9257 p = strchr(p0, '(');
9261 p0 = strchr(p, ')');
9266 if (size >= sizeof(s))
9269 snprintf(s, sizeof(s), "%.*s", size, p);
9270 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9271 if (ret < 0 || ret > max_num)
9273 for (i = 0; i < ret; i++) {
9275 int_fld = strtoul(str_fld[i], &end, 0);
9276 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9278 offsets[i] = (uint16_t)int_fld;
9284 cmd_flow_director_flxpld_parsed(void *parsed_result,
9285 __attribute__((unused)) struct cmdline *cl,
9286 __attribute__((unused)) void *data)
9288 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9289 struct rte_eth_flex_payload_cfg flex_cfg;
9290 struct rte_port *port;
9293 if (res->port_id > nb_ports) {
9294 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9298 port = &ports[res->port_id];
9299 /** Check if the port is not started **/
9300 if (port->port_status != RTE_PORT_STOPPED) {
9301 printf("Please stop port %d first\n", res->port_id);
9305 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9307 if (!strcmp(res->payload_layer, "raw"))
9308 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9309 else if (!strcmp(res->payload_layer, "l2"))
9310 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9311 else if (!strcmp(res->payload_layer, "l3"))
9312 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9313 else if (!strcmp(res->payload_layer, "l4"))
9314 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9316 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9317 RTE_ETH_FDIR_MAX_FLEXLEN);
9319 printf("error: Cannot parse flex payload input.\n");
9323 fdir_set_flex_payload(res->port_id, &flex_cfg);
9324 cmd_reconfig_device_queue(res->port_id, 1, 1);
9327 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9329 flow_director_flexpayload,
9330 "flow_director_flex_payload");
9331 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9332 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9334 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9336 payload_layer, "raw#l2#l3#l4");
9337 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9341 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9342 .f = cmd_flow_director_flxpld_parsed,
9344 .help_str = "set flow director's flex payload on NIC",
9346 (void *)&cmd_flow_director_flexpayload,
9347 (void *)&cmd_flow_director_flexpayload_port_id,
9348 (void *)&cmd_flow_director_flexpayload_payload_layer,
9349 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9354 /* *** Classification Filters Control *** */
9355 /* *** Get symmetric hash enable per port *** */
9356 struct cmd_get_sym_hash_ena_per_port_result {
9357 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9362 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9363 __rte_unused struct cmdline *cl,
9364 __rte_unused void *data)
9366 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9367 struct rte_eth_hash_filter_info info;
9370 if (rte_eth_dev_filter_supported(res->port_id,
9371 RTE_ETH_FILTER_HASH) < 0) {
9372 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9377 memset(&info, 0, sizeof(info));
9378 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9379 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9380 RTE_ETH_FILTER_GET, &info);
9383 printf("Cannot get symmetric hash enable per port "
9384 "on port %u\n", res->port_id);
9388 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9389 "enabled" : "disabled", res->port_id);
9392 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9393 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9394 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9395 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9396 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9399 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9400 .f = cmd_get_sym_hash_per_port_parsed,
9402 .help_str = "get_sym_hash_ena_per_port port_id",
9404 (void *)&cmd_get_sym_hash_ena_per_port_all,
9405 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9410 /* *** Set symmetric hash enable per port *** */
9411 struct cmd_set_sym_hash_ena_per_port_result {
9412 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9413 cmdline_fixed_string_t enable;
9418 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9419 __rte_unused struct cmdline *cl,
9420 __rte_unused void *data)
9422 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9423 struct rte_eth_hash_filter_info info;
9426 if (rte_eth_dev_filter_supported(res->port_id,
9427 RTE_ETH_FILTER_HASH) < 0) {
9428 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9433 memset(&info, 0, sizeof(info));
9434 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9435 if (!strcmp(res->enable, "enable"))
9436 info.info.enable = 1;
9437 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9438 RTE_ETH_FILTER_SET, &info);
9440 printf("Cannot set symmetric hash enable per port on "
9441 "port %u\n", res->port_id);
9444 printf("Symmetric hash has been set to %s on port %u\n",
9445 res->enable, res->port_id);
9448 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9449 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9450 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9451 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9452 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9454 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9455 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9456 enable, "enable#disable");
9458 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9459 .f = cmd_set_sym_hash_per_port_parsed,
9461 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9463 (void *)&cmd_set_sym_hash_ena_per_port_all,
9464 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9465 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9470 /* Get global config of hash function */
9471 struct cmd_get_hash_global_config_result {
9472 cmdline_fixed_string_t get_hash_global_config;
9477 flowtype_to_str(uint16_t ftype)
9484 {"ipv4", RTE_ETH_FLOW_IPV4},
9485 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9486 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9487 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9488 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9489 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9490 {"ipv6", RTE_ETH_FLOW_IPV6},
9491 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9492 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9493 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9494 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9495 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9496 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9497 {"port", RTE_ETH_FLOW_PORT},
9498 {"vxlan", RTE_ETH_FLOW_VXLAN},
9499 {"geneve", RTE_ETH_FLOW_GENEVE},
9500 {"nvgre", RTE_ETH_FLOW_NVGRE},
9503 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9504 if (ftype_table[i].ftype == ftype)
9505 return ftype_table[i].str;
9512 cmd_get_hash_global_config_parsed(void *parsed_result,
9513 __rte_unused struct cmdline *cl,
9514 __rte_unused void *data)
9516 struct cmd_get_hash_global_config_result *res = parsed_result;
9517 struct rte_eth_hash_filter_info info;
9518 uint32_t idx, offset;
9523 if (rte_eth_dev_filter_supported(res->port_id,
9524 RTE_ETH_FILTER_HASH) < 0) {
9525 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9530 memset(&info, 0, sizeof(info));
9531 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9532 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9533 RTE_ETH_FILTER_GET, &info);
9535 printf("Cannot get hash global configurations by port %d\n",
9540 switch (info.info.global_conf.hash_func) {
9541 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9542 printf("Hash function is Toeplitz\n");
9544 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9545 printf("Hash function is Simple XOR\n");
9548 printf("Unknown hash function\n");
9552 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9553 idx = i / UINT32_BIT;
9554 offset = i % UINT32_BIT;
9555 if (!(info.info.global_conf.valid_bit_mask[idx] &
9558 str = flowtype_to_str(i);
9561 printf("Symmetric hash is %s globally for flow type %s "
9563 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9564 (1UL << offset)) ? "enabled" : "disabled"), str,
9569 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9570 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9571 get_hash_global_config, "get_hash_global_config");
9572 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9573 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9576 cmdline_parse_inst_t cmd_get_hash_global_config = {
9577 .f = cmd_get_hash_global_config_parsed,
9579 .help_str = "get_hash_global_config port_id",
9581 (void *)&cmd_get_hash_global_config_all,
9582 (void *)&cmd_get_hash_global_config_port_id,
9587 /* Set global config of hash function */
9588 struct cmd_set_hash_global_config_result {
9589 cmdline_fixed_string_t set_hash_global_config;
9591 cmdline_fixed_string_t hash_func;
9592 cmdline_fixed_string_t flow_type;
9593 cmdline_fixed_string_t enable;
9597 cmd_set_hash_global_config_parsed(void *parsed_result,
9598 __rte_unused struct cmdline *cl,
9599 __rte_unused void *data)
9601 struct cmd_set_hash_global_config_result *res = parsed_result;
9602 struct rte_eth_hash_filter_info info;
9603 uint32_t ftype, idx, offset;
9606 if (rte_eth_dev_filter_supported(res->port_id,
9607 RTE_ETH_FILTER_HASH) < 0) {
9608 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9612 memset(&info, 0, sizeof(info));
9613 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9614 if (!strcmp(res->hash_func, "toeplitz"))
9615 info.info.global_conf.hash_func =
9616 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9617 else if (!strcmp(res->hash_func, "simple_xor"))
9618 info.info.global_conf.hash_func =
9619 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9620 else if (!strcmp(res->hash_func, "default"))
9621 info.info.global_conf.hash_func =
9622 RTE_ETH_HASH_FUNCTION_DEFAULT;
9624 ftype = str2flowtype(res->flow_type);
9625 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9626 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9627 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9628 if (!strcmp(res->enable, "enable"))
9629 info.info.global_conf.sym_hash_enable_mask[idx] |=
9631 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9632 RTE_ETH_FILTER_SET, &info);
9634 printf("Cannot set global hash configurations by port %d\n",
9637 printf("Global hash configurations have been set "
9638 "succcessfully by port %d\n", res->port_id);
9641 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9642 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9643 set_hash_global_config, "set_hash_global_config");
9644 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9645 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9647 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9648 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9649 hash_func, "toeplitz#simple_xor#default");
9650 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9651 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9653 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9654 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9655 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9656 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9657 enable, "enable#disable");
9659 cmdline_parse_inst_t cmd_set_hash_global_config = {
9660 .f = cmd_set_hash_global_config_parsed,
9662 .help_str = "set_hash_global_config port_id "
9663 "toeplitz|simple_xor|default "
9664 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9665 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9668 (void *)&cmd_set_hash_global_config_all,
9669 (void *)&cmd_set_hash_global_config_port_id,
9670 (void *)&cmd_set_hash_global_config_hash_func,
9671 (void *)&cmd_set_hash_global_config_flow_type,
9672 (void *)&cmd_set_hash_global_config_enable,
9677 /* Set hash input set */
9678 struct cmd_set_hash_input_set_result {
9679 cmdline_fixed_string_t set_hash_input_set;
9681 cmdline_fixed_string_t flow_type;
9682 cmdline_fixed_string_t inset_field;
9683 cmdline_fixed_string_t select;
9686 static enum rte_eth_input_set_field
9687 str2inset(char *string)
9691 static const struct {
9693 enum rte_eth_input_set_field inset;
9695 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9696 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9697 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9698 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9699 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9700 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9701 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9702 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9703 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9704 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9705 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9706 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9707 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9708 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9709 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9710 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9711 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9712 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9713 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9714 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9715 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9716 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9717 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9718 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9719 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9720 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9721 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9722 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9723 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9724 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9725 {"none", RTE_ETH_INPUT_SET_NONE},
9728 for (i = 0; i < RTE_DIM(inset_table); i++) {
9729 if (!strcmp(string, inset_table[i].str))
9730 return inset_table[i].inset;
9733 return RTE_ETH_INPUT_SET_UNKNOWN;
9737 cmd_set_hash_input_set_parsed(void *parsed_result,
9738 __rte_unused struct cmdline *cl,
9739 __rte_unused void *data)
9741 struct cmd_set_hash_input_set_result *res = parsed_result;
9742 struct rte_eth_hash_filter_info info;
9744 memset(&info, 0, sizeof(info));
9745 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9746 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9747 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9748 info.info.input_set_conf.inset_size = 1;
9749 if (!strcmp(res->select, "select"))
9750 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9751 else if (!strcmp(res->select, "add"))
9752 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9753 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9754 RTE_ETH_FILTER_SET, &info);
9757 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9758 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9759 set_hash_input_set, "set_hash_input_set");
9760 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9761 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9763 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9764 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9766 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9767 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9768 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9769 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9771 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9772 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9773 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9774 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9775 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9777 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9778 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9779 select, "select#add");
9781 cmdline_parse_inst_t cmd_set_hash_input_set = {
9782 .f = cmd_set_hash_input_set_parsed,
9784 .help_str = "set_hash_input_set <port_id> "
9785 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9786 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9787 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9788 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9789 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9790 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9791 "fld-7th|fld-8th|none select|add",
9793 (void *)&cmd_set_hash_input_set_cmd,
9794 (void *)&cmd_set_hash_input_set_port_id,
9795 (void *)&cmd_set_hash_input_set_flow_type,
9796 (void *)&cmd_set_hash_input_set_field,
9797 (void *)&cmd_set_hash_input_set_select,
9802 /* Set flow director input set */
9803 struct cmd_set_fdir_input_set_result {
9804 cmdline_fixed_string_t set_fdir_input_set;
9806 cmdline_fixed_string_t flow_type;
9807 cmdline_fixed_string_t inset_field;
9808 cmdline_fixed_string_t select;
9812 cmd_set_fdir_input_set_parsed(void *parsed_result,
9813 __rte_unused struct cmdline *cl,
9814 __rte_unused void *data)
9816 struct cmd_set_fdir_input_set_result *res = parsed_result;
9817 struct rte_eth_fdir_filter_info info;
9819 memset(&info, 0, sizeof(info));
9820 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9821 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9822 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9823 info.info.input_set_conf.inset_size = 1;
9824 if (!strcmp(res->select, "select"))
9825 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9826 else if (!strcmp(res->select, "add"))
9827 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9828 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9829 RTE_ETH_FILTER_SET, &info);
9832 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9833 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9834 set_fdir_input_set, "set_fdir_input_set");
9835 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9836 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9838 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9839 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9841 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9842 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9843 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9844 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9846 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9847 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9848 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9849 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9850 "sctp-veri-tag#none");
9851 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9852 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9853 select, "select#add");
9855 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9856 .f = cmd_set_fdir_input_set_parsed,
9858 .help_str = "set_fdir_input_set <port_id> "
9859 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9860 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9861 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
9862 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
9863 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
9864 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
9865 "sctp-veri-tag|none select|add",
9867 (void *)&cmd_set_fdir_input_set_cmd,
9868 (void *)&cmd_set_fdir_input_set_port_id,
9869 (void *)&cmd_set_fdir_input_set_flow_type,
9870 (void *)&cmd_set_fdir_input_set_field,
9871 (void *)&cmd_set_fdir_input_set_select,
9876 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9877 struct cmd_mcast_addr_result {
9878 cmdline_fixed_string_t mcast_addr_cmd;
9879 cmdline_fixed_string_t what;
9881 struct ether_addr mc_addr;
9884 static void cmd_mcast_addr_parsed(void *parsed_result,
9885 __attribute__((unused)) struct cmdline *cl,
9886 __attribute__((unused)) void *data)
9888 struct cmd_mcast_addr_result *res = parsed_result;
9890 if (!is_multicast_ether_addr(&res->mc_addr)) {
9891 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9892 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9893 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9894 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9897 if (strcmp(res->what, "add") == 0)
9898 mcast_addr_add(res->port_num, &res->mc_addr);
9900 mcast_addr_remove(res->port_num, &res->mc_addr);
9903 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9904 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9905 mcast_addr_cmd, "mcast_addr");
9906 cmdline_parse_token_string_t cmd_mcast_addr_what =
9907 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9909 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9910 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9911 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9912 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9914 cmdline_parse_inst_t cmd_mcast_addr = {
9915 .f = cmd_mcast_addr_parsed,
9917 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9919 (void *)&cmd_mcast_addr_cmd,
9920 (void *)&cmd_mcast_addr_what,
9921 (void *)&cmd_mcast_addr_portnum,
9922 (void *)&cmd_mcast_addr_addr,
9928 * only support E-tag now.
9931 /* Ether type config */
9932 struct cmd_config_l2_tunnel_eth_type_result {
9933 cmdline_fixed_string_t port;
9934 cmdline_fixed_string_t config;
9935 cmdline_fixed_string_t all;
9937 cmdline_fixed_string_t l2_tunnel;
9938 cmdline_fixed_string_t l2_tunnel_type;
9939 cmdline_fixed_string_t eth_type;
9940 uint16_t eth_type_val;
9943 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9944 TOKEN_STRING_INITIALIZER
9945 (struct cmd_config_l2_tunnel_eth_type_result,
9947 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9948 TOKEN_STRING_INITIALIZER
9949 (struct cmd_config_l2_tunnel_eth_type_result,
9951 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9952 TOKEN_STRING_INITIALIZER
9953 (struct cmd_config_l2_tunnel_eth_type_result,
9955 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9956 TOKEN_NUM_INITIALIZER
9957 (struct cmd_config_l2_tunnel_eth_type_result,
9959 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9960 TOKEN_STRING_INITIALIZER
9961 (struct cmd_config_l2_tunnel_eth_type_result,
9962 l2_tunnel, "l2-tunnel");
9963 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9964 TOKEN_STRING_INITIALIZER
9965 (struct cmd_config_l2_tunnel_eth_type_result,
9966 l2_tunnel_type, "E-tag");
9967 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9968 TOKEN_STRING_INITIALIZER
9969 (struct cmd_config_l2_tunnel_eth_type_result,
9970 eth_type, "ether-type");
9971 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9972 TOKEN_NUM_INITIALIZER
9973 (struct cmd_config_l2_tunnel_eth_type_result,
9974 eth_type_val, UINT16);
9976 static enum rte_eth_tunnel_type
9977 str2fdir_l2_tunnel_type(char *string)
9981 static const struct {
9983 enum rte_eth_tunnel_type type;
9984 } l2_tunnel_type_str[] = {
9985 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
9988 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
9989 if (!strcmp(l2_tunnel_type_str[i].str, string))
9990 return l2_tunnel_type_str[i].type;
9992 return RTE_TUNNEL_TYPE_NONE;
9995 /* ether type config for all ports */
9997 cmd_config_l2_tunnel_eth_type_all_parsed
9998 (void *parsed_result,
9999 __attribute__((unused)) struct cmdline *cl,
10000 __attribute__((unused)) void *data)
10002 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10003 struct rte_eth_l2_tunnel_conf entry;
10006 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10007 entry.ether_type = res->eth_type_val;
10009 FOREACH_PORT(pid, ports) {
10010 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10014 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10015 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10017 .help_str = "port config all l2-tunnel ether-type",
10019 (void *)&cmd_config_l2_tunnel_eth_type_port,
10020 (void *)&cmd_config_l2_tunnel_eth_type_config,
10021 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10022 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10023 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10024 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10025 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10030 /* ether type config for a specific port */
10032 cmd_config_l2_tunnel_eth_type_specific_parsed(
10033 void *parsed_result,
10034 __attribute__((unused)) struct cmdline *cl,
10035 __attribute__((unused)) void *data)
10037 struct cmd_config_l2_tunnel_eth_type_result *res =
10039 struct rte_eth_l2_tunnel_conf entry;
10041 if (port_id_is_invalid(res->id, ENABLED_WARN))
10044 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10045 entry.ether_type = res->eth_type_val;
10047 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10050 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10051 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10053 .help_str = "port config l2-tunnel ether-type",
10055 (void *)&cmd_config_l2_tunnel_eth_type_port,
10056 (void *)&cmd_config_l2_tunnel_eth_type_config,
10057 (void *)&cmd_config_l2_tunnel_eth_type_id,
10058 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10059 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10060 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10061 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10066 /* Enable/disable l2 tunnel */
10067 struct cmd_config_l2_tunnel_en_dis_result {
10068 cmdline_fixed_string_t port;
10069 cmdline_fixed_string_t config;
10070 cmdline_fixed_string_t all;
10072 cmdline_fixed_string_t l2_tunnel;
10073 cmdline_fixed_string_t l2_tunnel_type;
10074 cmdline_fixed_string_t en_dis;
10077 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10078 TOKEN_STRING_INITIALIZER
10079 (struct cmd_config_l2_tunnel_en_dis_result,
10081 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10082 TOKEN_STRING_INITIALIZER
10083 (struct cmd_config_l2_tunnel_en_dis_result,
10085 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10086 TOKEN_STRING_INITIALIZER
10087 (struct cmd_config_l2_tunnel_en_dis_result,
10089 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10090 TOKEN_NUM_INITIALIZER
10091 (struct cmd_config_l2_tunnel_en_dis_result,
10093 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10094 TOKEN_STRING_INITIALIZER
10095 (struct cmd_config_l2_tunnel_en_dis_result,
10096 l2_tunnel, "l2-tunnel");
10097 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10098 TOKEN_STRING_INITIALIZER
10099 (struct cmd_config_l2_tunnel_en_dis_result,
10100 l2_tunnel_type, "E-tag");
10101 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10102 TOKEN_STRING_INITIALIZER
10103 (struct cmd_config_l2_tunnel_en_dis_result,
10104 en_dis, "enable#disable");
10106 /* enable/disable l2 tunnel for all ports */
10108 cmd_config_l2_tunnel_en_dis_all_parsed(
10109 void *parsed_result,
10110 __attribute__((unused)) struct cmdline *cl,
10111 __attribute__((unused)) void *data)
10113 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10114 struct rte_eth_l2_tunnel_conf entry;
10118 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10120 if (!strcmp("enable", res->en_dis))
10125 FOREACH_PORT(pid, ports) {
10126 rte_eth_dev_l2_tunnel_offload_set(pid,
10128 ETH_L2_TUNNEL_ENABLE_MASK,
10133 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10134 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10136 .help_str = "port config all l2-tunnel enable/disable",
10138 (void *)&cmd_config_l2_tunnel_en_dis_port,
10139 (void *)&cmd_config_l2_tunnel_en_dis_config,
10140 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10141 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10142 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10143 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10148 /* enable/disable l2 tunnel for a port */
10150 cmd_config_l2_tunnel_en_dis_specific_parsed(
10151 void *parsed_result,
10152 __attribute__((unused)) struct cmdline *cl,
10153 __attribute__((unused)) void *data)
10155 struct cmd_config_l2_tunnel_en_dis_result *res =
10157 struct rte_eth_l2_tunnel_conf entry;
10159 if (port_id_is_invalid(res->id, ENABLED_WARN))
10162 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10164 if (!strcmp("enable", res->en_dis))
10165 rte_eth_dev_l2_tunnel_offload_set(res->id,
10167 ETH_L2_TUNNEL_ENABLE_MASK,
10170 rte_eth_dev_l2_tunnel_offload_set(res->id,
10172 ETH_L2_TUNNEL_ENABLE_MASK,
10176 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10177 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10179 .help_str = "port config l2-tunnel enable/disable",
10181 (void *)&cmd_config_l2_tunnel_en_dis_port,
10182 (void *)&cmd_config_l2_tunnel_en_dis_config,
10183 (void *)&cmd_config_l2_tunnel_en_dis_id,
10184 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10185 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10186 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10191 /* E-tag configuration */
10193 /* Common result structure for all E-tag configuration */
10194 struct cmd_config_e_tag_result {
10195 cmdline_fixed_string_t e_tag;
10196 cmdline_fixed_string_t set;
10197 cmdline_fixed_string_t insertion;
10198 cmdline_fixed_string_t stripping;
10199 cmdline_fixed_string_t forwarding;
10200 cmdline_fixed_string_t filter;
10201 cmdline_fixed_string_t add;
10202 cmdline_fixed_string_t del;
10203 cmdline_fixed_string_t on;
10204 cmdline_fixed_string_t off;
10205 cmdline_fixed_string_t on_off;
10206 cmdline_fixed_string_t port_tag_id;
10207 uint32_t port_tag_id_val;
10208 cmdline_fixed_string_t e_tag_id;
10209 uint16_t e_tag_id_val;
10210 cmdline_fixed_string_t dst_pool;
10211 uint8_t dst_pool_val;
10212 cmdline_fixed_string_t port;
10214 cmdline_fixed_string_t vf;
10218 /* Common CLI fields for all E-tag configuration */
10219 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10220 TOKEN_STRING_INITIALIZER
10221 (struct cmd_config_e_tag_result,
10223 cmdline_parse_token_string_t cmd_config_e_tag_set =
10224 TOKEN_STRING_INITIALIZER
10225 (struct cmd_config_e_tag_result,
10227 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10228 TOKEN_STRING_INITIALIZER
10229 (struct cmd_config_e_tag_result,
10230 insertion, "insertion");
10231 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10232 TOKEN_STRING_INITIALIZER
10233 (struct cmd_config_e_tag_result,
10234 stripping, "stripping");
10235 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10236 TOKEN_STRING_INITIALIZER
10237 (struct cmd_config_e_tag_result,
10238 forwarding, "forwarding");
10239 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10240 TOKEN_STRING_INITIALIZER
10241 (struct cmd_config_e_tag_result,
10243 cmdline_parse_token_string_t cmd_config_e_tag_add =
10244 TOKEN_STRING_INITIALIZER
10245 (struct cmd_config_e_tag_result,
10247 cmdline_parse_token_string_t cmd_config_e_tag_del =
10248 TOKEN_STRING_INITIALIZER
10249 (struct cmd_config_e_tag_result,
10251 cmdline_parse_token_string_t cmd_config_e_tag_on =
10252 TOKEN_STRING_INITIALIZER
10253 (struct cmd_config_e_tag_result,
10255 cmdline_parse_token_string_t cmd_config_e_tag_off =
10256 TOKEN_STRING_INITIALIZER
10257 (struct cmd_config_e_tag_result,
10259 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10260 TOKEN_STRING_INITIALIZER
10261 (struct cmd_config_e_tag_result,
10263 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10264 TOKEN_STRING_INITIALIZER
10265 (struct cmd_config_e_tag_result,
10266 port_tag_id, "port-tag-id");
10267 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10268 TOKEN_NUM_INITIALIZER
10269 (struct cmd_config_e_tag_result,
10270 port_tag_id_val, UINT32);
10271 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10272 TOKEN_STRING_INITIALIZER
10273 (struct cmd_config_e_tag_result,
10274 e_tag_id, "e-tag-id");
10275 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10276 TOKEN_NUM_INITIALIZER
10277 (struct cmd_config_e_tag_result,
10278 e_tag_id_val, UINT16);
10279 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10280 TOKEN_STRING_INITIALIZER
10281 (struct cmd_config_e_tag_result,
10282 dst_pool, "dst-pool");
10283 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10284 TOKEN_NUM_INITIALIZER
10285 (struct cmd_config_e_tag_result,
10286 dst_pool_val, UINT8);
10287 cmdline_parse_token_string_t cmd_config_e_tag_port =
10288 TOKEN_STRING_INITIALIZER
10289 (struct cmd_config_e_tag_result,
10291 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10292 TOKEN_NUM_INITIALIZER
10293 (struct cmd_config_e_tag_result,
10295 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10296 TOKEN_STRING_INITIALIZER
10297 (struct cmd_config_e_tag_result,
10299 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10300 TOKEN_NUM_INITIALIZER
10301 (struct cmd_config_e_tag_result,
10304 /* E-tag insertion configuration */
10306 cmd_config_e_tag_insertion_en_parsed(
10307 void *parsed_result,
10308 __attribute__((unused)) struct cmdline *cl,
10309 __attribute__((unused)) void *data)
10311 struct cmd_config_e_tag_result *res =
10313 struct rte_eth_l2_tunnel_conf entry;
10315 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10318 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10319 entry.tunnel_id = res->port_tag_id_val;
10320 entry.vf_id = res->vf_id;
10321 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10323 ETH_L2_TUNNEL_INSERTION_MASK,
10328 cmd_config_e_tag_insertion_dis_parsed(
10329 void *parsed_result,
10330 __attribute__((unused)) struct cmdline *cl,
10331 __attribute__((unused)) void *data)
10333 struct cmd_config_e_tag_result *res =
10335 struct rte_eth_l2_tunnel_conf entry;
10337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10340 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10341 entry.vf_id = res->vf_id;
10343 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10345 ETH_L2_TUNNEL_INSERTION_MASK,
10349 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10350 .f = cmd_config_e_tag_insertion_en_parsed,
10352 .help_str = "E-tag insertion enable",
10354 (void *)&cmd_config_e_tag_e_tag,
10355 (void *)&cmd_config_e_tag_set,
10356 (void *)&cmd_config_e_tag_insertion,
10357 (void *)&cmd_config_e_tag_on,
10358 (void *)&cmd_config_e_tag_port_tag_id,
10359 (void *)&cmd_config_e_tag_port_tag_id_val,
10360 (void *)&cmd_config_e_tag_port,
10361 (void *)&cmd_config_e_tag_port_id,
10362 (void *)&cmd_config_e_tag_vf,
10363 (void *)&cmd_config_e_tag_vf_id,
10368 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10369 .f = cmd_config_e_tag_insertion_dis_parsed,
10371 .help_str = "E-tag insertion disable",
10373 (void *)&cmd_config_e_tag_e_tag,
10374 (void *)&cmd_config_e_tag_set,
10375 (void *)&cmd_config_e_tag_insertion,
10376 (void *)&cmd_config_e_tag_off,
10377 (void *)&cmd_config_e_tag_port,
10378 (void *)&cmd_config_e_tag_port_id,
10379 (void *)&cmd_config_e_tag_vf,
10380 (void *)&cmd_config_e_tag_vf_id,
10385 /* E-tag stripping configuration */
10387 cmd_config_e_tag_stripping_parsed(
10388 void *parsed_result,
10389 __attribute__((unused)) struct cmdline *cl,
10390 __attribute__((unused)) void *data)
10392 struct cmd_config_e_tag_result *res =
10394 struct rte_eth_l2_tunnel_conf entry;
10396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10399 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10401 if (!strcmp(res->on_off, "on"))
10402 rte_eth_dev_l2_tunnel_offload_set
10405 ETH_L2_TUNNEL_STRIPPING_MASK,
10408 rte_eth_dev_l2_tunnel_offload_set
10411 ETH_L2_TUNNEL_STRIPPING_MASK,
10415 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10416 .f = cmd_config_e_tag_stripping_parsed,
10418 .help_str = "E-tag stripping enable/disable",
10420 (void *)&cmd_config_e_tag_e_tag,
10421 (void *)&cmd_config_e_tag_set,
10422 (void *)&cmd_config_e_tag_stripping,
10423 (void *)&cmd_config_e_tag_on_off,
10424 (void *)&cmd_config_e_tag_port,
10425 (void *)&cmd_config_e_tag_port_id,
10430 /* E-tag forwarding configuration */
10432 cmd_config_e_tag_forwarding_parsed(
10433 void *parsed_result,
10434 __attribute__((unused)) struct cmdline *cl,
10435 __attribute__((unused)) void *data)
10437 struct cmd_config_e_tag_result *res = parsed_result;
10438 struct rte_eth_l2_tunnel_conf entry;
10440 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10443 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10445 if (!strcmp(res->on_off, "on"))
10446 rte_eth_dev_l2_tunnel_offload_set
10449 ETH_L2_TUNNEL_FORWARDING_MASK,
10452 rte_eth_dev_l2_tunnel_offload_set
10455 ETH_L2_TUNNEL_FORWARDING_MASK,
10459 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10460 .f = cmd_config_e_tag_forwarding_parsed,
10462 .help_str = "E-tag forwarding enable/disable",
10464 (void *)&cmd_config_e_tag_e_tag,
10465 (void *)&cmd_config_e_tag_set,
10466 (void *)&cmd_config_e_tag_forwarding,
10467 (void *)&cmd_config_e_tag_on_off,
10468 (void *)&cmd_config_e_tag_port,
10469 (void *)&cmd_config_e_tag_port_id,
10474 /* E-tag filter configuration */
10476 cmd_config_e_tag_filter_add_parsed(
10477 void *parsed_result,
10478 __attribute__((unused)) struct cmdline *cl,
10479 __attribute__((unused)) void *data)
10481 struct cmd_config_e_tag_result *res = parsed_result;
10482 struct rte_eth_l2_tunnel_conf entry;
10485 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10488 if (res->e_tag_id_val > 0x3fff) {
10489 printf("e-tag-id must be equal or less than 0x3fff.\n");
10493 ret = rte_eth_dev_filter_supported(res->port_id,
10494 RTE_ETH_FILTER_L2_TUNNEL);
10496 printf("E-tag filter is not supported on port %u.\n",
10501 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10502 entry.tunnel_id = res->e_tag_id_val;
10503 entry.pool = res->dst_pool_val;
10505 ret = rte_eth_dev_filter_ctrl(res->port_id,
10506 RTE_ETH_FILTER_L2_TUNNEL,
10507 RTE_ETH_FILTER_ADD,
10510 printf("E-tag filter programming error: (%s)\n",
10514 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10515 .f = cmd_config_e_tag_filter_add_parsed,
10517 .help_str = "E-tag filter add",
10519 (void *)&cmd_config_e_tag_e_tag,
10520 (void *)&cmd_config_e_tag_set,
10521 (void *)&cmd_config_e_tag_filter,
10522 (void *)&cmd_config_e_tag_add,
10523 (void *)&cmd_config_e_tag_e_tag_id,
10524 (void *)&cmd_config_e_tag_e_tag_id_val,
10525 (void *)&cmd_config_e_tag_dst_pool,
10526 (void *)&cmd_config_e_tag_dst_pool_val,
10527 (void *)&cmd_config_e_tag_port,
10528 (void *)&cmd_config_e_tag_port_id,
10534 cmd_config_e_tag_filter_del_parsed(
10535 void *parsed_result,
10536 __attribute__((unused)) struct cmdline *cl,
10537 __attribute__((unused)) void *data)
10539 struct cmd_config_e_tag_result *res = parsed_result;
10540 struct rte_eth_l2_tunnel_conf entry;
10543 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10546 if (res->e_tag_id_val > 0x3fff) {
10547 printf("e-tag-id must be less than 0x3fff.\n");
10551 ret = rte_eth_dev_filter_supported(res->port_id,
10552 RTE_ETH_FILTER_L2_TUNNEL);
10554 printf("E-tag filter is not supported on port %u.\n",
10559 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10560 entry.tunnel_id = res->e_tag_id_val;
10562 ret = rte_eth_dev_filter_ctrl(res->port_id,
10563 RTE_ETH_FILTER_L2_TUNNEL,
10564 RTE_ETH_FILTER_DELETE,
10567 printf("E-tag filter programming error: (%s)\n",
10571 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10572 .f = cmd_config_e_tag_filter_del_parsed,
10574 .help_str = "E-tag filter delete",
10576 (void *)&cmd_config_e_tag_e_tag,
10577 (void *)&cmd_config_e_tag_set,
10578 (void *)&cmd_config_e_tag_filter,
10579 (void *)&cmd_config_e_tag_del,
10580 (void *)&cmd_config_e_tag_e_tag_id,
10581 (void *)&cmd_config_e_tag_e_tag_id_val,
10582 (void *)&cmd_config_e_tag_port,
10583 (void *)&cmd_config_e_tag_port_id,
10588 /* ******************************************************************************** */
10590 /* list of instructions */
10591 cmdline_parse_ctx_t main_ctx[] = {
10592 (cmdline_parse_inst_t *)&cmd_help_brief,
10593 (cmdline_parse_inst_t *)&cmd_help_long,
10594 (cmdline_parse_inst_t *)&cmd_quit,
10595 (cmdline_parse_inst_t *)&cmd_showport,
10596 (cmdline_parse_inst_t *)&cmd_showqueue,
10597 (cmdline_parse_inst_t *)&cmd_showportall,
10598 (cmdline_parse_inst_t *)&cmd_showcfg,
10599 (cmdline_parse_inst_t *)&cmd_start,
10600 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10601 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
10602 (cmdline_parse_inst_t *)&cmd_set_link_up,
10603 (cmdline_parse_inst_t *)&cmd_set_link_down,
10604 (cmdline_parse_inst_t *)&cmd_reset,
10605 (cmdline_parse_inst_t *)&cmd_set_numbers,
10606 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10607 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10608 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10609 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10610 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10611 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
10612 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10613 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10614 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10615 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10616 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10617 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10618 (cmdline_parse_inst_t *)&cmd_set_link_check,
10619 #ifdef RTE_NIC_BYPASS
10620 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10621 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10622 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10623 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10625 #ifdef RTE_LIBRTE_PMD_BOND
10626 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10627 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10628 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10629 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10630 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10631 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10632 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10633 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10634 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10636 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10637 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10638 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10639 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10640 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10641 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10642 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10643 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10644 (cmdline_parse_inst_t *)&cmd_csum_set,
10645 (cmdline_parse_inst_t *)&cmd_csum_show,
10646 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10647 (cmdline_parse_inst_t *)&cmd_tso_set,
10648 (cmdline_parse_inst_t *)&cmd_tso_show,
10649 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10650 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10651 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10652 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10653 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10654 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10655 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10656 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10657 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10658 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10659 (cmdline_parse_inst_t *)&cmd_config_dcb,
10660 (cmdline_parse_inst_t *)&cmd_read_reg,
10661 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10662 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10663 (cmdline_parse_inst_t *)&cmd_write_reg,
10664 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10665 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10666 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10667 (cmdline_parse_inst_t *)&cmd_stop,
10668 (cmdline_parse_inst_t *)&cmd_mac_addr,
10669 (cmdline_parse_inst_t *)&cmd_set_qmap,
10670 (cmdline_parse_inst_t *)&cmd_operate_port,
10671 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10672 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10673 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10674 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10675 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10676 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10677 (cmdline_parse_inst_t *)&cmd_config_mtu,
10678 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10679 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10680 (cmdline_parse_inst_t *)&cmd_config_rss,
10681 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10682 (cmdline_parse_inst_t *)&cmd_config_txqflags,
10683 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10684 (cmdline_parse_inst_t *)&cmd_showport_reta,
10685 (cmdline_parse_inst_t *)&cmd_config_burst,
10686 (cmdline_parse_inst_t *)&cmd_config_thresh,
10687 (cmdline_parse_inst_t *)&cmd_config_threshold,
10688 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10689 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10690 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10691 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10692 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10693 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10694 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10695 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10696 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10697 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10698 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10699 (cmdline_parse_inst_t *)&cmd_global_config,
10700 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10701 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10702 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10703 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10704 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10705 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10706 (cmdline_parse_inst_t *)&cmd_dump,
10707 (cmdline_parse_inst_t *)&cmd_dump_one,
10708 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10709 (cmdline_parse_inst_t *)&cmd_syn_filter,
10710 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10711 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10712 (cmdline_parse_inst_t *)&cmd_flex_filter,
10713 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10714 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10715 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10716 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10717 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10718 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10719 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10720 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10721 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10722 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10723 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10724 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10725 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10726 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10727 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10728 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10729 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10730 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10731 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10732 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10733 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10734 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10735 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10736 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10737 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10738 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10739 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10740 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10741 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10745 /* prompt function, called from main on MASTER lcore */
10749 /* initialize non-constant commands */
10750 cmd_set_fwd_mode_init();
10751 cmd_set_fwd_retry_mode_init();
10753 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10754 if (testpmd_cl == NULL)
10756 cmdline_interact(testpmd_cl);
10757 cmdline_stdin_exit(testpmd_cl);
10763 if (testpmd_cl != NULL)
10764 cmdline_quit(testpmd_cl);
10768 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10770 if (id == (portid_t)RTE_PORT_ALL) {
10773 FOREACH_PORT(pid, ports) {
10774 /* check if need_reconfig has been set to 1 */
10775 if (ports[pid].need_reconfig == 0)
10776 ports[pid].need_reconfig = dev;
10777 /* check if need_reconfig_queues has been set to 1 */
10778 if (ports[pid].need_reconfig_queues == 0)
10779 ports[pid].need_reconfig_queues = queue;
10781 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10782 /* check if need_reconfig has been set to 1 */
10783 if (ports[id].need_reconfig == 0)
10784 ports[id].need_reconfig = dev;
10785 /* check if need_reconfig_queues has been set to 1 */
10786 if (ports[id].need_reconfig_queues == 0)
10787 ports[id].need_reconfig_queues = queue;