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 void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
96 uint8_t bypass_is_supported(portid_t port_id);
99 /* *** Help command with introduction. *** */
100 struct cmd_help_brief_result {
101 cmdline_fixed_string_t help;
104 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
106 __attribute__((unused)) void *data)
111 "Help is available for the following sections:\n\n"
112 " help control : Start and stop forwarding.\n"
113 " help display : Displaying port, stats and config "
115 " help config : Configuration information.\n"
116 " help ports : Configuring ports.\n"
117 " help registers : Reading and setting port registers.\n"
118 " help filters : Filters configuration help.\n"
119 " help all : All of the above sections.\n\n"
124 cmdline_parse_token_string_t cmd_help_brief_help =
125 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
127 cmdline_parse_inst_t cmd_help_brief = {
128 .f = cmd_help_brief_parsed,
130 .help_str = "show help",
132 (void *)&cmd_help_brief_help,
137 /* *** Help command with help sections. *** */
138 struct cmd_help_long_result {
139 cmdline_fixed_string_t help;
140 cmdline_fixed_string_t section;
143 static void cmd_help_long_parsed(void *parsed_result,
145 __attribute__((unused)) void *data)
148 struct cmd_help_long_result *res = parsed_result;
150 if (!strcmp(res->section, "all"))
153 if (show_all || !strcmp(res->section, "control")) {
158 "Control forwarding:\n"
159 "-------------------\n\n"
162 " Start packet forwarding with current configuration.\n\n"
165 " Start packet forwarding with current config"
166 " after sending one burst of packets.\n\n"
169 " Stop packet forwarding, and display accumulated"
173 " Quit to prompt.\n\n"
177 if (show_all || !strcmp(res->section, "display")) {
185 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
186 " Display information for port_id, or all.\n\n"
188 "show port X rss reta (size) (mask0,mask1,...)\n"
189 " Display the rss redirection table entry indicated"
190 " by masks on port X. size is used to indicate the"
191 " hardware supported reta size\n\n"
193 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
194 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
195 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
196 " Display the RSS hash functions and RSS hash key"
199 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
200 " Clear information for port_id, or all.\n\n"
202 "show config (rxtx|cores|fwd|txpkts)\n"
203 " Display the given configuration.\n\n"
205 "read rxd (port_id) (queue_id) (rxd_id)\n"
206 " Display an RX descriptor of a port RX queue.\n\n"
208 "read txd (port_id) (queue_id) (txd_id)\n"
209 " Display a TX descriptor of a port TX queue.\n\n"
213 if (show_all || !strcmp(res->section, "config")) {
219 "Configuration changes only become active when"
220 " forwarding is started/restarted.\n\n"
223 " Reset forwarding to the default configuration.\n\n"
225 "set verbose (level)\n"
226 " Set the debug verbosity level X.\n\n"
229 " Set number of ports.\n\n"
232 " Set number of cores.\n\n"
234 "set coremask (mask)\n"
235 " Set the forwarding cores hexadecimal mask.\n\n"
237 "set portmask (mask)\n"
238 " Set the forwarding ports hexadecimal mask.\n\n"
241 " Set number of packets per burst.\n\n"
243 "set burst tx delay (microseconds) retry (num)\n"
244 " Set the transmit delay time and number of retries"
245 " in mac_retry forwarding mode.\n\n"
247 "set txpkts (x[,y]*)\n"
248 " Set the length of each segment of TXONLY"
249 " and optionally CSUM packets.\n\n"
251 "set txsplit (off|on|rand)\n"
252 " Set the split policy for the TX packets."
253 " Right now only applicable for CSUM and TXONLY"
256 "set corelist (x[,y]*)\n"
257 " Set the list of forwarding cores.\n\n"
259 "set portlist (x[,y]*)\n"
260 " Set the list of forwarding ports.\n\n"
262 "vlan set strip (on|off) (port_id)\n"
263 " Set the VLAN strip on a port.\n\n"
265 "vlan set stripq (on|off) (port_id,queue_id)\n"
266 " Set the VLAN strip for a queue on a port.\n\n"
268 "vlan set filter (on|off) (port_id)\n"
269 " Set the VLAN filter on a port.\n\n"
271 "vlan set qinq (on|off) (port_id)\n"
272 " Set the VLAN QinQ (extended queue in queue)"
275 "vlan set tpid (value) (port_id)\n"
276 " Set the outer VLAN TPID for Packet Filtering on"
279 "rx_vlan add (vlan_id|all) (port_id)\n"
280 " Add a vlan_id, or all identifiers, to the set"
281 " of VLAN identifiers filtered by port_id.\n\n"
283 "rx_vlan rm (vlan_id|all) (port_id)\n"
284 " Remove a vlan_id, or all identifiers, from the set"
285 " of VLAN identifiers filtered by port_id.\n\n"
287 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
288 " Add a vlan_id, to the set of VLAN identifiers"
289 "filtered for VF(s) from port_id.\n\n"
291 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
292 " Remove a vlan_id, to the set of VLAN identifiers"
293 "filtered for VF(s) from port_id.\n\n"
295 "rx_vlan set tpid (value) (port_id)\n"
296 " Set the outer VLAN TPID for Packet Filtering on"
299 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
300 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
301 " add a tunnel filter of a port.\n\n"
303 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
304 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
305 " remove a tunnel filter of a port.\n\n"
307 "rx_vxlan_port add (udp_port) (port_id)\n"
308 " Add an UDP port for VXLAN packet filter on a port\n\n"
310 "rx_vxlan_port rm (udp_port) (port_id)\n"
311 " Remove an UDP port for VXLAN packet filter on a port\n\n"
313 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
314 " Set hardware insertion of VLAN IDs (single or double VLAN "
315 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
317 "tx_vlan set pvid port_id vlan_id (on|off)\n"
318 " Set port based TX VLAN insertion.\n\n"
320 "tx_vlan reset (port_id)\n"
321 " Disable hardware insertion of a VLAN header in"
322 " packets sent on a port.\n\n"
324 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
325 " Select hardware or software calculation of the"
326 " checksum when transmitting a packet using the"
327 " csum forward engine.\n"
328 " ip|udp|tcp|sctp always concern the inner layer.\n"
329 " outer-ip concerns the outer IP layer in"
330 " case the packet is recognized as a tunnel packet by"
331 " the forward engine (vxlan, gre and ipip are supported)\n"
332 " Please check the NIC datasheet for HW limits.\n\n"
334 "csum parse-tunnel (on|off) (tx_port_id)\n"
335 " If disabled, treat tunnel packets as non-tunneled"
336 " packets (treat inner headers as payload). The port\n"
337 " argument is the port used for TX in csum forward"
340 "csum show (port_id)\n"
341 " Display tx checksum offload configuration\n\n"
343 "tso set (segsize) (portid)\n"
344 " Enable TCP Segmentation Offload in csum forward"
346 " Please check the NIC datasheet for HW limits.\n\n"
349 " Display the status of TCP Segmentation Offload.\n\n"
352 " Set packet forwarding mode.\n\n"
354 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
355 " Add a MAC address on port_id.\n\n"
357 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
358 " Remove a MAC address from port_id.\n\n"
360 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
361 " Add a MAC address for a VF on the port.\n\n"
363 "set port (port_id) uta (mac_address|all) (on|off)\n"
364 " Add/Remove a or all unicast hash filter(s)"
367 "set promisc (port_id|all) (on|off)\n"
368 " Set the promiscuous mode on port_id, or all.\n\n"
370 "set allmulti (port_id|all) (on|off)\n"
371 " Set the allmulti mode on port_id, or all.\n\n"
373 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
374 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
375 " (on|off) autoneg (on|off) (port_id)\n"
376 "set flow_ctrl rx (on|off) (portid)\n"
377 "set flow_ctrl tx (on|off) (portid)\n"
378 "set flow_ctrl high_water (high_water) (portid)\n"
379 "set flow_ctrl low_water (low_water) (portid)\n"
380 "set flow_ctrl pause_time (pause_time) (portid)\n"
381 "set flow_ctrl send_xon (send_xon) (portid)\n"
382 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
383 "set flow_ctrl autoneg (on|off) (port_id)\n"
384 " Set the link flow control parameter on a port.\n\n"
386 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
387 " (low_water) (pause_time) (priority) (port_id)\n"
388 " Set the priority flow control parameter on a"
391 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
392 " Set statistics mapping (qmapping 0..15) for RX/TX"
394 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
395 " on port 0 to mapping 5.\n\n"
397 "set port (port_id) vf (vf_id) rx|tx on|off\n"
398 " Enable/Disable a VF receive/tranmit from a port\n\n"
400 "set port (port_id) vf (vf_id) (mac_addr)"
401 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
402 " Add/Remove unicast or multicast MAC addr filter"
405 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
407 " AUPE:accepts untagged VLAN;"
408 "ROPE:accept unicast hash\n\n"
409 " BAM:accepts broadcast packets;"
410 "MPE:accepts all multicast packets\n\n"
411 " Enable/Disable a VF receive mode of a port\n\n"
413 "set port (port_id) queue (queue_id) rate (rate_num)\n"
414 " Set rate limit for a queue of a port\n\n"
416 "set port (port_id) vf (vf_id) rate (rate_num) "
417 "queue_mask (queue_mask_value)\n"
418 " Set rate limit for queues in VF of a port\n\n"
420 "set port (port_id) mirror-rule (rule_id)"
421 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
422 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
423 " Set pool or vlan type mirror rule on a port.\n"
424 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
425 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
428 "set port (port_id) mirror-rule (rule_id)"
429 " (uplink-mirror|downlink-mirror) dst-pool"
430 " (pool_id) (on|off)\n"
431 " Set uplink or downlink type mirror rule on a port.\n"
432 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
433 " 0 on' enable mirror income traffic to pool 0.\n\n"
435 "reset port (port_id) mirror-rule (rule_id)\n"
436 " Reset a mirror rule.\n\n"
438 "set flush_rx (on|off)\n"
439 " Flush (default) or don't flush RX streams before"
440 " forwarding. Mainly used with PCAP drivers.\n\n"
442 #ifdef RTE_NIC_BYPASS
443 "set bypass mode (normal|bypass|isolate) (port_id)\n"
444 " Set the bypass mode for the lowest port on bypass enabled"
447 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
448 "mode (normal|bypass|isolate) (port_id)\n"
449 " Set the event required to initiate specified bypass mode for"
450 " the lowest port on a bypass enabled NIC where:\n"
451 " timeout = enable bypass after watchdog timeout.\n"
452 " os_on = enable bypass when OS/board is powered on.\n"
453 " os_off = enable bypass when OS/board is powered off.\n"
454 " power_on = enable bypass when power supply is turned on.\n"
455 " power_off = enable bypass when power supply is turned off."
458 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
459 " Set the bypass watchdog timeout to 'n' seconds"
460 " where 0 = instant.\n\n"
462 "show bypass config (port_id)\n"
463 " Show the bypass configuration for a bypass enabled NIC"
464 " using the lowest port on the NIC.\n\n"
466 #ifdef RTE_LIBRTE_PMD_BOND
467 "create bonded device (mode) (socket)\n"
468 " Create a new bonded device with specific bonding mode and socket.\n\n"
470 "add bonding slave (slave_id) (port_id)\n"
471 " Add a slave device to a bonded device.\n\n"
473 "remove bonding slave (slave_id) (port_id)\n"
474 " Remove a slave device from a bonded device.\n\n"
476 "set bonding mode (value) (port_id)\n"
477 " Set the bonding mode on a bonded device.\n\n"
479 "set bonding primary (slave_id) (port_id)\n"
480 " Set the primary slave for a bonded device.\n\n"
482 "show bonding config (port_id)\n"
483 " Show the bonding config for port_id.\n\n"
485 "set bonding mac_addr (port_id) (address)\n"
486 " Set the MAC address of a bonded device.\n\n"
488 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
489 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
491 "set bonding mon_period (port_id) (value)\n"
492 " Set the bonding link status monitoring polling period in ms.\n\n"
494 "set link-up port (port_id)\n"
495 " Set link up for a port.\n\n"
497 "set link-down port (port_id)\n"
498 " Set link down for a port.\n\n"
500 , list_pkt_forwarding_modes()
504 if (show_all || !strcmp(res->section, "ports")) {
510 "----------------\n\n"
512 "port start (port_id|all)\n"
513 " Start all ports or port_id.\n\n"
515 "port stop (port_id|all)\n"
516 " Stop all ports or port_id.\n\n"
518 "port close (port_id|all)\n"
519 " Close all ports or port_id.\n\n"
521 "port attach (ident)\n"
522 " Attach physical or virtual dev by pci address or virtual device name\n\n"
524 "port detach (port_id)\n"
525 " Detach physical or virtual dev by port_id\n\n"
527 "port config (port_id|all)"
528 " speed (10|100|1000|10000|40000|auto)"
529 " duplex (half|full|auto)\n"
530 " Set speed and duplex for all ports or port_id\n\n"
532 "port config all (rxq|txq|rxd|txd) (value)\n"
533 " Set number for rxq/txq/rxd/txd.\n\n"
535 "port config all max-pkt-len (value)\n"
536 " Set the max packet length.\n\n"
538 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
539 "hw-vlan-strip|hw-vlan-extend|drop-en)"
541 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
544 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
545 " Set the RSS mode.\n\n"
547 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
548 " Set the RSS redirection table.\n\n"
550 "port config (port_id) dcb vt (on|off) (traffic_class)"
552 " Set the DCB mode.\n\n"
554 "port config all burst (value)\n"
555 " Set the number of packets per burst.\n\n"
557 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
559 " Set the ring prefetch/host/writeback threshold"
560 " for tx/rx queue.\n\n"
562 "port config all (txfreet|txrst|rxfreet) (value)\n"
563 " Set free threshold for rx/tx, or set"
564 " tx rs bit threshold.\n\n"
565 "port config mtu X value\n"
566 " Set the MTU of port X to a given value\n\n"
568 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
569 " Start/stop a rx/tx queue of port X. Only take effect"
570 " when port X is started\n"
574 if (show_all || !strcmp(res->section, "registers")) {
582 "read reg (port_id) (address)\n"
583 " Display value of a port register.\n\n"
585 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
586 " Display a port register bit field.\n\n"
588 "read regbit (port_id) (address) (bit_x)\n"
589 " Display a single port register bit.\n\n"
591 "write reg (port_id) (address) (value)\n"
592 " Set value of a port register.\n\n"
594 "write regfield (port_id) (address) (bit_x) (bit_y)"
596 " Set bit field of a port register.\n\n"
598 "write regbit (port_id) (address) (bit_x) (value)\n"
599 " Set single bit value of a port register.\n\n"
602 if (show_all || !strcmp(res->section, "filters")) {
610 "ethertype_filter (port_id) (add|del)"
611 " (mac_addr|mac_ignr) (mac_address) ethertype"
612 " (ether_type) (drop|fwd) queue (queue_id)\n"
613 " Add/Del an ethertype filter.\n\n"
615 "2tuple_filter (port_id) (add|del)"
616 " dst_port (dst_port_value) protocol (protocol_value)"
617 " mask (mask_value) tcp_flags (tcp_flags_value)"
618 " priority (prio_value) queue (queue_id)\n"
619 " Add/Del a 2tuple filter.\n\n"
621 "5tuple_filter (port_id) (add|del)"
622 " dst_ip (dst_address) src_ip (src_address)"
623 " dst_port (dst_port_value) src_port (src_port_value)"
624 " protocol (protocol_value)"
625 " mask (mask_value) tcp_flags (tcp_flags_value)"
626 " priority (prio_value) queue (queue_id)\n"
627 " Add/Del a 5tuple filter.\n\n"
629 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
630 " Add/Del syn filter.\n\n"
632 "flex_filter (port_id) (add|del) len (len_value)"
633 " bytes (bytes_value) mask (mask_value)"
634 " priority (prio_value) queue (queue_id)\n"
635 " Add/Del a flex filter.\n\n"
637 "flow_director_filter (port_id) mode IP (add|del|update)"
638 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
639 " src (src_ip_address) dst (dst_ip_address)"
640 " vlan (vlan_value) flexbytes (flexbytes_value)"
641 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
642 " fd_id (fd_id_value)\n"
643 " Add/Del an IP type flow director filter.\n\n"
645 "flow_director_filter (port_id) mode IP (add|del|update)"
646 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
647 " src (src_ip_address) (src_port)"
648 " dst (dst_ip_address) (dst_port)"
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 UDP/TCP type flow director filter.\n\n"
654 "flow_director_filter (port_id) mode IP (add|del|update)"
655 " flow (ipv4-sctp|ipv6-sctp)"
656 " src (src_ip_address) (src_port)"
657 " dst (dst_ip_address) (dst_port)"
658 " tag (verification_tag) vlan (vlan_value)"
659 " flexbytes (flexbytes_value) (drop|fwd)"
660 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
661 " Add/Del a SCTP type flow director filter.\n\n"
663 "flow_director_filter (port_id) mode IP (add|del|update)"
664 " flow l2_payload ether (ethertype)"
665 " flexbytes (flexbytes_value) (drop|fwd)"
666 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
667 " Add/Del a l2 payload type flow director filter.\n\n"
669 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
670 " mac (mac_address) vlan (vlan_value)"
671 " flexbytes (flexbytes_value) (drop|fwd)"
672 " queue (queue_id) fd_id (fd_id_value)\n"
673 " Add/Del a MAC-VLAN flow director filter.\n\n"
675 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
676 " mac (mac_address) vlan (vlan_value)"
677 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
678 " flexbytes (flexbytes_value) (drop|fwd)"
679 " queue (queue_id) fd_id (fd_id_value)\n"
680 " Add/Del a Tunnel flow director filter.\n\n"
682 "flush_flow_director (port_id)\n"
683 " Flush all flow director entries of a device.\n\n"
685 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
686 " src_mask (ipv4_src) (ipv6_src) (src_port)"
687 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
688 " Set flow director IP mask.\n\n"
690 "flow_director_mask (port_id) mode MAC-VLAN"
691 " vlan (vlan_value) mac (mac_value)\n"
692 " Set flow director MAC-VLAN mask.\n\n"
694 "flow_director_mask (port_id) mode Tunnel"
695 " vlan (vlan_value) mac (mac_value)"
696 " tunnel-type (tunnel_type_value)"
697 " tunnel-id (tunnel_id_value)\n"
698 " Set flow director Tunnel mask.\n\n"
700 "flow_director_flex_mask (port_id)"
701 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
702 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
704 " Configure mask of flex payload.\n\n"
706 "flow_director_flex_payload (port_id)"
707 " (raw|l2|l3|l4) (config)\n"
708 " Configure flex payload selection.\n\n"
710 "get_sym_hash_ena_per_port (port_id)\n"
711 " get symmetric hash enable configuration per port.\n\n"
713 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
714 " set symmetric hash enable configuration per port"
715 " to enable or disable.\n\n"
717 "get_hash_global_config (port_id)\n"
718 " Get the global configurations of hash filters.\n\n"
720 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
721 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
722 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
723 " (enable|disable)\n"
724 " Set the global configurations of hash filters.\n\n"
726 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
727 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
728 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
729 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
730 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
731 "ipv6-next-header|udp-src-port|udp-dst-port|"
732 "tcp-src-port|tcp-dst-port|sctp-src-port|"
733 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
734 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
735 "fld-8th|none) (select|add)\n"
736 " Set the input set for hash.\n\n"
738 "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
739 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
740 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
741 "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
742 "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
743 "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
744 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
745 "fld-8th|none) (select|add)\n"
746 " Set the input set for FDir.\n\n"
751 cmdline_parse_token_string_t cmd_help_long_help =
752 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
754 cmdline_parse_token_string_t cmd_help_long_section =
755 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
756 "all#control#display#config#"
757 "ports#registers#filters");
759 cmdline_parse_inst_t cmd_help_long = {
760 .f = cmd_help_long_parsed,
762 .help_str = "show help",
764 (void *)&cmd_help_long_help,
765 (void *)&cmd_help_long_section,
771 /* *** start/stop/close all ports *** */
772 struct cmd_operate_port_result {
773 cmdline_fixed_string_t keyword;
774 cmdline_fixed_string_t name;
775 cmdline_fixed_string_t value;
778 static void cmd_operate_port_parsed(void *parsed_result,
779 __attribute__((unused)) struct cmdline *cl,
780 __attribute__((unused)) void *data)
782 struct cmd_operate_port_result *res = parsed_result;
784 if (!strcmp(res->name, "start"))
785 start_port(RTE_PORT_ALL);
786 else if (!strcmp(res->name, "stop"))
787 stop_port(RTE_PORT_ALL);
788 else if (!strcmp(res->name, "close"))
789 close_port(RTE_PORT_ALL);
791 printf("Unknown parameter\n");
794 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
795 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
797 cmdline_parse_token_string_t cmd_operate_port_all_port =
798 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
800 cmdline_parse_token_string_t cmd_operate_port_all_all =
801 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
803 cmdline_parse_inst_t cmd_operate_port = {
804 .f = cmd_operate_port_parsed,
806 .help_str = "port start|stop|close all: start/stop/close all ports",
808 (void *)&cmd_operate_port_all_cmd,
809 (void *)&cmd_operate_port_all_port,
810 (void *)&cmd_operate_port_all_all,
815 /* *** start/stop/close specific port *** */
816 struct cmd_operate_specific_port_result {
817 cmdline_fixed_string_t keyword;
818 cmdline_fixed_string_t name;
822 static void cmd_operate_specific_port_parsed(void *parsed_result,
823 __attribute__((unused)) struct cmdline *cl,
824 __attribute__((unused)) void *data)
826 struct cmd_operate_specific_port_result *res = parsed_result;
828 if (!strcmp(res->name, "start"))
829 start_port(res->value);
830 else if (!strcmp(res->name, "stop"))
831 stop_port(res->value);
832 else if (!strcmp(res->name, "close"))
833 close_port(res->value);
835 printf("Unknown parameter\n");
838 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
839 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
841 cmdline_parse_token_string_t cmd_operate_specific_port_port =
842 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
843 name, "start#stop#close");
844 cmdline_parse_token_num_t cmd_operate_specific_port_id =
845 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
848 cmdline_parse_inst_t cmd_operate_specific_port = {
849 .f = cmd_operate_specific_port_parsed,
851 .help_str = "port start|stop|close X: start/stop/close port X",
853 (void *)&cmd_operate_specific_port_cmd,
854 (void *)&cmd_operate_specific_port_port,
855 (void *)&cmd_operate_specific_port_id,
860 /* *** attach a specified port *** */
861 struct cmd_operate_attach_port_result {
862 cmdline_fixed_string_t port;
863 cmdline_fixed_string_t keyword;
864 cmdline_fixed_string_t identifier;
867 static void cmd_operate_attach_port_parsed(void *parsed_result,
868 __attribute__((unused)) struct cmdline *cl,
869 __attribute__((unused)) void *data)
871 struct cmd_operate_attach_port_result *res = parsed_result;
873 if (!strcmp(res->keyword, "attach"))
874 attach_port(res->identifier);
876 printf("Unknown parameter\n");
879 cmdline_parse_token_string_t cmd_operate_attach_port_port =
880 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
882 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
883 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
885 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
886 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
889 cmdline_parse_inst_t cmd_operate_attach_port = {
890 .f = cmd_operate_attach_port_parsed,
892 .help_str = "port attach identifier, "
893 "identifier: pci address or virtual dev name",
895 (void *)&cmd_operate_attach_port_port,
896 (void *)&cmd_operate_attach_port_keyword,
897 (void *)&cmd_operate_attach_port_identifier,
902 /* *** detach a specified port *** */
903 struct cmd_operate_detach_port_result {
904 cmdline_fixed_string_t port;
905 cmdline_fixed_string_t keyword;
909 static void cmd_operate_detach_port_parsed(void *parsed_result,
910 __attribute__((unused)) struct cmdline *cl,
911 __attribute__((unused)) void *data)
913 struct cmd_operate_detach_port_result *res = parsed_result;
915 if (!strcmp(res->keyword, "detach"))
916 detach_port(res->port_id);
918 printf("Unknown parameter\n");
921 cmdline_parse_token_string_t cmd_operate_detach_port_port =
922 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
924 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
925 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
927 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
928 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
931 cmdline_parse_inst_t cmd_operate_detach_port = {
932 .f = cmd_operate_detach_port_parsed,
934 .help_str = "port detach port_id",
936 (void *)&cmd_operate_detach_port_port,
937 (void *)&cmd_operate_detach_port_keyword,
938 (void *)&cmd_operate_detach_port_port_id,
943 /* *** configure speed for all ports *** */
944 struct cmd_config_speed_all {
945 cmdline_fixed_string_t port;
946 cmdline_fixed_string_t keyword;
947 cmdline_fixed_string_t all;
948 cmdline_fixed_string_t item1;
949 cmdline_fixed_string_t item2;
950 cmdline_fixed_string_t value1;
951 cmdline_fixed_string_t value2;
955 cmd_config_speed_all_parsed(void *parsed_result,
956 __attribute__((unused)) struct cmdline *cl,
957 __attribute__((unused)) void *data)
959 struct cmd_config_speed_all *res = parsed_result;
960 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
961 uint16_t link_duplex = 0;
964 if (!all_ports_stopped()) {
965 printf("Please stop all ports first\n");
969 if (!strcmp(res->value1, "10"))
970 link_speed = ETH_LINK_SPEED_10;
971 else if (!strcmp(res->value1, "100"))
972 link_speed = ETH_LINK_SPEED_100;
973 else if (!strcmp(res->value1, "1000"))
974 link_speed = ETH_LINK_SPEED_1000;
975 else if (!strcmp(res->value1, "10000"))
976 link_speed = ETH_LINK_SPEED_10G;
977 else if (!strcmp(res->value1, "40000"))
978 link_speed = ETH_LINK_SPEED_40G;
979 else if (!strcmp(res->value1, "auto"))
980 link_speed = ETH_LINK_SPEED_AUTONEG;
982 printf("Unknown parameter\n");
986 if (!strcmp(res->value2, "half"))
987 link_duplex = ETH_LINK_HALF_DUPLEX;
988 else if (!strcmp(res->value2, "full"))
989 link_duplex = ETH_LINK_FULL_DUPLEX;
990 else if (!strcmp(res->value2, "auto"))
991 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
993 printf("Unknown parameter\n");
997 FOREACH_PORT(pid, ports) {
998 ports[pid].dev_conf.link_speed = link_speed;
999 ports[pid].dev_conf.link_duplex = link_duplex;
1002 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1005 cmdline_parse_token_string_t cmd_config_speed_all_port =
1006 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1007 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1008 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1010 cmdline_parse_token_string_t cmd_config_speed_all_all =
1011 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1012 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1013 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1014 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1015 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1016 "10#100#1000#10000#40000#auto");
1017 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1018 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1019 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1020 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1023 cmdline_parse_inst_t cmd_config_speed_all = {
1024 .f = cmd_config_speed_all_parsed,
1026 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
1029 (void *)&cmd_config_speed_all_port,
1030 (void *)&cmd_config_speed_all_keyword,
1031 (void *)&cmd_config_speed_all_all,
1032 (void *)&cmd_config_speed_all_item1,
1033 (void *)&cmd_config_speed_all_value1,
1034 (void *)&cmd_config_speed_all_item2,
1035 (void *)&cmd_config_speed_all_value2,
1040 /* *** configure speed for specific port *** */
1041 struct cmd_config_speed_specific {
1042 cmdline_fixed_string_t port;
1043 cmdline_fixed_string_t keyword;
1045 cmdline_fixed_string_t item1;
1046 cmdline_fixed_string_t item2;
1047 cmdline_fixed_string_t value1;
1048 cmdline_fixed_string_t value2;
1052 cmd_config_speed_specific_parsed(void *parsed_result,
1053 __attribute__((unused)) struct cmdline *cl,
1054 __attribute__((unused)) void *data)
1056 struct cmd_config_speed_specific *res = parsed_result;
1057 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1058 uint16_t link_duplex = 0;
1060 if (!all_ports_stopped()) {
1061 printf("Please stop all ports first\n");
1065 if (port_id_is_invalid(res->id, ENABLED_WARN))
1068 if (!strcmp(res->value1, "10"))
1069 link_speed = ETH_LINK_SPEED_10;
1070 else if (!strcmp(res->value1, "100"))
1071 link_speed = ETH_LINK_SPEED_100;
1072 else if (!strcmp(res->value1, "1000"))
1073 link_speed = ETH_LINK_SPEED_1000;
1074 else if (!strcmp(res->value1, "10000"))
1075 link_speed = ETH_LINK_SPEED_10000;
1076 else if (!strcmp(res->value1, "40000"))
1077 link_speed = ETH_LINK_SPEED_40G;
1078 else if (!strcmp(res->value1, "auto"))
1079 link_speed = ETH_LINK_SPEED_AUTONEG;
1081 printf("Unknown parameter\n");
1085 if (!strcmp(res->value2, "half"))
1086 link_duplex = ETH_LINK_HALF_DUPLEX;
1087 else if (!strcmp(res->value2, "full"))
1088 link_duplex = ETH_LINK_FULL_DUPLEX;
1089 else if (!strcmp(res->value2, "auto"))
1090 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1092 printf("Unknown parameter\n");
1096 ports[res->id].dev_conf.link_speed = link_speed;
1097 ports[res->id].dev_conf.link_duplex = link_duplex;
1099 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1103 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1104 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1106 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1107 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1109 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1110 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1111 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1112 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1114 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1115 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1116 "10#100#1000#10000#40000#auto");
1117 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1118 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1120 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1121 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1124 cmdline_parse_inst_t cmd_config_speed_specific = {
1125 .f = cmd_config_speed_specific_parsed,
1127 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1130 (void *)&cmd_config_speed_specific_port,
1131 (void *)&cmd_config_speed_specific_keyword,
1132 (void *)&cmd_config_speed_specific_id,
1133 (void *)&cmd_config_speed_specific_item1,
1134 (void *)&cmd_config_speed_specific_value1,
1135 (void *)&cmd_config_speed_specific_item2,
1136 (void *)&cmd_config_speed_specific_value2,
1141 /* *** configure txq/rxq, txd/rxd *** */
1142 struct cmd_config_rx_tx {
1143 cmdline_fixed_string_t port;
1144 cmdline_fixed_string_t keyword;
1145 cmdline_fixed_string_t all;
1146 cmdline_fixed_string_t name;
1151 cmd_config_rx_tx_parsed(void *parsed_result,
1152 __attribute__((unused)) struct cmdline *cl,
1153 __attribute__((unused)) void *data)
1155 struct cmd_config_rx_tx *res = parsed_result;
1157 if (!all_ports_stopped()) {
1158 printf("Please stop all ports first\n");
1162 if (!strcmp(res->name, "rxq")) {
1163 if (res->value <= 0) {
1164 printf("rxq %d invalid - must be > 0\n", res->value);
1167 nb_rxq = res->value;
1169 else if (!strcmp(res->name, "txq")) {
1170 if (res->value <= 0) {
1171 printf("txq %d invalid - must be > 0\n", res->value);
1174 nb_txq = res->value;
1176 else if (!strcmp(res->name, "rxd")) {
1177 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1178 printf("rxd %d invalid - must be > 0 && <= %d\n",
1179 res->value, RTE_TEST_RX_DESC_MAX);
1182 nb_rxd = res->value;
1183 } else if (!strcmp(res->name, "txd")) {
1184 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1185 printf("txd %d invalid - must be > 0 && <= %d\n",
1186 res->value, RTE_TEST_TX_DESC_MAX);
1189 nb_txd = res->value;
1191 printf("Unknown parameter\n");
1197 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1200 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1201 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1202 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1203 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1204 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1205 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1206 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1207 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1209 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1210 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1212 cmdline_parse_inst_t cmd_config_rx_tx = {
1213 .f = cmd_config_rx_tx_parsed,
1215 .help_str = "port config all rxq|txq|rxd|txd value",
1217 (void *)&cmd_config_rx_tx_port,
1218 (void *)&cmd_config_rx_tx_keyword,
1219 (void *)&cmd_config_rx_tx_all,
1220 (void *)&cmd_config_rx_tx_name,
1221 (void *)&cmd_config_rx_tx_value,
1226 /* *** config max packet length *** */
1227 struct cmd_config_max_pkt_len_result {
1228 cmdline_fixed_string_t port;
1229 cmdline_fixed_string_t keyword;
1230 cmdline_fixed_string_t all;
1231 cmdline_fixed_string_t name;
1236 cmd_config_max_pkt_len_parsed(void *parsed_result,
1237 __attribute__((unused)) struct cmdline *cl,
1238 __attribute__((unused)) void *data)
1240 struct cmd_config_max_pkt_len_result *res = parsed_result;
1242 if (!all_ports_stopped()) {
1243 printf("Please stop all ports first\n");
1247 if (!strcmp(res->name, "max-pkt-len")) {
1248 if (res->value < ETHER_MIN_LEN) {
1249 printf("max-pkt-len can not be less than %d\n",
1253 if (res->value == rx_mode.max_rx_pkt_len)
1256 rx_mode.max_rx_pkt_len = res->value;
1257 if (res->value > ETHER_MAX_LEN)
1258 rx_mode.jumbo_frame = 1;
1260 rx_mode.jumbo_frame = 0;
1262 printf("Unknown parameter\n");
1268 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1271 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1272 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1274 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1277 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1278 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1280 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1283 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1284 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1287 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1288 .f = cmd_config_max_pkt_len_parsed,
1290 .help_str = "port config all max-pkt-len value",
1292 (void *)&cmd_config_max_pkt_len_port,
1293 (void *)&cmd_config_max_pkt_len_keyword,
1294 (void *)&cmd_config_max_pkt_len_all,
1295 (void *)&cmd_config_max_pkt_len_name,
1296 (void *)&cmd_config_max_pkt_len_value,
1301 /* *** configure port MTU *** */
1302 struct cmd_config_mtu_result {
1303 cmdline_fixed_string_t port;
1304 cmdline_fixed_string_t keyword;
1305 cmdline_fixed_string_t mtu;
1311 cmd_config_mtu_parsed(void *parsed_result,
1312 __attribute__((unused)) struct cmdline *cl,
1313 __attribute__((unused)) void *data)
1315 struct cmd_config_mtu_result *res = parsed_result;
1317 if (res->value < ETHER_MIN_LEN) {
1318 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1321 port_mtu_set(res->port_id, res->value);
1324 cmdline_parse_token_string_t cmd_config_mtu_port =
1325 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1327 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1328 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1330 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1331 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1333 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1334 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1335 cmdline_parse_token_num_t cmd_config_mtu_value =
1336 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1338 cmdline_parse_inst_t cmd_config_mtu = {
1339 .f = cmd_config_mtu_parsed,
1341 .help_str = "port config mtu value",
1343 (void *)&cmd_config_mtu_port,
1344 (void *)&cmd_config_mtu_keyword,
1345 (void *)&cmd_config_mtu_mtu,
1346 (void *)&cmd_config_mtu_port_id,
1347 (void *)&cmd_config_mtu_value,
1352 /* *** configure rx mode *** */
1353 struct cmd_config_rx_mode_flag {
1354 cmdline_fixed_string_t port;
1355 cmdline_fixed_string_t keyword;
1356 cmdline_fixed_string_t all;
1357 cmdline_fixed_string_t name;
1358 cmdline_fixed_string_t value;
1362 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1363 __attribute__((unused)) struct cmdline *cl,
1364 __attribute__((unused)) void *data)
1366 struct cmd_config_rx_mode_flag *res = parsed_result;
1368 if (!all_ports_stopped()) {
1369 printf("Please stop all ports first\n");
1373 if (!strcmp(res->name, "crc-strip")) {
1374 if (!strcmp(res->value, "on"))
1375 rx_mode.hw_strip_crc = 1;
1376 else if (!strcmp(res->value, "off"))
1377 rx_mode.hw_strip_crc = 0;
1379 printf("Unknown parameter\n");
1382 } else if (!strcmp(res->name, "rx-cksum")) {
1383 if (!strcmp(res->value, "on"))
1384 rx_mode.hw_ip_checksum = 1;
1385 else if (!strcmp(res->value, "off"))
1386 rx_mode.hw_ip_checksum = 0;
1388 printf("Unknown parameter\n");
1391 } else if (!strcmp(res->name, "hw-vlan")) {
1392 if (!strcmp(res->value, "on")) {
1393 rx_mode.hw_vlan_filter = 1;
1394 rx_mode.hw_vlan_strip = 1;
1396 else if (!strcmp(res->value, "off")) {
1397 rx_mode.hw_vlan_filter = 0;
1398 rx_mode.hw_vlan_strip = 0;
1401 printf("Unknown parameter\n");
1404 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1405 if (!strcmp(res->value, "on"))
1406 rx_mode.hw_vlan_filter = 1;
1407 else if (!strcmp(res->value, "off"))
1408 rx_mode.hw_vlan_filter = 0;
1410 printf("Unknown parameter\n");
1413 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1414 if (!strcmp(res->value, "on"))
1415 rx_mode.hw_vlan_strip = 1;
1416 else if (!strcmp(res->value, "off"))
1417 rx_mode.hw_vlan_strip = 0;
1419 printf("Unknown parameter\n");
1422 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1423 if (!strcmp(res->value, "on"))
1424 rx_mode.hw_vlan_extend = 1;
1425 else if (!strcmp(res->value, "off"))
1426 rx_mode.hw_vlan_extend = 0;
1428 printf("Unknown parameter\n");
1431 } else if (!strcmp(res->name, "drop-en")) {
1432 if (!strcmp(res->value, "on"))
1434 else if (!strcmp(res->value, "off"))
1437 printf("Unknown parameter\n");
1441 printf("Unknown parameter\n");
1447 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1450 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1451 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1452 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1453 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1455 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1456 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1457 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1459 "crc-strip#rx-cksum#hw-vlan#"
1460 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1461 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1462 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1465 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1466 .f = cmd_config_rx_mode_flag_parsed,
1468 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1469 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1471 (void *)&cmd_config_rx_mode_flag_port,
1472 (void *)&cmd_config_rx_mode_flag_keyword,
1473 (void *)&cmd_config_rx_mode_flag_all,
1474 (void *)&cmd_config_rx_mode_flag_name,
1475 (void *)&cmd_config_rx_mode_flag_value,
1480 /* *** configure rss *** */
1481 struct cmd_config_rss {
1482 cmdline_fixed_string_t port;
1483 cmdline_fixed_string_t keyword;
1484 cmdline_fixed_string_t all;
1485 cmdline_fixed_string_t name;
1486 cmdline_fixed_string_t value;
1490 cmd_config_rss_parsed(void *parsed_result,
1491 __attribute__((unused)) struct cmdline *cl,
1492 __attribute__((unused)) void *data)
1494 struct cmd_config_rss *res = parsed_result;
1495 struct rte_eth_rss_conf rss_conf;
1498 if (!strcmp(res->value, "all"))
1499 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1500 ETH_RSS_UDP | ETH_RSS_SCTP |
1502 else if (!strcmp(res->value, "ip"))
1503 rss_conf.rss_hf = ETH_RSS_IP;
1504 else if (!strcmp(res->value, "udp"))
1505 rss_conf.rss_hf = ETH_RSS_UDP;
1506 else if (!strcmp(res->value, "tcp"))
1507 rss_conf.rss_hf = ETH_RSS_TCP;
1508 else if (!strcmp(res->value, "sctp"))
1509 rss_conf.rss_hf = ETH_RSS_SCTP;
1510 else if (!strcmp(res->value, "ether"))
1511 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1512 else if (!strcmp(res->value, "none"))
1513 rss_conf.rss_hf = 0;
1515 printf("Unknown parameter\n");
1518 rss_conf.rss_key = NULL;
1519 for (i = 0; i < rte_eth_dev_count(); i++)
1520 rte_eth_dev_rss_hash_update(i, &rss_conf);
1523 cmdline_parse_token_string_t cmd_config_rss_port =
1524 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1525 cmdline_parse_token_string_t cmd_config_rss_keyword =
1526 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1527 cmdline_parse_token_string_t cmd_config_rss_all =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1529 cmdline_parse_token_string_t cmd_config_rss_name =
1530 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1531 cmdline_parse_token_string_t cmd_config_rss_value =
1532 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1533 "all#ip#tcp#udp#sctp#ether#none");
1535 cmdline_parse_inst_t cmd_config_rss = {
1536 .f = cmd_config_rss_parsed,
1538 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1540 (void *)&cmd_config_rss_port,
1541 (void *)&cmd_config_rss_keyword,
1542 (void *)&cmd_config_rss_all,
1543 (void *)&cmd_config_rss_name,
1544 (void *)&cmd_config_rss_value,
1549 /* *** configure rss hash key *** */
1550 struct cmd_config_rss_hash_key {
1551 cmdline_fixed_string_t port;
1552 cmdline_fixed_string_t config;
1554 cmdline_fixed_string_t rss_hash_key;
1555 cmdline_fixed_string_t rss_type;
1556 cmdline_fixed_string_t key;
1559 #define RSS_HASH_KEY_LENGTH 40
1561 hexa_digit_to_value(char hexa_digit)
1563 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1564 return (uint8_t) (hexa_digit - '0');
1565 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1566 return (uint8_t) ((hexa_digit - 'a') + 10);
1567 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1568 return (uint8_t) ((hexa_digit - 'A') + 10);
1569 /* Invalid hexa digit */
1574 parse_and_check_key_hexa_digit(char *key, int idx)
1578 hexa_v = hexa_digit_to_value(key[idx]);
1580 printf("invalid key: character %c at position %d is not a "
1581 "valid hexa digit\n", key[idx], idx);
1586 cmd_config_rss_hash_key_parsed(void *parsed_result,
1587 __attribute__((unused)) struct cmdline *cl,
1588 __attribute__((unused)) void *data)
1590 struct cmd_config_rss_hash_key *res = parsed_result;
1591 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1596 /* Check the length of the RSS hash key */
1597 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1598 printf("key length: %d invalid - key must be a string of %d"
1599 "hexa-decimal numbers\n", (int) strlen(res->key),
1600 RSS_HASH_KEY_LENGTH * 2);
1603 /* Translate RSS hash key into binary representation */
1604 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1605 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1608 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1611 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1613 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1614 RSS_HASH_KEY_LENGTH);
1617 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1618 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1619 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1620 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1622 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1623 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1624 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1626 rss_hash_key, "rss-hash-key");
1627 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1629 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1630 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1631 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1632 "ipv6-tcp-ex#ipv6-udp-ex");
1633 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1636 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1637 .f = cmd_config_rss_hash_key_parsed,
1640 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1641 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1642 "ipv6-sctp|ipv6-other|l2-payload|"
1643 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1645 (void *)&cmd_config_rss_hash_key_port,
1646 (void *)&cmd_config_rss_hash_key_config,
1647 (void *)&cmd_config_rss_hash_key_port_id,
1648 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1649 (void *)&cmd_config_rss_hash_key_rss_type,
1650 (void *)&cmd_config_rss_hash_key_value,
1655 /* *** configure port rxq/txq start/stop *** */
1656 struct cmd_config_rxtx_queue {
1657 cmdline_fixed_string_t port;
1659 cmdline_fixed_string_t rxtxq;
1661 cmdline_fixed_string_t opname;
1665 cmd_config_rxtx_queue_parsed(void *parsed_result,
1666 __attribute__((unused)) struct cmdline *cl,
1667 __attribute__((unused)) void *data)
1669 struct cmd_config_rxtx_queue *res = parsed_result;
1674 if (test_done == 0) {
1675 printf("Please stop forwarding first\n");
1679 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1682 if (port_is_started(res->portid) != 1) {
1683 printf("Please start port %u first\n", res->portid);
1687 if (!strcmp(res->rxtxq, "rxq"))
1689 else if (!strcmp(res->rxtxq, "txq"))
1692 printf("Unknown parameter\n");
1696 if (isrx && rx_queue_id_is_invalid(res->qid))
1698 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1701 if (!strcmp(res->opname, "start"))
1703 else if (!strcmp(res->opname, "stop"))
1706 printf("Unknown parameter\n");
1710 if (isstart && isrx)
1711 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1712 else if (!isstart && isrx)
1713 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1714 else if (isstart && !isrx)
1715 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1717 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1719 if (ret == -ENOTSUP)
1720 printf("Function not supported in PMD driver\n");
1723 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1724 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1725 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1726 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1727 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1729 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1730 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1731 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1735 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1736 .f = cmd_config_rxtx_queue_parsed,
1738 .help_str = "port X rxq|txq ID start|stop",
1740 (void *)&cmd_config_speed_all_port,
1741 (void *)&cmd_config_rxtx_queue_portid,
1742 (void *)&cmd_config_rxtx_queue_rxtxq,
1743 (void *)&cmd_config_rxtx_queue_qid,
1744 (void *)&cmd_config_rxtx_queue_opname,
1749 /* *** Configure RSS RETA *** */
1750 struct cmd_config_rss_reta {
1751 cmdline_fixed_string_t port;
1752 cmdline_fixed_string_t keyword;
1754 cmdline_fixed_string_t name;
1755 cmdline_fixed_string_t list_name;
1756 cmdline_fixed_string_t list_of_items;
1760 parse_reta_config(const char *str,
1761 struct rte_eth_rss_reta_entry64 *reta_conf,
1762 uint16_t nb_entries)
1766 uint16_t hash_index, idx, shift;
1769 const char *p, *p0 = str;
1776 unsigned long int_fld[_NUM_FLD];
1777 char *str_fld[_NUM_FLD];
1779 while ((p = strchr(p0,'(')) != NULL) {
1781 if((p0 = strchr(p,')')) == NULL)
1785 if(size >= sizeof(s))
1788 snprintf(s, sizeof(s), "%.*s", size, p);
1789 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1791 for (i = 0; i < _NUM_FLD; i++) {
1793 int_fld[i] = strtoul(str_fld[i], &end, 0);
1794 if (errno != 0 || end == str_fld[i] ||
1799 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1800 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1802 if (hash_index >= nb_entries) {
1803 printf("Invalid RETA hash index=%d\n", hash_index);
1807 idx = hash_index / RTE_RETA_GROUP_SIZE;
1808 shift = hash_index % RTE_RETA_GROUP_SIZE;
1809 reta_conf[idx].mask |= (1ULL << shift);
1810 reta_conf[idx].reta[shift] = nb_queue;
1817 cmd_set_rss_reta_parsed(void *parsed_result,
1818 __attribute__((unused)) struct cmdline *cl,
1819 __attribute__((unused)) void *data)
1822 struct rte_eth_dev_info dev_info;
1823 struct rte_eth_rss_reta_entry64 reta_conf[8];
1824 struct cmd_config_rss_reta *res = parsed_result;
1826 memset(&dev_info, 0, sizeof(dev_info));
1827 rte_eth_dev_info_get(res->port_id, &dev_info);
1828 if (dev_info.reta_size == 0) {
1829 printf("Redirection table size is 0 which is "
1830 "invalid for RSS\n");
1833 printf("The reta size of port %d is %u\n",
1834 res->port_id, dev_info.reta_size);
1835 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1836 printf("Currently do not support more than %u entries of "
1837 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1841 memset(reta_conf, 0, sizeof(reta_conf));
1842 if (!strcmp(res->list_name, "reta")) {
1843 if (parse_reta_config(res->list_of_items, reta_conf,
1844 dev_info.reta_size)) {
1845 printf("Invalid RSS Redirection Table "
1846 "config entered\n");
1849 ret = rte_eth_dev_rss_reta_update(res->port_id,
1850 reta_conf, dev_info.reta_size);
1852 printf("Bad redirection table parameter, "
1853 "return code = %d \n", ret);
1857 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1859 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1861 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1862 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1863 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1865 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1867 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1868 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1870 cmdline_parse_inst_t cmd_config_rss_reta = {
1871 .f = cmd_set_rss_reta_parsed,
1873 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1875 (void *)&cmd_config_rss_reta_port,
1876 (void *)&cmd_config_rss_reta_keyword,
1877 (void *)&cmd_config_rss_reta_port_id,
1878 (void *)&cmd_config_rss_reta_name,
1879 (void *)&cmd_config_rss_reta_list_name,
1880 (void *)&cmd_config_rss_reta_list_of_items,
1885 /* *** SHOW PORT RETA INFO *** */
1886 struct cmd_showport_reta {
1887 cmdline_fixed_string_t show;
1888 cmdline_fixed_string_t port;
1890 cmdline_fixed_string_t rss;
1891 cmdline_fixed_string_t reta;
1893 cmdline_fixed_string_t list_of_items;
1897 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1898 uint16_t nb_entries,
1902 const char *p, *p0 = str;
1906 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1909 p = strchr(p0, '(');
1913 p0 = strchr(p, ')');
1917 if (size >= sizeof(s)) {
1918 printf("The string size exceeds the internal buffer size\n");
1921 snprintf(s, sizeof(s), "%.*s", size, p);
1922 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1923 if (ret <= 0 || ret != num) {
1924 printf("The bits of masks do not match the number of "
1925 "reta entries: %u\n", num);
1928 for (i = 0; i < ret; i++)
1929 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1935 cmd_showport_reta_parsed(void *parsed_result,
1936 __attribute__((unused)) struct cmdline *cl,
1937 __attribute__((unused)) void *data)
1939 struct cmd_showport_reta *res = parsed_result;
1940 struct rte_eth_rss_reta_entry64 reta_conf[8];
1941 struct rte_eth_dev_info dev_info;
1943 memset(&dev_info, 0, sizeof(dev_info));
1944 rte_eth_dev_info_get(res->port_id, &dev_info);
1945 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1946 res->size > ETH_RSS_RETA_SIZE_512) {
1947 printf("Invalid redirection table size: %u\n", res->size);
1951 memset(reta_conf, 0, sizeof(reta_conf));
1952 if (showport_parse_reta_config(reta_conf, res->size,
1953 res->list_of_items) < 0) {
1954 printf("Invalid string: %s for reta masks\n",
1955 res->list_of_items);
1958 port_rss_reta_info(res->port_id, reta_conf, res->size);
1961 cmdline_parse_token_string_t cmd_showport_reta_show =
1962 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1963 cmdline_parse_token_string_t cmd_showport_reta_port =
1964 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1965 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1966 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1967 cmdline_parse_token_string_t cmd_showport_reta_rss =
1968 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1969 cmdline_parse_token_string_t cmd_showport_reta_reta =
1970 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1971 cmdline_parse_token_num_t cmd_showport_reta_size =
1972 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1973 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1974 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1975 list_of_items, NULL);
1977 cmdline_parse_inst_t cmd_showport_reta = {
1978 .f = cmd_showport_reta_parsed,
1980 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1982 (void *)&cmd_showport_reta_show,
1983 (void *)&cmd_showport_reta_port,
1984 (void *)&cmd_showport_reta_port_id,
1985 (void *)&cmd_showport_reta_rss,
1986 (void *)&cmd_showport_reta_reta,
1987 (void *)&cmd_showport_reta_size,
1988 (void *)&cmd_showport_reta_list_of_items,
1993 /* *** Show RSS hash configuration *** */
1994 struct cmd_showport_rss_hash {
1995 cmdline_fixed_string_t show;
1996 cmdline_fixed_string_t port;
1998 cmdline_fixed_string_t rss_hash;
1999 cmdline_fixed_string_t rss_type;
2000 cmdline_fixed_string_t key; /* optional argument */
2003 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2004 __attribute__((unused)) struct cmdline *cl,
2007 struct cmd_showport_rss_hash *res = parsed_result;
2009 port_rss_hash_conf_show(res->port_id, res->rss_type,
2010 show_rss_key != NULL);
2013 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2014 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2015 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2016 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2017 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2018 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2019 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2020 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2022 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2023 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2024 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2025 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2026 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2027 "ipv6-tcp-ex#ipv6-udp-ex");
2028 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2029 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2031 cmdline_parse_inst_t cmd_showport_rss_hash = {
2032 .f = cmd_showport_rss_hash_parsed,
2035 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2036 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2037 "ipv6-sctp|ipv6-other|l2-payload|"
2038 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2040 (void *)&cmd_showport_rss_hash_show,
2041 (void *)&cmd_showport_rss_hash_port,
2042 (void *)&cmd_showport_rss_hash_port_id,
2043 (void *)&cmd_showport_rss_hash_rss_hash,
2044 (void *)&cmd_showport_rss_hash_rss_hash_info,
2049 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2050 .f = cmd_showport_rss_hash_parsed,
2053 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2054 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2055 "ipv6-sctp|ipv6-other|l2-payload|"
2056 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2058 (void *)&cmd_showport_rss_hash_show,
2059 (void *)&cmd_showport_rss_hash_port,
2060 (void *)&cmd_showport_rss_hash_port_id,
2061 (void *)&cmd_showport_rss_hash_rss_hash,
2062 (void *)&cmd_showport_rss_hash_rss_hash_info,
2063 (void *)&cmd_showport_rss_hash_rss_key,
2068 /* *** Configure DCB *** */
2069 struct cmd_config_dcb {
2070 cmdline_fixed_string_t port;
2071 cmdline_fixed_string_t config;
2073 cmdline_fixed_string_t dcb;
2074 cmdline_fixed_string_t vt;
2075 cmdline_fixed_string_t vt_en;
2077 cmdline_fixed_string_t pfc;
2078 cmdline_fixed_string_t pfc_en;
2082 cmd_config_dcb_parsed(void *parsed_result,
2083 __attribute__((unused)) struct cmdline *cl,
2084 __attribute__((unused)) void *data)
2086 struct cmd_config_dcb *res = parsed_result;
2087 portid_t port_id = res->port_id;
2088 struct rte_port *port;
2092 port = &ports[port_id];
2093 /** Check if the port is not started **/
2094 if (port->port_status != RTE_PORT_STOPPED) {
2095 printf("Please stop port %d first\n", port_id);
2099 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2100 printf("The invalid number of traffic class,"
2101 " only 4 or 8 allowed.\n");
2105 if (nb_fwd_lcores < res->num_tcs) {
2106 printf("nb_cores shouldn't be less than number of TCs.\n");
2109 if (!strncmp(res->pfc_en, "on", 2))
2114 /* DCB in VT mode */
2115 if (!strncmp(res->vt_en, "on", 2))
2116 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2117 (enum rte_eth_nb_tcs)res->num_tcs,
2120 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2121 (enum rte_eth_nb_tcs)res->num_tcs,
2126 printf("Cannot initialize network ports.\n");
2130 cmd_reconfig_device_queue(port_id, 1, 1);
2133 cmdline_parse_token_string_t cmd_config_dcb_port =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2135 cmdline_parse_token_string_t cmd_config_dcb_config =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2137 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2138 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2139 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2141 cmdline_parse_token_string_t cmd_config_dcb_vt =
2142 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2143 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2144 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2145 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2146 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2147 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2148 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2149 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2150 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2152 cmdline_parse_inst_t cmd_config_dcb = {
2153 .f = cmd_config_dcb_parsed,
2155 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2157 (void *)&cmd_config_dcb_port,
2158 (void *)&cmd_config_dcb_config,
2159 (void *)&cmd_config_dcb_port_id,
2160 (void *)&cmd_config_dcb_dcb,
2161 (void *)&cmd_config_dcb_vt,
2162 (void *)&cmd_config_dcb_vt_en,
2163 (void *)&cmd_config_dcb_num_tcs,
2164 (void *)&cmd_config_dcb_pfc,
2165 (void *)&cmd_config_dcb_pfc_en,
2170 /* *** configure number of packets per burst *** */
2171 struct cmd_config_burst {
2172 cmdline_fixed_string_t port;
2173 cmdline_fixed_string_t keyword;
2174 cmdline_fixed_string_t all;
2175 cmdline_fixed_string_t name;
2180 cmd_config_burst_parsed(void *parsed_result,
2181 __attribute__((unused)) struct cmdline *cl,
2182 __attribute__((unused)) void *data)
2184 struct cmd_config_burst *res = parsed_result;
2186 if (!all_ports_stopped()) {
2187 printf("Please stop all ports first\n");
2191 if (!strcmp(res->name, "burst")) {
2192 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2193 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2196 nb_pkt_per_burst = res->value;
2198 printf("Unknown parameter\n");
2204 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2207 cmdline_parse_token_string_t cmd_config_burst_port =
2208 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2209 cmdline_parse_token_string_t cmd_config_burst_keyword =
2210 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2211 cmdline_parse_token_string_t cmd_config_burst_all =
2212 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2213 cmdline_parse_token_string_t cmd_config_burst_name =
2214 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2215 cmdline_parse_token_num_t cmd_config_burst_value =
2216 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2218 cmdline_parse_inst_t cmd_config_burst = {
2219 .f = cmd_config_burst_parsed,
2221 .help_str = "port config all burst value",
2223 (void *)&cmd_config_burst_port,
2224 (void *)&cmd_config_burst_keyword,
2225 (void *)&cmd_config_burst_all,
2226 (void *)&cmd_config_burst_name,
2227 (void *)&cmd_config_burst_value,
2232 /* *** configure rx/tx queues *** */
2233 struct cmd_config_thresh {
2234 cmdline_fixed_string_t port;
2235 cmdline_fixed_string_t keyword;
2236 cmdline_fixed_string_t all;
2237 cmdline_fixed_string_t name;
2242 cmd_config_thresh_parsed(void *parsed_result,
2243 __attribute__((unused)) struct cmdline *cl,
2244 __attribute__((unused)) void *data)
2246 struct cmd_config_thresh *res = parsed_result;
2248 if (!all_ports_stopped()) {
2249 printf("Please stop all ports first\n");
2253 if (!strcmp(res->name, "txpt"))
2254 tx_pthresh = res->value;
2255 else if(!strcmp(res->name, "txht"))
2256 tx_hthresh = res->value;
2257 else if(!strcmp(res->name, "txwt"))
2258 tx_wthresh = res->value;
2259 else if(!strcmp(res->name, "rxpt"))
2260 rx_pthresh = res->value;
2261 else if(!strcmp(res->name, "rxht"))
2262 rx_hthresh = res->value;
2263 else if(!strcmp(res->name, "rxwt"))
2264 rx_wthresh = res->value;
2266 printf("Unknown parameter\n");
2272 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2275 cmdline_parse_token_string_t cmd_config_thresh_port =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2277 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2278 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2279 cmdline_parse_token_string_t cmd_config_thresh_all =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2281 cmdline_parse_token_string_t cmd_config_thresh_name =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2283 "txpt#txht#txwt#rxpt#rxht#rxwt");
2284 cmdline_parse_token_num_t cmd_config_thresh_value =
2285 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2287 cmdline_parse_inst_t cmd_config_thresh = {
2288 .f = cmd_config_thresh_parsed,
2290 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2292 (void *)&cmd_config_thresh_port,
2293 (void *)&cmd_config_thresh_keyword,
2294 (void *)&cmd_config_thresh_all,
2295 (void *)&cmd_config_thresh_name,
2296 (void *)&cmd_config_thresh_value,
2301 /* *** configure free/rs threshold *** */
2302 struct cmd_config_threshold {
2303 cmdline_fixed_string_t port;
2304 cmdline_fixed_string_t keyword;
2305 cmdline_fixed_string_t all;
2306 cmdline_fixed_string_t name;
2311 cmd_config_threshold_parsed(void *parsed_result,
2312 __attribute__((unused)) struct cmdline *cl,
2313 __attribute__((unused)) void *data)
2315 struct cmd_config_threshold *res = parsed_result;
2317 if (!all_ports_stopped()) {
2318 printf("Please stop all ports first\n");
2322 if (!strcmp(res->name, "txfreet"))
2323 tx_free_thresh = res->value;
2324 else if (!strcmp(res->name, "txrst"))
2325 tx_rs_thresh = res->value;
2326 else if (!strcmp(res->name, "rxfreet"))
2327 rx_free_thresh = res->value;
2329 printf("Unknown parameter\n");
2335 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2338 cmdline_parse_token_string_t cmd_config_threshold_port =
2339 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2340 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2343 cmdline_parse_token_string_t cmd_config_threshold_all =
2344 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2345 cmdline_parse_token_string_t cmd_config_threshold_name =
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2347 "txfreet#txrst#rxfreet");
2348 cmdline_parse_token_num_t cmd_config_threshold_value =
2349 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2351 cmdline_parse_inst_t cmd_config_threshold = {
2352 .f = cmd_config_threshold_parsed,
2354 .help_str = "port config all txfreet|txrst|rxfreet value",
2356 (void *)&cmd_config_threshold_port,
2357 (void *)&cmd_config_threshold_keyword,
2358 (void *)&cmd_config_threshold_all,
2359 (void *)&cmd_config_threshold_name,
2360 (void *)&cmd_config_threshold_value,
2366 struct cmd_stop_result {
2367 cmdline_fixed_string_t stop;
2370 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2371 __attribute__((unused)) struct cmdline *cl,
2372 __attribute__((unused)) void *data)
2374 stop_packet_forwarding();
2377 cmdline_parse_token_string_t cmd_stop_stop =
2378 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2380 cmdline_parse_inst_t cmd_stop = {
2381 .f = cmd_stop_parsed,
2383 .help_str = "stop - stop packet forwarding",
2385 (void *)&cmd_stop_stop,
2390 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2393 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2394 unsigned int *parsed_items, int check_unique_values)
2396 unsigned int nb_item;
2404 * First parse all items in the list and store their value.
2409 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2411 if ((c >= '0') && (c <= '9')) {
2412 value = (unsigned int) (value * 10 + (c - '0'));
2417 printf("character %c is not a decimal digit\n", c);
2421 printf("No valid value before comma\n");
2424 if (nb_item < max_items) {
2425 parsed_items[nb_item] = value;
2431 if (nb_item >= max_items) {
2432 printf("Number of %s = %u > %u (maximum items)\n",
2433 item_name, nb_item + 1, max_items);
2436 parsed_items[nb_item++] = value;
2437 if (! check_unique_values)
2441 * Then, check that all values in the list are differents.
2442 * No optimization here...
2444 for (i = 0; i < nb_item; i++) {
2445 for (j = i + 1; j < nb_item; j++) {
2446 if (parsed_items[j] == parsed_items[i]) {
2447 printf("duplicated %s %u at index %u and %u\n",
2448 item_name, parsed_items[i], i, j);
2456 struct cmd_set_list_result {
2457 cmdline_fixed_string_t cmd_keyword;
2458 cmdline_fixed_string_t list_name;
2459 cmdline_fixed_string_t list_of_items;
2462 static void cmd_set_list_parsed(void *parsed_result,
2463 __attribute__((unused)) struct cmdline *cl,
2464 __attribute__((unused)) void *data)
2466 struct cmd_set_list_result *res;
2468 unsigned int lcorelist[RTE_MAX_LCORE];
2469 unsigned int portlist[RTE_MAX_ETHPORTS];
2471 unsigned int nb_item;
2473 if (test_done == 0) {
2474 printf("Please stop forwarding first\n");
2478 res = parsed_result;
2479 if (!strcmp(res->list_name, "corelist")) {
2480 nb_item = parse_item_list(res->list_of_items, "core",
2482 parsed_items.lcorelist, 1);
2484 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2487 if (!strcmp(res->list_name, "portlist")) {
2488 nb_item = parse_item_list(res->list_of_items, "port",
2490 parsed_items.portlist, 1);
2492 set_fwd_ports_list(parsed_items.portlist, nb_item);
2496 cmdline_parse_token_string_t cmd_set_list_keyword =
2497 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2499 cmdline_parse_token_string_t cmd_set_list_name =
2500 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2501 "corelist#portlist");
2502 cmdline_parse_token_string_t cmd_set_list_of_items =
2503 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2506 cmdline_parse_inst_t cmd_set_fwd_list = {
2507 .f = cmd_set_list_parsed,
2509 .help_str = "set corelist|portlist x[,y]*",
2511 (void *)&cmd_set_list_keyword,
2512 (void *)&cmd_set_list_name,
2513 (void *)&cmd_set_list_of_items,
2518 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2520 struct cmd_setmask_result {
2521 cmdline_fixed_string_t set;
2522 cmdline_fixed_string_t mask;
2526 static void cmd_set_mask_parsed(void *parsed_result,
2527 __attribute__((unused)) struct cmdline *cl,
2528 __attribute__((unused)) void *data)
2530 struct cmd_setmask_result *res = parsed_result;
2532 if (test_done == 0) {
2533 printf("Please stop forwarding first\n");
2536 if (!strcmp(res->mask, "coremask"))
2537 set_fwd_lcores_mask(res->hexavalue);
2538 else if (!strcmp(res->mask, "portmask"))
2539 set_fwd_ports_mask(res->hexavalue);
2542 cmdline_parse_token_string_t cmd_setmask_set =
2543 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2544 cmdline_parse_token_string_t cmd_setmask_mask =
2545 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2546 "coremask#portmask");
2547 cmdline_parse_token_num_t cmd_setmask_value =
2548 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2550 cmdline_parse_inst_t cmd_set_fwd_mask = {
2551 .f = cmd_set_mask_parsed,
2553 .help_str = "set coremask|portmask hexadecimal value",
2555 (void *)&cmd_setmask_set,
2556 (void *)&cmd_setmask_mask,
2557 (void *)&cmd_setmask_value,
2563 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2565 struct cmd_set_result {
2566 cmdline_fixed_string_t set;
2567 cmdline_fixed_string_t what;
2571 static void cmd_set_parsed(void *parsed_result,
2572 __attribute__((unused)) struct cmdline *cl,
2573 __attribute__((unused)) void *data)
2575 struct cmd_set_result *res = parsed_result;
2576 if (!strcmp(res->what, "nbport"))
2577 set_fwd_ports_number(res->value);
2578 else if (!strcmp(res->what, "nbcore"))
2579 set_fwd_lcores_number(res->value);
2580 else if (!strcmp(res->what, "burst"))
2581 set_nb_pkt_per_burst(res->value);
2582 else if (!strcmp(res->what, "verbose"))
2583 set_verbose_level(res->value);
2586 cmdline_parse_token_string_t cmd_set_set =
2587 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2588 cmdline_parse_token_string_t cmd_set_what =
2589 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2590 "nbport#nbcore#burst#verbose");
2591 cmdline_parse_token_num_t cmd_set_value =
2592 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2594 cmdline_parse_inst_t cmd_set_numbers = {
2595 .f = cmd_set_parsed,
2597 .help_str = "set nbport|nbcore|burst|verbose value",
2599 (void *)&cmd_set_set,
2600 (void *)&cmd_set_what,
2601 (void *)&cmd_set_value,
2606 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2608 struct cmd_set_txpkts_result {
2609 cmdline_fixed_string_t cmd_keyword;
2610 cmdline_fixed_string_t txpkts;
2611 cmdline_fixed_string_t seg_lengths;
2615 cmd_set_txpkts_parsed(void *parsed_result,
2616 __attribute__((unused)) struct cmdline *cl,
2617 __attribute__((unused)) void *data)
2619 struct cmd_set_txpkts_result *res;
2620 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2621 unsigned int nb_segs;
2623 res = parsed_result;
2624 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2625 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2627 set_tx_pkt_segments(seg_lengths, nb_segs);
2630 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2631 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2632 cmd_keyword, "set");
2633 cmdline_parse_token_string_t cmd_set_txpkts_name =
2634 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2636 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2637 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2640 cmdline_parse_inst_t cmd_set_txpkts = {
2641 .f = cmd_set_txpkts_parsed,
2643 .help_str = "set txpkts x[,y]*",
2645 (void *)&cmd_set_txpkts_keyword,
2646 (void *)&cmd_set_txpkts_name,
2647 (void *)&cmd_set_txpkts_lengths,
2652 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2654 struct cmd_set_txsplit_result {
2655 cmdline_fixed_string_t cmd_keyword;
2656 cmdline_fixed_string_t txsplit;
2657 cmdline_fixed_string_t mode;
2661 cmd_set_txsplit_parsed(void *parsed_result,
2662 __attribute__((unused)) struct cmdline *cl,
2663 __attribute__((unused)) void *data)
2665 struct cmd_set_txsplit_result *res;
2667 res = parsed_result;
2668 set_tx_pkt_split(res->mode);
2671 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2672 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2673 cmd_keyword, "set");
2674 cmdline_parse_token_string_t cmd_set_txsplit_name =
2675 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2676 txsplit, "txsplit");
2677 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2678 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2681 cmdline_parse_inst_t cmd_set_txsplit = {
2682 .f = cmd_set_txsplit_parsed,
2684 .help_str = "set txsplit on|off|rand",
2686 (void *)&cmd_set_txsplit_keyword,
2687 (void *)&cmd_set_txsplit_name,
2688 (void *)&cmd_set_txsplit_mode,
2693 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2694 struct cmd_rx_vlan_filter_all_result {
2695 cmdline_fixed_string_t rx_vlan;
2696 cmdline_fixed_string_t what;
2697 cmdline_fixed_string_t all;
2702 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2703 __attribute__((unused)) struct cmdline *cl,
2704 __attribute__((unused)) void *data)
2706 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2708 if (!strcmp(res->what, "add"))
2709 rx_vlan_all_filter_set(res->port_id, 1);
2711 rx_vlan_all_filter_set(res->port_id, 0);
2714 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2715 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2716 rx_vlan, "rx_vlan");
2717 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2718 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2720 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2721 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2723 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2724 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2727 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2728 .f = cmd_rx_vlan_filter_all_parsed,
2730 .help_str = "add/remove all identifiers to/from the set of VLAN "
2731 "Identifiers filtered by a port",
2733 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2734 (void *)&cmd_rx_vlan_filter_all_what,
2735 (void *)&cmd_rx_vlan_filter_all_all,
2736 (void *)&cmd_rx_vlan_filter_all_portid,
2741 /* *** VLAN OFFLOAD SET ON A PORT *** */
2742 struct cmd_vlan_offload_result {
2743 cmdline_fixed_string_t vlan;
2744 cmdline_fixed_string_t set;
2745 cmdline_fixed_string_t what;
2746 cmdline_fixed_string_t on;
2747 cmdline_fixed_string_t port_id;
2751 cmd_vlan_offload_parsed(void *parsed_result,
2752 __attribute__((unused)) struct cmdline *cl,
2753 __attribute__((unused)) void *data)
2756 struct cmd_vlan_offload_result *res = parsed_result;
2759 portid_t port_id = 0;
2763 len = strnlen(str, STR_TOKEN_SIZE);
2765 /* Get port_id first */
2773 tmp = strtoul(str, NULL, 0);
2774 /* If port_id greater that what portid_t can represent, return */
2775 if(tmp >= RTE_MAX_ETHPORTS)
2777 port_id = (portid_t)tmp;
2779 if (!strcmp(res->on, "on"))
2784 if (!strcmp(res->what, "strip"))
2785 rx_vlan_strip_set(port_id, on);
2786 else if(!strcmp(res->what, "stripq")){
2787 uint16_t queue_id = 0;
2789 /* No queue_id, return */
2791 printf("must specify (port,queue_id)\n");
2794 tmp = strtoul(str + i + 1, NULL, 0);
2795 /* If queue_id greater that what 16-bits can represent, return */
2799 queue_id = (uint16_t)tmp;
2800 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2802 else if (!strcmp(res->what, "filter"))
2803 rx_vlan_filter_set(port_id, on);
2805 vlan_extend_set(port_id, on);
2810 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2811 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2813 cmdline_parse_token_string_t cmd_vlan_offload_set =
2814 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2816 cmdline_parse_token_string_t cmd_vlan_offload_what =
2817 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2818 what, "strip#filter#qinq#stripq");
2819 cmdline_parse_token_string_t cmd_vlan_offload_on =
2820 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2822 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2823 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2826 cmdline_parse_inst_t cmd_vlan_offload = {
2827 .f = cmd_vlan_offload_parsed,
2829 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2830 " qinq(extended) for both rx/tx sides ",
2832 (void *)&cmd_vlan_offload_vlan,
2833 (void *)&cmd_vlan_offload_set,
2834 (void *)&cmd_vlan_offload_what,
2835 (void *)&cmd_vlan_offload_on,
2836 (void *)&cmd_vlan_offload_portid,
2841 /* *** VLAN TPID SET ON A PORT *** */
2842 struct cmd_vlan_tpid_result {
2843 cmdline_fixed_string_t vlan;
2844 cmdline_fixed_string_t set;
2845 cmdline_fixed_string_t what;
2851 cmd_vlan_tpid_parsed(void *parsed_result,
2852 __attribute__((unused)) struct cmdline *cl,
2853 __attribute__((unused)) void *data)
2855 struct cmd_vlan_tpid_result *res = parsed_result;
2856 vlan_tpid_set(res->port_id, res->tp_id);
2860 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2861 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2863 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2864 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2866 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2867 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2869 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2870 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2872 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2873 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2876 cmdline_parse_inst_t cmd_vlan_tpid = {
2877 .f = cmd_vlan_tpid_parsed,
2879 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2881 (void *)&cmd_vlan_tpid_vlan,
2882 (void *)&cmd_vlan_tpid_set,
2883 (void *)&cmd_vlan_tpid_what,
2884 (void *)&cmd_vlan_tpid_tpid,
2885 (void *)&cmd_vlan_tpid_portid,
2890 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2891 struct cmd_rx_vlan_filter_result {
2892 cmdline_fixed_string_t rx_vlan;
2893 cmdline_fixed_string_t what;
2899 cmd_rx_vlan_filter_parsed(void *parsed_result,
2900 __attribute__((unused)) struct cmdline *cl,
2901 __attribute__((unused)) void *data)
2903 struct cmd_rx_vlan_filter_result *res = parsed_result;
2905 if (!strcmp(res->what, "add"))
2906 rx_vft_set(res->port_id, res->vlan_id, 1);
2908 rx_vft_set(res->port_id, res->vlan_id, 0);
2911 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2912 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2913 rx_vlan, "rx_vlan");
2914 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2915 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2917 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2918 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2920 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2921 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2924 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2925 .f = cmd_rx_vlan_filter_parsed,
2927 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2928 "Identifiers filtered by a port",
2930 (void *)&cmd_rx_vlan_filter_rx_vlan,
2931 (void *)&cmd_rx_vlan_filter_what,
2932 (void *)&cmd_rx_vlan_filter_vlanid,
2933 (void *)&cmd_rx_vlan_filter_portid,
2938 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2939 struct cmd_tx_vlan_set_result {
2940 cmdline_fixed_string_t tx_vlan;
2941 cmdline_fixed_string_t set;
2947 cmd_tx_vlan_set_parsed(void *parsed_result,
2948 __attribute__((unused)) struct cmdline *cl,
2949 __attribute__((unused)) void *data)
2951 struct cmd_tx_vlan_set_result *res = parsed_result;
2952 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2954 if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
2955 printf("Error, as QinQ has been enabled.\n");
2959 tx_vlan_set(res->port_id, res->vlan_id);
2962 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2963 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2964 tx_vlan, "tx_vlan");
2965 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2966 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2968 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2969 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2971 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2972 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2975 cmdline_parse_inst_t cmd_tx_vlan_set = {
2976 .f = cmd_tx_vlan_set_parsed,
2978 .help_str = "enable hardware insertion of a single VLAN header "
2979 "with a given TAG Identifier in packets sent on a port",
2981 (void *)&cmd_tx_vlan_set_tx_vlan,
2982 (void *)&cmd_tx_vlan_set_set,
2983 (void *)&cmd_tx_vlan_set_portid,
2984 (void *)&cmd_tx_vlan_set_vlanid,
2989 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
2990 struct cmd_tx_vlan_set_qinq_result {
2991 cmdline_fixed_string_t tx_vlan;
2992 cmdline_fixed_string_t set;
2995 uint16_t vlan_id_outer;
2999 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3000 __attribute__((unused)) struct cmdline *cl,
3001 __attribute__((unused)) void *data)
3003 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3004 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
3006 if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
3007 printf("Error, as QinQ hasn't been enabled.\n");
3011 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3014 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3015 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3016 tx_vlan, "tx_vlan");
3017 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3018 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3020 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3021 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3023 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3024 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3026 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3027 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3028 vlan_id_outer, UINT16);
3030 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3031 .f = cmd_tx_vlan_set_qinq_parsed,
3033 .help_str = "enable hardware insertion of double VLAN header "
3034 "with given TAG Identifiers in packets sent on a port",
3036 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3037 (void *)&cmd_tx_vlan_set_qinq_set,
3038 (void *)&cmd_tx_vlan_set_qinq_portid,
3039 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3040 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3045 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3046 struct cmd_tx_vlan_set_pvid_result {
3047 cmdline_fixed_string_t tx_vlan;
3048 cmdline_fixed_string_t set;
3049 cmdline_fixed_string_t pvid;
3052 cmdline_fixed_string_t mode;
3056 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3057 __attribute__((unused)) struct cmdline *cl,
3058 __attribute__((unused)) void *data)
3060 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3062 if (strcmp(res->mode, "on") == 0)
3063 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3065 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3068 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3069 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3070 tx_vlan, "tx_vlan");
3071 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3072 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3074 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3075 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3077 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3078 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3080 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3081 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3083 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3084 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3087 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3088 .f = cmd_tx_vlan_set_pvid_parsed,
3090 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3092 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3093 (void *)&cmd_tx_vlan_set_pvid_set,
3094 (void *)&cmd_tx_vlan_set_pvid_pvid,
3095 (void *)&cmd_tx_vlan_set_pvid_port_id,
3096 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3097 (void *)&cmd_tx_vlan_set_pvid_mode,
3102 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3103 struct cmd_tx_vlan_reset_result {
3104 cmdline_fixed_string_t tx_vlan;
3105 cmdline_fixed_string_t reset;
3110 cmd_tx_vlan_reset_parsed(void *parsed_result,
3111 __attribute__((unused)) struct cmdline *cl,
3112 __attribute__((unused)) void *data)
3114 struct cmd_tx_vlan_reset_result *res = parsed_result;
3116 tx_vlan_reset(res->port_id);
3119 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3120 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3121 tx_vlan, "tx_vlan");
3122 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3123 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3125 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3126 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3129 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3130 .f = cmd_tx_vlan_reset_parsed,
3132 .help_str = "disable hardware insertion of a VLAN header in packets "
3135 (void *)&cmd_tx_vlan_reset_tx_vlan,
3136 (void *)&cmd_tx_vlan_reset_reset,
3137 (void *)&cmd_tx_vlan_reset_portid,
3143 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3144 struct cmd_csum_result {
3145 cmdline_fixed_string_t csum;
3146 cmdline_fixed_string_t mode;
3147 cmdline_fixed_string_t proto;
3148 cmdline_fixed_string_t hwsw;
3153 csum_show(int port_id)
3155 struct rte_eth_dev_info dev_info;
3158 ol_flags = ports[port_id].tx_ol_flags;
3159 printf("Parse tunnel is %s\n",
3160 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3161 printf("IP checksum offload is %s\n",
3162 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3163 printf("UDP checksum offload is %s\n",
3164 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3165 printf("TCP checksum offload is %s\n",
3166 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3167 printf("SCTP checksum offload is %s\n",
3168 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3169 printf("Outer-Ip checksum offload is %s\n",
3170 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3172 /* display warnings if configuration is not supported by the NIC */
3173 rte_eth_dev_info_get(port_id, &dev_info);
3174 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3175 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3176 printf("Warning: hardware IP checksum enabled but not "
3177 "supported by port %d\n", port_id);
3179 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3180 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3181 printf("Warning: hardware UDP checksum enabled but not "
3182 "supported by port %d\n", port_id);
3184 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3185 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3186 printf("Warning: hardware TCP checksum enabled but not "
3187 "supported by port %d\n", port_id);
3189 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3190 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3191 printf("Warning: hardware SCTP checksum enabled but not "
3192 "supported by port %d\n", port_id);
3194 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3195 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3196 printf("Warning: hardware outer IP checksum enabled but not "
3197 "supported by port %d\n", port_id);
3202 cmd_csum_parsed(void *parsed_result,
3203 __attribute__((unused)) struct cmdline *cl,
3204 __attribute__((unused)) void *data)
3206 struct cmd_csum_result *res = parsed_result;
3210 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3211 printf("invalid port %d\n", res->port_id);
3215 if (!strcmp(res->mode, "set")) {
3217 if (!strcmp(res->hwsw, "hw"))
3220 if (!strcmp(res->proto, "ip")) {
3221 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3222 } else if (!strcmp(res->proto, "udp")) {
3223 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3224 } else if (!strcmp(res->proto, "tcp")) {
3225 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3226 } else if (!strcmp(res->proto, "sctp")) {
3227 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3228 } else if (!strcmp(res->proto, "outer-ip")) {
3229 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3233 ports[res->port_id].tx_ol_flags |= mask;
3235 ports[res->port_id].tx_ol_flags &= (~mask);
3237 csum_show(res->port_id);
3240 cmdline_parse_token_string_t cmd_csum_csum =
3241 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3243 cmdline_parse_token_string_t cmd_csum_mode =
3244 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3246 cmdline_parse_token_string_t cmd_csum_proto =
3247 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3248 proto, "ip#tcp#udp#sctp#outer-ip");
3249 cmdline_parse_token_string_t cmd_csum_hwsw =
3250 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3252 cmdline_parse_token_num_t cmd_csum_portid =
3253 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3256 cmdline_parse_inst_t cmd_csum_set = {
3257 .f = cmd_csum_parsed,
3259 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3260 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3262 (void *)&cmd_csum_csum,
3263 (void *)&cmd_csum_mode,
3264 (void *)&cmd_csum_proto,
3265 (void *)&cmd_csum_hwsw,
3266 (void *)&cmd_csum_portid,
3271 cmdline_parse_token_string_t cmd_csum_mode_show =
3272 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3275 cmdline_parse_inst_t cmd_csum_show = {
3276 .f = cmd_csum_parsed,
3278 .help_str = "show checksum offload configuration: csum show <port>",
3280 (void *)&cmd_csum_csum,
3281 (void *)&cmd_csum_mode_show,
3282 (void *)&cmd_csum_portid,
3287 /* Enable/disable tunnel parsing */
3288 struct cmd_csum_tunnel_result {
3289 cmdline_fixed_string_t csum;
3290 cmdline_fixed_string_t parse;
3291 cmdline_fixed_string_t onoff;
3296 cmd_csum_tunnel_parsed(void *parsed_result,
3297 __attribute__((unused)) struct cmdline *cl,
3298 __attribute__((unused)) void *data)
3300 struct cmd_csum_tunnel_result *res = parsed_result;
3302 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3305 if (!strcmp(res->onoff, "on"))
3306 ports[res->port_id].tx_ol_flags |=
3307 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3309 ports[res->port_id].tx_ol_flags &=
3310 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3312 csum_show(res->port_id);
3315 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3316 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3318 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3319 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3320 parse, "parse_tunnel");
3321 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3322 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3324 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3325 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3328 cmdline_parse_inst_t cmd_csum_tunnel = {
3329 .f = cmd_csum_tunnel_parsed,
3331 .help_str = "enable/disable parsing of tunnels for csum engine: "
3332 "csum parse_tunnel on|off <tx-port>",
3334 (void *)&cmd_csum_tunnel_csum,
3335 (void *)&cmd_csum_tunnel_parse,
3336 (void *)&cmd_csum_tunnel_onoff,
3337 (void *)&cmd_csum_tunnel_portid,
3342 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3343 struct cmd_tso_set_result {
3344 cmdline_fixed_string_t tso;
3345 cmdline_fixed_string_t mode;
3351 cmd_tso_set_parsed(void *parsed_result,
3352 __attribute__((unused)) struct cmdline *cl,
3353 __attribute__((unused)) void *data)
3355 struct cmd_tso_set_result *res = parsed_result;
3356 struct rte_eth_dev_info dev_info;
3358 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3361 if (!strcmp(res->mode, "set"))
3362 ports[res->port_id].tso_segsz = res->tso_segsz;
3364 if (ports[res->port_id].tso_segsz == 0)
3365 printf("TSO is disabled\n");
3367 printf("TSO segment size is %d\n",
3368 ports[res->port_id].tso_segsz);
3370 /* display warnings if configuration is not supported by the NIC */
3371 rte_eth_dev_info_get(res->port_id, &dev_info);
3372 if ((ports[res->port_id].tso_segsz != 0) &&
3373 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3374 printf("Warning: TSO enabled but not "
3375 "supported by port %d\n", res->port_id);
3379 cmdline_parse_token_string_t cmd_tso_set_tso =
3380 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3382 cmdline_parse_token_string_t cmd_tso_set_mode =
3383 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3385 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3386 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3388 cmdline_parse_token_num_t cmd_tso_set_portid =
3389 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3392 cmdline_parse_inst_t cmd_tso_set = {
3393 .f = cmd_tso_set_parsed,
3395 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3396 "tso set <tso_segsz> <port>",
3398 (void *)&cmd_tso_set_tso,
3399 (void *)&cmd_tso_set_mode,
3400 (void *)&cmd_tso_set_tso_segsz,
3401 (void *)&cmd_tso_set_portid,
3406 cmdline_parse_token_string_t cmd_tso_show_mode =
3407 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3411 cmdline_parse_inst_t cmd_tso_show = {
3412 .f = cmd_tso_set_parsed,
3414 .help_str = "Show TSO segment size for csum engine: "
3417 (void *)&cmd_tso_set_tso,
3418 (void *)&cmd_tso_show_mode,
3419 (void *)&cmd_tso_set_portid,
3424 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3425 struct cmd_set_flush_rx {
3426 cmdline_fixed_string_t set;
3427 cmdline_fixed_string_t flush_rx;
3428 cmdline_fixed_string_t mode;
3432 cmd_set_flush_rx_parsed(void *parsed_result,
3433 __attribute__((unused)) struct cmdline *cl,
3434 __attribute__((unused)) void *data)
3436 struct cmd_set_flush_rx *res = parsed_result;
3437 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3440 cmdline_parse_token_string_t cmd_setflushrx_set =
3441 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3443 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3444 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3445 flush_rx, "flush_rx");
3446 cmdline_parse_token_string_t cmd_setflushrx_mode =
3447 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3451 cmdline_parse_inst_t cmd_set_flush_rx = {
3452 .f = cmd_set_flush_rx_parsed,
3453 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3456 (void *)&cmd_setflushrx_set,
3457 (void *)&cmd_setflushrx_flush_rx,
3458 (void *)&cmd_setflushrx_mode,
3463 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3464 struct cmd_set_link_check {
3465 cmdline_fixed_string_t set;
3466 cmdline_fixed_string_t link_check;
3467 cmdline_fixed_string_t mode;
3471 cmd_set_link_check_parsed(void *parsed_result,
3472 __attribute__((unused)) struct cmdline *cl,
3473 __attribute__((unused)) void *data)
3475 struct cmd_set_link_check *res = parsed_result;
3476 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3479 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3480 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3482 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3483 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3484 link_check, "link_check");
3485 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3486 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3490 cmdline_parse_inst_t cmd_set_link_check = {
3491 .f = cmd_set_link_check_parsed,
3492 .help_str = "set link_check on|off: enable/disable link status check "
3493 "when starting/stopping a port",
3496 (void *)&cmd_setlinkcheck_set,
3497 (void *)&cmd_setlinkcheck_link_check,
3498 (void *)&cmd_setlinkcheck_mode,
3503 #ifdef RTE_NIC_BYPASS
3504 /* *** SET NIC BYPASS MODE *** */
3505 struct cmd_set_bypass_mode_result {
3506 cmdline_fixed_string_t set;
3507 cmdline_fixed_string_t bypass;
3508 cmdline_fixed_string_t mode;
3509 cmdline_fixed_string_t value;
3514 cmd_set_bypass_mode_parsed(void *parsed_result,
3515 __attribute__((unused)) struct cmdline *cl,
3516 __attribute__((unused)) void *data)
3518 struct cmd_set_bypass_mode_result *res = parsed_result;
3519 portid_t port_id = res->port_id;
3520 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3522 if (!bypass_is_supported(port_id))
3525 if (!strcmp(res->value, "bypass"))
3526 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3527 else if (!strcmp(res->value, "isolate"))
3528 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3530 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3532 /* Set the bypass mode for the relevant port. */
3533 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3534 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3538 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3539 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3541 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3542 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3544 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3545 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3547 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3548 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3549 value, "normal#bypass#isolate");
3550 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3551 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3554 cmdline_parse_inst_t cmd_set_bypass_mode = {
3555 .f = cmd_set_bypass_mode_parsed,
3556 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3557 "Set the NIC bypass mode for port_id",
3560 (void *)&cmd_setbypass_mode_set,
3561 (void *)&cmd_setbypass_mode_bypass,
3562 (void *)&cmd_setbypass_mode_mode,
3563 (void *)&cmd_setbypass_mode_value,
3564 (void *)&cmd_setbypass_mode_port,
3569 /* *** SET NIC BYPASS EVENT *** */
3570 struct cmd_set_bypass_event_result {
3571 cmdline_fixed_string_t set;
3572 cmdline_fixed_string_t bypass;
3573 cmdline_fixed_string_t event;
3574 cmdline_fixed_string_t event_value;
3575 cmdline_fixed_string_t mode;
3576 cmdline_fixed_string_t mode_value;
3581 cmd_set_bypass_event_parsed(void *parsed_result,
3582 __attribute__((unused)) struct cmdline *cl,
3583 __attribute__((unused)) void *data)
3586 struct cmd_set_bypass_event_result *res = parsed_result;
3587 portid_t port_id = res->port_id;
3588 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3589 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3591 if (!bypass_is_supported(port_id))
3594 if (!strcmp(res->event_value, "timeout"))
3595 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3596 else if (!strcmp(res->event_value, "os_on"))
3597 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3598 else if (!strcmp(res->event_value, "os_off"))
3599 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3600 else if (!strcmp(res->event_value, "power_on"))
3601 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3602 else if (!strcmp(res->event_value, "power_off"))
3603 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3605 bypass_event = RTE_BYPASS_EVENT_NONE;
3607 if (!strcmp(res->mode_value, "bypass"))
3608 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3609 else if (!strcmp(res->mode_value, "isolate"))
3610 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3612 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3614 /* Set the watchdog timeout. */
3615 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3618 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3619 (rc = rte_eth_dev_wd_timeout_store(port_id,
3620 bypass_timeout)) != 0) {
3621 printf("Failed to set timeout value %u "
3622 "for port %d, errto code: %d.\n",
3623 bypass_timeout, port_id, rc);
3627 /* Set the bypass event to transition to bypass mode. */
3628 if (0 != rte_eth_dev_bypass_event_store(port_id,
3629 bypass_event, bypass_mode)) {
3630 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3635 cmdline_parse_token_string_t cmd_setbypass_event_set =
3636 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3638 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3639 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3641 cmdline_parse_token_string_t cmd_setbypass_event_event =
3642 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3644 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3645 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3646 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3647 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3648 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3650 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3651 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3652 mode_value, "normal#bypass#isolate");
3653 cmdline_parse_token_num_t cmd_setbypass_event_port =
3654 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3657 cmdline_parse_inst_t cmd_set_bypass_event = {
3658 .f = cmd_set_bypass_event_parsed,
3659 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3660 "mode (normal|bypass|isolate) (port_id): "
3661 "Set the NIC bypass event mode for port_id",
3664 (void *)&cmd_setbypass_event_set,
3665 (void *)&cmd_setbypass_event_bypass,
3666 (void *)&cmd_setbypass_event_event,
3667 (void *)&cmd_setbypass_event_event_value,
3668 (void *)&cmd_setbypass_event_mode,
3669 (void *)&cmd_setbypass_event_mode_value,
3670 (void *)&cmd_setbypass_event_port,
3676 /* *** SET NIC BYPASS TIMEOUT *** */
3677 struct cmd_set_bypass_timeout_result {
3678 cmdline_fixed_string_t set;
3679 cmdline_fixed_string_t bypass;
3680 cmdline_fixed_string_t timeout;
3681 cmdline_fixed_string_t value;
3685 cmd_set_bypass_timeout_parsed(void *parsed_result,
3686 __attribute__((unused)) struct cmdline *cl,
3687 __attribute__((unused)) void *data)
3689 struct cmd_set_bypass_timeout_result *res = parsed_result;
3691 if (!strcmp(res->value, "1.5"))
3692 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3693 else if (!strcmp(res->value, "2"))
3694 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3695 else if (!strcmp(res->value, "3"))
3696 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3697 else if (!strcmp(res->value, "4"))
3698 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3699 else if (!strcmp(res->value, "8"))
3700 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3701 else if (!strcmp(res->value, "16"))
3702 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3703 else if (!strcmp(res->value, "32"))
3704 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3706 bypass_timeout = RTE_BYPASS_TMT_OFF;
3709 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3710 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3712 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3713 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3715 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3716 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3717 timeout, "timeout");
3718 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3719 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3720 value, "0#1.5#2#3#4#8#16#32");
3722 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3723 .f = cmd_set_bypass_timeout_parsed,
3724 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3725 "Set the NIC bypass watchdog timeout",
3728 (void *)&cmd_setbypass_timeout_set,
3729 (void *)&cmd_setbypass_timeout_bypass,
3730 (void *)&cmd_setbypass_timeout_timeout,
3731 (void *)&cmd_setbypass_timeout_value,
3736 /* *** SHOW NIC BYPASS MODE *** */
3737 struct cmd_show_bypass_config_result {
3738 cmdline_fixed_string_t show;
3739 cmdline_fixed_string_t bypass;
3740 cmdline_fixed_string_t config;
3745 cmd_show_bypass_config_parsed(void *parsed_result,
3746 __attribute__((unused)) struct cmdline *cl,
3747 __attribute__((unused)) void *data)
3749 struct cmd_show_bypass_config_result *res = parsed_result;
3750 uint32_t event_mode;
3751 uint32_t bypass_mode;
3752 portid_t port_id = res->port_id;
3753 uint32_t timeout = bypass_timeout;
3756 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3757 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3758 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3759 {"UNKNOWN", "normal", "bypass", "isolate"};
3760 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3767 int num_events = (sizeof events) / (sizeof events[0]);
3769 if (!bypass_is_supported(port_id))
3772 /* Display the bypass mode.*/
3773 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3774 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3778 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3779 bypass_mode = RTE_BYPASS_MODE_NONE;
3781 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3784 /* Display the bypass timeout.*/
3785 if (!RTE_BYPASS_TMT_VALID(timeout))
3786 timeout = RTE_BYPASS_TMT_OFF;
3788 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3790 /* Display the bypass events and associated modes. */
3791 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3793 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3794 printf("\tFailed to get bypass mode for event = %s\n",
3797 if (!RTE_BYPASS_MODE_VALID(event_mode))
3798 event_mode = RTE_BYPASS_MODE_NONE;
3800 printf("\tbypass event: %-16s = %s\n", events[i],
3806 cmdline_parse_token_string_t cmd_showbypass_config_show =
3807 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3809 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3810 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3812 cmdline_parse_token_string_t cmd_showbypass_config_config =
3813 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3815 cmdline_parse_token_num_t cmd_showbypass_config_port =
3816 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3819 cmdline_parse_inst_t cmd_show_bypass_config = {
3820 .f = cmd_show_bypass_config_parsed,
3821 .help_str = "show bypass config (port_id): "
3822 "Show the NIC bypass config for port_id",
3825 (void *)&cmd_showbypass_config_show,
3826 (void *)&cmd_showbypass_config_bypass,
3827 (void *)&cmd_showbypass_config_config,
3828 (void *)&cmd_showbypass_config_port,
3834 #ifdef RTE_LIBRTE_PMD_BOND
3835 /* *** SET BONDING MODE *** */
3836 struct cmd_set_bonding_mode_result {
3837 cmdline_fixed_string_t set;
3838 cmdline_fixed_string_t bonding;
3839 cmdline_fixed_string_t mode;
3844 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3845 __attribute__((unused)) struct cmdline *cl,
3846 __attribute__((unused)) void *data)
3848 struct cmd_set_bonding_mode_result *res = parsed_result;
3849 portid_t port_id = res->port_id;
3851 /* Set the bonding mode for the relevant port. */
3852 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3853 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3856 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3859 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3860 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3861 bonding, "bonding");
3862 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3863 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3865 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3866 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3868 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3869 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3872 cmdline_parse_inst_t cmd_set_bonding_mode = {
3873 .f = cmd_set_bonding_mode_parsed,
3874 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3877 (void *) &cmd_setbonding_mode_set,
3878 (void *) &cmd_setbonding_mode_bonding,
3879 (void *) &cmd_setbonding_mode_mode,
3880 (void *) &cmd_setbonding_mode_value,
3881 (void *) &cmd_setbonding_mode_port,
3886 /* *** SET BALANCE XMIT POLICY *** */
3887 struct cmd_set_bonding_balance_xmit_policy_result {
3888 cmdline_fixed_string_t set;
3889 cmdline_fixed_string_t bonding;
3890 cmdline_fixed_string_t balance_xmit_policy;
3892 cmdline_fixed_string_t policy;
3895 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3896 __attribute__((unused)) struct cmdline *cl,
3897 __attribute__((unused)) void *data)
3899 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3900 portid_t port_id = res->port_id;
3903 if (!strcmp(res->policy, "l2")) {
3904 policy = BALANCE_XMIT_POLICY_LAYER2;
3905 } else if (!strcmp(res->policy, "l23")) {
3906 policy = BALANCE_XMIT_POLICY_LAYER23;
3907 } else if (!strcmp(res->policy, "l34")) {
3908 policy = BALANCE_XMIT_POLICY_LAYER34;
3910 printf("\t Invalid xmit policy selection");
3914 /* Set the bonding mode for the relevant port. */
3915 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3916 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3921 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3922 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3924 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3925 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3926 bonding, "bonding");
3927 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3928 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3929 balance_xmit_policy, "balance_xmit_policy");
3930 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3931 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3933 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3934 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3935 policy, "l2#l23#l34");
3937 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3938 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3939 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3942 (void *)&cmd_setbonding_balance_xmit_policy_set,
3943 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3944 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3945 (void *)&cmd_setbonding_balance_xmit_policy_port,
3946 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3951 /* *** SHOW NIC BONDING CONFIGURATION *** */
3952 struct cmd_show_bonding_config_result {
3953 cmdline_fixed_string_t show;
3954 cmdline_fixed_string_t bonding;
3955 cmdline_fixed_string_t config;
3959 static void cmd_show_bonding_config_parsed(void *parsed_result,
3960 __attribute__((unused)) struct cmdline *cl,
3961 __attribute__((unused)) void *data)
3963 struct cmd_show_bonding_config_result *res = parsed_result;
3965 uint8_t slaves[RTE_MAX_ETHPORTS];
3966 int num_slaves, num_active_slaves;
3969 portid_t port_id = res->port_id;
3971 /* Display the bonding mode.*/
3972 bonding_mode = rte_eth_bond_mode_get(port_id);
3973 if (bonding_mode < 0) {
3974 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3977 printf("\tBonding mode: %d\n", bonding_mode);
3979 if (bonding_mode == BONDING_MODE_BALANCE) {
3980 int balance_xmit_policy;
3982 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3983 if (balance_xmit_policy < 0) {
3984 printf("\tFailed to get balance xmit policy for port = %d\n",
3988 printf("\tBalance Xmit Policy: ");
3990 switch (balance_xmit_policy) {
3991 case BALANCE_XMIT_POLICY_LAYER2:
3992 printf("BALANCE_XMIT_POLICY_LAYER2");
3994 case BALANCE_XMIT_POLICY_LAYER23:
3995 printf("BALANCE_XMIT_POLICY_LAYER23");
3997 case BALANCE_XMIT_POLICY_LAYER34:
3998 printf("BALANCE_XMIT_POLICY_LAYER34");
4005 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4007 if (num_slaves < 0) {
4008 printf("\tFailed to get slave list for port = %d\n", port_id);
4011 if (num_slaves > 0) {
4012 printf("\tSlaves (%d): [", num_slaves);
4013 for (i = 0; i < num_slaves - 1; i++)
4014 printf("%d ", slaves[i]);
4016 printf("%d]\n", slaves[num_slaves - 1]);
4018 printf("\tSlaves: []\n");
4022 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4025 if (num_active_slaves < 0) {
4026 printf("\tFailed to get active slave list for port = %d\n", port_id);
4029 if (num_active_slaves > 0) {
4030 printf("\tActive Slaves (%d): [", num_active_slaves);
4031 for (i = 0; i < num_active_slaves - 1; i++)
4032 printf("%d ", slaves[i]);
4034 printf("%d]\n", slaves[num_active_slaves - 1]);
4037 printf("\tActive Slaves: []\n");
4041 primary_id = rte_eth_bond_primary_get(port_id);
4042 if (primary_id < 0) {
4043 printf("\tFailed to get primary slave for port = %d\n", port_id);
4046 printf("\tPrimary: [%d]\n", primary_id);
4050 cmdline_parse_token_string_t cmd_showbonding_config_show =
4051 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4053 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4054 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4055 bonding, "bonding");
4056 cmdline_parse_token_string_t cmd_showbonding_config_config =
4057 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4059 cmdline_parse_token_num_t cmd_showbonding_config_port =
4060 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4063 cmdline_parse_inst_t cmd_show_bonding_config = {
4064 .f = cmd_show_bonding_config_parsed,
4065 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4068 (void *)&cmd_showbonding_config_show,
4069 (void *)&cmd_showbonding_config_bonding,
4070 (void *)&cmd_showbonding_config_config,
4071 (void *)&cmd_showbonding_config_port,
4076 /* *** SET BONDING PRIMARY *** */
4077 struct cmd_set_bonding_primary_result {
4078 cmdline_fixed_string_t set;
4079 cmdline_fixed_string_t bonding;
4080 cmdline_fixed_string_t primary;
4085 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4086 __attribute__((unused)) struct cmdline *cl,
4087 __attribute__((unused)) void *data)
4089 struct cmd_set_bonding_primary_result *res = parsed_result;
4090 portid_t master_port_id = res->port_id;
4091 portid_t slave_port_id = res->slave_id;
4093 /* Set the primary slave for a bonded device. */
4094 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4095 printf("\t Failed to set primary slave for port = %d.\n",
4102 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4103 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4105 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4106 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4107 bonding, "bonding");
4108 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4109 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4110 primary, "primary");
4111 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4112 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4114 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4115 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4118 cmdline_parse_inst_t cmd_set_bonding_primary = {
4119 .f = cmd_set_bonding_primary_parsed,
4120 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4123 (void *)&cmd_setbonding_primary_set,
4124 (void *)&cmd_setbonding_primary_bonding,
4125 (void *)&cmd_setbonding_primary_primary,
4126 (void *)&cmd_setbonding_primary_slave,
4127 (void *)&cmd_setbonding_primary_port,
4132 /* *** ADD SLAVE *** */
4133 struct cmd_add_bonding_slave_result {
4134 cmdline_fixed_string_t add;
4135 cmdline_fixed_string_t bonding;
4136 cmdline_fixed_string_t slave;
4141 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4142 __attribute__((unused)) struct cmdline *cl,
4143 __attribute__((unused)) void *data)
4145 struct cmd_add_bonding_slave_result *res = parsed_result;
4146 portid_t master_port_id = res->port_id;
4147 portid_t slave_port_id = res->slave_id;
4149 /* Set the primary slave for a bonded device. */
4150 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4151 printf("\t Failed to add slave %d to master port = %d.\n",
4152 slave_port_id, master_port_id);
4156 set_port_slave_flag(slave_port_id);
4159 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4160 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4162 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4163 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4164 bonding, "bonding");
4165 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4166 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4168 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4169 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4171 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4172 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4175 cmdline_parse_inst_t cmd_add_bonding_slave = {
4176 .f = cmd_add_bonding_slave_parsed,
4177 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4180 (void *)&cmd_addbonding_slave_add,
4181 (void *)&cmd_addbonding_slave_bonding,
4182 (void *)&cmd_addbonding_slave_slave,
4183 (void *)&cmd_addbonding_slave_slaveid,
4184 (void *)&cmd_addbonding_slave_port,
4189 /* *** REMOVE SLAVE *** */
4190 struct cmd_remove_bonding_slave_result {
4191 cmdline_fixed_string_t remove;
4192 cmdline_fixed_string_t bonding;
4193 cmdline_fixed_string_t slave;
4198 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4199 __attribute__((unused)) struct cmdline *cl,
4200 __attribute__((unused)) void *data)
4202 struct cmd_remove_bonding_slave_result *res = parsed_result;
4203 portid_t master_port_id = res->port_id;
4204 portid_t slave_port_id = res->slave_id;
4206 /* Set the primary slave for a bonded device. */
4207 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4208 printf("\t Failed to remove slave %d from master port = %d.\n",
4209 slave_port_id, master_port_id);
4213 clear_port_slave_flag(slave_port_id);
4216 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4217 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4219 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4220 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4221 bonding, "bonding");
4222 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4223 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4225 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4226 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4228 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4229 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4232 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4233 .f = cmd_remove_bonding_slave_parsed,
4234 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4237 (void *)&cmd_removebonding_slave_remove,
4238 (void *)&cmd_removebonding_slave_bonding,
4239 (void *)&cmd_removebonding_slave_slave,
4240 (void *)&cmd_removebonding_slave_slaveid,
4241 (void *)&cmd_removebonding_slave_port,
4246 /* *** CREATE BONDED DEVICE *** */
4247 struct cmd_create_bonded_device_result {
4248 cmdline_fixed_string_t create;
4249 cmdline_fixed_string_t bonded;
4250 cmdline_fixed_string_t device;
4255 static int bond_dev_num = 0;
4257 static void cmd_create_bonded_device_parsed(void *parsed_result,
4258 __attribute__((unused)) struct cmdline *cl,
4259 __attribute__((unused)) void *data)
4261 struct cmd_create_bonded_device_result *res = parsed_result;
4262 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4265 if (test_done == 0) {
4266 printf("Please stop forwarding first\n");
4270 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4273 /* Create a new bonded device. */
4274 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4276 printf("\t Failed to create bonded device.\n");
4279 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4282 /* Update number of ports */
4283 nb_ports = rte_eth_dev_count();
4284 reconfig(port_id, res->socket);
4285 rte_eth_promiscuous_enable(port_id);
4286 ports[port_id].enabled = 1;
4291 cmdline_parse_token_string_t cmd_createbonded_device_create =
4292 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4294 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4295 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4297 cmdline_parse_token_string_t cmd_createbonded_device_device =
4298 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4300 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4301 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4303 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4304 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4307 cmdline_parse_inst_t cmd_create_bonded_device = {
4308 .f = cmd_create_bonded_device_parsed,
4309 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4312 (void *)&cmd_createbonded_device_create,
4313 (void *)&cmd_createbonded_device_bonded,
4314 (void *)&cmd_createbonded_device_device,
4315 (void *)&cmd_createbonded_device_mode,
4316 (void *)&cmd_createbonded_device_socket,
4321 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4322 struct cmd_set_bond_mac_addr_result {
4323 cmdline_fixed_string_t set;
4324 cmdline_fixed_string_t bonding;
4325 cmdline_fixed_string_t mac_addr;
4327 struct ether_addr address;
4330 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4331 __attribute__((unused)) struct cmdline *cl,
4332 __attribute__((unused)) void *data)
4334 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4337 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4340 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4342 /* check the return value and print it if is < 0 */
4344 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4347 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4348 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4349 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4350 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4352 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4353 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4355 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4356 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4357 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4358 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4360 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4361 .f = cmd_set_bond_mac_addr_parsed,
4363 .help_str = "set bonding mac_addr (port_id) (address): ",
4365 (void *)&cmd_set_bond_mac_addr_set,
4366 (void *)&cmd_set_bond_mac_addr_bonding,
4367 (void *)&cmd_set_bond_mac_addr_mac,
4368 (void *)&cmd_set_bond_mac_addr_portnum,
4369 (void *)&cmd_set_bond_mac_addr_addr,
4375 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4376 struct cmd_set_bond_mon_period_result {
4377 cmdline_fixed_string_t set;
4378 cmdline_fixed_string_t bonding;
4379 cmdline_fixed_string_t mon_period;
4384 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4385 __attribute__((unused)) struct cmdline *cl,
4386 __attribute__((unused)) void *data)
4388 struct cmd_set_bond_mon_period_result *res = parsed_result;
4391 if (res->port_num >= nb_ports) {
4392 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4396 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4398 /* check the return value and print it if is < 0 */
4400 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4403 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4404 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4406 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4407 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4408 bonding, "bonding");
4409 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4410 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4411 mon_period, "mon_period");
4412 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4413 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4415 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4416 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4419 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4420 .f = cmd_set_bond_mon_period_parsed,
4422 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4424 (void *)&cmd_set_bond_mon_period_set,
4425 (void *)&cmd_set_bond_mon_period_bonding,
4426 (void *)&cmd_set_bond_mon_period_mon_period,
4427 (void *)&cmd_set_bond_mon_period_portnum,
4428 (void *)&cmd_set_bond_mon_period_period_ms,
4433 #endif /* RTE_LIBRTE_PMD_BOND */
4435 /* *** SET FORWARDING MODE *** */
4436 struct cmd_set_fwd_mode_result {
4437 cmdline_fixed_string_t set;
4438 cmdline_fixed_string_t fwd;
4439 cmdline_fixed_string_t mode;
4442 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4443 __attribute__((unused)) struct cmdline *cl,
4444 __attribute__((unused)) void *data)
4446 struct cmd_set_fwd_mode_result *res = parsed_result;
4448 set_pkt_forwarding_mode(res->mode);
4451 cmdline_parse_token_string_t cmd_setfwd_set =
4452 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4453 cmdline_parse_token_string_t cmd_setfwd_fwd =
4454 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4455 cmdline_parse_token_string_t cmd_setfwd_mode =
4456 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4457 "" /* defined at init */);
4459 cmdline_parse_inst_t cmd_set_fwd_mode = {
4460 .f = cmd_set_fwd_mode_parsed,
4462 .help_str = NULL, /* defined at init */
4464 (void *)&cmd_setfwd_set,
4465 (void *)&cmd_setfwd_fwd,
4466 (void *)&cmd_setfwd_mode,
4471 static void cmd_set_fwd_mode_init(void)
4474 static char token[128];
4475 static char help[256];
4476 cmdline_parse_token_string_t *token_struct;
4478 modes = list_pkt_forwarding_modes();
4479 snprintf(help, sizeof help, "set fwd %s - "
4480 "set packet forwarding mode", modes);
4481 cmd_set_fwd_mode.help_str = help;
4483 /* string token separator is # */
4484 for (c = token; *modes != '\0'; modes++)
4489 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4490 token_struct->string_data.str = token;
4493 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4494 struct cmd_set_burst_tx_retry_result {
4495 cmdline_fixed_string_t set;
4496 cmdline_fixed_string_t burst;
4497 cmdline_fixed_string_t tx;
4498 cmdline_fixed_string_t delay;
4500 cmdline_fixed_string_t retry;
4504 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4505 __attribute__((unused)) struct cmdline *cl,
4506 __attribute__((unused)) void *data)
4508 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4510 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4511 && !strcmp(res->tx, "tx")) {
4512 if (!strcmp(res->delay, "delay"))
4513 burst_tx_delay_time = res->time;
4514 if (!strcmp(res->retry, "retry"))
4515 burst_tx_retry_num = res->retry_num;
4520 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4521 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4522 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4523 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4525 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4526 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4527 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4528 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4529 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4530 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4531 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4532 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4533 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4534 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4536 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4537 .f = cmd_set_burst_tx_retry_parsed,
4538 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4540 (void *)&cmd_set_burst_tx_retry_set,
4541 (void *)&cmd_set_burst_tx_retry_burst,
4542 (void *)&cmd_set_burst_tx_retry_tx,
4543 (void *)&cmd_set_burst_tx_retry_delay,
4544 (void *)&cmd_set_burst_tx_retry_time,
4545 (void *)&cmd_set_burst_tx_retry_retry,
4546 (void *)&cmd_set_burst_tx_retry_retry_num,
4551 /* *** SET PROMISC MODE *** */
4552 struct cmd_set_promisc_mode_result {
4553 cmdline_fixed_string_t set;
4554 cmdline_fixed_string_t promisc;
4555 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4556 uint8_t port_num; /* valid if "allports" argument == 0 */
4557 cmdline_fixed_string_t mode;
4560 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4561 __attribute__((unused)) struct cmdline *cl,
4564 struct cmd_set_promisc_mode_result *res = parsed_result;
4568 if (!strcmp(res->mode, "on"))
4575 FOREACH_PORT(i, ports) {
4577 rte_eth_promiscuous_enable(i);
4579 rte_eth_promiscuous_disable(i);
4584 rte_eth_promiscuous_enable(res->port_num);
4586 rte_eth_promiscuous_disable(res->port_num);
4590 cmdline_parse_token_string_t cmd_setpromisc_set =
4591 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4592 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4593 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4595 cmdline_parse_token_string_t cmd_setpromisc_portall =
4596 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4598 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4599 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4601 cmdline_parse_token_string_t cmd_setpromisc_mode =
4602 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4605 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4606 .f = cmd_set_promisc_mode_parsed,
4608 .help_str = "set promisc all on|off: set promisc mode for all ports",
4610 (void *)&cmd_setpromisc_set,
4611 (void *)&cmd_setpromisc_promisc,
4612 (void *)&cmd_setpromisc_portall,
4613 (void *)&cmd_setpromisc_mode,
4618 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4619 .f = cmd_set_promisc_mode_parsed,
4621 .help_str = "set promisc X on|off: set promisc mode on port X",
4623 (void *)&cmd_setpromisc_set,
4624 (void *)&cmd_setpromisc_promisc,
4625 (void *)&cmd_setpromisc_portnum,
4626 (void *)&cmd_setpromisc_mode,
4631 /* *** SET ALLMULTI MODE *** */
4632 struct cmd_set_allmulti_mode_result {
4633 cmdline_fixed_string_t set;
4634 cmdline_fixed_string_t allmulti;
4635 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4636 uint8_t port_num; /* valid if "allports" argument == 0 */
4637 cmdline_fixed_string_t mode;
4640 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4641 __attribute__((unused)) struct cmdline *cl,
4644 struct cmd_set_allmulti_mode_result *res = parsed_result;
4648 if (!strcmp(res->mode, "on"))
4655 FOREACH_PORT(i, ports) {
4657 rte_eth_allmulticast_enable(i);
4659 rte_eth_allmulticast_disable(i);
4664 rte_eth_allmulticast_enable(res->port_num);
4666 rte_eth_allmulticast_disable(res->port_num);
4670 cmdline_parse_token_string_t cmd_setallmulti_set =
4671 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4672 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4673 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4675 cmdline_parse_token_string_t cmd_setallmulti_portall =
4676 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4678 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4679 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4681 cmdline_parse_token_string_t cmd_setallmulti_mode =
4682 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4685 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4686 .f = cmd_set_allmulti_mode_parsed,
4688 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4690 (void *)&cmd_setallmulti_set,
4691 (void *)&cmd_setallmulti_allmulti,
4692 (void *)&cmd_setallmulti_portall,
4693 (void *)&cmd_setallmulti_mode,
4698 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4699 .f = cmd_set_allmulti_mode_parsed,
4701 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4703 (void *)&cmd_setallmulti_set,
4704 (void *)&cmd_setallmulti_allmulti,
4705 (void *)&cmd_setallmulti_portnum,
4706 (void *)&cmd_setallmulti_mode,
4711 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4712 struct cmd_link_flow_ctrl_set_result {
4713 cmdline_fixed_string_t set;
4714 cmdline_fixed_string_t flow_ctrl;
4715 cmdline_fixed_string_t rx;
4716 cmdline_fixed_string_t rx_lfc_mode;
4717 cmdline_fixed_string_t tx;
4718 cmdline_fixed_string_t tx_lfc_mode;
4719 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4720 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4721 cmdline_fixed_string_t autoneg_str;
4722 cmdline_fixed_string_t autoneg;
4723 cmdline_fixed_string_t hw_str;
4724 uint32_t high_water;
4725 cmdline_fixed_string_t lw_str;
4727 cmdline_fixed_string_t pt_str;
4728 uint16_t pause_time;
4729 cmdline_fixed_string_t xon_str;
4734 cmdline_parse_token_string_t cmd_lfc_set_set =
4735 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4737 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4738 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4739 flow_ctrl, "flow_ctrl");
4740 cmdline_parse_token_string_t cmd_lfc_set_rx =
4741 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4743 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4744 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4745 rx_lfc_mode, "on#off");
4746 cmdline_parse_token_string_t cmd_lfc_set_tx =
4747 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4749 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4750 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4751 tx_lfc_mode, "on#off");
4752 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4753 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4754 hw_str, "high_water");
4755 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4756 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4757 high_water, UINT32);
4758 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4759 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4760 lw_str, "low_water");
4761 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4762 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4764 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4765 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4766 pt_str, "pause_time");
4767 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4768 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4769 pause_time, UINT16);
4770 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4771 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4772 xon_str, "send_xon");
4773 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4774 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4776 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4777 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4778 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4779 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4780 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4781 mac_ctrl_frame_fwd_mode, "on#off");
4782 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4783 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4784 autoneg_str, "autoneg");
4785 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4786 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4788 cmdline_parse_token_num_t cmd_lfc_set_portid =
4789 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4792 /* forward declaration */
4794 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4797 cmdline_parse_inst_t cmd_link_flow_control_set = {
4798 .f = cmd_link_flow_ctrl_set_parsed,
4800 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4801 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4802 autoneg on|off port_id",
4804 (void *)&cmd_lfc_set_set,
4805 (void *)&cmd_lfc_set_flow_ctrl,
4806 (void *)&cmd_lfc_set_rx,
4807 (void *)&cmd_lfc_set_rx_mode,
4808 (void *)&cmd_lfc_set_tx,
4809 (void *)&cmd_lfc_set_tx_mode,
4810 (void *)&cmd_lfc_set_high_water,
4811 (void *)&cmd_lfc_set_low_water,
4812 (void *)&cmd_lfc_set_pause_time,
4813 (void *)&cmd_lfc_set_send_xon,
4814 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4815 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4816 (void *)&cmd_lfc_set_autoneg_str,
4817 (void *)&cmd_lfc_set_autoneg,
4818 (void *)&cmd_lfc_set_portid,
4823 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4824 .f = cmd_link_flow_ctrl_set_parsed,
4825 .data = (void *)&cmd_link_flow_control_set_rx,
4826 .help_str = "Change rx flow control parameter: set flow_ctrl "
4827 "rx on|off port_id",
4829 (void *)&cmd_lfc_set_set,
4830 (void *)&cmd_lfc_set_flow_ctrl,
4831 (void *)&cmd_lfc_set_rx,
4832 (void *)&cmd_lfc_set_rx_mode,
4833 (void *)&cmd_lfc_set_portid,
4838 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4839 .f = cmd_link_flow_ctrl_set_parsed,
4840 .data = (void *)&cmd_link_flow_control_set_tx,
4841 .help_str = "Change tx flow control parameter: set flow_ctrl "
4842 "tx on|off port_id",
4844 (void *)&cmd_lfc_set_set,
4845 (void *)&cmd_lfc_set_flow_ctrl,
4846 (void *)&cmd_lfc_set_tx,
4847 (void *)&cmd_lfc_set_tx_mode,
4848 (void *)&cmd_lfc_set_portid,
4853 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4854 .f = cmd_link_flow_ctrl_set_parsed,
4855 .data = (void *)&cmd_link_flow_control_set_hw,
4856 .help_str = "Change high water flow control parameter: set flow_ctrl "
4857 "high_water value port_id",
4859 (void *)&cmd_lfc_set_set,
4860 (void *)&cmd_lfc_set_flow_ctrl,
4861 (void *)&cmd_lfc_set_high_water_str,
4862 (void *)&cmd_lfc_set_high_water,
4863 (void *)&cmd_lfc_set_portid,
4868 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4869 .f = cmd_link_flow_ctrl_set_parsed,
4870 .data = (void *)&cmd_link_flow_control_set_lw,
4871 .help_str = "Change low water flow control parameter: set flow_ctrl "
4872 "low_water value port_id",
4874 (void *)&cmd_lfc_set_set,
4875 (void *)&cmd_lfc_set_flow_ctrl,
4876 (void *)&cmd_lfc_set_low_water_str,
4877 (void *)&cmd_lfc_set_low_water,
4878 (void *)&cmd_lfc_set_portid,
4883 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4884 .f = cmd_link_flow_ctrl_set_parsed,
4885 .data = (void *)&cmd_link_flow_control_set_pt,
4886 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4887 "pause_time value port_id",
4889 (void *)&cmd_lfc_set_set,
4890 (void *)&cmd_lfc_set_flow_ctrl,
4891 (void *)&cmd_lfc_set_pause_time_str,
4892 (void *)&cmd_lfc_set_pause_time,
4893 (void *)&cmd_lfc_set_portid,
4898 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4899 .f = cmd_link_flow_ctrl_set_parsed,
4900 .data = (void *)&cmd_link_flow_control_set_xon,
4901 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4902 "send_xon value port_id",
4904 (void *)&cmd_lfc_set_set,
4905 (void *)&cmd_lfc_set_flow_ctrl,
4906 (void *)&cmd_lfc_set_send_xon_str,
4907 (void *)&cmd_lfc_set_send_xon,
4908 (void *)&cmd_lfc_set_portid,
4913 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4914 .f = cmd_link_flow_ctrl_set_parsed,
4915 .data = (void *)&cmd_link_flow_control_set_macfwd,
4916 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4917 "mac_ctrl_frame_fwd on|off port_id",
4919 (void *)&cmd_lfc_set_set,
4920 (void *)&cmd_lfc_set_flow_ctrl,
4921 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4922 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4923 (void *)&cmd_lfc_set_portid,
4928 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4929 .f = cmd_link_flow_ctrl_set_parsed,
4930 .data = (void *)&cmd_link_flow_control_set_autoneg,
4931 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4932 "autoneg on|off port_id",
4934 (void *)&cmd_lfc_set_set,
4935 (void *)&cmd_lfc_set_flow_ctrl,
4936 (void *)&cmd_lfc_set_autoneg_str,
4937 (void *)&cmd_lfc_set_autoneg,
4938 (void *)&cmd_lfc_set_portid,
4944 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4945 __attribute__((unused)) struct cmdline *cl,
4948 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4949 cmdline_parse_inst_t *cmd = data;
4950 struct rte_eth_fc_conf fc_conf;
4956 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4957 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4958 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4959 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4961 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4962 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4965 /* Partial command line, retrieve current configuration */
4967 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4969 printf("cannot get current flow ctrl parameters, return"
4970 "code = %d\n", ret);
4974 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4975 (fc_conf.mode == RTE_FC_FULL))
4977 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4978 (fc_conf.mode == RTE_FC_FULL))
4982 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4983 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4985 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4986 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4988 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4990 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4991 fc_conf.high_water = res->high_water;
4993 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4994 fc_conf.low_water = res->low_water;
4996 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4997 fc_conf.pause_time = res->pause_time;
4999 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5000 fc_conf.send_xon = res->send_xon;
5002 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5003 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5004 fc_conf.mac_ctrl_frame_fwd = 1;
5006 fc_conf.mac_ctrl_frame_fwd = 0;
5009 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5010 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5012 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5014 printf("bad flow contrl parameter, return code = %d \n", ret);
5017 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5018 struct cmd_priority_flow_ctrl_set_result {
5019 cmdline_fixed_string_t set;
5020 cmdline_fixed_string_t pfc_ctrl;
5021 cmdline_fixed_string_t rx;
5022 cmdline_fixed_string_t rx_pfc_mode;
5023 cmdline_fixed_string_t tx;
5024 cmdline_fixed_string_t tx_pfc_mode;
5025 uint32_t high_water;
5027 uint16_t pause_time;
5033 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5034 __attribute__((unused)) struct cmdline *cl,
5035 __attribute__((unused)) void *data)
5037 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5038 struct rte_eth_pfc_conf pfc_conf;
5039 int rx_fc_enable, tx_fc_enable;
5043 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5044 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5045 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5046 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5048 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5049 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5052 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5053 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5054 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5055 pfc_conf.fc.high_water = res->high_water;
5056 pfc_conf.fc.low_water = res->low_water;
5057 pfc_conf.fc.pause_time = res->pause_time;
5058 pfc_conf.priority = res->priority;
5060 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5062 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5065 cmdline_parse_token_string_t cmd_pfc_set_set =
5066 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5068 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5069 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5070 pfc_ctrl, "pfc_ctrl");
5071 cmdline_parse_token_string_t cmd_pfc_set_rx =
5072 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5074 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5075 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5076 rx_pfc_mode, "on#off");
5077 cmdline_parse_token_string_t cmd_pfc_set_tx =
5078 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5080 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5081 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5082 tx_pfc_mode, "on#off");
5083 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5084 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5085 high_water, UINT32);
5086 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5087 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5089 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5090 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5091 pause_time, UINT16);
5092 cmdline_parse_token_num_t cmd_pfc_set_priority =
5093 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5095 cmdline_parse_token_num_t cmd_pfc_set_portid =
5096 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5099 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5100 .f = cmd_priority_flow_ctrl_set_parsed,
5102 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5103 tx on|off high_water low_water pause_time priority port_id",
5105 (void *)&cmd_pfc_set_set,
5106 (void *)&cmd_pfc_set_flow_ctrl,
5107 (void *)&cmd_pfc_set_rx,
5108 (void *)&cmd_pfc_set_rx_mode,
5109 (void *)&cmd_pfc_set_tx,
5110 (void *)&cmd_pfc_set_tx_mode,
5111 (void *)&cmd_pfc_set_high_water,
5112 (void *)&cmd_pfc_set_low_water,
5113 (void *)&cmd_pfc_set_pause_time,
5114 (void *)&cmd_pfc_set_priority,
5115 (void *)&cmd_pfc_set_portid,
5120 /* *** RESET CONFIGURATION *** */
5121 struct cmd_reset_result {
5122 cmdline_fixed_string_t reset;
5123 cmdline_fixed_string_t def;
5126 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5128 __attribute__((unused)) void *data)
5130 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5131 set_def_fwd_config();
5134 cmdline_parse_token_string_t cmd_reset_set =
5135 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5136 cmdline_parse_token_string_t cmd_reset_def =
5137 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5140 cmdline_parse_inst_t cmd_reset = {
5141 .f = cmd_reset_parsed,
5143 .help_str = "set default: reset default forwarding configuration",
5145 (void *)&cmd_reset_set,
5146 (void *)&cmd_reset_def,
5151 /* *** START FORWARDING *** */
5152 struct cmd_start_result {
5153 cmdline_fixed_string_t start;
5156 cmdline_parse_token_string_t cmd_start_start =
5157 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5159 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5160 __attribute__((unused)) struct cmdline *cl,
5161 __attribute__((unused)) void *data)
5163 start_packet_forwarding(0);
5166 cmdline_parse_inst_t cmd_start = {
5167 .f = cmd_start_parsed,
5169 .help_str = "start packet forwarding",
5171 (void *)&cmd_start_start,
5176 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5177 struct cmd_start_tx_first_result {
5178 cmdline_fixed_string_t start;
5179 cmdline_fixed_string_t tx_first;
5183 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5184 __attribute__((unused)) struct cmdline *cl,
5185 __attribute__((unused)) void *data)
5187 start_packet_forwarding(1);
5190 cmdline_parse_token_string_t cmd_start_tx_first_start =
5191 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5193 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5194 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5195 tx_first, "tx_first");
5197 cmdline_parse_inst_t cmd_start_tx_first = {
5198 .f = cmd_start_tx_first_parsed,
5200 .help_str = "start packet forwarding, after sending 1 burst of packets",
5202 (void *)&cmd_start_tx_first_start,
5203 (void *)&cmd_start_tx_first_tx_first,
5208 /* *** SET LINK UP *** */
5209 struct cmd_set_link_up_result {
5210 cmdline_fixed_string_t set;
5211 cmdline_fixed_string_t link_up;
5212 cmdline_fixed_string_t port;
5216 cmdline_parse_token_string_t cmd_set_link_up_set =
5217 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5218 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5219 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5221 cmdline_parse_token_string_t cmd_set_link_up_port =
5222 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5223 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5224 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5226 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5227 __attribute__((unused)) struct cmdline *cl,
5228 __attribute__((unused)) void *data)
5230 struct cmd_set_link_up_result *res = parsed_result;
5231 dev_set_link_up(res->port_id);
5234 cmdline_parse_inst_t cmd_set_link_up = {
5235 .f = cmd_set_link_up_parsed,
5237 .help_str = "set link-up port (port id)",
5239 (void *)&cmd_set_link_up_set,
5240 (void *)&cmd_set_link_up_link_up,
5241 (void *)&cmd_set_link_up_port,
5242 (void *)&cmd_set_link_up_port_id,
5247 /* *** SET LINK DOWN *** */
5248 struct cmd_set_link_down_result {
5249 cmdline_fixed_string_t set;
5250 cmdline_fixed_string_t link_down;
5251 cmdline_fixed_string_t port;
5255 cmdline_parse_token_string_t cmd_set_link_down_set =
5256 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5257 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5258 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5260 cmdline_parse_token_string_t cmd_set_link_down_port =
5261 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5262 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5263 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5265 static void cmd_set_link_down_parsed(
5266 __attribute__((unused)) void *parsed_result,
5267 __attribute__((unused)) struct cmdline *cl,
5268 __attribute__((unused)) void *data)
5270 struct cmd_set_link_down_result *res = parsed_result;
5271 dev_set_link_down(res->port_id);
5274 cmdline_parse_inst_t cmd_set_link_down = {
5275 .f = cmd_set_link_down_parsed,
5277 .help_str = "set link-down port (port id)",
5279 (void *)&cmd_set_link_down_set,
5280 (void *)&cmd_set_link_down_link_down,
5281 (void *)&cmd_set_link_down_port,
5282 (void *)&cmd_set_link_down_port_id,
5287 /* *** SHOW CFG *** */
5288 struct cmd_showcfg_result {
5289 cmdline_fixed_string_t show;
5290 cmdline_fixed_string_t cfg;
5291 cmdline_fixed_string_t what;
5294 static void cmd_showcfg_parsed(void *parsed_result,
5295 __attribute__((unused)) struct cmdline *cl,
5296 __attribute__((unused)) void *data)
5298 struct cmd_showcfg_result *res = parsed_result;
5299 if (!strcmp(res->what, "rxtx"))
5300 rxtx_config_display();
5301 else if (!strcmp(res->what, "cores"))
5302 fwd_lcores_config_display();
5303 else if (!strcmp(res->what, "fwd"))
5304 fwd_config_display();
5305 else if (!strcmp(res->what, "txpkts"))
5306 show_tx_pkt_segments();
5309 cmdline_parse_token_string_t cmd_showcfg_show =
5310 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5311 cmdline_parse_token_string_t cmd_showcfg_port =
5312 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5313 cmdline_parse_token_string_t cmd_showcfg_what =
5314 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5315 "rxtx#cores#fwd#txpkts");
5317 cmdline_parse_inst_t cmd_showcfg = {
5318 .f = cmd_showcfg_parsed,
5320 .help_str = "show config rxtx|cores|fwd|txpkts",
5322 (void *)&cmd_showcfg_show,
5323 (void *)&cmd_showcfg_port,
5324 (void *)&cmd_showcfg_what,
5329 /* *** SHOW ALL PORT INFO *** */
5330 struct cmd_showportall_result {
5331 cmdline_fixed_string_t show;
5332 cmdline_fixed_string_t port;
5333 cmdline_fixed_string_t what;
5334 cmdline_fixed_string_t all;
5337 static void cmd_showportall_parsed(void *parsed_result,
5338 __attribute__((unused)) struct cmdline *cl,
5339 __attribute__((unused)) void *data)
5343 struct cmd_showportall_result *res = parsed_result;
5344 if (!strcmp(res->show, "clear")) {
5345 if (!strcmp(res->what, "stats"))
5346 FOREACH_PORT(i, ports)
5348 else if (!strcmp(res->what, "xstats"))
5349 FOREACH_PORT(i, ports)
5350 nic_xstats_clear(i);
5351 } else if (!strcmp(res->what, "info"))
5352 FOREACH_PORT(i, ports)
5353 port_infos_display(i);
5354 else if (!strcmp(res->what, "stats"))
5355 FOREACH_PORT(i, ports)
5356 nic_stats_display(i);
5357 else if (!strcmp(res->what, "xstats"))
5358 FOREACH_PORT(i, ports)
5359 nic_xstats_display(i);
5360 else if (!strcmp(res->what, "fdir"))
5361 FOREACH_PORT(i, ports)
5363 else if (!strcmp(res->what, "stat_qmap"))
5364 FOREACH_PORT(i, ports)
5365 nic_stats_mapping_display(i);
5366 else if (!strcmp(res->what, "dcb_tc"))
5367 FOREACH_PORT(i, ports)
5368 port_dcb_info_display(i);
5371 cmdline_parse_token_string_t cmd_showportall_show =
5372 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5374 cmdline_parse_token_string_t cmd_showportall_port =
5375 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5376 cmdline_parse_token_string_t cmd_showportall_what =
5377 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5378 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5379 cmdline_parse_token_string_t cmd_showportall_all =
5380 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5381 cmdline_parse_inst_t cmd_showportall = {
5382 .f = cmd_showportall_parsed,
5384 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5386 (void *)&cmd_showportall_show,
5387 (void *)&cmd_showportall_port,
5388 (void *)&cmd_showportall_what,
5389 (void *)&cmd_showportall_all,
5394 /* *** SHOW PORT INFO *** */
5395 struct cmd_showport_result {
5396 cmdline_fixed_string_t show;
5397 cmdline_fixed_string_t port;
5398 cmdline_fixed_string_t what;
5402 static void cmd_showport_parsed(void *parsed_result,
5403 __attribute__((unused)) struct cmdline *cl,
5404 __attribute__((unused)) void *data)
5406 struct cmd_showport_result *res = parsed_result;
5407 if (!strcmp(res->show, "clear")) {
5408 if (!strcmp(res->what, "stats"))
5409 nic_stats_clear(res->portnum);
5410 else if (!strcmp(res->what, "xstats"))
5411 nic_xstats_clear(res->portnum);
5412 } else if (!strcmp(res->what, "info"))
5413 port_infos_display(res->portnum);
5414 else if (!strcmp(res->what, "stats"))
5415 nic_stats_display(res->portnum);
5416 else if (!strcmp(res->what, "xstats"))
5417 nic_xstats_display(res->portnum);
5418 else if (!strcmp(res->what, "fdir"))
5419 fdir_get_infos(res->portnum);
5420 else if (!strcmp(res->what, "stat_qmap"))
5421 nic_stats_mapping_display(res->portnum);
5422 else if (!strcmp(res->what, "dcb_tc"))
5423 port_dcb_info_display(res->portnum);
5426 cmdline_parse_token_string_t cmd_showport_show =
5427 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5429 cmdline_parse_token_string_t cmd_showport_port =
5430 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5431 cmdline_parse_token_string_t cmd_showport_what =
5432 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5433 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5434 cmdline_parse_token_num_t cmd_showport_portnum =
5435 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5437 cmdline_parse_inst_t cmd_showport = {
5438 .f = cmd_showport_parsed,
5440 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5442 (void *)&cmd_showport_show,
5443 (void *)&cmd_showport_port,
5444 (void *)&cmd_showport_what,
5445 (void *)&cmd_showport_portnum,
5450 /* *** SHOW QUEUE INFO *** */
5451 struct cmd_showqueue_result {
5452 cmdline_fixed_string_t show;
5453 cmdline_fixed_string_t type;
5454 cmdline_fixed_string_t what;
5460 cmd_showqueue_parsed(void *parsed_result,
5461 __attribute__((unused)) struct cmdline *cl,
5462 __attribute__((unused)) void *data)
5464 struct cmd_showqueue_result *res = parsed_result;
5466 if (!strcmp(res->type, "rxq"))
5467 rx_queue_infos_display(res->portnum, res->queuenum);
5468 else if (!strcmp(res->type, "txq"))
5469 tx_queue_infos_display(res->portnum, res->queuenum);
5472 cmdline_parse_token_string_t cmd_showqueue_show =
5473 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5474 cmdline_parse_token_string_t cmd_showqueue_type =
5475 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5476 cmdline_parse_token_string_t cmd_showqueue_what =
5477 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5478 cmdline_parse_token_num_t cmd_showqueue_portnum =
5479 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5480 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5481 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5483 cmdline_parse_inst_t cmd_showqueue = {
5484 .f = cmd_showqueue_parsed,
5486 .help_str = "show rxq|txq info <port number> <queue_number>",
5488 (void *)&cmd_showqueue_show,
5489 (void *)&cmd_showqueue_type,
5490 (void *)&cmd_showqueue_what,
5491 (void *)&cmd_showqueue_portnum,
5492 (void *)&cmd_showqueue_queuenum,
5497 /* *** READ PORT REGISTER *** */
5498 struct cmd_read_reg_result {
5499 cmdline_fixed_string_t read;
5500 cmdline_fixed_string_t reg;
5506 cmd_read_reg_parsed(void *parsed_result,
5507 __attribute__((unused)) struct cmdline *cl,
5508 __attribute__((unused)) void *data)
5510 struct cmd_read_reg_result *res = parsed_result;
5511 port_reg_display(res->port_id, res->reg_off);
5514 cmdline_parse_token_string_t cmd_read_reg_read =
5515 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5516 cmdline_parse_token_string_t cmd_read_reg_reg =
5517 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5518 cmdline_parse_token_num_t cmd_read_reg_port_id =
5519 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5520 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5521 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5523 cmdline_parse_inst_t cmd_read_reg = {
5524 .f = cmd_read_reg_parsed,
5526 .help_str = "read reg port_id reg_off",
5528 (void *)&cmd_read_reg_read,
5529 (void *)&cmd_read_reg_reg,
5530 (void *)&cmd_read_reg_port_id,
5531 (void *)&cmd_read_reg_reg_off,
5536 /* *** READ PORT REGISTER BIT FIELD *** */
5537 struct cmd_read_reg_bit_field_result {
5538 cmdline_fixed_string_t read;
5539 cmdline_fixed_string_t regfield;
5547 cmd_read_reg_bit_field_parsed(void *parsed_result,
5548 __attribute__((unused)) struct cmdline *cl,
5549 __attribute__((unused)) void *data)
5551 struct cmd_read_reg_bit_field_result *res = parsed_result;
5552 port_reg_bit_field_display(res->port_id, res->reg_off,
5553 res->bit1_pos, res->bit2_pos);
5556 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5557 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5559 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5560 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5561 regfield, "regfield");
5562 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5563 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5565 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5566 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5568 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5569 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5571 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5572 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5575 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5576 .f = cmd_read_reg_bit_field_parsed,
5578 .help_str = "read regfield port_id reg_off bit_x bit_y "
5579 "(read register bit field between bit_x and bit_y included)",
5581 (void *)&cmd_read_reg_bit_field_read,
5582 (void *)&cmd_read_reg_bit_field_regfield,
5583 (void *)&cmd_read_reg_bit_field_port_id,
5584 (void *)&cmd_read_reg_bit_field_reg_off,
5585 (void *)&cmd_read_reg_bit_field_bit1_pos,
5586 (void *)&cmd_read_reg_bit_field_bit2_pos,
5591 /* *** READ PORT REGISTER BIT *** */
5592 struct cmd_read_reg_bit_result {
5593 cmdline_fixed_string_t read;
5594 cmdline_fixed_string_t regbit;
5601 cmd_read_reg_bit_parsed(void *parsed_result,
5602 __attribute__((unused)) struct cmdline *cl,
5603 __attribute__((unused)) void *data)
5605 struct cmd_read_reg_bit_result *res = parsed_result;
5606 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5609 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5610 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5611 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5612 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5614 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5615 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5616 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5617 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5618 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5619 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5621 cmdline_parse_inst_t cmd_read_reg_bit = {
5622 .f = cmd_read_reg_bit_parsed,
5624 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5626 (void *)&cmd_read_reg_bit_read,
5627 (void *)&cmd_read_reg_bit_regbit,
5628 (void *)&cmd_read_reg_bit_port_id,
5629 (void *)&cmd_read_reg_bit_reg_off,
5630 (void *)&cmd_read_reg_bit_bit_pos,
5635 /* *** WRITE PORT REGISTER *** */
5636 struct cmd_write_reg_result {
5637 cmdline_fixed_string_t write;
5638 cmdline_fixed_string_t reg;
5645 cmd_write_reg_parsed(void *parsed_result,
5646 __attribute__((unused)) struct cmdline *cl,
5647 __attribute__((unused)) void *data)
5649 struct cmd_write_reg_result *res = parsed_result;
5650 port_reg_set(res->port_id, res->reg_off, res->value);
5653 cmdline_parse_token_string_t cmd_write_reg_write =
5654 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5655 cmdline_parse_token_string_t cmd_write_reg_reg =
5656 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5657 cmdline_parse_token_num_t cmd_write_reg_port_id =
5658 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5659 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5660 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5661 cmdline_parse_token_num_t cmd_write_reg_value =
5662 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5664 cmdline_parse_inst_t cmd_write_reg = {
5665 .f = cmd_write_reg_parsed,
5667 .help_str = "write reg port_id reg_off reg_value",
5669 (void *)&cmd_write_reg_write,
5670 (void *)&cmd_write_reg_reg,
5671 (void *)&cmd_write_reg_port_id,
5672 (void *)&cmd_write_reg_reg_off,
5673 (void *)&cmd_write_reg_value,
5678 /* *** WRITE PORT REGISTER BIT FIELD *** */
5679 struct cmd_write_reg_bit_field_result {
5680 cmdline_fixed_string_t write;
5681 cmdline_fixed_string_t regfield;
5690 cmd_write_reg_bit_field_parsed(void *parsed_result,
5691 __attribute__((unused)) struct cmdline *cl,
5692 __attribute__((unused)) void *data)
5694 struct cmd_write_reg_bit_field_result *res = parsed_result;
5695 port_reg_bit_field_set(res->port_id, res->reg_off,
5696 res->bit1_pos, res->bit2_pos, res->value);
5699 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5700 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5702 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5703 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5704 regfield, "regfield");
5705 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5706 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5708 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5709 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5711 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5712 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5714 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5715 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5717 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5718 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5721 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5722 .f = cmd_write_reg_bit_field_parsed,
5724 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5725 "(set register bit field between bit_x and bit_y included)",
5727 (void *)&cmd_write_reg_bit_field_write,
5728 (void *)&cmd_write_reg_bit_field_regfield,
5729 (void *)&cmd_write_reg_bit_field_port_id,
5730 (void *)&cmd_write_reg_bit_field_reg_off,
5731 (void *)&cmd_write_reg_bit_field_bit1_pos,
5732 (void *)&cmd_write_reg_bit_field_bit2_pos,
5733 (void *)&cmd_write_reg_bit_field_value,
5738 /* *** WRITE PORT REGISTER BIT *** */
5739 struct cmd_write_reg_bit_result {
5740 cmdline_fixed_string_t write;
5741 cmdline_fixed_string_t regbit;
5749 cmd_write_reg_bit_parsed(void *parsed_result,
5750 __attribute__((unused)) struct cmdline *cl,
5751 __attribute__((unused)) void *data)
5753 struct cmd_write_reg_bit_result *res = parsed_result;
5754 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5757 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5758 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5760 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5761 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5763 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5764 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5765 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5766 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5767 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5768 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5769 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5770 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5772 cmdline_parse_inst_t cmd_write_reg_bit = {
5773 .f = cmd_write_reg_bit_parsed,
5775 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5777 (void *)&cmd_write_reg_bit_write,
5778 (void *)&cmd_write_reg_bit_regbit,
5779 (void *)&cmd_write_reg_bit_port_id,
5780 (void *)&cmd_write_reg_bit_reg_off,
5781 (void *)&cmd_write_reg_bit_bit_pos,
5782 (void *)&cmd_write_reg_bit_value,
5787 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5788 struct cmd_read_rxd_txd_result {
5789 cmdline_fixed_string_t read;
5790 cmdline_fixed_string_t rxd_txd;
5797 cmd_read_rxd_txd_parsed(void *parsed_result,
5798 __attribute__((unused)) struct cmdline *cl,
5799 __attribute__((unused)) void *data)
5801 struct cmd_read_rxd_txd_result *res = parsed_result;
5803 if (!strcmp(res->rxd_txd, "rxd"))
5804 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5805 else if (!strcmp(res->rxd_txd, "txd"))
5806 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5809 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5810 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5811 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5812 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5814 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5815 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5816 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5817 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5818 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5819 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5821 cmdline_parse_inst_t cmd_read_rxd_txd = {
5822 .f = cmd_read_rxd_txd_parsed,
5824 .help_str = "read rxd|txd port_id queue_id rxd_id",
5826 (void *)&cmd_read_rxd_txd_read,
5827 (void *)&cmd_read_rxd_txd_rxd_txd,
5828 (void *)&cmd_read_rxd_txd_port_id,
5829 (void *)&cmd_read_rxd_txd_queue_id,
5830 (void *)&cmd_read_rxd_txd_desc_id,
5836 struct cmd_quit_result {
5837 cmdline_fixed_string_t quit;
5840 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5842 __attribute__((unused)) void *data)
5848 cmdline_parse_token_string_t cmd_quit_quit =
5849 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5851 cmdline_parse_inst_t cmd_quit = {
5852 .f = cmd_quit_parsed,
5854 .help_str = "exit application",
5856 (void *)&cmd_quit_quit,
5861 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5862 struct cmd_mac_addr_result {
5863 cmdline_fixed_string_t mac_addr_cmd;
5864 cmdline_fixed_string_t what;
5866 struct ether_addr address;
5869 static void cmd_mac_addr_parsed(void *parsed_result,
5870 __attribute__((unused)) struct cmdline *cl,
5871 __attribute__((unused)) void *data)
5873 struct cmd_mac_addr_result *res = parsed_result;
5876 if (strcmp(res->what, "add") == 0)
5877 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5879 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5881 /* check the return value and print it if is < 0 */
5883 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5887 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5888 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5890 cmdline_parse_token_string_t cmd_mac_addr_what =
5891 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5893 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5894 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5895 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5896 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5898 cmdline_parse_inst_t cmd_mac_addr = {
5899 .f = cmd_mac_addr_parsed,
5901 .help_str = "mac_addr add|remove X <address>: "
5902 "add/remove MAC address on port X",
5904 (void *)&cmd_mac_addr_cmd,
5905 (void *)&cmd_mac_addr_what,
5906 (void *)&cmd_mac_addr_portnum,
5907 (void *)&cmd_mac_addr_addr,
5913 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5914 struct cmd_set_qmap_result {
5915 cmdline_fixed_string_t set;
5916 cmdline_fixed_string_t qmap;
5917 cmdline_fixed_string_t what;
5924 cmd_set_qmap_parsed(void *parsed_result,
5925 __attribute__((unused)) struct cmdline *cl,
5926 __attribute__((unused)) void *data)
5928 struct cmd_set_qmap_result *res = parsed_result;
5929 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5931 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5934 cmdline_parse_token_string_t cmd_setqmap_set =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5937 cmdline_parse_token_string_t cmd_setqmap_qmap =
5938 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5940 cmdline_parse_token_string_t cmd_setqmap_what =
5941 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5943 cmdline_parse_token_num_t cmd_setqmap_portid =
5944 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5946 cmdline_parse_token_num_t cmd_setqmap_queueid =
5947 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5949 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5950 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5953 cmdline_parse_inst_t cmd_set_qmap = {
5954 .f = cmd_set_qmap_parsed,
5956 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5958 (void *)&cmd_setqmap_set,
5959 (void *)&cmd_setqmap_qmap,
5960 (void *)&cmd_setqmap_what,
5961 (void *)&cmd_setqmap_portid,
5962 (void *)&cmd_setqmap_queueid,
5963 (void *)&cmd_setqmap_mapvalue,
5968 /* *** CONFIGURE UNICAST HASH TABLE *** */
5969 struct cmd_set_uc_hash_table {
5970 cmdline_fixed_string_t set;
5971 cmdline_fixed_string_t port;
5973 cmdline_fixed_string_t what;
5974 struct ether_addr address;
5975 cmdline_fixed_string_t mode;
5979 cmd_set_uc_hash_parsed(void *parsed_result,
5980 __attribute__((unused)) struct cmdline *cl,
5981 __attribute__((unused)) void *data)
5984 struct cmd_set_uc_hash_table *res = parsed_result;
5986 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5988 if (strcmp(res->what, "uta") == 0)
5989 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5990 &res->address,(uint8_t)is_on);
5992 printf("bad unicast hash table parameter, return code = %d \n", ret);
5996 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5997 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5999 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6000 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6002 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6003 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6005 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6006 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6008 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6009 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6011 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6012 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6015 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6016 .f = cmd_set_uc_hash_parsed,
6018 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6020 (void *)&cmd_set_uc_hash_set,
6021 (void *)&cmd_set_uc_hash_port,
6022 (void *)&cmd_set_uc_hash_portid,
6023 (void *)&cmd_set_uc_hash_what,
6024 (void *)&cmd_set_uc_hash_mac,
6025 (void *)&cmd_set_uc_hash_mode,
6030 struct cmd_set_uc_all_hash_table {
6031 cmdline_fixed_string_t set;
6032 cmdline_fixed_string_t port;
6034 cmdline_fixed_string_t what;
6035 cmdline_fixed_string_t value;
6036 cmdline_fixed_string_t mode;
6040 cmd_set_uc_all_hash_parsed(void *parsed_result,
6041 __attribute__((unused)) struct cmdline *cl,
6042 __attribute__((unused)) void *data)
6045 struct cmd_set_uc_all_hash_table *res = parsed_result;
6047 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6049 if ((strcmp(res->what, "uta") == 0) &&
6050 (strcmp(res->value, "all") == 0))
6051 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6053 printf("bad unicast hash table parameter,"
6054 "return code = %d \n", ret);
6057 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6058 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6060 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6061 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6063 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6064 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6066 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6067 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6069 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6070 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6072 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6073 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6076 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6077 .f = cmd_set_uc_all_hash_parsed,
6079 .help_str = "set port X uta all on|off (X = port number)",
6081 (void *)&cmd_set_uc_all_hash_set,
6082 (void *)&cmd_set_uc_all_hash_port,
6083 (void *)&cmd_set_uc_all_hash_portid,
6084 (void *)&cmd_set_uc_all_hash_what,
6085 (void *)&cmd_set_uc_all_hash_value,
6086 (void *)&cmd_set_uc_all_hash_mode,
6091 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6092 struct cmd_set_vf_macvlan_filter {
6093 cmdline_fixed_string_t set;
6094 cmdline_fixed_string_t port;
6096 cmdline_fixed_string_t vf;
6098 struct ether_addr address;
6099 cmdline_fixed_string_t filter_type;
6100 cmdline_fixed_string_t mode;
6104 cmd_set_vf_macvlan_parsed(void *parsed_result,
6105 __attribute__((unused)) struct cmdline *cl,
6106 __attribute__((unused)) void *data)
6109 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6110 struct rte_eth_mac_filter filter;
6112 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6114 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6116 /* set VF MAC filter */
6120 filter.dst_id = res->vf_id;
6122 if (!strcmp(res->filter_type, "exact-mac"))
6123 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6124 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6125 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6126 else if (!strcmp(res->filter_type, "hashmac"))
6127 filter.filter_type = RTE_MAC_HASH_MATCH;
6128 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6129 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6131 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6134 ret = rte_eth_dev_filter_ctrl(res->port_id,
6135 RTE_ETH_FILTER_MACVLAN,
6139 ret = rte_eth_dev_filter_ctrl(res->port_id,
6140 RTE_ETH_FILTER_MACVLAN,
6141 RTE_ETH_FILTER_DELETE,
6145 printf("bad set MAC hash parameter, return code = %d\n", ret);
6149 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6150 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6152 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6153 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6155 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6156 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6158 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6159 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6161 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6162 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6164 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6165 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6167 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6168 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6169 filter_type, "exact-mac#exact-mac-vlan"
6170 "#hashmac#hashmac-vlan");
6171 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6172 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6175 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6176 .f = cmd_set_vf_macvlan_parsed,
6178 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6179 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6181 "exact match rule:exact match of MAC or MAC and VLAN; "
6182 "hash match rule: hash match of MAC and exact match "
6185 (void *)&cmd_set_vf_macvlan_set,
6186 (void *)&cmd_set_vf_macvlan_port,
6187 (void *)&cmd_set_vf_macvlan_portid,
6188 (void *)&cmd_set_vf_macvlan_vf,
6189 (void *)&cmd_set_vf_macvlan_vf_id,
6190 (void *)&cmd_set_vf_macvlan_mac,
6191 (void *)&cmd_set_vf_macvlan_filter_type,
6192 (void *)&cmd_set_vf_macvlan_mode,
6197 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6198 struct cmd_set_vf_traffic {
6199 cmdline_fixed_string_t set;
6200 cmdline_fixed_string_t port;
6202 cmdline_fixed_string_t vf;
6204 cmdline_fixed_string_t what;
6205 cmdline_fixed_string_t mode;
6209 cmd_set_vf_traffic_parsed(void *parsed_result,
6210 __attribute__((unused)) struct cmdline *cl,
6211 __attribute__((unused)) void *data)
6213 struct cmd_set_vf_traffic *res = parsed_result;
6214 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6215 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6217 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6220 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6221 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6223 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6224 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6226 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6227 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6229 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6230 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6232 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6233 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6235 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6236 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6238 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6239 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6242 cmdline_parse_inst_t cmd_set_vf_traffic = {
6243 .f = cmd_set_vf_traffic_parsed,
6245 .help_str = "set port X vf Y rx|tx on|off"
6246 "(X = port number,Y = vf id)",
6248 (void *)&cmd_setvf_traffic_set,
6249 (void *)&cmd_setvf_traffic_port,
6250 (void *)&cmd_setvf_traffic_portid,
6251 (void *)&cmd_setvf_traffic_vf,
6252 (void *)&cmd_setvf_traffic_vfid,
6253 (void *)&cmd_setvf_traffic_what,
6254 (void *)&cmd_setvf_traffic_mode,
6259 /* *** CONFIGURE VF RECEIVE MODE *** */
6260 struct cmd_set_vf_rxmode {
6261 cmdline_fixed_string_t set;
6262 cmdline_fixed_string_t port;
6264 cmdline_fixed_string_t vf;
6266 cmdline_fixed_string_t what;
6267 cmdline_fixed_string_t mode;
6268 cmdline_fixed_string_t on;
6272 cmd_set_vf_rxmode_parsed(void *parsed_result,
6273 __attribute__((unused)) struct cmdline *cl,
6274 __attribute__((unused)) void *data)
6277 uint16_t rx_mode = 0;
6278 struct cmd_set_vf_rxmode *res = parsed_result;
6280 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6281 if (!strcmp(res->what,"rxmode")) {
6282 if (!strcmp(res->mode, "AUPE"))
6283 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6284 else if (!strcmp(res->mode, "ROPE"))
6285 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6286 else if (!strcmp(res->mode, "BAM"))
6287 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6288 else if (!strncmp(res->mode, "MPE",3))
6289 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6292 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6294 printf("bad VF receive mode parameter, return code = %d \n",
6298 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6299 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6301 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6302 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6304 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6305 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6307 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6308 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6310 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6311 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6313 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6314 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6316 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6317 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6318 mode, "AUPE#ROPE#BAM#MPE");
6319 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6320 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6323 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6324 .f = cmd_set_vf_rxmode_parsed,
6326 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6328 (void *)&cmd_set_vf_rxmode_set,
6329 (void *)&cmd_set_vf_rxmode_port,
6330 (void *)&cmd_set_vf_rxmode_portid,
6331 (void *)&cmd_set_vf_rxmode_vf,
6332 (void *)&cmd_set_vf_rxmode_vfid,
6333 (void *)&cmd_set_vf_rxmode_what,
6334 (void *)&cmd_set_vf_rxmode_mode,
6335 (void *)&cmd_set_vf_rxmode_on,
6340 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6341 struct cmd_vf_mac_addr_result {
6342 cmdline_fixed_string_t mac_addr_cmd;
6343 cmdline_fixed_string_t what;
6344 cmdline_fixed_string_t port;
6346 cmdline_fixed_string_t vf;
6348 struct ether_addr address;
6351 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6352 __attribute__((unused)) struct cmdline *cl,
6353 __attribute__((unused)) void *data)
6355 struct cmd_vf_mac_addr_result *res = parsed_result;
6358 if (strcmp(res->what, "add") == 0)
6359 ret = rte_eth_dev_mac_addr_add(res->port_num,
6360 &res->address, res->vf_num);
6362 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6366 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6367 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6368 mac_addr_cmd,"mac_addr");
6369 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6370 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6372 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6373 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6375 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6376 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6378 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6379 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6381 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6382 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6384 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6385 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6388 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6389 .f = cmd_vf_mac_addr_parsed,
6391 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6392 "Y = VF number)add MAC address filtering for a VF on port X",
6394 (void *)&cmd_vf_mac_addr_cmd,
6395 (void *)&cmd_vf_mac_addr_what,
6396 (void *)&cmd_vf_mac_addr_port,
6397 (void *)&cmd_vf_mac_addr_portnum,
6398 (void *)&cmd_vf_mac_addr_vf,
6399 (void *)&cmd_vf_mac_addr_vfnum,
6400 (void *)&cmd_vf_mac_addr_addr,
6405 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6406 struct cmd_vf_rx_vlan_filter {
6407 cmdline_fixed_string_t rx_vlan;
6408 cmdline_fixed_string_t what;
6410 cmdline_fixed_string_t port;
6412 cmdline_fixed_string_t vf;
6417 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6418 __attribute__((unused)) struct cmdline *cl,
6419 __attribute__((unused)) void *data)
6421 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6423 if (!strcmp(res->what, "add"))
6424 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6426 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6429 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6430 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6431 rx_vlan, "rx_vlan");
6432 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6433 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6435 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6436 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6438 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6439 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6441 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6442 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6444 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6445 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6447 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6448 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6451 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6452 .f = cmd_vf_rx_vlan_filter_parsed,
6454 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6455 "Y = port number,Z = hexadecimal VF mask)",
6457 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6458 (void *)&cmd_vf_rx_vlan_filter_what,
6459 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6460 (void *)&cmd_vf_rx_vlan_filter_port,
6461 (void *)&cmd_vf_rx_vlan_filter_portid,
6462 (void *)&cmd_vf_rx_vlan_filter_vf,
6463 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6468 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6469 struct cmd_queue_rate_limit_result {
6470 cmdline_fixed_string_t set;
6471 cmdline_fixed_string_t port;
6473 cmdline_fixed_string_t queue;
6475 cmdline_fixed_string_t rate;
6479 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6480 __attribute__((unused)) struct cmdline *cl,
6481 __attribute__((unused)) void *data)
6483 struct cmd_queue_rate_limit_result *res = parsed_result;
6486 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6487 && (strcmp(res->queue, "queue") == 0)
6488 && (strcmp(res->rate, "rate") == 0))
6489 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6492 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6496 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6497 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6499 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6500 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6502 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6503 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6505 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6506 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6508 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6509 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6511 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6512 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6514 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6515 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6518 cmdline_parse_inst_t cmd_queue_rate_limit = {
6519 .f = cmd_queue_rate_limit_parsed,
6521 .help_str = "set port X queue Y rate Z:(X = port number,"
6522 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6524 (void *)&cmd_queue_rate_limit_set,
6525 (void *)&cmd_queue_rate_limit_port,
6526 (void *)&cmd_queue_rate_limit_portnum,
6527 (void *)&cmd_queue_rate_limit_queue,
6528 (void *)&cmd_queue_rate_limit_queuenum,
6529 (void *)&cmd_queue_rate_limit_rate,
6530 (void *)&cmd_queue_rate_limit_ratenum,
6535 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6536 struct cmd_vf_rate_limit_result {
6537 cmdline_fixed_string_t set;
6538 cmdline_fixed_string_t port;
6540 cmdline_fixed_string_t vf;
6542 cmdline_fixed_string_t rate;
6544 cmdline_fixed_string_t q_msk;
6548 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6549 __attribute__((unused)) struct cmdline *cl,
6550 __attribute__((unused)) void *data)
6552 struct cmd_vf_rate_limit_result *res = parsed_result;
6555 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6556 && (strcmp(res->vf, "vf") == 0)
6557 && (strcmp(res->rate, "rate") == 0)
6558 && (strcmp(res->q_msk, "queue_mask") == 0))
6559 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6560 res->rate_num, res->q_msk_val);
6562 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6566 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6567 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6569 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6570 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6572 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6573 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6575 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6576 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6578 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6579 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6581 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6582 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6584 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6585 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6587 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6588 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6589 q_msk, "queue_mask");
6590 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6591 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6594 cmdline_parse_inst_t cmd_vf_rate_limit = {
6595 .f = cmd_vf_rate_limit_parsed,
6597 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6598 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6599 "for queues of VF on port X",
6601 (void *)&cmd_vf_rate_limit_set,
6602 (void *)&cmd_vf_rate_limit_port,
6603 (void *)&cmd_vf_rate_limit_portnum,
6604 (void *)&cmd_vf_rate_limit_vf,
6605 (void *)&cmd_vf_rate_limit_vfnum,
6606 (void *)&cmd_vf_rate_limit_rate,
6607 (void *)&cmd_vf_rate_limit_ratenum,
6608 (void *)&cmd_vf_rate_limit_q_msk,
6609 (void *)&cmd_vf_rate_limit_q_msk_val,
6614 /* *** ADD TUNNEL FILTER OF A PORT *** */
6615 struct cmd_tunnel_filter_result {
6616 cmdline_fixed_string_t cmd;
6617 cmdline_fixed_string_t what;
6619 struct ether_addr outer_mac;
6620 struct ether_addr inner_mac;
6621 cmdline_ipaddr_t ip_value;
6622 uint16_t inner_vlan;
6623 cmdline_fixed_string_t tunnel_type;
6624 cmdline_fixed_string_t filter_type;
6630 cmd_tunnel_filter_parsed(void *parsed_result,
6631 __attribute__((unused)) struct cmdline *cl,
6632 __attribute__((unused)) void *data)
6634 struct cmd_tunnel_filter_result *res = parsed_result;
6635 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6638 tunnel_filter_conf.outer_mac = &res->outer_mac;
6639 tunnel_filter_conf.inner_mac = &res->inner_mac;
6640 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6642 if (res->ip_value.family == AF_INET) {
6643 tunnel_filter_conf.ip_addr.ipv4_addr =
6644 res->ip_value.addr.ipv4.s_addr;
6645 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6647 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6648 &(res->ip_value.addr.ipv6),
6649 sizeof(struct in6_addr));
6650 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6653 if (!strcmp(res->filter_type, "imac-ivlan"))
6654 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6655 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6656 tunnel_filter_conf.filter_type =
6657 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6658 else if (!strcmp(res->filter_type, "imac-tenid"))
6659 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6660 else if (!strcmp(res->filter_type, "imac"))
6661 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6662 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6663 tunnel_filter_conf.filter_type =
6664 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6666 printf("The filter type is not supported");
6670 if (!strcmp(res->tunnel_type, "vxlan"))
6671 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6672 else if (!strcmp(res->tunnel_type, "nvgre"))
6673 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6675 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6679 tunnel_filter_conf.tenant_id = res->tenant_id;
6680 tunnel_filter_conf.queue_id = res->queue_num;
6681 if (!strcmp(res->what, "add"))
6682 ret = rte_eth_dev_filter_ctrl(res->port_id,
6683 RTE_ETH_FILTER_TUNNEL,
6685 &tunnel_filter_conf);
6687 ret = rte_eth_dev_filter_ctrl(res->port_id,
6688 RTE_ETH_FILTER_TUNNEL,
6689 RTE_ETH_FILTER_DELETE,
6690 &tunnel_filter_conf);
6692 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6696 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6697 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6698 cmd, "tunnel_filter");
6699 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6700 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6702 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6703 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6705 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6706 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6708 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6709 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6711 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6712 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6713 inner_vlan, UINT16);
6714 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6715 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6717 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6718 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6719 tunnel_type, "vxlan#nvgre");
6721 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6722 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6723 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6724 "imac#omac-imac-tenid");
6725 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6726 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6728 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6729 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6732 cmdline_parse_inst_t cmd_tunnel_filter = {
6733 .f = cmd_tunnel_filter_parsed,
6735 .help_str = "add/rm tunnel filter of a port: "
6736 "tunnel_filter add port_id outer_mac inner_mac ip "
6737 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6738 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6739 "imac|omac-imac-tenid) "
6740 "tenant_id queue_num",
6742 (void *)&cmd_tunnel_filter_cmd,
6743 (void *)&cmd_tunnel_filter_what,
6744 (void *)&cmd_tunnel_filter_port_id,
6745 (void *)&cmd_tunnel_filter_outer_mac,
6746 (void *)&cmd_tunnel_filter_inner_mac,
6747 (void *)&cmd_tunnel_filter_ip_value,
6748 (void *)&cmd_tunnel_filter_innner_vlan,
6749 (void *)&cmd_tunnel_filter_tunnel_type,
6750 (void *)&cmd_tunnel_filter_filter_type,
6751 (void *)&cmd_tunnel_filter_tenant_id,
6752 (void *)&cmd_tunnel_filter_queue_num,
6757 /* *** CONFIGURE TUNNEL UDP PORT *** */
6758 struct cmd_tunnel_udp_config {
6759 cmdline_fixed_string_t cmd;
6760 cmdline_fixed_string_t what;
6766 cmd_tunnel_udp_config_parsed(void *parsed_result,
6767 __attribute__((unused)) struct cmdline *cl,
6768 __attribute__((unused)) void *data)
6770 struct cmd_tunnel_udp_config *res = parsed_result;
6771 struct rte_eth_udp_tunnel tunnel_udp;
6774 tunnel_udp.udp_port = res->udp_port;
6776 if (!strcmp(res->cmd, "rx_vxlan_port"))
6777 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6779 if (!strcmp(res->what, "add"))
6780 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6782 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6785 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6788 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6789 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6790 cmd, "rx_vxlan_port");
6791 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6792 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6794 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6795 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6797 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6798 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6801 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6802 .f = cmd_tunnel_udp_config_parsed,
6804 .help_str = "add/rm an tunneling UDP port filter: "
6805 "rx_vxlan_port add udp_port port_id",
6807 (void *)&cmd_tunnel_udp_config_cmd,
6808 (void *)&cmd_tunnel_udp_config_what,
6809 (void *)&cmd_tunnel_udp_config_udp_port,
6810 (void *)&cmd_tunnel_udp_config_port_id,
6815 /* *** GLOBAL CONFIG *** */
6816 struct cmd_global_config_result {
6817 cmdline_fixed_string_t cmd;
6819 cmdline_fixed_string_t cfg_type;
6824 cmd_global_config_parsed(void *parsed_result,
6825 __attribute__((unused)) struct cmdline *cl,
6826 __attribute__((unused)) void *data)
6828 struct cmd_global_config_result *res = parsed_result;
6829 struct rte_eth_global_cfg conf;
6832 memset(&conf, 0, sizeof(conf));
6833 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6834 conf.cfg.gre_key_len = res->len;
6835 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6836 RTE_ETH_FILTER_SET, &conf);
6838 printf("Global config error\n");
6841 cmdline_parse_token_string_t cmd_global_config_cmd =
6842 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6844 cmdline_parse_token_num_t cmd_global_config_port_id =
6845 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6846 cmdline_parse_token_string_t cmd_global_config_type =
6847 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6848 cfg_type, "gre-key-len");
6849 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6850 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6853 cmdline_parse_inst_t cmd_global_config = {
6854 .f = cmd_global_config_parsed,
6855 .data = (void *)NULL,
6856 .help_str = "global_config <port_id> gre-key-len <number>",
6858 (void *)&cmd_global_config_cmd,
6859 (void *)&cmd_global_config_port_id,
6860 (void *)&cmd_global_config_type,
6861 (void *)&cmd_global_config_gre_key_len,
6866 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6867 struct cmd_set_mirror_mask_result {
6868 cmdline_fixed_string_t set;
6869 cmdline_fixed_string_t port;
6871 cmdline_fixed_string_t mirror;
6873 cmdline_fixed_string_t what;
6874 cmdline_fixed_string_t value;
6875 cmdline_fixed_string_t dstpool;
6877 cmdline_fixed_string_t on;
6880 cmdline_parse_token_string_t cmd_mirror_mask_set =
6881 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6883 cmdline_parse_token_string_t cmd_mirror_mask_port =
6884 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6886 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6887 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6889 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6890 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6891 mirror, "mirror-rule");
6892 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6893 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6895 cmdline_parse_token_string_t cmd_mirror_mask_what =
6896 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6897 what, "pool-mirror-up#pool-mirror-down"
6899 cmdline_parse_token_string_t cmd_mirror_mask_value =
6900 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6902 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6903 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6904 dstpool, "dst-pool");
6905 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6906 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6908 cmdline_parse_token_string_t cmd_mirror_mask_on =
6909 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6913 cmd_set_mirror_mask_parsed(void *parsed_result,
6914 __attribute__((unused)) struct cmdline *cl,
6915 __attribute__((unused)) void *data)
6918 struct cmd_set_mirror_mask_result *res = parsed_result;
6919 struct rte_eth_mirror_conf mr_conf;
6921 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6923 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6925 mr_conf.dst_pool = res->dstpool_id;
6927 if (!strcmp(res->what, "pool-mirror-up")) {
6928 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6929 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6930 } else if (!strcmp(res->what, "pool-mirror-down")) {
6931 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6932 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6933 } else if (!strcmp(res->what, "vlan-mirror")) {
6934 mr_conf.rule_type = ETH_MIRROR_VLAN;
6935 nb_item = parse_item_list(res->value, "vlan",
6936 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6940 for (i = 0; i < nb_item; i++) {
6941 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6942 printf("Invalid vlan_id: must be < 4096\n");
6946 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6947 mr_conf.vlan.vlan_mask |= 1ULL << i;
6951 if (!strcmp(res->on, "on"))
6952 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6955 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6958 printf("mirror rule add error: (%s)\n", strerror(-ret));
6961 cmdline_parse_inst_t cmd_set_mirror_mask = {
6962 .f = cmd_set_mirror_mask_parsed,
6964 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6965 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6967 (void *)&cmd_mirror_mask_set,
6968 (void *)&cmd_mirror_mask_port,
6969 (void *)&cmd_mirror_mask_portid,
6970 (void *)&cmd_mirror_mask_mirror,
6971 (void *)&cmd_mirror_mask_ruleid,
6972 (void *)&cmd_mirror_mask_what,
6973 (void *)&cmd_mirror_mask_value,
6974 (void *)&cmd_mirror_mask_dstpool,
6975 (void *)&cmd_mirror_mask_poolid,
6976 (void *)&cmd_mirror_mask_on,
6981 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6982 struct cmd_set_mirror_link_result {
6983 cmdline_fixed_string_t set;
6984 cmdline_fixed_string_t port;
6986 cmdline_fixed_string_t mirror;
6988 cmdline_fixed_string_t what;
6989 cmdline_fixed_string_t dstpool;
6991 cmdline_fixed_string_t on;
6994 cmdline_parse_token_string_t cmd_mirror_link_set =
6995 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6997 cmdline_parse_token_string_t cmd_mirror_link_port =
6998 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7000 cmdline_parse_token_num_t cmd_mirror_link_portid =
7001 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7003 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7004 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7005 mirror, "mirror-rule");
7006 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7007 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7009 cmdline_parse_token_string_t cmd_mirror_link_what =
7010 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7011 what, "uplink-mirror#downlink-mirror");
7012 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7013 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7014 dstpool, "dst-pool");
7015 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7016 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7018 cmdline_parse_token_string_t cmd_mirror_link_on =
7019 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7023 cmd_set_mirror_link_parsed(void *parsed_result,
7024 __attribute__((unused)) struct cmdline *cl,
7025 __attribute__((unused)) void *data)
7028 struct cmd_set_mirror_link_result *res = parsed_result;
7029 struct rte_eth_mirror_conf mr_conf;
7031 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7032 if (!strcmp(res->what, "uplink-mirror"))
7033 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7035 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7037 mr_conf.dst_pool = res->dstpool_id;
7039 if (!strcmp(res->on, "on"))
7040 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7043 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7046 /* check the return value and print it if is < 0 */
7048 printf("mirror rule add error: (%s)\n", strerror(-ret));
7052 cmdline_parse_inst_t cmd_set_mirror_link = {
7053 .f = cmd_set_mirror_link_parsed,
7055 .help_str = "set port X mirror-rule Y uplink-mirror|"
7056 "downlink-mirror dst-pool Z on|off",
7058 (void *)&cmd_mirror_link_set,
7059 (void *)&cmd_mirror_link_port,
7060 (void *)&cmd_mirror_link_portid,
7061 (void *)&cmd_mirror_link_mirror,
7062 (void *)&cmd_mirror_link_ruleid,
7063 (void *)&cmd_mirror_link_what,
7064 (void *)&cmd_mirror_link_dstpool,
7065 (void *)&cmd_mirror_link_poolid,
7066 (void *)&cmd_mirror_link_on,
7071 /* *** RESET VM MIRROR RULE *** */
7072 struct cmd_rm_mirror_rule_result {
7073 cmdline_fixed_string_t reset;
7074 cmdline_fixed_string_t port;
7076 cmdline_fixed_string_t mirror;
7080 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7081 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7083 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7084 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7086 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7087 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7089 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7090 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7091 mirror, "mirror-rule");
7092 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7093 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7097 cmd_reset_mirror_rule_parsed(void *parsed_result,
7098 __attribute__((unused)) struct cmdline *cl,
7099 __attribute__((unused)) void *data)
7102 struct cmd_set_mirror_link_result *res = parsed_result;
7104 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7106 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7109 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7110 .f = cmd_reset_mirror_rule_parsed,
7112 .help_str = "reset port X mirror-rule Y",
7114 (void *)&cmd_rm_mirror_rule_reset,
7115 (void *)&cmd_rm_mirror_rule_port,
7116 (void *)&cmd_rm_mirror_rule_portid,
7117 (void *)&cmd_rm_mirror_rule_mirror,
7118 (void *)&cmd_rm_mirror_rule_ruleid,
7123 /* ******************************************************************************** */
7125 struct cmd_dump_result {
7126 cmdline_fixed_string_t dump;
7130 dump_struct_sizes(void)
7132 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7133 DUMP_SIZE(struct rte_mbuf);
7134 DUMP_SIZE(struct rte_mempool);
7135 DUMP_SIZE(struct rte_ring);
7139 static void cmd_dump_parsed(void *parsed_result,
7140 __attribute__((unused)) struct cmdline *cl,
7141 __attribute__((unused)) void *data)
7143 struct cmd_dump_result *res = parsed_result;
7145 if (!strcmp(res->dump, "dump_physmem"))
7146 rte_dump_physmem_layout(stdout);
7147 else if (!strcmp(res->dump, "dump_memzone"))
7148 rte_memzone_dump(stdout);
7149 else if (!strcmp(res->dump, "dump_log_history"))
7150 rte_log_dump_history(stdout);
7151 else if (!strcmp(res->dump, "dump_struct_sizes"))
7152 dump_struct_sizes();
7153 else if (!strcmp(res->dump, "dump_ring"))
7154 rte_ring_list_dump(stdout);
7155 else if (!strcmp(res->dump, "dump_mempool"))
7156 rte_mempool_list_dump(stdout);
7157 else if (!strcmp(res->dump, "dump_devargs"))
7158 rte_eal_devargs_dump(stdout);
7161 cmdline_parse_token_string_t cmd_dump_dump =
7162 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7166 "dump_struct_sizes#"
7171 cmdline_parse_inst_t cmd_dump = {
7172 .f = cmd_dump_parsed, /* function to call */
7173 .data = NULL, /* 2nd arg of func */
7174 .help_str = "dump status",
7175 .tokens = { /* token list, NULL terminated */
7176 (void *)&cmd_dump_dump,
7181 /* ******************************************************************************** */
7183 struct cmd_dump_one_result {
7184 cmdline_fixed_string_t dump;
7185 cmdline_fixed_string_t name;
7188 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7189 __attribute__((unused)) void *data)
7191 struct cmd_dump_one_result *res = parsed_result;
7193 if (!strcmp(res->dump, "dump_ring")) {
7195 r = rte_ring_lookup(res->name);
7197 cmdline_printf(cl, "Cannot find ring\n");
7200 rte_ring_dump(stdout, r);
7201 } else if (!strcmp(res->dump, "dump_mempool")) {
7202 struct rte_mempool *mp;
7203 mp = rte_mempool_lookup(res->name);
7205 cmdline_printf(cl, "Cannot find mempool\n");
7208 rte_mempool_dump(stdout, mp);
7212 cmdline_parse_token_string_t cmd_dump_one_dump =
7213 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7214 "dump_ring#dump_mempool");
7216 cmdline_parse_token_string_t cmd_dump_one_name =
7217 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7219 cmdline_parse_inst_t cmd_dump_one = {
7220 .f = cmd_dump_one_parsed, /* function to call */
7221 .data = NULL, /* 2nd arg of func */
7222 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7223 .tokens = { /* token list, NULL terminated */
7224 (void *)&cmd_dump_one_dump,
7225 (void *)&cmd_dump_one_name,
7230 /* *** Add/Del syn filter *** */
7231 struct cmd_syn_filter_result {
7232 cmdline_fixed_string_t filter;
7234 cmdline_fixed_string_t ops;
7235 cmdline_fixed_string_t priority;
7236 cmdline_fixed_string_t high;
7237 cmdline_fixed_string_t queue;
7242 cmd_syn_filter_parsed(void *parsed_result,
7243 __attribute__((unused)) struct cmdline *cl,
7244 __attribute__((unused)) void *data)
7246 struct cmd_syn_filter_result *res = parsed_result;
7247 struct rte_eth_syn_filter syn_filter;
7250 ret = rte_eth_dev_filter_supported(res->port_id,
7251 RTE_ETH_FILTER_SYN);
7253 printf("syn filter is not supported on port %u.\n",
7258 memset(&syn_filter, 0, sizeof(syn_filter));
7260 if (!strcmp(res->ops, "add")) {
7261 if (!strcmp(res->high, "high"))
7262 syn_filter.hig_pri = 1;
7264 syn_filter.hig_pri = 0;
7266 syn_filter.queue = res->queue_id;
7267 ret = rte_eth_dev_filter_ctrl(res->port_id,
7272 ret = rte_eth_dev_filter_ctrl(res->port_id,
7274 RTE_ETH_FILTER_DELETE,
7278 printf("syn filter programming error: (%s)\n",
7282 cmdline_parse_token_string_t cmd_syn_filter_filter =
7283 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7284 filter, "syn_filter");
7285 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7286 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7288 cmdline_parse_token_string_t cmd_syn_filter_ops =
7289 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7291 cmdline_parse_token_string_t cmd_syn_filter_priority =
7292 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7293 priority, "priority");
7294 cmdline_parse_token_string_t cmd_syn_filter_high =
7295 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7297 cmdline_parse_token_string_t cmd_syn_filter_queue =
7298 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7300 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7301 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7304 cmdline_parse_inst_t cmd_syn_filter = {
7305 .f = cmd_syn_filter_parsed,
7307 .help_str = "add/delete syn filter",
7309 (void *)&cmd_syn_filter_filter,
7310 (void *)&cmd_syn_filter_port_id,
7311 (void *)&cmd_syn_filter_ops,
7312 (void *)&cmd_syn_filter_priority,
7313 (void *)&cmd_syn_filter_high,
7314 (void *)&cmd_syn_filter_queue,
7315 (void *)&cmd_syn_filter_queue_id,
7320 /* *** ADD/REMOVE A 2tuple FILTER *** */
7321 struct cmd_2tuple_filter_result {
7322 cmdline_fixed_string_t filter;
7324 cmdline_fixed_string_t ops;
7325 cmdline_fixed_string_t dst_port;
7326 uint16_t dst_port_value;
7327 cmdline_fixed_string_t protocol;
7328 uint8_t protocol_value;
7329 cmdline_fixed_string_t mask;
7331 cmdline_fixed_string_t tcp_flags;
7332 uint8_t tcp_flags_value;
7333 cmdline_fixed_string_t priority;
7334 uint8_t priority_value;
7335 cmdline_fixed_string_t queue;
7340 cmd_2tuple_filter_parsed(void *parsed_result,
7341 __attribute__((unused)) struct cmdline *cl,
7342 __attribute__((unused)) void *data)
7344 struct rte_eth_ntuple_filter filter;
7345 struct cmd_2tuple_filter_result *res = parsed_result;
7348 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7350 printf("ntuple filter is not supported on port %u.\n",
7355 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7357 filter.flags = RTE_2TUPLE_FLAGS;
7358 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7359 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7360 filter.proto = res->protocol_value;
7361 filter.priority = res->priority_value;
7362 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7363 printf("nonzero tcp_flags is only meaningful"
7364 " when protocol is TCP.\n");
7367 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7368 printf("invalid TCP flags.\n");
7372 if (res->tcp_flags_value != 0) {
7373 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7374 filter.tcp_flags = res->tcp_flags_value;
7377 /* need convert to big endian. */
7378 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7379 filter.queue = res->queue_id;
7381 if (!strcmp(res->ops, "add"))
7382 ret = rte_eth_dev_filter_ctrl(res->port_id,
7383 RTE_ETH_FILTER_NTUPLE,
7387 ret = rte_eth_dev_filter_ctrl(res->port_id,
7388 RTE_ETH_FILTER_NTUPLE,
7389 RTE_ETH_FILTER_DELETE,
7392 printf("2tuple filter programming error: (%s)\n",
7397 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7398 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7399 filter, "2tuple_filter");
7400 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7401 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7403 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7404 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7406 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7407 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7408 dst_port, "dst_port");
7409 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7410 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7411 dst_port_value, UINT16);
7412 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7413 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7414 protocol, "protocol");
7415 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7416 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7417 protocol_value, UINT8);
7418 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7419 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7421 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7422 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7424 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7425 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7426 tcp_flags, "tcp_flags");
7427 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7428 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7429 tcp_flags_value, UINT8);
7430 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7431 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7432 priority, "priority");
7433 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7434 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7435 priority_value, UINT8);
7436 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7437 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7439 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7440 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7443 cmdline_parse_inst_t cmd_2tuple_filter = {
7444 .f = cmd_2tuple_filter_parsed,
7446 .help_str = "add a 2tuple filter",
7448 (void *)&cmd_2tuple_filter_filter,
7449 (void *)&cmd_2tuple_filter_port_id,
7450 (void *)&cmd_2tuple_filter_ops,
7451 (void *)&cmd_2tuple_filter_dst_port,
7452 (void *)&cmd_2tuple_filter_dst_port_value,
7453 (void *)&cmd_2tuple_filter_protocol,
7454 (void *)&cmd_2tuple_filter_protocol_value,
7455 (void *)&cmd_2tuple_filter_mask,
7456 (void *)&cmd_2tuple_filter_mask_value,
7457 (void *)&cmd_2tuple_filter_tcp_flags,
7458 (void *)&cmd_2tuple_filter_tcp_flags_value,
7459 (void *)&cmd_2tuple_filter_priority,
7460 (void *)&cmd_2tuple_filter_priority_value,
7461 (void *)&cmd_2tuple_filter_queue,
7462 (void *)&cmd_2tuple_filter_queue_id,
7467 /* *** ADD/REMOVE A 5tuple FILTER *** */
7468 struct cmd_5tuple_filter_result {
7469 cmdline_fixed_string_t filter;
7471 cmdline_fixed_string_t ops;
7472 cmdline_fixed_string_t dst_ip;
7473 cmdline_ipaddr_t dst_ip_value;
7474 cmdline_fixed_string_t src_ip;
7475 cmdline_ipaddr_t src_ip_value;
7476 cmdline_fixed_string_t dst_port;
7477 uint16_t dst_port_value;
7478 cmdline_fixed_string_t src_port;
7479 uint16_t src_port_value;
7480 cmdline_fixed_string_t protocol;
7481 uint8_t protocol_value;
7482 cmdline_fixed_string_t mask;
7484 cmdline_fixed_string_t tcp_flags;
7485 uint8_t tcp_flags_value;
7486 cmdline_fixed_string_t priority;
7487 uint8_t priority_value;
7488 cmdline_fixed_string_t queue;
7493 cmd_5tuple_filter_parsed(void *parsed_result,
7494 __attribute__((unused)) struct cmdline *cl,
7495 __attribute__((unused)) void *data)
7497 struct rte_eth_ntuple_filter filter;
7498 struct cmd_5tuple_filter_result *res = parsed_result;
7501 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7503 printf("ntuple filter is not supported on port %u.\n",
7508 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7510 filter.flags = RTE_5TUPLE_FLAGS;
7511 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7512 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7513 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7514 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7515 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7516 filter.proto = res->protocol_value;
7517 filter.priority = res->priority_value;
7518 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7519 printf("nonzero tcp_flags is only meaningful"
7520 " when protocol is TCP.\n");
7523 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7524 printf("invalid TCP flags.\n");
7528 if (res->tcp_flags_value != 0) {
7529 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7530 filter.tcp_flags = res->tcp_flags_value;
7533 if (res->dst_ip_value.family == AF_INET)
7534 /* no need to convert, already big endian. */
7535 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7537 if (filter.dst_ip_mask == 0) {
7538 printf("can not support ipv6 involved compare.\n");
7544 if (res->src_ip_value.family == AF_INET)
7545 /* no need to convert, already big endian. */
7546 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7548 if (filter.src_ip_mask == 0) {
7549 printf("can not support ipv6 involved compare.\n");
7554 /* need convert to big endian. */
7555 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7556 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7557 filter.queue = res->queue_id;
7559 if (!strcmp(res->ops, "add"))
7560 ret = rte_eth_dev_filter_ctrl(res->port_id,
7561 RTE_ETH_FILTER_NTUPLE,
7565 ret = rte_eth_dev_filter_ctrl(res->port_id,
7566 RTE_ETH_FILTER_NTUPLE,
7567 RTE_ETH_FILTER_DELETE,
7570 printf("5tuple filter programming error: (%s)\n",
7574 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7575 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7576 filter, "5tuple_filter");
7577 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7578 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7580 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7581 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7583 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7584 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7586 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7587 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7589 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7590 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7592 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7593 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7595 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7596 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7597 dst_port, "dst_port");
7598 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7599 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7600 dst_port_value, UINT16);
7601 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7602 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7603 src_port, "src_port");
7604 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7605 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7606 src_port_value, UINT16);
7607 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7608 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7609 protocol, "protocol");
7610 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7611 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7612 protocol_value, UINT8);
7613 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7614 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7616 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7617 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7619 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7620 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7621 tcp_flags, "tcp_flags");
7622 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7623 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7624 tcp_flags_value, UINT8);
7625 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7626 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7627 priority, "priority");
7628 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7629 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7630 priority_value, UINT8);
7631 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7632 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7634 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7635 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7638 cmdline_parse_inst_t cmd_5tuple_filter = {
7639 .f = cmd_5tuple_filter_parsed,
7641 .help_str = "add/del a 5tuple filter",
7643 (void *)&cmd_5tuple_filter_filter,
7644 (void *)&cmd_5tuple_filter_port_id,
7645 (void *)&cmd_5tuple_filter_ops,
7646 (void *)&cmd_5tuple_filter_dst_ip,
7647 (void *)&cmd_5tuple_filter_dst_ip_value,
7648 (void *)&cmd_5tuple_filter_src_ip,
7649 (void *)&cmd_5tuple_filter_src_ip_value,
7650 (void *)&cmd_5tuple_filter_dst_port,
7651 (void *)&cmd_5tuple_filter_dst_port_value,
7652 (void *)&cmd_5tuple_filter_src_port,
7653 (void *)&cmd_5tuple_filter_src_port_value,
7654 (void *)&cmd_5tuple_filter_protocol,
7655 (void *)&cmd_5tuple_filter_protocol_value,
7656 (void *)&cmd_5tuple_filter_mask,
7657 (void *)&cmd_5tuple_filter_mask_value,
7658 (void *)&cmd_5tuple_filter_tcp_flags,
7659 (void *)&cmd_5tuple_filter_tcp_flags_value,
7660 (void *)&cmd_5tuple_filter_priority,
7661 (void *)&cmd_5tuple_filter_priority_value,
7662 (void *)&cmd_5tuple_filter_queue,
7663 (void *)&cmd_5tuple_filter_queue_id,
7668 /* *** ADD/REMOVE A flex FILTER *** */
7669 struct cmd_flex_filter_result {
7670 cmdline_fixed_string_t filter;
7671 cmdline_fixed_string_t ops;
7673 cmdline_fixed_string_t len;
7675 cmdline_fixed_string_t bytes;
7676 cmdline_fixed_string_t bytes_value;
7677 cmdline_fixed_string_t mask;
7678 cmdline_fixed_string_t mask_value;
7679 cmdline_fixed_string_t priority;
7680 uint8_t priority_value;
7681 cmdline_fixed_string_t queue;
7685 static int xdigit2val(unsigned char c)
7690 else if (isupper(c))
7698 cmd_flex_filter_parsed(void *parsed_result,
7699 __attribute__((unused)) struct cmdline *cl,
7700 __attribute__((unused)) void *data)
7703 struct rte_eth_flex_filter filter;
7704 struct cmd_flex_filter_result *res = parsed_result;
7705 char *bytes_ptr, *mask_ptr;
7706 uint16_t len, i, j = 0;
7711 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7712 printf("the len exceed the max length 128\n");
7715 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7716 filter.len = res->len_value;
7717 filter.priority = res->priority_value;
7718 filter.queue = res->queue_id;
7719 bytes_ptr = res->bytes_value;
7720 mask_ptr = res->mask_value;
7722 /* translate bytes string to array. */
7723 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7724 (bytes_ptr[1] == 'X')))
7726 len = strnlen(bytes_ptr, res->len_value * 2);
7727 if (len == 0 || (len % 8 != 0)) {
7728 printf("please check len and bytes input\n");
7731 for (i = 0; i < len; i++) {
7733 if (isxdigit(c) == 0) {
7734 /* invalid characters. */
7735 printf("invalid input\n");
7738 val = xdigit2val(c);
7741 filter.bytes[j] = byte;
7742 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7749 /* translate mask string to uint8_t array. */
7750 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7751 (mask_ptr[1] == 'X')))
7753 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7755 printf("invalid input\n");
7760 for (i = 0; i < len; i++) {
7762 if (isxdigit(c) == 0) {
7763 /* invalid characters. */
7764 printf("invalid input\n");
7767 val = xdigit2val(c);
7770 filter.mask[j] = byte;
7771 printf("mask[%d]:%02x ", j, filter.mask[j]);
7779 if (!strcmp(res->ops, "add"))
7780 ret = rte_eth_dev_filter_ctrl(res->port_id,
7781 RTE_ETH_FILTER_FLEXIBLE,
7785 ret = rte_eth_dev_filter_ctrl(res->port_id,
7786 RTE_ETH_FILTER_FLEXIBLE,
7787 RTE_ETH_FILTER_DELETE,
7791 printf("flex filter setting error: (%s)\n", strerror(-ret));
7794 cmdline_parse_token_string_t cmd_flex_filter_filter =
7795 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7796 filter, "flex_filter");
7797 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7798 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7800 cmdline_parse_token_string_t cmd_flex_filter_ops =
7801 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7803 cmdline_parse_token_string_t cmd_flex_filter_len =
7804 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7806 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7807 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7809 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7810 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7812 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7813 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7815 cmdline_parse_token_string_t cmd_flex_filter_mask =
7816 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7818 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7819 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7821 cmdline_parse_token_string_t cmd_flex_filter_priority =
7822 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7823 priority, "priority");
7824 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7825 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7826 priority_value, UINT8);
7827 cmdline_parse_token_string_t cmd_flex_filter_queue =
7828 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7830 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7831 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7833 cmdline_parse_inst_t cmd_flex_filter = {
7834 .f = cmd_flex_filter_parsed,
7836 .help_str = "add/del a flex filter",
7838 (void *)&cmd_flex_filter_filter,
7839 (void *)&cmd_flex_filter_port_id,
7840 (void *)&cmd_flex_filter_ops,
7841 (void *)&cmd_flex_filter_len,
7842 (void *)&cmd_flex_filter_len_value,
7843 (void *)&cmd_flex_filter_bytes,
7844 (void *)&cmd_flex_filter_bytes_value,
7845 (void *)&cmd_flex_filter_mask,
7846 (void *)&cmd_flex_filter_mask_value,
7847 (void *)&cmd_flex_filter_priority,
7848 (void *)&cmd_flex_filter_priority_value,
7849 (void *)&cmd_flex_filter_queue,
7850 (void *)&cmd_flex_filter_queue_id,
7855 /* *** Filters Control *** */
7857 /* *** deal with ethertype filter *** */
7858 struct cmd_ethertype_filter_result {
7859 cmdline_fixed_string_t filter;
7861 cmdline_fixed_string_t ops;
7862 cmdline_fixed_string_t mac;
7863 struct ether_addr mac_addr;
7864 cmdline_fixed_string_t ethertype;
7865 uint16_t ethertype_value;
7866 cmdline_fixed_string_t drop;
7867 cmdline_fixed_string_t queue;
7871 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7872 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7873 filter, "ethertype_filter");
7874 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7875 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7877 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7878 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7880 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7881 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7882 mac, "mac_addr#mac_ignr");
7883 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7884 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7886 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7887 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7888 ethertype, "ethertype");
7889 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7890 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7891 ethertype_value, UINT16);
7892 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7893 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7895 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7896 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7898 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7899 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7903 cmd_ethertype_filter_parsed(void *parsed_result,
7904 __attribute__((unused)) struct cmdline *cl,
7905 __attribute__((unused)) void *data)
7907 struct cmd_ethertype_filter_result *res = parsed_result;
7908 struct rte_eth_ethertype_filter filter;
7911 ret = rte_eth_dev_filter_supported(res->port_id,
7912 RTE_ETH_FILTER_ETHERTYPE);
7914 printf("ethertype filter is not supported on port %u.\n",
7919 memset(&filter, 0, sizeof(filter));
7920 if (!strcmp(res->mac, "mac_addr")) {
7921 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7922 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7923 sizeof(struct ether_addr));
7925 if (!strcmp(res->drop, "drop"))
7926 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7927 filter.ether_type = res->ethertype_value;
7928 filter.queue = res->queue_id;
7930 if (!strcmp(res->ops, "add"))
7931 ret = rte_eth_dev_filter_ctrl(res->port_id,
7932 RTE_ETH_FILTER_ETHERTYPE,
7936 ret = rte_eth_dev_filter_ctrl(res->port_id,
7937 RTE_ETH_FILTER_ETHERTYPE,
7938 RTE_ETH_FILTER_DELETE,
7941 printf("ethertype filter programming error: (%s)\n",
7945 cmdline_parse_inst_t cmd_ethertype_filter = {
7946 .f = cmd_ethertype_filter_parsed,
7948 .help_str = "add or delete an ethertype filter entry",
7950 (void *)&cmd_ethertype_filter_filter,
7951 (void *)&cmd_ethertype_filter_port_id,
7952 (void *)&cmd_ethertype_filter_ops,
7953 (void *)&cmd_ethertype_filter_mac,
7954 (void *)&cmd_ethertype_filter_mac_addr,
7955 (void *)&cmd_ethertype_filter_ethertype,
7956 (void *)&cmd_ethertype_filter_ethertype_value,
7957 (void *)&cmd_ethertype_filter_drop,
7958 (void *)&cmd_ethertype_filter_queue,
7959 (void *)&cmd_ethertype_filter_queue_id,
7964 /* *** deal with flow director filter *** */
7965 struct cmd_flow_director_result {
7966 cmdline_fixed_string_t flow_director_filter;
7968 cmdline_fixed_string_t mode;
7969 cmdline_fixed_string_t mode_value;
7970 cmdline_fixed_string_t ops;
7971 cmdline_fixed_string_t flow;
7972 cmdline_fixed_string_t flow_type;
7973 cmdline_fixed_string_t ether;
7974 uint16_t ether_type;
7975 cmdline_fixed_string_t src;
7976 cmdline_ipaddr_t ip_src;
7978 cmdline_fixed_string_t dst;
7979 cmdline_ipaddr_t ip_dst;
7981 cmdline_fixed_string_t verify_tag;
7982 uint32_t verify_tag_value;
7983 cmdline_fixed_string_t vlan;
7984 uint16_t vlan_value;
7985 cmdline_fixed_string_t flexbytes;
7986 cmdline_fixed_string_t flexbytes_value;
7987 cmdline_fixed_string_t pf_vf;
7988 cmdline_fixed_string_t drop;
7989 cmdline_fixed_string_t queue;
7991 cmdline_fixed_string_t fd_id;
7992 uint32_t fd_id_value;
7993 cmdline_fixed_string_t mac;
7994 struct ether_addr mac_addr;
7995 cmdline_fixed_string_t tunnel;
7996 cmdline_fixed_string_t tunnel_type;
7997 cmdline_fixed_string_t tunnel_id;
7998 uint32_t tunnel_id_value;
8002 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8005 const char *p, *p0 = q_arg;
8007 unsigned long int_fld;
8008 char *str_fld[max_num];
8013 p = strchr(p0, '(');
8017 p0 = strchr(p, ')');
8022 if (size >= sizeof(s))
8025 snprintf(s, sizeof(s), "%.*s", size, p);
8026 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8027 if (ret < 0 || ret > max_num)
8029 for (i = 0; i < ret; i++) {
8031 int_fld = strtoul(str_fld[i], &end, 0);
8032 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8034 flexbytes[i] = (uint8_t)int_fld;
8040 str2flowtype(char *string)
8043 static const struct {
8046 } flowtype_str[] = {
8047 {"raw", RTE_ETH_FLOW_RAW},
8048 {"ipv4", RTE_ETH_FLOW_IPV4},
8049 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8050 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8051 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8052 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8053 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8054 {"ipv6", RTE_ETH_FLOW_IPV6},
8055 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8056 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8057 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8058 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8059 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8060 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8063 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8064 if (!strcmp(flowtype_str[i].str, string))
8065 return flowtype_str[i].type;
8067 return RTE_ETH_FLOW_UNKNOWN;
8070 static enum rte_eth_fdir_tunnel_type
8071 str2fdir_tunneltype(char *string)
8075 static const struct {
8077 enum rte_eth_fdir_tunnel_type type;
8078 } tunneltype_str[] = {
8079 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8080 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8083 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8084 if (!strcmp(tunneltype_str[i].str, string))
8085 return tunneltype_str[i].type;
8087 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8090 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8092 if ((ip_addr).family == AF_INET) \
8093 (ip) = (ip_addr).addr.ipv4.s_addr; \
8095 printf("invalid parameter.\n"); \
8100 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8102 if ((ip_addr).family == AF_INET6) \
8103 (void)rte_memcpy(&(ip), \
8104 &((ip_addr).addr.ipv6), \
8105 sizeof(struct in6_addr)); \
8107 printf("invalid parameter.\n"); \
8113 cmd_flow_director_filter_parsed(void *parsed_result,
8114 __attribute__((unused)) struct cmdline *cl,
8115 __attribute__((unused)) void *data)
8117 struct cmd_flow_director_result *res = parsed_result;
8118 struct rte_eth_fdir_filter entry;
8119 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8121 unsigned long vf_id;
8124 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8126 printf("flow director is not supported on port %u.\n",
8130 memset(flexbytes, 0, sizeof(flexbytes));
8131 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8133 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8134 if (strcmp(res->mode_value, "MAC-VLAN")) {
8135 printf("Please set mode to MAC-VLAN.\n");
8138 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8139 if (strcmp(res->mode_value, "Tunnel")) {
8140 printf("Please set mode to Tunnel.\n");
8144 if (strcmp(res->mode_value, "IP")) {
8145 printf("Please set mode to IP.\n");
8148 entry.input.flow_type = str2flowtype(res->flow_type);
8151 ret = parse_flexbytes(res->flexbytes_value,
8153 RTE_ETH_FDIR_MAX_FLEXLEN);
8155 printf("error: Cannot parse flexbytes input.\n");
8159 switch (entry.input.flow_type) {
8160 case RTE_ETH_FLOW_FRAG_IPV4:
8161 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8162 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8163 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8164 IPV4_ADDR_TO_UINT(res->ip_dst,
8165 entry.input.flow.ip4_flow.dst_ip);
8166 IPV4_ADDR_TO_UINT(res->ip_src,
8167 entry.input.flow.ip4_flow.src_ip);
8168 /* need convert to big endian. */
8169 entry.input.flow.udp4_flow.dst_port =
8170 rte_cpu_to_be_16(res->port_dst);
8171 entry.input.flow.udp4_flow.src_port =
8172 rte_cpu_to_be_16(res->port_src);
8174 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8175 IPV4_ADDR_TO_UINT(res->ip_dst,
8176 entry.input.flow.sctp4_flow.ip.dst_ip);
8177 IPV4_ADDR_TO_UINT(res->ip_src,
8178 entry.input.flow.sctp4_flow.ip.src_ip);
8179 /* need convert to big endian. */
8180 entry.input.flow.sctp4_flow.dst_port =
8181 rte_cpu_to_be_16(res->port_dst);
8182 entry.input.flow.sctp4_flow.src_port =
8183 rte_cpu_to_be_16(res->port_src);
8184 entry.input.flow.sctp4_flow.verify_tag =
8185 rte_cpu_to_be_32(res->verify_tag_value);
8187 case RTE_ETH_FLOW_FRAG_IPV6:
8188 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8189 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8190 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8191 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8192 entry.input.flow.ipv6_flow.dst_ip);
8193 IPV6_ADDR_TO_ARRAY(res->ip_src,
8194 entry.input.flow.ipv6_flow.src_ip);
8195 /* need convert to big endian. */
8196 entry.input.flow.udp6_flow.dst_port =
8197 rte_cpu_to_be_16(res->port_dst);
8198 entry.input.flow.udp6_flow.src_port =
8199 rte_cpu_to_be_16(res->port_src);
8201 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8202 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8203 entry.input.flow.sctp6_flow.ip.dst_ip);
8204 IPV6_ADDR_TO_ARRAY(res->ip_src,
8205 entry.input.flow.sctp6_flow.ip.src_ip);
8206 /* need convert to big endian. */
8207 entry.input.flow.sctp6_flow.dst_port =
8208 rte_cpu_to_be_16(res->port_dst);
8209 entry.input.flow.sctp6_flow.src_port =
8210 rte_cpu_to_be_16(res->port_src);
8211 entry.input.flow.sctp6_flow.verify_tag =
8212 rte_cpu_to_be_32(res->verify_tag_value);
8214 case RTE_ETH_FLOW_L2_PAYLOAD:
8215 entry.input.flow.l2_flow.ether_type =
8216 rte_cpu_to_be_16(res->ether_type);
8222 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8223 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8225 sizeof(struct ether_addr));
8227 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8228 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8230 sizeof(struct ether_addr));
8231 entry.input.flow.tunnel_flow.tunnel_type =
8232 str2fdir_tunneltype(res->tunnel_type);
8233 entry.input.flow.tunnel_flow.tunnel_id =
8234 rte_cpu_to_be_32(res->tunnel_id_value);
8237 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8239 RTE_ETH_FDIR_MAX_FLEXLEN);
8241 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8243 entry.action.flex_off = 0; /*use 0 by default */
8244 if (!strcmp(res->drop, "drop"))
8245 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8247 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8249 if (!strcmp(res->pf_vf, "pf"))
8250 entry.input.flow_ext.is_vf = 0;
8251 else if (!strncmp(res->pf_vf, "vf", 2)) {
8252 struct rte_eth_dev_info dev_info;
8254 memset(&dev_info, 0, sizeof(dev_info));
8255 rte_eth_dev_info_get(res->port_id, &dev_info);
8257 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8258 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8259 printf("invalid parameter %s.\n", res->pf_vf);
8262 entry.input.flow_ext.is_vf = 1;
8263 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8265 printf("invalid parameter %s.\n", res->pf_vf);
8269 /* set to report FD ID by default */
8270 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8271 entry.action.rx_queue = res->queue_id;
8272 entry.soft_id = res->fd_id_value;
8273 if (!strcmp(res->ops, "add"))
8274 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8275 RTE_ETH_FILTER_ADD, &entry);
8276 else if (!strcmp(res->ops, "del"))
8277 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8278 RTE_ETH_FILTER_DELETE, &entry);
8280 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8281 RTE_ETH_FILTER_UPDATE, &entry);
8283 printf("flow director programming error: (%s)\n",
8287 cmdline_parse_token_string_t cmd_flow_director_filter =
8288 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8289 flow_director_filter, "flow_director_filter");
8290 cmdline_parse_token_num_t cmd_flow_director_port_id =
8291 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8293 cmdline_parse_token_string_t cmd_flow_director_ops =
8294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8295 ops, "add#del#update");
8296 cmdline_parse_token_string_t cmd_flow_director_flow =
8297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8299 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8300 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8301 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8302 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8303 cmdline_parse_token_string_t cmd_flow_director_ether =
8304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8306 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8307 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8308 ether_type, UINT16);
8309 cmdline_parse_token_string_t cmd_flow_director_src =
8310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8312 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8313 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8315 cmdline_parse_token_num_t cmd_flow_director_port_src =
8316 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8318 cmdline_parse_token_string_t cmd_flow_director_dst =
8319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8321 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8322 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8324 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8325 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8327 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8329 verify_tag, "verify_tag");
8330 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8331 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8332 verify_tag_value, UINT32);
8333 cmdline_parse_token_string_t cmd_flow_director_vlan =
8334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8336 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8338 vlan_value, UINT16);
8339 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8341 flexbytes, "flexbytes");
8342 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8343 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8344 flexbytes_value, NULL);
8345 cmdline_parse_token_string_t cmd_flow_director_drop =
8346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8348 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8351 cmdline_parse_token_string_t cmd_flow_director_queue =
8352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8354 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8355 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8357 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8360 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8361 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8362 fd_id_value, UINT32);
8364 cmdline_parse_token_string_t cmd_flow_director_mode =
8365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8367 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8370 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8372 mode_value, "MAC-VLAN");
8373 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8375 mode_value, "Tunnel");
8376 cmdline_parse_token_string_t cmd_flow_director_mac =
8377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8379 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8380 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8382 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8385 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8386 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8387 tunnel_type, "NVGRE#VxLAN");
8388 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8389 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8390 tunnel_id, "tunnel-id");
8391 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8392 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8393 tunnel_id_value, UINT32);
8395 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8396 .f = cmd_flow_director_filter_parsed,
8398 .help_str = "add or delete an ip flow director entry on NIC",
8400 (void *)&cmd_flow_director_filter,
8401 (void *)&cmd_flow_director_port_id,
8402 (void *)&cmd_flow_director_mode,
8403 (void *)&cmd_flow_director_mode_ip,
8404 (void *)&cmd_flow_director_ops,
8405 (void *)&cmd_flow_director_flow,
8406 (void *)&cmd_flow_director_flow_type,
8407 (void *)&cmd_flow_director_src,
8408 (void *)&cmd_flow_director_ip_src,
8409 (void *)&cmd_flow_director_dst,
8410 (void *)&cmd_flow_director_ip_dst,
8411 (void *)&cmd_flow_director_vlan,
8412 (void *)&cmd_flow_director_vlan_value,
8413 (void *)&cmd_flow_director_flexbytes,
8414 (void *)&cmd_flow_director_flexbytes_value,
8415 (void *)&cmd_flow_director_drop,
8416 (void *)&cmd_flow_director_pf_vf,
8417 (void *)&cmd_flow_director_queue,
8418 (void *)&cmd_flow_director_queue_id,
8419 (void *)&cmd_flow_director_fd_id,
8420 (void *)&cmd_flow_director_fd_id_value,
8425 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8426 .f = cmd_flow_director_filter_parsed,
8428 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8430 (void *)&cmd_flow_director_filter,
8431 (void *)&cmd_flow_director_port_id,
8432 (void *)&cmd_flow_director_mode,
8433 (void *)&cmd_flow_director_mode_ip,
8434 (void *)&cmd_flow_director_ops,
8435 (void *)&cmd_flow_director_flow,
8436 (void *)&cmd_flow_director_flow_type,
8437 (void *)&cmd_flow_director_src,
8438 (void *)&cmd_flow_director_ip_src,
8439 (void *)&cmd_flow_director_port_src,
8440 (void *)&cmd_flow_director_dst,
8441 (void *)&cmd_flow_director_ip_dst,
8442 (void *)&cmd_flow_director_port_dst,
8443 (void *)&cmd_flow_director_vlan,
8444 (void *)&cmd_flow_director_vlan_value,
8445 (void *)&cmd_flow_director_flexbytes,
8446 (void *)&cmd_flow_director_flexbytes_value,
8447 (void *)&cmd_flow_director_drop,
8448 (void *)&cmd_flow_director_pf_vf,
8449 (void *)&cmd_flow_director_queue,
8450 (void *)&cmd_flow_director_queue_id,
8451 (void *)&cmd_flow_director_fd_id,
8452 (void *)&cmd_flow_director_fd_id_value,
8457 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8458 .f = cmd_flow_director_filter_parsed,
8460 .help_str = "add or delete a sctp flow director entry on NIC",
8462 (void *)&cmd_flow_director_filter,
8463 (void *)&cmd_flow_director_port_id,
8464 (void *)&cmd_flow_director_mode,
8465 (void *)&cmd_flow_director_mode_ip,
8466 (void *)&cmd_flow_director_ops,
8467 (void *)&cmd_flow_director_flow,
8468 (void *)&cmd_flow_director_flow_type,
8469 (void *)&cmd_flow_director_src,
8470 (void *)&cmd_flow_director_ip_src,
8471 (void *)&cmd_flow_director_port_dst,
8472 (void *)&cmd_flow_director_dst,
8473 (void *)&cmd_flow_director_ip_dst,
8474 (void *)&cmd_flow_director_port_dst,
8475 (void *)&cmd_flow_director_verify_tag,
8476 (void *)&cmd_flow_director_verify_tag_value,
8477 (void *)&cmd_flow_director_vlan,
8478 (void *)&cmd_flow_director_vlan_value,
8479 (void *)&cmd_flow_director_flexbytes,
8480 (void *)&cmd_flow_director_flexbytes_value,
8481 (void *)&cmd_flow_director_drop,
8482 (void *)&cmd_flow_director_pf_vf,
8483 (void *)&cmd_flow_director_queue,
8484 (void *)&cmd_flow_director_queue_id,
8485 (void *)&cmd_flow_director_fd_id,
8486 (void *)&cmd_flow_director_fd_id_value,
8491 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8492 .f = cmd_flow_director_filter_parsed,
8494 .help_str = "add or delete a L2 flow director entry on NIC",
8496 (void *)&cmd_flow_director_filter,
8497 (void *)&cmd_flow_director_port_id,
8498 (void *)&cmd_flow_director_mode,
8499 (void *)&cmd_flow_director_mode_ip,
8500 (void *)&cmd_flow_director_ops,
8501 (void *)&cmd_flow_director_flow,
8502 (void *)&cmd_flow_director_flow_type,
8503 (void *)&cmd_flow_director_ether,
8504 (void *)&cmd_flow_director_ether_type,
8505 (void *)&cmd_flow_director_flexbytes,
8506 (void *)&cmd_flow_director_flexbytes_value,
8507 (void *)&cmd_flow_director_drop,
8508 (void *)&cmd_flow_director_pf_vf,
8509 (void *)&cmd_flow_director_queue,
8510 (void *)&cmd_flow_director_queue_id,
8511 (void *)&cmd_flow_director_fd_id,
8512 (void *)&cmd_flow_director_fd_id_value,
8517 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8518 .f = cmd_flow_director_filter_parsed,
8520 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8522 (void *)&cmd_flow_director_filter,
8523 (void *)&cmd_flow_director_port_id,
8524 (void *)&cmd_flow_director_mode,
8525 (void *)&cmd_flow_director_mode_mac_vlan,
8526 (void *)&cmd_flow_director_ops,
8527 (void *)&cmd_flow_director_mac,
8528 (void *)&cmd_flow_director_mac_addr,
8529 (void *)&cmd_flow_director_vlan,
8530 (void *)&cmd_flow_director_vlan_value,
8531 (void *)&cmd_flow_director_flexbytes,
8532 (void *)&cmd_flow_director_flexbytes_value,
8533 (void *)&cmd_flow_director_drop,
8534 (void *)&cmd_flow_director_queue,
8535 (void *)&cmd_flow_director_queue_id,
8536 (void *)&cmd_flow_director_fd_id,
8537 (void *)&cmd_flow_director_fd_id_value,
8542 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8543 .f = cmd_flow_director_filter_parsed,
8545 .help_str = "add or delete a tunnel flow director entry on NIC",
8547 (void *)&cmd_flow_director_filter,
8548 (void *)&cmd_flow_director_port_id,
8549 (void *)&cmd_flow_director_mode,
8550 (void *)&cmd_flow_director_mode_tunnel,
8551 (void *)&cmd_flow_director_ops,
8552 (void *)&cmd_flow_director_mac,
8553 (void *)&cmd_flow_director_mac_addr,
8554 (void *)&cmd_flow_director_vlan,
8555 (void *)&cmd_flow_director_vlan_value,
8556 (void *)&cmd_flow_director_tunnel,
8557 (void *)&cmd_flow_director_tunnel_type,
8558 (void *)&cmd_flow_director_tunnel_id,
8559 (void *)&cmd_flow_director_tunnel_id_value,
8560 (void *)&cmd_flow_director_flexbytes,
8561 (void *)&cmd_flow_director_flexbytes_value,
8562 (void *)&cmd_flow_director_drop,
8563 (void *)&cmd_flow_director_queue,
8564 (void *)&cmd_flow_director_queue_id,
8565 (void *)&cmd_flow_director_fd_id,
8566 (void *)&cmd_flow_director_fd_id_value,
8571 struct cmd_flush_flow_director_result {
8572 cmdline_fixed_string_t flush_flow_director;
8576 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8577 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8578 flush_flow_director, "flush_flow_director");
8579 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8580 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8584 cmd_flush_flow_director_parsed(void *parsed_result,
8585 __attribute__((unused)) struct cmdline *cl,
8586 __attribute__((unused)) void *data)
8588 struct cmd_flow_director_result *res = parsed_result;
8591 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8593 printf("flow director is not supported on port %u.\n",
8598 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8599 RTE_ETH_FILTER_FLUSH, NULL);
8601 printf("flow director table flushing error: (%s)\n",
8605 cmdline_parse_inst_t cmd_flush_flow_director = {
8606 .f = cmd_flush_flow_director_parsed,
8608 .help_str = "flush all flow director entries of a device on NIC",
8610 (void *)&cmd_flush_flow_director_flush,
8611 (void *)&cmd_flush_flow_director_port_id,
8616 /* *** deal with flow director mask *** */
8617 struct cmd_flow_director_mask_result {
8618 cmdline_fixed_string_t flow_director_mask;
8620 cmdline_fixed_string_t mode;
8621 cmdline_fixed_string_t mode_value;
8622 cmdline_fixed_string_t vlan;
8624 cmdline_fixed_string_t src_mask;
8625 cmdline_ipaddr_t ipv4_src;
8626 cmdline_ipaddr_t ipv6_src;
8628 cmdline_fixed_string_t dst_mask;
8629 cmdline_ipaddr_t ipv4_dst;
8630 cmdline_ipaddr_t ipv6_dst;
8632 cmdline_fixed_string_t mac;
8633 uint8_t mac_addr_byte_mask;
8634 cmdline_fixed_string_t tunnel_id;
8635 uint32_t tunnel_id_mask;
8636 cmdline_fixed_string_t tunnel_type;
8637 uint8_t tunnel_type_mask;
8641 cmd_flow_director_mask_parsed(void *parsed_result,
8642 __attribute__((unused)) struct cmdline *cl,
8643 __attribute__((unused)) void *data)
8645 struct cmd_flow_director_mask_result *res = parsed_result;
8646 struct rte_eth_fdir_masks *mask;
8647 struct rte_port *port;
8649 if (res->port_id > nb_ports) {
8650 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8654 port = &ports[res->port_id];
8655 /** Check if the port is not started **/
8656 if (port->port_status != RTE_PORT_STOPPED) {
8657 printf("Please stop port %d first\n", res->port_id);
8661 mask = &port->dev_conf.fdir_conf.mask;
8663 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8664 if (strcmp(res->mode_value, "MAC-VLAN")) {
8665 printf("Please set mode to MAC-VLAN.\n");
8669 mask->vlan_tci_mask = res->vlan_mask;
8670 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8671 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8672 if (strcmp(res->mode_value, "Tunnel")) {
8673 printf("Please set mode to Tunnel.\n");
8677 mask->vlan_tci_mask = res->vlan_mask;
8678 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8679 mask->tunnel_id_mask = res->tunnel_id_mask;
8680 mask->tunnel_type_mask = res->tunnel_type_mask;
8682 if (strcmp(res->mode_value, "IP")) {
8683 printf("Please set mode to IP.\n");
8687 mask->vlan_tci_mask = res->vlan_mask;
8688 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8689 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8690 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8691 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8692 mask->src_port_mask = res->port_src;
8693 mask->dst_port_mask = res->port_dst;
8696 cmd_reconfig_device_queue(res->port_id, 1, 1);
8699 cmdline_parse_token_string_t cmd_flow_director_mask =
8700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8701 flow_director_mask, "flow_director_mask");
8702 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8703 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8705 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8706 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8708 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8709 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8711 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8712 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8713 src_mask, "src_mask");
8714 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8715 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8717 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8718 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8720 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8721 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8723 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8725 dst_mask, "dst_mask");
8726 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8727 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8729 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8730 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8732 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8733 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8736 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8737 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8739 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8740 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8742 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8743 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8744 mode_value, "MAC-VLAN");
8745 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8746 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8747 mode_value, "Tunnel");
8748 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8751 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8752 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8753 mac_addr_byte_mask, UINT8);
8754 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8756 tunnel_type, "tunnel-type");
8757 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8758 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8759 tunnel_type_mask, UINT8);
8760 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8762 tunnel_id, "tunnel-id");
8763 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8764 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8765 tunnel_id_mask, UINT32);
8767 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8768 .f = cmd_flow_director_mask_parsed,
8770 .help_str = "set IP mode flow director's mask on NIC",
8772 (void *)&cmd_flow_director_mask,
8773 (void *)&cmd_flow_director_mask_port_id,
8774 (void *)&cmd_flow_director_mask_mode,
8775 (void *)&cmd_flow_director_mask_mode_ip,
8776 (void *)&cmd_flow_director_mask_vlan,
8777 (void *)&cmd_flow_director_mask_vlan_value,
8778 (void *)&cmd_flow_director_mask_src,
8779 (void *)&cmd_flow_director_mask_ipv4_src,
8780 (void *)&cmd_flow_director_mask_ipv6_src,
8781 (void *)&cmd_flow_director_mask_port_src,
8782 (void *)&cmd_flow_director_mask_dst,
8783 (void *)&cmd_flow_director_mask_ipv4_dst,
8784 (void *)&cmd_flow_director_mask_ipv6_dst,
8785 (void *)&cmd_flow_director_mask_port_dst,
8790 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8791 .f = cmd_flow_director_mask_parsed,
8793 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8795 (void *)&cmd_flow_director_mask,
8796 (void *)&cmd_flow_director_mask_port_id,
8797 (void *)&cmd_flow_director_mask_mode,
8798 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8799 (void *)&cmd_flow_director_mask_vlan,
8800 (void *)&cmd_flow_director_mask_vlan_value,
8801 (void *)&cmd_flow_director_mask_mac,
8802 (void *)&cmd_flow_director_mask_mac_value,
8807 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8808 .f = cmd_flow_director_mask_parsed,
8810 .help_str = "set tunnel mode flow director's mask on NIC",
8812 (void *)&cmd_flow_director_mask,
8813 (void *)&cmd_flow_director_mask_port_id,
8814 (void *)&cmd_flow_director_mask_mode,
8815 (void *)&cmd_flow_director_mask_mode_tunnel,
8816 (void *)&cmd_flow_director_mask_vlan,
8817 (void *)&cmd_flow_director_mask_vlan_value,
8818 (void *)&cmd_flow_director_mask_mac,
8819 (void *)&cmd_flow_director_mask_mac_value,
8820 (void *)&cmd_flow_director_mask_tunnel_type,
8821 (void *)&cmd_flow_director_mask_tunnel_type_value,
8822 (void *)&cmd_flow_director_mask_tunnel_id,
8823 (void *)&cmd_flow_director_mask_tunnel_id_value,
8828 /* *** deal with flow director mask on flexible payload *** */
8829 struct cmd_flow_director_flex_mask_result {
8830 cmdline_fixed_string_t flow_director_flexmask;
8832 cmdline_fixed_string_t flow;
8833 cmdline_fixed_string_t flow_type;
8834 cmdline_fixed_string_t mask;
8838 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8839 __attribute__((unused)) struct cmdline *cl,
8840 __attribute__((unused)) void *data)
8842 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8843 struct rte_eth_fdir_info fdir_info;
8844 struct rte_eth_fdir_flex_mask flex_mask;
8845 struct rte_port *port;
8846 uint32_t flow_type_mask;
8850 if (res->port_id > nb_ports) {
8851 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8855 port = &ports[res->port_id];
8856 /** Check if the port is not started **/
8857 if (port->port_status != RTE_PORT_STOPPED) {
8858 printf("Please stop port %d first\n", res->port_id);
8862 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8863 ret = parse_flexbytes(res->mask,
8865 RTE_ETH_FDIR_MAX_FLEXLEN);
8867 printf("error: Cannot parse mask input.\n");
8871 memset(&fdir_info, 0, sizeof(fdir_info));
8872 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8873 RTE_ETH_FILTER_INFO, &fdir_info);
8875 printf("Cannot get FDir filter info\n");
8879 if (!strcmp(res->flow_type, "none")) {
8880 /* means don't specify the flow type */
8881 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8882 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8883 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8884 0, sizeof(struct rte_eth_fdir_flex_mask));
8885 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8886 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8888 sizeof(struct rte_eth_fdir_flex_mask));
8889 cmd_reconfig_device_queue(res->port_id, 1, 1);
8892 flow_type_mask = fdir_info.flow_types_mask[0];
8893 if (!strcmp(res->flow_type, "all")) {
8894 if (!flow_type_mask) {
8895 printf("No flow type supported\n");
8898 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8899 if (flow_type_mask & (1 << i)) {
8900 flex_mask.flow_type = i;
8901 fdir_set_flex_mask(res->port_id, &flex_mask);
8904 cmd_reconfig_device_queue(res->port_id, 1, 1);
8907 flex_mask.flow_type = str2flowtype(res->flow_type);
8908 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8909 printf("Flow type %s not supported on port %d\n",
8910 res->flow_type, res->port_id);
8913 fdir_set_flex_mask(res->port_id, &flex_mask);
8914 cmd_reconfig_device_queue(res->port_id, 1, 1);
8917 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8918 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8919 flow_director_flexmask,
8920 "flow_director_flex_mask");
8921 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8922 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8924 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8927 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8929 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8930 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8931 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8932 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8935 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8936 .f = cmd_flow_director_flex_mask_parsed,
8938 .help_str = "set flow director's flex mask on NIC",
8940 (void *)&cmd_flow_director_flexmask,
8941 (void *)&cmd_flow_director_flexmask_port_id,
8942 (void *)&cmd_flow_director_flexmask_flow,
8943 (void *)&cmd_flow_director_flexmask_flow_type,
8944 (void *)&cmd_flow_director_flexmask_mask,
8949 /* *** deal with flow director flexible payload configuration *** */
8950 struct cmd_flow_director_flexpayload_result {
8951 cmdline_fixed_string_t flow_director_flexpayload;
8953 cmdline_fixed_string_t payload_layer;
8954 cmdline_fixed_string_t payload_cfg;
8958 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8961 const char *p, *p0 = q_arg;
8963 unsigned long int_fld;
8964 char *str_fld[max_num];
8969 p = strchr(p0, '(');
8973 p0 = strchr(p, ')');
8978 if (size >= sizeof(s))
8981 snprintf(s, sizeof(s), "%.*s", size, p);
8982 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8983 if (ret < 0 || ret > max_num)
8985 for (i = 0; i < ret; i++) {
8987 int_fld = strtoul(str_fld[i], &end, 0);
8988 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8990 offsets[i] = (uint16_t)int_fld;
8996 cmd_flow_director_flxpld_parsed(void *parsed_result,
8997 __attribute__((unused)) struct cmdline *cl,
8998 __attribute__((unused)) void *data)
9000 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9001 struct rte_eth_flex_payload_cfg flex_cfg;
9002 struct rte_port *port;
9005 if (res->port_id > nb_ports) {
9006 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9010 port = &ports[res->port_id];
9011 /** Check if the port is not started **/
9012 if (port->port_status != RTE_PORT_STOPPED) {
9013 printf("Please stop port %d first\n", res->port_id);
9017 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9019 if (!strcmp(res->payload_layer, "raw"))
9020 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9021 else if (!strcmp(res->payload_layer, "l2"))
9022 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9023 else if (!strcmp(res->payload_layer, "l3"))
9024 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9025 else if (!strcmp(res->payload_layer, "l4"))
9026 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9028 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9029 RTE_ETH_FDIR_MAX_FLEXLEN);
9031 printf("error: Cannot parse flex payload input.\n");
9035 fdir_set_flex_payload(res->port_id, &flex_cfg);
9036 cmd_reconfig_device_queue(res->port_id, 1, 1);
9039 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9040 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9041 flow_director_flexpayload,
9042 "flow_director_flex_payload");
9043 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9044 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9046 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9048 payload_layer, "raw#l2#l3#l4");
9049 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9050 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9053 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9054 .f = cmd_flow_director_flxpld_parsed,
9056 .help_str = "set flow director's flex payload on NIC",
9058 (void *)&cmd_flow_director_flexpayload,
9059 (void *)&cmd_flow_director_flexpayload_port_id,
9060 (void *)&cmd_flow_director_flexpayload_payload_layer,
9061 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9066 /* *** Classification Filters Control *** */
9067 /* *** Get symmetric hash enable per port *** */
9068 struct cmd_get_sym_hash_ena_per_port_result {
9069 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9074 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9075 __rte_unused struct cmdline *cl,
9076 __rte_unused void *data)
9078 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9079 struct rte_eth_hash_filter_info info;
9082 if (rte_eth_dev_filter_supported(res->port_id,
9083 RTE_ETH_FILTER_HASH) < 0) {
9084 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9089 memset(&info, 0, sizeof(info));
9090 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9091 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9092 RTE_ETH_FILTER_GET, &info);
9095 printf("Cannot get symmetric hash enable per port "
9096 "on port %u\n", res->port_id);
9100 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9101 "enabled" : "disabled", res->port_id);
9104 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9105 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9106 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9107 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9108 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9111 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9112 .f = cmd_get_sym_hash_per_port_parsed,
9114 .help_str = "get_sym_hash_ena_per_port port_id",
9116 (void *)&cmd_get_sym_hash_ena_per_port_all,
9117 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9122 /* *** Set symmetric hash enable per port *** */
9123 struct cmd_set_sym_hash_ena_per_port_result {
9124 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9125 cmdline_fixed_string_t enable;
9130 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9131 __rte_unused struct cmdline *cl,
9132 __rte_unused void *data)
9134 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9135 struct rte_eth_hash_filter_info info;
9138 if (rte_eth_dev_filter_supported(res->port_id,
9139 RTE_ETH_FILTER_HASH) < 0) {
9140 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9145 memset(&info, 0, sizeof(info));
9146 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9147 if (!strcmp(res->enable, "enable"))
9148 info.info.enable = 1;
9149 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9150 RTE_ETH_FILTER_SET, &info);
9152 printf("Cannot set symmetric hash enable per port on "
9153 "port %u\n", res->port_id);
9156 printf("Symmetric hash has been set to %s on port %u\n",
9157 res->enable, res->port_id);
9160 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9161 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9162 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9163 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9164 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9166 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9167 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9168 enable, "enable#disable");
9170 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9171 .f = cmd_set_sym_hash_per_port_parsed,
9173 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9175 (void *)&cmd_set_sym_hash_ena_per_port_all,
9176 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9177 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9182 /* Get global config of hash function */
9183 struct cmd_get_hash_global_config_result {
9184 cmdline_fixed_string_t get_hash_global_config;
9189 flowtype_to_str(uint16_t ftype)
9196 {"ipv4", RTE_ETH_FLOW_IPV4},
9197 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9198 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9199 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9200 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9201 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9202 {"ipv6", RTE_ETH_FLOW_IPV6},
9203 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9204 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9205 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9206 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9207 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9208 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9211 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9212 if (ftype_table[i].ftype == ftype)
9213 return ftype_table[i].str;
9220 cmd_get_hash_global_config_parsed(void *parsed_result,
9221 __rte_unused struct cmdline *cl,
9222 __rte_unused void *data)
9224 struct cmd_get_hash_global_config_result *res = parsed_result;
9225 struct rte_eth_hash_filter_info info;
9226 uint32_t idx, offset;
9231 if (rte_eth_dev_filter_supported(res->port_id,
9232 RTE_ETH_FILTER_HASH) < 0) {
9233 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9238 memset(&info, 0, sizeof(info));
9239 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9240 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9241 RTE_ETH_FILTER_GET, &info);
9243 printf("Cannot get hash global configurations by port %d\n",
9248 switch (info.info.global_conf.hash_func) {
9249 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9250 printf("Hash function is Toeplitz\n");
9252 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9253 printf("Hash function is Simple XOR\n");
9256 printf("Unknown hash function\n");
9260 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9261 idx = i / UINT32_BIT;
9262 offset = i % UINT32_BIT;
9263 if (!(info.info.global_conf.valid_bit_mask[idx] &
9266 str = flowtype_to_str(i);
9269 printf("Symmetric hash is %s globally for flow type %s "
9271 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9272 (1UL << offset)) ? "enabled" : "disabled"), str,
9277 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9278 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9279 get_hash_global_config, "get_hash_global_config");
9280 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9281 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9284 cmdline_parse_inst_t cmd_get_hash_global_config = {
9285 .f = cmd_get_hash_global_config_parsed,
9287 .help_str = "get_hash_global_config port_id",
9289 (void *)&cmd_get_hash_global_config_all,
9290 (void *)&cmd_get_hash_global_config_port_id,
9295 /* Set global config of hash function */
9296 struct cmd_set_hash_global_config_result {
9297 cmdline_fixed_string_t set_hash_global_config;
9299 cmdline_fixed_string_t hash_func;
9300 cmdline_fixed_string_t flow_type;
9301 cmdline_fixed_string_t enable;
9305 cmd_set_hash_global_config_parsed(void *parsed_result,
9306 __rte_unused struct cmdline *cl,
9307 __rte_unused void *data)
9309 struct cmd_set_hash_global_config_result *res = parsed_result;
9310 struct rte_eth_hash_filter_info info;
9311 uint32_t ftype, idx, offset;
9314 if (rte_eth_dev_filter_supported(res->port_id,
9315 RTE_ETH_FILTER_HASH) < 0) {
9316 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9320 memset(&info, 0, sizeof(info));
9321 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9322 if (!strcmp(res->hash_func, "toeplitz"))
9323 info.info.global_conf.hash_func =
9324 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9325 else if (!strcmp(res->hash_func, "simple_xor"))
9326 info.info.global_conf.hash_func =
9327 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9328 else if (!strcmp(res->hash_func, "default"))
9329 info.info.global_conf.hash_func =
9330 RTE_ETH_HASH_FUNCTION_DEFAULT;
9332 ftype = str2flowtype(res->flow_type);
9333 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9334 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9335 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9336 if (!strcmp(res->enable, "enable"))
9337 info.info.global_conf.sym_hash_enable_mask[idx] |=
9339 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9340 RTE_ETH_FILTER_SET, &info);
9342 printf("Cannot set global hash configurations by port %d\n",
9345 printf("Global hash configurations have been set "
9346 "succcessfully by port %d\n", res->port_id);
9349 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9350 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9351 set_hash_global_config, "set_hash_global_config");
9352 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9353 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9355 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9356 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9357 hash_func, "toeplitz#simple_xor#default");
9358 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9359 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9361 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9362 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9363 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9364 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9365 enable, "enable#disable");
9367 cmdline_parse_inst_t cmd_set_hash_global_config = {
9368 .f = cmd_set_hash_global_config_parsed,
9370 .help_str = "set_hash_global_config port_id "
9371 "toeplitz|simple_xor|default "
9372 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9373 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9376 (void *)&cmd_set_hash_global_config_all,
9377 (void *)&cmd_set_hash_global_config_port_id,
9378 (void *)&cmd_set_hash_global_config_hash_func,
9379 (void *)&cmd_set_hash_global_config_flow_type,
9380 (void *)&cmd_set_hash_global_config_enable,
9385 /* Set hash input set */
9386 struct cmd_set_hash_input_set_result {
9387 cmdline_fixed_string_t set_hash_input_set;
9389 cmdline_fixed_string_t flow_type;
9390 cmdline_fixed_string_t inset_field;
9391 cmdline_fixed_string_t select;
9394 static enum rte_eth_input_set_field
9395 str2inset(char *string)
9399 static const struct {
9401 enum rte_eth_input_set_field inset;
9403 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9404 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9405 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9406 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9407 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9408 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9409 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9410 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9411 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9412 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9413 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9414 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9415 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9416 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9417 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9418 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9419 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9420 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9421 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9422 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9423 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9424 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9425 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9426 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9427 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9428 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9429 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9430 {"none", RTE_ETH_INPUT_SET_NONE},
9433 for (i = 0; i < RTE_DIM(inset_table); i++) {
9434 if (!strcmp(string, inset_table[i].str))
9435 return inset_table[i].inset;
9438 return RTE_ETH_INPUT_SET_UNKNOWN;
9442 cmd_set_hash_input_set_parsed(void *parsed_result,
9443 __rte_unused struct cmdline *cl,
9444 __rte_unused void *data)
9446 struct cmd_set_hash_input_set_result *res = parsed_result;
9447 struct rte_eth_hash_filter_info info;
9449 memset(&info, 0, sizeof(info));
9450 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9451 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9452 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9453 info.info.input_set_conf.inset_size = 1;
9454 if (!strcmp(res->select, "select"))
9455 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9456 else if (!strcmp(res->select, "add"))
9457 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9458 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9459 RTE_ETH_FILTER_SET, &info);
9462 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9463 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9464 set_hash_input_set, "set_hash_input_set");
9465 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9466 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9468 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9469 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9471 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9472 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9473 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9474 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9476 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9477 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9478 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9479 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9480 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9482 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9483 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9484 select, "select#add");
9486 cmdline_parse_inst_t cmd_set_hash_input_set = {
9487 .f = cmd_set_hash_input_set_parsed,
9489 .help_str = "set_hash_input_set <port_id> "
9490 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9491 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9492 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9493 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9494 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9495 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9496 "fld-7th|fld-8th|none select|add",
9498 (void *)&cmd_set_hash_input_set_cmd,
9499 (void *)&cmd_set_hash_input_set_port_id,
9500 (void *)&cmd_set_hash_input_set_flow_type,
9501 (void *)&cmd_set_hash_input_set_field,
9502 (void *)&cmd_set_hash_input_set_select,
9507 /* Set flow director input set */
9508 struct cmd_set_fdir_input_set_result {
9509 cmdline_fixed_string_t set_fdir_input_set;
9511 cmdline_fixed_string_t flow_type;
9512 cmdline_fixed_string_t inset_field;
9513 cmdline_fixed_string_t select;
9517 cmd_set_fdir_input_set_parsed(void *parsed_result,
9518 __rte_unused struct cmdline *cl,
9519 __rte_unused void *data)
9521 struct cmd_set_fdir_input_set_result *res = parsed_result;
9522 struct rte_eth_fdir_filter_info info;
9524 memset(&info, 0, sizeof(info));
9525 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9526 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9527 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9528 info.info.input_set_conf.inset_size = 1;
9529 if (!strcmp(res->select, "select"))
9530 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9531 else if (!strcmp(res->select, "add"))
9532 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9533 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9534 RTE_ETH_FILTER_SET, &info);
9537 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9538 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9539 set_fdir_input_set, "set_fdir_input_set");
9540 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9541 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9543 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9544 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9546 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9547 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9548 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9549 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9551 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9552 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9553 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9554 "fld-7th#fld-8th#none");
9555 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9556 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9557 select, "select#add");
9559 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9560 .f = cmd_set_fdir_input_set_parsed,
9562 .help_str = "set_fdir_input_set <port_id> "
9563 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9564 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9565 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9566 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9567 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9568 "fld-7th|fld-8th|none select|add",
9570 (void *)&cmd_set_fdir_input_set_cmd,
9571 (void *)&cmd_set_fdir_input_set_port_id,
9572 (void *)&cmd_set_fdir_input_set_flow_type,
9573 (void *)&cmd_set_fdir_input_set_field,
9574 (void *)&cmd_set_fdir_input_set_select,
9579 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9580 struct cmd_mcast_addr_result {
9581 cmdline_fixed_string_t mcast_addr_cmd;
9582 cmdline_fixed_string_t what;
9584 struct ether_addr mc_addr;
9587 static void cmd_mcast_addr_parsed(void *parsed_result,
9588 __attribute__((unused)) struct cmdline *cl,
9589 __attribute__((unused)) void *data)
9591 struct cmd_mcast_addr_result *res = parsed_result;
9593 if (!is_multicast_ether_addr(&res->mc_addr)) {
9594 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9595 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9596 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9597 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9600 if (strcmp(res->what, "add") == 0)
9601 mcast_addr_add(res->port_num, &res->mc_addr);
9603 mcast_addr_remove(res->port_num, &res->mc_addr);
9606 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9607 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9608 mcast_addr_cmd, "mcast_addr");
9609 cmdline_parse_token_string_t cmd_mcast_addr_what =
9610 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9612 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9613 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9614 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9615 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9617 cmdline_parse_inst_t cmd_mcast_addr = {
9618 .f = cmd_mcast_addr_parsed,
9620 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9622 (void *)&cmd_mcast_addr_cmd,
9623 (void *)&cmd_mcast_addr_what,
9624 (void *)&cmd_mcast_addr_portnum,
9625 (void *)&cmd_mcast_addr_addr,
9630 /* ******************************************************************************** */
9632 /* list of instructions */
9633 cmdline_parse_ctx_t main_ctx[] = {
9634 (cmdline_parse_inst_t *)&cmd_help_brief,
9635 (cmdline_parse_inst_t *)&cmd_help_long,
9636 (cmdline_parse_inst_t *)&cmd_quit,
9637 (cmdline_parse_inst_t *)&cmd_showport,
9638 (cmdline_parse_inst_t *)&cmd_showqueue,
9639 (cmdline_parse_inst_t *)&cmd_showportall,
9640 (cmdline_parse_inst_t *)&cmd_showcfg,
9641 (cmdline_parse_inst_t *)&cmd_start,
9642 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9643 (cmdline_parse_inst_t *)&cmd_set_link_up,
9644 (cmdline_parse_inst_t *)&cmd_set_link_down,
9645 (cmdline_parse_inst_t *)&cmd_reset,
9646 (cmdline_parse_inst_t *)&cmd_set_numbers,
9647 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9648 (cmdline_parse_inst_t *)&cmd_set_txsplit,
9649 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9650 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9651 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9652 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9653 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9654 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9655 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9656 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9657 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9658 (cmdline_parse_inst_t *)&cmd_set_link_check,
9659 #ifdef RTE_NIC_BYPASS
9660 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9661 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9662 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9663 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9665 #ifdef RTE_LIBRTE_PMD_BOND
9666 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9667 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9668 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9669 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9670 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9671 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9672 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9673 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9674 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9676 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9677 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9678 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9679 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9680 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9681 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
9682 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9683 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9684 (cmdline_parse_inst_t *)&cmd_csum_set,
9685 (cmdline_parse_inst_t *)&cmd_csum_show,
9686 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9687 (cmdline_parse_inst_t *)&cmd_tso_set,
9688 (cmdline_parse_inst_t *)&cmd_tso_show,
9689 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9690 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9691 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9692 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9693 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9694 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9695 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9696 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9697 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9698 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9699 (cmdline_parse_inst_t *)&cmd_config_dcb,
9700 (cmdline_parse_inst_t *)&cmd_read_reg,
9701 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9702 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9703 (cmdline_parse_inst_t *)&cmd_write_reg,
9704 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9705 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9706 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9707 (cmdline_parse_inst_t *)&cmd_stop,
9708 (cmdline_parse_inst_t *)&cmd_mac_addr,
9709 (cmdline_parse_inst_t *)&cmd_set_qmap,
9710 (cmdline_parse_inst_t *)&cmd_operate_port,
9711 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9712 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
9713 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
9714 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9715 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9716 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9717 (cmdline_parse_inst_t *)&cmd_config_mtu,
9718 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9719 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9720 (cmdline_parse_inst_t *)&cmd_config_rss,
9721 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9722 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9723 (cmdline_parse_inst_t *)&cmd_showport_reta,
9724 (cmdline_parse_inst_t *)&cmd_config_burst,
9725 (cmdline_parse_inst_t *)&cmd_config_thresh,
9726 (cmdline_parse_inst_t *)&cmd_config_threshold,
9727 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9728 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9729 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9730 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9731 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9732 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9733 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9734 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9735 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9736 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9737 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9738 (cmdline_parse_inst_t *)&cmd_global_config,
9739 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9740 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9741 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9742 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9743 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9744 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9745 (cmdline_parse_inst_t *)&cmd_dump,
9746 (cmdline_parse_inst_t *)&cmd_dump_one,
9747 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9748 (cmdline_parse_inst_t *)&cmd_syn_filter,
9749 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9750 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9751 (cmdline_parse_inst_t *)&cmd_flex_filter,
9752 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9753 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9754 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9755 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9756 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
9757 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
9758 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9759 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
9760 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
9761 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
9762 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9763 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9764 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9765 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9766 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9767 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9768 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
9769 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
9770 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9774 /* prompt function, called from main on MASTER lcore */
9780 /* initialize non-constant commands */
9781 cmd_set_fwd_mode_init();
9783 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9787 cmdline_interact(cl);
9788 cmdline_stdin_exit(cl);
9792 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9794 if (id == (portid_t)RTE_PORT_ALL) {
9797 FOREACH_PORT(pid, ports) {
9798 /* check if need_reconfig has been set to 1 */
9799 if (ports[pid].need_reconfig == 0)
9800 ports[pid].need_reconfig = dev;
9801 /* check if need_reconfig_queues has been set to 1 */
9802 if (ports[pid].need_reconfig_queues == 0)
9803 ports[pid].need_reconfig_queues = queue;
9805 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9806 /* check if need_reconfig has been set to 1 */
9807 if (ports[id].need_reconfig == 0)
9808 ports[id].need_reconfig = dev;
9809 /* check if need_reconfig_queues has been set to 1 */
9810 if (ports[id].need_reconfig_queues == 0)
9811 ports[id].need_reconfig_queues = queue;
9815 #ifdef RTE_NIC_BYPASS
9816 #include <rte_pci_dev_ids.h>
9818 bypass_is_supported(portid_t port_id)
9820 struct rte_port *port;
9821 struct rte_pci_id *pci_id;
9823 if (port_id_is_invalid(port_id, ENABLED_WARN))
9826 /* Get the device id. */
9827 port = &ports[port_id];
9828 pci_id = &port->dev_info.pci_dev->id;
9830 /* Check if NIC supports bypass. */
9831 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9835 printf("\tBypass not supported for port_id = %d.\n", port_id);