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) (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 [key]\n"
194 " Display the RSS hash functions and RSS hash key"
197 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
198 " Clear information for port_id, or all.\n\n"
200 "show config (rxtx|cores|fwd)\n"
201 " Display the given configuration.\n\n"
203 "read rxd (port_id) (queue_id) (rxd_id)\n"
204 " Display an RX descriptor of a port RX queue.\n\n"
206 "read txd (port_id) (queue_id) (txd_id)\n"
207 " Display a TX descriptor of a port TX queue.\n\n"
211 if (show_all || !strcmp(res->section, "config")) {
217 "Configuration changes only become active when"
218 " forwarding is started/restarted.\n\n"
221 " Reset forwarding to the default configuration.\n\n"
223 "set verbose (level)\n"
224 " Set the debug verbosity level X.\n\n"
227 " Set number of ports.\n\n"
230 " Set number of cores.\n\n"
232 "set coremask (mask)\n"
233 " Set the forwarding cores hexadecimal mask.\n\n"
235 "set portmask (mask)\n"
236 " Set the forwarding ports hexadecimal mask.\n\n"
239 " Set number of packets per burst.\n\n"
241 "set burst tx delay (microseconds) retry (num)\n"
242 " Set the transmit delay time and number of retries"
243 " in mac_retry forwarding mode.\n\n"
245 "set txpkts (x[,y]*)\n"
246 " Set the length of each segment of TXONLY"
249 "set corelist (x[,y]*)\n"
250 " Set the list of forwarding cores.\n\n"
252 "set portlist (x[,y]*)\n"
253 " Set the list of forwarding ports.\n\n"
255 "vlan set strip (on|off) (port_id)\n"
256 " Set the VLAN strip on a port.\n\n"
258 "vlan set stripq (on|off) (port_id,queue_id)\n"
259 " Set the VLAN strip for a queue on a port.\n\n"
261 "vlan set filter (on|off) (port_id)\n"
262 " Set the VLAN filter on a port.\n\n"
264 "vlan set qinq (on|off) (port_id)\n"
265 " Set the VLAN QinQ (extended queue in queue)"
268 "vlan set tpid (value) (port_id)\n"
269 " Set the outer VLAN TPID for Packet Filtering on"
272 "rx_vlan add (vlan_id|all) (port_id)\n"
273 " Add a vlan_id, or all identifiers, to the set"
274 " of VLAN identifiers filtered by port_id.\n\n"
276 "rx_vlan rm (vlan_id|all) (port_id)\n"
277 " Remove a vlan_id, or all identifiers, from the set"
278 " of VLAN identifiers filtered by port_id.\n\n"
280 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
281 " Add a vlan_id, to the set of VLAN identifiers"
282 "filtered for VF(s) from port_id.\n\n"
284 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
285 " Remove a vlan_id, to the set of VLAN identifiers"
286 "filtered for VF(s) from port_id.\n\n"
288 "rx_vlan set tpid (value) (port_id)\n"
289 " Set the outer VLAN TPID for Packet Filtering on"
292 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
293 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
294 " add a tunnel filter of a port.\n\n"
296 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
297 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
298 " remove a tunnel filter of a port.\n\n"
300 "rx_vxlan_port add (udp_port) (port_id)\n"
301 " Add an UDP port for VXLAN packet filter on a port\n\n"
303 "rx_vxlan_port rm (udp_port) (port_id)\n"
304 " Remove an UDP port for VXLAN packet filter on a port\n\n"
306 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
307 " Set hardware insertion of VLAN IDs (single or double VLAN "
308 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
310 "tx_vlan set pvid port_id vlan_id (on|off)\n"
311 " Set port based TX VLAN insertion.\n\n"
313 "tx_vlan reset (port_id)\n"
314 " Disable hardware insertion of a VLAN header in"
315 " packets sent on a port.\n\n"
317 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
318 " Select hardware or software calculation of the"
319 " checksum when transmitting a packet using the"
320 " csum forward engine.\n"
321 " ip|udp|tcp|sctp always concern the inner layer.\n"
322 " outer-ip concerns the outer IP layer in"
323 " case the packet is recognized as a tunnel packet by"
324 " the forward engine (vxlan, gre and ipip are supported)\n"
325 " Please check the NIC datasheet for HW limits.\n\n"
327 "csum parse-tunnel (on|off) (tx_port_id)\n"
328 " If disabled, treat tunnel packets as non-tunneled"
329 " packets (treat inner headers as payload). The port\n"
330 " argument is the port used for TX in csum forward"
333 "csum show (port_id)\n"
334 " Display tx checksum offload configuration\n\n"
336 "tso set (segsize) (portid)\n"
337 " Enable TCP Segmentation Offload in csum forward"
339 " Please check the NIC datasheet for HW limits.\n\n"
342 " Display the status of TCP Segmentation Offload.\n\n"
345 " Set packet forwarding mode.\n\n"
347 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
348 " Add a MAC address on port_id.\n\n"
350 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
351 " Remove a MAC address from port_id.\n\n"
353 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
354 " Add a MAC address for a VF on the port.\n\n"
356 "set port (port_id) uta (mac_address|all) (on|off)\n"
357 " Add/Remove a or all unicast hash filter(s)"
360 "set promisc (port_id|all) (on|off)\n"
361 " Set the promiscuous mode on port_id, or all.\n\n"
363 "set allmulti (port_id|all) (on|off)\n"
364 " Set the allmulti mode on port_id, or all.\n\n"
366 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
367 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
368 " (on|off) autoneg (on|off) (port_id)\n"
369 "set flow_ctrl rx (on|off) (portid)\n"
370 "set flow_ctrl tx (on|off) (portid)\n"
371 "set flow_ctrl high_water (high_water) (portid)\n"
372 "set flow_ctrl low_water (low_water) (portid)\n"
373 "set flow_ctrl pause_time (pause_time) (portid)\n"
374 "set flow_ctrl send_xon (send_xon) (portid)\n"
375 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
376 "set flow_ctrl autoneg (on|off) (port_id)\n"
377 " Set the link flow control parameter on a port.\n\n"
379 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
380 " (low_water) (pause_time) (priority) (port_id)\n"
381 " Set the priority flow control parameter on a"
384 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
385 " Set statistics mapping (qmapping 0..15) for RX/TX"
387 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
388 " on port 0 to mapping 5.\n\n"
390 "set port (port_id) vf (vf_id) rx|tx on|off\n"
391 " Enable/Disable a VF receive/tranmit from a port\n\n"
393 "set port (port_id) vf (vf_id) (mac_addr)"
394 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
395 " Add/Remove unicast or multicast MAC addr filter"
398 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
400 " AUPE:accepts untagged VLAN;"
401 "ROPE:accept unicast hash\n\n"
402 " BAM:accepts broadcast packets;"
403 "MPE:accepts all multicast packets\n\n"
404 " Enable/Disable a VF receive mode of a port\n\n"
406 "set port (port_id) queue (queue_id) rate (rate_num)\n"
407 " Set rate limit for a queue of a port\n\n"
409 "set port (port_id) vf (vf_id) rate (rate_num) "
410 "queue_mask (queue_mask_value)\n"
411 " Set rate limit for queues in VF of a port\n\n"
413 "set port (port_id) mirror-rule (rule_id)"
414 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
415 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
416 " Set pool or vlan type mirror rule on a port.\n"
417 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
418 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
421 "set port (port_id) mirror-rule (rule_id)"
422 " (uplink-mirror|downlink-mirror) dst-pool"
423 " (pool_id) (on|off)\n"
424 " Set uplink or downlink type mirror rule on a port.\n"
425 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
426 " 0 on' enable mirror income traffic to pool 0.\n\n"
428 "reset port (port_id) mirror-rule (rule_id)\n"
429 " Reset a mirror rule.\n\n"
431 "set flush_rx (on|off)\n"
432 " Flush (default) or don't flush RX streams before"
433 " forwarding. Mainly used with PCAP drivers.\n\n"
435 #ifdef RTE_NIC_BYPASS
436 "set bypass mode (normal|bypass|isolate) (port_id)\n"
437 " Set the bypass mode for the lowest port on bypass enabled"
440 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
441 "mode (normal|bypass|isolate) (port_id)\n"
442 " Set the event required to initiate specified bypass mode for"
443 " the lowest port on a bypass enabled NIC where:\n"
444 " timeout = enable bypass after watchdog timeout.\n"
445 " os_on = enable bypass when OS/board is powered on.\n"
446 " os_off = enable bypass when OS/board is powered off.\n"
447 " power_on = enable bypass when power supply is turned on.\n"
448 " power_off = enable bypass when power supply is turned off."
451 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
452 " Set the bypass watchdog timeout to 'n' seconds"
453 " where 0 = instant.\n\n"
455 "show bypass config (port_id)\n"
456 " Show the bypass configuration for a bypass enabled NIC"
457 " using the lowest port on the NIC.\n\n"
459 #ifdef RTE_LIBRTE_PMD_BOND
460 "create bonded device (mode) (socket)\n"
461 " Create a new bonded device with specific bonding mode and socket.\n\n"
463 "add bonding slave (slave_id) (port_id)\n"
464 " Add a slave device to a bonded device.\n\n"
466 "remove bonding slave (slave_id) (port_id)\n"
467 " Remove a slave device from a bonded device.\n\n"
469 "set bonding mode (value) (port_id)\n"
470 " Set the bonding mode on a bonded device.\n\n"
472 "set bonding primary (slave_id) (port_id)\n"
473 " Set the primary slave for a bonded device.\n\n"
475 "show bonding config (port_id)\n"
476 " Show the bonding config for port_id.\n\n"
478 "set bonding mac_addr (port_id) (address)\n"
479 " Set the MAC address of a bonded device.\n\n"
481 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
482 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
484 "set bonding mon_period (port_id) (value)\n"
485 " Set the bonding link status monitoring polling period in ms.\n\n"
487 "set link-up port (port_id)\n"
488 " Set link up for a port.\n\n"
490 "set link-down port (port_id)\n"
491 " Set link down for a port.\n\n"
493 , list_pkt_forwarding_modes()
497 if (show_all || !strcmp(res->section, "ports")) {
503 "----------------\n\n"
505 "port start (port_id|all)\n"
506 " Start all ports or port_id.\n\n"
508 "port stop (port_id|all)\n"
509 " Stop all ports or port_id.\n\n"
511 "port close (port_id|all)\n"
512 " Close all ports or port_id.\n\n"
514 "port attach (ident)\n"
515 " Attach physical or virtual dev by pci address or virtual device name\n\n"
517 "port detach (port_id)\n"
518 " Detach physical or virtual dev by port_id\n\n"
520 "port config (port_id|all)"
521 " speed (10|100|1000|10000|40000|auto)"
522 " duplex (half|full|auto)\n"
523 " Set speed and duplex for all ports or port_id\n\n"
525 "port config all (rxq|txq|rxd|txd) (value)\n"
526 " Set number for rxq/txq/rxd/txd.\n\n"
528 "port config all max-pkt-len (value)\n"
529 " Set the max packet length.\n\n"
531 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
532 "hw-vlan-strip|hw-vlan-extend|drop-en)"
534 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
537 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
538 " Set the RSS mode.\n\n"
540 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
541 " Set the RSS redirection table.\n\n"
543 "port config (port_id) dcb vt (on|off) (traffic_class)"
545 " Set the DCB mode.\n\n"
547 "port config all burst (value)\n"
548 " Set the number of packets per burst.\n\n"
550 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
552 " Set the ring prefetch/host/writeback threshold"
553 " for tx/rx queue.\n\n"
555 "port config all (txfreet|txrst|rxfreet) (value)\n"
556 " Set free threshold for rx/tx, or set"
557 " tx rs bit threshold.\n\n"
558 "port config mtu X value\n"
559 " Set the MTU of port X to a given value\n\n"
561 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
562 " Start/stop a rx/tx queue of port X. Only take effect"
563 " when port X is started\n"
567 if (show_all || !strcmp(res->section, "registers")) {
575 "read reg (port_id) (address)\n"
576 " Display value of a port register.\n\n"
578 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
579 " Display a port register bit field.\n\n"
581 "read regbit (port_id) (address) (bit_x)\n"
582 " Display a single port register bit.\n\n"
584 "write reg (port_id) (address) (value)\n"
585 " Set value of a port register.\n\n"
587 "write regfield (port_id) (address) (bit_x) (bit_y)"
589 " Set bit field of a port register.\n\n"
591 "write regbit (port_id) (address) (bit_x) (value)\n"
592 " Set single bit value of a port register.\n\n"
595 if (show_all || !strcmp(res->section, "filters")) {
603 "ethertype_filter (port_id) (add|del)"
604 " (mac_addr|mac_ignr) (mac_address) ethertype"
605 " (ether_type) (drop|fwd) queue (queue_id)\n"
606 " Add/Del an ethertype filter.\n\n"
608 "2tuple_filter (port_id) (add|del)"
609 " dst_port (dst_port_value) protocol (protocol_value)"
610 " mask (mask_value) tcp_flags (tcp_flags_value)"
611 " priority (prio_value) queue (queue_id)\n"
612 " Add/Del a 2tuple filter.\n\n"
614 "5tuple_filter (port_id) (add|del)"
615 " dst_ip (dst_address) src_ip (src_address)"
616 " dst_port (dst_port_value) src_port (src_port_value)"
617 " protocol (protocol_value)"
618 " mask (mask_value) tcp_flags (tcp_flags_value)"
619 " priority (prio_value) queue (queue_id)\n"
620 " Add/Del a 5tuple filter.\n\n"
622 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
623 " Add/Del syn filter.\n\n"
625 "flex_filter (port_id) (add|del) len (len_value)"
626 " bytes (bytes_value) mask (mask_value)"
627 " priority (prio_value) queue (queue_id)\n"
628 " Add/Del a flex filter.\n\n"
630 "flow_director_filter (port_id) (add|del|update)"
631 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
632 " src (src_ip_address) dst (dst_ip_address)"
633 " vlan (vlan_value) flexbytes (flexbytes_value)"
634 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
635 " Add/Del an IP type flow director filter.\n\n"
637 "flow_director_filter (port_id) (add|del|update)"
638 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
639 " src (src_ip_address) (src_port)"
640 " dst (dst_ip_address) (dst_port)"
641 " vlan (vlan_value) flexbytes (flexbytes_value)"
642 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
643 " Add/Del an UDP/TCP type flow director filter.\n\n"
645 "flow_director_filter (port_id) (add|del|update)"
646 " flow (ipv4-sctp|ipv6-sctp)"
647 " src (src_ip_address) (src_port)"
648 " dst (dst_ip_address) (dst_port)"
649 " tag (verification_tag) vlan (vlan_value)"
650 " flexbytes (flexbytes_value) (drop|fwd)"
651 " queue (queue_id) fd_id (fd_id_value)\n"
652 " Add/Del a SCTP type flow director filter.\n\n"
654 "flow_director_filter (port_id) (add|del|update)"
655 " flow l2_payload ether (ethertype)"
656 " flexbytes (flexbytes_value) (drop|fwd)"
657 " queue (queue_id) fd_id (fd_id_value)\n"
658 " Add/Del a l2 payload type flow director filter.\n\n"
660 "flush_flow_director (port_id)\n"
661 " Flush all flow director entries of a device.\n\n"
663 "flow_director_mask (port_id) vlan (vlan_value)"
664 " src_mask (ipv4_src) (ipv6_src) (src_port)"
665 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
666 " Set flow director mask.\n\n"
668 "flow_director_flex_mask (port_id)"
669 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
670 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
672 " Configure mask of flex payload.\n\n"
674 "flow_director_flex_payload (port_id)"
675 " (raw|l2|l3|l4) (config)\n"
676 " Configure flex payload selection.\n\n"
678 "get_sym_hash_ena_per_port (port_id)\n"
679 " get symmetric hash enable configuration per port.\n\n"
681 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
682 " set symmetric hash enable configuration per port"
683 " to enable or disable.\n\n"
685 "get_hash_global_config (port_id)\n"
686 " Get the global configurations of hash filters.\n\n"
688 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
689 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
690 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
691 " (enable|disable)\n"
692 " Set the global configurations of hash filters.\n\n"
697 cmdline_parse_token_string_t cmd_help_long_help =
698 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
700 cmdline_parse_token_string_t cmd_help_long_section =
701 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
702 "all#control#display#config#"
703 "ports#registers#filters");
705 cmdline_parse_inst_t cmd_help_long = {
706 .f = cmd_help_long_parsed,
708 .help_str = "show help",
710 (void *)&cmd_help_long_help,
711 (void *)&cmd_help_long_section,
717 /* *** start/stop/close all ports *** */
718 struct cmd_operate_port_result {
719 cmdline_fixed_string_t keyword;
720 cmdline_fixed_string_t name;
721 cmdline_fixed_string_t value;
724 static void cmd_operate_port_parsed(void *parsed_result,
725 __attribute__((unused)) struct cmdline *cl,
726 __attribute__((unused)) void *data)
728 struct cmd_operate_port_result *res = parsed_result;
730 if (!strcmp(res->name, "start"))
731 start_port(RTE_PORT_ALL);
732 else if (!strcmp(res->name, "stop"))
733 stop_port(RTE_PORT_ALL);
734 else if (!strcmp(res->name, "close"))
735 close_port(RTE_PORT_ALL);
737 printf("Unknown parameter\n");
740 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
741 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
743 cmdline_parse_token_string_t cmd_operate_port_all_port =
744 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
746 cmdline_parse_token_string_t cmd_operate_port_all_all =
747 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
749 cmdline_parse_inst_t cmd_operate_port = {
750 .f = cmd_operate_port_parsed,
752 .help_str = "port start|stop|close all: start/stop/close all ports",
754 (void *)&cmd_operate_port_all_cmd,
755 (void *)&cmd_operate_port_all_port,
756 (void *)&cmd_operate_port_all_all,
761 /* *** start/stop/close specific port *** */
762 struct cmd_operate_specific_port_result {
763 cmdline_fixed_string_t keyword;
764 cmdline_fixed_string_t name;
768 static void cmd_operate_specific_port_parsed(void *parsed_result,
769 __attribute__((unused)) struct cmdline *cl,
770 __attribute__((unused)) void *data)
772 struct cmd_operate_specific_port_result *res = parsed_result;
774 if (!strcmp(res->name, "start"))
775 start_port(res->value);
776 else if (!strcmp(res->name, "stop"))
777 stop_port(res->value);
778 else if (!strcmp(res->name, "close"))
779 close_port(res->value);
781 printf("Unknown parameter\n");
784 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
785 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
787 cmdline_parse_token_string_t cmd_operate_specific_port_port =
788 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
789 name, "start#stop#close");
790 cmdline_parse_token_num_t cmd_operate_specific_port_id =
791 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
794 cmdline_parse_inst_t cmd_operate_specific_port = {
795 .f = cmd_operate_specific_port_parsed,
797 .help_str = "port start|stop|close X: start/stop/close port X",
799 (void *)&cmd_operate_specific_port_cmd,
800 (void *)&cmd_operate_specific_port_port,
801 (void *)&cmd_operate_specific_port_id,
806 /* *** attach a specified port *** */
807 struct cmd_operate_attach_port_result {
808 cmdline_fixed_string_t port;
809 cmdline_fixed_string_t keyword;
810 cmdline_fixed_string_t identifier;
813 static void cmd_operate_attach_port_parsed(void *parsed_result,
814 __attribute__((unused)) struct cmdline *cl,
815 __attribute__((unused)) void *data)
817 struct cmd_operate_attach_port_result *res = parsed_result;
819 if (!strcmp(res->keyword, "attach"))
820 attach_port(res->identifier);
822 printf("Unknown parameter\n");
825 cmdline_parse_token_string_t cmd_operate_attach_port_port =
826 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
828 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
829 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
831 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
832 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
835 cmdline_parse_inst_t cmd_operate_attach_port = {
836 .f = cmd_operate_attach_port_parsed,
838 .help_str = "port attach identifier, "
839 "identifier: pci address or virtual dev name",
841 (void *)&cmd_operate_attach_port_port,
842 (void *)&cmd_operate_attach_port_keyword,
843 (void *)&cmd_operate_attach_port_identifier,
848 /* *** detach a specified port *** */
849 struct cmd_operate_detach_port_result {
850 cmdline_fixed_string_t port;
851 cmdline_fixed_string_t keyword;
855 static void cmd_operate_detach_port_parsed(void *parsed_result,
856 __attribute__((unused)) struct cmdline *cl,
857 __attribute__((unused)) void *data)
859 struct cmd_operate_detach_port_result *res = parsed_result;
861 if (!strcmp(res->keyword, "detach"))
862 detach_port(res->port_id);
864 printf("Unknown parameter\n");
867 cmdline_parse_token_string_t cmd_operate_detach_port_port =
868 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
870 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
871 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
873 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
874 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
877 cmdline_parse_inst_t cmd_operate_detach_port = {
878 .f = cmd_operate_detach_port_parsed,
880 .help_str = "port detach port_id",
882 (void *)&cmd_operate_detach_port_port,
883 (void *)&cmd_operate_detach_port_keyword,
884 (void *)&cmd_operate_detach_port_port_id,
889 /* *** configure speed for all ports *** */
890 struct cmd_config_speed_all {
891 cmdline_fixed_string_t port;
892 cmdline_fixed_string_t keyword;
893 cmdline_fixed_string_t all;
894 cmdline_fixed_string_t item1;
895 cmdline_fixed_string_t item2;
896 cmdline_fixed_string_t value1;
897 cmdline_fixed_string_t value2;
901 cmd_config_speed_all_parsed(void *parsed_result,
902 __attribute__((unused)) struct cmdline *cl,
903 __attribute__((unused)) void *data)
905 struct cmd_config_speed_all *res = parsed_result;
906 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
907 uint16_t link_duplex = 0;
910 if (!all_ports_stopped()) {
911 printf("Please stop all ports first\n");
915 if (!strcmp(res->value1, "10"))
916 link_speed = ETH_LINK_SPEED_10;
917 else if (!strcmp(res->value1, "100"))
918 link_speed = ETH_LINK_SPEED_100;
919 else if (!strcmp(res->value1, "1000"))
920 link_speed = ETH_LINK_SPEED_1000;
921 else if (!strcmp(res->value1, "10000"))
922 link_speed = ETH_LINK_SPEED_10G;
923 else if (!strcmp(res->value1, "40000"))
924 link_speed = ETH_LINK_SPEED_40G;
925 else if (!strcmp(res->value1, "auto"))
926 link_speed = ETH_LINK_SPEED_AUTONEG;
928 printf("Unknown parameter\n");
932 if (!strcmp(res->value2, "half"))
933 link_duplex = ETH_LINK_HALF_DUPLEX;
934 else if (!strcmp(res->value2, "full"))
935 link_duplex = ETH_LINK_FULL_DUPLEX;
936 else if (!strcmp(res->value2, "auto"))
937 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
939 printf("Unknown parameter\n");
943 FOREACH_PORT(pid, ports) {
944 ports[pid].dev_conf.link_speed = link_speed;
945 ports[pid].dev_conf.link_duplex = link_duplex;
948 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
951 cmdline_parse_token_string_t cmd_config_speed_all_port =
952 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
953 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
954 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
956 cmdline_parse_token_string_t cmd_config_speed_all_all =
957 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
958 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
959 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
960 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
961 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
962 "10#100#1000#10000#40000#auto");
963 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
964 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
965 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
966 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
969 cmdline_parse_inst_t cmd_config_speed_all = {
970 .f = cmd_config_speed_all_parsed,
972 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
975 (void *)&cmd_config_speed_all_port,
976 (void *)&cmd_config_speed_all_keyword,
977 (void *)&cmd_config_speed_all_all,
978 (void *)&cmd_config_speed_all_item1,
979 (void *)&cmd_config_speed_all_value1,
980 (void *)&cmd_config_speed_all_item2,
981 (void *)&cmd_config_speed_all_value2,
986 /* *** configure speed for specific port *** */
987 struct cmd_config_speed_specific {
988 cmdline_fixed_string_t port;
989 cmdline_fixed_string_t keyword;
991 cmdline_fixed_string_t item1;
992 cmdline_fixed_string_t item2;
993 cmdline_fixed_string_t value1;
994 cmdline_fixed_string_t value2;
998 cmd_config_speed_specific_parsed(void *parsed_result,
999 __attribute__((unused)) struct cmdline *cl,
1000 __attribute__((unused)) void *data)
1002 struct cmd_config_speed_specific *res = parsed_result;
1003 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1004 uint16_t link_duplex = 0;
1006 if (!all_ports_stopped()) {
1007 printf("Please stop all ports first\n");
1011 if (port_id_is_invalid(res->id, ENABLED_WARN))
1014 if (!strcmp(res->value1, "10"))
1015 link_speed = ETH_LINK_SPEED_10;
1016 else if (!strcmp(res->value1, "100"))
1017 link_speed = ETH_LINK_SPEED_100;
1018 else if (!strcmp(res->value1, "1000"))
1019 link_speed = ETH_LINK_SPEED_1000;
1020 else if (!strcmp(res->value1, "10000"))
1021 link_speed = ETH_LINK_SPEED_10000;
1022 else if (!strcmp(res->value1, "40000"))
1023 link_speed = ETH_LINK_SPEED_40G;
1024 else if (!strcmp(res->value1, "auto"))
1025 link_speed = ETH_LINK_SPEED_AUTONEG;
1027 printf("Unknown parameter\n");
1031 if (!strcmp(res->value2, "half"))
1032 link_duplex = ETH_LINK_HALF_DUPLEX;
1033 else if (!strcmp(res->value2, "full"))
1034 link_duplex = ETH_LINK_FULL_DUPLEX;
1035 else if (!strcmp(res->value2, "auto"))
1036 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1038 printf("Unknown parameter\n");
1042 ports[res->id].dev_conf.link_speed = link_speed;
1043 ports[res->id].dev_conf.link_duplex = link_duplex;
1045 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1049 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1050 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1052 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1053 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1055 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1056 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1057 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1058 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1060 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1061 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1062 "10#100#1000#10000#40000#auto");
1063 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1064 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1066 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1067 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1070 cmdline_parse_inst_t cmd_config_speed_specific = {
1071 .f = cmd_config_speed_specific_parsed,
1073 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1076 (void *)&cmd_config_speed_specific_port,
1077 (void *)&cmd_config_speed_specific_keyword,
1078 (void *)&cmd_config_speed_specific_id,
1079 (void *)&cmd_config_speed_specific_item1,
1080 (void *)&cmd_config_speed_specific_value1,
1081 (void *)&cmd_config_speed_specific_item2,
1082 (void *)&cmd_config_speed_specific_value2,
1087 /* *** configure txq/rxq, txd/rxd *** */
1088 struct cmd_config_rx_tx {
1089 cmdline_fixed_string_t port;
1090 cmdline_fixed_string_t keyword;
1091 cmdline_fixed_string_t all;
1092 cmdline_fixed_string_t name;
1097 cmd_config_rx_tx_parsed(void *parsed_result,
1098 __attribute__((unused)) struct cmdline *cl,
1099 __attribute__((unused)) void *data)
1101 struct cmd_config_rx_tx *res = parsed_result;
1103 if (!all_ports_stopped()) {
1104 printf("Please stop all ports first\n");
1108 if (!strcmp(res->name, "rxq")) {
1109 if (res->value <= 0) {
1110 printf("rxq %d invalid - must be > 0\n", res->value);
1113 nb_rxq = res->value;
1115 else if (!strcmp(res->name, "txq")) {
1116 if (res->value <= 0) {
1117 printf("txq %d invalid - must be > 0\n", res->value);
1120 nb_txq = res->value;
1122 else if (!strcmp(res->name, "rxd")) {
1123 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1124 printf("rxd %d invalid - must be > 0 && <= %d\n",
1125 res->value, RTE_TEST_RX_DESC_MAX);
1128 nb_rxd = res->value;
1129 } else if (!strcmp(res->name, "txd")) {
1130 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1131 printf("txd %d invalid - must be > 0 && <= %d\n",
1132 res->value, RTE_TEST_TX_DESC_MAX);
1135 nb_txd = res->value;
1137 printf("Unknown parameter\n");
1143 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1146 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1148 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1150 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1152 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1155 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1156 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1158 cmdline_parse_inst_t cmd_config_rx_tx = {
1159 .f = cmd_config_rx_tx_parsed,
1161 .help_str = "port config all rxq|txq|rxd|txd value",
1163 (void *)&cmd_config_rx_tx_port,
1164 (void *)&cmd_config_rx_tx_keyword,
1165 (void *)&cmd_config_rx_tx_all,
1166 (void *)&cmd_config_rx_tx_name,
1167 (void *)&cmd_config_rx_tx_value,
1172 /* *** config max packet length *** */
1173 struct cmd_config_max_pkt_len_result {
1174 cmdline_fixed_string_t port;
1175 cmdline_fixed_string_t keyword;
1176 cmdline_fixed_string_t all;
1177 cmdline_fixed_string_t name;
1182 cmd_config_max_pkt_len_parsed(void *parsed_result,
1183 __attribute__((unused)) struct cmdline *cl,
1184 __attribute__((unused)) void *data)
1186 struct cmd_config_max_pkt_len_result *res = parsed_result;
1188 if (!all_ports_stopped()) {
1189 printf("Please stop all ports first\n");
1193 if (!strcmp(res->name, "max-pkt-len")) {
1194 if (res->value < ETHER_MIN_LEN) {
1195 printf("max-pkt-len can not be less than %d\n",
1199 if (res->value == rx_mode.max_rx_pkt_len)
1202 rx_mode.max_rx_pkt_len = res->value;
1203 if (res->value > ETHER_MAX_LEN)
1204 rx_mode.jumbo_frame = 1;
1206 rx_mode.jumbo_frame = 0;
1208 printf("Unknown parameter\n");
1214 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1217 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1218 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1220 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1221 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1223 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1224 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1226 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1227 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1229 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1230 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1233 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1234 .f = cmd_config_max_pkt_len_parsed,
1236 .help_str = "port config all max-pkt-len value",
1238 (void *)&cmd_config_max_pkt_len_port,
1239 (void *)&cmd_config_max_pkt_len_keyword,
1240 (void *)&cmd_config_max_pkt_len_all,
1241 (void *)&cmd_config_max_pkt_len_name,
1242 (void *)&cmd_config_max_pkt_len_value,
1247 /* *** configure port MTU *** */
1248 struct cmd_config_mtu_result {
1249 cmdline_fixed_string_t port;
1250 cmdline_fixed_string_t keyword;
1251 cmdline_fixed_string_t mtu;
1257 cmd_config_mtu_parsed(void *parsed_result,
1258 __attribute__((unused)) struct cmdline *cl,
1259 __attribute__((unused)) void *data)
1261 struct cmd_config_mtu_result *res = parsed_result;
1263 if (res->value < ETHER_MIN_LEN) {
1264 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1267 port_mtu_set(res->port_id, res->value);
1270 cmdline_parse_token_string_t cmd_config_mtu_port =
1271 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1273 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1274 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1276 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1277 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1279 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1280 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1281 cmdline_parse_token_num_t cmd_config_mtu_value =
1282 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1284 cmdline_parse_inst_t cmd_config_mtu = {
1285 .f = cmd_config_mtu_parsed,
1287 .help_str = "port config mtu value",
1289 (void *)&cmd_config_mtu_port,
1290 (void *)&cmd_config_mtu_keyword,
1291 (void *)&cmd_config_mtu_mtu,
1292 (void *)&cmd_config_mtu_port_id,
1293 (void *)&cmd_config_mtu_value,
1298 /* *** configure rx mode *** */
1299 struct cmd_config_rx_mode_flag {
1300 cmdline_fixed_string_t port;
1301 cmdline_fixed_string_t keyword;
1302 cmdline_fixed_string_t all;
1303 cmdline_fixed_string_t name;
1304 cmdline_fixed_string_t value;
1308 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1309 __attribute__((unused)) struct cmdline *cl,
1310 __attribute__((unused)) void *data)
1312 struct cmd_config_rx_mode_flag *res = parsed_result;
1314 if (!all_ports_stopped()) {
1315 printf("Please stop all ports first\n");
1319 if (!strcmp(res->name, "crc-strip")) {
1320 if (!strcmp(res->value, "on"))
1321 rx_mode.hw_strip_crc = 1;
1322 else if (!strcmp(res->value, "off"))
1323 rx_mode.hw_strip_crc = 0;
1325 printf("Unknown parameter\n");
1328 } else if (!strcmp(res->name, "rx-cksum")) {
1329 if (!strcmp(res->value, "on"))
1330 rx_mode.hw_ip_checksum = 1;
1331 else if (!strcmp(res->value, "off"))
1332 rx_mode.hw_ip_checksum = 0;
1334 printf("Unknown parameter\n");
1337 } else if (!strcmp(res->name, "hw-vlan")) {
1338 if (!strcmp(res->value, "on")) {
1339 rx_mode.hw_vlan_filter = 1;
1340 rx_mode.hw_vlan_strip = 1;
1342 else if (!strcmp(res->value, "off")) {
1343 rx_mode.hw_vlan_filter = 0;
1344 rx_mode.hw_vlan_strip = 0;
1347 printf("Unknown parameter\n");
1350 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1351 if (!strcmp(res->value, "on"))
1352 rx_mode.hw_vlan_filter = 1;
1353 else if (!strcmp(res->value, "off"))
1354 rx_mode.hw_vlan_filter = 0;
1356 printf("Unknown parameter\n");
1359 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1360 if (!strcmp(res->value, "on"))
1361 rx_mode.hw_vlan_strip = 1;
1362 else if (!strcmp(res->value, "off"))
1363 rx_mode.hw_vlan_strip = 0;
1365 printf("Unknown parameter\n");
1368 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1369 if (!strcmp(res->value, "on"))
1370 rx_mode.hw_vlan_extend = 1;
1371 else if (!strcmp(res->value, "off"))
1372 rx_mode.hw_vlan_extend = 0;
1374 printf("Unknown parameter\n");
1377 } else if (!strcmp(res->name, "drop-en")) {
1378 if (!strcmp(res->value, "on"))
1380 else if (!strcmp(res->value, "off"))
1383 printf("Unknown parameter\n");
1387 printf("Unknown parameter\n");
1393 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1396 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1398 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1401 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1403 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1405 "crc-strip#rx-cksum#hw-vlan#"
1406 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1407 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1411 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1412 .f = cmd_config_rx_mode_flag_parsed,
1414 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1415 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1417 (void *)&cmd_config_rx_mode_flag_port,
1418 (void *)&cmd_config_rx_mode_flag_keyword,
1419 (void *)&cmd_config_rx_mode_flag_all,
1420 (void *)&cmd_config_rx_mode_flag_name,
1421 (void *)&cmd_config_rx_mode_flag_value,
1426 /* *** configure rss *** */
1427 struct cmd_config_rss {
1428 cmdline_fixed_string_t port;
1429 cmdline_fixed_string_t keyword;
1430 cmdline_fixed_string_t all;
1431 cmdline_fixed_string_t name;
1432 cmdline_fixed_string_t value;
1436 cmd_config_rss_parsed(void *parsed_result,
1437 __attribute__((unused)) struct cmdline *cl,
1438 __attribute__((unused)) void *data)
1440 struct cmd_config_rss *res = parsed_result;
1441 struct rte_eth_rss_conf rss_conf;
1444 if (!strcmp(res->value, "all"))
1445 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1446 ETH_RSS_UDP | ETH_RSS_SCTP |
1448 else if (!strcmp(res->value, "ip"))
1449 rss_conf.rss_hf = ETH_RSS_IP;
1450 else if (!strcmp(res->value, "udp"))
1451 rss_conf.rss_hf = ETH_RSS_UDP;
1452 else if (!strcmp(res->value, "tcp"))
1453 rss_conf.rss_hf = ETH_RSS_TCP;
1454 else if (!strcmp(res->value, "sctp"))
1455 rss_conf.rss_hf = ETH_RSS_SCTP;
1456 else if (!strcmp(res->value, "ether"))
1457 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1458 else if (!strcmp(res->value, "none"))
1459 rss_conf.rss_hf = 0;
1461 printf("Unknown parameter\n");
1464 rss_conf.rss_key = NULL;
1465 for (i = 0; i < rte_eth_dev_count(); i++)
1466 rte_eth_dev_rss_hash_update(i, &rss_conf);
1469 cmdline_parse_token_string_t cmd_config_rss_port =
1470 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1471 cmdline_parse_token_string_t cmd_config_rss_keyword =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1473 cmdline_parse_token_string_t cmd_config_rss_all =
1474 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1475 cmdline_parse_token_string_t cmd_config_rss_name =
1476 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1477 cmdline_parse_token_string_t cmd_config_rss_value =
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1479 "all#ip#tcp#udp#sctp#ether#none");
1481 cmdline_parse_inst_t cmd_config_rss = {
1482 .f = cmd_config_rss_parsed,
1484 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1486 (void *)&cmd_config_rss_port,
1487 (void *)&cmd_config_rss_keyword,
1488 (void *)&cmd_config_rss_all,
1489 (void *)&cmd_config_rss_name,
1490 (void *)&cmd_config_rss_value,
1495 /* *** configure rss hash key *** */
1496 struct cmd_config_rss_hash_key {
1497 cmdline_fixed_string_t port;
1498 cmdline_fixed_string_t config;
1500 cmdline_fixed_string_t rss_hash_key;
1501 cmdline_fixed_string_t key;
1504 #define RSS_HASH_KEY_LENGTH 40
1506 hexa_digit_to_value(char hexa_digit)
1508 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1509 return (uint8_t) (hexa_digit - '0');
1510 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1511 return (uint8_t) ((hexa_digit - 'a') + 10);
1512 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1513 return (uint8_t) ((hexa_digit - 'A') + 10);
1514 /* Invalid hexa digit */
1519 parse_and_check_key_hexa_digit(char *key, int idx)
1523 hexa_v = hexa_digit_to_value(key[idx]);
1525 printf("invalid key: character %c at position %d is not a "
1526 "valid hexa digit\n", key[idx], idx);
1531 cmd_config_rss_hash_key_parsed(void *parsed_result,
1532 __attribute__((unused)) struct cmdline *cl,
1533 __attribute__((unused)) void *data)
1535 struct cmd_config_rss_hash_key *res = parsed_result;
1536 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1541 /* Check the length of the RSS hash key */
1542 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1543 printf("key length: %d invalid - key must be a string of %d"
1544 "hexa-decimal numbers\n", (int) strlen(res->key),
1545 RSS_HASH_KEY_LENGTH * 2);
1548 /* Translate RSS hash key into binary representation */
1549 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1550 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1553 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1556 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1558 port_rss_hash_key_update(res->port_id, hash_key);
1561 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1563 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1566 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1567 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1568 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1570 rss_hash_key, "rss-hash-key");
1571 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1574 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1575 .f = cmd_config_rss_hash_key_parsed,
1577 .help_str = "port config X rss-hash-key 80 hexa digits",
1579 (void *)&cmd_config_rss_hash_key_port,
1580 (void *)&cmd_config_rss_hash_key_config,
1581 (void *)&cmd_config_rss_hash_key_port_id,
1582 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1583 (void *)&cmd_config_rss_hash_key_value,
1588 /* *** configure port rxq/txq start/stop *** */
1589 struct cmd_config_rxtx_queue {
1590 cmdline_fixed_string_t port;
1592 cmdline_fixed_string_t rxtxq;
1594 cmdline_fixed_string_t opname;
1598 cmd_config_rxtx_queue_parsed(void *parsed_result,
1599 __attribute__((unused)) struct cmdline *cl,
1600 __attribute__((unused)) void *data)
1602 struct cmd_config_rxtx_queue *res = parsed_result;
1607 if (test_done == 0) {
1608 printf("Please stop forwarding first\n");
1612 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1615 if (port_is_started(res->portid) != 1) {
1616 printf("Please start port %u first\n", res->portid);
1620 if (!strcmp(res->rxtxq, "rxq"))
1622 else if (!strcmp(res->rxtxq, "txq"))
1625 printf("Unknown parameter\n");
1629 if (isrx && rx_queue_id_is_invalid(res->qid))
1631 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1634 if (!strcmp(res->opname, "start"))
1636 else if (!strcmp(res->opname, "stop"))
1639 printf("Unknown parameter\n");
1643 if (isstart && isrx)
1644 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1645 else if (!isstart && isrx)
1646 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1647 else if (isstart && !isrx)
1648 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1650 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1652 if (ret == -ENOTSUP)
1653 printf("Function not supported in PMD driver\n");
1656 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1658 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1659 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1660 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1662 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1663 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1664 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1668 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1669 .f = cmd_config_rxtx_queue_parsed,
1671 .help_str = "port X rxq|txq ID start|stop",
1673 (void *)&cmd_config_speed_all_port,
1674 (void *)&cmd_config_rxtx_queue_portid,
1675 (void *)&cmd_config_rxtx_queue_rxtxq,
1676 (void *)&cmd_config_rxtx_queue_qid,
1677 (void *)&cmd_config_rxtx_queue_opname,
1682 /* *** Configure RSS RETA *** */
1683 struct cmd_config_rss_reta {
1684 cmdline_fixed_string_t port;
1685 cmdline_fixed_string_t keyword;
1687 cmdline_fixed_string_t name;
1688 cmdline_fixed_string_t list_name;
1689 cmdline_fixed_string_t list_of_items;
1693 parse_reta_config(const char *str,
1694 struct rte_eth_rss_reta_entry64 *reta_conf,
1695 uint16_t nb_entries)
1699 uint16_t hash_index, idx, shift;
1702 const char *p, *p0 = str;
1709 unsigned long int_fld[_NUM_FLD];
1710 char *str_fld[_NUM_FLD];
1712 while ((p = strchr(p0,'(')) != NULL) {
1714 if((p0 = strchr(p,')')) == NULL)
1718 if(size >= sizeof(s))
1721 snprintf(s, sizeof(s), "%.*s", size, p);
1722 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1724 for (i = 0; i < _NUM_FLD; i++) {
1726 int_fld[i] = strtoul(str_fld[i], &end, 0);
1727 if (errno != 0 || end == str_fld[i] ||
1732 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1733 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1735 if (hash_index >= nb_entries) {
1736 printf("Invalid RETA hash index=%d\n", hash_index);
1740 idx = hash_index / RTE_RETA_GROUP_SIZE;
1741 shift = hash_index % RTE_RETA_GROUP_SIZE;
1742 reta_conf[idx].mask |= (1ULL << shift);
1743 reta_conf[idx].reta[shift] = nb_queue;
1750 cmd_set_rss_reta_parsed(void *parsed_result,
1751 __attribute__((unused)) struct cmdline *cl,
1752 __attribute__((unused)) void *data)
1755 struct rte_eth_dev_info dev_info;
1756 struct rte_eth_rss_reta_entry64 reta_conf[8];
1757 struct cmd_config_rss_reta *res = parsed_result;
1759 memset(&dev_info, 0, sizeof(dev_info));
1760 rte_eth_dev_info_get(res->port_id, &dev_info);
1761 if (dev_info.reta_size == 0) {
1762 printf("Redirection table size is 0 which is "
1763 "invalid for RSS\n");
1766 printf("The reta size of port %d is %u\n",
1767 res->port_id, dev_info.reta_size);
1768 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1769 printf("Currently do not support more than %u entries of "
1770 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1774 memset(reta_conf, 0, sizeof(reta_conf));
1775 if (!strcmp(res->list_name, "reta")) {
1776 if (parse_reta_config(res->list_of_items, reta_conf,
1777 dev_info.reta_size)) {
1778 printf("Invalid RSS Redirection Table "
1779 "config entered\n");
1782 ret = rte_eth_dev_rss_reta_update(res->port_id,
1783 reta_conf, dev_info.reta_size);
1785 printf("Bad redirection table parameter, "
1786 "return code = %d \n", ret);
1790 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1792 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1794 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1795 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1796 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1798 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1799 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1800 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1801 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1803 cmdline_parse_inst_t cmd_config_rss_reta = {
1804 .f = cmd_set_rss_reta_parsed,
1806 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1808 (void *)&cmd_config_rss_reta_port,
1809 (void *)&cmd_config_rss_reta_keyword,
1810 (void *)&cmd_config_rss_reta_port_id,
1811 (void *)&cmd_config_rss_reta_name,
1812 (void *)&cmd_config_rss_reta_list_name,
1813 (void *)&cmd_config_rss_reta_list_of_items,
1818 /* *** SHOW PORT RETA INFO *** */
1819 struct cmd_showport_reta {
1820 cmdline_fixed_string_t show;
1821 cmdline_fixed_string_t port;
1823 cmdline_fixed_string_t rss;
1824 cmdline_fixed_string_t reta;
1826 cmdline_fixed_string_t list_of_items;
1830 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1831 uint16_t nb_entries,
1835 const char *p, *p0 = str;
1839 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1842 p = strchr(p0, '(');
1846 p0 = strchr(p, ')');
1850 if (size >= sizeof(s)) {
1851 printf("The string size exceeds the internal buffer size\n");
1854 snprintf(s, sizeof(s), "%.*s", size, p);
1855 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1856 if (ret <= 0 || ret != num) {
1857 printf("The bits of masks do not match the number of "
1858 "reta entries: %u\n", num);
1861 for (i = 0; i < ret; i++)
1862 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1868 cmd_showport_reta_parsed(void *parsed_result,
1869 __attribute__((unused)) struct cmdline *cl,
1870 __attribute__((unused)) void *data)
1872 struct cmd_showport_reta *res = parsed_result;
1873 struct rte_eth_rss_reta_entry64 reta_conf[8];
1874 struct rte_eth_dev_info dev_info;
1876 memset(&dev_info, 0, sizeof(dev_info));
1877 rte_eth_dev_info_get(res->port_id, &dev_info);
1878 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1879 res->size > ETH_RSS_RETA_SIZE_512) {
1880 printf("Invalid redirection table size: %u\n", res->size);
1884 memset(reta_conf, 0, sizeof(reta_conf));
1885 if (showport_parse_reta_config(reta_conf, res->size,
1886 res->list_of_items) < 0) {
1887 printf("Invalid string: %s for reta masks\n",
1888 res->list_of_items);
1891 port_rss_reta_info(res->port_id, reta_conf, res->size);
1894 cmdline_parse_token_string_t cmd_showport_reta_show =
1895 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1896 cmdline_parse_token_string_t cmd_showport_reta_port =
1897 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1898 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1899 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1900 cmdline_parse_token_string_t cmd_showport_reta_rss =
1901 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1902 cmdline_parse_token_string_t cmd_showport_reta_reta =
1903 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1904 cmdline_parse_token_num_t cmd_showport_reta_size =
1905 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1906 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1907 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1908 list_of_items, NULL);
1910 cmdline_parse_inst_t cmd_showport_reta = {
1911 .f = cmd_showport_reta_parsed,
1913 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1915 (void *)&cmd_showport_reta_show,
1916 (void *)&cmd_showport_reta_port,
1917 (void *)&cmd_showport_reta_port_id,
1918 (void *)&cmd_showport_reta_rss,
1919 (void *)&cmd_showport_reta_reta,
1920 (void *)&cmd_showport_reta_size,
1921 (void *)&cmd_showport_reta_list_of_items,
1926 /* *** Show RSS hash configuration *** */
1927 struct cmd_showport_rss_hash {
1928 cmdline_fixed_string_t show;
1929 cmdline_fixed_string_t port;
1931 cmdline_fixed_string_t rss_hash;
1932 cmdline_fixed_string_t key; /* optional argument */
1935 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1936 __attribute__((unused)) struct cmdline *cl,
1939 struct cmd_showport_rss_hash *res = parsed_result;
1941 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1944 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1945 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1946 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1947 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1948 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1949 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1950 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1951 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1953 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1954 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1956 cmdline_parse_inst_t cmd_showport_rss_hash = {
1957 .f = cmd_showport_rss_hash_parsed,
1959 .help_str = "show port X rss-hash (X = port number)\n",
1961 (void *)&cmd_showport_rss_hash_show,
1962 (void *)&cmd_showport_rss_hash_port,
1963 (void *)&cmd_showport_rss_hash_port_id,
1964 (void *)&cmd_showport_rss_hash_rss_hash,
1969 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1970 .f = cmd_showport_rss_hash_parsed,
1972 .help_str = "show port X rss-hash key (X = port number)\n",
1974 (void *)&cmd_showport_rss_hash_show,
1975 (void *)&cmd_showport_rss_hash_port,
1976 (void *)&cmd_showport_rss_hash_port_id,
1977 (void *)&cmd_showport_rss_hash_rss_hash,
1978 (void *)&cmd_showport_rss_hash_rss_key,
1983 /* *** Configure DCB *** */
1984 struct cmd_config_dcb {
1985 cmdline_fixed_string_t port;
1986 cmdline_fixed_string_t config;
1988 cmdline_fixed_string_t dcb;
1989 cmdline_fixed_string_t vt;
1990 cmdline_fixed_string_t vt_en;
1992 cmdline_fixed_string_t pfc;
1993 cmdline_fixed_string_t pfc_en;
1997 cmd_config_dcb_parsed(void *parsed_result,
1998 __attribute__((unused)) struct cmdline *cl,
1999 __attribute__((unused)) void *data)
2001 struct cmd_config_dcb *res = parsed_result;
2002 struct dcb_config dcb_conf;
2003 portid_t port_id = res->port_id;
2004 struct rte_port *port;
2006 port = &ports[port_id];
2007 /** Check if the port is not started **/
2008 if (port->port_status != RTE_PORT_STOPPED) {
2009 printf("Please stop port %d first\n",port_id);
2013 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
2014 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
2015 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
2019 /* DCB in VT mode */
2020 if (!strncmp(res->vt_en, "on",2))
2021 dcb_conf.dcb_mode = DCB_VT_ENABLED;
2023 dcb_conf.dcb_mode = DCB_ENABLED;
2025 if (!strncmp(res->pfc_en, "on",2)) {
2026 dcb_conf.pfc_en = 1;
2029 dcb_conf.pfc_en = 0;
2031 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
2032 printf("Cannot initialize network ports\n");
2036 cmd_reconfig_device_queue(port_id, 1, 1);
2039 cmdline_parse_token_string_t cmd_config_dcb_port =
2040 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2041 cmdline_parse_token_string_t cmd_config_dcb_config =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2043 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2044 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2045 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2046 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2047 cmdline_parse_token_string_t cmd_config_dcb_vt =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2049 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2050 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2051 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2052 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2053 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2055 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2058 cmdline_parse_inst_t cmd_config_dcb = {
2059 .f = cmd_config_dcb_parsed,
2061 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2063 (void *)&cmd_config_dcb_port,
2064 (void *)&cmd_config_dcb_config,
2065 (void *)&cmd_config_dcb_port_id,
2066 (void *)&cmd_config_dcb_dcb,
2067 (void *)&cmd_config_dcb_vt,
2068 (void *)&cmd_config_dcb_vt_en,
2069 (void *)&cmd_config_dcb_num_tcs,
2070 (void *)&cmd_config_dcb_pfc,
2071 (void *)&cmd_config_dcb_pfc_en,
2076 /* *** configure number of packets per burst *** */
2077 struct cmd_config_burst {
2078 cmdline_fixed_string_t port;
2079 cmdline_fixed_string_t keyword;
2080 cmdline_fixed_string_t all;
2081 cmdline_fixed_string_t name;
2086 cmd_config_burst_parsed(void *parsed_result,
2087 __attribute__((unused)) struct cmdline *cl,
2088 __attribute__((unused)) void *data)
2090 struct cmd_config_burst *res = parsed_result;
2092 if (!all_ports_stopped()) {
2093 printf("Please stop all ports first\n");
2097 if (!strcmp(res->name, "burst")) {
2098 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2099 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2102 nb_pkt_per_burst = res->value;
2104 printf("Unknown parameter\n");
2110 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2113 cmdline_parse_token_string_t cmd_config_burst_port =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2115 cmdline_parse_token_string_t cmd_config_burst_keyword =
2116 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2117 cmdline_parse_token_string_t cmd_config_burst_all =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2119 cmdline_parse_token_string_t cmd_config_burst_name =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2121 cmdline_parse_token_num_t cmd_config_burst_value =
2122 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2124 cmdline_parse_inst_t cmd_config_burst = {
2125 .f = cmd_config_burst_parsed,
2127 .help_str = "port config all burst value",
2129 (void *)&cmd_config_burst_port,
2130 (void *)&cmd_config_burst_keyword,
2131 (void *)&cmd_config_burst_all,
2132 (void *)&cmd_config_burst_name,
2133 (void *)&cmd_config_burst_value,
2138 /* *** configure rx/tx queues *** */
2139 struct cmd_config_thresh {
2140 cmdline_fixed_string_t port;
2141 cmdline_fixed_string_t keyword;
2142 cmdline_fixed_string_t all;
2143 cmdline_fixed_string_t name;
2148 cmd_config_thresh_parsed(void *parsed_result,
2149 __attribute__((unused)) struct cmdline *cl,
2150 __attribute__((unused)) void *data)
2152 struct cmd_config_thresh *res = parsed_result;
2154 if (!all_ports_stopped()) {
2155 printf("Please stop all ports first\n");
2159 if (!strcmp(res->name, "txpt"))
2160 tx_pthresh = res->value;
2161 else if(!strcmp(res->name, "txht"))
2162 tx_hthresh = res->value;
2163 else if(!strcmp(res->name, "txwt"))
2164 tx_wthresh = res->value;
2165 else if(!strcmp(res->name, "rxpt"))
2166 rx_pthresh = res->value;
2167 else if(!strcmp(res->name, "rxht"))
2168 rx_hthresh = res->value;
2169 else if(!strcmp(res->name, "rxwt"))
2170 rx_wthresh = res->value;
2172 printf("Unknown parameter\n");
2178 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2181 cmdline_parse_token_string_t cmd_config_thresh_port =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2183 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2184 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2185 cmdline_parse_token_string_t cmd_config_thresh_all =
2186 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2187 cmdline_parse_token_string_t cmd_config_thresh_name =
2188 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2189 "txpt#txht#txwt#rxpt#rxht#rxwt");
2190 cmdline_parse_token_num_t cmd_config_thresh_value =
2191 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2193 cmdline_parse_inst_t cmd_config_thresh = {
2194 .f = cmd_config_thresh_parsed,
2196 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2198 (void *)&cmd_config_thresh_port,
2199 (void *)&cmd_config_thresh_keyword,
2200 (void *)&cmd_config_thresh_all,
2201 (void *)&cmd_config_thresh_name,
2202 (void *)&cmd_config_thresh_value,
2207 /* *** configure free/rs threshold *** */
2208 struct cmd_config_threshold {
2209 cmdline_fixed_string_t port;
2210 cmdline_fixed_string_t keyword;
2211 cmdline_fixed_string_t all;
2212 cmdline_fixed_string_t name;
2217 cmd_config_threshold_parsed(void *parsed_result,
2218 __attribute__((unused)) struct cmdline *cl,
2219 __attribute__((unused)) void *data)
2221 struct cmd_config_threshold *res = parsed_result;
2223 if (!all_ports_stopped()) {
2224 printf("Please stop all ports first\n");
2228 if (!strcmp(res->name, "txfreet"))
2229 tx_free_thresh = res->value;
2230 else if (!strcmp(res->name, "txrst"))
2231 tx_rs_thresh = res->value;
2232 else if (!strcmp(res->name, "rxfreet"))
2233 rx_free_thresh = res->value;
2235 printf("Unknown parameter\n");
2241 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2244 cmdline_parse_token_string_t cmd_config_threshold_port =
2245 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2246 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2247 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2249 cmdline_parse_token_string_t cmd_config_threshold_all =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2251 cmdline_parse_token_string_t cmd_config_threshold_name =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2253 "txfreet#txrst#rxfreet");
2254 cmdline_parse_token_num_t cmd_config_threshold_value =
2255 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2257 cmdline_parse_inst_t cmd_config_threshold = {
2258 .f = cmd_config_threshold_parsed,
2260 .help_str = "port config all txfreet|txrst|rxfreet value",
2262 (void *)&cmd_config_threshold_port,
2263 (void *)&cmd_config_threshold_keyword,
2264 (void *)&cmd_config_threshold_all,
2265 (void *)&cmd_config_threshold_name,
2266 (void *)&cmd_config_threshold_value,
2272 struct cmd_stop_result {
2273 cmdline_fixed_string_t stop;
2276 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2277 __attribute__((unused)) struct cmdline *cl,
2278 __attribute__((unused)) void *data)
2280 stop_packet_forwarding();
2283 cmdline_parse_token_string_t cmd_stop_stop =
2284 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2286 cmdline_parse_inst_t cmd_stop = {
2287 .f = cmd_stop_parsed,
2289 .help_str = "stop - stop packet forwarding",
2291 (void *)&cmd_stop_stop,
2296 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2299 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2300 unsigned int *parsed_items, int check_unique_values)
2302 unsigned int nb_item;
2310 * First parse all items in the list and store their value.
2315 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2317 if ((c >= '0') && (c <= '9')) {
2318 value = (unsigned int) (value * 10 + (c - '0'));
2323 printf("character %c is not a decimal digit\n", c);
2327 printf("No valid value before comma\n");
2330 if (nb_item < max_items) {
2331 parsed_items[nb_item] = value;
2337 if (nb_item >= max_items) {
2338 printf("Number of %s = %u > %u (maximum items)\n",
2339 item_name, nb_item + 1, max_items);
2342 parsed_items[nb_item++] = value;
2343 if (! check_unique_values)
2347 * Then, check that all values in the list are differents.
2348 * No optimization here...
2350 for (i = 0; i < nb_item; i++) {
2351 for (j = i + 1; j < nb_item; j++) {
2352 if (parsed_items[j] == parsed_items[i]) {
2353 printf("duplicated %s %u at index %u and %u\n",
2354 item_name, parsed_items[i], i, j);
2362 struct cmd_set_list_result {
2363 cmdline_fixed_string_t cmd_keyword;
2364 cmdline_fixed_string_t list_name;
2365 cmdline_fixed_string_t list_of_items;
2368 static void cmd_set_list_parsed(void *parsed_result,
2369 __attribute__((unused)) struct cmdline *cl,
2370 __attribute__((unused)) void *data)
2372 struct cmd_set_list_result *res;
2374 unsigned int lcorelist[RTE_MAX_LCORE];
2375 unsigned int portlist[RTE_MAX_ETHPORTS];
2377 unsigned int nb_item;
2379 if (test_done == 0) {
2380 printf("Please stop forwarding first\n");
2384 res = parsed_result;
2385 if (!strcmp(res->list_name, "corelist")) {
2386 nb_item = parse_item_list(res->list_of_items, "core",
2388 parsed_items.lcorelist, 1);
2390 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2393 if (!strcmp(res->list_name, "portlist")) {
2394 nb_item = parse_item_list(res->list_of_items, "port",
2396 parsed_items.portlist, 1);
2398 set_fwd_ports_list(parsed_items.portlist, nb_item);
2402 cmdline_parse_token_string_t cmd_set_list_keyword =
2403 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2405 cmdline_parse_token_string_t cmd_set_list_name =
2406 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2407 "corelist#portlist");
2408 cmdline_parse_token_string_t cmd_set_list_of_items =
2409 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2412 cmdline_parse_inst_t cmd_set_fwd_list = {
2413 .f = cmd_set_list_parsed,
2415 .help_str = "set corelist|portlist x[,y]*",
2417 (void *)&cmd_set_list_keyword,
2418 (void *)&cmd_set_list_name,
2419 (void *)&cmd_set_list_of_items,
2424 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2426 struct cmd_setmask_result {
2427 cmdline_fixed_string_t set;
2428 cmdline_fixed_string_t mask;
2432 static void cmd_set_mask_parsed(void *parsed_result,
2433 __attribute__((unused)) struct cmdline *cl,
2434 __attribute__((unused)) void *data)
2436 struct cmd_setmask_result *res = parsed_result;
2438 if (test_done == 0) {
2439 printf("Please stop forwarding first\n");
2442 if (!strcmp(res->mask, "coremask"))
2443 set_fwd_lcores_mask(res->hexavalue);
2444 else if (!strcmp(res->mask, "portmask"))
2445 set_fwd_ports_mask(res->hexavalue);
2448 cmdline_parse_token_string_t cmd_setmask_set =
2449 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2450 cmdline_parse_token_string_t cmd_setmask_mask =
2451 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2452 "coremask#portmask");
2453 cmdline_parse_token_num_t cmd_setmask_value =
2454 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2456 cmdline_parse_inst_t cmd_set_fwd_mask = {
2457 .f = cmd_set_mask_parsed,
2459 .help_str = "set coremask|portmask hexadecimal value",
2461 (void *)&cmd_setmask_set,
2462 (void *)&cmd_setmask_mask,
2463 (void *)&cmd_setmask_value,
2469 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2471 struct cmd_set_result {
2472 cmdline_fixed_string_t set;
2473 cmdline_fixed_string_t what;
2477 static void cmd_set_parsed(void *parsed_result,
2478 __attribute__((unused)) struct cmdline *cl,
2479 __attribute__((unused)) void *data)
2481 struct cmd_set_result *res = parsed_result;
2482 if (!strcmp(res->what, "nbport"))
2483 set_fwd_ports_number(res->value);
2484 else if (!strcmp(res->what, "nbcore"))
2485 set_fwd_lcores_number(res->value);
2486 else if (!strcmp(res->what, "burst"))
2487 set_nb_pkt_per_burst(res->value);
2488 else if (!strcmp(res->what, "verbose"))
2489 set_verbose_level(res->value);
2492 cmdline_parse_token_string_t cmd_set_set =
2493 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2494 cmdline_parse_token_string_t cmd_set_what =
2495 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2496 "nbport#nbcore#burst#verbose");
2497 cmdline_parse_token_num_t cmd_set_value =
2498 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2500 cmdline_parse_inst_t cmd_set_numbers = {
2501 .f = cmd_set_parsed,
2503 .help_str = "set nbport|nbcore|burst|verbose value",
2505 (void *)&cmd_set_set,
2506 (void *)&cmd_set_what,
2507 (void *)&cmd_set_value,
2512 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2514 struct cmd_set_txpkts_result {
2515 cmdline_fixed_string_t cmd_keyword;
2516 cmdline_fixed_string_t txpkts;
2517 cmdline_fixed_string_t seg_lengths;
2521 cmd_set_txpkts_parsed(void *parsed_result,
2522 __attribute__((unused)) struct cmdline *cl,
2523 __attribute__((unused)) void *data)
2525 struct cmd_set_txpkts_result *res;
2526 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2527 unsigned int nb_segs;
2529 res = parsed_result;
2530 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2531 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2533 set_tx_pkt_segments(seg_lengths, nb_segs);
2536 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2537 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2538 cmd_keyword, "set");
2539 cmdline_parse_token_string_t cmd_set_txpkts_name =
2540 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2542 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2543 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2546 cmdline_parse_inst_t cmd_set_txpkts = {
2547 .f = cmd_set_txpkts_parsed,
2549 .help_str = "set txpkts x[,y]*",
2551 (void *)&cmd_set_txpkts_keyword,
2552 (void *)&cmd_set_txpkts_name,
2553 (void *)&cmd_set_txpkts_lengths,
2558 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2559 struct cmd_rx_vlan_filter_all_result {
2560 cmdline_fixed_string_t rx_vlan;
2561 cmdline_fixed_string_t what;
2562 cmdline_fixed_string_t all;
2567 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2568 __attribute__((unused)) struct cmdline *cl,
2569 __attribute__((unused)) void *data)
2571 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2573 if (!strcmp(res->what, "add"))
2574 rx_vlan_all_filter_set(res->port_id, 1);
2576 rx_vlan_all_filter_set(res->port_id, 0);
2579 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2580 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2581 rx_vlan, "rx_vlan");
2582 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2583 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2585 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2586 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2588 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2589 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2592 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2593 .f = cmd_rx_vlan_filter_all_parsed,
2595 .help_str = "add/remove all identifiers to/from the set of VLAN "
2596 "Identifiers filtered by a port",
2598 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2599 (void *)&cmd_rx_vlan_filter_all_what,
2600 (void *)&cmd_rx_vlan_filter_all_all,
2601 (void *)&cmd_rx_vlan_filter_all_portid,
2606 /* *** VLAN OFFLOAD SET ON A PORT *** */
2607 struct cmd_vlan_offload_result {
2608 cmdline_fixed_string_t vlan;
2609 cmdline_fixed_string_t set;
2610 cmdline_fixed_string_t what;
2611 cmdline_fixed_string_t on;
2612 cmdline_fixed_string_t port_id;
2616 cmd_vlan_offload_parsed(void *parsed_result,
2617 __attribute__((unused)) struct cmdline *cl,
2618 __attribute__((unused)) void *data)
2621 struct cmd_vlan_offload_result *res = parsed_result;
2624 portid_t port_id = 0;
2628 len = strnlen(str, STR_TOKEN_SIZE);
2630 /* Get port_id first */
2638 tmp = strtoul(str, NULL, 0);
2639 /* If port_id greater that what portid_t can represent, return */
2640 if(tmp >= RTE_MAX_ETHPORTS)
2642 port_id = (portid_t)tmp;
2644 if (!strcmp(res->on, "on"))
2649 if (!strcmp(res->what, "strip"))
2650 rx_vlan_strip_set(port_id, on);
2651 else if(!strcmp(res->what, "stripq")){
2652 uint16_t queue_id = 0;
2654 /* No queue_id, return */
2656 printf("must specify (port,queue_id)\n");
2659 tmp = strtoul(str + i + 1, NULL, 0);
2660 /* If queue_id greater that what 16-bits can represent, return */
2664 queue_id = (uint16_t)tmp;
2665 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2667 else if (!strcmp(res->what, "filter"))
2668 rx_vlan_filter_set(port_id, on);
2670 vlan_extend_set(port_id, on);
2675 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2676 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2678 cmdline_parse_token_string_t cmd_vlan_offload_set =
2679 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2681 cmdline_parse_token_string_t cmd_vlan_offload_what =
2682 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2683 what, "strip#filter#qinq#stripq");
2684 cmdline_parse_token_string_t cmd_vlan_offload_on =
2685 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2687 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2688 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2691 cmdline_parse_inst_t cmd_vlan_offload = {
2692 .f = cmd_vlan_offload_parsed,
2694 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2695 " qinq(extended) for both rx/tx sides ",
2697 (void *)&cmd_vlan_offload_vlan,
2698 (void *)&cmd_vlan_offload_set,
2699 (void *)&cmd_vlan_offload_what,
2700 (void *)&cmd_vlan_offload_on,
2701 (void *)&cmd_vlan_offload_portid,
2706 /* *** VLAN TPID SET ON A PORT *** */
2707 struct cmd_vlan_tpid_result {
2708 cmdline_fixed_string_t vlan;
2709 cmdline_fixed_string_t set;
2710 cmdline_fixed_string_t what;
2716 cmd_vlan_tpid_parsed(void *parsed_result,
2717 __attribute__((unused)) struct cmdline *cl,
2718 __attribute__((unused)) void *data)
2720 struct cmd_vlan_tpid_result *res = parsed_result;
2721 vlan_tpid_set(res->port_id, res->tp_id);
2725 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2726 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2728 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2729 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2731 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2732 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2734 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2735 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2737 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2738 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2741 cmdline_parse_inst_t cmd_vlan_tpid = {
2742 .f = cmd_vlan_tpid_parsed,
2744 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2746 (void *)&cmd_vlan_tpid_vlan,
2747 (void *)&cmd_vlan_tpid_set,
2748 (void *)&cmd_vlan_tpid_what,
2749 (void *)&cmd_vlan_tpid_tpid,
2750 (void *)&cmd_vlan_tpid_portid,
2755 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2756 struct cmd_rx_vlan_filter_result {
2757 cmdline_fixed_string_t rx_vlan;
2758 cmdline_fixed_string_t what;
2764 cmd_rx_vlan_filter_parsed(void *parsed_result,
2765 __attribute__((unused)) struct cmdline *cl,
2766 __attribute__((unused)) void *data)
2768 struct cmd_rx_vlan_filter_result *res = parsed_result;
2770 if (!strcmp(res->what, "add"))
2771 rx_vft_set(res->port_id, res->vlan_id, 1);
2773 rx_vft_set(res->port_id, res->vlan_id, 0);
2776 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2777 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2778 rx_vlan, "rx_vlan");
2779 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2780 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2782 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2783 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2785 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2786 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2789 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2790 .f = cmd_rx_vlan_filter_parsed,
2792 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2793 "Identifiers filtered by a port",
2795 (void *)&cmd_rx_vlan_filter_rx_vlan,
2796 (void *)&cmd_rx_vlan_filter_what,
2797 (void *)&cmd_rx_vlan_filter_vlanid,
2798 (void *)&cmd_rx_vlan_filter_portid,
2803 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2804 struct cmd_tx_vlan_set_result {
2805 cmdline_fixed_string_t tx_vlan;
2806 cmdline_fixed_string_t set;
2812 cmd_tx_vlan_set_parsed(void *parsed_result,
2813 __attribute__((unused)) struct cmdline *cl,
2814 __attribute__((unused)) void *data)
2816 struct cmd_tx_vlan_set_result *res = parsed_result;
2817 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2819 if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
2820 printf("Error, as QinQ has been enabled.\n");
2824 tx_vlan_set(res->port_id, res->vlan_id);
2827 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2828 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2829 tx_vlan, "tx_vlan");
2830 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2831 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2833 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2834 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2836 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2837 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2840 cmdline_parse_inst_t cmd_tx_vlan_set = {
2841 .f = cmd_tx_vlan_set_parsed,
2843 .help_str = "enable hardware insertion of a single VLAN header "
2844 "with a given TAG Identifier in packets sent on a port",
2846 (void *)&cmd_tx_vlan_set_tx_vlan,
2847 (void *)&cmd_tx_vlan_set_set,
2848 (void *)&cmd_tx_vlan_set_portid,
2849 (void *)&cmd_tx_vlan_set_vlanid,
2854 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
2855 struct cmd_tx_vlan_set_qinq_result {
2856 cmdline_fixed_string_t tx_vlan;
2857 cmdline_fixed_string_t set;
2860 uint16_t vlan_id_outer;
2864 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
2865 __attribute__((unused)) struct cmdline *cl,
2866 __attribute__((unused)) void *data)
2868 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
2869 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2871 if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
2872 printf("Error, as QinQ hasn't been enabled.\n");
2876 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
2879 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
2880 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2881 tx_vlan, "tx_vlan");
2882 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
2883 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2885 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
2886 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2888 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
2889 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2891 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
2892 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
2893 vlan_id_outer, UINT16);
2895 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
2896 .f = cmd_tx_vlan_set_qinq_parsed,
2898 .help_str = "enable hardware insertion of double VLAN header "
2899 "with given TAG Identifiers in packets sent on a port",
2901 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
2902 (void *)&cmd_tx_vlan_set_qinq_set,
2903 (void *)&cmd_tx_vlan_set_qinq_portid,
2904 (void *)&cmd_tx_vlan_set_qinq_vlanid,
2905 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
2910 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2911 struct cmd_tx_vlan_set_pvid_result {
2912 cmdline_fixed_string_t tx_vlan;
2913 cmdline_fixed_string_t set;
2914 cmdline_fixed_string_t pvid;
2917 cmdline_fixed_string_t mode;
2921 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2922 __attribute__((unused)) struct cmdline *cl,
2923 __attribute__((unused)) void *data)
2925 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2927 if (strcmp(res->mode, "on") == 0)
2928 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2930 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2933 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2934 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2935 tx_vlan, "tx_vlan");
2936 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2937 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2939 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2940 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2942 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2943 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2945 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2946 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2948 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2949 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2952 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2953 .f = cmd_tx_vlan_set_pvid_parsed,
2955 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2957 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2958 (void *)&cmd_tx_vlan_set_pvid_set,
2959 (void *)&cmd_tx_vlan_set_pvid_pvid,
2960 (void *)&cmd_tx_vlan_set_pvid_port_id,
2961 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2962 (void *)&cmd_tx_vlan_set_pvid_mode,
2967 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2968 struct cmd_tx_vlan_reset_result {
2969 cmdline_fixed_string_t tx_vlan;
2970 cmdline_fixed_string_t reset;
2975 cmd_tx_vlan_reset_parsed(void *parsed_result,
2976 __attribute__((unused)) struct cmdline *cl,
2977 __attribute__((unused)) void *data)
2979 struct cmd_tx_vlan_reset_result *res = parsed_result;
2981 tx_vlan_reset(res->port_id);
2984 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2985 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2986 tx_vlan, "tx_vlan");
2987 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2988 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2990 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2991 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2994 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2995 .f = cmd_tx_vlan_reset_parsed,
2997 .help_str = "disable hardware insertion of a VLAN header in packets "
3000 (void *)&cmd_tx_vlan_reset_tx_vlan,
3001 (void *)&cmd_tx_vlan_reset_reset,
3002 (void *)&cmd_tx_vlan_reset_portid,
3008 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3009 struct cmd_csum_result {
3010 cmdline_fixed_string_t csum;
3011 cmdline_fixed_string_t mode;
3012 cmdline_fixed_string_t proto;
3013 cmdline_fixed_string_t hwsw;
3018 csum_show(int port_id)
3020 struct rte_eth_dev_info dev_info;
3023 ol_flags = ports[port_id].tx_ol_flags;
3024 printf("Parse tunnel is %s\n",
3025 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3026 printf("IP checksum offload is %s\n",
3027 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3028 printf("UDP checksum offload is %s\n",
3029 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3030 printf("TCP checksum offload is %s\n",
3031 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3032 printf("SCTP checksum offload is %s\n",
3033 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3034 printf("Outer-Ip checksum offload is %s\n",
3035 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3037 /* display warnings if configuration is not supported by the NIC */
3038 rte_eth_dev_info_get(port_id, &dev_info);
3039 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3040 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3041 printf("Warning: hardware IP checksum enabled but not "
3042 "supported by port %d\n", port_id);
3044 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3045 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3046 printf("Warning: hardware UDP checksum enabled but not "
3047 "supported by port %d\n", port_id);
3049 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3050 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3051 printf("Warning: hardware TCP checksum enabled but not "
3052 "supported by port %d\n", port_id);
3054 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3055 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3056 printf("Warning: hardware SCTP checksum enabled but not "
3057 "supported by port %d\n", port_id);
3059 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3060 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3061 printf("Warning: hardware outer IP checksum enabled but not "
3062 "supported by port %d\n", port_id);
3067 cmd_csum_parsed(void *parsed_result,
3068 __attribute__((unused)) struct cmdline *cl,
3069 __attribute__((unused)) void *data)
3071 struct cmd_csum_result *res = parsed_result;
3075 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3076 printf("invalid port %d\n", res->port_id);
3080 if (!strcmp(res->mode, "set")) {
3082 if (!strcmp(res->hwsw, "hw"))
3085 if (!strcmp(res->proto, "ip")) {
3086 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3087 } else if (!strcmp(res->proto, "udp")) {
3088 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3089 } else if (!strcmp(res->proto, "tcp")) {
3090 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3091 } else if (!strcmp(res->proto, "sctp")) {
3092 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3093 } else if (!strcmp(res->proto, "outer-ip")) {
3094 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3098 ports[res->port_id].tx_ol_flags |= mask;
3100 ports[res->port_id].tx_ol_flags &= (~mask);
3102 csum_show(res->port_id);
3105 cmdline_parse_token_string_t cmd_csum_csum =
3106 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3108 cmdline_parse_token_string_t cmd_csum_mode =
3109 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3111 cmdline_parse_token_string_t cmd_csum_proto =
3112 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3113 proto, "ip#tcp#udp#sctp#outer-ip");
3114 cmdline_parse_token_string_t cmd_csum_hwsw =
3115 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3117 cmdline_parse_token_num_t cmd_csum_portid =
3118 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3121 cmdline_parse_inst_t cmd_csum_set = {
3122 .f = cmd_csum_parsed,
3124 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3125 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3127 (void *)&cmd_csum_csum,
3128 (void *)&cmd_csum_mode,
3129 (void *)&cmd_csum_proto,
3130 (void *)&cmd_csum_hwsw,
3131 (void *)&cmd_csum_portid,
3136 cmdline_parse_token_string_t cmd_csum_mode_show =
3137 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3140 cmdline_parse_inst_t cmd_csum_show = {
3141 .f = cmd_csum_parsed,
3143 .help_str = "show checksum offload configuration: csum show <port>",
3145 (void *)&cmd_csum_csum,
3146 (void *)&cmd_csum_mode_show,
3147 (void *)&cmd_csum_portid,
3152 /* Enable/disable tunnel parsing */
3153 struct cmd_csum_tunnel_result {
3154 cmdline_fixed_string_t csum;
3155 cmdline_fixed_string_t parse;
3156 cmdline_fixed_string_t onoff;
3161 cmd_csum_tunnel_parsed(void *parsed_result,
3162 __attribute__((unused)) struct cmdline *cl,
3163 __attribute__((unused)) void *data)
3165 struct cmd_csum_tunnel_result *res = parsed_result;
3167 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3170 if (!strcmp(res->onoff, "on"))
3171 ports[res->port_id].tx_ol_flags |=
3172 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3174 ports[res->port_id].tx_ol_flags &=
3175 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3177 csum_show(res->port_id);
3180 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3181 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3183 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3184 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3185 parse, "parse_tunnel");
3186 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3187 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3189 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3190 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3193 cmdline_parse_inst_t cmd_csum_tunnel = {
3194 .f = cmd_csum_tunnel_parsed,
3196 .help_str = "enable/disable parsing of tunnels for csum engine: "
3197 "csum parse_tunnel on|off <tx-port>",
3199 (void *)&cmd_csum_tunnel_csum,
3200 (void *)&cmd_csum_tunnel_parse,
3201 (void *)&cmd_csum_tunnel_onoff,
3202 (void *)&cmd_csum_tunnel_portid,
3207 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3208 struct cmd_tso_set_result {
3209 cmdline_fixed_string_t tso;
3210 cmdline_fixed_string_t mode;
3216 cmd_tso_set_parsed(void *parsed_result,
3217 __attribute__((unused)) struct cmdline *cl,
3218 __attribute__((unused)) void *data)
3220 struct cmd_tso_set_result *res = parsed_result;
3221 struct rte_eth_dev_info dev_info;
3223 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3226 if (!strcmp(res->mode, "set"))
3227 ports[res->port_id].tso_segsz = res->tso_segsz;
3229 if (ports[res->port_id].tso_segsz == 0)
3230 printf("TSO is disabled\n");
3232 printf("TSO segment size is %d\n",
3233 ports[res->port_id].tso_segsz);
3235 /* display warnings if configuration is not supported by the NIC */
3236 rte_eth_dev_info_get(res->port_id, &dev_info);
3237 if ((ports[res->port_id].tso_segsz != 0) &&
3238 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3239 printf("Warning: TSO enabled but not "
3240 "supported by port %d\n", res->port_id);
3244 cmdline_parse_token_string_t cmd_tso_set_tso =
3245 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3247 cmdline_parse_token_string_t cmd_tso_set_mode =
3248 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3250 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3251 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3253 cmdline_parse_token_num_t cmd_tso_set_portid =
3254 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3257 cmdline_parse_inst_t cmd_tso_set = {
3258 .f = cmd_tso_set_parsed,
3260 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3261 "tso set <tso_segsz> <port>",
3263 (void *)&cmd_tso_set_tso,
3264 (void *)&cmd_tso_set_mode,
3265 (void *)&cmd_tso_set_tso_segsz,
3266 (void *)&cmd_tso_set_portid,
3271 cmdline_parse_token_string_t cmd_tso_show_mode =
3272 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3276 cmdline_parse_inst_t cmd_tso_show = {
3277 .f = cmd_tso_set_parsed,
3279 .help_str = "Show TSO segment size for csum engine: "
3282 (void *)&cmd_tso_set_tso,
3283 (void *)&cmd_tso_show_mode,
3284 (void *)&cmd_tso_set_portid,
3289 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3290 struct cmd_set_flush_rx {
3291 cmdline_fixed_string_t set;
3292 cmdline_fixed_string_t flush_rx;
3293 cmdline_fixed_string_t mode;
3297 cmd_set_flush_rx_parsed(void *parsed_result,
3298 __attribute__((unused)) struct cmdline *cl,
3299 __attribute__((unused)) void *data)
3301 struct cmd_set_flush_rx *res = parsed_result;
3302 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3305 cmdline_parse_token_string_t cmd_setflushrx_set =
3306 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3308 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3309 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3310 flush_rx, "flush_rx");
3311 cmdline_parse_token_string_t cmd_setflushrx_mode =
3312 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3316 cmdline_parse_inst_t cmd_set_flush_rx = {
3317 .f = cmd_set_flush_rx_parsed,
3318 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3321 (void *)&cmd_setflushrx_set,
3322 (void *)&cmd_setflushrx_flush_rx,
3323 (void *)&cmd_setflushrx_mode,
3328 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3329 struct cmd_set_link_check {
3330 cmdline_fixed_string_t set;
3331 cmdline_fixed_string_t link_check;
3332 cmdline_fixed_string_t mode;
3336 cmd_set_link_check_parsed(void *parsed_result,
3337 __attribute__((unused)) struct cmdline *cl,
3338 __attribute__((unused)) void *data)
3340 struct cmd_set_link_check *res = parsed_result;
3341 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3344 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3345 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3347 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3348 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3349 link_check, "link_check");
3350 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3351 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3355 cmdline_parse_inst_t cmd_set_link_check = {
3356 .f = cmd_set_link_check_parsed,
3357 .help_str = "set link_check on|off: enable/disable link status check "
3358 "when starting/stopping a port",
3361 (void *)&cmd_setlinkcheck_set,
3362 (void *)&cmd_setlinkcheck_link_check,
3363 (void *)&cmd_setlinkcheck_mode,
3368 #ifdef RTE_NIC_BYPASS
3369 /* *** SET NIC BYPASS MODE *** */
3370 struct cmd_set_bypass_mode_result {
3371 cmdline_fixed_string_t set;
3372 cmdline_fixed_string_t bypass;
3373 cmdline_fixed_string_t mode;
3374 cmdline_fixed_string_t value;
3379 cmd_set_bypass_mode_parsed(void *parsed_result,
3380 __attribute__((unused)) struct cmdline *cl,
3381 __attribute__((unused)) void *data)
3383 struct cmd_set_bypass_mode_result *res = parsed_result;
3384 portid_t port_id = res->port_id;
3385 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3387 if (!bypass_is_supported(port_id))
3390 if (!strcmp(res->value, "bypass"))
3391 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3392 else if (!strcmp(res->value, "isolate"))
3393 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3395 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3397 /* Set the bypass mode for the relevant port. */
3398 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3399 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3403 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3404 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3406 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3407 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3409 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3410 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3412 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3413 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3414 value, "normal#bypass#isolate");
3415 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3416 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3419 cmdline_parse_inst_t cmd_set_bypass_mode = {
3420 .f = cmd_set_bypass_mode_parsed,
3421 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3422 "Set the NIC bypass mode for port_id",
3425 (void *)&cmd_setbypass_mode_set,
3426 (void *)&cmd_setbypass_mode_bypass,
3427 (void *)&cmd_setbypass_mode_mode,
3428 (void *)&cmd_setbypass_mode_value,
3429 (void *)&cmd_setbypass_mode_port,
3434 /* *** SET NIC BYPASS EVENT *** */
3435 struct cmd_set_bypass_event_result {
3436 cmdline_fixed_string_t set;
3437 cmdline_fixed_string_t bypass;
3438 cmdline_fixed_string_t event;
3439 cmdline_fixed_string_t event_value;
3440 cmdline_fixed_string_t mode;
3441 cmdline_fixed_string_t mode_value;
3446 cmd_set_bypass_event_parsed(void *parsed_result,
3447 __attribute__((unused)) struct cmdline *cl,
3448 __attribute__((unused)) void *data)
3451 struct cmd_set_bypass_event_result *res = parsed_result;
3452 portid_t port_id = res->port_id;
3453 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3454 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3456 if (!bypass_is_supported(port_id))
3459 if (!strcmp(res->event_value, "timeout"))
3460 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3461 else if (!strcmp(res->event_value, "os_on"))
3462 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3463 else if (!strcmp(res->event_value, "os_off"))
3464 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3465 else if (!strcmp(res->event_value, "power_on"))
3466 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3467 else if (!strcmp(res->event_value, "power_off"))
3468 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3470 bypass_event = RTE_BYPASS_EVENT_NONE;
3472 if (!strcmp(res->mode_value, "bypass"))
3473 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3474 else if (!strcmp(res->mode_value, "isolate"))
3475 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3477 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3479 /* Set the watchdog timeout. */
3480 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3483 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3484 (rc = rte_eth_dev_wd_timeout_store(port_id,
3485 bypass_timeout)) != 0) {
3486 printf("Failed to set timeout value %u "
3487 "for port %d, errto code: %d.\n",
3488 bypass_timeout, port_id, rc);
3492 /* Set the bypass event to transition to bypass mode. */
3493 if (0 != rte_eth_dev_bypass_event_store(port_id,
3494 bypass_event, bypass_mode)) {
3495 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3500 cmdline_parse_token_string_t cmd_setbypass_event_set =
3501 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3503 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3504 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3506 cmdline_parse_token_string_t cmd_setbypass_event_event =
3507 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3509 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3510 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3511 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3512 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3513 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3515 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3516 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3517 mode_value, "normal#bypass#isolate");
3518 cmdline_parse_token_num_t cmd_setbypass_event_port =
3519 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3522 cmdline_parse_inst_t cmd_set_bypass_event = {
3523 .f = cmd_set_bypass_event_parsed,
3524 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3525 "mode (normal|bypass|isolate) (port_id): "
3526 "Set the NIC bypass event mode for port_id",
3529 (void *)&cmd_setbypass_event_set,
3530 (void *)&cmd_setbypass_event_bypass,
3531 (void *)&cmd_setbypass_event_event,
3532 (void *)&cmd_setbypass_event_event_value,
3533 (void *)&cmd_setbypass_event_mode,
3534 (void *)&cmd_setbypass_event_mode_value,
3535 (void *)&cmd_setbypass_event_port,
3541 /* *** SET NIC BYPASS TIMEOUT *** */
3542 struct cmd_set_bypass_timeout_result {
3543 cmdline_fixed_string_t set;
3544 cmdline_fixed_string_t bypass;
3545 cmdline_fixed_string_t timeout;
3546 cmdline_fixed_string_t value;
3550 cmd_set_bypass_timeout_parsed(void *parsed_result,
3551 __attribute__((unused)) struct cmdline *cl,
3552 __attribute__((unused)) void *data)
3554 struct cmd_set_bypass_timeout_result *res = parsed_result;
3556 if (!strcmp(res->value, "1.5"))
3557 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3558 else if (!strcmp(res->value, "2"))
3559 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3560 else if (!strcmp(res->value, "3"))
3561 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3562 else if (!strcmp(res->value, "4"))
3563 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3564 else if (!strcmp(res->value, "8"))
3565 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3566 else if (!strcmp(res->value, "16"))
3567 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3568 else if (!strcmp(res->value, "32"))
3569 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3571 bypass_timeout = RTE_BYPASS_TMT_OFF;
3574 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3575 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3577 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3578 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3580 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3581 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3582 timeout, "timeout");
3583 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3584 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3585 value, "0#1.5#2#3#4#8#16#32");
3587 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3588 .f = cmd_set_bypass_timeout_parsed,
3589 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3590 "Set the NIC bypass watchdog timeout",
3593 (void *)&cmd_setbypass_timeout_set,
3594 (void *)&cmd_setbypass_timeout_bypass,
3595 (void *)&cmd_setbypass_timeout_timeout,
3596 (void *)&cmd_setbypass_timeout_value,
3601 /* *** SHOW NIC BYPASS MODE *** */
3602 struct cmd_show_bypass_config_result {
3603 cmdline_fixed_string_t show;
3604 cmdline_fixed_string_t bypass;
3605 cmdline_fixed_string_t config;
3610 cmd_show_bypass_config_parsed(void *parsed_result,
3611 __attribute__((unused)) struct cmdline *cl,
3612 __attribute__((unused)) void *data)
3614 struct cmd_show_bypass_config_result *res = parsed_result;
3615 uint32_t event_mode;
3616 uint32_t bypass_mode;
3617 portid_t port_id = res->port_id;
3618 uint32_t timeout = bypass_timeout;
3621 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3622 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3623 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3624 {"UNKNOWN", "normal", "bypass", "isolate"};
3625 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3632 int num_events = (sizeof events) / (sizeof events[0]);
3634 if (!bypass_is_supported(port_id))
3637 /* Display the bypass mode.*/
3638 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3639 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3643 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3644 bypass_mode = RTE_BYPASS_MODE_NONE;
3646 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3649 /* Display the bypass timeout.*/
3650 if (!RTE_BYPASS_TMT_VALID(timeout))
3651 timeout = RTE_BYPASS_TMT_OFF;
3653 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3655 /* Display the bypass events and associated modes. */
3656 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3658 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3659 printf("\tFailed to get bypass mode for event = %s\n",
3662 if (!RTE_BYPASS_MODE_VALID(event_mode))
3663 event_mode = RTE_BYPASS_MODE_NONE;
3665 printf("\tbypass event: %-16s = %s\n", events[i],
3671 cmdline_parse_token_string_t cmd_showbypass_config_show =
3672 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3674 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3675 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3677 cmdline_parse_token_string_t cmd_showbypass_config_config =
3678 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3680 cmdline_parse_token_num_t cmd_showbypass_config_port =
3681 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3684 cmdline_parse_inst_t cmd_show_bypass_config = {
3685 .f = cmd_show_bypass_config_parsed,
3686 .help_str = "show bypass config (port_id): "
3687 "Show the NIC bypass config for port_id",
3690 (void *)&cmd_showbypass_config_show,
3691 (void *)&cmd_showbypass_config_bypass,
3692 (void *)&cmd_showbypass_config_config,
3693 (void *)&cmd_showbypass_config_port,
3699 #ifdef RTE_LIBRTE_PMD_BOND
3700 /* *** SET BONDING MODE *** */
3701 struct cmd_set_bonding_mode_result {
3702 cmdline_fixed_string_t set;
3703 cmdline_fixed_string_t bonding;
3704 cmdline_fixed_string_t mode;
3709 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3710 __attribute__((unused)) struct cmdline *cl,
3711 __attribute__((unused)) void *data)
3713 struct cmd_set_bonding_mode_result *res = parsed_result;
3714 portid_t port_id = res->port_id;
3716 /* Set the bonding mode for the relevant port. */
3717 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3718 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3721 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3722 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3724 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3725 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3726 bonding, "bonding");
3727 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3728 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3730 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3731 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3733 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3734 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3737 cmdline_parse_inst_t cmd_set_bonding_mode = {
3738 .f = cmd_set_bonding_mode_parsed,
3739 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3742 (void *) &cmd_setbonding_mode_set,
3743 (void *) &cmd_setbonding_mode_bonding,
3744 (void *) &cmd_setbonding_mode_mode,
3745 (void *) &cmd_setbonding_mode_value,
3746 (void *) &cmd_setbonding_mode_port,
3751 /* *** SET BALANCE XMIT POLICY *** */
3752 struct cmd_set_bonding_balance_xmit_policy_result {
3753 cmdline_fixed_string_t set;
3754 cmdline_fixed_string_t bonding;
3755 cmdline_fixed_string_t balance_xmit_policy;
3757 cmdline_fixed_string_t policy;
3760 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3761 __attribute__((unused)) struct cmdline *cl,
3762 __attribute__((unused)) void *data)
3764 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3765 portid_t port_id = res->port_id;
3768 if (!strcmp(res->policy, "l2")) {
3769 policy = BALANCE_XMIT_POLICY_LAYER2;
3770 } else if (!strcmp(res->policy, "l23")) {
3771 policy = BALANCE_XMIT_POLICY_LAYER23;
3772 } else if (!strcmp(res->policy, "l34")) {
3773 policy = BALANCE_XMIT_POLICY_LAYER34;
3775 printf("\t Invalid xmit policy selection");
3779 /* Set the bonding mode for the relevant port. */
3780 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3781 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3786 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3789 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3790 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3791 bonding, "bonding");
3792 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3793 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3794 balance_xmit_policy, "balance_xmit_policy");
3795 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3796 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3798 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3799 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3800 policy, "l2#l23#l34");
3802 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3803 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3804 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3807 (void *)&cmd_setbonding_balance_xmit_policy_set,
3808 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3809 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3810 (void *)&cmd_setbonding_balance_xmit_policy_port,
3811 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3816 /* *** SHOW NIC BONDING CONFIGURATION *** */
3817 struct cmd_show_bonding_config_result {
3818 cmdline_fixed_string_t show;
3819 cmdline_fixed_string_t bonding;
3820 cmdline_fixed_string_t config;
3824 static void cmd_show_bonding_config_parsed(void *parsed_result,
3825 __attribute__((unused)) struct cmdline *cl,
3826 __attribute__((unused)) void *data)
3828 struct cmd_show_bonding_config_result *res = parsed_result;
3830 uint8_t slaves[RTE_MAX_ETHPORTS];
3831 int num_slaves, num_active_slaves;
3834 portid_t port_id = res->port_id;
3836 /* Display the bonding mode.*/
3837 bonding_mode = rte_eth_bond_mode_get(port_id);
3838 if (bonding_mode < 0) {
3839 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3842 printf("\tBonding mode: %d\n", bonding_mode);
3844 if (bonding_mode == BONDING_MODE_BALANCE) {
3845 int balance_xmit_policy;
3847 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3848 if (balance_xmit_policy < 0) {
3849 printf("\tFailed to get balance xmit policy for port = %d\n",
3853 printf("\tBalance Xmit Policy: ");
3855 switch (balance_xmit_policy) {
3856 case BALANCE_XMIT_POLICY_LAYER2:
3857 printf("BALANCE_XMIT_POLICY_LAYER2");
3859 case BALANCE_XMIT_POLICY_LAYER23:
3860 printf("BALANCE_XMIT_POLICY_LAYER23");
3862 case BALANCE_XMIT_POLICY_LAYER34:
3863 printf("BALANCE_XMIT_POLICY_LAYER34");
3870 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3872 if (num_slaves < 0) {
3873 printf("\tFailed to get slave list for port = %d\n", port_id);
3876 if (num_slaves > 0) {
3877 printf("\tSlaves (%d): [", num_slaves);
3878 for (i = 0; i < num_slaves - 1; i++)
3879 printf("%d ", slaves[i]);
3881 printf("%d]\n", slaves[num_slaves - 1]);
3883 printf("\tSlaves: []\n");
3887 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3890 if (num_active_slaves < 0) {
3891 printf("\tFailed to get active slave list for port = %d\n", port_id);
3894 if (num_active_slaves > 0) {
3895 printf("\tActive Slaves (%d): [", num_active_slaves);
3896 for (i = 0; i < num_active_slaves - 1; i++)
3897 printf("%d ", slaves[i]);
3899 printf("%d]\n", slaves[num_active_slaves - 1]);
3902 printf("\tActive Slaves: []\n");
3906 primary_id = rte_eth_bond_primary_get(port_id);
3907 if (primary_id < 0) {
3908 printf("\tFailed to get primary slave for port = %d\n", port_id);
3911 printf("\tPrimary: [%d]\n", primary_id);
3915 cmdline_parse_token_string_t cmd_showbonding_config_show =
3916 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3918 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3919 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3920 bonding, "bonding");
3921 cmdline_parse_token_string_t cmd_showbonding_config_config =
3922 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3924 cmdline_parse_token_num_t cmd_showbonding_config_port =
3925 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3928 cmdline_parse_inst_t cmd_show_bonding_config = {
3929 .f = cmd_show_bonding_config_parsed,
3930 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3933 (void *)&cmd_showbonding_config_show,
3934 (void *)&cmd_showbonding_config_bonding,
3935 (void *)&cmd_showbonding_config_config,
3936 (void *)&cmd_showbonding_config_port,
3941 /* *** SET BONDING PRIMARY *** */
3942 struct cmd_set_bonding_primary_result {
3943 cmdline_fixed_string_t set;
3944 cmdline_fixed_string_t bonding;
3945 cmdline_fixed_string_t primary;
3950 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3951 __attribute__((unused)) struct cmdline *cl,
3952 __attribute__((unused)) void *data)
3954 struct cmd_set_bonding_primary_result *res = parsed_result;
3955 portid_t master_port_id = res->port_id;
3956 portid_t slave_port_id = res->slave_id;
3958 /* Set the primary slave for a bonded device. */
3959 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3960 printf("\t Failed to set primary slave for port = %d.\n",
3967 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3970 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3971 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3972 bonding, "bonding");
3973 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3974 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3975 primary, "primary");
3976 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3977 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3979 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3980 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3983 cmdline_parse_inst_t cmd_set_bonding_primary = {
3984 .f = cmd_set_bonding_primary_parsed,
3985 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3988 (void *)&cmd_setbonding_primary_set,
3989 (void *)&cmd_setbonding_primary_bonding,
3990 (void *)&cmd_setbonding_primary_primary,
3991 (void *)&cmd_setbonding_primary_slave,
3992 (void *)&cmd_setbonding_primary_port,
3997 /* *** ADD SLAVE *** */
3998 struct cmd_add_bonding_slave_result {
3999 cmdline_fixed_string_t add;
4000 cmdline_fixed_string_t bonding;
4001 cmdline_fixed_string_t slave;
4006 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4007 __attribute__((unused)) struct cmdline *cl,
4008 __attribute__((unused)) void *data)
4010 struct cmd_add_bonding_slave_result *res = parsed_result;
4011 portid_t master_port_id = res->port_id;
4012 portid_t slave_port_id = res->slave_id;
4014 /* Set the primary slave for a bonded device. */
4015 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4016 printf("\t Failed to add slave %d to master port = %d.\n",
4017 slave_port_id, master_port_id);
4021 set_port_slave_flag(slave_port_id);
4024 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4025 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4027 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4028 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4029 bonding, "bonding");
4030 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4031 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4033 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4034 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4036 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4037 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4040 cmdline_parse_inst_t cmd_add_bonding_slave = {
4041 .f = cmd_add_bonding_slave_parsed,
4042 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4045 (void *)&cmd_addbonding_slave_add,
4046 (void *)&cmd_addbonding_slave_bonding,
4047 (void *)&cmd_addbonding_slave_slave,
4048 (void *)&cmd_addbonding_slave_slaveid,
4049 (void *)&cmd_addbonding_slave_port,
4054 /* *** REMOVE SLAVE *** */
4055 struct cmd_remove_bonding_slave_result {
4056 cmdline_fixed_string_t remove;
4057 cmdline_fixed_string_t bonding;
4058 cmdline_fixed_string_t slave;
4063 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4064 __attribute__((unused)) struct cmdline *cl,
4065 __attribute__((unused)) void *data)
4067 struct cmd_remove_bonding_slave_result *res = parsed_result;
4068 portid_t master_port_id = res->port_id;
4069 portid_t slave_port_id = res->slave_id;
4071 /* Set the primary slave for a bonded device. */
4072 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4073 printf("\t Failed to remove slave %d from master port = %d.\n",
4074 slave_port_id, master_port_id);
4078 clear_port_slave_flag(slave_port_id);
4081 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4082 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4084 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4085 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4086 bonding, "bonding");
4087 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4088 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4090 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4091 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4093 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4094 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4097 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4098 .f = cmd_remove_bonding_slave_parsed,
4099 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4102 (void *)&cmd_removebonding_slave_remove,
4103 (void *)&cmd_removebonding_slave_bonding,
4104 (void *)&cmd_removebonding_slave_slave,
4105 (void *)&cmd_removebonding_slave_slaveid,
4106 (void *)&cmd_removebonding_slave_port,
4111 /* *** CREATE BONDED DEVICE *** */
4112 struct cmd_create_bonded_device_result {
4113 cmdline_fixed_string_t create;
4114 cmdline_fixed_string_t bonded;
4115 cmdline_fixed_string_t device;
4120 static int bond_dev_num = 0;
4122 static void cmd_create_bonded_device_parsed(void *parsed_result,
4123 __attribute__((unused)) struct cmdline *cl,
4124 __attribute__((unused)) void *data)
4126 struct cmd_create_bonded_device_result *res = parsed_result;
4127 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4130 if (test_done == 0) {
4131 printf("Please stop forwarding first\n");
4135 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4138 /* Create a new bonded device. */
4139 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4141 printf("\t Failed to create bonded device.\n");
4144 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4147 /* Update number of ports */
4148 nb_ports = rte_eth_dev_count();
4149 reconfig(port_id, res->socket);
4150 rte_eth_promiscuous_enable(port_id);
4151 ports[port_id].enabled = 1;
4156 cmdline_parse_token_string_t cmd_createbonded_device_create =
4157 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4159 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4160 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4162 cmdline_parse_token_string_t cmd_createbonded_device_device =
4163 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4165 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4166 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4168 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4169 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4172 cmdline_parse_inst_t cmd_create_bonded_device = {
4173 .f = cmd_create_bonded_device_parsed,
4174 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4177 (void *)&cmd_createbonded_device_create,
4178 (void *)&cmd_createbonded_device_bonded,
4179 (void *)&cmd_createbonded_device_device,
4180 (void *)&cmd_createbonded_device_mode,
4181 (void *)&cmd_createbonded_device_socket,
4186 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4187 struct cmd_set_bond_mac_addr_result {
4188 cmdline_fixed_string_t set;
4189 cmdline_fixed_string_t bonding;
4190 cmdline_fixed_string_t mac_addr;
4192 struct ether_addr address;
4195 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4196 __attribute__((unused)) struct cmdline *cl,
4197 __attribute__((unused)) void *data)
4199 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4202 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4205 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4207 /* check the return value and print it if is < 0 */
4209 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4212 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4213 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4214 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4215 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4217 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4218 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4220 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4221 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4222 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4223 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4225 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4226 .f = cmd_set_bond_mac_addr_parsed,
4228 .help_str = "set bonding mac_addr (port_id) (address): ",
4230 (void *)&cmd_set_bond_mac_addr_set,
4231 (void *)&cmd_set_bond_mac_addr_bonding,
4232 (void *)&cmd_set_bond_mac_addr_mac,
4233 (void *)&cmd_set_bond_mac_addr_portnum,
4234 (void *)&cmd_set_bond_mac_addr_addr,
4240 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4241 struct cmd_set_bond_mon_period_result {
4242 cmdline_fixed_string_t set;
4243 cmdline_fixed_string_t bonding;
4244 cmdline_fixed_string_t mon_period;
4249 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4250 __attribute__((unused)) struct cmdline *cl,
4251 __attribute__((unused)) void *data)
4253 struct cmd_set_bond_mon_period_result *res = parsed_result;
4256 if (res->port_num >= nb_ports) {
4257 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4261 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4263 /* check the return value and print it if is < 0 */
4265 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4268 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4269 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4271 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4272 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4273 bonding, "bonding");
4274 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4275 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4276 mon_period, "mon_period");
4277 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4278 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4280 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4281 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4284 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4285 .f = cmd_set_bond_mon_period_parsed,
4287 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4289 (void *)&cmd_set_bond_mon_period_set,
4290 (void *)&cmd_set_bond_mon_period_bonding,
4291 (void *)&cmd_set_bond_mon_period_mon_period,
4292 (void *)&cmd_set_bond_mon_period_portnum,
4293 (void *)&cmd_set_bond_mon_period_period_ms,
4298 #endif /* RTE_LIBRTE_PMD_BOND */
4300 /* *** SET FORWARDING MODE *** */
4301 struct cmd_set_fwd_mode_result {
4302 cmdline_fixed_string_t set;
4303 cmdline_fixed_string_t fwd;
4304 cmdline_fixed_string_t mode;
4307 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4308 __attribute__((unused)) struct cmdline *cl,
4309 __attribute__((unused)) void *data)
4311 struct cmd_set_fwd_mode_result *res = parsed_result;
4313 set_pkt_forwarding_mode(res->mode);
4316 cmdline_parse_token_string_t cmd_setfwd_set =
4317 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4318 cmdline_parse_token_string_t cmd_setfwd_fwd =
4319 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4320 cmdline_parse_token_string_t cmd_setfwd_mode =
4321 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4322 "" /* defined at init */);
4324 cmdline_parse_inst_t cmd_set_fwd_mode = {
4325 .f = cmd_set_fwd_mode_parsed,
4327 .help_str = NULL, /* defined at init */
4329 (void *)&cmd_setfwd_set,
4330 (void *)&cmd_setfwd_fwd,
4331 (void *)&cmd_setfwd_mode,
4336 static void cmd_set_fwd_mode_init(void)
4339 static char token[128];
4340 static char help[256];
4341 cmdline_parse_token_string_t *token_struct;
4343 modes = list_pkt_forwarding_modes();
4344 snprintf(help, sizeof help, "set fwd %s - "
4345 "set packet forwarding mode", modes);
4346 cmd_set_fwd_mode.help_str = help;
4348 /* string token separator is # */
4349 for (c = token; *modes != '\0'; modes++)
4354 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4355 token_struct->string_data.str = token;
4358 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4359 struct cmd_set_burst_tx_retry_result {
4360 cmdline_fixed_string_t set;
4361 cmdline_fixed_string_t burst;
4362 cmdline_fixed_string_t tx;
4363 cmdline_fixed_string_t delay;
4365 cmdline_fixed_string_t retry;
4369 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4370 __attribute__((unused)) struct cmdline *cl,
4371 __attribute__((unused)) void *data)
4373 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4375 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4376 && !strcmp(res->tx, "tx")) {
4377 if (!strcmp(res->delay, "delay"))
4378 burst_tx_delay_time = res->time;
4379 if (!strcmp(res->retry, "retry"))
4380 burst_tx_retry_num = res->retry_num;
4385 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4386 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4387 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4388 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4390 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4391 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4392 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4393 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4394 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4395 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4396 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4397 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4398 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4399 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4401 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4402 .f = cmd_set_burst_tx_retry_parsed,
4403 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4405 (void *)&cmd_set_burst_tx_retry_set,
4406 (void *)&cmd_set_burst_tx_retry_burst,
4407 (void *)&cmd_set_burst_tx_retry_tx,
4408 (void *)&cmd_set_burst_tx_retry_delay,
4409 (void *)&cmd_set_burst_tx_retry_time,
4410 (void *)&cmd_set_burst_tx_retry_retry,
4411 (void *)&cmd_set_burst_tx_retry_retry_num,
4416 /* *** SET PROMISC MODE *** */
4417 struct cmd_set_promisc_mode_result {
4418 cmdline_fixed_string_t set;
4419 cmdline_fixed_string_t promisc;
4420 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4421 uint8_t port_num; /* valid if "allports" argument == 0 */
4422 cmdline_fixed_string_t mode;
4425 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4426 __attribute__((unused)) struct cmdline *cl,
4429 struct cmd_set_promisc_mode_result *res = parsed_result;
4433 if (!strcmp(res->mode, "on"))
4440 FOREACH_PORT(i, ports) {
4442 rte_eth_promiscuous_enable(i);
4444 rte_eth_promiscuous_disable(i);
4449 rte_eth_promiscuous_enable(res->port_num);
4451 rte_eth_promiscuous_disable(res->port_num);
4455 cmdline_parse_token_string_t cmd_setpromisc_set =
4456 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4457 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4458 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4460 cmdline_parse_token_string_t cmd_setpromisc_portall =
4461 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4463 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4464 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4466 cmdline_parse_token_string_t cmd_setpromisc_mode =
4467 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4470 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4471 .f = cmd_set_promisc_mode_parsed,
4473 .help_str = "set promisc all on|off: set promisc mode for all ports",
4475 (void *)&cmd_setpromisc_set,
4476 (void *)&cmd_setpromisc_promisc,
4477 (void *)&cmd_setpromisc_portall,
4478 (void *)&cmd_setpromisc_mode,
4483 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4484 .f = cmd_set_promisc_mode_parsed,
4486 .help_str = "set promisc X on|off: set promisc mode on port X",
4488 (void *)&cmd_setpromisc_set,
4489 (void *)&cmd_setpromisc_promisc,
4490 (void *)&cmd_setpromisc_portnum,
4491 (void *)&cmd_setpromisc_mode,
4496 /* *** SET ALLMULTI MODE *** */
4497 struct cmd_set_allmulti_mode_result {
4498 cmdline_fixed_string_t set;
4499 cmdline_fixed_string_t allmulti;
4500 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4501 uint8_t port_num; /* valid if "allports" argument == 0 */
4502 cmdline_fixed_string_t mode;
4505 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4506 __attribute__((unused)) struct cmdline *cl,
4509 struct cmd_set_allmulti_mode_result *res = parsed_result;
4513 if (!strcmp(res->mode, "on"))
4520 FOREACH_PORT(i, ports) {
4522 rte_eth_allmulticast_enable(i);
4524 rte_eth_allmulticast_disable(i);
4529 rte_eth_allmulticast_enable(res->port_num);
4531 rte_eth_allmulticast_disable(res->port_num);
4535 cmdline_parse_token_string_t cmd_setallmulti_set =
4536 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4537 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4538 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4540 cmdline_parse_token_string_t cmd_setallmulti_portall =
4541 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4543 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4544 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4546 cmdline_parse_token_string_t cmd_setallmulti_mode =
4547 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4550 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4551 .f = cmd_set_allmulti_mode_parsed,
4553 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4555 (void *)&cmd_setallmulti_set,
4556 (void *)&cmd_setallmulti_allmulti,
4557 (void *)&cmd_setallmulti_portall,
4558 (void *)&cmd_setallmulti_mode,
4563 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4564 .f = cmd_set_allmulti_mode_parsed,
4566 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4568 (void *)&cmd_setallmulti_set,
4569 (void *)&cmd_setallmulti_allmulti,
4570 (void *)&cmd_setallmulti_portnum,
4571 (void *)&cmd_setallmulti_mode,
4576 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4577 struct cmd_link_flow_ctrl_set_result {
4578 cmdline_fixed_string_t set;
4579 cmdline_fixed_string_t flow_ctrl;
4580 cmdline_fixed_string_t rx;
4581 cmdline_fixed_string_t rx_lfc_mode;
4582 cmdline_fixed_string_t tx;
4583 cmdline_fixed_string_t tx_lfc_mode;
4584 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4585 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4586 cmdline_fixed_string_t autoneg_str;
4587 cmdline_fixed_string_t autoneg;
4588 cmdline_fixed_string_t hw_str;
4589 uint32_t high_water;
4590 cmdline_fixed_string_t lw_str;
4592 cmdline_fixed_string_t pt_str;
4593 uint16_t pause_time;
4594 cmdline_fixed_string_t xon_str;
4599 cmdline_parse_token_string_t cmd_lfc_set_set =
4600 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4602 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4603 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4604 flow_ctrl, "flow_ctrl");
4605 cmdline_parse_token_string_t cmd_lfc_set_rx =
4606 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4608 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4609 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4610 rx_lfc_mode, "on#off");
4611 cmdline_parse_token_string_t cmd_lfc_set_tx =
4612 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4614 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4615 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4616 tx_lfc_mode, "on#off");
4617 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4618 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4619 hw_str, "high_water");
4620 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4621 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4622 high_water, UINT32);
4623 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4624 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4625 lw_str, "low_water");
4626 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4627 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4629 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4630 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4631 pt_str, "pause_time");
4632 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4633 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4634 pause_time, UINT16);
4635 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4636 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4637 xon_str, "send_xon");
4638 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4639 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4641 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4642 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4643 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4644 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4645 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4646 mac_ctrl_frame_fwd_mode, "on#off");
4647 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4648 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4649 autoneg_str, "autoneg");
4650 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4651 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4653 cmdline_parse_token_num_t cmd_lfc_set_portid =
4654 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4657 /* forward declaration */
4659 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4662 cmdline_parse_inst_t cmd_link_flow_control_set = {
4663 .f = cmd_link_flow_ctrl_set_parsed,
4665 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4666 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4667 autoneg on|off port_id",
4669 (void *)&cmd_lfc_set_set,
4670 (void *)&cmd_lfc_set_flow_ctrl,
4671 (void *)&cmd_lfc_set_rx,
4672 (void *)&cmd_lfc_set_rx_mode,
4673 (void *)&cmd_lfc_set_tx,
4674 (void *)&cmd_lfc_set_tx_mode,
4675 (void *)&cmd_lfc_set_high_water,
4676 (void *)&cmd_lfc_set_low_water,
4677 (void *)&cmd_lfc_set_pause_time,
4678 (void *)&cmd_lfc_set_send_xon,
4679 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4680 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4681 (void *)&cmd_lfc_set_autoneg_str,
4682 (void *)&cmd_lfc_set_autoneg,
4683 (void *)&cmd_lfc_set_portid,
4688 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4689 .f = cmd_link_flow_ctrl_set_parsed,
4690 .data = (void *)&cmd_link_flow_control_set_rx,
4691 .help_str = "Change rx flow control parameter: set flow_ctrl "
4692 "rx on|off port_id",
4694 (void *)&cmd_lfc_set_set,
4695 (void *)&cmd_lfc_set_flow_ctrl,
4696 (void *)&cmd_lfc_set_rx,
4697 (void *)&cmd_lfc_set_rx_mode,
4698 (void *)&cmd_lfc_set_portid,
4703 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4704 .f = cmd_link_flow_ctrl_set_parsed,
4705 .data = (void *)&cmd_link_flow_control_set_tx,
4706 .help_str = "Change tx flow control parameter: set flow_ctrl "
4707 "tx on|off port_id",
4709 (void *)&cmd_lfc_set_set,
4710 (void *)&cmd_lfc_set_flow_ctrl,
4711 (void *)&cmd_lfc_set_tx,
4712 (void *)&cmd_lfc_set_tx_mode,
4713 (void *)&cmd_lfc_set_portid,
4718 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4719 .f = cmd_link_flow_ctrl_set_parsed,
4720 .data = (void *)&cmd_link_flow_control_set_hw,
4721 .help_str = "Change high water flow control parameter: set flow_ctrl "
4722 "high_water value port_id",
4724 (void *)&cmd_lfc_set_set,
4725 (void *)&cmd_lfc_set_flow_ctrl,
4726 (void *)&cmd_lfc_set_high_water_str,
4727 (void *)&cmd_lfc_set_high_water,
4728 (void *)&cmd_lfc_set_portid,
4733 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4734 .f = cmd_link_flow_ctrl_set_parsed,
4735 .data = (void *)&cmd_link_flow_control_set_lw,
4736 .help_str = "Change low water flow control parameter: set flow_ctrl "
4737 "low_water value port_id",
4739 (void *)&cmd_lfc_set_set,
4740 (void *)&cmd_lfc_set_flow_ctrl,
4741 (void *)&cmd_lfc_set_low_water_str,
4742 (void *)&cmd_lfc_set_low_water,
4743 (void *)&cmd_lfc_set_portid,
4748 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4749 .f = cmd_link_flow_ctrl_set_parsed,
4750 .data = (void *)&cmd_link_flow_control_set_pt,
4751 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4752 "pause_time value port_id",
4754 (void *)&cmd_lfc_set_set,
4755 (void *)&cmd_lfc_set_flow_ctrl,
4756 (void *)&cmd_lfc_set_pause_time_str,
4757 (void *)&cmd_lfc_set_pause_time,
4758 (void *)&cmd_lfc_set_portid,
4763 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4764 .f = cmd_link_flow_ctrl_set_parsed,
4765 .data = (void *)&cmd_link_flow_control_set_xon,
4766 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4767 "send_xon value port_id",
4769 (void *)&cmd_lfc_set_set,
4770 (void *)&cmd_lfc_set_flow_ctrl,
4771 (void *)&cmd_lfc_set_send_xon_str,
4772 (void *)&cmd_lfc_set_send_xon,
4773 (void *)&cmd_lfc_set_portid,
4778 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4779 .f = cmd_link_flow_ctrl_set_parsed,
4780 .data = (void *)&cmd_link_flow_control_set_macfwd,
4781 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4782 "mac_ctrl_frame_fwd on|off port_id",
4784 (void *)&cmd_lfc_set_set,
4785 (void *)&cmd_lfc_set_flow_ctrl,
4786 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4787 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4788 (void *)&cmd_lfc_set_portid,
4793 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4794 .f = cmd_link_flow_ctrl_set_parsed,
4795 .data = (void *)&cmd_link_flow_control_set_autoneg,
4796 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4797 "autoneg on|off port_id",
4799 (void *)&cmd_lfc_set_set,
4800 (void *)&cmd_lfc_set_flow_ctrl,
4801 (void *)&cmd_lfc_set_autoneg_str,
4802 (void *)&cmd_lfc_set_autoneg,
4803 (void *)&cmd_lfc_set_portid,
4809 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4810 __attribute__((unused)) struct cmdline *cl,
4813 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4814 cmdline_parse_inst_t *cmd = data;
4815 struct rte_eth_fc_conf fc_conf;
4821 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4822 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4823 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4824 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4826 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4827 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4830 /* Partial command line, retrieve current configuration */
4832 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4834 printf("cannot get current flow ctrl parameters, return"
4835 "code = %d\n", ret);
4839 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4840 (fc_conf.mode == RTE_FC_FULL))
4842 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4843 (fc_conf.mode == RTE_FC_FULL))
4847 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4848 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4850 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4851 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4853 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4855 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4856 fc_conf.high_water = res->high_water;
4858 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4859 fc_conf.low_water = res->low_water;
4861 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4862 fc_conf.pause_time = res->pause_time;
4864 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4865 fc_conf.send_xon = res->send_xon;
4867 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4868 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4869 fc_conf.mac_ctrl_frame_fwd = 1;
4871 fc_conf.mac_ctrl_frame_fwd = 0;
4874 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4875 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4877 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4879 printf("bad flow contrl parameter, return code = %d \n", ret);
4882 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4883 struct cmd_priority_flow_ctrl_set_result {
4884 cmdline_fixed_string_t set;
4885 cmdline_fixed_string_t pfc_ctrl;
4886 cmdline_fixed_string_t rx;
4887 cmdline_fixed_string_t rx_pfc_mode;
4888 cmdline_fixed_string_t tx;
4889 cmdline_fixed_string_t tx_pfc_mode;
4890 uint32_t high_water;
4892 uint16_t pause_time;
4898 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4899 __attribute__((unused)) struct cmdline *cl,
4900 __attribute__((unused)) void *data)
4902 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4903 struct rte_eth_pfc_conf pfc_conf;
4904 int rx_fc_enable, tx_fc_enable;
4908 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4909 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4910 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4911 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4913 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4914 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4917 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4918 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4919 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4920 pfc_conf.fc.high_water = res->high_water;
4921 pfc_conf.fc.low_water = res->low_water;
4922 pfc_conf.fc.pause_time = res->pause_time;
4923 pfc_conf.priority = res->priority;
4925 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4927 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4930 cmdline_parse_token_string_t cmd_pfc_set_set =
4931 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4933 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4934 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4935 pfc_ctrl, "pfc_ctrl");
4936 cmdline_parse_token_string_t cmd_pfc_set_rx =
4937 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4939 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4940 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4941 rx_pfc_mode, "on#off");
4942 cmdline_parse_token_string_t cmd_pfc_set_tx =
4943 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4945 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4946 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4947 tx_pfc_mode, "on#off");
4948 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4949 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4950 high_water, UINT32);
4951 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4952 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4954 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4955 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4956 pause_time, UINT16);
4957 cmdline_parse_token_num_t cmd_pfc_set_priority =
4958 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4960 cmdline_parse_token_num_t cmd_pfc_set_portid =
4961 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4964 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4965 .f = cmd_priority_flow_ctrl_set_parsed,
4967 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4968 tx on|off high_water low_water pause_time priority port_id",
4970 (void *)&cmd_pfc_set_set,
4971 (void *)&cmd_pfc_set_flow_ctrl,
4972 (void *)&cmd_pfc_set_rx,
4973 (void *)&cmd_pfc_set_rx_mode,
4974 (void *)&cmd_pfc_set_tx,
4975 (void *)&cmd_pfc_set_tx_mode,
4976 (void *)&cmd_pfc_set_high_water,
4977 (void *)&cmd_pfc_set_low_water,
4978 (void *)&cmd_pfc_set_pause_time,
4979 (void *)&cmd_pfc_set_priority,
4980 (void *)&cmd_pfc_set_portid,
4985 /* *** RESET CONFIGURATION *** */
4986 struct cmd_reset_result {
4987 cmdline_fixed_string_t reset;
4988 cmdline_fixed_string_t def;
4991 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4993 __attribute__((unused)) void *data)
4995 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4996 set_def_fwd_config();
4999 cmdline_parse_token_string_t cmd_reset_set =
5000 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5001 cmdline_parse_token_string_t cmd_reset_def =
5002 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5005 cmdline_parse_inst_t cmd_reset = {
5006 .f = cmd_reset_parsed,
5008 .help_str = "set default: reset default forwarding configuration",
5010 (void *)&cmd_reset_set,
5011 (void *)&cmd_reset_def,
5016 /* *** START FORWARDING *** */
5017 struct cmd_start_result {
5018 cmdline_fixed_string_t start;
5021 cmdline_parse_token_string_t cmd_start_start =
5022 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5024 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5025 __attribute__((unused)) struct cmdline *cl,
5026 __attribute__((unused)) void *data)
5028 start_packet_forwarding(0);
5031 cmdline_parse_inst_t cmd_start = {
5032 .f = cmd_start_parsed,
5034 .help_str = "start packet forwarding",
5036 (void *)&cmd_start_start,
5041 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5042 struct cmd_start_tx_first_result {
5043 cmdline_fixed_string_t start;
5044 cmdline_fixed_string_t tx_first;
5048 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5049 __attribute__((unused)) struct cmdline *cl,
5050 __attribute__((unused)) void *data)
5052 start_packet_forwarding(1);
5055 cmdline_parse_token_string_t cmd_start_tx_first_start =
5056 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5058 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5059 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5060 tx_first, "tx_first");
5062 cmdline_parse_inst_t cmd_start_tx_first = {
5063 .f = cmd_start_tx_first_parsed,
5065 .help_str = "start packet forwarding, after sending 1 burst of packets",
5067 (void *)&cmd_start_tx_first_start,
5068 (void *)&cmd_start_tx_first_tx_first,
5073 /* *** SET LINK UP *** */
5074 struct cmd_set_link_up_result {
5075 cmdline_fixed_string_t set;
5076 cmdline_fixed_string_t link_up;
5077 cmdline_fixed_string_t port;
5081 cmdline_parse_token_string_t cmd_set_link_up_set =
5082 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5083 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5084 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5086 cmdline_parse_token_string_t cmd_set_link_up_port =
5087 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5088 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5089 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5091 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5092 __attribute__((unused)) struct cmdline *cl,
5093 __attribute__((unused)) void *data)
5095 struct cmd_set_link_up_result *res = parsed_result;
5096 dev_set_link_up(res->port_id);
5099 cmdline_parse_inst_t cmd_set_link_up = {
5100 .f = cmd_set_link_up_parsed,
5102 .help_str = "set link-up port (port id)",
5104 (void *)&cmd_set_link_up_set,
5105 (void *)&cmd_set_link_up_link_up,
5106 (void *)&cmd_set_link_up_port,
5107 (void *)&cmd_set_link_up_port_id,
5112 /* *** SET LINK DOWN *** */
5113 struct cmd_set_link_down_result {
5114 cmdline_fixed_string_t set;
5115 cmdline_fixed_string_t link_down;
5116 cmdline_fixed_string_t port;
5120 cmdline_parse_token_string_t cmd_set_link_down_set =
5121 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5122 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5123 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5125 cmdline_parse_token_string_t cmd_set_link_down_port =
5126 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5127 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5128 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5130 static void cmd_set_link_down_parsed(
5131 __attribute__((unused)) void *parsed_result,
5132 __attribute__((unused)) struct cmdline *cl,
5133 __attribute__((unused)) void *data)
5135 struct cmd_set_link_down_result *res = parsed_result;
5136 dev_set_link_down(res->port_id);
5139 cmdline_parse_inst_t cmd_set_link_down = {
5140 .f = cmd_set_link_down_parsed,
5142 .help_str = "set link-down port (port id)",
5144 (void *)&cmd_set_link_down_set,
5145 (void *)&cmd_set_link_down_link_down,
5146 (void *)&cmd_set_link_down_port,
5147 (void *)&cmd_set_link_down_port_id,
5152 /* *** SHOW CFG *** */
5153 struct cmd_showcfg_result {
5154 cmdline_fixed_string_t show;
5155 cmdline_fixed_string_t cfg;
5156 cmdline_fixed_string_t what;
5159 static void cmd_showcfg_parsed(void *parsed_result,
5160 __attribute__((unused)) struct cmdline *cl,
5161 __attribute__((unused)) void *data)
5163 struct cmd_showcfg_result *res = parsed_result;
5164 if (!strcmp(res->what, "rxtx"))
5165 rxtx_config_display();
5166 else if (!strcmp(res->what, "cores"))
5167 fwd_lcores_config_display();
5168 else if (!strcmp(res->what, "fwd"))
5169 fwd_config_display();
5172 cmdline_parse_token_string_t cmd_showcfg_show =
5173 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5174 cmdline_parse_token_string_t cmd_showcfg_port =
5175 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5176 cmdline_parse_token_string_t cmd_showcfg_what =
5177 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5180 cmdline_parse_inst_t cmd_showcfg = {
5181 .f = cmd_showcfg_parsed,
5183 .help_str = "show config rxtx|cores|fwd",
5185 (void *)&cmd_showcfg_show,
5186 (void *)&cmd_showcfg_port,
5187 (void *)&cmd_showcfg_what,
5192 /* *** SHOW ALL PORT INFO *** */
5193 struct cmd_showportall_result {
5194 cmdline_fixed_string_t show;
5195 cmdline_fixed_string_t port;
5196 cmdline_fixed_string_t what;
5197 cmdline_fixed_string_t all;
5200 static void cmd_showportall_parsed(void *parsed_result,
5201 __attribute__((unused)) struct cmdline *cl,
5202 __attribute__((unused)) void *data)
5206 struct cmd_showportall_result *res = parsed_result;
5207 if (!strcmp(res->show, "clear")) {
5208 if (!strcmp(res->what, "stats"))
5209 FOREACH_PORT(i, ports)
5211 else if (!strcmp(res->what, "xstats"))
5212 FOREACH_PORT(i, ports)
5213 nic_xstats_clear(i);
5214 } else if (!strcmp(res->what, "info"))
5215 FOREACH_PORT(i, ports)
5216 port_infos_display(i);
5217 else if (!strcmp(res->what, "stats"))
5218 FOREACH_PORT(i, ports)
5219 nic_stats_display(i);
5220 else if (!strcmp(res->what, "xstats"))
5221 FOREACH_PORT(i, ports)
5222 nic_xstats_display(i);
5223 else if (!strcmp(res->what, "fdir"))
5224 FOREACH_PORT(i, ports)
5226 else if (!strcmp(res->what, "stat_qmap"))
5227 FOREACH_PORT(i, ports)
5228 nic_stats_mapping_display(i);
5231 cmdline_parse_token_string_t cmd_showportall_show =
5232 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5234 cmdline_parse_token_string_t cmd_showportall_port =
5235 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5236 cmdline_parse_token_string_t cmd_showportall_what =
5237 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5238 "info#stats#xstats#fdir#stat_qmap");
5239 cmdline_parse_token_string_t cmd_showportall_all =
5240 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5241 cmdline_parse_inst_t cmd_showportall = {
5242 .f = cmd_showportall_parsed,
5244 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5246 (void *)&cmd_showportall_show,
5247 (void *)&cmd_showportall_port,
5248 (void *)&cmd_showportall_what,
5249 (void *)&cmd_showportall_all,
5254 /* *** SHOW PORT INFO *** */
5255 struct cmd_showport_result {
5256 cmdline_fixed_string_t show;
5257 cmdline_fixed_string_t port;
5258 cmdline_fixed_string_t what;
5262 static void cmd_showport_parsed(void *parsed_result,
5263 __attribute__((unused)) struct cmdline *cl,
5264 __attribute__((unused)) void *data)
5266 struct cmd_showport_result *res = parsed_result;
5267 if (!strcmp(res->show, "clear")) {
5268 if (!strcmp(res->what, "stats"))
5269 nic_stats_clear(res->portnum);
5270 else if (!strcmp(res->what, "xstats"))
5271 nic_xstats_clear(res->portnum);
5272 } else if (!strcmp(res->what, "info"))
5273 port_infos_display(res->portnum);
5274 else if (!strcmp(res->what, "stats"))
5275 nic_stats_display(res->portnum);
5276 else if (!strcmp(res->what, "xstats"))
5277 nic_xstats_display(res->portnum);
5278 else if (!strcmp(res->what, "fdir"))
5279 fdir_get_infos(res->portnum);
5280 else if (!strcmp(res->what, "stat_qmap"))
5281 nic_stats_mapping_display(res->portnum);
5284 cmdline_parse_token_string_t cmd_showport_show =
5285 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5287 cmdline_parse_token_string_t cmd_showport_port =
5288 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5289 cmdline_parse_token_string_t cmd_showport_what =
5290 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5291 "info#stats#xstats#fdir#stat_qmap");
5292 cmdline_parse_token_num_t cmd_showport_portnum =
5293 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5295 cmdline_parse_inst_t cmd_showport = {
5296 .f = cmd_showport_parsed,
5298 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5300 (void *)&cmd_showport_show,
5301 (void *)&cmd_showport_port,
5302 (void *)&cmd_showport_what,
5303 (void *)&cmd_showport_portnum,
5308 /* *** READ PORT REGISTER *** */
5309 struct cmd_read_reg_result {
5310 cmdline_fixed_string_t read;
5311 cmdline_fixed_string_t reg;
5317 cmd_read_reg_parsed(void *parsed_result,
5318 __attribute__((unused)) struct cmdline *cl,
5319 __attribute__((unused)) void *data)
5321 struct cmd_read_reg_result *res = parsed_result;
5322 port_reg_display(res->port_id, res->reg_off);
5325 cmdline_parse_token_string_t cmd_read_reg_read =
5326 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5327 cmdline_parse_token_string_t cmd_read_reg_reg =
5328 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5329 cmdline_parse_token_num_t cmd_read_reg_port_id =
5330 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5331 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5332 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5334 cmdline_parse_inst_t cmd_read_reg = {
5335 .f = cmd_read_reg_parsed,
5337 .help_str = "read reg port_id reg_off",
5339 (void *)&cmd_read_reg_read,
5340 (void *)&cmd_read_reg_reg,
5341 (void *)&cmd_read_reg_port_id,
5342 (void *)&cmd_read_reg_reg_off,
5347 /* *** READ PORT REGISTER BIT FIELD *** */
5348 struct cmd_read_reg_bit_field_result {
5349 cmdline_fixed_string_t read;
5350 cmdline_fixed_string_t regfield;
5358 cmd_read_reg_bit_field_parsed(void *parsed_result,
5359 __attribute__((unused)) struct cmdline *cl,
5360 __attribute__((unused)) void *data)
5362 struct cmd_read_reg_bit_field_result *res = parsed_result;
5363 port_reg_bit_field_display(res->port_id, res->reg_off,
5364 res->bit1_pos, res->bit2_pos);
5367 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5368 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5370 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5371 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5372 regfield, "regfield");
5373 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5374 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5376 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5377 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5379 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5380 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5382 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5383 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5386 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5387 .f = cmd_read_reg_bit_field_parsed,
5389 .help_str = "read regfield port_id reg_off bit_x bit_y "
5390 "(read register bit field between bit_x and bit_y included)",
5392 (void *)&cmd_read_reg_bit_field_read,
5393 (void *)&cmd_read_reg_bit_field_regfield,
5394 (void *)&cmd_read_reg_bit_field_port_id,
5395 (void *)&cmd_read_reg_bit_field_reg_off,
5396 (void *)&cmd_read_reg_bit_field_bit1_pos,
5397 (void *)&cmd_read_reg_bit_field_bit2_pos,
5402 /* *** READ PORT REGISTER BIT *** */
5403 struct cmd_read_reg_bit_result {
5404 cmdline_fixed_string_t read;
5405 cmdline_fixed_string_t regbit;
5412 cmd_read_reg_bit_parsed(void *parsed_result,
5413 __attribute__((unused)) struct cmdline *cl,
5414 __attribute__((unused)) void *data)
5416 struct cmd_read_reg_bit_result *res = parsed_result;
5417 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5420 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5421 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5422 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5423 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5425 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5426 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5427 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5428 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5429 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5430 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5432 cmdline_parse_inst_t cmd_read_reg_bit = {
5433 .f = cmd_read_reg_bit_parsed,
5435 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5437 (void *)&cmd_read_reg_bit_read,
5438 (void *)&cmd_read_reg_bit_regbit,
5439 (void *)&cmd_read_reg_bit_port_id,
5440 (void *)&cmd_read_reg_bit_reg_off,
5441 (void *)&cmd_read_reg_bit_bit_pos,
5446 /* *** WRITE PORT REGISTER *** */
5447 struct cmd_write_reg_result {
5448 cmdline_fixed_string_t write;
5449 cmdline_fixed_string_t reg;
5456 cmd_write_reg_parsed(void *parsed_result,
5457 __attribute__((unused)) struct cmdline *cl,
5458 __attribute__((unused)) void *data)
5460 struct cmd_write_reg_result *res = parsed_result;
5461 port_reg_set(res->port_id, res->reg_off, res->value);
5464 cmdline_parse_token_string_t cmd_write_reg_write =
5465 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5466 cmdline_parse_token_string_t cmd_write_reg_reg =
5467 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5468 cmdline_parse_token_num_t cmd_write_reg_port_id =
5469 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5470 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5471 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5472 cmdline_parse_token_num_t cmd_write_reg_value =
5473 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5475 cmdline_parse_inst_t cmd_write_reg = {
5476 .f = cmd_write_reg_parsed,
5478 .help_str = "write reg port_id reg_off reg_value",
5480 (void *)&cmd_write_reg_write,
5481 (void *)&cmd_write_reg_reg,
5482 (void *)&cmd_write_reg_port_id,
5483 (void *)&cmd_write_reg_reg_off,
5484 (void *)&cmd_write_reg_value,
5489 /* *** WRITE PORT REGISTER BIT FIELD *** */
5490 struct cmd_write_reg_bit_field_result {
5491 cmdline_fixed_string_t write;
5492 cmdline_fixed_string_t regfield;
5501 cmd_write_reg_bit_field_parsed(void *parsed_result,
5502 __attribute__((unused)) struct cmdline *cl,
5503 __attribute__((unused)) void *data)
5505 struct cmd_write_reg_bit_field_result *res = parsed_result;
5506 port_reg_bit_field_set(res->port_id, res->reg_off,
5507 res->bit1_pos, res->bit2_pos, res->value);
5510 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5511 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5513 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5514 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5515 regfield, "regfield");
5516 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5517 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5519 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5520 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5522 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5523 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5525 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5526 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5528 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5529 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5532 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5533 .f = cmd_write_reg_bit_field_parsed,
5535 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5536 "(set register bit field between bit_x and bit_y included)",
5538 (void *)&cmd_write_reg_bit_field_write,
5539 (void *)&cmd_write_reg_bit_field_regfield,
5540 (void *)&cmd_write_reg_bit_field_port_id,
5541 (void *)&cmd_write_reg_bit_field_reg_off,
5542 (void *)&cmd_write_reg_bit_field_bit1_pos,
5543 (void *)&cmd_write_reg_bit_field_bit2_pos,
5544 (void *)&cmd_write_reg_bit_field_value,
5549 /* *** WRITE PORT REGISTER BIT *** */
5550 struct cmd_write_reg_bit_result {
5551 cmdline_fixed_string_t write;
5552 cmdline_fixed_string_t regbit;
5560 cmd_write_reg_bit_parsed(void *parsed_result,
5561 __attribute__((unused)) struct cmdline *cl,
5562 __attribute__((unused)) void *data)
5564 struct cmd_write_reg_bit_result *res = parsed_result;
5565 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5568 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5569 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5571 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5572 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5574 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5575 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5576 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5577 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5578 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5579 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5580 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5581 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5583 cmdline_parse_inst_t cmd_write_reg_bit = {
5584 .f = cmd_write_reg_bit_parsed,
5586 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5588 (void *)&cmd_write_reg_bit_write,
5589 (void *)&cmd_write_reg_bit_regbit,
5590 (void *)&cmd_write_reg_bit_port_id,
5591 (void *)&cmd_write_reg_bit_reg_off,
5592 (void *)&cmd_write_reg_bit_bit_pos,
5593 (void *)&cmd_write_reg_bit_value,
5598 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5599 struct cmd_read_rxd_txd_result {
5600 cmdline_fixed_string_t read;
5601 cmdline_fixed_string_t rxd_txd;
5608 cmd_read_rxd_txd_parsed(void *parsed_result,
5609 __attribute__((unused)) struct cmdline *cl,
5610 __attribute__((unused)) void *data)
5612 struct cmd_read_rxd_txd_result *res = parsed_result;
5614 if (!strcmp(res->rxd_txd, "rxd"))
5615 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5616 else if (!strcmp(res->rxd_txd, "txd"))
5617 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5620 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5621 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5622 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5623 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5625 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5626 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5627 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5628 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5629 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5630 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5632 cmdline_parse_inst_t cmd_read_rxd_txd = {
5633 .f = cmd_read_rxd_txd_parsed,
5635 .help_str = "read rxd|txd port_id queue_id rxd_id",
5637 (void *)&cmd_read_rxd_txd_read,
5638 (void *)&cmd_read_rxd_txd_rxd_txd,
5639 (void *)&cmd_read_rxd_txd_port_id,
5640 (void *)&cmd_read_rxd_txd_queue_id,
5641 (void *)&cmd_read_rxd_txd_desc_id,
5647 struct cmd_quit_result {
5648 cmdline_fixed_string_t quit;
5651 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5653 __attribute__((unused)) void *data)
5659 cmdline_parse_token_string_t cmd_quit_quit =
5660 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5662 cmdline_parse_inst_t cmd_quit = {
5663 .f = cmd_quit_parsed,
5665 .help_str = "exit application",
5667 (void *)&cmd_quit_quit,
5672 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5673 struct cmd_mac_addr_result {
5674 cmdline_fixed_string_t mac_addr_cmd;
5675 cmdline_fixed_string_t what;
5677 struct ether_addr address;
5680 static void cmd_mac_addr_parsed(void *parsed_result,
5681 __attribute__((unused)) struct cmdline *cl,
5682 __attribute__((unused)) void *data)
5684 struct cmd_mac_addr_result *res = parsed_result;
5687 if (strcmp(res->what, "add") == 0)
5688 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5690 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5692 /* check the return value and print it if is < 0 */
5694 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5698 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5699 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5701 cmdline_parse_token_string_t cmd_mac_addr_what =
5702 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5704 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5705 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5706 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5707 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5709 cmdline_parse_inst_t cmd_mac_addr = {
5710 .f = cmd_mac_addr_parsed,
5712 .help_str = "mac_addr add|remove X <address>: "
5713 "add/remove MAC address on port X",
5715 (void *)&cmd_mac_addr_cmd,
5716 (void *)&cmd_mac_addr_what,
5717 (void *)&cmd_mac_addr_portnum,
5718 (void *)&cmd_mac_addr_addr,
5724 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5725 struct cmd_set_qmap_result {
5726 cmdline_fixed_string_t set;
5727 cmdline_fixed_string_t qmap;
5728 cmdline_fixed_string_t what;
5735 cmd_set_qmap_parsed(void *parsed_result,
5736 __attribute__((unused)) struct cmdline *cl,
5737 __attribute__((unused)) void *data)
5739 struct cmd_set_qmap_result *res = parsed_result;
5740 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5742 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5745 cmdline_parse_token_string_t cmd_setqmap_set =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5748 cmdline_parse_token_string_t cmd_setqmap_qmap =
5749 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5751 cmdline_parse_token_string_t cmd_setqmap_what =
5752 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5754 cmdline_parse_token_num_t cmd_setqmap_portid =
5755 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5757 cmdline_parse_token_num_t cmd_setqmap_queueid =
5758 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5760 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5761 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5764 cmdline_parse_inst_t cmd_set_qmap = {
5765 .f = cmd_set_qmap_parsed,
5767 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5769 (void *)&cmd_setqmap_set,
5770 (void *)&cmd_setqmap_qmap,
5771 (void *)&cmd_setqmap_what,
5772 (void *)&cmd_setqmap_portid,
5773 (void *)&cmd_setqmap_queueid,
5774 (void *)&cmd_setqmap_mapvalue,
5779 /* *** CONFIGURE UNICAST HASH TABLE *** */
5780 struct cmd_set_uc_hash_table {
5781 cmdline_fixed_string_t set;
5782 cmdline_fixed_string_t port;
5784 cmdline_fixed_string_t what;
5785 struct ether_addr address;
5786 cmdline_fixed_string_t mode;
5790 cmd_set_uc_hash_parsed(void *parsed_result,
5791 __attribute__((unused)) struct cmdline *cl,
5792 __attribute__((unused)) void *data)
5795 struct cmd_set_uc_hash_table *res = parsed_result;
5797 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5799 if (strcmp(res->what, "uta") == 0)
5800 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5801 &res->address,(uint8_t)is_on);
5803 printf("bad unicast hash table parameter, return code = %d \n", ret);
5807 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5808 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5810 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5811 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5813 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5814 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5816 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5817 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5819 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5820 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5822 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5823 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5826 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5827 .f = cmd_set_uc_hash_parsed,
5829 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5831 (void *)&cmd_set_uc_hash_set,
5832 (void *)&cmd_set_uc_hash_port,
5833 (void *)&cmd_set_uc_hash_portid,
5834 (void *)&cmd_set_uc_hash_what,
5835 (void *)&cmd_set_uc_hash_mac,
5836 (void *)&cmd_set_uc_hash_mode,
5841 struct cmd_set_uc_all_hash_table {
5842 cmdline_fixed_string_t set;
5843 cmdline_fixed_string_t port;
5845 cmdline_fixed_string_t what;
5846 cmdline_fixed_string_t value;
5847 cmdline_fixed_string_t mode;
5851 cmd_set_uc_all_hash_parsed(void *parsed_result,
5852 __attribute__((unused)) struct cmdline *cl,
5853 __attribute__((unused)) void *data)
5856 struct cmd_set_uc_all_hash_table *res = parsed_result;
5858 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5860 if ((strcmp(res->what, "uta") == 0) &&
5861 (strcmp(res->value, "all") == 0))
5862 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5864 printf("bad unicast hash table parameter,"
5865 "return code = %d \n", ret);
5868 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5869 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5871 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5872 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5874 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5875 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5877 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5878 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5880 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5881 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5883 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5884 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5887 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5888 .f = cmd_set_uc_all_hash_parsed,
5890 .help_str = "set port X uta all on|off (X = port number)",
5892 (void *)&cmd_set_uc_all_hash_set,
5893 (void *)&cmd_set_uc_all_hash_port,
5894 (void *)&cmd_set_uc_all_hash_portid,
5895 (void *)&cmd_set_uc_all_hash_what,
5896 (void *)&cmd_set_uc_all_hash_value,
5897 (void *)&cmd_set_uc_all_hash_mode,
5902 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5903 struct cmd_set_vf_macvlan_filter {
5904 cmdline_fixed_string_t set;
5905 cmdline_fixed_string_t port;
5907 cmdline_fixed_string_t vf;
5909 struct ether_addr address;
5910 cmdline_fixed_string_t filter_type;
5911 cmdline_fixed_string_t mode;
5915 cmd_set_vf_macvlan_parsed(void *parsed_result,
5916 __attribute__((unused)) struct cmdline *cl,
5917 __attribute__((unused)) void *data)
5920 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5921 struct rte_eth_mac_filter filter;
5923 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5925 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5927 /* set VF MAC filter */
5931 filter.dst_id = res->vf_id;
5933 if (!strcmp(res->filter_type, "exact-mac"))
5934 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5935 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5936 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5937 else if (!strcmp(res->filter_type, "hashmac"))
5938 filter.filter_type = RTE_MAC_HASH_MATCH;
5939 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5940 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5942 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5945 ret = rte_eth_dev_filter_ctrl(res->port_id,
5946 RTE_ETH_FILTER_MACVLAN,
5950 ret = rte_eth_dev_filter_ctrl(res->port_id,
5951 RTE_ETH_FILTER_MACVLAN,
5952 RTE_ETH_FILTER_DELETE,
5956 printf("bad set MAC hash parameter, return code = %d\n", ret);
5960 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5961 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5963 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5964 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5966 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5967 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5969 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5970 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5972 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5973 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5975 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5976 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5978 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5979 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5980 filter_type, "exact-mac#exact-mac-vlan"
5981 "#hashmac#hashmac-vlan");
5982 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5983 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5986 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5987 .f = cmd_set_vf_macvlan_parsed,
5989 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5990 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5992 "exact match rule:exact match of MAC or MAC and VLAN; "
5993 "hash match rule: hash match of MAC and exact match "
5996 (void *)&cmd_set_vf_macvlan_set,
5997 (void *)&cmd_set_vf_macvlan_port,
5998 (void *)&cmd_set_vf_macvlan_portid,
5999 (void *)&cmd_set_vf_macvlan_vf,
6000 (void *)&cmd_set_vf_macvlan_vf_id,
6001 (void *)&cmd_set_vf_macvlan_mac,
6002 (void *)&cmd_set_vf_macvlan_filter_type,
6003 (void *)&cmd_set_vf_macvlan_mode,
6008 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6009 struct cmd_set_vf_traffic {
6010 cmdline_fixed_string_t set;
6011 cmdline_fixed_string_t port;
6013 cmdline_fixed_string_t vf;
6015 cmdline_fixed_string_t what;
6016 cmdline_fixed_string_t mode;
6020 cmd_set_vf_traffic_parsed(void *parsed_result,
6021 __attribute__((unused)) struct cmdline *cl,
6022 __attribute__((unused)) void *data)
6024 struct cmd_set_vf_traffic *res = parsed_result;
6025 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6026 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6028 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6031 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6032 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6034 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6035 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6037 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6038 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6040 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6041 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6043 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6044 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6046 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6047 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6049 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6050 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6053 cmdline_parse_inst_t cmd_set_vf_traffic = {
6054 .f = cmd_set_vf_traffic_parsed,
6056 .help_str = "set port X vf Y rx|tx on|off"
6057 "(X = port number,Y = vf id)",
6059 (void *)&cmd_setvf_traffic_set,
6060 (void *)&cmd_setvf_traffic_port,
6061 (void *)&cmd_setvf_traffic_portid,
6062 (void *)&cmd_setvf_traffic_vf,
6063 (void *)&cmd_setvf_traffic_vfid,
6064 (void *)&cmd_setvf_traffic_what,
6065 (void *)&cmd_setvf_traffic_mode,
6070 /* *** CONFIGURE VF RECEIVE MODE *** */
6071 struct cmd_set_vf_rxmode {
6072 cmdline_fixed_string_t set;
6073 cmdline_fixed_string_t port;
6075 cmdline_fixed_string_t vf;
6077 cmdline_fixed_string_t what;
6078 cmdline_fixed_string_t mode;
6079 cmdline_fixed_string_t on;
6083 cmd_set_vf_rxmode_parsed(void *parsed_result,
6084 __attribute__((unused)) struct cmdline *cl,
6085 __attribute__((unused)) void *data)
6088 uint16_t rx_mode = 0;
6089 struct cmd_set_vf_rxmode *res = parsed_result;
6091 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6092 if (!strcmp(res->what,"rxmode")) {
6093 if (!strcmp(res->mode, "AUPE"))
6094 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6095 else if (!strcmp(res->mode, "ROPE"))
6096 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6097 else if (!strcmp(res->mode, "BAM"))
6098 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6099 else if (!strncmp(res->mode, "MPE",3))
6100 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6103 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6105 printf("bad VF receive mode parameter, return code = %d \n",
6109 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6112 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6113 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6115 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6116 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6118 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6119 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6121 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6122 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6124 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6125 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6127 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6128 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6129 mode, "AUPE#ROPE#BAM#MPE");
6130 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6131 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6134 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6135 .f = cmd_set_vf_rxmode_parsed,
6137 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6139 (void *)&cmd_set_vf_rxmode_set,
6140 (void *)&cmd_set_vf_rxmode_port,
6141 (void *)&cmd_set_vf_rxmode_portid,
6142 (void *)&cmd_set_vf_rxmode_vf,
6143 (void *)&cmd_set_vf_rxmode_vfid,
6144 (void *)&cmd_set_vf_rxmode_what,
6145 (void *)&cmd_set_vf_rxmode_mode,
6146 (void *)&cmd_set_vf_rxmode_on,
6151 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6152 struct cmd_vf_mac_addr_result {
6153 cmdline_fixed_string_t mac_addr_cmd;
6154 cmdline_fixed_string_t what;
6155 cmdline_fixed_string_t port;
6157 cmdline_fixed_string_t vf;
6159 struct ether_addr address;
6162 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6163 __attribute__((unused)) struct cmdline *cl,
6164 __attribute__((unused)) void *data)
6166 struct cmd_vf_mac_addr_result *res = parsed_result;
6169 if (strcmp(res->what, "add") == 0)
6170 ret = rte_eth_dev_mac_addr_add(res->port_num,
6171 &res->address, res->vf_num);
6173 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6177 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6178 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6179 mac_addr_cmd,"mac_addr");
6180 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6181 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6183 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6184 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6186 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6187 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6189 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6190 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6192 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6193 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6195 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6196 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6199 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6200 .f = cmd_vf_mac_addr_parsed,
6202 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6203 "Y = VF number)add MAC address filtering for a VF on port X",
6205 (void *)&cmd_vf_mac_addr_cmd,
6206 (void *)&cmd_vf_mac_addr_what,
6207 (void *)&cmd_vf_mac_addr_port,
6208 (void *)&cmd_vf_mac_addr_portnum,
6209 (void *)&cmd_vf_mac_addr_vf,
6210 (void *)&cmd_vf_mac_addr_vfnum,
6211 (void *)&cmd_vf_mac_addr_addr,
6216 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6217 struct cmd_vf_rx_vlan_filter {
6218 cmdline_fixed_string_t rx_vlan;
6219 cmdline_fixed_string_t what;
6221 cmdline_fixed_string_t port;
6223 cmdline_fixed_string_t vf;
6228 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6229 __attribute__((unused)) struct cmdline *cl,
6230 __attribute__((unused)) void *data)
6232 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6234 if (!strcmp(res->what, "add"))
6235 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6237 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6240 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6241 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6242 rx_vlan, "rx_vlan");
6243 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6244 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6246 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6247 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6249 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6250 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6252 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6253 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6255 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6256 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6258 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6259 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6262 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6263 .f = cmd_vf_rx_vlan_filter_parsed,
6265 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6266 "Y = port number,Z = hexadecimal VF mask)",
6268 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6269 (void *)&cmd_vf_rx_vlan_filter_what,
6270 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6271 (void *)&cmd_vf_rx_vlan_filter_port,
6272 (void *)&cmd_vf_rx_vlan_filter_portid,
6273 (void *)&cmd_vf_rx_vlan_filter_vf,
6274 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6279 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6280 struct cmd_queue_rate_limit_result {
6281 cmdline_fixed_string_t set;
6282 cmdline_fixed_string_t port;
6284 cmdline_fixed_string_t queue;
6286 cmdline_fixed_string_t rate;
6290 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6291 __attribute__((unused)) struct cmdline *cl,
6292 __attribute__((unused)) void *data)
6294 struct cmd_queue_rate_limit_result *res = parsed_result;
6297 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6298 && (strcmp(res->queue, "queue") == 0)
6299 && (strcmp(res->rate, "rate") == 0))
6300 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6303 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6307 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6308 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6310 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6311 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6313 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6314 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6316 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6317 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6319 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6320 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6322 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6323 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6325 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6326 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6329 cmdline_parse_inst_t cmd_queue_rate_limit = {
6330 .f = cmd_queue_rate_limit_parsed,
6332 .help_str = "set port X queue Y rate Z:(X = port number,"
6333 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6335 (void *)&cmd_queue_rate_limit_set,
6336 (void *)&cmd_queue_rate_limit_port,
6337 (void *)&cmd_queue_rate_limit_portnum,
6338 (void *)&cmd_queue_rate_limit_queue,
6339 (void *)&cmd_queue_rate_limit_queuenum,
6340 (void *)&cmd_queue_rate_limit_rate,
6341 (void *)&cmd_queue_rate_limit_ratenum,
6346 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6347 struct cmd_vf_rate_limit_result {
6348 cmdline_fixed_string_t set;
6349 cmdline_fixed_string_t port;
6351 cmdline_fixed_string_t vf;
6353 cmdline_fixed_string_t rate;
6355 cmdline_fixed_string_t q_msk;
6359 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6360 __attribute__((unused)) struct cmdline *cl,
6361 __attribute__((unused)) void *data)
6363 struct cmd_vf_rate_limit_result *res = parsed_result;
6366 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6367 && (strcmp(res->vf, "vf") == 0)
6368 && (strcmp(res->rate, "rate") == 0)
6369 && (strcmp(res->q_msk, "queue_mask") == 0))
6370 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6371 res->rate_num, res->q_msk_val);
6373 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6377 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6378 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6380 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6381 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6383 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6384 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6386 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6387 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6389 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6390 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6392 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6393 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6395 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6396 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6398 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6399 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6400 q_msk, "queue_mask");
6401 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6402 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6405 cmdline_parse_inst_t cmd_vf_rate_limit = {
6406 .f = cmd_vf_rate_limit_parsed,
6408 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6409 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6410 "for queues of VF on port X",
6412 (void *)&cmd_vf_rate_limit_set,
6413 (void *)&cmd_vf_rate_limit_port,
6414 (void *)&cmd_vf_rate_limit_portnum,
6415 (void *)&cmd_vf_rate_limit_vf,
6416 (void *)&cmd_vf_rate_limit_vfnum,
6417 (void *)&cmd_vf_rate_limit_rate,
6418 (void *)&cmd_vf_rate_limit_ratenum,
6419 (void *)&cmd_vf_rate_limit_q_msk,
6420 (void *)&cmd_vf_rate_limit_q_msk_val,
6425 /* *** ADD TUNNEL FILTER OF A PORT *** */
6426 struct cmd_tunnel_filter_result {
6427 cmdline_fixed_string_t cmd;
6428 cmdline_fixed_string_t what;
6430 struct ether_addr outer_mac;
6431 struct ether_addr inner_mac;
6432 cmdline_ipaddr_t ip_value;
6433 uint16_t inner_vlan;
6434 cmdline_fixed_string_t tunnel_type;
6435 cmdline_fixed_string_t filter_type;
6441 cmd_tunnel_filter_parsed(void *parsed_result,
6442 __attribute__((unused)) struct cmdline *cl,
6443 __attribute__((unused)) void *data)
6445 struct cmd_tunnel_filter_result *res = parsed_result;
6446 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6449 tunnel_filter_conf.outer_mac = &res->outer_mac;
6450 tunnel_filter_conf.inner_mac = &res->inner_mac;
6451 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6453 if (res->ip_value.family == AF_INET) {
6454 tunnel_filter_conf.ip_addr.ipv4_addr =
6455 res->ip_value.addr.ipv4.s_addr;
6456 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6458 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6459 &(res->ip_value.addr.ipv6),
6460 sizeof(struct in6_addr));
6461 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6464 if (!strcmp(res->filter_type, "imac-ivlan"))
6465 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6466 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6467 tunnel_filter_conf.filter_type =
6468 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6469 else if (!strcmp(res->filter_type, "imac-tenid"))
6470 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6471 else if (!strcmp(res->filter_type, "imac"))
6472 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6473 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6474 tunnel_filter_conf.filter_type =
6475 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6477 printf("The filter type is not supported");
6481 if (!strcmp(res->tunnel_type, "vxlan"))
6482 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6483 else if (!strcmp(res->tunnel_type, "nvgre"))
6484 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6486 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6490 tunnel_filter_conf.tenant_id = res->tenant_id;
6491 tunnel_filter_conf.queue_id = res->queue_num;
6492 if (!strcmp(res->what, "add"))
6493 ret = rte_eth_dev_filter_ctrl(res->port_id,
6494 RTE_ETH_FILTER_TUNNEL,
6496 &tunnel_filter_conf);
6498 ret = rte_eth_dev_filter_ctrl(res->port_id,
6499 RTE_ETH_FILTER_TUNNEL,
6500 RTE_ETH_FILTER_DELETE,
6501 &tunnel_filter_conf);
6503 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6507 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6508 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6509 cmd, "tunnel_filter");
6510 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6511 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6513 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6514 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6516 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6517 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6519 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6520 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6522 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6523 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6524 inner_vlan, UINT16);
6525 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6526 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6528 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6529 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6530 tunnel_type, "vxlan#nvgre");
6532 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6533 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6534 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6535 "imac#omac-imac-tenid");
6536 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6537 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6539 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6540 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6543 cmdline_parse_inst_t cmd_tunnel_filter = {
6544 .f = cmd_tunnel_filter_parsed,
6546 .help_str = "add/rm tunnel filter of a port: "
6547 "tunnel_filter add port_id outer_mac inner_mac ip "
6548 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6549 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6550 "imac|omac-imac-tenid) "
6551 "tenant_id queue_num",
6553 (void *)&cmd_tunnel_filter_cmd,
6554 (void *)&cmd_tunnel_filter_what,
6555 (void *)&cmd_tunnel_filter_port_id,
6556 (void *)&cmd_tunnel_filter_outer_mac,
6557 (void *)&cmd_tunnel_filter_inner_mac,
6558 (void *)&cmd_tunnel_filter_ip_value,
6559 (void *)&cmd_tunnel_filter_innner_vlan,
6560 (void *)&cmd_tunnel_filter_tunnel_type,
6561 (void *)&cmd_tunnel_filter_filter_type,
6562 (void *)&cmd_tunnel_filter_tenant_id,
6563 (void *)&cmd_tunnel_filter_queue_num,
6568 /* *** CONFIGURE TUNNEL UDP PORT *** */
6569 struct cmd_tunnel_udp_config {
6570 cmdline_fixed_string_t cmd;
6571 cmdline_fixed_string_t what;
6577 cmd_tunnel_udp_config_parsed(void *parsed_result,
6578 __attribute__((unused)) struct cmdline *cl,
6579 __attribute__((unused)) void *data)
6581 struct cmd_tunnel_udp_config *res = parsed_result;
6582 struct rte_eth_udp_tunnel tunnel_udp;
6585 tunnel_udp.udp_port = res->udp_port;
6587 if (!strcmp(res->cmd, "rx_vxlan_port"))
6588 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6590 if (!strcmp(res->what, "add"))
6591 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6593 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6596 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6599 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6600 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6601 cmd, "rx_vxlan_port");
6602 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6603 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6605 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6606 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6608 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6609 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6612 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6613 .f = cmd_tunnel_udp_config_parsed,
6615 .help_str = "add/rm an tunneling UDP port filter: "
6616 "rx_vxlan_port add udp_port port_id",
6618 (void *)&cmd_tunnel_udp_config_cmd,
6619 (void *)&cmd_tunnel_udp_config_what,
6620 (void *)&cmd_tunnel_udp_config_udp_port,
6621 (void *)&cmd_tunnel_udp_config_port_id,
6626 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6627 struct cmd_set_mirror_mask_result {
6628 cmdline_fixed_string_t set;
6629 cmdline_fixed_string_t port;
6631 cmdline_fixed_string_t mirror;
6633 cmdline_fixed_string_t what;
6634 cmdline_fixed_string_t value;
6635 cmdline_fixed_string_t dstpool;
6637 cmdline_fixed_string_t on;
6640 cmdline_parse_token_string_t cmd_mirror_mask_set =
6641 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6643 cmdline_parse_token_string_t cmd_mirror_mask_port =
6644 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6646 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6647 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6649 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6651 mirror, "mirror-rule");
6652 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6653 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6655 cmdline_parse_token_string_t cmd_mirror_mask_what =
6656 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6657 what, "pool-mirror-up#pool-mirror-down"
6659 cmdline_parse_token_string_t cmd_mirror_mask_value =
6660 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6662 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6663 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6664 dstpool, "dst-pool");
6665 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6666 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6668 cmdline_parse_token_string_t cmd_mirror_mask_on =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6673 cmd_set_mirror_mask_parsed(void *parsed_result,
6674 __attribute__((unused)) struct cmdline *cl,
6675 __attribute__((unused)) void *data)
6678 struct cmd_set_mirror_mask_result *res = parsed_result;
6679 struct rte_eth_mirror_conf mr_conf;
6681 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6683 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6685 mr_conf.dst_pool = res->dstpool_id;
6687 if (!strcmp(res->what, "pool-mirror-up")) {
6688 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6689 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6690 } else if (!strcmp(res->what, "pool-mirror-down")) {
6691 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6692 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6693 } else if (!strcmp(res->what, "vlan-mirror")) {
6694 mr_conf.rule_type = ETH_MIRROR_VLAN;
6695 nb_item = parse_item_list(res->value, "vlan",
6696 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6700 for (i = 0; i < nb_item; i++) {
6701 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6702 printf("Invalid vlan_id: must be < 4096\n");
6706 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6707 mr_conf.vlan.vlan_mask |= 1ULL << i;
6711 if (!strcmp(res->on, "on"))
6712 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6715 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6718 printf("mirror rule add error: (%s)\n", strerror(-ret));
6721 cmdline_parse_inst_t cmd_set_mirror_mask = {
6722 .f = cmd_set_mirror_mask_parsed,
6724 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6725 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6727 (void *)&cmd_mirror_mask_set,
6728 (void *)&cmd_mirror_mask_port,
6729 (void *)&cmd_mirror_mask_portid,
6730 (void *)&cmd_mirror_mask_mirror,
6731 (void *)&cmd_mirror_mask_ruleid,
6732 (void *)&cmd_mirror_mask_what,
6733 (void *)&cmd_mirror_mask_value,
6734 (void *)&cmd_mirror_mask_dstpool,
6735 (void *)&cmd_mirror_mask_poolid,
6736 (void *)&cmd_mirror_mask_on,
6741 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6742 struct cmd_set_mirror_link_result {
6743 cmdline_fixed_string_t set;
6744 cmdline_fixed_string_t port;
6746 cmdline_fixed_string_t mirror;
6748 cmdline_fixed_string_t what;
6749 cmdline_fixed_string_t dstpool;
6751 cmdline_fixed_string_t on;
6754 cmdline_parse_token_string_t cmd_mirror_link_set =
6755 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6757 cmdline_parse_token_string_t cmd_mirror_link_port =
6758 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6760 cmdline_parse_token_num_t cmd_mirror_link_portid =
6761 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6763 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6765 mirror, "mirror-rule");
6766 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6767 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6769 cmdline_parse_token_string_t cmd_mirror_link_what =
6770 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6771 what, "uplink-mirror#downlink-mirror");
6772 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6773 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6774 dstpool, "dst-pool");
6775 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6776 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6778 cmdline_parse_token_string_t cmd_mirror_link_on =
6779 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6783 cmd_set_mirror_link_parsed(void *parsed_result,
6784 __attribute__((unused)) struct cmdline *cl,
6785 __attribute__((unused)) void *data)
6788 struct cmd_set_mirror_link_result *res = parsed_result;
6789 struct rte_eth_mirror_conf mr_conf;
6791 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6792 if (!strcmp(res->what, "uplink-mirror"))
6793 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
6795 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
6797 mr_conf.dst_pool = res->dstpool_id;
6799 if (!strcmp(res->on, "on"))
6800 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6803 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6806 /* check the return value and print it if is < 0 */
6808 printf("mirror rule add error: (%s)\n", strerror(-ret));
6812 cmdline_parse_inst_t cmd_set_mirror_link = {
6813 .f = cmd_set_mirror_link_parsed,
6815 .help_str = "set port X mirror-rule Y uplink-mirror|"
6816 "downlink-mirror dst-pool Z on|off",
6818 (void *)&cmd_mirror_link_set,
6819 (void *)&cmd_mirror_link_port,
6820 (void *)&cmd_mirror_link_portid,
6821 (void *)&cmd_mirror_link_mirror,
6822 (void *)&cmd_mirror_link_ruleid,
6823 (void *)&cmd_mirror_link_what,
6824 (void *)&cmd_mirror_link_dstpool,
6825 (void *)&cmd_mirror_link_poolid,
6826 (void *)&cmd_mirror_link_on,
6831 /* *** RESET VM MIRROR RULE *** */
6832 struct cmd_rm_mirror_rule_result {
6833 cmdline_fixed_string_t reset;
6834 cmdline_fixed_string_t port;
6836 cmdline_fixed_string_t mirror;
6840 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6841 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6843 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6844 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6846 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6847 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6849 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6850 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6851 mirror, "mirror-rule");
6852 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6853 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6857 cmd_reset_mirror_rule_parsed(void *parsed_result,
6858 __attribute__((unused)) struct cmdline *cl,
6859 __attribute__((unused)) void *data)
6862 struct cmd_set_mirror_link_result *res = parsed_result;
6864 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6866 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6869 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6870 .f = cmd_reset_mirror_rule_parsed,
6872 .help_str = "reset port X mirror-rule Y",
6874 (void *)&cmd_rm_mirror_rule_reset,
6875 (void *)&cmd_rm_mirror_rule_port,
6876 (void *)&cmd_rm_mirror_rule_portid,
6877 (void *)&cmd_rm_mirror_rule_mirror,
6878 (void *)&cmd_rm_mirror_rule_ruleid,
6883 /* ******************************************************************************** */
6885 struct cmd_dump_result {
6886 cmdline_fixed_string_t dump;
6890 dump_struct_sizes(void)
6892 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6893 DUMP_SIZE(struct rte_mbuf);
6894 DUMP_SIZE(struct rte_mempool);
6895 DUMP_SIZE(struct rte_ring);
6899 static void cmd_dump_parsed(void *parsed_result,
6900 __attribute__((unused)) struct cmdline *cl,
6901 __attribute__((unused)) void *data)
6903 struct cmd_dump_result *res = parsed_result;
6905 if (!strcmp(res->dump, "dump_physmem"))
6906 rte_dump_physmem_layout(stdout);
6907 else if (!strcmp(res->dump, "dump_memzone"))
6908 rte_memzone_dump(stdout);
6909 else if (!strcmp(res->dump, "dump_log_history"))
6910 rte_log_dump_history(stdout);
6911 else if (!strcmp(res->dump, "dump_struct_sizes"))
6912 dump_struct_sizes();
6913 else if (!strcmp(res->dump, "dump_ring"))
6914 rte_ring_list_dump(stdout);
6915 else if (!strcmp(res->dump, "dump_mempool"))
6916 rte_mempool_list_dump(stdout);
6917 else if (!strcmp(res->dump, "dump_devargs"))
6918 rte_eal_devargs_dump(stdout);
6921 cmdline_parse_token_string_t cmd_dump_dump =
6922 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6926 "dump_struct_sizes#"
6931 cmdline_parse_inst_t cmd_dump = {
6932 .f = cmd_dump_parsed, /* function to call */
6933 .data = NULL, /* 2nd arg of func */
6934 .help_str = "dump status",
6935 .tokens = { /* token list, NULL terminated */
6936 (void *)&cmd_dump_dump,
6941 /* ******************************************************************************** */
6943 struct cmd_dump_one_result {
6944 cmdline_fixed_string_t dump;
6945 cmdline_fixed_string_t name;
6948 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6949 __attribute__((unused)) void *data)
6951 struct cmd_dump_one_result *res = parsed_result;
6953 if (!strcmp(res->dump, "dump_ring")) {
6955 r = rte_ring_lookup(res->name);
6957 cmdline_printf(cl, "Cannot find ring\n");
6960 rte_ring_dump(stdout, r);
6961 } else if (!strcmp(res->dump, "dump_mempool")) {
6962 struct rte_mempool *mp;
6963 mp = rte_mempool_lookup(res->name);
6965 cmdline_printf(cl, "Cannot find mempool\n");
6968 rte_mempool_dump(stdout, mp);
6972 cmdline_parse_token_string_t cmd_dump_one_dump =
6973 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6974 "dump_ring#dump_mempool");
6976 cmdline_parse_token_string_t cmd_dump_one_name =
6977 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6979 cmdline_parse_inst_t cmd_dump_one = {
6980 .f = cmd_dump_one_parsed, /* function to call */
6981 .data = NULL, /* 2nd arg of func */
6982 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6983 .tokens = { /* token list, NULL terminated */
6984 (void *)&cmd_dump_one_dump,
6985 (void *)&cmd_dump_one_name,
6990 /* *** Add/Del syn filter *** */
6991 struct cmd_syn_filter_result {
6992 cmdline_fixed_string_t filter;
6994 cmdline_fixed_string_t ops;
6995 cmdline_fixed_string_t priority;
6996 cmdline_fixed_string_t high;
6997 cmdline_fixed_string_t queue;
7002 cmd_syn_filter_parsed(void *parsed_result,
7003 __attribute__((unused)) struct cmdline *cl,
7004 __attribute__((unused)) void *data)
7006 struct cmd_syn_filter_result *res = parsed_result;
7007 struct rte_eth_syn_filter syn_filter;
7010 ret = rte_eth_dev_filter_supported(res->port_id,
7011 RTE_ETH_FILTER_SYN);
7013 printf("syn filter is not supported on port %u.\n",
7018 memset(&syn_filter, 0, sizeof(syn_filter));
7020 if (!strcmp(res->ops, "add")) {
7021 if (!strcmp(res->high, "high"))
7022 syn_filter.hig_pri = 1;
7024 syn_filter.hig_pri = 0;
7026 syn_filter.queue = res->queue_id;
7027 ret = rte_eth_dev_filter_ctrl(res->port_id,
7032 ret = rte_eth_dev_filter_ctrl(res->port_id,
7034 RTE_ETH_FILTER_DELETE,
7038 printf("syn filter programming error: (%s)\n",
7042 cmdline_parse_token_string_t cmd_syn_filter_filter =
7043 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7044 filter, "syn_filter");
7045 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7046 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7048 cmdline_parse_token_string_t cmd_syn_filter_ops =
7049 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7051 cmdline_parse_token_string_t cmd_syn_filter_priority =
7052 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7053 priority, "priority");
7054 cmdline_parse_token_string_t cmd_syn_filter_high =
7055 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7057 cmdline_parse_token_string_t cmd_syn_filter_queue =
7058 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7060 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7061 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7064 cmdline_parse_inst_t cmd_syn_filter = {
7065 .f = cmd_syn_filter_parsed,
7067 .help_str = "add/delete syn filter",
7069 (void *)&cmd_syn_filter_filter,
7070 (void *)&cmd_syn_filter_port_id,
7071 (void *)&cmd_syn_filter_ops,
7072 (void *)&cmd_syn_filter_priority,
7073 (void *)&cmd_syn_filter_high,
7074 (void *)&cmd_syn_filter_queue,
7075 (void *)&cmd_syn_filter_queue_id,
7080 /* *** ADD/REMOVE A 2tuple FILTER *** */
7081 struct cmd_2tuple_filter_result {
7082 cmdline_fixed_string_t filter;
7084 cmdline_fixed_string_t ops;
7085 cmdline_fixed_string_t dst_port;
7086 uint16_t dst_port_value;
7087 cmdline_fixed_string_t protocol;
7088 uint8_t protocol_value;
7089 cmdline_fixed_string_t mask;
7091 cmdline_fixed_string_t tcp_flags;
7092 uint8_t tcp_flags_value;
7093 cmdline_fixed_string_t priority;
7094 uint8_t priority_value;
7095 cmdline_fixed_string_t queue;
7100 cmd_2tuple_filter_parsed(void *parsed_result,
7101 __attribute__((unused)) struct cmdline *cl,
7102 __attribute__((unused)) void *data)
7104 struct rte_eth_ntuple_filter filter;
7105 struct cmd_2tuple_filter_result *res = parsed_result;
7108 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7110 printf("ntuple filter is not supported on port %u.\n",
7115 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7117 filter.flags = RTE_2TUPLE_FLAGS;
7118 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7119 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7120 filter.proto = res->protocol_value;
7121 filter.priority = res->priority_value;
7122 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7123 printf("nonzero tcp_flags is only meaningful"
7124 " when protocol is TCP.\n");
7127 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7128 printf("invalid TCP flags.\n");
7132 if (res->tcp_flags_value != 0) {
7133 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7134 filter.tcp_flags = res->tcp_flags_value;
7137 /* need convert to big endian. */
7138 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7139 filter.queue = res->queue_id;
7141 if (!strcmp(res->ops, "add"))
7142 ret = rte_eth_dev_filter_ctrl(res->port_id,
7143 RTE_ETH_FILTER_NTUPLE,
7147 ret = rte_eth_dev_filter_ctrl(res->port_id,
7148 RTE_ETH_FILTER_NTUPLE,
7149 RTE_ETH_FILTER_DELETE,
7152 printf("2tuple filter programming error: (%s)\n",
7157 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7158 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7159 filter, "2tuple_filter");
7160 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7161 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7163 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7164 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7166 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7167 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7168 dst_port, "dst_port");
7169 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7170 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7171 dst_port_value, UINT16);
7172 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7173 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7174 protocol, "protocol");
7175 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7176 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7177 protocol_value, UINT8);
7178 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7179 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7181 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7182 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7184 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7185 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7186 tcp_flags, "tcp_flags");
7187 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7188 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7189 tcp_flags_value, UINT8);
7190 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7191 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7192 priority, "priority");
7193 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7194 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7195 priority_value, UINT8);
7196 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7197 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7199 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7200 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7203 cmdline_parse_inst_t cmd_2tuple_filter = {
7204 .f = cmd_2tuple_filter_parsed,
7206 .help_str = "add a 2tuple filter",
7208 (void *)&cmd_2tuple_filter_filter,
7209 (void *)&cmd_2tuple_filter_port_id,
7210 (void *)&cmd_2tuple_filter_ops,
7211 (void *)&cmd_2tuple_filter_dst_port,
7212 (void *)&cmd_2tuple_filter_dst_port_value,
7213 (void *)&cmd_2tuple_filter_protocol,
7214 (void *)&cmd_2tuple_filter_protocol_value,
7215 (void *)&cmd_2tuple_filter_mask,
7216 (void *)&cmd_2tuple_filter_mask_value,
7217 (void *)&cmd_2tuple_filter_tcp_flags,
7218 (void *)&cmd_2tuple_filter_tcp_flags_value,
7219 (void *)&cmd_2tuple_filter_priority,
7220 (void *)&cmd_2tuple_filter_priority_value,
7221 (void *)&cmd_2tuple_filter_queue,
7222 (void *)&cmd_2tuple_filter_queue_id,
7227 /* *** ADD/REMOVE A 5tuple FILTER *** */
7228 struct cmd_5tuple_filter_result {
7229 cmdline_fixed_string_t filter;
7231 cmdline_fixed_string_t ops;
7232 cmdline_fixed_string_t dst_ip;
7233 cmdline_ipaddr_t dst_ip_value;
7234 cmdline_fixed_string_t src_ip;
7235 cmdline_ipaddr_t src_ip_value;
7236 cmdline_fixed_string_t dst_port;
7237 uint16_t dst_port_value;
7238 cmdline_fixed_string_t src_port;
7239 uint16_t src_port_value;
7240 cmdline_fixed_string_t protocol;
7241 uint8_t protocol_value;
7242 cmdline_fixed_string_t mask;
7244 cmdline_fixed_string_t tcp_flags;
7245 uint8_t tcp_flags_value;
7246 cmdline_fixed_string_t priority;
7247 uint8_t priority_value;
7248 cmdline_fixed_string_t queue;
7253 cmd_5tuple_filter_parsed(void *parsed_result,
7254 __attribute__((unused)) struct cmdline *cl,
7255 __attribute__((unused)) void *data)
7257 struct rte_eth_ntuple_filter filter;
7258 struct cmd_5tuple_filter_result *res = parsed_result;
7261 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7263 printf("ntuple filter is not supported on port %u.\n",
7268 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7270 filter.flags = RTE_5TUPLE_FLAGS;
7271 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7272 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7273 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7274 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7275 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7276 filter.proto = res->protocol_value;
7277 filter.priority = res->priority_value;
7278 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7279 printf("nonzero tcp_flags is only meaningful"
7280 " when protocol is TCP.\n");
7283 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7284 printf("invalid TCP flags.\n");
7288 if (res->tcp_flags_value != 0) {
7289 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7290 filter.tcp_flags = res->tcp_flags_value;
7293 if (res->dst_ip_value.family == AF_INET)
7294 /* no need to convert, already big endian. */
7295 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7297 if (filter.dst_ip_mask == 0) {
7298 printf("can not support ipv6 involved compare.\n");
7304 if (res->src_ip_value.family == AF_INET)
7305 /* no need to convert, already big endian. */
7306 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7308 if (filter.src_ip_mask == 0) {
7309 printf("can not support ipv6 involved compare.\n");
7314 /* need convert to big endian. */
7315 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7316 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7317 filter.queue = res->queue_id;
7319 if (!strcmp(res->ops, "add"))
7320 ret = rte_eth_dev_filter_ctrl(res->port_id,
7321 RTE_ETH_FILTER_NTUPLE,
7325 ret = rte_eth_dev_filter_ctrl(res->port_id,
7326 RTE_ETH_FILTER_NTUPLE,
7327 RTE_ETH_FILTER_DELETE,
7330 printf("5tuple filter programming error: (%s)\n",
7334 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7335 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7336 filter, "5tuple_filter");
7337 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7338 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7340 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7341 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7343 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7344 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7346 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7347 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7349 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7350 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7352 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7353 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7355 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7356 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7357 dst_port, "dst_port");
7358 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7359 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7360 dst_port_value, UINT16);
7361 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7362 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7363 src_port, "src_port");
7364 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7365 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7366 src_port_value, UINT16);
7367 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7368 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7369 protocol, "protocol");
7370 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7371 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7372 protocol_value, UINT8);
7373 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7374 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7376 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7377 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7379 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7380 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7381 tcp_flags, "tcp_flags");
7382 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7383 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7384 tcp_flags_value, UINT8);
7385 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7386 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7387 priority, "priority");
7388 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7389 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7390 priority_value, UINT8);
7391 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7392 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7394 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7395 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7398 cmdline_parse_inst_t cmd_5tuple_filter = {
7399 .f = cmd_5tuple_filter_parsed,
7401 .help_str = "add/del a 5tuple filter",
7403 (void *)&cmd_5tuple_filter_filter,
7404 (void *)&cmd_5tuple_filter_port_id,
7405 (void *)&cmd_5tuple_filter_ops,
7406 (void *)&cmd_5tuple_filter_dst_ip,
7407 (void *)&cmd_5tuple_filter_dst_ip_value,
7408 (void *)&cmd_5tuple_filter_src_ip,
7409 (void *)&cmd_5tuple_filter_src_ip_value,
7410 (void *)&cmd_5tuple_filter_dst_port,
7411 (void *)&cmd_5tuple_filter_dst_port_value,
7412 (void *)&cmd_5tuple_filter_src_port,
7413 (void *)&cmd_5tuple_filter_src_port_value,
7414 (void *)&cmd_5tuple_filter_protocol,
7415 (void *)&cmd_5tuple_filter_protocol_value,
7416 (void *)&cmd_5tuple_filter_mask,
7417 (void *)&cmd_5tuple_filter_mask_value,
7418 (void *)&cmd_5tuple_filter_tcp_flags,
7419 (void *)&cmd_5tuple_filter_tcp_flags_value,
7420 (void *)&cmd_5tuple_filter_priority,
7421 (void *)&cmd_5tuple_filter_priority_value,
7422 (void *)&cmd_5tuple_filter_queue,
7423 (void *)&cmd_5tuple_filter_queue_id,
7428 /* *** ADD/REMOVE A flex FILTER *** */
7429 struct cmd_flex_filter_result {
7430 cmdline_fixed_string_t filter;
7431 cmdline_fixed_string_t ops;
7433 cmdline_fixed_string_t len;
7435 cmdline_fixed_string_t bytes;
7436 cmdline_fixed_string_t bytes_value;
7437 cmdline_fixed_string_t mask;
7438 cmdline_fixed_string_t mask_value;
7439 cmdline_fixed_string_t priority;
7440 uint8_t priority_value;
7441 cmdline_fixed_string_t queue;
7445 static int xdigit2val(unsigned char c)
7450 else if (isupper(c))
7458 cmd_flex_filter_parsed(void *parsed_result,
7459 __attribute__((unused)) struct cmdline *cl,
7460 __attribute__((unused)) void *data)
7463 struct rte_eth_flex_filter filter;
7464 struct cmd_flex_filter_result *res = parsed_result;
7465 char *bytes_ptr, *mask_ptr;
7466 uint16_t len, i, j = 0;
7471 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7472 printf("the len exceed the max length 128\n");
7475 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7476 filter.len = res->len_value;
7477 filter.priority = res->priority_value;
7478 filter.queue = res->queue_id;
7479 bytes_ptr = res->bytes_value;
7480 mask_ptr = res->mask_value;
7482 /* translate bytes string to array. */
7483 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7484 (bytes_ptr[1] == 'X')))
7486 len = strnlen(bytes_ptr, res->len_value * 2);
7487 if (len == 0 || (len % 8 != 0)) {
7488 printf("please check len and bytes input\n");
7491 for (i = 0; i < len; i++) {
7493 if (isxdigit(c) == 0) {
7494 /* invalid characters. */
7495 printf("invalid input\n");
7498 val = xdigit2val(c);
7501 filter.bytes[j] = byte;
7502 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7509 /* translate mask string to uint8_t array. */
7510 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7511 (mask_ptr[1] == 'X')))
7513 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7515 printf("invalid input\n");
7520 for (i = 0; i < len; i++) {
7522 if (isxdigit(c) == 0) {
7523 /* invalid characters. */
7524 printf("invalid input\n");
7527 val = xdigit2val(c);
7530 filter.mask[j] = byte;
7531 printf("mask[%d]:%02x ", j, filter.mask[j]);
7539 if (!strcmp(res->ops, "add"))
7540 ret = rte_eth_dev_filter_ctrl(res->port_id,
7541 RTE_ETH_FILTER_FLEXIBLE,
7545 ret = rte_eth_dev_filter_ctrl(res->port_id,
7546 RTE_ETH_FILTER_FLEXIBLE,
7547 RTE_ETH_FILTER_DELETE,
7551 printf("flex filter setting error: (%s)\n", strerror(-ret));
7554 cmdline_parse_token_string_t cmd_flex_filter_filter =
7555 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7556 filter, "flex_filter");
7557 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7558 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7560 cmdline_parse_token_string_t cmd_flex_filter_ops =
7561 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7563 cmdline_parse_token_string_t cmd_flex_filter_len =
7564 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7566 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7567 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7569 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7570 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7572 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7573 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7575 cmdline_parse_token_string_t cmd_flex_filter_mask =
7576 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7578 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7579 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7581 cmdline_parse_token_string_t cmd_flex_filter_priority =
7582 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7583 priority, "priority");
7584 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7585 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7586 priority_value, UINT8);
7587 cmdline_parse_token_string_t cmd_flex_filter_queue =
7588 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7590 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7591 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7593 cmdline_parse_inst_t cmd_flex_filter = {
7594 .f = cmd_flex_filter_parsed,
7596 .help_str = "add/del a flex filter",
7598 (void *)&cmd_flex_filter_filter,
7599 (void *)&cmd_flex_filter_port_id,
7600 (void *)&cmd_flex_filter_ops,
7601 (void *)&cmd_flex_filter_len,
7602 (void *)&cmd_flex_filter_len_value,
7603 (void *)&cmd_flex_filter_bytes,
7604 (void *)&cmd_flex_filter_bytes_value,
7605 (void *)&cmd_flex_filter_mask,
7606 (void *)&cmd_flex_filter_mask_value,
7607 (void *)&cmd_flex_filter_priority,
7608 (void *)&cmd_flex_filter_priority_value,
7609 (void *)&cmd_flex_filter_queue,
7610 (void *)&cmd_flex_filter_queue_id,
7615 /* *** Filters Control *** */
7617 /* *** deal with ethertype filter *** */
7618 struct cmd_ethertype_filter_result {
7619 cmdline_fixed_string_t filter;
7621 cmdline_fixed_string_t ops;
7622 cmdline_fixed_string_t mac;
7623 struct ether_addr mac_addr;
7624 cmdline_fixed_string_t ethertype;
7625 uint16_t ethertype_value;
7626 cmdline_fixed_string_t drop;
7627 cmdline_fixed_string_t queue;
7631 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7632 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7633 filter, "ethertype_filter");
7634 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7635 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7637 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7638 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7640 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7641 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7642 mac, "mac_addr#mac_ignr");
7643 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7644 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7646 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7647 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7648 ethertype, "ethertype");
7649 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7650 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7651 ethertype_value, UINT16);
7652 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7653 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7655 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7656 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7658 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7659 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7663 cmd_ethertype_filter_parsed(void *parsed_result,
7664 __attribute__((unused)) struct cmdline *cl,
7665 __attribute__((unused)) void *data)
7667 struct cmd_ethertype_filter_result *res = parsed_result;
7668 struct rte_eth_ethertype_filter filter;
7671 ret = rte_eth_dev_filter_supported(res->port_id,
7672 RTE_ETH_FILTER_ETHERTYPE);
7674 printf("ethertype filter is not supported on port %u.\n",
7679 memset(&filter, 0, sizeof(filter));
7680 if (!strcmp(res->mac, "mac_addr")) {
7681 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7682 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7683 sizeof(struct ether_addr));
7685 if (!strcmp(res->drop, "drop"))
7686 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7687 filter.ether_type = res->ethertype_value;
7688 filter.queue = res->queue_id;
7690 if (!strcmp(res->ops, "add"))
7691 ret = rte_eth_dev_filter_ctrl(res->port_id,
7692 RTE_ETH_FILTER_ETHERTYPE,
7696 ret = rte_eth_dev_filter_ctrl(res->port_id,
7697 RTE_ETH_FILTER_ETHERTYPE,
7698 RTE_ETH_FILTER_DELETE,
7701 printf("ethertype filter programming error: (%s)\n",
7705 cmdline_parse_inst_t cmd_ethertype_filter = {
7706 .f = cmd_ethertype_filter_parsed,
7708 .help_str = "add or delete an ethertype filter entry",
7710 (void *)&cmd_ethertype_filter_filter,
7711 (void *)&cmd_ethertype_filter_port_id,
7712 (void *)&cmd_ethertype_filter_ops,
7713 (void *)&cmd_ethertype_filter_mac,
7714 (void *)&cmd_ethertype_filter_mac_addr,
7715 (void *)&cmd_ethertype_filter_ethertype,
7716 (void *)&cmd_ethertype_filter_ethertype_value,
7717 (void *)&cmd_ethertype_filter_drop,
7718 (void *)&cmd_ethertype_filter_queue,
7719 (void *)&cmd_ethertype_filter_queue_id,
7724 /* *** deal with flow director filter *** */
7725 struct cmd_flow_director_result {
7726 cmdline_fixed_string_t flow_director_filter;
7728 cmdline_fixed_string_t ops;
7729 cmdline_fixed_string_t flow;
7730 cmdline_fixed_string_t flow_type;
7731 cmdline_fixed_string_t ether;
7732 uint16_t ether_type;
7733 cmdline_fixed_string_t src;
7734 cmdline_ipaddr_t ip_src;
7736 cmdline_fixed_string_t dst;
7737 cmdline_ipaddr_t ip_dst;
7739 cmdline_fixed_string_t verify_tag;
7740 uint32_t verify_tag_value;
7741 cmdline_fixed_string_t vlan;
7742 uint16_t vlan_value;
7743 cmdline_fixed_string_t flexbytes;
7744 cmdline_fixed_string_t flexbytes_value;
7745 cmdline_fixed_string_t drop;
7746 cmdline_fixed_string_t queue;
7748 cmdline_fixed_string_t fd_id;
7749 uint32_t fd_id_value;
7753 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7756 const char *p, *p0 = q_arg;
7758 unsigned long int_fld;
7759 char *str_fld[max_num];
7764 p = strchr(p0, '(');
7768 p0 = strchr(p, ')');
7773 if (size >= sizeof(s))
7776 snprintf(s, sizeof(s), "%.*s", size, p);
7777 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7778 if (ret < 0 || ret > max_num)
7780 for (i = 0; i < ret; i++) {
7782 int_fld = strtoul(str_fld[i], &end, 0);
7783 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7785 flexbytes[i] = (uint8_t)int_fld;
7791 str2flowtype(char *string)
7794 static const struct {
7797 } flowtype_str[] = {
7798 {"raw", RTE_ETH_FLOW_RAW},
7799 {"ipv4", RTE_ETH_FLOW_IPV4},
7800 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7801 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7802 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7803 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7804 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7805 {"ipv6", RTE_ETH_FLOW_IPV6},
7806 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7807 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7808 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7809 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7810 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7811 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7814 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7815 if (!strcmp(flowtype_str[i].str, string))
7816 return flowtype_str[i].type;
7818 return RTE_ETH_FLOW_UNKNOWN;
7821 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7823 if ((ip_addr).family == AF_INET) \
7824 (ip) = (ip_addr).addr.ipv4.s_addr; \
7826 printf("invalid parameter.\n"); \
7831 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7833 if ((ip_addr).family == AF_INET6) \
7834 (void)rte_memcpy(&(ip), \
7835 &((ip_addr).addr.ipv6), \
7836 sizeof(struct in6_addr)); \
7838 printf("invalid parameter.\n"); \
7844 cmd_flow_director_filter_parsed(void *parsed_result,
7845 __attribute__((unused)) struct cmdline *cl,
7846 __attribute__((unused)) void *data)
7848 struct cmd_flow_director_result *res = parsed_result;
7849 struct rte_eth_fdir_filter entry;
7850 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7853 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7855 printf("flow director is not supported on port %u.\n",
7859 memset(flexbytes, 0, sizeof(flexbytes));
7860 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7861 ret = parse_flexbytes(res->flexbytes_value,
7863 RTE_ETH_FDIR_MAX_FLEXLEN);
7865 printf("error: Cannot parse flexbytes input.\n");
7869 entry.input.flow_type = str2flowtype(res->flow_type);
7870 switch (entry.input.flow_type) {
7871 case RTE_ETH_FLOW_FRAG_IPV4:
7872 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
7873 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
7874 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
7875 IPV4_ADDR_TO_UINT(res->ip_dst,
7876 entry.input.flow.ip4_flow.dst_ip);
7877 IPV4_ADDR_TO_UINT(res->ip_src,
7878 entry.input.flow.ip4_flow.src_ip);
7879 /* need convert to big endian. */
7880 entry.input.flow.udp4_flow.dst_port =
7881 rte_cpu_to_be_16(res->port_dst);
7882 entry.input.flow.udp4_flow.src_port =
7883 rte_cpu_to_be_16(res->port_src);
7885 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
7886 IPV4_ADDR_TO_UINT(res->ip_dst,
7887 entry.input.flow.sctp4_flow.ip.dst_ip);
7888 IPV4_ADDR_TO_UINT(res->ip_src,
7889 entry.input.flow.sctp4_flow.ip.src_ip);
7890 /* need convert to big endian. */
7892 entry.input.flow.sctp4_flow.dst_port =
7893 rte_cpu_to_be_16(res->port_dst);
7894 entry.input.flow.sctp4_flow.src_port =
7895 rte_cpu_to_be_16(res->port_src);
7897 entry.input.flow.sctp4_flow.verify_tag =
7898 rte_cpu_to_be_32(res->verify_tag_value);
7900 case RTE_ETH_FLOW_FRAG_IPV6:
7901 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
7902 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
7903 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
7904 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7905 entry.input.flow.ipv6_flow.dst_ip);
7906 IPV6_ADDR_TO_ARRAY(res->ip_src,
7907 entry.input.flow.ipv6_flow.src_ip);
7908 /* need convert to big endian. */
7909 entry.input.flow.udp6_flow.dst_port =
7910 rte_cpu_to_be_16(res->port_dst);
7911 entry.input.flow.udp6_flow.src_port =
7912 rte_cpu_to_be_16(res->port_src);
7914 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
7915 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7916 entry.input.flow.sctp6_flow.ip.dst_ip);
7917 IPV6_ADDR_TO_ARRAY(res->ip_src,
7918 entry.input.flow.sctp6_flow.ip.src_ip);
7919 /* need convert to big endian. */
7921 entry.input.flow.sctp6_flow.dst_port =
7922 rte_cpu_to_be_16(res->port_dst);
7923 entry.input.flow.sctp6_flow.src_port =
7924 rte_cpu_to_be_16(res->port_src);
7926 entry.input.flow.sctp6_flow.verify_tag =
7927 rte_cpu_to_be_32(res->verify_tag_value);
7929 case RTE_ETH_FLOW_L2_PAYLOAD:
7930 entry.input.flow.l2_flow.ether_type =
7931 rte_cpu_to_be_16(res->ether_type);
7934 printf("invalid parameter.\n");
7937 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7939 RTE_ETH_FDIR_MAX_FLEXLEN);
7941 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7943 entry.action.flex_off = 0; /*use 0 by default */
7944 if (!strcmp(res->drop, "drop"))
7945 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7947 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7948 /* set to report FD ID by default */
7949 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7950 entry.action.rx_queue = res->queue_id;
7951 entry.soft_id = res->fd_id_value;
7952 if (!strcmp(res->ops, "add"))
7953 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7954 RTE_ETH_FILTER_ADD, &entry);
7955 else if (!strcmp(res->ops, "del"))
7956 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7957 RTE_ETH_FILTER_DELETE, &entry);
7959 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7960 RTE_ETH_FILTER_UPDATE, &entry);
7962 printf("flow director programming error: (%s)\n",
7966 cmdline_parse_token_string_t cmd_flow_director_filter =
7967 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7968 flow_director_filter, "flow_director_filter");
7969 cmdline_parse_token_num_t cmd_flow_director_port_id =
7970 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7972 cmdline_parse_token_string_t cmd_flow_director_ops =
7973 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7974 ops, "add#del#update");
7975 cmdline_parse_token_string_t cmd_flow_director_flow =
7976 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7978 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7980 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
7981 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
7982 cmdline_parse_token_string_t cmd_flow_director_ether =
7983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7985 cmdline_parse_token_num_t cmd_flow_director_ether_type =
7986 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7987 ether_type, UINT16);
7988 cmdline_parse_token_string_t cmd_flow_director_src =
7989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7991 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7992 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7994 cmdline_parse_token_num_t cmd_flow_director_port_src =
7995 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7997 cmdline_parse_token_string_t cmd_flow_director_dst =
7998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8000 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8001 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8003 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8004 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8006 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8008 verify_tag, "verify_tag");
8009 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8010 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8011 verify_tag_value, UINT32);
8012 cmdline_parse_token_string_t cmd_flow_director_vlan =
8013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8015 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8016 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8017 vlan_value, UINT16);
8018 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8020 flexbytes, "flexbytes");
8021 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8022 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8023 flexbytes_value, NULL);
8024 cmdline_parse_token_string_t cmd_flow_director_drop =
8025 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8027 cmdline_parse_token_string_t cmd_flow_director_queue =
8028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8030 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8031 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8033 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8034 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8036 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8037 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8038 fd_id_value, UINT32);
8040 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8041 .f = cmd_flow_director_filter_parsed,
8043 .help_str = "add or delete an ip flow director entry on NIC",
8045 (void *)&cmd_flow_director_filter,
8046 (void *)&cmd_flow_director_port_id,
8047 (void *)&cmd_flow_director_ops,
8048 (void *)&cmd_flow_director_flow,
8049 (void *)&cmd_flow_director_flow_type,
8050 (void *)&cmd_flow_director_src,
8051 (void *)&cmd_flow_director_ip_src,
8052 (void *)&cmd_flow_director_dst,
8053 (void *)&cmd_flow_director_ip_dst,
8054 (void *)&cmd_flow_director_vlan,
8055 (void *)&cmd_flow_director_vlan_value,
8056 (void *)&cmd_flow_director_flexbytes,
8057 (void *)&cmd_flow_director_flexbytes_value,
8058 (void *)&cmd_flow_director_drop,
8059 (void *)&cmd_flow_director_queue,
8060 (void *)&cmd_flow_director_queue_id,
8061 (void *)&cmd_flow_director_fd_id,
8062 (void *)&cmd_flow_director_fd_id_value,
8067 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8068 .f = cmd_flow_director_filter_parsed,
8070 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8072 (void *)&cmd_flow_director_filter,
8073 (void *)&cmd_flow_director_port_id,
8074 (void *)&cmd_flow_director_ops,
8075 (void *)&cmd_flow_director_flow,
8076 (void *)&cmd_flow_director_flow_type,
8077 (void *)&cmd_flow_director_src,
8078 (void *)&cmd_flow_director_ip_src,
8079 (void *)&cmd_flow_director_port_src,
8080 (void *)&cmd_flow_director_dst,
8081 (void *)&cmd_flow_director_ip_dst,
8082 (void *)&cmd_flow_director_port_dst,
8083 (void *)&cmd_flow_director_vlan,
8084 (void *)&cmd_flow_director_vlan_value,
8085 (void *)&cmd_flow_director_flexbytes,
8086 (void *)&cmd_flow_director_flexbytes_value,
8087 (void *)&cmd_flow_director_drop,
8088 (void *)&cmd_flow_director_queue,
8089 (void *)&cmd_flow_director_queue_id,
8090 (void *)&cmd_flow_director_fd_id,
8091 (void *)&cmd_flow_director_fd_id_value,
8096 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8097 .f = cmd_flow_director_filter_parsed,
8099 .help_str = "add or delete a sctp flow director entry on NIC",
8101 (void *)&cmd_flow_director_filter,
8102 (void *)&cmd_flow_director_port_id,
8103 (void *)&cmd_flow_director_ops,
8104 (void *)&cmd_flow_director_flow,
8105 (void *)&cmd_flow_director_flow_type,
8106 (void *)&cmd_flow_director_src,
8107 (void *)&cmd_flow_director_ip_src,
8108 (void *)&cmd_flow_director_port_dst,
8109 (void *)&cmd_flow_director_dst,
8110 (void *)&cmd_flow_director_ip_dst,
8111 (void *)&cmd_flow_director_port_dst,
8112 (void *)&cmd_flow_director_verify_tag,
8113 (void *)&cmd_flow_director_verify_tag_value,
8114 (void *)&cmd_flow_director_vlan,
8115 (void *)&cmd_flow_director_vlan_value,
8116 (void *)&cmd_flow_director_flexbytes,
8117 (void *)&cmd_flow_director_flexbytes_value,
8118 (void *)&cmd_flow_director_drop,
8119 (void *)&cmd_flow_director_queue,
8120 (void *)&cmd_flow_director_queue_id,
8121 (void *)&cmd_flow_director_fd_id,
8122 (void *)&cmd_flow_director_fd_id_value,
8127 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8128 .f = cmd_flow_director_filter_parsed,
8130 .help_str = "add or delete a L2 flow director entry on NIC",
8132 (void *)&cmd_flow_director_filter,
8133 (void *)&cmd_flow_director_port_id,
8134 (void *)&cmd_flow_director_ops,
8135 (void *)&cmd_flow_director_flow,
8136 (void *)&cmd_flow_director_flow_type,
8137 (void *)&cmd_flow_director_ether,
8138 (void *)&cmd_flow_director_ether_type,
8139 (void *)&cmd_flow_director_flexbytes,
8140 (void *)&cmd_flow_director_flexbytes_value,
8141 (void *)&cmd_flow_director_drop,
8142 (void *)&cmd_flow_director_queue,
8143 (void *)&cmd_flow_director_queue_id,
8144 (void *)&cmd_flow_director_fd_id,
8145 (void *)&cmd_flow_director_fd_id_value,
8150 struct cmd_flush_flow_director_result {
8151 cmdline_fixed_string_t flush_flow_director;
8155 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8156 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8157 flush_flow_director, "flush_flow_director");
8158 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8159 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8163 cmd_flush_flow_director_parsed(void *parsed_result,
8164 __attribute__((unused)) struct cmdline *cl,
8165 __attribute__((unused)) void *data)
8167 struct cmd_flow_director_result *res = parsed_result;
8170 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8172 printf("flow director is not supported on port %u.\n",
8177 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8178 RTE_ETH_FILTER_FLUSH, NULL);
8180 printf("flow director table flushing error: (%s)\n",
8184 cmdline_parse_inst_t cmd_flush_flow_director = {
8185 .f = cmd_flush_flow_director_parsed,
8187 .help_str = "flush all flow director entries of a device on NIC",
8189 (void *)&cmd_flush_flow_director_flush,
8190 (void *)&cmd_flush_flow_director_port_id,
8195 /* *** deal with flow director mask *** */
8196 struct cmd_flow_director_mask_result {
8197 cmdline_fixed_string_t flow_director_mask;
8199 cmdline_fixed_string_t vlan;
8200 uint16_t vlan_value;
8201 cmdline_fixed_string_t src_mask;
8202 cmdline_ipaddr_t ipv4_src;
8203 cmdline_ipaddr_t ipv6_src;
8205 cmdline_fixed_string_t dst_mask;
8206 cmdline_ipaddr_t ipv4_dst;
8207 cmdline_ipaddr_t ipv6_dst;
8212 cmd_flow_director_mask_parsed(void *parsed_result,
8213 __attribute__((unused)) struct cmdline *cl,
8214 __attribute__((unused)) void *data)
8216 struct cmd_flow_director_mask_result *res = parsed_result;
8217 struct rte_eth_fdir_masks *mask;
8218 struct rte_port *port;
8220 if (res->port_id > nb_ports) {
8221 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8225 port = &ports[res->port_id];
8226 /** Check if the port is not started **/
8227 if (port->port_status != RTE_PORT_STOPPED) {
8228 printf("Please stop port %d first\n", res->port_id);
8231 mask = &port->dev_conf.fdir_conf.mask;
8233 mask->vlan_tci_mask = res->vlan_value;
8234 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8235 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8236 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8237 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8238 mask->src_port_mask = res->port_src;
8239 mask->dst_port_mask = res->port_dst;
8241 cmd_reconfig_device_queue(res->port_id, 1, 1);
8244 cmdline_parse_token_string_t cmd_flow_director_mask =
8245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8246 flow_director_mask, "flow_director_mask");
8247 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8248 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8250 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8253 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8254 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8255 vlan_value, UINT16);
8256 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8258 src_mask, "src_mask");
8259 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8260 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8262 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8263 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8265 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8266 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8268 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8270 dst_mask, "dst_mask");
8271 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8272 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8274 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8275 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8277 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8278 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8280 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8281 .f = cmd_flow_director_mask_parsed,
8283 .help_str = "set flow director's mask on NIC",
8285 (void *)&cmd_flow_director_mask,
8286 (void *)&cmd_flow_director_mask_port_id,
8287 (void *)&cmd_flow_director_mask_vlan,
8288 (void *)&cmd_flow_director_mask_vlan_value,
8289 (void *)&cmd_flow_director_mask_src,
8290 (void *)&cmd_flow_director_mask_ipv4_src,
8291 (void *)&cmd_flow_director_mask_ipv6_src,
8292 (void *)&cmd_flow_director_mask_port_src,
8293 (void *)&cmd_flow_director_mask_dst,
8294 (void *)&cmd_flow_director_mask_ipv4_dst,
8295 (void *)&cmd_flow_director_mask_ipv6_dst,
8296 (void *)&cmd_flow_director_mask_port_dst,
8301 /* *** deal with flow director mask on flexible payload *** */
8302 struct cmd_flow_director_flex_mask_result {
8303 cmdline_fixed_string_t flow_director_flexmask;
8305 cmdline_fixed_string_t flow;
8306 cmdline_fixed_string_t flow_type;
8307 cmdline_fixed_string_t mask;
8311 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8312 __attribute__((unused)) struct cmdline *cl,
8313 __attribute__((unused)) void *data)
8315 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8316 struct rte_eth_fdir_info fdir_info;
8317 struct rte_eth_fdir_flex_mask flex_mask;
8318 struct rte_port *port;
8319 uint32_t flow_type_mask;
8323 if (res->port_id > nb_ports) {
8324 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8328 port = &ports[res->port_id];
8329 /** Check if the port is not started **/
8330 if (port->port_status != RTE_PORT_STOPPED) {
8331 printf("Please stop port %d first\n", res->port_id);
8335 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8336 ret = parse_flexbytes(res->mask,
8338 RTE_ETH_FDIR_MAX_FLEXLEN);
8340 printf("error: Cannot parse mask input.\n");
8344 memset(&fdir_info, 0, sizeof(fdir_info));
8345 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8346 RTE_ETH_FILTER_INFO, &fdir_info);
8348 printf("Cannot get FDir filter info\n");
8352 if (!strcmp(res->flow_type, "none")) {
8353 /* means don't specify the flow type */
8354 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8355 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8356 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8357 0, sizeof(struct rte_eth_fdir_flex_mask));
8358 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8359 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8361 sizeof(struct rte_eth_fdir_flex_mask));
8362 cmd_reconfig_device_queue(res->port_id, 1, 1);
8365 flow_type_mask = fdir_info.flow_types_mask[0];
8366 if (!strcmp(res->flow_type, "all")) {
8367 if (!flow_type_mask) {
8368 printf("No flow type supported\n");
8371 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8372 if (flow_type_mask & (1 << i)) {
8373 flex_mask.flow_type = i;
8374 fdir_set_flex_mask(res->port_id, &flex_mask);
8377 cmd_reconfig_device_queue(res->port_id, 1, 1);
8380 flex_mask.flow_type = str2flowtype(res->flow_type);
8381 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8382 printf("Flow type %s not supported on port %d\n",
8383 res->flow_type, res->port_id);
8386 fdir_set_flex_mask(res->port_id, &flex_mask);
8387 cmd_reconfig_device_queue(res->port_id, 1, 1);
8390 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8392 flow_director_flexmask,
8393 "flow_director_flex_mask");
8394 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8395 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8397 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8398 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8400 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8401 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8402 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8403 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8404 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8408 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8409 .f = cmd_flow_director_flex_mask_parsed,
8411 .help_str = "set flow director's flex mask on NIC",
8413 (void *)&cmd_flow_director_flexmask,
8414 (void *)&cmd_flow_director_flexmask_port_id,
8415 (void *)&cmd_flow_director_flexmask_flow,
8416 (void *)&cmd_flow_director_flexmask_flow_type,
8417 (void *)&cmd_flow_director_flexmask_mask,
8422 /* *** deal with flow director flexible payload configuration *** */
8423 struct cmd_flow_director_flexpayload_result {
8424 cmdline_fixed_string_t flow_director_flexpayload;
8426 cmdline_fixed_string_t payload_layer;
8427 cmdline_fixed_string_t payload_cfg;
8431 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8434 const char *p, *p0 = q_arg;
8436 unsigned long int_fld;
8437 char *str_fld[max_num];
8442 p = strchr(p0, '(');
8446 p0 = strchr(p, ')');
8451 if (size >= sizeof(s))
8454 snprintf(s, sizeof(s), "%.*s", size, p);
8455 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8456 if (ret < 0 || ret > max_num)
8458 for (i = 0; i < ret; i++) {
8460 int_fld = strtoul(str_fld[i], &end, 0);
8461 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8463 offsets[i] = (uint16_t)int_fld;
8469 cmd_flow_director_flxpld_parsed(void *parsed_result,
8470 __attribute__((unused)) struct cmdline *cl,
8471 __attribute__((unused)) void *data)
8473 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8474 struct rte_eth_flex_payload_cfg flex_cfg;
8475 struct rte_port *port;
8478 if (res->port_id > nb_ports) {
8479 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8483 port = &ports[res->port_id];
8484 /** Check if the port is not started **/
8485 if (port->port_status != RTE_PORT_STOPPED) {
8486 printf("Please stop port %d first\n", res->port_id);
8490 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8492 if (!strcmp(res->payload_layer, "raw"))
8493 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8494 else if (!strcmp(res->payload_layer, "l2"))
8495 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8496 else if (!strcmp(res->payload_layer, "l3"))
8497 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8498 else if (!strcmp(res->payload_layer, "l4"))
8499 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8501 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8502 RTE_ETH_FDIR_MAX_FLEXLEN);
8504 printf("error: Cannot parse flex payload input.\n");
8508 fdir_set_flex_payload(res->port_id, &flex_cfg);
8509 cmd_reconfig_device_queue(res->port_id, 1, 1);
8512 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8513 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8514 flow_director_flexpayload,
8515 "flow_director_flex_payload");
8516 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8517 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8519 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8520 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8521 payload_layer, "raw#l2#l3#l4");
8522 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8523 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8526 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8527 .f = cmd_flow_director_flxpld_parsed,
8529 .help_str = "set flow director's flex payload on NIC",
8531 (void *)&cmd_flow_director_flexpayload,
8532 (void *)&cmd_flow_director_flexpayload_port_id,
8533 (void *)&cmd_flow_director_flexpayload_payload_layer,
8534 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8539 /* *** Classification Filters Control *** */
8540 /* *** Get symmetric hash enable per port *** */
8541 struct cmd_get_sym_hash_ena_per_port_result {
8542 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8547 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8548 __rte_unused struct cmdline *cl,
8549 __rte_unused void *data)
8551 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8552 struct rte_eth_hash_filter_info info;
8555 if (rte_eth_dev_filter_supported(res->port_id,
8556 RTE_ETH_FILTER_HASH) < 0) {
8557 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8562 memset(&info, 0, sizeof(info));
8563 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8564 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8565 RTE_ETH_FILTER_GET, &info);
8568 printf("Cannot get symmetric hash enable per port "
8569 "on port %u\n", res->port_id);
8573 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8574 "enabled" : "disabled", res->port_id);
8577 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8578 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8579 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8580 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8581 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8584 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8585 .f = cmd_get_sym_hash_per_port_parsed,
8587 .help_str = "get_sym_hash_ena_per_port port_id",
8589 (void *)&cmd_get_sym_hash_ena_per_port_all,
8590 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8595 /* *** Set symmetric hash enable per port *** */
8596 struct cmd_set_sym_hash_ena_per_port_result {
8597 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8598 cmdline_fixed_string_t enable;
8603 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8604 __rte_unused struct cmdline *cl,
8605 __rte_unused void *data)
8607 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8608 struct rte_eth_hash_filter_info info;
8611 if (rte_eth_dev_filter_supported(res->port_id,
8612 RTE_ETH_FILTER_HASH) < 0) {
8613 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8618 memset(&info, 0, sizeof(info));
8619 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8620 if (!strcmp(res->enable, "enable"))
8621 info.info.enable = 1;
8622 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8623 RTE_ETH_FILTER_SET, &info);
8625 printf("Cannot set symmetric hash enable per port on "
8626 "port %u\n", res->port_id);
8629 printf("Symmetric hash has been set to %s on port %u\n",
8630 res->enable, res->port_id);
8633 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8634 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8635 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8636 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8637 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8639 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8640 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8641 enable, "enable#disable");
8643 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8644 .f = cmd_set_sym_hash_per_port_parsed,
8646 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8648 (void *)&cmd_set_sym_hash_ena_per_port_all,
8649 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8650 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8655 /* Get global config of hash function */
8656 struct cmd_get_hash_global_config_result {
8657 cmdline_fixed_string_t get_hash_global_config;
8662 flowtype_to_str(uint16_t ftype)
8669 {"ipv4", RTE_ETH_FLOW_IPV4},
8670 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8671 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8672 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8673 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8674 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8675 {"ipv6", RTE_ETH_FLOW_IPV6},
8676 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8677 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8678 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8679 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8680 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8681 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8684 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8685 if (ftype_table[i].ftype == ftype)
8686 return ftype_table[i].str;
8693 cmd_get_hash_global_config_parsed(void *parsed_result,
8694 __rte_unused struct cmdline *cl,
8695 __rte_unused void *data)
8697 struct cmd_get_hash_global_config_result *res = parsed_result;
8698 struct rte_eth_hash_filter_info info;
8699 uint32_t idx, offset;
8704 if (rte_eth_dev_filter_supported(res->port_id,
8705 RTE_ETH_FILTER_HASH) < 0) {
8706 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8711 memset(&info, 0, sizeof(info));
8712 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8713 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8714 RTE_ETH_FILTER_GET, &info);
8716 printf("Cannot get hash global configurations by port %d\n",
8721 switch (info.info.global_conf.hash_func) {
8722 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8723 printf("Hash function is Toeplitz\n");
8725 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8726 printf("Hash function is Simple XOR\n");
8729 printf("Unknown hash function\n");
8733 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
8734 idx = i / UINT32_BIT;
8735 offset = i % UINT32_BIT;
8736 if (!(info.info.global_conf.valid_bit_mask[idx] &
8739 str = flowtype_to_str(i);
8742 printf("Symmetric hash is %s globally for flow type %s "
8744 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8745 (1UL << offset)) ? "enabled" : "disabled"), str,
8750 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8751 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8752 get_hash_global_config, "get_hash_global_config");
8753 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8754 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8757 cmdline_parse_inst_t cmd_get_hash_global_config = {
8758 .f = cmd_get_hash_global_config_parsed,
8760 .help_str = "get_hash_global_config port_id",
8762 (void *)&cmd_get_hash_global_config_all,
8763 (void *)&cmd_get_hash_global_config_port_id,
8768 /* Set global config of hash function */
8769 struct cmd_set_hash_global_config_result {
8770 cmdline_fixed_string_t set_hash_global_config;
8772 cmdline_fixed_string_t hash_func;
8773 cmdline_fixed_string_t flow_type;
8774 cmdline_fixed_string_t enable;
8778 cmd_set_hash_global_config_parsed(void *parsed_result,
8779 __rte_unused struct cmdline *cl,
8780 __rte_unused void *data)
8782 struct cmd_set_hash_global_config_result *res = parsed_result;
8783 struct rte_eth_hash_filter_info info;
8784 uint32_t ftype, idx, offset;
8787 if (rte_eth_dev_filter_supported(res->port_id,
8788 RTE_ETH_FILTER_HASH) < 0) {
8789 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8793 memset(&info, 0, sizeof(info));
8794 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8795 if (!strcmp(res->hash_func, "toeplitz"))
8796 info.info.global_conf.hash_func =
8797 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8798 else if (!strcmp(res->hash_func, "simple_xor"))
8799 info.info.global_conf.hash_func =
8800 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8801 else if (!strcmp(res->hash_func, "default"))
8802 info.info.global_conf.hash_func =
8803 RTE_ETH_HASH_FUNCTION_DEFAULT;
8805 ftype = str2flowtype(res->flow_type);
8806 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8807 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8808 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8809 if (!strcmp(res->enable, "enable"))
8810 info.info.global_conf.sym_hash_enable_mask[idx] |=
8812 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8813 RTE_ETH_FILTER_SET, &info);
8815 printf("Cannot set global hash configurations by port %d\n",
8818 printf("Global hash configurations have been set "
8819 "succcessfully by port %d\n", res->port_id);
8822 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8823 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8824 set_hash_global_config, "set_hash_global_config");
8825 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8826 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8828 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8829 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8830 hash_func, "toeplitz#simple_xor#default");
8831 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8832 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8834 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
8835 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
8836 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8837 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8838 enable, "enable#disable");
8840 cmdline_parse_inst_t cmd_set_hash_global_config = {
8841 .f = cmd_set_hash_global_config_parsed,
8843 .help_str = "set_hash_global_config port_id "
8844 "toeplitz|simple_xor|default "
8845 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
8846 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
8849 (void *)&cmd_set_hash_global_config_all,
8850 (void *)&cmd_set_hash_global_config_port_id,
8851 (void *)&cmd_set_hash_global_config_hash_func,
8852 (void *)&cmd_set_hash_global_config_flow_type,
8853 (void *)&cmd_set_hash_global_config_enable,
8858 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
8859 struct cmd_mcast_addr_result {
8860 cmdline_fixed_string_t mcast_addr_cmd;
8861 cmdline_fixed_string_t what;
8863 struct ether_addr mc_addr;
8866 static void cmd_mcast_addr_parsed(void *parsed_result,
8867 __attribute__((unused)) struct cmdline *cl,
8868 __attribute__((unused)) void *data)
8870 struct cmd_mcast_addr_result *res = parsed_result;
8872 if (!is_multicast_ether_addr(&res->mc_addr)) {
8873 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
8874 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
8875 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
8876 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
8879 if (strcmp(res->what, "add") == 0)
8880 mcast_addr_add(res->port_num, &res->mc_addr);
8882 mcast_addr_remove(res->port_num, &res->mc_addr);
8885 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
8886 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8887 mcast_addr_cmd, "mcast_addr");
8888 cmdline_parse_token_string_t cmd_mcast_addr_what =
8889 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8891 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
8892 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
8893 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
8894 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8896 cmdline_parse_inst_t cmd_mcast_addr = {
8897 .f = cmd_mcast_addr_parsed,
8899 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
8901 (void *)&cmd_mcast_addr_cmd,
8902 (void *)&cmd_mcast_addr_what,
8903 (void *)&cmd_mcast_addr_portnum,
8904 (void *)&cmd_mcast_addr_addr,
8909 /* ******************************************************************************** */
8911 /* list of instructions */
8912 cmdline_parse_ctx_t main_ctx[] = {
8913 (cmdline_parse_inst_t *)&cmd_help_brief,
8914 (cmdline_parse_inst_t *)&cmd_help_long,
8915 (cmdline_parse_inst_t *)&cmd_quit,
8916 (cmdline_parse_inst_t *)&cmd_showport,
8917 (cmdline_parse_inst_t *)&cmd_showportall,
8918 (cmdline_parse_inst_t *)&cmd_showcfg,
8919 (cmdline_parse_inst_t *)&cmd_start,
8920 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8921 (cmdline_parse_inst_t *)&cmd_set_link_up,
8922 (cmdline_parse_inst_t *)&cmd_set_link_down,
8923 (cmdline_parse_inst_t *)&cmd_reset,
8924 (cmdline_parse_inst_t *)&cmd_set_numbers,
8925 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8926 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8927 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8928 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8929 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8930 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8931 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8932 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8933 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8934 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8935 (cmdline_parse_inst_t *)&cmd_set_link_check,
8936 #ifdef RTE_NIC_BYPASS
8937 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8938 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8939 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8940 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8942 #ifdef RTE_LIBRTE_PMD_BOND
8943 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8944 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8945 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8946 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8947 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8948 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8949 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8950 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8951 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8953 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8954 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8955 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8956 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8957 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8958 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
8959 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8960 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8961 (cmdline_parse_inst_t *)&cmd_csum_set,
8962 (cmdline_parse_inst_t *)&cmd_csum_show,
8963 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8964 (cmdline_parse_inst_t *)&cmd_tso_set,
8965 (cmdline_parse_inst_t *)&cmd_tso_show,
8966 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8967 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8968 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8969 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8970 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8971 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8972 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8973 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8974 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8975 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8976 (cmdline_parse_inst_t *)&cmd_config_dcb,
8977 (cmdline_parse_inst_t *)&cmd_read_reg,
8978 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8979 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8980 (cmdline_parse_inst_t *)&cmd_write_reg,
8981 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8982 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8983 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8984 (cmdline_parse_inst_t *)&cmd_stop,
8985 (cmdline_parse_inst_t *)&cmd_mac_addr,
8986 (cmdline_parse_inst_t *)&cmd_set_qmap,
8987 (cmdline_parse_inst_t *)&cmd_operate_port,
8988 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8989 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
8990 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
8991 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8992 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8993 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8994 (cmdline_parse_inst_t *)&cmd_config_mtu,
8995 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8996 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8997 (cmdline_parse_inst_t *)&cmd_config_rss,
8998 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8999 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9000 (cmdline_parse_inst_t *)&cmd_showport_reta,
9001 (cmdline_parse_inst_t *)&cmd_config_burst,
9002 (cmdline_parse_inst_t *)&cmd_config_thresh,
9003 (cmdline_parse_inst_t *)&cmd_config_threshold,
9004 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9005 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9006 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9007 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9008 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9009 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9010 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9011 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9012 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9013 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9014 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9015 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9016 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9017 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9018 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9019 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9020 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9021 (cmdline_parse_inst_t *)&cmd_dump,
9022 (cmdline_parse_inst_t *)&cmd_dump_one,
9023 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9024 (cmdline_parse_inst_t *)&cmd_syn_filter,
9025 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9026 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9027 (cmdline_parse_inst_t *)&cmd_flex_filter,
9028 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9029 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9030 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9031 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9032 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9033 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
9034 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9035 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9036 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9037 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9038 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9039 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9040 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9044 /* prompt function, called from main on MASTER lcore */
9050 /* initialize non-constant commands */
9051 cmd_set_fwd_mode_init();
9053 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9057 cmdline_interact(cl);
9058 cmdline_stdin_exit(cl);
9062 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9064 if (id == (portid_t)RTE_PORT_ALL) {
9067 FOREACH_PORT(pid, ports) {
9068 /* check if need_reconfig has been set to 1 */
9069 if (ports[pid].need_reconfig == 0)
9070 ports[pid].need_reconfig = dev;
9071 /* check if need_reconfig_queues has been set to 1 */
9072 if (ports[pid].need_reconfig_queues == 0)
9073 ports[pid].need_reconfig_queues = queue;
9075 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9076 /* check if need_reconfig has been set to 1 */
9077 if (ports[id].need_reconfig == 0)
9078 ports[id].need_reconfig = dev;
9079 /* check if need_reconfig_queues has been set to 1 */
9080 if (ports[id].need_reconfig_queues == 0)
9081 ports[id].need_reconfig_queues = queue;
9085 #ifdef RTE_NIC_BYPASS
9086 #include <rte_pci_dev_ids.h>
9088 bypass_is_supported(portid_t port_id)
9090 struct rte_port *port;
9091 struct rte_pci_id *pci_id;
9093 if (port_id_is_invalid(port_id, ENABLED_WARN))
9096 /* Get the device id. */
9097 port = &ports[port_id];
9098 pci_id = &port->dev_info.pci_dev->id;
9100 /* Check if NIC supports bypass. */
9101 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9105 printf("\tBypass not supported for port_id = %d.\n", port_id);