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;
1612 hexa_digit_to_value(char hexa_digit)
1614 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1615 return (uint8_t) (hexa_digit - '0');
1616 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1617 return (uint8_t) ((hexa_digit - 'a') + 10);
1618 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1619 return (uint8_t) ((hexa_digit - 'A') + 10);
1620 /* Invalid hexa digit */
1625 parse_and_check_key_hexa_digit(char *key, int idx)
1629 hexa_v = hexa_digit_to_value(key[idx]);
1631 printf("invalid key: character %c at position %d is not a "
1632 "valid hexa digit\n", key[idx], idx);
1637 cmd_config_rss_hash_key_parsed(void *parsed_result,
1638 __attribute__((unused)) struct cmdline *cl,
1639 __attribute__((unused)) void *data)
1641 struct cmd_config_rss_hash_key *res = parsed_result;
1642 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1646 struct rte_eth_dev_info dev_info;
1647 uint8_t hash_key_size;
1650 memset(&dev_info, 0, sizeof(dev_info));
1651 rte_eth_dev_info_get(res->port_id, &dev_info);
1652 if (dev_info.hash_key_size > 0 &&
1653 dev_info.hash_key_size <= sizeof(hash_key))
1654 hash_key_size = dev_info.hash_key_size;
1656 printf("dev_info did not provide a valid hash key size\n");
1659 /* Check the length of the RSS hash key */
1660 key_len = strlen(res->key);
1661 if (key_len != (hash_key_size * 2)) {
1662 printf("key length: %d invalid - key must be a string of %d"
1663 " hexa-decimal numbers\n",
1664 (int) key_len, hash_key_size * 2);
1667 /* Translate RSS hash key into binary representation */
1668 for (i = 0; i < hash_key_size; i++) {
1669 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1672 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1675 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1677 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1681 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1683 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1686 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1687 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1688 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1689 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1690 rss_hash_key, "rss-hash-key");
1691 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1693 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1694 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1695 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1696 "ipv6-tcp-ex#ipv6-udp-ex");
1697 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1700 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1701 .f = cmd_config_rss_hash_key_parsed,
1704 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1705 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1706 "ipv6-sctp|ipv6-other|l2-payload|"
1707 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1708 "<string of hexa digits (variable length, NIC dependent)>\n",
1710 (void *)&cmd_config_rss_hash_key_port,
1711 (void *)&cmd_config_rss_hash_key_config,
1712 (void *)&cmd_config_rss_hash_key_port_id,
1713 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1714 (void *)&cmd_config_rss_hash_key_rss_type,
1715 (void *)&cmd_config_rss_hash_key_value,
1720 /* *** configure port rxq/txq start/stop *** */
1721 struct cmd_config_rxtx_queue {
1722 cmdline_fixed_string_t port;
1724 cmdline_fixed_string_t rxtxq;
1726 cmdline_fixed_string_t opname;
1730 cmd_config_rxtx_queue_parsed(void *parsed_result,
1731 __attribute__((unused)) struct cmdline *cl,
1732 __attribute__((unused)) void *data)
1734 struct cmd_config_rxtx_queue *res = parsed_result;
1739 if (test_done == 0) {
1740 printf("Please stop forwarding first\n");
1744 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1747 if (port_is_started(res->portid) != 1) {
1748 printf("Please start port %u first\n", res->portid);
1752 if (!strcmp(res->rxtxq, "rxq"))
1754 else if (!strcmp(res->rxtxq, "txq"))
1757 printf("Unknown parameter\n");
1761 if (isrx && rx_queue_id_is_invalid(res->qid))
1763 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1766 if (!strcmp(res->opname, "start"))
1768 else if (!strcmp(res->opname, "stop"))
1771 printf("Unknown parameter\n");
1775 if (isstart && isrx)
1776 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1777 else if (!isstart && isrx)
1778 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1779 else if (isstart && !isrx)
1780 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1782 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1784 if (ret == -ENOTSUP)
1785 printf("Function not supported in PMD driver\n");
1788 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1790 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1791 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1792 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1794 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1795 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1796 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1800 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1801 .f = cmd_config_rxtx_queue_parsed,
1803 .help_str = "port X rxq|txq ID start|stop",
1805 (void *)&cmd_config_speed_all_port,
1806 (void *)&cmd_config_rxtx_queue_portid,
1807 (void *)&cmd_config_rxtx_queue_rxtxq,
1808 (void *)&cmd_config_rxtx_queue_qid,
1809 (void *)&cmd_config_rxtx_queue_opname,
1814 /* *** Configure RSS RETA *** */
1815 struct cmd_config_rss_reta {
1816 cmdline_fixed_string_t port;
1817 cmdline_fixed_string_t keyword;
1819 cmdline_fixed_string_t name;
1820 cmdline_fixed_string_t list_name;
1821 cmdline_fixed_string_t list_of_items;
1825 parse_reta_config(const char *str,
1826 struct rte_eth_rss_reta_entry64 *reta_conf,
1827 uint16_t nb_entries)
1831 uint16_t hash_index, idx, shift;
1834 const char *p, *p0 = str;
1841 unsigned long int_fld[_NUM_FLD];
1842 char *str_fld[_NUM_FLD];
1844 while ((p = strchr(p0,'(')) != NULL) {
1846 if((p0 = strchr(p,')')) == NULL)
1850 if(size >= sizeof(s))
1853 snprintf(s, sizeof(s), "%.*s", size, p);
1854 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1856 for (i = 0; i < _NUM_FLD; i++) {
1858 int_fld[i] = strtoul(str_fld[i], &end, 0);
1859 if (errno != 0 || end == str_fld[i] ||
1864 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1865 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1867 if (hash_index >= nb_entries) {
1868 printf("Invalid RETA hash index=%d\n", hash_index);
1872 idx = hash_index / RTE_RETA_GROUP_SIZE;
1873 shift = hash_index % RTE_RETA_GROUP_SIZE;
1874 reta_conf[idx].mask |= (1ULL << shift);
1875 reta_conf[idx].reta[shift] = nb_queue;
1882 cmd_set_rss_reta_parsed(void *parsed_result,
1883 __attribute__((unused)) struct cmdline *cl,
1884 __attribute__((unused)) void *data)
1887 struct rte_eth_dev_info dev_info;
1888 struct rte_eth_rss_reta_entry64 reta_conf[8];
1889 struct cmd_config_rss_reta *res = parsed_result;
1891 memset(&dev_info, 0, sizeof(dev_info));
1892 rte_eth_dev_info_get(res->port_id, &dev_info);
1893 if (dev_info.reta_size == 0) {
1894 printf("Redirection table size is 0 which is "
1895 "invalid for RSS\n");
1898 printf("The reta size of port %d is %u\n",
1899 res->port_id, dev_info.reta_size);
1900 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1901 printf("Currently do not support more than %u entries of "
1902 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1906 memset(reta_conf, 0, sizeof(reta_conf));
1907 if (!strcmp(res->list_name, "reta")) {
1908 if (parse_reta_config(res->list_of_items, reta_conf,
1909 dev_info.reta_size)) {
1910 printf("Invalid RSS Redirection Table "
1911 "config entered\n");
1914 ret = rte_eth_dev_rss_reta_update(res->port_id,
1915 reta_conf, dev_info.reta_size);
1917 printf("Bad redirection table parameter, "
1918 "return code = %d \n", ret);
1922 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1923 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1924 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1925 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1926 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1927 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1928 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1930 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1932 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1935 cmdline_parse_inst_t cmd_config_rss_reta = {
1936 .f = cmd_set_rss_reta_parsed,
1938 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1940 (void *)&cmd_config_rss_reta_port,
1941 (void *)&cmd_config_rss_reta_keyword,
1942 (void *)&cmd_config_rss_reta_port_id,
1943 (void *)&cmd_config_rss_reta_name,
1944 (void *)&cmd_config_rss_reta_list_name,
1945 (void *)&cmd_config_rss_reta_list_of_items,
1950 /* *** SHOW PORT RETA INFO *** */
1951 struct cmd_showport_reta {
1952 cmdline_fixed_string_t show;
1953 cmdline_fixed_string_t port;
1955 cmdline_fixed_string_t rss;
1956 cmdline_fixed_string_t reta;
1958 cmdline_fixed_string_t list_of_items;
1962 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1963 uint16_t nb_entries,
1967 const char *p, *p0 = str;
1971 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1974 p = strchr(p0, '(');
1978 p0 = strchr(p, ')');
1982 if (size >= sizeof(s)) {
1983 printf("The string size exceeds the internal buffer size\n");
1986 snprintf(s, sizeof(s), "%.*s", size, p);
1987 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1988 if (ret <= 0 || ret != num) {
1989 printf("The bits of masks do not match the number of "
1990 "reta entries: %u\n", num);
1993 for (i = 0; i < ret; i++)
1994 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2000 cmd_showport_reta_parsed(void *parsed_result,
2001 __attribute__((unused)) struct cmdline *cl,
2002 __attribute__((unused)) void *data)
2004 struct cmd_showport_reta *res = parsed_result;
2005 struct rte_eth_rss_reta_entry64 reta_conf[8];
2006 struct rte_eth_dev_info dev_info;
2008 memset(&dev_info, 0, sizeof(dev_info));
2009 rte_eth_dev_info_get(res->port_id, &dev_info);
2010 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2011 res->size > ETH_RSS_RETA_SIZE_512) {
2012 printf("Invalid redirection table size: %u\n", res->size);
2016 memset(reta_conf, 0, sizeof(reta_conf));
2017 if (showport_parse_reta_config(reta_conf, res->size,
2018 res->list_of_items) < 0) {
2019 printf("Invalid string: %s for reta masks\n",
2020 res->list_of_items);
2023 port_rss_reta_info(res->port_id, reta_conf, res->size);
2026 cmdline_parse_token_string_t cmd_showport_reta_show =
2027 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2028 cmdline_parse_token_string_t cmd_showport_reta_port =
2029 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2030 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2031 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2032 cmdline_parse_token_string_t cmd_showport_reta_rss =
2033 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2034 cmdline_parse_token_string_t cmd_showport_reta_reta =
2035 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2036 cmdline_parse_token_num_t cmd_showport_reta_size =
2037 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2038 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2039 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2040 list_of_items, NULL);
2042 cmdline_parse_inst_t cmd_showport_reta = {
2043 .f = cmd_showport_reta_parsed,
2045 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2047 (void *)&cmd_showport_reta_show,
2048 (void *)&cmd_showport_reta_port,
2049 (void *)&cmd_showport_reta_port_id,
2050 (void *)&cmd_showport_reta_rss,
2051 (void *)&cmd_showport_reta_reta,
2052 (void *)&cmd_showport_reta_size,
2053 (void *)&cmd_showport_reta_list_of_items,
2058 /* *** Show RSS hash configuration *** */
2059 struct cmd_showport_rss_hash {
2060 cmdline_fixed_string_t show;
2061 cmdline_fixed_string_t port;
2063 cmdline_fixed_string_t rss_hash;
2064 cmdline_fixed_string_t rss_type;
2065 cmdline_fixed_string_t key; /* optional argument */
2068 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2069 __attribute__((unused)) struct cmdline *cl,
2072 struct cmd_showport_rss_hash *res = parsed_result;
2074 port_rss_hash_conf_show(res->port_id, res->rss_type,
2075 show_rss_key != NULL);
2078 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2079 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2080 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2081 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2082 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2083 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2084 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2085 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2087 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2088 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2089 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2090 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2091 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2092 "ipv6-tcp-ex#ipv6-udp-ex");
2093 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2094 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2096 cmdline_parse_inst_t cmd_showport_rss_hash = {
2097 .f = cmd_showport_rss_hash_parsed,
2100 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2101 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2102 "ipv6-sctp|ipv6-other|l2-payload|"
2103 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2105 (void *)&cmd_showport_rss_hash_show,
2106 (void *)&cmd_showport_rss_hash_port,
2107 (void *)&cmd_showport_rss_hash_port_id,
2108 (void *)&cmd_showport_rss_hash_rss_hash,
2109 (void *)&cmd_showport_rss_hash_rss_hash_info,
2114 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2115 .f = cmd_showport_rss_hash_parsed,
2118 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2119 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2120 "ipv6-sctp|ipv6-other|l2-payload|"
2121 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2123 (void *)&cmd_showport_rss_hash_show,
2124 (void *)&cmd_showport_rss_hash_port,
2125 (void *)&cmd_showport_rss_hash_port_id,
2126 (void *)&cmd_showport_rss_hash_rss_hash,
2127 (void *)&cmd_showport_rss_hash_rss_hash_info,
2128 (void *)&cmd_showport_rss_hash_rss_key,
2133 /* *** Configure DCB *** */
2134 struct cmd_config_dcb {
2135 cmdline_fixed_string_t port;
2136 cmdline_fixed_string_t config;
2138 cmdline_fixed_string_t dcb;
2139 cmdline_fixed_string_t vt;
2140 cmdline_fixed_string_t vt_en;
2142 cmdline_fixed_string_t pfc;
2143 cmdline_fixed_string_t pfc_en;
2147 cmd_config_dcb_parsed(void *parsed_result,
2148 __attribute__((unused)) struct cmdline *cl,
2149 __attribute__((unused)) void *data)
2151 struct cmd_config_dcb *res = parsed_result;
2152 portid_t port_id = res->port_id;
2153 struct rte_port *port;
2157 port = &ports[port_id];
2158 /** Check if the port is not started **/
2159 if (port->port_status != RTE_PORT_STOPPED) {
2160 printf("Please stop port %d first\n", port_id);
2164 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2165 printf("The invalid number of traffic class,"
2166 " only 4 or 8 allowed.\n");
2170 if (nb_fwd_lcores < res->num_tcs) {
2171 printf("nb_cores shouldn't be less than number of TCs.\n");
2174 if (!strncmp(res->pfc_en, "on", 2))
2179 /* DCB in VT mode */
2180 if (!strncmp(res->vt_en, "on", 2))
2181 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2182 (enum rte_eth_nb_tcs)res->num_tcs,
2185 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2186 (enum rte_eth_nb_tcs)res->num_tcs,
2191 printf("Cannot initialize network ports.\n");
2195 cmd_reconfig_device_queue(port_id, 1, 1);
2198 cmdline_parse_token_string_t cmd_config_dcb_port =
2199 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2200 cmdline_parse_token_string_t cmd_config_dcb_config =
2201 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2202 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2203 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2204 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2205 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2206 cmdline_parse_token_string_t cmd_config_dcb_vt =
2207 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2208 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2209 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2210 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2211 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2212 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2213 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2214 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2215 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2217 cmdline_parse_inst_t cmd_config_dcb = {
2218 .f = cmd_config_dcb_parsed,
2220 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2222 (void *)&cmd_config_dcb_port,
2223 (void *)&cmd_config_dcb_config,
2224 (void *)&cmd_config_dcb_port_id,
2225 (void *)&cmd_config_dcb_dcb,
2226 (void *)&cmd_config_dcb_vt,
2227 (void *)&cmd_config_dcb_vt_en,
2228 (void *)&cmd_config_dcb_num_tcs,
2229 (void *)&cmd_config_dcb_pfc,
2230 (void *)&cmd_config_dcb_pfc_en,
2235 /* *** configure number of packets per burst *** */
2236 struct cmd_config_burst {
2237 cmdline_fixed_string_t port;
2238 cmdline_fixed_string_t keyword;
2239 cmdline_fixed_string_t all;
2240 cmdline_fixed_string_t name;
2245 cmd_config_burst_parsed(void *parsed_result,
2246 __attribute__((unused)) struct cmdline *cl,
2247 __attribute__((unused)) void *data)
2249 struct cmd_config_burst *res = parsed_result;
2251 if (!all_ports_stopped()) {
2252 printf("Please stop all ports first\n");
2256 if (!strcmp(res->name, "burst")) {
2257 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2258 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2261 nb_pkt_per_burst = res->value;
2263 printf("Unknown parameter\n");
2269 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2272 cmdline_parse_token_string_t cmd_config_burst_port =
2273 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2274 cmdline_parse_token_string_t cmd_config_burst_keyword =
2275 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2276 cmdline_parse_token_string_t cmd_config_burst_all =
2277 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2278 cmdline_parse_token_string_t cmd_config_burst_name =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2280 cmdline_parse_token_num_t cmd_config_burst_value =
2281 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2283 cmdline_parse_inst_t cmd_config_burst = {
2284 .f = cmd_config_burst_parsed,
2286 .help_str = "port config all burst value",
2288 (void *)&cmd_config_burst_port,
2289 (void *)&cmd_config_burst_keyword,
2290 (void *)&cmd_config_burst_all,
2291 (void *)&cmd_config_burst_name,
2292 (void *)&cmd_config_burst_value,
2297 /* *** configure rx/tx queues *** */
2298 struct cmd_config_thresh {
2299 cmdline_fixed_string_t port;
2300 cmdline_fixed_string_t keyword;
2301 cmdline_fixed_string_t all;
2302 cmdline_fixed_string_t name;
2307 cmd_config_thresh_parsed(void *parsed_result,
2308 __attribute__((unused)) struct cmdline *cl,
2309 __attribute__((unused)) void *data)
2311 struct cmd_config_thresh *res = parsed_result;
2313 if (!all_ports_stopped()) {
2314 printf("Please stop all ports first\n");
2318 if (!strcmp(res->name, "txpt"))
2319 tx_pthresh = res->value;
2320 else if(!strcmp(res->name, "txht"))
2321 tx_hthresh = res->value;
2322 else if(!strcmp(res->name, "txwt"))
2323 tx_wthresh = res->value;
2324 else if(!strcmp(res->name, "rxpt"))
2325 rx_pthresh = res->value;
2326 else if(!strcmp(res->name, "rxht"))
2327 rx_hthresh = res->value;
2328 else if(!strcmp(res->name, "rxwt"))
2329 rx_wthresh = res->value;
2331 printf("Unknown parameter\n");
2337 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2340 cmdline_parse_token_string_t cmd_config_thresh_port =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2342 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2343 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2344 cmdline_parse_token_string_t cmd_config_thresh_all =
2345 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2346 cmdline_parse_token_string_t cmd_config_thresh_name =
2347 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2348 "txpt#txht#txwt#rxpt#rxht#rxwt");
2349 cmdline_parse_token_num_t cmd_config_thresh_value =
2350 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2352 cmdline_parse_inst_t cmd_config_thresh = {
2353 .f = cmd_config_thresh_parsed,
2355 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2357 (void *)&cmd_config_thresh_port,
2358 (void *)&cmd_config_thresh_keyword,
2359 (void *)&cmd_config_thresh_all,
2360 (void *)&cmd_config_thresh_name,
2361 (void *)&cmd_config_thresh_value,
2366 /* *** configure free/rs threshold *** */
2367 struct cmd_config_threshold {
2368 cmdline_fixed_string_t port;
2369 cmdline_fixed_string_t keyword;
2370 cmdline_fixed_string_t all;
2371 cmdline_fixed_string_t name;
2376 cmd_config_threshold_parsed(void *parsed_result,
2377 __attribute__((unused)) struct cmdline *cl,
2378 __attribute__((unused)) void *data)
2380 struct cmd_config_threshold *res = parsed_result;
2382 if (!all_ports_stopped()) {
2383 printf("Please stop all ports first\n");
2387 if (!strcmp(res->name, "txfreet"))
2388 tx_free_thresh = res->value;
2389 else if (!strcmp(res->name, "txrst"))
2390 tx_rs_thresh = res->value;
2391 else if (!strcmp(res->name, "rxfreet"))
2392 rx_free_thresh = res->value;
2394 printf("Unknown parameter\n");
2400 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2403 cmdline_parse_token_string_t cmd_config_threshold_port =
2404 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2405 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2406 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2408 cmdline_parse_token_string_t cmd_config_threshold_all =
2409 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2410 cmdline_parse_token_string_t cmd_config_threshold_name =
2411 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2412 "txfreet#txrst#rxfreet");
2413 cmdline_parse_token_num_t cmd_config_threshold_value =
2414 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2416 cmdline_parse_inst_t cmd_config_threshold = {
2417 .f = cmd_config_threshold_parsed,
2419 .help_str = "port config all txfreet|txrst|rxfreet value",
2421 (void *)&cmd_config_threshold_port,
2422 (void *)&cmd_config_threshold_keyword,
2423 (void *)&cmd_config_threshold_all,
2424 (void *)&cmd_config_threshold_name,
2425 (void *)&cmd_config_threshold_value,
2431 struct cmd_stop_result {
2432 cmdline_fixed_string_t stop;
2435 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2436 __attribute__((unused)) struct cmdline *cl,
2437 __attribute__((unused)) void *data)
2439 stop_packet_forwarding();
2442 cmdline_parse_token_string_t cmd_stop_stop =
2443 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2445 cmdline_parse_inst_t cmd_stop = {
2446 .f = cmd_stop_parsed,
2448 .help_str = "stop - stop packet forwarding",
2450 (void *)&cmd_stop_stop,
2455 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2458 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2459 unsigned int *parsed_items, int check_unique_values)
2461 unsigned int nb_item;
2469 * First parse all items in the list and store their value.
2474 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2476 if ((c >= '0') && (c <= '9')) {
2477 value = (unsigned int) (value * 10 + (c - '0'));
2482 printf("character %c is not a decimal digit\n", c);
2486 printf("No valid value before comma\n");
2489 if (nb_item < max_items) {
2490 parsed_items[nb_item] = value;
2496 if (nb_item >= max_items) {
2497 printf("Number of %s = %u > %u (maximum items)\n",
2498 item_name, nb_item + 1, max_items);
2501 parsed_items[nb_item++] = value;
2502 if (! check_unique_values)
2506 * Then, check that all values in the list are differents.
2507 * No optimization here...
2509 for (i = 0; i < nb_item; i++) {
2510 for (j = i + 1; j < nb_item; j++) {
2511 if (parsed_items[j] == parsed_items[i]) {
2512 printf("duplicated %s %u at index %u and %u\n",
2513 item_name, parsed_items[i], i, j);
2521 struct cmd_set_list_result {
2522 cmdline_fixed_string_t cmd_keyword;
2523 cmdline_fixed_string_t list_name;
2524 cmdline_fixed_string_t list_of_items;
2527 static void cmd_set_list_parsed(void *parsed_result,
2528 __attribute__((unused)) struct cmdline *cl,
2529 __attribute__((unused)) void *data)
2531 struct cmd_set_list_result *res;
2533 unsigned int lcorelist[RTE_MAX_LCORE];
2534 unsigned int portlist[RTE_MAX_ETHPORTS];
2536 unsigned int nb_item;
2538 if (test_done == 0) {
2539 printf("Please stop forwarding first\n");
2543 res = parsed_result;
2544 if (!strcmp(res->list_name, "corelist")) {
2545 nb_item = parse_item_list(res->list_of_items, "core",
2547 parsed_items.lcorelist, 1);
2549 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2554 if (!strcmp(res->list_name, "portlist")) {
2555 nb_item = parse_item_list(res->list_of_items, "port",
2557 parsed_items.portlist, 1);
2559 set_fwd_ports_list(parsed_items.portlist, nb_item);
2565 cmdline_parse_token_string_t cmd_set_list_keyword =
2566 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2568 cmdline_parse_token_string_t cmd_set_list_name =
2569 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2570 "corelist#portlist");
2571 cmdline_parse_token_string_t cmd_set_list_of_items =
2572 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2575 cmdline_parse_inst_t cmd_set_fwd_list = {
2576 .f = cmd_set_list_parsed,
2578 .help_str = "set corelist|portlist x[,y]*",
2580 (void *)&cmd_set_list_keyword,
2581 (void *)&cmd_set_list_name,
2582 (void *)&cmd_set_list_of_items,
2587 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2589 struct cmd_setmask_result {
2590 cmdline_fixed_string_t set;
2591 cmdline_fixed_string_t mask;
2595 static void cmd_set_mask_parsed(void *parsed_result,
2596 __attribute__((unused)) struct cmdline *cl,
2597 __attribute__((unused)) void *data)
2599 struct cmd_setmask_result *res = parsed_result;
2601 if (test_done == 0) {
2602 printf("Please stop forwarding first\n");
2605 if (!strcmp(res->mask, "coremask")) {
2606 set_fwd_lcores_mask(res->hexavalue);
2608 } else if (!strcmp(res->mask, "portmask")) {
2609 set_fwd_ports_mask(res->hexavalue);
2614 cmdline_parse_token_string_t cmd_setmask_set =
2615 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2616 cmdline_parse_token_string_t cmd_setmask_mask =
2617 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2618 "coremask#portmask");
2619 cmdline_parse_token_num_t cmd_setmask_value =
2620 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2622 cmdline_parse_inst_t cmd_set_fwd_mask = {
2623 .f = cmd_set_mask_parsed,
2625 .help_str = "set coremask|portmask hexadecimal value",
2627 (void *)&cmd_setmask_set,
2628 (void *)&cmd_setmask_mask,
2629 (void *)&cmd_setmask_value,
2635 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2637 struct cmd_set_result {
2638 cmdline_fixed_string_t set;
2639 cmdline_fixed_string_t what;
2643 static void cmd_set_parsed(void *parsed_result,
2644 __attribute__((unused)) struct cmdline *cl,
2645 __attribute__((unused)) void *data)
2647 struct cmd_set_result *res = parsed_result;
2648 if (!strcmp(res->what, "nbport")) {
2649 set_fwd_ports_number(res->value);
2651 } else if (!strcmp(res->what, "nbcore")) {
2652 set_fwd_lcores_number(res->value);
2654 } else if (!strcmp(res->what, "burst"))
2655 set_nb_pkt_per_burst(res->value);
2656 else if (!strcmp(res->what, "verbose"))
2657 set_verbose_level(res->value);
2660 cmdline_parse_token_string_t cmd_set_set =
2661 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2662 cmdline_parse_token_string_t cmd_set_what =
2663 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2664 "nbport#nbcore#burst#verbose");
2665 cmdline_parse_token_num_t cmd_set_value =
2666 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2668 cmdline_parse_inst_t cmd_set_numbers = {
2669 .f = cmd_set_parsed,
2671 .help_str = "set nbport|nbcore|burst|verbose value",
2673 (void *)&cmd_set_set,
2674 (void *)&cmd_set_what,
2675 (void *)&cmd_set_value,
2680 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2682 struct cmd_set_txpkts_result {
2683 cmdline_fixed_string_t cmd_keyword;
2684 cmdline_fixed_string_t txpkts;
2685 cmdline_fixed_string_t seg_lengths;
2689 cmd_set_txpkts_parsed(void *parsed_result,
2690 __attribute__((unused)) struct cmdline *cl,
2691 __attribute__((unused)) void *data)
2693 struct cmd_set_txpkts_result *res;
2694 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2695 unsigned int nb_segs;
2697 res = parsed_result;
2698 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2699 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2701 set_tx_pkt_segments(seg_lengths, nb_segs);
2704 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2705 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2706 cmd_keyword, "set");
2707 cmdline_parse_token_string_t cmd_set_txpkts_name =
2708 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2710 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2711 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2714 cmdline_parse_inst_t cmd_set_txpkts = {
2715 .f = cmd_set_txpkts_parsed,
2717 .help_str = "set txpkts x[,y]*",
2719 (void *)&cmd_set_txpkts_keyword,
2720 (void *)&cmd_set_txpkts_name,
2721 (void *)&cmd_set_txpkts_lengths,
2726 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2728 struct cmd_set_txsplit_result {
2729 cmdline_fixed_string_t cmd_keyword;
2730 cmdline_fixed_string_t txsplit;
2731 cmdline_fixed_string_t mode;
2735 cmd_set_txsplit_parsed(void *parsed_result,
2736 __attribute__((unused)) struct cmdline *cl,
2737 __attribute__((unused)) void *data)
2739 struct cmd_set_txsplit_result *res;
2741 res = parsed_result;
2742 set_tx_pkt_split(res->mode);
2745 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2746 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2747 cmd_keyword, "set");
2748 cmdline_parse_token_string_t cmd_set_txsplit_name =
2749 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2750 txsplit, "txsplit");
2751 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2752 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2755 cmdline_parse_inst_t cmd_set_txsplit = {
2756 .f = cmd_set_txsplit_parsed,
2758 .help_str = "set txsplit on|off|rand",
2760 (void *)&cmd_set_txsplit_keyword,
2761 (void *)&cmd_set_txsplit_name,
2762 (void *)&cmd_set_txsplit_mode,
2767 /* *** CONFIG TX QUEUE FLAGS *** */
2769 struct cmd_config_txqflags_result {
2770 cmdline_fixed_string_t port;
2771 cmdline_fixed_string_t config;
2772 cmdline_fixed_string_t all;
2773 cmdline_fixed_string_t what;
2777 static void cmd_config_txqflags_parsed(void *parsed_result,
2778 __attribute__((unused)) struct cmdline *cl,
2779 __attribute__((unused)) void *data)
2781 struct cmd_config_txqflags_result *res = parsed_result;
2783 if (!all_ports_stopped()) {
2784 printf("Please stop all ports first\n");
2788 if (strcmp(res->what, "txqflags")) {
2789 printf("Unknown parameter\n");
2793 if (res->hexvalue >= 0) {
2794 txq_flags = res->hexvalue;
2796 printf("txqflags must be >= 0\n");
2802 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2805 cmdline_parse_token_string_t cmd_config_txqflags_port =
2806 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2808 cmdline_parse_token_string_t cmd_config_txqflags_config =
2809 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2811 cmdline_parse_token_string_t cmd_config_txqflags_all =
2812 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2814 cmdline_parse_token_string_t cmd_config_txqflags_what =
2815 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2817 cmdline_parse_token_num_t cmd_config_txqflags_value =
2818 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2821 cmdline_parse_inst_t cmd_config_txqflags = {
2822 .f = cmd_config_txqflags_parsed,
2824 .help_str = "port config all txqflags value",
2826 (void *)&cmd_config_txqflags_port,
2827 (void *)&cmd_config_txqflags_config,
2828 (void *)&cmd_config_txqflags_all,
2829 (void *)&cmd_config_txqflags_what,
2830 (void *)&cmd_config_txqflags_value,
2835 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2836 struct cmd_rx_vlan_filter_all_result {
2837 cmdline_fixed_string_t rx_vlan;
2838 cmdline_fixed_string_t what;
2839 cmdline_fixed_string_t all;
2844 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2845 __attribute__((unused)) struct cmdline *cl,
2846 __attribute__((unused)) void *data)
2848 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2850 if (!strcmp(res->what, "add"))
2851 rx_vlan_all_filter_set(res->port_id, 1);
2853 rx_vlan_all_filter_set(res->port_id, 0);
2856 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2857 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2858 rx_vlan, "rx_vlan");
2859 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2860 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2862 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2863 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2865 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2866 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2869 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2870 .f = cmd_rx_vlan_filter_all_parsed,
2872 .help_str = "add/remove all identifiers to/from the set of VLAN "
2873 "Identifiers filtered by a port",
2875 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2876 (void *)&cmd_rx_vlan_filter_all_what,
2877 (void *)&cmd_rx_vlan_filter_all_all,
2878 (void *)&cmd_rx_vlan_filter_all_portid,
2883 /* *** VLAN OFFLOAD SET ON A PORT *** */
2884 struct cmd_vlan_offload_result {
2885 cmdline_fixed_string_t vlan;
2886 cmdline_fixed_string_t set;
2887 cmdline_fixed_string_t vlan_type;
2888 cmdline_fixed_string_t what;
2889 cmdline_fixed_string_t on;
2890 cmdline_fixed_string_t port_id;
2894 cmd_vlan_offload_parsed(void *parsed_result,
2895 __attribute__((unused)) struct cmdline *cl,
2896 __attribute__((unused)) void *data)
2899 struct cmd_vlan_offload_result *res = parsed_result;
2902 portid_t port_id = 0;
2906 len = strnlen(str, STR_TOKEN_SIZE);
2908 /* Get port_id first */
2916 tmp = strtoul(str, NULL, 0);
2917 /* If port_id greater that what portid_t can represent, return */
2918 if(tmp >= RTE_MAX_ETHPORTS)
2920 port_id = (portid_t)tmp;
2922 if (!strcmp(res->on, "on"))
2927 if (!strcmp(res->what, "strip"))
2928 rx_vlan_strip_set(port_id, on);
2929 else if(!strcmp(res->what, "stripq")){
2930 uint16_t queue_id = 0;
2932 /* No queue_id, return */
2934 printf("must specify (port,queue_id)\n");
2937 tmp = strtoul(str + i + 1, NULL, 0);
2938 /* If queue_id greater that what 16-bits can represent, return */
2942 queue_id = (uint16_t)tmp;
2943 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2945 else if (!strcmp(res->what, "filter"))
2946 rx_vlan_filter_set(port_id, on);
2948 vlan_extend_set(port_id, on);
2953 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2954 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2956 cmdline_parse_token_string_t cmd_vlan_offload_set =
2957 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2959 cmdline_parse_token_string_t cmd_vlan_offload_what =
2960 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2961 what, "strip#filter#qinq#stripq");
2962 cmdline_parse_token_string_t cmd_vlan_offload_on =
2963 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2965 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2966 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2969 cmdline_parse_inst_t cmd_vlan_offload = {
2970 .f = cmd_vlan_offload_parsed,
2972 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2973 " qinq(extended) for both rx/tx sides ",
2975 (void *)&cmd_vlan_offload_vlan,
2976 (void *)&cmd_vlan_offload_set,
2977 (void *)&cmd_vlan_offload_what,
2978 (void *)&cmd_vlan_offload_on,
2979 (void *)&cmd_vlan_offload_portid,
2984 /* *** VLAN TPID SET ON A PORT *** */
2985 struct cmd_vlan_tpid_result {
2986 cmdline_fixed_string_t vlan;
2987 cmdline_fixed_string_t set;
2988 cmdline_fixed_string_t vlan_type;
2989 cmdline_fixed_string_t what;
2995 cmd_vlan_tpid_parsed(void *parsed_result,
2996 __attribute__((unused)) struct cmdline *cl,
2997 __attribute__((unused)) void *data)
2999 struct cmd_vlan_tpid_result *res = parsed_result;
3000 enum rte_vlan_type vlan_type;
3002 if (!strcmp(res->vlan_type, "inner"))
3003 vlan_type = ETH_VLAN_TYPE_INNER;
3004 else if (!strcmp(res->vlan_type, "outer"))
3005 vlan_type = ETH_VLAN_TYPE_OUTER;
3007 printf("Unknown vlan type\n");
3010 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3013 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3014 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3016 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3017 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3019 cmdline_parse_token_string_t cmd_vlan_type =
3020 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3021 vlan_type, "inner#outer");
3022 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3023 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3025 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3026 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3028 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3029 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3032 cmdline_parse_inst_t cmd_vlan_tpid = {
3033 .f = cmd_vlan_tpid_parsed,
3035 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
3038 (void *)&cmd_vlan_tpid_vlan,
3039 (void *)&cmd_vlan_tpid_set,
3040 (void *)&cmd_vlan_type,
3041 (void *)&cmd_vlan_tpid_what,
3042 (void *)&cmd_vlan_tpid_tpid,
3043 (void *)&cmd_vlan_tpid_portid,
3048 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3049 struct cmd_rx_vlan_filter_result {
3050 cmdline_fixed_string_t rx_vlan;
3051 cmdline_fixed_string_t what;
3057 cmd_rx_vlan_filter_parsed(void *parsed_result,
3058 __attribute__((unused)) struct cmdline *cl,
3059 __attribute__((unused)) void *data)
3061 struct cmd_rx_vlan_filter_result *res = parsed_result;
3063 if (!strcmp(res->what, "add"))
3064 rx_vft_set(res->port_id, res->vlan_id, 1);
3066 rx_vft_set(res->port_id, res->vlan_id, 0);
3069 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3070 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3071 rx_vlan, "rx_vlan");
3072 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3073 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3075 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3076 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3078 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3079 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3082 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3083 .f = cmd_rx_vlan_filter_parsed,
3085 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
3086 "Identifiers filtered by a port",
3088 (void *)&cmd_rx_vlan_filter_rx_vlan,
3089 (void *)&cmd_rx_vlan_filter_what,
3090 (void *)&cmd_rx_vlan_filter_vlanid,
3091 (void *)&cmd_rx_vlan_filter_portid,
3096 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3097 struct cmd_tx_vlan_set_result {
3098 cmdline_fixed_string_t tx_vlan;
3099 cmdline_fixed_string_t set;
3105 cmd_tx_vlan_set_parsed(void *parsed_result,
3106 __attribute__((unused)) struct cmdline *cl,
3107 __attribute__((unused)) void *data)
3109 struct cmd_tx_vlan_set_result *res = parsed_result;
3111 tx_vlan_set(res->port_id, res->vlan_id);
3114 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3115 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3116 tx_vlan, "tx_vlan");
3117 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3118 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3120 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3121 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3123 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3124 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3127 cmdline_parse_inst_t cmd_tx_vlan_set = {
3128 .f = cmd_tx_vlan_set_parsed,
3130 .help_str = "enable hardware insertion of a single VLAN header "
3131 "with a given TAG Identifier in packets sent on a port",
3133 (void *)&cmd_tx_vlan_set_tx_vlan,
3134 (void *)&cmd_tx_vlan_set_set,
3135 (void *)&cmd_tx_vlan_set_portid,
3136 (void *)&cmd_tx_vlan_set_vlanid,
3141 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3142 struct cmd_tx_vlan_set_qinq_result {
3143 cmdline_fixed_string_t tx_vlan;
3144 cmdline_fixed_string_t set;
3147 uint16_t vlan_id_outer;
3151 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3152 __attribute__((unused)) struct cmdline *cl,
3153 __attribute__((unused)) void *data)
3155 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3157 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3160 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3161 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3162 tx_vlan, "tx_vlan");
3163 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3164 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3166 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3167 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3169 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3170 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3172 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3173 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3174 vlan_id_outer, UINT16);
3176 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3177 .f = cmd_tx_vlan_set_qinq_parsed,
3179 .help_str = "enable hardware insertion of double VLAN header "
3180 "with given TAG Identifiers in packets sent on a port",
3182 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3183 (void *)&cmd_tx_vlan_set_qinq_set,
3184 (void *)&cmd_tx_vlan_set_qinq_portid,
3185 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3186 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3191 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3192 struct cmd_tx_vlan_set_pvid_result {
3193 cmdline_fixed_string_t tx_vlan;
3194 cmdline_fixed_string_t set;
3195 cmdline_fixed_string_t pvid;
3198 cmdline_fixed_string_t mode;
3202 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3203 __attribute__((unused)) struct cmdline *cl,
3204 __attribute__((unused)) void *data)
3206 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3208 if (strcmp(res->mode, "on") == 0)
3209 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3211 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3214 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3215 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3216 tx_vlan, "tx_vlan");
3217 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3218 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3223 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3224 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3226 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3227 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3229 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3230 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3233 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3234 .f = cmd_tx_vlan_set_pvid_parsed,
3236 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3238 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3239 (void *)&cmd_tx_vlan_set_pvid_set,
3240 (void *)&cmd_tx_vlan_set_pvid_pvid,
3241 (void *)&cmd_tx_vlan_set_pvid_port_id,
3242 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3243 (void *)&cmd_tx_vlan_set_pvid_mode,
3248 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3249 struct cmd_tx_vlan_reset_result {
3250 cmdline_fixed_string_t tx_vlan;
3251 cmdline_fixed_string_t reset;
3256 cmd_tx_vlan_reset_parsed(void *parsed_result,
3257 __attribute__((unused)) struct cmdline *cl,
3258 __attribute__((unused)) void *data)
3260 struct cmd_tx_vlan_reset_result *res = parsed_result;
3262 tx_vlan_reset(res->port_id);
3265 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3266 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3267 tx_vlan, "tx_vlan");
3268 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3269 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3271 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3272 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3275 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3276 .f = cmd_tx_vlan_reset_parsed,
3278 .help_str = "disable hardware insertion of a VLAN header in packets "
3281 (void *)&cmd_tx_vlan_reset_tx_vlan,
3282 (void *)&cmd_tx_vlan_reset_reset,
3283 (void *)&cmd_tx_vlan_reset_portid,
3289 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3290 struct cmd_csum_result {
3291 cmdline_fixed_string_t csum;
3292 cmdline_fixed_string_t mode;
3293 cmdline_fixed_string_t proto;
3294 cmdline_fixed_string_t hwsw;
3299 csum_show(int port_id)
3301 struct rte_eth_dev_info dev_info;
3304 ol_flags = ports[port_id].tx_ol_flags;
3305 printf("Parse tunnel is %s\n",
3306 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3307 printf("IP checksum offload is %s\n",
3308 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3309 printf("UDP checksum offload is %s\n",
3310 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3311 printf("TCP checksum offload is %s\n",
3312 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3313 printf("SCTP checksum offload is %s\n",
3314 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3315 printf("Outer-Ip checksum offload is %s\n",
3316 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3318 /* display warnings if configuration is not supported by the NIC */
3319 rte_eth_dev_info_get(port_id, &dev_info);
3320 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3321 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3322 printf("Warning: hardware IP checksum enabled but not "
3323 "supported by port %d\n", port_id);
3325 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3326 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3327 printf("Warning: hardware UDP checksum enabled but not "
3328 "supported by port %d\n", port_id);
3330 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3331 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3332 printf("Warning: hardware TCP checksum enabled but not "
3333 "supported by port %d\n", port_id);
3335 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3336 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3337 printf("Warning: hardware SCTP checksum enabled but not "
3338 "supported by port %d\n", port_id);
3340 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3341 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3342 printf("Warning: hardware outer IP checksum enabled but not "
3343 "supported by port %d\n", port_id);
3348 cmd_csum_parsed(void *parsed_result,
3349 __attribute__((unused)) struct cmdline *cl,
3350 __attribute__((unused)) void *data)
3352 struct cmd_csum_result *res = parsed_result;
3356 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3357 printf("invalid port %d\n", res->port_id);
3361 if (!strcmp(res->mode, "set")) {
3363 if (!strcmp(res->hwsw, "hw"))
3366 if (!strcmp(res->proto, "ip")) {
3367 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3368 } else if (!strcmp(res->proto, "udp")) {
3369 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3370 } else if (!strcmp(res->proto, "tcp")) {
3371 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3372 } else if (!strcmp(res->proto, "sctp")) {
3373 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3374 } else if (!strcmp(res->proto, "outer-ip")) {
3375 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3379 ports[res->port_id].tx_ol_flags |= mask;
3381 ports[res->port_id].tx_ol_flags &= (~mask);
3383 csum_show(res->port_id);
3386 cmdline_parse_token_string_t cmd_csum_csum =
3387 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3389 cmdline_parse_token_string_t cmd_csum_mode =
3390 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3392 cmdline_parse_token_string_t cmd_csum_proto =
3393 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3394 proto, "ip#tcp#udp#sctp#outer-ip");
3395 cmdline_parse_token_string_t cmd_csum_hwsw =
3396 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3398 cmdline_parse_token_num_t cmd_csum_portid =
3399 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3402 cmdline_parse_inst_t cmd_csum_set = {
3403 .f = cmd_csum_parsed,
3405 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3406 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3408 (void *)&cmd_csum_csum,
3409 (void *)&cmd_csum_mode,
3410 (void *)&cmd_csum_proto,
3411 (void *)&cmd_csum_hwsw,
3412 (void *)&cmd_csum_portid,
3417 cmdline_parse_token_string_t cmd_csum_mode_show =
3418 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3421 cmdline_parse_inst_t cmd_csum_show = {
3422 .f = cmd_csum_parsed,
3424 .help_str = "show checksum offload configuration: csum show <port>",
3426 (void *)&cmd_csum_csum,
3427 (void *)&cmd_csum_mode_show,
3428 (void *)&cmd_csum_portid,
3433 /* Enable/disable tunnel parsing */
3434 struct cmd_csum_tunnel_result {
3435 cmdline_fixed_string_t csum;
3436 cmdline_fixed_string_t parse;
3437 cmdline_fixed_string_t onoff;
3442 cmd_csum_tunnel_parsed(void *parsed_result,
3443 __attribute__((unused)) struct cmdline *cl,
3444 __attribute__((unused)) void *data)
3446 struct cmd_csum_tunnel_result *res = parsed_result;
3448 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3451 if (!strcmp(res->onoff, "on"))
3452 ports[res->port_id].tx_ol_flags |=
3453 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3455 ports[res->port_id].tx_ol_flags &=
3456 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3458 csum_show(res->port_id);
3461 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3462 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3464 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3465 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3466 parse, "parse_tunnel");
3467 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3468 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3470 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3471 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3474 cmdline_parse_inst_t cmd_csum_tunnel = {
3475 .f = cmd_csum_tunnel_parsed,
3477 .help_str = "enable/disable parsing of tunnels for csum engine: "
3478 "csum parse_tunnel on|off <tx-port>",
3480 (void *)&cmd_csum_tunnel_csum,
3481 (void *)&cmd_csum_tunnel_parse,
3482 (void *)&cmd_csum_tunnel_onoff,
3483 (void *)&cmd_csum_tunnel_portid,
3488 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3489 struct cmd_tso_set_result {
3490 cmdline_fixed_string_t tso;
3491 cmdline_fixed_string_t mode;
3497 cmd_tso_set_parsed(void *parsed_result,
3498 __attribute__((unused)) struct cmdline *cl,
3499 __attribute__((unused)) void *data)
3501 struct cmd_tso_set_result *res = parsed_result;
3502 struct rte_eth_dev_info dev_info;
3504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3507 if (!strcmp(res->mode, "set"))
3508 ports[res->port_id].tso_segsz = res->tso_segsz;
3510 if (ports[res->port_id].tso_segsz == 0)
3511 printf("TSO for non-tunneled packets is disabled\n");
3513 printf("TSO segment size for non-tunneled packets is %d\n",
3514 ports[res->port_id].tso_segsz);
3516 /* display warnings if configuration is not supported by the NIC */
3517 rte_eth_dev_info_get(res->port_id, &dev_info);
3518 if ((ports[res->port_id].tso_segsz != 0) &&
3519 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3520 printf("Warning: TSO enabled but not "
3521 "supported by port %d\n", res->port_id);
3525 cmdline_parse_token_string_t cmd_tso_set_tso =
3526 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3528 cmdline_parse_token_string_t cmd_tso_set_mode =
3529 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3531 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3532 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3534 cmdline_parse_token_num_t cmd_tso_set_portid =
3535 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3538 cmdline_parse_inst_t cmd_tso_set = {
3539 .f = cmd_tso_set_parsed,
3541 .help_str = "Set TSO segment size of non-tunneled packets "
3542 "for csum engine (0 to disable): tso set <tso_segsz> <port>",
3544 (void *)&cmd_tso_set_tso,
3545 (void *)&cmd_tso_set_mode,
3546 (void *)&cmd_tso_set_tso_segsz,
3547 (void *)&cmd_tso_set_portid,
3552 cmdline_parse_token_string_t cmd_tso_show_mode =
3553 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3557 cmdline_parse_inst_t cmd_tso_show = {
3558 .f = cmd_tso_set_parsed,
3560 .help_str = "Show TSO segment size of non-tunneled packets "
3561 "for csum engine: tso show <port>",
3563 (void *)&cmd_tso_set_tso,
3564 (void *)&cmd_tso_show_mode,
3565 (void *)&cmd_tso_set_portid,
3570 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3571 struct cmd_tunnel_tso_set_result {
3572 cmdline_fixed_string_t tso;
3573 cmdline_fixed_string_t mode;
3579 check_tunnel_tso_nic_support(uint8_t port_id)
3581 struct rte_eth_dev_info dev_info;
3583 rte_eth_dev_info_get(port_id, &dev_info);
3584 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3585 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3586 "supported by port %d\n", port_id);
3587 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3588 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3589 "supported by port %d\n", port_id);
3590 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3591 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3592 "supported by port %d\n", port_id);
3593 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3594 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3595 "supported by port %d\n", port_id);
3599 cmd_tunnel_tso_set_parsed(void *parsed_result,
3600 __attribute__((unused)) struct cmdline *cl,
3601 __attribute__((unused)) void *data)
3603 struct cmd_tunnel_tso_set_result *res = parsed_result;
3605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3608 if (!strcmp(res->mode, "set"))
3609 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3611 if (ports[res->port_id].tunnel_tso_segsz == 0)
3612 printf("TSO for tunneled packets is disabled\n");
3614 printf("TSO segment size for tunneled packets is %d\n",
3615 ports[res->port_id].tunnel_tso_segsz);
3617 /* Below conditions are needed to make it work:
3618 * (1) tunnel TSO is supported by the NIC;
3619 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3621 * (3) for tunneled pkts with outer L3 of IPv4,
3622 * "csum set outer-ip" must be set to hw, because after tso,
3623 * total_len of outer IP header is changed, and the checksum
3624 * of outer IP header calculated by sw should be wrong; that
3625 * is not necessary for IPv6 tunneled pkts because there's no
3626 * checksum in IP header anymore.
3628 check_tunnel_tso_nic_support(res->port_id);
3630 if (!(ports[res->port_id].tx_ol_flags &
3631 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3632 printf("Warning: csum parse_tunnel must be set "
3633 "so that tunneled packets are recognized\n");
3634 if (!(ports[res->port_id].tx_ol_flags &
3635 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3636 printf("Warning: csum set outer-ip must be set to hw "
3637 "if outer L3 is IPv4; not necessary for IPv6\n");
3641 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3642 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3644 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3645 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3647 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3648 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3650 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3651 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3654 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3655 .f = cmd_tunnel_tso_set_parsed,
3657 .help_str = "Set TSO segment size of tunneled packets for csum engine "
3658 "(0 to disable): tunnel_tso set <tso_segsz> <port>",
3660 (void *)&cmd_tunnel_tso_set_tso,
3661 (void *)&cmd_tunnel_tso_set_mode,
3662 (void *)&cmd_tunnel_tso_set_tso_segsz,
3663 (void *)&cmd_tunnel_tso_set_portid,
3668 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3669 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3673 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3674 .f = cmd_tunnel_tso_set_parsed,
3676 .help_str = "Show TSO segment size of tunneled packets "
3677 "for csum engine: tunnel_tso show <port>",
3679 (void *)&cmd_tunnel_tso_set_tso,
3680 (void *)&cmd_tunnel_tso_show_mode,
3681 (void *)&cmd_tunnel_tso_set_portid,
3686 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3687 struct cmd_set_flush_rx {
3688 cmdline_fixed_string_t set;
3689 cmdline_fixed_string_t flush_rx;
3690 cmdline_fixed_string_t mode;
3694 cmd_set_flush_rx_parsed(void *parsed_result,
3695 __attribute__((unused)) struct cmdline *cl,
3696 __attribute__((unused)) void *data)
3698 struct cmd_set_flush_rx *res = parsed_result;
3699 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3702 cmdline_parse_token_string_t cmd_setflushrx_set =
3703 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3705 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3706 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3707 flush_rx, "flush_rx");
3708 cmdline_parse_token_string_t cmd_setflushrx_mode =
3709 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3713 cmdline_parse_inst_t cmd_set_flush_rx = {
3714 .f = cmd_set_flush_rx_parsed,
3715 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3718 (void *)&cmd_setflushrx_set,
3719 (void *)&cmd_setflushrx_flush_rx,
3720 (void *)&cmd_setflushrx_mode,
3725 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3726 struct cmd_set_link_check {
3727 cmdline_fixed_string_t set;
3728 cmdline_fixed_string_t link_check;
3729 cmdline_fixed_string_t mode;
3733 cmd_set_link_check_parsed(void *parsed_result,
3734 __attribute__((unused)) struct cmdline *cl,
3735 __attribute__((unused)) void *data)
3737 struct cmd_set_link_check *res = parsed_result;
3738 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3741 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3742 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3744 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3745 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3746 link_check, "link_check");
3747 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3748 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3752 cmdline_parse_inst_t cmd_set_link_check = {
3753 .f = cmd_set_link_check_parsed,
3754 .help_str = "set link_check on|off: enable/disable link status check "
3755 "when starting/stopping a port",
3758 (void *)&cmd_setlinkcheck_set,
3759 (void *)&cmd_setlinkcheck_link_check,
3760 (void *)&cmd_setlinkcheck_mode,
3765 #ifdef RTE_NIC_BYPASS
3766 /* *** SET NIC BYPASS MODE *** */
3767 struct cmd_set_bypass_mode_result {
3768 cmdline_fixed_string_t set;
3769 cmdline_fixed_string_t bypass;
3770 cmdline_fixed_string_t mode;
3771 cmdline_fixed_string_t value;
3776 cmd_set_bypass_mode_parsed(void *parsed_result,
3777 __attribute__((unused)) struct cmdline *cl,
3778 __attribute__((unused)) void *data)
3780 struct cmd_set_bypass_mode_result *res = parsed_result;
3781 portid_t port_id = res->port_id;
3782 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3784 if (!strcmp(res->value, "bypass"))
3785 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3786 else if (!strcmp(res->value, "isolate"))
3787 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3789 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3791 /* Set the bypass mode for the relevant port. */
3792 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3793 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3797 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3800 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3801 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3803 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3804 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3806 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3808 value, "normal#bypass#isolate");
3809 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3810 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3813 cmdline_parse_inst_t cmd_set_bypass_mode = {
3814 .f = cmd_set_bypass_mode_parsed,
3815 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3816 "Set the NIC bypass mode for port_id",
3819 (void *)&cmd_setbypass_mode_set,
3820 (void *)&cmd_setbypass_mode_bypass,
3821 (void *)&cmd_setbypass_mode_mode,
3822 (void *)&cmd_setbypass_mode_value,
3823 (void *)&cmd_setbypass_mode_port,
3828 /* *** SET NIC BYPASS EVENT *** */
3829 struct cmd_set_bypass_event_result {
3830 cmdline_fixed_string_t set;
3831 cmdline_fixed_string_t bypass;
3832 cmdline_fixed_string_t event;
3833 cmdline_fixed_string_t event_value;
3834 cmdline_fixed_string_t mode;
3835 cmdline_fixed_string_t mode_value;
3840 cmd_set_bypass_event_parsed(void *parsed_result,
3841 __attribute__((unused)) struct cmdline *cl,
3842 __attribute__((unused)) void *data)
3845 struct cmd_set_bypass_event_result *res = parsed_result;
3846 portid_t port_id = res->port_id;
3847 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3848 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3850 if (!strcmp(res->event_value, "timeout"))
3851 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3852 else if (!strcmp(res->event_value, "os_on"))
3853 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3854 else if (!strcmp(res->event_value, "os_off"))
3855 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3856 else if (!strcmp(res->event_value, "power_on"))
3857 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3858 else if (!strcmp(res->event_value, "power_off"))
3859 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3861 bypass_event = RTE_BYPASS_EVENT_NONE;
3863 if (!strcmp(res->mode_value, "bypass"))
3864 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3865 else if (!strcmp(res->mode_value, "isolate"))
3866 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3868 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3870 /* Set the watchdog timeout. */
3871 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3874 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3875 (rc = rte_eth_dev_wd_timeout_store(port_id,
3876 bypass_timeout)) != 0) {
3877 printf("Failed to set timeout value %u "
3878 "for port %d, errto code: %d.\n",
3879 bypass_timeout, port_id, rc);
3883 /* Set the bypass event to transition to bypass mode. */
3884 if (0 != rte_eth_dev_bypass_event_store(port_id,
3885 bypass_event, bypass_mode)) {
3886 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3891 cmdline_parse_token_string_t cmd_setbypass_event_set =
3892 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3894 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3895 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3897 cmdline_parse_token_string_t cmd_setbypass_event_event =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3900 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3902 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3903 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3904 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3906 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3907 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3908 mode_value, "normal#bypass#isolate");
3909 cmdline_parse_token_num_t cmd_setbypass_event_port =
3910 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3913 cmdline_parse_inst_t cmd_set_bypass_event = {
3914 .f = cmd_set_bypass_event_parsed,
3915 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3916 "mode (normal|bypass|isolate) (port_id): "
3917 "Set the NIC bypass event mode for port_id",
3920 (void *)&cmd_setbypass_event_set,
3921 (void *)&cmd_setbypass_event_bypass,
3922 (void *)&cmd_setbypass_event_event,
3923 (void *)&cmd_setbypass_event_event_value,
3924 (void *)&cmd_setbypass_event_mode,
3925 (void *)&cmd_setbypass_event_mode_value,
3926 (void *)&cmd_setbypass_event_port,
3932 /* *** SET NIC BYPASS TIMEOUT *** */
3933 struct cmd_set_bypass_timeout_result {
3934 cmdline_fixed_string_t set;
3935 cmdline_fixed_string_t bypass;
3936 cmdline_fixed_string_t timeout;
3937 cmdline_fixed_string_t value;
3941 cmd_set_bypass_timeout_parsed(void *parsed_result,
3942 __attribute__((unused)) struct cmdline *cl,
3943 __attribute__((unused)) void *data)
3945 struct cmd_set_bypass_timeout_result *res = parsed_result;
3947 if (!strcmp(res->value, "1.5"))
3948 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3949 else if (!strcmp(res->value, "2"))
3950 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3951 else if (!strcmp(res->value, "3"))
3952 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3953 else if (!strcmp(res->value, "4"))
3954 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3955 else if (!strcmp(res->value, "8"))
3956 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3957 else if (!strcmp(res->value, "16"))
3958 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3959 else if (!strcmp(res->value, "32"))
3960 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3962 bypass_timeout = RTE_BYPASS_TMT_OFF;
3965 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3966 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3968 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3971 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3973 timeout, "timeout");
3974 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3976 value, "0#1.5#2#3#4#8#16#32");
3978 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3979 .f = cmd_set_bypass_timeout_parsed,
3980 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3981 "Set the NIC bypass watchdog timeout",
3984 (void *)&cmd_setbypass_timeout_set,
3985 (void *)&cmd_setbypass_timeout_bypass,
3986 (void *)&cmd_setbypass_timeout_timeout,
3987 (void *)&cmd_setbypass_timeout_value,
3992 /* *** SHOW NIC BYPASS MODE *** */
3993 struct cmd_show_bypass_config_result {
3994 cmdline_fixed_string_t show;
3995 cmdline_fixed_string_t bypass;
3996 cmdline_fixed_string_t config;
4001 cmd_show_bypass_config_parsed(void *parsed_result,
4002 __attribute__((unused)) struct cmdline *cl,
4003 __attribute__((unused)) void *data)
4005 struct cmd_show_bypass_config_result *res = parsed_result;
4006 uint32_t event_mode;
4007 uint32_t bypass_mode;
4008 portid_t port_id = res->port_id;
4009 uint32_t timeout = bypass_timeout;
4012 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4013 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4014 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4015 {"UNKNOWN", "normal", "bypass", "isolate"};
4016 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4023 int num_events = (sizeof events) / (sizeof events[0]);
4025 /* Display the bypass mode.*/
4026 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4027 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4031 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4032 bypass_mode = RTE_BYPASS_MODE_NONE;
4034 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4037 /* Display the bypass timeout.*/
4038 if (!RTE_BYPASS_TMT_VALID(timeout))
4039 timeout = RTE_BYPASS_TMT_OFF;
4041 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4043 /* Display the bypass events and associated modes. */
4044 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4046 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4047 printf("\tFailed to get bypass mode for event = %s\n",
4050 if (!RTE_BYPASS_MODE_VALID(event_mode))
4051 event_mode = RTE_BYPASS_MODE_NONE;
4053 printf("\tbypass event: %-16s = %s\n", events[i],
4059 cmdline_parse_token_string_t cmd_showbypass_config_show =
4060 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4062 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4063 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4065 cmdline_parse_token_string_t cmd_showbypass_config_config =
4066 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4068 cmdline_parse_token_num_t cmd_showbypass_config_port =
4069 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4072 cmdline_parse_inst_t cmd_show_bypass_config = {
4073 .f = cmd_show_bypass_config_parsed,
4074 .help_str = "show bypass config (port_id): "
4075 "Show the NIC bypass config for port_id",
4078 (void *)&cmd_showbypass_config_show,
4079 (void *)&cmd_showbypass_config_bypass,
4080 (void *)&cmd_showbypass_config_config,
4081 (void *)&cmd_showbypass_config_port,
4087 #ifdef RTE_LIBRTE_PMD_BOND
4088 /* *** SET BONDING MODE *** */
4089 struct cmd_set_bonding_mode_result {
4090 cmdline_fixed_string_t set;
4091 cmdline_fixed_string_t bonding;
4092 cmdline_fixed_string_t mode;
4097 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4098 __attribute__((unused)) struct cmdline *cl,
4099 __attribute__((unused)) void *data)
4101 struct cmd_set_bonding_mode_result *res = parsed_result;
4102 portid_t port_id = res->port_id;
4104 /* Set the bonding mode for the relevant port. */
4105 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4106 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4109 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4110 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4112 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4113 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4114 bonding, "bonding");
4115 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4116 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4118 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4119 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4121 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4122 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4125 cmdline_parse_inst_t cmd_set_bonding_mode = {
4126 .f = cmd_set_bonding_mode_parsed,
4127 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
4130 (void *) &cmd_setbonding_mode_set,
4131 (void *) &cmd_setbonding_mode_bonding,
4132 (void *) &cmd_setbonding_mode_mode,
4133 (void *) &cmd_setbonding_mode_value,
4134 (void *) &cmd_setbonding_mode_port,
4139 /* *** SET BALANCE XMIT POLICY *** */
4140 struct cmd_set_bonding_balance_xmit_policy_result {
4141 cmdline_fixed_string_t set;
4142 cmdline_fixed_string_t bonding;
4143 cmdline_fixed_string_t balance_xmit_policy;
4145 cmdline_fixed_string_t policy;
4148 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4149 __attribute__((unused)) struct cmdline *cl,
4150 __attribute__((unused)) void *data)
4152 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4153 portid_t port_id = res->port_id;
4156 if (!strcmp(res->policy, "l2")) {
4157 policy = BALANCE_XMIT_POLICY_LAYER2;
4158 } else if (!strcmp(res->policy, "l23")) {
4159 policy = BALANCE_XMIT_POLICY_LAYER23;
4160 } else if (!strcmp(res->policy, "l34")) {
4161 policy = BALANCE_XMIT_POLICY_LAYER34;
4163 printf("\t Invalid xmit policy selection");
4167 /* Set the bonding mode for the relevant port. */
4168 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4169 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4174 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4175 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4177 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4178 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4179 bonding, "bonding");
4180 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4181 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4182 balance_xmit_policy, "balance_xmit_policy");
4183 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4184 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4186 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4187 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4188 policy, "l2#l23#l34");
4190 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4191 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4192 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
4195 (void *)&cmd_setbonding_balance_xmit_policy_set,
4196 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4197 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4198 (void *)&cmd_setbonding_balance_xmit_policy_port,
4199 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4204 /* *** SHOW NIC BONDING CONFIGURATION *** */
4205 struct cmd_show_bonding_config_result {
4206 cmdline_fixed_string_t show;
4207 cmdline_fixed_string_t bonding;
4208 cmdline_fixed_string_t config;
4212 static void cmd_show_bonding_config_parsed(void *parsed_result,
4213 __attribute__((unused)) struct cmdline *cl,
4214 __attribute__((unused)) void *data)
4216 struct cmd_show_bonding_config_result *res = parsed_result;
4218 uint8_t slaves[RTE_MAX_ETHPORTS];
4219 int num_slaves, num_active_slaves;
4222 portid_t port_id = res->port_id;
4224 /* Display the bonding mode.*/
4225 bonding_mode = rte_eth_bond_mode_get(port_id);
4226 if (bonding_mode < 0) {
4227 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4230 printf("\tBonding mode: %d\n", bonding_mode);
4232 if (bonding_mode == BONDING_MODE_BALANCE) {
4233 int balance_xmit_policy;
4235 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4236 if (balance_xmit_policy < 0) {
4237 printf("\tFailed to get balance xmit policy for port = %d\n",
4241 printf("\tBalance Xmit Policy: ");
4243 switch (balance_xmit_policy) {
4244 case BALANCE_XMIT_POLICY_LAYER2:
4245 printf("BALANCE_XMIT_POLICY_LAYER2");
4247 case BALANCE_XMIT_POLICY_LAYER23:
4248 printf("BALANCE_XMIT_POLICY_LAYER23");
4250 case BALANCE_XMIT_POLICY_LAYER34:
4251 printf("BALANCE_XMIT_POLICY_LAYER34");
4258 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4260 if (num_slaves < 0) {
4261 printf("\tFailed to get slave list for port = %d\n", port_id);
4264 if (num_slaves > 0) {
4265 printf("\tSlaves (%d): [", num_slaves);
4266 for (i = 0; i < num_slaves - 1; i++)
4267 printf("%d ", slaves[i]);
4269 printf("%d]\n", slaves[num_slaves - 1]);
4271 printf("\tSlaves: []\n");
4275 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4278 if (num_active_slaves < 0) {
4279 printf("\tFailed to get active slave list for port = %d\n", port_id);
4282 if (num_active_slaves > 0) {
4283 printf("\tActive Slaves (%d): [", num_active_slaves);
4284 for (i = 0; i < num_active_slaves - 1; i++)
4285 printf("%d ", slaves[i]);
4287 printf("%d]\n", slaves[num_active_slaves - 1]);
4290 printf("\tActive Slaves: []\n");
4294 primary_id = rte_eth_bond_primary_get(port_id);
4295 if (primary_id < 0) {
4296 printf("\tFailed to get primary slave for port = %d\n", port_id);
4299 printf("\tPrimary: [%d]\n", primary_id);
4303 cmdline_parse_token_string_t cmd_showbonding_config_show =
4304 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4306 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4307 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4308 bonding, "bonding");
4309 cmdline_parse_token_string_t cmd_showbonding_config_config =
4310 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4312 cmdline_parse_token_num_t cmd_showbonding_config_port =
4313 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4316 cmdline_parse_inst_t cmd_show_bonding_config = {
4317 .f = cmd_show_bonding_config_parsed,
4318 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4321 (void *)&cmd_showbonding_config_show,
4322 (void *)&cmd_showbonding_config_bonding,
4323 (void *)&cmd_showbonding_config_config,
4324 (void *)&cmd_showbonding_config_port,
4329 /* *** SET BONDING PRIMARY *** */
4330 struct cmd_set_bonding_primary_result {
4331 cmdline_fixed_string_t set;
4332 cmdline_fixed_string_t bonding;
4333 cmdline_fixed_string_t primary;
4338 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4339 __attribute__((unused)) struct cmdline *cl,
4340 __attribute__((unused)) void *data)
4342 struct cmd_set_bonding_primary_result *res = parsed_result;
4343 portid_t master_port_id = res->port_id;
4344 portid_t slave_port_id = res->slave_id;
4346 /* Set the primary slave for a bonded device. */
4347 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4348 printf("\t Failed to set primary slave for port = %d.\n",
4355 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4356 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4358 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4359 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4360 bonding, "bonding");
4361 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4362 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4363 primary, "primary");
4364 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4365 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4367 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4368 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4371 cmdline_parse_inst_t cmd_set_bonding_primary = {
4372 .f = cmd_set_bonding_primary_parsed,
4373 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4376 (void *)&cmd_setbonding_primary_set,
4377 (void *)&cmd_setbonding_primary_bonding,
4378 (void *)&cmd_setbonding_primary_primary,
4379 (void *)&cmd_setbonding_primary_slave,
4380 (void *)&cmd_setbonding_primary_port,
4385 /* *** ADD SLAVE *** */
4386 struct cmd_add_bonding_slave_result {
4387 cmdline_fixed_string_t add;
4388 cmdline_fixed_string_t bonding;
4389 cmdline_fixed_string_t slave;
4394 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4395 __attribute__((unused)) struct cmdline *cl,
4396 __attribute__((unused)) void *data)
4398 struct cmd_add_bonding_slave_result *res = parsed_result;
4399 portid_t master_port_id = res->port_id;
4400 portid_t slave_port_id = res->slave_id;
4402 /* Set the primary slave for a bonded device. */
4403 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4404 printf("\t Failed to add slave %d to master port = %d.\n",
4405 slave_port_id, master_port_id);
4409 set_port_slave_flag(slave_port_id);
4412 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4413 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4415 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4416 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4417 bonding, "bonding");
4418 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4419 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4421 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4422 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4424 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4425 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4428 cmdline_parse_inst_t cmd_add_bonding_slave = {
4429 .f = cmd_add_bonding_slave_parsed,
4430 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4433 (void *)&cmd_addbonding_slave_add,
4434 (void *)&cmd_addbonding_slave_bonding,
4435 (void *)&cmd_addbonding_slave_slave,
4436 (void *)&cmd_addbonding_slave_slaveid,
4437 (void *)&cmd_addbonding_slave_port,
4442 /* *** REMOVE SLAVE *** */
4443 struct cmd_remove_bonding_slave_result {
4444 cmdline_fixed_string_t remove;
4445 cmdline_fixed_string_t bonding;
4446 cmdline_fixed_string_t slave;
4451 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4452 __attribute__((unused)) struct cmdline *cl,
4453 __attribute__((unused)) void *data)
4455 struct cmd_remove_bonding_slave_result *res = parsed_result;
4456 portid_t master_port_id = res->port_id;
4457 portid_t slave_port_id = res->slave_id;
4459 /* Set the primary slave for a bonded device. */
4460 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4461 printf("\t Failed to remove slave %d from master port = %d.\n",
4462 slave_port_id, master_port_id);
4466 clear_port_slave_flag(slave_port_id);
4469 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4470 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4472 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4473 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4474 bonding, "bonding");
4475 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4476 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4478 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4479 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4481 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4482 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4485 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4486 .f = cmd_remove_bonding_slave_parsed,
4487 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4490 (void *)&cmd_removebonding_slave_remove,
4491 (void *)&cmd_removebonding_slave_bonding,
4492 (void *)&cmd_removebonding_slave_slave,
4493 (void *)&cmd_removebonding_slave_slaveid,
4494 (void *)&cmd_removebonding_slave_port,
4499 /* *** CREATE BONDED DEVICE *** */
4500 struct cmd_create_bonded_device_result {
4501 cmdline_fixed_string_t create;
4502 cmdline_fixed_string_t bonded;
4503 cmdline_fixed_string_t device;
4508 static int bond_dev_num = 0;
4510 static void cmd_create_bonded_device_parsed(void *parsed_result,
4511 __attribute__((unused)) struct cmdline *cl,
4512 __attribute__((unused)) void *data)
4514 struct cmd_create_bonded_device_result *res = parsed_result;
4515 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4518 if (test_done == 0) {
4519 printf("Please stop forwarding first\n");
4523 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4526 /* Create a new bonded device. */
4527 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4529 printf("\t Failed to create bonded device.\n");
4532 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4535 /* Update number of ports */
4536 nb_ports = rte_eth_dev_count();
4537 reconfig(port_id, res->socket);
4538 rte_eth_promiscuous_enable(port_id);
4539 ports[port_id].enabled = 1;
4544 cmdline_parse_token_string_t cmd_createbonded_device_create =
4545 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4547 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4548 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4550 cmdline_parse_token_string_t cmd_createbonded_device_device =
4551 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4553 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4554 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4556 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4557 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4560 cmdline_parse_inst_t cmd_create_bonded_device = {
4561 .f = cmd_create_bonded_device_parsed,
4562 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4565 (void *)&cmd_createbonded_device_create,
4566 (void *)&cmd_createbonded_device_bonded,
4567 (void *)&cmd_createbonded_device_device,
4568 (void *)&cmd_createbonded_device_mode,
4569 (void *)&cmd_createbonded_device_socket,
4574 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4575 struct cmd_set_bond_mac_addr_result {
4576 cmdline_fixed_string_t set;
4577 cmdline_fixed_string_t bonding;
4578 cmdline_fixed_string_t mac_addr;
4580 struct ether_addr address;
4583 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4584 __attribute__((unused)) struct cmdline *cl,
4585 __attribute__((unused)) void *data)
4587 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4590 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4593 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4595 /* check the return value and print it if is < 0 */
4597 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4600 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4601 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4602 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4603 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4605 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4606 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4608 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4609 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4610 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4611 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4613 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4614 .f = cmd_set_bond_mac_addr_parsed,
4616 .help_str = "set bonding mac_addr (port_id) (address): ",
4618 (void *)&cmd_set_bond_mac_addr_set,
4619 (void *)&cmd_set_bond_mac_addr_bonding,
4620 (void *)&cmd_set_bond_mac_addr_mac,
4621 (void *)&cmd_set_bond_mac_addr_portnum,
4622 (void *)&cmd_set_bond_mac_addr_addr,
4628 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4629 struct cmd_set_bond_mon_period_result {
4630 cmdline_fixed_string_t set;
4631 cmdline_fixed_string_t bonding;
4632 cmdline_fixed_string_t mon_period;
4637 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4638 __attribute__((unused)) struct cmdline *cl,
4639 __attribute__((unused)) void *data)
4641 struct cmd_set_bond_mon_period_result *res = parsed_result;
4644 if (res->port_num >= nb_ports) {
4645 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4649 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4651 /* check the return value and print it if is < 0 */
4653 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4656 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4657 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4659 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4660 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4661 bonding, "bonding");
4662 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4663 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4664 mon_period, "mon_period");
4665 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4666 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4668 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4669 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4672 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4673 .f = cmd_set_bond_mon_period_parsed,
4675 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4677 (void *)&cmd_set_bond_mon_period_set,
4678 (void *)&cmd_set_bond_mon_period_bonding,
4679 (void *)&cmd_set_bond_mon_period_mon_period,
4680 (void *)&cmd_set_bond_mon_period_portnum,
4681 (void *)&cmd_set_bond_mon_period_period_ms,
4686 #endif /* RTE_LIBRTE_PMD_BOND */
4688 /* *** SET FORWARDING MODE *** */
4689 struct cmd_set_fwd_mode_result {
4690 cmdline_fixed_string_t set;
4691 cmdline_fixed_string_t fwd;
4692 cmdline_fixed_string_t mode;
4695 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4696 __attribute__((unused)) struct cmdline *cl,
4697 __attribute__((unused)) void *data)
4699 struct cmd_set_fwd_mode_result *res = parsed_result;
4702 set_pkt_forwarding_mode(res->mode);
4705 cmdline_parse_token_string_t cmd_setfwd_set =
4706 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4707 cmdline_parse_token_string_t cmd_setfwd_fwd =
4708 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4709 cmdline_parse_token_string_t cmd_setfwd_mode =
4710 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4711 "" /* defined at init */);
4713 cmdline_parse_inst_t cmd_set_fwd_mode = {
4714 .f = cmd_set_fwd_mode_parsed,
4716 .help_str = NULL, /* defined at init */
4718 (void *)&cmd_setfwd_set,
4719 (void *)&cmd_setfwd_fwd,
4720 (void *)&cmd_setfwd_mode,
4725 static void cmd_set_fwd_mode_init(void)
4728 static char token[128];
4729 static char help[256];
4730 cmdline_parse_token_string_t *token_struct;
4732 modes = list_pkt_forwarding_modes();
4733 snprintf(help, sizeof help, "set fwd %s - "
4734 "set packet forwarding mode", modes);
4735 cmd_set_fwd_mode.help_str = help;
4737 /* string token separator is # */
4738 for (c = token; *modes != '\0'; modes++)
4743 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4744 token_struct->string_data.str = token;
4747 /* *** SET RETRY FORWARDING MODE *** */
4748 struct cmd_set_fwd_retry_mode_result {
4749 cmdline_fixed_string_t set;
4750 cmdline_fixed_string_t fwd;
4751 cmdline_fixed_string_t mode;
4752 cmdline_fixed_string_t retry;
4755 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4756 __attribute__((unused)) struct cmdline *cl,
4757 __attribute__((unused)) void *data)
4759 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4762 set_pkt_forwarding_mode(res->mode);
4765 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4766 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4768 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4769 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4771 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4772 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4774 "" /* defined at init */);
4775 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4776 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4779 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4780 .f = cmd_set_fwd_retry_mode_parsed,
4782 .help_str = NULL, /* defined at init */
4784 (void *)&cmd_setfwd_retry_set,
4785 (void *)&cmd_setfwd_retry_fwd,
4786 (void *)&cmd_setfwd_retry_mode,
4787 (void *)&cmd_setfwd_retry_retry,
4792 static void cmd_set_fwd_retry_mode_init(void)
4795 static char token[128];
4796 static char help[256];
4797 cmdline_parse_token_string_t *token_struct;
4799 modes = list_pkt_forwarding_retry_modes();
4800 snprintf(help, sizeof(help), "set fwd %s retry - "
4801 "set packet forwarding mode with retry", modes);
4802 cmd_set_fwd_retry_mode.help_str = help;
4804 /* string token separator is # */
4805 for (c = token; *modes != '\0'; modes++)
4810 token_struct = (cmdline_parse_token_string_t *)
4811 cmd_set_fwd_retry_mode.tokens[2];
4812 token_struct->string_data.str = token;
4815 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4816 struct cmd_set_burst_tx_retry_result {
4817 cmdline_fixed_string_t set;
4818 cmdline_fixed_string_t burst;
4819 cmdline_fixed_string_t tx;
4820 cmdline_fixed_string_t delay;
4822 cmdline_fixed_string_t retry;
4826 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4827 __attribute__((unused)) struct cmdline *cl,
4828 __attribute__((unused)) void *data)
4830 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4832 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4833 && !strcmp(res->tx, "tx")) {
4834 if (!strcmp(res->delay, "delay"))
4835 burst_tx_delay_time = res->time;
4836 if (!strcmp(res->retry, "retry"))
4837 burst_tx_retry_num = res->retry_num;
4842 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4843 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4844 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4845 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4847 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4848 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4849 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4850 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4851 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4852 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4853 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4854 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4855 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4856 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4858 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4859 .f = cmd_set_burst_tx_retry_parsed,
4860 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4862 (void *)&cmd_set_burst_tx_retry_set,
4863 (void *)&cmd_set_burst_tx_retry_burst,
4864 (void *)&cmd_set_burst_tx_retry_tx,
4865 (void *)&cmd_set_burst_tx_retry_delay,
4866 (void *)&cmd_set_burst_tx_retry_time,
4867 (void *)&cmd_set_burst_tx_retry_retry,
4868 (void *)&cmd_set_burst_tx_retry_retry_num,
4873 /* *** SET PROMISC MODE *** */
4874 struct cmd_set_promisc_mode_result {
4875 cmdline_fixed_string_t set;
4876 cmdline_fixed_string_t promisc;
4877 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4878 uint8_t port_num; /* valid if "allports" argument == 0 */
4879 cmdline_fixed_string_t mode;
4882 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4883 __attribute__((unused)) struct cmdline *cl,
4886 struct cmd_set_promisc_mode_result *res = parsed_result;
4890 if (!strcmp(res->mode, "on"))
4897 FOREACH_PORT(i, ports) {
4899 rte_eth_promiscuous_enable(i);
4901 rte_eth_promiscuous_disable(i);
4906 rte_eth_promiscuous_enable(res->port_num);
4908 rte_eth_promiscuous_disable(res->port_num);
4912 cmdline_parse_token_string_t cmd_setpromisc_set =
4913 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4914 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4915 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4917 cmdline_parse_token_string_t cmd_setpromisc_portall =
4918 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4920 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4921 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4923 cmdline_parse_token_string_t cmd_setpromisc_mode =
4924 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4927 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4928 .f = cmd_set_promisc_mode_parsed,
4930 .help_str = "set promisc all on|off: set promisc mode for all ports",
4932 (void *)&cmd_setpromisc_set,
4933 (void *)&cmd_setpromisc_promisc,
4934 (void *)&cmd_setpromisc_portall,
4935 (void *)&cmd_setpromisc_mode,
4940 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4941 .f = cmd_set_promisc_mode_parsed,
4943 .help_str = "set promisc X on|off: set promisc mode on port X",
4945 (void *)&cmd_setpromisc_set,
4946 (void *)&cmd_setpromisc_promisc,
4947 (void *)&cmd_setpromisc_portnum,
4948 (void *)&cmd_setpromisc_mode,
4953 /* *** SET ALLMULTI MODE *** */
4954 struct cmd_set_allmulti_mode_result {
4955 cmdline_fixed_string_t set;
4956 cmdline_fixed_string_t allmulti;
4957 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4958 uint8_t port_num; /* valid if "allports" argument == 0 */
4959 cmdline_fixed_string_t mode;
4962 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4963 __attribute__((unused)) struct cmdline *cl,
4966 struct cmd_set_allmulti_mode_result *res = parsed_result;
4970 if (!strcmp(res->mode, "on"))
4977 FOREACH_PORT(i, ports) {
4979 rte_eth_allmulticast_enable(i);
4981 rte_eth_allmulticast_disable(i);
4986 rte_eth_allmulticast_enable(res->port_num);
4988 rte_eth_allmulticast_disable(res->port_num);
4992 cmdline_parse_token_string_t cmd_setallmulti_set =
4993 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4994 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4995 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4997 cmdline_parse_token_string_t cmd_setallmulti_portall =
4998 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5000 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5001 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5003 cmdline_parse_token_string_t cmd_setallmulti_mode =
5004 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5007 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5008 .f = cmd_set_allmulti_mode_parsed,
5010 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
5012 (void *)&cmd_setallmulti_set,
5013 (void *)&cmd_setallmulti_allmulti,
5014 (void *)&cmd_setallmulti_portall,
5015 (void *)&cmd_setallmulti_mode,
5020 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5021 .f = cmd_set_allmulti_mode_parsed,
5023 .help_str = "set allmulti X on|off: set allmulti mode on port X",
5025 (void *)&cmd_setallmulti_set,
5026 (void *)&cmd_setallmulti_allmulti,
5027 (void *)&cmd_setallmulti_portnum,
5028 (void *)&cmd_setallmulti_mode,
5033 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5034 struct cmd_link_flow_ctrl_set_result {
5035 cmdline_fixed_string_t set;
5036 cmdline_fixed_string_t flow_ctrl;
5037 cmdline_fixed_string_t rx;
5038 cmdline_fixed_string_t rx_lfc_mode;
5039 cmdline_fixed_string_t tx;
5040 cmdline_fixed_string_t tx_lfc_mode;
5041 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5042 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5043 cmdline_fixed_string_t autoneg_str;
5044 cmdline_fixed_string_t autoneg;
5045 cmdline_fixed_string_t hw_str;
5046 uint32_t high_water;
5047 cmdline_fixed_string_t lw_str;
5049 cmdline_fixed_string_t pt_str;
5050 uint16_t pause_time;
5051 cmdline_fixed_string_t xon_str;
5056 cmdline_parse_token_string_t cmd_lfc_set_set =
5057 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5059 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5060 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5061 flow_ctrl, "flow_ctrl");
5062 cmdline_parse_token_string_t cmd_lfc_set_rx =
5063 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5065 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5066 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5067 rx_lfc_mode, "on#off");
5068 cmdline_parse_token_string_t cmd_lfc_set_tx =
5069 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5071 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5072 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5073 tx_lfc_mode, "on#off");
5074 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5075 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5076 hw_str, "high_water");
5077 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5078 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5079 high_water, UINT32);
5080 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5081 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5082 lw_str, "low_water");
5083 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5084 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5086 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5087 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5088 pt_str, "pause_time");
5089 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5090 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5091 pause_time, UINT16);
5092 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5093 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5094 xon_str, "send_xon");
5095 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5096 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5098 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5099 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5100 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5101 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5102 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5103 mac_ctrl_frame_fwd_mode, "on#off");
5104 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5105 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5106 autoneg_str, "autoneg");
5107 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5108 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5110 cmdline_parse_token_num_t cmd_lfc_set_portid =
5111 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5114 /* forward declaration */
5116 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5119 cmdline_parse_inst_t cmd_link_flow_control_set = {
5120 .f = cmd_link_flow_ctrl_set_parsed,
5122 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
5123 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
5124 autoneg on|off port_id",
5126 (void *)&cmd_lfc_set_set,
5127 (void *)&cmd_lfc_set_flow_ctrl,
5128 (void *)&cmd_lfc_set_rx,
5129 (void *)&cmd_lfc_set_rx_mode,
5130 (void *)&cmd_lfc_set_tx,
5131 (void *)&cmd_lfc_set_tx_mode,
5132 (void *)&cmd_lfc_set_high_water,
5133 (void *)&cmd_lfc_set_low_water,
5134 (void *)&cmd_lfc_set_pause_time,
5135 (void *)&cmd_lfc_set_send_xon,
5136 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5137 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5138 (void *)&cmd_lfc_set_autoneg_str,
5139 (void *)&cmd_lfc_set_autoneg,
5140 (void *)&cmd_lfc_set_portid,
5145 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5146 .f = cmd_link_flow_ctrl_set_parsed,
5147 .data = (void *)&cmd_link_flow_control_set_rx,
5148 .help_str = "Change rx flow control parameter: set flow_ctrl "
5149 "rx on|off port_id",
5151 (void *)&cmd_lfc_set_set,
5152 (void *)&cmd_lfc_set_flow_ctrl,
5153 (void *)&cmd_lfc_set_rx,
5154 (void *)&cmd_lfc_set_rx_mode,
5155 (void *)&cmd_lfc_set_portid,
5160 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5161 .f = cmd_link_flow_ctrl_set_parsed,
5162 .data = (void *)&cmd_link_flow_control_set_tx,
5163 .help_str = "Change tx flow control parameter: set flow_ctrl "
5164 "tx on|off port_id",
5166 (void *)&cmd_lfc_set_set,
5167 (void *)&cmd_lfc_set_flow_ctrl,
5168 (void *)&cmd_lfc_set_tx,
5169 (void *)&cmd_lfc_set_tx_mode,
5170 (void *)&cmd_lfc_set_portid,
5175 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5176 .f = cmd_link_flow_ctrl_set_parsed,
5177 .data = (void *)&cmd_link_flow_control_set_hw,
5178 .help_str = "Change high water flow control parameter: set flow_ctrl "
5179 "high_water value port_id",
5181 (void *)&cmd_lfc_set_set,
5182 (void *)&cmd_lfc_set_flow_ctrl,
5183 (void *)&cmd_lfc_set_high_water_str,
5184 (void *)&cmd_lfc_set_high_water,
5185 (void *)&cmd_lfc_set_portid,
5190 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5191 .f = cmd_link_flow_ctrl_set_parsed,
5192 .data = (void *)&cmd_link_flow_control_set_lw,
5193 .help_str = "Change low water flow control parameter: set flow_ctrl "
5194 "low_water value port_id",
5196 (void *)&cmd_lfc_set_set,
5197 (void *)&cmd_lfc_set_flow_ctrl,
5198 (void *)&cmd_lfc_set_low_water_str,
5199 (void *)&cmd_lfc_set_low_water,
5200 (void *)&cmd_lfc_set_portid,
5205 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5206 .f = cmd_link_flow_ctrl_set_parsed,
5207 .data = (void *)&cmd_link_flow_control_set_pt,
5208 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5209 "pause_time value port_id",
5211 (void *)&cmd_lfc_set_set,
5212 (void *)&cmd_lfc_set_flow_ctrl,
5213 (void *)&cmd_lfc_set_pause_time_str,
5214 (void *)&cmd_lfc_set_pause_time,
5215 (void *)&cmd_lfc_set_portid,
5220 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5221 .f = cmd_link_flow_ctrl_set_parsed,
5222 .data = (void *)&cmd_link_flow_control_set_xon,
5223 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5224 "send_xon value port_id",
5226 (void *)&cmd_lfc_set_set,
5227 (void *)&cmd_lfc_set_flow_ctrl,
5228 (void *)&cmd_lfc_set_send_xon_str,
5229 (void *)&cmd_lfc_set_send_xon,
5230 (void *)&cmd_lfc_set_portid,
5235 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5236 .f = cmd_link_flow_ctrl_set_parsed,
5237 .data = (void *)&cmd_link_flow_control_set_macfwd,
5238 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5239 "mac_ctrl_frame_fwd on|off port_id",
5241 (void *)&cmd_lfc_set_set,
5242 (void *)&cmd_lfc_set_flow_ctrl,
5243 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5244 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5245 (void *)&cmd_lfc_set_portid,
5250 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5251 .f = cmd_link_flow_ctrl_set_parsed,
5252 .data = (void *)&cmd_link_flow_control_set_autoneg,
5253 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5254 "autoneg on|off port_id",
5256 (void *)&cmd_lfc_set_set,
5257 (void *)&cmd_lfc_set_flow_ctrl,
5258 (void *)&cmd_lfc_set_autoneg_str,
5259 (void *)&cmd_lfc_set_autoneg,
5260 (void *)&cmd_lfc_set_portid,
5266 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5267 __attribute__((unused)) struct cmdline *cl,
5270 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5271 cmdline_parse_inst_t *cmd = data;
5272 struct rte_eth_fc_conf fc_conf;
5278 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5279 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5280 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5281 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5283 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5284 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5287 /* Partial command line, retrieve current configuration */
5289 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5291 printf("cannot get current flow ctrl parameters, return"
5292 "code = %d\n", ret);
5296 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5297 (fc_conf.mode == RTE_FC_FULL))
5299 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5300 (fc_conf.mode == RTE_FC_FULL))
5304 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5305 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5307 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5308 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5310 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5312 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5313 fc_conf.high_water = res->high_water;
5315 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5316 fc_conf.low_water = res->low_water;
5318 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5319 fc_conf.pause_time = res->pause_time;
5321 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5322 fc_conf.send_xon = res->send_xon;
5324 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5325 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5326 fc_conf.mac_ctrl_frame_fwd = 1;
5328 fc_conf.mac_ctrl_frame_fwd = 0;
5331 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5332 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5334 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5336 printf("bad flow contrl parameter, return code = %d \n", ret);
5339 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5340 struct cmd_priority_flow_ctrl_set_result {
5341 cmdline_fixed_string_t set;
5342 cmdline_fixed_string_t pfc_ctrl;
5343 cmdline_fixed_string_t rx;
5344 cmdline_fixed_string_t rx_pfc_mode;
5345 cmdline_fixed_string_t tx;
5346 cmdline_fixed_string_t tx_pfc_mode;
5347 uint32_t high_water;
5349 uint16_t pause_time;
5355 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5356 __attribute__((unused)) struct cmdline *cl,
5357 __attribute__((unused)) void *data)
5359 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5360 struct rte_eth_pfc_conf pfc_conf;
5361 int rx_fc_enable, tx_fc_enable;
5365 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5366 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5367 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5368 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5370 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5371 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5374 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5375 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5376 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5377 pfc_conf.fc.high_water = res->high_water;
5378 pfc_conf.fc.low_water = res->low_water;
5379 pfc_conf.fc.pause_time = res->pause_time;
5380 pfc_conf.priority = res->priority;
5382 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5384 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5387 cmdline_parse_token_string_t cmd_pfc_set_set =
5388 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5390 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5391 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5392 pfc_ctrl, "pfc_ctrl");
5393 cmdline_parse_token_string_t cmd_pfc_set_rx =
5394 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5396 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5397 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5398 rx_pfc_mode, "on#off");
5399 cmdline_parse_token_string_t cmd_pfc_set_tx =
5400 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5402 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5403 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5404 tx_pfc_mode, "on#off");
5405 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5406 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5407 high_water, UINT32);
5408 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5409 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5411 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5412 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5413 pause_time, UINT16);
5414 cmdline_parse_token_num_t cmd_pfc_set_priority =
5415 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5417 cmdline_parse_token_num_t cmd_pfc_set_portid =
5418 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5421 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5422 .f = cmd_priority_flow_ctrl_set_parsed,
5424 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5425 tx on|off high_water low_water pause_time priority port_id",
5427 (void *)&cmd_pfc_set_set,
5428 (void *)&cmd_pfc_set_flow_ctrl,
5429 (void *)&cmd_pfc_set_rx,
5430 (void *)&cmd_pfc_set_rx_mode,
5431 (void *)&cmd_pfc_set_tx,
5432 (void *)&cmd_pfc_set_tx_mode,
5433 (void *)&cmd_pfc_set_high_water,
5434 (void *)&cmd_pfc_set_low_water,
5435 (void *)&cmd_pfc_set_pause_time,
5436 (void *)&cmd_pfc_set_priority,
5437 (void *)&cmd_pfc_set_portid,
5442 /* *** RESET CONFIGURATION *** */
5443 struct cmd_reset_result {
5444 cmdline_fixed_string_t reset;
5445 cmdline_fixed_string_t def;
5448 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5450 __attribute__((unused)) void *data)
5452 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5453 set_def_fwd_config();
5456 cmdline_parse_token_string_t cmd_reset_set =
5457 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5458 cmdline_parse_token_string_t cmd_reset_def =
5459 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5462 cmdline_parse_inst_t cmd_reset = {
5463 .f = cmd_reset_parsed,
5465 .help_str = "set default: reset default forwarding configuration",
5467 (void *)&cmd_reset_set,
5468 (void *)&cmd_reset_def,
5473 /* *** START FORWARDING *** */
5474 struct cmd_start_result {
5475 cmdline_fixed_string_t start;
5478 cmdline_parse_token_string_t cmd_start_start =
5479 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5481 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5482 __attribute__((unused)) struct cmdline *cl,
5483 __attribute__((unused)) void *data)
5485 start_packet_forwarding(0);
5488 cmdline_parse_inst_t cmd_start = {
5489 .f = cmd_start_parsed,
5491 .help_str = "start packet forwarding",
5493 (void *)&cmd_start_start,
5498 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5499 struct cmd_start_tx_first_result {
5500 cmdline_fixed_string_t start;
5501 cmdline_fixed_string_t tx_first;
5505 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5506 __attribute__((unused)) struct cmdline *cl,
5507 __attribute__((unused)) void *data)
5509 start_packet_forwarding(1);
5512 cmdline_parse_token_string_t cmd_start_tx_first_start =
5513 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5515 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5516 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5517 tx_first, "tx_first");
5519 cmdline_parse_inst_t cmd_start_tx_first = {
5520 .f = cmd_start_tx_first_parsed,
5522 .help_str = "start packet forwarding, after sending 1 burst of packets",
5524 (void *)&cmd_start_tx_first_start,
5525 (void *)&cmd_start_tx_first_tx_first,
5530 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5531 struct cmd_start_tx_first_n_result {
5532 cmdline_fixed_string_t start;
5533 cmdline_fixed_string_t tx_first;
5538 cmd_start_tx_first_n_parsed(void *parsed_result,
5539 __attribute__((unused)) struct cmdline *cl,
5540 __attribute__((unused)) void *data)
5542 struct cmd_start_tx_first_n_result *res = parsed_result;
5544 start_packet_forwarding(res->tx_num);
5547 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5548 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5550 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5551 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5552 tx_first, "tx_first");
5553 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5554 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5557 cmdline_parse_inst_t cmd_start_tx_first_n = {
5558 .f = cmd_start_tx_first_n_parsed,
5560 .help_str = "start packet forwarding, after sending <num> "
5561 "bursts of packets",
5563 (void *)&cmd_start_tx_first_n_start,
5564 (void *)&cmd_start_tx_first_n_tx_first,
5565 (void *)&cmd_start_tx_first_n_tx_num,
5570 /* *** SET LINK UP *** */
5571 struct cmd_set_link_up_result {
5572 cmdline_fixed_string_t set;
5573 cmdline_fixed_string_t link_up;
5574 cmdline_fixed_string_t port;
5578 cmdline_parse_token_string_t cmd_set_link_up_set =
5579 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5580 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5581 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5583 cmdline_parse_token_string_t cmd_set_link_up_port =
5584 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5585 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5586 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5588 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5589 __attribute__((unused)) struct cmdline *cl,
5590 __attribute__((unused)) void *data)
5592 struct cmd_set_link_up_result *res = parsed_result;
5593 dev_set_link_up(res->port_id);
5596 cmdline_parse_inst_t cmd_set_link_up = {
5597 .f = cmd_set_link_up_parsed,
5599 .help_str = "set link-up port (port id)",
5601 (void *)&cmd_set_link_up_set,
5602 (void *)&cmd_set_link_up_link_up,
5603 (void *)&cmd_set_link_up_port,
5604 (void *)&cmd_set_link_up_port_id,
5609 /* *** SET LINK DOWN *** */
5610 struct cmd_set_link_down_result {
5611 cmdline_fixed_string_t set;
5612 cmdline_fixed_string_t link_down;
5613 cmdline_fixed_string_t port;
5617 cmdline_parse_token_string_t cmd_set_link_down_set =
5618 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5619 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5622 cmdline_parse_token_string_t cmd_set_link_down_port =
5623 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5624 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5625 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5627 static void cmd_set_link_down_parsed(
5628 __attribute__((unused)) void *parsed_result,
5629 __attribute__((unused)) struct cmdline *cl,
5630 __attribute__((unused)) void *data)
5632 struct cmd_set_link_down_result *res = parsed_result;
5633 dev_set_link_down(res->port_id);
5636 cmdline_parse_inst_t cmd_set_link_down = {
5637 .f = cmd_set_link_down_parsed,
5639 .help_str = "set link-down port (port id)",
5641 (void *)&cmd_set_link_down_set,
5642 (void *)&cmd_set_link_down_link_down,
5643 (void *)&cmd_set_link_down_port,
5644 (void *)&cmd_set_link_down_port_id,
5649 /* *** SHOW CFG *** */
5650 struct cmd_showcfg_result {
5651 cmdline_fixed_string_t show;
5652 cmdline_fixed_string_t cfg;
5653 cmdline_fixed_string_t what;
5656 static void cmd_showcfg_parsed(void *parsed_result,
5657 __attribute__((unused)) struct cmdline *cl,
5658 __attribute__((unused)) void *data)
5660 struct cmd_showcfg_result *res = parsed_result;
5661 if (!strcmp(res->what, "rxtx"))
5662 rxtx_config_display();
5663 else if (!strcmp(res->what, "cores"))
5664 fwd_lcores_config_display();
5665 else if (!strcmp(res->what, "fwd"))
5666 pkt_fwd_config_display(&cur_fwd_config);
5667 else if (!strcmp(res->what, "txpkts"))
5668 show_tx_pkt_segments();
5671 cmdline_parse_token_string_t cmd_showcfg_show =
5672 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5673 cmdline_parse_token_string_t cmd_showcfg_port =
5674 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5675 cmdline_parse_token_string_t cmd_showcfg_what =
5676 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5677 "rxtx#cores#fwd#txpkts");
5679 cmdline_parse_inst_t cmd_showcfg = {
5680 .f = cmd_showcfg_parsed,
5682 .help_str = "show config rxtx|cores|fwd|txpkts",
5684 (void *)&cmd_showcfg_show,
5685 (void *)&cmd_showcfg_port,
5686 (void *)&cmd_showcfg_what,
5691 /* *** SHOW ALL PORT INFO *** */
5692 struct cmd_showportall_result {
5693 cmdline_fixed_string_t show;
5694 cmdline_fixed_string_t port;
5695 cmdline_fixed_string_t what;
5696 cmdline_fixed_string_t all;
5699 static void cmd_showportall_parsed(void *parsed_result,
5700 __attribute__((unused)) struct cmdline *cl,
5701 __attribute__((unused)) void *data)
5705 struct cmd_showportall_result *res = parsed_result;
5706 if (!strcmp(res->show, "clear")) {
5707 if (!strcmp(res->what, "stats"))
5708 FOREACH_PORT(i, ports)
5710 else if (!strcmp(res->what, "xstats"))
5711 FOREACH_PORT(i, ports)
5712 nic_xstats_clear(i);
5713 } else if (!strcmp(res->what, "info"))
5714 FOREACH_PORT(i, ports)
5715 port_infos_display(i);
5716 else if (!strcmp(res->what, "stats"))
5717 FOREACH_PORT(i, ports)
5718 nic_stats_display(i);
5719 else if (!strcmp(res->what, "xstats"))
5720 FOREACH_PORT(i, ports)
5721 nic_xstats_display(i);
5722 else if (!strcmp(res->what, "fdir"))
5723 FOREACH_PORT(i, ports)
5725 else if (!strcmp(res->what, "stat_qmap"))
5726 FOREACH_PORT(i, ports)
5727 nic_stats_mapping_display(i);
5728 else if (!strcmp(res->what, "dcb_tc"))
5729 FOREACH_PORT(i, ports)
5730 port_dcb_info_display(i);
5733 cmdline_parse_token_string_t cmd_showportall_show =
5734 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5736 cmdline_parse_token_string_t cmd_showportall_port =
5737 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5738 cmdline_parse_token_string_t cmd_showportall_what =
5739 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5740 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5741 cmdline_parse_token_string_t cmd_showportall_all =
5742 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5743 cmdline_parse_inst_t cmd_showportall = {
5744 .f = cmd_showportall_parsed,
5746 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5748 (void *)&cmd_showportall_show,
5749 (void *)&cmd_showportall_port,
5750 (void *)&cmd_showportall_what,
5751 (void *)&cmd_showportall_all,
5756 /* *** SHOW PORT INFO *** */
5757 struct cmd_showport_result {
5758 cmdline_fixed_string_t show;
5759 cmdline_fixed_string_t port;
5760 cmdline_fixed_string_t what;
5764 static void cmd_showport_parsed(void *parsed_result,
5765 __attribute__((unused)) struct cmdline *cl,
5766 __attribute__((unused)) void *data)
5768 struct cmd_showport_result *res = parsed_result;
5769 if (!strcmp(res->show, "clear")) {
5770 if (!strcmp(res->what, "stats"))
5771 nic_stats_clear(res->portnum);
5772 else if (!strcmp(res->what, "xstats"))
5773 nic_xstats_clear(res->portnum);
5774 } else if (!strcmp(res->what, "info"))
5775 port_infos_display(res->portnum);
5776 else if (!strcmp(res->what, "stats"))
5777 nic_stats_display(res->portnum);
5778 else if (!strcmp(res->what, "xstats"))
5779 nic_xstats_display(res->portnum);
5780 else if (!strcmp(res->what, "fdir"))
5781 fdir_get_infos(res->portnum);
5782 else if (!strcmp(res->what, "stat_qmap"))
5783 nic_stats_mapping_display(res->portnum);
5784 else if (!strcmp(res->what, "dcb_tc"))
5785 port_dcb_info_display(res->portnum);
5788 cmdline_parse_token_string_t cmd_showport_show =
5789 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5791 cmdline_parse_token_string_t cmd_showport_port =
5792 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5793 cmdline_parse_token_string_t cmd_showport_what =
5794 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5795 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5796 cmdline_parse_token_num_t cmd_showport_portnum =
5797 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5799 cmdline_parse_inst_t cmd_showport = {
5800 .f = cmd_showport_parsed,
5802 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5804 (void *)&cmd_showport_show,
5805 (void *)&cmd_showport_port,
5806 (void *)&cmd_showport_what,
5807 (void *)&cmd_showport_portnum,
5812 /* *** SHOW QUEUE INFO *** */
5813 struct cmd_showqueue_result {
5814 cmdline_fixed_string_t show;
5815 cmdline_fixed_string_t type;
5816 cmdline_fixed_string_t what;
5822 cmd_showqueue_parsed(void *parsed_result,
5823 __attribute__((unused)) struct cmdline *cl,
5824 __attribute__((unused)) void *data)
5826 struct cmd_showqueue_result *res = parsed_result;
5828 if (!strcmp(res->type, "rxq"))
5829 rx_queue_infos_display(res->portnum, res->queuenum);
5830 else if (!strcmp(res->type, "txq"))
5831 tx_queue_infos_display(res->portnum, res->queuenum);
5834 cmdline_parse_token_string_t cmd_showqueue_show =
5835 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5836 cmdline_parse_token_string_t cmd_showqueue_type =
5837 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5838 cmdline_parse_token_string_t cmd_showqueue_what =
5839 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5840 cmdline_parse_token_num_t cmd_showqueue_portnum =
5841 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5842 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5843 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5845 cmdline_parse_inst_t cmd_showqueue = {
5846 .f = cmd_showqueue_parsed,
5848 .help_str = "show rxq|txq info <port number> <queue_number>",
5850 (void *)&cmd_showqueue_show,
5851 (void *)&cmd_showqueue_type,
5852 (void *)&cmd_showqueue_what,
5853 (void *)&cmd_showqueue_portnum,
5854 (void *)&cmd_showqueue_queuenum,
5859 /* *** READ PORT REGISTER *** */
5860 struct cmd_read_reg_result {
5861 cmdline_fixed_string_t read;
5862 cmdline_fixed_string_t reg;
5868 cmd_read_reg_parsed(void *parsed_result,
5869 __attribute__((unused)) struct cmdline *cl,
5870 __attribute__((unused)) void *data)
5872 struct cmd_read_reg_result *res = parsed_result;
5873 port_reg_display(res->port_id, res->reg_off);
5876 cmdline_parse_token_string_t cmd_read_reg_read =
5877 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5878 cmdline_parse_token_string_t cmd_read_reg_reg =
5879 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5880 cmdline_parse_token_num_t cmd_read_reg_port_id =
5881 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5882 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5883 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5885 cmdline_parse_inst_t cmd_read_reg = {
5886 .f = cmd_read_reg_parsed,
5888 .help_str = "read reg port_id reg_off",
5890 (void *)&cmd_read_reg_read,
5891 (void *)&cmd_read_reg_reg,
5892 (void *)&cmd_read_reg_port_id,
5893 (void *)&cmd_read_reg_reg_off,
5898 /* *** READ PORT REGISTER BIT FIELD *** */
5899 struct cmd_read_reg_bit_field_result {
5900 cmdline_fixed_string_t read;
5901 cmdline_fixed_string_t regfield;
5909 cmd_read_reg_bit_field_parsed(void *parsed_result,
5910 __attribute__((unused)) struct cmdline *cl,
5911 __attribute__((unused)) void *data)
5913 struct cmd_read_reg_bit_field_result *res = parsed_result;
5914 port_reg_bit_field_display(res->port_id, res->reg_off,
5915 res->bit1_pos, res->bit2_pos);
5918 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5919 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5921 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5922 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5923 regfield, "regfield");
5924 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5925 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5927 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5928 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5930 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5931 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5933 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5934 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5937 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5938 .f = cmd_read_reg_bit_field_parsed,
5940 .help_str = "read regfield port_id reg_off bit_x bit_y "
5941 "(read register bit field between bit_x and bit_y included)",
5943 (void *)&cmd_read_reg_bit_field_read,
5944 (void *)&cmd_read_reg_bit_field_regfield,
5945 (void *)&cmd_read_reg_bit_field_port_id,
5946 (void *)&cmd_read_reg_bit_field_reg_off,
5947 (void *)&cmd_read_reg_bit_field_bit1_pos,
5948 (void *)&cmd_read_reg_bit_field_bit2_pos,
5953 /* *** READ PORT REGISTER BIT *** */
5954 struct cmd_read_reg_bit_result {
5955 cmdline_fixed_string_t read;
5956 cmdline_fixed_string_t regbit;
5963 cmd_read_reg_bit_parsed(void *parsed_result,
5964 __attribute__((unused)) struct cmdline *cl,
5965 __attribute__((unused)) void *data)
5967 struct cmd_read_reg_bit_result *res = parsed_result;
5968 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5971 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5972 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5973 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5974 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5976 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5977 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5978 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5979 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5980 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5981 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5983 cmdline_parse_inst_t cmd_read_reg_bit = {
5984 .f = cmd_read_reg_bit_parsed,
5986 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5988 (void *)&cmd_read_reg_bit_read,
5989 (void *)&cmd_read_reg_bit_regbit,
5990 (void *)&cmd_read_reg_bit_port_id,
5991 (void *)&cmd_read_reg_bit_reg_off,
5992 (void *)&cmd_read_reg_bit_bit_pos,
5997 /* *** WRITE PORT REGISTER *** */
5998 struct cmd_write_reg_result {
5999 cmdline_fixed_string_t write;
6000 cmdline_fixed_string_t reg;
6007 cmd_write_reg_parsed(void *parsed_result,
6008 __attribute__((unused)) struct cmdline *cl,
6009 __attribute__((unused)) void *data)
6011 struct cmd_write_reg_result *res = parsed_result;
6012 port_reg_set(res->port_id, res->reg_off, res->value);
6015 cmdline_parse_token_string_t cmd_write_reg_write =
6016 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6017 cmdline_parse_token_string_t cmd_write_reg_reg =
6018 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6019 cmdline_parse_token_num_t cmd_write_reg_port_id =
6020 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6021 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6022 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6023 cmdline_parse_token_num_t cmd_write_reg_value =
6024 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6026 cmdline_parse_inst_t cmd_write_reg = {
6027 .f = cmd_write_reg_parsed,
6029 .help_str = "write reg port_id reg_off reg_value",
6031 (void *)&cmd_write_reg_write,
6032 (void *)&cmd_write_reg_reg,
6033 (void *)&cmd_write_reg_port_id,
6034 (void *)&cmd_write_reg_reg_off,
6035 (void *)&cmd_write_reg_value,
6040 /* *** WRITE PORT REGISTER BIT FIELD *** */
6041 struct cmd_write_reg_bit_field_result {
6042 cmdline_fixed_string_t write;
6043 cmdline_fixed_string_t regfield;
6052 cmd_write_reg_bit_field_parsed(void *parsed_result,
6053 __attribute__((unused)) struct cmdline *cl,
6054 __attribute__((unused)) void *data)
6056 struct cmd_write_reg_bit_field_result *res = parsed_result;
6057 port_reg_bit_field_set(res->port_id, res->reg_off,
6058 res->bit1_pos, res->bit2_pos, res->value);
6061 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6062 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6064 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6065 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6066 regfield, "regfield");
6067 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6068 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6070 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6071 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6073 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6074 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6076 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6077 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6079 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6080 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6083 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6084 .f = cmd_write_reg_bit_field_parsed,
6086 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
6087 "(set register bit field between bit_x and bit_y included)",
6089 (void *)&cmd_write_reg_bit_field_write,
6090 (void *)&cmd_write_reg_bit_field_regfield,
6091 (void *)&cmd_write_reg_bit_field_port_id,
6092 (void *)&cmd_write_reg_bit_field_reg_off,
6093 (void *)&cmd_write_reg_bit_field_bit1_pos,
6094 (void *)&cmd_write_reg_bit_field_bit2_pos,
6095 (void *)&cmd_write_reg_bit_field_value,
6100 /* *** WRITE PORT REGISTER BIT *** */
6101 struct cmd_write_reg_bit_result {
6102 cmdline_fixed_string_t write;
6103 cmdline_fixed_string_t regbit;
6111 cmd_write_reg_bit_parsed(void *parsed_result,
6112 __attribute__((unused)) struct cmdline *cl,
6113 __attribute__((unused)) void *data)
6115 struct cmd_write_reg_bit_result *res = parsed_result;
6116 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6119 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6120 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6122 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6123 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6125 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6126 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6127 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6128 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6129 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6130 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6131 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6132 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6134 cmdline_parse_inst_t cmd_write_reg_bit = {
6135 .f = cmd_write_reg_bit_parsed,
6137 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
6139 (void *)&cmd_write_reg_bit_write,
6140 (void *)&cmd_write_reg_bit_regbit,
6141 (void *)&cmd_write_reg_bit_port_id,
6142 (void *)&cmd_write_reg_bit_reg_off,
6143 (void *)&cmd_write_reg_bit_bit_pos,
6144 (void *)&cmd_write_reg_bit_value,
6149 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6150 struct cmd_read_rxd_txd_result {
6151 cmdline_fixed_string_t read;
6152 cmdline_fixed_string_t rxd_txd;
6159 cmd_read_rxd_txd_parsed(void *parsed_result,
6160 __attribute__((unused)) struct cmdline *cl,
6161 __attribute__((unused)) void *data)
6163 struct cmd_read_rxd_txd_result *res = parsed_result;
6165 if (!strcmp(res->rxd_txd, "rxd"))
6166 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6167 else if (!strcmp(res->rxd_txd, "txd"))
6168 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6171 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6172 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6173 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6174 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6176 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6177 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6178 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6179 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6180 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6181 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6183 cmdline_parse_inst_t cmd_read_rxd_txd = {
6184 .f = cmd_read_rxd_txd_parsed,
6186 .help_str = "read rxd|txd port_id queue_id rxd_id",
6188 (void *)&cmd_read_rxd_txd_read,
6189 (void *)&cmd_read_rxd_txd_rxd_txd,
6190 (void *)&cmd_read_rxd_txd_port_id,
6191 (void *)&cmd_read_rxd_txd_queue_id,
6192 (void *)&cmd_read_rxd_txd_desc_id,
6198 struct cmd_quit_result {
6199 cmdline_fixed_string_t quit;
6202 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6204 __attribute__((unused)) void *data)
6210 cmdline_parse_token_string_t cmd_quit_quit =
6211 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6213 cmdline_parse_inst_t cmd_quit = {
6214 .f = cmd_quit_parsed,
6216 .help_str = "exit application",
6218 (void *)&cmd_quit_quit,
6223 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6224 struct cmd_mac_addr_result {
6225 cmdline_fixed_string_t mac_addr_cmd;
6226 cmdline_fixed_string_t what;
6228 struct ether_addr address;
6231 static void cmd_mac_addr_parsed(void *parsed_result,
6232 __attribute__((unused)) struct cmdline *cl,
6233 __attribute__((unused)) void *data)
6235 struct cmd_mac_addr_result *res = parsed_result;
6238 if (strcmp(res->what, "add") == 0)
6239 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6241 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6243 /* check the return value and print it if is < 0 */
6245 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6249 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6250 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6252 cmdline_parse_token_string_t cmd_mac_addr_what =
6253 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6255 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6256 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6257 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6258 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6260 cmdline_parse_inst_t cmd_mac_addr = {
6261 .f = cmd_mac_addr_parsed,
6263 .help_str = "mac_addr add|remove X <address>: "
6264 "add/remove MAC address on port X",
6266 (void *)&cmd_mac_addr_cmd,
6267 (void *)&cmd_mac_addr_what,
6268 (void *)&cmd_mac_addr_portnum,
6269 (void *)&cmd_mac_addr_addr,
6275 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6276 struct cmd_set_qmap_result {
6277 cmdline_fixed_string_t set;
6278 cmdline_fixed_string_t qmap;
6279 cmdline_fixed_string_t what;
6286 cmd_set_qmap_parsed(void *parsed_result,
6287 __attribute__((unused)) struct cmdline *cl,
6288 __attribute__((unused)) void *data)
6290 struct cmd_set_qmap_result *res = parsed_result;
6291 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6293 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6296 cmdline_parse_token_string_t cmd_setqmap_set =
6297 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6299 cmdline_parse_token_string_t cmd_setqmap_qmap =
6300 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6302 cmdline_parse_token_string_t cmd_setqmap_what =
6303 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6305 cmdline_parse_token_num_t cmd_setqmap_portid =
6306 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6308 cmdline_parse_token_num_t cmd_setqmap_queueid =
6309 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6311 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6312 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6315 cmdline_parse_inst_t cmd_set_qmap = {
6316 .f = cmd_set_qmap_parsed,
6318 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6320 (void *)&cmd_setqmap_set,
6321 (void *)&cmd_setqmap_qmap,
6322 (void *)&cmd_setqmap_what,
6323 (void *)&cmd_setqmap_portid,
6324 (void *)&cmd_setqmap_queueid,
6325 (void *)&cmd_setqmap_mapvalue,
6330 /* *** CONFIGURE UNICAST HASH TABLE *** */
6331 struct cmd_set_uc_hash_table {
6332 cmdline_fixed_string_t set;
6333 cmdline_fixed_string_t port;
6335 cmdline_fixed_string_t what;
6336 struct ether_addr address;
6337 cmdline_fixed_string_t mode;
6341 cmd_set_uc_hash_parsed(void *parsed_result,
6342 __attribute__((unused)) struct cmdline *cl,
6343 __attribute__((unused)) void *data)
6346 struct cmd_set_uc_hash_table *res = parsed_result;
6348 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6350 if (strcmp(res->what, "uta") == 0)
6351 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6352 &res->address,(uint8_t)is_on);
6354 printf("bad unicast hash table parameter, return code = %d \n", ret);
6358 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6359 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6361 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6362 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6364 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6365 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6367 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6368 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6370 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6371 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6373 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6374 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6377 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6378 .f = cmd_set_uc_hash_parsed,
6380 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6382 (void *)&cmd_set_uc_hash_set,
6383 (void *)&cmd_set_uc_hash_port,
6384 (void *)&cmd_set_uc_hash_portid,
6385 (void *)&cmd_set_uc_hash_what,
6386 (void *)&cmd_set_uc_hash_mac,
6387 (void *)&cmd_set_uc_hash_mode,
6392 struct cmd_set_uc_all_hash_table {
6393 cmdline_fixed_string_t set;
6394 cmdline_fixed_string_t port;
6396 cmdline_fixed_string_t what;
6397 cmdline_fixed_string_t value;
6398 cmdline_fixed_string_t mode;
6402 cmd_set_uc_all_hash_parsed(void *parsed_result,
6403 __attribute__((unused)) struct cmdline *cl,
6404 __attribute__((unused)) void *data)
6407 struct cmd_set_uc_all_hash_table *res = parsed_result;
6409 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6411 if ((strcmp(res->what, "uta") == 0) &&
6412 (strcmp(res->value, "all") == 0))
6413 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6415 printf("bad unicast hash table parameter,"
6416 "return code = %d \n", ret);
6419 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6420 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6422 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6423 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6425 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6426 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6428 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6429 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6431 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6432 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6434 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6435 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6438 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6439 .f = cmd_set_uc_all_hash_parsed,
6441 .help_str = "set port X uta all on|off (X = port number)",
6443 (void *)&cmd_set_uc_all_hash_set,
6444 (void *)&cmd_set_uc_all_hash_port,
6445 (void *)&cmd_set_uc_all_hash_portid,
6446 (void *)&cmd_set_uc_all_hash_what,
6447 (void *)&cmd_set_uc_all_hash_value,
6448 (void *)&cmd_set_uc_all_hash_mode,
6453 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6454 struct cmd_set_vf_macvlan_filter {
6455 cmdline_fixed_string_t set;
6456 cmdline_fixed_string_t port;
6458 cmdline_fixed_string_t vf;
6460 struct ether_addr address;
6461 cmdline_fixed_string_t filter_type;
6462 cmdline_fixed_string_t mode;
6466 cmd_set_vf_macvlan_parsed(void *parsed_result,
6467 __attribute__((unused)) struct cmdline *cl,
6468 __attribute__((unused)) void *data)
6471 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6472 struct rte_eth_mac_filter filter;
6474 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6476 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6478 /* set VF MAC filter */
6482 filter.dst_id = res->vf_id;
6484 if (!strcmp(res->filter_type, "exact-mac"))
6485 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6486 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6487 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6488 else if (!strcmp(res->filter_type, "hashmac"))
6489 filter.filter_type = RTE_MAC_HASH_MATCH;
6490 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6491 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6493 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6496 ret = rte_eth_dev_filter_ctrl(res->port_id,
6497 RTE_ETH_FILTER_MACVLAN,
6501 ret = rte_eth_dev_filter_ctrl(res->port_id,
6502 RTE_ETH_FILTER_MACVLAN,
6503 RTE_ETH_FILTER_DELETE,
6507 printf("bad set MAC hash parameter, return code = %d\n", ret);
6511 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6512 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6514 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6515 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6517 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6518 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6520 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6521 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6523 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6524 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6526 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6527 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6529 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6530 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6531 filter_type, "exact-mac#exact-mac-vlan"
6532 "#hashmac#hashmac-vlan");
6533 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6534 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6537 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6538 .f = cmd_set_vf_macvlan_parsed,
6540 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6541 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6543 "exact match rule:exact match of MAC or MAC and VLAN; "
6544 "hash match rule: hash match of MAC and exact match "
6547 (void *)&cmd_set_vf_macvlan_set,
6548 (void *)&cmd_set_vf_macvlan_port,
6549 (void *)&cmd_set_vf_macvlan_portid,
6550 (void *)&cmd_set_vf_macvlan_vf,
6551 (void *)&cmd_set_vf_macvlan_vf_id,
6552 (void *)&cmd_set_vf_macvlan_mac,
6553 (void *)&cmd_set_vf_macvlan_filter_type,
6554 (void *)&cmd_set_vf_macvlan_mode,
6559 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6560 struct cmd_set_vf_traffic {
6561 cmdline_fixed_string_t set;
6562 cmdline_fixed_string_t port;
6564 cmdline_fixed_string_t vf;
6566 cmdline_fixed_string_t what;
6567 cmdline_fixed_string_t mode;
6571 cmd_set_vf_traffic_parsed(void *parsed_result,
6572 __attribute__((unused)) struct cmdline *cl,
6573 __attribute__((unused)) void *data)
6575 struct cmd_set_vf_traffic *res = parsed_result;
6576 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6577 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6579 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6582 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6583 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6585 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6586 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6588 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6589 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6591 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6592 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6594 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6595 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6597 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6598 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6600 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6604 cmdline_parse_inst_t cmd_set_vf_traffic = {
6605 .f = cmd_set_vf_traffic_parsed,
6607 .help_str = "set port X vf Y rx|tx on|off"
6608 "(X = port number,Y = vf id)",
6610 (void *)&cmd_setvf_traffic_set,
6611 (void *)&cmd_setvf_traffic_port,
6612 (void *)&cmd_setvf_traffic_portid,
6613 (void *)&cmd_setvf_traffic_vf,
6614 (void *)&cmd_setvf_traffic_vfid,
6615 (void *)&cmd_setvf_traffic_what,
6616 (void *)&cmd_setvf_traffic_mode,
6621 /* *** CONFIGURE VF RECEIVE MODE *** */
6622 struct cmd_set_vf_rxmode {
6623 cmdline_fixed_string_t set;
6624 cmdline_fixed_string_t port;
6626 cmdline_fixed_string_t vf;
6628 cmdline_fixed_string_t what;
6629 cmdline_fixed_string_t mode;
6630 cmdline_fixed_string_t on;
6634 cmd_set_vf_rxmode_parsed(void *parsed_result,
6635 __attribute__((unused)) struct cmdline *cl,
6636 __attribute__((unused)) void *data)
6639 uint16_t rx_mode = 0;
6640 struct cmd_set_vf_rxmode *res = parsed_result;
6642 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6643 if (!strcmp(res->what,"rxmode")) {
6644 if (!strcmp(res->mode, "AUPE"))
6645 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6646 else if (!strcmp(res->mode, "ROPE"))
6647 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6648 else if (!strcmp(res->mode, "BAM"))
6649 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6650 else if (!strncmp(res->mode, "MPE",3))
6651 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6654 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6656 printf("bad VF receive mode parameter, return code = %d \n",
6660 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6663 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6664 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6666 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6667 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6669 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6672 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6673 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6675 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6676 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6678 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6679 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6680 mode, "AUPE#ROPE#BAM#MPE");
6681 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6682 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6685 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6686 .f = cmd_set_vf_rxmode_parsed,
6688 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6690 (void *)&cmd_set_vf_rxmode_set,
6691 (void *)&cmd_set_vf_rxmode_port,
6692 (void *)&cmd_set_vf_rxmode_portid,
6693 (void *)&cmd_set_vf_rxmode_vf,
6694 (void *)&cmd_set_vf_rxmode_vfid,
6695 (void *)&cmd_set_vf_rxmode_what,
6696 (void *)&cmd_set_vf_rxmode_mode,
6697 (void *)&cmd_set_vf_rxmode_on,
6702 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6703 struct cmd_vf_mac_addr_result {
6704 cmdline_fixed_string_t mac_addr_cmd;
6705 cmdline_fixed_string_t what;
6706 cmdline_fixed_string_t port;
6708 cmdline_fixed_string_t vf;
6710 struct ether_addr address;
6713 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6714 __attribute__((unused)) struct cmdline *cl,
6715 __attribute__((unused)) void *data)
6717 struct cmd_vf_mac_addr_result *res = parsed_result;
6720 if (strcmp(res->what, "add") == 0)
6721 ret = rte_eth_dev_mac_addr_add(res->port_num,
6722 &res->address, res->vf_num);
6724 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6728 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6729 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6730 mac_addr_cmd,"mac_addr");
6731 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6732 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6734 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6735 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6737 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6738 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6740 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6741 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6743 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6744 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6746 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6747 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6750 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6751 .f = cmd_vf_mac_addr_parsed,
6753 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6754 "Y = VF number)add MAC address filtering for a VF on port X",
6756 (void *)&cmd_vf_mac_addr_cmd,
6757 (void *)&cmd_vf_mac_addr_what,
6758 (void *)&cmd_vf_mac_addr_port,
6759 (void *)&cmd_vf_mac_addr_portnum,
6760 (void *)&cmd_vf_mac_addr_vf,
6761 (void *)&cmd_vf_mac_addr_vfnum,
6762 (void *)&cmd_vf_mac_addr_addr,
6767 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6768 struct cmd_vf_rx_vlan_filter {
6769 cmdline_fixed_string_t rx_vlan;
6770 cmdline_fixed_string_t what;
6772 cmdline_fixed_string_t port;
6774 cmdline_fixed_string_t vf;
6779 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6780 __attribute__((unused)) struct cmdline *cl,
6781 __attribute__((unused)) void *data)
6783 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6785 if (!strcmp(res->what, "add"))
6786 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6788 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6791 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6792 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6793 rx_vlan, "rx_vlan");
6794 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6795 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6797 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6798 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6800 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6801 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6803 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6804 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6806 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6807 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6809 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6810 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6813 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6814 .f = cmd_vf_rx_vlan_filter_parsed,
6816 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6817 "Y = port number,Z = hexadecimal VF mask)",
6819 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6820 (void *)&cmd_vf_rx_vlan_filter_what,
6821 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6822 (void *)&cmd_vf_rx_vlan_filter_port,
6823 (void *)&cmd_vf_rx_vlan_filter_portid,
6824 (void *)&cmd_vf_rx_vlan_filter_vf,
6825 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6830 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6831 struct cmd_queue_rate_limit_result {
6832 cmdline_fixed_string_t set;
6833 cmdline_fixed_string_t port;
6835 cmdline_fixed_string_t queue;
6837 cmdline_fixed_string_t rate;
6841 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6842 __attribute__((unused)) struct cmdline *cl,
6843 __attribute__((unused)) void *data)
6845 struct cmd_queue_rate_limit_result *res = parsed_result;
6848 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6849 && (strcmp(res->queue, "queue") == 0)
6850 && (strcmp(res->rate, "rate") == 0))
6851 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6854 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6858 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6859 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6861 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6862 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6864 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6865 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6867 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6868 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6870 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6871 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6873 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6874 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6876 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6877 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6880 cmdline_parse_inst_t cmd_queue_rate_limit = {
6881 .f = cmd_queue_rate_limit_parsed,
6883 .help_str = "set port X queue Y rate Z:(X = port number,"
6884 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6886 (void *)&cmd_queue_rate_limit_set,
6887 (void *)&cmd_queue_rate_limit_port,
6888 (void *)&cmd_queue_rate_limit_portnum,
6889 (void *)&cmd_queue_rate_limit_queue,
6890 (void *)&cmd_queue_rate_limit_queuenum,
6891 (void *)&cmd_queue_rate_limit_rate,
6892 (void *)&cmd_queue_rate_limit_ratenum,
6897 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6898 struct cmd_vf_rate_limit_result {
6899 cmdline_fixed_string_t set;
6900 cmdline_fixed_string_t port;
6902 cmdline_fixed_string_t vf;
6904 cmdline_fixed_string_t rate;
6906 cmdline_fixed_string_t q_msk;
6910 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6911 __attribute__((unused)) struct cmdline *cl,
6912 __attribute__((unused)) void *data)
6914 struct cmd_vf_rate_limit_result *res = parsed_result;
6917 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6918 && (strcmp(res->vf, "vf") == 0)
6919 && (strcmp(res->rate, "rate") == 0)
6920 && (strcmp(res->q_msk, "queue_mask") == 0))
6921 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6922 res->rate_num, res->q_msk_val);
6924 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6928 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6929 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6931 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6932 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6934 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6935 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6937 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6938 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6940 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6941 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6943 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6944 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6946 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6947 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6949 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6950 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6951 q_msk, "queue_mask");
6952 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6953 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6956 cmdline_parse_inst_t cmd_vf_rate_limit = {
6957 .f = cmd_vf_rate_limit_parsed,
6959 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6960 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6961 "for queues of VF on port X",
6963 (void *)&cmd_vf_rate_limit_set,
6964 (void *)&cmd_vf_rate_limit_port,
6965 (void *)&cmd_vf_rate_limit_portnum,
6966 (void *)&cmd_vf_rate_limit_vf,
6967 (void *)&cmd_vf_rate_limit_vfnum,
6968 (void *)&cmd_vf_rate_limit_rate,
6969 (void *)&cmd_vf_rate_limit_ratenum,
6970 (void *)&cmd_vf_rate_limit_q_msk,
6971 (void *)&cmd_vf_rate_limit_q_msk_val,
6976 /* *** ADD TUNNEL FILTER OF A PORT *** */
6977 struct cmd_tunnel_filter_result {
6978 cmdline_fixed_string_t cmd;
6979 cmdline_fixed_string_t what;
6981 struct ether_addr outer_mac;
6982 struct ether_addr inner_mac;
6983 cmdline_ipaddr_t ip_value;
6984 uint16_t inner_vlan;
6985 cmdline_fixed_string_t tunnel_type;
6986 cmdline_fixed_string_t filter_type;
6992 cmd_tunnel_filter_parsed(void *parsed_result,
6993 __attribute__((unused)) struct cmdline *cl,
6994 __attribute__((unused)) void *data)
6996 struct cmd_tunnel_filter_result *res = parsed_result;
6997 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7000 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7002 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7003 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7004 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7006 if (res->ip_value.family == AF_INET) {
7007 tunnel_filter_conf.ip_addr.ipv4_addr =
7008 res->ip_value.addr.ipv4.s_addr;
7009 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7011 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7012 &(res->ip_value.addr.ipv6),
7013 sizeof(struct in6_addr));
7014 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7017 if (!strcmp(res->filter_type, "imac-ivlan"))
7018 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7019 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7020 tunnel_filter_conf.filter_type =
7021 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7022 else if (!strcmp(res->filter_type, "imac-tenid"))
7023 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7024 else if (!strcmp(res->filter_type, "imac"))
7025 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7026 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7027 tunnel_filter_conf.filter_type =
7028 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7029 else if (!strcmp(res->filter_type, "oip"))
7030 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7031 else if (!strcmp(res->filter_type, "iip"))
7032 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7034 printf("The filter type is not supported");
7038 if (!strcmp(res->tunnel_type, "vxlan"))
7039 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7040 else if (!strcmp(res->tunnel_type, "nvgre"))
7041 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7042 else if (!strcmp(res->tunnel_type, "ipingre"))
7043 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7045 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7049 tunnel_filter_conf.tenant_id = res->tenant_id;
7050 tunnel_filter_conf.queue_id = res->queue_num;
7051 if (!strcmp(res->what, "add"))
7052 ret = rte_eth_dev_filter_ctrl(res->port_id,
7053 RTE_ETH_FILTER_TUNNEL,
7055 &tunnel_filter_conf);
7057 ret = rte_eth_dev_filter_ctrl(res->port_id,
7058 RTE_ETH_FILTER_TUNNEL,
7059 RTE_ETH_FILTER_DELETE,
7060 &tunnel_filter_conf);
7062 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7066 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7067 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7068 cmd, "tunnel_filter");
7069 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7070 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7072 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7073 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7075 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7076 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7078 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7079 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7081 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7082 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7083 inner_vlan, UINT16);
7084 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7085 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7087 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7088 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7089 tunnel_type, "vxlan#nvgre#ipingre");
7091 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7092 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7093 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7094 "imac#omac-imac-tenid");
7095 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7096 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7098 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7099 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7102 cmdline_parse_inst_t cmd_tunnel_filter = {
7103 .f = cmd_tunnel_filter_parsed,
7105 .help_str = "add/rm tunnel filter of a port: "
7106 "tunnel_filter add port_id outer_mac inner_mac ip "
7107 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
7108 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
7109 "imac|omac-imac-tenid) "
7110 "tenant_id queue_num",
7112 (void *)&cmd_tunnel_filter_cmd,
7113 (void *)&cmd_tunnel_filter_what,
7114 (void *)&cmd_tunnel_filter_port_id,
7115 (void *)&cmd_tunnel_filter_outer_mac,
7116 (void *)&cmd_tunnel_filter_inner_mac,
7117 (void *)&cmd_tunnel_filter_ip_value,
7118 (void *)&cmd_tunnel_filter_innner_vlan,
7119 (void *)&cmd_tunnel_filter_tunnel_type,
7120 (void *)&cmd_tunnel_filter_filter_type,
7121 (void *)&cmd_tunnel_filter_tenant_id,
7122 (void *)&cmd_tunnel_filter_queue_num,
7127 /* *** CONFIGURE TUNNEL UDP PORT *** */
7128 struct cmd_tunnel_udp_config {
7129 cmdline_fixed_string_t cmd;
7130 cmdline_fixed_string_t what;
7136 cmd_tunnel_udp_config_parsed(void *parsed_result,
7137 __attribute__((unused)) struct cmdline *cl,
7138 __attribute__((unused)) void *data)
7140 struct cmd_tunnel_udp_config *res = parsed_result;
7141 struct rte_eth_udp_tunnel tunnel_udp;
7144 tunnel_udp.udp_port = res->udp_port;
7146 if (!strcmp(res->cmd, "rx_vxlan_port"))
7147 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7149 if (!strcmp(res->what, "add"))
7150 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7153 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7157 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7160 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7161 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7162 cmd, "rx_vxlan_port");
7163 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7164 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7166 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7167 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7169 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7170 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7173 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7174 .f = cmd_tunnel_udp_config_parsed,
7176 .help_str = "add/rm an tunneling UDP port filter: "
7177 "rx_vxlan_port add udp_port port_id",
7179 (void *)&cmd_tunnel_udp_config_cmd,
7180 (void *)&cmd_tunnel_udp_config_what,
7181 (void *)&cmd_tunnel_udp_config_udp_port,
7182 (void *)&cmd_tunnel_udp_config_port_id,
7187 /* *** GLOBAL CONFIG *** */
7188 struct cmd_global_config_result {
7189 cmdline_fixed_string_t cmd;
7191 cmdline_fixed_string_t cfg_type;
7196 cmd_global_config_parsed(void *parsed_result,
7197 __attribute__((unused)) struct cmdline *cl,
7198 __attribute__((unused)) void *data)
7200 struct cmd_global_config_result *res = parsed_result;
7201 struct rte_eth_global_cfg conf;
7204 memset(&conf, 0, sizeof(conf));
7205 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7206 conf.cfg.gre_key_len = res->len;
7207 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7208 RTE_ETH_FILTER_SET, &conf);
7210 printf("Global config error\n");
7213 cmdline_parse_token_string_t cmd_global_config_cmd =
7214 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7216 cmdline_parse_token_num_t cmd_global_config_port_id =
7217 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7218 cmdline_parse_token_string_t cmd_global_config_type =
7219 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7220 cfg_type, "gre-key-len");
7221 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7222 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7225 cmdline_parse_inst_t cmd_global_config = {
7226 .f = cmd_global_config_parsed,
7227 .data = (void *)NULL,
7228 .help_str = "global_config <port_id> gre-key-len <number>",
7230 (void *)&cmd_global_config_cmd,
7231 (void *)&cmd_global_config_port_id,
7232 (void *)&cmd_global_config_type,
7233 (void *)&cmd_global_config_gre_key_len,
7238 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7239 struct cmd_set_mirror_mask_result {
7240 cmdline_fixed_string_t set;
7241 cmdline_fixed_string_t port;
7243 cmdline_fixed_string_t mirror;
7245 cmdline_fixed_string_t what;
7246 cmdline_fixed_string_t value;
7247 cmdline_fixed_string_t dstpool;
7249 cmdline_fixed_string_t on;
7252 cmdline_parse_token_string_t cmd_mirror_mask_set =
7253 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7255 cmdline_parse_token_string_t cmd_mirror_mask_port =
7256 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7258 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7259 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7261 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7262 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7263 mirror, "mirror-rule");
7264 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7265 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7267 cmdline_parse_token_string_t cmd_mirror_mask_what =
7268 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7269 what, "pool-mirror-up#pool-mirror-down"
7271 cmdline_parse_token_string_t cmd_mirror_mask_value =
7272 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7274 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7275 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7276 dstpool, "dst-pool");
7277 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7278 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7280 cmdline_parse_token_string_t cmd_mirror_mask_on =
7281 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7285 cmd_set_mirror_mask_parsed(void *parsed_result,
7286 __attribute__((unused)) struct cmdline *cl,
7287 __attribute__((unused)) void *data)
7290 struct cmd_set_mirror_mask_result *res = parsed_result;
7291 struct rte_eth_mirror_conf mr_conf;
7293 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7295 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7297 mr_conf.dst_pool = res->dstpool_id;
7299 if (!strcmp(res->what, "pool-mirror-up")) {
7300 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7301 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7302 } else if (!strcmp(res->what, "pool-mirror-down")) {
7303 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7304 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7305 } else if (!strcmp(res->what, "vlan-mirror")) {
7306 mr_conf.rule_type = ETH_MIRROR_VLAN;
7307 nb_item = parse_item_list(res->value, "vlan",
7308 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7312 for (i = 0; i < nb_item; i++) {
7313 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7314 printf("Invalid vlan_id: must be < 4096\n");
7318 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7319 mr_conf.vlan.vlan_mask |= 1ULL << i;
7323 if (!strcmp(res->on, "on"))
7324 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7327 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7330 printf("mirror rule add error: (%s)\n", strerror(-ret));
7333 cmdline_parse_inst_t cmd_set_mirror_mask = {
7334 .f = cmd_set_mirror_mask_parsed,
7336 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7337 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7339 (void *)&cmd_mirror_mask_set,
7340 (void *)&cmd_mirror_mask_port,
7341 (void *)&cmd_mirror_mask_portid,
7342 (void *)&cmd_mirror_mask_mirror,
7343 (void *)&cmd_mirror_mask_ruleid,
7344 (void *)&cmd_mirror_mask_what,
7345 (void *)&cmd_mirror_mask_value,
7346 (void *)&cmd_mirror_mask_dstpool,
7347 (void *)&cmd_mirror_mask_poolid,
7348 (void *)&cmd_mirror_mask_on,
7353 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7354 struct cmd_set_mirror_link_result {
7355 cmdline_fixed_string_t set;
7356 cmdline_fixed_string_t port;
7358 cmdline_fixed_string_t mirror;
7360 cmdline_fixed_string_t what;
7361 cmdline_fixed_string_t dstpool;
7363 cmdline_fixed_string_t on;
7366 cmdline_parse_token_string_t cmd_mirror_link_set =
7367 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7369 cmdline_parse_token_string_t cmd_mirror_link_port =
7370 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7372 cmdline_parse_token_num_t cmd_mirror_link_portid =
7373 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7375 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7376 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7377 mirror, "mirror-rule");
7378 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7379 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7381 cmdline_parse_token_string_t cmd_mirror_link_what =
7382 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7383 what, "uplink-mirror#downlink-mirror");
7384 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7385 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7386 dstpool, "dst-pool");
7387 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7388 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7390 cmdline_parse_token_string_t cmd_mirror_link_on =
7391 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7395 cmd_set_mirror_link_parsed(void *parsed_result,
7396 __attribute__((unused)) struct cmdline *cl,
7397 __attribute__((unused)) void *data)
7400 struct cmd_set_mirror_link_result *res = parsed_result;
7401 struct rte_eth_mirror_conf mr_conf;
7403 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7404 if (!strcmp(res->what, "uplink-mirror"))
7405 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7407 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7409 mr_conf.dst_pool = res->dstpool_id;
7411 if (!strcmp(res->on, "on"))
7412 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7415 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7418 /* check the return value and print it if is < 0 */
7420 printf("mirror rule add error: (%s)\n", strerror(-ret));
7424 cmdline_parse_inst_t cmd_set_mirror_link = {
7425 .f = cmd_set_mirror_link_parsed,
7427 .help_str = "set port X mirror-rule Y uplink-mirror|"
7428 "downlink-mirror dst-pool Z on|off",
7430 (void *)&cmd_mirror_link_set,
7431 (void *)&cmd_mirror_link_port,
7432 (void *)&cmd_mirror_link_portid,
7433 (void *)&cmd_mirror_link_mirror,
7434 (void *)&cmd_mirror_link_ruleid,
7435 (void *)&cmd_mirror_link_what,
7436 (void *)&cmd_mirror_link_dstpool,
7437 (void *)&cmd_mirror_link_poolid,
7438 (void *)&cmd_mirror_link_on,
7443 /* *** RESET VM MIRROR RULE *** */
7444 struct cmd_rm_mirror_rule_result {
7445 cmdline_fixed_string_t reset;
7446 cmdline_fixed_string_t port;
7448 cmdline_fixed_string_t mirror;
7452 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7453 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7455 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7456 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7458 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7459 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7461 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7462 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7463 mirror, "mirror-rule");
7464 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7465 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7469 cmd_reset_mirror_rule_parsed(void *parsed_result,
7470 __attribute__((unused)) struct cmdline *cl,
7471 __attribute__((unused)) void *data)
7474 struct cmd_set_mirror_link_result *res = parsed_result;
7476 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7478 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7481 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7482 .f = cmd_reset_mirror_rule_parsed,
7484 .help_str = "reset port X mirror-rule Y",
7486 (void *)&cmd_rm_mirror_rule_reset,
7487 (void *)&cmd_rm_mirror_rule_port,
7488 (void *)&cmd_rm_mirror_rule_portid,
7489 (void *)&cmd_rm_mirror_rule_mirror,
7490 (void *)&cmd_rm_mirror_rule_ruleid,
7495 /* ******************************************************************************** */
7497 struct cmd_dump_result {
7498 cmdline_fixed_string_t dump;
7502 dump_struct_sizes(void)
7504 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7505 DUMP_SIZE(struct rte_mbuf);
7506 DUMP_SIZE(struct rte_mempool);
7507 DUMP_SIZE(struct rte_ring);
7511 static void cmd_dump_parsed(void *parsed_result,
7512 __attribute__((unused)) struct cmdline *cl,
7513 __attribute__((unused)) void *data)
7515 struct cmd_dump_result *res = parsed_result;
7517 if (!strcmp(res->dump, "dump_physmem"))
7518 rte_dump_physmem_layout(stdout);
7519 else if (!strcmp(res->dump, "dump_memzone"))
7520 rte_memzone_dump(stdout);
7521 else if (!strcmp(res->dump, "dump_struct_sizes"))
7522 dump_struct_sizes();
7523 else if (!strcmp(res->dump, "dump_ring"))
7524 rte_ring_list_dump(stdout);
7525 else if (!strcmp(res->dump, "dump_mempool"))
7526 rte_mempool_list_dump(stdout);
7527 else if (!strcmp(res->dump, "dump_devargs"))
7528 rte_eal_devargs_dump(stdout);
7531 cmdline_parse_token_string_t cmd_dump_dump =
7532 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7535 "dump_struct_sizes#"
7540 cmdline_parse_inst_t cmd_dump = {
7541 .f = cmd_dump_parsed, /* function to call */
7542 .data = NULL, /* 2nd arg of func */
7543 .help_str = "dump status",
7544 .tokens = { /* token list, NULL terminated */
7545 (void *)&cmd_dump_dump,
7550 /* ******************************************************************************** */
7552 struct cmd_dump_one_result {
7553 cmdline_fixed_string_t dump;
7554 cmdline_fixed_string_t name;
7557 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7558 __attribute__((unused)) void *data)
7560 struct cmd_dump_one_result *res = parsed_result;
7562 if (!strcmp(res->dump, "dump_ring")) {
7564 r = rte_ring_lookup(res->name);
7566 cmdline_printf(cl, "Cannot find ring\n");
7569 rte_ring_dump(stdout, r);
7570 } else if (!strcmp(res->dump, "dump_mempool")) {
7571 struct rte_mempool *mp;
7572 mp = rte_mempool_lookup(res->name);
7574 cmdline_printf(cl, "Cannot find mempool\n");
7577 rte_mempool_dump(stdout, mp);
7581 cmdline_parse_token_string_t cmd_dump_one_dump =
7582 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7583 "dump_ring#dump_mempool");
7585 cmdline_parse_token_string_t cmd_dump_one_name =
7586 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7588 cmdline_parse_inst_t cmd_dump_one = {
7589 .f = cmd_dump_one_parsed, /* function to call */
7590 .data = NULL, /* 2nd arg of func */
7591 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7592 .tokens = { /* token list, NULL terminated */
7593 (void *)&cmd_dump_one_dump,
7594 (void *)&cmd_dump_one_name,
7599 /* *** Add/Del syn filter *** */
7600 struct cmd_syn_filter_result {
7601 cmdline_fixed_string_t filter;
7603 cmdline_fixed_string_t ops;
7604 cmdline_fixed_string_t priority;
7605 cmdline_fixed_string_t high;
7606 cmdline_fixed_string_t queue;
7611 cmd_syn_filter_parsed(void *parsed_result,
7612 __attribute__((unused)) struct cmdline *cl,
7613 __attribute__((unused)) void *data)
7615 struct cmd_syn_filter_result *res = parsed_result;
7616 struct rte_eth_syn_filter syn_filter;
7619 ret = rte_eth_dev_filter_supported(res->port_id,
7620 RTE_ETH_FILTER_SYN);
7622 printf("syn filter is not supported on port %u.\n",
7627 memset(&syn_filter, 0, sizeof(syn_filter));
7629 if (!strcmp(res->ops, "add")) {
7630 if (!strcmp(res->high, "high"))
7631 syn_filter.hig_pri = 1;
7633 syn_filter.hig_pri = 0;
7635 syn_filter.queue = res->queue_id;
7636 ret = rte_eth_dev_filter_ctrl(res->port_id,
7641 ret = rte_eth_dev_filter_ctrl(res->port_id,
7643 RTE_ETH_FILTER_DELETE,
7647 printf("syn filter programming error: (%s)\n",
7651 cmdline_parse_token_string_t cmd_syn_filter_filter =
7652 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7653 filter, "syn_filter");
7654 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7655 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7657 cmdline_parse_token_string_t cmd_syn_filter_ops =
7658 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7660 cmdline_parse_token_string_t cmd_syn_filter_priority =
7661 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7662 priority, "priority");
7663 cmdline_parse_token_string_t cmd_syn_filter_high =
7664 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7666 cmdline_parse_token_string_t cmd_syn_filter_queue =
7667 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7669 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7670 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7673 cmdline_parse_inst_t cmd_syn_filter = {
7674 .f = cmd_syn_filter_parsed,
7676 .help_str = "add/delete syn filter",
7678 (void *)&cmd_syn_filter_filter,
7679 (void *)&cmd_syn_filter_port_id,
7680 (void *)&cmd_syn_filter_ops,
7681 (void *)&cmd_syn_filter_priority,
7682 (void *)&cmd_syn_filter_high,
7683 (void *)&cmd_syn_filter_queue,
7684 (void *)&cmd_syn_filter_queue_id,
7689 /* *** ADD/REMOVE A 2tuple FILTER *** */
7690 struct cmd_2tuple_filter_result {
7691 cmdline_fixed_string_t filter;
7693 cmdline_fixed_string_t ops;
7694 cmdline_fixed_string_t dst_port;
7695 uint16_t dst_port_value;
7696 cmdline_fixed_string_t protocol;
7697 uint8_t protocol_value;
7698 cmdline_fixed_string_t mask;
7700 cmdline_fixed_string_t tcp_flags;
7701 uint8_t tcp_flags_value;
7702 cmdline_fixed_string_t priority;
7703 uint8_t priority_value;
7704 cmdline_fixed_string_t queue;
7709 cmd_2tuple_filter_parsed(void *parsed_result,
7710 __attribute__((unused)) struct cmdline *cl,
7711 __attribute__((unused)) void *data)
7713 struct rte_eth_ntuple_filter filter;
7714 struct cmd_2tuple_filter_result *res = parsed_result;
7717 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7719 printf("ntuple filter is not supported on port %u.\n",
7724 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7726 filter.flags = RTE_2TUPLE_FLAGS;
7727 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7728 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7729 filter.proto = res->protocol_value;
7730 filter.priority = res->priority_value;
7731 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7732 printf("nonzero tcp_flags is only meaningful"
7733 " when protocol is TCP.\n");
7736 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7737 printf("invalid TCP flags.\n");
7741 if (res->tcp_flags_value != 0) {
7742 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7743 filter.tcp_flags = res->tcp_flags_value;
7746 /* need convert to big endian. */
7747 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7748 filter.queue = res->queue_id;
7750 if (!strcmp(res->ops, "add"))
7751 ret = rte_eth_dev_filter_ctrl(res->port_id,
7752 RTE_ETH_FILTER_NTUPLE,
7756 ret = rte_eth_dev_filter_ctrl(res->port_id,
7757 RTE_ETH_FILTER_NTUPLE,
7758 RTE_ETH_FILTER_DELETE,
7761 printf("2tuple filter programming error: (%s)\n",
7766 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7767 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7768 filter, "2tuple_filter");
7769 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7770 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7772 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7773 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7775 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7776 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7777 dst_port, "dst_port");
7778 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7779 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7780 dst_port_value, UINT16);
7781 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7782 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7783 protocol, "protocol");
7784 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7785 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7786 protocol_value, UINT8);
7787 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7788 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7790 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7791 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7793 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7794 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7795 tcp_flags, "tcp_flags");
7796 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7797 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7798 tcp_flags_value, UINT8);
7799 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7800 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7801 priority, "priority");
7802 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7803 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7804 priority_value, UINT8);
7805 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7806 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7808 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7809 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7812 cmdline_parse_inst_t cmd_2tuple_filter = {
7813 .f = cmd_2tuple_filter_parsed,
7815 .help_str = "add a 2tuple filter",
7817 (void *)&cmd_2tuple_filter_filter,
7818 (void *)&cmd_2tuple_filter_port_id,
7819 (void *)&cmd_2tuple_filter_ops,
7820 (void *)&cmd_2tuple_filter_dst_port,
7821 (void *)&cmd_2tuple_filter_dst_port_value,
7822 (void *)&cmd_2tuple_filter_protocol,
7823 (void *)&cmd_2tuple_filter_protocol_value,
7824 (void *)&cmd_2tuple_filter_mask,
7825 (void *)&cmd_2tuple_filter_mask_value,
7826 (void *)&cmd_2tuple_filter_tcp_flags,
7827 (void *)&cmd_2tuple_filter_tcp_flags_value,
7828 (void *)&cmd_2tuple_filter_priority,
7829 (void *)&cmd_2tuple_filter_priority_value,
7830 (void *)&cmd_2tuple_filter_queue,
7831 (void *)&cmd_2tuple_filter_queue_id,
7836 /* *** ADD/REMOVE A 5tuple FILTER *** */
7837 struct cmd_5tuple_filter_result {
7838 cmdline_fixed_string_t filter;
7840 cmdline_fixed_string_t ops;
7841 cmdline_fixed_string_t dst_ip;
7842 cmdline_ipaddr_t dst_ip_value;
7843 cmdline_fixed_string_t src_ip;
7844 cmdline_ipaddr_t src_ip_value;
7845 cmdline_fixed_string_t dst_port;
7846 uint16_t dst_port_value;
7847 cmdline_fixed_string_t src_port;
7848 uint16_t src_port_value;
7849 cmdline_fixed_string_t protocol;
7850 uint8_t protocol_value;
7851 cmdline_fixed_string_t mask;
7853 cmdline_fixed_string_t tcp_flags;
7854 uint8_t tcp_flags_value;
7855 cmdline_fixed_string_t priority;
7856 uint8_t priority_value;
7857 cmdline_fixed_string_t queue;
7862 cmd_5tuple_filter_parsed(void *parsed_result,
7863 __attribute__((unused)) struct cmdline *cl,
7864 __attribute__((unused)) void *data)
7866 struct rte_eth_ntuple_filter filter;
7867 struct cmd_5tuple_filter_result *res = parsed_result;
7870 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7872 printf("ntuple filter is not supported on port %u.\n",
7877 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7879 filter.flags = RTE_5TUPLE_FLAGS;
7880 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7881 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7882 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7883 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7884 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7885 filter.proto = res->protocol_value;
7886 filter.priority = res->priority_value;
7887 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7888 printf("nonzero tcp_flags is only meaningful"
7889 " when protocol is TCP.\n");
7892 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7893 printf("invalid TCP flags.\n");
7897 if (res->tcp_flags_value != 0) {
7898 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7899 filter.tcp_flags = res->tcp_flags_value;
7902 if (res->dst_ip_value.family == AF_INET)
7903 /* no need to convert, already big endian. */
7904 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7906 if (filter.dst_ip_mask == 0) {
7907 printf("can not support ipv6 involved compare.\n");
7913 if (res->src_ip_value.family == AF_INET)
7914 /* no need to convert, already big endian. */
7915 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7917 if (filter.src_ip_mask == 0) {
7918 printf("can not support ipv6 involved compare.\n");
7923 /* need convert to big endian. */
7924 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7925 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7926 filter.queue = res->queue_id;
7928 if (!strcmp(res->ops, "add"))
7929 ret = rte_eth_dev_filter_ctrl(res->port_id,
7930 RTE_ETH_FILTER_NTUPLE,
7934 ret = rte_eth_dev_filter_ctrl(res->port_id,
7935 RTE_ETH_FILTER_NTUPLE,
7936 RTE_ETH_FILTER_DELETE,
7939 printf("5tuple filter programming error: (%s)\n",
7943 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7944 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7945 filter, "5tuple_filter");
7946 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7947 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7949 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7950 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7952 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7953 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7955 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7956 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7958 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7959 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7961 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7962 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7964 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7965 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7966 dst_port, "dst_port");
7967 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7968 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7969 dst_port_value, UINT16);
7970 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7971 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7972 src_port, "src_port");
7973 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7974 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7975 src_port_value, UINT16);
7976 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7977 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7978 protocol, "protocol");
7979 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7980 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7981 protocol_value, UINT8);
7982 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7983 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7985 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7986 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7988 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7989 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7990 tcp_flags, "tcp_flags");
7991 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7992 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7993 tcp_flags_value, UINT8);
7994 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7995 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7996 priority, "priority");
7997 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7998 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7999 priority_value, UINT8);
8000 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8001 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8003 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8004 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8007 cmdline_parse_inst_t cmd_5tuple_filter = {
8008 .f = cmd_5tuple_filter_parsed,
8010 .help_str = "add/del a 5tuple filter",
8012 (void *)&cmd_5tuple_filter_filter,
8013 (void *)&cmd_5tuple_filter_port_id,
8014 (void *)&cmd_5tuple_filter_ops,
8015 (void *)&cmd_5tuple_filter_dst_ip,
8016 (void *)&cmd_5tuple_filter_dst_ip_value,
8017 (void *)&cmd_5tuple_filter_src_ip,
8018 (void *)&cmd_5tuple_filter_src_ip_value,
8019 (void *)&cmd_5tuple_filter_dst_port,
8020 (void *)&cmd_5tuple_filter_dst_port_value,
8021 (void *)&cmd_5tuple_filter_src_port,
8022 (void *)&cmd_5tuple_filter_src_port_value,
8023 (void *)&cmd_5tuple_filter_protocol,
8024 (void *)&cmd_5tuple_filter_protocol_value,
8025 (void *)&cmd_5tuple_filter_mask,
8026 (void *)&cmd_5tuple_filter_mask_value,
8027 (void *)&cmd_5tuple_filter_tcp_flags,
8028 (void *)&cmd_5tuple_filter_tcp_flags_value,
8029 (void *)&cmd_5tuple_filter_priority,
8030 (void *)&cmd_5tuple_filter_priority_value,
8031 (void *)&cmd_5tuple_filter_queue,
8032 (void *)&cmd_5tuple_filter_queue_id,
8037 /* *** ADD/REMOVE A flex FILTER *** */
8038 struct cmd_flex_filter_result {
8039 cmdline_fixed_string_t filter;
8040 cmdline_fixed_string_t ops;
8042 cmdline_fixed_string_t len;
8044 cmdline_fixed_string_t bytes;
8045 cmdline_fixed_string_t bytes_value;
8046 cmdline_fixed_string_t mask;
8047 cmdline_fixed_string_t mask_value;
8048 cmdline_fixed_string_t priority;
8049 uint8_t priority_value;
8050 cmdline_fixed_string_t queue;
8054 static int xdigit2val(unsigned char c)
8059 else if (isupper(c))
8067 cmd_flex_filter_parsed(void *parsed_result,
8068 __attribute__((unused)) struct cmdline *cl,
8069 __attribute__((unused)) void *data)
8072 struct rte_eth_flex_filter filter;
8073 struct cmd_flex_filter_result *res = parsed_result;
8074 char *bytes_ptr, *mask_ptr;
8075 uint16_t len, i, j = 0;
8080 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8081 printf("the len exceed the max length 128\n");
8084 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8085 filter.len = res->len_value;
8086 filter.priority = res->priority_value;
8087 filter.queue = res->queue_id;
8088 bytes_ptr = res->bytes_value;
8089 mask_ptr = res->mask_value;
8091 /* translate bytes string to array. */
8092 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8093 (bytes_ptr[1] == 'X')))
8095 len = strnlen(bytes_ptr, res->len_value * 2);
8096 if (len == 0 || (len % 8 != 0)) {
8097 printf("please check len and bytes input\n");
8100 for (i = 0; i < len; i++) {
8102 if (isxdigit(c) == 0) {
8103 /* invalid characters. */
8104 printf("invalid input\n");
8107 val = xdigit2val(c);
8110 filter.bytes[j] = byte;
8111 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8118 /* translate mask string to uint8_t array. */
8119 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8120 (mask_ptr[1] == 'X')))
8122 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8124 printf("invalid input\n");
8129 for (i = 0; i < len; i++) {
8131 if (isxdigit(c) == 0) {
8132 /* invalid characters. */
8133 printf("invalid input\n");
8136 val = xdigit2val(c);
8139 filter.mask[j] = byte;
8140 printf("mask[%d]:%02x ", j, filter.mask[j]);
8148 if (!strcmp(res->ops, "add"))
8149 ret = rte_eth_dev_filter_ctrl(res->port_id,
8150 RTE_ETH_FILTER_FLEXIBLE,
8154 ret = rte_eth_dev_filter_ctrl(res->port_id,
8155 RTE_ETH_FILTER_FLEXIBLE,
8156 RTE_ETH_FILTER_DELETE,
8160 printf("flex filter setting error: (%s)\n", strerror(-ret));
8163 cmdline_parse_token_string_t cmd_flex_filter_filter =
8164 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8165 filter, "flex_filter");
8166 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8167 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8169 cmdline_parse_token_string_t cmd_flex_filter_ops =
8170 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8172 cmdline_parse_token_string_t cmd_flex_filter_len =
8173 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8175 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8176 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8178 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8179 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8181 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8182 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8184 cmdline_parse_token_string_t cmd_flex_filter_mask =
8185 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8187 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8188 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8190 cmdline_parse_token_string_t cmd_flex_filter_priority =
8191 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8192 priority, "priority");
8193 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8194 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8195 priority_value, UINT8);
8196 cmdline_parse_token_string_t cmd_flex_filter_queue =
8197 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8199 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8200 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8202 cmdline_parse_inst_t cmd_flex_filter = {
8203 .f = cmd_flex_filter_parsed,
8205 .help_str = "add/del a flex filter",
8207 (void *)&cmd_flex_filter_filter,
8208 (void *)&cmd_flex_filter_port_id,
8209 (void *)&cmd_flex_filter_ops,
8210 (void *)&cmd_flex_filter_len,
8211 (void *)&cmd_flex_filter_len_value,
8212 (void *)&cmd_flex_filter_bytes,
8213 (void *)&cmd_flex_filter_bytes_value,
8214 (void *)&cmd_flex_filter_mask,
8215 (void *)&cmd_flex_filter_mask_value,
8216 (void *)&cmd_flex_filter_priority,
8217 (void *)&cmd_flex_filter_priority_value,
8218 (void *)&cmd_flex_filter_queue,
8219 (void *)&cmd_flex_filter_queue_id,
8224 /* *** Filters Control *** */
8226 /* *** deal with ethertype filter *** */
8227 struct cmd_ethertype_filter_result {
8228 cmdline_fixed_string_t filter;
8230 cmdline_fixed_string_t ops;
8231 cmdline_fixed_string_t mac;
8232 struct ether_addr mac_addr;
8233 cmdline_fixed_string_t ethertype;
8234 uint16_t ethertype_value;
8235 cmdline_fixed_string_t drop;
8236 cmdline_fixed_string_t queue;
8240 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8241 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8242 filter, "ethertype_filter");
8243 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8244 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8246 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8247 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8249 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8250 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8251 mac, "mac_addr#mac_ignr");
8252 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8253 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8255 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8256 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8257 ethertype, "ethertype");
8258 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8259 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8260 ethertype_value, UINT16);
8261 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8262 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8264 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8265 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8267 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8268 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8272 cmd_ethertype_filter_parsed(void *parsed_result,
8273 __attribute__((unused)) struct cmdline *cl,
8274 __attribute__((unused)) void *data)
8276 struct cmd_ethertype_filter_result *res = parsed_result;
8277 struct rte_eth_ethertype_filter filter;
8280 ret = rte_eth_dev_filter_supported(res->port_id,
8281 RTE_ETH_FILTER_ETHERTYPE);
8283 printf("ethertype filter is not supported on port %u.\n",
8288 memset(&filter, 0, sizeof(filter));
8289 if (!strcmp(res->mac, "mac_addr")) {
8290 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8291 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8292 sizeof(struct ether_addr));
8294 if (!strcmp(res->drop, "drop"))
8295 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8296 filter.ether_type = res->ethertype_value;
8297 filter.queue = res->queue_id;
8299 if (!strcmp(res->ops, "add"))
8300 ret = rte_eth_dev_filter_ctrl(res->port_id,
8301 RTE_ETH_FILTER_ETHERTYPE,
8305 ret = rte_eth_dev_filter_ctrl(res->port_id,
8306 RTE_ETH_FILTER_ETHERTYPE,
8307 RTE_ETH_FILTER_DELETE,
8310 printf("ethertype filter programming error: (%s)\n",
8314 cmdline_parse_inst_t cmd_ethertype_filter = {
8315 .f = cmd_ethertype_filter_parsed,
8317 .help_str = "add or delete an ethertype filter entry",
8319 (void *)&cmd_ethertype_filter_filter,
8320 (void *)&cmd_ethertype_filter_port_id,
8321 (void *)&cmd_ethertype_filter_ops,
8322 (void *)&cmd_ethertype_filter_mac,
8323 (void *)&cmd_ethertype_filter_mac_addr,
8324 (void *)&cmd_ethertype_filter_ethertype,
8325 (void *)&cmd_ethertype_filter_ethertype_value,
8326 (void *)&cmd_ethertype_filter_drop,
8327 (void *)&cmd_ethertype_filter_queue,
8328 (void *)&cmd_ethertype_filter_queue_id,
8333 /* *** deal with flow director filter *** */
8334 struct cmd_flow_director_result {
8335 cmdline_fixed_string_t flow_director_filter;
8337 cmdline_fixed_string_t mode;
8338 cmdline_fixed_string_t mode_value;
8339 cmdline_fixed_string_t ops;
8340 cmdline_fixed_string_t flow;
8341 cmdline_fixed_string_t flow_type;
8342 cmdline_fixed_string_t ether;
8343 uint16_t ether_type;
8344 cmdline_fixed_string_t src;
8345 cmdline_ipaddr_t ip_src;
8347 cmdline_fixed_string_t dst;
8348 cmdline_ipaddr_t ip_dst;
8350 cmdline_fixed_string_t verify_tag;
8351 uint32_t verify_tag_value;
8352 cmdline_ipaddr_t tos;
8354 cmdline_ipaddr_t proto;
8355 uint8_t proto_value;
8356 cmdline_ipaddr_t ttl;
8358 cmdline_fixed_string_t vlan;
8359 uint16_t vlan_value;
8360 cmdline_fixed_string_t flexbytes;
8361 cmdline_fixed_string_t flexbytes_value;
8362 cmdline_fixed_string_t pf_vf;
8363 cmdline_fixed_string_t drop;
8364 cmdline_fixed_string_t queue;
8366 cmdline_fixed_string_t fd_id;
8367 uint32_t fd_id_value;
8368 cmdline_fixed_string_t mac;
8369 struct ether_addr mac_addr;
8370 cmdline_fixed_string_t tunnel;
8371 cmdline_fixed_string_t tunnel_type;
8372 cmdline_fixed_string_t tunnel_id;
8373 uint32_t tunnel_id_value;
8377 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8380 const char *p, *p0 = q_arg;
8382 unsigned long int_fld;
8383 char *str_fld[max_num];
8388 p = strchr(p0, '(');
8392 p0 = strchr(p, ')');
8397 if (size >= sizeof(s))
8400 snprintf(s, sizeof(s), "%.*s", size, p);
8401 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8402 if (ret < 0 || ret > max_num)
8404 for (i = 0; i < ret; i++) {
8406 int_fld = strtoul(str_fld[i], &end, 0);
8407 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8409 flexbytes[i] = (uint8_t)int_fld;
8415 str2flowtype(char *string)
8418 static const struct {
8421 } flowtype_str[] = {
8422 {"raw", RTE_ETH_FLOW_RAW},
8423 {"ipv4", RTE_ETH_FLOW_IPV4},
8424 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8425 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8426 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8427 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8428 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8429 {"ipv6", RTE_ETH_FLOW_IPV6},
8430 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8431 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8432 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8433 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8434 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8435 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8438 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8439 if (!strcmp(flowtype_str[i].str, string))
8440 return flowtype_str[i].type;
8442 return RTE_ETH_FLOW_UNKNOWN;
8445 static enum rte_eth_fdir_tunnel_type
8446 str2fdir_tunneltype(char *string)
8450 static const struct {
8452 enum rte_eth_fdir_tunnel_type type;
8453 } tunneltype_str[] = {
8454 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8455 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8458 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8459 if (!strcmp(tunneltype_str[i].str, string))
8460 return tunneltype_str[i].type;
8462 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8465 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8467 if ((ip_addr).family == AF_INET) \
8468 (ip) = (ip_addr).addr.ipv4.s_addr; \
8470 printf("invalid parameter.\n"); \
8475 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8477 if ((ip_addr).family == AF_INET6) \
8478 (void)rte_memcpy(&(ip), \
8479 &((ip_addr).addr.ipv6), \
8480 sizeof(struct in6_addr)); \
8482 printf("invalid parameter.\n"); \
8488 cmd_flow_director_filter_parsed(void *parsed_result,
8489 __attribute__((unused)) struct cmdline *cl,
8490 __attribute__((unused)) void *data)
8492 struct cmd_flow_director_result *res = parsed_result;
8493 struct rte_eth_fdir_filter entry;
8494 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8496 unsigned long vf_id;
8499 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8501 printf("flow director is not supported on port %u.\n",
8505 memset(flexbytes, 0, sizeof(flexbytes));
8506 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8508 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8509 if (strcmp(res->mode_value, "MAC-VLAN")) {
8510 printf("Please set mode to MAC-VLAN.\n");
8513 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8514 if (strcmp(res->mode_value, "Tunnel")) {
8515 printf("Please set mode to Tunnel.\n");
8519 if (strcmp(res->mode_value, "IP")) {
8520 printf("Please set mode to IP.\n");
8523 entry.input.flow_type = str2flowtype(res->flow_type);
8526 ret = parse_flexbytes(res->flexbytes_value,
8528 RTE_ETH_FDIR_MAX_FLEXLEN);
8530 printf("error: Cannot parse flexbytes input.\n");
8534 switch (entry.input.flow_type) {
8535 case RTE_ETH_FLOW_FRAG_IPV4:
8536 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8537 entry.input.flow.ip4_flow.proto = res->proto_value;
8538 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8539 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8540 IPV4_ADDR_TO_UINT(res->ip_dst,
8541 entry.input.flow.ip4_flow.dst_ip);
8542 IPV4_ADDR_TO_UINT(res->ip_src,
8543 entry.input.flow.ip4_flow.src_ip);
8544 entry.input.flow.ip4_flow.tos = res->tos_value;
8545 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8546 /* need convert to big endian. */
8547 entry.input.flow.udp4_flow.dst_port =
8548 rte_cpu_to_be_16(res->port_dst);
8549 entry.input.flow.udp4_flow.src_port =
8550 rte_cpu_to_be_16(res->port_src);
8552 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8553 IPV4_ADDR_TO_UINT(res->ip_dst,
8554 entry.input.flow.sctp4_flow.ip.dst_ip);
8555 IPV4_ADDR_TO_UINT(res->ip_src,
8556 entry.input.flow.sctp4_flow.ip.src_ip);
8557 entry.input.flow.ip4_flow.tos = res->tos_value;
8558 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8559 /* need convert to big endian. */
8560 entry.input.flow.sctp4_flow.dst_port =
8561 rte_cpu_to_be_16(res->port_dst);
8562 entry.input.flow.sctp4_flow.src_port =
8563 rte_cpu_to_be_16(res->port_src);
8564 entry.input.flow.sctp4_flow.verify_tag =
8565 rte_cpu_to_be_32(res->verify_tag_value);
8567 case RTE_ETH_FLOW_FRAG_IPV6:
8568 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8569 entry.input.flow.ipv6_flow.proto = res->proto_value;
8570 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8571 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8572 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8573 entry.input.flow.ipv6_flow.dst_ip);
8574 IPV6_ADDR_TO_ARRAY(res->ip_src,
8575 entry.input.flow.ipv6_flow.src_ip);
8576 entry.input.flow.ipv6_flow.tc = res->tos_value;
8577 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8578 /* need convert to big endian. */
8579 entry.input.flow.udp6_flow.dst_port =
8580 rte_cpu_to_be_16(res->port_dst);
8581 entry.input.flow.udp6_flow.src_port =
8582 rte_cpu_to_be_16(res->port_src);
8584 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8585 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8586 entry.input.flow.sctp6_flow.ip.dst_ip);
8587 IPV6_ADDR_TO_ARRAY(res->ip_src,
8588 entry.input.flow.sctp6_flow.ip.src_ip);
8589 entry.input.flow.ipv6_flow.tc = res->tos_value;
8590 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8591 /* need convert to big endian. */
8592 entry.input.flow.sctp6_flow.dst_port =
8593 rte_cpu_to_be_16(res->port_dst);
8594 entry.input.flow.sctp6_flow.src_port =
8595 rte_cpu_to_be_16(res->port_src);
8596 entry.input.flow.sctp6_flow.verify_tag =
8597 rte_cpu_to_be_32(res->verify_tag_value);
8599 case RTE_ETH_FLOW_L2_PAYLOAD:
8600 entry.input.flow.l2_flow.ether_type =
8601 rte_cpu_to_be_16(res->ether_type);
8607 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8608 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8610 sizeof(struct ether_addr));
8612 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8613 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8615 sizeof(struct ether_addr));
8616 entry.input.flow.tunnel_flow.tunnel_type =
8617 str2fdir_tunneltype(res->tunnel_type);
8618 entry.input.flow.tunnel_flow.tunnel_id =
8619 rte_cpu_to_be_32(res->tunnel_id_value);
8622 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8624 RTE_ETH_FDIR_MAX_FLEXLEN);
8626 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8628 entry.action.flex_off = 0; /*use 0 by default */
8629 if (!strcmp(res->drop, "drop"))
8630 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8632 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8634 if (!strcmp(res->pf_vf, "pf"))
8635 entry.input.flow_ext.is_vf = 0;
8636 else if (!strncmp(res->pf_vf, "vf", 2)) {
8637 struct rte_eth_dev_info dev_info;
8639 memset(&dev_info, 0, sizeof(dev_info));
8640 rte_eth_dev_info_get(res->port_id, &dev_info);
8642 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8643 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8644 printf("invalid parameter %s.\n", res->pf_vf);
8647 entry.input.flow_ext.is_vf = 1;
8648 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8650 printf("invalid parameter %s.\n", res->pf_vf);
8654 /* set to report FD ID by default */
8655 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8656 entry.action.rx_queue = res->queue_id;
8657 entry.soft_id = res->fd_id_value;
8658 if (!strcmp(res->ops, "add"))
8659 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8660 RTE_ETH_FILTER_ADD, &entry);
8661 else if (!strcmp(res->ops, "del"))
8662 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8663 RTE_ETH_FILTER_DELETE, &entry);
8665 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8666 RTE_ETH_FILTER_UPDATE, &entry);
8668 printf("flow director programming error: (%s)\n",
8672 cmdline_parse_token_string_t cmd_flow_director_filter =
8673 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8674 flow_director_filter, "flow_director_filter");
8675 cmdline_parse_token_num_t cmd_flow_director_port_id =
8676 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8678 cmdline_parse_token_string_t cmd_flow_director_ops =
8679 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8680 ops, "add#del#update");
8681 cmdline_parse_token_string_t cmd_flow_director_flow =
8682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8684 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8686 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8687 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8688 cmdline_parse_token_string_t cmd_flow_director_ether =
8689 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8691 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8692 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8693 ether_type, UINT16);
8694 cmdline_parse_token_string_t cmd_flow_director_src =
8695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8697 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8698 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8700 cmdline_parse_token_num_t cmd_flow_director_port_src =
8701 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8703 cmdline_parse_token_string_t cmd_flow_director_dst =
8704 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8706 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8707 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8709 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8710 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8712 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8713 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8714 verify_tag, "verify_tag");
8715 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8716 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8717 verify_tag_value, UINT32);
8718 cmdline_parse_token_string_t cmd_flow_director_tos =
8719 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8721 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8722 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8724 cmdline_parse_token_string_t cmd_flow_director_proto =
8725 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8727 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8728 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8729 proto_value, UINT8);
8730 cmdline_parse_token_string_t cmd_flow_director_ttl =
8731 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8733 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8734 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8736 cmdline_parse_token_string_t cmd_flow_director_vlan =
8737 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8739 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8740 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8741 vlan_value, UINT16);
8742 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8743 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8744 flexbytes, "flexbytes");
8745 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8746 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8747 flexbytes_value, NULL);
8748 cmdline_parse_token_string_t cmd_flow_director_drop =
8749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8751 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8754 cmdline_parse_token_string_t cmd_flow_director_queue =
8755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8757 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8758 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8760 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8763 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8764 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8765 fd_id_value, UINT32);
8767 cmdline_parse_token_string_t cmd_flow_director_mode =
8768 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8770 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8771 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8773 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8775 mode_value, "MAC-VLAN");
8776 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8777 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8778 mode_value, "Tunnel");
8779 cmdline_parse_token_string_t cmd_flow_director_mac =
8780 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8782 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8783 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8785 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8786 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8788 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8790 tunnel_type, "NVGRE#VxLAN");
8791 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8793 tunnel_id, "tunnel-id");
8794 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8795 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8796 tunnel_id_value, UINT32);
8798 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8799 .f = cmd_flow_director_filter_parsed,
8801 .help_str = "add or delete an ip flow director entry on NIC",
8803 (void *)&cmd_flow_director_filter,
8804 (void *)&cmd_flow_director_port_id,
8805 (void *)&cmd_flow_director_mode,
8806 (void *)&cmd_flow_director_mode_ip,
8807 (void *)&cmd_flow_director_ops,
8808 (void *)&cmd_flow_director_flow,
8809 (void *)&cmd_flow_director_flow_type,
8810 (void *)&cmd_flow_director_src,
8811 (void *)&cmd_flow_director_ip_src,
8812 (void *)&cmd_flow_director_dst,
8813 (void *)&cmd_flow_director_ip_dst,
8814 (void *)&cmd_flow_director_tos,
8815 (void *)&cmd_flow_director_tos_value,
8816 (void *)&cmd_flow_director_proto,
8817 (void *)&cmd_flow_director_proto_value,
8818 (void *)&cmd_flow_director_ttl,
8819 (void *)&cmd_flow_director_ttl_value,
8820 (void *)&cmd_flow_director_vlan,
8821 (void *)&cmd_flow_director_vlan_value,
8822 (void *)&cmd_flow_director_flexbytes,
8823 (void *)&cmd_flow_director_flexbytes_value,
8824 (void *)&cmd_flow_director_drop,
8825 (void *)&cmd_flow_director_pf_vf,
8826 (void *)&cmd_flow_director_queue,
8827 (void *)&cmd_flow_director_queue_id,
8828 (void *)&cmd_flow_director_fd_id,
8829 (void *)&cmd_flow_director_fd_id_value,
8834 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8835 .f = cmd_flow_director_filter_parsed,
8837 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8839 (void *)&cmd_flow_director_filter,
8840 (void *)&cmd_flow_director_port_id,
8841 (void *)&cmd_flow_director_mode,
8842 (void *)&cmd_flow_director_mode_ip,
8843 (void *)&cmd_flow_director_ops,
8844 (void *)&cmd_flow_director_flow,
8845 (void *)&cmd_flow_director_flow_type,
8846 (void *)&cmd_flow_director_src,
8847 (void *)&cmd_flow_director_ip_src,
8848 (void *)&cmd_flow_director_port_src,
8849 (void *)&cmd_flow_director_dst,
8850 (void *)&cmd_flow_director_ip_dst,
8851 (void *)&cmd_flow_director_port_dst,
8852 (void *)&cmd_flow_director_tos,
8853 (void *)&cmd_flow_director_tos_value,
8854 (void *)&cmd_flow_director_ttl,
8855 (void *)&cmd_flow_director_ttl_value,
8856 (void *)&cmd_flow_director_vlan,
8857 (void *)&cmd_flow_director_vlan_value,
8858 (void *)&cmd_flow_director_flexbytes,
8859 (void *)&cmd_flow_director_flexbytes_value,
8860 (void *)&cmd_flow_director_drop,
8861 (void *)&cmd_flow_director_pf_vf,
8862 (void *)&cmd_flow_director_queue,
8863 (void *)&cmd_flow_director_queue_id,
8864 (void *)&cmd_flow_director_fd_id,
8865 (void *)&cmd_flow_director_fd_id_value,
8870 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8871 .f = cmd_flow_director_filter_parsed,
8873 .help_str = "add or delete a sctp flow director entry on NIC",
8875 (void *)&cmd_flow_director_filter,
8876 (void *)&cmd_flow_director_port_id,
8877 (void *)&cmd_flow_director_mode,
8878 (void *)&cmd_flow_director_mode_ip,
8879 (void *)&cmd_flow_director_ops,
8880 (void *)&cmd_flow_director_flow,
8881 (void *)&cmd_flow_director_flow_type,
8882 (void *)&cmd_flow_director_src,
8883 (void *)&cmd_flow_director_ip_src,
8884 (void *)&cmd_flow_director_port_dst,
8885 (void *)&cmd_flow_director_dst,
8886 (void *)&cmd_flow_director_ip_dst,
8887 (void *)&cmd_flow_director_port_dst,
8888 (void *)&cmd_flow_director_verify_tag,
8889 (void *)&cmd_flow_director_verify_tag_value,
8890 (void *)&cmd_flow_director_tos,
8891 (void *)&cmd_flow_director_tos_value,
8892 (void *)&cmd_flow_director_ttl,
8893 (void *)&cmd_flow_director_ttl_value,
8894 (void *)&cmd_flow_director_vlan,
8895 (void *)&cmd_flow_director_vlan_value,
8896 (void *)&cmd_flow_director_flexbytes,
8897 (void *)&cmd_flow_director_flexbytes_value,
8898 (void *)&cmd_flow_director_drop,
8899 (void *)&cmd_flow_director_pf_vf,
8900 (void *)&cmd_flow_director_queue,
8901 (void *)&cmd_flow_director_queue_id,
8902 (void *)&cmd_flow_director_fd_id,
8903 (void *)&cmd_flow_director_fd_id_value,
8908 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8909 .f = cmd_flow_director_filter_parsed,
8911 .help_str = "add or delete a L2 flow director entry on NIC",
8913 (void *)&cmd_flow_director_filter,
8914 (void *)&cmd_flow_director_port_id,
8915 (void *)&cmd_flow_director_mode,
8916 (void *)&cmd_flow_director_mode_ip,
8917 (void *)&cmd_flow_director_ops,
8918 (void *)&cmd_flow_director_flow,
8919 (void *)&cmd_flow_director_flow_type,
8920 (void *)&cmd_flow_director_ether,
8921 (void *)&cmd_flow_director_ether_type,
8922 (void *)&cmd_flow_director_flexbytes,
8923 (void *)&cmd_flow_director_flexbytes_value,
8924 (void *)&cmd_flow_director_drop,
8925 (void *)&cmd_flow_director_pf_vf,
8926 (void *)&cmd_flow_director_queue,
8927 (void *)&cmd_flow_director_queue_id,
8928 (void *)&cmd_flow_director_fd_id,
8929 (void *)&cmd_flow_director_fd_id_value,
8934 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8935 .f = cmd_flow_director_filter_parsed,
8937 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8939 (void *)&cmd_flow_director_filter,
8940 (void *)&cmd_flow_director_port_id,
8941 (void *)&cmd_flow_director_mode,
8942 (void *)&cmd_flow_director_mode_mac_vlan,
8943 (void *)&cmd_flow_director_ops,
8944 (void *)&cmd_flow_director_mac,
8945 (void *)&cmd_flow_director_mac_addr,
8946 (void *)&cmd_flow_director_vlan,
8947 (void *)&cmd_flow_director_vlan_value,
8948 (void *)&cmd_flow_director_flexbytes,
8949 (void *)&cmd_flow_director_flexbytes_value,
8950 (void *)&cmd_flow_director_drop,
8951 (void *)&cmd_flow_director_queue,
8952 (void *)&cmd_flow_director_queue_id,
8953 (void *)&cmd_flow_director_fd_id,
8954 (void *)&cmd_flow_director_fd_id_value,
8959 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8960 .f = cmd_flow_director_filter_parsed,
8962 .help_str = "add or delete a tunnel flow director entry on NIC",
8964 (void *)&cmd_flow_director_filter,
8965 (void *)&cmd_flow_director_port_id,
8966 (void *)&cmd_flow_director_mode,
8967 (void *)&cmd_flow_director_mode_tunnel,
8968 (void *)&cmd_flow_director_ops,
8969 (void *)&cmd_flow_director_mac,
8970 (void *)&cmd_flow_director_mac_addr,
8971 (void *)&cmd_flow_director_vlan,
8972 (void *)&cmd_flow_director_vlan_value,
8973 (void *)&cmd_flow_director_tunnel,
8974 (void *)&cmd_flow_director_tunnel_type,
8975 (void *)&cmd_flow_director_tunnel_id,
8976 (void *)&cmd_flow_director_tunnel_id_value,
8977 (void *)&cmd_flow_director_flexbytes,
8978 (void *)&cmd_flow_director_flexbytes_value,
8979 (void *)&cmd_flow_director_drop,
8980 (void *)&cmd_flow_director_queue,
8981 (void *)&cmd_flow_director_queue_id,
8982 (void *)&cmd_flow_director_fd_id,
8983 (void *)&cmd_flow_director_fd_id_value,
8988 struct cmd_flush_flow_director_result {
8989 cmdline_fixed_string_t flush_flow_director;
8993 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8994 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8995 flush_flow_director, "flush_flow_director");
8996 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8997 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9001 cmd_flush_flow_director_parsed(void *parsed_result,
9002 __attribute__((unused)) struct cmdline *cl,
9003 __attribute__((unused)) void *data)
9005 struct cmd_flow_director_result *res = parsed_result;
9008 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9010 printf("flow director is not supported on port %u.\n",
9015 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9016 RTE_ETH_FILTER_FLUSH, NULL);
9018 printf("flow director table flushing error: (%s)\n",
9022 cmdline_parse_inst_t cmd_flush_flow_director = {
9023 .f = cmd_flush_flow_director_parsed,
9025 .help_str = "flush all flow director entries of a device on NIC",
9027 (void *)&cmd_flush_flow_director_flush,
9028 (void *)&cmd_flush_flow_director_port_id,
9033 /* *** deal with flow director mask *** */
9034 struct cmd_flow_director_mask_result {
9035 cmdline_fixed_string_t flow_director_mask;
9037 cmdline_fixed_string_t mode;
9038 cmdline_fixed_string_t mode_value;
9039 cmdline_fixed_string_t vlan;
9041 cmdline_fixed_string_t src_mask;
9042 cmdline_ipaddr_t ipv4_src;
9043 cmdline_ipaddr_t ipv6_src;
9045 cmdline_fixed_string_t dst_mask;
9046 cmdline_ipaddr_t ipv4_dst;
9047 cmdline_ipaddr_t ipv6_dst;
9049 cmdline_fixed_string_t mac;
9050 uint8_t mac_addr_byte_mask;
9051 cmdline_fixed_string_t tunnel_id;
9052 uint32_t tunnel_id_mask;
9053 cmdline_fixed_string_t tunnel_type;
9054 uint8_t tunnel_type_mask;
9058 cmd_flow_director_mask_parsed(void *parsed_result,
9059 __attribute__((unused)) struct cmdline *cl,
9060 __attribute__((unused)) void *data)
9062 struct cmd_flow_director_mask_result *res = parsed_result;
9063 struct rte_eth_fdir_masks *mask;
9064 struct rte_port *port;
9066 if (res->port_id > nb_ports) {
9067 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9071 port = &ports[res->port_id];
9072 /** Check if the port is not started **/
9073 if (port->port_status != RTE_PORT_STOPPED) {
9074 printf("Please stop port %d first\n", res->port_id);
9078 mask = &port->dev_conf.fdir_conf.mask;
9080 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9081 if (strcmp(res->mode_value, "MAC-VLAN")) {
9082 printf("Please set mode to MAC-VLAN.\n");
9086 mask->vlan_tci_mask = res->vlan_mask;
9087 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9088 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9089 if (strcmp(res->mode_value, "Tunnel")) {
9090 printf("Please set mode to Tunnel.\n");
9094 mask->vlan_tci_mask = res->vlan_mask;
9095 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9096 mask->tunnel_id_mask = res->tunnel_id_mask;
9097 mask->tunnel_type_mask = res->tunnel_type_mask;
9099 if (strcmp(res->mode_value, "IP")) {
9100 printf("Please set mode to IP.\n");
9104 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9105 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9106 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9107 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9108 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9109 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9110 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9113 cmd_reconfig_device_queue(res->port_id, 1, 1);
9116 cmdline_parse_token_string_t cmd_flow_director_mask =
9117 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9118 flow_director_mask, "flow_director_mask");
9119 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9120 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9122 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9123 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9125 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9126 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9128 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9129 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9130 src_mask, "src_mask");
9131 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9132 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9134 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9135 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9137 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9138 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9140 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9142 dst_mask, "dst_mask");
9143 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9144 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9146 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9147 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9149 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9150 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9153 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9154 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9156 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9159 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9161 mode_value, "MAC-VLAN");
9162 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9163 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9164 mode_value, "Tunnel");
9165 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9166 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9168 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9169 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9170 mac_addr_byte_mask, UINT8);
9171 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9172 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9173 tunnel_type, "tunnel-type");
9174 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9175 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9176 tunnel_type_mask, UINT8);
9177 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9178 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9179 tunnel_id, "tunnel-id");
9180 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9181 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9182 tunnel_id_mask, UINT32);
9184 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9185 .f = cmd_flow_director_mask_parsed,
9187 .help_str = "set IP mode flow director's mask on NIC",
9189 (void *)&cmd_flow_director_mask,
9190 (void *)&cmd_flow_director_mask_port_id,
9191 (void *)&cmd_flow_director_mask_mode,
9192 (void *)&cmd_flow_director_mask_mode_ip,
9193 (void *)&cmd_flow_director_mask_vlan,
9194 (void *)&cmd_flow_director_mask_vlan_value,
9195 (void *)&cmd_flow_director_mask_src,
9196 (void *)&cmd_flow_director_mask_ipv4_src,
9197 (void *)&cmd_flow_director_mask_ipv6_src,
9198 (void *)&cmd_flow_director_mask_port_src,
9199 (void *)&cmd_flow_director_mask_dst,
9200 (void *)&cmd_flow_director_mask_ipv4_dst,
9201 (void *)&cmd_flow_director_mask_ipv6_dst,
9202 (void *)&cmd_flow_director_mask_port_dst,
9207 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9208 .f = cmd_flow_director_mask_parsed,
9210 .help_str = "set MAC VLAN mode flow director's mask on NIC",
9212 (void *)&cmd_flow_director_mask,
9213 (void *)&cmd_flow_director_mask_port_id,
9214 (void *)&cmd_flow_director_mask_mode,
9215 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9216 (void *)&cmd_flow_director_mask_vlan,
9217 (void *)&cmd_flow_director_mask_vlan_value,
9218 (void *)&cmd_flow_director_mask_mac,
9219 (void *)&cmd_flow_director_mask_mac_value,
9224 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9225 .f = cmd_flow_director_mask_parsed,
9227 .help_str = "set tunnel mode flow director's mask on NIC",
9229 (void *)&cmd_flow_director_mask,
9230 (void *)&cmd_flow_director_mask_port_id,
9231 (void *)&cmd_flow_director_mask_mode,
9232 (void *)&cmd_flow_director_mask_mode_tunnel,
9233 (void *)&cmd_flow_director_mask_vlan,
9234 (void *)&cmd_flow_director_mask_vlan_value,
9235 (void *)&cmd_flow_director_mask_mac,
9236 (void *)&cmd_flow_director_mask_mac_value,
9237 (void *)&cmd_flow_director_mask_tunnel_type,
9238 (void *)&cmd_flow_director_mask_tunnel_type_value,
9239 (void *)&cmd_flow_director_mask_tunnel_id,
9240 (void *)&cmd_flow_director_mask_tunnel_id_value,
9245 /* *** deal with flow director mask on flexible payload *** */
9246 struct cmd_flow_director_flex_mask_result {
9247 cmdline_fixed_string_t flow_director_flexmask;
9249 cmdline_fixed_string_t flow;
9250 cmdline_fixed_string_t flow_type;
9251 cmdline_fixed_string_t mask;
9255 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9256 __attribute__((unused)) struct cmdline *cl,
9257 __attribute__((unused)) void *data)
9259 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9260 struct rte_eth_fdir_info fdir_info;
9261 struct rte_eth_fdir_flex_mask flex_mask;
9262 struct rte_port *port;
9263 uint32_t flow_type_mask;
9267 if (res->port_id > nb_ports) {
9268 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9272 port = &ports[res->port_id];
9273 /** Check if the port is not started **/
9274 if (port->port_status != RTE_PORT_STOPPED) {
9275 printf("Please stop port %d first\n", res->port_id);
9279 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9280 ret = parse_flexbytes(res->mask,
9282 RTE_ETH_FDIR_MAX_FLEXLEN);
9284 printf("error: Cannot parse mask input.\n");
9288 memset(&fdir_info, 0, sizeof(fdir_info));
9289 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9290 RTE_ETH_FILTER_INFO, &fdir_info);
9292 printf("Cannot get FDir filter info\n");
9296 if (!strcmp(res->flow_type, "none")) {
9297 /* means don't specify the flow type */
9298 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9299 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9300 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9301 0, sizeof(struct rte_eth_fdir_flex_mask));
9302 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9303 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9305 sizeof(struct rte_eth_fdir_flex_mask));
9306 cmd_reconfig_device_queue(res->port_id, 1, 1);
9309 flow_type_mask = fdir_info.flow_types_mask[0];
9310 if (!strcmp(res->flow_type, "all")) {
9311 if (!flow_type_mask) {
9312 printf("No flow type supported\n");
9315 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9316 if (flow_type_mask & (1 << i)) {
9317 flex_mask.flow_type = i;
9318 fdir_set_flex_mask(res->port_id, &flex_mask);
9321 cmd_reconfig_device_queue(res->port_id, 1, 1);
9324 flex_mask.flow_type = str2flowtype(res->flow_type);
9325 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9326 printf("Flow type %s not supported on port %d\n",
9327 res->flow_type, res->port_id);
9330 fdir_set_flex_mask(res->port_id, &flex_mask);
9331 cmd_reconfig_device_queue(res->port_id, 1, 1);
9334 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9336 flow_director_flexmask,
9337 "flow_director_flex_mask");
9338 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9339 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9341 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9344 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9346 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9347 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9348 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9352 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9353 .f = cmd_flow_director_flex_mask_parsed,
9355 .help_str = "set flow director's flex mask on NIC",
9357 (void *)&cmd_flow_director_flexmask,
9358 (void *)&cmd_flow_director_flexmask_port_id,
9359 (void *)&cmd_flow_director_flexmask_flow,
9360 (void *)&cmd_flow_director_flexmask_flow_type,
9361 (void *)&cmd_flow_director_flexmask_mask,
9366 /* *** deal with flow director flexible payload configuration *** */
9367 struct cmd_flow_director_flexpayload_result {
9368 cmdline_fixed_string_t flow_director_flexpayload;
9370 cmdline_fixed_string_t payload_layer;
9371 cmdline_fixed_string_t payload_cfg;
9375 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9378 const char *p, *p0 = q_arg;
9380 unsigned long int_fld;
9381 char *str_fld[max_num];
9386 p = strchr(p0, '(');
9390 p0 = strchr(p, ')');
9395 if (size >= sizeof(s))
9398 snprintf(s, sizeof(s), "%.*s", size, p);
9399 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9400 if (ret < 0 || ret > max_num)
9402 for (i = 0; i < ret; i++) {
9404 int_fld = strtoul(str_fld[i], &end, 0);
9405 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9407 offsets[i] = (uint16_t)int_fld;
9413 cmd_flow_director_flxpld_parsed(void *parsed_result,
9414 __attribute__((unused)) struct cmdline *cl,
9415 __attribute__((unused)) void *data)
9417 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9418 struct rte_eth_flex_payload_cfg flex_cfg;
9419 struct rte_port *port;
9422 if (res->port_id > nb_ports) {
9423 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9427 port = &ports[res->port_id];
9428 /** Check if the port is not started **/
9429 if (port->port_status != RTE_PORT_STOPPED) {
9430 printf("Please stop port %d first\n", res->port_id);
9434 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9436 if (!strcmp(res->payload_layer, "raw"))
9437 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9438 else if (!strcmp(res->payload_layer, "l2"))
9439 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9440 else if (!strcmp(res->payload_layer, "l3"))
9441 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9442 else if (!strcmp(res->payload_layer, "l4"))
9443 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9445 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9446 RTE_ETH_FDIR_MAX_FLEXLEN);
9448 printf("error: Cannot parse flex payload input.\n");
9452 fdir_set_flex_payload(res->port_id, &flex_cfg);
9453 cmd_reconfig_device_queue(res->port_id, 1, 1);
9456 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9458 flow_director_flexpayload,
9459 "flow_director_flex_payload");
9460 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9461 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9463 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9464 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9465 payload_layer, "raw#l2#l3#l4");
9466 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9470 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9471 .f = cmd_flow_director_flxpld_parsed,
9473 .help_str = "set flow director's flex payload on NIC",
9475 (void *)&cmd_flow_director_flexpayload,
9476 (void *)&cmd_flow_director_flexpayload_port_id,
9477 (void *)&cmd_flow_director_flexpayload_payload_layer,
9478 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9483 /* *** Classification Filters Control *** */
9484 /* *** Get symmetric hash enable per port *** */
9485 struct cmd_get_sym_hash_ena_per_port_result {
9486 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9491 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9492 __rte_unused struct cmdline *cl,
9493 __rte_unused void *data)
9495 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9496 struct rte_eth_hash_filter_info info;
9499 if (rte_eth_dev_filter_supported(res->port_id,
9500 RTE_ETH_FILTER_HASH) < 0) {
9501 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9506 memset(&info, 0, sizeof(info));
9507 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9508 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9509 RTE_ETH_FILTER_GET, &info);
9512 printf("Cannot get symmetric hash enable per port "
9513 "on port %u\n", res->port_id);
9517 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9518 "enabled" : "disabled", res->port_id);
9521 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9522 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9523 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9524 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9525 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9528 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9529 .f = cmd_get_sym_hash_per_port_parsed,
9531 .help_str = "get_sym_hash_ena_per_port port_id",
9533 (void *)&cmd_get_sym_hash_ena_per_port_all,
9534 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9539 /* *** Set symmetric hash enable per port *** */
9540 struct cmd_set_sym_hash_ena_per_port_result {
9541 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9542 cmdline_fixed_string_t enable;
9547 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9548 __rte_unused struct cmdline *cl,
9549 __rte_unused void *data)
9551 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9552 struct rte_eth_hash_filter_info info;
9555 if (rte_eth_dev_filter_supported(res->port_id,
9556 RTE_ETH_FILTER_HASH) < 0) {
9557 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9562 memset(&info, 0, sizeof(info));
9563 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9564 if (!strcmp(res->enable, "enable"))
9565 info.info.enable = 1;
9566 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9567 RTE_ETH_FILTER_SET, &info);
9569 printf("Cannot set symmetric hash enable per port on "
9570 "port %u\n", res->port_id);
9573 printf("Symmetric hash has been set to %s on port %u\n",
9574 res->enable, res->port_id);
9577 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9578 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9579 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9580 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9581 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9583 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9584 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9585 enable, "enable#disable");
9587 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9588 .f = cmd_set_sym_hash_per_port_parsed,
9590 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9592 (void *)&cmd_set_sym_hash_ena_per_port_all,
9593 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9594 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9599 /* Get global config of hash function */
9600 struct cmd_get_hash_global_config_result {
9601 cmdline_fixed_string_t get_hash_global_config;
9606 flowtype_to_str(uint16_t ftype)
9613 {"ipv4", RTE_ETH_FLOW_IPV4},
9614 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9615 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9616 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9617 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9618 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9619 {"ipv6", RTE_ETH_FLOW_IPV6},
9620 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9621 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9622 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9623 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9624 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9625 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9626 {"port", RTE_ETH_FLOW_PORT},
9627 {"vxlan", RTE_ETH_FLOW_VXLAN},
9628 {"geneve", RTE_ETH_FLOW_GENEVE},
9629 {"nvgre", RTE_ETH_FLOW_NVGRE},
9632 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9633 if (ftype_table[i].ftype == ftype)
9634 return ftype_table[i].str;
9641 cmd_get_hash_global_config_parsed(void *parsed_result,
9642 __rte_unused struct cmdline *cl,
9643 __rte_unused void *data)
9645 struct cmd_get_hash_global_config_result *res = parsed_result;
9646 struct rte_eth_hash_filter_info info;
9647 uint32_t idx, offset;
9652 if (rte_eth_dev_filter_supported(res->port_id,
9653 RTE_ETH_FILTER_HASH) < 0) {
9654 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9659 memset(&info, 0, sizeof(info));
9660 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9661 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9662 RTE_ETH_FILTER_GET, &info);
9664 printf("Cannot get hash global configurations by port %d\n",
9669 switch (info.info.global_conf.hash_func) {
9670 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9671 printf("Hash function is Toeplitz\n");
9673 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9674 printf("Hash function is Simple XOR\n");
9677 printf("Unknown hash function\n");
9681 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9682 idx = i / UINT32_BIT;
9683 offset = i % UINT32_BIT;
9684 if (!(info.info.global_conf.valid_bit_mask[idx] &
9687 str = flowtype_to_str(i);
9690 printf("Symmetric hash is %s globally for flow type %s "
9692 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9693 (1UL << offset)) ? "enabled" : "disabled"), str,
9698 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9699 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9700 get_hash_global_config, "get_hash_global_config");
9701 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9702 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9705 cmdline_parse_inst_t cmd_get_hash_global_config = {
9706 .f = cmd_get_hash_global_config_parsed,
9708 .help_str = "get_hash_global_config port_id",
9710 (void *)&cmd_get_hash_global_config_all,
9711 (void *)&cmd_get_hash_global_config_port_id,
9716 /* Set global config of hash function */
9717 struct cmd_set_hash_global_config_result {
9718 cmdline_fixed_string_t set_hash_global_config;
9720 cmdline_fixed_string_t hash_func;
9721 cmdline_fixed_string_t flow_type;
9722 cmdline_fixed_string_t enable;
9726 cmd_set_hash_global_config_parsed(void *parsed_result,
9727 __rte_unused struct cmdline *cl,
9728 __rte_unused void *data)
9730 struct cmd_set_hash_global_config_result *res = parsed_result;
9731 struct rte_eth_hash_filter_info info;
9732 uint32_t ftype, idx, offset;
9735 if (rte_eth_dev_filter_supported(res->port_id,
9736 RTE_ETH_FILTER_HASH) < 0) {
9737 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9741 memset(&info, 0, sizeof(info));
9742 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9743 if (!strcmp(res->hash_func, "toeplitz"))
9744 info.info.global_conf.hash_func =
9745 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9746 else if (!strcmp(res->hash_func, "simple_xor"))
9747 info.info.global_conf.hash_func =
9748 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9749 else if (!strcmp(res->hash_func, "default"))
9750 info.info.global_conf.hash_func =
9751 RTE_ETH_HASH_FUNCTION_DEFAULT;
9753 ftype = str2flowtype(res->flow_type);
9754 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9755 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9756 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9757 if (!strcmp(res->enable, "enable"))
9758 info.info.global_conf.sym_hash_enable_mask[idx] |=
9760 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9761 RTE_ETH_FILTER_SET, &info);
9763 printf("Cannot set global hash configurations by port %d\n",
9766 printf("Global hash configurations have been set "
9767 "succcessfully by port %d\n", res->port_id);
9770 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9771 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9772 set_hash_global_config, "set_hash_global_config");
9773 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9774 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9776 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9777 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9778 hash_func, "toeplitz#simple_xor#default");
9779 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9780 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9782 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9783 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9784 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9785 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9786 enable, "enable#disable");
9788 cmdline_parse_inst_t cmd_set_hash_global_config = {
9789 .f = cmd_set_hash_global_config_parsed,
9791 .help_str = "set_hash_global_config port_id "
9792 "toeplitz|simple_xor|default "
9793 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9794 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9797 (void *)&cmd_set_hash_global_config_all,
9798 (void *)&cmd_set_hash_global_config_port_id,
9799 (void *)&cmd_set_hash_global_config_hash_func,
9800 (void *)&cmd_set_hash_global_config_flow_type,
9801 (void *)&cmd_set_hash_global_config_enable,
9806 /* Set hash input set */
9807 struct cmd_set_hash_input_set_result {
9808 cmdline_fixed_string_t set_hash_input_set;
9810 cmdline_fixed_string_t flow_type;
9811 cmdline_fixed_string_t inset_field;
9812 cmdline_fixed_string_t select;
9815 static enum rte_eth_input_set_field
9816 str2inset(char *string)
9820 static const struct {
9822 enum rte_eth_input_set_field inset;
9824 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9825 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9826 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9827 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9828 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9829 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9830 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9831 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9832 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9833 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9834 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9835 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9836 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9837 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9838 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9839 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9840 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9841 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9842 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9843 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9844 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9845 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9846 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9847 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9848 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9849 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9850 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9851 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9852 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9853 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9854 {"none", RTE_ETH_INPUT_SET_NONE},
9857 for (i = 0; i < RTE_DIM(inset_table); i++) {
9858 if (!strcmp(string, inset_table[i].str))
9859 return inset_table[i].inset;
9862 return RTE_ETH_INPUT_SET_UNKNOWN;
9866 cmd_set_hash_input_set_parsed(void *parsed_result,
9867 __rte_unused struct cmdline *cl,
9868 __rte_unused void *data)
9870 struct cmd_set_hash_input_set_result *res = parsed_result;
9871 struct rte_eth_hash_filter_info info;
9873 memset(&info, 0, sizeof(info));
9874 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9875 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9876 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9877 info.info.input_set_conf.inset_size = 1;
9878 if (!strcmp(res->select, "select"))
9879 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9880 else if (!strcmp(res->select, "add"))
9881 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9882 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9883 RTE_ETH_FILTER_SET, &info);
9886 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9887 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9888 set_hash_input_set, "set_hash_input_set");
9889 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9890 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9892 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9893 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9895 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9896 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9897 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9898 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9900 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9901 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9902 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9903 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9904 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9906 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9907 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9908 select, "select#add");
9910 cmdline_parse_inst_t cmd_set_hash_input_set = {
9911 .f = cmd_set_hash_input_set_parsed,
9913 .help_str = "set_hash_input_set <port_id> "
9914 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9915 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9916 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9917 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9918 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9919 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9920 "fld-7th|fld-8th|none select|add",
9922 (void *)&cmd_set_hash_input_set_cmd,
9923 (void *)&cmd_set_hash_input_set_port_id,
9924 (void *)&cmd_set_hash_input_set_flow_type,
9925 (void *)&cmd_set_hash_input_set_field,
9926 (void *)&cmd_set_hash_input_set_select,
9931 /* Set flow director input set */
9932 struct cmd_set_fdir_input_set_result {
9933 cmdline_fixed_string_t set_fdir_input_set;
9935 cmdline_fixed_string_t flow_type;
9936 cmdline_fixed_string_t inset_field;
9937 cmdline_fixed_string_t select;
9941 cmd_set_fdir_input_set_parsed(void *parsed_result,
9942 __rte_unused struct cmdline *cl,
9943 __rte_unused void *data)
9945 struct cmd_set_fdir_input_set_result *res = parsed_result;
9946 struct rte_eth_fdir_filter_info info;
9948 memset(&info, 0, sizeof(info));
9949 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9950 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9951 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9952 info.info.input_set_conf.inset_size = 1;
9953 if (!strcmp(res->select, "select"))
9954 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9955 else if (!strcmp(res->select, "add"))
9956 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9957 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9958 RTE_ETH_FILTER_SET, &info);
9961 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9962 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9963 set_fdir_input_set, "set_fdir_input_set");
9964 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9965 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9967 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9968 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9970 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9971 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9972 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9973 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9975 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9976 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9977 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9978 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9979 "sctp-veri-tag#none");
9980 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9981 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9982 select, "select#add");
9984 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9985 .f = cmd_set_fdir_input_set_parsed,
9987 .help_str = "set_fdir_input_set <port_id> "
9988 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9989 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9990 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
9991 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
9992 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
9993 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
9994 "sctp-veri-tag|none select|add",
9996 (void *)&cmd_set_fdir_input_set_cmd,
9997 (void *)&cmd_set_fdir_input_set_port_id,
9998 (void *)&cmd_set_fdir_input_set_flow_type,
9999 (void *)&cmd_set_fdir_input_set_field,
10000 (void *)&cmd_set_fdir_input_set_select,
10005 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10006 struct cmd_mcast_addr_result {
10007 cmdline_fixed_string_t mcast_addr_cmd;
10008 cmdline_fixed_string_t what;
10010 struct ether_addr mc_addr;
10013 static void cmd_mcast_addr_parsed(void *parsed_result,
10014 __attribute__((unused)) struct cmdline *cl,
10015 __attribute__((unused)) void *data)
10017 struct cmd_mcast_addr_result *res = parsed_result;
10019 if (!is_multicast_ether_addr(&res->mc_addr)) {
10020 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10021 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10022 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10023 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10026 if (strcmp(res->what, "add") == 0)
10027 mcast_addr_add(res->port_num, &res->mc_addr);
10029 mcast_addr_remove(res->port_num, &res->mc_addr);
10032 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10033 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10034 mcast_addr_cmd, "mcast_addr");
10035 cmdline_parse_token_string_t cmd_mcast_addr_what =
10036 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10038 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10039 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10040 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10041 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10043 cmdline_parse_inst_t cmd_mcast_addr = {
10044 .f = cmd_mcast_addr_parsed,
10046 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
10048 (void *)&cmd_mcast_addr_cmd,
10049 (void *)&cmd_mcast_addr_what,
10050 (void *)&cmd_mcast_addr_portnum,
10051 (void *)&cmd_mcast_addr_addr,
10056 /* l2 tunnel config
10057 * only support E-tag now.
10060 /* Ether type config */
10061 struct cmd_config_l2_tunnel_eth_type_result {
10062 cmdline_fixed_string_t port;
10063 cmdline_fixed_string_t config;
10064 cmdline_fixed_string_t all;
10066 cmdline_fixed_string_t l2_tunnel;
10067 cmdline_fixed_string_t l2_tunnel_type;
10068 cmdline_fixed_string_t eth_type;
10069 uint16_t eth_type_val;
10072 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10073 TOKEN_STRING_INITIALIZER
10074 (struct cmd_config_l2_tunnel_eth_type_result,
10076 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10077 TOKEN_STRING_INITIALIZER
10078 (struct cmd_config_l2_tunnel_eth_type_result,
10080 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10081 TOKEN_STRING_INITIALIZER
10082 (struct cmd_config_l2_tunnel_eth_type_result,
10084 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10085 TOKEN_NUM_INITIALIZER
10086 (struct cmd_config_l2_tunnel_eth_type_result,
10088 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10089 TOKEN_STRING_INITIALIZER
10090 (struct cmd_config_l2_tunnel_eth_type_result,
10091 l2_tunnel, "l2-tunnel");
10092 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10093 TOKEN_STRING_INITIALIZER
10094 (struct cmd_config_l2_tunnel_eth_type_result,
10095 l2_tunnel_type, "E-tag");
10096 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10097 TOKEN_STRING_INITIALIZER
10098 (struct cmd_config_l2_tunnel_eth_type_result,
10099 eth_type, "ether-type");
10100 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10101 TOKEN_NUM_INITIALIZER
10102 (struct cmd_config_l2_tunnel_eth_type_result,
10103 eth_type_val, UINT16);
10105 static enum rte_eth_tunnel_type
10106 str2fdir_l2_tunnel_type(char *string)
10110 static const struct {
10112 enum rte_eth_tunnel_type type;
10113 } l2_tunnel_type_str[] = {
10114 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10117 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10118 if (!strcmp(l2_tunnel_type_str[i].str, string))
10119 return l2_tunnel_type_str[i].type;
10121 return RTE_TUNNEL_TYPE_NONE;
10124 /* ether type config for all ports */
10126 cmd_config_l2_tunnel_eth_type_all_parsed
10127 (void *parsed_result,
10128 __attribute__((unused)) struct cmdline *cl,
10129 __attribute__((unused)) void *data)
10131 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10132 struct rte_eth_l2_tunnel_conf entry;
10135 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10136 entry.ether_type = res->eth_type_val;
10138 FOREACH_PORT(pid, ports) {
10139 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10143 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10144 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10146 .help_str = "port config all l2-tunnel ether-type",
10148 (void *)&cmd_config_l2_tunnel_eth_type_port,
10149 (void *)&cmd_config_l2_tunnel_eth_type_config,
10150 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10151 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10152 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10153 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10154 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10159 /* ether type config for a specific port */
10161 cmd_config_l2_tunnel_eth_type_specific_parsed(
10162 void *parsed_result,
10163 __attribute__((unused)) struct cmdline *cl,
10164 __attribute__((unused)) void *data)
10166 struct cmd_config_l2_tunnel_eth_type_result *res =
10168 struct rte_eth_l2_tunnel_conf entry;
10170 if (port_id_is_invalid(res->id, ENABLED_WARN))
10173 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10174 entry.ether_type = res->eth_type_val;
10176 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10179 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10180 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10182 .help_str = "port config l2-tunnel ether-type",
10184 (void *)&cmd_config_l2_tunnel_eth_type_port,
10185 (void *)&cmd_config_l2_tunnel_eth_type_config,
10186 (void *)&cmd_config_l2_tunnel_eth_type_id,
10187 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10188 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10189 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10190 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10195 /* Enable/disable l2 tunnel */
10196 struct cmd_config_l2_tunnel_en_dis_result {
10197 cmdline_fixed_string_t port;
10198 cmdline_fixed_string_t config;
10199 cmdline_fixed_string_t all;
10201 cmdline_fixed_string_t l2_tunnel;
10202 cmdline_fixed_string_t l2_tunnel_type;
10203 cmdline_fixed_string_t en_dis;
10206 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10207 TOKEN_STRING_INITIALIZER
10208 (struct cmd_config_l2_tunnel_en_dis_result,
10210 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10211 TOKEN_STRING_INITIALIZER
10212 (struct cmd_config_l2_tunnel_en_dis_result,
10214 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10215 TOKEN_STRING_INITIALIZER
10216 (struct cmd_config_l2_tunnel_en_dis_result,
10218 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10219 TOKEN_NUM_INITIALIZER
10220 (struct cmd_config_l2_tunnel_en_dis_result,
10222 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10223 TOKEN_STRING_INITIALIZER
10224 (struct cmd_config_l2_tunnel_en_dis_result,
10225 l2_tunnel, "l2-tunnel");
10226 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10227 TOKEN_STRING_INITIALIZER
10228 (struct cmd_config_l2_tunnel_en_dis_result,
10229 l2_tunnel_type, "E-tag");
10230 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10231 TOKEN_STRING_INITIALIZER
10232 (struct cmd_config_l2_tunnel_en_dis_result,
10233 en_dis, "enable#disable");
10235 /* enable/disable l2 tunnel for all ports */
10237 cmd_config_l2_tunnel_en_dis_all_parsed(
10238 void *parsed_result,
10239 __attribute__((unused)) struct cmdline *cl,
10240 __attribute__((unused)) void *data)
10242 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10243 struct rte_eth_l2_tunnel_conf entry;
10247 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10249 if (!strcmp("enable", res->en_dis))
10254 FOREACH_PORT(pid, ports) {
10255 rte_eth_dev_l2_tunnel_offload_set(pid,
10257 ETH_L2_TUNNEL_ENABLE_MASK,
10262 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10263 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10265 .help_str = "port config all l2-tunnel enable/disable",
10267 (void *)&cmd_config_l2_tunnel_en_dis_port,
10268 (void *)&cmd_config_l2_tunnel_en_dis_config,
10269 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10270 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10271 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10272 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10277 /* enable/disable l2 tunnel for a port */
10279 cmd_config_l2_tunnel_en_dis_specific_parsed(
10280 void *parsed_result,
10281 __attribute__((unused)) struct cmdline *cl,
10282 __attribute__((unused)) void *data)
10284 struct cmd_config_l2_tunnel_en_dis_result *res =
10286 struct rte_eth_l2_tunnel_conf entry;
10288 if (port_id_is_invalid(res->id, ENABLED_WARN))
10291 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10293 if (!strcmp("enable", res->en_dis))
10294 rte_eth_dev_l2_tunnel_offload_set(res->id,
10296 ETH_L2_TUNNEL_ENABLE_MASK,
10299 rte_eth_dev_l2_tunnel_offload_set(res->id,
10301 ETH_L2_TUNNEL_ENABLE_MASK,
10305 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10306 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10308 .help_str = "port config l2-tunnel enable/disable",
10310 (void *)&cmd_config_l2_tunnel_en_dis_port,
10311 (void *)&cmd_config_l2_tunnel_en_dis_config,
10312 (void *)&cmd_config_l2_tunnel_en_dis_id,
10313 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10314 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10315 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10320 /* E-tag configuration */
10322 /* Common result structure for all E-tag configuration */
10323 struct cmd_config_e_tag_result {
10324 cmdline_fixed_string_t e_tag;
10325 cmdline_fixed_string_t set;
10326 cmdline_fixed_string_t insertion;
10327 cmdline_fixed_string_t stripping;
10328 cmdline_fixed_string_t forwarding;
10329 cmdline_fixed_string_t filter;
10330 cmdline_fixed_string_t add;
10331 cmdline_fixed_string_t del;
10332 cmdline_fixed_string_t on;
10333 cmdline_fixed_string_t off;
10334 cmdline_fixed_string_t on_off;
10335 cmdline_fixed_string_t port_tag_id;
10336 uint32_t port_tag_id_val;
10337 cmdline_fixed_string_t e_tag_id;
10338 uint16_t e_tag_id_val;
10339 cmdline_fixed_string_t dst_pool;
10340 uint8_t dst_pool_val;
10341 cmdline_fixed_string_t port;
10343 cmdline_fixed_string_t vf;
10347 /* Common CLI fields for all E-tag configuration */
10348 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10349 TOKEN_STRING_INITIALIZER
10350 (struct cmd_config_e_tag_result,
10352 cmdline_parse_token_string_t cmd_config_e_tag_set =
10353 TOKEN_STRING_INITIALIZER
10354 (struct cmd_config_e_tag_result,
10356 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10357 TOKEN_STRING_INITIALIZER
10358 (struct cmd_config_e_tag_result,
10359 insertion, "insertion");
10360 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10361 TOKEN_STRING_INITIALIZER
10362 (struct cmd_config_e_tag_result,
10363 stripping, "stripping");
10364 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10365 TOKEN_STRING_INITIALIZER
10366 (struct cmd_config_e_tag_result,
10367 forwarding, "forwarding");
10368 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10369 TOKEN_STRING_INITIALIZER
10370 (struct cmd_config_e_tag_result,
10372 cmdline_parse_token_string_t cmd_config_e_tag_add =
10373 TOKEN_STRING_INITIALIZER
10374 (struct cmd_config_e_tag_result,
10376 cmdline_parse_token_string_t cmd_config_e_tag_del =
10377 TOKEN_STRING_INITIALIZER
10378 (struct cmd_config_e_tag_result,
10380 cmdline_parse_token_string_t cmd_config_e_tag_on =
10381 TOKEN_STRING_INITIALIZER
10382 (struct cmd_config_e_tag_result,
10384 cmdline_parse_token_string_t cmd_config_e_tag_off =
10385 TOKEN_STRING_INITIALIZER
10386 (struct cmd_config_e_tag_result,
10388 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10389 TOKEN_STRING_INITIALIZER
10390 (struct cmd_config_e_tag_result,
10392 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10393 TOKEN_STRING_INITIALIZER
10394 (struct cmd_config_e_tag_result,
10395 port_tag_id, "port-tag-id");
10396 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10397 TOKEN_NUM_INITIALIZER
10398 (struct cmd_config_e_tag_result,
10399 port_tag_id_val, UINT32);
10400 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10401 TOKEN_STRING_INITIALIZER
10402 (struct cmd_config_e_tag_result,
10403 e_tag_id, "e-tag-id");
10404 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10405 TOKEN_NUM_INITIALIZER
10406 (struct cmd_config_e_tag_result,
10407 e_tag_id_val, UINT16);
10408 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10409 TOKEN_STRING_INITIALIZER
10410 (struct cmd_config_e_tag_result,
10411 dst_pool, "dst-pool");
10412 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10413 TOKEN_NUM_INITIALIZER
10414 (struct cmd_config_e_tag_result,
10415 dst_pool_val, UINT8);
10416 cmdline_parse_token_string_t cmd_config_e_tag_port =
10417 TOKEN_STRING_INITIALIZER
10418 (struct cmd_config_e_tag_result,
10420 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10421 TOKEN_NUM_INITIALIZER
10422 (struct cmd_config_e_tag_result,
10424 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10425 TOKEN_STRING_INITIALIZER
10426 (struct cmd_config_e_tag_result,
10428 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10429 TOKEN_NUM_INITIALIZER
10430 (struct cmd_config_e_tag_result,
10433 /* E-tag insertion configuration */
10435 cmd_config_e_tag_insertion_en_parsed(
10436 void *parsed_result,
10437 __attribute__((unused)) struct cmdline *cl,
10438 __attribute__((unused)) void *data)
10440 struct cmd_config_e_tag_result *res =
10442 struct rte_eth_l2_tunnel_conf entry;
10444 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10447 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10448 entry.tunnel_id = res->port_tag_id_val;
10449 entry.vf_id = res->vf_id;
10450 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10452 ETH_L2_TUNNEL_INSERTION_MASK,
10457 cmd_config_e_tag_insertion_dis_parsed(
10458 void *parsed_result,
10459 __attribute__((unused)) struct cmdline *cl,
10460 __attribute__((unused)) void *data)
10462 struct cmd_config_e_tag_result *res =
10464 struct rte_eth_l2_tunnel_conf entry;
10466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10469 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10470 entry.vf_id = res->vf_id;
10472 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10474 ETH_L2_TUNNEL_INSERTION_MASK,
10478 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10479 .f = cmd_config_e_tag_insertion_en_parsed,
10481 .help_str = "E-tag insertion enable",
10483 (void *)&cmd_config_e_tag_e_tag,
10484 (void *)&cmd_config_e_tag_set,
10485 (void *)&cmd_config_e_tag_insertion,
10486 (void *)&cmd_config_e_tag_on,
10487 (void *)&cmd_config_e_tag_port_tag_id,
10488 (void *)&cmd_config_e_tag_port_tag_id_val,
10489 (void *)&cmd_config_e_tag_port,
10490 (void *)&cmd_config_e_tag_port_id,
10491 (void *)&cmd_config_e_tag_vf,
10492 (void *)&cmd_config_e_tag_vf_id,
10497 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10498 .f = cmd_config_e_tag_insertion_dis_parsed,
10500 .help_str = "E-tag insertion disable",
10502 (void *)&cmd_config_e_tag_e_tag,
10503 (void *)&cmd_config_e_tag_set,
10504 (void *)&cmd_config_e_tag_insertion,
10505 (void *)&cmd_config_e_tag_off,
10506 (void *)&cmd_config_e_tag_port,
10507 (void *)&cmd_config_e_tag_port_id,
10508 (void *)&cmd_config_e_tag_vf,
10509 (void *)&cmd_config_e_tag_vf_id,
10514 /* E-tag stripping configuration */
10516 cmd_config_e_tag_stripping_parsed(
10517 void *parsed_result,
10518 __attribute__((unused)) struct cmdline *cl,
10519 __attribute__((unused)) void *data)
10521 struct cmd_config_e_tag_result *res =
10523 struct rte_eth_l2_tunnel_conf entry;
10525 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10528 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10530 if (!strcmp(res->on_off, "on"))
10531 rte_eth_dev_l2_tunnel_offload_set
10534 ETH_L2_TUNNEL_STRIPPING_MASK,
10537 rte_eth_dev_l2_tunnel_offload_set
10540 ETH_L2_TUNNEL_STRIPPING_MASK,
10544 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10545 .f = cmd_config_e_tag_stripping_parsed,
10547 .help_str = "E-tag stripping enable/disable",
10549 (void *)&cmd_config_e_tag_e_tag,
10550 (void *)&cmd_config_e_tag_set,
10551 (void *)&cmd_config_e_tag_stripping,
10552 (void *)&cmd_config_e_tag_on_off,
10553 (void *)&cmd_config_e_tag_port,
10554 (void *)&cmd_config_e_tag_port_id,
10559 /* E-tag forwarding configuration */
10561 cmd_config_e_tag_forwarding_parsed(
10562 void *parsed_result,
10563 __attribute__((unused)) struct cmdline *cl,
10564 __attribute__((unused)) void *data)
10566 struct cmd_config_e_tag_result *res = parsed_result;
10567 struct rte_eth_l2_tunnel_conf entry;
10569 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10572 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10574 if (!strcmp(res->on_off, "on"))
10575 rte_eth_dev_l2_tunnel_offload_set
10578 ETH_L2_TUNNEL_FORWARDING_MASK,
10581 rte_eth_dev_l2_tunnel_offload_set
10584 ETH_L2_TUNNEL_FORWARDING_MASK,
10588 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10589 .f = cmd_config_e_tag_forwarding_parsed,
10591 .help_str = "E-tag forwarding enable/disable",
10593 (void *)&cmd_config_e_tag_e_tag,
10594 (void *)&cmd_config_e_tag_set,
10595 (void *)&cmd_config_e_tag_forwarding,
10596 (void *)&cmd_config_e_tag_on_off,
10597 (void *)&cmd_config_e_tag_port,
10598 (void *)&cmd_config_e_tag_port_id,
10603 /* E-tag filter configuration */
10605 cmd_config_e_tag_filter_add_parsed(
10606 void *parsed_result,
10607 __attribute__((unused)) struct cmdline *cl,
10608 __attribute__((unused)) void *data)
10610 struct cmd_config_e_tag_result *res = parsed_result;
10611 struct rte_eth_l2_tunnel_conf entry;
10614 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10617 if (res->e_tag_id_val > 0x3fff) {
10618 printf("e-tag-id must be equal or less than 0x3fff.\n");
10622 ret = rte_eth_dev_filter_supported(res->port_id,
10623 RTE_ETH_FILTER_L2_TUNNEL);
10625 printf("E-tag filter is not supported on port %u.\n",
10630 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10631 entry.tunnel_id = res->e_tag_id_val;
10632 entry.pool = res->dst_pool_val;
10634 ret = rte_eth_dev_filter_ctrl(res->port_id,
10635 RTE_ETH_FILTER_L2_TUNNEL,
10636 RTE_ETH_FILTER_ADD,
10639 printf("E-tag filter programming error: (%s)\n",
10643 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10644 .f = cmd_config_e_tag_filter_add_parsed,
10646 .help_str = "E-tag filter add",
10648 (void *)&cmd_config_e_tag_e_tag,
10649 (void *)&cmd_config_e_tag_set,
10650 (void *)&cmd_config_e_tag_filter,
10651 (void *)&cmd_config_e_tag_add,
10652 (void *)&cmd_config_e_tag_e_tag_id,
10653 (void *)&cmd_config_e_tag_e_tag_id_val,
10654 (void *)&cmd_config_e_tag_dst_pool,
10655 (void *)&cmd_config_e_tag_dst_pool_val,
10656 (void *)&cmd_config_e_tag_port,
10657 (void *)&cmd_config_e_tag_port_id,
10663 cmd_config_e_tag_filter_del_parsed(
10664 void *parsed_result,
10665 __attribute__((unused)) struct cmdline *cl,
10666 __attribute__((unused)) void *data)
10668 struct cmd_config_e_tag_result *res = parsed_result;
10669 struct rte_eth_l2_tunnel_conf entry;
10672 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10675 if (res->e_tag_id_val > 0x3fff) {
10676 printf("e-tag-id must be less than 0x3fff.\n");
10680 ret = rte_eth_dev_filter_supported(res->port_id,
10681 RTE_ETH_FILTER_L2_TUNNEL);
10683 printf("E-tag filter is not supported on port %u.\n",
10688 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10689 entry.tunnel_id = res->e_tag_id_val;
10691 ret = rte_eth_dev_filter_ctrl(res->port_id,
10692 RTE_ETH_FILTER_L2_TUNNEL,
10693 RTE_ETH_FILTER_DELETE,
10696 printf("E-tag filter programming error: (%s)\n",
10700 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10701 .f = cmd_config_e_tag_filter_del_parsed,
10703 .help_str = "E-tag filter delete",
10705 (void *)&cmd_config_e_tag_e_tag,
10706 (void *)&cmd_config_e_tag_set,
10707 (void *)&cmd_config_e_tag_filter,
10708 (void *)&cmd_config_e_tag_del,
10709 (void *)&cmd_config_e_tag_e_tag_id,
10710 (void *)&cmd_config_e_tag_e_tag_id_val,
10711 (void *)&cmd_config_e_tag_port,
10712 (void *)&cmd_config_e_tag_port_id,
10717 /* ******************************************************************************** */
10719 /* list of instructions */
10720 cmdline_parse_ctx_t main_ctx[] = {
10721 (cmdline_parse_inst_t *)&cmd_help_brief,
10722 (cmdline_parse_inst_t *)&cmd_help_long,
10723 (cmdline_parse_inst_t *)&cmd_quit,
10724 (cmdline_parse_inst_t *)&cmd_showport,
10725 (cmdline_parse_inst_t *)&cmd_showqueue,
10726 (cmdline_parse_inst_t *)&cmd_showportall,
10727 (cmdline_parse_inst_t *)&cmd_showcfg,
10728 (cmdline_parse_inst_t *)&cmd_start,
10729 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10730 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
10731 (cmdline_parse_inst_t *)&cmd_set_link_up,
10732 (cmdline_parse_inst_t *)&cmd_set_link_down,
10733 (cmdline_parse_inst_t *)&cmd_reset,
10734 (cmdline_parse_inst_t *)&cmd_set_numbers,
10735 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10736 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10737 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10738 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10739 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10740 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
10741 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10742 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10743 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10744 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10745 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10746 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10747 (cmdline_parse_inst_t *)&cmd_set_link_check,
10748 #ifdef RTE_NIC_BYPASS
10749 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10750 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10751 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10752 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10754 #ifdef RTE_LIBRTE_PMD_BOND
10755 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10756 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10757 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10758 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10759 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10760 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10761 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10762 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10763 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10765 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10766 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10767 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10768 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10769 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10770 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10771 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10772 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10773 (cmdline_parse_inst_t *)&cmd_csum_set,
10774 (cmdline_parse_inst_t *)&cmd_csum_show,
10775 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10776 (cmdline_parse_inst_t *)&cmd_tso_set,
10777 (cmdline_parse_inst_t *)&cmd_tso_show,
10778 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
10779 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
10780 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10781 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10782 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10783 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10784 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10785 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10786 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10787 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10788 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10789 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10790 (cmdline_parse_inst_t *)&cmd_config_dcb,
10791 (cmdline_parse_inst_t *)&cmd_read_reg,
10792 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10793 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10794 (cmdline_parse_inst_t *)&cmd_write_reg,
10795 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10796 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10797 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10798 (cmdline_parse_inst_t *)&cmd_stop,
10799 (cmdline_parse_inst_t *)&cmd_mac_addr,
10800 (cmdline_parse_inst_t *)&cmd_set_qmap,
10801 (cmdline_parse_inst_t *)&cmd_operate_port,
10802 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10803 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10804 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10805 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10806 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10807 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10808 (cmdline_parse_inst_t *)&cmd_config_mtu,
10809 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10810 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10811 (cmdline_parse_inst_t *)&cmd_config_rss,
10812 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10813 (cmdline_parse_inst_t *)&cmd_config_txqflags,
10814 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10815 (cmdline_parse_inst_t *)&cmd_showport_reta,
10816 (cmdline_parse_inst_t *)&cmd_config_burst,
10817 (cmdline_parse_inst_t *)&cmd_config_thresh,
10818 (cmdline_parse_inst_t *)&cmd_config_threshold,
10819 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10820 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10821 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10822 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10823 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10824 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10825 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10826 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10827 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10828 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10829 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10830 (cmdline_parse_inst_t *)&cmd_global_config,
10831 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10832 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10833 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10834 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10835 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10836 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10837 (cmdline_parse_inst_t *)&cmd_dump,
10838 (cmdline_parse_inst_t *)&cmd_dump_one,
10839 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10840 (cmdline_parse_inst_t *)&cmd_syn_filter,
10841 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10842 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10843 (cmdline_parse_inst_t *)&cmd_flex_filter,
10844 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10845 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10846 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10847 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10848 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10849 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10850 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10851 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10852 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10853 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10854 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10855 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10856 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10857 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10858 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10859 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10860 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10861 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10862 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10863 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10864 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10865 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10866 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10867 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10868 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10869 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10870 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10871 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10872 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10876 /* prompt function, called from main on MASTER lcore */
10880 /* initialize non-constant commands */
10881 cmd_set_fwd_mode_init();
10882 cmd_set_fwd_retry_mode_init();
10884 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10885 if (testpmd_cl == NULL)
10887 cmdline_interact(testpmd_cl);
10888 cmdline_stdin_exit(testpmd_cl);
10894 if (testpmd_cl != NULL)
10895 cmdline_quit(testpmd_cl);
10899 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10901 if (id == (portid_t)RTE_PORT_ALL) {
10904 FOREACH_PORT(pid, ports) {
10905 /* check if need_reconfig has been set to 1 */
10906 if (ports[pid].need_reconfig == 0)
10907 ports[pid].need_reconfig = dev;
10908 /* check if need_reconfig_queues has been set to 1 */
10909 if (ports[pid].need_reconfig_queues == 0)
10910 ports[pid].need_reconfig_queues = queue;
10912 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10913 /* check if need_reconfig has been set to 1 */
10914 if (ports[id].need_reconfig == 0)
10915 ports[id].need_reconfig = dev;
10916 /* check if need_reconfig_queues has been set to 1 */
10917 if (ports[id].need_reconfig_queues == 0)
10918 ports[id].need_reconfig_queues = queue;