4 * Copyright(c) 2010-2015 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);
98 uint8_t bypass_is_supported(portid_t port_id);
101 /* *** Help command with introduction. *** */
102 struct cmd_help_brief_result {
103 cmdline_fixed_string_t help;
106 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
108 __attribute__((unused)) void *data)
113 "Help is available for the following sections:\n\n"
114 " help control : Start and stop forwarding.\n"
115 " help display : Displaying port, stats and config "
117 " help config : Configuration information.\n"
118 " help ports : Configuring ports.\n"
119 " help registers : Reading and setting port registers.\n"
120 " help filters : Filters configuration help.\n"
121 " help all : All of the above sections.\n\n"
126 cmdline_parse_token_string_t cmd_help_brief_help =
127 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
129 cmdline_parse_inst_t cmd_help_brief = {
130 .f = cmd_help_brief_parsed,
132 .help_str = "show help",
134 (void *)&cmd_help_brief_help,
139 /* *** Help command with help sections. *** */
140 struct cmd_help_long_result {
141 cmdline_fixed_string_t help;
142 cmdline_fixed_string_t section;
145 static void cmd_help_long_parsed(void *parsed_result,
147 __attribute__((unused)) void *data)
150 struct cmd_help_long_result *res = parsed_result;
152 if (!strcmp(res->section, "all"))
155 if (show_all || !strcmp(res->section, "control")) {
160 "Control forwarding:\n"
161 "-------------------\n\n"
164 " Start packet forwarding with current configuration.\n\n"
167 " Start packet forwarding with current config"
168 " after sending one burst of packets.\n\n"
171 " Stop packet forwarding, and display accumulated"
175 " Quit to prompt.\n\n"
179 if (show_all || !strcmp(res->section, "display")) {
187 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
188 " Display information for port_id, or all.\n\n"
190 "show port X rss reta (size) (mask0,mask1,...)\n"
191 " Display the rss redirection table entry indicated"
192 " by masks on port X. size is used to indicate the"
193 " hardware supported reta size\n\n"
195 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
196 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
197 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
198 " Display the RSS hash functions and RSS hash key"
201 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
202 " Clear information for port_id, or all.\n\n"
204 "show (rxq|txq) info (port_id) (queue_id)\n"
205 " Display information for configured RX/TX queue.\n\n"
207 "show config (rxtx|cores|fwd|txpkts)\n"
208 " Display the given configuration.\n\n"
210 "read rxd (port_id) (queue_id) (rxd_id)\n"
211 " Display an RX descriptor of a port RX queue.\n\n"
213 "read txd (port_id) (queue_id) (txd_id)\n"
214 " Display a TX descriptor of a port TX queue.\n\n"
218 if (show_all || !strcmp(res->section, "config")) {
224 "Configuration changes only become active when"
225 " forwarding is started/restarted.\n\n"
228 " Reset forwarding to the default configuration.\n\n"
230 "set verbose (level)\n"
231 " Set the debug verbosity level X.\n\n"
234 " Set number of ports.\n\n"
237 " Set number of cores.\n\n"
239 "set coremask (mask)\n"
240 " Set the forwarding cores hexadecimal mask.\n\n"
242 "set portmask (mask)\n"
243 " Set the forwarding ports hexadecimal mask.\n\n"
246 " Set number of packets per burst.\n\n"
248 "set burst tx delay (microseconds) retry (num)\n"
249 " Set the transmit delay time and number of retries"
250 " in mac_retry forwarding mode.\n\n"
252 "set txpkts (x[,y]*)\n"
253 " Set the length of each segment of TXONLY"
254 " and optionally CSUM packets.\n\n"
256 "set txsplit (off|on|rand)\n"
257 " Set the split policy for the TX packets."
258 " Right now only applicable for CSUM and TXONLY"
261 "set corelist (x[,y]*)\n"
262 " Set the list of forwarding cores.\n\n"
264 "set portlist (x[,y]*)\n"
265 " Set the list of forwarding ports.\n\n"
267 "vlan set strip (on|off) (port_id)\n"
268 " Set the VLAN strip on a port.\n\n"
270 "vlan set stripq (on|off) (port_id,queue_id)\n"
271 " Set the VLAN strip for a queue on a port.\n\n"
273 "vlan set filter (on|off) (port_id)\n"
274 " Set the VLAN filter on a port.\n\n"
276 "vlan set qinq (on|off) (port_id)\n"
277 " Set the VLAN QinQ (extended queue in queue)"
280 "vlan set (inner|outer) tpid (value) (port_id)\n"
281 " Set the VLAN TPID for Packet Filtering on"
284 "rx_vlan add (vlan_id|all) (port_id)\n"
285 " Add a vlan_id, or all identifiers, to the set"
286 " of VLAN identifiers filtered by port_id.\n\n"
288 "rx_vlan rm (vlan_id|all) (port_id)\n"
289 " Remove a vlan_id, or all identifiers, from the set"
290 " of VLAN identifiers filtered by port_id.\n\n"
292 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
293 " Add a vlan_id, to the set of VLAN identifiers"
294 "filtered for VF(s) from port_id.\n\n"
296 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
297 " Remove a vlan_id, to the set of VLAN identifiers"
298 "filtered for VF(s) from port_id.\n\n"
300 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
301 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
302 " add a tunnel filter of a port.\n\n"
304 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
305 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
306 " remove a tunnel filter of a port.\n\n"
308 "rx_vxlan_port add (udp_port) (port_id)\n"
309 " Add an UDP port for VXLAN packet filter on a port\n\n"
311 "rx_vxlan_port rm (udp_port) (port_id)\n"
312 " Remove an UDP port for VXLAN packet filter on a port\n\n"
314 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
315 " Set hardware insertion of VLAN IDs (single or double VLAN "
316 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
318 "tx_vlan set pvid port_id vlan_id (on|off)\n"
319 " Set port based TX VLAN insertion.\n\n"
321 "tx_vlan reset (port_id)\n"
322 " Disable hardware insertion of a VLAN header in"
323 " packets sent on a port.\n\n"
325 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
326 " Select hardware or software calculation of the"
327 " checksum when transmitting a packet using the"
328 " csum forward engine.\n"
329 " ip|udp|tcp|sctp always concern the inner layer.\n"
330 " outer-ip concerns the outer IP layer in"
331 " case the packet is recognized as a tunnel packet by"
332 " the forward engine (vxlan, gre and ipip are supported)\n"
333 " Please check the NIC datasheet for HW limits.\n\n"
335 "csum parse-tunnel (on|off) (tx_port_id)\n"
336 " If disabled, treat tunnel packets as non-tunneled"
337 " packets (treat inner headers as payload). The port\n"
338 " argument is the port used for TX in csum forward"
341 "csum show (port_id)\n"
342 " Display tx checksum offload configuration\n\n"
344 "tso set (segsize) (portid)\n"
345 " Enable TCP Segmentation Offload in csum forward"
347 " Please check the NIC datasheet for HW limits.\n\n"
350 " Display the status of TCP Segmentation Offload.\n\n"
353 " Set packet forwarding mode.\n\n"
355 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
356 " Add a MAC address on port_id.\n\n"
358 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
359 " Remove a MAC address from port_id.\n\n"
361 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
362 " Add a MAC address for a VF on the port.\n\n"
364 "set port (port_id) uta (mac_address|all) (on|off)\n"
365 " Add/Remove a or all unicast hash filter(s)"
368 "set promisc (port_id|all) (on|off)\n"
369 " Set the promiscuous mode on port_id, or all.\n\n"
371 "set allmulti (port_id|all) (on|off)\n"
372 " Set the allmulti mode on port_id, or all.\n\n"
374 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
375 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
376 " (on|off) autoneg (on|off) (port_id)\n"
377 "set flow_ctrl rx (on|off) (portid)\n"
378 "set flow_ctrl tx (on|off) (portid)\n"
379 "set flow_ctrl high_water (high_water) (portid)\n"
380 "set flow_ctrl low_water (low_water) (portid)\n"
381 "set flow_ctrl pause_time (pause_time) (portid)\n"
382 "set flow_ctrl send_xon (send_xon) (portid)\n"
383 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
384 "set flow_ctrl autoneg (on|off) (port_id)\n"
385 " Set the link flow control parameter on a port.\n\n"
387 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
388 " (low_water) (pause_time) (priority) (port_id)\n"
389 " Set the priority flow control parameter on a"
392 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
393 " Set statistics mapping (qmapping 0..15) for RX/TX"
395 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
396 " on port 0 to mapping 5.\n\n"
398 "set port (port_id) vf (vf_id) rx|tx on|off\n"
399 " Enable/Disable a VF receive/tranmit from a port\n\n"
401 "set port (port_id) vf (vf_id) (mac_addr)"
402 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
403 " Add/Remove unicast or multicast MAC addr filter"
406 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
408 " AUPE:accepts untagged VLAN;"
409 "ROPE:accept unicast hash\n\n"
410 " BAM:accepts broadcast packets;"
411 "MPE:accepts all multicast packets\n\n"
412 " Enable/Disable a VF receive mode of a port\n\n"
414 "set port (port_id) queue (queue_id) rate (rate_num)\n"
415 " Set rate limit for a queue of a port\n\n"
417 "set port (port_id) vf (vf_id) rate (rate_num) "
418 "queue_mask (queue_mask_value)\n"
419 " Set rate limit for queues in VF of a port\n\n"
421 "set port (port_id) mirror-rule (rule_id)"
422 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
423 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
424 " Set pool or vlan type mirror rule on a port.\n"
425 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
426 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
429 "set port (port_id) mirror-rule (rule_id)"
430 " (uplink-mirror|downlink-mirror) dst-pool"
431 " (pool_id) (on|off)\n"
432 " Set uplink or downlink type mirror rule on a port.\n"
433 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
434 " 0 on' enable mirror income traffic to pool 0.\n\n"
436 "reset port (port_id) mirror-rule (rule_id)\n"
437 " Reset a mirror rule.\n\n"
439 "set flush_rx (on|off)\n"
440 " Flush (default) or don't flush RX streams before"
441 " forwarding. Mainly used with PCAP drivers.\n\n"
443 #ifdef RTE_NIC_BYPASS
444 "set bypass mode (normal|bypass|isolate) (port_id)\n"
445 " Set the bypass mode for the lowest port on bypass enabled"
448 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
449 "mode (normal|bypass|isolate) (port_id)\n"
450 " Set the event required to initiate specified bypass mode for"
451 " the lowest port on a bypass enabled NIC where:\n"
452 " timeout = enable bypass after watchdog timeout.\n"
453 " os_on = enable bypass when OS/board is powered on.\n"
454 " os_off = enable bypass when OS/board is powered off.\n"
455 " power_on = enable bypass when power supply is turned on.\n"
456 " power_off = enable bypass when power supply is turned off."
459 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
460 " Set the bypass watchdog timeout to 'n' seconds"
461 " where 0 = instant.\n\n"
463 "show bypass config (port_id)\n"
464 " Show the bypass configuration for a bypass enabled NIC"
465 " using the lowest port on the NIC.\n\n"
467 #ifdef RTE_LIBRTE_PMD_BOND
468 "create bonded device (mode) (socket)\n"
469 " Create a new bonded device with specific bonding mode and socket.\n\n"
471 "add bonding slave (slave_id) (port_id)\n"
472 " Add a slave device to a bonded device.\n\n"
474 "remove bonding slave (slave_id) (port_id)\n"
475 " Remove a slave device from a bonded device.\n\n"
477 "set bonding mode (value) (port_id)\n"
478 " Set the bonding mode on a bonded device.\n\n"
480 "set bonding primary (slave_id) (port_id)\n"
481 " Set the primary slave for a bonded device.\n\n"
483 "show bonding config (port_id)\n"
484 " Show the bonding config for port_id.\n\n"
486 "set bonding mac_addr (port_id) (address)\n"
487 " Set the MAC address of a bonded device.\n\n"
489 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
490 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
492 "set bonding mon_period (port_id) (value)\n"
493 " Set the bonding link status monitoring polling period in ms.\n\n"
495 "set link-up port (port_id)\n"
496 " Set link up for a port.\n\n"
498 "set link-down port (port_id)\n"
499 " Set link down for a port.\n\n"
501 "E-tag set insertion on port-tag-id (value)"
502 " port (port_id) vf (vf_id)\n"
503 " Enable E-tag insertion for a VF on a port\n\n"
505 "E-tag set insertion off port (port_id) vf (vf_id)\n"
506 " Disable E-tag insertion for a VF on a port\n\n"
508 "E-tag set stripping (on|off) port (port_id)\n"
509 " Enable/disable E-tag stripping on a port\n\n"
511 "E-tag set forwarding (on|off) port (port_id)\n"
512 " Enable/disable E-tag based forwarding"
515 "E-tag set filter add e-tag-id (value) dst-pool"
516 " (pool_id) port (port_id)\n"
517 " Add an E-tag forwarding filter on a port\n\n"
519 "E-tag set filter del e-tag-id (value) port (port_id)\n"
520 " Delete an E-tag forwarding filter on a port\n\n"
522 , list_pkt_forwarding_modes()
526 if (show_all || !strcmp(res->section, "ports")) {
532 "----------------\n\n"
534 "port start (port_id|all)\n"
535 " Start all ports or port_id.\n\n"
537 "port stop (port_id|all)\n"
538 " Stop all ports or port_id.\n\n"
540 "port close (port_id|all)\n"
541 " Close all ports or port_id.\n\n"
543 "port attach (ident)\n"
544 " Attach physical or virtual dev by pci address or virtual device name\n\n"
546 "port detach (port_id)\n"
547 " Detach physical or virtual dev by port_id\n\n"
549 "port config (port_id|all)"
550 " speed (10|100|1000|10000|40000|auto)"
551 " duplex (half|full|auto)\n"
552 " Set speed and duplex for all ports or port_id\n\n"
554 "port config all (rxq|txq|rxd|txd) (value)\n"
555 " Set number for rxq/txq/rxd/txd.\n\n"
557 "port config all max-pkt-len (value)\n"
558 " Set the max packet length.\n\n"
560 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
561 "hw-vlan-strip|hw-vlan-extend|drop-en)"
563 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
566 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
567 " Set the RSS mode.\n\n"
569 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
570 " Set the RSS redirection table.\n\n"
572 "port config (port_id) dcb vt (on|off) (traffic_class)"
574 " Set the DCB mode.\n\n"
576 "port config all burst (value)\n"
577 " Set the number of packets per burst.\n\n"
579 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
581 " Set the ring prefetch/host/writeback threshold"
582 " for tx/rx queue.\n\n"
584 "port config all (txfreet|txrst|rxfreet) (value)\n"
585 " Set free threshold for rx/tx, or set"
586 " tx rs bit threshold.\n\n"
587 "port config mtu X value\n"
588 " Set the MTU of port X to a given value\n\n"
590 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
591 " Start/stop a rx/tx queue of port X. Only take effect"
592 " when port X is started\n\n"
594 "port config (port_id|all) l2-tunnel E-tag ether-type"
596 " Set the value of E-tag ether-type.\n\n"
598 "port config (port_id|all) l2-tunnel E-tag"
599 " (enable|disable)\n"
600 " Enable/disable the E-tag support.\n\n"
604 if (show_all || !strcmp(res->section, "registers")) {
612 "read reg (port_id) (address)\n"
613 " Display value of a port register.\n\n"
615 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
616 " Display a port register bit field.\n\n"
618 "read regbit (port_id) (address) (bit_x)\n"
619 " Display a single port register bit.\n\n"
621 "write reg (port_id) (address) (value)\n"
622 " Set value of a port register.\n\n"
624 "write regfield (port_id) (address) (bit_x) (bit_y)"
626 " Set bit field of a port register.\n\n"
628 "write regbit (port_id) (address) (bit_x) (value)\n"
629 " Set single bit value of a port register.\n\n"
632 if (show_all || !strcmp(res->section, "filters")) {
640 "ethertype_filter (port_id) (add|del)"
641 " (mac_addr|mac_ignr) (mac_address) ethertype"
642 " (ether_type) (drop|fwd) queue (queue_id)\n"
643 " Add/Del an ethertype filter.\n\n"
645 "2tuple_filter (port_id) (add|del)"
646 " dst_port (dst_port_value) protocol (protocol_value)"
647 " mask (mask_value) tcp_flags (tcp_flags_value)"
648 " priority (prio_value) queue (queue_id)\n"
649 " Add/Del a 2tuple filter.\n\n"
651 "5tuple_filter (port_id) (add|del)"
652 " dst_ip (dst_address) src_ip (src_address)"
653 " dst_port (dst_port_value) src_port (src_port_value)"
654 " protocol (protocol_value)"
655 " mask (mask_value) tcp_flags (tcp_flags_value)"
656 " priority (prio_value) queue (queue_id)\n"
657 " Add/Del a 5tuple filter.\n\n"
659 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
660 " Add/Del syn filter.\n\n"
662 "flex_filter (port_id) (add|del) len (len_value)"
663 " bytes (bytes_value) mask (mask_value)"
664 " priority (prio_value) queue (queue_id)\n"
665 " Add/Del a flex filter.\n\n"
667 "flow_director_filter (port_id) mode IP (add|del|update)"
668 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
669 " src (src_ip_address) dst (dst_ip_address)"
670 " vlan (vlan_value) flexbytes (flexbytes_value)"
671 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
672 " fd_id (fd_id_value)\n"
673 " Add/Del an IP type flow director filter.\n\n"
675 "flow_director_filter (port_id) mode IP (add|del|update)"
676 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
677 " src (src_ip_address) (src_port)"
678 " dst (dst_ip_address) (dst_port)"
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) vlan (vlan_value)"
689 " flexbytes (flexbytes_value) (drop|fwd)"
690 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
691 " Add/Del a SCTP type flow director filter.\n\n"
693 "flow_director_filter (port_id) mode IP (add|del|update)"
694 " flow l2_payload ether (ethertype)"
695 " flexbytes (flexbytes_value) (drop|fwd)"
696 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
697 " Add/Del a l2 payload type flow director filter.\n\n"
699 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
700 " mac (mac_address) vlan (vlan_value)"
701 " flexbytes (flexbytes_value) (drop|fwd)"
702 " queue (queue_id) fd_id (fd_id_value)\n"
703 " Add/Del a MAC-VLAN flow director filter.\n\n"
705 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
706 " mac (mac_address) vlan (vlan_value)"
707 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
708 " flexbytes (flexbytes_value) (drop|fwd)"
709 " queue (queue_id) fd_id (fd_id_value)\n"
710 " Add/Del a Tunnel flow director filter.\n\n"
712 "flush_flow_director (port_id)\n"
713 " Flush all flow director entries of a device.\n\n"
715 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
716 " src_mask (ipv4_src) (ipv6_src) (src_port)"
717 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
718 " Set flow director IP mask.\n\n"
720 "flow_director_mask (port_id) mode MAC-VLAN"
721 " vlan (vlan_value) mac (mac_value)\n"
722 " Set flow director MAC-VLAN mask.\n\n"
724 "flow_director_mask (port_id) mode Tunnel"
725 " vlan (vlan_value) mac (mac_value)"
726 " tunnel-type (tunnel_type_value)"
727 " tunnel-id (tunnel_id_value)\n"
728 " Set flow director Tunnel mask.\n\n"
730 "flow_director_flex_mask (port_id)"
731 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
732 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
734 " Configure mask of flex payload.\n\n"
736 "flow_director_flex_payload (port_id)"
737 " (raw|l2|l3|l4) (config)\n"
738 " Configure flex payload selection.\n\n"
740 "get_sym_hash_ena_per_port (port_id)\n"
741 " get symmetric hash enable configuration per port.\n\n"
743 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
744 " set symmetric hash enable configuration per port"
745 " to enable or disable.\n\n"
747 "get_hash_global_config (port_id)\n"
748 " Get the global configurations of hash filters.\n\n"
750 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
751 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
752 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
753 " (enable|disable)\n"
754 " Set the global configurations of hash filters.\n\n"
756 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
757 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
758 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
759 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
760 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
761 "ipv6-next-header|udp-src-port|udp-dst-port|"
762 "tcp-src-port|tcp-dst-port|sctp-src-port|"
763 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
764 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
765 "fld-8th|none) (select|add)\n"
766 " Set the input set for hash.\n\n"
768 "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
769 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
770 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
771 "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
772 "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
773 "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
774 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
775 "fld-8th|none) (select|add)\n"
776 " Set the input set for FDir.\n\n"
781 cmdline_parse_token_string_t cmd_help_long_help =
782 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
784 cmdline_parse_token_string_t cmd_help_long_section =
785 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
786 "all#control#display#config#"
787 "ports#registers#filters");
789 cmdline_parse_inst_t cmd_help_long = {
790 .f = cmd_help_long_parsed,
792 .help_str = "show help",
794 (void *)&cmd_help_long_help,
795 (void *)&cmd_help_long_section,
801 /* *** start/stop/close all ports *** */
802 struct cmd_operate_port_result {
803 cmdline_fixed_string_t keyword;
804 cmdline_fixed_string_t name;
805 cmdline_fixed_string_t value;
808 static void cmd_operate_port_parsed(void *parsed_result,
809 __attribute__((unused)) struct cmdline *cl,
810 __attribute__((unused)) void *data)
812 struct cmd_operate_port_result *res = parsed_result;
814 if (!strcmp(res->name, "start"))
815 start_port(RTE_PORT_ALL);
816 else if (!strcmp(res->name, "stop"))
817 stop_port(RTE_PORT_ALL);
818 else if (!strcmp(res->name, "close"))
819 close_port(RTE_PORT_ALL);
821 printf("Unknown parameter\n");
824 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
825 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
827 cmdline_parse_token_string_t cmd_operate_port_all_port =
828 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
830 cmdline_parse_token_string_t cmd_operate_port_all_all =
831 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
833 cmdline_parse_inst_t cmd_operate_port = {
834 .f = cmd_operate_port_parsed,
836 .help_str = "port start|stop|close all: start/stop/close all ports",
838 (void *)&cmd_operate_port_all_cmd,
839 (void *)&cmd_operate_port_all_port,
840 (void *)&cmd_operate_port_all_all,
845 /* *** start/stop/close specific port *** */
846 struct cmd_operate_specific_port_result {
847 cmdline_fixed_string_t keyword;
848 cmdline_fixed_string_t name;
852 static void cmd_operate_specific_port_parsed(void *parsed_result,
853 __attribute__((unused)) struct cmdline *cl,
854 __attribute__((unused)) void *data)
856 struct cmd_operate_specific_port_result *res = parsed_result;
858 if (!strcmp(res->name, "start"))
859 start_port(res->value);
860 else if (!strcmp(res->name, "stop"))
861 stop_port(res->value);
862 else if (!strcmp(res->name, "close"))
863 close_port(res->value);
865 printf("Unknown parameter\n");
868 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
869 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
871 cmdline_parse_token_string_t cmd_operate_specific_port_port =
872 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
873 name, "start#stop#close");
874 cmdline_parse_token_num_t cmd_operate_specific_port_id =
875 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
878 cmdline_parse_inst_t cmd_operate_specific_port = {
879 .f = cmd_operate_specific_port_parsed,
881 .help_str = "port start|stop|close X: start/stop/close port X",
883 (void *)&cmd_operate_specific_port_cmd,
884 (void *)&cmd_operate_specific_port_port,
885 (void *)&cmd_operate_specific_port_id,
890 /* *** attach a specified port *** */
891 struct cmd_operate_attach_port_result {
892 cmdline_fixed_string_t port;
893 cmdline_fixed_string_t keyword;
894 cmdline_fixed_string_t identifier;
897 static void cmd_operate_attach_port_parsed(void *parsed_result,
898 __attribute__((unused)) struct cmdline *cl,
899 __attribute__((unused)) void *data)
901 struct cmd_operate_attach_port_result *res = parsed_result;
903 if (!strcmp(res->keyword, "attach"))
904 attach_port(res->identifier);
906 printf("Unknown parameter\n");
909 cmdline_parse_token_string_t cmd_operate_attach_port_port =
910 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
912 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
913 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
915 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
916 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
919 cmdline_parse_inst_t cmd_operate_attach_port = {
920 .f = cmd_operate_attach_port_parsed,
922 .help_str = "port attach identifier, "
923 "identifier: pci address or virtual dev name",
925 (void *)&cmd_operate_attach_port_port,
926 (void *)&cmd_operate_attach_port_keyword,
927 (void *)&cmd_operate_attach_port_identifier,
932 /* *** detach a specified port *** */
933 struct cmd_operate_detach_port_result {
934 cmdline_fixed_string_t port;
935 cmdline_fixed_string_t keyword;
939 static void cmd_operate_detach_port_parsed(void *parsed_result,
940 __attribute__((unused)) struct cmdline *cl,
941 __attribute__((unused)) void *data)
943 struct cmd_operate_detach_port_result *res = parsed_result;
945 if (!strcmp(res->keyword, "detach"))
946 detach_port(res->port_id);
948 printf("Unknown parameter\n");
951 cmdline_parse_token_string_t cmd_operate_detach_port_port =
952 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
954 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
955 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
957 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
958 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
961 cmdline_parse_inst_t cmd_operate_detach_port = {
962 .f = cmd_operate_detach_port_parsed,
964 .help_str = "port detach port_id",
966 (void *)&cmd_operate_detach_port_port,
967 (void *)&cmd_operate_detach_port_keyword,
968 (void *)&cmd_operate_detach_port_port_id,
973 /* *** configure speed for all ports *** */
974 struct cmd_config_speed_all {
975 cmdline_fixed_string_t port;
976 cmdline_fixed_string_t keyword;
977 cmdline_fixed_string_t all;
978 cmdline_fixed_string_t item1;
979 cmdline_fixed_string_t item2;
980 cmdline_fixed_string_t value1;
981 cmdline_fixed_string_t value2;
985 cmd_config_speed_all_parsed(void *parsed_result,
986 __attribute__((unused)) struct cmdline *cl,
987 __attribute__((unused)) void *data)
989 struct cmd_config_speed_all *res = parsed_result;
990 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
991 uint16_t link_duplex = 0;
994 if (!all_ports_stopped()) {
995 printf("Please stop all ports first\n");
999 if (!strcmp(res->value1, "10"))
1000 link_speed = ETH_LINK_SPEED_10;
1001 else if (!strcmp(res->value1, "100"))
1002 link_speed = ETH_LINK_SPEED_100;
1003 else if (!strcmp(res->value1, "1000"))
1004 link_speed = ETH_LINK_SPEED_1000;
1005 else if (!strcmp(res->value1, "10000"))
1006 link_speed = ETH_LINK_SPEED_10G;
1007 else if (!strcmp(res->value1, "40000"))
1008 link_speed = ETH_LINK_SPEED_40G;
1009 else if (!strcmp(res->value1, "auto"))
1010 link_speed = ETH_LINK_SPEED_AUTONEG;
1012 printf("Unknown parameter\n");
1016 if (!strcmp(res->value2, "half"))
1017 link_duplex = ETH_LINK_HALF_DUPLEX;
1018 else if (!strcmp(res->value2, "full"))
1019 link_duplex = ETH_LINK_FULL_DUPLEX;
1020 else if (!strcmp(res->value2, "auto"))
1021 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1023 printf("Unknown parameter\n");
1027 FOREACH_PORT(pid, ports) {
1028 ports[pid].dev_conf.link_speed = link_speed;
1029 ports[pid].dev_conf.link_duplex = link_duplex;
1032 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1035 cmdline_parse_token_string_t cmd_config_speed_all_port =
1036 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1037 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1038 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1040 cmdline_parse_token_string_t cmd_config_speed_all_all =
1041 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1042 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1043 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1044 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1045 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1046 "10#100#1000#10000#40000#auto");
1047 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1048 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1049 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1050 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1053 cmdline_parse_inst_t cmd_config_speed_all = {
1054 .f = cmd_config_speed_all_parsed,
1056 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
1059 (void *)&cmd_config_speed_all_port,
1060 (void *)&cmd_config_speed_all_keyword,
1061 (void *)&cmd_config_speed_all_all,
1062 (void *)&cmd_config_speed_all_item1,
1063 (void *)&cmd_config_speed_all_value1,
1064 (void *)&cmd_config_speed_all_item2,
1065 (void *)&cmd_config_speed_all_value2,
1070 /* *** configure speed for specific port *** */
1071 struct cmd_config_speed_specific {
1072 cmdline_fixed_string_t port;
1073 cmdline_fixed_string_t keyword;
1075 cmdline_fixed_string_t item1;
1076 cmdline_fixed_string_t item2;
1077 cmdline_fixed_string_t value1;
1078 cmdline_fixed_string_t value2;
1082 cmd_config_speed_specific_parsed(void *parsed_result,
1083 __attribute__((unused)) struct cmdline *cl,
1084 __attribute__((unused)) void *data)
1086 struct cmd_config_speed_specific *res = parsed_result;
1087 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1088 uint16_t link_duplex = 0;
1090 if (!all_ports_stopped()) {
1091 printf("Please stop all ports first\n");
1095 if (port_id_is_invalid(res->id, ENABLED_WARN))
1098 if (!strcmp(res->value1, "10"))
1099 link_speed = ETH_LINK_SPEED_10;
1100 else if (!strcmp(res->value1, "100"))
1101 link_speed = ETH_LINK_SPEED_100;
1102 else if (!strcmp(res->value1, "1000"))
1103 link_speed = ETH_LINK_SPEED_1000;
1104 else if (!strcmp(res->value1, "10000"))
1105 link_speed = ETH_LINK_SPEED_10000;
1106 else if (!strcmp(res->value1, "40000"))
1107 link_speed = ETH_LINK_SPEED_40G;
1108 else if (!strcmp(res->value1, "auto"))
1109 link_speed = ETH_LINK_SPEED_AUTONEG;
1111 printf("Unknown parameter\n");
1115 if (!strcmp(res->value2, "half"))
1116 link_duplex = ETH_LINK_HALF_DUPLEX;
1117 else if (!strcmp(res->value2, "full"))
1118 link_duplex = ETH_LINK_FULL_DUPLEX;
1119 else if (!strcmp(res->value2, "auto"))
1120 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1122 printf("Unknown parameter\n");
1126 ports[res->id].dev_conf.link_speed = link_speed;
1127 ports[res->id].dev_conf.link_duplex = link_duplex;
1129 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1133 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1134 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1136 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1137 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1139 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1140 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1141 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1142 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1144 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1145 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1146 "10#100#1000#10000#40000#auto");
1147 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1148 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1150 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1154 cmdline_parse_inst_t cmd_config_speed_specific = {
1155 .f = cmd_config_speed_specific_parsed,
1157 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1160 (void *)&cmd_config_speed_specific_port,
1161 (void *)&cmd_config_speed_specific_keyword,
1162 (void *)&cmd_config_speed_specific_id,
1163 (void *)&cmd_config_speed_specific_item1,
1164 (void *)&cmd_config_speed_specific_value1,
1165 (void *)&cmd_config_speed_specific_item2,
1166 (void *)&cmd_config_speed_specific_value2,
1171 /* *** configure txq/rxq, txd/rxd *** */
1172 struct cmd_config_rx_tx {
1173 cmdline_fixed_string_t port;
1174 cmdline_fixed_string_t keyword;
1175 cmdline_fixed_string_t all;
1176 cmdline_fixed_string_t name;
1181 cmd_config_rx_tx_parsed(void *parsed_result,
1182 __attribute__((unused)) struct cmdline *cl,
1183 __attribute__((unused)) void *data)
1185 struct cmd_config_rx_tx *res = parsed_result;
1187 if (!all_ports_stopped()) {
1188 printf("Please stop all ports first\n");
1192 if (!strcmp(res->name, "rxq")) {
1193 if (res->value <= 0) {
1194 printf("rxq %d invalid - must be > 0\n", res->value);
1197 nb_rxq = res->value;
1199 else if (!strcmp(res->name, "txq")) {
1200 if (res->value <= 0) {
1201 printf("txq %d invalid - must be > 0\n", res->value);
1204 nb_txq = res->value;
1206 else if (!strcmp(res->name, "rxd")) {
1207 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1208 printf("rxd %d invalid - must be > 0 && <= %d\n",
1209 res->value, RTE_TEST_RX_DESC_MAX);
1212 nb_rxd = res->value;
1213 } else if (!strcmp(res->name, "txd")) {
1214 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1215 printf("txd %d invalid - must be > 0 && <= %d\n",
1216 res->value, RTE_TEST_TX_DESC_MAX);
1219 nb_txd = res->value;
1221 printf("Unknown parameter\n");
1227 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1230 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1231 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1232 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1233 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1234 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1235 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1236 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1237 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1239 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1240 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1242 cmdline_parse_inst_t cmd_config_rx_tx = {
1243 .f = cmd_config_rx_tx_parsed,
1245 .help_str = "port config all rxq|txq|rxd|txd value",
1247 (void *)&cmd_config_rx_tx_port,
1248 (void *)&cmd_config_rx_tx_keyword,
1249 (void *)&cmd_config_rx_tx_all,
1250 (void *)&cmd_config_rx_tx_name,
1251 (void *)&cmd_config_rx_tx_value,
1256 /* *** config max packet length *** */
1257 struct cmd_config_max_pkt_len_result {
1258 cmdline_fixed_string_t port;
1259 cmdline_fixed_string_t keyword;
1260 cmdline_fixed_string_t all;
1261 cmdline_fixed_string_t name;
1266 cmd_config_max_pkt_len_parsed(void *parsed_result,
1267 __attribute__((unused)) struct cmdline *cl,
1268 __attribute__((unused)) void *data)
1270 struct cmd_config_max_pkt_len_result *res = parsed_result;
1272 if (!all_ports_stopped()) {
1273 printf("Please stop all ports first\n");
1277 if (!strcmp(res->name, "max-pkt-len")) {
1278 if (res->value < ETHER_MIN_LEN) {
1279 printf("max-pkt-len can not be less than %d\n",
1283 if (res->value == rx_mode.max_rx_pkt_len)
1286 rx_mode.max_rx_pkt_len = res->value;
1287 if (res->value > ETHER_MAX_LEN)
1288 rx_mode.jumbo_frame = 1;
1290 rx_mode.jumbo_frame = 0;
1292 printf("Unknown parameter\n");
1298 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1301 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1302 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1304 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1305 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1307 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1308 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1310 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1311 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1313 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1314 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1317 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1318 .f = cmd_config_max_pkt_len_parsed,
1320 .help_str = "port config all max-pkt-len value",
1322 (void *)&cmd_config_max_pkt_len_port,
1323 (void *)&cmd_config_max_pkt_len_keyword,
1324 (void *)&cmd_config_max_pkt_len_all,
1325 (void *)&cmd_config_max_pkt_len_name,
1326 (void *)&cmd_config_max_pkt_len_value,
1331 /* *** configure port MTU *** */
1332 struct cmd_config_mtu_result {
1333 cmdline_fixed_string_t port;
1334 cmdline_fixed_string_t keyword;
1335 cmdline_fixed_string_t mtu;
1341 cmd_config_mtu_parsed(void *parsed_result,
1342 __attribute__((unused)) struct cmdline *cl,
1343 __attribute__((unused)) void *data)
1345 struct cmd_config_mtu_result *res = parsed_result;
1347 if (res->value < ETHER_MIN_LEN) {
1348 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1351 port_mtu_set(res->port_id, res->value);
1354 cmdline_parse_token_string_t cmd_config_mtu_port =
1355 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1357 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1358 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1360 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1361 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1363 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1364 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1365 cmdline_parse_token_num_t cmd_config_mtu_value =
1366 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1368 cmdline_parse_inst_t cmd_config_mtu = {
1369 .f = cmd_config_mtu_parsed,
1371 .help_str = "port config mtu value",
1373 (void *)&cmd_config_mtu_port,
1374 (void *)&cmd_config_mtu_keyword,
1375 (void *)&cmd_config_mtu_mtu,
1376 (void *)&cmd_config_mtu_port_id,
1377 (void *)&cmd_config_mtu_value,
1382 /* *** configure rx mode *** */
1383 struct cmd_config_rx_mode_flag {
1384 cmdline_fixed_string_t port;
1385 cmdline_fixed_string_t keyword;
1386 cmdline_fixed_string_t all;
1387 cmdline_fixed_string_t name;
1388 cmdline_fixed_string_t value;
1392 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1393 __attribute__((unused)) struct cmdline *cl,
1394 __attribute__((unused)) void *data)
1396 struct cmd_config_rx_mode_flag *res = parsed_result;
1398 if (!all_ports_stopped()) {
1399 printf("Please stop all ports first\n");
1403 if (!strcmp(res->name, "crc-strip")) {
1404 if (!strcmp(res->value, "on"))
1405 rx_mode.hw_strip_crc = 1;
1406 else if (!strcmp(res->value, "off"))
1407 rx_mode.hw_strip_crc = 0;
1409 printf("Unknown parameter\n");
1412 } else if (!strcmp(res->name, "rx-cksum")) {
1413 if (!strcmp(res->value, "on"))
1414 rx_mode.hw_ip_checksum = 1;
1415 else if (!strcmp(res->value, "off"))
1416 rx_mode.hw_ip_checksum = 0;
1418 printf("Unknown parameter\n");
1421 } else if (!strcmp(res->name, "hw-vlan")) {
1422 if (!strcmp(res->value, "on")) {
1423 rx_mode.hw_vlan_filter = 1;
1424 rx_mode.hw_vlan_strip = 1;
1426 else if (!strcmp(res->value, "off")) {
1427 rx_mode.hw_vlan_filter = 0;
1428 rx_mode.hw_vlan_strip = 0;
1431 printf("Unknown parameter\n");
1434 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1435 if (!strcmp(res->value, "on"))
1436 rx_mode.hw_vlan_filter = 1;
1437 else if (!strcmp(res->value, "off"))
1438 rx_mode.hw_vlan_filter = 0;
1440 printf("Unknown parameter\n");
1443 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1444 if (!strcmp(res->value, "on"))
1445 rx_mode.hw_vlan_strip = 1;
1446 else if (!strcmp(res->value, "off"))
1447 rx_mode.hw_vlan_strip = 0;
1449 printf("Unknown parameter\n");
1452 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1453 if (!strcmp(res->value, "on"))
1454 rx_mode.hw_vlan_extend = 1;
1455 else if (!strcmp(res->value, "off"))
1456 rx_mode.hw_vlan_extend = 0;
1458 printf("Unknown parameter\n");
1461 } else if (!strcmp(res->name, "drop-en")) {
1462 if (!strcmp(res->value, "on"))
1464 else if (!strcmp(res->value, "off"))
1467 printf("Unknown parameter\n");
1471 printf("Unknown parameter\n");
1477 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1480 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1482 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1485 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1487 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1489 "crc-strip#rx-cksum#hw-vlan#"
1490 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1491 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1492 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1495 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1496 .f = cmd_config_rx_mode_flag_parsed,
1498 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1499 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1501 (void *)&cmd_config_rx_mode_flag_port,
1502 (void *)&cmd_config_rx_mode_flag_keyword,
1503 (void *)&cmd_config_rx_mode_flag_all,
1504 (void *)&cmd_config_rx_mode_flag_name,
1505 (void *)&cmd_config_rx_mode_flag_value,
1510 /* *** configure rss *** */
1511 struct cmd_config_rss {
1512 cmdline_fixed_string_t port;
1513 cmdline_fixed_string_t keyword;
1514 cmdline_fixed_string_t all;
1515 cmdline_fixed_string_t name;
1516 cmdline_fixed_string_t value;
1520 cmd_config_rss_parsed(void *parsed_result,
1521 __attribute__((unused)) struct cmdline *cl,
1522 __attribute__((unused)) void *data)
1524 struct cmd_config_rss *res = parsed_result;
1525 struct rte_eth_rss_conf rss_conf;
1528 if (!strcmp(res->value, "all"))
1529 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1530 ETH_RSS_UDP | ETH_RSS_SCTP |
1532 else if (!strcmp(res->value, "ip"))
1533 rss_conf.rss_hf = ETH_RSS_IP;
1534 else if (!strcmp(res->value, "udp"))
1535 rss_conf.rss_hf = ETH_RSS_UDP;
1536 else if (!strcmp(res->value, "tcp"))
1537 rss_conf.rss_hf = ETH_RSS_TCP;
1538 else if (!strcmp(res->value, "sctp"))
1539 rss_conf.rss_hf = ETH_RSS_SCTP;
1540 else if (!strcmp(res->value, "ether"))
1541 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1542 else if (!strcmp(res->value, "none"))
1543 rss_conf.rss_hf = 0;
1545 printf("Unknown parameter\n");
1548 rss_conf.rss_key = NULL;
1549 for (i = 0; i < rte_eth_dev_count(); i++)
1550 rte_eth_dev_rss_hash_update(i, &rss_conf);
1553 cmdline_parse_token_string_t cmd_config_rss_port =
1554 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1555 cmdline_parse_token_string_t cmd_config_rss_keyword =
1556 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1557 cmdline_parse_token_string_t cmd_config_rss_all =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1559 cmdline_parse_token_string_t cmd_config_rss_name =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1561 cmdline_parse_token_string_t cmd_config_rss_value =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1563 "all#ip#tcp#udp#sctp#ether#none");
1565 cmdline_parse_inst_t cmd_config_rss = {
1566 .f = cmd_config_rss_parsed,
1568 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1570 (void *)&cmd_config_rss_port,
1571 (void *)&cmd_config_rss_keyword,
1572 (void *)&cmd_config_rss_all,
1573 (void *)&cmd_config_rss_name,
1574 (void *)&cmd_config_rss_value,
1579 /* *** configure rss hash key *** */
1580 struct cmd_config_rss_hash_key {
1581 cmdline_fixed_string_t port;
1582 cmdline_fixed_string_t config;
1584 cmdline_fixed_string_t rss_hash_key;
1585 cmdline_fixed_string_t rss_type;
1586 cmdline_fixed_string_t key;
1589 #define RSS_HASH_KEY_LENGTH 40
1591 hexa_digit_to_value(char hexa_digit)
1593 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1594 return (uint8_t) (hexa_digit - '0');
1595 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1596 return (uint8_t) ((hexa_digit - 'a') + 10);
1597 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1598 return (uint8_t) ((hexa_digit - 'A') + 10);
1599 /* Invalid hexa digit */
1604 parse_and_check_key_hexa_digit(char *key, int idx)
1608 hexa_v = hexa_digit_to_value(key[idx]);
1610 printf("invalid key: character %c at position %d is not a "
1611 "valid hexa digit\n", key[idx], idx);
1616 cmd_config_rss_hash_key_parsed(void *parsed_result,
1617 __attribute__((unused)) struct cmdline *cl,
1618 __attribute__((unused)) void *data)
1620 struct cmd_config_rss_hash_key *res = parsed_result;
1621 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1626 /* Check the length of the RSS hash key */
1627 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1628 printf("key length: %d invalid - key must be a string of %d"
1629 "hexa-decimal numbers\n", (int) strlen(res->key),
1630 RSS_HASH_KEY_LENGTH * 2);
1633 /* Translate RSS hash key into binary representation */
1634 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1635 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1638 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1641 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1643 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1644 RSS_HASH_KEY_LENGTH);
1647 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1649 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1652 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1653 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1654 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1656 rss_hash_key, "rss-hash-key");
1657 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1659 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1660 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1661 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1662 "ipv6-tcp-ex#ipv6-udp-ex");
1663 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1666 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1667 .f = cmd_config_rss_hash_key_parsed,
1670 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1671 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1672 "ipv6-sctp|ipv6-other|l2-payload|"
1673 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1675 (void *)&cmd_config_rss_hash_key_port,
1676 (void *)&cmd_config_rss_hash_key_config,
1677 (void *)&cmd_config_rss_hash_key_port_id,
1678 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1679 (void *)&cmd_config_rss_hash_key_rss_type,
1680 (void *)&cmd_config_rss_hash_key_value,
1685 /* *** configure port rxq/txq start/stop *** */
1686 struct cmd_config_rxtx_queue {
1687 cmdline_fixed_string_t port;
1689 cmdline_fixed_string_t rxtxq;
1691 cmdline_fixed_string_t opname;
1695 cmd_config_rxtx_queue_parsed(void *parsed_result,
1696 __attribute__((unused)) struct cmdline *cl,
1697 __attribute__((unused)) void *data)
1699 struct cmd_config_rxtx_queue *res = parsed_result;
1704 if (test_done == 0) {
1705 printf("Please stop forwarding first\n");
1709 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1712 if (port_is_started(res->portid) != 1) {
1713 printf("Please start port %u first\n", res->portid);
1717 if (!strcmp(res->rxtxq, "rxq"))
1719 else if (!strcmp(res->rxtxq, "txq"))
1722 printf("Unknown parameter\n");
1726 if (isrx && rx_queue_id_is_invalid(res->qid))
1728 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1731 if (!strcmp(res->opname, "start"))
1733 else if (!strcmp(res->opname, "stop"))
1736 printf("Unknown parameter\n");
1740 if (isstart && isrx)
1741 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1742 else if (!isstart && isrx)
1743 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1744 else if (isstart && !isrx)
1745 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1747 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1749 if (ret == -ENOTSUP)
1750 printf("Function not supported in PMD driver\n");
1753 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1755 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1756 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1757 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1759 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1760 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1761 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1762 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1765 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1766 .f = cmd_config_rxtx_queue_parsed,
1768 .help_str = "port X rxq|txq ID start|stop",
1770 (void *)&cmd_config_speed_all_port,
1771 (void *)&cmd_config_rxtx_queue_portid,
1772 (void *)&cmd_config_rxtx_queue_rxtxq,
1773 (void *)&cmd_config_rxtx_queue_qid,
1774 (void *)&cmd_config_rxtx_queue_opname,
1779 /* *** Configure RSS RETA *** */
1780 struct cmd_config_rss_reta {
1781 cmdline_fixed_string_t port;
1782 cmdline_fixed_string_t keyword;
1784 cmdline_fixed_string_t name;
1785 cmdline_fixed_string_t list_name;
1786 cmdline_fixed_string_t list_of_items;
1790 parse_reta_config(const char *str,
1791 struct rte_eth_rss_reta_entry64 *reta_conf,
1792 uint16_t nb_entries)
1796 uint16_t hash_index, idx, shift;
1799 const char *p, *p0 = str;
1806 unsigned long int_fld[_NUM_FLD];
1807 char *str_fld[_NUM_FLD];
1809 while ((p = strchr(p0,'(')) != NULL) {
1811 if((p0 = strchr(p,')')) == NULL)
1815 if(size >= sizeof(s))
1818 snprintf(s, sizeof(s), "%.*s", size, p);
1819 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1821 for (i = 0; i < _NUM_FLD; i++) {
1823 int_fld[i] = strtoul(str_fld[i], &end, 0);
1824 if (errno != 0 || end == str_fld[i] ||
1829 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1830 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1832 if (hash_index >= nb_entries) {
1833 printf("Invalid RETA hash index=%d\n", hash_index);
1837 idx = hash_index / RTE_RETA_GROUP_SIZE;
1838 shift = hash_index % RTE_RETA_GROUP_SIZE;
1839 reta_conf[idx].mask |= (1ULL << shift);
1840 reta_conf[idx].reta[shift] = nb_queue;
1847 cmd_set_rss_reta_parsed(void *parsed_result,
1848 __attribute__((unused)) struct cmdline *cl,
1849 __attribute__((unused)) void *data)
1852 struct rte_eth_dev_info dev_info;
1853 struct rte_eth_rss_reta_entry64 reta_conf[8];
1854 struct cmd_config_rss_reta *res = parsed_result;
1856 memset(&dev_info, 0, sizeof(dev_info));
1857 rte_eth_dev_info_get(res->port_id, &dev_info);
1858 if (dev_info.reta_size == 0) {
1859 printf("Redirection table size is 0 which is "
1860 "invalid for RSS\n");
1863 printf("The reta size of port %d is %u\n",
1864 res->port_id, dev_info.reta_size);
1865 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1866 printf("Currently do not support more than %u entries of "
1867 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1871 memset(reta_conf, 0, sizeof(reta_conf));
1872 if (!strcmp(res->list_name, "reta")) {
1873 if (parse_reta_config(res->list_of_items, reta_conf,
1874 dev_info.reta_size)) {
1875 printf("Invalid RSS Redirection Table "
1876 "config entered\n");
1879 ret = rte_eth_dev_rss_reta_update(res->port_id,
1880 reta_conf, dev_info.reta_size);
1882 printf("Bad redirection table parameter, "
1883 "return code = %d \n", ret);
1887 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1888 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1889 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1890 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1891 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1892 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1893 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1894 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1895 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1896 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1897 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1898 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1900 cmdline_parse_inst_t cmd_config_rss_reta = {
1901 .f = cmd_set_rss_reta_parsed,
1903 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1905 (void *)&cmd_config_rss_reta_port,
1906 (void *)&cmd_config_rss_reta_keyword,
1907 (void *)&cmd_config_rss_reta_port_id,
1908 (void *)&cmd_config_rss_reta_name,
1909 (void *)&cmd_config_rss_reta_list_name,
1910 (void *)&cmd_config_rss_reta_list_of_items,
1915 /* *** SHOW PORT RETA INFO *** */
1916 struct cmd_showport_reta {
1917 cmdline_fixed_string_t show;
1918 cmdline_fixed_string_t port;
1920 cmdline_fixed_string_t rss;
1921 cmdline_fixed_string_t reta;
1923 cmdline_fixed_string_t list_of_items;
1927 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1928 uint16_t nb_entries,
1932 const char *p, *p0 = str;
1936 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1939 p = strchr(p0, '(');
1943 p0 = strchr(p, ')');
1947 if (size >= sizeof(s)) {
1948 printf("The string size exceeds the internal buffer size\n");
1951 snprintf(s, sizeof(s), "%.*s", size, p);
1952 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1953 if (ret <= 0 || ret != num) {
1954 printf("The bits of masks do not match the number of "
1955 "reta entries: %u\n", num);
1958 for (i = 0; i < ret; i++)
1959 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1965 cmd_showport_reta_parsed(void *parsed_result,
1966 __attribute__((unused)) struct cmdline *cl,
1967 __attribute__((unused)) void *data)
1969 struct cmd_showport_reta *res = parsed_result;
1970 struct rte_eth_rss_reta_entry64 reta_conf[8];
1971 struct rte_eth_dev_info dev_info;
1973 memset(&dev_info, 0, sizeof(dev_info));
1974 rte_eth_dev_info_get(res->port_id, &dev_info);
1975 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1976 res->size > ETH_RSS_RETA_SIZE_512) {
1977 printf("Invalid redirection table size: %u\n", res->size);
1981 memset(reta_conf, 0, sizeof(reta_conf));
1982 if (showport_parse_reta_config(reta_conf, res->size,
1983 res->list_of_items) < 0) {
1984 printf("Invalid string: %s for reta masks\n",
1985 res->list_of_items);
1988 port_rss_reta_info(res->port_id, reta_conf, res->size);
1991 cmdline_parse_token_string_t cmd_showport_reta_show =
1992 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1993 cmdline_parse_token_string_t cmd_showport_reta_port =
1994 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1995 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1996 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1997 cmdline_parse_token_string_t cmd_showport_reta_rss =
1998 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1999 cmdline_parse_token_string_t cmd_showport_reta_reta =
2000 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2001 cmdline_parse_token_num_t cmd_showport_reta_size =
2002 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2003 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2004 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2005 list_of_items, NULL);
2007 cmdline_parse_inst_t cmd_showport_reta = {
2008 .f = cmd_showport_reta_parsed,
2010 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2012 (void *)&cmd_showport_reta_show,
2013 (void *)&cmd_showport_reta_port,
2014 (void *)&cmd_showport_reta_port_id,
2015 (void *)&cmd_showport_reta_rss,
2016 (void *)&cmd_showport_reta_reta,
2017 (void *)&cmd_showport_reta_size,
2018 (void *)&cmd_showport_reta_list_of_items,
2023 /* *** Show RSS hash configuration *** */
2024 struct cmd_showport_rss_hash {
2025 cmdline_fixed_string_t show;
2026 cmdline_fixed_string_t port;
2028 cmdline_fixed_string_t rss_hash;
2029 cmdline_fixed_string_t rss_type;
2030 cmdline_fixed_string_t key; /* optional argument */
2033 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2034 __attribute__((unused)) struct cmdline *cl,
2037 struct cmd_showport_rss_hash *res = parsed_result;
2039 port_rss_hash_conf_show(res->port_id, res->rss_type,
2040 show_rss_key != NULL);
2043 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2044 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2045 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2046 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2047 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2048 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2049 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2050 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2052 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2053 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2054 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2055 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2056 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2057 "ipv6-tcp-ex#ipv6-udp-ex");
2058 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2059 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2061 cmdline_parse_inst_t cmd_showport_rss_hash = {
2062 .f = cmd_showport_rss_hash_parsed,
2065 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2066 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2067 "ipv6-sctp|ipv6-other|l2-payload|"
2068 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2070 (void *)&cmd_showport_rss_hash_show,
2071 (void *)&cmd_showport_rss_hash_port,
2072 (void *)&cmd_showport_rss_hash_port_id,
2073 (void *)&cmd_showport_rss_hash_rss_hash,
2074 (void *)&cmd_showport_rss_hash_rss_hash_info,
2079 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2080 .f = cmd_showport_rss_hash_parsed,
2083 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2084 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2085 "ipv6-sctp|ipv6-other|l2-payload|"
2086 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2088 (void *)&cmd_showport_rss_hash_show,
2089 (void *)&cmd_showport_rss_hash_port,
2090 (void *)&cmd_showport_rss_hash_port_id,
2091 (void *)&cmd_showport_rss_hash_rss_hash,
2092 (void *)&cmd_showport_rss_hash_rss_hash_info,
2093 (void *)&cmd_showport_rss_hash_rss_key,
2098 /* *** Configure DCB *** */
2099 struct cmd_config_dcb {
2100 cmdline_fixed_string_t port;
2101 cmdline_fixed_string_t config;
2103 cmdline_fixed_string_t dcb;
2104 cmdline_fixed_string_t vt;
2105 cmdline_fixed_string_t vt_en;
2107 cmdline_fixed_string_t pfc;
2108 cmdline_fixed_string_t pfc_en;
2112 cmd_config_dcb_parsed(void *parsed_result,
2113 __attribute__((unused)) struct cmdline *cl,
2114 __attribute__((unused)) void *data)
2116 struct cmd_config_dcb *res = parsed_result;
2117 portid_t port_id = res->port_id;
2118 struct rte_port *port;
2122 port = &ports[port_id];
2123 /** Check if the port is not started **/
2124 if (port->port_status != RTE_PORT_STOPPED) {
2125 printf("Please stop port %d first\n", port_id);
2129 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2130 printf("The invalid number of traffic class,"
2131 " only 4 or 8 allowed.\n");
2135 if (nb_fwd_lcores < res->num_tcs) {
2136 printf("nb_cores shouldn't be less than number of TCs.\n");
2139 if (!strncmp(res->pfc_en, "on", 2))
2144 /* DCB in VT mode */
2145 if (!strncmp(res->vt_en, "on", 2))
2146 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2147 (enum rte_eth_nb_tcs)res->num_tcs,
2150 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2151 (enum rte_eth_nb_tcs)res->num_tcs,
2156 printf("Cannot initialize network ports.\n");
2160 cmd_reconfig_device_queue(port_id, 1, 1);
2163 cmdline_parse_token_string_t cmd_config_dcb_port =
2164 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2165 cmdline_parse_token_string_t cmd_config_dcb_config =
2166 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2167 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2168 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2169 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2170 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2171 cmdline_parse_token_string_t cmd_config_dcb_vt =
2172 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2173 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2174 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2175 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2176 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2177 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2178 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2179 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2182 cmdline_parse_inst_t cmd_config_dcb = {
2183 .f = cmd_config_dcb_parsed,
2185 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2187 (void *)&cmd_config_dcb_port,
2188 (void *)&cmd_config_dcb_config,
2189 (void *)&cmd_config_dcb_port_id,
2190 (void *)&cmd_config_dcb_dcb,
2191 (void *)&cmd_config_dcb_vt,
2192 (void *)&cmd_config_dcb_vt_en,
2193 (void *)&cmd_config_dcb_num_tcs,
2194 (void *)&cmd_config_dcb_pfc,
2195 (void *)&cmd_config_dcb_pfc_en,
2200 /* *** configure number of packets per burst *** */
2201 struct cmd_config_burst {
2202 cmdline_fixed_string_t port;
2203 cmdline_fixed_string_t keyword;
2204 cmdline_fixed_string_t all;
2205 cmdline_fixed_string_t name;
2210 cmd_config_burst_parsed(void *parsed_result,
2211 __attribute__((unused)) struct cmdline *cl,
2212 __attribute__((unused)) void *data)
2214 struct cmd_config_burst *res = parsed_result;
2216 if (!all_ports_stopped()) {
2217 printf("Please stop all ports first\n");
2221 if (!strcmp(res->name, "burst")) {
2222 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2223 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2226 nb_pkt_per_burst = res->value;
2228 printf("Unknown parameter\n");
2234 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2237 cmdline_parse_token_string_t cmd_config_burst_port =
2238 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2239 cmdline_parse_token_string_t cmd_config_burst_keyword =
2240 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2241 cmdline_parse_token_string_t cmd_config_burst_all =
2242 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2243 cmdline_parse_token_string_t cmd_config_burst_name =
2244 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2245 cmdline_parse_token_num_t cmd_config_burst_value =
2246 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2248 cmdline_parse_inst_t cmd_config_burst = {
2249 .f = cmd_config_burst_parsed,
2251 .help_str = "port config all burst value",
2253 (void *)&cmd_config_burst_port,
2254 (void *)&cmd_config_burst_keyword,
2255 (void *)&cmd_config_burst_all,
2256 (void *)&cmd_config_burst_name,
2257 (void *)&cmd_config_burst_value,
2262 /* *** configure rx/tx queues *** */
2263 struct cmd_config_thresh {
2264 cmdline_fixed_string_t port;
2265 cmdline_fixed_string_t keyword;
2266 cmdline_fixed_string_t all;
2267 cmdline_fixed_string_t name;
2272 cmd_config_thresh_parsed(void *parsed_result,
2273 __attribute__((unused)) struct cmdline *cl,
2274 __attribute__((unused)) void *data)
2276 struct cmd_config_thresh *res = parsed_result;
2278 if (!all_ports_stopped()) {
2279 printf("Please stop all ports first\n");
2283 if (!strcmp(res->name, "txpt"))
2284 tx_pthresh = res->value;
2285 else if(!strcmp(res->name, "txht"))
2286 tx_hthresh = res->value;
2287 else if(!strcmp(res->name, "txwt"))
2288 tx_wthresh = res->value;
2289 else if(!strcmp(res->name, "rxpt"))
2290 rx_pthresh = res->value;
2291 else if(!strcmp(res->name, "rxht"))
2292 rx_hthresh = res->value;
2293 else if(!strcmp(res->name, "rxwt"))
2294 rx_wthresh = res->value;
2296 printf("Unknown parameter\n");
2302 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2305 cmdline_parse_token_string_t cmd_config_thresh_port =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2307 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2309 cmdline_parse_token_string_t cmd_config_thresh_all =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2311 cmdline_parse_token_string_t cmd_config_thresh_name =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2313 "txpt#txht#txwt#rxpt#rxht#rxwt");
2314 cmdline_parse_token_num_t cmd_config_thresh_value =
2315 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2317 cmdline_parse_inst_t cmd_config_thresh = {
2318 .f = cmd_config_thresh_parsed,
2320 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2322 (void *)&cmd_config_thresh_port,
2323 (void *)&cmd_config_thresh_keyword,
2324 (void *)&cmd_config_thresh_all,
2325 (void *)&cmd_config_thresh_name,
2326 (void *)&cmd_config_thresh_value,
2331 /* *** configure free/rs threshold *** */
2332 struct cmd_config_threshold {
2333 cmdline_fixed_string_t port;
2334 cmdline_fixed_string_t keyword;
2335 cmdline_fixed_string_t all;
2336 cmdline_fixed_string_t name;
2341 cmd_config_threshold_parsed(void *parsed_result,
2342 __attribute__((unused)) struct cmdline *cl,
2343 __attribute__((unused)) void *data)
2345 struct cmd_config_threshold *res = parsed_result;
2347 if (!all_ports_stopped()) {
2348 printf("Please stop all ports first\n");
2352 if (!strcmp(res->name, "txfreet"))
2353 tx_free_thresh = res->value;
2354 else if (!strcmp(res->name, "txrst"))
2355 tx_rs_thresh = res->value;
2356 else if (!strcmp(res->name, "rxfreet"))
2357 rx_free_thresh = res->value;
2359 printf("Unknown parameter\n");
2365 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2368 cmdline_parse_token_string_t cmd_config_threshold_port =
2369 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2370 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2371 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2373 cmdline_parse_token_string_t cmd_config_threshold_all =
2374 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2375 cmdline_parse_token_string_t cmd_config_threshold_name =
2376 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2377 "txfreet#txrst#rxfreet");
2378 cmdline_parse_token_num_t cmd_config_threshold_value =
2379 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2381 cmdline_parse_inst_t cmd_config_threshold = {
2382 .f = cmd_config_threshold_parsed,
2384 .help_str = "port config all txfreet|txrst|rxfreet value",
2386 (void *)&cmd_config_threshold_port,
2387 (void *)&cmd_config_threshold_keyword,
2388 (void *)&cmd_config_threshold_all,
2389 (void *)&cmd_config_threshold_name,
2390 (void *)&cmd_config_threshold_value,
2396 struct cmd_stop_result {
2397 cmdline_fixed_string_t stop;
2400 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2401 __attribute__((unused)) struct cmdline *cl,
2402 __attribute__((unused)) void *data)
2404 stop_packet_forwarding();
2407 cmdline_parse_token_string_t cmd_stop_stop =
2408 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2410 cmdline_parse_inst_t cmd_stop = {
2411 .f = cmd_stop_parsed,
2413 .help_str = "stop - stop packet forwarding",
2415 (void *)&cmd_stop_stop,
2420 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2423 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2424 unsigned int *parsed_items, int check_unique_values)
2426 unsigned int nb_item;
2434 * First parse all items in the list and store their value.
2439 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2441 if ((c >= '0') && (c <= '9')) {
2442 value = (unsigned int) (value * 10 + (c - '0'));
2447 printf("character %c is not a decimal digit\n", c);
2451 printf("No valid value before comma\n");
2454 if (nb_item < max_items) {
2455 parsed_items[nb_item] = value;
2461 if (nb_item >= max_items) {
2462 printf("Number of %s = %u > %u (maximum items)\n",
2463 item_name, nb_item + 1, max_items);
2466 parsed_items[nb_item++] = value;
2467 if (! check_unique_values)
2471 * Then, check that all values in the list are differents.
2472 * No optimization here...
2474 for (i = 0; i < nb_item; i++) {
2475 for (j = i + 1; j < nb_item; j++) {
2476 if (parsed_items[j] == parsed_items[i]) {
2477 printf("duplicated %s %u at index %u and %u\n",
2478 item_name, parsed_items[i], i, j);
2486 struct cmd_set_list_result {
2487 cmdline_fixed_string_t cmd_keyword;
2488 cmdline_fixed_string_t list_name;
2489 cmdline_fixed_string_t list_of_items;
2492 static void cmd_set_list_parsed(void *parsed_result,
2493 __attribute__((unused)) struct cmdline *cl,
2494 __attribute__((unused)) void *data)
2496 struct cmd_set_list_result *res;
2498 unsigned int lcorelist[RTE_MAX_LCORE];
2499 unsigned int portlist[RTE_MAX_ETHPORTS];
2501 unsigned int nb_item;
2503 if (test_done == 0) {
2504 printf("Please stop forwarding first\n");
2508 res = parsed_result;
2509 if (!strcmp(res->list_name, "corelist")) {
2510 nb_item = parse_item_list(res->list_of_items, "core",
2512 parsed_items.lcorelist, 1);
2514 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2517 if (!strcmp(res->list_name, "portlist")) {
2518 nb_item = parse_item_list(res->list_of_items, "port",
2520 parsed_items.portlist, 1);
2522 set_fwd_ports_list(parsed_items.portlist, nb_item);
2526 cmdline_parse_token_string_t cmd_set_list_keyword =
2527 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2529 cmdline_parse_token_string_t cmd_set_list_name =
2530 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2531 "corelist#portlist");
2532 cmdline_parse_token_string_t cmd_set_list_of_items =
2533 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2536 cmdline_parse_inst_t cmd_set_fwd_list = {
2537 .f = cmd_set_list_parsed,
2539 .help_str = "set corelist|portlist x[,y]*",
2541 (void *)&cmd_set_list_keyword,
2542 (void *)&cmd_set_list_name,
2543 (void *)&cmd_set_list_of_items,
2548 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2550 struct cmd_setmask_result {
2551 cmdline_fixed_string_t set;
2552 cmdline_fixed_string_t mask;
2556 static void cmd_set_mask_parsed(void *parsed_result,
2557 __attribute__((unused)) struct cmdline *cl,
2558 __attribute__((unused)) void *data)
2560 struct cmd_setmask_result *res = parsed_result;
2562 if (test_done == 0) {
2563 printf("Please stop forwarding first\n");
2566 if (!strcmp(res->mask, "coremask"))
2567 set_fwd_lcores_mask(res->hexavalue);
2568 else if (!strcmp(res->mask, "portmask"))
2569 set_fwd_ports_mask(res->hexavalue);
2572 cmdline_parse_token_string_t cmd_setmask_set =
2573 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2574 cmdline_parse_token_string_t cmd_setmask_mask =
2575 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2576 "coremask#portmask");
2577 cmdline_parse_token_num_t cmd_setmask_value =
2578 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2580 cmdline_parse_inst_t cmd_set_fwd_mask = {
2581 .f = cmd_set_mask_parsed,
2583 .help_str = "set coremask|portmask hexadecimal value",
2585 (void *)&cmd_setmask_set,
2586 (void *)&cmd_setmask_mask,
2587 (void *)&cmd_setmask_value,
2593 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2595 struct cmd_set_result {
2596 cmdline_fixed_string_t set;
2597 cmdline_fixed_string_t what;
2601 static void cmd_set_parsed(void *parsed_result,
2602 __attribute__((unused)) struct cmdline *cl,
2603 __attribute__((unused)) void *data)
2605 struct cmd_set_result *res = parsed_result;
2606 if (!strcmp(res->what, "nbport"))
2607 set_fwd_ports_number(res->value);
2608 else if (!strcmp(res->what, "nbcore"))
2609 set_fwd_lcores_number(res->value);
2610 else if (!strcmp(res->what, "burst"))
2611 set_nb_pkt_per_burst(res->value);
2612 else if (!strcmp(res->what, "verbose"))
2613 set_verbose_level(res->value);
2616 cmdline_parse_token_string_t cmd_set_set =
2617 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2618 cmdline_parse_token_string_t cmd_set_what =
2619 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2620 "nbport#nbcore#burst#verbose");
2621 cmdline_parse_token_num_t cmd_set_value =
2622 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2624 cmdline_parse_inst_t cmd_set_numbers = {
2625 .f = cmd_set_parsed,
2627 .help_str = "set nbport|nbcore|burst|verbose value",
2629 (void *)&cmd_set_set,
2630 (void *)&cmd_set_what,
2631 (void *)&cmd_set_value,
2636 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2638 struct cmd_set_txpkts_result {
2639 cmdline_fixed_string_t cmd_keyword;
2640 cmdline_fixed_string_t txpkts;
2641 cmdline_fixed_string_t seg_lengths;
2645 cmd_set_txpkts_parsed(void *parsed_result,
2646 __attribute__((unused)) struct cmdline *cl,
2647 __attribute__((unused)) void *data)
2649 struct cmd_set_txpkts_result *res;
2650 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2651 unsigned int nb_segs;
2653 res = parsed_result;
2654 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2655 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2657 set_tx_pkt_segments(seg_lengths, nb_segs);
2660 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2661 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2662 cmd_keyword, "set");
2663 cmdline_parse_token_string_t cmd_set_txpkts_name =
2664 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2666 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2667 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2670 cmdline_parse_inst_t cmd_set_txpkts = {
2671 .f = cmd_set_txpkts_parsed,
2673 .help_str = "set txpkts x[,y]*",
2675 (void *)&cmd_set_txpkts_keyword,
2676 (void *)&cmd_set_txpkts_name,
2677 (void *)&cmd_set_txpkts_lengths,
2682 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2684 struct cmd_set_txsplit_result {
2685 cmdline_fixed_string_t cmd_keyword;
2686 cmdline_fixed_string_t txsplit;
2687 cmdline_fixed_string_t mode;
2691 cmd_set_txsplit_parsed(void *parsed_result,
2692 __attribute__((unused)) struct cmdline *cl,
2693 __attribute__((unused)) void *data)
2695 struct cmd_set_txsplit_result *res;
2697 res = parsed_result;
2698 set_tx_pkt_split(res->mode);
2701 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2702 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2703 cmd_keyword, "set");
2704 cmdline_parse_token_string_t cmd_set_txsplit_name =
2705 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2706 txsplit, "txsplit");
2707 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2708 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2711 cmdline_parse_inst_t cmd_set_txsplit = {
2712 .f = cmd_set_txsplit_parsed,
2714 .help_str = "set txsplit on|off|rand",
2716 (void *)&cmd_set_txsplit_keyword,
2717 (void *)&cmd_set_txsplit_name,
2718 (void *)&cmd_set_txsplit_mode,
2723 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2724 struct cmd_rx_vlan_filter_all_result {
2725 cmdline_fixed_string_t rx_vlan;
2726 cmdline_fixed_string_t what;
2727 cmdline_fixed_string_t all;
2732 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2733 __attribute__((unused)) struct cmdline *cl,
2734 __attribute__((unused)) void *data)
2736 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2738 if (!strcmp(res->what, "add"))
2739 rx_vlan_all_filter_set(res->port_id, 1);
2741 rx_vlan_all_filter_set(res->port_id, 0);
2744 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2745 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2746 rx_vlan, "rx_vlan");
2747 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2748 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2750 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2751 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2753 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2754 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2757 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2758 .f = cmd_rx_vlan_filter_all_parsed,
2760 .help_str = "add/remove all identifiers to/from the set of VLAN "
2761 "Identifiers filtered by a port",
2763 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2764 (void *)&cmd_rx_vlan_filter_all_what,
2765 (void *)&cmd_rx_vlan_filter_all_all,
2766 (void *)&cmd_rx_vlan_filter_all_portid,
2771 /* *** VLAN OFFLOAD SET ON A PORT *** */
2772 struct cmd_vlan_offload_result {
2773 cmdline_fixed_string_t vlan;
2774 cmdline_fixed_string_t set;
2775 cmdline_fixed_string_t vlan_type;
2776 cmdline_fixed_string_t what;
2777 cmdline_fixed_string_t on;
2778 cmdline_fixed_string_t port_id;
2782 cmd_vlan_offload_parsed(void *parsed_result,
2783 __attribute__((unused)) struct cmdline *cl,
2784 __attribute__((unused)) void *data)
2787 struct cmd_vlan_offload_result *res = parsed_result;
2790 portid_t port_id = 0;
2794 len = strnlen(str, STR_TOKEN_SIZE);
2796 /* Get port_id first */
2804 tmp = strtoul(str, NULL, 0);
2805 /* If port_id greater that what portid_t can represent, return */
2806 if(tmp >= RTE_MAX_ETHPORTS)
2808 port_id = (portid_t)tmp;
2810 if (!strcmp(res->on, "on"))
2815 if (!strcmp(res->what, "strip"))
2816 rx_vlan_strip_set(port_id, on);
2817 else if(!strcmp(res->what, "stripq")){
2818 uint16_t queue_id = 0;
2820 /* No queue_id, return */
2822 printf("must specify (port,queue_id)\n");
2825 tmp = strtoul(str + i + 1, NULL, 0);
2826 /* If queue_id greater that what 16-bits can represent, return */
2830 queue_id = (uint16_t)tmp;
2831 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2833 else if (!strcmp(res->what, "filter"))
2834 rx_vlan_filter_set(port_id, on);
2836 vlan_extend_set(port_id, on);
2841 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2842 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2844 cmdline_parse_token_string_t cmd_vlan_offload_set =
2845 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2847 cmdline_parse_token_string_t cmd_vlan_offload_what =
2848 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2849 what, "strip#filter#qinq#stripq");
2850 cmdline_parse_token_string_t cmd_vlan_offload_on =
2851 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2853 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2854 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2857 cmdline_parse_inst_t cmd_vlan_offload = {
2858 .f = cmd_vlan_offload_parsed,
2860 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2861 " qinq(extended) for both rx/tx sides ",
2863 (void *)&cmd_vlan_offload_vlan,
2864 (void *)&cmd_vlan_offload_set,
2865 (void *)&cmd_vlan_offload_what,
2866 (void *)&cmd_vlan_offload_on,
2867 (void *)&cmd_vlan_offload_portid,
2872 /* *** VLAN TPID SET ON A PORT *** */
2873 struct cmd_vlan_tpid_result {
2874 cmdline_fixed_string_t vlan;
2875 cmdline_fixed_string_t set;
2876 cmdline_fixed_string_t vlan_type;
2877 cmdline_fixed_string_t what;
2883 cmd_vlan_tpid_parsed(void *parsed_result,
2884 __attribute__((unused)) struct cmdline *cl,
2885 __attribute__((unused)) void *data)
2887 struct cmd_vlan_tpid_result *res = parsed_result;
2888 enum rte_vlan_type vlan_type;
2890 if (!strcmp(res->vlan_type, "inner"))
2891 vlan_type = ETH_VLAN_TYPE_INNER;
2892 else if (!strcmp(res->vlan_type, "outer"))
2893 vlan_type = ETH_VLAN_TYPE_OUTER;
2895 printf("Unknown vlan type\n");
2898 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
2901 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2902 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2904 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2905 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2907 cmdline_parse_token_string_t cmd_vlan_type =
2908 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2909 vlan_type, "inner#outer");
2910 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2911 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2913 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2914 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2916 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2917 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2920 cmdline_parse_inst_t cmd_vlan_tpid = {
2921 .f = cmd_vlan_tpid_parsed,
2923 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
2926 (void *)&cmd_vlan_tpid_vlan,
2927 (void *)&cmd_vlan_tpid_set,
2928 (void *)&cmd_vlan_type,
2929 (void *)&cmd_vlan_tpid_what,
2930 (void *)&cmd_vlan_tpid_tpid,
2931 (void *)&cmd_vlan_tpid_portid,
2936 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2937 struct cmd_rx_vlan_filter_result {
2938 cmdline_fixed_string_t rx_vlan;
2939 cmdline_fixed_string_t what;
2945 cmd_rx_vlan_filter_parsed(void *parsed_result,
2946 __attribute__((unused)) struct cmdline *cl,
2947 __attribute__((unused)) void *data)
2949 struct cmd_rx_vlan_filter_result *res = parsed_result;
2951 if (!strcmp(res->what, "add"))
2952 rx_vft_set(res->port_id, res->vlan_id, 1);
2954 rx_vft_set(res->port_id, res->vlan_id, 0);
2957 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2958 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2959 rx_vlan, "rx_vlan");
2960 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2961 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2963 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2964 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2966 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2967 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2970 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2971 .f = cmd_rx_vlan_filter_parsed,
2973 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2974 "Identifiers filtered by a port",
2976 (void *)&cmd_rx_vlan_filter_rx_vlan,
2977 (void *)&cmd_rx_vlan_filter_what,
2978 (void *)&cmd_rx_vlan_filter_vlanid,
2979 (void *)&cmd_rx_vlan_filter_portid,
2984 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2985 struct cmd_tx_vlan_set_result {
2986 cmdline_fixed_string_t tx_vlan;
2987 cmdline_fixed_string_t set;
2993 cmd_tx_vlan_set_parsed(void *parsed_result,
2994 __attribute__((unused)) struct cmdline *cl,
2995 __attribute__((unused)) void *data)
2997 struct cmd_tx_vlan_set_result *res = parsed_result;
2999 tx_vlan_set(res->port_id, res->vlan_id);
3002 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3003 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3004 tx_vlan, "tx_vlan");
3005 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3006 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3008 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3009 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3011 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3012 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3015 cmdline_parse_inst_t cmd_tx_vlan_set = {
3016 .f = cmd_tx_vlan_set_parsed,
3018 .help_str = "enable hardware insertion of a single VLAN header "
3019 "with a given TAG Identifier in packets sent on a port",
3021 (void *)&cmd_tx_vlan_set_tx_vlan,
3022 (void *)&cmd_tx_vlan_set_set,
3023 (void *)&cmd_tx_vlan_set_portid,
3024 (void *)&cmd_tx_vlan_set_vlanid,
3029 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3030 struct cmd_tx_vlan_set_qinq_result {
3031 cmdline_fixed_string_t tx_vlan;
3032 cmdline_fixed_string_t set;
3035 uint16_t vlan_id_outer;
3039 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3040 __attribute__((unused)) struct cmdline *cl,
3041 __attribute__((unused)) void *data)
3043 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3045 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3048 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3049 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3050 tx_vlan, "tx_vlan");
3051 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3052 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3054 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3055 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3057 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3058 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3060 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3061 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3062 vlan_id_outer, UINT16);
3064 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3065 .f = cmd_tx_vlan_set_qinq_parsed,
3067 .help_str = "enable hardware insertion of double VLAN header "
3068 "with given TAG Identifiers in packets sent on a port",
3070 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3071 (void *)&cmd_tx_vlan_set_qinq_set,
3072 (void *)&cmd_tx_vlan_set_qinq_portid,
3073 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3074 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3079 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3080 struct cmd_tx_vlan_set_pvid_result {
3081 cmdline_fixed_string_t tx_vlan;
3082 cmdline_fixed_string_t set;
3083 cmdline_fixed_string_t pvid;
3086 cmdline_fixed_string_t mode;
3090 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3091 __attribute__((unused)) struct cmdline *cl,
3092 __attribute__((unused)) void *data)
3094 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3096 if (strcmp(res->mode, "on") == 0)
3097 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3099 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3102 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3103 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3104 tx_vlan, "tx_vlan");
3105 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3106 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3108 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3109 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3111 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3112 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3114 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3115 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3117 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3118 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3121 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3122 .f = cmd_tx_vlan_set_pvid_parsed,
3124 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3126 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3127 (void *)&cmd_tx_vlan_set_pvid_set,
3128 (void *)&cmd_tx_vlan_set_pvid_pvid,
3129 (void *)&cmd_tx_vlan_set_pvid_port_id,
3130 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3131 (void *)&cmd_tx_vlan_set_pvid_mode,
3136 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3137 struct cmd_tx_vlan_reset_result {
3138 cmdline_fixed_string_t tx_vlan;
3139 cmdline_fixed_string_t reset;
3144 cmd_tx_vlan_reset_parsed(void *parsed_result,
3145 __attribute__((unused)) struct cmdline *cl,
3146 __attribute__((unused)) void *data)
3148 struct cmd_tx_vlan_reset_result *res = parsed_result;
3150 tx_vlan_reset(res->port_id);
3153 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3154 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3155 tx_vlan, "tx_vlan");
3156 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3157 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3159 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3160 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3163 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3164 .f = cmd_tx_vlan_reset_parsed,
3166 .help_str = "disable hardware insertion of a VLAN header in packets "
3169 (void *)&cmd_tx_vlan_reset_tx_vlan,
3170 (void *)&cmd_tx_vlan_reset_reset,
3171 (void *)&cmd_tx_vlan_reset_portid,
3177 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3178 struct cmd_csum_result {
3179 cmdline_fixed_string_t csum;
3180 cmdline_fixed_string_t mode;
3181 cmdline_fixed_string_t proto;
3182 cmdline_fixed_string_t hwsw;
3187 csum_show(int port_id)
3189 struct rte_eth_dev_info dev_info;
3192 ol_flags = ports[port_id].tx_ol_flags;
3193 printf("Parse tunnel is %s\n",
3194 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3195 printf("IP checksum offload is %s\n",
3196 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3197 printf("UDP checksum offload is %s\n",
3198 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3199 printf("TCP checksum offload is %s\n",
3200 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3201 printf("SCTP checksum offload is %s\n",
3202 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3203 printf("Outer-Ip checksum offload is %s\n",
3204 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3206 /* display warnings if configuration is not supported by the NIC */
3207 rte_eth_dev_info_get(port_id, &dev_info);
3208 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3209 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3210 printf("Warning: hardware IP checksum enabled but not "
3211 "supported by port %d\n", port_id);
3213 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3214 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3215 printf("Warning: hardware UDP checksum enabled but not "
3216 "supported by port %d\n", port_id);
3218 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3219 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3220 printf("Warning: hardware TCP checksum enabled but not "
3221 "supported by port %d\n", port_id);
3223 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3224 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3225 printf("Warning: hardware SCTP checksum enabled but not "
3226 "supported by port %d\n", port_id);
3228 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3229 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3230 printf("Warning: hardware outer IP checksum enabled but not "
3231 "supported by port %d\n", port_id);
3236 cmd_csum_parsed(void *parsed_result,
3237 __attribute__((unused)) struct cmdline *cl,
3238 __attribute__((unused)) void *data)
3240 struct cmd_csum_result *res = parsed_result;
3244 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3245 printf("invalid port %d\n", res->port_id);
3249 if (!strcmp(res->mode, "set")) {
3251 if (!strcmp(res->hwsw, "hw"))
3254 if (!strcmp(res->proto, "ip")) {
3255 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3256 } else if (!strcmp(res->proto, "udp")) {
3257 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3258 } else if (!strcmp(res->proto, "tcp")) {
3259 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3260 } else if (!strcmp(res->proto, "sctp")) {
3261 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3262 } else if (!strcmp(res->proto, "outer-ip")) {
3263 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3267 ports[res->port_id].tx_ol_flags |= mask;
3269 ports[res->port_id].tx_ol_flags &= (~mask);
3271 csum_show(res->port_id);
3274 cmdline_parse_token_string_t cmd_csum_csum =
3275 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3277 cmdline_parse_token_string_t cmd_csum_mode =
3278 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3280 cmdline_parse_token_string_t cmd_csum_proto =
3281 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3282 proto, "ip#tcp#udp#sctp#outer-ip");
3283 cmdline_parse_token_string_t cmd_csum_hwsw =
3284 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3286 cmdline_parse_token_num_t cmd_csum_portid =
3287 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3290 cmdline_parse_inst_t cmd_csum_set = {
3291 .f = cmd_csum_parsed,
3293 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3294 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3296 (void *)&cmd_csum_csum,
3297 (void *)&cmd_csum_mode,
3298 (void *)&cmd_csum_proto,
3299 (void *)&cmd_csum_hwsw,
3300 (void *)&cmd_csum_portid,
3305 cmdline_parse_token_string_t cmd_csum_mode_show =
3306 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3309 cmdline_parse_inst_t cmd_csum_show = {
3310 .f = cmd_csum_parsed,
3312 .help_str = "show checksum offload configuration: csum show <port>",
3314 (void *)&cmd_csum_csum,
3315 (void *)&cmd_csum_mode_show,
3316 (void *)&cmd_csum_portid,
3321 /* Enable/disable tunnel parsing */
3322 struct cmd_csum_tunnel_result {
3323 cmdline_fixed_string_t csum;
3324 cmdline_fixed_string_t parse;
3325 cmdline_fixed_string_t onoff;
3330 cmd_csum_tunnel_parsed(void *parsed_result,
3331 __attribute__((unused)) struct cmdline *cl,
3332 __attribute__((unused)) void *data)
3334 struct cmd_csum_tunnel_result *res = parsed_result;
3336 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3339 if (!strcmp(res->onoff, "on"))
3340 ports[res->port_id].tx_ol_flags |=
3341 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3343 ports[res->port_id].tx_ol_flags &=
3344 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3346 csum_show(res->port_id);
3349 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3350 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3352 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3353 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3354 parse, "parse_tunnel");
3355 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3356 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3358 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3359 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3362 cmdline_parse_inst_t cmd_csum_tunnel = {
3363 .f = cmd_csum_tunnel_parsed,
3365 .help_str = "enable/disable parsing of tunnels for csum engine: "
3366 "csum parse_tunnel on|off <tx-port>",
3368 (void *)&cmd_csum_tunnel_csum,
3369 (void *)&cmd_csum_tunnel_parse,
3370 (void *)&cmd_csum_tunnel_onoff,
3371 (void *)&cmd_csum_tunnel_portid,
3376 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3377 struct cmd_tso_set_result {
3378 cmdline_fixed_string_t tso;
3379 cmdline_fixed_string_t mode;
3385 cmd_tso_set_parsed(void *parsed_result,
3386 __attribute__((unused)) struct cmdline *cl,
3387 __attribute__((unused)) void *data)
3389 struct cmd_tso_set_result *res = parsed_result;
3390 struct rte_eth_dev_info dev_info;
3392 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3395 if (!strcmp(res->mode, "set"))
3396 ports[res->port_id].tso_segsz = res->tso_segsz;
3398 if (ports[res->port_id].tso_segsz == 0)
3399 printf("TSO is disabled\n");
3401 printf("TSO segment size is %d\n",
3402 ports[res->port_id].tso_segsz);
3404 /* display warnings if configuration is not supported by the NIC */
3405 rte_eth_dev_info_get(res->port_id, &dev_info);
3406 if ((ports[res->port_id].tso_segsz != 0) &&
3407 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3408 printf("Warning: TSO enabled but not "
3409 "supported by port %d\n", res->port_id);
3413 cmdline_parse_token_string_t cmd_tso_set_tso =
3414 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3416 cmdline_parse_token_string_t cmd_tso_set_mode =
3417 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3419 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3420 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3422 cmdline_parse_token_num_t cmd_tso_set_portid =
3423 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3426 cmdline_parse_inst_t cmd_tso_set = {
3427 .f = cmd_tso_set_parsed,
3429 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3430 "tso set <tso_segsz> <port>",
3432 (void *)&cmd_tso_set_tso,
3433 (void *)&cmd_tso_set_mode,
3434 (void *)&cmd_tso_set_tso_segsz,
3435 (void *)&cmd_tso_set_portid,
3440 cmdline_parse_token_string_t cmd_tso_show_mode =
3441 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3445 cmdline_parse_inst_t cmd_tso_show = {
3446 .f = cmd_tso_set_parsed,
3448 .help_str = "Show TSO segment size for csum engine: "
3451 (void *)&cmd_tso_set_tso,
3452 (void *)&cmd_tso_show_mode,
3453 (void *)&cmd_tso_set_portid,
3458 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3459 struct cmd_set_flush_rx {
3460 cmdline_fixed_string_t set;
3461 cmdline_fixed_string_t flush_rx;
3462 cmdline_fixed_string_t mode;
3466 cmd_set_flush_rx_parsed(void *parsed_result,
3467 __attribute__((unused)) struct cmdline *cl,
3468 __attribute__((unused)) void *data)
3470 struct cmd_set_flush_rx *res = parsed_result;
3471 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3474 cmdline_parse_token_string_t cmd_setflushrx_set =
3475 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3477 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3478 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3479 flush_rx, "flush_rx");
3480 cmdline_parse_token_string_t cmd_setflushrx_mode =
3481 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3485 cmdline_parse_inst_t cmd_set_flush_rx = {
3486 .f = cmd_set_flush_rx_parsed,
3487 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3490 (void *)&cmd_setflushrx_set,
3491 (void *)&cmd_setflushrx_flush_rx,
3492 (void *)&cmd_setflushrx_mode,
3497 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3498 struct cmd_set_link_check {
3499 cmdline_fixed_string_t set;
3500 cmdline_fixed_string_t link_check;
3501 cmdline_fixed_string_t mode;
3505 cmd_set_link_check_parsed(void *parsed_result,
3506 __attribute__((unused)) struct cmdline *cl,
3507 __attribute__((unused)) void *data)
3509 struct cmd_set_link_check *res = parsed_result;
3510 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3513 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3514 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3516 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3517 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3518 link_check, "link_check");
3519 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3520 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3524 cmdline_parse_inst_t cmd_set_link_check = {
3525 .f = cmd_set_link_check_parsed,
3526 .help_str = "set link_check on|off: enable/disable link status check "
3527 "when starting/stopping a port",
3530 (void *)&cmd_setlinkcheck_set,
3531 (void *)&cmd_setlinkcheck_link_check,
3532 (void *)&cmd_setlinkcheck_mode,
3537 #ifdef RTE_NIC_BYPASS
3538 /* *** SET NIC BYPASS MODE *** */
3539 struct cmd_set_bypass_mode_result {
3540 cmdline_fixed_string_t set;
3541 cmdline_fixed_string_t bypass;
3542 cmdline_fixed_string_t mode;
3543 cmdline_fixed_string_t value;
3548 cmd_set_bypass_mode_parsed(void *parsed_result,
3549 __attribute__((unused)) struct cmdline *cl,
3550 __attribute__((unused)) void *data)
3552 struct cmd_set_bypass_mode_result *res = parsed_result;
3553 portid_t port_id = res->port_id;
3554 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3556 if (!bypass_is_supported(port_id))
3559 if (!strcmp(res->value, "bypass"))
3560 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3561 else if (!strcmp(res->value, "isolate"))
3562 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3564 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3566 /* Set the bypass mode for the relevant port. */
3567 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3568 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3572 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3573 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3575 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3576 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3578 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3579 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3581 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3582 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3583 value, "normal#bypass#isolate");
3584 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3585 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3588 cmdline_parse_inst_t cmd_set_bypass_mode = {
3589 .f = cmd_set_bypass_mode_parsed,
3590 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3591 "Set the NIC bypass mode for port_id",
3594 (void *)&cmd_setbypass_mode_set,
3595 (void *)&cmd_setbypass_mode_bypass,
3596 (void *)&cmd_setbypass_mode_mode,
3597 (void *)&cmd_setbypass_mode_value,
3598 (void *)&cmd_setbypass_mode_port,
3603 /* *** SET NIC BYPASS EVENT *** */
3604 struct cmd_set_bypass_event_result {
3605 cmdline_fixed_string_t set;
3606 cmdline_fixed_string_t bypass;
3607 cmdline_fixed_string_t event;
3608 cmdline_fixed_string_t event_value;
3609 cmdline_fixed_string_t mode;
3610 cmdline_fixed_string_t mode_value;
3615 cmd_set_bypass_event_parsed(void *parsed_result,
3616 __attribute__((unused)) struct cmdline *cl,
3617 __attribute__((unused)) void *data)
3620 struct cmd_set_bypass_event_result *res = parsed_result;
3621 portid_t port_id = res->port_id;
3622 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3623 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3625 if (!bypass_is_supported(port_id))
3628 if (!strcmp(res->event_value, "timeout"))
3629 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3630 else if (!strcmp(res->event_value, "os_on"))
3631 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3632 else if (!strcmp(res->event_value, "os_off"))
3633 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3634 else if (!strcmp(res->event_value, "power_on"))
3635 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3636 else if (!strcmp(res->event_value, "power_off"))
3637 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3639 bypass_event = RTE_BYPASS_EVENT_NONE;
3641 if (!strcmp(res->mode_value, "bypass"))
3642 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3643 else if (!strcmp(res->mode_value, "isolate"))
3644 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3646 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3648 /* Set the watchdog timeout. */
3649 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3652 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3653 (rc = rte_eth_dev_wd_timeout_store(port_id,
3654 bypass_timeout)) != 0) {
3655 printf("Failed to set timeout value %u "
3656 "for port %d, errto code: %d.\n",
3657 bypass_timeout, port_id, rc);
3661 /* Set the bypass event to transition to bypass mode. */
3662 if (0 != rte_eth_dev_bypass_event_store(port_id,
3663 bypass_event, bypass_mode)) {
3664 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3669 cmdline_parse_token_string_t cmd_setbypass_event_set =
3670 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3672 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3673 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3675 cmdline_parse_token_string_t cmd_setbypass_event_event =
3676 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3678 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3679 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3680 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3681 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3682 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3684 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3685 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3686 mode_value, "normal#bypass#isolate");
3687 cmdline_parse_token_num_t cmd_setbypass_event_port =
3688 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3691 cmdline_parse_inst_t cmd_set_bypass_event = {
3692 .f = cmd_set_bypass_event_parsed,
3693 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3694 "mode (normal|bypass|isolate) (port_id): "
3695 "Set the NIC bypass event mode for port_id",
3698 (void *)&cmd_setbypass_event_set,
3699 (void *)&cmd_setbypass_event_bypass,
3700 (void *)&cmd_setbypass_event_event,
3701 (void *)&cmd_setbypass_event_event_value,
3702 (void *)&cmd_setbypass_event_mode,
3703 (void *)&cmd_setbypass_event_mode_value,
3704 (void *)&cmd_setbypass_event_port,
3710 /* *** SET NIC BYPASS TIMEOUT *** */
3711 struct cmd_set_bypass_timeout_result {
3712 cmdline_fixed_string_t set;
3713 cmdline_fixed_string_t bypass;
3714 cmdline_fixed_string_t timeout;
3715 cmdline_fixed_string_t value;
3719 cmd_set_bypass_timeout_parsed(void *parsed_result,
3720 __attribute__((unused)) struct cmdline *cl,
3721 __attribute__((unused)) void *data)
3723 struct cmd_set_bypass_timeout_result *res = parsed_result;
3725 if (!strcmp(res->value, "1.5"))
3726 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3727 else if (!strcmp(res->value, "2"))
3728 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3729 else if (!strcmp(res->value, "3"))
3730 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3731 else if (!strcmp(res->value, "4"))
3732 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3733 else if (!strcmp(res->value, "8"))
3734 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3735 else if (!strcmp(res->value, "16"))
3736 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3737 else if (!strcmp(res->value, "32"))
3738 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3740 bypass_timeout = RTE_BYPASS_TMT_OFF;
3743 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3744 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3746 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3747 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3749 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3750 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3751 timeout, "timeout");
3752 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3753 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3754 value, "0#1.5#2#3#4#8#16#32");
3756 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3757 .f = cmd_set_bypass_timeout_parsed,
3758 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3759 "Set the NIC bypass watchdog timeout",
3762 (void *)&cmd_setbypass_timeout_set,
3763 (void *)&cmd_setbypass_timeout_bypass,
3764 (void *)&cmd_setbypass_timeout_timeout,
3765 (void *)&cmd_setbypass_timeout_value,
3770 /* *** SHOW NIC BYPASS MODE *** */
3771 struct cmd_show_bypass_config_result {
3772 cmdline_fixed_string_t show;
3773 cmdline_fixed_string_t bypass;
3774 cmdline_fixed_string_t config;
3779 cmd_show_bypass_config_parsed(void *parsed_result,
3780 __attribute__((unused)) struct cmdline *cl,
3781 __attribute__((unused)) void *data)
3783 struct cmd_show_bypass_config_result *res = parsed_result;
3784 uint32_t event_mode;
3785 uint32_t bypass_mode;
3786 portid_t port_id = res->port_id;
3787 uint32_t timeout = bypass_timeout;
3790 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3791 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3792 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3793 {"UNKNOWN", "normal", "bypass", "isolate"};
3794 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3801 int num_events = (sizeof events) / (sizeof events[0]);
3803 if (!bypass_is_supported(port_id))
3806 /* Display the bypass mode.*/
3807 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3808 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3812 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3813 bypass_mode = RTE_BYPASS_MODE_NONE;
3815 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3818 /* Display the bypass timeout.*/
3819 if (!RTE_BYPASS_TMT_VALID(timeout))
3820 timeout = RTE_BYPASS_TMT_OFF;
3822 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3824 /* Display the bypass events and associated modes. */
3825 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3827 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3828 printf("\tFailed to get bypass mode for event = %s\n",
3831 if (!RTE_BYPASS_MODE_VALID(event_mode))
3832 event_mode = RTE_BYPASS_MODE_NONE;
3834 printf("\tbypass event: %-16s = %s\n", events[i],
3840 cmdline_parse_token_string_t cmd_showbypass_config_show =
3841 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3843 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3844 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3846 cmdline_parse_token_string_t cmd_showbypass_config_config =
3847 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3849 cmdline_parse_token_num_t cmd_showbypass_config_port =
3850 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3853 cmdline_parse_inst_t cmd_show_bypass_config = {
3854 .f = cmd_show_bypass_config_parsed,
3855 .help_str = "show bypass config (port_id): "
3856 "Show the NIC bypass config for port_id",
3859 (void *)&cmd_showbypass_config_show,
3860 (void *)&cmd_showbypass_config_bypass,
3861 (void *)&cmd_showbypass_config_config,
3862 (void *)&cmd_showbypass_config_port,
3868 #ifdef RTE_LIBRTE_PMD_BOND
3869 /* *** SET BONDING MODE *** */
3870 struct cmd_set_bonding_mode_result {
3871 cmdline_fixed_string_t set;
3872 cmdline_fixed_string_t bonding;
3873 cmdline_fixed_string_t mode;
3878 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3879 __attribute__((unused)) struct cmdline *cl,
3880 __attribute__((unused)) void *data)
3882 struct cmd_set_bonding_mode_result *res = parsed_result;
3883 portid_t port_id = res->port_id;
3885 /* Set the bonding mode for the relevant port. */
3886 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3887 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3890 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3893 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3894 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3895 bonding, "bonding");
3896 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3897 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3899 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3900 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3902 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3903 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3906 cmdline_parse_inst_t cmd_set_bonding_mode = {
3907 .f = cmd_set_bonding_mode_parsed,
3908 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3911 (void *) &cmd_setbonding_mode_set,
3912 (void *) &cmd_setbonding_mode_bonding,
3913 (void *) &cmd_setbonding_mode_mode,
3914 (void *) &cmd_setbonding_mode_value,
3915 (void *) &cmd_setbonding_mode_port,
3920 /* *** SET BALANCE XMIT POLICY *** */
3921 struct cmd_set_bonding_balance_xmit_policy_result {
3922 cmdline_fixed_string_t set;
3923 cmdline_fixed_string_t bonding;
3924 cmdline_fixed_string_t balance_xmit_policy;
3926 cmdline_fixed_string_t policy;
3929 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3930 __attribute__((unused)) struct cmdline *cl,
3931 __attribute__((unused)) void *data)
3933 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3934 portid_t port_id = res->port_id;
3937 if (!strcmp(res->policy, "l2")) {
3938 policy = BALANCE_XMIT_POLICY_LAYER2;
3939 } else if (!strcmp(res->policy, "l23")) {
3940 policy = BALANCE_XMIT_POLICY_LAYER23;
3941 } else if (!strcmp(res->policy, "l34")) {
3942 policy = BALANCE_XMIT_POLICY_LAYER34;
3944 printf("\t Invalid xmit policy selection");
3948 /* Set the bonding mode for the relevant port. */
3949 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3950 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3955 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3956 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3958 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3959 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3960 bonding, "bonding");
3961 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3962 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3963 balance_xmit_policy, "balance_xmit_policy");
3964 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3965 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3967 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3969 policy, "l2#l23#l34");
3971 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3972 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3973 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3976 (void *)&cmd_setbonding_balance_xmit_policy_set,
3977 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3978 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3979 (void *)&cmd_setbonding_balance_xmit_policy_port,
3980 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3985 /* *** SHOW NIC BONDING CONFIGURATION *** */
3986 struct cmd_show_bonding_config_result {
3987 cmdline_fixed_string_t show;
3988 cmdline_fixed_string_t bonding;
3989 cmdline_fixed_string_t config;
3993 static void cmd_show_bonding_config_parsed(void *parsed_result,
3994 __attribute__((unused)) struct cmdline *cl,
3995 __attribute__((unused)) void *data)
3997 struct cmd_show_bonding_config_result *res = parsed_result;
3999 uint8_t slaves[RTE_MAX_ETHPORTS];
4000 int num_slaves, num_active_slaves;
4003 portid_t port_id = res->port_id;
4005 /* Display the bonding mode.*/
4006 bonding_mode = rte_eth_bond_mode_get(port_id);
4007 if (bonding_mode < 0) {
4008 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4011 printf("\tBonding mode: %d\n", bonding_mode);
4013 if (bonding_mode == BONDING_MODE_BALANCE) {
4014 int balance_xmit_policy;
4016 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4017 if (balance_xmit_policy < 0) {
4018 printf("\tFailed to get balance xmit policy for port = %d\n",
4022 printf("\tBalance Xmit Policy: ");
4024 switch (balance_xmit_policy) {
4025 case BALANCE_XMIT_POLICY_LAYER2:
4026 printf("BALANCE_XMIT_POLICY_LAYER2");
4028 case BALANCE_XMIT_POLICY_LAYER23:
4029 printf("BALANCE_XMIT_POLICY_LAYER23");
4031 case BALANCE_XMIT_POLICY_LAYER34:
4032 printf("BALANCE_XMIT_POLICY_LAYER34");
4039 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4041 if (num_slaves < 0) {
4042 printf("\tFailed to get slave list for port = %d\n", port_id);
4045 if (num_slaves > 0) {
4046 printf("\tSlaves (%d): [", num_slaves);
4047 for (i = 0; i < num_slaves - 1; i++)
4048 printf("%d ", slaves[i]);
4050 printf("%d]\n", slaves[num_slaves - 1]);
4052 printf("\tSlaves: []\n");
4056 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4059 if (num_active_slaves < 0) {
4060 printf("\tFailed to get active slave list for port = %d\n", port_id);
4063 if (num_active_slaves > 0) {
4064 printf("\tActive Slaves (%d): [", num_active_slaves);
4065 for (i = 0; i < num_active_slaves - 1; i++)
4066 printf("%d ", slaves[i]);
4068 printf("%d]\n", slaves[num_active_slaves - 1]);
4071 printf("\tActive Slaves: []\n");
4075 primary_id = rte_eth_bond_primary_get(port_id);
4076 if (primary_id < 0) {
4077 printf("\tFailed to get primary slave for port = %d\n", port_id);
4080 printf("\tPrimary: [%d]\n", primary_id);
4084 cmdline_parse_token_string_t cmd_showbonding_config_show =
4085 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4087 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4088 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4089 bonding, "bonding");
4090 cmdline_parse_token_string_t cmd_showbonding_config_config =
4091 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4093 cmdline_parse_token_num_t cmd_showbonding_config_port =
4094 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4097 cmdline_parse_inst_t cmd_show_bonding_config = {
4098 .f = cmd_show_bonding_config_parsed,
4099 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4102 (void *)&cmd_showbonding_config_show,
4103 (void *)&cmd_showbonding_config_bonding,
4104 (void *)&cmd_showbonding_config_config,
4105 (void *)&cmd_showbonding_config_port,
4110 /* *** SET BONDING PRIMARY *** */
4111 struct cmd_set_bonding_primary_result {
4112 cmdline_fixed_string_t set;
4113 cmdline_fixed_string_t bonding;
4114 cmdline_fixed_string_t primary;
4119 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4120 __attribute__((unused)) struct cmdline *cl,
4121 __attribute__((unused)) void *data)
4123 struct cmd_set_bonding_primary_result *res = parsed_result;
4124 portid_t master_port_id = res->port_id;
4125 portid_t slave_port_id = res->slave_id;
4127 /* Set the primary slave for a bonded device. */
4128 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4129 printf("\t Failed to set primary slave for port = %d.\n",
4136 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4137 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4139 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4140 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4141 bonding, "bonding");
4142 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4143 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4144 primary, "primary");
4145 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4146 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4148 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4149 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4152 cmdline_parse_inst_t cmd_set_bonding_primary = {
4153 .f = cmd_set_bonding_primary_parsed,
4154 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4157 (void *)&cmd_setbonding_primary_set,
4158 (void *)&cmd_setbonding_primary_bonding,
4159 (void *)&cmd_setbonding_primary_primary,
4160 (void *)&cmd_setbonding_primary_slave,
4161 (void *)&cmd_setbonding_primary_port,
4166 /* *** ADD SLAVE *** */
4167 struct cmd_add_bonding_slave_result {
4168 cmdline_fixed_string_t add;
4169 cmdline_fixed_string_t bonding;
4170 cmdline_fixed_string_t slave;
4175 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4176 __attribute__((unused)) struct cmdline *cl,
4177 __attribute__((unused)) void *data)
4179 struct cmd_add_bonding_slave_result *res = parsed_result;
4180 portid_t master_port_id = res->port_id;
4181 portid_t slave_port_id = res->slave_id;
4183 /* Set the primary slave for a bonded device. */
4184 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4185 printf("\t Failed to add slave %d to master port = %d.\n",
4186 slave_port_id, master_port_id);
4190 set_port_slave_flag(slave_port_id);
4193 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4194 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4196 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4197 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4198 bonding, "bonding");
4199 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4200 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4202 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4203 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4205 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4206 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4209 cmdline_parse_inst_t cmd_add_bonding_slave = {
4210 .f = cmd_add_bonding_slave_parsed,
4211 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4214 (void *)&cmd_addbonding_slave_add,
4215 (void *)&cmd_addbonding_slave_bonding,
4216 (void *)&cmd_addbonding_slave_slave,
4217 (void *)&cmd_addbonding_slave_slaveid,
4218 (void *)&cmd_addbonding_slave_port,
4223 /* *** REMOVE SLAVE *** */
4224 struct cmd_remove_bonding_slave_result {
4225 cmdline_fixed_string_t remove;
4226 cmdline_fixed_string_t bonding;
4227 cmdline_fixed_string_t slave;
4232 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4233 __attribute__((unused)) struct cmdline *cl,
4234 __attribute__((unused)) void *data)
4236 struct cmd_remove_bonding_slave_result *res = parsed_result;
4237 portid_t master_port_id = res->port_id;
4238 portid_t slave_port_id = res->slave_id;
4240 /* Set the primary slave for a bonded device. */
4241 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4242 printf("\t Failed to remove slave %d from master port = %d.\n",
4243 slave_port_id, master_port_id);
4247 clear_port_slave_flag(slave_port_id);
4250 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4251 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4253 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4254 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4255 bonding, "bonding");
4256 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4257 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4259 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4260 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4262 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4263 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4266 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4267 .f = cmd_remove_bonding_slave_parsed,
4268 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4271 (void *)&cmd_removebonding_slave_remove,
4272 (void *)&cmd_removebonding_slave_bonding,
4273 (void *)&cmd_removebonding_slave_slave,
4274 (void *)&cmd_removebonding_slave_slaveid,
4275 (void *)&cmd_removebonding_slave_port,
4280 /* *** CREATE BONDED DEVICE *** */
4281 struct cmd_create_bonded_device_result {
4282 cmdline_fixed_string_t create;
4283 cmdline_fixed_string_t bonded;
4284 cmdline_fixed_string_t device;
4289 static int bond_dev_num = 0;
4291 static void cmd_create_bonded_device_parsed(void *parsed_result,
4292 __attribute__((unused)) struct cmdline *cl,
4293 __attribute__((unused)) void *data)
4295 struct cmd_create_bonded_device_result *res = parsed_result;
4296 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4299 if (test_done == 0) {
4300 printf("Please stop forwarding first\n");
4304 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4307 /* Create a new bonded device. */
4308 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4310 printf("\t Failed to create bonded device.\n");
4313 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4316 /* Update number of ports */
4317 nb_ports = rte_eth_dev_count();
4318 reconfig(port_id, res->socket);
4319 rte_eth_promiscuous_enable(port_id);
4320 ports[port_id].enabled = 1;
4325 cmdline_parse_token_string_t cmd_createbonded_device_create =
4326 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4328 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4329 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4331 cmdline_parse_token_string_t cmd_createbonded_device_device =
4332 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4334 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4335 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4337 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4338 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4341 cmdline_parse_inst_t cmd_create_bonded_device = {
4342 .f = cmd_create_bonded_device_parsed,
4343 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4346 (void *)&cmd_createbonded_device_create,
4347 (void *)&cmd_createbonded_device_bonded,
4348 (void *)&cmd_createbonded_device_device,
4349 (void *)&cmd_createbonded_device_mode,
4350 (void *)&cmd_createbonded_device_socket,
4355 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4356 struct cmd_set_bond_mac_addr_result {
4357 cmdline_fixed_string_t set;
4358 cmdline_fixed_string_t bonding;
4359 cmdline_fixed_string_t mac_addr;
4361 struct ether_addr address;
4364 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4365 __attribute__((unused)) struct cmdline *cl,
4366 __attribute__((unused)) void *data)
4368 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4371 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4374 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4376 /* check the return value and print it if is < 0 */
4378 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4381 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4382 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4383 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4384 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4386 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4387 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4389 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4390 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4391 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4392 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4394 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4395 .f = cmd_set_bond_mac_addr_parsed,
4397 .help_str = "set bonding mac_addr (port_id) (address): ",
4399 (void *)&cmd_set_bond_mac_addr_set,
4400 (void *)&cmd_set_bond_mac_addr_bonding,
4401 (void *)&cmd_set_bond_mac_addr_mac,
4402 (void *)&cmd_set_bond_mac_addr_portnum,
4403 (void *)&cmd_set_bond_mac_addr_addr,
4409 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4410 struct cmd_set_bond_mon_period_result {
4411 cmdline_fixed_string_t set;
4412 cmdline_fixed_string_t bonding;
4413 cmdline_fixed_string_t mon_period;
4418 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4419 __attribute__((unused)) struct cmdline *cl,
4420 __attribute__((unused)) void *data)
4422 struct cmd_set_bond_mon_period_result *res = parsed_result;
4425 if (res->port_num >= nb_ports) {
4426 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4430 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4432 /* check the return value and print it if is < 0 */
4434 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4437 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4438 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4440 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4441 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4442 bonding, "bonding");
4443 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4444 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4445 mon_period, "mon_period");
4446 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4447 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4449 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4450 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4453 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4454 .f = cmd_set_bond_mon_period_parsed,
4456 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4458 (void *)&cmd_set_bond_mon_period_set,
4459 (void *)&cmd_set_bond_mon_period_bonding,
4460 (void *)&cmd_set_bond_mon_period_mon_period,
4461 (void *)&cmd_set_bond_mon_period_portnum,
4462 (void *)&cmd_set_bond_mon_period_period_ms,
4467 #endif /* RTE_LIBRTE_PMD_BOND */
4469 /* *** SET FORWARDING MODE *** */
4470 struct cmd_set_fwd_mode_result {
4471 cmdline_fixed_string_t set;
4472 cmdline_fixed_string_t fwd;
4473 cmdline_fixed_string_t mode;
4476 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4477 __attribute__((unused)) struct cmdline *cl,
4478 __attribute__((unused)) void *data)
4480 struct cmd_set_fwd_mode_result *res = parsed_result;
4482 set_pkt_forwarding_mode(res->mode);
4485 cmdline_parse_token_string_t cmd_setfwd_set =
4486 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4487 cmdline_parse_token_string_t cmd_setfwd_fwd =
4488 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4489 cmdline_parse_token_string_t cmd_setfwd_mode =
4490 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4491 "" /* defined at init */);
4493 cmdline_parse_inst_t cmd_set_fwd_mode = {
4494 .f = cmd_set_fwd_mode_parsed,
4496 .help_str = NULL, /* defined at init */
4498 (void *)&cmd_setfwd_set,
4499 (void *)&cmd_setfwd_fwd,
4500 (void *)&cmd_setfwd_mode,
4505 static void cmd_set_fwd_mode_init(void)
4508 static char token[128];
4509 static char help[256];
4510 cmdline_parse_token_string_t *token_struct;
4512 modes = list_pkt_forwarding_modes();
4513 snprintf(help, sizeof help, "set fwd %s - "
4514 "set packet forwarding mode", modes);
4515 cmd_set_fwd_mode.help_str = help;
4517 /* string token separator is # */
4518 for (c = token; *modes != '\0'; modes++)
4523 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4524 token_struct->string_data.str = token;
4527 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4528 struct cmd_set_burst_tx_retry_result {
4529 cmdline_fixed_string_t set;
4530 cmdline_fixed_string_t burst;
4531 cmdline_fixed_string_t tx;
4532 cmdline_fixed_string_t delay;
4534 cmdline_fixed_string_t retry;
4538 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4539 __attribute__((unused)) struct cmdline *cl,
4540 __attribute__((unused)) void *data)
4542 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4544 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4545 && !strcmp(res->tx, "tx")) {
4546 if (!strcmp(res->delay, "delay"))
4547 burst_tx_delay_time = res->time;
4548 if (!strcmp(res->retry, "retry"))
4549 burst_tx_retry_num = res->retry_num;
4554 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4555 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4556 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4557 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4559 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4560 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4561 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4562 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4563 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4564 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4565 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4566 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4567 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4568 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4570 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4571 .f = cmd_set_burst_tx_retry_parsed,
4572 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4574 (void *)&cmd_set_burst_tx_retry_set,
4575 (void *)&cmd_set_burst_tx_retry_burst,
4576 (void *)&cmd_set_burst_tx_retry_tx,
4577 (void *)&cmd_set_burst_tx_retry_delay,
4578 (void *)&cmd_set_burst_tx_retry_time,
4579 (void *)&cmd_set_burst_tx_retry_retry,
4580 (void *)&cmd_set_burst_tx_retry_retry_num,
4585 /* *** SET PROMISC MODE *** */
4586 struct cmd_set_promisc_mode_result {
4587 cmdline_fixed_string_t set;
4588 cmdline_fixed_string_t promisc;
4589 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4590 uint8_t port_num; /* valid if "allports" argument == 0 */
4591 cmdline_fixed_string_t mode;
4594 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4595 __attribute__((unused)) struct cmdline *cl,
4598 struct cmd_set_promisc_mode_result *res = parsed_result;
4602 if (!strcmp(res->mode, "on"))
4609 FOREACH_PORT(i, ports) {
4611 rte_eth_promiscuous_enable(i);
4613 rte_eth_promiscuous_disable(i);
4618 rte_eth_promiscuous_enable(res->port_num);
4620 rte_eth_promiscuous_disable(res->port_num);
4624 cmdline_parse_token_string_t cmd_setpromisc_set =
4625 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4626 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4627 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4629 cmdline_parse_token_string_t cmd_setpromisc_portall =
4630 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4632 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4633 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4635 cmdline_parse_token_string_t cmd_setpromisc_mode =
4636 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4639 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4640 .f = cmd_set_promisc_mode_parsed,
4642 .help_str = "set promisc all on|off: set promisc mode for all ports",
4644 (void *)&cmd_setpromisc_set,
4645 (void *)&cmd_setpromisc_promisc,
4646 (void *)&cmd_setpromisc_portall,
4647 (void *)&cmd_setpromisc_mode,
4652 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4653 .f = cmd_set_promisc_mode_parsed,
4655 .help_str = "set promisc X on|off: set promisc mode on port X",
4657 (void *)&cmd_setpromisc_set,
4658 (void *)&cmd_setpromisc_promisc,
4659 (void *)&cmd_setpromisc_portnum,
4660 (void *)&cmd_setpromisc_mode,
4665 /* *** SET ALLMULTI MODE *** */
4666 struct cmd_set_allmulti_mode_result {
4667 cmdline_fixed_string_t set;
4668 cmdline_fixed_string_t allmulti;
4669 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4670 uint8_t port_num; /* valid if "allports" argument == 0 */
4671 cmdline_fixed_string_t mode;
4674 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4675 __attribute__((unused)) struct cmdline *cl,
4678 struct cmd_set_allmulti_mode_result *res = parsed_result;
4682 if (!strcmp(res->mode, "on"))
4689 FOREACH_PORT(i, ports) {
4691 rte_eth_allmulticast_enable(i);
4693 rte_eth_allmulticast_disable(i);
4698 rte_eth_allmulticast_enable(res->port_num);
4700 rte_eth_allmulticast_disable(res->port_num);
4704 cmdline_parse_token_string_t cmd_setallmulti_set =
4705 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4706 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4707 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4709 cmdline_parse_token_string_t cmd_setallmulti_portall =
4710 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4712 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4713 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4715 cmdline_parse_token_string_t cmd_setallmulti_mode =
4716 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4719 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4720 .f = cmd_set_allmulti_mode_parsed,
4722 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4724 (void *)&cmd_setallmulti_set,
4725 (void *)&cmd_setallmulti_allmulti,
4726 (void *)&cmd_setallmulti_portall,
4727 (void *)&cmd_setallmulti_mode,
4732 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4733 .f = cmd_set_allmulti_mode_parsed,
4735 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4737 (void *)&cmd_setallmulti_set,
4738 (void *)&cmd_setallmulti_allmulti,
4739 (void *)&cmd_setallmulti_portnum,
4740 (void *)&cmd_setallmulti_mode,
4745 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4746 struct cmd_link_flow_ctrl_set_result {
4747 cmdline_fixed_string_t set;
4748 cmdline_fixed_string_t flow_ctrl;
4749 cmdline_fixed_string_t rx;
4750 cmdline_fixed_string_t rx_lfc_mode;
4751 cmdline_fixed_string_t tx;
4752 cmdline_fixed_string_t tx_lfc_mode;
4753 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4754 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4755 cmdline_fixed_string_t autoneg_str;
4756 cmdline_fixed_string_t autoneg;
4757 cmdline_fixed_string_t hw_str;
4758 uint32_t high_water;
4759 cmdline_fixed_string_t lw_str;
4761 cmdline_fixed_string_t pt_str;
4762 uint16_t pause_time;
4763 cmdline_fixed_string_t xon_str;
4768 cmdline_parse_token_string_t cmd_lfc_set_set =
4769 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4771 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4772 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4773 flow_ctrl, "flow_ctrl");
4774 cmdline_parse_token_string_t cmd_lfc_set_rx =
4775 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4777 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4779 rx_lfc_mode, "on#off");
4780 cmdline_parse_token_string_t cmd_lfc_set_tx =
4781 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4783 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4784 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4785 tx_lfc_mode, "on#off");
4786 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4787 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4788 hw_str, "high_water");
4789 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4790 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4791 high_water, UINT32);
4792 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4793 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4794 lw_str, "low_water");
4795 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4796 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4798 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4799 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4800 pt_str, "pause_time");
4801 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4802 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4803 pause_time, UINT16);
4804 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4805 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4806 xon_str, "send_xon");
4807 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4808 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4810 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4811 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4812 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4813 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4814 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4815 mac_ctrl_frame_fwd_mode, "on#off");
4816 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4817 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4818 autoneg_str, "autoneg");
4819 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4820 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4822 cmdline_parse_token_num_t cmd_lfc_set_portid =
4823 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4826 /* forward declaration */
4828 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4831 cmdline_parse_inst_t cmd_link_flow_control_set = {
4832 .f = cmd_link_flow_ctrl_set_parsed,
4834 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4835 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4836 autoneg on|off port_id",
4838 (void *)&cmd_lfc_set_set,
4839 (void *)&cmd_lfc_set_flow_ctrl,
4840 (void *)&cmd_lfc_set_rx,
4841 (void *)&cmd_lfc_set_rx_mode,
4842 (void *)&cmd_lfc_set_tx,
4843 (void *)&cmd_lfc_set_tx_mode,
4844 (void *)&cmd_lfc_set_high_water,
4845 (void *)&cmd_lfc_set_low_water,
4846 (void *)&cmd_lfc_set_pause_time,
4847 (void *)&cmd_lfc_set_send_xon,
4848 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4849 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4850 (void *)&cmd_lfc_set_autoneg_str,
4851 (void *)&cmd_lfc_set_autoneg,
4852 (void *)&cmd_lfc_set_portid,
4857 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4858 .f = cmd_link_flow_ctrl_set_parsed,
4859 .data = (void *)&cmd_link_flow_control_set_rx,
4860 .help_str = "Change rx flow control parameter: set flow_ctrl "
4861 "rx on|off port_id",
4863 (void *)&cmd_lfc_set_set,
4864 (void *)&cmd_lfc_set_flow_ctrl,
4865 (void *)&cmd_lfc_set_rx,
4866 (void *)&cmd_lfc_set_rx_mode,
4867 (void *)&cmd_lfc_set_portid,
4872 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4873 .f = cmd_link_flow_ctrl_set_parsed,
4874 .data = (void *)&cmd_link_flow_control_set_tx,
4875 .help_str = "Change tx flow control parameter: set flow_ctrl "
4876 "tx on|off port_id",
4878 (void *)&cmd_lfc_set_set,
4879 (void *)&cmd_lfc_set_flow_ctrl,
4880 (void *)&cmd_lfc_set_tx,
4881 (void *)&cmd_lfc_set_tx_mode,
4882 (void *)&cmd_lfc_set_portid,
4887 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4888 .f = cmd_link_flow_ctrl_set_parsed,
4889 .data = (void *)&cmd_link_flow_control_set_hw,
4890 .help_str = "Change high water flow control parameter: set flow_ctrl "
4891 "high_water value port_id",
4893 (void *)&cmd_lfc_set_set,
4894 (void *)&cmd_lfc_set_flow_ctrl,
4895 (void *)&cmd_lfc_set_high_water_str,
4896 (void *)&cmd_lfc_set_high_water,
4897 (void *)&cmd_lfc_set_portid,
4902 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4903 .f = cmd_link_flow_ctrl_set_parsed,
4904 .data = (void *)&cmd_link_flow_control_set_lw,
4905 .help_str = "Change low water flow control parameter: set flow_ctrl "
4906 "low_water value port_id",
4908 (void *)&cmd_lfc_set_set,
4909 (void *)&cmd_lfc_set_flow_ctrl,
4910 (void *)&cmd_lfc_set_low_water_str,
4911 (void *)&cmd_lfc_set_low_water,
4912 (void *)&cmd_lfc_set_portid,
4917 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4918 .f = cmd_link_flow_ctrl_set_parsed,
4919 .data = (void *)&cmd_link_flow_control_set_pt,
4920 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4921 "pause_time value port_id",
4923 (void *)&cmd_lfc_set_set,
4924 (void *)&cmd_lfc_set_flow_ctrl,
4925 (void *)&cmd_lfc_set_pause_time_str,
4926 (void *)&cmd_lfc_set_pause_time,
4927 (void *)&cmd_lfc_set_portid,
4932 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4933 .f = cmd_link_flow_ctrl_set_parsed,
4934 .data = (void *)&cmd_link_flow_control_set_xon,
4935 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4936 "send_xon value port_id",
4938 (void *)&cmd_lfc_set_set,
4939 (void *)&cmd_lfc_set_flow_ctrl,
4940 (void *)&cmd_lfc_set_send_xon_str,
4941 (void *)&cmd_lfc_set_send_xon,
4942 (void *)&cmd_lfc_set_portid,
4947 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4948 .f = cmd_link_flow_ctrl_set_parsed,
4949 .data = (void *)&cmd_link_flow_control_set_macfwd,
4950 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4951 "mac_ctrl_frame_fwd on|off port_id",
4953 (void *)&cmd_lfc_set_set,
4954 (void *)&cmd_lfc_set_flow_ctrl,
4955 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4956 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4957 (void *)&cmd_lfc_set_portid,
4962 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4963 .f = cmd_link_flow_ctrl_set_parsed,
4964 .data = (void *)&cmd_link_flow_control_set_autoneg,
4965 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4966 "autoneg on|off port_id",
4968 (void *)&cmd_lfc_set_set,
4969 (void *)&cmd_lfc_set_flow_ctrl,
4970 (void *)&cmd_lfc_set_autoneg_str,
4971 (void *)&cmd_lfc_set_autoneg,
4972 (void *)&cmd_lfc_set_portid,
4978 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4979 __attribute__((unused)) struct cmdline *cl,
4982 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4983 cmdline_parse_inst_t *cmd = data;
4984 struct rte_eth_fc_conf fc_conf;
4990 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4991 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4992 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4993 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4995 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4996 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4999 /* Partial command line, retrieve current configuration */
5001 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5003 printf("cannot get current flow ctrl parameters, return"
5004 "code = %d\n", ret);
5008 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5009 (fc_conf.mode == RTE_FC_FULL))
5011 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5012 (fc_conf.mode == RTE_FC_FULL))
5016 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5017 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5019 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5020 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5022 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5024 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5025 fc_conf.high_water = res->high_water;
5027 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5028 fc_conf.low_water = res->low_water;
5030 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5031 fc_conf.pause_time = res->pause_time;
5033 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5034 fc_conf.send_xon = res->send_xon;
5036 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5037 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5038 fc_conf.mac_ctrl_frame_fwd = 1;
5040 fc_conf.mac_ctrl_frame_fwd = 0;
5043 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5044 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5046 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5048 printf("bad flow contrl parameter, return code = %d \n", ret);
5051 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5052 struct cmd_priority_flow_ctrl_set_result {
5053 cmdline_fixed_string_t set;
5054 cmdline_fixed_string_t pfc_ctrl;
5055 cmdline_fixed_string_t rx;
5056 cmdline_fixed_string_t rx_pfc_mode;
5057 cmdline_fixed_string_t tx;
5058 cmdline_fixed_string_t tx_pfc_mode;
5059 uint32_t high_water;
5061 uint16_t pause_time;
5067 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5068 __attribute__((unused)) struct cmdline *cl,
5069 __attribute__((unused)) void *data)
5071 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5072 struct rte_eth_pfc_conf pfc_conf;
5073 int rx_fc_enable, tx_fc_enable;
5077 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5078 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5079 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5080 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5082 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5083 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5086 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5087 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5088 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5089 pfc_conf.fc.high_water = res->high_water;
5090 pfc_conf.fc.low_water = res->low_water;
5091 pfc_conf.fc.pause_time = res->pause_time;
5092 pfc_conf.priority = res->priority;
5094 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5096 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5099 cmdline_parse_token_string_t cmd_pfc_set_set =
5100 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5102 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5103 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5104 pfc_ctrl, "pfc_ctrl");
5105 cmdline_parse_token_string_t cmd_pfc_set_rx =
5106 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5108 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5109 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5110 rx_pfc_mode, "on#off");
5111 cmdline_parse_token_string_t cmd_pfc_set_tx =
5112 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5114 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5115 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5116 tx_pfc_mode, "on#off");
5117 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5118 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5119 high_water, UINT32);
5120 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5121 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5123 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5124 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5125 pause_time, UINT16);
5126 cmdline_parse_token_num_t cmd_pfc_set_priority =
5127 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5129 cmdline_parse_token_num_t cmd_pfc_set_portid =
5130 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5133 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5134 .f = cmd_priority_flow_ctrl_set_parsed,
5136 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5137 tx on|off high_water low_water pause_time priority port_id",
5139 (void *)&cmd_pfc_set_set,
5140 (void *)&cmd_pfc_set_flow_ctrl,
5141 (void *)&cmd_pfc_set_rx,
5142 (void *)&cmd_pfc_set_rx_mode,
5143 (void *)&cmd_pfc_set_tx,
5144 (void *)&cmd_pfc_set_tx_mode,
5145 (void *)&cmd_pfc_set_high_water,
5146 (void *)&cmd_pfc_set_low_water,
5147 (void *)&cmd_pfc_set_pause_time,
5148 (void *)&cmd_pfc_set_priority,
5149 (void *)&cmd_pfc_set_portid,
5154 /* *** RESET CONFIGURATION *** */
5155 struct cmd_reset_result {
5156 cmdline_fixed_string_t reset;
5157 cmdline_fixed_string_t def;
5160 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5162 __attribute__((unused)) void *data)
5164 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5165 set_def_fwd_config();
5168 cmdline_parse_token_string_t cmd_reset_set =
5169 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5170 cmdline_parse_token_string_t cmd_reset_def =
5171 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5174 cmdline_parse_inst_t cmd_reset = {
5175 .f = cmd_reset_parsed,
5177 .help_str = "set default: reset default forwarding configuration",
5179 (void *)&cmd_reset_set,
5180 (void *)&cmd_reset_def,
5185 /* *** START FORWARDING *** */
5186 struct cmd_start_result {
5187 cmdline_fixed_string_t start;
5190 cmdline_parse_token_string_t cmd_start_start =
5191 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5193 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5194 __attribute__((unused)) struct cmdline *cl,
5195 __attribute__((unused)) void *data)
5197 start_packet_forwarding(0);
5200 cmdline_parse_inst_t cmd_start = {
5201 .f = cmd_start_parsed,
5203 .help_str = "start packet forwarding",
5205 (void *)&cmd_start_start,
5210 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5211 struct cmd_start_tx_first_result {
5212 cmdline_fixed_string_t start;
5213 cmdline_fixed_string_t tx_first;
5217 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5218 __attribute__((unused)) struct cmdline *cl,
5219 __attribute__((unused)) void *data)
5221 start_packet_forwarding(1);
5224 cmdline_parse_token_string_t cmd_start_tx_first_start =
5225 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5227 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5228 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5229 tx_first, "tx_first");
5231 cmdline_parse_inst_t cmd_start_tx_first = {
5232 .f = cmd_start_tx_first_parsed,
5234 .help_str = "start packet forwarding, after sending 1 burst of packets",
5236 (void *)&cmd_start_tx_first_start,
5237 (void *)&cmd_start_tx_first_tx_first,
5242 /* *** SET LINK UP *** */
5243 struct cmd_set_link_up_result {
5244 cmdline_fixed_string_t set;
5245 cmdline_fixed_string_t link_up;
5246 cmdline_fixed_string_t port;
5250 cmdline_parse_token_string_t cmd_set_link_up_set =
5251 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5252 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5253 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5255 cmdline_parse_token_string_t cmd_set_link_up_port =
5256 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5257 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5258 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5260 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5261 __attribute__((unused)) struct cmdline *cl,
5262 __attribute__((unused)) void *data)
5264 struct cmd_set_link_up_result *res = parsed_result;
5265 dev_set_link_up(res->port_id);
5268 cmdline_parse_inst_t cmd_set_link_up = {
5269 .f = cmd_set_link_up_parsed,
5271 .help_str = "set link-up port (port id)",
5273 (void *)&cmd_set_link_up_set,
5274 (void *)&cmd_set_link_up_link_up,
5275 (void *)&cmd_set_link_up_port,
5276 (void *)&cmd_set_link_up_port_id,
5281 /* *** SET LINK DOWN *** */
5282 struct cmd_set_link_down_result {
5283 cmdline_fixed_string_t set;
5284 cmdline_fixed_string_t link_down;
5285 cmdline_fixed_string_t port;
5289 cmdline_parse_token_string_t cmd_set_link_down_set =
5290 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5291 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5292 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5294 cmdline_parse_token_string_t cmd_set_link_down_port =
5295 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5296 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5297 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5299 static void cmd_set_link_down_parsed(
5300 __attribute__((unused)) void *parsed_result,
5301 __attribute__((unused)) struct cmdline *cl,
5302 __attribute__((unused)) void *data)
5304 struct cmd_set_link_down_result *res = parsed_result;
5305 dev_set_link_down(res->port_id);
5308 cmdline_parse_inst_t cmd_set_link_down = {
5309 .f = cmd_set_link_down_parsed,
5311 .help_str = "set link-down port (port id)",
5313 (void *)&cmd_set_link_down_set,
5314 (void *)&cmd_set_link_down_link_down,
5315 (void *)&cmd_set_link_down_port,
5316 (void *)&cmd_set_link_down_port_id,
5321 /* *** SHOW CFG *** */
5322 struct cmd_showcfg_result {
5323 cmdline_fixed_string_t show;
5324 cmdline_fixed_string_t cfg;
5325 cmdline_fixed_string_t what;
5328 static void cmd_showcfg_parsed(void *parsed_result,
5329 __attribute__((unused)) struct cmdline *cl,
5330 __attribute__((unused)) void *data)
5332 struct cmd_showcfg_result *res = parsed_result;
5333 if (!strcmp(res->what, "rxtx"))
5334 rxtx_config_display();
5335 else if (!strcmp(res->what, "cores"))
5336 fwd_lcores_config_display();
5337 else if (!strcmp(res->what, "fwd"))
5338 fwd_config_display();
5339 else if (!strcmp(res->what, "txpkts"))
5340 show_tx_pkt_segments();
5343 cmdline_parse_token_string_t cmd_showcfg_show =
5344 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5345 cmdline_parse_token_string_t cmd_showcfg_port =
5346 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5347 cmdline_parse_token_string_t cmd_showcfg_what =
5348 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5349 "rxtx#cores#fwd#txpkts");
5351 cmdline_parse_inst_t cmd_showcfg = {
5352 .f = cmd_showcfg_parsed,
5354 .help_str = "show config rxtx|cores|fwd|txpkts",
5356 (void *)&cmd_showcfg_show,
5357 (void *)&cmd_showcfg_port,
5358 (void *)&cmd_showcfg_what,
5363 /* *** SHOW ALL PORT INFO *** */
5364 struct cmd_showportall_result {
5365 cmdline_fixed_string_t show;
5366 cmdline_fixed_string_t port;
5367 cmdline_fixed_string_t what;
5368 cmdline_fixed_string_t all;
5371 static void cmd_showportall_parsed(void *parsed_result,
5372 __attribute__((unused)) struct cmdline *cl,
5373 __attribute__((unused)) void *data)
5377 struct cmd_showportall_result *res = parsed_result;
5378 if (!strcmp(res->show, "clear")) {
5379 if (!strcmp(res->what, "stats"))
5380 FOREACH_PORT(i, ports)
5382 else if (!strcmp(res->what, "xstats"))
5383 FOREACH_PORT(i, ports)
5384 nic_xstats_clear(i);
5385 } else if (!strcmp(res->what, "info"))
5386 FOREACH_PORT(i, ports)
5387 port_infos_display(i);
5388 else if (!strcmp(res->what, "stats"))
5389 FOREACH_PORT(i, ports)
5390 nic_stats_display(i);
5391 else if (!strcmp(res->what, "xstats"))
5392 FOREACH_PORT(i, ports)
5393 nic_xstats_display(i);
5394 else if (!strcmp(res->what, "fdir"))
5395 FOREACH_PORT(i, ports)
5397 else if (!strcmp(res->what, "stat_qmap"))
5398 FOREACH_PORT(i, ports)
5399 nic_stats_mapping_display(i);
5400 else if (!strcmp(res->what, "dcb_tc"))
5401 FOREACH_PORT(i, ports)
5402 port_dcb_info_display(i);
5405 cmdline_parse_token_string_t cmd_showportall_show =
5406 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5408 cmdline_parse_token_string_t cmd_showportall_port =
5409 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5410 cmdline_parse_token_string_t cmd_showportall_what =
5411 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5412 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5413 cmdline_parse_token_string_t cmd_showportall_all =
5414 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5415 cmdline_parse_inst_t cmd_showportall = {
5416 .f = cmd_showportall_parsed,
5418 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5420 (void *)&cmd_showportall_show,
5421 (void *)&cmd_showportall_port,
5422 (void *)&cmd_showportall_what,
5423 (void *)&cmd_showportall_all,
5428 /* *** SHOW PORT INFO *** */
5429 struct cmd_showport_result {
5430 cmdline_fixed_string_t show;
5431 cmdline_fixed_string_t port;
5432 cmdline_fixed_string_t what;
5436 static void cmd_showport_parsed(void *parsed_result,
5437 __attribute__((unused)) struct cmdline *cl,
5438 __attribute__((unused)) void *data)
5440 struct cmd_showport_result *res = parsed_result;
5441 if (!strcmp(res->show, "clear")) {
5442 if (!strcmp(res->what, "stats"))
5443 nic_stats_clear(res->portnum);
5444 else if (!strcmp(res->what, "xstats"))
5445 nic_xstats_clear(res->portnum);
5446 } else if (!strcmp(res->what, "info"))
5447 port_infos_display(res->portnum);
5448 else if (!strcmp(res->what, "stats"))
5449 nic_stats_display(res->portnum);
5450 else if (!strcmp(res->what, "xstats"))
5451 nic_xstats_display(res->portnum);
5452 else if (!strcmp(res->what, "fdir"))
5453 fdir_get_infos(res->portnum);
5454 else if (!strcmp(res->what, "stat_qmap"))
5455 nic_stats_mapping_display(res->portnum);
5456 else if (!strcmp(res->what, "dcb_tc"))
5457 port_dcb_info_display(res->portnum);
5460 cmdline_parse_token_string_t cmd_showport_show =
5461 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5463 cmdline_parse_token_string_t cmd_showport_port =
5464 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5465 cmdline_parse_token_string_t cmd_showport_what =
5466 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5467 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5468 cmdline_parse_token_num_t cmd_showport_portnum =
5469 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5471 cmdline_parse_inst_t cmd_showport = {
5472 .f = cmd_showport_parsed,
5474 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5476 (void *)&cmd_showport_show,
5477 (void *)&cmd_showport_port,
5478 (void *)&cmd_showport_what,
5479 (void *)&cmd_showport_portnum,
5484 /* *** SHOW QUEUE INFO *** */
5485 struct cmd_showqueue_result {
5486 cmdline_fixed_string_t show;
5487 cmdline_fixed_string_t type;
5488 cmdline_fixed_string_t what;
5494 cmd_showqueue_parsed(void *parsed_result,
5495 __attribute__((unused)) struct cmdline *cl,
5496 __attribute__((unused)) void *data)
5498 struct cmd_showqueue_result *res = parsed_result;
5500 if (!strcmp(res->type, "rxq"))
5501 rx_queue_infos_display(res->portnum, res->queuenum);
5502 else if (!strcmp(res->type, "txq"))
5503 tx_queue_infos_display(res->portnum, res->queuenum);
5506 cmdline_parse_token_string_t cmd_showqueue_show =
5507 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5508 cmdline_parse_token_string_t cmd_showqueue_type =
5509 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5510 cmdline_parse_token_string_t cmd_showqueue_what =
5511 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5512 cmdline_parse_token_num_t cmd_showqueue_portnum =
5513 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5514 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5515 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5517 cmdline_parse_inst_t cmd_showqueue = {
5518 .f = cmd_showqueue_parsed,
5520 .help_str = "show rxq|txq info <port number> <queue_number>",
5522 (void *)&cmd_showqueue_show,
5523 (void *)&cmd_showqueue_type,
5524 (void *)&cmd_showqueue_what,
5525 (void *)&cmd_showqueue_portnum,
5526 (void *)&cmd_showqueue_queuenum,
5531 /* *** READ PORT REGISTER *** */
5532 struct cmd_read_reg_result {
5533 cmdline_fixed_string_t read;
5534 cmdline_fixed_string_t reg;
5540 cmd_read_reg_parsed(void *parsed_result,
5541 __attribute__((unused)) struct cmdline *cl,
5542 __attribute__((unused)) void *data)
5544 struct cmd_read_reg_result *res = parsed_result;
5545 port_reg_display(res->port_id, res->reg_off);
5548 cmdline_parse_token_string_t cmd_read_reg_read =
5549 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5550 cmdline_parse_token_string_t cmd_read_reg_reg =
5551 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5552 cmdline_parse_token_num_t cmd_read_reg_port_id =
5553 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5554 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5555 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5557 cmdline_parse_inst_t cmd_read_reg = {
5558 .f = cmd_read_reg_parsed,
5560 .help_str = "read reg port_id reg_off",
5562 (void *)&cmd_read_reg_read,
5563 (void *)&cmd_read_reg_reg,
5564 (void *)&cmd_read_reg_port_id,
5565 (void *)&cmd_read_reg_reg_off,
5570 /* *** READ PORT REGISTER BIT FIELD *** */
5571 struct cmd_read_reg_bit_field_result {
5572 cmdline_fixed_string_t read;
5573 cmdline_fixed_string_t regfield;
5581 cmd_read_reg_bit_field_parsed(void *parsed_result,
5582 __attribute__((unused)) struct cmdline *cl,
5583 __attribute__((unused)) void *data)
5585 struct cmd_read_reg_bit_field_result *res = parsed_result;
5586 port_reg_bit_field_display(res->port_id, res->reg_off,
5587 res->bit1_pos, res->bit2_pos);
5590 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5591 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5593 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5594 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5595 regfield, "regfield");
5596 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5597 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5599 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5600 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5602 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5603 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5605 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5606 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5609 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5610 .f = cmd_read_reg_bit_field_parsed,
5612 .help_str = "read regfield port_id reg_off bit_x bit_y "
5613 "(read register bit field between bit_x and bit_y included)",
5615 (void *)&cmd_read_reg_bit_field_read,
5616 (void *)&cmd_read_reg_bit_field_regfield,
5617 (void *)&cmd_read_reg_bit_field_port_id,
5618 (void *)&cmd_read_reg_bit_field_reg_off,
5619 (void *)&cmd_read_reg_bit_field_bit1_pos,
5620 (void *)&cmd_read_reg_bit_field_bit2_pos,
5625 /* *** READ PORT REGISTER BIT *** */
5626 struct cmd_read_reg_bit_result {
5627 cmdline_fixed_string_t read;
5628 cmdline_fixed_string_t regbit;
5635 cmd_read_reg_bit_parsed(void *parsed_result,
5636 __attribute__((unused)) struct cmdline *cl,
5637 __attribute__((unused)) void *data)
5639 struct cmd_read_reg_bit_result *res = parsed_result;
5640 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5643 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5644 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5645 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5646 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5648 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5649 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5650 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5651 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5652 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5653 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5655 cmdline_parse_inst_t cmd_read_reg_bit = {
5656 .f = cmd_read_reg_bit_parsed,
5658 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5660 (void *)&cmd_read_reg_bit_read,
5661 (void *)&cmd_read_reg_bit_regbit,
5662 (void *)&cmd_read_reg_bit_port_id,
5663 (void *)&cmd_read_reg_bit_reg_off,
5664 (void *)&cmd_read_reg_bit_bit_pos,
5669 /* *** WRITE PORT REGISTER *** */
5670 struct cmd_write_reg_result {
5671 cmdline_fixed_string_t write;
5672 cmdline_fixed_string_t reg;
5679 cmd_write_reg_parsed(void *parsed_result,
5680 __attribute__((unused)) struct cmdline *cl,
5681 __attribute__((unused)) void *data)
5683 struct cmd_write_reg_result *res = parsed_result;
5684 port_reg_set(res->port_id, res->reg_off, res->value);
5687 cmdline_parse_token_string_t cmd_write_reg_write =
5688 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5689 cmdline_parse_token_string_t cmd_write_reg_reg =
5690 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5691 cmdline_parse_token_num_t cmd_write_reg_port_id =
5692 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5693 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5694 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5695 cmdline_parse_token_num_t cmd_write_reg_value =
5696 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5698 cmdline_parse_inst_t cmd_write_reg = {
5699 .f = cmd_write_reg_parsed,
5701 .help_str = "write reg port_id reg_off reg_value",
5703 (void *)&cmd_write_reg_write,
5704 (void *)&cmd_write_reg_reg,
5705 (void *)&cmd_write_reg_port_id,
5706 (void *)&cmd_write_reg_reg_off,
5707 (void *)&cmd_write_reg_value,
5712 /* *** WRITE PORT REGISTER BIT FIELD *** */
5713 struct cmd_write_reg_bit_field_result {
5714 cmdline_fixed_string_t write;
5715 cmdline_fixed_string_t regfield;
5724 cmd_write_reg_bit_field_parsed(void *parsed_result,
5725 __attribute__((unused)) struct cmdline *cl,
5726 __attribute__((unused)) void *data)
5728 struct cmd_write_reg_bit_field_result *res = parsed_result;
5729 port_reg_bit_field_set(res->port_id, res->reg_off,
5730 res->bit1_pos, res->bit2_pos, res->value);
5733 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5734 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5736 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5737 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5738 regfield, "regfield");
5739 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5740 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5742 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5743 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5745 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5746 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5748 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5749 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5751 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5752 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5755 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5756 .f = cmd_write_reg_bit_field_parsed,
5758 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5759 "(set register bit field between bit_x and bit_y included)",
5761 (void *)&cmd_write_reg_bit_field_write,
5762 (void *)&cmd_write_reg_bit_field_regfield,
5763 (void *)&cmd_write_reg_bit_field_port_id,
5764 (void *)&cmd_write_reg_bit_field_reg_off,
5765 (void *)&cmd_write_reg_bit_field_bit1_pos,
5766 (void *)&cmd_write_reg_bit_field_bit2_pos,
5767 (void *)&cmd_write_reg_bit_field_value,
5772 /* *** WRITE PORT REGISTER BIT *** */
5773 struct cmd_write_reg_bit_result {
5774 cmdline_fixed_string_t write;
5775 cmdline_fixed_string_t regbit;
5783 cmd_write_reg_bit_parsed(void *parsed_result,
5784 __attribute__((unused)) struct cmdline *cl,
5785 __attribute__((unused)) void *data)
5787 struct cmd_write_reg_bit_result *res = parsed_result;
5788 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5791 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5792 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5794 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5795 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5797 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5798 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5799 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5800 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5801 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5802 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5803 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5804 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5806 cmdline_parse_inst_t cmd_write_reg_bit = {
5807 .f = cmd_write_reg_bit_parsed,
5809 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5811 (void *)&cmd_write_reg_bit_write,
5812 (void *)&cmd_write_reg_bit_regbit,
5813 (void *)&cmd_write_reg_bit_port_id,
5814 (void *)&cmd_write_reg_bit_reg_off,
5815 (void *)&cmd_write_reg_bit_bit_pos,
5816 (void *)&cmd_write_reg_bit_value,
5821 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5822 struct cmd_read_rxd_txd_result {
5823 cmdline_fixed_string_t read;
5824 cmdline_fixed_string_t rxd_txd;
5831 cmd_read_rxd_txd_parsed(void *parsed_result,
5832 __attribute__((unused)) struct cmdline *cl,
5833 __attribute__((unused)) void *data)
5835 struct cmd_read_rxd_txd_result *res = parsed_result;
5837 if (!strcmp(res->rxd_txd, "rxd"))
5838 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5839 else if (!strcmp(res->rxd_txd, "txd"))
5840 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5843 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5844 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5845 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5846 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5848 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5849 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5850 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5851 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5852 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5853 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5855 cmdline_parse_inst_t cmd_read_rxd_txd = {
5856 .f = cmd_read_rxd_txd_parsed,
5858 .help_str = "read rxd|txd port_id queue_id rxd_id",
5860 (void *)&cmd_read_rxd_txd_read,
5861 (void *)&cmd_read_rxd_txd_rxd_txd,
5862 (void *)&cmd_read_rxd_txd_port_id,
5863 (void *)&cmd_read_rxd_txd_queue_id,
5864 (void *)&cmd_read_rxd_txd_desc_id,
5870 struct cmd_quit_result {
5871 cmdline_fixed_string_t quit;
5874 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5876 __attribute__((unused)) void *data)
5882 cmdline_parse_token_string_t cmd_quit_quit =
5883 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5885 cmdline_parse_inst_t cmd_quit = {
5886 .f = cmd_quit_parsed,
5888 .help_str = "exit application",
5890 (void *)&cmd_quit_quit,
5895 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5896 struct cmd_mac_addr_result {
5897 cmdline_fixed_string_t mac_addr_cmd;
5898 cmdline_fixed_string_t what;
5900 struct ether_addr address;
5903 static void cmd_mac_addr_parsed(void *parsed_result,
5904 __attribute__((unused)) struct cmdline *cl,
5905 __attribute__((unused)) void *data)
5907 struct cmd_mac_addr_result *res = parsed_result;
5910 if (strcmp(res->what, "add") == 0)
5911 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5913 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5915 /* check the return value and print it if is < 0 */
5917 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5921 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5922 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5924 cmdline_parse_token_string_t cmd_mac_addr_what =
5925 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5927 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5928 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5929 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5930 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5932 cmdline_parse_inst_t cmd_mac_addr = {
5933 .f = cmd_mac_addr_parsed,
5935 .help_str = "mac_addr add|remove X <address>: "
5936 "add/remove MAC address on port X",
5938 (void *)&cmd_mac_addr_cmd,
5939 (void *)&cmd_mac_addr_what,
5940 (void *)&cmd_mac_addr_portnum,
5941 (void *)&cmd_mac_addr_addr,
5947 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5948 struct cmd_set_qmap_result {
5949 cmdline_fixed_string_t set;
5950 cmdline_fixed_string_t qmap;
5951 cmdline_fixed_string_t what;
5958 cmd_set_qmap_parsed(void *parsed_result,
5959 __attribute__((unused)) struct cmdline *cl,
5960 __attribute__((unused)) void *data)
5962 struct cmd_set_qmap_result *res = parsed_result;
5963 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5965 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5968 cmdline_parse_token_string_t cmd_setqmap_set =
5969 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5971 cmdline_parse_token_string_t cmd_setqmap_qmap =
5972 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5974 cmdline_parse_token_string_t cmd_setqmap_what =
5975 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5977 cmdline_parse_token_num_t cmd_setqmap_portid =
5978 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5980 cmdline_parse_token_num_t cmd_setqmap_queueid =
5981 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5983 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5984 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5987 cmdline_parse_inst_t cmd_set_qmap = {
5988 .f = cmd_set_qmap_parsed,
5990 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5992 (void *)&cmd_setqmap_set,
5993 (void *)&cmd_setqmap_qmap,
5994 (void *)&cmd_setqmap_what,
5995 (void *)&cmd_setqmap_portid,
5996 (void *)&cmd_setqmap_queueid,
5997 (void *)&cmd_setqmap_mapvalue,
6002 /* *** CONFIGURE UNICAST HASH TABLE *** */
6003 struct cmd_set_uc_hash_table {
6004 cmdline_fixed_string_t set;
6005 cmdline_fixed_string_t port;
6007 cmdline_fixed_string_t what;
6008 struct ether_addr address;
6009 cmdline_fixed_string_t mode;
6013 cmd_set_uc_hash_parsed(void *parsed_result,
6014 __attribute__((unused)) struct cmdline *cl,
6015 __attribute__((unused)) void *data)
6018 struct cmd_set_uc_hash_table *res = parsed_result;
6020 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6022 if (strcmp(res->what, "uta") == 0)
6023 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6024 &res->address,(uint8_t)is_on);
6026 printf("bad unicast hash table parameter, return code = %d \n", ret);
6030 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6031 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6033 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6034 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6036 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6037 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6039 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6042 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6043 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6045 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6046 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6049 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6050 .f = cmd_set_uc_hash_parsed,
6052 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6054 (void *)&cmd_set_uc_hash_set,
6055 (void *)&cmd_set_uc_hash_port,
6056 (void *)&cmd_set_uc_hash_portid,
6057 (void *)&cmd_set_uc_hash_what,
6058 (void *)&cmd_set_uc_hash_mac,
6059 (void *)&cmd_set_uc_hash_mode,
6064 struct cmd_set_uc_all_hash_table {
6065 cmdline_fixed_string_t set;
6066 cmdline_fixed_string_t port;
6068 cmdline_fixed_string_t what;
6069 cmdline_fixed_string_t value;
6070 cmdline_fixed_string_t mode;
6074 cmd_set_uc_all_hash_parsed(void *parsed_result,
6075 __attribute__((unused)) struct cmdline *cl,
6076 __attribute__((unused)) void *data)
6079 struct cmd_set_uc_all_hash_table *res = parsed_result;
6081 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6083 if ((strcmp(res->what, "uta") == 0) &&
6084 (strcmp(res->value, "all") == 0))
6085 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6087 printf("bad unicast hash table parameter,"
6088 "return code = %d \n", ret);
6091 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6092 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6094 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6095 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6097 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6098 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6100 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6101 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6103 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6104 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6106 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6110 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6111 .f = cmd_set_uc_all_hash_parsed,
6113 .help_str = "set port X uta all on|off (X = port number)",
6115 (void *)&cmd_set_uc_all_hash_set,
6116 (void *)&cmd_set_uc_all_hash_port,
6117 (void *)&cmd_set_uc_all_hash_portid,
6118 (void *)&cmd_set_uc_all_hash_what,
6119 (void *)&cmd_set_uc_all_hash_value,
6120 (void *)&cmd_set_uc_all_hash_mode,
6125 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6126 struct cmd_set_vf_macvlan_filter {
6127 cmdline_fixed_string_t set;
6128 cmdline_fixed_string_t port;
6130 cmdline_fixed_string_t vf;
6132 struct ether_addr address;
6133 cmdline_fixed_string_t filter_type;
6134 cmdline_fixed_string_t mode;
6138 cmd_set_vf_macvlan_parsed(void *parsed_result,
6139 __attribute__((unused)) struct cmdline *cl,
6140 __attribute__((unused)) void *data)
6143 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6144 struct rte_eth_mac_filter filter;
6146 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6148 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6150 /* set VF MAC filter */
6154 filter.dst_id = res->vf_id;
6156 if (!strcmp(res->filter_type, "exact-mac"))
6157 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6158 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6159 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6160 else if (!strcmp(res->filter_type, "hashmac"))
6161 filter.filter_type = RTE_MAC_HASH_MATCH;
6162 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6163 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6165 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6168 ret = rte_eth_dev_filter_ctrl(res->port_id,
6169 RTE_ETH_FILTER_MACVLAN,
6173 ret = rte_eth_dev_filter_ctrl(res->port_id,
6174 RTE_ETH_FILTER_MACVLAN,
6175 RTE_ETH_FILTER_DELETE,
6179 printf("bad set MAC hash parameter, return code = %d\n", ret);
6183 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6184 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6186 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6187 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6189 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6190 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6192 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6193 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6195 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6196 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6198 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6199 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6201 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6202 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6203 filter_type, "exact-mac#exact-mac-vlan"
6204 "#hashmac#hashmac-vlan");
6205 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6206 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6209 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6210 .f = cmd_set_vf_macvlan_parsed,
6212 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6213 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6215 "exact match rule:exact match of MAC or MAC and VLAN; "
6216 "hash match rule: hash match of MAC and exact match "
6219 (void *)&cmd_set_vf_macvlan_set,
6220 (void *)&cmd_set_vf_macvlan_port,
6221 (void *)&cmd_set_vf_macvlan_portid,
6222 (void *)&cmd_set_vf_macvlan_vf,
6223 (void *)&cmd_set_vf_macvlan_vf_id,
6224 (void *)&cmd_set_vf_macvlan_mac,
6225 (void *)&cmd_set_vf_macvlan_filter_type,
6226 (void *)&cmd_set_vf_macvlan_mode,
6231 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6232 struct cmd_set_vf_traffic {
6233 cmdline_fixed_string_t set;
6234 cmdline_fixed_string_t port;
6236 cmdline_fixed_string_t vf;
6238 cmdline_fixed_string_t what;
6239 cmdline_fixed_string_t mode;
6243 cmd_set_vf_traffic_parsed(void *parsed_result,
6244 __attribute__((unused)) struct cmdline *cl,
6245 __attribute__((unused)) void *data)
6247 struct cmd_set_vf_traffic *res = parsed_result;
6248 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6249 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6251 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6254 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6255 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6257 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6260 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6261 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6263 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6264 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6266 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6267 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6269 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6272 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6276 cmdline_parse_inst_t cmd_set_vf_traffic = {
6277 .f = cmd_set_vf_traffic_parsed,
6279 .help_str = "set port X vf Y rx|tx on|off"
6280 "(X = port number,Y = vf id)",
6282 (void *)&cmd_setvf_traffic_set,
6283 (void *)&cmd_setvf_traffic_port,
6284 (void *)&cmd_setvf_traffic_portid,
6285 (void *)&cmd_setvf_traffic_vf,
6286 (void *)&cmd_setvf_traffic_vfid,
6287 (void *)&cmd_setvf_traffic_what,
6288 (void *)&cmd_setvf_traffic_mode,
6293 /* *** CONFIGURE VF RECEIVE MODE *** */
6294 struct cmd_set_vf_rxmode {
6295 cmdline_fixed_string_t set;
6296 cmdline_fixed_string_t port;
6298 cmdline_fixed_string_t vf;
6300 cmdline_fixed_string_t what;
6301 cmdline_fixed_string_t mode;
6302 cmdline_fixed_string_t on;
6306 cmd_set_vf_rxmode_parsed(void *parsed_result,
6307 __attribute__((unused)) struct cmdline *cl,
6308 __attribute__((unused)) void *data)
6311 uint16_t rx_mode = 0;
6312 struct cmd_set_vf_rxmode *res = parsed_result;
6314 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6315 if (!strcmp(res->what,"rxmode")) {
6316 if (!strcmp(res->mode, "AUPE"))
6317 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6318 else if (!strcmp(res->mode, "ROPE"))
6319 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6320 else if (!strcmp(res->mode, "BAM"))
6321 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6322 else if (!strncmp(res->mode, "MPE",3))
6323 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6326 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6328 printf("bad VF receive mode parameter, return code = %d \n",
6332 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6333 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6335 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6336 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6338 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6339 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6341 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6342 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6344 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6345 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6347 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6348 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6350 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6351 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6352 mode, "AUPE#ROPE#BAM#MPE");
6353 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6354 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6357 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6358 .f = cmd_set_vf_rxmode_parsed,
6360 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6362 (void *)&cmd_set_vf_rxmode_set,
6363 (void *)&cmd_set_vf_rxmode_port,
6364 (void *)&cmd_set_vf_rxmode_portid,
6365 (void *)&cmd_set_vf_rxmode_vf,
6366 (void *)&cmd_set_vf_rxmode_vfid,
6367 (void *)&cmd_set_vf_rxmode_what,
6368 (void *)&cmd_set_vf_rxmode_mode,
6369 (void *)&cmd_set_vf_rxmode_on,
6374 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6375 struct cmd_vf_mac_addr_result {
6376 cmdline_fixed_string_t mac_addr_cmd;
6377 cmdline_fixed_string_t what;
6378 cmdline_fixed_string_t port;
6380 cmdline_fixed_string_t vf;
6382 struct ether_addr address;
6385 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6386 __attribute__((unused)) struct cmdline *cl,
6387 __attribute__((unused)) void *data)
6389 struct cmd_vf_mac_addr_result *res = parsed_result;
6392 if (strcmp(res->what, "add") == 0)
6393 ret = rte_eth_dev_mac_addr_add(res->port_num,
6394 &res->address, res->vf_num);
6396 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6400 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6401 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6402 mac_addr_cmd,"mac_addr");
6403 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6404 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6406 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6407 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6409 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6410 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6412 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6413 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6415 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6416 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6418 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6419 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6422 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6423 .f = cmd_vf_mac_addr_parsed,
6425 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6426 "Y = VF number)add MAC address filtering for a VF on port X",
6428 (void *)&cmd_vf_mac_addr_cmd,
6429 (void *)&cmd_vf_mac_addr_what,
6430 (void *)&cmd_vf_mac_addr_port,
6431 (void *)&cmd_vf_mac_addr_portnum,
6432 (void *)&cmd_vf_mac_addr_vf,
6433 (void *)&cmd_vf_mac_addr_vfnum,
6434 (void *)&cmd_vf_mac_addr_addr,
6439 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6440 struct cmd_vf_rx_vlan_filter {
6441 cmdline_fixed_string_t rx_vlan;
6442 cmdline_fixed_string_t what;
6444 cmdline_fixed_string_t port;
6446 cmdline_fixed_string_t vf;
6451 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6452 __attribute__((unused)) struct cmdline *cl,
6453 __attribute__((unused)) void *data)
6455 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6457 if (!strcmp(res->what, "add"))
6458 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6460 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6463 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6464 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6465 rx_vlan, "rx_vlan");
6466 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6467 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6469 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6470 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6472 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6473 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6475 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6476 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6478 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6479 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6481 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6482 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6485 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6486 .f = cmd_vf_rx_vlan_filter_parsed,
6488 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6489 "Y = port number,Z = hexadecimal VF mask)",
6491 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6492 (void *)&cmd_vf_rx_vlan_filter_what,
6493 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6494 (void *)&cmd_vf_rx_vlan_filter_port,
6495 (void *)&cmd_vf_rx_vlan_filter_portid,
6496 (void *)&cmd_vf_rx_vlan_filter_vf,
6497 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6502 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6503 struct cmd_queue_rate_limit_result {
6504 cmdline_fixed_string_t set;
6505 cmdline_fixed_string_t port;
6507 cmdline_fixed_string_t queue;
6509 cmdline_fixed_string_t rate;
6513 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6514 __attribute__((unused)) struct cmdline *cl,
6515 __attribute__((unused)) void *data)
6517 struct cmd_queue_rate_limit_result *res = parsed_result;
6520 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6521 && (strcmp(res->queue, "queue") == 0)
6522 && (strcmp(res->rate, "rate") == 0))
6523 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6526 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6530 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6531 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6533 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6534 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6536 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6537 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6539 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6540 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6542 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6543 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6545 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6546 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6548 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6549 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6552 cmdline_parse_inst_t cmd_queue_rate_limit = {
6553 .f = cmd_queue_rate_limit_parsed,
6555 .help_str = "set port X queue Y rate Z:(X = port number,"
6556 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6558 (void *)&cmd_queue_rate_limit_set,
6559 (void *)&cmd_queue_rate_limit_port,
6560 (void *)&cmd_queue_rate_limit_portnum,
6561 (void *)&cmd_queue_rate_limit_queue,
6562 (void *)&cmd_queue_rate_limit_queuenum,
6563 (void *)&cmd_queue_rate_limit_rate,
6564 (void *)&cmd_queue_rate_limit_ratenum,
6569 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6570 struct cmd_vf_rate_limit_result {
6571 cmdline_fixed_string_t set;
6572 cmdline_fixed_string_t port;
6574 cmdline_fixed_string_t vf;
6576 cmdline_fixed_string_t rate;
6578 cmdline_fixed_string_t q_msk;
6582 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6583 __attribute__((unused)) struct cmdline *cl,
6584 __attribute__((unused)) void *data)
6586 struct cmd_vf_rate_limit_result *res = parsed_result;
6589 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6590 && (strcmp(res->vf, "vf") == 0)
6591 && (strcmp(res->rate, "rate") == 0)
6592 && (strcmp(res->q_msk, "queue_mask") == 0))
6593 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6594 res->rate_num, res->q_msk_val);
6596 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6600 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6601 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6603 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6604 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6606 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6607 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6609 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6610 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6612 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6613 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6615 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6616 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6618 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6619 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6621 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6622 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6623 q_msk, "queue_mask");
6624 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6625 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6628 cmdline_parse_inst_t cmd_vf_rate_limit = {
6629 .f = cmd_vf_rate_limit_parsed,
6631 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6632 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6633 "for queues of VF on port X",
6635 (void *)&cmd_vf_rate_limit_set,
6636 (void *)&cmd_vf_rate_limit_port,
6637 (void *)&cmd_vf_rate_limit_portnum,
6638 (void *)&cmd_vf_rate_limit_vf,
6639 (void *)&cmd_vf_rate_limit_vfnum,
6640 (void *)&cmd_vf_rate_limit_rate,
6641 (void *)&cmd_vf_rate_limit_ratenum,
6642 (void *)&cmd_vf_rate_limit_q_msk,
6643 (void *)&cmd_vf_rate_limit_q_msk_val,
6648 /* *** ADD TUNNEL FILTER OF A PORT *** */
6649 struct cmd_tunnel_filter_result {
6650 cmdline_fixed_string_t cmd;
6651 cmdline_fixed_string_t what;
6653 struct ether_addr outer_mac;
6654 struct ether_addr inner_mac;
6655 cmdline_ipaddr_t ip_value;
6656 uint16_t inner_vlan;
6657 cmdline_fixed_string_t tunnel_type;
6658 cmdline_fixed_string_t filter_type;
6664 cmd_tunnel_filter_parsed(void *parsed_result,
6665 __attribute__((unused)) struct cmdline *cl,
6666 __attribute__((unused)) void *data)
6668 struct cmd_tunnel_filter_result *res = parsed_result;
6669 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6672 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
6673 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
6674 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6676 if (res->ip_value.family == AF_INET) {
6677 tunnel_filter_conf.ip_addr.ipv4_addr =
6678 res->ip_value.addr.ipv4.s_addr;
6679 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6681 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6682 &(res->ip_value.addr.ipv6),
6683 sizeof(struct in6_addr));
6684 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6687 if (!strcmp(res->filter_type, "imac-ivlan"))
6688 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6689 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6690 tunnel_filter_conf.filter_type =
6691 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6692 else if (!strcmp(res->filter_type, "imac-tenid"))
6693 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6694 else if (!strcmp(res->filter_type, "imac"))
6695 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6696 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6697 tunnel_filter_conf.filter_type =
6698 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6700 printf("The filter type is not supported");
6704 if (!strcmp(res->tunnel_type, "vxlan"))
6705 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6706 else if (!strcmp(res->tunnel_type, "nvgre"))
6707 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6709 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6713 tunnel_filter_conf.tenant_id = res->tenant_id;
6714 tunnel_filter_conf.queue_id = res->queue_num;
6715 if (!strcmp(res->what, "add"))
6716 ret = rte_eth_dev_filter_ctrl(res->port_id,
6717 RTE_ETH_FILTER_TUNNEL,
6719 &tunnel_filter_conf);
6721 ret = rte_eth_dev_filter_ctrl(res->port_id,
6722 RTE_ETH_FILTER_TUNNEL,
6723 RTE_ETH_FILTER_DELETE,
6724 &tunnel_filter_conf);
6726 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6730 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6731 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6732 cmd, "tunnel_filter");
6733 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6734 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6736 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6737 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6739 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6740 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6742 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6743 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6745 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6746 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6747 inner_vlan, UINT16);
6748 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6749 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6751 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6752 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6753 tunnel_type, "vxlan#nvgre");
6755 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6756 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6757 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6758 "imac#omac-imac-tenid");
6759 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6760 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6762 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6763 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6766 cmdline_parse_inst_t cmd_tunnel_filter = {
6767 .f = cmd_tunnel_filter_parsed,
6769 .help_str = "add/rm tunnel filter of a port: "
6770 "tunnel_filter add port_id outer_mac inner_mac ip "
6771 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6772 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6773 "imac|omac-imac-tenid) "
6774 "tenant_id queue_num",
6776 (void *)&cmd_tunnel_filter_cmd,
6777 (void *)&cmd_tunnel_filter_what,
6778 (void *)&cmd_tunnel_filter_port_id,
6779 (void *)&cmd_tunnel_filter_outer_mac,
6780 (void *)&cmd_tunnel_filter_inner_mac,
6781 (void *)&cmd_tunnel_filter_ip_value,
6782 (void *)&cmd_tunnel_filter_innner_vlan,
6783 (void *)&cmd_tunnel_filter_tunnel_type,
6784 (void *)&cmd_tunnel_filter_filter_type,
6785 (void *)&cmd_tunnel_filter_tenant_id,
6786 (void *)&cmd_tunnel_filter_queue_num,
6791 /* *** CONFIGURE TUNNEL UDP PORT *** */
6792 struct cmd_tunnel_udp_config {
6793 cmdline_fixed_string_t cmd;
6794 cmdline_fixed_string_t what;
6800 cmd_tunnel_udp_config_parsed(void *parsed_result,
6801 __attribute__((unused)) struct cmdline *cl,
6802 __attribute__((unused)) void *data)
6804 struct cmd_tunnel_udp_config *res = parsed_result;
6805 struct rte_eth_udp_tunnel tunnel_udp;
6808 tunnel_udp.udp_port = res->udp_port;
6810 if (!strcmp(res->cmd, "rx_vxlan_port"))
6811 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6813 if (!strcmp(res->what, "add"))
6814 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
6817 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
6821 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6824 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6825 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6826 cmd, "rx_vxlan_port");
6827 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6828 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6830 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6831 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6833 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6834 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6837 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6838 .f = cmd_tunnel_udp_config_parsed,
6840 .help_str = "add/rm an tunneling UDP port filter: "
6841 "rx_vxlan_port add udp_port port_id",
6843 (void *)&cmd_tunnel_udp_config_cmd,
6844 (void *)&cmd_tunnel_udp_config_what,
6845 (void *)&cmd_tunnel_udp_config_udp_port,
6846 (void *)&cmd_tunnel_udp_config_port_id,
6851 /* *** GLOBAL CONFIG *** */
6852 struct cmd_global_config_result {
6853 cmdline_fixed_string_t cmd;
6855 cmdline_fixed_string_t cfg_type;
6860 cmd_global_config_parsed(void *parsed_result,
6861 __attribute__((unused)) struct cmdline *cl,
6862 __attribute__((unused)) void *data)
6864 struct cmd_global_config_result *res = parsed_result;
6865 struct rte_eth_global_cfg conf;
6868 memset(&conf, 0, sizeof(conf));
6869 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6870 conf.cfg.gre_key_len = res->len;
6871 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6872 RTE_ETH_FILTER_SET, &conf);
6874 printf("Global config error\n");
6877 cmdline_parse_token_string_t cmd_global_config_cmd =
6878 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6880 cmdline_parse_token_num_t cmd_global_config_port_id =
6881 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6882 cmdline_parse_token_string_t cmd_global_config_type =
6883 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6884 cfg_type, "gre-key-len");
6885 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6886 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6889 cmdline_parse_inst_t cmd_global_config = {
6890 .f = cmd_global_config_parsed,
6891 .data = (void *)NULL,
6892 .help_str = "global_config <port_id> gre-key-len <number>",
6894 (void *)&cmd_global_config_cmd,
6895 (void *)&cmd_global_config_port_id,
6896 (void *)&cmd_global_config_type,
6897 (void *)&cmd_global_config_gre_key_len,
6902 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6903 struct cmd_set_mirror_mask_result {
6904 cmdline_fixed_string_t set;
6905 cmdline_fixed_string_t port;
6907 cmdline_fixed_string_t mirror;
6909 cmdline_fixed_string_t what;
6910 cmdline_fixed_string_t value;
6911 cmdline_fixed_string_t dstpool;
6913 cmdline_fixed_string_t on;
6916 cmdline_parse_token_string_t cmd_mirror_mask_set =
6917 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6919 cmdline_parse_token_string_t cmd_mirror_mask_port =
6920 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6922 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6923 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6925 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6926 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6927 mirror, "mirror-rule");
6928 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6929 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6931 cmdline_parse_token_string_t cmd_mirror_mask_what =
6932 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6933 what, "pool-mirror-up#pool-mirror-down"
6935 cmdline_parse_token_string_t cmd_mirror_mask_value =
6936 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6938 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6939 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6940 dstpool, "dst-pool");
6941 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6942 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6944 cmdline_parse_token_string_t cmd_mirror_mask_on =
6945 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6949 cmd_set_mirror_mask_parsed(void *parsed_result,
6950 __attribute__((unused)) struct cmdline *cl,
6951 __attribute__((unused)) void *data)
6954 struct cmd_set_mirror_mask_result *res = parsed_result;
6955 struct rte_eth_mirror_conf mr_conf;
6957 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6959 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6961 mr_conf.dst_pool = res->dstpool_id;
6963 if (!strcmp(res->what, "pool-mirror-up")) {
6964 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6965 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6966 } else if (!strcmp(res->what, "pool-mirror-down")) {
6967 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6968 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6969 } else if (!strcmp(res->what, "vlan-mirror")) {
6970 mr_conf.rule_type = ETH_MIRROR_VLAN;
6971 nb_item = parse_item_list(res->value, "vlan",
6972 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6976 for (i = 0; i < nb_item; i++) {
6977 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6978 printf("Invalid vlan_id: must be < 4096\n");
6982 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6983 mr_conf.vlan.vlan_mask |= 1ULL << i;
6987 if (!strcmp(res->on, "on"))
6988 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6991 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6994 printf("mirror rule add error: (%s)\n", strerror(-ret));
6997 cmdline_parse_inst_t cmd_set_mirror_mask = {
6998 .f = cmd_set_mirror_mask_parsed,
7000 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7001 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7003 (void *)&cmd_mirror_mask_set,
7004 (void *)&cmd_mirror_mask_port,
7005 (void *)&cmd_mirror_mask_portid,
7006 (void *)&cmd_mirror_mask_mirror,
7007 (void *)&cmd_mirror_mask_ruleid,
7008 (void *)&cmd_mirror_mask_what,
7009 (void *)&cmd_mirror_mask_value,
7010 (void *)&cmd_mirror_mask_dstpool,
7011 (void *)&cmd_mirror_mask_poolid,
7012 (void *)&cmd_mirror_mask_on,
7017 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7018 struct cmd_set_mirror_link_result {
7019 cmdline_fixed_string_t set;
7020 cmdline_fixed_string_t port;
7022 cmdline_fixed_string_t mirror;
7024 cmdline_fixed_string_t what;
7025 cmdline_fixed_string_t dstpool;
7027 cmdline_fixed_string_t on;
7030 cmdline_parse_token_string_t cmd_mirror_link_set =
7031 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7033 cmdline_parse_token_string_t cmd_mirror_link_port =
7034 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7036 cmdline_parse_token_num_t cmd_mirror_link_portid =
7037 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7039 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7040 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7041 mirror, "mirror-rule");
7042 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7043 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7045 cmdline_parse_token_string_t cmd_mirror_link_what =
7046 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7047 what, "uplink-mirror#downlink-mirror");
7048 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7049 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7050 dstpool, "dst-pool");
7051 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7052 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7054 cmdline_parse_token_string_t cmd_mirror_link_on =
7055 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7059 cmd_set_mirror_link_parsed(void *parsed_result,
7060 __attribute__((unused)) struct cmdline *cl,
7061 __attribute__((unused)) void *data)
7064 struct cmd_set_mirror_link_result *res = parsed_result;
7065 struct rte_eth_mirror_conf mr_conf;
7067 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7068 if (!strcmp(res->what, "uplink-mirror"))
7069 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7071 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7073 mr_conf.dst_pool = res->dstpool_id;
7075 if (!strcmp(res->on, "on"))
7076 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7079 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7082 /* check the return value and print it if is < 0 */
7084 printf("mirror rule add error: (%s)\n", strerror(-ret));
7088 cmdline_parse_inst_t cmd_set_mirror_link = {
7089 .f = cmd_set_mirror_link_parsed,
7091 .help_str = "set port X mirror-rule Y uplink-mirror|"
7092 "downlink-mirror dst-pool Z on|off",
7094 (void *)&cmd_mirror_link_set,
7095 (void *)&cmd_mirror_link_port,
7096 (void *)&cmd_mirror_link_portid,
7097 (void *)&cmd_mirror_link_mirror,
7098 (void *)&cmd_mirror_link_ruleid,
7099 (void *)&cmd_mirror_link_what,
7100 (void *)&cmd_mirror_link_dstpool,
7101 (void *)&cmd_mirror_link_poolid,
7102 (void *)&cmd_mirror_link_on,
7107 /* *** RESET VM MIRROR RULE *** */
7108 struct cmd_rm_mirror_rule_result {
7109 cmdline_fixed_string_t reset;
7110 cmdline_fixed_string_t port;
7112 cmdline_fixed_string_t mirror;
7116 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7117 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7119 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7120 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7122 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7123 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7125 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7126 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7127 mirror, "mirror-rule");
7128 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7129 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7133 cmd_reset_mirror_rule_parsed(void *parsed_result,
7134 __attribute__((unused)) struct cmdline *cl,
7135 __attribute__((unused)) void *data)
7138 struct cmd_set_mirror_link_result *res = parsed_result;
7140 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7142 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7145 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7146 .f = cmd_reset_mirror_rule_parsed,
7148 .help_str = "reset port X mirror-rule Y",
7150 (void *)&cmd_rm_mirror_rule_reset,
7151 (void *)&cmd_rm_mirror_rule_port,
7152 (void *)&cmd_rm_mirror_rule_portid,
7153 (void *)&cmd_rm_mirror_rule_mirror,
7154 (void *)&cmd_rm_mirror_rule_ruleid,
7159 /* ******************************************************************************** */
7161 struct cmd_dump_result {
7162 cmdline_fixed_string_t dump;
7166 dump_struct_sizes(void)
7168 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7169 DUMP_SIZE(struct rte_mbuf);
7170 DUMP_SIZE(struct rte_mempool);
7171 DUMP_SIZE(struct rte_ring);
7175 static void cmd_dump_parsed(void *parsed_result,
7176 __attribute__((unused)) struct cmdline *cl,
7177 __attribute__((unused)) void *data)
7179 struct cmd_dump_result *res = parsed_result;
7181 if (!strcmp(res->dump, "dump_physmem"))
7182 rte_dump_physmem_layout(stdout);
7183 else if (!strcmp(res->dump, "dump_memzone"))
7184 rte_memzone_dump(stdout);
7185 else if (!strcmp(res->dump, "dump_log_history"))
7186 rte_log_dump_history(stdout);
7187 else if (!strcmp(res->dump, "dump_struct_sizes"))
7188 dump_struct_sizes();
7189 else if (!strcmp(res->dump, "dump_ring"))
7190 rte_ring_list_dump(stdout);
7191 else if (!strcmp(res->dump, "dump_mempool"))
7192 rte_mempool_list_dump(stdout);
7193 else if (!strcmp(res->dump, "dump_devargs"))
7194 rte_eal_devargs_dump(stdout);
7197 cmdline_parse_token_string_t cmd_dump_dump =
7198 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7202 "dump_struct_sizes#"
7207 cmdline_parse_inst_t cmd_dump = {
7208 .f = cmd_dump_parsed, /* function to call */
7209 .data = NULL, /* 2nd arg of func */
7210 .help_str = "dump status",
7211 .tokens = { /* token list, NULL terminated */
7212 (void *)&cmd_dump_dump,
7217 /* ******************************************************************************** */
7219 struct cmd_dump_one_result {
7220 cmdline_fixed_string_t dump;
7221 cmdline_fixed_string_t name;
7224 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7225 __attribute__((unused)) void *data)
7227 struct cmd_dump_one_result *res = parsed_result;
7229 if (!strcmp(res->dump, "dump_ring")) {
7231 r = rte_ring_lookup(res->name);
7233 cmdline_printf(cl, "Cannot find ring\n");
7236 rte_ring_dump(stdout, r);
7237 } else if (!strcmp(res->dump, "dump_mempool")) {
7238 struct rte_mempool *mp;
7239 mp = rte_mempool_lookup(res->name);
7241 cmdline_printf(cl, "Cannot find mempool\n");
7244 rte_mempool_dump(stdout, mp);
7248 cmdline_parse_token_string_t cmd_dump_one_dump =
7249 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7250 "dump_ring#dump_mempool");
7252 cmdline_parse_token_string_t cmd_dump_one_name =
7253 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7255 cmdline_parse_inst_t cmd_dump_one = {
7256 .f = cmd_dump_one_parsed, /* function to call */
7257 .data = NULL, /* 2nd arg of func */
7258 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7259 .tokens = { /* token list, NULL terminated */
7260 (void *)&cmd_dump_one_dump,
7261 (void *)&cmd_dump_one_name,
7266 /* *** Add/Del syn filter *** */
7267 struct cmd_syn_filter_result {
7268 cmdline_fixed_string_t filter;
7270 cmdline_fixed_string_t ops;
7271 cmdline_fixed_string_t priority;
7272 cmdline_fixed_string_t high;
7273 cmdline_fixed_string_t queue;
7278 cmd_syn_filter_parsed(void *parsed_result,
7279 __attribute__((unused)) struct cmdline *cl,
7280 __attribute__((unused)) void *data)
7282 struct cmd_syn_filter_result *res = parsed_result;
7283 struct rte_eth_syn_filter syn_filter;
7286 ret = rte_eth_dev_filter_supported(res->port_id,
7287 RTE_ETH_FILTER_SYN);
7289 printf("syn filter is not supported on port %u.\n",
7294 memset(&syn_filter, 0, sizeof(syn_filter));
7296 if (!strcmp(res->ops, "add")) {
7297 if (!strcmp(res->high, "high"))
7298 syn_filter.hig_pri = 1;
7300 syn_filter.hig_pri = 0;
7302 syn_filter.queue = res->queue_id;
7303 ret = rte_eth_dev_filter_ctrl(res->port_id,
7308 ret = rte_eth_dev_filter_ctrl(res->port_id,
7310 RTE_ETH_FILTER_DELETE,
7314 printf("syn filter programming error: (%s)\n",
7318 cmdline_parse_token_string_t cmd_syn_filter_filter =
7319 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7320 filter, "syn_filter");
7321 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7322 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7324 cmdline_parse_token_string_t cmd_syn_filter_ops =
7325 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7327 cmdline_parse_token_string_t cmd_syn_filter_priority =
7328 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7329 priority, "priority");
7330 cmdline_parse_token_string_t cmd_syn_filter_high =
7331 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7333 cmdline_parse_token_string_t cmd_syn_filter_queue =
7334 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7336 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7337 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7340 cmdline_parse_inst_t cmd_syn_filter = {
7341 .f = cmd_syn_filter_parsed,
7343 .help_str = "add/delete syn filter",
7345 (void *)&cmd_syn_filter_filter,
7346 (void *)&cmd_syn_filter_port_id,
7347 (void *)&cmd_syn_filter_ops,
7348 (void *)&cmd_syn_filter_priority,
7349 (void *)&cmd_syn_filter_high,
7350 (void *)&cmd_syn_filter_queue,
7351 (void *)&cmd_syn_filter_queue_id,
7356 /* *** ADD/REMOVE A 2tuple FILTER *** */
7357 struct cmd_2tuple_filter_result {
7358 cmdline_fixed_string_t filter;
7360 cmdline_fixed_string_t ops;
7361 cmdline_fixed_string_t dst_port;
7362 uint16_t dst_port_value;
7363 cmdline_fixed_string_t protocol;
7364 uint8_t protocol_value;
7365 cmdline_fixed_string_t mask;
7367 cmdline_fixed_string_t tcp_flags;
7368 uint8_t tcp_flags_value;
7369 cmdline_fixed_string_t priority;
7370 uint8_t priority_value;
7371 cmdline_fixed_string_t queue;
7376 cmd_2tuple_filter_parsed(void *parsed_result,
7377 __attribute__((unused)) struct cmdline *cl,
7378 __attribute__((unused)) void *data)
7380 struct rte_eth_ntuple_filter filter;
7381 struct cmd_2tuple_filter_result *res = parsed_result;
7384 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7386 printf("ntuple filter is not supported on port %u.\n",
7391 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7393 filter.flags = RTE_2TUPLE_FLAGS;
7394 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7395 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7396 filter.proto = res->protocol_value;
7397 filter.priority = res->priority_value;
7398 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7399 printf("nonzero tcp_flags is only meaningful"
7400 " when protocol is TCP.\n");
7403 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7404 printf("invalid TCP flags.\n");
7408 if (res->tcp_flags_value != 0) {
7409 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7410 filter.tcp_flags = res->tcp_flags_value;
7413 /* need convert to big endian. */
7414 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7415 filter.queue = res->queue_id;
7417 if (!strcmp(res->ops, "add"))
7418 ret = rte_eth_dev_filter_ctrl(res->port_id,
7419 RTE_ETH_FILTER_NTUPLE,
7423 ret = rte_eth_dev_filter_ctrl(res->port_id,
7424 RTE_ETH_FILTER_NTUPLE,
7425 RTE_ETH_FILTER_DELETE,
7428 printf("2tuple filter programming error: (%s)\n",
7433 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7434 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7435 filter, "2tuple_filter");
7436 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7437 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7439 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7440 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7442 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7443 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7444 dst_port, "dst_port");
7445 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7446 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7447 dst_port_value, UINT16);
7448 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7449 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7450 protocol, "protocol");
7451 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7452 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7453 protocol_value, UINT8);
7454 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7455 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7457 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7458 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7460 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7461 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7462 tcp_flags, "tcp_flags");
7463 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7464 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7465 tcp_flags_value, UINT8);
7466 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7467 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7468 priority, "priority");
7469 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7470 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7471 priority_value, UINT8);
7472 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7473 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7475 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7476 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7479 cmdline_parse_inst_t cmd_2tuple_filter = {
7480 .f = cmd_2tuple_filter_parsed,
7482 .help_str = "add a 2tuple filter",
7484 (void *)&cmd_2tuple_filter_filter,
7485 (void *)&cmd_2tuple_filter_port_id,
7486 (void *)&cmd_2tuple_filter_ops,
7487 (void *)&cmd_2tuple_filter_dst_port,
7488 (void *)&cmd_2tuple_filter_dst_port_value,
7489 (void *)&cmd_2tuple_filter_protocol,
7490 (void *)&cmd_2tuple_filter_protocol_value,
7491 (void *)&cmd_2tuple_filter_mask,
7492 (void *)&cmd_2tuple_filter_mask_value,
7493 (void *)&cmd_2tuple_filter_tcp_flags,
7494 (void *)&cmd_2tuple_filter_tcp_flags_value,
7495 (void *)&cmd_2tuple_filter_priority,
7496 (void *)&cmd_2tuple_filter_priority_value,
7497 (void *)&cmd_2tuple_filter_queue,
7498 (void *)&cmd_2tuple_filter_queue_id,
7503 /* *** ADD/REMOVE A 5tuple FILTER *** */
7504 struct cmd_5tuple_filter_result {
7505 cmdline_fixed_string_t filter;
7507 cmdline_fixed_string_t ops;
7508 cmdline_fixed_string_t dst_ip;
7509 cmdline_ipaddr_t dst_ip_value;
7510 cmdline_fixed_string_t src_ip;
7511 cmdline_ipaddr_t src_ip_value;
7512 cmdline_fixed_string_t dst_port;
7513 uint16_t dst_port_value;
7514 cmdline_fixed_string_t src_port;
7515 uint16_t src_port_value;
7516 cmdline_fixed_string_t protocol;
7517 uint8_t protocol_value;
7518 cmdline_fixed_string_t mask;
7520 cmdline_fixed_string_t tcp_flags;
7521 uint8_t tcp_flags_value;
7522 cmdline_fixed_string_t priority;
7523 uint8_t priority_value;
7524 cmdline_fixed_string_t queue;
7529 cmd_5tuple_filter_parsed(void *parsed_result,
7530 __attribute__((unused)) struct cmdline *cl,
7531 __attribute__((unused)) void *data)
7533 struct rte_eth_ntuple_filter filter;
7534 struct cmd_5tuple_filter_result *res = parsed_result;
7537 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7539 printf("ntuple filter is not supported on port %u.\n",
7544 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7546 filter.flags = RTE_5TUPLE_FLAGS;
7547 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7548 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7549 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7550 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7551 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7552 filter.proto = res->protocol_value;
7553 filter.priority = res->priority_value;
7554 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7555 printf("nonzero tcp_flags is only meaningful"
7556 " when protocol is TCP.\n");
7559 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7560 printf("invalid TCP flags.\n");
7564 if (res->tcp_flags_value != 0) {
7565 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7566 filter.tcp_flags = res->tcp_flags_value;
7569 if (res->dst_ip_value.family == AF_INET)
7570 /* no need to convert, already big endian. */
7571 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7573 if (filter.dst_ip_mask == 0) {
7574 printf("can not support ipv6 involved compare.\n");
7580 if (res->src_ip_value.family == AF_INET)
7581 /* no need to convert, already big endian. */
7582 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7584 if (filter.src_ip_mask == 0) {
7585 printf("can not support ipv6 involved compare.\n");
7590 /* need convert to big endian. */
7591 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7592 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7593 filter.queue = res->queue_id;
7595 if (!strcmp(res->ops, "add"))
7596 ret = rte_eth_dev_filter_ctrl(res->port_id,
7597 RTE_ETH_FILTER_NTUPLE,
7601 ret = rte_eth_dev_filter_ctrl(res->port_id,
7602 RTE_ETH_FILTER_NTUPLE,
7603 RTE_ETH_FILTER_DELETE,
7606 printf("5tuple filter programming error: (%s)\n",
7610 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7611 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7612 filter, "5tuple_filter");
7613 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7614 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7616 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7617 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7619 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7620 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7622 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7623 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7625 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7626 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7628 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7629 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7631 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7632 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7633 dst_port, "dst_port");
7634 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7635 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7636 dst_port_value, UINT16);
7637 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7638 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7639 src_port, "src_port");
7640 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7641 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7642 src_port_value, UINT16);
7643 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7644 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7645 protocol, "protocol");
7646 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7647 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7648 protocol_value, UINT8);
7649 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7650 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7652 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7653 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7655 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7656 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7657 tcp_flags, "tcp_flags");
7658 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7659 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7660 tcp_flags_value, UINT8);
7661 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7662 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7663 priority, "priority");
7664 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7665 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7666 priority_value, UINT8);
7667 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7668 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7670 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7671 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7674 cmdline_parse_inst_t cmd_5tuple_filter = {
7675 .f = cmd_5tuple_filter_parsed,
7677 .help_str = "add/del a 5tuple filter",
7679 (void *)&cmd_5tuple_filter_filter,
7680 (void *)&cmd_5tuple_filter_port_id,
7681 (void *)&cmd_5tuple_filter_ops,
7682 (void *)&cmd_5tuple_filter_dst_ip,
7683 (void *)&cmd_5tuple_filter_dst_ip_value,
7684 (void *)&cmd_5tuple_filter_src_ip,
7685 (void *)&cmd_5tuple_filter_src_ip_value,
7686 (void *)&cmd_5tuple_filter_dst_port,
7687 (void *)&cmd_5tuple_filter_dst_port_value,
7688 (void *)&cmd_5tuple_filter_src_port,
7689 (void *)&cmd_5tuple_filter_src_port_value,
7690 (void *)&cmd_5tuple_filter_protocol,
7691 (void *)&cmd_5tuple_filter_protocol_value,
7692 (void *)&cmd_5tuple_filter_mask,
7693 (void *)&cmd_5tuple_filter_mask_value,
7694 (void *)&cmd_5tuple_filter_tcp_flags,
7695 (void *)&cmd_5tuple_filter_tcp_flags_value,
7696 (void *)&cmd_5tuple_filter_priority,
7697 (void *)&cmd_5tuple_filter_priority_value,
7698 (void *)&cmd_5tuple_filter_queue,
7699 (void *)&cmd_5tuple_filter_queue_id,
7704 /* *** ADD/REMOVE A flex FILTER *** */
7705 struct cmd_flex_filter_result {
7706 cmdline_fixed_string_t filter;
7707 cmdline_fixed_string_t ops;
7709 cmdline_fixed_string_t len;
7711 cmdline_fixed_string_t bytes;
7712 cmdline_fixed_string_t bytes_value;
7713 cmdline_fixed_string_t mask;
7714 cmdline_fixed_string_t mask_value;
7715 cmdline_fixed_string_t priority;
7716 uint8_t priority_value;
7717 cmdline_fixed_string_t queue;
7721 static int xdigit2val(unsigned char c)
7726 else if (isupper(c))
7734 cmd_flex_filter_parsed(void *parsed_result,
7735 __attribute__((unused)) struct cmdline *cl,
7736 __attribute__((unused)) void *data)
7739 struct rte_eth_flex_filter filter;
7740 struct cmd_flex_filter_result *res = parsed_result;
7741 char *bytes_ptr, *mask_ptr;
7742 uint16_t len, i, j = 0;
7747 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7748 printf("the len exceed the max length 128\n");
7751 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7752 filter.len = res->len_value;
7753 filter.priority = res->priority_value;
7754 filter.queue = res->queue_id;
7755 bytes_ptr = res->bytes_value;
7756 mask_ptr = res->mask_value;
7758 /* translate bytes string to array. */
7759 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7760 (bytes_ptr[1] == 'X')))
7762 len = strnlen(bytes_ptr, res->len_value * 2);
7763 if (len == 0 || (len % 8 != 0)) {
7764 printf("please check len and bytes input\n");
7767 for (i = 0; i < len; i++) {
7769 if (isxdigit(c) == 0) {
7770 /* invalid characters. */
7771 printf("invalid input\n");
7774 val = xdigit2val(c);
7777 filter.bytes[j] = byte;
7778 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7785 /* translate mask string to uint8_t array. */
7786 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7787 (mask_ptr[1] == 'X')))
7789 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7791 printf("invalid input\n");
7796 for (i = 0; i < len; i++) {
7798 if (isxdigit(c) == 0) {
7799 /* invalid characters. */
7800 printf("invalid input\n");
7803 val = xdigit2val(c);
7806 filter.mask[j] = byte;
7807 printf("mask[%d]:%02x ", j, filter.mask[j]);
7815 if (!strcmp(res->ops, "add"))
7816 ret = rte_eth_dev_filter_ctrl(res->port_id,
7817 RTE_ETH_FILTER_FLEXIBLE,
7821 ret = rte_eth_dev_filter_ctrl(res->port_id,
7822 RTE_ETH_FILTER_FLEXIBLE,
7823 RTE_ETH_FILTER_DELETE,
7827 printf("flex filter setting error: (%s)\n", strerror(-ret));
7830 cmdline_parse_token_string_t cmd_flex_filter_filter =
7831 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7832 filter, "flex_filter");
7833 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7834 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7836 cmdline_parse_token_string_t cmd_flex_filter_ops =
7837 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7839 cmdline_parse_token_string_t cmd_flex_filter_len =
7840 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7842 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7843 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7845 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7846 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7848 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7849 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7851 cmdline_parse_token_string_t cmd_flex_filter_mask =
7852 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7854 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7855 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7857 cmdline_parse_token_string_t cmd_flex_filter_priority =
7858 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7859 priority, "priority");
7860 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7861 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7862 priority_value, UINT8);
7863 cmdline_parse_token_string_t cmd_flex_filter_queue =
7864 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7866 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7867 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7869 cmdline_parse_inst_t cmd_flex_filter = {
7870 .f = cmd_flex_filter_parsed,
7872 .help_str = "add/del a flex filter",
7874 (void *)&cmd_flex_filter_filter,
7875 (void *)&cmd_flex_filter_port_id,
7876 (void *)&cmd_flex_filter_ops,
7877 (void *)&cmd_flex_filter_len,
7878 (void *)&cmd_flex_filter_len_value,
7879 (void *)&cmd_flex_filter_bytes,
7880 (void *)&cmd_flex_filter_bytes_value,
7881 (void *)&cmd_flex_filter_mask,
7882 (void *)&cmd_flex_filter_mask_value,
7883 (void *)&cmd_flex_filter_priority,
7884 (void *)&cmd_flex_filter_priority_value,
7885 (void *)&cmd_flex_filter_queue,
7886 (void *)&cmd_flex_filter_queue_id,
7891 /* *** Filters Control *** */
7893 /* *** deal with ethertype filter *** */
7894 struct cmd_ethertype_filter_result {
7895 cmdline_fixed_string_t filter;
7897 cmdline_fixed_string_t ops;
7898 cmdline_fixed_string_t mac;
7899 struct ether_addr mac_addr;
7900 cmdline_fixed_string_t ethertype;
7901 uint16_t ethertype_value;
7902 cmdline_fixed_string_t drop;
7903 cmdline_fixed_string_t queue;
7907 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7908 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7909 filter, "ethertype_filter");
7910 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7911 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7913 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7914 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7916 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7917 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7918 mac, "mac_addr#mac_ignr");
7919 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7920 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7922 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7923 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7924 ethertype, "ethertype");
7925 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7926 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7927 ethertype_value, UINT16);
7928 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7929 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7931 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7932 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7934 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7935 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7939 cmd_ethertype_filter_parsed(void *parsed_result,
7940 __attribute__((unused)) struct cmdline *cl,
7941 __attribute__((unused)) void *data)
7943 struct cmd_ethertype_filter_result *res = parsed_result;
7944 struct rte_eth_ethertype_filter filter;
7947 ret = rte_eth_dev_filter_supported(res->port_id,
7948 RTE_ETH_FILTER_ETHERTYPE);
7950 printf("ethertype filter is not supported on port %u.\n",
7955 memset(&filter, 0, sizeof(filter));
7956 if (!strcmp(res->mac, "mac_addr")) {
7957 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7958 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7959 sizeof(struct ether_addr));
7961 if (!strcmp(res->drop, "drop"))
7962 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7963 filter.ether_type = res->ethertype_value;
7964 filter.queue = res->queue_id;
7966 if (!strcmp(res->ops, "add"))
7967 ret = rte_eth_dev_filter_ctrl(res->port_id,
7968 RTE_ETH_FILTER_ETHERTYPE,
7972 ret = rte_eth_dev_filter_ctrl(res->port_id,
7973 RTE_ETH_FILTER_ETHERTYPE,
7974 RTE_ETH_FILTER_DELETE,
7977 printf("ethertype filter programming error: (%s)\n",
7981 cmdline_parse_inst_t cmd_ethertype_filter = {
7982 .f = cmd_ethertype_filter_parsed,
7984 .help_str = "add or delete an ethertype filter entry",
7986 (void *)&cmd_ethertype_filter_filter,
7987 (void *)&cmd_ethertype_filter_port_id,
7988 (void *)&cmd_ethertype_filter_ops,
7989 (void *)&cmd_ethertype_filter_mac,
7990 (void *)&cmd_ethertype_filter_mac_addr,
7991 (void *)&cmd_ethertype_filter_ethertype,
7992 (void *)&cmd_ethertype_filter_ethertype_value,
7993 (void *)&cmd_ethertype_filter_drop,
7994 (void *)&cmd_ethertype_filter_queue,
7995 (void *)&cmd_ethertype_filter_queue_id,
8000 /* *** deal with flow director filter *** */
8001 struct cmd_flow_director_result {
8002 cmdline_fixed_string_t flow_director_filter;
8004 cmdline_fixed_string_t mode;
8005 cmdline_fixed_string_t mode_value;
8006 cmdline_fixed_string_t ops;
8007 cmdline_fixed_string_t flow;
8008 cmdline_fixed_string_t flow_type;
8009 cmdline_fixed_string_t ether;
8010 uint16_t ether_type;
8011 cmdline_fixed_string_t src;
8012 cmdline_ipaddr_t ip_src;
8014 cmdline_fixed_string_t dst;
8015 cmdline_ipaddr_t ip_dst;
8017 cmdline_fixed_string_t verify_tag;
8018 uint32_t verify_tag_value;
8019 cmdline_fixed_string_t vlan;
8020 uint16_t vlan_value;
8021 cmdline_fixed_string_t flexbytes;
8022 cmdline_fixed_string_t flexbytes_value;
8023 cmdline_fixed_string_t pf_vf;
8024 cmdline_fixed_string_t drop;
8025 cmdline_fixed_string_t queue;
8027 cmdline_fixed_string_t fd_id;
8028 uint32_t fd_id_value;
8029 cmdline_fixed_string_t mac;
8030 struct ether_addr mac_addr;
8031 cmdline_fixed_string_t tunnel;
8032 cmdline_fixed_string_t tunnel_type;
8033 cmdline_fixed_string_t tunnel_id;
8034 uint32_t tunnel_id_value;
8038 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8041 const char *p, *p0 = q_arg;
8043 unsigned long int_fld;
8044 char *str_fld[max_num];
8049 p = strchr(p0, '(');
8053 p0 = strchr(p, ')');
8058 if (size >= sizeof(s))
8061 snprintf(s, sizeof(s), "%.*s", size, p);
8062 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8063 if (ret < 0 || ret > max_num)
8065 for (i = 0; i < ret; i++) {
8067 int_fld = strtoul(str_fld[i], &end, 0);
8068 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8070 flexbytes[i] = (uint8_t)int_fld;
8076 str2flowtype(char *string)
8079 static const struct {
8082 } flowtype_str[] = {
8083 {"raw", RTE_ETH_FLOW_RAW},
8084 {"ipv4", RTE_ETH_FLOW_IPV4},
8085 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8086 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8087 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8088 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8089 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8090 {"ipv6", RTE_ETH_FLOW_IPV6},
8091 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8092 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8093 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8094 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8095 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8096 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8099 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8100 if (!strcmp(flowtype_str[i].str, string))
8101 return flowtype_str[i].type;
8103 return RTE_ETH_FLOW_UNKNOWN;
8106 static enum rte_eth_fdir_tunnel_type
8107 str2fdir_tunneltype(char *string)
8111 static const struct {
8113 enum rte_eth_fdir_tunnel_type type;
8114 } tunneltype_str[] = {
8115 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8116 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8119 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8120 if (!strcmp(tunneltype_str[i].str, string))
8121 return tunneltype_str[i].type;
8123 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8126 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8128 if ((ip_addr).family == AF_INET) \
8129 (ip) = (ip_addr).addr.ipv4.s_addr; \
8131 printf("invalid parameter.\n"); \
8136 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8138 if ((ip_addr).family == AF_INET6) \
8139 (void)rte_memcpy(&(ip), \
8140 &((ip_addr).addr.ipv6), \
8141 sizeof(struct in6_addr)); \
8143 printf("invalid parameter.\n"); \
8149 cmd_flow_director_filter_parsed(void *parsed_result,
8150 __attribute__((unused)) struct cmdline *cl,
8151 __attribute__((unused)) void *data)
8153 struct cmd_flow_director_result *res = parsed_result;
8154 struct rte_eth_fdir_filter entry;
8155 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8157 unsigned long vf_id;
8160 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8162 printf("flow director is not supported on port %u.\n",
8166 memset(flexbytes, 0, sizeof(flexbytes));
8167 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8169 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8170 if (strcmp(res->mode_value, "MAC-VLAN")) {
8171 printf("Please set mode to MAC-VLAN.\n");
8174 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8175 if (strcmp(res->mode_value, "Tunnel")) {
8176 printf("Please set mode to Tunnel.\n");
8180 if (strcmp(res->mode_value, "IP")) {
8181 printf("Please set mode to IP.\n");
8184 entry.input.flow_type = str2flowtype(res->flow_type);
8187 ret = parse_flexbytes(res->flexbytes_value,
8189 RTE_ETH_FDIR_MAX_FLEXLEN);
8191 printf("error: Cannot parse flexbytes input.\n");
8195 switch (entry.input.flow_type) {
8196 case RTE_ETH_FLOW_FRAG_IPV4:
8197 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8198 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8199 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8200 IPV4_ADDR_TO_UINT(res->ip_dst,
8201 entry.input.flow.ip4_flow.dst_ip);
8202 IPV4_ADDR_TO_UINT(res->ip_src,
8203 entry.input.flow.ip4_flow.src_ip);
8204 /* need convert to big endian. */
8205 entry.input.flow.udp4_flow.dst_port =
8206 rte_cpu_to_be_16(res->port_dst);
8207 entry.input.flow.udp4_flow.src_port =
8208 rte_cpu_to_be_16(res->port_src);
8210 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8211 IPV4_ADDR_TO_UINT(res->ip_dst,
8212 entry.input.flow.sctp4_flow.ip.dst_ip);
8213 IPV4_ADDR_TO_UINT(res->ip_src,
8214 entry.input.flow.sctp4_flow.ip.src_ip);
8215 /* need convert to big endian. */
8216 entry.input.flow.sctp4_flow.dst_port =
8217 rte_cpu_to_be_16(res->port_dst);
8218 entry.input.flow.sctp4_flow.src_port =
8219 rte_cpu_to_be_16(res->port_src);
8220 entry.input.flow.sctp4_flow.verify_tag =
8221 rte_cpu_to_be_32(res->verify_tag_value);
8223 case RTE_ETH_FLOW_FRAG_IPV6:
8224 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8225 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8226 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8227 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8228 entry.input.flow.ipv6_flow.dst_ip);
8229 IPV6_ADDR_TO_ARRAY(res->ip_src,
8230 entry.input.flow.ipv6_flow.src_ip);
8231 /* need convert to big endian. */
8232 entry.input.flow.udp6_flow.dst_port =
8233 rte_cpu_to_be_16(res->port_dst);
8234 entry.input.flow.udp6_flow.src_port =
8235 rte_cpu_to_be_16(res->port_src);
8237 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8238 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8239 entry.input.flow.sctp6_flow.ip.dst_ip);
8240 IPV6_ADDR_TO_ARRAY(res->ip_src,
8241 entry.input.flow.sctp6_flow.ip.src_ip);
8242 /* need convert to big endian. */
8243 entry.input.flow.sctp6_flow.dst_port =
8244 rte_cpu_to_be_16(res->port_dst);
8245 entry.input.flow.sctp6_flow.src_port =
8246 rte_cpu_to_be_16(res->port_src);
8247 entry.input.flow.sctp6_flow.verify_tag =
8248 rte_cpu_to_be_32(res->verify_tag_value);
8250 case RTE_ETH_FLOW_L2_PAYLOAD:
8251 entry.input.flow.l2_flow.ether_type =
8252 rte_cpu_to_be_16(res->ether_type);
8258 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8259 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8261 sizeof(struct ether_addr));
8263 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8264 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8266 sizeof(struct ether_addr));
8267 entry.input.flow.tunnel_flow.tunnel_type =
8268 str2fdir_tunneltype(res->tunnel_type);
8269 entry.input.flow.tunnel_flow.tunnel_id =
8270 rte_cpu_to_be_32(res->tunnel_id_value);
8273 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8275 RTE_ETH_FDIR_MAX_FLEXLEN);
8277 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8279 entry.action.flex_off = 0; /*use 0 by default */
8280 if (!strcmp(res->drop, "drop"))
8281 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8283 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8285 if (!strcmp(res->pf_vf, "pf"))
8286 entry.input.flow_ext.is_vf = 0;
8287 else if (!strncmp(res->pf_vf, "vf", 2)) {
8288 struct rte_eth_dev_info dev_info;
8290 memset(&dev_info, 0, sizeof(dev_info));
8291 rte_eth_dev_info_get(res->port_id, &dev_info);
8293 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8294 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8295 printf("invalid parameter %s.\n", res->pf_vf);
8298 entry.input.flow_ext.is_vf = 1;
8299 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8301 printf("invalid parameter %s.\n", res->pf_vf);
8305 /* set to report FD ID by default */
8306 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8307 entry.action.rx_queue = res->queue_id;
8308 entry.soft_id = res->fd_id_value;
8309 if (!strcmp(res->ops, "add"))
8310 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8311 RTE_ETH_FILTER_ADD, &entry);
8312 else if (!strcmp(res->ops, "del"))
8313 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8314 RTE_ETH_FILTER_DELETE, &entry);
8316 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8317 RTE_ETH_FILTER_UPDATE, &entry);
8319 printf("flow director programming error: (%s)\n",
8323 cmdline_parse_token_string_t cmd_flow_director_filter =
8324 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8325 flow_director_filter, "flow_director_filter");
8326 cmdline_parse_token_num_t cmd_flow_director_port_id =
8327 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8329 cmdline_parse_token_string_t cmd_flow_director_ops =
8330 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8331 ops, "add#del#update");
8332 cmdline_parse_token_string_t cmd_flow_director_flow =
8333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8335 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8337 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8338 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8339 cmdline_parse_token_string_t cmd_flow_director_ether =
8340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8342 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8343 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8344 ether_type, UINT16);
8345 cmdline_parse_token_string_t cmd_flow_director_src =
8346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8348 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8349 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8351 cmdline_parse_token_num_t cmd_flow_director_port_src =
8352 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8354 cmdline_parse_token_string_t cmd_flow_director_dst =
8355 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8357 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8358 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8360 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8361 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8363 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8365 verify_tag, "verify_tag");
8366 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8367 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8368 verify_tag_value, UINT32);
8369 cmdline_parse_token_string_t cmd_flow_director_vlan =
8370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8372 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8373 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8374 vlan_value, UINT16);
8375 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8377 flexbytes, "flexbytes");
8378 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8380 flexbytes_value, NULL);
8381 cmdline_parse_token_string_t cmd_flow_director_drop =
8382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8384 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8385 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8387 cmdline_parse_token_string_t cmd_flow_director_queue =
8388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8390 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8391 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8393 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8396 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8397 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8398 fd_id_value, UINT32);
8400 cmdline_parse_token_string_t cmd_flow_director_mode =
8401 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8403 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8404 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8406 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8407 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8408 mode_value, "MAC-VLAN");
8409 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8410 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8411 mode_value, "Tunnel");
8412 cmdline_parse_token_string_t cmd_flow_director_mac =
8413 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8415 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8416 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8418 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8419 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8421 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8422 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8423 tunnel_type, "NVGRE#VxLAN");
8424 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8426 tunnel_id, "tunnel-id");
8427 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8428 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8429 tunnel_id_value, UINT32);
8431 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8432 .f = cmd_flow_director_filter_parsed,
8434 .help_str = "add or delete an ip flow director entry on NIC",
8436 (void *)&cmd_flow_director_filter,
8437 (void *)&cmd_flow_director_port_id,
8438 (void *)&cmd_flow_director_mode,
8439 (void *)&cmd_flow_director_mode_ip,
8440 (void *)&cmd_flow_director_ops,
8441 (void *)&cmd_flow_director_flow,
8442 (void *)&cmd_flow_director_flow_type,
8443 (void *)&cmd_flow_director_src,
8444 (void *)&cmd_flow_director_ip_src,
8445 (void *)&cmd_flow_director_dst,
8446 (void *)&cmd_flow_director_ip_dst,
8447 (void *)&cmd_flow_director_vlan,
8448 (void *)&cmd_flow_director_vlan_value,
8449 (void *)&cmd_flow_director_flexbytes,
8450 (void *)&cmd_flow_director_flexbytes_value,
8451 (void *)&cmd_flow_director_drop,
8452 (void *)&cmd_flow_director_pf_vf,
8453 (void *)&cmd_flow_director_queue,
8454 (void *)&cmd_flow_director_queue_id,
8455 (void *)&cmd_flow_director_fd_id,
8456 (void *)&cmd_flow_director_fd_id_value,
8461 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8462 .f = cmd_flow_director_filter_parsed,
8464 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8466 (void *)&cmd_flow_director_filter,
8467 (void *)&cmd_flow_director_port_id,
8468 (void *)&cmd_flow_director_mode,
8469 (void *)&cmd_flow_director_mode_ip,
8470 (void *)&cmd_flow_director_ops,
8471 (void *)&cmd_flow_director_flow,
8472 (void *)&cmd_flow_director_flow_type,
8473 (void *)&cmd_flow_director_src,
8474 (void *)&cmd_flow_director_ip_src,
8475 (void *)&cmd_flow_director_port_src,
8476 (void *)&cmd_flow_director_dst,
8477 (void *)&cmd_flow_director_ip_dst,
8478 (void *)&cmd_flow_director_port_dst,
8479 (void *)&cmd_flow_director_vlan,
8480 (void *)&cmd_flow_director_vlan_value,
8481 (void *)&cmd_flow_director_flexbytes,
8482 (void *)&cmd_flow_director_flexbytes_value,
8483 (void *)&cmd_flow_director_drop,
8484 (void *)&cmd_flow_director_pf_vf,
8485 (void *)&cmd_flow_director_queue,
8486 (void *)&cmd_flow_director_queue_id,
8487 (void *)&cmd_flow_director_fd_id,
8488 (void *)&cmd_flow_director_fd_id_value,
8493 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8494 .f = cmd_flow_director_filter_parsed,
8496 .help_str = "add or delete a sctp flow director entry on NIC",
8498 (void *)&cmd_flow_director_filter,
8499 (void *)&cmd_flow_director_port_id,
8500 (void *)&cmd_flow_director_mode,
8501 (void *)&cmd_flow_director_mode_ip,
8502 (void *)&cmd_flow_director_ops,
8503 (void *)&cmd_flow_director_flow,
8504 (void *)&cmd_flow_director_flow_type,
8505 (void *)&cmd_flow_director_src,
8506 (void *)&cmd_flow_director_ip_src,
8507 (void *)&cmd_flow_director_port_dst,
8508 (void *)&cmd_flow_director_dst,
8509 (void *)&cmd_flow_director_ip_dst,
8510 (void *)&cmd_flow_director_port_dst,
8511 (void *)&cmd_flow_director_verify_tag,
8512 (void *)&cmd_flow_director_verify_tag_value,
8513 (void *)&cmd_flow_director_vlan,
8514 (void *)&cmd_flow_director_vlan_value,
8515 (void *)&cmd_flow_director_flexbytes,
8516 (void *)&cmd_flow_director_flexbytes_value,
8517 (void *)&cmd_flow_director_drop,
8518 (void *)&cmd_flow_director_pf_vf,
8519 (void *)&cmd_flow_director_queue,
8520 (void *)&cmd_flow_director_queue_id,
8521 (void *)&cmd_flow_director_fd_id,
8522 (void *)&cmd_flow_director_fd_id_value,
8527 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8528 .f = cmd_flow_director_filter_parsed,
8530 .help_str = "add or delete a L2 flow director entry on NIC",
8532 (void *)&cmd_flow_director_filter,
8533 (void *)&cmd_flow_director_port_id,
8534 (void *)&cmd_flow_director_mode,
8535 (void *)&cmd_flow_director_mode_ip,
8536 (void *)&cmd_flow_director_ops,
8537 (void *)&cmd_flow_director_flow,
8538 (void *)&cmd_flow_director_flow_type,
8539 (void *)&cmd_flow_director_ether,
8540 (void *)&cmd_flow_director_ether_type,
8541 (void *)&cmd_flow_director_flexbytes,
8542 (void *)&cmd_flow_director_flexbytes_value,
8543 (void *)&cmd_flow_director_drop,
8544 (void *)&cmd_flow_director_pf_vf,
8545 (void *)&cmd_flow_director_queue,
8546 (void *)&cmd_flow_director_queue_id,
8547 (void *)&cmd_flow_director_fd_id,
8548 (void *)&cmd_flow_director_fd_id_value,
8553 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8554 .f = cmd_flow_director_filter_parsed,
8556 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8558 (void *)&cmd_flow_director_filter,
8559 (void *)&cmd_flow_director_port_id,
8560 (void *)&cmd_flow_director_mode,
8561 (void *)&cmd_flow_director_mode_mac_vlan,
8562 (void *)&cmd_flow_director_ops,
8563 (void *)&cmd_flow_director_mac,
8564 (void *)&cmd_flow_director_mac_addr,
8565 (void *)&cmd_flow_director_vlan,
8566 (void *)&cmd_flow_director_vlan_value,
8567 (void *)&cmd_flow_director_flexbytes,
8568 (void *)&cmd_flow_director_flexbytes_value,
8569 (void *)&cmd_flow_director_drop,
8570 (void *)&cmd_flow_director_queue,
8571 (void *)&cmd_flow_director_queue_id,
8572 (void *)&cmd_flow_director_fd_id,
8573 (void *)&cmd_flow_director_fd_id_value,
8578 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8579 .f = cmd_flow_director_filter_parsed,
8581 .help_str = "add or delete a tunnel flow director entry on NIC",
8583 (void *)&cmd_flow_director_filter,
8584 (void *)&cmd_flow_director_port_id,
8585 (void *)&cmd_flow_director_mode,
8586 (void *)&cmd_flow_director_mode_tunnel,
8587 (void *)&cmd_flow_director_ops,
8588 (void *)&cmd_flow_director_mac,
8589 (void *)&cmd_flow_director_mac_addr,
8590 (void *)&cmd_flow_director_vlan,
8591 (void *)&cmd_flow_director_vlan_value,
8592 (void *)&cmd_flow_director_tunnel,
8593 (void *)&cmd_flow_director_tunnel_type,
8594 (void *)&cmd_flow_director_tunnel_id,
8595 (void *)&cmd_flow_director_tunnel_id_value,
8596 (void *)&cmd_flow_director_flexbytes,
8597 (void *)&cmd_flow_director_flexbytes_value,
8598 (void *)&cmd_flow_director_drop,
8599 (void *)&cmd_flow_director_queue,
8600 (void *)&cmd_flow_director_queue_id,
8601 (void *)&cmd_flow_director_fd_id,
8602 (void *)&cmd_flow_director_fd_id_value,
8607 struct cmd_flush_flow_director_result {
8608 cmdline_fixed_string_t flush_flow_director;
8612 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8613 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8614 flush_flow_director, "flush_flow_director");
8615 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8616 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8620 cmd_flush_flow_director_parsed(void *parsed_result,
8621 __attribute__((unused)) struct cmdline *cl,
8622 __attribute__((unused)) void *data)
8624 struct cmd_flow_director_result *res = parsed_result;
8627 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8629 printf("flow director is not supported on port %u.\n",
8634 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8635 RTE_ETH_FILTER_FLUSH, NULL);
8637 printf("flow director table flushing error: (%s)\n",
8641 cmdline_parse_inst_t cmd_flush_flow_director = {
8642 .f = cmd_flush_flow_director_parsed,
8644 .help_str = "flush all flow director entries of a device on NIC",
8646 (void *)&cmd_flush_flow_director_flush,
8647 (void *)&cmd_flush_flow_director_port_id,
8652 /* *** deal with flow director mask *** */
8653 struct cmd_flow_director_mask_result {
8654 cmdline_fixed_string_t flow_director_mask;
8656 cmdline_fixed_string_t mode;
8657 cmdline_fixed_string_t mode_value;
8658 cmdline_fixed_string_t vlan;
8660 cmdline_fixed_string_t src_mask;
8661 cmdline_ipaddr_t ipv4_src;
8662 cmdline_ipaddr_t ipv6_src;
8664 cmdline_fixed_string_t dst_mask;
8665 cmdline_ipaddr_t ipv4_dst;
8666 cmdline_ipaddr_t ipv6_dst;
8668 cmdline_fixed_string_t mac;
8669 uint8_t mac_addr_byte_mask;
8670 cmdline_fixed_string_t tunnel_id;
8671 uint32_t tunnel_id_mask;
8672 cmdline_fixed_string_t tunnel_type;
8673 uint8_t tunnel_type_mask;
8677 cmd_flow_director_mask_parsed(void *parsed_result,
8678 __attribute__((unused)) struct cmdline *cl,
8679 __attribute__((unused)) void *data)
8681 struct cmd_flow_director_mask_result *res = parsed_result;
8682 struct rte_eth_fdir_masks *mask;
8683 struct rte_port *port;
8685 if (res->port_id > nb_ports) {
8686 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8690 port = &ports[res->port_id];
8691 /** Check if the port is not started **/
8692 if (port->port_status != RTE_PORT_STOPPED) {
8693 printf("Please stop port %d first\n", res->port_id);
8697 mask = &port->dev_conf.fdir_conf.mask;
8699 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8700 if (strcmp(res->mode_value, "MAC-VLAN")) {
8701 printf("Please set mode to MAC-VLAN.\n");
8705 mask->vlan_tci_mask = res->vlan_mask;
8706 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8707 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8708 if (strcmp(res->mode_value, "Tunnel")) {
8709 printf("Please set mode to Tunnel.\n");
8713 mask->vlan_tci_mask = res->vlan_mask;
8714 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8715 mask->tunnel_id_mask = res->tunnel_id_mask;
8716 mask->tunnel_type_mask = res->tunnel_type_mask;
8718 if (strcmp(res->mode_value, "IP")) {
8719 printf("Please set mode to IP.\n");
8723 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8724 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8725 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8726 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8727 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8728 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8729 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8732 cmd_reconfig_device_queue(res->port_id, 1, 1);
8735 cmdline_parse_token_string_t cmd_flow_director_mask =
8736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8737 flow_director_mask, "flow_director_mask");
8738 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8739 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8741 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8744 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8745 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8747 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8749 src_mask, "src_mask");
8750 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8751 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8753 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8754 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8756 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8759 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8761 dst_mask, "dst_mask");
8762 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8763 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8765 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8766 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8768 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8772 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8775 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8778 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8780 mode_value, "MAC-VLAN");
8781 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8783 mode_value, "Tunnel");
8784 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8787 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8788 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8789 mac_addr_byte_mask, UINT8);
8790 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8792 tunnel_type, "tunnel-type");
8793 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8794 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8795 tunnel_type_mask, UINT8);
8796 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8798 tunnel_id, "tunnel-id");
8799 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8800 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8801 tunnel_id_mask, UINT32);
8803 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8804 .f = cmd_flow_director_mask_parsed,
8806 .help_str = "set IP mode flow director's mask on NIC",
8808 (void *)&cmd_flow_director_mask,
8809 (void *)&cmd_flow_director_mask_port_id,
8810 (void *)&cmd_flow_director_mask_mode,
8811 (void *)&cmd_flow_director_mask_mode_ip,
8812 (void *)&cmd_flow_director_mask_vlan,
8813 (void *)&cmd_flow_director_mask_vlan_value,
8814 (void *)&cmd_flow_director_mask_src,
8815 (void *)&cmd_flow_director_mask_ipv4_src,
8816 (void *)&cmd_flow_director_mask_ipv6_src,
8817 (void *)&cmd_flow_director_mask_port_src,
8818 (void *)&cmd_flow_director_mask_dst,
8819 (void *)&cmd_flow_director_mask_ipv4_dst,
8820 (void *)&cmd_flow_director_mask_ipv6_dst,
8821 (void *)&cmd_flow_director_mask_port_dst,
8826 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8827 .f = cmd_flow_director_mask_parsed,
8829 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8831 (void *)&cmd_flow_director_mask,
8832 (void *)&cmd_flow_director_mask_port_id,
8833 (void *)&cmd_flow_director_mask_mode,
8834 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8835 (void *)&cmd_flow_director_mask_vlan,
8836 (void *)&cmd_flow_director_mask_vlan_value,
8837 (void *)&cmd_flow_director_mask_mac,
8838 (void *)&cmd_flow_director_mask_mac_value,
8843 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8844 .f = cmd_flow_director_mask_parsed,
8846 .help_str = "set tunnel mode flow director's mask on NIC",
8848 (void *)&cmd_flow_director_mask,
8849 (void *)&cmd_flow_director_mask_port_id,
8850 (void *)&cmd_flow_director_mask_mode,
8851 (void *)&cmd_flow_director_mask_mode_tunnel,
8852 (void *)&cmd_flow_director_mask_vlan,
8853 (void *)&cmd_flow_director_mask_vlan_value,
8854 (void *)&cmd_flow_director_mask_mac,
8855 (void *)&cmd_flow_director_mask_mac_value,
8856 (void *)&cmd_flow_director_mask_tunnel_type,
8857 (void *)&cmd_flow_director_mask_tunnel_type_value,
8858 (void *)&cmd_flow_director_mask_tunnel_id,
8859 (void *)&cmd_flow_director_mask_tunnel_id_value,
8864 /* *** deal with flow director mask on flexible payload *** */
8865 struct cmd_flow_director_flex_mask_result {
8866 cmdline_fixed_string_t flow_director_flexmask;
8868 cmdline_fixed_string_t flow;
8869 cmdline_fixed_string_t flow_type;
8870 cmdline_fixed_string_t mask;
8874 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8875 __attribute__((unused)) struct cmdline *cl,
8876 __attribute__((unused)) void *data)
8878 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8879 struct rte_eth_fdir_info fdir_info;
8880 struct rte_eth_fdir_flex_mask flex_mask;
8881 struct rte_port *port;
8882 uint32_t flow_type_mask;
8886 if (res->port_id > nb_ports) {
8887 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8891 port = &ports[res->port_id];
8892 /** Check if the port is not started **/
8893 if (port->port_status != RTE_PORT_STOPPED) {
8894 printf("Please stop port %d first\n", res->port_id);
8898 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8899 ret = parse_flexbytes(res->mask,
8901 RTE_ETH_FDIR_MAX_FLEXLEN);
8903 printf("error: Cannot parse mask input.\n");
8907 memset(&fdir_info, 0, sizeof(fdir_info));
8908 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8909 RTE_ETH_FILTER_INFO, &fdir_info);
8911 printf("Cannot get FDir filter info\n");
8915 if (!strcmp(res->flow_type, "none")) {
8916 /* means don't specify the flow type */
8917 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8918 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8919 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8920 0, sizeof(struct rte_eth_fdir_flex_mask));
8921 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8922 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8924 sizeof(struct rte_eth_fdir_flex_mask));
8925 cmd_reconfig_device_queue(res->port_id, 1, 1);
8928 flow_type_mask = fdir_info.flow_types_mask[0];
8929 if (!strcmp(res->flow_type, "all")) {
8930 if (!flow_type_mask) {
8931 printf("No flow type supported\n");
8934 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8935 if (flow_type_mask & (1 << i)) {
8936 flex_mask.flow_type = i;
8937 fdir_set_flex_mask(res->port_id, &flex_mask);
8940 cmd_reconfig_device_queue(res->port_id, 1, 1);
8943 flex_mask.flow_type = str2flowtype(res->flow_type);
8944 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8945 printf("Flow type %s not supported on port %d\n",
8946 res->flow_type, res->port_id);
8949 fdir_set_flex_mask(res->port_id, &flex_mask);
8950 cmd_reconfig_device_queue(res->port_id, 1, 1);
8953 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8954 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8955 flow_director_flexmask,
8956 "flow_director_flex_mask");
8957 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8958 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8960 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8961 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8963 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8964 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8965 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8966 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8967 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8971 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8972 .f = cmd_flow_director_flex_mask_parsed,
8974 .help_str = "set flow director's flex mask on NIC",
8976 (void *)&cmd_flow_director_flexmask,
8977 (void *)&cmd_flow_director_flexmask_port_id,
8978 (void *)&cmd_flow_director_flexmask_flow,
8979 (void *)&cmd_flow_director_flexmask_flow_type,
8980 (void *)&cmd_flow_director_flexmask_mask,
8985 /* *** deal with flow director flexible payload configuration *** */
8986 struct cmd_flow_director_flexpayload_result {
8987 cmdline_fixed_string_t flow_director_flexpayload;
8989 cmdline_fixed_string_t payload_layer;
8990 cmdline_fixed_string_t payload_cfg;
8994 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8997 const char *p, *p0 = q_arg;
8999 unsigned long int_fld;
9000 char *str_fld[max_num];
9005 p = strchr(p0, '(');
9009 p0 = strchr(p, ')');
9014 if (size >= sizeof(s))
9017 snprintf(s, sizeof(s), "%.*s", size, p);
9018 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9019 if (ret < 0 || ret > max_num)
9021 for (i = 0; i < ret; i++) {
9023 int_fld = strtoul(str_fld[i], &end, 0);
9024 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9026 offsets[i] = (uint16_t)int_fld;
9032 cmd_flow_director_flxpld_parsed(void *parsed_result,
9033 __attribute__((unused)) struct cmdline *cl,
9034 __attribute__((unused)) void *data)
9036 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9037 struct rte_eth_flex_payload_cfg flex_cfg;
9038 struct rte_port *port;
9041 if (res->port_id > nb_ports) {
9042 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9046 port = &ports[res->port_id];
9047 /** Check if the port is not started **/
9048 if (port->port_status != RTE_PORT_STOPPED) {
9049 printf("Please stop port %d first\n", res->port_id);
9053 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9055 if (!strcmp(res->payload_layer, "raw"))
9056 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9057 else if (!strcmp(res->payload_layer, "l2"))
9058 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9059 else if (!strcmp(res->payload_layer, "l3"))
9060 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9061 else if (!strcmp(res->payload_layer, "l4"))
9062 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9064 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9065 RTE_ETH_FDIR_MAX_FLEXLEN);
9067 printf("error: Cannot parse flex payload input.\n");
9071 fdir_set_flex_payload(res->port_id, &flex_cfg);
9072 cmd_reconfig_device_queue(res->port_id, 1, 1);
9075 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9076 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9077 flow_director_flexpayload,
9078 "flow_director_flex_payload");
9079 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9080 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9082 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9083 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9084 payload_layer, "raw#l2#l3#l4");
9085 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9086 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9089 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9090 .f = cmd_flow_director_flxpld_parsed,
9092 .help_str = "set flow director's flex payload on NIC",
9094 (void *)&cmd_flow_director_flexpayload,
9095 (void *)&cmd_flow_director_flexpayload_port_id,
9096 (void *)&cmd_flow_director_flexpayload_payload_layer,
9097 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9102 /* *** Classification Filters Control *** */
9103 /* *** Get symmetric hash enable per port *** */
9104 struct cmd_get_sym_hash_ena_per_port_result {
9105 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9110 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9111 __rte_unused struct cmdline *cl,
9112 __rte_unused void *data)
9114 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9115 struct rte_eth_hash_filter_info info;
9118 if (rte_eth_dev_filter_supported(res->port_id,
9119 RTE_ETH_FILTER_HASH) < 0) {
9120 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9125 memset(&info, 0, sizeof(info));
9126 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9127 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9128 RTE_ETH_FILTER_GET, &info);
9131 printf("Cannot get symmetric hash enable per port "
9132 "on port %u\n", res->port_id);
9136 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9137 "enabled" : "disabled", res->port_id);
9140 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9141 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9142 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9143 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9144 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9147 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9148 .f = cmd_get_sym_hash_per_port_parsed,
9150 .help_str = "get_sym_hash_ena_per_port port_id",
9152 (void *)&cmd_get_sym_hash_ena_per_port_all,
9153 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9158 /* *** Set symmetric hash enable per port *** */
9159 struct cmd_set_sym_hash_ena_per_port_result {
9160 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9161 cmdline_fixed_string_t enable;
9166 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9167 __rte_unused struct cmdline *cl,
9168 __rte_unused void *data)
9170 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9171 struct rte_eth_hash_filter_info info;
9174 if (rte_eth_dev_filter_supported(res->port_id,
9175 RTE_ETH_FILTER_HASH) < 0) {
9176 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9181 memset(&info, 0, sizeof(info));
9182 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9183 if (!strcmp(res->enable, "enable"))
9184 info.info.enable = 1;
9185 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9186 RTE_ETH_FILTER_SET, &info);
9188 printf("Cannot set symmetric hash enable per port on "
9189 "port %u\n", res->port_id);
9192 printf("Symmetric hash has been set to %s on port %u\n",
9193 res->enable, res->port_id);
9196 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9197 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9198 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9199 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9200 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9202 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9203 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9204 enable, "enable#disable");
9206 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9207 .f = cmd_set_sym_hash_per_port_parsed,
9209 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9211 (void *)&cmd_set_sym_hash_ena_per_port_all,
9212 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9213 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9218 /* Get global config of hash function */
9219 struct cmd_get_hash_global_config_result {
9220 cmdline_fixed_string_t get_hash_global_config;
9225 flowtype_to_str(uint16_t ftype)
9232 {"ipv4", RTE_ETH_FLOW_IPV4},
9233 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9234 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9235 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9236 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9237 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9238 {"ipv6", RTE_ETH_FLOW_IPV6},
9239 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9240 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9241 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9242 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9243 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9244 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9247 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9248 if (ftype_table[i].ftype == ftype)
9249 return ftype_table[i].str;
9256 cmd_get_hash_global_config_parsed(void *parsed_result,
9257 __rte_unused struct cmdline *cl,
9258 __rte_unused void *data)
9260 struct cmd_get_hash_global_config_result *res = parsed_result;
9261 struct rte_eth_hash_filter_info info;
9262 uint32_t idx, offset;
9267 if (rte_eth_dev_filter_supported(res->port_id,
9268 RTE_ETH_FILTER_HASH) < 0) {
9269 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9274 memset(&info, 0, sizeof(info));
9275 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9276 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9277 RTE_ETH_FILTER_GET, &info);
9279 printf("Cannot get hash global configurations by port %d\n",
9284 switch (info.info.global_conf.hash_func) {
9285 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9286 printf("Hash function is Toeplitz\n");
9288 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9289 printf("Hash function is Simple XOR\n");
9292 printf("Unknown hash function\n");
9296 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9297 idx = i / UINT32_BIT;
9298 offset = i % UINT32_BIT;
9299 if (!(info.info.global_conf.valid_bit_mask[idx] &
9302 str = flowtype_to_str(i);
9305 printf("Symmetric hash is %s globally for flow type %s "
9307 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9308 (1UL << offset)) ? "enabled" : "disabled"), str,
9313 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9314 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9315 get_hash_global_config, "get_hash_global_config");
9316 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9317 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9320 cmdline_parse_inst_t cmd_get_hash_global_config = {
9321 .f = cmd_get_hash_global_config_parsed,
9323 .help_str = "get_hash_global_config port_id",
9325 (void *)&cmd_get_hash_global_config_all,
9326 (void *)&cmd_get_hash_global_config_port_id,
9331 /* Set global config of hash function */
9332 struct cmd_set_hash_global_config_result {
9333 cmdline_fixed_string_t set_hash_global_config;
9335 cmdline_fixed_string_t hash_func;
9336 cmdline_fixed_string_t flow_type;
9337 cmdline_fixed_string_t enable;
9341 cmd_set_hash_global_config_parsed(void *parsed_result,
9342 __rte_unused struct cmdline *cl,
9343 __rte_unused void *data)
9345 struct cmd_set_hash_global_config_result *res = parsed_result;
9346 struct rte_eth_hash_filter_info info;
9347 uint32_t ftype, idx, offset;
9350 if (rte_eth_dev_filter_supported(res->port_id,
9351 RTE_ETH_FILTER_HASH) < 0) {
9352 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9356 memset(&info, 0, sizeof(info));
9357 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9358 if (!strcmp(res->hash_func, "toeplitz"))
9359 info.info.global_conf.hash_func =
9360 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9361 else if (!strcmp(res->hash_func, "simple_xor"))
9362 info.info.global_conf.hash_func =
9363 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9364 else if (!strcmp(res->hash_func, "default"))
9365 info.info.global_conf.hash_func =
9366 RTE_ETH_HASH_FUNCTION_DEFAULT;
9368 ftype = str2flowtype(res->flow_type);
9369 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9370 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9371 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9372 if (!strcmp(res->enable, "enable"))
9373 info.info.global_conf.sym_hash_enable_mask[idx] |=
9375 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9376 RTE_ETH_FILTER_SET, &info);
9378 printf("Cannot set global hash configurations by port %d\n",
9381 printf("Global hash configurations have been set "
9382 "succcessfully by port %d\n", res->port_id);
9385 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9386 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9387 set_hash_global_config, "set_hash_global_config");
9388 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9389 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9391 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9392 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9393 hash_func, "toeplitz#simple_xor#default");
9394 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9395 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9397 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9398 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9399 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9400 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9401 enable, "enable#disable");
9403 cmdline_parse_inst_t cmd_set_hash_global_config = {
9404 .f = cmd_set_hash_global_config_parsed,
9406 .help_str = "set_hash_global_config port_id "
9407 "toeplitz|simple_xor|default "
9408 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9409 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9412 (void *)&cmd_set_hash_global_config_all,
9413 (void *)&cmd_set_hash_global_config_port_id,
9414 (void *)&cmd_set_hash_global_config_hash_func,
9415 (void *)&cmd_set_hash_global_config_flow_type,
9416 (void *)&cmd_set_hash_global_config_enable,
9421 /* Set hash input set */
9422 struct cmd_set_hash_input_set_result {
9423 cmdline_fixed_string_t set_hash_input_set;
9425 cmdline_fixed_string_t flow_type;
9426 cmdline_fixed_string_t inset_field;
9427 cmdline_fixed_string_t select;
9430 static enum rte_eth_input_set_field
9431 str2inset(char *string)
9435 static const struct {
9437 enum rte_eth_input_set_field inset;
9439 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9440 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9441 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9442 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9443 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9444 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9445 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9446 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9447 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9448 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9449 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9450 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9451 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9452 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9453 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9454 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9455 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9456 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9457 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9458 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9459 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9460 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9461 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9462 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9463 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9464 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9465 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9466 {"none", RTE_ETH_INPUT_SET_NONE},
9469 for (i = 0; i < RTE_DIM(inset_table); i++) {
9470 if (!strcmp(string, inset_table[i].str))
9471 return inset_table[i].inset;
9474 return RTE_ETH_INPUT_SET_UNKNOWN;
9478 cmd_set_hash_input_set_parsed(void *parsed_result,
9479 __rte_unused struct cmdline *cl,
9480 __rte_unused void *data)
9482 struct cmd_set_hash_input_set_result *res = parsed_result;
9483 struct rte_eth_hash_filter_info info;
9485 memset(&info, 0, sizeof(info));
9486 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9487 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9488 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9489 info.info.input_set_conf.inset_size = 1;
9490 if (!strcmp(res->select, "select"))
9491 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9492 else if (!strcmp(res->select, "add"))
9493 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9494 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9495 RTE_ETH_FILTER_SET, &info);
9498 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9499 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9500 set_hash_input_set, "set_hash_input_set");
9501 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9502 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9504 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9505 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9507 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9508 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9509 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9510 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9512 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9513 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9514 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9515 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9516 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9518 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9519 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9520 select, "select#add");
9522 cmdline_parse_inst_t cmd_set_hash_input_set = {
9523 .f = cmd_set_hash_input_set_parsed,
9525 .help_str = "set_hash_input_set <port_id> "
9526 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9527 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9528 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9529 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9530 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9531 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9532 "fld-7th|fld-8th|none select|add",
9534 (void *)&cmd_set_hash_input_set_cmd,
9535 (void *)&cmd_set_hash_input_set_port_id,
9536 (void *)&cmd_set_hash_input_set_flow_type,
9537 (void *)&cmd_set_hash_input_set_field,
9538 (void *)&cmd_set_hash_input_set_select,
9543 /* Set flow director input set */
9544 struct cmd_set_fdir_input_set_result {
9545 cmdline_fixed_string_t set_fdir_input_set;
9547 cmdline_fixed_string_t flow_type;
9548 cmdline_fixed_string_t inset_field;
9549 cmdline_fixed_string_t select;
9553 cmd_set_fdir_input_set_parsed(void *parsed_result,
9554 __rte_unused struct cmdline *cl,
9555 __rte_unused void *data)
9557 struct cmd_set_fdir_input_set_result *res = parsed_result;
9558 struct rte_eth_fdir_filter_info info;
9560 memset(&info, 0, sizeof(info));
9561 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9562 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9563 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9564 info.info.input_set_conf.inset_size = 1;
9565 if (!strcmp(res->select, "select"))
9566 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9567 else if (!strcmp(res->select, "add"))
9568 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9569 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9570 RTE_ETH_FILTER_SET, &info);
9573 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9574 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9575 set_fdir_input_set, "set_fdir_input_set");
9576 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9577 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9579 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9580 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9582 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9583 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9584 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9585 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9587 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9588 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9589 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9590 "fld-7th#fld-8th#none");
9591 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9592 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9593 select, "select#add");
9595 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9596 .f = cmd_set_fdir_input_set_parsed,
9598 .help_str = "set_fdir_input_set <port_id> "
9599 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9600 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9601 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9602 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9603 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9604 "fld-7th|fld-8th|none select|add",
9606 (void *)&cmd_set_fdir_input_set_cmd,
9607 (void *)&cmd_set_fdir_input_set_port_id,
9608 (void *)&cmd_set_fdir_input_set_flow_type,
9609 (void *)&cmd_set_fdir_input_set_field,
9610 (void *)&cmd_set_fdir_input_set_select,
9615 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9616 struct cmd_mcast_addr_result {
9617 cmdline_fixed_string_t mcast_addr_cmd;
9618 cmdline_fixed_string_t what;
9620 struct ether_addr mc_addr;
9623 static void cmd_mcast_addr_parsed(void *parsed_result,
9624 __attribute__((unused)) struct cmdline *cl,
9625 __attribute__((unused)) void *data)
9627 struct cmd_mcast_addr_result *res = parsed_result;
9629 if (!is_multicast_ether_addr(&res->mc_addr)) {
9630 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9631 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9632 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9633 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9636 if (strcmp(res->what, "add") == 0)
9637 mcast_addr_add(res->port_num, &res->mc_addr);
9639 mcast_addr_remove(res->port_num, &res->mc_addr);
9642 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9643 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9644 mcast_addr_cmd, "mcast_addr");
9645 cmdline_parse_token_string_t cmd_mcast_addr_what =
9646 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9648 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9649 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9650 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9651 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9653 cmdline_parse_inst_t cmd_mcast_addr = {
9654 .f = cmd_mcast_addr_parsed,
9656 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9658 (void *)&cmd_mcast_addr_cmd,
9659 (void *)&cmd_mcast_addr_what,
9660 (void *)&cmd_mcast_addr_portnum,
9661 (void *)&cmd_mcast_addr_addr,
9667 * only support E-tag now.
9670 /* Ether type config */
9671 struct cmd_config_l2_tunnel_eth_type_result {
9672 cmdline_fixed_string_t port;
9673 cmdline_fixed_string_t config;
9674 cmdline_fixed_string_t all;
9676 cmdline_fixed_string_t l2_tunnel;
9677 cmdline_fixed_string_t l2_tunnel_type;
9678 cmdline_fixed_string_t eth_type;
9679 uint16_t eth_type_val;
9682 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9683 TOKEN_STRING_INITIALIZER
9684 (struct cmd_config_l2_tunnel_eth_type_result,
9686 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9687 TOKEN_STRING_INITIALIZER
9688 (struct cmd_config_l2_tunnel_eth_type_result,
9690 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9691 TOKEN_STRING_INITIALIZER
9692 (struct cmd_config_l2_tunnel_eth_type_result,
9694 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9695 TOKEN_NUM_INITIALIZER
9696 (struct cmd_config_l2_tunnel_eth_type_result,
9698 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9699 TOKEN_STRING_INITIALIZER
9700 (struct cmd_config_l2_tunnel_eth_type_result,
9701 l2_tunnel, "l2-tunnel");
9702 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9703 TOKEN_STRING_INITIALIZER
9704 (struct cmd_config_l2_tunnel_eth_type_result,
9705 l2_tunnel_type, "E-tag");
9706 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9707 TOKEN_STRING_INITIALIZER
9708 (struct cmd_config_l2_tunnel_eth_type_result,
9709 eth_type, "ether-type");
9710 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9711 TOKEN_NUM_INITIALIZER
9712 (struct cmd_config_l2_tunnel_eth_type_result,
9713 eth_type_val, UINT16);
9716 str2fdir_l2_tunnel_type(char *string)
9720 static const struct {
9723 } l2_tunnel_type_str[] = {
9724 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
9727 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
9728 if (!strcmp(l2_tunnel_type_str[i].str, string))
9729 return l2_tunnel_type_str[i].type;
9731 return RTE_TUNNEL_TYPE_NONE;
9734 /* ether type config for all ports */
9736 cmd_config_l2_tunnel_eth_type_all_parsed
9737 (void *parsed_result,
9738 __attribute__((unused)) struct cmdline *cl,
9739 __attribute__((unused)) void *data)
9741 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
9742 struct rte_eth_l2_tunnel_conf entry;
9745 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9746 entry.ether_type = res->eth_type_val;
9748 FOREACH_PORT(pid, ports) {
9749 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
9753 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
9754 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
9756 .help_str = "port config all l2-tunnel ether-type",
9758 (void *)&cmd_config_l2_tunnel_eth_type_port,
9759 (void *)&cmd_config_l2_tunnel_eth_type_config,
9760 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
9761 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9762 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9763 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9764 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9769 /* ether type config for a specific port */
9771 cmd_config_l2_tunnel_eth_type_specific_parsed(
9772 void *parsed_result,
9773 __attribute__((unused)) struct cmdline *cl,
9774 __attribute__((unused)) void *data)
9776 struct cmd_config_l2_tunnel_eth_type_result *res =
9778 struct rte_eth_l2_tunnel_conf entry;
9780 if (port_id_is_invalid(res->id, ENABLED_WARN))
9783 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9784 entry.ether_type = res->eth_type_val;
9786 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
9789 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
9790 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
9792 .help_str = "port config l2-tunnel ether-type",
9794 (void *)&cmd_config_l2_tunnel_eth_type_port,
9795 (void *)&cmd_config_l2_tunnel_eth_type_config,
9796 (void *)&cmd_config_l2_tunnel_eth_type_id,
9797 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9798 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9799 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9800 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9805 /* Enable/disable l2 tunnel */
9806 struct cmd_config_l2_tunnel_en_dis_result {
9807 cmdline_fixed_string_t port;
9808 cmdline_fixed_string_t config;
9809 cmdline_fixed_string_t all;
9811 cmdline_fixed_string_t l2_tunnel;
9812 cmdline_fixed_string_t l2_tunnel_type;
9813 cmdline_fixed_string_t en_dis;
9816 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
9817 TOKEN_STRING_INITIALIZER
9818 (struct cmd_config_l2_tunnel_en_dis_result,
9820 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
9821 TOKEN_STRING_INITIALIZER
9822 (struct cmd_config_l2_tunnel_en_dis_result,
9824 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
9825 TOKEN_STRING_INITIALIZER
9826 (struct cmd_config_l2_tunnel_en_dis_result,
9828 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
9829 TOKEN_NUM_INITIALIZER
9830 (struct cmd_config_l2_tunnel_en_dis_result,
9832 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
9833 TOKEN_STRING_INITIALIZER
9834 (struct cmd_config_l2_tunnel_en_dis_result,
9835 l2_tunnel, "l2-tunnel");
9836 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
9837 TOKEN_STRING_INITIALIZER
9838 (struct cmd_config_l2_tunnel_en_dis_result,
9839 l2_tunnel_type, "E-tag");
9840 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
9841 TOKEN_STRING_INITIALIZER
9842 (struct cmd_config_l2_tunnel_en_dis_result,
9843 en_dis, "enable#disable");
9845 /* enable/disable l2 tunnel for all ports */
9847 cmd_config_l2_tunnel_en_dis_all_parsed(
9848 void *parsed_result,
9849 __attribute__((unused)) struct cmdline *cl,
9850 __attribute__((unused)) void *data)
9852 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
9853 struct rte_eth_l2_tunnel_conf entry;
9857 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9859 if (!strcmp("enable", res->en_dis))
9864 FOREACH_PORT(pid, ports) {
9865 rte_eth_dev_l2_tunnel_offload_set(pid,
9867 ETH_L2_TUNNEL_ENABLE_MASK,
9872 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
9873 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
9875 .help_str = "port config all l2-tunnel enable/disable",
9877 (void *)&cmd_config_l2_tunnel_en_dis_port,
9878 (void *)&cmd_config_l2_tunnel_en_dis_config,
9879 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
9880 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9881 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9882 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9887 /* enable/disable l2 tunnel for a port */
9889 cmd_config_l2_tunnel_en_dis_specific_parsed(
9890 void *parsed_result,
9891 __attribute__((unused)) struct cmdline *cl,
9892 __attribute__((unused)) void *data)
9894 struct cmd_config_l2_tunnel_en_dis_result *res =
9896 struct rte_eth_l2_tunnel_conf entry;
9898 if (port_id_is_invalid(res->id, ENABLED_WARN))
9901 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9903 if (!strcmp("enable", res->en_dis))
9904 rte_eth_dev_l2_tunnel_offload_set(res->id,
9906 ETH_L2_TUNNEL_ENABLE_MASK,
9909 rte_eth_dev_l2_tunnel_offload_set(res->id,
9911 ETH_L2_TUNNEL_ENABLE_MASK,
9915 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
9916 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
9918 .help_str = "port config l2-tunnel enable/disable",
9920 (void *)&cmd_config_l2_tunnel_en_dis_port,
9921 (void *)&cmd_config_l2_tunnel_en_dis_config,
9922 (void *)&cmd_config_l2_tunnel_en_dis_id,
9923 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9924 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9925 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9930 /* E-tag configuration */
9932 /* Common result structure for all E-tag configuration */
9933 struct cmd_config_e_tag_result {
9934 cmdline_fixed_string_t e_tag;
9935 cmdline_fixed_string_t set;
9936 cmdline_fixed_string_t insertion;
9937 cmdline_fixed_string_t stripping;
9938 cmdline_fixed_string_t forwarding;
9939 cmdline_fixed_string_t filter;
9940 cmdline_fixed_string_t add;
9941 cmdline_fixed_string_t del;
9942 cmdline_fixed_string_t on;
9943 cmdline_fixed_string_t off;
9944 cmdline_fixed_string_t on_off;
9945 cmdline_fixed_string_t port_tag_id;
9946 uint32_t port_tag_id_val;
9947 cmdline_fixed_string_t e_tag_id;
9948 uint16_t e_tag_id_val;
9949 cmdline_fixed_string_t dst_pool;
9950 uint8_t dst_pool_val;
9951 cmdline_fixed_string_t port;
9953 cmdline_fixed_string_t vf;
9957 /* Common CLI fields for all E-tag configuration */
9958 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
9959 TOKEN_STRING_INITIALIZER
9960 (struct cmd_config_e_tag_result,
9962 cmdline_parse_token_string_t cmd_config_e_tag_set =
9963 TOKEN_STRING_INITIALIZER
9964 (struct cmd_config_e_tag_result,
9966 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
9967 TOKEN_STRING_INITIALIZER
9968 (struct cmd_config_e_tag_result,
9969 insertion, "insertion");
9970 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
9971 TOKEN_STRING_INITIALIZER
9972 (struct cmd_config_e_tag_result,
9973 stripping, "stripping");
9974 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
9975 TOKEN_STRING_INITIALIZER
9976 (struct cmd_config_e_tag_result,
9977 forwarding, "forwarding");
9978 cmdline_parse_token_string_t cmd_config_e_tag_filter =
9979 TOKEN_STRING_INITIALIZER
9980 (struct cmd_config_e_tag_result,
9982 cmdline_parse_token_string_t cmd_config_e_tag_add =
9983 TOKEN_STRING_INITIALIZER
9984 (struct cmd_config_e_tag_result,
9986 cmdline_parse_token_string_t cmd_config_e_tag_del =
9987 TOKEN_STRING_INITIALIZER
9988 (struct cmd_config_e_tag_result,
9990 cmdline_parse_token_string_t cmd_config_e_tag_on =
9991 TOKEN_STRING_INITIALIZER
9992 (struct cmd_config_e_tag_result,
9994 cmdline_parse_token_string_t cmd_config_e_tag_off =
9995 TOKEN_STRING_INITIALIZER
9996 (struct cmd_config_e_tag_result,
9998 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
9999 TOKEN_STRING_INITIALIZER
10000 (struct cmd_config_e_tag_result,
10002 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10003 TOKEN_STRING_INITIALIZER
10004 (struct cmd_config_e_tag_result,
10005 port_tag_id, "port-tag-id");
10006 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10007 TOKEN_NUM_INITIALIZER
10008 (struct cmd_config_e_tag_result,
10009 port_tag_id_val, UINT32);
10010 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10011 TOKEN_STRING_INITIALIZER
10012 (struct cmd_config_e_tag_result,
10013 e_tag_id, "e-tag-id");
10014 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10015 TOKEN_NUM_INITIALIZER
10016 (struct cmd_config_e_tag_result,
10017 e_tag_id_val, UINT16);
10018 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10019 TOKEN_STRING_INITIALIZER
10020 (struct cmd_config_e_tag_result,
10021 dst_pool, "dst-pool");
10022 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10023 TOKEN_NUM_INITIALIZER
10024 (struct cmd_config_e_tag_result,
10025 dst_pool_val, UINT8);
10026 cmdline_parse_token_string_t cmd_config_e_tag_port =
10027 TOKEN_STRING_INITIALIZER
10028 (struct cmd_config_e_tag_result,
10030 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10031 TOKEN_NUM_INITIALIZER
10032 (struct cmd_config_e_tag_result,
10034 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10035 TOKEN_STRING_INITIALIZER
10036 (struct cmd_config_e_tag_result,
10038 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10039 TOKEN_NUM_INITIALIZER
10040 (struct cmd_config_e_tag_result,
10043 /* E-tag insertion configuration */
10045 cmd_config_e_tag_insertion_en_parsed(
10046 void *parsed_result,
10047 __attribute__((unused)) struct cmdline *cl,
10048 __attribute__((unused)) void *data)
10050 struct cmd_config_e_tag_result *res =
10052 struct rte_eth_l2_tunnel_conf entry;
10054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10057 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10058 entry.tunnel_id = res->port_tag_id_val;
10059 entry.vf_id = res->vf_id;
10060 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10062 ETH_L2_TUNNEL_INSERTION_MASK,
10067 cmd_config_e_tag_insertion_dis_parsed(
10068 void *parsed_result,
10069 __attribute__((unused)) struct cmdline *cl,
10070 __attribute__((unused)) void *data)
10072 struct cmd_config_e_tag_result *res =
10074 struct rte_eth_l2_tunnel_conf entry;
10076 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10079 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10080 entry.vf_id = res->vf_id;
10082 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10084 ETH_L2_TUNNEL_INSERTION_MASK,
10088 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10089 .f = cmd_config_e_tag_insertion_en_parsed,
10091 .help_str = "E-tag insertion enable",
10093 (void *)&cmd_config_e_tag_e_tag,
10094 (void *)&cmd_config_e_tag_set,
10095 (void *)&cmd_config_e_tag_insertion,
10096 (void *)&cmd_config_e_tag_on,
10097 (void *)&cmd_config_e_tag_port_tag_id,
10098 (void *)&cmd_config_e_tag_port_tag_id_val,
10099 (void *)&cmd_config_e_tag_port,
10100 (void *)&cmd_config_e_tag_port_id,
10101 (void *)&cmd_config_e_tag_vf,
10102 (void *)&cmd_config_e_tag_vf_id,
10107 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10108 .f = cmd_config_e_tag_insertion_dis_parsed,
10110 .help_str = "E-tag insertion disable",
10112 (void *)&cmd_config_e_tag_e_tag,
10113 (void *)&cmd_config_e_tag_set,
10114 (void *)&cmd_config_e_tag_insertion,
10115 (void *)&cmd_config_e_tag_off,
10116 (void *)&cmd_config_e_tag_port,
10117 (void *)&cmd_config_e_tag_port_id,
10118 (void *)&cmd_config_e_tag_vf,
10119 (void *)&cmd_config_e_tag_vf_id,
10124 /* E-tag stripping configuration */
10126 cmd_config_e_tag_stripping_parsed(
10127 void *parsed_result,
10128 __attribute__((unused)) struct cmdline *cl,
10129 __attribute__((unused)) void *data)
10131 struct cmd_config_e_tag_result *res =
10133 struct rte_eth_l2_tunnel_conf entry;
10135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10138 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10140 if (!strcmp(res->on_off, "on"))
10141 rte_eth_dev_l2_tunnel_offload_set
10144 ETH_L2_TUNNEL_STRIPPING_MASK,
10147 rte_eth_dev_l2_tunnel_offload_set
10150 ETH_L2_TUNNEL_STRIPPING_MASK,
10154 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10155 .f = cmd_config_e_tag_stripping_parsed,
10157 .help_str = "E-tag stripping enable/disable",
10159 (void *)&cmd_config_e_tag_e_tag,
10160 (void *)&cmd_config_e_tag_set,
10161 (void *)&cmd_config_e_tag_stripping,
10162 (void *)&cmd_config_e_tag_on_off,
10163 (void *)&cmd_config_e_tag_port,
10164 (void *)&cmd_config_e_tag_port_id,
10169 /* E-tag forwarding configuration */
10171 cmd_config_e_tag_forwarding_parsed(
10172 void *parsed_result,
10173 __attribute__((unused)) struct cmdline *cl,
10174 __attribute__((unused)) void *data)
10176 struct cmd_config_e_tag_result *res = parsed_result;
10177 struct rte_eth_l2_tunnel_conf entry;
10179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10182 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10184 if (!strcmp(res->on_off, "on"))
10185 rte_eth_dev_l2_tunnel_offload_set
10188 ETH_L2_TUNNEL_FORWARDING_MASK,
10191 rte_eth_dev_l2_tunnel_offload_set
10194 ETH_L2_TUNNEL_FORWARDING_MASK,
10198 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10199 .f = cmd_config_e_tag_forwarding_parsed,
10201 .help_str = "E-tag forwarding enable/disable",
10203 (void *)&cmd_config_e_tag_e_tag,
10204 (void *)&cmd_config_e_tag_set,
10205 (void *)&cmd_config_e_tag_forwarding,
10206 (void *)&cmd_config_e_tag_on_off,
10207 (void *)&cmd_config_e_tag_port,
10208 (void *)&cmd_config_e_tag_port_id,
10213 /* E-tag filter configuration */
10215 cmd_config_e_tag_filter_add_parsed(
10216 void *parsed_result,
10217 __attribute__((unused)) struct cmdline *cl,
10218 __attribute__((unused)) void *data)
10220 struct cmd_config_e_tag_result *res = parsed_result;
10221 struct rte_eth_l2_tunnel_conf entry;
10224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10227 if (res->e_tag_id_val > 0x3fff) {
10228 printf("e-tag-id must be equal or less than 0x3fff.\n");
10232 ret = rte_eth_dev_filter_supported(res->port_id,
10233 RTE_ETH_FILTER_L2_TUNNEL);
10235 printf("E-tag filter is not supported on port %u.\n",
10240 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10241 entry.tunnel_id = res->e_tag_id_val;
10242 entry.pool = res->dst_pool_val;
10244 ret = rte_eth_dev_filter_ctrl(res->port_id,
10245 RTE_ETH_FILTER_L2_TUNNEL,
10246 RTE_ETH_FILTER_ADD,
10249 printf("E-tag filter programming error: (%s)\n",
10253 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10254 .f = cmd_config_e_tag_filter_add_parsed,
10256 .help_str = "E-tag filter add",
10258 (void *)&cmd_config_e_tag_e_tag,
10259 (void *)&cmd_config_e_tag_set,
10260 (void *)&cmd_config_e_tag_filter,
10261 (void *)&cmd_config_e_tag_add,
10262 (void *)&cmd_config_e_tag_e_tag_id,
10263 (void *)&cmd_config_e_tag_e_tag_id_val,
10264 (void *)&cmd_config_e_tag_dst_pool,
10265 (void *)&cmd_config_e_tag_dst_pool_val,
10266 (void *)&cmd_config_e_tag_port,
10267 (void *)&cmd_config_e_tag_port_id,
10273 cmd_config_e_tag_filter_del_parsed(
10274 void *parsed_result,
10275 __attribute__((unused)) struct cmdline *cl,
10276 __attribute__((unused)) void *data)
10278 struct cmd_config_e_tag_result *res = parsed_result;
10279 struct rte_eth_l2_tunnel_conf entry;
10282 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10285 if (res->e_tag_id_val > 0x3fff) {
10286 printf("e-tag-id must be less than 0x3fff.\n");
10290 ret = rte_eth_dev_filter_supported(res->port_id,
10291 RTE_ETH_FILTER_L2_TUNNEL);
10293 printf("E-tag filter is not supported on port %u.\n",
10298 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10299 entry.tunnel_id = res->e_tag_id_val;
10301 ret = rte_eth_dev_filter_ctrl(res->port_id,
10302 RTE_ETH_FILTER_L2_TUNNEL,
10303 RTE_ETH_FILTER_DELETE,
10306 printf("E-tag filter programming error: (%s)\n",
10310 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10311 .f = cmd_config_e_tag_filter_del_parsed,
10313 .help_str = "E-tag filter delete",
10315 (void *)&cmd_config_e_tag_e_tag,
10316 (void *)&cmd_config_e_tag_set,
10317 (void *)&cmd_config_e_tag_filter,
10318 (void *)&cmd_config_e_tag_del,
10319 (void *)&cmd_config_e_tag_e_tag_id,
10320 (void *)&cmd_config_e_tag_e_tag_id_val,
10321 (void *)&cmd_config_e_tag_port,
10322 (void *)&cmd_config_e_tag_port_id,
10327 /* ******************************************************************************** */
10329 /* list of instructions */
10330 cmdline_parse_ctx_t main_ctx[] = {
10331 (cmdline_parse_inst_t *)&cmd_help_brief,
10332 (cmdline_parse_inst_t *)&cmd_help_long,
10333 (cmdline_parse_inst_t *)&cmd_quit,
10334 (cmdline_parse_inst_t *)&cmd_showport,
10335 (cmdline_parse_inst_t *)&cmd_showqueue,
10336 (cmdline_parse_inst_t *)&cmd_showportall,
10337 (cmdline_parse_inst_t *)&cmd_showcfg,
10338 (cmdline_parse_inst_t *)&cmd_start,
10339 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10340 (cmdline_parse_inst_t *)&cmd_set_link_up,
10341 (cmdline_parse_inst_t *)&cmd_set_link_down,
10342 (cmdline_parse_inst_t *)&cmd_reset,
10343 (cmdline_parse_inst_t *)&cmd_set_numbers,
10344 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10345 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10346 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10347 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10348 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10349 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10350 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10351 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10352 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10353 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10354 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10355 (cmdline_parse_inst_t *)&cmd_set_link_check,
10356 #ifdef RTE_NIC_BYPASS
10357 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10358 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10359 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10360 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10362 #ifdef RTE_LIBRTE_PMD_BOND
10363 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10364 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10365 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10366 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10367 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10368 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10369 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10370 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10371 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10373 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10374 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10375 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10376 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10377 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10378 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10379 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10380 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10381 (cmdline_parse_inst_t *)&cmd_csum_set,
10382 (cmdline_parse_inst_t *)&cmd_csum_show,
10383 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10384 (cmdline_parse_inst_t *)&cmd_tso_set,
10385 (cmdline_parse_inst_t *)&cmd_tso_show,
10386 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10387 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10388 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10389 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10390 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10391 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10392 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10393 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10394 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10395 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10396 (cmdline_parse_inst_t *)&cmd_config_dcb,
10397 (cmdline_parse_inst_t *)&cmd_read_reg,
10398 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10399 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10400 (cmdline_parse_inst_t *)&cmd_write_reg,
10401 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10402 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10403 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10404 (cmdline_parse_inst_t *)&cmd_stop,
10405 (cmdline_parse_inst_t *)&cmd_mac_addr,
10406 (cmdline_parse_inst_t *)&cmd_set_qmap,
10407 (cmdline_parse_inst_t *)&cmd_operate_port,
10408 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10409 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10410 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10411 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10412 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10413 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10414 (cmdline_parse_inst_t *)&cmd_config_mtu,
10415 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10416 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10417 (cmdline_parse_inst_t *)&cmd_config_rss,
10418 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10419 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10420 (cmdline_parse_inst_t *)&cmd_showport_reta,
10421 (cmdline_parse_inst_t *)&cmd_config_burst,
10422 (cmdline_parse_inst_t *)&cmd_config_thresh,
10423 (cmdline_parse_inst_t *)&cmd_config_threshold,
10424 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10425 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10426 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10427 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10428 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10429 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10430 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10431 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10432 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10433 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10434 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10435 (cmdline_parse_inst_t *)&cmd_global_config,
10436 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10437 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10438 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10439 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10440 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10441 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10442 (cmdline_parse_inst_t *)&cmd_dump,
10443 (cmdline_parse_inst_t *)&cmd_dump_one,
10444 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10445 (cmdline_parse_inst_t *)&cmd_syn_filter,
10446 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10447 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10448 (cmdline_parse_inst_t *)&cmd_flex_filter,
10449 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10450 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10451 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10452 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10453 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10454 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10455 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10456 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10457 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10458 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10459 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10460 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10461 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10462 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10463 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10464 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10465 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10466 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10467 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10468 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10469 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10470 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10471 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10472 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10473 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10474 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10475 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10476 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10477 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10481 /* prompt function, called from main on MASTER lcore */
10485 /* initialize non-constant commands */
10486 cmd_set_fwd_mode_init();
10488 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10489 if (testpmd_cl == NULL)
10491 cmdline_interact(testpmd_cl);
10492 cmdline_stdin_exit(testpmd_cl);
10498 if (testpmd_cl != NULL)
10499 cmdline_quit(testpmd_cl);
10503 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10505 if (id == (portid_t)RTE_PORT_ALL) {
10508 FOREACH_PORT(pid, ports) {
10509 /* check if need_reconfig has been set to 1 */
10510 if (ports[pid].need_reconfig == 0)
10511 ports[pid].need_reconfig = dev;
10512 /* check if need_reconfig_queues has been set to 1 */
10513 if (ports[pid].need_reconfig_queues == 0)
10514 ports[pid].need_reconfig_queues = queue;
10516 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10517 /* check if need_reconfig has been set to 1 */
10518 if (ports[id].need_reconfig == 0)
10519 ports[id].need_reconfig = dev;
10520 /* check if need_reconfig_queues has been set to 1 */
10521 if (ports[id].need_reconfig_queues == 0)
10522 ports[id].need_reconfig_queues = queue;
10526 #ifdef RTE_NIC_BYPASS
10527 #include <rte_pci_dev_ids.h>
10529 bypass_is_supported(portid_t port_id)
10531 struct rte_port *port;
10532 struct rte_pci_id *pci_id;
10534 if (port_id_is_invalid(port_id, ENABLED_WARN))
10537 /* Get the device id. */
10538 port = &ports[port_id];
10539 pci_id = &port->dev_info.pci_dev->id;
10541 /* Check if NIC supports bypass. */
10542 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
10546 printf("\tBypass not supported for port_id = %d.\n", port_id);