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 , list_pkt_forwarding_modes()
505 if (show_all || !strcmp(res->section, "ports")) {
511 "----------------\n\n"
513 "port start (port_id|all)\n"
514 " Start all ports or port_id.\n\n"
516 "port stop (port_id|all)\n"
517 " Stop all ports or port_id.\n\n"
519 "port close (port_id|all)\n"
520 " Close all ports or port_id.\n\n"
522 "port attach (ident)\n"
523 " Attach physical or virtual dev by pci address or virtual device name\n\n"
525 "port detach (port_id)\n"
526 " Detach physical or virtual dev by port_id\n\n"
528 "port config (port_id|all)"
529 " speed (10|100|1000|10000|40000|auto)"
530 " duplex (half|full|auto)\n"
531 " Set speed and duplex for all ports or port_id\n\n"
533 "port config all (rxq|txq|rxd|txd) (value)\n"
534 " Set number for rxq/txq/rxd/txd.\n\n"
536 "port config all max-pkt-len (value)\n"
537 " Set the max packet length.\n\n"
539 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
540 "hw-vlan-strip|hw-vlan-extend|drop-en)"
542 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
545 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
546 " Set the RSS mode.\n\n"
548 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
549 " Set the RSS redirection table.\n\n"
551 "port config (port_id) dcb vt (on|off) (traffic_class)"
553 " Set the DCB mode.\n\n"
555 "port config all burst (value)\n"
556 " Set the number of packets per burst.\n\n"
558 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
560 " Set the ring prefetch/host/writeback threshold"
561 " for tx/rx queue.\n\n"
563 "port config all (txfreet|txrst|rxfreet) (value)\n"
564 " Set free threshold for rx/tx, or set"
565 " tx rs bit threshold.\n\n"
566 "port config mtu X value\n"
567 " Set the MTU of port X to a given value\n\n"
569 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
570 " Start/stop a rx/tx queue of port X. Only take effect"
571 " when port X is started\n\n"
573 "port config (port_id|all) l2-tunnel E-tag ether-type"
575 " Set the value of E-tag ether-type.\n\n"
577 "port config (port_id|all) l2-tunnel E-tag"
578 " (enable|disable)\n"
579 " Enable/disable the E-tag support.\n\n"
583 if (show_all || !strcmp(res->section, "registers")) {
591 "read reg (port_id) (address)\n"
592 " Display value of a port register.\n\n"
594 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
595 " Display a port register bit field.\n\n"
597 "read regbit (port_id) (address) (bit_x)\n"
598 " Display a single port register bit.\n\n"
600 "write reg (port_id) (address) (value)\n"
601 " Set value of a port register.\n\n"
603 "write regfield (port_id) (address) (bit_x) (bit_y)"
605 " Set bit field of a port register.\n\n"
607 "write regbit (port_id) (address) (bit_x) (value)\n"
608 " Set single bit value of a port register.\n\n"
611 if (show_all || !strcmp(res->section, "filters")) {
619 "ethertype_filter (port_id) (add|del)"
620 " (mac_addr|mac_ignr) (mac_address) ethertype"
621 " (ether_type) (drop|fwd) queue (queue_id)\n"
622 " Add/Del an ethertype filter.\n\n"
624 "2tuple_filter (port_id) (add|del)"
625 " dst_port (dst_port_value) protocol (protocol_value)"
626 " mask (mask_value) tcp_flags (tcp_flags_value)"
627 " priority (prio_value) queue (queue_id)\n"
628 " Add/Del a 2tuple filter.\n\n"
630 "5tuple_filter (port_id) (add|del)"
631 " dst_ip (dst_address) src_ip (src_address)"
632 " dst_port (dst_port_value) src_port (src_port_value)"
633 " protocol (protocol_value)"
634 " mask (mask_value) tcp_flags (tcp_flags_value)"
635 " priority (prio_value) queue (queue_id)\n"
636 " Add/Del a 5tuple filter.\n\n"
638 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
639 " Add/Del syn filter.\n\n"
641 "flex_filter (port_id) (add|del) len (len_value)"
642 " bytes (bytes_value) mask (mask_value)"
643 " priority (prio_value) queue (queue_id)\n"
644 " Add/Del a flex filter.\n\n"
646 "flow_director_filter (port_id) mode IP (add|del|update)"
647 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
648 " src (src_ip_address) dst (dst_ip_address)"
649 " vlan (vlan_value) flexbytes (flexbytes_value)"
650 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
651 " fd_id (fd_id_value)\n"
652 " Add/Del an IP type flow director filter.\n\n"
654 "flow_director_filter (port_id) mode IP (add|del|update)"
655 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
656 " src (src_ip_address) (src_port)"
657 " dst (dst_ip_address) (dst_port)"
658 " vlan (vlan_value) flexbytes (flexbytes_value)"
659 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
660 " fd_id (fd_id_value)\n"
661 " Add/Del an UDP/TCP type flow director filter.\n\n"
663 "flow_director_filter (port_id) mode IP (add|del|update)"
664 " flow (ipv4-sctp|ipv6-sctp)"
665 " src (src_ip_address) (src_port)"
666 " dst (dst_ip_address) (dst_port)"
667 " tag (verification_tag) vlan (vlan_value)"
668 " flexbytes (flexbytes_value) (drop|fwd)"
669 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
670 " Add/Del a SCTP type flow director filter.\n\n"
672 "flow_director_filter (port_id) mode IP (add|del|update)"
673 " flow l2_payload ether (ethertype)"
674 " flexbytes (flexbytes_value) (drop|fwd)"
675 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
676 " Add/Del a l2 payload type flow director filter.\n\n"
678 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
679 " mac (mac_address) vlan (vlan_value)"
680 " flexbytes (flexbytes_value) (drop|fwd)"
681 " queue (queue_id) fd_id (fd_id_value)\n"
682 " Add/Del a MAC-VLAN flow director filter.\n\n"
684 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
685 " mac (mac_address) vlan (vlan_value)"
686 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
687 " flexbytes (flexbytes_value) (drop|fwd)"
688 " queue (queue_id) fd_id (fd_id_value)\n"
689 " Add/Del a Tunnel flow director filter.\n\n"
691 "flush_flow_director (port_id)\n"
692 " Flush all flow director entries of a device.\n\n"
694 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
695 " src_mask (ipv4_src) (ipv6_src) (src_port)"
696 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
697 " Set flow director IP mask.\n\n"
699 "flow_director_mask (port_id) mode MAC-VLAN"
700 " vlan (vlan_value) mac (mac_value)\n"
701 " Set flow director MAC-VLAN mask.\n\n"
703 "flow_director_mask (port_id) mode Tunnel"
704 " vlan (vlan_value) mac (mac_value)"
705 " tunnel-type (tunnel_type_value)"
706 " tunnel-id (tunnel_id_value)\n"
707 " Set flow director Tunnel mask.\n\n"
709 "flow_director_flex_mask (port_id)"
710 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
711 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
713 " Configure mask of flex payload.\n\n"
715 "flow_director_flex_payload (port_id)"
716 " (raw|l2|l3|l4) (config)\n"
717 " Configure flex payload selection.\n\n"
719 "get_sym_hash_ena_per_port (port_id)\n"
720 " get symmetric hash enable configuration per port.\n\n"
722 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
723 " set symmetric hash enable configuration per port"
724 " to enable or disable.\n\n"
726 "get_hash_global_config (port_id)\n"
727 " Get the global configurations of hash filters.\n\n"
729 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
730 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
731 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
732 " (enable|disable)\n"
733 " Set the global configurations of hash filters.\n\n"
735 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
736 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
737 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
738 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
739 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
740 "ipv6-next-header|udp-src-port|udp-dst-port|"
741 "tcp-src-port|tcp-dst-port|sctp-src-port|"
742 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
743 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
744 "fld-8th|none) (select|add)\n"
745 " Set the input set for hash.\n\n"
747 "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
748 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
749 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
750 "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
751 "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
752 "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
753 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
754 "fld-8th|none) (select|add)\n"
755 " Set the input set for FDir.\n\n"
760 cmdline_parse_token_string_t cmd_help_long_help =
761 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
763 cmdline_parse_token_string_t cmd_help_long_section =
764 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
765 "all#control#display#config#"
766 "ports#registers#filters");
768 cmdline_parse_inst_t cmd_help_long = {
769 .f = cmd_help_long_parsed,
771 .help_str = "show help",
773 (void *)&cmd_help_long_help,
774 (void *)&cmd_help_long_section,
780 /* *** start/stop/close all ports *** */
781 struct cmd_operate_port_result {
782 cmdline_fixed_string_t keyword;
783 cmdline_fixed_string_t name;
784 cmdline_fixed_string_t value;
787 static void cmd_operate_port_parsed(void *parsed_result,
788 __attribute__((unused)) struct cmdline *cl,
789 __attribute__((unused)) void *data)
791 struct cmd_operate_port_result *res = parsed_result;
793 if (!strcmp(res->name, "start"))
794 start_port(RTE_PORT_ALL);
795 else if (!strcmp(res->name, "stop"))
796 stop_port(RTE_PORT_ALL);
797 else if (!strcmp(res->name, "close"))
798 close_port(RTE_PORT_ALL);
800 printf("Unknown parameter\n");
803 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
804 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
806 cmdline_parse_token_string_t cmd_operate_port_all_port =
807 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
809 cmdline_parse_token_string_t cmd_operate_port_all_all =
810 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
812 cmdline_parse_inst_t cmd_operate_port = {
813 .f = cmd_operate_port_parsed,
815 .help_str = "port start|stop|close all: start/stop/close all ports",
817 (void *)&cmd_operate_port_all_cmd,
818 (void *)&cmd_operate_port_all_port,
819 (void *)&cmd_operate_port_all_all,
824 /* *** start/stop/close specific port *** */
825 struct cmd_operate_specific_port_result {
826 cmdline_fixed_string_t keyword;
827 cmdline_fixed_string_t name;
831 static void cmd_operate_specific_port_parsed(void *parsed_result,
832 __attribute__((unused)) struct cmdline *cl,
833 __attribute__((unused)) void *data)
835 struct cmd_operate_specific_port_result *res = parsed_result;
837 if (!strcmp(res->name, "start"))
838 start_port(res->value);
839 else if (!strcmp(res->name, "stop"))
840 stop_port(res->value);
841 else if (!strcmp(res->name, "close"))
842 close_port(res->value);
844 printf("Unknown parameter\n");
847 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
848 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
850 cmdline_parse_token_string_t cmd_operate_specific_port_port =
851 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
852 name, "start#stop#close");
853 cmdline_parse_token_num_t cmd_operate_specific_port_id =
854 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
857 cmdline_parse_inst_t cmd_operate_specific_port = {
858 .f = cmd_operate_specific_port_parsed,
860 .help_str = "port start|stop|close X: start/stop/close port X",
862 (void *)&cmd_operate_specific_port_cmd,
863 (void *)&cmd_operate_specific_port_port,
864 (void *)&cmd_operate_specific_port_id,
869 /* *** attach a specified port *** */
870 struct cmd_operate_attach_port_result {
871 cmdline_fixed_string_t port;
872 cmdline_fixed_string_t keyword;
873 cmdline_fixed_string_t identifier;
876 static void cmd_operate_attach_port_parsed(void *parsed_result,
877 __attribute__((unused)) struct cmdline *cl,
878 __attribute__((unused)) void *data)
880 struct cmd_operate_attach_port_result *res = parsed_result;
882 if (!strcmp(res->keyword, "attach"))
883 attach_port(res->identifier);
885 printf("Unknown parameter\n");
888 cmdline_parse_token_string_t cmd_operate_attach_port_port =
889 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
891 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
892 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
894 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
895 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
898 cmdline_parse_inst_t cmd_operate_attach_port = {
899 .f = cmd_operate_attach_port_parsed,
901 .help_str = "port attach identifier, "
902 "identifier: pci address or virtual dev name",
904 (void *)&cmd_operate_attach_port_port,
905 (void *)&cmd_operate_attach_port_keyword,
906 (void *)&cmd_operate_attach_port_identifier,
911 /* *** detach a specified port *** */
912 struct cmd_operate_detach_port_result {
913 cmdline_fixed_string_t port;
914 cmdline_fixed_string_t keyword;
918 static void cmd_operate_detach_port_parsed(void *parsed_result,
919 __attribute__((unused)) struct cmdline *cl,
920 __attribute__((unused)) void *data)
922 struct cmd_operate_detach_port_result *res = parsed_result;
924 if (!strcmp(res->keyword, "detach"))
925 detach_port(res->port_id);
927 printf("Unknown parameter\n");
930 cmdline_parse_token_string_t cmd_operate_detach_port_port =
931 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
933 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
934 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
936 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
937 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
940 cmdline_parse_inst_t cmd_operate_detach_port = {
941 .f = cmd_operate_detach_port_parsed,
943 .help_str = "port detach port_id",
945 (void *)&cmd_operate_detach_port_port,
946 (void *)&cmd_operate_detach_port_keyword,
947 (void *)&cmd_operate_detach_port_port_id,
952 /* *** configure speed for all ports *** */
953 struct cmd_config_speed_all {
954 cmdline_fixed_string_t port;
955 cmdline_fixed_string_t keyword;
956 cmdline_fixed_string_t all;
957 cmdline_fixed_string_t item1;
958 cmdline_fixed_string_t item2;
959 cmdline_fixed_string_t value1;
960 cmdline_fixed_string_t value2;
964 cmd_config_speed_all_parsed(void *parsed_result,
965 __attribute__((unused)) struct cmdline *cl,
966 __attribute__((unused)) void *data)
968 struct cmd_config_speed_all *res = parsed_result;
969 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
970 uint16_t link_duplex = 0;
973 if (!all_ports_stopped()) {
974 printf("Please stop all ports first\n");
978 if (!strcmp(res->value1, "10"))
979 link_speed = ETH_LINK_SPEED_10;
980 else if (!strcmp(res->value1, "100"))
981 link_speed = ETH_LINK_SPEED_100;
982 else if (!strcmp(res->value1, "1000"))
983 link_speed = ETH_LINK_SPEED_1000;
984 else if (!strcmp(res->value1, "10000"))
985 link_speed = ETH_LINK_SPEED_10G;
986 else if (!strcmp(res->value1, "40000"))
987 link_speed = ETH_LINK_SPEED_40G;
988 else if (!strcmp(res->value1, "auto"))
989 link_speed = ETH_LINK_SPEED_AUTONEG;
991 printf("Unknown parameter\n");
995 if (!strcmp(res->value2, "half"))
996 link_duplex = ETH_LINK_HALF_DUPLEX;
997 else if (!strcmp(res->value2, "full"))
998 link_duplex = ETH_LINK_FULL_DUPLEX;
999 else if (!strcmp(res->value2, "auto"))
1000 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1002 printf("Unknown parameter\n");
1006 FOREACH_PORT(pid, ports) {
1007 ports[pid].dev_conf.link_speed = link_speed;
1008 ports[pid].dev_conf.link_duplex = link_duplex;
1011 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1014 cmdline_parse_token_string_t cmd_config_speed_all_port =
1015 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1016 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1017 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1019 cmdline_parse_token_string_t cmd_config_speed_all_all =
1020 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1021 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1022 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1023 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1024 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1025 "10#100#1000#10000#40000#auto");
1026 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1027 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1028 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1029 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1032 cmdline_parse_inst_t cmd_config_speed_all = {
1033 .f = cmd_config_speed_all_parsed,
1035 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
1038 (void *)&cmd_config_speed_all_port,
1039 (void *)&cmd_config_speed_all_keyword,
1040 (void *)&cmd_config_speed_all_all,
1041 (void *)&cmd_config_speed_all_item1,
1042 (void *)&cmd_config_speed_all_value1,
1043 (void *)&cmd_config_speed_all_item2,
1044 (void *)&cmd_config_speed_all_value2,
1049 /* *** configure speed for specific port *** */
1050 struct cmd_config_speed_specific {
1051 cmdline_fixed_string_t port;
1052 cmdline_fixed_string_t keyword;
1054 cmdline_fixed_string_t item1;
1055 cmdline_fixed_string_t item2;
1056 cmdline_fixed_string_t value1;
1057 cmdline_fixed_string_t value2;
1061 cmd_config_speed_specific_parsed(void *parsed_result,
1062 __attribute__((unused)) struct cmdline *cl,
1063 __attribute__((unused)) void *data)
1065 struct cmd_config_speed_specific *res = parsed_result;
1066 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1067 uint16_t link_duplex = 0;
1069 if (!all_ports_stopped()) {
1070 printf("Please stop all ports first\n");
1074 if (port_id_is_invalid(res->id, ENABLED_WARN))
1077 if (!strcmp(res->value1, "10"))
1078 link_speed = ETH_LINK_SPEED_10;
1079 else if (!strcmp(res->value1, "100"))
1080 link_speed = ETH_LINK_SPEED_100;
1081 else if (!strcmp(res->value1, "1000"))
1082 link_speed = ETH_LINK_SPEED_1000;
1083 else if (!strcmp(res->value1, "10000"))
1084 link_speed = ETH_LINK_SPEED_10000;
1085 else if (!strcmp(res->value1, "40000"))
1086 link_speed = ETH_LINK_SPEED_40G;
1087 else if (!strcmp(res->value1, "auto"))
1088 link_speed = ETH_LINK_SPEED_AUTONEG;
1090 printf("Unknown parameter\n");
1094 if (!strcmp(res->value2, "half"))
1095 link_duplex = ETH_LINK_HALF_DUPLEX;
1096 else if (!strcmp(res->value2, "full"))
1097 link_duplex = ETH_LINK_FULL_DUPLEX;
1098 else if (!strcmp(res->value2, "auto"))
1099 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1101 printf("Unknown parameter\n");
1105 ports[res->id].dev_conf.link_speed = link_speed;
1106 ports[res->id].dev_conf.link_duplex = link_duplex;
1108 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1112 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1113 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1115 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1116 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1118 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1119 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1120 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1121 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1123 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1124 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1125 "10#100#1000#10000#40000#auto");
1126 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1127 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1129 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1130 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1133 cmdline_parse_inst_t cmd_config_speed_specific = {
1134 .f = cmd_config_speed_specific_parsed,
1136 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1139 (void *)&cmd_config_speed_specific_port,
1140 (void *)&cmd_config_speed_specific_keyword,
1141 (void *)&cmd_config_speed_specific_id,
1142 (void *)&cmd_config_speed_specific_item1,
1143 (void *)&cmd_config_speed_specific_value1,
1144 (void *)&cmd_config_speed_specific_item2,
1145 (void *)&cmd_config_speed_specific_value2,
1150 /* *** configure txq/rxq, txd/rxd *** */
1151 struct cmd_config_rx_tx {
1152 cmdline_fixed_string_t port;
1153 cmdline_fixed_string_t keyword;
1154 cmdline_fixed_string_t all;
1155 cmdline_fixed_string_t name;
1160 cmd_config_rx_tx_parsed(void *parsed_result,
1161 __attribute__((unused)) struct cmdline *cl,
1162 __attribute__((unused)) void *data)
1164 struct cmd_config_rx_tx *res = parsed_result;
1166 if (!all_ports_stopped()) {
1167 printf("Please stop all ports first\n");
1171 if (!strcmp(res->name, "rxq")) {
1172 if (res->value <= 0) {
1173 printf("rxq %d invalid - must be > 0\n", res->value);
1176 nb_rxq = res->value;
1178 else if (!strcmp(res->name, "txq")) {
1179 if (res->value <= 0) {
1180 printf("txq %d invalid - must be > 0\n", res->value);
1183 nb_txq = res->value;
1185 else if (!strcmp(res->name, "rxd")) {
1186 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1187 printf("rxd %d invalid - must be > 0 && <= %d\n",
1188 res->value, RTE_TEST_RX_DESC_MAX);
1191 nb_rxd = res->value;
1192 } else if (!strcmp(res->name, "txd")) {
1193 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1194 printf("txd %d invalid - must be > 0 && <= %d\n",
1195 res->value, RTE_TEST_TX_DESC_MAX);
1198 nb_txd = res->value;
1200 printf("Unknown parameter\n");
1206 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1209 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1210 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1211 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1212 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1213 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1214 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1215 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1216 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1218 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1219 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1221 cmdline_parse_inst_t cmd_config_rx_tx = {
1222 .f = cmd_config_rx_tx_parsed,
1224 .help_str = "port config all rxq|txq|rxd|txd value",
1226 (void *)&cmd_config_rx_tx_port,
1227 (void *)&cmd_config_rx_tx_keyword,
1228 (void *)&cmd_config_rx_tx_all,
1229 (void *)&cmd_config_rx_tx_name,
1230 (void *)&cmd_config_rx_tx_value,
1235 /* *** config max packet length *** */
1236 struct cmd_config_max_pkt_len_result {
1237 cmdline_fixed_string_t port;
1238 cmdline_fixed_string_t keyword;
1239 cmdline_fixed_string_t all;
1240 cmdline_fixed_string_t name;
1245 cmd_config_max_pkt_len_parsed(void *parsed_result,
1246 __attribute__((unused)) struct cmdline *cl,
1247 __attribute__((unused)) void *data)
1249 struct cmd_config_max_pkt_len_result *res = parsed_result;
1251 if (!all_ports_stopped()) {
1252 printf("Please stop all ports first\n");
1256 if (!strcmp(res->name, "max-pkt-len")) {
1257 if (res->value < ETHER_MIN_LEN) {
1258 printf("max-pkt-len can not be less than %d\n",
1262 if (res->value == rx_mode.max_rx_pkt_len)
1265 rx_mode.max_rx_pkt_len = res->value;
1266 if (res->value > ETHER_MAX_LEN)
1267 rx_mode.jumbo_frame = 1;
1269 rx_mode.jumbo_frame = 0;
1271 printf("Unknown parameter\n");
1277 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1280 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1283 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1284 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1286 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1289 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1290 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1292 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1293 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1296 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1297 .f = cmd_config_max_pkt_len_parsed,
1299 .help_str = "port config all max-pkt-len value",
1301 (void *)&cmd_config_max_pkt_len_port,
1302 (void *)&cmd_config_max_pkt_len_keyword,
1303 (void *)&cmd_config_max_pkt_len_all,
1304 (void *)&cmd_config_max_pkt_len_name,
1305 (void *)&cmd_config_max_pkt_len_value,
1310 /* *** configure port MTU *** */
1311 struct cmd_config_mtu_result {
1312 cmdline_fixed_string_t port;
1313 cmdline_fixed_string_t keyword;
1314 cmdline_fixed_string_t mtu;
1320 cmd_config_mtu_parsed(void *parsed_result,
1321 __attribute__((unused)) struct cmdline *cl,
1322 __attribute__((unused)) void *data)
1324 struct cmd_config_mtu_result *res = parsed_result;
1326 if (res->value < ETHER_MIN_LEN) {
1327 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1330 port_mtu_set(res->port_id, res->value);
1333 cmdline_parse_token_string_t cmd_config_mtu_port =
1334 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1336 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1337 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1339 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1340 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1342 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1343 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1344 cmdline_parse_token_num_t cmd_config_mtu_value =
1345 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1347 cmdline_parse_inst_t cmd_config_mtu = {
1348 .f = cmd_config_mtu_parsed,
1350 .help_str = "port config mtu value",
1352 (void *)&cmd_config_mtu_port,
1353 (void *)&cmd_config_mtu_keyword,
1354 (void *)&cmd_config_mtu_mtu,
1355 (void *)&cmd_config_mtu_port_id,
1356 (void *)&cmd_config_mtu_value,
1361 /* *** configure rx mode *** */
1362 struct cmd_config_rx_mode_flag {
1363 cmdline_fixed_string_t port;
1364 cmdline_fixed_string_t keyword;
1365 cmdline_fixed_string_t all;
1366 cmdline_fixed_string_t name;
1367 cmdline_fixed_string_t value;
1371 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1372 __attribute__((unused)) struct cmdline *cl,
1373 __attribute__((unused)) void *data)
1375 struct cmd_config_rx_mode_flag *res = parsed_result;
1377 if (!all_ports_stopped()) {
1378 printf("Please stop all ports first\n");
1382 if (!strcmp(res->name, "crc-strip")) {
1383 if (!strcmp(res->value, "on"))
1384 rx_mode.hw_strip_crc = 1;
1385 else if (!strcmp(res->value, "off"))
1386 rx_mode.hw_strip_crc = 0;
1388 printf("Unknown parameter\n");
1391 } else if (!strcmp(res->name, "rx-cksum")) {
1392 if (!strcmp(res->value, "on"))
1393 rx_mode.hw_ip_checksum = 1;
1394 else if (!strcmp(res->value, "off"))
1395 rx_mode.hw_ip_checksum = 0;
1397 printf("Unknown parameter\n");
1400 } else if (!strcmp(res->name, "hw-vlan")) {
1401 if (!strcmp(res->value, "on")) {
1402 rx_mode.hw_vlan_filter = 1;
1403 rx_mode.hw_vlan_strip = 1;
1405 else if (!strcmp(res->value, "off")) {
1406 rx_mode.hw_vlan_filter = 0;
1407 rx_mode.hw_vlan_strip = 0;
1410 printf("Unknown parameter\n");
1413 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1414 if (!strcmp(res->value, "on"))
1415 rx_mode.hw_vlan_filter = 1;
1416 else if (!strcmp(res->value, "off"))
1417 rx_mode.hw_vlan_filter = 0;
1419 printf("Unknown parameter\n");
1422 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1423 if (!strcmp(res->value, "on"))
1424 rx_mode.hw_vlan_strip = 1;
1425 else if (!strcmp(res->value, "off"))
1426 rx_mode.hw_vlan_strip = 0;
1428 printf("Unknown parameter\n");
1431 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1432 if (!strcmp(res->value, "on"))
1433 rx_mode.hw_vlan_extend = 1;
1434 else if (!strcmp(res->value, "off"))
1435 rx_mode.hw_vlan_extend = 0;
1437 printf("Unknown parameter\n");
1440 } else if (!strcmp(res->name, "drop-en")) {
1441 if (!strcmp(res->value, "on"))
1443 else if (!strcmp(res->value, "off"))
1446 printf("Unknown parameter\n");
1450 printf("Unknown parameter\n");
1456 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1459 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1460 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1461 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1462 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1464 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1465 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1466 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1467 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1468 "crc-strip#rx-cksum#hw-vlan#"
1469 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1470 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1471 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1474 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1475 .f = cmd_config_rx_mode_flag_parsed,
1477 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1478 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1480 (void *)&cmd_config_rx_mode_flag_port,
1481 (void *)&cmd_config_rx_mode_flag_keyword,
1482 (void *)&cmd_config_rx_mode_flag_all,
1483 (void *)&cmd_config_rx_mode_flag_name,
1484 (void *)&cmd_config_rx_mode_flag_value,
1489 /* *** configure rss *** */
1490 struct cmd_config_rss {
1491 cmdline_fixed_string_t port;
1492 cmdline_fixed_string_t keyword;
1493 cmdline_fixed_string_t all;
1494 cmdline_fixed_string_t name;
1495 cmdline_fixed_string_t value;
1499 cmd_config_rss_parsed(void *parsed_result,
1500 __attribute__((unused)) struct cmdline *cl,
1501 __attribute__((unused)) void *data)
1503 struct cmd_config_rss *res = parsed_result;
1504 struct rte_eth_rss_conf rss_conf;
1507 if (!strcmp(res->value, "all"))
1508 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1509 ETH_RSS_UDP | ETH_RSS_SCTP |
1511 else if (!strcmp(res->value, "ip"))
1512 rss_conf.rss_hf = ETH_RSS_IP;
1513 else if (!strcmp(res->value, "udp"))
1514 rss_conf.rss_hf = ETH_RSS_UDP;
1515 else if (!strcmp(res->value, "tcp"))
1516 rss_conf.rss_hf = ETH_RSS_TCP;
1517 else if (!strcmp(res->value, "sctp"))
1518 rss_conf.rss_hf = ETH_RSS_SCTP;
1519 else if (!strcmp(res->value, "ether"))
1520 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1521 else if (!strcmp(res->value, "none"))
1522 rss_conf.rss_hf = 0;
1524 printf("Unknown parameter\n");
1527 rss_conf.rss_key = NULL;
1528 for (i = 0; i < rte_eth_dev_count(); i++)
1529 rte_eth_dev_rss_hash_update(i, &rss_conf);
1532 cmdline_parse_token_string_t cmd_config_rss_port =
1533 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1534 cmdline_parse_token_string_t cmd_config_rss_keyword =
1535 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1536 cmdline_parse_token_string_t cmd_config_rss_all =
1537 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1538 cmdline_parse_token_string_t cmd_config_rss_name =
1539 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1540 cmdline_parse_token_string_t cmd_config_rss_value =
1541 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1542 "all#ip#tcp#udp#sctp#ether#none");
1544 cmdline_parse_inst_t cmd_config_rss = {
1545 .f = cmd_config_rss_parsed,
1547 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1549 (void *)&cmd_config_rss_port,
1550 (void *)&cmd_config_rss_keyword,
1551 (void *)&cmd_config_rss_all,
1552 (void *)&cmd_config_rss_name,
1553 (void *)&cmd_config_rss_value,
1558 /* *** configure rss hash key *** */
1559 struct cmd_config_rss_hash_key {
1560 cmdline_fixed_string_t port;
1561 cmdline_fixed_string_t config;
1563 cmdline_fixed_string_t rss_hash_key;
1564 cmdline_fixed_string_t rss_type;
1565 cmdline_fixed_string_t key;
1568 #define RSS_HASH_KEY_LENGTH 40
1570 hexa_digit_to_value(char hexa_digit)
1572 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1573 return (uint8_t) (hexa_digit - '0');
1574 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1575 return (uint8_t) ((hexa_digit - 'a') + 10);
1576 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1577 return (uint8_t) ((hexa_digit - 'A') + 10);
1578 /* Invalid hexa digit */
1583 parse_and_check_key_hexa_digit(char *key, int idx)
1587 hexa_v = hexa_digit_to_value(key[idx]);
1589 printf("invalid key: character %c at position %d is not a "
1590 "valid hexa digit\n", key[idx], idx);
1595 cmd_config_rss_hash_key_parsed(void *parsed_result,
1596 __attribute__((unused)) struct cmdline *cl,
1597 __attribute__((unused)) void *data)
1599 struct cmd_config_rss_hash_key *res = parsed_result;
1600 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1605 /* Check the length of the RSS hash key */
1606 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1607 printf("key length: %d invalid - key must be a string of %d"
1608 "hexa-decimal numbers\n", (int) strlen(res->key),
1609 RSS_HASH_KEY_LENGTH * 2);
1612 /* Translate RSS hash key into binary representation */
1613 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1614 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1617 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1620 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1622 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1623 RSS_HASH_KEY_LENGTH);
1626 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1627 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1628 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1631 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1632 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1633 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1635 rss_hash_key, "rss-hash-key");
1636 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1638 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1639 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1640 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1641 "ipv6-tcp-ex#ipv6-udp-ex");
1642 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1645 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1646 .f = cmd_config_rss_hash_key_parsed,
1649 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1650 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1651 "ipv6-sctp|ipv6-other|l2-payload|"
1652 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1654 (void *)&cmd_config_rss_hash_key_port,
1655 (void *)&cmd_config_rss_hash_key_config,
1656 (void *)&cmd_config_rss_hash_key_port_id,
1657 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1658 (void *)&cmd_config_rss_hash_key_rss_type,
1659 (void *)&cmd_config_rss_hash_key_value,
1664 /* *** configure port rxq/txq start/stop *** */
1665 struct cmd_config_rxtx_queue {
1666 cmdline_fixed_string_t port;
1668 cmdline_fixed_string_t rxtxq;
1670 cmdline_fixed_string_t opname;
1674 cmd_config_rxtx_queue_parsed(void *parsed_result,
1675 __attribute__((unused)) struct cmdline *cl,
1676 __attribute__((unused)) void *data)
1678 struct cmd_config_rxtx_queue *res = parsed_result;
1683 if (test_done == 0) {
1684 printf("Please stop forwarding first\n");
1688 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1691 if (port_is_started(res->portid) != 1) {
1692 printf("Please start port %u first\n", res->portid);
1696 if (!strcmp(res->rxtxq, "rxq"))
1698 else if (!strcmp(res->rxtxq, "txq"))
1701 printf("Unknown parameter\n");
1705 if (isrx && rx_queue_id_is_invalid(res->qid))
1707 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1710 if (!strcmp(res->opname, "start"))
1712 else if (!strcmp(res->opname, "stop"))
1715 printf("Unknown parameter\n");
1719 if (isstart && isrx)
1720 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1721 else if (!isstart && isrx)
1722 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1723 else if (isstart && !isrx)
1724 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1726 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1728 if (ret == -ENOTSUP)
1729 printf("Function not supported in PMD driver\n");
1732 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1734 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1735 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1736 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1738 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1739 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1740 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1744 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1745 .f = cmd_config_rxtx_queue_parsed,
1747 .help_str = "port X rxq|txq ID start|stop",
1749 (void *)&cmd_config_speed_all_port,
1750 (void *)&cmd_config_rxtx_queue_portid,
1751 (void *)&cmd_config_rxtx_queue_rxtxq,
1752 (void *)&cmd_config_rxtx_queue_qid,
1753 (void *)&cmd_config_rxtx_queue_opname,
1758 /* *** Configure RSS RETA *** */
1759 struct cmd_config_rss_reta {
1760 cmdline_fixed_string_t port;
1761 cmdline_fixed_string_t keyword;
1763 cmdline_fixed_string_t name;
1764 cmdline_fixed_string_t list_name;
1765 cmdline_fixed_string_t list_of_items;
1769 parse_reta_config(const char *str,
1770 struct rte_eth_rss_reta_entry64 *reta_conf,
1771 uint16_t nb_entries)
1775 uint16_t hash_index, idx, shift;
1778 const char *p, *p0 = str;
1785 unsigned long int_fld[_NUM_FLD];
1786 char *str_fld[_NUM_FLD];
1788 while ((p = strchr(p0,'(')) != NULL) {
1790 if((p0 = strchr(p,')')) == NULL)
1794 if(size >= sizeof(s))
1797 snprintf(s, sizeof(s), "%.*s", size, p);
1798 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1800 for (i = 0; i < _NUM_FLD; i++) {
1802 int_fld[i] = strtoul(str_fld[i], &end, 0);
1803 if (errno != 0 || end == str_fld[i] ||
1808 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1809 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1811 if (hash_index >= nb_entries) {
1812 printf("Invalid RETA hash index=%d\n", hash_index);
1816 idx = hash_index / RTE_RETA_GROUP_SIZE;
1817 shift = hash_index % RTE_RETA_GROUP_SIZE;
1818 reta_conf[idx].mask |= (1ULL << shift);
1819 reta_conf[idx].reta[shift] = nb_queue;
1826 cmd_set_rss_reta_parsed(void *parsed_result,
1827 __attribute__((unused)) struct cmdline *cl,
1828 __attribute__((unused)) void *data)
1831 struct rte_eth_dev_info dev_info;
1832 struct rte_eth_rss_reta_entry64 reta_conf[8];
1833 struct cmd_config_rss_reta *res = parsed_result;
1835 memset(&dev_info, 0, sizeof(dev_info));
1836 rte_eth_dev_info_get(res->port_id, &dev_info);
1837 if (dev_info.reta_size == 0) {
1838 printf("Redirection table size is 0 which is "
1839 "invalid for RSS\n");
1842 printf("The reta size of port %d is %u\n",
1843 res->port_id, dev_info.reta_size);
1844 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1845 printf("Currently do not support more than %u entries of "
1846 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1850 memset(reta_conf, 0, sizeof(reta_conf));
1851 if (!strcmp(res->list_name, "reta")) {
1852 if (parse_reta_config(res->list_of_items, reta_conf,
1853 dev_info.reta_size)) {
1854 printf("Invalid RSS Redirection Table "
1855 "config entered\n");
1858 ret = rte_eth_dev_rss_reta_update(res->port_id,
1859 reta_conf, dev_info.reta_size);
1861 printf("Bad redirection table parameter, "
1862 "return code = %d \n", ret);
1866 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1867 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1868 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1869 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1870 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1871 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1872 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1873 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1874 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1875 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1876 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1877 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1879 cmdline_parse_inst_t cmd_config_rss_reta = {
1880 .f = cmd_set_rss_reta_parsed,
1882 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1884 (void *)&cmd_config_rss_reta_port,
1885 (void *)&cmd_config_rss_reta_keyword,
1886 (void *)&cmd_config_rss_reta_port_id,
1887 (void *)&cmd_config_rss_reta_name,
1888 (void *)&cmd_config_rss_reta_list_name,
1889 (void *)&cmd_config_rss_reta_list_of_items,
1894 /* *** SHOW PORT RETA INFO *** */
1895 struct cmd_showport_reta {
1896 cmdline_fixed_string_t show;
1897 cmdline_fixed_string_t port;
1899 cmdline_fixed_string_t rss;
1900 cmdline_fixed_string_t reta;
1902 cmdline_fixed_string_t list_of_items;
1906 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1907 uint16_t nb_entries,
1911 const char *p, *p0 = str;
1915 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1918 p = strchr(p0, '(');
1922 p0 = strchr(p, ')');
1926 if (size >= sizeof(s)) {
1927 printf("The string size exceeds the internal buffer size\n");
1930 snprintf(s, sizeof(s), "%.*s", size, p);
1931 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1932 if (ret <= 0 || ret != num) {
1933 printf("The bits of masks do not match the number of "
1934 "reta entries: %u\n", num);
1937 for (i = 0; i < ret; i++)
1938 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1944 cmd_showport_reta_parsed(void *parsed_result,
1945 __attribute__((unused)) struct cmdline *cl,
1946 __attribute__((unused)) void *data)
1948 struct cmd_showport_reta *res = parsed_result;
1949 struct rte_eth_rss_reta_entry64 reta_conf[8];
1950 struct rte_eth_dev_info dev_info;
1952 memset(&dev_info, 0, sizeof(dev_info));
1953 rte_eth_dev_info_get(res->port_id, &dev_info);
1954 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1955 res->size > ETH_RSS_RETA_SIZE_512) {
1956 printf("Invalid redirection table size: %u\n", res->size);
1960 memset(reta_conf, 0, sizeof(reta_conf));
1961 if (showport_parse_reta_config(reta_conf, res->size,
1962 res->list_of_items) < 0) {
1963 printf("Invalid string: %s for reta masks\n",
1964 res->list_of_items);
1967 port_rss_reta_info(res->port_id, reta_conf, res->size);
1970 cmdline_parse_token_string_t cmd_showport_reta_show =
1971 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1972 cmdline_parse_token_string_t cmd_showport_reta_port =
1973 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1974 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1975 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1976 cmdline_parse_token_string_t cmd_showport_reta_rss =
1977 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1978 cmdline_parse_token_string_t cmd_showport_reta_reta =
1979 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1980 cmdline_parse_token_num_t cmd_showport_reta_size =
1981 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1982 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1983 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1984 list_of_items, NULL);
1986 cmdline_parse_inst_t cmd_showport_reta = {
1987 .f = cmd_showport_reta_parsed,
1989 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1991 (void *)&cmd_showport_reta_show,
1992 (void *)&cmd_showport_reta_port,
1993 (void *)&cmd_showport_reta_port_id,
1994 (void *)&cmd_showport_reta_rss,
1995 (void *)&cmd_showport_reta_reta,
1996 (void *)&cmd_showport_reta_size,
1997 (void *)&cmd_showport_reta_list_of_items,
2002 /* *** Show RSS hash configuration *** */
2003 struct cmd_showport_rss_hash {
2004 cmdline_fixed_string_t show;
2005 cmdline_fixed_string_t port;
2007 cmdline_fixed_string_t rss_hash;
2008 cmdline_fixed_string_t rss_type;
2009 cmdline_fixed_string_t key; /* optional argument */
2012 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2013 __attribute__((unused)) struct cmdline *cl,
2016 struct cmd_showport_rss_hash *res = parsed_result;
2018 port_rss_hash_conf_show(res->port_id, res->rss_type,
2019 show_rss_key != NULL);
2022 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2023 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2024 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2025 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2026 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2027 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2028 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2029 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2031 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2032 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2033 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2034 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2035 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2036 "ipv6-tcp-ex#ipv6-udp-ex");
2037 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2038 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2040 cmdline_parse_inst_t cmd_showport_rss_hash = {
2041 .f = cmd_showport_rss_hash_parsed,
2044 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2045 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2046 "ipv6-sctp|ipv6-other|l2-payload|"
2047 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2049 (void *)&cmd_showport_rss_hash_show,
2050 (void *)&cmd_showport_rss_hash_port,
2051 (void *)&cmd_showport_rss_hash_port_id,
2052 (void *)&cmd_showport_rss_hash_rss_hash,
2053 (void *)&cmd_showport_rss_hash_rss_hash_info,
2058 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2059 .f = cmd_showport_rss_hash_parsed,
2062 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2063 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2064 "ipv6-sctp|ipv6-other|l2-payload|"
2065 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2067 (void *)&cmd_showport_rss_hash_show,
2068 (void *)&cmd_showport_rss_hash_port,
2069 (void *)&cmd_showport_rss_hash_port_id,
2070 (void *)&cmd_showport_rss_hash_rss_hash,
2071 (void *)&cmd_showport_rss_hash_rss_hash_info,
2072 (void *)&cmd_showport_rss_hash_rss_key,
2077 /* *** Configure DCB *** */
2078 struct cmd_config_dcb {
2079 cmdline_fixed_string_t port;
2080 cmdline_fixed_string_t config;
2082 cmdline_fixed_string_t dcb;
2083 cmdline_fixed_string_t vt;
2084 cmdline_fixed_string_t vt_en;
2086 cmdline_fixed_string_t pfc;
2087 cmdline_fixed_string_t pfc_en;
2091 cmd_config_dcb_parsed(void *parsed_result,
2092 __attribute__((unused)) struct cmdline *cl,
2093 __attribute__((unused)) void *data)
2095 struct cmd_config_dcb *res = parsed_result;
2096 portid_t port_id = res->port_id;
2097 struct rte_port *port;
2101 port = &ports[port_id];
2102 /** Check if the port is not started **/
2103 if (port->port_status != RTE_PORT_STOPPED) {
2104 printf("Please stop port %d first\n", port_id);
2108 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2109 printf("The invalid number of traffic class,"
2110 " only 4 or 8 allowed.\n");
2114 if (nb_fwd_lcores < res->num_tcs) {
2115 printf("nb_cores shouldn't be less than number of TCs.\n");
2118 if (!strncmp(res->pfc_en, "on", 2))
2123 /* DCB in VT mode */
2124 if (!strncmp(res->vt_en, "on", 2))
2125 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2126 (enum rte_eth_nb_tcs)res->num_tcs,
2129 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2130 (enum rte_eth_nb_tcs)res->num_tcs,
2135 printf("Cannot initialize network ports.\n");
2139 cmd_reconfig_device_queue(port_id, 1, 1);
2142 cmdline_parse_token_string_t cmd_config_dcb_port =
2143 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2144 cmdline_parse_token_string_t cmd_config_dcb_config =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2146 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2147 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2148 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2150 cmdline_parse_token_string_t cmd_config_dcb_vt =
2151 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2152 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2154 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2155 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2156 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2157 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2158 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2159 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2161 cmdline_parse_inst_t cmd_config_dcb = {
2162 .f = cmd_config_dcb_parsed,
2164 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2166 (void *)&cmd_config_dcb_port,
2167 (void *)&cmd_config_dcb_config,
2168 (void *)&cmd_config_dcb_port_id,
2169 (void *)&cmd_config_dcb_dcb,
2170 (void *)&cmd_config_dcb_vt,
2171 (void *)&cmd_config_dcb_vt_en,
2172 (void *)&cmd_config_dcb_num_tcs,
2173 (void *)&cmd_config_dcb_pfc,
2174 (void *)&cmd_config_dcb_pfc_en,
2179 /* *** configure number of packets per burst *** */
2180 struct cmd_config_burst {
2181 cmdline_fixed_string_t port;
2182 cmdline_fixed_string_t keyword;
2183 cmdline_fixed_string_t all;
2184 cmdline_fixed_string_t name;
2189 cmd_config_burst_parsed(void *parsed_result,
2190 __attribute__((unused)) struct cmdline *cl,
2191 __attribute__((unused)) void *data)
2193 struct cmd_config_burst *res = parsed_result;
2195 if (!all_ports_stopped()) {
2196 printf("Please stop all ports first\n");
2200 if (!strcmp(res->name, "burst")) {
2201 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2202 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2205 nb_pkt_per_burst = res->value;
2207 printf("Unknown parameter\n");
2213 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2216 cmdline_parse_token_string_t cmd_config_burst_port =
2217 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2218 cmdline_parse_token_string_t cmd_config_burst_keyword =
2219 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2220 cmdline_parse_token_string_t cmd_config_burst_all =
2221 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2222 cmdline_parse_token_string_t cmd_config_burst_name =
2223 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2224 cmdline_parse_token_num_t cmd_config_burst_value =
2225 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2227 cmdline_parse_inst_t cmd_config_burst = {
2228 .f = cmd_config_burst_parsed,
2230 .help_str = "port config all burst value",
2232 (void *)&cmd_config_burst_port,
2233 (void *)&cmd_config_burst_keyword,
2234 (void *)&cmd_config_burst_all,
2235 (void *)&cmd_config_burst_name,
2236 (void *)&cmd_config_burst_value,
2241 /* *** configure rx/tx queues *** */
2242 struct cmd_config_thresh {
2243 cmdline_fixed_string_t port;
2244 cmdline_fixed_string_t keyword;
2245 cmdline_fixed_string_t all;
2246 cmdline_fixed_string_t name;
2251 cmd_config_thresh_parsed(void *parsed_result,
2252 __attribute__((unused)) struct cmdline *cl,
2253 __attribute__((unused)) void *data)
2255 struct cmd_config_thresh *res = parsed_result;
2257 if (!all_ports_stopped()) {
2258 printf("Please stop all ports first\n");
2262 if (!strcmp(res->name, "txpt"))
2263 tx_pthresh = res->value;
2264 else if(!strcmp(res->name, "txht"))
2265 tx_hthresh = res->value;
2266 else if(!strcmp(res->name, "txwt"))
2267 tx_wthresh = res->value;
2268 else if(!strcmp(res->name, "rxpt"))
2269 rx_pthresh = res->value;
2270 else if(!strcmp(res->name, "rxht"))
2271 rx_hthresh = res->value;
2272 else if(!strcmp(res->name, "rxwt"))
2273 rx_wthresh = res->value;
2275 printf("Unknown parameter\n");
2281 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2284 cmdline_parse_token_string_t cmd_config_thresh_port =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2286 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2287 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2288 cmdline_parse_token_string_t cmd_config_thresh_all =
2289 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2290 cmdline_parse_token_string_t cmd_config_thresh_name =
2291 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2292 "txpt#txht#txwt#rxpt#rxht#rxwt");
2293 cmdline_parse_token_num_t cmd_config_thresh_value =
2294 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2296 cmdline_parse_inst_t cmd_config_thresh = {
2297 .f = cmd_config_thresh_parsed,
2299 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2301 (void *)&cmd_config_thresh_port,
2302 (void *)&cmd_config_thresh_keyword,
2303 (void *)&cmd_config_thresh_all,
2304 (void *)&cmd_config_thresh_name,
2305 (void *)&cmd_config_thresh_value,
2310 /* *** configure free/rs threshold *** */
2311 struct cmd_config_threshold {
2312 cmdline_fixed_string_t port;
2313 cmdline_fixed_string_t keyword;
2314 cmdline_fixed_string_t all;
2315 cmdline_fixed_string_t name;
2320 cmd_config_threshold_parsed(void *parsed_result,
2321 __attribute__((unused)) struct cmdline *cl,
2322 __attribute__((unused)) void *data)
2324 struct cmd_config_threshold *res = parsed_result;
2326 if (!all_ports_stopped()) {
2327 printf("Please stop all ports first\n");
2331 if (!strcmp(res->name, "txfreet"))
2332 tx_free_thresh = res->value;
2333 else if (!strcmp(res->name, "txrst"))
2334 tx_rs_thresh = res->value;
2335 else if (!strcmp(res->name, "rxfreet"))
2336 rx_free_thresh = res->value;
2338 printf("Unknown parameter\n");
2344 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2347 cmdline_parse_token_string_t cmd_config_threshold_port =
2348 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2349 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2350 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2352 cmdline_parse_token_string_t cmd_config_threshold_all =
2353 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2354 cmdline_parse_token_string_t cmd_config_threshold_name =
2355 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2356 "txfreet#txrst#rxfreet");
2357 cmdline_parse_token_num_t cmd_config_threshold_value =
2358 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2360 cmdline_parse_inst_t cmd_config_threshold = {
2361 .f = cmd_config_threshold_parsed,
2363 .help_str = "port config all txfreet|txrst|rxfreet value",
2365 (void *)&cmd_config_threshold_port,
2366 (void *)&cmd_config_threshold_keyword,
2367 (void *)&cmd_config_threshold_all,
2368 (void *)&cmd_config_threshold_name,
2369 (void *)&cmd_config_threshold_value,
2375 struct cmd_stop_result {
2376 cmdline_fixed_string_t stop;
2379 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2380 __attribute__((unused)) struct cmdline *cl,
2381 __attribute__((unused)) void *data)
2383 stop_packet_forwarding();
2386 cmdline_parse_token_string_t cmd_stop_stop =
2387 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2389 cmdline_parse_inst_t cmd_stop = {
2390 .f = cmd_stop_parsed,
2392 .help_str = "stop - stop packet forwarding",
2394 (void *)&cmd_stop_stop,
2399 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2402 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2403 unsigned int *parsed_items, int check_unique_values)
2405 unsigned int nb_item;
2413 * First parse all items in the list and store their value.
2418 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2420 if ((c >= '0') && (c <= '9')) {
2421 value = (unsigned int) (value * 10 + (c - '0'));
2426 printf("character %c is not a decimal digit\n", c);
2430 printf("No valid value before comma\n");
2433 if (nb_item < max_items) {
2434 parsed_items[nb_item] = value;
2440 if (nb_item >= max_items) {
2441 printf("Number of %s = %u > %u (maximum items)\n",
2442 item_name, nb_item + 1, max_items);
2445 parsed_items[nb_item++] = value;
2446 if (! check_unique_values)
2450 * Then, check that all values in the list are differents.
2451 * No optimization here...
2453 for (i = 0; i < nb_item; i++) {
2454 for (j = i + 1; j < nb_item; j++) {
2455 if (parsed_items[j] == parsed_items[i]) {
2456 printf("duplicated %s %u at index %u and %u\n",
2457 item_name, parsed_items[i], i, j);
2465 struct cmd_set_list_result {
2466 cmdline_fixed_string_t cmd_keyword;
2467 cmdline_fixed_string_t list_name;
2468 cmdline_fixed_string_t list_of_items;
2471 static void cmd_set_list_parsed(void *parsed_result,
2472 __attribute__((unused)) struct cmdline *cl,
2473 __attribute__((unused)) void *data)
2475 struct cmd_set_list_result *res;
2477 unsigned int lcorelist[RTE_MAX_LCORE];
2478 unsigned int portlist[RTE_MAX_ETHPORTS];
2480 unsigned int nb_item;
2482 if (test_done == 0) {
2483 printf("Please stop forwarding first\n");
2487 res = parsed_result;
2488 if (!strcmp(res->list_name, "corelist")) {
2489 nb_item = parse_item_list(res->list_of_items, "core",
2491 parsed_items.lcorelist, 1);
2493 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2496 if (!strcmp(res->list_name, "portlist")) {
2497 nb_item = parse_item_list(res->list_of_items, "port",
2499 parsed_items.portlist, 1);
2501 set_fwd_ports_list(parsed_items.portlist, nb_item);
2505 cmdline_parse_token_string_t cmd_set_list_keyword =
2506 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2508 cmdline_parse_token_string_t cmd_set_list_name =
2509 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2510 "corelist#portlist");
2511 cmdline_parse_token_string_t cmd_set_list_of_items =
2512 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2515 cmdline_parse_inst_t cmd_set_fwd_list = {
2516 .f = cmd_set_list_parsed,
2518 .help_str = "set corelist|portlist x[,y]*",
2520 (void *)&cmd_set_list_keyword,
2521 (void *)&cmd_set_list_name,
2522 (void *)&cmd_set_list_of_items,
2527 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2529 struct cmd_setmask_result {
2530 cmdline_fixed_string_t set;
2531 cmdline_fixed_string_t mask;
2535 static void cmd_set_mask_parsed(void *parsed_result,
2536 __attribute__((unused)) struct cmdline *cl,
2537 __attribute__((unused)) void *data)
2539 struct cmd_setmask_result *res = parsed_result;
2541 if (test_done == 0) {
2542 printf("Please stop forwarding first\n");
2545 if (!strcmp(res->mask, "coremask"))
2546 set_fwd_lcores_mask(res->hexavalue);
2547 else if (!strcmp(res->mask, "portmask"))
2548 set_fwd_ports_mask(res->hexavalue);
2551 cmdline_parse_token_string_t cmd_setmask_set =
2552 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2553 cmdline_parse_token_string_t cmd_setmask_mask =
2554 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2555 "coremask#portmask");
2556 cmdline_parse_token_num_t cmd_setmask_value =
2557 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2559 cmdline_parse_inst_t cmd_set_fwd_mask = {
2560 .f = cmd_set_mask_parsed,
2562 .help_str = "set coremask|portmask hexadecimal value",
2564 (void *)&cmd_setmask_set,
2565 (void *)&cmd_setmask_mask,
2566 (void *)&cmd_setmask_value,
2572 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2574 struct cmd_set_result {
2575 cmdline_fixed_string_t set;
2576 cmdline_fixed_string_t what;
2580 static void cmd_set_parsed(void *parsed_result,
2581 __attribute__((unused)) struct cmdline *cl,
2582 __attribute__((unused)) void *data)
2584 struct cmd_set_result *res = parsed_result;
2585 if (!strcmp(res->what, "nbport"))
2586 set_fwd_ports_number(res->value);
2587 else if (!strcmp(res->what, "nbcore"))
2588 set_fwd_lcores_number(res->value);
2589 else if (!strcmp(res->what, "burst"))
2590 set_nb_pkt_per_burst(res->value);
2591 else if (!strcmp(res->what, "verbose"))
2592 set_verbose_level(res->value);
2595 cmdline_parse_token_string_t cmd_set_set =
2596 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2597 cmdline_parse_token_string_t cmd_set_what =
2598 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2599 "nbport#nbcore#burst#verbose");
2600 cmdline_parse_token_num_t cmd_set_value =
2601 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2603 cmdline_parse_inst_t cmd_set_numbers = {
2604 .f = cmd_set_parsed,
2606 .help_str = "set nbport|nbcore|burst|verbose value",
2608 (void *)&cmd_set_set,
2609 (void *)&cmd_set_what,
2610 (void *)&cmd_set_value,
2615 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2617 struct cmd_set_txpkts_result {
2618 cmdline_fixed_string_t cmd_keyword;
2619 cmdline_fixed_string_t txpkts;
2620 cmdline_fixed_string_t seg_lengths;
2624 cmd_set_txpkts_parsed(void *parsed_result,
2625 __attribute__((unused)) struct cmdline *cl,
2626 __attribute__((unused)) void *data)
2628 struct cmd_set_txpkts_result *res;
2629 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2630 unsigned int nb_segs;
2632 res = parsed_result;
2633 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2634 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2636 set_tx_pkt_segments(seg_lengths, nb_segs);
2639 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2640 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2641 cmd_keyword, "set");
2642 cmdline_parse_token_string_t cmd_set_txpkts_name =
2643 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2645 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2646 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2649 cmdline_parse_inst_t cmd_set_txpkts = {
2650 .f = cmd_set_txpkts_parsed,
2652 .help_str = "set txpkts x[,y]*",
2654 (void *)&cmd_set_txpkts_keyword,
2655 (void *)&cmd_set_txpkts_name,
2656 (void *)&cmd_set_txpkts_lengths,
2661 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2663 struct cmd_set_txsplit_result {
2664 cmdline_fixed_string_t cmd_keyword;
2665 cmdline_fixed_string_t txsplit;
2666 cmdline_fixed_string_t mode;
2670 cmd_set_txsplit_parsed(void *parsed_result,
2671 __attribute__((unused)) struct cmdline *cl,
2672 __attribute__((unused)) void *data)
2674 struct cmd_set_txsplit_result *res;
2676 res = parsed_result;
2677 set_tx_pkt_split(res->mode);
2680 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2681 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2682 cmd_keyword, "set");
2683 cmdline_parse_token_string_t cmd_set_txsplit_name =
2684 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2685 txsplit, "txsplit");
2686 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2687 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2690 cmdline_parse_inst_t cmd_set_txsplit = {
2691 .f = cmd_set_txsplit_parsed,
2693 .help_str = "set txsplit on|off|rand",
2695 (void *)&cmd_set_txsplit_keyword,
2696 (void *)&cmd_set_txsplit_name,
2697 (void *)&cmd_set_txsplit_mode,
2702 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2703 struct cmd_rx_vlan_filter_all_result {
2704 cmdline_fixed_string_t rx_vlan;
2705 cmdline_fixed_string_t what;
2706 cmdline_fixed_string_t all;
2711 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2712 __attribute__((unused)) struct cmdline *cl,
2713 __attribute__((unused)) void *data)
2715 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2717 if (!strcmp(res->what, "add"))
2718 rx_vlan_all_filter_set(res->port_id, 1);
2720 rx_vlan_all_filter_set(res->port_id, 0);
2723 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2724 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2725 rx_vlan, "rx_vlan");
2726 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2727 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2729 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2730 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2732 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2733 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2736 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2737 .f = cmd_rx_vlan_filter_all_parsed,
2739 .help_str = "add/remove all identifiers to/from the set of VLAN "
2740 "Identifiers filtered by a port",
2742 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2743 (void *)&cmd_rx_vlan_filter_all_what,
2744 (void *)&cmd_rx_vlan_filter_all_all,
2745 (void *)&cmd_rx_vlan_filter_all_portid,
2750 /* *** VLAN OFFLOAD SET ON A PORT *** */
2751 struct cmd_vlan_offload_result {
2752 cmdline_fixed_string_t vlan;
2753 cmdline_fixed_string_t set;
2754 cmdline_fixed_string_t vlan_type;
2755 cmdline_fixed_string_t what;
2756 cmdline_fixed_string_t on;
2757 cmdline_fixed_string_t port_id;
2761 cmd_vlan_offload_parsed(void *parsed_result,
2762 __attribute__((unused)) struct cmdline *cl,
2763 __attribute__((unused)) void *data)
2766 struct cmd_vlan_offload_result *res = parsed_result;
2769 portid_t port_id = 0;
2773 len = strnlen(str, STR_TOKEN_SIZE);
2775 /* Get port_id first */
2783 tmp = strtoul(str, NULL, 0);
2784 /* If port_id greater that what portid_t can represent, return */
2785 if(tmp >= RTE_MAX_ETHPORTS)
2787 port_id = (portid_t)tmp;
2789 if (!strcmp(res->on, "on"))
2794 if (!strcmp(res->what, "strip"))
2795 rx_vlan_strip_set(port_id, on);
2796 else if(!strcmp(res->what, "stripq")){
2797 uint16_t queue_id = 0;
2799 /* No queue_id, return */
2801 printf("must specify (port,queue_id)\n");
2804 tmp = strtoul(str + i + 1, NULL, 0);
2805 /* If queue_id greater that what 16-bits can represent, return */
2809 queue_id = (uint16_t)tmp;
2810 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2812 else if (!strcmp(res->what, "filter"))
2813 rx_vlan_filter_set(port_id, on);
2815 vlan_extend_set(port_id, on);
2820 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2821 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2823 cmdline_parse_token_string_t cmd_vlan_offload_set =
2824 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2826 cmdline_parse_token_string_t cmd_vlan_offload_what =
2827 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2828 what, "strip#filter#qinq#stripq");
2829 cmdline_parse_token_string_t cmd_vlan_offload_on =
2830 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2832 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2833 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2836 cmdline_parse_inst_t cmd_vlan_offload = {
2837 .f = cmd_vlan_offload_parsed,
2839 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2840 " qinq(extended) for both rx/tx sides ",
2842 (void *)&cmd_vlan_offload_vlan,
2843 (void *)&cmd_vlan_offload_set,
2844 (void *)&cmd_vlan_offload_what,
2845 (void *)&cmd_vlan_offload_on,
2846 (void *)&cmd_vlan_offload_portid,
2851 /* *** VLAN TPID SET ON A PORT *** */
2852 struct cmd_vlan_tpid_result {
2853 cmdline_fixed_string_t vlan;
2854 cmdline_fixed_string_t set;
2855 cmdline_fixed_string_t vlan_type;
2856 cmdline_fixed_string_t what;
2862 cmd_vlan_tpid_parsed(void *parsed_result,
2863 __attribute__((unused)) struct cmdline *cl,
2864 __attribute__((unused)) void *data)
2866 struct cmd_vlan_tpid_result *res = parsed_result;
2867 enum rte_vlan_type vlan_type;
2869 if (!strcmp(res->vlan_type, "inner"))
2870 vlan_type = ETH_VLAN_TYPE_INNER;
2871 else if (!strcmp(res->vlan_type, "outer"))
2872 vlan_type = ETH_VLAN_TYPE_OUTER;
2874 printf("Unknown vlan type\n");
2877 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
2880 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2881 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2883 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2884 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2886 cmdline_parse_token_string_t cmd_vlan_type =
2887 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2888 vlan_type, "inner#outer");
2889 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2890 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2892 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2893 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2895 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2896 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2899 cmdline_parse_inst_t cmd_vlan_tpid = {
2900 .f = cmd_vlan_tpid_parsed,
2902 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
2905 (void *)&cmd_vlan_tpid_vlan,
2906 (void *)&cmd_vlan_tpid_set,
2907 (void *)&cmd_vlan_type,
2908 (void *)&cmd_vlan_tpid_what,
2909 (void *)&cmd_vlan_tpid_tpid,
2910 (void *)&cmd_vlan_tpid_portid,
2915 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2916 struct cmd_rx_vlan_filter_result {
2917 cmdline_fixed_string_t rx_vlan;
2918 cmdline_fixed_string_t what;
2924 cmd_rx_vlan_filter_parsed(void *parsed_result,
2925 __attribute__((unused)) struct cmdline *cl,
2926 __attribute__((unused)) void *data)
2928 struct cmd_rx_vlan_filter_result *res = parsed_result;
2930 if (!strcmp(res->what, "add"))
2931 rx_vft_set(res->port_id, res->vlan_id, 1);
2933 rx_vft_set(res->port_id, res->vlan_id, 0);
2936 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2937 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2938 rx_vlan, "rx_vlan");
2939 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2940 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2942 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2943 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2945 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2946 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2949 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2950 .f = cmd_rx_vlan_filter_parsed,
2952 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2953 "Identifiers filtered by a port",
2955 (void *)&cmd_rx_vlan_filter_rx_vlan,
2956 (void *)&cmd_rx_vlan_filter_what,
2957 (void *)&cmd_rx_vlan_filter_vlanid,
2958 (void *)&cmd_rx_vlan_filter_portid,
2963 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2964 struct cmd_tx_vlan_set_result {
2965 cmdline_fixed_string_t tx_vlan;
2966 cmdline_fixed_string_t set;
2972 cmd_tx_vlan_set_parsed(void *parsed_result,
2973 __attribute__((unused)) struct cmdline *cl,
2974 __attribute__((unused)) void *data)
2976 struct cmd_tx_vlan_set_result *res = parsed_result;
2978 tx_vlan_set(res->port_id, res->vlan_id);
2981 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2982 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2983 tx_vlan, "tx_vlan");
2984 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2985 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2987 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2988 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2990 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2991 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2994 cmdline_parse_inst_t cmd_tx_vlan_set = {
2995 .f = cmd_tx_vlan_set_parsed,
2997 .help_str = "enable hardware insertion of a single VLAN header "
2998 "with a given TAG Identifier in packets sent on a port",
3000 (void *)&cmd_tx_vlan_set_tx_vlan,
3001 (void *)&cmd_tx_vlan_set_set,
3002 (void *)&cmd_tx_vlan_set_portid,
3003 (void *)&cmd_tx_vlan_set_vlanid,
3008 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3009 struct cmd_tx_vlan_set_qinq_result {
3010 cmdline_fixed_string_t tx_vlan;
3011 cmdline_fixed_string_t set;
3014 uint16_t vlan_id_outer;
3018 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3019 __attribute__((unused)) struct cmdline *cl,
3020 __attribute__((unused)) void *data)
3022 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3024 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3027 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3028 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3029 tx_vlan, "tx_vlan");
3030 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3031 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3033 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3034 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3036 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3037 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3039 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3040 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3041 vlan_id_outer, UINT16);
3043 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3044 .f = cmd_tx_vlan_set_qinq_parsed,
3046 .help_str = "enable hardware insertion of double VLAN header "
3047 "with given TAG Identifiers in packets sent on a port",
3049 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3050 (void *)&cmd_tx_vlan_set_qinq_set,
3051 (void *)&cmd_tx_vlan_set_qinq_portid,
3052 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3053 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3058 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3059 struct cmd_tx_vlan_set_pvid_result {
3060 cmdline_fixed_string_t tx_vlan;
3061 cmdline_fixed_string_t set;
3062 cmdline_fixed_string_t pvid;
3065 cmdline_fixed_string_t mode;
3069 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3070 __attribute__((unused)) struct cmdline *cl,
3071 __attribute__((unused)) void *data)
3073 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3075 if (strcmp(res->mode, "on") == 0)
3076 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3078 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3081 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3082 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3083 tx_vlan, "tx_vlan");
3084 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3085 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3087 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3088 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3090 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3091 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3093 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3094 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3096 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3097 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3100 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3101 .f = cmd_tx_vlan_set_pvid_parsed,
3103 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3105 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3106 (void *)&cmd_tx_vlan_set_pvid_set,
3107 (void *)&cmd_tx_vlan_set_pvid_pvid,
3108 (void *)&cmd_tx_vlan_set_pvid_port_id,
3109 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3110 (void *)&cmd_tx_vlan_set_pvid_mode,
3115 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3116 struct cmd_tx_vlan_reset_result {
3117 cmdline_fixed_string_t tx_vlan;
3118 cmdline_fixed_string_t reset;
3123 cmd_tx_vlan_reset_parsed(void *parsed_result,
3124 __attribute__((unused)) struct cmdline *cl,
3125 __attribute__((unused)) void *data)
3127 struct cmd_tx_vlan_reset_result *res = parsed_result;
3129 tx_vlan_reset(res->port_id);
3132 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3133 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3134 tx_vlan, "tx_vlan");
3135 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3136 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3138 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3139 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3142 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3143 .f = cmd_tx_vlan_reset_parsed,
3145 .help_str = "disable hardware insertion of a VLAN header in packets "
3148 (void *)&cmd_tx_vlan_reset_tx_vlan,
3149 (void *)&cmd_tx_vlan_reset_reset,
3150 (void *)&cmd_tx_vlan_reset_portid,
3156 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3157 struct cmd_csum_result {
3158 cmdline_fixed_string_t csum;
3159 cmdline_fixed_string_t mode;
3160 cmdline_fixed_string_t proto;
3161 cmdline_fixed_string_t hwsw;
3166 csum_show(int port_id)
3168 struct rte_eth_dev_info dev_info;
3171 ol_flags = ports[port_id].tx_ol_flags;
3172 printf("Parse tunnel is %s\n",
3173 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3174 printf("IP checksum offload is %s\n",
3175 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3176 printf("UDP checksum offload is %s\n",
3177 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3178 printf("TCP checksum offload is %s\n",
3179 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3180 printf("SCTP checksum offload is %s\n",
3181 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3182 printf("Outer-Ip checksum offload is %s\n",
3183 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3185 /* display warnings if configuration is not supported by the NIC */
3186 rte_eth_dev_info_get(port_id, &dev_info);
3187 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3188 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3189 printf("Warning: hardware IP checksum enabled but not "
3190 "supported by port %d\n", port_id);
3192 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3193 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3194 printf("Warning: hardware UDP checksum enabled but not "
3195 "supported by port %d\n", port_id);
3197 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3198 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3199 printf("Warning: hardware TCP checksum enabled but not "
3200 "supported by port %d\n", port_id);
3202 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3203 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3204 printf("Warning: hardware SCTP checksum enabled but not "
3205 "supported by port %d\n", port_id);
3207 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3208 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3209 printf("Warning: hardware outer IP checksum enabled but not "
3210 "supported by port %d\n", port_id);
3215 cmd_csum_parsed(void *parsed_result,
3216 __attribute__((unused)) struct cmdline *cl,
3217 __attribute__((unused)) void *data)
3219 struct cmd_csum_result *res = parsed_result;
3223 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3224 printf("invalid port %d\n", res->port_id);
3228 if (!strcmp(res->mode, "set")) {
3230 if (!strcmp(res->hwsw, "hw"))
3233 if (!strcmp(res->proto, "ip")) {
3234 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3235 } else if (!strcmp(res->proto, "udp")) {
3236 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3237 } else if (!strcmp(res->proto, "tcp")) {
3238 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3239 } else if (!strcmp(res->proto, "sctp")) {
3240 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3241 } else if (!strcmp(res->proto, "outer-ip")) {
3242 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3246 ports[res->port_id].tx_ol_flags |= mask;
3248 ports[res->port_id].tx_ol_flags &= (~mask);
3250 csum_show(res->port_id);
3253 cmdline_parse_token_string_t cmd_csum_csum =
3254 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3256 cmdline_parse_token_string_t cmd_csum_mode =
3257 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3259 cmdline_parse_token_string_t cmd_csum_proto =
3260 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3261 proto, "ip#tcp#udp#sctp#outer-ip");
3262 cmdline_parse_token_string_t cmd_csum_hwsw =
3263 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3265 cmdline_parse_token_num_t cmd_csum_portid =
3266 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3269 cmdline_parse_inst_t cmd_csum_set = {
3270 .f = cmd_csum_parsed,
3272 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3273 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3275 (void *)&cmd_csum_csum,
3276 (void *)&cmd_csum_mode,
3277 (void *)&cmd_csum_proto,
3278 (void *)&cmd_csum_hwsw,
3279 (void *)&cmd_csum_portid,
3284 cmdline_parse_token_string_t cmd_csum_mode_show =
3285 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3288 cmdline_parse_inst_t cmd_csum_show = {
3289 .f = cmd_csum_parsed,
3291 .help_str = "show checksum offload configuration: csum show <port>",
3293 (void *)&cmd_csum_csum,
3294 (void *)&cmd_csum_mode_show,
3295 (void *)&cmd_csum_portid,
3300 /* Enable/disable tunnel parsing */
3301 struct cmd_csum_tunnel_result {
3302 cmdline_fixed_string_t csum;
3303 cmdline_fixed_string_t parse;
3304 cmdline_fixed_string_t onoff;
3309 cmd_csum_tunnel_parsed(void *parsed_result,
3310 __attribute__((unused)) struct cmdline *cl,
3311 __attribute__((unused)) void *data)
3313 struct cmd_csum_tunnel_result *res = parsed_result;
3315 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3318 if (!strcmp(res->onoff, "on"))
3319 ports[res->port_id].tx_ol_flags |=
3320 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3322 ports[res->port_id].tx_ol_flags &=
3323 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3325 csum_show(res->port_id);
3328 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3329 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3331 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3332 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3333 parse, "parse_tunnel");
3334 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3335 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3337 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3338 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3341 cmdline_parse_inst_t cmd_csum_tunnel = {
3342 .f = cmd_csum_tunnel_parsed,
3344 .help_str = "enable/disable parsing of tunnels for csum engine: "
3345 "csum parse_tunnel on|off <tx-port>",
3347 (void *)&cmd_csum_tunnel_csum,
3348 (void *)&cmd_csum_tunnel_parse,
3349 (void *)&cmd_csum_tunnel_onoff,
3350 (void *)&cmd_csum_tunnel_portid,
3355 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3356 struct cmd_tso_set_result {
3357 cmdline_fixed_string_t tso;
3358 cmdline_fixed_string_t mode;
3364 cmd_tso_set_parsed(void *parsed_result,
3365 __attribute__((unused)) struct cmdline *cl,
3366 __attribute__((unused)) void *data)
3368 struct cmd_tso_set_result *res = parsed_result;
3369 struct rte_eth_dev_info dev_info;
3371 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3374 if (!strcmp(res->mode, "set"))
3375 ports[res->port_id].tso_segsz = res->tso_segsz;
3377 if (ports[res->port_id].tso_segsz == 0)
3378 printf("TSO is disabled\n");
3380 printf("TSO segment size is %d\n",
3381 ports[res->port_id].tso_segsz);
3383 /* display warnings if configuration is not supported by the NIC */
3384 rte_eth_dev_info_get(res->port_id, &dev_info);
3385 if ((ports[res->port_id].tso_segsz != 0) &&
3386 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3387 printf("Warning: TSO enabled but not "
3388 "supported by port %d\n", res->port_id);
3392 cmdline_parse_token_string_t cmd_tso_set_tso =
3393 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3395 cmdline_parse_token_string_t cmd_tso_set_mode =
3396 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3398 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3399 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3401 cmdline_parse_token_num_t cmd_tso_set_portid =
3402 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3405 cmdline_parse_inst_t cmd_tso_set = {
3406 .f = cmd_tso_set_parsed,
3408 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3409 "tso set <tso_segsz> <port>",
3411 (void *)&cmd_tso_set_tso,
3412 (void *)&cmd_tso_set_mode,
3413 (void *)&cmd_tso_set_tso_segsz,
3414 (void *)&cmd_tso_set_portid,
3419 cmdline_parse_token_string_t cmd_tso_show_mode =
3420 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3424 cmdline_parse_inst_t cmd_tso_show = {
3425 .f = cmd_tso_set_parsed,
3427 .help_str = "Show TSO segment size for csum engine: "
3430 (void *)&cmd_tso_set_tso,
3431 (void *)&cmd_tso_show_mode,
3432 (void *)&cmd_tso_set_portid,
3437 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3438 struct cmd_set_flush_rx {
3439 cmdline_fixed_string_t set;
3440 cmdline_fixed_string_t flush_rx;
3441 cmdline_fixed_string_t mode;
3445 cmd_set_flush_rx_parsed(void *parsed_result,
3446 __attribute__((unused)) struct cmdline *cl,
3447 __attribute__((unused)) void *data)
3449 struct cmd_set_flush_rx *res = parsed_result;
3450 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3453 cmdline_parse_token_string_t cmd_setflushrx_set =
3454 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3456 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3457 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3458 flush_rx, "flush_rx");
3459 cmdline_parse_token_string_t cmd_setflushrx_mode =
3460 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3464 cmdline_parse_inst_t cmd_set_flush_rx = {
3465 .f = cmd_set_flush_rx_parsed,
3466 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3469 (void *)&cmd_setflushrx_set,
3470 (void *)&cmd_setflushrx_flush_rx,
3471 (void *)&cmd_setflushrx_mode,
3476 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3477 struct cmd_set_link_check {
3478 cmdline_fixed_string_t set;
3479 cmdline_fixed_string_t link_check;
3480 cmdline_fixed_string_t mode;
3484 cmd_set_link_check_parsed(void *parsed_result,
3485 __attribute__((unused)) struct cmdline *cl,
3486 __attribute__((unused)) void *data)
3488 struct cmd_set_link_check *res = parsed_result;
3489 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3492 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3493 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3495 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3496 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3497 link_check, "link_check");
3498 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3499 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3503 cmdline_parse_inst_t cmd_set_link_check = {
3504 .f = cmd_set_link_check_parsed,
3505 .help_str = "set link_check on|off: enable/disable link status check "
3506 "when starting/stopping a port",
3509 (void *)&cmd_setlinkcheck_set,
3510 (void *)&cmd_setlinkcheck_link_check,
3511 (void *)&cmd_setlinkcheck_mode,
3516 #ifdef RTE_NIC_BYPASS
3517 /* *** SET NIC BYPASS MODE *** */
3518 struct cmd_set_bypass_mode_result {
3519 cmdline_fixed_string_t set;
3520 cmdline_fixed_string_t bypass;
3521 cmdline_fixed_string_t mode;
3522 cmdline_fixed_string_t value;
3527 cmd_set_bypass_mode_parsed(void *parsed_result,
3528 __attribute__((unused)) struct cmdline *cl,
3529 __attribute__((unused)) void *data)
3531 struct cmd_set_bypass_mode_result *res = parsed_result;
3532 portid_t port_id = res->port_id;
3533 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3535 if (!bypass_is_supported(port_id))
3538 if (!strcmp(res->value, "bypass"))
3539 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3540 else if (!strcmp(res->value, "isolate"))
3541 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3543 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3545 /* Set the bypass mode for the relevant port. */
3546 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3547 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3551 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3554 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3557 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3560 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3562 value, "normal#bypass#isolate");
3563 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3564 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3567 cmdline_parse_inst_t cmd_set_bypass_mode = {
3568 .f = cmd_set_bypass_mode_parsed,
3569 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3570 "Set the NIC bypass mode for port_id",
3573 (void *)&cmd_setbypass_mode_set,
3574 (void *)&cmd_setbypass_mode_bypass,
3575 (void *)&cmd_setbypass_mode_mode,
3576 (void *)&cmd_setbypass_mode_value,
3577 (void *)&cmd_setbypass_mode_port,
3582 /* *** SET NIC BYPASS EVENT *** */
3583 struct cmd_set_bypass_event_result {
3584 cmdline_fixed_string_t set;
3585 cmdline_fixed_string_t bypass;
3586 cmdline_fixed_string_t event;
3587 cmdline_fixed_string_t event_value;
3588 cmdline_fixed_string_t mode;
3589 cmdline_fixed_string_t mode_value;
3594 cmd_set_bypass_event_parsed(void *parsed_result,
3595 __attribute__((unused)) struct cmdline *cl,
3596 __attribute__((unused)) void *data)
3599 struct cmd_set_bypass_event_result *res = parsed_result;
3600 portid_t port_id = res->port_id;
3601 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3602 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3604 if (!bypass_is_supported(port_id))
3607 if (!strcmp(res->event_value, "timeout"))
3608 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3609 else if (!strcmp(res->event_value, "os_on"))
3610 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3611 else if (!strcmp(res->event_value, "os_off"))
3612 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3613 else if (!strcmp(res->event_value, "power_on"))
3614 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3615 else if (!strcmp(res->event_value, "power_off"))
3616 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3618 bypass_event = RTE_BYPASS_EVENT_NONE;
3620 if (!strcmp(res->mode_value, "bypass"))
3621 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3622 else if (!strcmp(res->mode_value, "isolate"))
3623 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3625 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3627 /* Set the watchdog timeout. */
3628 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3631 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3632 (rc = rte_eth_dev_wd_timeout_store(port_id,
3633 bypass_timeout)) != 0) {
3634 printf("Failed to set timeout value %u "
3635 "for port %d, errto code: %d.\n",
3636 bypass_timeout, port_id, rc);
3640 /* Set the bypass event to transition to bypass mode. */
3641 if (0 != rte_eth_dev_bypass_event_store(port_id,
3642 bypass_event, bypass_mode)) {
3643 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3648 cmdline_parse_token_string_t cmd_setbypass_event_set =
3649 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3651 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3652 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3654 cmdline_parse_token_string_t cmd_setbypass_event_event =
3655 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3657 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3658 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3659 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3660 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3661 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3663 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3664 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3665 mode_value, "normal#bypass#isolate");
3666 cmdline_parse_token_num_t cmd_setbypass_event_port =
3667 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3670 cmdline_parse_inst_t cmd_set_bypass_event = {
3671 .f = cmd_set_bypass_event_parsed,
3672 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3673 "mode (normal|bypass|isolate) (port_id): "
3674 "Set the NIC bypass event mode for port_id",
3677 (void *)&cmd_setbypass_event_set,
3678 (void *)&cmd_setbypass_event_bypass,
3679 (void *)&cmd_setbypass_event_event,
3680 (void *)&cmd_setbypass_event_event_value,
3681 (void *)&cmd_setbypass_event_mode,
3682 (void *)&cmd_setbypass_event_mode_value,
3683 (void *)&cmd_setbypass_event_port,
3689 /* *** SET NIC BYPASS TIMEOUT *** */
3690 struct cmd_set_bypass_timeout_result {
3691 cmdline_fixed_string_t set;
3692 cmdline_fixed_string_t bypass;
3693 cmdline_fixed_string_t timeout;
3694 cmdline_fixed_string_t value;
3698 cmd_set_bypass_timeout_parsed(void *parsed_result,
3699 __attribute__((unused)) struct cmdline *cl,
3700 __attribute__((unused)) void *data)
3702 struct cmd_set_bypass_timeout_result *res = parsed_result;
3704 if (!strcmp(res->value, "1.5"))
3705 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3706 else if (!strcmp(res->value, "2"))
3707 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3708 else if (!strcmp(res->value, "3"))
3709 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3710 else if (!strcmp(res->value, "4"))
3711 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3712 else if (!strcmp(res->value, "8"))
3713 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3714 else if (!strcmp(res->value, "16"))
3715 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3716 else if (!strcmp(res->value, "32"))
3717 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3719 bypass_timeout = RTE_BYPASS_TMT_OFF;
3722 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3723 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3725 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3726 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3728 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3729 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3730 timeout, "timeout");
3731 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3732 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3733 value, "0#1.5#2#3#4#8#16#32");
3735 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3736 .f = cmd_set_bypass_timeout_parsed,
3737 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3738 "Set the NIC bypass watchdog timeout",
3741 (void *)&cmd_setbypass_timeout_set,
3742 (void *)&cmd_setbypass_timeout_bypass,
3743 (void *)&cmd_setbypass_timeout_timeout,
3744 (void *)&cmd_setbypass_timeout_value,
3749 /* *** SHOW NIC BYPASS MODE *** */
3750 struct cmd_show_bypass_config_result {
3751 cmdline_fixed_string_t show;
3752 cmdline_fixed_string_t bypass;
3753 cmdline_fixed_string_t config;
3758 cmd_show_bypass_config_parsed(void *parsed_result,
3759 __attribute__((unused)) struct cmdline *cl,
3760 __attribute__((unused)) void *data)
3762 struct cmd_show_bypass_config_result *res = parsed_result;
3763 uint32_t event_mode;
3764 uint32_t bypass_mode;
3765 portid_t port_id = res->port_id;
3766 uint32_t timeout = bypass_timeout;
3769 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3770 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3771 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3772 {"UNKNOWN", "normal", "bypass", "isolate"};
3773 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3780 int num_events = (sizeof events) / (sizeof events[0]);
3782 if (!bypass_is_supported(port_id))
3785 /* Display the bypass mode.*/
3786 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3787 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3791 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3792 bypass_mode = RTE_BYPASS_MODE_NONE;
3794 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3797 /* Display the bypass timeout.*/
3798 if (!RTE_BYPASS_TMT_VALID(timeout))
3799 timeout = RTE_BYPASS_TMT_OFF;
3801 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3803 /* Display the bypass events and associated modes. */
3804 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3806 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3807 printf("\tFailed to get bypass mode for event = %s\n",
3810 if (!RTE_BYPASS_MODE_VALID(event_mode))
3811 event_mode = RTE_BYPASS_MODE_NONE;
3813 printf("\tbypass event: %-16s = %s\n", events[i],
3819 cmdline_parse_token_string_t cmd_showbypass_config_show =
3820 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3822 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3823 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3825 cmdline_parse_token_string_t cmd_showbypass_config_config =
3826 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3828 cmdline_parse_token_num_t cmd_showbypass_config_port =
3829 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3832 cmdline_parse_inst_t cmd_show_bypass_config = {
3833 .f = cmd_show_bypass_config_parsed,
3834 .help_str = "show bypass config (port_id): "
3835 "Show the NIC bypass config for port_id",
3838 (void *)&cmd_showbypass_config_show,
3839 (void *)&cmd_showbypass_config_bypass,
3840 (void *)&cmd_showbypass_config_config,
3841 (void *)&cmd_showbypass_config_port,
3847 #ifdef RTE_LIBRTE_PMD_BOND
3848 /* *** SET BONDING MODE *** */
3849 struct cmd_set_bonding_mode_result {
3850 cmdline_fixed_string_t set;
3851 cmdline_fixed_string_t bonding;
3852 cmdline_fixed_string_t mode;
3857 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3858 __attribute__((unused)) struct cmdline *cl,
3859 __attribute__((unused)) void *data)
3861 struct cmd_set_bonding_mode_result *res = parsed_result;
3862 portid_t port_id = res->port_id;
3864 /* Set the bonding mode for the relevant port. */
3865 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3866 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3869 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3870 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3872 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3873 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3874 bonding, "bonding");
3875 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3878 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3879 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3881 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3882 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3885 cmdline_parse_inst_t cmd_set_bonding_mode = {
3886 .f = cmd_set_bonding_mode_parsed,
3887 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3890 (void *) &cmd_setbonding_mode_set,
3891 (void *) &cmd_setbonding_mode_bonding,
3892 (void *) &cmd_setbonding_mode_mode,
3893 (void *) &cmd_setbonding_mode_value,
3894 (void *) &cmd_setbonding_mode_port,
3899 /* *** SET BALANCE XMIT POLICY *** */
3900 struct cmd_set_bonding_balance_xmit_policy_result {
3901 cmdline_fixed_string_t set;
3902 cmdline_fixed_string_t bonding;
3903 cmdline_fixed_string_t balance_xmit_policy;
3905 cmdline_fixed_string_t policy;
3908 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3909 __attribute__((unused)) struct cmdline *cl,
3910 __attribute__((unused)) void *data)
3912 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3913 portid_t port_id = res->port_id;
3916 if (!strcmp(res->policy, "l2")) {
3917 policy = BALANCE_XMIT_POLICY_LAYER2;
3918 } else if (!strcmp(res->policy, "l23")) {
3919 policy = BALANCE_XMIT_POLICY_LAYER23;
3920 } else if (!strcmp(res->policy, "l34")) {
3921 policy = BALANCE_XMIT_POLICY_LAYER34;
3923 printf("\t Invalid xmit policy selection");
3927 /* Set the bonding mode for the relevant port. */
3928 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3929 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3934 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3935 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3937 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3938 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3939 bonding, "bonding");
3940 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3941 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3942 balance_xmit_policy, "balance_xmit_policy");
3943 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3944 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3946 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3947 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3948 policy, "l2#l23#l34");
3950 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3951 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3952 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3955 (void *)&cmd_setbonding_balance_xmit_policy_set,
3956 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3957 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3958 (void *)&cmd_setbonding_balance_xmit_policy_port,
3959 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3964 /* *** SHOW NIC BONDING CONFIGURATION *** */
3965 struct cmd_show_bonding_config_result {
3966 cmdline_fixed_string_t show;
3967 cmdline_fixed_string_t bonding;
3968 cmdline_fixed_string_t config;
3972 static void cmd_show_bonding_config_parsed(void *parsed_result,
3973 __attribute__((unused)) struct cmdline *cl,
3974 __attribute__((unused)) void *data)
3976 struct cmd_show_bonding_config_result *res = parsed_result;
3978 uint8_t slaves[RTE_MAX_ETHPORTS];
3979 int num_slaves, num_active_slaves;
3982 portid_t port_id = res->port_id;
3984 /* Display the bonding mode.*/
3985 bonding_mode = rte_eth_bond_mode_get(port_id);
3986 if (bonding_mode < 0) {
3987 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3990 printf("\tBonding mode: %d\n", bonding_mode);
3992 if (bonding_mode == BONDING_MODE_BALANCE) {
3993 int balance_xmit_policy;
3995 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3996 if (balance_xmit_policy < 0) {
3997 printf("\tFailed to get balance xmit policy for port = %d\n",
4001 printf("\tBalance Xmit Policy: ");
4003 switch (balance_xmit_policy) {
4004 case BALANCE_XMIT_POLICY_LAYER2:
4005 printf("BALANCE_XMIT_POLICY_LAYER2");
4007 case BALANCE_XMIT_POLICY_LAYER23:
4008 printf("BALANCE_XMIT_POLICY_LAYER23");
4010 case BALANCE_XMIT_POLICY_LAYER34:
4011 printf("BALANCE_XMIT_POLICY_LAYER34");
4018 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4020 if (num_slaves < 0) {
4021 printf("\tFailed to get slave list for port = %d\n", port_id);
4024 if (num_slaves > 0) {
4025 printf("\tSlaves (%d): [", num_slaves);
4026 for (i = 0; i < num_slaves - 1; i++)
4027 printf("%d ", slaves[i]);
4029 printf("%d]\n", slaves[num_slaves - 1]);
4031 printf("\tSlaves: []\n");
4035 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4038 if (num_active_slaves < 0) {
4039 printf("\tFailed to get active slave list for port = %d\n", port_id);
4042 if (num_active_slaves > 0) {
4043 printf("\tActive Slaves (%d): [", num_active_slaves);
4044 for (i = 0; i < num_active_slaves - 1; i++)
4045 printf("%d ", slaves[i]);
4047 printf("%d]\n", slaves[num_active_slaves - 1]);
4050 printf("\tActive Slaves: []\n");
4054 primary_id = rte_eth_bond_primary_get(port_id);
4055 if (primary_id < 0) {
4056 printf("\tFailed to get primary slave for port = %d\n", port_id);
4059 printf("\tPrimary: [%d]\n", primary_id);
4063 cmdline_parse_token_string_t cmd_showbonding_config_show =
4064 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4066 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4067 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4068 bonding, "bonding");
4069 cmdline_parse_token_string_t cmd_showbonding_config_config =
4070 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4072 cmdline_parse_token_num_t cmd_showbonding_config_port =
4073 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4076 cmdline_parse_inst_t cmd_show_bonding_config = {
4077 .f = cmd_show_bonding_config_parsed,
4078 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4081 (void *)&cmd_showbonding_config_show,
4082 (void *)&cmd_showbonding_config_bonding,
4083 (void *)&cmd_showbonding_config_config,
4084 (void *)&cmd_showbonding_config_port,
4089 /* *** SET BONDING PRIMARY *** */
4090 struct cmd_set_bonding_primary_result {
4091 cmdline_fixed_string_t set;
4092 cmdline_fixed_string_t bonding;
4093 cmdline_fixed_string_t primary;
4098 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4099 __attribute__((unused)) struct cmdline *cl,
4100 __attribute__((unused)) void *data)
4102 struct cmd_set_bonding_primary_result *res = parsed_result;
4103 portid_t master_port_id = res->port_id;
4104 portid_t slave_port_id = res->slave_id;
4106 /* Set the primary slave for a bonded device. */
4107 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4108 printf("\t Failed to set primary slave for port = %d.\n",
4115 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4116 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4118 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4119 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4120 bonding, "bonding");
4121 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4122 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4123 primary, "primary");
4124 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4125 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4127 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4128 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4131 cmdline_parse_inst_t cmd_set_bonding_primary = {
4132 .f = cmd_set_bonding_primary_parsed,
4133 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4136 (void *)&cmd_setbonding_primary_set,
4137 (void *)&cmd_setbonding_primary_bonding,
4138 (void *)&cmd_setbonding_primary_primary,
4139 (void *)&cmd_setbonding_primary_slave,
4140 (void *)&cmd_setbonding_primary_port,
4145 /* *** ADD SLAVE *** */
4146 struct cmd_add_bonding_slave_result {
4147 cmdline_fixed_string_t add;
4148 cmdline_fixed_string_t bonding;
4149 cmdline_fixed_string_t slave;
4154 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4155 __attribute__((unused)) struct cmdline *cl,
4156 __attribute__((unused)) void *data)
4158 struct cmd_add_bonding_slave_result *res = parsed_result;
4159 portid_t master_port_id = res->port_id;
4160 portid_t slave_port_id = res->slave_id;
4162 /* Set the primary slave for a bonded device. */
4163 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4164 printf("\t Failed to add slave %d to master port = %d.\n",
4165 slave_port_id, master_port_id);
4169 set_port_slave_flag(slave_port_id);
4172 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4173 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4175 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4176 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4177 bonding, "bonding");
4178 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4179 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4181 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4182 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4184 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4185 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4188 cmdline_parse_inst_t cmd_add_bonding_slave = {
4189 .f = cmd_add_bonding_slave_parsed,
4190 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4193 (void *)&cmd_addbonding_slave_add,
4194 (void *)&cmd_addbonding_slave_bonding,
4195 (void *)&cmd_addbonding_slave_slave,
4196 (void *)&cmd_addbonding_slave_slaveid,
4197 (void *)&cmd_addbonding_slave_port,
4202 /* *** REMOVE SLAVE *** */
4203 struct cmd_remove_bonding_slave_result {
4204 cmdline_fixed_string_t remove;
4205 cmdline_fixed_string_t bonding;
4206 cmdline_fixed_string_t slave;
4211 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4212 __attribute__((unused)) struct cmdline *cl,
4213 __attribute__((unused)) void *data)
4215 struct cmd_remove_bonding_slave_result *res = parsed_result;
4216 portid_t master_port_id = res->port_id;
4217 portid_t slave_port_id = res->slave_id;
4219 /* Set the primary slave for a bonded device. */
4220 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4221 printf("\t Failed to remove slave %d from master port = %d.\n",
4222 slave_port_id, master_port_id);
4226 clear_port_slave_flag(slave_port_id);
4229 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4230 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4232 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4233 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4234 bonding, "bonding");
4235 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4236 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4238 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4239 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4241 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4242 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4245 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4246 .f = cmd_remove_bonding_slave_parsed,
4247 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4250 (void *)&cmd_removebonding_slave_remove,
4251 (void *)&cmd_removebonding_slave_bonding,
4252 (void *)&cmd_removebonding_slave_slave,
4253 (void *)&cmd_removebonding_slave_slaveid,
4254 (void *)&cmd_removebonding_slave_port,
4259 /* *** CREATE BONDED DEVICE *** */
4260 struct cmd_create_bonded_device_result {
4261 cmdline_fixed_string_t create;
4262 cmdline_fixed_string_t bonded;
4263 cmdline_fixed_string_t device;
4268 static int bond_dev_num = 0;
4270 static void cmd_create_bonded_device_parsed(void *parsed_result,
4271 __attribute__((unused)) struct cmdline *cl,
4272 __attribute__((unused)) void *data)
4274 struct cmd_create_bonded_device_result *res = parsed_result;
4275 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4278 if (test_done == 0) {
4279 printf("Please stop forwarding first\n");
4283 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4286 /* Create a new bonded device. */
4287 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4289 printf("\t Failed to create bonded device.\n");
4292 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4295 /* Update number of ports */
4296 nb_ports = rte_eth_dev_count();
4297 reconfig(port_id, res->socket);
4298 rte_eth_promiscuous_enable(port_id);
4299 ports[port_id].enabled = 1;
4304 cmdline_parse_token_string_t cmd_createbonded_device_create =
4305 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4307 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4308 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4310 cmdline_parse_token_string_t cmd_createbonded_device_device =
4311 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4313 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4314 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4316 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4317 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4320 cmdline_parse_inst_t cmd_create_bonded_device = {
4321 .f = cmd_create_bonded_device_parsed,
4322 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4325 (void *)&cmd_createbonded_device_create,
4326 (void *)&cmd_createbonded_device_bonded,
4327 (void *)&cmd_createbonded_device_device,
4328 (void *)&cmd_createbonded_device_mode,
4329 (void *)&cmd_createbonded_device_socket,
4334 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4335 struct cmd_set_bond_mac_addr_result {
4336 cmdline_fixed_string_t set;
4337 cmdline_fixed_string_t bonding;
4338 cmdline_fixed_string_t mac_addr;
4340 struct ether_addr address;
4343 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4344 __attribute__((unused)) struct cmdline *cl,
4345 __attribute__((unused)) void *data)
4347 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4350 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4353 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4355 /* check the return value and print it if is < 0 */
4357 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4360 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4361 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4362 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4363 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4365 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4366 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4368 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4369 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4370 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4371 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4373 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4374 .f = cmd_set_bond_mac_addr_parsed,
4376 .help_str = "set bonding mac_addr (port_id) (address): ",
4378 (void *)&cmd_set_bond_mac_addr_set,
4379 (void *)&cmd_set_bond_mac_addr_bonding,
4380 (void *)&cmd_set_bond_mac_addr_mac,
4381 (void *)&cmd_set_bond_mac_addr_portnum,
4382 (void *)&cmd_set_bond_mac_addr_addr,
4388 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4389 struct cmd_set_bond_mon_period_result {
4390 cmdline_fixed_string_t set;
4391 cmdline_fixed_string_t bonding;
4392 cmdline_fixed_string_t mon_period;
4397 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4398 __attribute__((unused)) struct cmdline *cl,
4399 __attribute__((unused)) void *data)
4401 struct cmd_set_bond_mon_period_result *res = parsed_result;
4404 if (res->port_num >= nb_ports) {
4405 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4409 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4411 /* check the return value and print it if is < 0 */
4413 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4416 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4417 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4419 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4420 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4421 bonding, "bonding");
4422 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4423 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4424 mon_period, "mon_period");
4425 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4426 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4428 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4429 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4432 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4433 .f = cmd_set_bond_mon_period_parsed,
4435 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4437 (void *)&cmd_set_bond_mon_period_set,
4438 (void *)&cmd_set_bond_mon_period_bonding,
4439 (void *)&cmd_set_bond_mon_period_mon_period,
4440 (void *)&cmd_set_bond_mon_period_portnum,
4441 (void *)&cmd_set_bond_mon_period_period_ms,
4446 #endif /* RTE_LIBRTE_PMD_BOND */
4448 /* *** SET FORWARDING MODE *** */
4449 struct cmd_set_fwd_mode_result {
4450 cmdline_fixed_string_t set;
4451 cmdline_fixed_string_t fwd;
4452 cmdline_fixed_string_t mode;
4455 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4456 __attribute__((unused)) struct cmdline *cl,
4457 __attribute__((unused)) void *data)
4459 struct cmd_set_fwd_mode_result *res = parsed_result;
4461 set_pkt_forwarding_mode(res->mode);
4464 cmdline_parse_token_string_t cmd_setfwd_set =
4465 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4466 cmdline_parse_token_string_t cmd_setfwd_fwd =
4467 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4468 cmdline_parse_token_string_t cmd_setfwd_mode =
4469 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4470 "" /* defined at init */);
4472 cmdline_parse_inst_t cmd_set_fwd_mode = {
4473 .f = cmd_set_fwd_mode_parsed,
4475 .help_str = NULL, /* defined at init */
4477 (void *)&cmd_setfwd_set,
4478 (void *)&cmd_setfwd_fwd,
4479 (void *)&cmd_setfwd_mode,
4484 static void cmd_set_fwd_mode_init(void)
4487 static char token[128];
4488 static char help[256];
4489 cmdline_parse_token_string_t *token_struct;
4491 modes = list_pkt_forwarding_modes();
4492 snprintf(help, sizeof help, "set fwd %s - "
4493 "set packet forwarding mode", modes);
4494 cmd_set_fwd_mode.help_str = help;
4496 /* string token separator is # */
4497 for (c = token; *modes != '\0'; modes++)
4502 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4503 token_struct->string_data.str = token;
4506 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4507 struct cmd_set_burst_tx_retry_result {
4508 cmdline_fixed_string_t set;
4509 cmdline_fixed_string_t burst;
4510 cmdline_fixed_string_t tx;
4511 cmdline_fixed_string_t delay;
4513 cmdline_fixed_string_t retry;
4517 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4518 __attribute__((unused)) struct cmdline *cl,
4519 __attribute__((unused)) void *data)
4521 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4523 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4524 && !strcmp(res->tx, "tx")) {
4525 if (!strcmp(res->delay, "delay"))
4526 burst_tx_delay_time = res->time;
4527 if (!strcmp(res->retry, "retry"))
4528 burst_tx_retry_num = res->retry_num;
4533 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4534 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4535 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4536 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4538 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4539 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4540 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4541 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4542 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4543 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4544 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4545 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4546 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4547 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4549 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4550 .f = cmd_set_burst_tx_retry_parsed,
4551 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4553 (void *)&cmd_set_burst_tx_retry_set,
4554 (void *)&cmd_set_burst_tx_retry_burst,
4555 (void *)&cmd_set_burst_tx_retry_tx,
4556 (void *)&cmd_set_burst_tx_retry_delay,
4557 (void *)&cmd_set_burst_tx_retry_time,
4558 (void *)&cmd_set_burst_tx_retry_retry,
4559 (void *)&cmd_set_burst_tx_retry_retry_num,
4564 /* *** SET PROMISC MODE *** */
4565 struct cmd_set_promisc_mode_result {
4566 cmdline_fixed_string_t set;
4567 cmdline_fixed_string_t promisc;
4568 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4569 uint8_t port_num; /* valid if "allports" argument == 0 */
4570 cmdline_fixed_string_t mode;
4573 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4574 __attribute__((unused)) struct cmdline *cl,
4577 struct cmd_set_promisc_mode_result *res = parsed_result;
4581 if (!strcmp(res->mode, "on"))
4588 FOREACH_PORT(i, ports) {
4590 rte_eth_promiscuous_enable(i);
4592 rte_eth_promiscuous_disable(i);
4597 rte_eth_promiscuous_enable(res->port_num);
4599 rte_eth_promiscuous_disable(res->port_num);
4603 cmdline_parse_token_string_t cmd_setpromisc_set =
4604 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4605 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4606 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4608 cmdline_parse_token_string_t cmd_setpromisc_portall =
4609 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4611 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4612 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4614 cmdline_parse_token_string_t cmd_setpromisc_mode =
4615 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4618 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4619 .f = cmd_set_promisc_mode_parsed,
4621 .help_str = "set promisc all on|off: set promisc mode for all ports",
4623 (void *)&cmd_setpromisc_set,
4624 (void *)&cmd_setpromisc_promisc,
4625 (void *)&cmd_setpromisc_portall,
4626 (void *)&cmd_setpromisc_mode,
4631 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4632 .f = cmd_set_promisc_mode_parsed,
4634 .help_str = "set promisc X on|off: set promisc mode on port X",
4636 (void *)&cmd_setpromisc_set,
4637 (void *)&cmd_setpromisc_promisc,
4638 (void *)&cmd_setpromisc_portnum,
4639 (void *)&cmd_setpromisc_mode,
4644 /* *** SET ALLMULTI MODE *** */
4645 struct cmd_set_allmulti_mode_result {
4646 cmdline_fixed_string_t set;
4647 cmdline_fixed_string_t allmulti;
4648 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4649 uint8_t port_num; /* valid if "allports" argument == 0 */
4650 cmdline_fixed_string_t mode;
4653 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4654 __attribute__((unused)) struct cmdline *cl,
4657 struct cmd_set_allmulti_mode_result *res = parsed_result;
4661 if (!strcmp(res->mode, "on"))
4668 FOREACH_PORT(i, ports) {
4670 rte_eth_allmulticast_enable(i);
4672 rte_eth_allmulticast_disable(i);
4677 rte_eth_allmulticast_enable(res->port_num);
4679 rte_eth_allmulticast_disable(res->port_num);
4683 cmdline_parse_token_string_t cmd_setallmulti_set =
4684 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4685 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4686 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4688 cmdline_parse_token_string_t cmd_setallmulti_portall =
4689 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4691 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4692 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4694 cmdline_parse_token_string_t cmd_setallmulti_mode =
4695 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4698 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4699 .f = cmd_set_allmulti_mode_parsed,
4701 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4703 (void *)&cmd_setallmulti_set,
4704 (void *)&cmd_setallmulti_allmulti,
4705 (void *)&cmd_setallmulti_portall,
4706 (void *)&cmd_setallmulti_mode,
4711 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4712 .f = cmd_set_allmulti_mode_parsed,
4714 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4716 (void *)&cmd_setallmulti_set,
4717 (void *)&cmd_setallmulti_allmulti,
4718 (void *)&cmd_setallmulti_portnum,
4719 (void *)&cmd_setallmulti_mode,
4724 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4725 struct cmd_link_flow_ctrl_set_result {
4726 cmdline_fixed_string_t set;
4727 cmdline_fixed_string_t flow_ctrl;
4728 cmdline_fixed_string_t rx;
4729 cmdline_fixed_string_t rx_lfc_mode;
4730 cmdline_fixed_string_t tx;
4731 cmdline_fixed_string_t tx_lfc_mode;
4732 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4733 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4734 cmdline_fixed_string_t autoneg_str;
4735 cmdline_fixed_string_t autoneg;
4736 cmdline_fixed_string_t hw_str;
4737 uint32_t high_water;
4738 cmdline_fixed_string_t lw_str;
4740 cmdline_fixed_string_t pt_str;
4741 uint16_t pause_time;
4742 cmdline_fixed_string_t xon_str;
4747 cmdline_parse_token_string_t cmd_lfc_set_set =
4748 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4750 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4751 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4752 flow_ctrl, "flow_ctrl");
4753 cmdline_parse_token_string_t cmd_lfc_set_rx =
4754 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4756 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4757 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4758 rx_lfc_mode, "on#off");
4759 cmdline_parse_token_string_t cmd_lfc_set_tx =
4760 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4762 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4763 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4764 tx_lfc_mode, "on#off");
4765 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4766 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4767 hw_str, "high_water");
4768 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4769 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4770 high_water, UINT32);
4771 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4772 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4773 lw_str, "low_water");
4774 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4775 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4777 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4779 pt_str, "pause_time");
4780 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4781 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4782 pause_time, UINT16);
4783 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4784 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4785 xon_str, "send_xon");
4786 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4787 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4789 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4790 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4791 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4792 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4793 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4794 mac_ctrl_frame_fwd_mode, "on#off");
4795 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4796 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4797 autoneg_str, "autoneg");
4798 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4799 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4801 cmdline_parse_token_num_t cmd_lfc_set_portid =
4802 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4805 /* forward declaration */
4807 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4810 cmdline_parse_inst_t cmd_link_flow_control_set = {
4811 .f = cmd_link_flow_ctrl_set_parsed,
4813 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4814 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4815 autoneg on|off port_id",
4817 (void *)&cmd_lfc_set_set,
4818 (void *)&cmd_lfc_set_flow_ctrl,
4819 (void *)&cmd_lfc_set_rx,
4820 (void *)&cmd_lfc_set_rx_mode,
4821 (void *)&cmd_lfc_set_tx,
4822 (void *)&cmd_lfc_set_tx_mode,
4823 (void *)&cmd_lfc_set_high_water,
4824 (void *)&cmd_lfc_set_low_water,
4825 (void *)&cmd_lfc_set_pause_time,
4826 (void *)&cmd_lfc_set_send_xon,
4827 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4828 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4829 (void *)&cmd_lfc_set_autoneg_str,
4830 (void *)&cmd_lfc_set_autoneg,
4831 (void *)&cmd_lfc_set_portid,
4836 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4837 .f = cmd_link_flow_ctrl_set_parsed,
4838 .data = (void *)&cmd_link_flow_control_set_rx,
4839 .help_str = "Change rx flow control parameter: set flow_ctrl "
4840 "rx on|off port_id",
4842 (void *)&cmd_lfc_set_set,
4843 (void *)&cmd_lfc_set_flow_ctrl,
4844 (void *)&cmd_lfc_set_rx,
4845 (void *)&cmd_lfc_set_rx_mode,
4846 (void *)&cmd_lfc_set_portid,
4851 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4852 .f = cmd_link_flow_ctrl_set_parsed,
4853 .data = (void *)&cmd_link_flow_control_set_tx,
4854 .help_str = "Change tx flow control parameter: set flow_ctrl "
4855 "tx on|off port_id",
4857 (void *)&cmd_lfc_set_set,
4858 (void *)&cmd_lfc_set_flow_ctrl,
4859 (void *)&cmd_lfc_set_tx,
4860 (void *)&cmd_lfc_set_tx_mode,
4861 (void *)&cmd_lfc_set_portid,
4866 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4867 .f = cmd_link_flow_ctrl_set_parsed,
4868 .data = (void *)&cmd_link_flow_control_set_hw,
4869 .help_str = "Change high water flow control parameter: set flow_ctrl "
4870 "high_water value port_id",
4872 (void *)&cmd_lfc_set_set,
4873 (void *)&cmd_lfc_set_flow_ctrl,
4874 (void *)&cmd_lfc_set_high_water_str,
4875 (void *)&cmd_lfc_set_high_water,
4876 (void *)&cmd_lfc_set_portid,
4881 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4882 .f = cmd_link_flow_ctrl_set_parsed,
4883 .data = (void *)&cmd_link_flow_control_set_lw,
4884 .help_str = "Change low water flow control parameter: set flow_ctrl "
4885 "low_water value port_id",
4887 (void *)&cmd_lfc_set_set,
4888 (void *)&cmd_lfc_set_flow_ctrl,
4889 (void *)&cmd_lfc_set_low_water_str,
4890 (void *)&cmd_lfc_set_low_water,
4891 (void *)&cmd_lfc_set_portid,
4896 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4897 .f = cmd_link_flow_ctrl_set_parsed,
4898 .data = (void *)&cmd_link_flow_control_set_pt,
4899 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4900 "pause_time value port_id",
4902 (void *)&cmd_lfc_set_set,
4903 (void *)&cmd_lfc_set_flow_ctrl,
4904 (void *)&cmd_lfc_set_pause_time_str,
4905 (void *)&cmd_lfc_set_pause_time,
4906 (void *)&cmd_lfc_set_portid,
4911 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4912 .f = cmd_link_flow_ctrl_set_parsed,
4913 .data = (void *)&cmd_link_flow_control_set_xon,
4914 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4915 "send_xon value port_id",
4917 (void *)&cmd_lfc_set_set,
4918 (void *)&cmd_lfc_set_flow_ctrl,
4919 (void *)&cmd_lfc_set_send_xon_str,
4920 (void *)&cmd_lfc_set_send_xon,
4921 (void *)&cmd_lfc_set_portid,
4926 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4927 .f = cmd_link_flow_ctrl_set_parsed,
4928 .data = (void *)&cmd_link_flow_control_set_macfwd,
4929 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4930 "mac_ctrl_frame_fwd on|off port_id",
4932 (void *)&cmd_lfc_set_set,
4933 (void *)&cmd_lfc_set_flow_ctrl,
4934 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4935 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4936 (void *)&cmd_lfc_set_portid,
4941 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4942 .f = cmd_link_flow_ctrl_set_parsed,
4943 .data = (void *)&cmd_link_flow_control_set_autoneg,
4944 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4945 "autoneg on|off port_id",
4947 (void *)&cmd_lfc_set_set,
4948 (void *)&cmd_lfc_set_flow_ctrl,
4949 (void *)&cmd_lfc_set_autoneg_str,
4950 (void *)&cmd_lfc_set_autoneg,
4951 (void *)&cmd_lfc_set_portid,
4957 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4958 __attribute__((unused)) struct cmdline *cl,
4961 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4962 cmdline_parse_inst_t *cmd = data;
4963 struct rte_eth_fc_conf fc_conf;
4969 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4970 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4971 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4972 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4974 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4975 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4978 /* Partial command line, retrieve current configuration */
4980 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4982 printf("cannot get current flow ctrl parameters, return"
4983 "code = %d\n", ret);
4987 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4988 (fc_conf.mode == RTE_FC_FULL))
4990 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4991 (fc_conf.mode == RTE_FC_FULL))
4995 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4996 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4998 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4999 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5001 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5003 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5004 fc_conf.high_water = res->high_water;
5006 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5007 fc_conf.low_water = res->low_water;
5009 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5010 fc_conf.pause_time = res->pause_time;
5012 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5013 fc_conf.send_xon = res->send_xon;
5015 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5016 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5017 fc_conf.mac_ctrl_frame_fwd = 1;
5019 fc_conf.mac_ctrl_frame_fwd = 0;
5022 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5023 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5025 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5027 printf("bad flow contrl parameter, return code = %d \n", ret);
5030 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5031 struct cmd_priority_flow_ctrl_set_result {
5032 cmdline_fixed_string_t set;
5033 cmdline_fixed_string_t pfc_ctrl;
5034 cmdline_fixed_string_t rx;
5035 cmdline_fixed_string_t rx_pfc_mode;
5036 cmdline_fixed_string_t tx;
5037 cmdline_fixed_string_t tx_pfc_mode;
5038 uint32_t high_water;
5040 uint16_t pause_time;
5046 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5047 __attribute__((unused)) struct cmdline *cl,
5048 __attribute__((unused)) void *data)
5050 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5051 struct rte_eth_pfc_conf pfc_conf;
5052 int rx_fc_enable, tx_fc_enable;
5056 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5057 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5058 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5059 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5061 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5062 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5065 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5066 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5067 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5068 pfc_conf.fc.high_water = res->high_water;
5069 pfc_conf.fc.low_water = res->low_water;
5070 pfc_conf.fc.pause_time = res->pause_time;
5071 pfc_conf.priority = res->priority;
5073 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5075 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5078 cmdline_parse_token_string_t cmd_pfc_set_set =
5079 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5081 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5082 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5083 pfc_ctrl, "pfc_ctrl");
5084 cmdline_parse_token_string_t cmd_pfc_set_rx =
5085 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5087 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5088 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5089 rx_pfc_mode, "on#off");
5090 cmdline_parse_token_string_t cmd_pfc_set_tx =
5091 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5093 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5094 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5095 tx_pfc_mode, "on#off");
5096 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5097 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5098 high_water, UINT32);
5099 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5100 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5102 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5103 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5104 pause_time, UINT16);
5105 cmdline_parse_token_num_t cmd_pfc_set_priority =
5106 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5108 cmdline_parse_token_num_t cmd_pfc_set_portid =
5109 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5112 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5113 .f = cmd_priority_flow_ctrl_set_parsed,
5115 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5116 tx on|off high_water low_water pause_time priority port_id",
5118 (void *)&cmd_pfc_set_set,
5119 (void *)&cmd_pfc_set_flow_ctrl,
5120 (void *)&cmd_pfc_set_rx,
5121 (void *)&cmd_pfc_set_rx_mode,
5122 (void *)&cmd_pfc_set_tx,
5123 (void *)&cmd_pfc_set_tx_mode,
5124 (void *)&cmd_pfc_set_high_water,
5125 (void *)&cmd_pfc_set_low_water,
5126 (void *)&cmd_pfc_set_pause_time,
5127 (void *)&cmd_pfc_set_priority,
5128 (void *)&cmd_pfc_set_portid,
5133 /* *** RESET CONFIGURATION *** */
5134 struct cmd_reset_result {
5135 cmdline_fixed_string_t reset;
5136 cmdline_fixed_string_t def;
5139 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5141 __attribute__((unused)) void *data)
5143 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5144 set_def_fwd_config();
5147 cmdline_parse_token_string_t cmd_reset_set =
5148 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5149 cmdline_parse_token_string_t cmd_reset_def =
5150 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5153 cmdline_parse_inst_t cmd_reset = {
5154 .f = cmd_reset_parsed,
5156 .help_str = "set default: reset default forwarding configuration",
5158 (void *)&cmd_reset_set,
5159 (void *)&cmd_reset_def,
5164 /* *** START FORWARDING *** */
5165 struct cmd_start_result {
5166 cmdline_fixed_string_t start;
5169 cmdline_parse_token_string_t cmd_start_start =
5170 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5172 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5173 __attribute__((unused)) struct cmdline *cl,
5174 __attribute__((unused)) void *data)
5176 start_packet_forwarding(0);
5179 cmdline_parse_inst_t cmd_start = {
5180 .f = cmd_start_parsed,
5182 .help_str = "start packet forwarding",
5184 (void *)&cmd_start_start,
5189 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5190 struct cmd_start_tx_first_result {
5191 cmdline_fixed_string_t start;
5192 cmdline_fixed_string_t tx_first;
5196 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5197 __attribute__((unused)) struct cmdline *cl,
5198 __attribute__((unused)) void *data)
5200 start_packet_forwarding(1);
5203 cmdline_parse_token_string_t cmd_start_tx_first_start =
5204 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5206 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5207 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5208 tx_first, "tx_first");
5210 cmdline_parse_inst_t cmd_start_tx_first = {
5211 .f = cmd_start_tx_first_parsed,
5213 .help_str = "start packet forwarding, after sending 1 burst of packets",
5215 (void *)&cmd_start_tx_first_start,
5216 (void *)&cmd_start_tx_first_tx_first,
5221 /* *** SET LINK UP *** */
5222 struct cmd_set_link_up_result {
5223 cmdline_fixed_string_t set;
5224 cmdline_fixed_string_t link_up;
5225 cmdline_fixed_string_t port;
5229 cmdline_parse_token_string_t cmd_set_link_up_set =
5230 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5231 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5232 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5234 cmdline_parse_token_string_t cmd_set_link_up_port =
5235 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5236 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5237 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5239 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5240 __attribute__((unused)) struct cmdline *cl,
5241 __attribute__((unused)) void *data)
5243 struct cmd_set_link_up_result *res = parsed_result;
5244 dev_set_link_up(res->port_id);
5247 cmdline_parse_inst_t cmd_set_link_up = {
5248 .f = cmd_set_link_up_parsed,
5250 .help_str = "set link-up port (port id)",
5252 (void *)&cmd_set_link_up_set,
5253 (void *)&cmd_set_link_up_link_up,
5254 (void *)&cmd_set_link_up_port,
5255 (void *)&cmd_set_link_up_port_id,
5260 /* *** SET LINK DOWN *** */
5261 struct cmd_set_link_down_result {
5262 cmdline_fixed_string_t set;
5263 cmdline_fixed_string_t link_down;
5264 cmdline_fixed_string_t port;
5268 cmdline_parse_token_string_t cmd_set_link_down_set =
5269 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5270 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5271 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5273 cmdline_parse_token_string_t cmd_set_link_down_port =
5274 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5275 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5276 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5278 static void cmd_set_link_down_parsed(
5279 __attribute__((unused)) void *parsed_result,
5280 __attribute__((unused)) struct cmdline *cl,
5281 __attribute__((unused)) void *data)
5283 struct cmd_set_link_down_result *res = parsed_result;
5284 dev_set_link_down(res->port_id);
5287 cmdline_parse_inst_t cmd_set_link_down = {
5288 .f = cmd_set_link_down_parsed,
5290 .help_str = "set link-down port (port id)",
5292 (void *)&cmd_set_link_down_set,
5293 (void *)&cmd_set_link_down_link_down,
5294 (void *)&cmd_set_link_down_port,
5295 (void *)&cmd_set_link_down_port_id,
5300 /* *** SHOW CFG *** */
5301 struct cmd_showcfg_result {
5302 cmdline_fixed_string_t show;
5303 cmdline_fixed_string_t cfg;
5304 cmdline_fixed_string_t what;
5307 static void cmd_showcfg_parsed(void *parsed_result,
5308 __attribute__((unused)) struct cmdline *cl,
5309 __attribute__((unused)) void *data)
5311 struct cmd_showcfg_result *res = parsed_result;
5312 if (!strcmp(res->what, "rxtx"))
5313 rxtx_config_display();
5314 else if (!strcmp(res->what, "cores"))
5315 fwd_lcores_config_display();
5316 else if (!strcmp(res->what, "fwd"))
5317 fwd_config_display();
5318 else if (!strcmp(res->what, "txpkts"))
5319 show_tx_pkt_segments();
5322 cmdline_parse_token_string_t cmd_showcfg_show =
5323 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5324 cmdline_parse_token_string_t cmd_showcfg_port =
5325 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5326 cmdline_parse_token_string_t cmd_showcfg_what =
5327 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5328 "rxtx#cores#fwd#txpkts");
5330 cmdline_parse_inst_t cmd_showcfg = {
5331 .f = cmd_showcfg_parsed,
5333 .help_str = "show config rxtx|cores|fwd|txpkts",
5335 (void *)&cmd_showcfg_show,
5336 (void *)&cmd_showcfg_port,
5337 (void *)&cmd_showcfg_what,
5342 /* *** SHOW ALL PORT INFO *** */
5343 struct cmd_showportall_result {
5344 cmdline_fixed_string_t show;
5345 cmdline_fixed_string_t port;
5346 cmdline_fixed_string_t what;
5347 cmdline_fixed_string_t all;
5350 static void cmd_showportall_parsed(void *parsed_result,
5351 __attribute__((unused)) struct cmdline *cl,
5352 __attribute__((unused)) void *data)
5356 struct cmd_showportall_result *res = parsed_result;
5357 if (!strcmp(res->show, "clear")) {
5358 if (!strcmp(res->what, "stats"))
5359 FOREACH_PORT(i, ports)
5361 else if (!strcmp(res->what, "xstats"))
5362 FOREACH_PORT(i, ports)
5363 nic_xstats_clear(i);
5364 } else if (!strcmp(res->what, "info"))
5365 FOREACH_PORT(i, ports)
5366 port_infos_display(i);
5367 else if (!strcmp(res->what, "stats"))
5368 FOREACH_PORT(i, ports)
5369 nic_stats_display(i);
5370 else if (!strcmp(res->what, "xstats"))
5371 FOREACH_PORT(i, ports)
5372 nic_xstats_display(i);
5373 else if (!strcmp(res->what, "fdir"))
5374 FOREACH_PORT(i, ports)
5376 else if (!strcmp(res->what, "stat_qmap"))
5377 FOREACH_PORT(i, ports)
5378 nic_stats_mapping_display(i);
5379 else if (!strcmp(res->what, "dcb_tc"))
5380 FOREACH_PORT(i, ports)
5381 port_dcb_info_display(i);
5384 cmdline_parse_token_string_t cmd_showportall_show =
5385 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5387 cmdline_parse_token_string_t cmd_showportall_port =
5388 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5389 cmdline_parse_token_string_t cmd_showportall_what =
5390 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5391 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5392 cmdline_parse_token_string_t cmd_showportall_all =
5393 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5394 cmdline_parse_inst_t cmd_showportall = {
5395 .f = cmd_showportall_parsed,
5397 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5399 (void *)&cmd_showportall_show,
5400 (void *)&cmd_showportall_port,
5401 (void *)&cmd_showportall_what,
5402 (void *)&cmd_showportall_all,
5407 /* *** SHOW PORT INFO *** */
5408 struct cmd_showport_result {
5409 cmdline_fixed_string_t show;
5410 cmdline_fixed_string_t port;
5411 cmdline_fixed_string_t what;
5415 static void cmd_showport_parsed(void *parsed_result,
5416 __attribute__((unused)) struct cmdline *cl,
5417 __attribute__((unused)) void *data)
5419 struct cmd_showport_result *res = parsed_result;
5420 if (!strcmp(res->show, "clear")) {
5421 if (!strcmp(res->what, "stats"))
5422 nic_stats_clear(res->portnum);
5423 else if (!strcmp(res->what, "xstats"))
5424 nic_xstats_clear(res->portnum);
5425 } else if (!strcmp(res->what, "info"))
5426 port_infos_display(res->portnum);
5427 else if (!strcmp(res->what, "stats"))
5428 nic_stats_display(res->portnum);
5429 else if (!strcmp(res->what, "xstats"))
5430 nic_xstats_display(res->portnum);
5431 else if (!strcmp(res->what, "fdir"))
5432 fdir_get_infos(res->portnum);
5433 else if (!strcmp(res->what, "stat_qmap"))
5434 nic_stats_mapping_display(res->portnum);
5435 else if (!strcmp(res->what, "dcb_tc"))
5436 port_dcb_info_display(res->portnum);
5439 cmdline_parse_token_string_t cmd_showport_show =
5440 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5442 cmdline_parse_token_string_t cmd_showport_port =
5443 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5444 cmdline_parse_token_string_t cmd_showport_what =
5445 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5446 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5447 cmdline_parse_token_num_t cmd_showport_portnum =
5448 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5450 cmdline_parse_inst_t cmd_showport = {
5451 .f = cmd_showport_parsed,
5453 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5455 (void *)&cmd_showport_show,
5456 (void *)&cmd_showport_port,
5457 (void *)&cmd_showport_what,
5458 (void *)&cmd_showport_portnum,
5463 /* *** SHOW QUEUE INFO *** */
5464 struct cmd_showqueue_result {
5465 cmdline_fixed_string_t show;
5466 cmdline_fixed_string_t type;
5467 cmdline_fixed_string_t what;
5473 cmd_showqueue_parsed(void *parsed_result,
5474 __attribute__((unused)) struct cmdline *cl,
5475 __attribute__((unused)) void *data)
5477 struct cmd_showqueue_result *res = parsed_result;
5479 if (!strcmp(res->type, "rxq"))
5480 rx_queue_infos_display(res->portnum, res->queuenum);
5481 else if (!strcmp(res->type, "txq"))
5482 tx_queue_infos_display(res->portnum, res->queuenum);
5485 cmdline_parse_token_string_t cmd_showqueue_show =
5486 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5487 cmdline_parse_token_string_t cmd_showqueue_type =
5488 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5489 cmdline_parse_token_string_t cmd_showqueue_what =
5490 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5491 cmdline_parse_token_num_t cmd_showqueue_portnum =
5492 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5493 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5494 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5496 cmdline_parse_inst_t cmd_showqueue = {
5497 .f = cmd_showqueue_parsed,
5499 .help_str = "show rxq|txq info <port number> <queue_number>",
5501 (void *)&cmd_showqueue_show,
5502 (void *)&cmd_showqueue_type,
5503 (void *)&cmd_showqueue_what,
5504 (void *)&cmd_showqueue_portnum,
5505 (void *)&cmd_showqueue_queuenum,
5510 /* *** READ PORT REGISTER *** */
5511 struct cmd_read_reg_result {
5512 cmdline_fixed_string_t read;
5513 cmdline_fixed_string_t reg;
5519 cmd_read_reg_parsed(void *parsed_result,
5520 __attribute__((unused)) struct cmdline *cl,
5521 __attribute__((unused)) void *data)
5523 struct cmd_read_reg_result *res = parsed_result;
5524 port_reg_display(res->port_id, res->reg_off);
5527 cmdline_parse_token_string_t cmd_read_reg_read =
5528 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5529 cmdline_parse_token_string_t cmd_read_reg_reg =
5530 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5531 cmdline_parse_token_num_t cmd_read_reg_port_id =
5532 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5533 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5534 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5536 cmdline_parse_inst_t cmd_read_reg = {
5537 .f = cmd_read_reg_parsed,
5539 .help_str = "read reg port_id reg_off",
5541 (void *)&cmd_read_reg_read,
5542 (void *)&cmd_read_reg_reg,
5543 (void *)&cmd_read_reg_port_id,
5544 (void *)&cmd_read_reg_reg_off,
5549 /* *** READ PORT REGISTER BIT FIELD *** */
5550 struct cmd_read_reg_bit_field_result {
5551 cmdline_fixed_string_t read;
5552 cmdline_fixed_string_t regfield;
5560 cmd_read_reg_bit_field_parsed(void *parsed_result,
5561 __attribute__((unused)) struct cmdline *cl,
5562 __attribute__((unused)) void *data)
5564 struct cmd_read_reg_bit_field_result *res = parsed_result;
5565 port_reg_bit_field_display(res->port_id, res->reg_off,
5566 res->bit1_pos, res->bit2_pos);
5569 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5570 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5572 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5573 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5574 regfield, "regfield");
5575 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5576 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5578 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5579 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5581 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5582 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5584 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5585 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5588 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5589 .f = cmd_read_reg_bit_field_parsed,
5591 .help_str = "read regfield port_id reg_off bit_x bit_y "
5592 "(read register bit field between bit_x and bit_y included)",
5594 (void *)&cmd_read_reg_bit_field_read,
5595 (void *)&cmd_read_reg_bit_field_regfield,
5596 (void *)&cmd_read_reg_bit_field_port_id,
5597 (void *)&cmd_read_reg_bit_field_reg_off,
5598 (void *)&cmd_read_reg_bit_field_bit1_pos,
5599 (void *)&cmd_read_reg_bit_field_bit2_pos,
5604 /* *** READ PORT REGISTER BIT *** */
5605 struct cmd_read_reg_bit_result {
5606 cmdline_fixed_string_t read;
5607 cmdline_fixed_string_t regbit;
5614 cmd_read_reg_bit_parsed(void *parsed_result,
5615 __attribute__((unused)) struct cmdline *cl,
5616 __attribute__((unused)) void *data)
5618 struct cmd_read_reg_bit_result *res = parsed_result;
5619 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5622 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5623 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5624 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5625 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5627 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5628 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5629 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5630 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5631 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5632 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5634 cmdline_parse_inst_t cmd_read_reg_bit = {
5635 .f = cmd_read_reg_bit_parsed,
5637 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5639 (void *)&cmd_read_reg_bit_read,
5640 (void *)&cmd_read_reg_bit_regbit,
5641 (void *)&cmd_read_reg_bit_port_id,
5642 (void *)&cmd_read_reg_bit_reg_off,
5643 (void *)&cmd_read_reg_bit_bit_pos,
5648 /* *** WRITE PORT REGISTER *** */
5649 struct cmd_write_reg_result {
5650 cmdline_fixed_string_t write;
5651 cmdline_fixed_string_t reg;
5658 cmd_write_reg_parsed(void *parsed_result,
5659 __attribute__((unused)) struct cmdline *cl,
5660 __attribute__((unused)) void *data)
5662 struct cmd_write_reg_result *res = parsed_result;
5663 port_reg_set(res->port_id, res->reg_off, res->value);
5666 cmdline_parse_token_string_t cmd_write_reg_write =
5667 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5668 cmdline_parse_token_string_t cmd_write_reg_reg =
5669 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5670 cmdline_parse_token_num_t cmd_write_reg_port_id =
5671 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5672 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5673 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5674 cmdline_parse_token_num_t cmd_write_reg_value =
5675 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5677 cmdline_parse_inst_t cmd_write_reg = {
5678 .f = cmd_write_reg_parsed,
5680 .help_str = "write reg port_id reg_off reg_value",
5682 (void *)&cmd_write_reg_write,
5683 (void *)&cmd_write_reg_reg,
5684 (void *)&cmd_write_reg_port_id,
5685 (void *)&cmd_write_reg_reg_off,
5686 (void *)&cmd_write_reg_value,
5691 /* *** WRITE PORT REGISTER BIT FIELD *** */
5692 struct cmd_write_reg_bit_field_result {
5693 cmdline_fixed_string_t write;
5694 cmdline_fixed_string_t regfield;
5703 cmd_write_reg_bit_field_parsed(void *parsed_result,
5704 __attribute__((unused)) struct cmdline *cl,
5705 __attribute__((unused)) void *data)
5707 struct cmd_write_reg_bit_field_result *res = parsed_result;
5708 port_reg_bit_field_set(res->port_id, res->reg_off,
5709 res->bit1_pos, res->bit2_pos, res->value);
5712 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5713 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5715 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5716 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5717 regfield, "regfield");
5718 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5719 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5721 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5722 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5724 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5725 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5727 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5728 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5730 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5731 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5734 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5735 .f = cmd_write_reg_bit_field_parsed,
5737 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5738 "(set register bit field between bit_x and bit_y included)",
5740 (void *)&cmd_write_reg_bit_field_write,
5741 (void *)&cmd_write_reg_bit_field_regfield,
5742 (void *)&cmd_write_reg_bit_field_port_id,
5743 (void *)&cmd_write_reg_bit_field_reg_off,
5744 (void *)&cmd_write_reg_bit_field_bit1_pos,
5745 (void *)&cmd_write_reg_bit_field_bit2_pos,
5746 (void *)&cmd_write_reg_bit_field_value,
5751 /* *** WRITE PORT REGISTER BIT *** */
5752 struct cmd_write_reg_bit_result {
5753 cmdline_fixed_string_t write;
5754 cmdline_fixed_string_t regbit;
5762 cmd_write_reg_bit_parsed(void *parsed_result,
5763 __attribute__((unused)) struct cmdline *cl,
5764 __attribute__((unused)) void *data)
5766 struct cmd_write_reg_bit_result *res = parsed_result;
5767 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5770 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5771 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5773 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5774 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5776 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5777 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5778 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5779 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5780 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5781 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5782 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5783 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5785 cmdline_parse_inst_t cmd_write_reg_bit = {
5786 .f = cmd_write_reg_bit_parsed,
5788 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5790 (void *)&cmd_write_reg_bit_write,
5791 (void *)&cmd_write_reg_bit_regbit,
5792 (void *)&cmd_write_reg_bit_port_id,
5793 (void *)&cmd_write_reg_bit_reg_off,
5794 (void *)&cmd_write_reg_bit_bit_pos,
5795 (void *)&cmd_write_reg_bit_value,
5800 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5801 struct cmd_read_rxd_txd_result {
5802 cmdline_fixed_string_t read;
5803 cmdline_fixed_string_t rxd_txd;
5810 cmd_read_rxd_txd_parsed(void *parsed_result,
5811 __attribute__((unused)) struct cmdline *cl,
5812 __attribute__((unused)) void *data)
5814 struct cmd_read_rxd_txd_result *res = parsed_result;
5816 if (!strcmp(res->rxd_txd, "rxd"))
5817 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5818 else if (!strcmp(res->rxd_txd, "txd"))
5819 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5822 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5823 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5824 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5825 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5827 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5828 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5829 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5830 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5831 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5832 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5834 cmdline_parse_inst_t cmd_read_rxd_txd = {
5835 .f = cmd_read_rxd_txd_parsed,
5837 .help_str = "read rxd|txd port_id queue_id rxd_id",
5839 (void *)&cmd_read_rxd_txd_read,
5840 (void *)&cmd_read_rxd_txd_rxd_txd,
5841 (void *)&cmd_read_rxd_txd_port_id,
5842 (void *)&cmd_read_rxd_txd_queue_id,
5843 (void *)&cmd_read_rxd_txd_desc_id,
5849 struct cmd_quit_result {
5850 cmdline_fixed_string_t quit;
5853 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5855 __attribute__((unused)) void *data)
5861 cmdline_parse_token_string_t cmd_quit_quit =
5862 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5864 cmdline_parse_inst_t cmd_quit = {
5865 .f = cmd_quit_parsed,
5867 .help_str = "exit application",
5869 (void *)&cmd_quit_quit,
5874 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5875 struct cmd_mac_addr_result {
5876 cmdline_fixed_string_t mac_addr_cmd;
5877 cmdline_fixed_string_t what;
5879 struct ether_addr address;
5882 static void cmd_mac_addr_parsed(void *parsed_result,
5883 __attribute__((unused)) struct cmdline *cl,
5884 __attribute__((unused)) void *data)
5886 struct cmd_mac_addr_result *res = parsed_result;
5889 if (strcmp(res->what, "add") == 0)
5890 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5892 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5894 /* check the return value and print it if is < 0 */
5896 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5900 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5901 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5903 cmdline_parse_token_string_t cmd_mac_addr_what =
5904 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5906 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5907 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5908 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5909 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5911 cmdline_parse_inst_t cmd_mac_addr = {
5912 .f = cmd_mac_addr_parsed,
5914 .help_str = "mac_addr add|remove X <address>: "
5915 "add/remove MAC address on port X",
5917 (void *)&cmd_mac_addr_cmd,
5918 (void *)&cmd_mac_addr_what,
5919 (void *)&cmd_mac_addr_portnum,
5920 (void *)&cmd_mac_addr_addr,
5926 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5927 struct cmd_set_qmap_result {
5928 cmdline_fixed_string_t set;
5929 cmdline_fixed_string_t qmap;
5930 cmdline_fixed_string_t what;
5937 cmd_set_qmap_parsed(void *parsed_result,
5938 __attribute__((unused)) struct cmdline *cl,
5939 __attribute__((unused)) void *data)
5941 struct cmd_set_qmap_result *res = parsed_result;
5942 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5944 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5947 cmdline_parse_token_string_t cmd_setqmap_set =
5948 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5950 cmdline_parse_token_string_t cmd_setqmap_qmap =
5951 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5953 cmdline_parse_token_string_t cmd_setqmap_what =
5954 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5956 cmdline_parse_token_num_t cmd_setqmap_portid =
5957 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5959 cmdline_parse_token_num_t cmd_setqmap_queueid =
5960 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5962 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5963 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5966 cmdline_parse_inst_t cmd_set_qmap = {
5967 .f = cmd_set_qmap_parsed,
5969 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5971 (void *)&cmd_setqmap_set,
5972 (void *)&cmd_setqmap_qmap,
5973 (void *)&cmd_setqmap_what,
5974 (void *)&cmd_setqmap_portid,
5975 (void *)&cmd_setqmap_queueid,
5976 (void *)&cmd_setqmap_mapvalue,
5981 /* *** CONFIGURE UNICAST HASH TABLE *** */
5982 struct cmd_set_uc_hash_table {
5983 cmdline_fixed_string_t set;
5984 cmdline_fixed_string_t port;
5986 cmdline_fixed_string_t what;
5987 struct ether_addr address;
5988 cmdline_fixed_string_t mode;
5992 cmd_set_uc_hash_parsed(void *parsed_result,
5993 __attribute__((unused)) struct cmdline *cl,
5994 __attribute__((unused)) void *data)
5997 struct cmd_set_uc_hash_table *res = parsed_result;
5999 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6001 if (strcmp(res->what, "uta") == 0)
6002 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6003 &res->address,(uint8_t)is_on);
6005 printf("bad unicast hash table parameter, return code = %d \n", ret);
6009 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6012 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6015 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6016 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6018 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6021 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6022 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6024 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6025 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6028 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6029 .f = cmd_set_uc_hash_parsed,
6031 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6033 (void *)&cmd_set_uc_hash_set,
6034 (void *)&cmd_set_uc_hash_port,
6035 (void *)&cmd_set_uc_hash_portid,
6036 (void *)&cmd_set_uc_hash_what,
6037 (void *)&cmd_set_uc_hash_mac,
6038 (void *)&cmd_set_uc_hash_mode,
6043 struct cmd_set_uc_all_hash_table {
6044 cmdline_fixed_string_t set;
6045 cmdline_fixed_string_t port;
6047 cmdline_fixed_string_t what;
6048 cmdline_fixed_string_t value;
6049 cmdline_fixed_string_t mode;
6053 cmd_set_uc_all_hash_parsed(void *parsed_result,
6054 __attribute__((unused)) struct cmdline *cl,
6055 __attribute__((unused)) void *data)
6058 struct cmd_set_uc_all_hash_table *res = parsed_result;
6060 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6062 if ((strcmp(res->what, "uta") == 0) &&
6063 (strcmp(res->value, "all") == 0))
6064 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6066 printf("bad unicast hash table parameter,"
6067 "return code = %d \n", ret);
6070 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6071 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6073 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6074 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6076 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6077 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6079 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6080 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6082 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6083 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6085 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6086 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6089 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6090 .f = cmd_set_uc_all_hash_parsed,
6092 .help_str = "set port X uta all on|off (X = port number)",
6094 (void *)&cmd_set_uc_all_hash_set,
6095 (void *)&cmd_set_uc_all_hash_port,
6096 (void *)&cmd_set_uc_all_hash_portid,
6097 (void *)&cmd_set_uc_all_hash_what,
6098 (void *)&cmd_set_uc_all_hash_value,
6099 (void *)&cmd_set_uc_all_hash_mode,
6104 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6105 struct cmd_set_vf_macvlan_filter {
6106 cmdline_fixed_string_t set;
6107 cmdline_fixed_string_t port;
6109 cmdline_fixed_string_t vf;
6111 struct ether_addr address;
6112 cmdline_fixed_string_t filter_type;
6113 cmdline_fixed_string_t mode;
6117 cmd_set_vf_macvlan_parsed(void *parsed_result,
6118 __attribute__((unused)) struct cmdline *cl,
6119 __attribute__((unused)) void *data)
6122 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6123 struct rte_eth_mac_filter filter;
6125 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6127 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6129 /* set VF MAC filter */
6133 filter.dst_id = res->vf_id;
6135 if (!strcmp(res->filter_type, "exact-mac"))
6136 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6137 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6138 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6139 else if (!strcmp(res->filter_type, "hashmac"))
6140 filter.filter_type = RTE_MAC_HASH_MATCH;
6141 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6142 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6144 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6147 ret = rte_eth_dev_filter_ctrl(res->port_id,
6148 RTE_ETH_FILTER_MACVLAN,
6152 ret = rte_eth_dev_filter_ctrl(res->port_id,
6153 RTE_ETH_FILTER_MACVLAN,
6154 RTE_ETH_FILTER_DELETE,
6158 printf("bad set MAC hash parameter, return code = %d\n", ret);
6162 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6163 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6165 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6166 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6168 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6169 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6171 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6172 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6174 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6175 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6177 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6178 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6180 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6181 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6182 filter_type, "exact-mac#exact-mac-vlan"
6183 "#hashmac#hashmac-vlan");
6184 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6185 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6188 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6189 .f = cmd_set_vf_macvlan_parsed,
6191 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6192 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6194 "exact match rule:exact match of MAC or MAC and VLAN; "
6195 "hash match rule: hash match of MAC and exact match "
6198 (void *)&cmd_set_vf_macvlan_set,
6199 (void *)&cmd_set_vf_macvlan_port,
6200 (void *)&cmd_set_vf_macvlan_portid,
6201 (void *)&cmd_set_vf_macvlan_vf,
6202 (void *)&cmd_set_vf_macvlan_vf_id,
6203 (void *)&cmd_set_vf_macvlan_mac,
6204 (void *)&cmd_set_vf_macvlan_filter_type,
6205 (void *)&cmd_set_vf_macvlan_mode,
6210 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6211 struct cmd_set_vf_traffic {
6212 cmdline_fixed_string_t set;
6213 cmdline_fixed_string_t port;
6215 cmdline_fixed_string_t vf;
6217 cmdline_fixed_string_t what;
6218 cmdline_fixed_string_t mode;
6222 cmd_set_vf_traffic_parsed(void *parsed_result,
6223 __attribute__((unused)) struct cmdline *cl,
6224 __attribute__((unused)) void *data)
6226 struct cmd_set_vf_traffic *res = parsed_result;
6227 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6228 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6230 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6233 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6234 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6236 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6237 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6239 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6240 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6242 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6243 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6245 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6246 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6248 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6249 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6251 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6252 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6255 cmdline_parse_inst_t cmd_set_vf_traffic = {
6256 .f = cmd_set_vf_traffic_parsed,
6258 .help_str = "set port X vf Y rx|tx on|off"
6259 "(X = port number,Y = vf id)",
6261 (void *)&cmd_setvf_traffic_set,
6262 (void *)&cmd_setvf_traffic_port,
6263 (void *)&cmd_setvf_traffic_portid,
6264 (void *)&cmd_setvf_traffic_vf,
6265 (void *)&cmd_setvf_traffic_vfid,
6266 (void *)&cmd_setvf_traffic_what,
6267 (void *)&cmd_setvf_traffic_mode,
6272 /* *** CONFIGURE VF RECEIVE MODE *** */
6273 struct cmd_set_vf_rxmode {
6274 cmdline_fixed_string_t set;
6275 cmdline_fixed_string_t port;
6277 cmdline_fixed_string_t vf;
6279 cmdline_fixed_string_t what;
6280 cmdline_fixed_string_t mode;
6281 cmdline_fixed_string_t on;
6285 cmd_set_vf_rxmode_parsed(void *parsed_result,
6286 __attribute__((unused)) struct cmdline *cl,
6287 __attribute__((unused)) void *data)
6290 uint16_t rx_mode = 0;
6291 struct cmd_set_vf_rxmode *res = parsed_result;
6293 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6294 if (!strcmp(res->what,"rxmode")) {
6295 if (!strcmp(res->mode, "AUPE"))
6296 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6297 else if (!strcmp(res->mode, "ROPE"))
6298 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6299 else if (!strcmp(res->mode, "BAM"))
6300 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6301 else if (!strncmp(res->mode, "MPE",3))
6302 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6305 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6307 printf("bad VF receive mode parameter, return code = %d \n",
6311 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6312 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6314 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6315 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6317 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6318 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6320 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6321 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6323 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6324 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6326 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6327 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6329 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6330 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6331 mode, "AUPE#ROPE#BAM#MPE");
6332 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6333 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6336 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6337 .f = cmd_set_vf_rxmode_parsed,
6339 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6341 (void *)&cmd_set_vf_rxmode_set,
6342 (void *)&cmd_set_vf_rxmode_port,
6343 (void *)&cmd_set_vf_rxmode_portid,
6344 (void *)&cmd_set_vf_rxmode_vf,
6345 (void *)&cmd_set_vf_rxmode_vfid,
6346 (void *)&cmd_set_vf_rxmode_what,
6347 (void *)&cmd_set_vf_rxmode_mode,
6348 (void *)&cmd_set_vf_rxmode_on,
6353 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6354 struct cmd_vf_mac_addr_result {
6355 cmdline_fixed_string_t mac_addr_cmd;
6356 cmdline_fixed_string_t what;
6357 cmdline_fixed_string_t port;
6359 cmdline_fixed_string_t vf;
6361 struct ether_addr address;
6364 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6365 __attribute__((unused)) struct cmdline *cl,
6366 __attribute__((unused)) void *data)
6368 struct cmd_vf_mac_addr_result *res = parsed_result;
6371 if (strcmp(res->what, "add") == 0)
6372 ret = rte_eth_dev_mac_addr_add(res->port_num,
6373 &res->address, res->vf_num);
6375 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6379 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6380 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6381 mac_addr_cmd,"mac_addr");
6382 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6383 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6385 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6386 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6388 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6389 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6391 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6392 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6394 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6395 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6397 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6398 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6401 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6402 .f = cmd_vf_mac_addr_parsed,
6404 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6405 "Y = VF number)add MAC address filtering for a VF on port X",
6407 (void *)&cmd_vf_mac_addr_cmd,
6408 (void *)&cmd_vf_mac_addr_what,
6409 (void *)&cmd_vf_mac_addr_port,
6410 (void *)&cmd_vf_mac_addr_portnum,
6411 (void *)&cmd_vf_mac_addr_vf,
6412 (void *)&cmd_vf_mac_addr_vfnum,
6413 (void *)&cmd_vf_mac_addr_addr,
6418 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6419 struct cmd_vf_rx_vlan_filter {
6420 cmdline_fixed_string_t rx_vlan;
6421 cmdline_fixed_string_t what;
6423 cmdline_fixed_string_t port;
6425 cmdline_fixed_string_t vf;
6430 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6431 __attribute__((unused)) struct cmdline *cl,
6432 __attribute__((unused)) void *data)
6434 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6436 if (!strcmp(res->what, "add"))
6437 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6439 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6442 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6443 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6444 rx_vlan, "rx_vlan");
6445 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6446 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6448 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6449 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6451 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6452 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6454 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6455 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6457 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6458 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6460 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6461 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6464 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6465 .f = cmd_vf_rx_vlan_filter_parsed,
6467 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6468 "Y = port number,Z = hexadecimal VF mask)",
6470 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6471 (void *)&cmd_vf_rx_vlan_filter_what,
6472 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6473 (void *)&cmd_vf_rx_vlan_filter_port,
6474 (void *)&cmd_vf_rx_vlan_filter_portid,
6475 (void *)&cmd_vf_rx_vlan_filter_vf,
6476 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6481 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6482 struct cmd_queue_rate_limit_result {
6483 cmdline_fixed_string_t set;
6484 cmdline_fixed_string_t port;
6486 cmdline_fixed_string_t queue;
6488 cmdline_fixed_string_t rate;
6492 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6493 __attribute__((unused)) struct cmdline *cl,
6494 __attribute__((unused)) void *data)
6496 struct cmd_queue_rate_limit_result *res = parsed_result;
6499 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6500 && (strcmp(res->queue, "queue") == 0)
6501 && (strcmp(res->rate, "rate") == 0))
6502 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6505 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6509 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6510 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6512 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6513 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6515 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6516 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6518 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6519 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6521 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6522 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6524 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6525 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6527 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6528 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6531 cmdline_parse_inst_t cmd_queue_rate_limit = {
6532 .f = cmd_queue_rate_limit_parsed,
6534 .help_str = "set port X queue Y rate Z:(X = port number,"
6535 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6537 (void *)&cmd_queue_rate_limit_set,
6538 (void *)&cmd_queue_rate_limit_port,
6539 (void *)&cmd_queue_rate_limit_portnum,
6540 (void *)&cmd_queue_rate_limit_queue,
6541 (void *)&cmd_queue_rate_limit_queuenum,
6542 (void *)&cmd_queue_rate_limit_rate,
6543 (void *)&cmd_queue_rate_limit_ratenum,
6548 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6549 struct cmd_vf_rate_limit_result {
6550 cmdline_fixed_string_t set;
6551 cmdline_fixed_string_t port;
6553 cmdline_fixed_string_t vf;
6555 cmdline_fixed_string_t rate;
6557 cmdline_fixed_string_t q_msk;
6561 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6562 __attribute__((unused)) struct cmdline *cl,
6563 __attribute__((unused)) void *data)
6565 struct cmd_vf_rate_limit_result *res = parsed_result;
6568 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6569 && (strcmp(res->vf, "vf") == 0)
6570 && (strcmp(res->rate, "rate") == 0)
6571 && (strcmp(res->q_msk, "queue_mask") == 0))
6572 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6573 res->rate_num, res->q_msk_val);
6575 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6579 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6580 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6582 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6583 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6585 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6586 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6588 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6589 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6591 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6592 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6594 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6595 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6597 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6598 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6600 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6601 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6602 q_msk, "queue_mask");
6603 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6604 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6607 cmdline_parse_inst_t cmd_vf_rate_limit = {
6608 .f = cmd_vf_rate_limit_parsed,
6610 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6611 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6612 "for queues of VF on port X",
6614 (void *)&cmd_vf_rate_limit_set,
6615 (void *)&cmd_vf_rate_limit_port,
6616 (void *)&cmd_vf_rate_limit_portnum,
6617 (void *)&cmd_vf_rate_limit_vf,
6618 (void *)&cmd_vf_rate_limit_vfnum,
6619 (void *)&cmd_vf_rate_limit_rate,
6620 (void *)&cmd_vf_rate_limit_ratenum,
6621 (void *)&cmd_vf_rate_limit_q_msk,
6622 (void *)&cmd_vf_rate_limit_q_msk_val,
6627 /* *** ADD TUNNEL FILTER OF A PORT *** */
6628 struct cmd_tunnel_filter_result {
6629 cmdline_fixed_string_t cmd;
6630 cmdline_fixed_string_t what;
6632 struct ether_addr outer_mac;
6633 struct ether_addr inner_mac;
6634 cmdline_ipaddr_t ip_value;
6635 uint16_t inner_vlan;
6636 cmdline_fixed_string_t tunnel_type;
6637 cmdline_fixed_string_t filter_type;
6643 cmd_tunnel_filter_parsed(void *parsed_result,
6644 __attribute__((unused)) struct cmdline *cl,
6645 __attribute__((unused)) void *data)
6647 struct cmd_tunnel_filter_result *res = parsed_result;
6648 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6651 tunnel_filter_conf.outer_mac = &res->outer_mac;
6652 tunnel_filter_conf.inner_mac = &res->inner_mac;
6653 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6655 if (res->ip_value.family == AF_INET) {
6656 tunnel_filter_conf.ip_addr.ipv4_addr =
6657 res->ip_value.addr.ipv4.s_addr;
6658 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6660 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6661 &(res->ip_value.addr.ipv6),
6662 sizeof(struct in6_addr));
6663 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6666 if (!strcmp(res->filter_type, "imac-ivlan"))
6667 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6668 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6669 tunnel_filter_conf.filter_type =
6670 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6671 else if (!strcmp(res->filter_type, "imac-tenid"))
6672 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6673 else if (!strcmp(res->filter_type, "imac"))
6674 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6675 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6676 tunnel_filter_conf.filter_type =
6677 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6679 printf("The filter type is not supported");
6683 if (!strcmp(res->tunnel_type, "vxlan"))
6684 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6685 else if (!strcmp(res->tunnel_type, "nvgre"))
6686 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6688 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6692 tunnel_filter_conf.tenant_id = res->tenant_id;
6693 tunnel_filter_conf.queue_id = res->queue_num;
6694 if (!strcmp(res->what, "add"))
6695 ret = rte_eth_dev_filter_ctrl(res->port_id,
6696 RTE_ETH_FILTER_TUNNEL,
6698 &tunnel_filter_conf);
6700 ret = rte_eth_dev_filter_ctrl(res->port_id,
6701 RTE_ETH_FILTER_TUNNEL,
6702 RTE_ETH_FILTER_DELETE,
6703 &tunnel_filter_conf);
6705 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6709 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6710 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6711 cmd, "tunnel_filter");
6712 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6713 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6715 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6716 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6718 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6719 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6721 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6722 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6724 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6725 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6726 inner_vlan, UINT16);
6727 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6728 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6730 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6731 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6732 tunnel_type, "vxlan#nvgre");
6734 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6735 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6736 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6737 "imac#omac-imac-tenid");
6738 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6739 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6741 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6742 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6745 cmdline_parse_inst_t cmd_tunnel_filter = {
6746 .f = cmd_tunnel_filter_parsed,
6748 .help_str = "add/rm tunnel filter of a port: "
6749 "tunnel_filter add port_id outer_mac inner_mac ip "
6750 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6751 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6752 "imac|omac-imac-tenid) "
6753 "tenant_id queue_num",
6755 (void *)&cmd_tunnel_filter_cmd,
6756 (void *)&cmd_tunnel_filter_what,
6757 (void *)&cmd_tunnel_filter_port_id,
6758 (void *)&cmd_tunnel_filter_outer_mac,
6759 (void *)&cmd_tunnel_filter_inner_mac,
6760 (void *)&cmd_tunnel_filter_ip_value,
6761 (void *)&cmd_tunnel_filter_innner_vlan,
6762 (void *)&cmd_tunnel_filter_tunnel_type,
6763 (void *)&cmd_tunnel_filter_filter_type,
6764 (void *)&cmd_tunnel_filter_tenant_id,
6765 (void *)&cmd_tunnel_filter_queue_num,
6770 /* *** CONFIGURE TUNNEL UDP PORT *** */
6771 struct cmd_tunnel_udp_config {
6772 cmdline_fixed_string_t cmd;
6773 cmdline_fixed_string_t what;
6779 cmd_tunnel_udp_config_parsed(void *parsed_result,
6780 __attribute__((unused)) struct cmdline *cl,
6781 __attribute__((unused)) void *data)
6783 struct cmd_tunnel_udp_config *res = parsed_result;
6784 struct rte_eth_udp_tunnel tunnel_udp;
6787 tunnel_udp.udp_port = res->udp_port;
6789 if (!strcmp(res->cmd, "rx_vxlan_port"))
6790 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6792 if (!strcmp(res->what, "add"))
6793 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6795 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6798 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6801 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6802 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6803 cmd, "rx_vxlan_port");
6804 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6805 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6807 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6808 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6810 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6811 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6814 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6815 .f = cmd_tunnel_udp_config_parsed,
6817 .help_str = "add/rm an tunneling UDP port filter: "
6818 "rx_vxlan_port add udp_port port_id",
6820 (void *)&cmd_tunnel_udp_config_cmd,
6821 (void *)&cmd_tunnel_udp_config_what,
6822 (void *)&cmd_tunnel_udp_config_udp_port,
6823 (void *)&cmd_tunnel_udp_config_port_id,
6828 /* *** GLOBAL CONFIG *** */
6829 struct cmd_global_config_result {
6830 cmdline_fixed_string_t cmd;
6832 cmdline_fixed_string_t cfg_type;
6837 cmd_global_config_parsed(void *parsed_result,
6838 __attribute__((unused)) struct cmdline *cl,
6839 __attribute__((unused)) void *data)
6841 struct cmd_global_config_result *res = parsed_result;
6842 struct rte_eth_global_cfg conf;
6845 memset(&conf, 0, sizeof(conf));
6846 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6847 conf.cfg.gre_key_len = res->len;
6848 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6849 RTE_ETH_FILTER_SET, &conf);
6851 printf("Global config error\n");
6854 cmdline_parse_token_string_t cmd_global_config_cmd =
6855 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6857 cmdline_parse_token_num_t cmd_global_config_port_id =
6858 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6859 cmdline_parse_token_string_t cmd_global_config_type =
6860 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6861 cfg_type, "gre-key-len");
6862 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6863 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6866 cmdline_parse_inst_t cmd_global_config = {
6867 .f = cmd_global_config_parsed,
6868 .data = (void *)NULL,
6869 .help_str = "global_config <port_id> gre-key-len <number>",
6871 (void *)&cmd_global_config_cmd,
6872 (void *)&cmd_global_config_port_id,
6873 (void *)&cmd_global_config_type,
6874 (void *)&cmd_global_config_gre_key_len,
6879 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6880 struct cmd_set_mirror_mask_result {
6881 cmdline_fixed_string_t set;
6882 cmdline_fixed_string_t port;
6884 cmdline_fixed_string_t mirror;
6886 cmdline_fixed_string_t what;
6887 cmdline_fixed_string_t value;
6888 cmdline_fixed_string_t dstpool;
6890 cmdline_fixed_string_t on;
6893 cmdline_parse_token_string_t cmd_mirror_mask_set =
6894 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6896 cmdline_parse_token_string_t cmd_mirror_mask_port =
6897 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6899 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6900 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6902 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6903 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6904 mirror, "mirror-rule");
6905 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6906 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6908 cmdline_parse_token_string_t cmd_mirror_mask_what =
6909 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6910 what, "pool-mirror-up#pool-mirror-down"
6912 cmdline_parse_token_string_t cmd_mirror_mask_value =
6913 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6915 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6916 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6917 dstpool, "dst-pool");
6918 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6919 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6921 cmdline_parse_token_string_t cmd_mirror_mask_on =
6922 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6926 cmd_set_mirror_mask_parsed(void *parsed_result,
6927 __attribute__((unused)) struct cmdline *cl,
6928 __attribute__((unused)) void *data)
6931 struct cmd_set_mirror_mask_result *res = parsed_result;
6932 struct rte_eth_mirror_conf mr_conf;
6934 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6936 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6938 mr_conf.dst_pool = res->dstpool_id;
6940 if (!strcmp(res->what, "pool-mirror-up")) {
6941 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6942 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6943 } else if (!strcmp(res->what, "pool-mirror-down")) {
6944 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6945 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6946 } else if (!strcmp(res->what, "vlan-mirror")) {
6947 mr_conf.rule_type = ETH_MIRROR_VLAN;
6948 nb_item = parse_item_list(res->value, "vlan",
6949 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6953 for (i = 0; i < nb_item; i++) {
6954 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6955 printf("Invalid vlan_id: must be < 4096\n");
6959 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6960 mr_conf.vlan.vlan_mask |= 1ULL << i;
6964 if (!strcmp(res->on, "on"))
6965 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6968 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6971 printf("mirror rule add error: (%s)\n", strerror(-ret));
6974 cmdline_parse_inst_t cmd_set_mirror_mask = {
6975 .f = cmd_set_mirror_mask_parsed,
6977 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6978 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6980 (void *)&cmd_mirror_mask_set,
6981 (void *)&cmd_mirror_mask_port,
6982 (void *)&cmd_mirror_mask_portid,
6983 (void *)&cmd_mirror_mask_mirror,
6984 (void *)&cmd_mirror_mask_ruleid,
6985 (void *)&cmd_mirror_mask_what,
6986 (void *)&cmd_mirror_mask_value,
6987 (void *)&cmd_mirror_mask_dstpool,
6988 (void *)&cmd_mirror_mask_poolid,
6989 (void *)&cmd_mirror_mask_on,
6994 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6995 struct cmd_set_mirror_link_result {
6996 cmdline_fixed_string_t set;
6997 cmdline_fixed_string_t port;
6999 cmdline_fixed_string_t mirror;
7001 cmdline_fixed_string_t what;
7002 cmdline_fixed_string_t dstpool;
7004 cmdline_fixed_string_t on;
7007 cmdline_parse_token_string_t cmd_mirror_link_set =
7008 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7010 cmdline_parse_token_string_t cmd_mirror_link_port =
7011 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7013 cmdline_parse_token_num_t cmd_mirror_link_portid =
7014 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7016 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7017 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7018 mirror, "mirror-rule");
7019 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7020 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7022 cmdline_parse_token_string_t cmd_mirror_link_what =
7023 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7024 what, "uplink-mirror#downlink-mirror");
7025 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7026 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7027 dstpool, "dst-pool");
7028 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7029 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7031 cmdline_parse_token_string_t cmd_mirror_link_on =
7032 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7036 cmd_set_mirror_link_parsed(void *parsed_result,
7037 __attribute__((unused)) struct cmdline *cl,
7038 __attribute__((unused)) void *data)
7041 struct cmd_set_mirror_link_result *res = parsed_result;
7042 struct rte_eth_mirror_conf mr_conf;
7044 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7045 if (!strcmp(res->what, "uplink-mirror"))
7046 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7048 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7050 mr_conf.dst_pool = res->dstpool_id;
7052 if (!strcmp(res->on, "on"))
7053 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7056 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7059 /* check the return value and print it if is < 0 */
7061 printf("mirror rule add error: (%s)\n", strerror(-ret));
7065 cmdline_parse_inst_t cmd_set_mirror_link = {
7066 .f = cmd_set_mirror_link_parsed,
7068 .help_str = "set port X mirror-rule Y uplink-mirror|"
7069 "downlink-mirror dst-pool Z on|off",
7071 (void *)&cmd_mirror_link_set,
7072 (void *)&cmd_mirror_link_port,
7073 (void *)&cmd_mirror_link_portid,
7074 (void *)&cmd_mirror_link_mirror,
7075 (void *)&cmd_mirror_link_ruleid,
7076 (void *)&cmd_mirror_link_what,
7077 (void *)&cmd_mirror_link_dstpool,
7078 (void *)&cmd_mirror_link_poolid,
7079 (void *)&cmd_mirror_link_on,
7084 /* *** RESET VM MIRROR RULE *** */
7085 struct cmd_rm_mirror_rule_result {
7086 cmdline_fixed_string_t reset;
7087 cmdline_fixed_string_t port;
7089 cmdline_fixed_string_t mirror;
7093 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7094 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7096 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7097 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7099 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7100 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7102 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7103 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7104 mirror, "mirror-rule");
7105 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7106 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7110 cmd_reset_mirror_rule_parsed(void *parsed_result,
7111 __attribute__((unused)) struct cmdline *cl,
7112 __attribute__((unused)) void *data)
7115 struct cmd_set_mirror_link_result *res = parsed_result;
7117 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7119 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7122 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7123 .f = cmd_reset_mirror_rule_parsed,
7125 .help_str = "reset port X mirror-rule Y",
7127 (void *)&cmd_rm_mirror_rule_reset,
7128 (void *)&cmd_rm_mirror_rule_port,
7129 (void *)&cmd_rm_mirror_rule_portid,
7130 (void *)&cmd_rm_mirror_rule_mirror,
7131 (void *)&cmd_rm_mirror_rule_ruleid,
7136 /* ******************************************************************************** */
7138 struct cmd_dump_result {
7139 cmdline_fixed_string_t dump;
7143 dump_struct_sizes(void)
7145 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7146 DUMP_SIZE(struct rte_mbuf);
7147 DUMP_SIZE(struct rte_mempool);
7148 DUMP_SIZE(struct rte_ring);
7152 static void cmd_dump_parsed(void *parsed_result,
7153 __attribute__((unused)) struct cmdline *cl,
7154 __attribute__((unused)) void *data)
7156 struct cmd_dump_result *res = parsed_result;
7158 if (!strcmp(res->dump, "dump_physmem"))
7159 rte_dump_physmem_layout(stdout);
7160 else if (!strcmp(res->dump, "dump_memzone"))
7161 rte_memzone_dump(stdout);
7162 else if (!strcmp(res->dump, "dump_log_history"))
7163 rte_log_dump_history(stdout);
7164 else if (!strcmp(res->dump, "dump_struct_sizes"))
7165 dump_struct_sizes();
7166 else if (!strcmp(res->dump, "dump_ring"))
7167 rte_ring_list_dump(stdout);
7168 else if (!strcmp(res->dump, "dump_mempool"))
7169 rte_mempool_list_dump(stdout);
7170 else if (!strcmp(res->dump, "dump_devargs"))
7171 rte_eal_devargs_dump(stdout);
7174 cmdline_parse_token_string_t cmd_dump_dump =
7175 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7179 "dump_struct_sizes#"
7184 cmdline_parse_inst_t cmd_dump = {
7185 .f = cmd_dump_parsed, /* function to call */
7186 .data = NULL, /* 2nd arg of func */
7187 .help_str = "dump status",
7188 .tokens = { /* token list, NULL terminated */
7189 (void *)&cmd_dump_dump,
7194 /* ******************************************************************************** */
7196 struct cmd_dump_one_result {
7197 cmdline_fixed_string_t dump;
7198 cmdline_fixed_string_t name;
7201 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7202 __attribute__((unused)) void *data)
7204 struct cmd_dump_one_result *res = parsed_result;
7206 if (!strcmp(res->dump, "dump_ring")) {
7208 r = rte_ring_lookup(res->name);
7210 cmdline_printf(cl, "Cannot find ring\n");
7213 rte_ring_dump(stdout, r);
7214 } else if (!strcmp(res->dump, "dump_mempool")) {
7215 struct rte_mempool *mp;
7216 mp = rte_mempool_lookup(res->name);
7218 cmdline_printf(cl, "Cannot find mempool\n");
7221 rte_mempool_dump(stdout, mp);
7225 cmdline_parse_token_string_t cmd_dump_one_dump =
7226 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7227 "dump_ring#dump_mempool");
7229 cmdline_parse_token_string_t cmd_dump_one_name =
7230 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7232 cmdline_parse_inst_t cmd_dump_one = {
7233 .f = cmd_dump_one_parsed, /* function to call */
7234 .data = NULL, /* 2nd arg of func */
7235 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7236 .tokens = { /* token list, NULL terminated */
7237 (void *)&cmd_dump_one_dump,
7238 (void *)&cmd_dump_one_name,
7243 /* *** Add/Del syn filter *** */
7244 struct cmd_syn_filter_result {
7245 cmdline_fixed_string_t filter;
7247 cmdline_fixed_string_t ops;
7248 cmdline_fixed_string_t priority;
7249 cmdline_fixed_string_t high;
7250 cmdline_fixed_string_t queue;
7255 cmd_syn_filter_parsed(void *parsed_result,
7256 __attribute__((unused)) struct cmdline *cl,
7257 __attribute__((unused)) void *data)
7259 struct cmd_syn_filter_result *res = parsed_result;
7260 struct rte_eth_syn_filter syn_filter;
7263 ret = rte_eth_dev_filter_supported(res->port_id,
7264 RTE_ETH_FILTER_SYN);
7266 printf("syn filter is not supported on port %u.\n",
7271 memset(&syn_filter, 0, sizeof(syn_filter));
7273 if (!strcmp(res->ops, "add")) {
7274 if (!strcmp(res->high, "high"))
7275 syn_filter.hig_pri = 1;
7277 syn_filter.hig_pri = 0;
7279 syn_filter.queue = res->queue_id;
7280 ret = rte_eth_dev_filter_ctrl(res->port_id,
7285 ret = rte_eth_dev_filter_ctrl(res->port_id,
7287 RTE_ETH_FILTER_DELETE,
7291 printf("syn filter programming error: (%s)\n",
7295 cmdline_parse_token_string_t cmd_syn_filter_filter =
7296 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7297 filter, "syn_filter");
7298 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7299 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7301 cmdline_parse_token_string_t cmd_syn_filter_ops =
7302 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7304 cmdline_parse_token_string_t cmd_syn_filter_priority =
7305 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7306 priority, "priority");
7307 cmdline_parse_token_string_t cmd_syn_filter_high =
7308 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7310 cmdline_parse_token_string_t cmd_syn_filter_queue =
7311 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7313 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7314 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7317 cmdline_parse_inst_t cmd_syn_filter = {
7318 .f = cmd_syn_filter_parsed,
7320 .help_str = "add/delete syn filter",
7322 (void *)&cmd_syn_filter_filter,
7323 (void *)&cmd_syn_filter_port_id,
7324 (void *)&cmd_syn_filter_ops,
7325 (void *)&cmd_syn_filter_priority,
7326 (void *)&cmd_syn_filter_high,
7327 (void *)&cmd_syn_filter_queue,
7328 (void *)&cmd_syn_filter_queue_id,
7333 /* *** ADD/REMOVE A 2tuple FILTER *** */
7334 struct cmd_2tuple_filter_result {
7335 cmdline_fixed_string_t filter;
7337 cmdline_fixed_string_t ops;
7338 cmdline_fixed_string_t dst_port;
7339 uint16_t dst_port_value;
7340 cmdline_fixed_string_t protocol;
7341 uint8_t protocol_value;
7342 cmdline_fixed_string_t mask;
7344 cmdline_fixed_string_t tcp_flags;
7345 uint8_t tcp_flags_value;
7346 cmdline_fixed_string_t priority;
7347 uint8_t priority_value;
7348 cmdline_fixed_string_t queue;
7353 cmd_2tuple_filter_parsed(void *parsed_result,
7354 __attribute__((unused)) struct cmdline *cl,
7355 __attribute__((unused)) void *data)
7357 struct rte_eth_ntuple_filter filter;
7358 struct cmd_2tuple_filter_result *res = parsed_result;
7361 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7363 printf("ntuple filter is not supported on port %u.\n",
7368 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7370 filter.flags = RTE_2TUPLE_FLAGS;
7371 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7372 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7373 filter.proto = res->protocol_value;
7374 filter.priority = res->priority_value;
7375 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7376 printf("nonzero tcp_flags is only meaningful"
7377 " when protocol is TCP.\n");
7380 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7381 printf("invalid TCP flags.\n");
7385 if (res->tcp_flags_value != 0) {
7386 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7387 filter.tcp_flags = res->tcp_flags_value;
7390 /* need convert to big endian. */
7391 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7392 filter.queue = res->queue_id;
7394 if (!strcmp(res->ops, "add"))
7395 ret = rte_eth_dev_filter_ctrl(res->port_id,
7396 RTE_ETH_FILTER_NTUPLE,
7400 ret = rte_eth_dev_filter_ctrl(res->port_id,
7401 RTE_ETH_FILTER_NTUPLE,
7402 RTE_ETH_FILTER_DELETE,
7405 printf("2tuple filter programming error: (%s)\n",
7410 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7411 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7412 filter, "2tuple_filter");
7413 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7414 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7416 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7417 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7419 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7420 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7421 dst_port, "dst_port");
7422 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7423 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7424 dst_port_value, UINT16);
7425 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7426 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7427 protocol, "protocol");
7428 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7429 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7430 protocol_value, UINT8);
7431 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7432 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7434 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7435 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7437 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7438 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7439 tcp_flags, "tcp_flags");
7440 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7441 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7442 tcp_flags_value, UINT8);
7443 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7444 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7445 priority, "priority");
7446 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7447 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7448 priority_value, UINT8);
7449 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7450 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7452 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7453 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7456 cmdline_parse_inst_t cmd_2tuple_filter = {
7457 .f = cmd_2tuple_filter_parsed,
7459 .help_str = "add a 2tuple filter",
7461 (void *)&cmd_2tuple_filter_filter,
7462 (void *)&cmd_2tuple_filter_port_id,
7463 (void *)&cmd_2tuple_filter_ops,
7464 (void *)&cmd_2tuple_filter_dst_port,
7465 (void *)&cmd_2tuple_filter_dst_port_value,
7466 (void *)&cmd_2tuple_filter_protocol,
7467 (void *)&cmd_2tuple_filter_protocol_value,
7468 (void *)&cmd_2tuple_filter_mask,
7469 (void *)&cmd_2tuple_filter_mask_value,
7470 (void *)&cmd_2tuple_filter_tcp_flags,
7471 (void *)&cmd_2tuple_filter_tcp_flags_value,
7472 (void *)&cmd_2tuple_filter_priority,
7473 (void *)&cmd_2tuple_filter_priority_value,
7474 (void *)&cmd_2tuple_filter_queue,
7475 (void *)&cmd_2tuple_filter_queue_id,
7480 /* *** ADD/REMOVE A 5tuple FILTER *** */
7481 struct cmd_5tuple_filter_result {
7482 cmdline_fixed_string_t filter;
7484 cmdline_fixed_string_t ops;
7485 cmdline_fixed_string_t dst_ip;
7486 cmdline_ipaddr_t dst_ip_value;
7487 cmdline_fixed_string_t src_ip;
7488 cmdline_ipaddr_t src_ip_value;
7489 cmdline_fixed_string_t dst_port;
7490 uint16_t dst_port_value;
7491 cmdline_fixed_string_t src_port;
7492 uint16_t src_port_value;
7493 cmdline_fixed_string_t protocol;
7494 uint8_t protocol_value;
7495 cmdline_fixed_string_t mask;
7497 cmdline_fixed_string_t tcp_flags;
7498 uint8_t tcp_flags_value;
7499 cmdline_fixed_string_t priority;
7500 uint8_t priority_value;
7501 cmdline_fixed_string_t queue;
7506 cmd_5tuple_filter_parsed(void *parsed_result,
7507 __attribute__((unused)) struct cmdline *cl,
7508 __attribute__((unused)) void *data)
7510 struct rte_eth_ntuple_filter filter;
7511 struct cmd_5tuple_filter_result *res = parsed_result;
7514 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7516 printf("ntuple filter is not supported on port %u.\n",
7521 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7523 filter.flags = RTE_5TUPLE_FLAGS;
7524 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7525 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7526 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7527 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7528 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7529 filter.proto = res->protocol_value;
7530 filter.priority = res->priority_value;
7531 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7532 printf("nonzero tcp_flags is only meaningful"
7533 " when protocol is TCP.\n");
7536 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7537 printf("invalid TCP flags.\n");
7541 if (res->tcp_flags_value != 0) {
7542 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7543 filter.tcp_flags = res->tcp_flags_value;
7546 if (res->dst_ip_value.family == AF_INET)
7547 /* no need to convert, already big endian. */
7548 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7550 if (filter.dst_ip_mask == 0) {
7551 printf("can not support ipv6 involved compare.\n");
7557 if (res->src_ip_value.family == AF_INET)
7558 /* no need to convert, already big endian. */
7559 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7561 if (filter.src_ip_mask == 0) {
7562 printf("can not support ipv6 involved compare.\n");
7567 /* need convert to big endian. */
7568 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7569 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7570 filter.queue = res->queue_id;
7572 if (!strcmp(res->ops, "add"))
7573 ret = rte_eth_dev_filter_ctrl(res->port_id,
7574 RTE_ETH_FILTER_NTUPLE,
7578 ret = rte_eth_dev_filter_ctrl(res->port_id,
7579 RTE_ETH_FILTER_NTUPLE,
7580 RTE_ETH_FILTER_DELETE,
7583 printf("5tuple filter programming error: (%s)\n",
7587 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7588 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7589 filter, "5tuple_filter");
7590 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7591 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7593 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7594 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7596 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7597 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7599 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7600 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7602 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7603 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7605 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7606 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7608 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7609 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7610 dst_port, "dst_port");
7611 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7612 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7613 dst_port_value, UINT16);
7614 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7615 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7616 src_port, "src_port");
7617 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7618 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7619 src_port_value, UINT16);
7620 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7621 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7622 protocol, "protocol");
7623 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7624 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7625 protocol_value, UINT8);
7626 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7627 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7629 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7630 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7632 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7633 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7634 tcp_flags, "tcp_flags");
7635 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7636 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7637 tcp_flags_value, UINT8);
7638 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7639 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7640 priority, "priority");
7641 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7642 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7643 priority_value, UINT8);
7644 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7645 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7647 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7648 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7651 cmdline_parse_inst_t cmd_5tuple_filter = {
7652 .f = cmd_5tuple_filter_parsed,
7654 .help_str = "add/del a 5tuple filter",
7656 (void *)&cmd_5tuple_filter_filter,
7657 (void *)&cmd_5tuple_filter_port_id,
7658 (void *)&cmd_5tuple_filter_ops,
7659 (void *)&cmd_5tuple_filter_dst_ip,
7660 (void *)&cmd_5tuple_filter_dst_ip_value,
7661 (void *)&cmd_5tuple_filter_src_ip,
7662 (void *)&cmd_5tuple_filter_src_ip_value,
7663 (void *)&cmd_5tuple_filter_dst_port,
7664 (void *)&cmd_5tuple_filter_dst_port_value,
7665 (void *)&cmd_5tuple_filter_src_port,
7666 (void *)&cmd_5tuple_filter_src_port_value,
7667 (void *)&cmd_5tuple_filter_protocol,
7668 (void *)&cmd_5tuple_filter_protocol_value,
7669 (void *)&cmd_5tuple_filter_mask,
7670 (void *)&cmd_5tuple_filter_mask_value,
7671 (void *)&cmd_5tuple_filter_tcp_flags,
7672 (void *)&cmd_5tuple_filter_tcp_flags_value,
7673 (void *)&cmd_5tuple_filter_priority,
7674 (void *)&cmd_5tuple_filter_priority_value,
7675 (void *)&cmd_5tuple_filter_queue,
7676 (void *)&cmd_5tuple_filter_queue_id,
7681 /* *** ADD/REMOVE A flex FILTER *** */
7682 struct cmd_flex_filter_result {
7683 cmdline_fixed_string_t filter;
7684 cmdline_fixed_string_t ops;
7686 cmdline_fixed_string_t len;
7688 cmdline_fixed_string_t bytes;
7689 cmdline_fixed_string_t bytes_value;
7690 cmdline_fixed_string_t mask;
7691 cmdline_fixed_string_t mask_value;
7692 cmdline_fixed_string_t priority;
7693 uint8_t priority_value;
7694 cmdline_fixed_string_t queue;
7698 static int xdigit2val(unsigned char c)
7703 else if (isupper(c))
7711 cmd_flex_filter_parsed(void *parsed_result,
7712 __attribute__((unused)) struct cmdline *cl,
7713 __attribute__((unused)) void *data)
7716 struct rte_eth_flex_filter filter;
7717 struct cmd_flex_filter_result *res = parsed_result;
7718 char *bytes_ptr, *mask_ptr;
7719 uint16_t len, i, j = 0;
7724 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7725 printf("the len exceed the max length 128\n");
7728 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7729 filter.len = res->len_value;
7730 filter.priority = res->priority_value;
7731 filter.queue = res->queue_id;
7732 bytes_ptr = res->bytes_value;
7733 mask_ptr = res->mask_value;
7735 /* translate bytes string to array. */
7736 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7737 (bytes_ptr[1] == 'X')))
7739 len = strnlen(bytes_ptr, res->len_value * 2);
7740 if (len == 0 || (len % 8 != 0)) {
7741 printf("please check len and bytes input\n");
7744 for (i = 0; i < len; i++) {
7746 if (isxdigit(c) == 0) {
7747 /* invalid characters. */
7748 printf("invalid input\n");
7751 val = xdigit2val(c);
7754 filter.bytes[j] = byte;
7755 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7762 /* translate mask string to uint8_t array. */
7763 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7764 (mask_ptr[1] == 'X')))
7766 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7768 printf("invalid input\n");
7773 for (i = 0; i < len; i++) {
7775 if (isxdigit(c) == 0) {
7776 /* invalid characters. */
7777 printf("invalid input\n");
7780 val = xdigit2val(c);
7783 filter.mask[j] = byte;
7784 printf("mask[%d]:%02x ", j, filter.mask[j]);
7792 if (!strcmp(res->ops, "add"))
7793 ret = rte_eth_dev_filter_ctrl(res->port_id,
7794 RTE_ETH_FILTER_FLEXIBLE,
7798 ret = rte_eth_dev_filter_ctrl(res->port_id,
7799 RTE_ETH_FILTER_FLEXIBLE,
7800 RTE_ETH_FILTER_DELETE,
7804 printf("flex filter setting error: (%s)\n", strerror(-ret));
7807 cmdline_parse_token_string_t cmd_flex_filter_filter =
7808 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7809 filter, "flex_filter");
7810 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7811 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7813 cmdline_parse_token_string_t cmd_flex_filter_ops =
7814 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7816 cmdline_parse_token_string_t cmd_flex_filter_len =
7817 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7819 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7820 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7822 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7823 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7825 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7826 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7828 cmdline_parse_token_string_t cmd_flex_filter_mask =
7829 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7831 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7832 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7834 cmdline_parse_token_string_t cmd_flex_filter_priority =
7835 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7836 priority, "priority");
7837 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7838 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7839 priority_value, UINT8);
7840 cmdline_parse_token_string_t cmd_flex_filter_queue =
7841 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7843 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7844 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7846 cmdline_parse_inst_t cmd_flex_filter = {
7847 .f = cmd_flex_filter_parsed,
7849 .help_str = "add/del a flex filter",
7851 (void *)&cmd_flex_filter_filter,
7852 (void *)&cmd_flex_filter_port_id,
7853 (void *)&cmd_flex_filter_ops,
7854 (void *)&cmd_flex_filter_len,
7855 (void *)&cmd_flex_filter_len_value,
7856 (void *)&cmd_flex_filter_bytes,
7857 (void *)&cmd_flex_filter_bytes_value,
7858 (void *)&cmd_flex_filter_mask,
7859 (void *)&cmd_flex_filter_mask_value,
7860 (void *)&cmd_flex_filter_priority,
7861 (void *)&cmd_flex_filter_priority_value,
7862 (void *)&cmd_flex_filter_queue,
7863 (void *)&cmd_flex_filter_queue_id,
7868 /* *** Filters Control *** */
7870 /* *** deal with ethertype filter *** */
7871 struct cmd_ethertype_filter_result {
7872 cmdline_fixed_string_t filter;
7874 cmdline_fixed_string_t ops;
7875 cmdline_fixed_string_t mac;
7876 struct ether_addr mac_addr;
7877 cmdline_fixed_string_t ethertype;
7878 uint16_t ethertype_value;
7879 cmdline_fixed_string_t drop;
7880 cmdline_fixed_string_t queue;
7884 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7885 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7886 filter, "ethertype_filter");
7887 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7888 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7890 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7891 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7893 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7894 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7895 mac, "mac_addr#mac_ignr");
7896 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7897 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7899 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7900 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7901 ethertype, "ethertype");
7902 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7903 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7904 ethertype_value, UINT16);
7905 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7906 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7908 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7909 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7911 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7912 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7916 cmd_ethertype_filter_parsed(void *parsed_result,
7917 __attribute__((unused)) struct cmdline *cl,
7918 __attribute__((unused)) void *data)
7920 struct cmd_ethertype_filter_result *res = parsed_result;
7921 struct rte_eth_ethertype_filter filter;
7924 ret = rte_eth_dev_filter_supported(res->port_id,
7925 RTE_ETH_FILTER_ETHERTYPE);
7927 printf("ethertype filter is not supported on port %u.\n",
7932 memset(&filter, 0, sizeof(filter));
7933 if (!strcmp(res->mac, "mac_addr")) {
7934 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7935 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7936 sizeof(struct ether_addr));
7938 if (!strcmp(res->drop, "drop"))
7939 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7940 filter.ether_type = res->ethertype_value;
7941 filter.queue = res->queue_id;
7943 if (!strcmp(res->ops, "add"))
7944 ret = rte_eth_dev_filter_ctrl(res->port_id,
7945 RTE_ETH_FILTER_ETHERTYPE,
7949 ret = rte_eth_dev_filter_ctrl(res->port_id,
7950 RTE_ETH_FILTER_ETHERTYPE,
7951 RTE_ETH_FILTER_DELETE,
7954 printf("ethertype filter programming error: (%s)\n",
7958 cmdline_parse_inst_t cmd_ethertype_filter = {
7959 .f = cmd_ethertype_filter_parsed,
7961 .help_str = "add or delete an ethertype filter entry",
7963 (void *)&cmd_ethertype_filter_filter,
7964 (void *)&cmd_ethertype_filter_port_id,
7965 (void *)&cmd_ethertype_filter_ops,
7966 (void *)&cmd_ethertype_filter_mac,
7967 (void *)&cmd_ethertype_filter_mac_addr,
7968 (void *)&cmd_ethertype_filter_ethertype,
7969 (void *)&cmd_ethertype_filter_ethertype_value,
7970 (void *)&cmd_ethertype_filter_drop,
7971 (void *)&cmd_ethertype_filter_queue,
7972 (void *)&cmd_ethertype_filter_queue_id,
7977 /* *** deal with flow director filter *** */
7978 struct cmd_flow_director_result {
7979 cmdline_fixed_string_t flow_director_filter;
7981 cmdline_fixed_string_t mode;
7982 cmdline_fixed_string_t mode_value;
7983 cmdline_fixed_string_t ops;
7984 cmdline_fixed_string_t flow;
7985 cmdline_fixed_string_t flow_type;
7986 cmdline_fixed_string_t ether;
7987 uint16_t ether_type;
7988 cmdline_fixed_string_t src;
7989 cmdline_ipaddr_t ip_src;
7991 cmdline_fixed_string_t dst;
7992 cmdline_ipaddr_t ip_dst;
7994 cmdline_fixed_string_t verify_tag;
7995 uint32_t verify_tag_value;
7996 cmdline_fixed_string_t vlan;
7997 uint16_t vlan_value;
7998 cmdline_fixed_string_t flexbytes;
7999 cmdline_fixed_string_t flexbytes_value;
8000 cmdline_fixed_string_t pf_vf;
8001 cmdline_fixed_string_t drop;
8002 cmdline_fixed_string_t queue;
8004 cmdline_fixed_string_t fd_id;
8005 uint32_t fd_id_value;
8006 cmdline_fixed_string_t mac;
8007 struct ether_addr mac_addr;
8008 cmdline_fixed_string_t tunnel;
8009 cmdline_fixed_string_t tunnel_type;
8010 cmdline_fixed_string_t tunnel_id;
8011 uint32_t tunnel_id_value;
8015 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8018 const char *p, *p0 = q_arg;
8020 unsigned long int_fld;
8021 char *str_fld[max_num];
8026 p = strchr(p0, '(');
8030 p0 = strchr(p, ')');
8035 if (size >= sizeof(s))
8038 snprintf(s, sizeof(s), "%.*s", size, p);
8039 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8040 if (ret < 0 || ret > max_num)
8042 for (i = 0; i < ret; i++) {
8044 int_fld = strtoul(str_fld[i], &end, 0);
8045 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8047 flexbytes[i] = (uint8_t)int_fld;
8053 str2flowtype(char *string)
8056 static const struct {
8059 } flowtype_str[] = {
8060 {"raw", RTE_ETH_FLOW_RAW},
8061 {"ipv4", RTE_ETH_FLOW_IPV4},
8062 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8063 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8064 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8065 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8066 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8067 {"ipv6", RTE_ETH_FLOW_IPV6},
8068 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8069 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8070 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8071 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8072 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8073 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8076 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8077 if (!strcmp(flowtype_str[i].str, string))
8078 return flowtype_str[i].type;
8080 return RTE_ETH_FLOW_UNKNOWN;
8083 static enum rte_eth_fdir_tunnel_type
8084 str2fdir_tunneltype(char *string)
8088 static const struct {
8090 enum rte_eth_fdir_tunnel_type type;
8091 } tunneltype_str[] = {
8092 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8093 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8096 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8097 if (!strcmp(tunneltype_str[i].str, string))
8098 return tunneltype_str[i].type;
8100 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8103 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8105 if ((ip_addr).family == AF_INET) \
8106 (ip) = (ip_addr).addr.ipv4.s_addr; \
8108 printf("invalid parameter.\n"); \
8113 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8115 if ((ip_addr).family == AF_INET6) \
8116 (void)rte_memcpy(&(ip), \
8117 &((ip_addr).addr.ipv6), \
8118 sizeof(struct in6_addr)); \
8120 printf("invalid parameter.\n"); \
8126 cmd_flow_director_filter_parsed(void *parsed_result,
8127 __attribute__((unused)) struct cmdline *cl,
8128 __attribute__((unused)) void *data)
8130 struct cmd_flow_director_result *res = parsed_result;
8131 struct rte_eth_fdir_filter entry;
8132 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8134 unsigned long vf_id;
8137 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8139 printf("flow director is not supported on port %u.\n",
8143 memset(flexbytes, 0, sizeof(flexbytes));
8144 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8146 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8147 if (strcmp(res->mode_value, "MAC-VLAN")) {
8148 printf("Please set mode to MAC-VLAN.\n");
8151 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8152 if (strcmp(res->mode_value, "Tunnel")) {
8153 printf("Please set mode to Tunnel.\n");
8157 if (strcmp(res->mode_value, "IP")) {
8158 printf("Please set mode to IP.\n");
8161 entry.input.flow_type = str2flowtype(res->flow_type);
8164 ret = parse_flexbytes(res->flexbytes_value,
8166 RTE_ETH_FDIR_MAX_FLEXLEN);
8168 printf("error: Cannot parse flexbytes input.\n");
8172 switch (entry.input.flow_type) {
8173 case RTE_ETH_FLOW_FRAG_IPV4:
8174 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8175 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8176 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8177 IPV4_ADDR_TO_UINT(res->ip_dst,
8178 entry.input.flow.ip4_flow.dst_ip);
8179 IPV4_ADDR_TO_UINT(res->ip_src,
8180 entry.input.flow.ip4_flow.src_ip);
8181 /* need convert to big endian. */
8182 entry.input.flow.udp4_flow.dst_port =
8183 rte_cpu_to_be_16(res->port_dst);
8184 entry.input.flow.udp4_flow.src_port =
8185 rte_cpu_to_be_16(res->port_src);
8187 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8188 IPV4_ADDR_TO_UINT(res->ip_dst,
8189 entry.input.flow.sctp4_flow.ip.dst_ip);
8190 IPV4_ADDR_TO_UINT(res->ip_src,
8191 entry.input.flow.sctp4_flow.ip.src_ip);
8192 /* need convert to big endian. */
8193 entry.input.flow.sctp4_flow.dst_port =
8194 rte_cpu_to_be_16(res->port_dst);
8195 entry.input.flow.sctp4_flow.src_port =
8196 rte_cpu_to_be_16(res->port_src);
8197 entry.input.flow.sctp4_flow.verify_tag =
8198 rte_cpu_to_be_32(res->verify_tag_value);
8200 case RTE_ETH_FLOW_FRAG_IPV6:
8201 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8202 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8203 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8204 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8205 entry.input.flow.ipv6_flow.dst_ip);
8206 IPV6_ADDR_TO_ARRAY(res->ip_src,
8207 entry.input.flow.ipv6_flow.src_ip);
8208 /* need convert to big endian. */
8209 entry.input.flow.udp6_flow.dst_port =
8210 rte_cpu_to_be_16(res->port_dst);
8211 entry.input.flow.udp6_flow.src_port =
8212 rte_cpu_to_be_16(res->port_src);
8214 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8215 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8216 entry.input.flow.sctp6_flow.ip.dst_ip);
8217 IPV6_ADDR_TO_ARRAY(res->ip_src,
8218 entry.input.flow.sctp6_flow.ip.src_ip);
8219 /* need convert to big endian. */
8220 entry.input.flow.sctp6_flow.dst_port =
8221 rte_cpu_to_be_16(res->port_dst);
8222 entry.input.flow.sctp6_flow.src_port =
8223 rte_cpu_to_be_16(res->port_src);
8224 entry.input.flow.sctp6_flow.verify_tag =
8225 rte_cpu_to_be_32(res->verify_tag_value);
8227 case RTE_ETH_FLOW_L2_PAYLOAD:
8228 entry.input.flow.l2_flow.ether_type =
8229 rte_cpu_to_be_16(res->ether_type);
8235 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8236 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8238 sizeof(struct ether_addr));
8240 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8241 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8243 sizeof(struct ether_addr));
8244 entry.input.flow.tunnel_flow.tunnel_type =
8245 str2fdir_tunneltype(res->tunnel_type);
8246 entry.input.flow.tunnel_flow.tunnel_id =
8247 rte_cpu_to_be_32(res->tunnel_id_value);
8250 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8252 RTE_ETH_FDIR_MAX_FLEXLEN);
8254 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8256 entry.action.flex_off = 0; /*use 0 by default */
8257 if (!strcmp(res->drop, "drop"))
8258 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8260 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8262 if (!strcmp(res->pf_vf, "pf"))
8263 entry.input.flow_ext.is_vf = 0;
8264 else if (!strncmp(res->pf_vf, "vf", 2)) {
8265 struct rte_eth_dev_info dev_info;
8267 memset(&dev_info, 0, sizeof(dev_info));
8268 rte_eth_dev_info_get(res->port_id, &dev_info);
8270 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8271 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8272 printf("invalid parameter %s.\n", res->pf_vf);
8275 entry.input.flow_ext.is_vf = 1;
8276 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8278 printf("invalid parameter %s.\n", res->pf_vf);
8282 /* set to report FD ID by default */
8283 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8284 entry.action.rx_queue = res->queue_id;
8285 entry.soft_id = res->fd_id_value;
8286 if (!strcmp(res->ops, "add"))
8287 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8288 RTE_ETH_FILTER_ADD, &entry);
8289 else if (!strcmp(res->ops, "del"))
8290 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8291 RTE_ETH_FILTER_DELETE, &entry);
8293 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8294 RTE_ETH_FILTER_UPDATE, &entry);
8296 printf("flow director programming error: (%s)\n",
8300 cmdline_parse_token_string_t cmd_flow_director_filter =
8301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8302 flow_director_filter, "flow_director_filter");
8303 cmdline_parse_token_num_t cmd_flow_director_port_id =
8304 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8306 cmdline_parse_token_string_t cmd_flow_director_ops =
8307 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8308 ops, "add#del#update");
8309 cmdline_parse_token_string_t cmd_flow_director_flow =
8310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8312 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8313 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8314 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8315 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8316 cmdline_parse_token_string_t cmd_flow_director_ether =
8317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8319 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8320 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8321 ether_type, UINT16);
8322 cmdline_parse_token_string_t cmd_flow_director_src =
8323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8325 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8326 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8328 cmdline_parse_token_num_t cmd_flow_director_port_src =
8329 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8331 cmdline_parse_token_string_t cmd_flow_director_dst =
8332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8334 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8335 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8337 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8338 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8340 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8342 verify_tag, "verify_tag");
8343 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8344 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8345 verify_tag_value, UINT32);
8346 cmdline_parse_token_string_t cmd_flow_director_vlan =
8347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8349 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8350 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8351 vlan_value, UINT16);
8352 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8354 flexbytes, "flexbytes");
8355 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8357 flexbytes_value, NULL);
8358 cmdline_parse_token_string_t cmd_flow_director_drop =
8359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8361 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8364 cmdline_parse_token_string_t cmd_flow_director_queue =
8365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8367 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8368 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8370 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8373 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8374 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8375 fd_id_value, UINT32);
8377 cmdline_parse_token_string_t cmd_flow_director_mode =
8378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8380 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8383 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8385 mode_value, "MAC-VLAN");
8386 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8388 mode_value, "Tunnel");
8389 cmdline_parse_token_string_t cmd_flow_director_mac =
8390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8392 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8393 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8395 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8398 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8400 tunnel_type, "NVGRE#VxLAN");
8401 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8403 tunnel_id, "tunnel-id");
8404 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8405 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8406 tunnel_id_value, UINT32);
8408 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8409 .f = cmd_flow_director_filter_parsed,
8411 .help_str = "add or delete an ip flow director entry on NIC",
8413 (void *)&cmd_flow_director_filter,
8414 (void *)&cmd_flow_director_port_id,
8415 (void *)&cmd_flow_director_mode,
8416 (void *)&cmd_flow_director_mode_ip,
8417 (void *)&cmd_flow_director_ops,
8418 (void *)&cmd_flow_director_flow,
8419 (void *)&cmd_flow_director_flow_type,
8420 (void *)&cmd_flow_director_src,
8421 (void *)&cmd_flow_director_ip_src,
8422 (void *)&cmd_flow_director_dst,
8423 (void *)&cmd_flow_director_ip_dst,
8424 (void *)&cmd_flow_director_vlan,
8425 (void *)&cmd_flow_director_vlan_value,
8426 (void *)&cmd_flow_director_flexbytes,
8427 (void *)&cmd_flow_director_flexbytes_value,
8428 (void *)&cmd_flow_director_drop,
8429 (void *)&cmd_flow_director_pf_vf,
8430 (void *)&cmd_flow_director_queue,
8431 (void *)&cmd_flow_director_queue_id,
8432 (void *)&cmd_flow_director_fd_id,
8433 (void *)&cmd_flow_director_fd_id_value,
8438 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8439 .f = cmd_flow_director_filter_parsed,
8441 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8443 (void *)&cmd_flow_director_filter,
8444 (void *)&cmd_flow_director_port_id,
8445 (void *)&cmd_flow_director_mode,
8446 (void *)&cmd_flow_director_mode_ip,
8447 (void *)&cmd_flow_director_ops,
8448 (void *)&cmd_flow_director_flow,
8449 (void *)&cmd_flow_director_flow_type,
8450 (void *)&cmd_flow_director_src,
8451 (void *)&cmd_flow_director_ip_src,
8452 (void *)&cmd_flow_director_port_src,
8453 (void *)&cmd_flow_director_dst,
8454 (void *)&cmd_flow_director_ip_dst,
8455 (void *)&cmd_flow_director_port_dst,
8456 (void *)&cmd_flow_director_vlan,
8457 (void *)&cmd_flow_director_vlan_value,
8458 (void *)&cmd_flow_director_flexbytes,
8459 (void *)&cmd_flow_director_flexbytes_value,
8460 (void *)&cmd_flow_director_drop,
8461 (void *)&cmd_flow_director_pf_vf,
8462 (void *)&cmd_flow_director_queue,
8463 (void *)&cmd_flow_director_queue_id,
8464 (void *)&cmd_flow_director_fd_id,
8465 (void *)&cmd_flow_director_fd_id_value,
8470 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8471 .f = cmd_flow_director_filter_parsed,
8473 .help_str = "add or delete a sctp flow director entry on NIC",
8475 (void *)&cmd_flow_director_filter,
8476 (void *)&cmd_flow_director_port_id,
8477 (void *)&cmd_flow_director_mode,
8478 (void *)&cmd_flow_director_mode_ip,
8479 (void *)&cmd_flow_director_ops,
8480 (void *)&cmd_flow_director_flow,
8481 (void *)&cmd_flow_director_flow_type,
8482 (void *)&cmd_flow_director_src,
8483 (void *)&cmd_flow_director_ip_src,
8484 (void *)&cmd_flow_director_port_dst,
8485 (void *)&cmd_flow_director_dst,
8486 (void *)&cmd_flow_director_ip_dst,
8487 (void *)&cmd_flow_director_port_dst,
8488 (void *)&cmd_flow_director_verify_tag,
8489 (void *)&cmd_flow_director_verify_tag_value,
8490 (void *)&cmd_flow_director_vlan,
8491 (void *)&cmd_flow_director_vlan_value,
8492 (void *)&cmd_flow_director_flexbytes,
8493 (void *)&cmd_flow_director_flexbytes_value,
8494 (void *)&cmd_flow_director_drop,
8495 (void *)&cmd_flow_director_pf_vf,
8496 (void *)&cmd_flow_director_queue,
8497 (void *)&cmd_flow_director_queue_id,
8498 (void *)&cmd_flow_director_fd_id,
8499 (void *)&cmd_flow_director_fd_id_value,
8504 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8505 .f = cmd_flow_director_filter_parsed,
8507 .help_str = "add or delete a L2 flow director entry on NIC",
8509 (void *)&cmd_flow_director_filter,
8510 (void *)&cmd_flow_director_port_id,
8511 (void *)&cmd_flow_director_mode,
8512 (void *)&cmd_flow_director_mode_ip,
8513 (void *)&cmd_flow_director_ops,
8514 (void *)&cmd_flow_director_flow,
8515 (void *)&cmd_flow_director_flow_type,
8516 (void *)&cmd_flow_director_ether,
8517 (void *)&cmd_flow_director_ether_type,
8518 (void *)&cmd_flow_director_flexbytes,
8519 (void *)&cmd_flow_director_flexbytes_value,
8520 (void *)&cmd_flow_director_drop,
8521 (void *)&cmd_flow_director_pf_vf,
8522 (void *)&cmd_flow_director_queue,
8523 (void *)&cmd_flow_director_queue_id,
8524 (void *)&cmd_flow_director_fd_id,
8525 (void *)&cmd_flow_director_fd_id_value,
8530 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8531 .f = cmd_flow_director_filter_parsed,
8533 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8535 (void *)&cmd_flow_director_filter,
8536 (void *)&cmd_flow_director_port_id,
8537 (void *)&cmd_flow_director_mode,
8538 (void *)&cmd_flow_director_mode_mac_vlan,
8539 (void *)&cmd_flow_director_ops,
8540 (void *)&cmd_flow_director_mac,
8541 (void *)&cmd_flow_director_mac_addr,
8542 (void *)&cmd_flow_director_vlan,
8543 (void *)&cmd_flow_director_vlan_value,
8544 (void *)&cmd_flow_director_flexbytes,
8545 (void *)&cmd_flow_director_flexbytes_value,
8546 (void *)&cmd_flow_director_drop,
8547 (void *)&cmd_flow_director_queue,
8548 (void *)&cmd_flow_director_queue_id,
8549 (void *)&cmd_flow_director_fd_id,
8550 (void *)&cmd_flow_director_fd_id_value,
8555 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8556 .f = cmd_flow_director_filter_parsed,
8558 .help_str = "add or delete a tunnel flow director entry on NIC",
8560 (void *)&cmd_flow_director_filter,
8561 (void *)&cmd_flow_director_port_id,
8562 (void *)&cmd_flow_director_mode,
8563 (void *)&cmd_flow_director_mode_tunnel,
8564 (void *)&cmd_flow_director_ops,
8565 (void *)&cmd_flow_director_mac,
8566 (void *)&cmd_flow_director_mac_addr,
8567 (void *)&cmd_flow_director_vlan,
8568 (void *)&cmd_flow_director_vlan_value,
8569 (void *)&cmd_flow_director_tunnel,
8570 (void *)&cmd_flow_director_tunnel_type,
8571 (void *)&cmd_flow_director_tunnel_id,
8572 (void *)&cmd_flow_director_tunnel_id_value,
8573 (void *)&cmd_flow_director_flexbytes,
8574 (void *)&cmd_flow_director_flexbytes_value,
8575 (void *)&cmd_flow_director_drop,
8576 (void *)&cmd_flow_director_queue,
8577 (void *)&cmd_flow_director_queue_id,
8578 (void *)&cmd_flow_director_fd_id,
8579 (void *)&cmd_flow_director_fd_id_value,
8584 struct cmd_flush_flow_director_result {
8585 cmdline_fixed_string_t flush_flow_director;
8589 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8590 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8591 flush_flow_director, "flush_flow_director");
8592 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8593 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8597 cmd_flush_flow_director_parsed(void *parsed_result,
8598 __attribute__((unused)) struct cmdline *cl,
8599 __attribute__((unused)) void *data)
8601 struct cmd_flow_director_result *res = parsed_result;
8604 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8606 printf("flow director is not supported on port %u.\n",
8611 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8612 RTE_ETH_FILTER_FLUSH, NULL);
8614 printf("flow director table flushing error: (%s)\n",
8618 cmdline_parse_inst_t cmd_flush_flow_director = {
8619 .f = cmd_flush_flow_director_parsed,
8621 .help_str = "flush all flow director entries of a device on NIC",
8623 (void *)&cmd_flush_flow_director_flush,
8624 (void *)&cmd_flush_flow_director_port_id,
8629 /* *** deal with flow director mask *** */
8630 struct cmd_flow_director_mask_result {
8631 cmdline_fixed_string_t flow_director_mask;
8633 cmdline_fixed_string_t mode;
8634 cmdline_fixed_string_t mode_value;
8635 cmdline_fixed_string_t vlan;
8637 cmdline_fixed_string_t src_mask;
8638 cmdline_ipaddr_t ipv4_src;
8639 cmdline_ipaddr_t ipv6_src;
8641 cmdline_fixed_string_t dst_mask;
8642 cmdline_ipaddr_t ipv4_dst;
8643 cmdline_ipaddr_t ipv6_dst;
8645 cmdline_fixed_string_t mac;
8646 uint8_t mac_addr_byte_mask;
8647 cmdline_fixed_string_t tunnel_id;
8648 uint32_t tunnel_id_mask;
8649 cmdline_fixed_string_t tunnel_type;
8650 uint8_t tunnel_type_mask;
8654 cmd_flow_director_mask_parsed(void *parsed_result,
8655 __attribute__((unused)) struct cmdline *cl,
8656 __attribute__((unused)) void *data)
8658 struct cmd_flow_director_mask_result *res = parsed_result;
8659 struct rte_eth_fdir_masks *mask;
8660 struct rte_port *port;
8662 if (res->port_id > nb_ports) {
8663 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8667 port = &ports[res->port_id];
8668 /** Check if the port is not started **/
8669 if (port->port_status != RTE_PORT_STOPPED) {
8670 printf("Please stop port %d first\n", res->port_id);
8674 mask = &port->dev_conf.fdir_conf.mask;
8676 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8677 if (strcmp(res->mode_value, "MAC-VLAN")) {
8678 printf("Please set mode to MAC-VLAN.\n");
8682 mask->vlan_tci_mask = res->vlan_mask;
8683 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8684 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8685 if (strcmp(res->mode_value, "Tunnel")) {
8686 printf("Please set mode to Tunnel.\n");
8690 mask->vlan_tci_mask = res->vlan_mask;
8691 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8692 mask->tunnel_id_mask = res->tunnel_id_mask;
8693 mask->tunnel_type_mask = res->tunnel_type_mask;
8695 if (strcmp(res->mode_value, "IP")) {
8696 printf("Please set mode to IP.\n");
8700 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8701 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8702 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8703 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8704 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8705 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8706 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8709 cmd_reconfig_device_queue(res->port_id, 1, 1);
8712 cmdline_parse_token_string_t cmd_flow_director_mask =
8713 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8714 flow_director_mask, "flow_director_mask");
8715 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8716 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8718 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8719 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8721 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8722 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8724 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8725 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8726 src_mask, "src_mask");
8727 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8728 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8730 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8731 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8733 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8734 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8736 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8737 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8738 dst_mask, "dst_mask");
8739 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8740 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8742 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8743 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8745 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8746 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8749 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8750 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8752 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8753 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8755 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8756 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8757 mode_value, "MAC-VLAN");
8758 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8759 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8760 mode_value, "Tunnel");
8761 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8762 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8764 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8765 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8766 mac_addr_byte_mask, UINT8);
8767 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8768 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8769 tunnel_type, "tunnel-type");
8770 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8771 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8772 tunnel_type_mask, UINT8);
8773 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8775 tunnel_id, "tunnel-id");
8776 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8777 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8778 tunnel_id_mask, UINT32);
8780 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8781 .f = cmd_flow_director_mask_parsed,
8783 .help_str = "set IP mode flow director's mask on NIC",
8785 (void *)&cmd_flow_director_mask,
8786 (void *)&cmd_flow_director_mask_port_id,
8787 (void *)&cmd_flow_director_mask_mode,
8788 (void *)&cmd_flow_director_mask_mode_ip,
8789 (void *)&cmd_flow_director_mask_vlan,
8790 (void *)&cmd_flow_director_mask_vlan_value,
8791 (void *)&cmd_flow_director_mask_src,
8792 (void *)&cmd_flow_director_mask_ipv4_src,
8793 (void *)&cmd_flow_director_mask_ipv6_src,
8794 (void *)&cmd_flow_director_mask_port_src,
8795 (void *)&cmd_flow_director_mask_dst,
8796 (void *)&cmd_flow_director_mask_ipv4_dst,
8797 (void *)&cmd_flow_director_mask_ipv6_dst,
8798 (void *)&cmd_flow_director_mask_port_dst,
8803 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8804 .f = cmd_flow_director_mask_parsed,
8806 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8808 (void *)&cmd_flow_director_mask,
8809 (void *)&cmd_flow_director_mask_port_id,
8810 (void *)&cmd_flow_director_mask_mode,
8811 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8812 (void *)&cmd_flow_director_mask_vlan,
8813 (void *)&cmd_flow_director_mask_vlan_value,
8814 (void *)&cmd_flow_director_mask_mac,
8815 (void *)&cmd_flow_director_mask_mac_value,
8820 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8821 .f = cmd_flow_director_mask_parsed,
8823 .help_str = "set tunnel mode flow director's mask on NIC",
8825 (void *)&cmd_flow_director_mask,
8826 (void *)&cmd_flow_director_mask_port_id,
8827 (void *)&cmd_flow_director_mask_mode,
8828 (void *)&cmd_flow_director_mask_mode_tunnel,
8829 (void *)&cmd_flow_director_mask_vlan,
8830 (void *)&cmd_flow_director_mask_vlan_value,
8831 (void *)&cmd_flow_director_mask_mac,
8832 (void *)&cmd_flow_director_mask_mac_value,
8833 (void *)&cmd_flow_director_mask_tunnel_type,
8834 (void *)&cmd_flow_director_mask_tunnel_type_value,
8835 (void *)&cmd_flow_director_mask_tunnel_id,
8836 (void *)&cmd_flow_director_mask_tunnel_id_value,
8841 /* *** deal with flow director mask on flexible payload *** */
8842 struct cmd_flow_director_flex_mask_result {
8843 cmdline_fixed_string_t flow_director_flexmask;
8845 cmdline_fixed_string_t flow;
8846 cmdline_fixed_string_t flow_type;
8847 cmdline_fixed_string_t mask;
8851 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8852 __attribute__((unused)) struct cmdline *cl,
8853 __attribute__((unused)) void *data)
8855 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8856 struct rte_eth_fdir_info fdir_info;
8857 struct rte_eth_fdir_flex_mask flex_mask;
8858 struct rte_port *port;
8859 uint32_t flow_type_mask;
8863 if (res->port_id > nb_ports) {
8864 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8868 port = &ports[res->port_id];
8869 /** Check if the port is not started **/
8870 if (port->port_status != RTE_PORT_STOPPED) {
8871 printf("Please stop port %d first\n", res->port_id);
8875 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8876 ret = parse_flexbytes(res->mask,
8878 RTE_ETH_FDIR_MAX_FLEXLEN);
8880 printf("error: Cannot parse mask input.\n");
8884 memset(&fdir_info, 0, sizeof(fdir_info));
8885 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8886 RTE_ETH_FILTER_INFO, &fdir_info);
8888 printf("Cannot get FDir filter info\n");
8892 if (!strcmp(res->flow_type, "none")) {
8893 /* means don't specify the flow type */
8894 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8895 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8896 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8897 0, sizeof(struct rte_eth_fdir_flex_mask));
8898 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8899 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8901 sizeof(struct rte_eth_fdir_flex_mask));
8902 cmd_reconfig_device_queue(res->port_id, 1, 1);
8905 flow_type_mask = fdir_info.flow_types_mask[0];
8906 if (!strcmp(res->flow_type, "all")) {
8907 if (!flow_type_mask) {
8908 printf("No flow type supported\n");
8911 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8912 if (flow_type_mask & (1 << i)) {
8913 flex_mask.flow_type = i;
8914 fdir_set_flex_mask(res->port_id, &flex_mask);
8917 cmd_reconfig_device_queue(res->port_id, 1, 1);
8920 flex_mask.flow_type = str2flowtype(res->flow_type);
8921 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8922 printf("Flow type %s not supported on port %d\n",
8923 res->flow_type, res->port_id);
8926 fdir_set_flex_mask(res->port_id, &flex_mask);
8927 cmd_reconfig_device_queue(res->port_id, 1, 1);
8930 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8932 flow_director_flexmask,
8933 "flow_director_flex_mask");
8934 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8935 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8937 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8938 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8940 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8942 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8943 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8944 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8945 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8948 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8949 .f = cmd_flow_director_flex_mask_parsed,
8951 .help_str = "set flow director's flex mask on NIC",
8953 (void *)&cmd_flow_director_flexmask,
8954 (void *)&cmd_flow_director_flexmask_port_id,
8955 (void *)&cmd_flow_director_flexmask_flow,
8956 (void *)&cmd_flow_director_flexmask_flow_type,
8957 (void *)&cmd_flow_director_flexmask_mask,
8962 /* *** deal with flow director flexible payload configuration *** */
8963 struct cmd_flow_director_flexpayload_result {
8964 cmdline_fixed_string_t flow_director_flexpayload;
8966 cmdline_fixed_string_t payload_layer;
8967 cmdline_fixed_string_t payload_cfg;
8971 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8974 const char *p, *p0 = q_arg;
8976 unsigned long int_fld;
8977 char *str_fld[max_num];
8982 p = strchr(p0, '(');
8986 p0 = strchr(p, ')');
8991 if (size >= sizeof(s))
8994 snprintf(s, sizeof(s), "%.*s", size, p);
8995 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8996 if (ret < 0 || ret > max_num)
8998 for (i = 0; i < ret; i++) {
9000 int_fld = strtoul(str_fld[i], &end, 0);
9001 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9003 offsets[i] = (uint16_t)int_fld;
9009 cmd_flow_director_flxpld_parsed(void *parsed_result,
9010 __attribute__((unused)) struct cmdline *cl,
9011 __attribute__((unused)) void *data)
9013 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9014 struct rte_eth_flex_payload_cfg flex_cfg;
9015 struct rte_port *port;
9018 if (res->port_id > nb_ports) {
9019 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9023 port = &ports[res->port_id];
9024 /** Check if the port is not started **/
9025 if (port->port_status != RTE_PORT_STOPPED) {
9026 printf("Please stop port %d first\n", res->port_id);
9030 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9032 if (!strcmp(res->payload_layer, "raw"))
9033 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9034 else if (!strcmp(res->payload_layer, "l2"))
9035 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9036 else if (!strcmp(res->payload_layer, "l3"))
9037 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9038 else if (!strcmp(res->payload_layer, "l4"))
9039 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9041 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9042 RTE_ETH_FDIR_MAX_FLEXLEN);
9044 printf("error: Cannot parse flex payload input.\n");
9048 fdir_set_flex_payload(res->port_id, &flex_cfg);
9049 cmd_reconfig_device_queue(res->port_id, 1, 1);
9052 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9053 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9054 flow_director_flexpayload,
9055 "flow_director_flex_payload");
9056 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9057 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9059 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9060 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9061 payload_layer, "raw#l2#l3#l4");
9062 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9063 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9066 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9067 .f = cmd_flow_director_flxpld_parsed,
9069 .help_str = "set flow director's flex payload on NIC",
9071 (void *)&cmd_flow_director_flexpayload,
9072 (void *)&cmd_flow_director_flexpayload_port_id,
9073 (void *)&cmd_flow_director_flexpayload_payload_layer,
9074 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9079 /* *** Classification Filters Control *** */
9080 /* *** Get symmetric hash enable per port *** */
9081 struct cmd_get_sym_hash_ena_per_port_result {
9082 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9087 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9088 __rte_unused struct cmdline *cl,
9089 __rte_unused void *data)
9091 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9092 struct rte_eth_hash_filter_info info;
9095 if (rte_eth_dev_filter_supported(res->port_id,
9096 RTE_ETH_FILTER_HASH) < 0) {
9097 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9102 memset(&info, 0, sizeof(info));
9103 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9104 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9105 RTE_ETH_FILTER_GET, &info);
9108 printf("Cannot get symmetric hash enable per port "
9109 "on port %u\n", res->port_id);
9113 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9114 "enabled" : "disabled", res->port_id);
9117 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9118 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9119 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9120 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9121 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9124 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9125 .f = cmd_get_sym_hash_per_port_parsed,
9127 .help_str = "get_sym_hash_ena_per_port port_id",
9129 (void *)&cmd_get_sym_hash_ena_per_port_all,
9130 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9135 /* *** Set symmetric hash enable per port *** */
9136 struct cmd_set_sym_hash_ena_per_port_result {
9137 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9138 cmdline_fixed_string_t enable;
9143 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9144 __rte_unused struct cmdline *cl,
9145 __rte_unused void *data)
9147 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9148 struct rte_eth_hash_filter_info info;
9151 if (rte_eth_dev_filter_supported(res->port_id,
9152 RTE_ETH_FILTER_HASH) < 0) {
9153 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9158 memset(&info, 0, sizeof(info));
9159 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9160 if (!strcmp(res->enable, "enable"))
9161 info.info.enable = 1;
9162 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9163 RTE_ETH_FILTER_SET, &info);
9165 printf("Cannot set symmetric hash enable per port on "
9166 "port %u\n", res->port_id);
9169 printf("Symmetric hash has been set to %s on port %u\n",
9170 res->enable, res->port_id);
9173 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9174 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9175 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9176 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9177 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9179 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9180 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9181 enable, "enable#disable");
9183 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9184 .f = cmd_set_sym_hash_per_port_parsed,
9186 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9188 (void *)&cmd_set_sym_hash_ena_per_port_all,
9189 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9190 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9195 /* Get global config of hash function */
9196 struct cmd_get_hash_global_config_result {
9197 cmdline_fixed_string_t get_hash_global_config;
9202 flowtype_to_str(uint16_t ftype)
9209 {"ipv4", RTE_ETH_FLOW_IPV4},
9210 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9211 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9212 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9213 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9214 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9215 {"ipv6", RTE_ETH_FLOW_IPV6},
9216 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9217 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9218 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9219 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9220 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9221 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9224 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9225 if (ftype_table[i].ftype == ftype)
9226 return ftype_table[i].str;
9233 cmd_get_hash_global_config_parsed(void *parsed_result,
9234 __rte_unused struct cmdline *cl,
9235 __rte_unused void *data)
9237 struct cmd_get_hash_global_config_result *res = parsed_result;
9238 struct rte_eth_hash_filter_info info;
9239 uint32_t idx, offset;
9244 if (rte_eth_dev_filter_supported(res->port_id,
9245 RTE_ETH_FILTER_HASH) < 0) {
9246 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9251 memset(&info, 0, sizeof(info));
9252 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9253 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9254 RTE_ETH_FILTER_GET, &info);
9256 printf("Cannot get hash global configurations by port %d\n",
9261 switch (info.info.global_conf.hash_func) {
9262 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9263 printf("Hash function is Toeplitz\n");
9265 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9266 printf("Hash function is Simple XOR\n");
9269 printf("Unknown hash function\n");
9273 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9274 idx = i / UINT32_BIT;
9275 offset = i % UINT32_BIT;
9276 if (!(info.info.global_conf.valid_bit_mask[idx] &
9279 str = flowtype_to_str(i);
9282 printf("Symmetric hash is %s globally for flow type %s "
9284 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9285 (1UL << offset)) ? "enabled" : "disabled"), str,
9290 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9291 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9292 get_hash_global_config, "get_hash_global_config");
9293 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9294 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9297 cmdline_parse_inst_t cmd_get_hash_global_config = {
9298 .f = cmd_get_hash_global_config_parsed,
9300 .help_str = "get_hash_global_config port_id",
9302 (void *)&cmd_get_hash_global_config_all,
9303 (void *)&cmd_get_hash_global_config_port_id,
9308 /* Set global config of hash function */
9309 struct cmd_set_hash_global_config_result {
9310 cmdline_fixed_string_t set_hash_global_config;
9312 cmdline_fixed_string_t hash_func;
9313 cmdline_fixed_string_t flow_type;
9314 cmdline_fixed_string_t enable;
9318 cmd_set_hash_global_config_parsed(void *parsed_result,
9319 __rte_unused struct cmdline *cl,
9320 __rte_unused void *data)
9322 struct cmd_set_hash_global_config_result *res = parsed_result;
9323 struct rte_eth_hash_filter_info info;
9324 uint32_t ftype, idx, offset;
9327 if (rte_eth_dev_filter_supported(res->port_id,
9328 RTE_ETH_FILTER_HASH) < 0) {
9329 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9333 memset(&info, 0, sizeof(info));
9334 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9335 if (!strcmp(res->hash_func, "toeplitz"))
9336 info.info.global_conf.hash_func =
9337 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9338 else if (!strcmp(res->hash_func, "simple_xor"))
9339 info.info.global_conf.hash_func =
9340 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9341 else if (!strcmp(res->hash_func, "default"))
9342 info.info.global_conf.hash_func =
9343 RTE_ETH_HASH_FUNCTION_DEFAULT;
9345 ftype = str2flowtype(res->flow_type);
9346 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9347 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9348 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9349 if (!strcmp(res->enable, "enable"))
9350 info.info.global_conf.sym_hash_enable_mask[idx] |=
9352 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9353 RTE_ETH_FILTER_SET, &info);
9355 printf("Cannot set global hash configurations by port %d\n",
9358 printf("Global hash configurations have been set "
9359 "succcessfully by port %d\n", res->port_id);
9362 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9363 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9364 set_hash_global_config, "set_hash_global_config");
9365 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9366 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9368 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9369 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9370 hash_func, "toeplitz#simple_xor#default");
9371 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9372 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9374 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9375 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9376 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9377 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9378 enable, "enable#disable");
9380 cmdline_parse_inst_t cmd_set_hash_global_config = {
9381 .f = cmd_set_hash_global_config_parsed,
9383 .help_str = "set_hash_global_config port_id "
9384 "toeplitz|simple_xor|default "
9385 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9386 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9389 (void *)&cmd_set_hash_global_config_all,
9390 (void *)&cmd_set_hash_global_config_port_id,
9391 (void *)&cmd_set_hash_global_config_hash_func,
9392 (void *)&cmd_set_hash_global_config_flow_type,
9393 (void *)&cmd_set_hash_global_config_enable,
9398 /* Set hash input set */
9399 struct cmd_set_hash_input_set_result {
9400 cmdline_fixed_string_t set_hash_input_set;
9402 cmdline_fixed_string_t flow_type;
9403 cmdline_fixed_string_t inset_field;
9404 cmdline_fixed_string_t select;
9407 static enum rte_eth_input_set_field
9408 str2inset(char *string)
9412 static const struct {
9414 enum rte_eth_input_set_field inset;
9416 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9417 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9418 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9419 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9420 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9421 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9422 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9423 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9424 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9425 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9426 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9427 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9428 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9429 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9430 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9431 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9432 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9433 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9434 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9435 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9436 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9437 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9438 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9439 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9440 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9441 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9442 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9443 {"none", RTE_ETH_INPUT_SET_NONE},
9446 for (i = 0; i < RTE_DIM(inset_table); i++) {
9447 if (!strcmp(string, inset_table[i].str))
9448 return inset_table[i].inset;
9451 return RTE_ETH_INPUT_SET_UNKNOWN;
9455 cmd_set_hash_input_set_parsed(void *parsed_result,
9456 __rte_unused struct cmdline *cl,
9457 __rte_unused void *data)
9459 struct cmd_set_hash_input_set_result *res = parsed_result;
9460 struct rte_eth_hash_filter_info info;
9462 memset(&info, 0, sizeof(info));
9463 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9464 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9465 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9466 info.info.input_set_conf.inset_size = 1;
9467 if (!strcmp(res->select, "select"))
9468 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9469 else if (!strcmp(res->select, "add"))
9470 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9471 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9472 RTE_ETH_FILTER_SET, &info);
9475 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9476 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9477 set_hash_input_set, "set_hash_input_set");
9478 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9479 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9481 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9482 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9484 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9485 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9486 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9487 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9489 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9490 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9491 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9492 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9493 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9495 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9496 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9497 select, "select#add");
9499 cmdline_parse_inst_t cmd_set_hash_input_set = {
9500 .f = cmd_set_hash_input_set_parsed,
9502 .help_str = "set_hash_input_set <port_id> "
9503 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9504 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9505 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9506 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9507 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9508 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9509 "fld-7th|fld-8th|none select|add",
9511 (void *)&cmd_set_hash_input_set_cmd,
9512 (void *)&cmd_set_hash_input_set_port_id,
9513 (void *)&cmd_set_hash_input_set_flow_type,
9514 (void *)&cmd_set_hash_input_set_field,
9515 (void *)&cmd_set_hash_input_set_select,
9520 /* Set flow director input set */
9521 struct cmd_set_fdir_input_set_result {
9522 cmdline_fixed_string_t set_fdir_input_set;
9524 cmdline_fixed_string_t flow_type;
9525 cmdline_fixed_string_t inset_field;
9526 cmdline_fixed_string_t select;
9530 cmd_set_fdir_input_set_parsed(void *parsed_result,
9531 __rte_unused struct cmdline *cl,
9532 __rte_unused void *data)
9534 struct cmd_set_fdir_input_set_result *res = parsed_result;
9535 struct rte_eth_fdir_filter_info info;
9537 memset(&info, 0, sizeof(info));
9538 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9539 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9540 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9541 info.info.input_set_conf.inset_size = 1;
9542 if (!strcmp(res->select, "select"))
9543 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9544 else if (!strcmp(res->select, "add"))
9545 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9546 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9547 RTE_ETH_FILTER_SET, &info);
9550 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9551 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9552 set_fdir_input_set, "set_fdir_input_set");
9553 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9554 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9556 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9557 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9559 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9560 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9561 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9562 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9564 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9565 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9566 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9567 "fld-7th#fld-8th#none");
9568 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9569 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9570 select, "select#add");
9572 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9573 .f = cmd_set_fdir_input_set_parsed,
9575 .help_str = "set_fdir_input_set <port_id> "
9576 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9577 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9578 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9579 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9580 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9581 "fld-7th|fld-8th|none select|add",
9583 (void *)&cmd_set_fdir_input_set_cmd,
9584 (void *)&cmd_set_fdir_input_set_port_id,
9585 (void *)&cmd_set_fdir_input_set_flow_type,
9586 (void *)&cmd_set_fdir_input_set_field,
9587 (void *)&cmd_set_fdir_input_set_select,
9592 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9593 struct cmd_mcast_addr_result {
9594 cmdline_fixed_string_t mcast_addr_cmd;
9595 cmdline_fixed_string_t what;
9597 struct ether_addr mc_addr;
9600 static void cmd_mcast_addr_parsed(void *parsed_result,
9601 __attribute__((unused)) struct cmdline *cl,
9602 __attribute__((unused)) void *data)
9604 struct cmd_mcast_addr_result *res = parsed_result;
9606 if (!is_multicast_ether_addr(&res->mc_addr)) {
9607 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9608 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9609 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9610 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9613 if (strcmp(res->what, "add") == 0)
9614 mcast_addr_add(res->port_num, &res->mc_addr);
9616 mcast_addr_remove(res->port_num, &res->mc_addr);
9619 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9620 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9621 mcast_addr_cmd, "mcast_addr");
9622 cmdline_parse_token_string_t cmd_mcast_addr_what =
9623 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9625 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9626 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9627 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9628 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9630 cmdline_parse_inst_t cmd_mcast_addr = {
9631 .f = cmd_mcast_addr_parsed,
9633 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9635 (void *)&cmd_mcast_addr_cmd,
9636 (void *)&cmd_mcast_addr_what,
9637 (void *)&cmd_mcast_addr_portnum,
9638 (void *)&cmd_mcast_addr_addr,
9644 * only support E-tag now.
9647 /* Ether type config */
9648 struct cmd_config_l2_tunnel_eth_type_result {
9649 cmdline_fixed_string_t port;
9650 cmdline_fixed_string_t config;
9651 cmdline_fixed_string_t all;
9653 cmdline_fixed_string_t l2_tunnel;
9654 cmdline_fixed_string_t l2_tunnel_type;
9655 cmdline_fixed_string_t eth_type;
9656 uint16_t eth_type_val;
9659 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9660 TOKEN_STRING_INITIALIZER
9661 (struct cmd_config_l2_tunnel_eth_type_result,
9663 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9664 TOKEN_STRING_INITIALIZER
9665 (struct cmd_config_l2_tunnel_eth_type_result,
9667 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9668 TOKEN_STRING_INITIALIZER
9669 (struct cmd_config_l2_tunnel_eth_type_result,
9671 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9672 TOKEN_NUM_INITIALIZER
9673 (struct cmd_config_l2_tunnel_eth_type_result,
9675 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9676 TOKEN_STRING_INITIALIZER
9677 (struct cmd_config_l2_tunnel_eth_type_result,
9678 l2_tunnel, "l2-tunnel");
9679 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9680 TOKEN_STRING_INITIALIZER
9681 (struct cmd_config_l2_tunnel_eth_type_result,
9682 l2_tunnel_type, "E-tag");
9683 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9684 TOKEN_STRING_INITIALIZER
9685 (struct cmd_config_l2_tunnel_eth_type_result,
9686 eth_type, "ether-type");
9687 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9688 TOKEN_NUM_INITIALIZER
9689 (struct cmd_config_l2_tunnel_eth_type_result,
9690 eth_type_val, UINT16);
9693 str2fdir_l2_tunnel_type(char *string)
9697 static const struct {
9700 } l2_tunnel_type_str[] = {
9701 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
9704 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
9705 if (!strcmp(l2_tunnel_type_str[i].str, string))
9706 return l2_tunnel_type_str[i].type;
9708 return RTE_TUNNEL_TYPE_NONE;
9711 /* ether type config for all ports */
9713 cmd_config_l2_tunnel_eth_type_all_parsed
9714 (void *parsed_result,
9715 __attribute__((unused)) struct cmdline *cl,
9716 __attribute__((unused)) void *data)
9718 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
9719 struct rte_eth_l2_tunnel_conf entry;
9722 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9723 entry.ether_type = res->eth_type_val;
9725 FOREACH_PORT(pid, ports) {
9726 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
9730 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
9731 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
9733 .help_str = "port config all l2-tunnel ether-type",
9735 (void *)&cmd_config_l2_tunnel_eth_type_port,
9736 (void *)&cmd_config_l2_tunnel_eth_type_config,
9737 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
9738 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9739 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9740 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9741 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9746 /* ether type config for a specific port */
9748 cmd_config_l2_tunnel_eth_type_specific_parsed(
9749 void *parsed_result,
9750 __attribute__((unused)) struct cmdline *cl,
9751 __attribute__((unused)) void *data)
9753 struct cmd_config_l2_tunnel_eth_type_result *res =
9755 struct rte_eth_l2_tunnel_conf entry;
9757 if (port_id_is_invalid(res->id, ENABLED_WARN))
9760 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9761 entry.ether_type = res->eth_type_val;
9763 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
9766 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
9767 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
9769 .help_str = "port config l2-tunnel ether-type",
9771 (void *)&cmd_config_l2_tunnel_eth_type_port,
9772 (void *)&cmd_config_l2_tunnel_eth_type_config,
9773 (void *)&cmd_config_l2_tunnel_eth_type_id,
9774 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9775 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9776 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9777 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9782 /* Enable/disable l2 tunnel */
9783 struct cmd_config_l2_tunnel_en_dis_result {
9784 cmdline_fixed_string_t port;
9785 cmdline_fixed_string_t config;
9786 cmdline_fixed_string_t all;
9788 cmdline_fixed_string_t l2_tunnel;
9789 cmdline_fixed_string_t l2_tunnel_type;
9790 cmdline_fixed_string_t en_dis;
9793 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
9794 TOKEN_STRING_INITIALIZER
9795 (struct cmd_config_l2_tunnel_en_dis_result,
9797 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
9798 TOKEN_STRING_INITIALIZER
9799 (struct cmd_config_l2_tunnel_en_dis_result,
9801 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
9802 TOKEN_STRING_INITIALIZER
9803 (struct cmd_config_l2_tunnel_en_dis_result,
9805 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
9806 TOKEN_NUM_INITIALIZER
9807 (struct cmd_config_l2_tunnel_en_dis_result,
9809 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
9810 TOKEN_STRING_INITIALIZER
9811 (struct cmd_config_l2_tunnel_en_dis_result,
9812 l2_tunnel, "l2-tunnel");
9813 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
9814 TOKEN_STRING_INITIALIZER
9815 (struct cmd_config_l2_tunnel_en_dis_result,
9816 l2_tunnel_type, "E-tag");
9817 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
9818 TOKEN_STRING_INITIALIZER
9819 (struct cmd_config_l2_tunnel_en_dis_result,
9820 en_dis, "enable#disable");
9822 /* enable/disable l2 tunnel for all ports */
9824 cmd_config_l2_tunnel_en_dis_all_parsed(
9825 void *parsed_result,
9826 __attribute__((unused)) struct cmdline *cl,
9827 __attribute__((unused)) void *data)
9829 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
9830 struct rte_eth_l2_tunnel_conf entry;
9834 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9836 if (!strcmp("enable", res->en_dis))
9841 FOREACH_PORT(pid, ports) {
9842 rte_eth_dev_l2_tunnel_offload_set(pid,
9844 ETH_L2_TUNNEL_ENABLE_MASK,
9849 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
9850 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
9852 .help_str = "port config all l2-tunnel enable/disable",
9854 (void *)&cmd_config_l2_tunnel_en_dis_port,
9855 (void *)&cmd_config_l2_tunnel_en_dis_config,
9856 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
9857 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9858 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9859 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9864 /* enable/disable l2 tunnel for a port */
9866 cmd_config_l2_tunnel_en_dis_specific_parsed(
9867 void *parsed_result,
9868 __attribute__((unused)) struct cmdline *cl,
9869 __attribute__((unused)) void *data)
9871 struct cmd_config_l2_tunnel_en_dis_result *res =
9873 struct rte_eth_l2_tunnel_conf entry;
9875 if (port_id_is_invalid(res->id, ENABLED_WARN))
9878 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9880 if (!strcmp("enable", res->en_dis))
9881 rte_eth_dev_l2_tunnel_offload_set(res->id,
9883 ETH_L2_TUNNEL_ENABLE_MASK,
9886 rte_eth_dev_l2_tunnel_offload_set(res->id,
9888 ETH_L2_TUNNEL_ENABLE_MASK,
9892 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
9893 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
9895 .help_str = "port config l2-tunnel enable/disable",
9897 (void *)&cmd_config_l2_tunnel_en_dis_port,
9898 (void *)&cmd_config_l2_tunnel_en_dis_config,
9899 (void *)&cmd_config_l2_tunnel_en_dis_id,
9900 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9901 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9902 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9907 /* ******************************************************************************** */
9909 /* list of instructions */
9910 cmdline_parse_ctx_t main_ctx[] = {
9911 (cmdline_parse_inst_t *)&cmd_help_brief,
9912 (cmdline_parse_inst_t *)&cmd_help_long,
9913 (cmdline_parse_inst_t *)&cmd_quit,
9914 (cmdline_parse_inst_t *)&cmd_showport,
9915 (cmdline_parse_inst_t *)&cmd_showqueue,
9916 (cmdline_parse_inst_t *)&cmd_showportall,
9917 (cmdline_parse_inst_t *)&cmd_showcfg,
9918 (cmdline_parse_inst_t *)&cmd_start,
9919 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9920 (cmdline_parse_inst_t *)&cmd_set_link_up,
9921 (cmdline_parse_inst_t *)&cmd_set_link_down,
9922 (cmdline_parse_inst_t *)&cmd_reset,
9923 (cmdline_parse_inst_t *)&cmd_set_numbers,
9924 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9925 (cmdline_parse_inst_t *)&cmd_set_txsplit,
9926 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9927 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9928 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9929 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9930 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9931 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9932 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9933 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9934 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9935 (cmdline_parse_inst_t *)&cmd_set_link_check,
9936 #ifdef RTE_NIC_BYPASS
9937 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9938 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9939 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9940 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9942 #ifdef RTE_LIBRTE_PMD_BOND
9943 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9944 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9945 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9946 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9947 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9948 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9949 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9950 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9951 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9953 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9954 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9955 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9956 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9957 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9958 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
9959 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9960 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9961 (cmdline_parse_inst_t *)&cmd_csum_set,
9962 (cmdline_parse_inst_t *)&cmd_csum_show,
9963 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9964 (cmdline_parse_inst_t *)&cmd_tso_set,
9965 (cmdline_parse_inst_t *)&cmd_tso_show,
9966 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9967 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9968 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9969 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9970 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9971 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9972 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9973 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9974 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9975 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9976 (cmdline_parse_inst_t *)&cmd_config_dcb,
9977 (cmdline_parse_inst_t *)&cmd_read_reg,
9978 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9979 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9980 (cmdline_parse_inst_t *)&cmd_write_reg,
9981 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9982 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9983 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9984 (cmdline_parse_inst_t *)&cmd_stop,
9985 (cmdline_parse_inst_t *)&cmd_mac_addr,
9986 (cmdline_parse_inst_t *)&cmd_set_qmap,
9987 (cmdline_parse_inst_t *)&cmd_operate_port,
9988 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9989 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
9990 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
9991 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9992 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9993 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9994 (cmdline_parse_inst_t *)&cmd_config_mtu,
9995 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9996 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9997 (cmdline_parse_inst_t *)&cmd_config_rss,
9998 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9999 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10000 (cmdline_parse_inst_t *)&cmd_showport_reta,
10001 (cmdline_parse_inst_t *)&cmd_config_burst,
10002 (cmdline_parse_inst_t *)&cmd_config_thresh,
10003 (cmdline_parse_inst_t *)&cmd_config_threshold,
10004 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10005 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10006 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10007 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10008 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10009 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10010 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10011 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10012 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10013 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10014 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10015 (cmdline_parse_inst_t *)&cmd_global_config,
10016 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10017 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10018 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10019 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10020 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10021 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10022 (cmdline_parse_inst_t *)&cmd_dump,
10023 (cmdline_parse_inst_t *)&cmd_dump_one,
10024 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10025 (cmdline_parse_inst_t *)&cmd_syn_filter,
10026 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10027 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10028 (cmdline_parse_inst_t *)&cmd_flex_filter,
10029 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10030 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10031 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10032 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10033 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10034 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10035 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10036 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10037 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10038 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10039 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10040 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10041 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10042 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10043 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10044 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10045 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10046 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10047 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10048 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10049 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10050 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10051 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10055 /* prompt function, called from main on MASTER lcore */
10059 /* initialize non-constant commands */
10060 cmd_set_fwd_mode_init();
10062 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10063 if (testpmd_cl == NULL)
10065 cmdline_interact(testpmd_cl);
10066 cmdline_stdin_exit(testpmd_cl);
10072 if (testpmd_cl != NULL)
10073 cmdline_quit(testpmd_cl);
10077 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10079 if (id == (portid_t)RTE_PORT_ALL) {
10082 FOREACH_PORT(pid, ports) {
10083 /* check if need_reconfig has been set to 1 */
10084 if (ports[pid].need_reconfig == 0)
10085 ports[pid].need_reconfig = dev;
10086 /* check if need_reconfig_queues has been set to 1 */
10087 if (ports[pid].need_reconfig_queues == 0)
10088 ports[pid].need_reconfig_queues = queue;
10090 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10091 /* check if need_reconfig has been set to 1 */
10092 if (ports[id].need_reconfig == 0)
10093 ports[id].need_reconfig = dev;
10094 /* check if need_reconfig_queues has been set to 1 */
10095 if (ports[id].need_reconfig_queues == 0)
10096 ports[id].need_reconfig_queues = queue;
10100 #ifdef RTE_NIC_BYPASS
10101 #include <rte_pci_dev_ids.h>
10103 bypass_is_supported(portid_t port_id)
10105 struct rte_port *port;
10106 struct rte_pci_id *pci_id;
10108 if (port_id_is_invalid(port_id, ENABLED_WARN))
10111 /* Get the device id. */
10112 port = &ports[port_id];
10113 pci_id = &port->dev_info.pci_dev->id;
10115 /* Check if NIC supports bypass. */
10116 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
10120 printf("\tBypass not supported for port_id = %d.\n", port_id);