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 tunnel_filter_conf.outer_mac = &res->outer_mac;
6673 tunnel_filter_conf.inner_mac = &res->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_add(res->port_id, &tunnel_udp);
6816 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6819 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6822 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6823 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6824 cmd, "rx_vxlan_port");
6825 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6826 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6828 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6829 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6831 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6832 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6835 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6836 .f = cmd_tunnel_udp_config_parsed,
6838 .help_str = "add/rm an tunneling UDP port filter: "
6839 "rx_vxlan_port add udp_port port_id",
6841 (void *)&cmd_tunnel_udp_config_cmd,
6842 (void *)&cmd_tunnel_udp_config_what,
6843 (void *)&cmd_tunnel_udp_config_udp_port,
6844 (void *)&cmd_tunnel_udp_config_port_id,
6849 /* *** GLOBAL CONFIG *** */
6850 struct cmd_global_config_result {
6851 cmdline_fixed_string_t cmd;
6853 cmdline_fixed_string_t cfg_type;
6858 cmd_global_config_parsed(void *parsed_result,
6859 __attribute__((unused)) struct cmdline *cl,
6860 __attribute__((unused)) void *data)
6862 struct cmd_global_config_result *res = parsed_result;
6863 struct rte_eth_global_cfg conf;
6866 memset(&conf, 0, sizeof(conf));
6867 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6868 conf.cfg.gre_key_len = res->len;
6869 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6870 RTE_ETH_FILTER_SET, &conf);
6872 printf("Global config error\n");
6875 cmdline_parse_token_string_t cmd_global_config_cmd =
6876 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6878 cmdline_parse_token_num_t cmd_global_config_port_id =
6879 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6880 cmdline_parse_token_string_t cmd_global_config_type =
6881 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6882 cfg_type, "gre-key-len");
6883 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6884 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6887 cmdline_parse_inst_t cmd_global_config = {
6888 .f = cmd_global_config_parsed,
6889 .data = (void *)NULL,
6890 .help_str = "global_config <port_id> gre-key-len <number>",
6892 (void *)&cmd_global_config_cmd,
6893 (void *)&cmd_global_config_port_id,
6894 (void *)&cmd_global_config_type,
6895 (void *)&cmd_global_config_gre_key_len,
6900 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6901 struct cmd_set_mirror_mask_result {
6902 cmdline_fixed_string_t set;
6903 cmdline_fixed_string_t port;
6905 cmdline_fixed_string_t mirror;
6907 cmdline_fixed_string_t what;
6908 cmdline_fixed_string_t value;
6909 cmdline_fixed_string_t dstpool;
6911 cmdline_fixed_string_t on;
6914 cmdline_parse_token_string_t cmd_mirror_mask_set =
6915 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6917 cmdline_parse_token_string_t cmd_mirror_mask_port =
6918 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6920 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6921 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6923 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6924 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6925 mirror, "mirror-rule");
6926 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6927 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6929 cmdline_parse_token_string_t cmd_mirror_mask_what =
6930 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6931 what, "pool-mirror-up#pool-mirror-down"
6933 cmdline_parse_token_string_t cmd_mirror_mask_value =
6934 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6936 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6937 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6938 dstpool, "dst-pool");
6939 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6940 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6942 cmdline_parse_token_string_t cmd_mirror_mask_on =
6943 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6947 cmd_set_mirror_mask_parsed(void *parsed_result,
6948 __attribute__((unused)) struct cmdline *cl,
6949 __attribute__((unused)) void *data)
6952 struct cmd_set_mirror_mask_result *res = parsed_result;
6953 struct rte_eth_mirror_conf mr_conf;
6955 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6957 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6959 mr_conf.dst_pool = res->dstpool_id;
6961 if (!strcmp(res->what, "pool-mirror-up")) {
6962 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6963 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6964 } else if (!strcmp(res->what, "pool-mirror-down")) {
6965 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6966 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6967 } else if (!strcmp(res->what, "vlan-mirror")) {
6968 mr_conf.rule_type = ETH_MIRROR_VLAN;
6969 nb_item = parse_item_list(res->value, "vlan",
6970 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6974 for (i = 0; i < nb_item; i++) {
6975 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6976 printf("Invalid vlan_id: must be < 4096\n");
6980 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6981 mr_conf.vlan.vlan_mask |= 1ULL << i;
6985 if (!strcmp(res->on, "on"))
6986 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6989 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6992 printf("mirror rule add error: (%s)\n", strerror(-ret));
6995 cmdline_parse_inst_t cmd_set_mirror_mask = {
6996 .f = cmd_set_mirror_mask_parsed,
6998 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6999 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7001 (void *)&cmd_mirror_mask_set,
7002 (void *)&cmd_mirror_mask_port,
7003 (void *)&cmd_mirror_mask_portid,
7004 (void *)&cmd_mirror_mask_mirror,
7005 (void *)&cmd_mirror_mask_ruleid,
7006 (void *)&cmd_mirror_mask_what,
7007 (void *)&cmd_mirror_mask_value,
7008 (void *)&cmd_mirror_mask_dstpool,
7009 (void *)&cmd_mirror_mask_poolid,
7010 (void *)&cmd_mirror_mask_on,
7015 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7016 struct cmd_set_mirror_link_result {
7017 cmdline_fixed_string_t set;
7018 cmdline_fixed_string_t port;
7020 cmdline_fixed_string_t mirror;
7022 cmdline_fixed_string_t what;
7023 cmdline_fixed_string_t dstpool;
7025 cmdline_fixed_string_t on;
7028 cmdline_parse_token_string_t cmd_mirror_link_set =
7029 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7031 cmdline_parse_token_string_t cmd_mirror_link_port =
7032 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7034 cmdline_parse_token_num_t cmd_mirror_link_portid =
7035 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7037 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7038 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7039 mirror, "mirror-rule");
7040 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7041 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7043 cmdline_parse_token_string_t cmd_mirror_link_what =
7044 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7045 what, "uplink-mirror#downlink-mirror");
7046 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7047 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7048 dstpool, "dst-pool");
7049 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7050 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7052 cmdline_parse_token_string_t cmd_mirror_link_on =
7053 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7057 cmd_set_mirror_link_parsed(void *parsed_result,
7058 __attribute__((unused)) struct cmdline *cl,
7059 __attribute__((unused)) void *data)
7062 struct cmd_set_mirror_link_result *res = parsed_result;
7063 struct rte_eth_mirror_conf mr_conf;
7065 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7066 if (!strcmp(res->what, "uplink-mirror"))
7067 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7069 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7071 mr_conf.dst_pool = res->dstpool_id;
7073 if (!strcmp(res->on, "on"))
7074 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7077 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7080 /* check the return value and print it if is < 0 */
7082 printf("mirror rule add error: (%s)\n", strerror(-ret));
7086 cmdline_parse_inst_t cmd_set_mirror_link = {
7087 .f = cmd_set_mirror_link_parsed,
7089 .help_str = "set port X mirror-rule Y uplink-mirror|"
7090 "downlink-mirror dst-pool Z on|off",
7092 (void *)&cmd_mirror_link_set,
7093 (void *)&cmd_mirror_link_port,
7094 (void *)&cmd_mirror_link_portid,
7095 (void *)&cmd_mirror_link_mirror,
7096 (void *)&cmd_mirror_link_ruleid,
7097 (void *)&cmd_mirror_link_what,
7098 (void *)&cmd_mirror_link_dstpool,
7099 (void *)&cmd_mirror_link_poolid,
7100 (void *)&cmd_mirror_link_on,
7105 /* *** RESET VM MIRROR RULE *** */
7106 struct cmd_rm_mirror_rule_result {
7107 cmdline_fixed_string_t reset;
7108 cmdline_fixed_string_t port;
7110 cmdline_fixed_string_t mirror;
7114 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7115 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7117 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7118 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7120 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7121 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7123 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7124 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7125 mirror, "mirror-rule");
7126 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7127 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7131 cmd_reset_mirror_rule_parsed(void *parsed_result,
7132 __attribute__((unused)) struct cmdline *cl,
7133 __attribute__((unused)) void *data)
7136 struct cmd_set_mirror_link_result *res = parsed_result;
7138 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7140 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7143 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7144 .f = cmd_reset_mirror_rule_parsed,
7146 .help_str = "reset port X mirror-rule Y",
7148 (void *)&cmd_rm_mirror_rule_reset,
7149 (void *)&cmd_rm_mirror_rule_port,
7150 (void *)&cmd_rm_mirror_rule_portid,
7151 (void *)&cmd_rm_mirror_rule_mirror,
7152 (void *)&cmd_rm_mirror_rule_ruleid,
7157 /* ******************************************************************************** */
7159 struct cmd_dump_result {
7160 cmdline_fixed_string_t dump;
7164 dump_struct_sizes(void)
7166 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7167 DUMP_SIZE(struct rte_mbuf);
7168 DUMP_SIZE(struct rte_mempool);
7169 DUMP_SIZE(struct rte_ring);
7173 static void cmd_dump_parsed(void *parsed_result,
7174 __attribute__((unused)) struct cmdline *cl,
7175 __attribute__((unused)) void *data)
7177 struct cmd_dump_result *res = parsed_result;
7179 if (!strcmp(res->dump, "dump_physmem"))
7180 rte_dump_physmem_layout(stdout);
7181 else if (!strcmp(res->dump, "dump_memzone"))
7182 rte_memzone_dump(stdout);
7183 else if (!strcmp(res->dump, "dump_log_history"))
7184 rte_log_dump_history(stdout);
7185 else if (!strcmp(res->dump, "dump_struct_sizes"))
7186 dump_struct_sizes();
7187 else if (!strcmp(res->dump, "dump_ring"))
7188 rte_ring_list_dump(stdout);
7189 else if (!strcmp(res->dump, "dump_mempool"))
7190 rte_mempool_list_dump(stdout);
7191 else if (!strcmp(res->dump, "dump_devargs"))
7192 rte_eal_devargs_dump(stdout);
7195 cmdline_parse_token_string_t cmd_dump_dump =
7196 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7200 "dump_struct_sizes#"
7205 cmdline_parse_inst_t cmd_dump = {
7206 .f = cmd_dump_parsed, /* function to call */
7207 .data = NULL, /* 2nd arg of func */
7208 .help_str = "dump status",
7209 .tokens = { /* token list, NULL terminated */
7210 (void *)&cmd_dump_dump,
7215 /* ******************************************************************************** */
7217 struct cmd_dump_one_result {
7218 cmdline_fixed_string_t dump;
7219 cmdline_fixed_string_t name;
7222 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7223 __attribute__((unused)) void *data)
7225 struct cmd_dump_one_result *res = parsed_result;
7227 if (!strcmp(res->dump, "dump_ring")) {
7229 r = rte_ring_lookup(res->name);
7231 cmdline_printf(cl, "Cannot find ring\n");
7234 rte_ring_dump(stdout, r);
7235 } else if (!strcmp(res->dump, "dump_mempool")) {
7236 struct rte_mempool *mp;
7237 mp = rte_mempool_lookup(res->name);
7239 cmdline_printf(cl, "Cannot find mempool\n");
7242 rte_mempool_dump(stdout, mp);
7246 cmdline_parse_token_string_t cmd_dump_one_dump =
7247 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7248 "dump_ring#dump_mempool");
7250 cmdline_parse_token_string_t cmd_dump_one_name =
7251 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7253 cmdline_parse_inst_t cmd_dump_one = {
7254 .f = cmd_dump_one_parsed, /* function to call */
7255 .data = NULL, /* 2nd arg of func */
7256 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7257 .tokens = { /* token list, NULL terminated */
7258 (void *)&cmd_dump_one_dump,
7259 (void *)&cmd_dump_one_name,
7264 /* *** Add/Del syn filter *** */
7265 struct cmd_syn_filter_result {
7266 cmdline_fixed_string_t filter;
7268 cmdline_fixed_string_t ops;
7269 cmdline_fixed_string_t priority;
7270 cmdline_fixed_string_t high;
7271 cmdline_fixed_string_t queue;
7276 cmd_syn_filter_parsed(void *parsed_result,
7277 __attribute__((unused)) struct cmdline *cl,
7278 __attribute__((unused)) void *data)
7280 struct cmd_syn_filter_result *res = parsed_result;
7281 struct rte_eth_syn_filter syn_filter;
7284 ret = rte_eth_dev_filter_supported(res->port_id,
7285 RTE_ETH_FILTER_SYN);
7287 printf("syn filter is not supported on port %u.\n",
7292 memset(&syn_filter, 0, sizeof(syn_filter));
7294 if (!strcmp(res->ops, "add")) {
7295 if (!strcmp(res->high, "high"))
7296 syn_filter.hig_pri = 1;
7298 syn_filter.hig_pri = 0;
7300 syn_filter.queue = res->queue_id;
7301 ret = rte_eth_dev_filter_ctrl(res->port_id,
7306 ret = rte_eth_dev_filter_ctrl(res->port_id,
7308 RTE_ETH_FILTER_DELETE,
7312 printf("syn filter programming error: (%s)\n",
7316 cmdline_parse_token_string_t cmd_syn_filter_filter =
7317 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7318 filter, "syn_filter");
7319 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7320 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7322 cmdline_parse_token_string_t cmd_syn_filter_ops =
7323 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7325 cmdline_parse_token_string_t cmd_syn_filter_priority =
7326 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7327 priority, "priority");
7328 cmdline_parse_token_string_t cmd_syn_filter_high =
7329 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7331 cmdline_parse_token_string_t cmd_syn_filter_queue =
7332 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7334 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7335 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7338 cmdline_parse_inst_t cmd_syn_filter = {
7339 .f = cmd_syn_filter_parsed,
7341 .help_str = "add/delete syn filter",
7343 (void *)&cmd_syn_filter_filter,
7344 (void *)&cmd_syn_filter_port_id,
7345 (void *)&cmd_syn_filter_ops,
7346 (void *)&cmd_syn_filter_priority,
7347 (void *)&cmd_syn_filter_high,
7348 (void *)&cmd_syn_filter_queue,
7349 (void *)&cmd_syn_filter_queue_id,
7354 /* *** ADD/REMOVE A 2tuple FILTER *** */
7355 struct cmd_2tuple_filter_result {
7356 cmdline_fixed_string_t filter;
7358 cmdline_fixed_string_t ops;
7359 cmdline_fixed_string_t dst_port;
7360 uint16_t dst_port_value;
7361 cmdline_fixed_string_t protocol;
7362 uint8_t protocol_value;
7363 cmdline_fixed_string_t mask;
7365 cmdline_fixed_string_t tcp_flags;
7366 uint8_t tcp_flags_value;
7367 cmdline_fixed_string_t priority;
7368 uint8_t priority_value;
7369 cmdline_fixed_string_t queue;
7374 cmd_2tuple_filter_parsed(void *parsed_result,
7375 __attribute__((unused)) struct cmdline *cl,
7376 __attribute__((unused)) void *data)
7378 struct rte_eth_ntuple_filter filter;
7379 struct cmd_2tuple_filter_result *res = parsed_result;
7382 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7384 printf("ntuple filter is not supported on port %u.\n",
7389 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7391 filter.flags = RTE_2TUPLE_FLAGS;
7392 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7393 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7394 filter.proto = res->protocol_value;
7395 filter.priority = res->priority_value;
7396 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7397 printf("nonzero tcp_flags is only meaningful"
7398 " when protocol is TCP.\n");
7401 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7402 printf("invalid TCP flags.\n");
7406 if (res->tcp_flags_value != 0) {
7407 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7408 filter.tcp_flags = res->tcp_flags_value;
7411 /* need convert to big endian. */
7412 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7413 filter.queue = res->queue_id;
7415 if (!strcmp(res->ops, "add"))
7416 ret = rte_eth_dev_filter_ctrl(res->port_id,
7417 RTE_ETH_FILTER_NTUPLE,
7421 ret = rte_eth_dev_filter_ctrl(res->port_id,
7422 RTE_ETH_FILTER_NTUPLE,
7423 RTE_ETH_FILTER_DELETE,
7426 printf("2tuple filter programming error: (%s)\n",
7431 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7432 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7433 filter, "2tuple_filter");
7434 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7435 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7437 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7438 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7440 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7441 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7442 dst_port, "dst_port");
7443 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7444 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7445 dst_port_value, UINT16);
7446 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7447 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7448 protocol, "protocol");
7449 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7450 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7451 protocol_value, UINT8);
7452 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7453 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7455 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7456 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7458 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7459 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7460 tcp_flags, "tcp_flags");
7461 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7462 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7463 tcp_flags_value, UINT8);
7464 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7465 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7466 priority, "priority");
7467 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7468 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7469 priority_value, UINT8);
7470 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7471 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7473 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7474 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7477 cmdline_parse_inst_t cmd_2tuple_filter = {
7478 .f = cmd_2tuple_filter_parsed,
7480 .help_str = "add a 2tuple filter",
7482 (void *)&cmd_2tuple_filter_filter,
7483 (void *)&cmd_2tuple_filter_port_id,
7484 (void *)&cmd_2tuple_filter_ops,
7485 (void *)&cmd_2tuple_filter_dst_port,
7486 (void *)&cmd_2tuple_filter_dst_port_value,
7487 (void *)&cmd_2tuple_filter_protocol,
7488 (void *)&cmd_2tuple_filter_protocol_value,
7489 (void *)&cmd_2tuple_filter_mask,
7490 (void *)&cmd_2tuple_filter_mask_value,
7491 (void *)&cmd_2tuple_filter_tcp_flags,
7492 (void *)&cmd_2tuple_filter_tcp_flags_value,
7493 (void *)&cmd_2tuple_filter_priority,
7494 (void *)&cmd_2tuple_filter_priority_value,
7495 (void *)&cmd_2tuple_filter_queue,
7496 (void *)&cmd_2tuple_filter_queue_id,
7501 /* *** ADD/REMOVE A 5tuple FILTER *** */
7502 struct cmd_5tuple_filter_result {
7503 cmdline_fixed_string_t filter;
7505 cmdline_fixed_string_t ops;
7506 cmdline_fixed_string_t dst_ip;
7507 cmdline_ipaddr_t dst_ip_value;
7508 cmdline_fixed_string_t src_ip;
7509 cmdline_ipaddr_t src_ip_value;
7510 cmdline_fixed_string_t dst_port;
7511 uint16_t dst_port_value;
7512 cmdline_fixed_string_t src_port;
7513 uint16_t src_port_value;
7514 cmdline_fixed_string_t protocol;
7515 uint8_t protocol_value;
7516 cmdline_fixed_string_t mask;
7518 cmdline_fixed_string_t tcp_flags;
7519 uint8_t tcp_flags_value;
7520 cmdline_fixed_string_t priority;
7521 uint8_t priority_value;
7522 cmdline_fixed_string_t queue;
7527 cmd_5tuple_filter_parsed(void *parsed_result,
7528 __attribute__((unused)) struct cmdline *cl,
7529 __attribute__((unused)) void *data)
7531 struct rte_eth_ntuple_filter filter;
7532 struct cmd_5tuple_filter_result *res = parsed_result;
7535 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7537 printf("ntuple filter is not supported on port %u.\n",
7542 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7544 filter.flags = RTE_5TUPLE_FLAGS;
7545 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7546 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7547 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7548 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7549 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7550 filter.proto = res->protocol_value;
7551 filter.priority = res->priority_value;
7552 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7553 printf("nonzero tcp_flags is only meaningful"
7554 " when protocol is TCP.\n");
7557 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7558 printf("invalid TCP flags.\n");
7562 if (res->tcp_flags_value != 0) {
7563 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7564 filter.tcp_flags = res->tcp_flags_value;
7567 if (res->dst_ip_value.family == AF_INET)
7568 /* no need to convert, already big endian. */
7569 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7571 if (filter.dst_ip_mask == 0) {
7572 printf("can not support ipv6 involved compare.\n");
7578 if (res->src_ip_value.family == AF_INET)
7579 /* no need to convert, already big endian. */
7580 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7582 if (filter.src_ip_mask == 0) {
7583 printf("can not support ipv6 involved compare.\n");
7588 /* need convert to big endian. */
7589 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7590 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7591 filter.queue = res->queue_id;
7593 if (!strcmp(res->ops, "add"))
7594 ret = rte_eth_dev_filter_ctrl(res->port_id,
7595 RTE_ETH_FILTER_NTUPLE,
7599 ret = rte_eth_dev_filter_ctrl(res->port_id,
7600 RTE_ETH_FILTER_NTUPLE,
7601 RTE_ETH_FILTER_DELETE,
7604 printf("5tuple filter programming error: (%s)\n",
7608 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7609 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7610 filter, "5tuple_filter");
7611 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7612 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7614 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7615 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7617 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7618 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7620 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7621 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7623 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7624 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7626 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7627 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7629 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7630 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7631 dst_port, "dst_port");
7632 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7633 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7634 dst_port_value, UINT16);
7635 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7636 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7637 src_port, "src_port");
7638 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7639 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7640 src_port_value, UINT16);
7641 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7642 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7643 protocol, "protocol");
7644 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7645 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7646 protocol_value, UINT8);
7647 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7648 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7650 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7651 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7653 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7654 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7655 tcp_flags, "tcp_flags");
7656 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7657 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7658 tcp_flags_value, UINT8);
7659 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7660 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7661 priority, "priority");
7662 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7663 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7664 priority_value, UINT8);
7665 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7666 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7668 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7669 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7672 cmdline_parse_inst_t cmd_5tuple_filter = {
7673 .f = cmd_5tuple_filter_parsed,
7675 .help_str = "add/del a 5tuple filter",
7677 (void *)&cmd_5tuple_filter_filter,
7678 (void *)&cmd_5tuple_filter_port_id,
7679 (void *)&cmd_5tuple_filter_ops,
7680 (void *)&cmd_5tuple_filter_dst_ip,
7681 (void *)&cmd_5tuple_filter_dst_ip_value,
7682 (void *)&cmd_5tuple_filter_src_ip,
7683 (void *)&cmd_5tuple_filter_src_ip_value,
7684 (void *)&cmd_5tuple_filter_dst_port,
7685 (void *)&cmd_5tuple_filter_dst_port_value,
7686 (void *)&cmd_5tuple_filter_src_port,
7687 (void *)&cmd_5tuple_filter_src_port_value,
7688 (void *)&cmd_5tuple_filter_protocol,
7689 (void *)&cmd_5tuple_filter_protocol_value,
7690 (void *)&cmd_5tuple_filter_mask,
7691 (void *)&cmd_5tuple_filter_mask_value,
7692 (void *)&cmd_5tuple_filter_tcp_flags,
7693 (void *)&cmd_5tuple_filter_tcp_flags_value,
7694 (void *)&cmd_5tuple_filter_priority,
7695 (void *)&cmd_5tuple_filter_priority_value,
7696 (void *)&cmd_5tuple_filter_queue,
7697 (void *)&cmd_5tuple_filter_queue_id,
7702 /* *** ADD/REMOVE A flex FILTER *** */
7703 struct cmd_flex_filter_result {
7704 cmdline_fixed_string_t filter;
7705 cmdline_fixed_string_t ops;
7707 cmdline_fixed_string_t len;
7709 cmdline_fixed_string_t bytes;
7710 cmdline_fixed_string_t bytes_value;
7711 cmdline_fixed_string_t mask;
7712 cmdline_fixed_string_t mask_value;
7713 cmdline_fixed_string_t priority;
7714 uint8_t priority_value;
7715 cmdline_fixed_string_t queue;
7719 static int xdigit2val(unsigned char c)
7724 else if (isupper(c))
7732 cmd_flex_filter_parsed(void *parsed_result,
7733 __attribute__((unused)) struct cmdline *cl,
7734 __attribute__((unused)) void *data)
7737 struct rte_eth_flex_filter filter;
7738 struct cmd_flex_filter_result *res = parsed_result;
7739 char *bytes_ptr, *mask_ptr;
7740 uint16_t len, i, j = 0;
7745 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7746 printf("the len exceed the max length 128\n");
7749 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7750 filter.len = res->len_value;
7751 filter.priority = res->priority_value;
7752 filter.queue = res->queue_id;
7753 bytes_ptr = res->bytes_value;
7754 mask_ptr = res->mask_value;
7756 /* translate bytes string to array. */
7757 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7758 (bytes_ptr[1] == 'X')))
7760 len = strnlen(bytes_ptr, res->len_value * 2);
7761 if (len == 0 || (len % 8 != 0)) {
7762 printf("please check len and bytes input\n");
7765 for (i = 0; i < len; i++) {
7767 if (isxdigit(c) == 0) {
7768 /* invalid characters. */
7769 printf("invalid input\n");
7772 val = xdigit2val(c);
7775 filter.bytes[j] = byte;
7776 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7783 /* translate mask string to uint8_t array. */
7784 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7785 (mask_ptr[1] == 'X')))
7787 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7789 printf("invalid input\n");
7794 for (i = 0; i < len; i++) {
7796 if (isxdigit(c) == 0) {
7797 /* invalid characters. */
7798 printf("invalid input\n");
7801 val = xdigit2val(c);
7804 filter.mask[j] = byte;
7805 printf("mask[%d]:%02x ", j, filter.mask[j]);
7813 if (!strcmp(res->ops, "add"))
7814 ret = rte_eth_dev_filter_ctrl(res->port_id,
7815 RTE_ETH_FILTER_FLEXIBLE,
7819 ret = rte_eth_dev_filter_ctrl(res->port_id,
7820 RTE_ETH_FILTER_FLEXIBLE,
7821 RTE_ETH_FILTER_DELETE,
7825 printf("flex filter setting error: (%s)\n", strerror(-ret));
7828 cmdline_parse_token_string_t cmd_flex_filter_filter =
7829 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7830 filter, "flex_filter");
7831 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7832 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7834 cmdline_parse_token_string_t cmd_flex_filter_ops =
7835 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7837 cmdline_parse_token_string_t cmd_flex_filter_len =
7838 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7840 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7841 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7843 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7844 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7846 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7847 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7849 cmdline_parse_token_string_t cmd_flex_filter_mask =
7850 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7852 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7853 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7855 cmdline_parse_token_string_t cmd_flex_filter_priority =
7856 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7857 priority, "priority");
7858 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7859 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7860 priority_value, UINT8);
7861 cmdline_parse_token_string_t cmd_flex_filter_queue =
7862 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7864 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7865 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7867 cmdline_parse_inst_t cmd_flex_filter = {
7868 .f = cmd_flex_filter_parsed,
7870 .help_str = "add/del a flex filter",
7872 (void *)&cmd_flex_filter_filter,
7873 (void *)&cmd_flex_filter_port_id,
7874 (void *)&cmd_flex_filter_ops,
7875 (void *)&cmd_flex_filter_len,
7876 (void *)&cmd_flex_filter_len_value,
7877 (void *)&cmd_flex_filter_bytes,
7878 (void *)&cmd_flex_filter_bytes_value,
7879 (void *)&cmd_flex_filter_mask,
7880 (void *)&cmd_flex_filter_mask_value,
7881 (void *)&cmd_flex_filter_priority,
7882 (void *)&cmd_flex_filter_priority_value,
7883 (void *)&cmd_flex_filter_queue,
7884 (void *)&cmd_flex_filter_queue_id,
7889 /* *** Filters Control *** */
7891 /* *** deal with ethertype filter *** */
7892 struct cmd_ethertype_filter_result {
7893 cmdline_fixed_string_t filter;
7895 cmdline_fixed_string_t ops;
7896 cmdline_fixed_string_t mac;
7897 struct ether_addr mac_addr;
7898 cmdline_fixed_string_t ethertype;
7899 uint16_t ethertype_value;
7900 cmdline_fixed_string_t drop;
7901 cmdline_fixed_string_t queue;
7905 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7906 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7907 filter, "ethertype_filter");
7908 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7909 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7911 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7912 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7914 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7915 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7916 mac, "mac_addr#mac_ignr");
7917 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7918 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7920 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7921 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7922 ethertype, "ethertype");
7923 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7924 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7925 ethertype_value, UINT16);
7926 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7927 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7929 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7930 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7932 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7933 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7937 cmd_ethertype_filter_parsed(void *parsed_result,
7938 __attribute__((unused)) struct cmdline *cl,
7939 __attribute__((unused)) void *data)
7941 struct cmd_ethertype_filter_result *res = parsed_result;
7942 struct rte_eth_ethertype_filter filter;
7945 ret = rte_eth_dev_filter_supported(res->port_id,
7946 RTE_ETH_FILTER_ETHERTYPE);
7948 printf("ethertype filter is not supported on port %u.\n",
7953 memset(&filter, 0, sizeof(filter));
7954 if (!strcmp(res->mac, "mac_addr")) {
7955 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7956 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7957 sizeof(struct ether_addr));
7959 if (!strcmp(res->drop, "drop"))
7960 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7961 filter.ether_type = res->ethertype_value;
7962 filter.queue = res->queue_id;
7964 if (!strcmp(res->ops, "add"))
7965 ret = rte_eth_dev_filter_ctrl(res->port_id,
7966 RTE_ETH_FILTER_ETHERTYPE,
7970 ret = rte_eth_dev_filter_ctrl(res->port_id,
7971 RTE_ETH_FILTER_ETHERTYPE,
7972 RTE_ETH_FILTER_DELETE,
7975 printf("ethertype filter programming error: (%s)\n",
7979 cmdline_parse_inst_t cmd_ethertype_filter = {
7980 .f = cmd_ethertype_filter_parsed,
7982 .help_str = "add or delete an ethertype filter entry",
7984 (void *)&cmd_ethertype_filter_filter,
7985 (void *)&cmd_ethertype_filter_port_id,
7986 (void *)&cmd_ethertype_filter_ops,
7987 (void *)&cmd_ethertype_filter_mac,
7988 (void *)&cmd_ethertype_filter_mac_addr,
7989 (void *)&cmd_ethertype_filter_ethertype,
7990 (void *)&cmd_ethertype_filter_ethertype_value,
7991 (void *)&cmd_ethertype_filter_drop,
7992 (void *)&cmd_ethertype_filter_queue,
7993 (void *)&cmd_ethertype_filter_queue_id,
7998 /* *** deal with flow director filter *** */
7999 struct cmd_flow_director_result {
8000 cmdline_fixed_string_t flow_director_filter;
8002 cmdline_fixed_string_t mode;
8003 cmdline_fixed_string_t mode_value;
8004 cmdline_fixed_string_t ops;
8005 cmdline_fixed_string_t flow;
8006 cmdline_fixed_string_t flow_type;
8007 cmdline_fixed_string_t ether;
8008 uint16_t ether_type;
8009 cmdline_fixed_string_t src;
8010 cmdline_ipaddr_t ip_src;
8012 cmdline_fixed_string_t dst;
8013 cmdline_ipaddr_t ip_dst;
8015 cmdline_fixed_string_t verify_tag;
8016 uint32_t verify_tag_value;
8017 cmdline_fixed_string_t vlan;
8018 uint16_t vlan_value;
8019 cmdline_fixed_string_t flexbytes;
8020 cmdline_fixed_string_t flexbytes_value;
8021 cmdline_fixed_string_t pf_vf;
8022 cmdline_fixed_string_t drop;
8023 cmdline_fixed_string_t queue;
8025 cmdline_fixed_string_t fd_id;
8026 uint32_t fd_id_value;
8027 cmdline_fixed_string_t mac;
8028 struct ether_addr mac_addr;
8029 cmdline_fixed_string_t tunnel;
8030 cmdline_fixed_string_t tunnel_type;
8031 cmdline_fixed_string_t tunnel_id;
8032 uint32_t tunnel_id_value;
8036 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8039 const char *p, *p0 = q_arg;
8041 unsigned long int_fld;
8042 char *str_fld[max_num];
8047 p = strchr(p0, '(');
8051 p0 = strchr(p, ')');
8056 if (size >= sizeof(s))
8059 snprintf(s, sizeof(s), "%.*s", size, p);
8060 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8061 if (ret < 0 || ret > max_num)
8063 for (i = 0; i < ret; i++) {
8065 int_fld = strtoul(str_fld[i], &end, 0);
8066 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8068 flexbytes[i] = (uint8_t)int_fld;
8074 str2flowtype(char *string)
8077 static const struct {
8080 } flowtype_str[] = {
8081 {"raw", RTE_ETH_FLOW_RAW},
8082 {"ipv4", RTE_ETH_FLOW_IPV4},
8083 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8084 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8085 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8086 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8087 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8088 {"ipv6", RTE_ETH_FLOW_IPV6},
8089 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8090 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8091 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8092 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8093 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8094 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8097 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8098 if (!strcmp(flowtype_str[i].str, string))
8099 return flowtype_str[i].type;
8101 return RTE_ETH_FLOW_UNKNOWN;
8104 static enum rte_eth_fdir_tunnel_type
8105 str2fdir_tunneltype(char *string)
8109 static const struct {
8111 enum rte_eth_fdir_tunnel_type type;
8112 } tunneltype_str[] = {
8113 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8114 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8117 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8118 if (!strcmp(tunneltype_str[i].str, string))
8119 return tunneltype_str[i].type;
8121 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8124 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8126 if ((ip_addr).family == AF_INET) \
8127 (ip) = (ip_addr).addr.ipv4.s_addr; \
8129 printf("invalid parameter.\n"); \
8134 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8136 if ((ip_addr).family == AF_INET6) \
8137 (void)rte_memcpy(&(ip), \
8138 &((ip_addr).addr.ipv6), \
8139 sizeof(struct in6_addr)); \
8141 printf("invalid parameter.\n"); \
8147 cmd_flow_director_filter_parsed(void *parsed_result,
8148 __attribute__((unused)) struct cmdline *cl,
8149 __attribute__((unused)) void *data)
8151 struct cmd_flow_director_result *res = parsed_result;
8152 struct rte_eth_fdir_filter entry;
8153 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8155 unsigned long vf_id;
8158 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8160 printf("flow director is not supported on port %u.\n",
8164 memset(flexbytes, 0, sizeof(flexbytes));
8165 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8167 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8168 if (strcmp(res->mode_value, "MAC-VLAN")) {
8169 printf("Please set mode to MAC-VLAN.\n");
8172 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8173 if (strcmp(res->mode_value, "Tunnel")) {
8174 printf("Please set mode to Tunnel.\n");
8178 if (strcmp(res->mode_value, "IP")) {
8179 printf("Please set mode to IP.\n");
8182 entry.input.flow_type = str2flowtype(res->flow_type);
8185 ret = parse_flexbytes(res->flexbytes_value,
8187 RTE_ETH_FDIR_MAX_FLEXLEN);
8189 printf("error: Cannot parse flexbytes input.\n");
8193 switch (entry.input.flow_type) {
8194 case RTE_ETH_FLOW_FRAG_IPV4:
8195 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8196 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8197 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8198 IPV4_ADDR_TO_UINT(res->ip_dst,
8199 entry.input.flow.ip4_flow.dst_ip);
8200 IPV4_ADDR_TO_UINT(res->ip_src,
8201 entry.input.flow.ip4_flow.src_ip);
8202 /* need convert to big endian. */
8203 entry.input.flow.udp4_flow.dst_port =
8204 rte_cpu_to_be_16(res->port_dst);
8205 entry.input.flow.udp4_flow.src_port =
8206 rte_cpu_to_be_16(res->port_src);
8208 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8209 IPV4_ADDR_TO_UINT(res->ip_dst,
8210 entry.input.flow.sctp4_flow.ip.dst_ip);
8211 IPV4_ADDR_TO_UINT(res->ip_src,
8212 entry.input.flow.sctp4_flow.ip.src_ip);
8213 /* need convert to big endian. */
8214 entry.input.flow.sctp4_flow.dst_port =
8215 rte_cpu_to_be_16(res->port_dst);
8216 entry.input.flow.sctp4_flow.src_port =
8217 rte_cpu_to_be_16(res->port_src);
8218 entry.input.flow.sctp4_flow.verify_tag =
8219 rte_cpu_to_be_32(res->verify_tag_value);
8221 case RTE_ETH_FLOW_FRAG_IPV6:
8222 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8223 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8224 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8225 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8226 entry.input.flow.ipv6_flow.dst_ip);
8227 IPV6_ADDR_TO_ARRAY(res->ip_src,
8228 entry.input.flow.ipv6_flow.src_ip);
8229 /* need convert to big endian. */
8230 entry.input.flow.udp6_flow.dst_port =
8231 rte_cpu_to_be_16(res->port_dst);
8232 entry.input.flow.udp6_flow.src_port =
8233 rte_cpu_to_be_16(res->port_src);
8235 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8236 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8237 entry.input.flow.sctp6_flow.ip.dst_ip);
8238 IPV6_ADDR_TO_ARRAY(res->ip_src,
8239 entry.input.flow.sctp6_flow.ip.src_ip);
8240 /* need convert to big endian. */
8241 entry.input.flow.sctp6_flow.dst_port =
8242 rte_cpu_to_be_16(res->port_dst);
8243 entry.input.flow.sctp6_flow.src_port =
8244 rte_cpu_to_be_16(res->port_src);
8245 entry.input.flow.sctp6_flow.verify_tag =
8246 rte_cpu_to_be_32(res->verify_tag_value);
8248 case RTE_ETH_FLOW_L2_PAYLOAD:
8249 entry.input.flow.l2_flow.ether_type =
8250 rte_cpu_to_be_16(res->ether_type);
8256 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8257 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8259 sizeof(struct ether_addr));
8261 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8262 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8264 sizeof(struct ether_addr));
8265 entry.input.flow.tunnel_flow.tunnel_type =
8266 str2fdir_tunneltype(res->tunnel_type);
8267 entry.input.flow.tunnel_flow.tunnel_id =
8268 rte_cpu_to_be_32(res->tunnel_id_value);
8271 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8273 RTE_ETH_FDIR_MAX_FLEXLEN);
8275 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8277 entry.action.flex_off = 0; /*use 0 by default */
8278 if (!strcmp(res->drop, "drop"))
8279 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8281 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8283 if (!strcmp(res->pf_vf, "pf"))
8284 entry.input.flow_ext.is_vf = 0;
8285 else if (!strncmp(res->pf_vf, "vf", 2)) {
8286 struct rte_eth_dev_info dev_info;
8288 memset(&dev_info, 0, sizeof(dev_info));
8289 rte_eth_dev_info_get(res->port_id, &dev_info);
8291 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8292 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8293 printf("invalid parameter %s.\n", res->pf_vf);
8296 entry.input.flow_ext.is_vf = 1;
8297 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8299 printf("invalid parameter %s.\n", res->pf_vf);
8303 /* set to report FD ID by default */
8304 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8305 entry.action.rx_queue = res->queue_id;
8306 entry.soft_id = res->fd_id_value;
8307 if (!strcmp(res->ops, "add"))
8308 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8309 RTE_ETH_FILTER_ADD, &entry);
8310 else if (!strcmp(res->ops, "del"))
8311 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8312 RTE_ETH_FILTER_DELETE, &entry);
8314 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8315 RTE_ETH_FILTER_UPDATE, &entry);
8317 printf("flow director programming error: (%s)\n",
8321 cmdline_parse_token_string_t cmd_flow_director_filter =
8322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8323 flow_director_filter, "flow_director_filter");
8324 cmdline_parse_token_num_t cmd_flow_director_port_id =
8325 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8327 cmdline_parse_token_string_t cmd_flow_director_ops =
8328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8329 ops, "add#del#update");
8330 cmdline_parse_token_string_t cmd_flow_director_flow =
8331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8333 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8335 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8336 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8337 cmdline_parse_token_string_t cmd_flow_director_ether =
8338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8340 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8341 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8342 ether_type, UINT16);
8343 cmdline_parse_token_string_t cmd_flow_director_src =
8344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8346 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8347 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8349 cmdline_parse_token_num_t cmd_flow_director_port_src =
8350 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8352 cmdline_parse_token_string_t cmd_flow_director_dst =
8353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8355 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8356 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8358 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8359 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8361 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8363 verify_tag, "verify_tag");
8364 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8365 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8366 verify_tag_value, UINT32);
8367 cmdline_parse_token_string_t cmd_flow_director_vlan =
8368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8370 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8371 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8372 vlan_value, UINT16);
8373 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8375 flexbytes, "flexbytes");
8376 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8378 flexbytes_value, NULL);
8379 cmdline_parse_token_string_t cmd_flow_director_drop =
8380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8382 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8385 cmdline_parse_token_string_t cmd_flow_director_queue =
8386 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8388 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8389 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8391 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8392 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8394 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8395 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8396 fd_id_value, UINT32);
8398 cmdline_parse_token_string_t cmd_flow_director_mode =
8399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8401 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8404 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8406 mode_value, "MAC-VLAN");
8407 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8408 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8409 mode_value, "Tunnel");
8410 cmdline_parse_token_string_t cmd_flow_director_mac =
8411 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8413 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8414 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8416 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8419 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8420 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8421 tunnel_type, "NVGRE#VxLAN");
8422 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8423 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8424 tunnel_id, "tunnel-id");
8425 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8426 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8427 tunnel_id_value, UINT32);
8429 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8430 .f = cmd_flow_director_filter_parsed,
8432 .help_str = "add or delete an ip flow director entry on NIC",
8434 (void *)&cmd_flow_director_filter,
8435 (void *)&cmd_flow_director_port_id,
8436 (void *)&cmd_flow_director_mode,
8437 (void *)&cmd_flow_director_mode_ip,
8438 (void *)&cmd_flow_director_ops,
8439 (void *)&cmd_flow_director_flow,
8440 (void *)&cmd_flow_director_flow_type,
8441 (void *)&cmd_flow_director_src,
8442 (void *)&cmd_flow_director_ip_src,
8443 (void *)&cmd_flow_director_dst,
8444 (void *)&cmd_flow_director_ip_dst,
8445 (void *)&cmd_flow_director_vlan,
8446 (void *)&cmd_flow_director_vlan_value,
8447 (void *)&cmd_flow_director_flexbytes,
8448 (void *)&cmd_flow_director_flexbytes_value,
8449 (void *)&cmd_flow_director_drop,
8450 (void *)&cmd_flow_director_pf_vf,
8451 (void *)&cmd_flow_director_queue,
8452 (void *)&cmd_flow_director_queue_id,
8453 (void *)&cmd_flow_director_fd_id,
8454 (void *)&cmd_flow_director_fd_id_value,
8459 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8460 .f = cmd_flow_director_filter_parsed,
8462 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8464 (void *)&cmd_flow_director_filter,
8465 (void *)&cmd_flow_director_port_id,
8466 (void *)&cmd_flow_director_mode,
8467 (void *)&cmd_flow_director_mode_ip,
8468 (void *)&cmd_flow_director_ops,
8469 (void *)&cmd_flow_director_flow,
8470 (void *)&cmd_flow_director_flow_type,
8471 (void *)&cmd_flow_director_src,
8472 (void *)&cmd_flow_director_ip_src,
8473 (void *)&cmd_flow_director_port_src,
8474 (void *)&cmd_flow_director_dst,
8475 (void *)&cmd_flow_director_ip_dst,
8476 (void *)&cmd_flow_director_port_dst,
8477 (void *)&cmd_flow_director_vlan,
8478 (void *)&cmd_flow_director_vlan_value,
8479 (void *)&cmd_flow_director_flexbytes,
8480 (void *)&cmd_flow_director_flexbytes_value,
8481 (void *)&cmd_flow_director_drop,
8482 (void *)&cmd_flow_director_pf_vf,
8483 (void *)&cmd_flow_director_queue,
8484 (void *)&cmd_flow_director_queue_id,
8485 (void *)&cmd_flow_director_fd_id,
8486 (void *)&cmd_flow_director_fd_id_value,
8491 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8492 .f = cmd_flow_director_filter_parsed,
8494 .help_str = "add or delete a sctp flow director entry on NIC",
8496 (void *)&cmd_flow_director_filter,
8497 (void *)&cmd_flow_director_port_id,
8498 (void *)&cmd_flow_director_mode,
8499 (void *)&cmd_flow_director_mode_ip,
8500 (void *)&cmd_flow_director_ops,
8501 (void *)&cmd_flow_director_flow,
8502 (void *)&cmd_flow_director_flow_type,
8503 (void *)&cmd_flow_director_src,
8504 (void *)&cmd_flow_director_ip_src,
8505 (void *)&cmd_flow_director_port_dst,
8506 (void *)&cmd_flow_director_dst,
8507 (void *)&cmd_flow_director_ip_dst,
8508 (void *)&cmd_flow_director_port_dst,
8509 (void *)&cmd_flow_director_verify_tag,
8510 (void *)&cmd_flow_director_verify_tag_value,
8511 (void *)&cmd_flow_director_vlan,
8512 (void *)&cmd_flow_director_vlan_value,
8513 (void *)&cmd_flow_director_flexbytes,
8514 (void *)&cmd_flow_director_flexbytes_value,
8515 (void *)&cmd_flow_director_drop,
8516 (void *)&cmd_flow_director_pf_vf,
8517 (void *)&cmd_flow_director_queue,
8518 (void *)&cmd_flow_director_queue_id,
8519 (void *)&cmd_flow_director_fd_id,
8520 (void *)&cmd_flow_director_fd_id_value,
8525 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8526 .f = cmd_flow_director_filter_parsed,
8528 .help_str = "add or delete a L2 flow director entry on NIC",
8530 (void *)&cmd_flow_director_filter,
8531 (void *)&cmd_flow_director_port_id,
8532 (void *)&cmd_flow_director_mode,
8533 (void *)&cmd_flow_director_mode_ip,
8534 (void *)&cmd_flow_director_ops,
8535 (void *)&cmd_flow_director_flow,
8536 (void *)&cmd_flow_director_flow_type,
8537 (void *)&cmd_flow_director_ether,
8538 (void *)&cmd_flow_director_ether_type,
8539 (void *)&cmd_flow_director_flexbytes,
8540 (void *)&cmd_flow_director_flexbytes_value,
8541 (void *)&cmd_flow_director_drop,
8542 (void *)&cmd_flow_director_pf_vf,
8543 (void *)&cmd_flow_director_queue,
8544 (void *)&cmd_flow_director_queue_id,
8545 (void *)&cmd_flow_director_fd_id,
8546 (void *)&cmd_flow_director_fd_id_value,
8551 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8552 .f = cmd_flow_director_filter_parsed,
8554 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8556 (void *)&cmd_flow_director_filter,
8557 (void *)&cmd_flow_director_port_id,
8558 (void *)&cmd_flow_director_mode,
8559 (void *)&cmd_flow_director_mode_mac_vlan,
8560 (void *)&cmd_flow_director_ops,
8561 (void *)&cmd_flow_director_mac,
8562 (void *)&cmd_flow_director_mac_addr,
8563 (void *)&cmd_flow_director_vlan,
8564 (void *)&cmd_flow_director_vlan_value,
8565 (void *)&cmd_flow_director_flexbytes,
8566 (void *)&cmd_flow_director_flexbytes_value,
8567 (void *)&cmd_flow_director_drop,
8568 (void *)&cmd_flow_director_queue,
8569 (void *)&cmd_flow_director_queue_id,
8570 (void *)&cmd_flow_director_fd_id,
8571 (void *)&cmd_flow_director_fd_id_value,
8576 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8577 .f = cmd_flow_director_filter_parsed,
8579 .help_str = "add or delete a tunnel flow director entry on NIC",
8581 (void *)&cmd_flow_director_filter,
8582 (void *)&cmd_flow_director_port_id,
8583 (void *)&cmd_flow_director_mode,
8584 (void *)&cmd_flow_director_mode_tunnel,
8585 (void *)&cmd_flow_director_ops,
8586 (void *)&cmd_flow_director_mac,
8587 (void *)&cmd_flow_director_mac_addr,
8588 (void *)&cmd_flow_director_vlan,
8589 (void *)&cmd_flow_director_vlan_value,
8590 (void *)&cmd_flow_director_tunnel,
8591 (void *)&cmd_flow_director_tunnel_type,
8592 (void *)&cmd_flow_director_tunnel_id,
8593 (void *)&cmd_flow_director_tunnel_id_value,
8594 (void *)&cmd_flow_director_flexbytes,
8595 (void *)&cmd_flow_director_flexbytes_value,
8596 (void *)&cmd_flow_director_drop,
8597 (void *)&cmd_flow_director_queue,
8598 (void *)&cmd_flow_director_queue_id,
8599 (void *)&cmd_flow_director_fd_id,
8600 (void *)&cmd_flow_director_fd_id_value,
8605 struct cmd_flush_flow_director_result {
8606 cmdline_fixed_string_t flush_flow_director;
8610 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8611 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8612 flush_flow_director, "flush_flow_director");
8613 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8614 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8618 cmd_flush_flow_director_parsed(void *parsed_result,
8619 __attribute__((unused)) struct cmdline *cl,
8620 __attribute__((unused)) void *data)
8622 struct cmd_flow_director_result *res = parsed_result;
8625 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8627 printf("flow director is not supported on port %u.\n",
8632 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8633 RTE_ETH_FILTER_FLUSH, NULL);
8635 printf("flow director table flushing error: (%s)\n",
8639 cmdline_parse_inst_t cmd_flush_flow_director = {
8640 .f = cmd_flush_flow_director_parsed,
8642 .help_str = "flush all flow director entries of a device on NIC",
8644 (void *)&cmd_flush_flow_director_flush,
8645 (void *)&cmd_flush_flow_director_port_id,
8650 /* *** deal with flow director mask *** */
8651 struct cmd_flow_director_mask_result {
8652 cmdline_fixed_string_t flow_director_mask;
8654 cmdline_fixed_string_t mode;
8655 cmdline_fixed_string_t mode_value;
8656 cmdline_fixed_string_t vlan;
8658 cmdline_fixed_string_t src_mask;
8659 cmdline_ipaddr_t ipv4_src;
8660 cmdline_ipaddr_t ipv6_src;
8662 cmdline_fixed_string_t dst_mask;
8663 cmdline_ipaddr_t ipv4_dst;
8664 cmdline_ipaddr_t ipv6_dst;
8666 cmdline_fixed_string_t mac;
8667 uint8_t mac_addr_byte_mask;
8668 cmdline_fixed_string_t tunnel_id;
8669 uint32_t tunnel_id_mask;
8670 cmdline_fixed_string_t tunnel_type;
8671 uint8_t tunnel_type_mask;
8675 cmd_flow_director_mask_parsed(void *parsed_result,
8676 __attribute__((unused)) struct cmdline *cl,
8677 __attribute__((unused)) void *data)
8679 struct cmd_flow_director_mask_result *res = parsed_result;
8680 struct rte_eth_fdir_masks *mask;
8681 struct rte_port *port;
8683 if (res->port_id > nb_ports) {
8684 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8688 port = &ports[res->port_id];
8689 /** Check if the port is not started **/
8690 if (port->port_status != RTE_PORT_STOPPED) {
8691 printf("Please stop port %d first\n", res->port_id);
8695 mask = &port->dev_conf.fdir_conf.mask;
8697 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8698 if (strcmp(res->mode_value, "MAC-VLAN")) {
8699 printf("Please set mode to MAC-VLAN.\n");
8703 mask->vlan_tci_mask = res->vlan_mask;
8704 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8705 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8706 if (strcmp(res->mode_value, "Tunnel")) {
8707 printf("Please set mode to Tunnel.\n");
8711 mask->vlan_tci_mask = res->vlan_mask;
8712 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8713 mask->tunnel_id_mask = res->tunnel_id_mask;
8714 mask->tunnel_type_mask = res->tunnel_type_mask;
8716 if (strcmp(res->mode_value, "IP")) {
8717 printf("Please set mode to IP.\n");
8721 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8722 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8723 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8724 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8725 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8726 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8727 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8730 cmd_reconfig_device_queue(res->port_id, 1, 1);
8733 cmdline_parse_token_string_t cmd_flow_director_mask =
8734 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8735 flow_director_mask, "flow_director_mask");
8736 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8737 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8739 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8740 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8742 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8743 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8745 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8746 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8747 src_mask, "src_mask");
8748 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8749 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8751 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8752 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8754 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8755 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8757 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8758 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8759 dst_mask, "dst_mask");
8760 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8761 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8763 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8764 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8766 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8767 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8770 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8771 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8773 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8776 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8777 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8778 mode_value, "MAC-VLAN");
8779 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8780 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8781 mode_value, "Tunnel");
8782 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8783 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8785 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8786 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8787 mac_addr_byte_mask, UINT8);
8788 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8790 tunnel_type, "tunnel-type");
8791 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8792 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8793 tunnel_type_mask, UINT8);
8794 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8796 tunnel_id, "tunnel-id");
8797 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8798 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8799 tunnel_id_mask, UINT32);
8801 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8802 .f = cmd_flow_director_mask_parsed,
8804 .help_str = "set IP mode flow director's mask on NIC",
8806 (void *)&cmd_flow_director_mask,
8807 (void *)&cmd_flow_director_mask_port_id,
8808 (void *)&cmd_flow_director_mask_mode,
8809 (void *)&cmd_flow_director_mask_mode_ip,
8810 (void *)&cmd_flow_director_mask_vlan,
8811 (void *)&cmd_flow_director_mask_vlan_value,
8812 (void *)&cmd_flow_director_mask_src,
8813 (void *)&cmd_flow_director_mask_ipv4_src,
8814 (void *)&cmd_flow_director_mask_ipv6_src,
8815 (void *)&cmd_flow_director_mask_port_src,
8816 (void *)&cmd_flow_director_mask_dst,
8817 (void *)&cmd_flow_director_mask_ipv4_dst,
8818 (void *)&cmd_flow_director_mask_ipv6_dst,
8819 (void *)&cmd_flow_director_mask_port_dst,
8824 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8825 .f = cmd_flow_director_mask_parsed,
8827 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8829 (void *)&cmd_flow_director_mask,
8830 (void *)&cmd_flow_director_mask_port_id,
8831 (void *)&cmd_flow_director_mask_mode,
8832 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8833 (void *)&cmd_flow_director_mask_vlan,
8834 (void *)&cmd_flow_director_mask_vlan_value,
8835 (void *)&cmd_flow_director_mask_mac,
8836 (void *)&cmd_flow_director_mask_mac_value,
8841 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8842 .f = cmd_flow_director_mask_parsed,
8844 .help_str = "set tunnel mode flow director's mask on NIC",
8846 (void *)&cmd_flow_director_mask,
8847 (void *)&cmd_flow_director_mask_port_id,
8848 (void *)&cmd_flow_director_mask_mode,
8849 (void *)&cmd_flow_director_mask_mode_tunnel,
8850 (void *)&cmd_flow_director_mask_vlan,
8851 (void *)&cmd_flow_director_mask_vlan_value,
8852 (void *)&cmd_flow_director_mask_mac,
8853 (void *)&cmd_flow_director_mask_mac_value,
8854 (void *)&cmd_flow_director_mask_tunnel_type,
8855 (void *)&cmd_flow_director_mask_tunnel_type_value,
8856 (void *)&cmd_flow_director_mask_tunnel_id,
8857 (void *)&cmd_flow_director_mask_tunnel_id_value,
8862 /* *** deal with flow director mask on flexible payload *** */
8863 struct cmd_flow_director_flex_mask_result {
8864 cmdline_fixed_string_t flow_director_flexmask;
8866 cmdline_fixed_string_t flow;
8867 cmdline_fixed_string_t flow_type;
8868 cmdline_fixed_string_t mask;
8872 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8873 __attribute__((unused)) struct cmdline *cl,
8874 __attribute__((unused)) void *data)
8876 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8877 struct rte_eth_fdir_info fdir_info;
8878 struct rte_eth_fdir_flex_mask flex_mask;
8879 struct rte_port *port;
8880 uint32_t flow_type_mask;
8884 if (res->port_id > nb_ports) {
8885 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8889 port = &ports[res->port_id];
8890 /** Check if the port is not started **/
8891 if (port->port_status != RTE_PORT_STOPPED) {
8892 printf("Please stop port %d first\n", res->port_id);
8896 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8897 ret = parse_flexbytes(res->mask,
8899 RTE_ETH_FDIR_MAX_FLEXLEN);
8901 printf("error: Cannot parse mask input.\n");
8905 memset(&fdir_info, 0, sizeof(fdir_info));
8906 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8907 RTE_ETH_FILTER_INFO, &fdir_info);
8909 printf("Cannot get FDir filter info\n");
8913 if (!strcmp(res->flow_type, "none")) {
8914 /* means don't specify the flow type */
8915 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8916 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8917 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8918 0, sizeof(struct rte_eth_fdir_flex_mask));
8919 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8920 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8922 sizeof(struct rte_eth_fdir_flex_mask));
8923 cmd_reconfig_device_queue(res->port_id, 1, 1);
8926 flow_type_mask = fdir_info.flow_types_mask[0];
8927 if (!strcmp(res->flow_type, "all")) {
8928 if (!flow_type_mask) {
8929 printf("No flow type supported\n");
8932 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8933 if (flow_type_mask & (1 << i)) {
8934 flex_mask.flow_type = i;
8935 fdir_set_flex_mask(res->port_id, &flex_mask);
8938 cmd_reconfig_device_queue(res->port_id, 1, 1);
8941 flex_mask.flow_type = str2flowtype(res->flow_type);
8942 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8943 printf("Flow type %s not supported on port %d\n",
8944 res->flow_type, res->port_id);
8947 fdir_set_flex_mask(res->port_id, &flex_mask);
8948 cmd_reconfig_device_queue(res->port_id, 1, 1);
8951 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8953 flow_director_flexmask,
8954 "flow_director_flex_mask");
8955 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8956 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8958 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8961 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8963 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8964 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8965 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8966 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8969 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8970 .f = cmd_flow_director_flex_mask_parsed,
8972 .help_str = "set flow director's flex mask on NIC",
8974 (void *)&cmd_flow_director_flexmask,
8975 (void *)&cmd_flow_director_flexmask_port_id,
8976 (void *)&cmd_flow_director_flexmask_flow,
8977 (void *)&cmd_flow_director_flexmask_flow_type,
8978 (void *)&cmd_flow_director_flexmask_mask,
8983 /* *** deal with flow director flexible payload configuration *** */
8984 struct cmd_flow_director_flexpayload_result {
8985 cmdline_fixed_string_t flow_director_flexpayload;
8987 cmdline_fixed_string_t payload_layer;
8988 cmdline_fixed_string_t payload_cfg;
8992 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8995 const char *p, *p0 = q_arg;
8997 unsigned long int_fld;
8998 char *str_fld[max_num];
9003 p = strchr(p0, '(');
9007 p0 = strchr(p, ')');
9012 if (size >= sizeof(s))
9015 snprintf(s, sizeof(s), "%.*s", size, p);
9016 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9017 if (ret < 0 || ret > max_num)
9019 for (i = 0; i < ret; i++) {
9021 int_fld = strtoul(str_fld[i], &end, 0);
9022 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9024 offsets[i] = (uint16_t)int_fld;
9030 cmd_flow_director_flxpld_parsed(void *parsed_result,
9031 __attribute__((unused)) struct cmdline *cl,
9032 __attribute__((unused)) void *data)
9034 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9035 struct rte_eth_flex_payload_cfg flex_cfg;
9036 struct rte_port *port;
9039 if (res->port_id > nb_ports) {
9040 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9044 port = &ports[res->port_id];
9045 /** Check if the port is not started **/
9046 if (port->port_status != RTE_PORT_STOPPED) {
9047 printf("Please stop port %d first\n", res->port_id);
9051 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9053 if (!strcmp(res->payload_layer, "raw"))
9054 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9055 else if (!strcmp(res->payload_layer, "l2"))
9056 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9057 else if (!strcmp(res->payload_layer, "l3"))
9058 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9059 else if (!strcmp(res->payload_layer, "l4"))
9060 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9062 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9063 RTE_ETH_FDIR_MAX_FLEXLEN);
9065 printf("error: Cannot parse flex payload input.\n");
9069 fdir_set_flex_payload(res->port_id, &flex_cfg);
9070 cmd_reconfig_device_queue(res->port_id, 1, 1);
9073 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9074 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9075 flow_director_flexpayload,
9076 "flow_director_flex_payload");
9077 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9078 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9080 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9081 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9082 payload_layer, "raw#l2#l3#l4");
9083 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9084 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9087 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9088 .f = cmd_flow_director_flxpld_parsed,
9090 .help_str = "set flow director's flex payload on NIC",
9092 (void *)&cmd_flow_director_flexpayload,
9093 (void *)&cmd_flow_director_flexpayload_port_id,
9094 (void *)&cmd_flow_director_flexpayload_payload_layer,
9095 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9100 /* *** Classification Filters Control *** */
9101 /* *** Get symmetric hash enable per port *** */
9102 struct cmd_get_sym_hash_ena_per_port_result {
9103 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9108 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9109 __rte_unused struct cmdline *cl,
9110 __rte_unused void *data)
9112 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9113 struct rte_eth_hash_filter_info info;
9116 if (rte_eth_dev_filter_supported(res->port_id,
9117 RTE_ETH_FILTER_HASH) < 0) {
9118 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9123 memset(&info, 0, sizeof(info));
9124 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9125 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9126 RTE_ETH_FILTER_GET, &info);
9129 printf("Cannot get symmetric hash enable per port "
9130 "on port %u\n", res->port_id);
9134 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9135 "enabled" : "disabled", res->port_id);
9138 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9139 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9140 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9141 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9142 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9145 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9146 .f = cmd_get_sym_hash_per_port_parsed,
9148 .help_str = "get_sym_hash_ena_per_port port_id",
9150 (void *)&cmd_get_sym_hash_ena_per_port_all,
9151 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9156 /* *** Set symmetric hash enable per port *** */
9157 struct cmd_set_sym_hash_ena_per_port_result {
9158 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9159 cmdline_fixed_string_t enable;
9164 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9165 __rte_unused struct cmdline *cl,
9166 __rte_unused void *data)
9168 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9169 struct rte_eth_hash_filter_info info;
9172 if (rte_eth_dev_filter_supported(res->port_id,
9173 RTE_ETH_FILTER_HASH) < 0) {
9174 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9179 memset(&info, 0, sizeof(info));
9180 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9181 if (!strcmp(res->enable, "enable"))
9182 info.info.enable = 1;
9183 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9184 RTE_ETH_FILTER_SET, &info);
9186 printf("Cannot set symmetric hash enable per port on "
9187 "port %u\n", res->port_id);
9190 printf("Symmetric hash has been set to %s on port %u\n",
9191 res->enable, res->port_id);
9194 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9195 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9196 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9197 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9198 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9200 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9201 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9202 enable, "enable#disable");
9204 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9205 .f = cmd_set_sym_hash_per_port_parsed,
9207 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9209 (void *)&cmd_set_sym_hash_ena_per_port_all,
9210 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9211 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9216 /* Get global config of hash function */
9217 struct cmd_get_hash_global_config_result {
9218 cmdline_fixed_string_t get_hash_global_config;
9223 flowtype_to_str(uint16_t ftype)
9230 {"ipv4", RTE_ETH_FLOW_IPV4},
9231 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9232 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9233 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9234 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9235 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9236 {"ipv6", RTE_ETH_FLOW_IPV6},
9237 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9238 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9239 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9240 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9241 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9242 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9245 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9246 if (ftype_table[i].ftype == ftype)
9247 return ftype_table[i].str;
9254 cmd_get_hash_global_config_parsed(void *parsed_result,
9255 __rte_unused struct cmdline *cl,
9256 __rte_unused void *data)
9258 struct cmd_get_hash_global_config_result *res = parsed_result;
9259 struct rte_eth_hash_filter_info info;
9260 uint32_t idx, offset;
9265 if (rte_eth_dev_filter_supported(res->port_id,
9266 RTE_ETH_FILTER_HASH) < 0) {
9267 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9272 memset(&info, 0, sizeof(info));
9273 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9274 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9275 RTE_ETH_FILTER_GET, &info);
9277 printf("Cannot get hash global configurations by port %d\n",
9282 switch (info.info.global_conf.hash_func) {
9283 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9284 printf("Hash function is Toeplitz\n");
9286 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9287 printf("Hash function is Simple XOR\n");
9290 printf("Unknown hash function\n");
9294 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9295 idx = i / UINT32_BIT;
9296 offset = i % UINT32_BIT;
9297 if (!(info.info.global_conf.valid_bit_mask[idx] &
9300 str = flowtype_to_str(i);
9303 printf("Symmetric hash is %s globally for flow type %s "
9305 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9306 (1UL << offset)) ? "enabled" : "disabled"), str,
9311 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9312 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9313 get_hash_global_config, "get_hash_global_config");
9314 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9315 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9318 cmdline_parse_inst_t cmd_get_hash_global_config = {
9319 .f = cmd_get_hash_global_config_parsed,
9321 .help_str = "get_hash_global_config port_id",
9323 (void *)&cmd_get_hash_global_config_all,
9324 (void *)&cmd_get_hash_global_config_port_id,
9329 /* Set global config of hash function */
9330 struct cmd_set_hash_global_config_result {
9331 cmdline_fixed_string_t set_hash_global_config;
9333 cmdline_fixed_string_t hash_func;
9334 cmdline_fixed_string_t flow_type;
9335 cmdline_fixed_string_t enable;
9339 cmd_set_hash_global_config_parsed(void *parsed_result,
9340 __rte_unused struct cmdline *cl,
9341 __rte_unused void *data)
9343 struct cmd_set_hash_global_config_result *res = parsed_result;
9344 struct rte_eth_hash_filter_info info;
9345 uint32_t ftype, idx, offset;
9348 if (rte_eth_dev_filter_supported(res->port_id,
9349 RTE_ETH_FILTER_HASH) < 0) {
9350 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9354 memset(&info, 0, sizeof(info));
9355 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9356 if (!strcmp(res->hash_func, "toeplitz"))
9357 info.info.global_conf.hash_func =
9358 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9359 else if (!strcmp(res->hash_func, "simple_xor"))
9360 info.info.global_conf.hash_func =
9361 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9362 else if (!strcmp(res->hash_func, "default"))
9363 info.info.global_conf.hash_func =
9364 RTE_ETH_HASH_FUNCTION_DEFAULT;
9366 ftype = str2flowtype(res->flow_type);
9367 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9368 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9369 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9370 if (!strcmp(res->enable, "enable"))
9371 info.info.global_conf.sym_hash_enable_mask[idx] |=
9373 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9374 RTE_ETH_FILTER_SET, &info);
9376 printf("Cannot set global hash configurations by port %d\n",
9379 printf("Global hash configurations have been set "
9380 "succcessfully by port %d\n", res->port_id);
9383 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9384 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9385 set_hash_global_config, "set_hash_global_config");
9386 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9387 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9389 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9390 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9391 hash_func, "toeplitz#simple_xor#default");
9392 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9393 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9395 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9396 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9397 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9399 enable, "enable#disable");
9401 cmdline_parse_inst_t cmd_set_hash_global_config = {
9402 .f = cmd_set_hash_global_config_parsed,
9404 .help_str = "set_hash_global_config port_id "
9405 "toeplitz|simple_xor|default "
9406 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9407 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9410 (void *)&cmd_set_hash_global_config_all,
9411 (void *)&cmd_set_hash_global_config_port_id,
9412 (void *)&cmd_set_hash_global_config_hash_func,
9413 (void *)&cmd_set_hash_global_config_flow_type,
9414 (void *)&cmd_set_hash_global_config_enable,
9419 /* Set hash input set */
9420 struct cmd_set_hash_input_set_result {
9421 cmdline_fixed_string_t set_hash_input_set;
9423 cmdline_fixed_string_t flow_type;
9424 cmdline_fixed_string_t inset_field;
9425 cmdline_fixed_string_t select;
9428 static enum rte_eth_input_set_field
9429 str2inset(char *string)
9433 static const struct {
9435 enum rte_eth_input_set_field inset;
9437 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9438 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9439 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9440 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9441 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9442 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9443 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9444 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9445 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9446 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9447 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9448 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9449 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9450 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9451 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9452 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9453 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9454 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9455 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9456 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9457 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9458 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9459 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9460 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9461 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9462 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9463 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9464 {"none", RTE_ETH_INPUT_SET_NONE},
9467 for (i = 0; i < RTE_DIM(inset_table); i++) {
9468 if (!strcmp(string, inset_table[i].str))
9469 return inset_table[i].inset;
9472 return RTE_ETH_INPUT_SET_UNKNOWN;
9476 cmd_set_hash_input_set_parsed(void *parsed_result,
9477 __rte_unused struct cmdline *cl,
9478 __rte_unused void *data)
9480 struct cmd_set_hash_input_set_result *res = parsed_result;
9481 struct rte_eth_hash_filter_info info;
9483 memset(&info, 0, sizeof(info));
9484 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9485 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9486 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9487 info.info.input_set_conf.inset_size = 1;
9488 if (!strcmp(res->select, "select"))
9489 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9490 else if (!strcmp(res->select, "add"))
9491 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9492 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9493 RTE_ETH_FILTER_SET, &info);
9496 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9497 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9498 set_hash_input_set, "set_hash_input_set");
9499 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9500 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9502 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9503 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9505 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9506 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9507 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9508 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9510 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9511 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9512 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9513 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9514 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9516 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9517 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9518 select, "select#add");
9520 cmdline_parse_inst_t cmd_set_hash_input_set = {
9521 .f = cmd_set_hash_input_set_parsed,
9523 .help_str = "set_hash_input_set <port_id> "
9524 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9525 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9526 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9527 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9528 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9529 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9530 "fld-7th|fld-8th|none select|add",
9532 (void *)&cmd_set_hash_input_set_cmd,
9533 (void *)&cmd_set_hash_input_set_port_id,
9534 (void *)&cmd_set_hash_input_set_flow_type,
9535 (void *)&cmd_set_hash_input_set_field,
9536 (void *)&cmd_set_hash_input_set_select,
9541 /* Set flow director input set */
9542 struct cmd_set_fdir_input_set_result {
9543 cmdline_fixed_string_t set_fdir_input_set;
9545 cmdline_fixed_string_t flow_type;
9546 cmdline_fixed_string_t inset_field;
9547 cmdline_fixed_string_t select;
9551 cmd_set_fdir_input_set_parsed(void *parsed_result,
9552 __rte_unused struct cmdline *cl,
9553 __rte_unused void *data)
9555 struct cmd_set_fdir_input_set_result *res = parsed_result;
9556 struct rte_eth_fdir_filter_info info;
9558 memset(&info, 0, sizeof(info));
9559 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9560 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9561 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9562 info.info.input_set_conf.inset_size = 1;
9563 if (!strcmp(res->select, "select"))
9564 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9565 else if (!strcmp(res->select, "add"))
9566 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9567 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9568 RTE_ETH_FILTER_SET, &info);
9571 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9572 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9573 set_fdir_input_set, "set_fdir_input_set");
9574 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9575 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9577 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9578 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9580 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9581 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9582 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9583 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9585 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9586 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9587 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9588 "fld-7th#fld-8th#none");
9589 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9590 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9591 select, "select#add");
9593 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9594 .f = cmd_set_fdir_input_set_parsed,
9596 .help_str = "set_fdir_input_set <port_id> "
9597 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9598 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9599 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9600 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9601 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9602 "fld-7th|fld-8th|none select|add",
9604 (void *)&cmd_set_fdir_input_set_cmd,
9605 (void *)&cmd_set_fdir_input_set_port_id,
9606 (void *)&cmd_set_fdir_input_set_flow_type,
9607 (void *)&cmd_set_fdir_input_set_field,
9608 (void *)&cmd_set_fdir_input_set_select,
9613 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9614 struct cmd_mcast_addr_result {
9615 cmdline_fixed_string_t mcast_addr_cmd;
9616 cmdline_fixed_string_t what;
9618 struct ether_addr mc_addr;
9621 static void cmd_mcast_addr_parsed(void *parsed_result,
9622 __attribute__((unused)) struct cmdline *cl,
9623 __attribute__((unused)) void *data)
9625 struct cmd_mcast_addr_result *res = parsed_result;
9627 if (!is_multicast_ether_addr(&res->mc_addr)) {
9628 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9629 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9630 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9631 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9634 if (strcmp(res->what, "add") == 0)
9635 mcast_addr_add(res->port_num, &res->mc_addr);
9637 mcast_addr_remove(res->port_num, &res->mc_addr);
9640 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9641 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9642 mcast_addr_cmd, "mcast_addr");
9643 cmdline_parse_token_string_t cmd_mcast_addr_what =
9644 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9646 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9647 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9648 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9649 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9651 cmdline_parse_inst_t cmd_mcast_addr = {
9652 .f = cmd_mcast_addr_parsed,
9654 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9656 (void *)&cmd_mcast_addr_cmd,
9657 (void *)&cmd_mcast_addr_what,
9658 (void *)&cmd_mcast_addr_portnum,
9659 (void *)&cmd_mcast_addr_addr,
9665 * only support E-tag now.
9668 /* Ether type config */
9669 struct cmd_config_l2_tunnel_eth_type_result {
9670 cmdline_fixed_string_t port;
9671 cmdline_fixed_string_t config;
9672 cmdline_fixed_string_t all;
9674 cmdline_fixed_string_t l2_tunnel;
9675 cmdline_fixed_string_t l2_tunnel_type;
9676 cmdline_fixed_string_t eth_type;
9677 uint16_t eth_type_val;
9680 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9681 TOKEN_STRING_INITIALIZER
9682 (struct cmd_config_l2_tunnel_eth_type_result,
9684 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9685 TOKEN_STRING_INITIALIZER
9686 (struct cmd_config_l2_tunnel_eth_type_result,
9688 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9689 TOKEN_STRING_INITIALIZER
9690 (struct cmd_config_l2_tunnel_eth_type_result,
9692 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9693 TOKEN_NUM_INITIALIZER
9694 (struct cmd_config_l2_tunnel_eth_type_result,
9696 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9697 TOKEN_STRING_INITIALIZER
9698 (struct cmd_config_l2_tunnel_eth_type_result,
9699 l2_tunnel, "l2-tunnel");
9700 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9701 TOKEN_STRING_INITIALIZER
9702 (struct cmd_config_l2_tunnel_eth_type_result,
9703 l2_tunnel_type, "E-tag");
9704 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9705 TOKEN_STRING_INITIALIZER
9706 (struct cmd_config_l2_tunnel_eth_type_result,
9707 eth_type, "ether-type");
9708 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9709 TOKEN_NUM_INITIALIZER
9710 (struct cmd_config_l2_tunnel_eth_type_result,
9711 eth_type_val, UINT16);
9714 str2fdir_l2_tunnel_type(char *string)
9718 static const struct {
9721 } l2_tunnel_type_str[] = {
9722 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
9725 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
9726 if (!strcmp(l2_tunnel_type_str[i].str, string))
9727 return l2_tunnel_type_str[i].type;
9729 return RTE_TUNNEL_TYPE_NONE;
9732 /* ether type config for all ports */
9734 cmd_config_l2_tunnel_eth_type_all_parsed
9735 (void *parsed_result,
9736 __attribute__((unused)) struct cmdline *cl,
9737 __attribute__((unused)) void *data)
9739 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
9740 struct rte_eth_l2_tunnel_conf entry;
9743 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9744 entry.ether_type = res->eth_type_val;
9746 FOREACH_PORT(pid, ports) {
9747 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
9751 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
9752 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
9754 .help_str = "port config all l2-tunnel ether-type",
9756 (void *)&cmd_config_l2_tunnel_eth_type_port,
9757 (void *)&cmd_config_l2_tunnel_eth_type_config,
9758 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
9759 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9760 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9761 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9762 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9767 /* ether type config for a specific port */
9769 cmd_config_l2_tunnel_eth_type_specific_parsed(
9770 void *parsed_result,
9771 __attribute__((unused)) struct cmdline *cl,
9772 __attribute__((unused)) void *data)
9774 struct cmd_config_l2_tunnel_eth_type_result *res =
9776 struct rte_eth_l2_tunnel_conf entry;
9778 if (port_id_is_invalid(res->id, ENABLED_WARN))
9781 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9782 entry.ether_type = res->eth_type_val;
9784 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
9787 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
9788 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
9790 .help_str = "port config l2-tunnel ether-type",
9792 (void *)&cmd_config_l2_tunnel_eth_type_port,
9793 (void *)&cmd_config_l2_tunnel_eth_type_config,
9794 (void *)&cmd_config_l2_tunnel_eth_type_id,
9795 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9796 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9797 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9798 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9803 /* Enable/disable l2 tunnel */
9804 struct cmd_config_l2_tunnel_en_dis_result {
9805 cmdline_fixed_string_t port;
9806 cmdline_fixed_string_t config;
9807 cmdline_fixed_string_t all;
9809 cmdline_fixed_string_t l2_tunnel;
9810 cmdline_fixed_string_t l2_tunnel_type;
9811 cmdline_fixed_string_t en_dis;
9814 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
9815 TOKEN_STRING_INITIALIZER
9816 (struct cmd_config_l2_tunnel_en_dis_result,
9818 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
9819 TOKEN_STRING_INITIALIZER
9820 (struct cmd_config_l2_tunnel_en_dis_result,
9822 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
9823 TOKEN_STRING_INITIALIZER
9824 (struct cmd_config_l2_tunnel_en_dis_result,
9826 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
9827 TOKEN_NUM_INITIALIZER
9828 (struct cmd_config_l2_tunnel_en_dis_result,
9830 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
9831 TOKEN_STRING_INITIALIZER
9832 (struct cmd_config_l2_tunnel_en_dis_result,
9833 l2_tunnel, "l2-tunnel");
9834 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
9835 TOKEN_STRING_INITIALIZER
9836 (struct cmd_config_l2_tunnel_en_dis_result,
9837 l2_tunnel_type, "E-tag");
9838 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
9839 TOKEN_STRING_INITIALIZER
9840 (struct cmd_config_l2_tunnel_en_dis_result,
9841 en_dis, "enable#disable");
9843 /* enable/disable l2 tunnel for all ports */
9845 cmd_config_l2_tunnel_en_dis_all_parsed(
9846 void *parsed_result,
9847 __attribute__((unused)) struct cmdline *cl,
9848 __attribute__((unused)) void *data)
9850 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
9851 struct rte_eth_l2_tunnel_conf entry;
9855 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9857 if (!strcmp("enable", res->en_dis))
9862 FOREACH_PORT(pid, ports) {
9863 rte_eth_dev_l2_tunnel_offload_set(pid,
9865 ETH_L2_TUNNEL_ENABLE_MASK,
9870 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
9871 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
9873 .help_str = "port config all l2-tunnel enable/disable",
9875 (void *)&cmd_config_l2_tunnel_en_dis_port,
9876 (void *)&cmd_config_l2_tunnel_en_dis_config,
9877 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
9878 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9879 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9880 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9885 /* enable/disable l2 tunnel for a port */
9887 cmd_config_l2_tunnel_en_dis_specific_parsed(
9888 void *parsed_result,
9889 __attribute__((unused)) struct cmdline *cl,
9890 __attribute__((unused)) void *data)
9892 struct cmd_config_l2_tunnel_en_dis_result *res =
9894 struct rte_eth_l2_tunnel_conf entry;
9896 if (port_id_is_invalid(res->id, ENABLED_WARN))
9899 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9901 if (!strcmp("enable", res->en_dis))
9902 rte_eth_dev_l2_tunnel_offload_set(res->id,
9904 ETH_L2_TUNNEL_ENABLE_MASK,
9907 rte_eth_dev_l2_tunnel_offload_set(res->id,
9909 ETH_L2_TUNNEL_ENABLE_MASK,
9913 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
9914 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
9916 .help_str = "port config l2-tunnel enable/disable",
9918 (void *)&cmd_config_l2_tunnel_en_dis_port,
9919 (void *)&cmd_config_l2_tunnel_en_dis_config,
9920 (void *)&cmd_config_l2_tunnel_en_dis_id,
9921 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9922 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9923 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9928 /* E-tag configuration */
9930 /* Common result structure for all E-tag configuration */
9931 struct cmd_config_e_tag_result {
9932 cmdline_fixed_string_t e_tag;
9933 cmdline_fixed_string_t set;
9934 cmdline_fixed_string_t insertion;
9935 cmdline_fixed_string_t stripping;
9936 cmdline_fixed_string_t forwarding;
9937 cmdline_fixed_string_t filter;
9938 cmdline_fixed_string_t add;
9939 cmdline_fixed_string_t del;
9940 cmdline_fixed_string_t on;
9941 cmdline_fixed_string_t off;
9942 cmdline_fixed_string_t on_off;
9943 cmdline_fixed_string_t port_tag_id;
9944 uint32_t port_tag_id_val;
9945 cmdline_fixed_string_t e_tag_id;
9946 uint16_t e_tag_id_val;
9947 cmdline_fixed_string_t dst_pool;
9948 uint8_t dst_pool_val;
9949 cmdline_fixed_string_t port;
9951 cmdline_fixed_string_t vf;
9955 /* Common CLI fields for all E-tag configuration */
9956 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
9957 TOKEN_STRING_INITIALIZER
9958 (struct cmd_config_e_tag_result,
9960 cmdline_parse_token_string_t cmd_config_e_tag_set =
9961 TOKEN_STRING_INITIALIZER
9962 (struct cmd_config_e_tag_result,
9964 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
9965 TOKEN_STRING_INITIALIZER
9966 (struct cmd_config_e_tag_result,
9967 insertion, "insertion");
9968 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
9969 TOKEN_STRING_INITIALIZER
9970 (struct cmd_config_e_tag_result,
9971 stripping, "stripping");
9972 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
9973 TOKEN_STRING_INITIALIZER
9974 (struct cmd_config_e_tag_result,
9975 forwarding, "forwarding");
9976 cmdline_parse_token_string_t cmd_config_e_tag_filter =
9977 TOKEN_STRING_INITIALIZER
9978 (struct cmd_config_e_tag_result,
9980 cmdline_parse_token_string_t cmd_config_e_tag_add =
9981 TOKEN_STRING_INITIALIZER
9982 (struct cmd_config_e_tag_result,
9984 cmdline_parse_token_string_t cmd_config_e_tag_del =
9985 TOKEN_STRING_INITIALIZER
9986 (struct cmd_config_e_tag_result,
9988 cmdline_parse_token_string_t cmd_config_e_tag_on =
9989 TOKEN_STRING_INITIALIZER
9990 (struct cmd_config_e_tag_result,
9992 cmdline_parse_token_string_t cmd_config_e_tag_off =
9993 TOKEN_STRING_INITIALIZER
9994 (struct cmd_config_e_tag_result,
9996 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
9997 TOKEN_STRING_INITIALIZER
9998 (struct cmd_config_e_tag_result,
10000 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10001 TOKEN_STRING_INITIALIZER
10002 (struct cmd_config_e_tag_result,
10003 port_tag_id, "port-tag-id");
10004 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10005 TOKEN_NUM_INITIALIZER
10006 (struct cmd_config_e_tag_result,
10007 port_tag_id_val, UINT32);
10008 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10009 TOKEN_STRING_INITIALIZER
10010 (struct cmd_config_e_tag_result,
10011 e_tag_id, "e-tag-id");
10012 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10013 TOKEN_NUM_INITIALIZER
10014 (struct cmd_config_e_tag_result,
10015 e_tag_id_val, UINT16);
10016 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10017 TOKEN_STRING_INITIALIZER
10018 (struct cmd_config_e_tag_result,
10019 dst_pool, "dst-pool");
10020 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10021 TOKEN_NUM_INITIALIZER
10022 (struct cmd_config_e_tag_result,
10023 dst_pool_val, UINT8);
10024 cmdline_parse_token_string_t cmd_config_e_tag_port =
10025 TOKEN_STRING_INITIALIZER
10026 (struct cmd_config_e_tag_result,
10028 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10029 TOKEN_NUM_INITIALIZER
10030 (struct cmd_config_e_tag_result,
10032 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10033 TOKEN_STRING_INITIALIZER
10034 (struct cmd_config_e_tag_result,
10036 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10037 TOKEN_NUM_INITIALIZER
10038 (struct cmd_config_e_tag_result,
10041 /* E-tag insertion configuration */
10043 cmd_config_e_tag_insertion_en_parsed(
10044 void *parsed_result,
10045 __attribute__((unused)) struct cmdline *cl,
10046 __attribute__((unused)) void *data)
10048 struct cmd_config_e_tag_result *res =
10050 struct rte_eth_l2_tunnel_conf entry;
10052 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10055 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10056 entry.tunnel_id = res->port_tag_id_val;
10057 entry.vf_id = res->vf_id;
10058 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10060 ETH_L2_TUNNEL_INSERTION_MASK,
10065 cmd_config_e_tag_insertion_dis_parsed(
10066 void *parsed_result,
10067 __attribute__((unused)) struct cmdline *cl,
10068 __attribute__((unused)) void *data)
10070 struct cmd_config_e_tag_result *res =
10072 struct rte_eth_l2_tunnel_conf entry;
10074 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10077 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10078 entry.vf_id = res->vf_id;
10080 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10082 ETH_L2_TUNNEL_INSERTION_MASK,
10086 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10087 .f = cmd_config_e_tag_insertion_en_parsed,
10089 .help_str = "E-tag insertion enable",
10091 (void *)&cmd_config_e_tag_e_tag,
10092 (void *)&cmd_config_e_tag_set,
10093 (void *)&cmd_config_e_tag_insertion,
10094 (void *)&cmd_config_e_tag_on,
10095 (void *)&cmd_config_e_tag_port_tag_id,
10096 (void *)&cmd_config_e_tag_port_tag_id_val,
10097 (void *)&cmd_config_e_tag_port,
10098 (void *)&cmd_config_e_tag_port_id,
10099 (void *)&cmd_config_e_tag_vf,
10100 (void *)&cmd_config_e_tag_vf_id,
10105 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10106 .f = cmd_config_e_tag_insertion_dis_parsed,
10108 .help_str = "E-tag insertion disable",
10110 (void *)&cmd_config_e_tag_e_tag,
10111 (void *)&cmd_config_e_tag_set,
10112 (void *)&cmd_config_e_tag_insertion,
10113 (void *)&cmd_config_e_tag_off,
10114 (void *)&cmd_config_e_tag_port,
10115 (void *)&cmd_config_e_tag_port_id,
10116 (void *)&cmd_config_e_tag_vf,
10117 (void *)&cmd_config_e_tag_vf_id,
10122 /* E-tag stripping configuration */
10124 cmd_config_e_tag_stripping_parsed(
10125 void *parsed_result,
10126 __attribute__((unused)) struct cmdline *cl,
10127 __attribute__((unused)) void *data)
10129 struct cmd_config_e_tag_result *res =
10131 struct rte_eth_l2_tunnel_conf entry;
10133 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10136 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10138 if (!strcmp(res->on_off, "on"))
10139 rte_eth_dev_l2_tunnel_offload_set
10142 ETH_L2_TUNNEL_STRIPPING_MASK,
10145 rte_eth_dev_l2_tunnel_offload_set
10148 ETH_L2_TUNNEL_STRIPPING_MASK,
10152 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10153 .f = cmd_config_e_tag_stripping_parsed,
10155 .help_str = "E-tag stripping enable/disable",
10157 (void *)&cmd_config_e_tag_e_tag,
10158 (void *)&cmd_config_e_tag_set,
10159 (void *)&cmd_config_e_tag_stripping,
10160 (void *)&cmd_config_e_tag_on_off,
10161 (void *)&cmd_config_e_tag_port,
10162 (void *)&cmd_config_e_tag_port_id,
10167 /* E-tag forwarding configuration */
10169 cmd_config_e_tag_forwarding_parsed(
10170 void *parsed_result,
10171 __attribute__((unused)) struct cmdline *cl,
10172 __attribute__((unused)) void *data)
10174 struct cmd_config_e_tag_result *res = parsed_result;
10175 struct rte_eth_l2_tunnel_conf entry;
10177 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10180 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10182 if (!strcmp(res->on_off, "on"))
10183 rte_eth_dev_l2_tunnel_offload_set
10186 ETH_L2_TUNNEL_FORWARDING_MASK,
10189 rte_eth_dev_l2_tunnel_offload_set
10192 ETH_L2_TUNNEL_FORWARDING_MASK,
10196 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10197 .f = cmd_config_e_tag_forwarding_parsed,
10199 .help_str = "E-tag forwarding enable/disable",
10201 (void *)&cmd_config_e_tag_e_tag,
10202 (void *)&cmd_config_e_tag_set,
10203 (void *)&cmd_config_e_tag_forwarding,
10204 (void *)&cmd_config_e_tag_on_off,
10205 (void *)&cmd_config_e_tag_port,
10206 (void *)&cmd_config_e_tag_port_id,
10211 /* E-tag filter configuration */
10213 cmd_config_e_tag_filter_add_parsed(
10214 void *parsed_result,
10215 __attribute__((unused)) struct cmdline *cl,
10216 __attribute__((unused)) void *data)
10218 struct cmd_config_e_tag_result *res = parsed_result;
10219 struct rte_eth_l2_tunnel_conf entry;
10222 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10225 if (res->e_tag_id_val > 0x3fff) {
10226 printf("e-tag-id must be equal or less than 0x3fff.\n");
10230 ret = rte_eth_dev_filter_supported(res->port_id,
10231 RTE_ETH_FILTER_L2_TUNNEL);
10233 printf("E-tag filter is not supported on port %u.\n",
10238 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10239 entry.tunnel_id = res->e_tag_id_val;
10240 entry.pool = res->dst_pool_val;
10242 ret = rte_eth_dev_filter_ctrl(res->port_id,
10243 RTE_ETH_FILTER_L2_TUNNEL,
10244 RTE_ETH_FILTER_ADD,
10247 printf("E-tag filter programming error: (%s)\n",
10251 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10252 .f = cmd_config_e_tag_filter_add_parsed,
10254 .help_str = "E-tag filter add",
10256 (void *)&cmd_config_e_tag_e_tag,
10257 (void *)&cmd_config_e_tag_set,
10258 (void *)&cmd_config_e_tag_filter,
10259 (void *)&cmd_config_e_tag_add,
10260 (void *)&cmd_config_e_tag_e_tag_id,
10261 (void *)&cmd_config_e_tag_e_tag_id_val,
10262 (void *)&cmd_config_e_tag_dst_pool,
10263 (void *)&cmd_config_e_tag_dst_pool_val,
10264 (void *)&cmd_config_e_tag_port,
10265 (void *)&cmd_config_e_tag_port_id,
10271 cmd_config_e_tag_filter_del_parsed(
10272 void *parsed_result,
10273 __attribute__((unused)) struct cmdline *cl,
10274 __attribute__((unused)) void *data)
10276 struct cmd_config_e_tag_result *res = parsed_result;
10277 struct rte_eth_l2_tunnel_conf entry;
10280 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10283 if (res->e_tag_id_val > 0x3fff) {
10284 printf("e-tag-id must be less than 0x3fff.\n");
10288 ret = rte_eth_dev_filter_supported(res->port_id,
10289 RTE_ETH_FILTER_L2_TUNNEL);
10291 printf("E-tag filter is not supported on port %u.\n",
10296 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10297 entry.tunnel_id = res->e_tag_id_val;
10299 ret = rte_eth_dev_filter_ctrl(res->port_id,
10300 RTE_ETH_FILTER_L2_TUNNEL,
10301 RTE_ETH_FILTER_DELETE,
10304 printf("E-tag filter programming error: (%s)\n",
10308 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10309 .f = cmd_config_e_tag_filter_del_parsed,
10311 .help_str = "E-tag filter delete",
10313 (void *)&cmd_config_e_tag_e_tag,
10314 (void *)&cmd_config_e_tag_set,
10315 (void *)&cmd_config_e_tag_filter,
10316 (void *)&cmd_config_e_tag_del,
10317 (void *)&cmd_config_e_tag_e_tag_id,
10318 (void *)&cmd_config_e_tag_e_tag_id_val,
10319 (void *)&cmd_config_e_tag_port,
10320 (void *)&cmd_config_e_tag_port_id,
10325 /* ******************************************************************************** */
10327 /* list of instructions */
10328 cmdline_parse_ctx_t main_ctx[] = {
10329 (cmdline_parse_inst_t *)&cmd_help_brief,
10330 (cmdline_parse_inst_t *)&cmd_help_long,
10331 (cmdline_parse_inst_t *)&cmd_quit,
10332 (cmdline_parse_inst_t *)&cmd_showport,
10333 (cmdline_parse_inst_t *)&cmd_showqueue,
10334 (cmdline_parse_inst_t *)&cmd_showportall,
10335 (cmdline_parse_inst_t *)&cmd_showcfg,
10336 (cmdline_parse_inst_t *)&cmd_start,
10337 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10338 (cmdline_parse_inst_t *)&cmd_set_link_up,
10339 (cmdline_parse_inst_t *)&cmd_set_link_down,
10340 (cmdline_parse_inst_t *)&cmd_reset,
10341 (cmdline_parse_inst_t *)&cmd_set_numbers,
10342 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10343 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10344 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10345 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10346 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10347 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10348 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10349 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10350 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10351 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10352 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10353 (cmdline_parse_inst_t *)&cmd_set_link_check,
10354 #ifdef RTE_NIC_BYPASS
10355 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10356 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10357 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10358 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10360 #ifdef RTE_LIBRTE_PMD_BOND
10361 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10362 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10363 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10364 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10365 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10366 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10367 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10368 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10369 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10371 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10372 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10373 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10374 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10375 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10376 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10377 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10378 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10379 (cmdline_parse_inst_t *)&cmd_csum_set,
10380 (cmdline_parse_inst_t *)&cmd_csum_show,
10381 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10382 (cmdline_parse_inst_t *)&cmd_tso_set,
10383 (cmdline_parse_inst_t *)&cmd_tso_show,
10384 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10385 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10386 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10387 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10388 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10389 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10390 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10391 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10392 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10393 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10394 (cmdline_parse_inst_t *)&cmd_config_dcb,
10395 (cmdline_parse_inst_t *)&cmd_read_reg,
10396 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10397 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10398 (cmdline_parse_inst_t *)&cmd_write_reg,
10399 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10400 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10401 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10402 (cmdline_parse_inst_t *)&cmd_stop,
10403 (cmdline_parse_inst_t *)&cmd_mac_addr,
10404 (cmdline_parse_inst_t *)&cmd_set_qmap,
10405 (cmdline_parse_inst_t *)&cmd_operate_port,
10406 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10407 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10408 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10409 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10410 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10411 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10412 (cmdline_parse_inst_t *)&cmd_config_mtu,
10413 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10414 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10415 (cmdline_parse_inst_t *)&cmd_config_rss,
10416 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10417 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10418 (cmdline_parse_inst_t *)&cmd_showport_reta,
10419 (cmdline_parse_inst_t *)&cmd_config_burst,
10420 (cmdline_parse_inst_t *)&cmd_config_thresh,
10421 (cmdline_parse_inst_t *)&cmd_config_threshold,
10422 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10423 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10424 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10425 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10426 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10427 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10428 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10429 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10430 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10431 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10432 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10433 (cmdline_parse_inst_t *)&cmd_global_config,
10434 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10435 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10436 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10437 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10438 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10439 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10440 (cmdline_parse_inst_t *)&cmd_dump,
10441 (cmdline_parse_inst_t *)&cmd_dump_one,
10442 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10443 (cmdline_parse_inst_t *)&cmd_syn_filter,
10444 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10445 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10446 (cmdline_parse_inst_t *)&cmd_flex_filter,
10447 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10448 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10449 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10450 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10451 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10452 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10453 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10454 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10455 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10456 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10457 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10458 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10459 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10460 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10461 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10462 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10463 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10464 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10465 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10466 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10467 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10468 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10469 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10470 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10471 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10472 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10473 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10474 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10475 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10479 /* prompt function, called from main on MASTER lcore */
10483 /* initialize non-constant commands */
10484 cmd_set_fwd_mode_init();
10486 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10487 if (testpmd_cl == NULL)
10489 cmdline_interact(testpmd_cl);
10490 cmdline_stdin_exit(testpmd_cl);
10496 if (testpmd_cl != NULL)
10497 cmdline_quit(testpmd_cl);
10501 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10503 if (id == (portid_t)RTE_PORT_ALL) {
10506 FOREACH_PORT(pid, ports) {
10507 /* check if need_reconfig has been set to 1 */
10508 if (ports[pid].need_reconfig == 0)
10509 ports[pid].need_reconfig = dev;
10510 /* check if need_reconfig_queues has been set to 1 */
10511 if (ports[pid].need_reconfig_queues == 0)
10512 ports[pid].need_reconfig_queues = queue;
10514 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10515 /* check if need_reconfig has been set to 1 */
10516 if (ports[id].need_reconfig == 0)
10517 ports[id].need_reconfig = dev;
10518 /* check if need_reconfig_queues has been set to 1 */
10519 if (ports[id].need_reconfig_queues == 0)
10520 ports[id].need_reconfig_queues = queue;
10524 #ifdef RTE_NIC_BYPASS
10525 #include <rte_pci_dev_ids.h>
10527 bypass_is_supported(portid_t port_id)
10529 struct rte_port *port;
10530 struct rte_pci_id *pci_id;
10532 if (port_id_is_invalid(port_id, ENABLED_WARN))
10535 /* Get the device id. */
10536 port = &ports[port_id];
10537 pci_id = &port->dev_info.pci_dev->id;
10539 /* Check if NIC supports bypass. */
10540 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
10544 printf("\tBypass not supported for port_id = %d.\n", port_id);