4 * Copyright(c) 2010-2014 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);
4023 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4024 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4026 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4027 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4028 bonding, "bonding");
4029 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4030 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4032 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4033 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4035 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4036 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4039 cmdline_parse_inst_t cmd_add_bonding_slave = {
4040 .f = cmd_add_bonding_slave_parsed,
4041 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4044 (void *)&cmd_addbonding_slave_add,
4045 (void *)&cmd_addbonding_slave_bonding,
4046 (void *)&cmd_addbonding_slave_slave,
4047 (void *)&cmd_addbonding_slave_slaveid,
4048 (void *)&cmd_addbonding_slave_port,
4053 /* *** REMOVE SLAVE *** */
4054 struct cmd_remove_bonding_slave_result {
4055 cmdline_fixed_string_t remove;
4056 cmdline_fixed_string_t bonding;
4057 cmdline_fixed_string_t slave;
4062 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4063 __attribute__((unused)) struct cmdline *cl,
4064 __attribute__((unused)) void *data)
4066 struct cmd_remove_bonding_slave_result *res = parsed_result;
4067 portid_t master_port_id = res->port_id;
4068 portid_t slave_port_id = res->slave_id;
4070 /* Set the primary slave for a bonded device. */
4071 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4072 printf("\t Failed to remove slave %d from master port = %d.\n",
4073 slave_port_id, master_port_id);
4079 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4080 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4082 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4083 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4084 bonding, "bonding");
4085 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4086 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4088 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4089 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4091 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4092 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4095 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4096 .f = cmd_remove_bonding_slave_parsed,
4097 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4100 (void *)&cmd_removebonding_slave_remove,
4101 (void *)&cmd_removebonding_slave_bonding,
4102 (void *)&cmd_removebonding_slave_slave,
4103 (void *)&cmd_removebonding_slave_slaveid,
4104 (void *)&cmd_removebonding_slave_port,
4109 /* *** CREATE BONDED DEVICE *** */
4110 struct cmd_create_bonded_device_result {
4111 cmdline_fixed_string_t create;
4112 cmdline_fixed_string_t bonded;
4113 cmdline_fixed_string_t device;
4118 static int bond_dev_num = 0;
4120 static void cmd_create_bonded_device_parsed(void *parsed_result,
4121 __attribute__((unused)) struct cmdline *cl,
4122 __attribute__((unused)) void *data)
4124 struct cmd_create_bonded_device_result *res = parsed_result;
4125 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4128 if (test_done == 0) {
4129 printf("Please stop forwarding first\n");
4133 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4136 /* Create a new bonded device. */
4137 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4139 printf("\t Failed to create bonded device.\n");
4142 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4145 /* Update number of ports */
4146 nb_ports = rte_eth_dev_count();
4147 reconfig(port_id, res->socket);
4148 rte_eth_promiscuous_enable(port_id);
4149 ports[port_id].enabled = 1;
4154 cmdline_parse_token_string_t cmd_createbonded_device_create =
4155 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4157 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4158 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4160 cmdline_parse_token_string_t cmd_createbonded_device_device =
4161 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4163 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4164 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4166 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4167 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4170 cmdline_parse_inst_t cmd_create_bonded_device = {
4171 .f = cmd_create_bonded_device_parsed,
4172 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4175 (void *)&cmd_createbonded_device_create,
4176 (void *)&cmd_createbonded_device_bonded,
4177 (void *)&cmd_createbonded_device_device,
4178 (void *)&cmd_createbonded_device_mode,
4179 (void *)&cmd_createbonded_device_socket,
4184 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4185 struct cmd_set_bond_mac_addr_result {
4186 cmdline_fixed_string_t set;
4187 cmdline_fixed_string_t bonding;
4188 cmdline_fixed_string_t mac_addr;
4190 struct ether_addr address;
4193 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4194 __attribute__((unused)) struct cmdline *cl,
4195 __attribute__((unused)) void *data)
4197 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4200 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4203 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4205 /* check the return value and print it if is < 0 */
4207 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4210 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4211 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4212 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4213 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4215 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4216 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4218 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4219 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4220 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4221 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4223 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4224 .f = cmd_set_bond_mac_addr_parsed,
4226 .help_str = "set bonding mac_addr (port_id) (address): ",
4228 (void *)&cmd_set_bond_mac_addr_set,
4229 (void *)&cmd_set_bond_mac_addr_bonding,
4230 (void *)&cmd_set_bond_mac_addr_mac,
4231 (void *)&cmd_set_bond_mac_addr_portnum,
4232 (void *)&cmd_set_bond_mac_addr_addr,
4238 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4239 struct cmd_set_bond_mon_period_result {
4240 cmdline_fixed_string_t set;
4241 cmdline_fixed_string_t bonding;
4242 cmdline_fixed_string_t mon_period;
4247 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4248 __attribute__((unused)) struct cmdline *cl,
4249 __attribute__((unused)) void *data)
4251 struct cmd_set_bond_mon_period_result *res = parsed_result;
4254 if (res->port_num >= nb_ports) {
4255 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4259 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4261 /* check the return value and print it if is < 0 */
4263 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4266 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4267 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4269 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4270 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4271 bonding, "bonding");
4272 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4273 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4274 mon_period, "mon_period");
4275 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4276 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4278 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4279 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4282 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4283 .f = cmd_set_bond_mon_period_parsed,
4285 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4287 (void *)&cmd_set_bond_mon_period_set,
4288 (void *)&cmd_set_bond_mon_period_bonding,
4289 (void *)&cmd_set_bond_mon_period_mon_period,
4290 (void *)&cmd_set_bond_mon_period_portnum,
4291 (void *)&cmd_set_bond_mon_period_period_ms,
4296 #endif /* RTE_LIBRTE_PMD_BOND */
4298 /* *** SET FORWARDING MODE *** */
4299 struct cmd_set_fwd_mode_result {
4300 cmdline_fixed_string_t set;
4301 cmdline_fixed_string_t fwd;
4302 cmdline_fixed_string_t mode;
4305 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4306 __attribute__((unused)) struct cmdline *cl,
4307 __attribute__((unused)) void *data)
4309 struct cmd_set_fwd_mode_result *res = parsed_result;
4311 set_pkt_forwarding_mode(res->mode);
4314 cmdline_parse_token_string_t cmd_setfwd_set =
4315 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4316 cmdline_parse_token_string_t cmd_setfwd_fwd =
4317 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4318 cmdline_parse_token_string_t cmd_setfwd_mode =
4319 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4320 "" /* defined at init */);
4322 cmdline_parse_inst_t cmd_set_fwd_mode = {
4323 .f = cmd_set_fwd_mode_parsed,
4325 .help_str = NULL, /* defined at init */
4327 (void *)&cmd_setfwd_set,
4328 (void *)&cmd_setfwd_fwd,
4329 (void *)&cmd_setfwd_mode,
4334 static void cmd_set_fwd_mode_init(void)
4337 static char token[128];
4338 static char help[256];
4339 cmdline_parse_token_string_t *token_struct;
4341 modes = list_pkt_forwarding_modes();
4342 snprintf(help, sizeof help, "set fwd %s - "
4343 "set packet forwarding mode", modes);
4344 cmd_set_fwd_mode.help_str = help;
4346 /* string token separator is # */
4347 for (c = token; *modes != '\0'; modes++)
4352 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4353 token_struct->string_data.str = token;
4356 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4357 struct cmd_set_burst_tx_retry_result {
4358 cmdline_fixed_string_t set;
4359 cmdline_fixed_string_t burst;
4360 cmdline_fixed_string_t tx;
4361 cmdline_fixed_string_t delay;
4363 cmdline_fixed_string_t retry;
4367 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4368 __attribute__((unused)) struct cmdline *cl,
4369 __attribute__((unused)) void *data)
4371 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4373 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4374 && !strcmp(res->tx, "tx")) {
4375 if (!strcmp(res->delay, "delay"))
4376 burst_tx_delay_time = res->time;
4377 if (!strcmp(res->retry, "retry"))
4378 burst_tx_retry_num = res->retry_num;
4383 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4384 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4385 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4386 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4388 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4389 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4390 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4391 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4392 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4393 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4394 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4395 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4396 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4397 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4399 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4400 .f = cmd_set_burst_tx_retry_parsed,
4401 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4403 (void *)&cmd_set_burst_tx_retry_set,
4404 (void *)&cmd_set_burst_tx_retry_burst,
4405 (void *)&cmd_set_burst_tx_retry_tx,
4406 (void *)&cmd_set_burst_tx_retry_delay,
4407 (void *)&cmd_set_burst_tx_retry_time,
4408 (void *)&cmd_set_burst_tx_retry_retry,
4409 (void *)&cmd_set_burst_tx_retry_retry_num,
4414 /* *** SET PROMISC MODE *** */
4415 struct cmd_set_promisc_mode_result {
4416 cmdline_fixed_string_t set;
4417 cmdline_fixed_string_t promisc;
4418 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4419 uint8_t port_num; /* valid if "allports" argument == 0 */
4420 cmdline_fixed_string_t mode;
4423 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4424 __attribute__((unused)) struct cmdline *cl,
4427 struct cmd_set_promisc_mode_result *res = parsed_result;
4431 if (!strcmp(res->mode, "on"))
4438 FOREACH_PORT(i, ports) {
4440 rte_eth_promiscuous_enable(i);
4442 rte_eth_promiscuous_disable(i);
4447 rte_eth_promiscuous_enable(res->port_num);
4449 rte_eth_promiscuous_disable(res->port_num);
4453 cmdline_parse_token_string_t cmd_setpromisc_set =
4454 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4455 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4456 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4458 cmdline_parse_token_string_t cmd_setpromisc_portall =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4461 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4462 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4464 cmdline_parse_token_string_t cmd_setpromisc_mode =
4465 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4468 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4469 .f = cmd_set_promisc_mode_parsed,
4471 .help_str = "set promisc all on|off: set promisc mode for all ports",
4473 (void *)&cmd_setpromisc_set,
4474 (void *)&cmd_setpromisc_promisc,
4475 (void *)&cmd_setpromisc_portall,
4476 (void *)&cmd_setpromisc_mode,
4481 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4482 .f = cmd_set_promisc_mode_parsed,
4484 .help_str = "set promisc X on|off: set promisc mode on port X",
4486 (void *)&cmd_setpromisc_set,
4487 (void *)&cmd_setpromisc_promisc,
4488 (void *)&cmd_setpromisc_portnum,
4489 (void *)&cmd_setpromisc_mode,
4494 /* *** SET ALLMULTI MODE *** */
4495 struct cmd_set_allmulti_mode_result {
4496 cmdline_fixed_string_t set;
4497 cmdline_fixed_string_t allmulti;
4498 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4499 uint8_t port_num; /* valid if "allports" argument == 0 */
4500 cmdline_fixed_string_t mode;
4503 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4504 __attribute__((unused)) struct cmdline *cl,
4507 struct cmd_set_allmulti_mode_result *res = parsed_result;
4511 if (!strcmp(res->mode, "on"))
4518 FOREACH_PORT(i, ports) {
4520 rte_eth_allmulticast_enable(i);
4522 rte_eth_allmulticast_disable(i);
4527 rte_eth_allmulticast_enable(res->port_num);
4529 rte_eth_allmulticast_disable(res->port_num);
4533 cmdline_parse_token_string_t cmd_setallmulti_set =
4534 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4535 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4536 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4538 cmdline_parse_token_string_t cmd_setallmulti_portall =
4539 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4541 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4542 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4544 cmdline_parse_token_string_t cmd_setallmulti_mode =
4545 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4548 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4549 .f = cmd_set_allmulti_mode_parsed,
4551 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4553 (void *)&cmd_setallmulti_set,
4554 (void *)&cmd_setallmulti_allmulti,
4555 (void *)&cmd_setallmulti_portall,
4556 (void *)&cmd_setallmulti_mode,
4561 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4562 .f = cmd_set_allmulti_mode_parsed,
4564 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4566 (void *)&cmd_setallmulti_set,
4567 (void *)&cmd_setallmulti_allmulti,
4568 (void *)&cmd_setallmulti_portnum,
4569 (void *)&cmd_setallmulti_mode,
4574 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4575 struct cmd_link_flow_ctrl_set_result {
4576 cmdline_fixed_string_t set;
4577 cmdline_fixed_string_t flow_ctrl;
4578 cmdline_fixed_string_t rx;
4579 cmdline_fixed_string_t rx_lfc_mode;
4580 cmdline_fixed_string_t tx;
4581 cmdline_fixed_string_t tx_lfc_mode;
4582 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4583 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4584 cmdline_fixed_string_t autoneg_str;
4585 cmdline_fixed_string_t autoneg;
4586 cmdline_fixed_string_t hw_str;
4587 uint32_t high_water;
4588 cmdline_fixed_string_t lw_str;
4590 cmdline_fixed_string_t pt_str;
4591 uint16_t pause_time;
4592 cmdline_fixed_string_t xon_str;
4597 cmdline_parse_token_string_t cmd_lfc_set_set =
4598 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4600 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4601 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4602 flow_ctrl, "flow_ctrl");
4603 cmdline_parse_token_string_t cmd_lfc_set_rx =
4604 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4606 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4607 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4608 rx_lfc_mode, "on#off");
4609 cmdline_parse_token_string_t cmd_lfc_set_tx =
4610 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4612 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4613 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4614 tx_lfc_mode, "on#off");
4615 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4616 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4617 hw_str, "high_water");
4618 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4619 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4620 high_water, UINT32);
4621 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4622 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4623 lw_str, "low_water");
4624 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4625 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4627 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4628 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4629 pt_str, "pause_time");
4630 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4631 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4632 pause_time, UINT16);
4633 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4634 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4635 xon_str, "send_xon");
4636 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4637 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4639 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4640 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4641 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4642 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4643 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4644 mac_ctrl_frame_fwd_mode, "on#off");
4645 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4646 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4647 autoneg_str, "autoneg");
4648 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4649 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4651 cmdline_parse_token_num_t cmd_lfc_set_portid =
4652 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4655 /* forward declaration */
4657 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4660 cmdline_parse_inst_t cmd_link_flow_control_set = {
4661 .f = cmd_link_flow_ctrl_set_parsed,
4663 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4664 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4665 autoneg on|off port_id",
4667 (void *)&cmd_lfc_set_set,
4668 (void *)&cmd_lfc_set_flow_ctrl,
4669 (void *)&cmd_lfc_set_rx,
4670 (void *)&cmd_lfc_set_rx_mode,
4671 (void *)&cmd_lfc_set_tx,
4672 (void *)&cmd_lfc_set_tx_mode,
4673 (void *)&cmd_lfc_set_high_water,
4674 (void *)&cmd_lfc_set_low_water,
4675 (void *)&cmd_lfc_set_pause_time,
4676 (void *)&cmd_lfc_set_send_xon,
4677 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4678 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4679 (void *)&cmd_lfc_set_autoneg_str,
4680 (void *)&cmd_lfc_set_autoneg,
4681 (void *)&cmd_lfc_set_portid,
4686 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4687 .f = cmd_link_flow_ctrl_set_parsed,
4688 .data = (void *)&cmd_link_flow_control_set_rx,
4689 .help_str = "Change rx flow control parameter: set flow_ctrl "
4690 "rx on|off port_id",
4692 (void *)&cmd_lfc_set_set,
4693 (void *)&cmd_lfc_set_flow_ctrl,
4694 (void *)&cmd_lfc_set_rx,
4695 (void *)&cmd_lfc_set_rx_mode,
4696 (void *)&cmd_lfc_set_portid,
4701 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4702 .f = cmd_link_flow_ctrl_set_parsed,
4703 .data = (void *)&cmd_link_flow_control_set_tx,
4704 .help_str = "Change tx flow control parameter: set flow_ctrl "
4705 "tx on|off port_id",
4707 (void *)&cmd_lfc_set_set,
4708 (void *)&cmd_lfc_set_flow_ctrl,
4709 (void *)&cmd_lfc_set_tx,
4710 (void *)&cmd_lfc_set_tx_mode,
4711 (void *)&cmd_lfc_set_portid,
4716 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4717 .f = cmd_link_flow_ctrl_set_parsed,
4718 .data = (void *)&cmd_link_flow_control_set_hw,
4719 .help_str = "Change high water flow control parameter: set flow_ctrl "
4720 "high_water value port_id",
4722 (void *)&cmd_lfc_set_set,
4723 (void *)&cmd_lfc_set_flow_ctrl,
4724 (void *)&cmd_lfc_set_high_water_str,
4725 (void *)&cmd_lfc_set_high_water,
4726 (void *)&cmd_lfc_set_portid,
4731 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4732 .f = cmd_link_flow_ctrl_set_parsed,
4733 .data = (void *)&cmd_link_flow_control_set_lw,
4734 .help_str = "Change low water flow control parameter: set flow_ctrl "
4735 "low_water value port_id",
4737 (void *)&cmd_lfc_set_set,
4738 (void *)&cmd_lfc_set_flow_ctrl,
4739 (void *)&cmd_lfc_set_low_water_str,
4740 (void *)&cmd_lfc_set_low_water,
4741 (void *)&cmd_lfc_set_portid,
4746 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4747 .f = cmd_link_flow_ctrl_set_parsed,
4748 .data = (void *)&cmd_link_flow_control_set_pt,
4749 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4750 "pause_time value port_id",
4752 (void *)&cmd_lfc_set_set,
4753 (void *)&cmd_lfc_set_flow_ctrl,
4754 (void *)&cmd_lfc_set_pause_time_str,
4755 (void *)&cmd_lfc_set_pause_time,
4756 (void *)&cmd_lfc_set_portid,
4761 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4762 .f = cmd_link_flow_ctrl_set_parsed,
4763 .data = (void *)&cmd_link_flow_control_set_xon,
4764 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4765 "send_xon value port_id",
4767 (void *)&cmd_lfc_set_set,
4768 (void *)&cmd_lfc_set_flow_ctrl,
4769 (void *)&cmd_lfc_set_send_xon_str,
4770 (void *)&cmd_lfc_set_send_xon,
4771 (void *)&cmd_lfc_set_portid,
4776 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4777 .f = cmd_link_flow_ctrl_set_parsed,
4778 .data = (void *)&cmd_link_flow_control_set_macfwd,
4779 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4780 "mac_ctrl_frame_fwd on|off port_id",
4782 (void *)&cmd_lfc_set_set,
4783 (void *)&cmd_lfc_set_flow_ctrl,
4784 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4785 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4786 (void *)&cmd_lfc_set_portid,
4791 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4792 .f = cmd_link_flow_ctrl_set_parsed,
4793 .data = (void *)&cmd_link_flow_control_set_autoneg,
4794 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4795 "autoneg on|off port_id",
4797 (void *)&cmd_lfc_set_set,
4798 (void *)&cmd_lfc_set_flow_ctrl,
4799 (void *)&cmd_lfc_set_autoneg_str,
4800 (void *)&cmd_lfc_set_autoneg,
4801 (void *)&cmd_lfc_set_portid,
4807 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4808 __attribute__((unused)) struct cmdline *cl,
4811 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4812 cmdline_parse_inst_t *cmd = data;
4813 struct rte_eth_fc_conf fc_conf;
4819 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4820 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4821 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4822 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4824 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4825 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4828 /* Partial command line, retrieve current configuration */
4830 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4832 printf("cannot get current flow ctrl parameters, return"
4833 "code = %d\n", ret);
4837 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4838 (fc_conf.mode == RTE_FC_FULL))
4840 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4841 (fc_conf.mode == RTE_FC_FULL))
4845 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4846 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4848 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4849 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4851 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4853 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4854 fc_conf.high_water = res->high_water;
4856 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4857 fc_conf.low_water = res->low_water;
4859 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4860 fc_conf.pause_time = res->pause_time;
4862 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4863 fc_conf.send_xon = res->send_xon;
4865 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4866 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4867 fc_conf.mac_ctrl_frame_fwd = 1;
4869 fc_conf.mac_ctrl_frame_fwd = 0;
4872 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4873 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4875 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4877 printf("bad flow contrl parameter, return code = %d \n", ret);
4880 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4881 struct cmd_priority_flow_ctrl_set_result {
4882 cmdline_fixed_string_t set;
4883 cmdline_fixed_string_t pfc_ctrl;
4884 cmdline_fixed_string_t rx;
4885 cmdline_fixed_string_t rx_pfc_mode;
4886 cmdline_fixed_string_t tx;
4887 cmdline_fixed_string_t tx_pfc_mode;
4888 uint32_t high_water;
4890 uint16_t pause_time;
4896 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4897 __attribute__((unused)) struct cmdline *cl,
4898 __attribute__((unused)) void *data)
4900 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4901 struct rte_eth_pfc_conf pfc_conf;
4902 int rx_fc_enable, tx_fc_enable;
4906 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4907 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4908 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4909 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4911 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4912 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4915 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4916 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4917 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4918 pfc_conf.fc.high_water = res->high_water;
4919 pfc_conf.fc.low_water = res->low_water;
4920 pfc_conf.fc.pause_time = res->pause_time;
4921 pfc_conf.priority = res->priority;
4923 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4925 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4928 cmdline_parse_token_string_t cmd_pfc_set_set =
4929 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4931 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4932 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4933 pfc_ctrl, "pfc_ctrl");
4934 cmdline_parse_token_string_t cmd_pfc_set_rx =
4935 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4937 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4938 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4939 rx_pfc_mode, "on#off");
4940 cmdline_parse_token_string_t cmd_pfc_set_tx =
4941 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4943 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4944 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4945 tx_pfc_mode, "on#off");
4946 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4947 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4948 high_water, UINT32);
4949 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4950 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4952 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4953 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4954 pause_time, UINT16);
4955 cmdline_parse_token_num_t cmd_pfc_set_priority =
4956 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4958 cmdline_parse_token_num_t cmd_pfc_set_portid =
4959 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4962 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4963 .f = cmd_priority_flow_ctrl_set_parsed,
4965 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4966 tx on|off high_water low_water pause_time priority port_id",
4968 (void *)&cmd_pfc_set_set,
4969 (void *)&cmd_pfc_set_flow_ctrl,
4970 (void *)&cmd_pfc_set_rx,
4971 (void *)&cmd_pfc_set_rx_mode,
4972 (void *)&cmd_pfc_set_tx,
4973 (void *)&cmd_pfc_set_tx_mode,
4974 (void *)&cmd_pfc_set_high_water,
4975 (void *)&cmd_pfc_set_low_water,
4976 (void *)&cmd_pfc_set_pause_time,
4977 (void *)&cmd_pfc_set_priority,
4978 (void *)&cmd_pfc_set_portid,
4983 /* *** RESET CONFIGURATION *** */
4984 struct cmd_reset_result {
4985 cmdline_fixed_string_t reset;
4986 cmdline_fixed_string_t def;
4989 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4991 __attribute__((unused)) void *data)
4993 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4994 set_def_fwd_config();
4997 cmdline_parse_token_string_t cmd_reset_set =
4998 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4999 cmdline_parse_token_string_t cmd_reset_def =
5000 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5003 cmdline_parse_inst_t cmd_reset = {
5004 .f = cmd_reset_parsed,
5006 .help_str = "set default: reset default forwarding configuration",
5008 (void *)&cmd_reset_set,
5009 (void *)&cmd_reset_def,
5014 /* *** START FORWARDING *** */
5015 struct cmd_start_result {
5016 cmdline_fixed_string_t start;
5019 cmdline_parse_token_string_t cmd_start_start =
5020 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5022 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5023 __attribute__((unused)) struct cmdline *cl,
5024 __attribute__((unused)) void *data)
5026 start_packet_forwarding(0);
5029 cmdline_parse_inst_t cmd_start = {
5030 .f = cmd_start_parsed,
5032 .help_str = "start packet forwarding",
5034 (void *)&cmd_start_start,
5039 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5040 struct cmd_start_tx_first_result {
5041 cmdline_fixed_string_t start;
5042 cmdline_fixed_string_t tx_first;
5046 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5047 __attribute__((unused)) struct cmdline *cl,
5048 __attribute__((unused)) void *data)
5050 start_packet_forwarding(1);
5053 cmdline_parse_token_string_t cmd_start_tx_first_start =
5054 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5056 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5057 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5058 tx_first, "tx_first");
5060 cmdline_parse_inst_t cmd_start_tx_first = {
5061 .f = cmd_start_tx_first_parsed,
5063 .help_str = "start packet forwarding, after sending 1 burst of packets",
5065 (void *)&cmd_start_tx_first_start,
5066 (void *)&cmd_start_tx_first_tx_first,
5071 /* *** SET LINK UP *** */
5072 struct cmd_set_link_up_result {
5073 cmdline_fixed_string_t set;
5074 cmdline_fixed_string_t link_up;
5075 cmdline_fixed_string_t port;
5079 cmdline_parse_token_string_t cmd_set_link_up_set =
5080 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5081 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5082 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5084 cmdline_parse_token_string_t cmd_set_link_up_port =
5085 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5086 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5087 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5089 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5090 __attribute__((unused)) struct cmdline *cl,
5091 __attribute__((unused)) void *data)
5093 struct cmd_set_link_up_result *res = parsed_result;
5094 dev_set_link_up(res->port_id);
5097 cmdline_parse_inst_t cmd_set_link_up = {
5098 .f = cmd_set_link_up_parsed,
5100 .help_str = "set link-up port (port id)",
5102 (void *)&cmd_set_link_up_set,
5103 (void *)&cmd_set_link_up_link_up,
5104 (void *)&cmd_set_link_up_port,
5105 (void *)&cmd_set_link_up_port_id,
5110 /* *** SET LINK DOWN *** */
5111 struct cmd_set_link_down_result {
5112 cmdline_fixed_string_t set;
5113 cmdline_fixed_string_t link_down;
5114 cmdline_fixed_string_t port;
5118 cmdline_parse_token_string_t cmd_set_link_down_set =
5119 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5120 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5121 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5123 cmdline_parse_token_string_t cmd_set_link_down_port =
5124 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5125 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5126 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5128 static void cmd_set_link_down_parsed(
5129 __attribute__((unused)) void *parsed_result,
5130 __attribute__((unused)) struct cmdline *cl,
5131 __attribute__((unused)) void *data)
5133 struct cmd_set_link_down_result *res = parsed_result;
5134 dev_set_link_down(res->port_id);
5137 cmdline_parse_inst_t cmd_set_link_down = {
5138 .f = cmd_set_link_down_parsed,
5140 .help_str = "set link-down port (port id)",
5142 (void *)&cmd_set_link_down_set,
5143 (void *)&cmd_set_link_down_link_down,
5144 (void *)&cmd_set_link_down_port,
5145 (void *)&cmd_set_link_down_port_id,
5150 /* *** SHOW CFG *** */
5151 struct cmd_showcfg_result {
5152 cmdline_fixed_string_t show;
5153 cmdline_fixed_string_t cfg;
5154 cmdline_fixed_string_t what;
5157 static void cmd_showcfg_parsed(void *parsed_result,
5158 __attribute__((unused)) struct cmdline *cl,
5159 __attribute__((unused)) void *data)
5161 struct cmd_showcfg_result *res = parsed_result;
5162 if (!strcmp(res->what, "rxtx"))
5163 rxtx_config_display();
5164 else if (!strcmp(res->what, "cores"))
5165 fwd_lcores_config_display();
5166 else if (!strcmp(res->what, "fwd"))
5167 fwd_config_display();
5170 cmdline_parse_token_string_t cmd_showcfg_show =
5171 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5172 cmdline_parse_token_string_t cmd_showcfg_port =
5173 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5174 cmdline_parse_token_string_t cmd_showcfg_what =
5175 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5178 cmdline_parse_inst_t cmd_showcfg = {
5179 .f = cmd_showcfg_parsed,
5181 .help_str = "show config rxtx|cores|fwd",
5183 (void *)&cmd_showcfg_show,
5184 (void *)&cmd_showcfg_port,
5185 (void *)&cmd_showcfg_what,
5190 /* *** SHOW ALL PORT INFO *** */
5191 struct cmd_showportall_result {
5192 cmdline_fixed_string_t show;
5193 cmdline_fixed_string_t port;
5194 cmdline_fixed_string_t what;
5195 cmdline_fixed_string_t all;
5198 static void cmd_showportall_parsed(void *parsed_result,
5199 __attribute__((unused)) struct cmdline *cl,
5200 __attribute__((unused)) void *data)
5204 struct cmd_showportall_result *res = parsed_result;
5205 if (!strcmp(res->show, "clear")) {
5206 if (!strcmp(res->what, "stats"))
5207 FOREACH_PORT(i, ports)
5209 else if (!strcmp(res->what, "xstats"))
5210 FOREACH_PORT(i, ports)
5211 nic_xstats_clear(i);
5212 } else if (!strcmp(res->what, "info"))
5213 FOREACH_PORT(i, ports)
5214 port_infos_display(i);
5215 else if (!strcmp(res->what, "stats"))
5216 FOREACH_PORT(i, ports)
5217 nic_stats_display(i);
5218 else if (!strcmp(res->what, "xstats"))
5219 FOREACH_PORT(i, ports)
5220 nic_xstats_display(i);
5221 else if (!strcmp(res->what, "fdir"))
5222 FOREACH_PORT(i, ports)
5224 else if (!strcmp(res->what, "stat_qmap"))
5225 FOREACH_PORT(i, ports)
5226 nic_stats_mapping_display(i);
5229 cmdline_parse_token_string_t cmd_showportall_show =
5230 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5232 cmdline_parse_token_string_t cmd_showportall_port =
5233 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5234 cmdline_parse_token_string_t cmd_showportall_what =
5235 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5236 "info#stats#xstats#fdir#stat_qmap");
5237 cmdline_parse_token_string_t cmd_showportall_all =
5238 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5239 cmdline_parse_inst_t cmd_showportall = {
5240 .f = cmd_showportall_parsed,
5242 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5244 (void *)&cmd_showportall_show,
5245 (void *)&cmd_showportall_port,
5246 (void *)&cmd_showportall_what,
5247 (void *)&cmd_showportall_all,
5252 /* *** SHOW PORT INFO *** */
5253 struct cmd_showport_result {
5254 cmdline_fixed_string_t show;
5255 cmdline_fixed_string_t port;
5256 cmdline_fixed_string_t what;
5260 static void cmd_showport_parsed(void *parsed_result,
5261 __attribute__((unused)) struct cmdline *cl,
5262 __attribute__((unused)) void *data)
5264 struct cmd_showport_result *res = parsed_result;
5265 if (!strcmp(res->show, "clear")) {
5266 if (!strcmp(res->what, "stats"))
5267 nic_stats_clear(res->portnum);
5268 else if (!strcmp(res->what, "xstats"))
5269 nic_xstats_clear(res->portnum);
5270 } else if (!strcmp(res->what, "info"))
5271 port_infos_display(res->portnum);
5272 else if (!strcmp(res->what, "stats"))
5273 nic_stats_display(res->portnum);
5274 else if (!strcmp(res->what, "xstats"))
5275 nic_xstats_display(res->portnum);
5276 else if (!strcmp(res->what, "fdir"))
5277 fdir_get_infos(res->portnum);
5278 else if (!strcmp(res->what, "stat_qmap"))
5279 nic_stats_mapping_display(res->portnum);
5282 cmdline_parse_token_string_t cmd_showport_show =
5283 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5285 cmdline_parse_token_string_t cmd_showport_port =
5286 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5287 cmdline_parse_token_string_t cmd_showport_what =
5288 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5289 "info#stats#xstats#fdir#stat_qmap");
5290 cmdline_parse_token_num_t cmd_showport_portnum =
5291 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5293 cmdline_parse_inst_t cmd_showport = {
5294 .f = cmd_showport_parsed,
5296 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5298 (void *)&cmd_showport_show,
5299 (void *)&cmd_showport_port,
5300 (void *)&cmd_showport_what,
5301 (void *)&cmd_showport_portnum,
5306 /* *** READ PORT REGISTER *** */
5307 struct cmd_read_reg_result {
5308 cmdline_fixed_string_t read;
5309 cmdline_fixed_string_t reg;
5315 cmd_read_reg_parsed(void *parsed_result,
5316 __attribute__((unused)) struct cmdline *cl,
5317 __attribute__((unused)) void *data)
5319 struct cmd_read_reg_result *res = parsed_result;
5320 port_reg_display(res->port_id, res->reg_off);
5323 cmdline_parse_token_string_t cmd_read_reg_read =
5324 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5325 cmdline_parse_token_string_t cmd_read_reg_reg =
5326 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5327 cmdline_parse_token_num_t cmd_read_reg_port_id =
5328 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5329 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5330 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5332 cmdline_parse_inst_t cmd_read_reg = {
5333 .f = cmd_read_reg_parsed,
5335 .help_str = "read reg port_id reg_off",
5337 (void *)&cmd_read_reg_read,
5338 (void *)&cmd_read_reg_reg,
5339 (void *)&cmd_read_reg_port_id,
5340 (void *)&cmd_read_reg_reg_off,
5345 /* *** READ PORT REGISTER BIT FIELD *** */
5346 struct cmd_read_reg_bit_field_result {
5347 cmdline_fixed_string_t read;
5348 cmdline_fixed_string_t regfield;
5356 cmd_read_reg_bit_field_parsed(void *parsed_result,
5357 __attribute__((unused)) struct cmdline *cl,
5358 __attribute__((unused)) void *data)
5360 struct cmd_read_reg_bit_field_result *res = parsed_result;
5361 port_reg_bit_field_display(res->port_id, res->reg_off,
5362 res->bit1_pos, res->bit2_pos);
5365 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5366 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5368 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5369 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5370 regfield, "regfield");
5371 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5372 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5374 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5375 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5377 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5378 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5380 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5381 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5384 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5385 .f = cmd_read_reg_bit_field_parsed,
5387 .help_str = "read regfield port_id reg_off bit_x bit_y "
5388 "(read register bit field between bit_x and bit_y included)",
5390 (void *)&cmd_read_reg_bit_field_read,
5391 (void *)&cmd_read_reg_bit_field_regfield,
5392 (void *)&cmd_read_reg_bit_field_port_id,
5393 (void *)&cmd_read_reg_bit_field_reg_off,
5394 (void *)&cmd_read_reg_bit_field_bit1_pos,
5395 (void *)&cmd_read_reg_bit_field_bit2_pos,
5400 /* *** READ PORT REGISTER BIT *** */
5401 struct cmd_read_reg_bit_result {
5402 cmdline_fixed_string_t read;
5403 cmdline_fixed_string_t regbit;
5410 cmd_read_reg_bit_parsed(void *parsed_result,
5411 __attribute__((unused)) struct cmdline *cl,
5412 __attribute__((unused)) void *data)
5414 struct cmd_read_reg_bit_result *res = parsed_result;
5415 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5418 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5419 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5420 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5421 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5423 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5424 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5425 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5426 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5427 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5428 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5430 cmdline_parse_inst_t cmd_read_reg_bit = {
5431 .f = cmd_read_reg_bit_parsed,
5433 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5435 (void *)&cmd_read_reg_bit_read,
5436 (void *)&cmd_read_reg_bit_regbit,
5437 (void *)&cmd_read_reg_bit_port_id,
5438 (void *)&cmd_read_reg_bit_reg_off,
5439 (void *)&cmd_read_reg_bit_bit_pos,
5444 /* *** WRITE PORT REGISTER *** */
5445 struct cmd_write_reg_result {
5446 cmdline_fixed_string_t write;
5447 cmdline_fixed_string_t reg;
5454 cmd_write_reg_parsed(void *parsed_result,
5455 __attribute__((unused)) struct cmdline *cl,
5456 __attribute__((unused)) void *data)
5458 struct cmd_write_reg_result *res = parsed_result;
5459 port_reg_set(res->port_id, res->reg_off, res->value);
5462 cmdline_parse_token_string_t cmd_write_reg_write =
5463 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5464 cmdline_parse_token_string_t cmd_write_reg_reg =
5465 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5466 cmdline_parse_token_num_t cmd_write_reg_port_id =
5467 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5468 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5469 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5470 cmdline_parse_token_num_t cmd_write_reg_value =
5471 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5473 cmdline_parse_inst_t cmd_write_reg = {
5474 .f = cmd_write_reg_parsed,
5476 .help_str = "write reg port_id reg_off reg_value",
5478 (void *)&cmd_write_reg_write,
5479 (void *)&cmd_write_reg_reg,
5480 (void *)&cmd_write_reg_port_id,
5481 (void *)&cmd_write_reg_reg_off,
5482 (void *)&cmd_write_reg_value,
5487 /* *** WRITE PORT REGISTER BIT FIELD *** */
5488 struct cmd_write_reg_bit_field_result {
5489 cmdline_fixed_string_t write;
5490 cmdline_fixed_string_t regfield;
5499 cmd_write_reg_bit_field_parsed(void *parsed_result,
5500 __attribute__((unused)) struct cmdline *cl,
5501 __attribute__((unused)) void *data)
5503 struct cmd_write_reg_bit_field_result *res = parsed_result;
5504 port_reg_bit_field_set(res->port_id, res->reg_off,
5505 res->bit1_pos, res->bit2_pos, res->value);
5508 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5509 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5511 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5512 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5513 regfield, "regfield");
5514 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5515 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5517 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5518 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5520 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5521 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5523 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5524 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5526 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5527 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5530 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5531 .f = cmd_write_reg_bit_field_parsed,
5533 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5534 "(set register bit field between bit_x and bit_y included)",
5536 (void *)&cmd_write_reg_bit_field_write,
5537 (void *)&cmd_write_reg_bit_field_regfield,
5538 (void *)&cmd_write_reg_bit_field_port_id,
5539 (void *)&cmd_write_reg_bit_field_reg_off,
5540 (void *)&cmd_write_reg_bit_field_bit1_pos,
5541 (void *)&cmd_write_reg_bit_field_bit2_pos,
5542 (void *)&cmd_write_reg_bit_field_value,
5547 /* *** WRITE PORT REGISTER BIT *** */
5548 struct cmd_write_reg_bit_result {
5549 cmdline_fixed_string_t write;
5550 cmdline_fixed_string_t regbit;
5558 cmd_write_reg_bit_parsed(void *parsed_result,
5559 __attribute__((unused)) struct cmdline *cl,
5560 __attribute__((unused)) void *data)
5562 struct cmd_write_reg_bit_result *res = parsed_result;
5563 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5566 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5567 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5569 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5570 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5572 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5573 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5574 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5575 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5576 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5577 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5578 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5579 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5581 cmdline_parse_inst_t cmd_write_reg_bit = {
5582 .f = cmd_write_reg_bit_parsed,
5584 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5586 (void *)&cmd_write_reg_bit_write,
5587 (void *)&cmd_write_reg_bit_regbit,
5588 (void *)&cmd_write_reg_bit_port_id,
5589 (void *)&cmd_write_reg_bit_reg_off,
5590 (void *)&cmd_write_reg_bit_bit_pos,
5591 (void *)&cmd_write_reg_bit_value,
5596 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5597 struct cmd_read_rxd_txd_result {
5598 cmdline_fixed_string_t read;
5599 cmdline_fixed_string_t rxd_txd;
5606 cmd_read_rxd_txd_parsed(void *parsed_result,
5607 __attribute__((unused)) struct cmdline *cl,
5608 __attribute__((unused)) void *data)
5610 struct cmd_read_rxd_txd_result *res = parsed_result;
5612 if (!strcmp(res->rxd_txd, "rxd"))
5613 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5614 else if (!strcmp(res->rxd_txd, "txd"))
5615 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5618 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5619 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5620 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5621 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5623 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5624 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5625 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5626 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5627 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5628 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5630 cmdline_parse_inst_t cmd_read_rxd_txd = {
5631 .f = cmd_read_rxd_txd_parsed,
5633 .help_str = "read rxd|txd port_id queue_id rxd_id",
5635 (void *)&cmd_read_rxd_txd_read,
5636 (void *)&cmd_read_rxd_txd_rxd_txd,
5637 (void *)&cmd_read_rxd_txd_port_id,
5638 (void *)&cmd_read_rxd_txd_queue_id,
5639 (void *)&cmd_read_rxd_txd_desc_id,
5645 struct cmd_quit_result {
5646 cmdline_fixed_string_t quit;
5649 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5651 __attribute__((unused)) void *data)
5657 cmdline_parse_token_string_t cmd_quit_quit =
5658 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5660 cmdline_parse_inst_t cmd_quit = {
5661 .f = cmd_quit_parsed,
5663 .help_str = "exit application",
5665 (void *)&cmd_quit_quit,
5670 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5671 struct cmd_mac_addr_result {
5672 cmdline_fixed_string_t mac_addr_cmd;
5673 cmdline_fixed_string_t what;
5675 struct ether_addr address;
5678 static void cmd_mac_addr_parsed(void *parsed_result,
5679 __attribute__((unused)) struct cmdline *cl,
5680 __attribute__((unused)) void *data)
5682 struct cmd_mac_addr_result *res = parsed_result;
5685 if (strcmp(res->what, "add") == 0)
5686 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5688 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5690 /* check the return value and print it if is < 0 */
5692 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5696 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5697 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5699 cmdline_parse_token_string_t cmd_mac_addr_what =
5700 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5702 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5703 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5704 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5705 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5707 cmdline_parse_inst_t cmd_mac_addr = {
5708 .f = cmd_mac_addr_parsed,
5710 .help_str = "mac_addr add|remove X <address>: "
5711 "add/remove MAC address on port X",
5713 (void *)&cmd_mac_addr_cmd,
5714 (void *)&cmd_mac_addr_what,
5715 (void *)&cmd_mac_addr_portnum,
5716 (void *)&cmd_mac_addr_addr,
5722 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5723 struct cmd_set_qmap_result {
5724 cmdline_fixed_string_t set;
5725 cmdline_fixed_string_t qmap;
5726 cmdline_fixed_string_t what;
5733 cmd_set_qmap_parsed(void *parsed_result,
5734 __attribute__((unused)) struct cmdline *cl,
5735 __attribute__((unused)) void *data)
5737 struct cmd_set_qmap_result *res = parsed_result;
5738 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5740 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5743 cmdline_parse_token_string_t cmd_setqmap_set =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5746 cmdline_parse_token_string_t cmd_setqmap_qmap =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5749 cmdline_parse_token_string_t cmd_setqmap_what =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5752 cmdline_parse_token_num_t cmd_setqmap_portid =
5753 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5755 cmdline_parse_token_num_t cmd_setqmap_queueid =
5756 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5758 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5759 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5762 cmdline_parse_inst_t cmd_set_qmap = {
5763 .f = cmd_set_qmap_parsed,
5765 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5767 (void *)&cmd_setqmap_set,
5768 (void *)&cmd_setqmap_qmap,
5769 (void *)&cmd_setqmap_what,
5770 (void *)&cmd_setqmap_portid,
5771 (void *)&cmd_setqmap_queueid,
5772 (void *)&cmd_setqmap_mapvalue,
5777 /* *** CONFIGURE UNICAST HASH TABLE *** */
5778 struct cmd_set_uc_hash_table {
5779 cmdline_fixed_string_t set;
5780 cmdline_fixed_string_t port;
5782 cmdline_fixed_string_t what;
5783 struct ether_addr address;
5784 cmdline_fixed_string_t mode;
5788 cmd_set_uc_hash_parsed(void *parsed_result,
5789 __attribute__((unused)) struct cmdline *cl,
5790 __attribute__((unused)) void *data)
5793 struct cmd_set_uc_hash_table *res = parsed_result;
5795 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5797 if (strcmp(res->what, "uta") == 0)
5798 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5799 &res->address,(uint8_t)is_on);
5801 printf("bad unicast hash table parameter, return code = %d \n", ret);
5805 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5806 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5808 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5809 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5811 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5812 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5814 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5817 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5818 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5820 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5821 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5824 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5825 .f = cmd_set_uc_hash_parsed,
5827 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5829 (void *)&cmd_set_uc_hash_set,
5830 (void *)&cmd_set_uc_hash_port,
5831 (void *)&cmd_set_uc_hash_portid,
5832 (void *)&cmd_set_uc_hash_what,
5833 (void *)&cmd_set_uc_hash_mac,
5834 (void *)&cmd_set_uc_hash_mode,
5839 struct cmd_set_uc_all_hash_table {
5840 cmdline_fixed_string_t set;
5841 cmdline_fixed_string_t port;
5843 cmdline_fixed_string_t what;
5844 cmdline_fixed_string_t value;
5845 cmdline_fixed_string_t mode;
5849 cmd_set_uc_all_hash_parsed(void *parsed_result,
5850 __attribute__((unused)) struct cmdline *cl,
5851 __attribute__((unused)) void *data)
5854 struct cmd_set_uc_all_hash_table *res = parsed_result;
5856 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5858 if ((strcmp(res->what, "uta") == 0) &&
5859 (strcmp(res->value, "all") == 0))
5860 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5862 printf("bad unicast hash table parameter,"
5863 "return code = %d \n", ret);
5866 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5867 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5869 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5870 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5872 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5873 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5875 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5876 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5878 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5881 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5885 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5886 .f = cmd_set_uc_all_hash_parsed,
5888 .help_str = "set port X uta all on|off (X = port number)",
5890 (void *)&cmd_set_uc_all_hash_set,
5891 (void *)&cmd_set_uc_all_hash_port,
5892 (void *)&cmd_set_uc_all_hash_portid,
5893 (void *)&cmd_set_uc_all_hash_what,
5894 (void *)&cmd_set_uc_all_hash_value,
5895 (void *)&cmd_set_uc_all_hash_mode,
5900 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5901 struct cmd_set_vf_macvlan_filter {
5902 cmdline_fixed_string_t set;
5903 cmdline_fixed_string_t port;
5905 cmdline_fixed_string_t vf;
5907 struct ether_addr address;
5908 cmdline_fixed_string_t filter_type;
5909 cmdline_fixed_string_t mode;
5913 cmd_set_vf_macvlan_parsed(void *parsed_result,
5914 __attribute__((unused)) struct cmdline *cl,
5915 __attribute__((unused)) void *data)
5918 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5919 struct rte_eth_mac_filter filter;
5921 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5923 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5925 /* set VF MAC filter */
5929 filter.dst_id = res->vf_id;
5931 if (!strcmp(res->filter_type, "exact-mac"))
5932 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5933 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5934 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5935 else if (!strcmp(res->filter_type, "hashmac"))
5936 filter.filter_type = RTE_MAC_HASH_MATCH;
5937 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5938 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5940 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5943 ret = rte_eth_dev_filter_ctrl(res->port_id,
5944 RTE_ETH_FILTER_MACVLAN,
5948 ret = rte_eth_dev_filter_ctrl(res->port_id,
5949 RTE_ETH_FILTER_MACVLAN,
5950 RTE_ETH_FILTER_DELETE,
5954 printf("bad set MAC hash parameter, return code = %d\n", ret);
5958 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5959 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5961 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5962 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5964 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5965 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5967 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5968 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5970 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5971 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5973 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5974 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5976 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5977 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5978 filter_type, "exact-mac#exact-mac-vlan"
5979 "#hashmac#hashmac-vlan");
5980 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5981 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5984 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5985 .f = cmd_set_vf_macvlan_parsed,
5987 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5988 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5990 "exact match rule:exact match of MAC or MAC and VLAN; "
5991 "hash match rule: hash match of MAC and exact match "
5994 (void *)&cmd_set_vf_macvlan_set,
5995 (void *)&cmd_set_vf_macvlan_port,
5996 (void *)&cmd_set_vf_macvlan_portid,
5997 (void *)&cmd_set_vf_macvlan_vf,
5998 (void *)&cmd_set_vf_macvlan_vf_id,
5999 (void *)&cmd_set_vf_macvlan_mac,
6000 (void *)&cmd_set_vf_macvlan_filter_type,
6001 (void *)&cmd_set_vf_macvlan_mode,
6006 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6007 struct cmd_set_vf_traffic {
6008 cmdline_fixed_string_t set;
6009 cmdline_fixed_string_t port;
6011 cmdline_fixed_string_t vf;
6013 cmdline_fixed_string_t what;
6014 cmdline_fixed_string_t mode;
6018 cmd_set_vf_traffic_parsed(void *parsed_result,
6019 __attribute__((unused)) struct cmdline *cl,
6020 __attribute__((unused)) void *data)
6022 struct cmd_set_vf_traffic *res = parsed_result;
6023 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6024 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6026 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6029 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6030 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6032 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6035 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6036 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6038 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6039 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6041 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6042 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6044 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6045 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6047 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6048 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6051 cmdline_parse_inst_t cmd_set_vf_traffic = {
6052 .f = cmd_set_vf_traffic_parsed,
6054 .help_str = "set port X vf Y rx|tx on|off"
6055 "(X = port number,Y = vf id)",
6057 (void *)&cmd_setvf_traffic_set,
6058 (void *)&cmd_setvf_traffic_port,
6059 (void *)&cmd_setvf_traffic_portid,
6060 (void *)&cmd_setvf_traffic_vf,
6061 (void *)&cmd_setvf_traffic_vfid,
6062 (void *)&cmd_setvf_traffic_what,
6063 (void *)&cmd_setvf_traffic_mode,
6068 /* *** CONFIGURE VF RECEIVE MODE *** */
6069 struct cmd_set_vf_rxmode {
6070 cmdline_fixed_string_t set;
6071 cmdline_fixed_string_t port;
6073 cmdline_fixed_string_t vf;
6075 cmdline_fixed_string_t what;
6076 cmdline_fixed_string_t mode;
6077 cmdline_fixed_string_t on;
6081 cmd_set_vf_rxmode_parsed(void *parsed_result,
6082 __attribute__((unused)) struct cmdline *cl,
6083 __attribute__((unused)) void *data)
6086 uint16_t rx_mode = 0;
6087 struct cmd_set_vf_rxmode *res = parsed_result;
6089 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6090 if (!strcmp(res->what,"rxmode")) {
6091 if (!strcmp(res->mode, "AUPE"))
6092 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6093 else if (!strcmp(res->mode, "ROPE"))
6094 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6095 else if (!strcmp(res->mode, "BAM"))
6096 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6097 else if (!strncmp(res->mode, "MPE",3))
6098 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6101 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6103 printf("bad VF receive mode parameter, return code = %d \n",
6107 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6108 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6110 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6111 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6113 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6114 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6116 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6117 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6119 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6120 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6122 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6123 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6125 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6126 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6127 mode, "AUPE#ROPE#BAM#MPE");
6128 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6129 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6132 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6133 .f = cmd_set_vf_rxmode_parsed,
6135 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6137 (void *)&cmd_set_vf_rxmode_set,
6138 (void *)&cmd_set_vf_rxmode_port,
6139 (void *)&cmd_set_vf_rxmode_portid,
6140 (void *)&cmd_set_vf_rxmode_vf,
6141 (void *)&cmd_set_vf_rxmode_vfid,
6142 (void *)&cmd_set_vf_rxmode_what,
6143 (void *)&cmd_set_vf_rxmode_mode,
6144 (void *)&cmd_set_vf_rxmode_on,
6149 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6150 struct cmd_vf_mac_addr_result {
6151 cmdline_fixed_string_t mac_addr_cmd;
6152 cmdline_fixed_string_t what;
6153 cmdline_fixed_string_t port;
6155 cmdline_fixed_string_t vf;
6157 struct ether_addr address;
6160 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6161 __attribute__((unused)) struct cmdline *cl,
6162 __attribute__((unused)) void *data)
6164 struct cmd_vf_mac_addr_result *res = parsed_result;
6167 if (strcmp(res->what, "add") == 0)
6168 ret = rte_eth_dev_mac_addr_add(res->port_num,
6169 &res->address, res->vf_num);
6171 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6175 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6176 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6177 mac_addr_cmd,"mac_addr");
6178 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6179 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6181 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6182 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6184 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6185 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6187 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6188 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6190 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6191 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6193 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6194 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6197 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6198 .f = cmd_vf_mac_addr_parsed,
6200 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6201 "Y = VF number)add MAC address filtering for a VF on port X",
6203 (void *)&cmd_vf_mac_addr_cmd,
6204 (void *)&cmd_vf_mac_addr_what,
6205 (void *)&cmd_vf_mac_addr_port,
6206 (void *)&cmd_vf_mac_addr_portnum,
6207 (void *)&cmd_vf_mac_addr_vf,
6208 (void *)&cmd_vf_mac_addr_vfnum,
6209 (void *)&cmd_vf_mac_addr_addr,
6214 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6215 struct cmd_vf_rx_vlan_filter {
6216 cmdline_fixed_string_t rx_vlan;
6217 cmdline_fixed_string_t what;
6219 cmdline_fixed_string_t port;
6221 cmdline_fixed_string_t vf;
6226 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6227 __attribute__((unused)) struct cmdline *cl,
6228 __attribute__((unused)) void *data)
6230 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6232 if (!strcmp(res->what, "add"))
6233 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6235 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6238 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6239 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6240 rx_vlan, "rx_vlan");
6241 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6242 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6244 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6245 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6247 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6248 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6250 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6251 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6253 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6254 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6256 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6257 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6260 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6261 .f = cmd_vf_rx_vlan_filter_parsed,
6263 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6264 "Y = port number,Z = hexadecimal VF mask)",
6266 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6267 (void *)&cmd_vf_rx_vlan_filter_what,
6268 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6269 (void *)&cmd_vf_rx_vlan_filter_port,
6270 (void *)&cmd_vf_rx_vlan_filter_portid,
6271 (void *)&cmd_vf_rx_vlan_filter_vf,
6272 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6277 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6278 struct cmd_queue_rate_limit_result {
6279 cmdline_fixed_string_t set;
6280 cmdline_fixed_string_t port;
6282 cmdline_fixed_string_t queue;
6284 cmdline_fixed_string_t rate;
6288 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6289 __attribute__((unused)) struct cmdline *cl,
6290 __attribute__((unused)) void *data)
6292 struct cmd_queue_rate_limit_result *res = parsed_result;
6295 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6296 && (strcmp(res->queue, "queue") == 0)
6297 && (strcmp(res->rate, "rate") == 0))
6298 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6301 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6305 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6306 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6308 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6309 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6311 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6312 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6314 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6315 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6317 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6318 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6320 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6321 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6323 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6324 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6327 cmdline_parse_inst_t cmd_queue_rate_limit = {
6328 .f = cmd_queue_rate_limit_parsed,
6330 .help_str = "set port X queue Y rate Z:(X = port number,"
6331 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6333 (void *)&cmd_queue_rate_limit_set,
6334 (void *)&cmd_queue_rate_limit_port,
6335 (void *)&cmd_queue_rate_limit_portnum,
6336 (void *)&cmd_queue_rate_limit_queue,
6337 (void *)&cmd_queue_rate_limit_queuenum,
6338 (void *)&cmd_queue_rate_limit_rate,
6339 (void *)&cmd_queue_rate_limit_ratenum,
6344 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6345 struct cmd_vf_rate_limit_result {
6346 cmdline_fixed_string_t set;
6347 cmdline_fixed_string_t port;
6349 cmdline_fixed_string_t vf;
6351 cmdline_fixed_string_t rate;
6353 cmdline_fixed_string_t q_msk;
6357 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6358 __attribute__((unused)) struct cmdline *cl,
6359 __attribute__((unused)) void *data)
6361 struct cmd_vf_rate_limit_result *res = parsed_result;
6364 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6365 && (strcmp(res->vf, "vf") == 0)
6366 && (strcmp(res->rate, "rate") == 0)
6367 && (strcmp(res->q_msk, "queue_mask") == 0))
6368 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6369 res->rate_num, res->q_msk_val);
6371 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6375 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6376 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6378 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6379 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6381 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6382 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6384 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6385 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6387 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6388 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6390 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6391 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6393 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6394 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6396 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6397 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6398 q_msk, "queue_mask");
6399 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6400 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6403 cmdline_parse_inst_t cmd_vf_rate_limit = {
6404 .f = cmd_vf_rate_limit_parsed,
6406 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6407 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6408 "for queues of VF on port X",
6410 (void *)&cmd_vf_rate_limit_set,
6411 (void *)&cmd_vf_rate_limit_port,
6412 (void *)&cmd_vf_rate_limit_portnum,
6413 (void *)&cmd_vf_rate_limit_vf,
6414 (void *)&cmd_vf_rate_limit_vfnum,
6415 (void *)&cmd_vf_rate_limit_rate,
6416 (void *)&cmd_vf_rate_limit_ratenum,
6417 (void *)&cmd_vf_rate_limit_q_msk,
6418 (void *)&cmd_vf_rate_limit_q_msk_val,
6423 /* *** ADD TUNNEL FILTER OF A PORT *** */
6424 struct cmd_tunnel_filter_result {
6425 cmdline_fixed_string_t cmd;
6426 cmdline_fixed_string_t what;
6428 struct ether_addr outer_mac;
6429 struct ether_addr inner_mac;
6430 cmdline_ipaddr_t ip_value;
6431 uint16_t inner_vlan;
6432 cmdline_fixed_string_t tunnel_type;
6433 cmdline_fixed_string_t filter_type;
6439 cmd_tunnel_filter_parsed(void *parsed_result,
6440 __attribute__((unused)) struct cmdline *cl,
6441 __attribute__((unused)) void *data)
6443 struct cmd_tunnel_filter_result *res = parsed_result;
6444 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6447 tunnel_filter_conf.outer_mac = &res->outer_mac;
6448 tunnel_filter_conf.inner_mac = &res->inner_mac;
6449 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6451 if (res->ip_value.family == AF_INET) {
6452 tunnel_filter_conf.ip_addr.ipv4_addr =
6453 res->ip_value.addr.ipv4.s_addr;
6454 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6456 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6457 &(res->ip_value.addr.ipv6),
6458 sizeof(struct in6_addr));
6459 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6462 if (!strcmp(res->filter_type, "imac-ivlan"))
6463 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6464 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6465 tunnel_filter_conf.filter_type =
6466 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6467 else if (!strcmp(res->filter_type, "imac-tenid"))
6468 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6469 else if (!strcmp(res->filter_type, "imac"))
6470 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6471 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6472 tunnel_filter_conf.filter_type =
6473 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6475 printf("The filter type is not supported");
6479 if (!strcmp(res->tunnel_type, "vxlan"))
6480 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6481 else if (!strcmp(res->tunnel_type, "nvgre"))
6482 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6484 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6488 tunnel_filter_conf.tenant_id = res->tenant_id;
6489 tunnel_filter_conf.queue_id = res->queue_num;
6490 if (!strcmp(res->what, "add"))
6491 ret = rte_eth_dev_filter_ctrl(res->port_id,
6492 RTE_ETH_FILTER_TUNNEL,
6494 &tunnel_filter_conf);
6496 ret = rte_eth_dev_filter_ctrl(res->port_id,
6497 RTE_ETH_FILTER_TUNNEL,
6498 RTE_ETH_FILTER_DELETE,
6499 &tunnel_filter_conf);
6501 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6505 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6506 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6507 cmd, "tunnel_filter");
6508 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6509 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6511 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6512 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6514 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6515 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6517 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6518 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6520 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6521 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6522 inner_vlan, UINT16);
6523 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6524 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6526 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6527 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6528 tunnel_type, "vxlan#nvgre");
6530 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6531 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6532 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6533 "imac#omac-imac-tenid");
6534 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6535 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6537 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6538 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6541 cmdline_parse_inst_t cmd_tunnel_filter = {
6542 .f = cmd_tunnel_filter_parsed,
6544 .help_str = "add/rm tunnel filter of a port: "
6545 "tunnel_filter add port_id outer_mac inner_mac ip "
6546 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6547 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6548 "imac|omac-imac-tenid) "
6549 "tenant_id queue_num",
6551 (void *)&cmd_tunnel_filter_cmd,
6552 (void *)&cmd_tunnel_filter_what,
6553 (void *)&cmd_tunnel_filter_port_id,
6554 (void *)&cmd_tunnel_filter_outer_mac,
6555 (void *)&cmd_tunnel_filter_inner_mac,
6556 (void *)&cmd_tunnel_filter_ip_value,
6557 (void *)&cmd_tunnel_filter_innner_vlan,
6558 (void *)&cmd_tunnel_filter_tunnel_type,
6559 (void *)&cmd_tunnel_filter_filter_type,
6560 (void *)&cmd_tunnel_filter_tenant_id,
6561 (void *)&cmd_tunnel_filter_queue_num,
6566 /* *** CONFIGURE TUNNEL UDP PORT *** */
6567 struct cmd_tunnel_udp_config {
6568 cmdline_fixed_string_t cmd;
6569 cmdline_fixed_string_t what;
6575 cmd_tunnel_udp_config_parsed(void *parsed_result,
6576 __attribute__((unused)) struct cmdline *cl,
6577 __attribute__((unused)) void *data)
6579 struct cmd_tunnel_udp_config *res = parsed_result;
6580 struct rte_eth_udp_tunnel tunnel_udp;
6583 tunnel_udp.udp_port = res->udp_port;
6585 if (!strcmp(res->cmd, "rx_vxlan_port"))
6586 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6588 if (!strcmp(res->what, "add"))
6589 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6591 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6594 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6597 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6598 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6599 cmd, "rx_vxlan_port");
6600 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6601 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6603 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6604 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6606 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6607 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6610 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6611 .f = cmd_tunnel_udp_config_parsed,
6613 .help_str = "add/rm an tunneling UDP port filter: "
6614 "rx_vxlan_port add udp_port port_id",
6616 (void *)&cmd_tunnel_udp_config_cmd,
6617 (void *)&cmd_tunnel_udp_config_what,
6618 (void *)&cmd_tunnel_udp_config_udp_port,
6619 (void *)&cmd_tunnel_udp_config_port_id,
6624 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6625 struct cmd_set_mirror_mask_result {
6626 cmdline_fixed_string_t set;
6627 cmdline_fixed_string_t port;
6629 cmdline_fixed_string_t mirror;
6631 cmdline_fixed_string_t what;
6632 cmdline_fixed_string_t value;
6633 cmdline_fixed_string_t dstpool;
6635 cmdline_fixed_string_t on;
6638 cmdline_parse_token_string_t cmd_mirror_mask_set =
6639 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6641 cmdline_parse_token_string_t cmd_mirror_mask_port =
6642 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6644 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6645 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6647 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6648 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6649 mirror, "mirror-rule");
6650 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6651 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6653 cmdline_parse_token_string_t cmd_mirror_mask_what =
6654 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6655 what, "pool-mirror-up#pool-mirror-down"
6657 cmdline_parse_token_string_t cmd_mirror_mask_value =
6658 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6660 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6662 dstpool, "dst-pool");
6663 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6664 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6666 cmdline_parse_token_string_t cmd_mirror_mask_on =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6671 cmd_set_mirror_mask_parsed(void *parsed_result,
6672 __attribute__((unused)) struct cmdline *cl,
6673 __attribute__((unused)) void *data)
6676 struct cmd_set_mirror_mask_result *res = parsed_result;
6677 struct rte_eth_mirror_conf mr_conf;
6679 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6681 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6683 mr_conf.dst_pool = res->dstpool_id;
6685 if (!strcmp(res->what, "pool-mirror-up")) {
6686 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6687 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6688 } else if (!strcmp(res->what, "pool-mirror-down")) {
6689 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6690 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6691 } else if (!strcmp(res->what, "vlan-mirror")) {
6692 mr_conf.rule_type = ETH_MIRROR_VLAN;
6693 nb_item = parse_item_list(res->value, "vlan",
6694 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6698 for (i = 0; i < nb_item; i++) {
6699 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6700 printf("Invalid vlan_id: must be < 4096\n");
6704 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6705 mr_conf.vlan.vlan_mask |= 1ULL << i;
6709 if (!strcmp(res->on, "on"))
6710 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6713 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6716 printf("mirror rule add error: (%s)\n", strerror(-ret));
6719 cmdline_parse_inst_t cmd_set_mirror_mask = {
6720 .f = cmd_set_mirror_mask_parsed,
6722 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6723 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6725 (void *)&cmd_mirror_mask_set,
6726 (void *)&cmd_mirror_mask_port,
6727 (void *)&cmd_mirror_mask_portid,
6728 (void *)&cmd_mirror_mask_mirror,
6729 (void *)&cmd_mirror_mask_ruleid,
6730 (void *)&cmd_mirror_mask_what,
6731 (void *)&cmd_mirror_mask_value,
6732 (void *)&cmd_mirror_mask_dstpool,
6733 (void *)&cmd_mirror_mask_poolid,
6734 (void *)&cmd_mirror_mask_on,
6739 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6740 struct cmd_set_mirror_link_result {
6741 cmdline_fixed_string_t set;
6742 cmdline_fixed_string_t port;
6744 cmdline_fixed_string_t mirror;
6746 cmdline_fixed_string_t what;
6747 cmdline_fixed_string_t dstpool;
6749 cmdline_fixed_string_t on;
6752 cmdline_parse_token_string_t cmd_mirror_link_set =
6753 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6755 cmdline_parse_token_string_t cmd_mirror_link_port =
6756 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6758 cmdline_parse_token_num_t cmd_mirror_link_portid =
6759 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6761 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6762 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6763 mirror, "mirror-rule");
6764 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6765 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6767 cmdline_parse_token_string_t cmd_mirror_link_what =
6768 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6769 what, "uplink-mirror#downlink-mirror");
6770 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6771 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6772 dstpool, "dst-pool");
6773 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6774 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6776 cmdline_parse_token_string_t cmd_mirror_link_on =
6777 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6781 cmd_set_mirror_link_parsed(void *parsed_result,
6782 __attribute__((unused)) struct cmdline *cl,
6783 __attribute__((unused)) void *data)
6786 struct cmd_set_mirror_link_result *res = parsed_result;
6787 struct rte_eth_mirror_conf mr_conf;
6789 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6790 if (!strcmp(res->what, "uplink-mirror"))
6791 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
6793 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
6795 mr_conf.dst_pool = res->dstpool_id;
6797 if (!strcmp(res->on, "on"))
6798 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6801 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6804 /* check the return value and print it if is < 0 */
6806 printf("mirror rule add error: (%s)\n", strerror(-ret));
6810 cmdline_parse_inst_t cmd_set_mirror_link = {
6811 .f = cmd_set_mirror_link_parsed,
6813 .help_str = "set port X mirror-rule Y uplink-mirror|"
6814 "downlink-mirror dst-pool Z on|off",
6816 (void *)&cmd_mirror_link_set,
6817 (void *)&cmd_mirror_link_port,
6818 (void *)&cmd_mirror_link_portid,
6819 (void *)&cmd_mirror_link_mirror,
6820 (void *)&cmd_mirror_link_ruleid,
6821 (void *)&cmd_mirror_link_what,
6822 (void *)&cmd_mirror_link_dstpool,
6823 (void *)&cmd_mirror_link_poolid,
6824 (void *)&cmd_mirror_link_on,
6829 /* *** RESET VM MIRROR RULE *** */
6830 struct cmd_rm_mirror_rule_result {
6831 cmdline_fixed_string_t reset;
6832 cmdline_fixed_string_t port;
6834 cmdline_fixed_string_t mirror;
6838 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6839 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6841 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6842 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6844 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6845 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6847 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6848 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6849 mirror, "mirror-rule");
6850 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6851 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6855 cmd_reset_mirror_rule_parsed(void *parsed_result,
6856 __attribute__((unused)) struct cmdline *cl,
6857 __attribute__((unused)) void *data)
6860 struct cmd_set_mirror_link_result *res = parsed_result;
6862 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6864 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6867 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6868 .f = cmd_reset_mirror_rule_parsed,
6870 .help_str = "reset port X mirror-rule Y",
6872 (void *)&cmd_rm_mirror_rule_reset,
6873 (void *)&cmd_rm_mirror_rule_port,
6874 (void *)&cmd_rm_mirror_rule_portid,
6875 (void *)&cmd_rm_mirror_rule_mirror,
6876 (void *)&cmd_rm_mirror_rule_ruleid,
6881 /* ******************************************************************************** */
6883 struct cmd_dump_result {
6884 cmdline_fixed_string_t dump;
6888 dump_struct_sizes(void)
6890 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6891 DUMP_SIZE(struct rte_mbuf);
6892 DUMP_SIZE(struct rte_mempool);
6893 DUMP_SIZE(struct rte_ring);
6897 static void cmd_dump_parsed(void *parsed_result,
6898 __attribute__((unused)) struct cmdline *cl,
6899 __attribute__((unused)) void *data)
6901 struct cmd_dump_result *res = parsed_result;
6903 if (!strcmp(res->dump, "dump_physmem"))
6904 rte_dump_physmem_layout(stdout);
6905 else if (!strcmp(res->dump, "dump_memzone"))
6906 rte_memzone_dump(stdout);
6907 else if (!strcmp(res->dump, "dump_log_history"))
6908 rte_log_dump_history(stdout);
6909 else if (!strcmp(res->dump, "dump_struct_sizes"))
6910 dump_struct_sizes();
6911 else if (!strcmp(res->dump, "dump_ring"))
6912 rte_ring_list_dump(stdout);
6913 else if (!strcmp(res->dump, "dump_mempool"))
6914 rte_mempool_list_dump(stdout);
6915 else if (!strcmp(res->dump, "dump_devargs"))
6916 rte_eal_devargs_dump(stdout);
6919 cmdline_parse_token_string_t cmd_dump_dump =
6920 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6924 "dump_struct_sizes#"
6929 cmdline_parse_inst_t cmd_dump = {
6930 .f = cmd_dump_parsed, /* function to call */
6931 .data = NULL, /* 2nd arg of func */
6932 .help_str = "dump status",
6933 .tokens = { /* token list, NULL terminated */
6934 (void *)&cmd_dump_dump,
6939 /* ******************************************************************************** */
6941 struct cmd_dump_one_result {
6942 cmdline_fixed_string_t dump;
6943 cmdline_fixed_string_t name;
6946 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6947 __attribute__((unused)) void *data)
6949 struct cmd_dump_one_result *res = parsed_result;
6951 if (!strcmp(res->dump, "dump_ring")) {
6953 r = rte_ring_lookup(res->name);
6955 cmdline_printf(cl, "Cannot find ring\n");
6958 rte_ring_dump(stdout, r);
6959 } else if (!strcmp(res->dump, "dump_mempool")) {
6960 struct rte_mempool *mp;
6961 mp = rte_mempool_lookup(res->name);
6963 cmdline_printf(cl, "Cannot find mempool\n");
6966 rte_mempool_dump(stdout, mp);
6970 cmdline_parse_token_string_t cmd_dump_one_dump =
6971 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6972 "dump_ring#dump_mempool");
6974 cmdline_parse_token_string_t cmd_dump_one_name =
6975 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6977 cmdline_parse_inst_t cmd_dump_one = {
6978 .f = cmd_dump_one_parsed, /* function to call */
6979 .data = NULL, /* 2nd arg of func */
6980 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6981 .tokens = { /* token list, NULL terminated */
6982 (void *)&cmd_dump_one_dump,
6983 (void *)&cmd_dump_one_name,
6988 /* *** Add/Del syn filter *** */
6989 struct cmd_syn_filter_result {
6990 cmdline_fixed_string_t filter;
6992 cmdline_fixed_string_t ops;
6993 cmdline_fixed_string_t priority;
6994 cmdline_fixed_string_t high;
6995 cmdline_fixed_string_t queue;
7000 cmd_syn_filter_parsed(void *parsed_result,
7001 __attribute__((unused)) struct cmdline *cl,
7002 __attribute__((unused)) void *data)
7004 struct cmd_syn_filter_result *res = parsed_result;
7005 struct rte_eth_syn_filter syn_filter;
7008 ret = rte_eth_dev_filter_supported(res->port_id,
7009 RTE_ETH_FILTER_SYN);
7011 printf("syn filter is not supported on port %u.\n",
7016 memset(&syn_filter, 0, sizeof(syn_filter));
7018 if (!strcmp(res->ops, "add")) {
7019 if (!strcmp(res->high, "high"))
7020 syn_filter.hig_pri = 1;
7022 syn_filter.hig_pri = 0;
7024 syn_filter.queue = res->queue_id;
7025 ret = rte_eth_dev_filter_ctrl(res->port_id,
7030 ret = rte_eth_dev_filter_ctrl(res->port_id,
7032 RTE_ETH_FILTER_DELETE,
7036 printf("syn filter programming error: (%s)\n",
7040 cmdline_parse_token_string_t cmd_syn_filter_filter =
7041 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7042 filter, "syn_filter");
7043 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7044 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7046 cmdline_parse_token_string_t cmd_syn_filter_ops =
7047 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7049 cmdline_parse_token_string_t cmd_syn_filter_priority =
7050 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7051 priority, "priority");
7052 cmdline_parse_token_string_t cmd_syn_filter_high =
7053 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7055 cmdline_parse_token_string_t cmd_syn_filter_queue =
7056 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7058 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7059 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7062 cmdline_parse_inst_t cmd_syn_filter = {
7063 .f = cmd_syn_filter_parsed,
7065 .help_str = "add/delete syn filter",
7067 (void *)&cmd_syn_filter_filter,
7068 (void *)&cmd_syn_filter_port_id,
7069 (void *)&cmd_syn_filter_ops,
7070 (void *)&cmd_syn_filter_priority,
7071 (void *)&cmd_syn_filter_high,
7072 (void *)&cmd_syn_filter_queue,
7073 (void *)&cmd_syn_filter_queue_id,
7078 /* *** ADD/REMOVE A 2tuple FILTER *** */
7079 struct cmd_2tuple_filter_result {
7080 cmdline_fixed_string_t filter;
7082 cmdline_fixed_string_t ops;
7083 cmdline_fixed_string_t dst_port;
7084 uint16_t dst_port_value;
7085 cmdline_fixed_string_t protocol;
7086 uint8_t protocol_value;
7087 cmdline_fixed_string_t mask;
7089 cmdline_fixed_string_t tcp_flags;
7090 uint8_t tcp_flags_value;
7091 cmdline_fixed_string_t priority;
7092 uint8_t priority_value;
7093 cmdline_fixed_string_t queue;
7098 cmd_2tuple_filter_parsed(void *parsed_result,
7099 __attribute__((unused)) struct cmdline *cl,
7100 __attribute__((unused)) void *data)
7102 struct rte_eth_ntuple_filter filter;
7103 struct cmd_2tuple_filter_result *res = parsed_result;
7106 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7108 printf("ntuple filter is not supported on port %u.\n",
7113 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7115 filter.flags = RTE_2TUPLE_FLAGS;
7116 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7117 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7118 filter.proto = res->protocol_value;
7119 filter.priority = res->priority_value;
7120 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7121 printf("nonzero tcp_flags is only meaningful"
7122 " when protocol is TCP.\n");
7125 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7126 printf("invalid TCP flags.\n");
7130 if (res->tcp_flags_value != 0) {
7131 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7132 filter.tcp_flags = res->tcp_flags_value;
7135 /* need convert to big endian. */
7136 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7137 filter.queue = res->queue_id;
7139 if (!strcmp(res->ops, "add"))
7140 ret = rte_eth_dev_filter_ctrl(res->port_id,
7141 RTE_ETH_FILTER_NTUPLE,
7145 ret = rte_eth_dev_filter_ctrl(res->port_id,
7146 RTE_ETH_FILTER_NTUPLE,
7147 RTE_ETH_FILTER_DELETE,
7150 printf("2tuple filter programming error: (%s)\n",
7155 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7156 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7157 filter, "2tuple_filter");
7158 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7159 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7161 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7162 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7164 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7165 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7166 dst_port, "dst_port");
7167 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7168 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7169 dst_port_value, UINT16);
7170 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7171 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7172 protocol, "protocol");
7173 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7174 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7175 protocol_value, UINT8);
7176 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7177 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7179 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7180 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7182 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7183 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7184 tcp_flags, "tcp_flags");
7185 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7186 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7187 tcp_flags_value, UINT8);
7188 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7189 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7190 priority, "priority");
7191 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7192 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7193 priority_value, UINT8);
7194 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7195 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7197 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7198 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7201 cmdline_parse_inst_t cmd_2tuple_filter = {
7202 .f = cmd_2tuple_filter_parsed,
7204 .help_str = "add a 2tuple filter",
7206 (void *)&cmd_2tuple_filter_filter,
7207 (void *)&cmd_2tuple_filter_port_id,
7208 (void *)&cmd_2tuple_filter_ops,
7209 (void *)&cmd_2tuple_filter_dst_port,
7210 (void *)&cmd_2tuple_filter_dst_port_value,
7211 (void *)&cmd_2tuple_filter_protocol,
7212 (void *)&cmd_2tuple_filter_protocol_value,
7213 (void *)&cmd_2tuple_filter_mask,
7214 (void *)&cmd_2tuple_filter_mask_value,
7215 (void *)&cmd_2tuple_filter_tcp_flags,
7216 (void *)&cmd_2tuple_filter_tcp_flags_value,
7217 (void *)&cmd_2tuple_filter_priority,
7218 (void *)&cmd_2tuple_filter_priority_value,
7219 (void *)&cmd_2tuple_filter_queue,
7220 (void *)&cmd_2tuple_filter_queue_id,
7225 /* *** ADD/REMOVE A 5tuple FILTER *** */
7226 struct cmd_5tuple_filter_result {
7227 cmdline_fixed_string_t filter;
7229 cmdline_fixed_string_t ops;
7230 cmdline_fixed_string_t dst_ip;
7231 cmdline_ipaddr_t dst_ip_value;
7232 cmdline_fixed_string_t src_ip;
7233 cmdline_ipaddr_t src_ip_value;
7234 cmdline_fixed_string_t dst_port;
7235 uint16_t dst_port_value;
7236 cmdline_fixed_string_t src_port;
7237 uint16_t src_port_value;
7238 cmdline_fixed_string_t protocol;
7239 uint8_t protocol_value;
7240 cmdline_fixed_string_t mask;
7242 cmdline_fixed_string_t tcp_flags;
7243 uint8_t tcp_flags_value;
7244 cmdline_fixed_string_t priority;
7245 uint8_t priority_value;
7246 cmdline_fixed_string_t queue;
7251 cmd_5tuple_filter_parsed(void *parsed_result,
7252 __attribute__((unused)) struct cmdline *cl,
7253 __attribute__((unused)) void *data)
7255 struct rte_eth_ntuple_filter filter;
7256 struct cmd_5tuple_filter_result *res = parsed_result;
7259 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7261 printf("ntuple filter is not supported on port %u.\n",
7266 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7268 filter.flags = RTE_5TUPLE_FLAGS;
7269 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7270 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7271 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7272 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7273 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7274 filter.proto = res->protocol_value;
7275 filter.priority = res->priority_value;
7276 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7277 printf("nonzero tcp_flags is only meaningful"
7278 " when protocol is TCP.\n");
7281 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7282 printf("invalid TCP flags.\n");
7286 if (res->tcp_flags_value != 0) {
7287 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7288 filter.tcp_flags = res->tcp_flags_value;
7291 if (res->dst_ip_value.family == AF_INET)
7292 /* no need to convert, already big endian. */
7293 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7295 if (filter.dst_ip_mask == 0) {
7296 printf("can not support ipv6 involved compare.\n");
7302 if (res->src_ip_value.family == AF_INET)
7303 /* no need to convert, already big endian. */
7304 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7306 if (filter.src_ip_mask == 0) {
7307 printf("can not support ipv6 involved compare.\n");
7312 /* need convert to big endian. */
7313 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7314 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7315 filter.queue = res->queue_id;
7317 if (!strcmp(res->ops, "add"))
7318 ret = rte_eth_dev_filter_ctrl(res->port_id,
7319 RTE_ETH_FILTER_NTUPLE,
7323 ret = rte_eth_dev_filter_ctrl(res->port_id,
7324 RTE_ETH_FILTER_NTUPLE,
7325 RTE_ETH_FILTER_DELETE,
7328 printf("5tuple filter programming error: (%s)\n",
7332 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7333 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7334 filter, "5tuple_filter");
7335 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7336 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7338 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7339 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7341 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7342 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7344 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7345 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7347 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7348 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7350 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7351 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7353 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7354 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7355 dst_port, "dst_port");
7356 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7357 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7358 dst_port_value, UINT16);
7359 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7360 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7361 src_port, "src_port");
7362 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7363 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7364 src_port_value, UINT16);
7365 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7366 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7367 protocol, "protocol");
7368 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7369 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7370 protocol_value, UINT8);
7371 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7372 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7374 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7375 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7377 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7378 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7379 tcp_flags, "tcp_flags");
7380 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7381 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7382 tcp_flags_value, UINT8);
7383 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7384 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7385 priority, "priority");
7386 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7387 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7388 priority_value, UINT8);
7389 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7390 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7392 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7393 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7396 cmdline_parse_inst_t cmd_5tuple_filter = {
7397 .f = cmd_5tuple_filter_parsed,
7399 .help_str = "add/del a 5tuple filter",
7401 (void *)&cmd_5tuple_filter_filter,
7402 (void *)&cmd_5tuple_filter_port_id,
7403 (void *)&cmd_5tuple_filter_ops,
7404 (void *)&cmd_5tuple_filter_dst_ip,
7405 (void *)&cmd_5tuple_filter_dst_ip_value,
7406 (void *)&cmd_5tuple_filter_src_ip,
7407 (void *)&cmd_5tuple_filter_src_ip_value,
7408 (void *)&cmd_5tuple_filter_dst_port,
7409 (void *)&cmd_5tuple_filter_dst_port_value,
7410 (void *)&cmd_5tuple_filter_src_port,
7411 (void *)&cmd_5tuple_filter_src_port_value,
7412 (void *)&cmd_5tuple_filter_protocol,
7413 (void *)&cmd_5tuple_filter_protocol_value,
7414 (void *)&cmd_5tuple_filter_mask,
7415 (void *)&cmd_5tuple_filter_mask_value,
7416 (void *)&cmd_5tuple_filter_tcp_flags,
7417 (void *)&cmd_5tuple_filter_tcp_flags_value,
7418 (void *)&cmd_5tuple_filter_priority,
7419 (void *)&cmd_5tuple_filter_priority_value,
7420 (void *)&cmd_5tuple_filter_queue,
7421 (void *)&cmd_5tuple_filter_queue_id,
7426 /* *** ADD/REMOVE A flex FILTER *** */
7427 struct cmd_flex_filter_result {
7428 cmdline_fixed_string_t filter;
7429 cmdline_fixed_string_t ops;
7431 cmdline_fixed_string_t len;
7433 cmdline_fixed_string_t bytes;
7434 cmdline_fixed_string_t bytes_value;
7435 cmdline_fixed_string_t mask;
7436 cmdline_fixed_string_t mask_value;
7437 cmdline_fixed_string_t priority;
7438 uint8_t priority_value;
7439 cmdline_fixed_string_t queue;
7443 static int xdigit2val(unsigned char c)
7448 else if (isupper(c))
7456 cmd_flex_filter_parsed(void *parsed_result,
7457 __attribute__((unused)) struct cmdline *cl,
7458 __attribute__((unused)) void *data)
7461 struct rte_eth_flex_filter filter;
7462 struct cmd_flex_filter_result *res = parsed_result;
7463 char *bytes_ptr, *mask_ptr;
7464 uint16_t len, i, j = 0;
7469 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7470 printf("the len exceed the max length 128\n");
7473 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7474 filter.len = res->len_value;
7475 filter.priority = res->priority_value;
7476 filter.queue = res->queue_id;
7477 bytes_ptr = res->bytes_value;
7478 mask_ptr = res->mask_value;
7480 /* translate bytes string to array. */
7481 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7482 (bytes_ptr[1] == 'X')))
7484 len = strnlen(bytes_ptr, res->len_value * 2);
7485 if (len == 0 || (len % 8 != 0)) {
7486 printf("please check len and bytes input\n");
7489 for (i = 0; i < len; i++) {
7491 if (isxdigit(c) == 0) {
7492 /* invalid characters. */
7493 printf("invalid input\n");
7496 val = xdigit2val(c);
7499 filter.bytes[j] = byte;
7500 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7507 /* translate mask string to uint8_t array. */
7508 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7509 (mask_ptr[1] == 'X')))
7511 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7513 printf("invalid input\n");
7518 for (i = 0; i < len; i++) {
7520 if (isxdigit(c) == 0) {
7521 /* invalid characters. */
7522 printf("invalid input\n");
7525 val = xdigit2val(c);
7528 filter.mask[j] = byte;
7529 printf("mask[%d]:%02x ", j, filter.mask[j]);
7537 if (!strcmp(res->ops, "add"))
7538 ret = rte_eth_dev_filter_ctrl(res->port_id,
7539 RTE_ETH_FILTER_FLEXIBLE,
7543 ret = rte_eth_dev_filter_ctrl(res->port_id,
7544 RTE_ETH_FILTER_FLEXIBLE,
7545 RTE_ETH_FILTER_DELETE,
7549 printf("flex filter setting error: (%s)\n", strerror(-ret));
7552 cmdline_parse_token_string_t cmd_flex_filter_filter =
7553 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7554 filter, "flex_filter");
7555 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7556 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7558 cmdline_parse_token_string_t cmd_flex_filter_ops =
7559 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7561 cmdline_parse_token_string_t cmd_flex_filter_len =
7562 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7564 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7565 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7567 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7568 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7570 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7571 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7573 cmdline_parse_token_string_t cmd_flex_filter_mask =
7574 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7576 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7577 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7579 cmdline_parse_token_string_t cmd_flex_filter_priority =
7580 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7581 priority, "priority");
7582 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7583 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7584 priority_value, UINT8);
7585 cmdline_parse_token_string_t cmd_flex_filter_queue =
7586 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7588 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7589 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7591 cmdline_parse_inst_t cmd_flex_filter = {
7592 .f = cmd_flex_filter_parsed,
7594 .help_str = "add/del a flex filter",
7596 (void *)&cmd_flex_filter_filter,
7597 (void *)&cmd_flex_filter_port_id,
7598 (void *)&cmd_flex_filter_ops,
7599 (void *)&cmd_flex_filter_len,
7600 (void *)&cmd_flex_filter_len_value,
7601 (void *)&cmd_flex_filter_bytes,
7602 (void *)&cmd_flex_filter_bytes_value,
7603 (void *)&cmd_flex_filter_mask,
7604 (void *)&cmd_flex_filter_mask_value,
7605 (void *)&cmd_flex_filter_priority,
7606 (void *)&cmd_flex_filter_priority_value,
7607 (void *)&cmd_flex_filter_queue,
7608 (void *)&cmd_flex_filter_queue_id,
7613 /* *** Filters Control *** */
7615 /* *** deal with ethertype filter *** */
7616 struct cmd_ethertype_filter_result {
7617 cmdline_fixed_string_t filter;
7619 cmdline_fixed_string_t ops;
7620 cmdline_fixed_string_t mac;
7621 struct ether_addr mac_addr;
7622 cmdline_fixed_string_t ethertype;
7623 uint16_t ethertype_value;
7624 cmdline_fixed_string_t drop;
7625 cmdline_fixed_string_t queue;
7629 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7630 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7631 filter, "ethertype_filter");
7632 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7633 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7635 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7636 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7638 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7639 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7640 mac, "mac_addr#mac_ignr");
7641 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7642 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7644 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7645 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7646 ethertype, "ethertype");
7647 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7648 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7649 ethertype_value, UINT16);
7650 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7651 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7653 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7654 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7656 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7657 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7661 cmd_ethertype_filter_parsed(void *parsed_result,
7662 __attribute__((unused)) struct cmdline *cl,
7663 __attribute__((unused)) void *data)
7665 struct cmd_ethertype_filter_result *res = parsed_result;
7666 struct rte_eth_ethertype_filter filter;
7669 ret = rte_eth_dev_filter_supported(res->port_id,
7670 RTE_ETH_FILTER_ETHERTYPE);
7672 printf("ethertype filter is not supported on port %u.\n",
7677 memset(&filter, 0, sizeof(filter));
7678 if (!strcmp(res->mac, "mac_addr")) {
7679 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7680 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7681 sizeof(struct ether_addr));
7683 if (!strcmp(res->drop, "drop"))
7684 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7685 filter.ether_type = res->ethertype_value;
7686 filter.queue = res->queue_id;
7688 if (!strcmp(res->ops, "add"))
7689 ret = rte_eth_dev_filter_ctrl(res->port_id,
7690 RTE_ETH_FILTER_ETHERTYPE,
7694 ret = rte_eth_dev_filter_ctrl(res->port_id,
7695 RTE_ETH_FILTER_ETHERTYPE,
7696 RTE_ETH_FILTER_DELETE,
7699 printf("ethertype filter programming error: (%s)\n",
7703 cmdline_parse_inst_t cmd_ethertype_filter = {
7704 .f = cmd_ethertype_filter_parsed,
7706 .help_str = "add or delete an ethertype filter entry",
7708 (void *)&cmd_ethertype_filter_filter,
7709 (void *)&cmd_ethertype_filter_port_id,
7710 (void *)&cmd_ethertype_filter_ops,
7711 (void *)&cmd_ethertype_filter_mac,
7712 (void *)&cmd_ethertype_filter_mac_addr,
7713 (void *)&cmd_ethertype_filter_ethertype,
7714 (void *)&cmd_ethertype_filter_ethertype_value,
7715 (void *)&cmd_ethertype_filter_drop,
7716 (void *)&cmd_ethertype_filter_queue,
7717 (void *)&cmd_ethertype_filter_queue_id,
7722 /* *** deal with flow director filter *** */
7723 struct cmd_flow_director_result {
7724 cmdline_fixed_string_t flow_director_filter;
7726 cmdline_fixed_string_t ops;
7727 cmdline_fixed_string_t flow;
7728 cmdline_fixed_string_t flow_type;
7729 cmdline_fixed_string_t ether;
7730 uint16_t ether_type;
7731 cmdline_fixed_string_t src;
7732 cmdline_ipaddr_t ip_src;
7734 cmdline_fixed_string_t dst;
7735 cmdline_ipaddr_t ip_dst;
7737 cmdline_fixed_string_t verify_tag;
7738 uint32_t verify_tag_value;
7739 cmdline_fixed_string_t vlan;
7740 uint16_t vlan_value;
7741 cmdline_fixed_string_t flexbytes;
7742 cmdline_fixed_string_t flexbytes_value;
7743 cmdline_fixed_string_t drop;
7744 cmdline_fixed_string_t queue;
7746 cmdline_fixed_string_t fd_id;
7747 uint32_t fd_id_value;
7751 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7754 const char *p, *p0 = q_arg;
7756 unsigned long int_fld;
7757 char *str_fld[max_num];
7762 p = strchr(p0, '(');
7766 p0 = strchr(p, ')');
7771 if (size >= sizeof(s))
7774 snprintf(s, sizeof(s), "%.*s", size, p);
7775 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7776 if (ret < 0 || ret > max_num)
7778 for (i = 0; i < ret; i++) {
7780 int_fld = strtoul(str_fld[i], &end, 0);
7781 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7783 flexbytes[i] = (uint8_t)int_fld;
7789 str2flowtype(char *string)
7792 static const struct {
7795 } flowtype_str[] = {
7796 {"raw", RTE_ETH_FLOW_RAW},
7797 {"ipv4", RTE_ETH_FLOW_IPV4},
7798 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7799 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7800 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7801 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7802 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7803 {"ipv6", RTE_ETH_FLOW_IPV6},
7804 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7805 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7806 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7807 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7808 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7809 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7812 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7813 if (!strcmp(flowtype_str[i].str, string))
7814 return flowtype_str[i].type;
7816 return RTE_ETH_FLOW_UNKNOWN;
7819 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7821 if ((ip_addr).family == AF_INET) \
7822 (ip) = (ip_addr).addr.ipv4.s_addr; \
7824 printf("invalid parameter.\n"); \
7829 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7831 if ((ip_addr).family == AF_INET6) \
7832 (void)rte_memcpy(&(ip), \
7833 &((ip_addr).addr.ipv6), \
7834 sizeof(struct in6_addr)); \
7836 printf("invalid parameter.\n"); \
7842 cmd_flow_director_filter_parsed(void *parsed_result,
7843 __attribute__((unused)) struct cmdline *cl,
7844 __attribute__((unused)) void *data)
7846 struct cmd_flow_director_result *res = parsed_result;
7847 struct rte_eth_fdir_filter entry;
7848 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7851 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7853 printf("flow director is not supported on port %u.\n",
7857 memset(flexbytes, 0, sizeof(flexbytes));
7858 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7859 ret = parse_flexbytes(res->flexbytes_value,
7861 RTE_ETH_FDIR_MAX_FLEXLEN);
7863 printf("error: Cannot parse flexbytes input.\n");
7867 entry.input.flow_type = str2flowtype(res->flow_type);
7868 switch (entry.input.flow_type) {
7869 case RTE_ETH_FLOW_FRAG_IPV4:
7870 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
7871 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
7872 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
7873 IPV4_ADDR_TO_UINT(res->ip_dst,
7874 entry.input.flow.ip4_flow.dst_ip);
7875 IPV4_ADDR_TO_UINT(res->ip_src,
7876 entry.input.flow.ip4_flow.src_ip);
7877 /* need convert to big endian. */
7878 entry.input.flow.udp4_flow.dst_port =
7879 rte_cpu_to_be_16(res->port_dst);
7880 entry.input.flow.udp4_flow.src_port =
7881 rte_cpu_to_be_16(res->port_src);
7883 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
7884 IPV4_ADDR_TO_UINT(res->ip_dst,
7885 entry.input.flow.sctp4_flow.ip.dst_ip);
7886 IPV4_ADDR_TO_UINT(res->ip_src,
7887 entry.input.flow.sctp4_flow.ip.src_ip);
7888 /* need convert to big endian. */
7890 entry.input.flow.sctp4_flow.dst_port =
7891 rte_cpu_to_be_16(res->port_dst);
7892 entry.input.flow.sctp4_flow.src_port =
7893 rte_cpu_to_be_16(res->port_src);
7895 entry.input.flow.sctp4_flow.verify_tag =
7896 rte_cpu_to_be_32(res->verify_tag_value);
7898 case RTE_ETH_FLOW_FRAG_IPV6:
7899 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
7900 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
7901 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
7902 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7903 entry.input.flow.ipv6_flow.dst_ip);
7904 IPV6_ADDR_TO_ARRAY(res->ip_src,
7905 entry.input.flow.ipv6_flow.src_ip);
7906 /* need convert to big endian. */
7907 entry.input.flow.udp6_flow.dst_port =
7908 rte_cpu_to_be_16(res->port_dst);
7909 entry.input.flow.udp6_flow.src_port =
7910 rte_cpu_to_be_16(res->port_src);
7912 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
7913 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7914 entry.input.flow.sctp6_flow.ip.dst_ip);
7915 IPV6_ADDR_TO_ARRAY(res->ip_src,
7916 entry.input.flow.sctp6_flow.ip.src_ip);
7917 /* need convert to big endian. */
7919 entry.input.flow.sctp6_flow.dst_port =
7920 rte_cpu_to_be_16(res->port_dst);
7921 entry.input.flow.sctp6_flow.src_port =
7922 rte_cpu_to_be_16(res->port_src);
7924 entry.input.flow.sctp6_flow.verify_tag =
7925 rte_cpu_to_be_32(res->verify_tag_value);
7927 case RTE_ETH_FLOW_L2_PAYLOAD:
7928 entry.input.flow.l2_flow.ether_type =
7929 rte_cpu_to_be_16(res->ether_type);
7932 printf("invalid parameter.\n");
7935 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7937 RTE_ETH_FDIR_MAX_FLEXLEN);
7939 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7941 entry.action.flex_off = 0; /*use 0 by default */
7942 if (!strcmp(res->drop, "drop"))
7943 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7945 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7946 /* set to report FD ID by default */
7947 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7948 entry.action.rx_queue = res->queue_id;
7949 entry.soft_id = res->fd_id_value;
7950 if (!strcmp(res->ops, "add"))
7951 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7952 RTE_ETH_FILTER_ADD, &entry);
7953 else if (!strcmp(res->ops, "del"))
7954 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7955 RTE_ETH_FILTER_DELETE, &entry);
7957 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7958 RTE_ETH_FILTER_UPDATE, &entry);
7960 printf("flow director programming error: (%s)\n",
7964 cmdline_parse_token_string_t cmd_flow_director_filter =
7965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7966 flow_director_filter, "flow_director_filter");
7967 cmdline_parse_token_num_t cmd_flow_director_port_id =
7968 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7970 cmdline_parse_token_string_t cmd_flow_director_ops =
7971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7972 ops, "add#del#update");
7973 cmdline_parse_token_string_t cmd_flow_director_flow =
7974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7976 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7978 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
7979 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
7980 cmdline_parse_token_string_t cmd_flow_director_ether =
7981 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7983 cmdline_parse_token_num_t cmd_flow_director_ether_type =
7984 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7985 ether_type, UINT16);
7986 cmdline_parse_token_string_t cmd_flow_director_src =
7987 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7989 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7990 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7992 cmdline_parse_token_num_t cmd_flow_director_port_src =
7993 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7995 cmdline_parse_token_string_t cmd_flow_director_dst =
7996 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7998 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
7999 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8001 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8002 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8004 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8005 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8006 verify_tag, "verify_tag");
8007 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8008 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8009 verify_tag_value, UINT32);
8010 cmdline_parse_token_string_t cmd_flow_director_vlan =
8011 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8013 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8014 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8015 vlan_value, UINT16);
8016 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8017 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8018 flexbytes, "flexbytes");
8019 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8020 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8021 flexbytes_value, NULL);
8022 cmdline_parse_token_string_t cmd_flow_director_drop =
8023 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8025 cmdline_parse_token_string_t cmd_flow_director_queue =
8026 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8028 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8029 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8031 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8032 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8034 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8035 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8036 fd_id_value, UINT32);
8038 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8039 .f = cmd_flow_director_filter_parsed,
8041 .help_str = "add or delete an ip flow director entry on NIC",
8043 (void *)&cmd_flow_director_filter,
8044 (void *)&cmd_flow_director_port_id,
8045 (void *)&cmd_flow_director_ops,
8046 (void *)&cmd_flow_director_flow,
8047 (void *)&cmd_flow_director_flow_type,
8048 (void *)&cmd_flow_director_src,
8049 (void *)&cmd_flow_director_ip_src,
8050 (void *)&cmd_flow_director_dst,
8051 (void *)&cmd_flow_director_ip_dst,
8052 (void *)&cmd_flow_director_vlan,
8053 (void *)&cmd_flow_director_vlan_value,
8054 (void *)&cmd_flow_director_flexbytes,
8055 (void *)&cmd_flow_director_flexbytes_value,
8056 (void *)&cmd_flow_director_drop,
8057 (void *)&cmd_flow_director_queue,
8058 (void *)&cmd_flow_director_queue_id,
8059 (void *)&cmd_flow_director_fd_id,
8060 (void *)&cmd_flow_director_fd_id_value,
8065 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8066 .f = cmd_flow_director_filter_parsed,
8068 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8070 (void *)&cmd_flow_director_filter,
8071 (void *)&cmd_flow_director_port_id,
8072 (void *)&cmd_flow_director_ops,
8073 (void *)&cmd_flow_director_flow,
8074 (void *)&cmd_flow_director_flow_type,
8075 (void *)&cmd_flow_director_src,
8076 (void *)&cmd_flow_director_ip_src,
8077 (void *)&cmd_flow_director_port_src,
8078 (void *)&cmd_flow_director_dst,
8079 (void *)&cmd_flow_director_ip_dst,
8080 (void *)&cmd_flow_director_port_dst,
8081 (void *)&cmd_flow_director_vlan,
8082 (void *)&cmd_flow_director_vlan_value,
8083 (void *)&cmd_flow_director_flexbytes,
8084 (void *)&cmd_flow_director_flexbytes_value,
8085 (void *)&cmd_flow_director_drop,
8086 (void *)&cmd_flow_director_queue,
8087 (void *)&cmd_flow_director_queue_id,
8088 (void *)&cmd_flow_director_fd_id,
8089 (void *)&cmd_flow_director_fd_id_value,
8094 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8095 .f = cmd_flow_director_filter_parsed,
8097 .help_str = "add or delete a sctp flow director entry on NIC",
8099 (void *)&cmd_flow_director_filter,
8100 (void *)&cmd_flow_director_port_id,
8101 (void *)&cmd_flow_director_ops,
8102 (void *)&cmd_flow_director_flow,
8103 (void *)&cmd_flow_director_flow_type,
8104 (void *)&cmd_flow_director_src,
8105 (void *)&cmd_flow_director_ip_src,
8106 (void *)&cmd_flow_director_port_dst,
8107 (void *)&cmd_flow_director_dst,
8108 (void *)&cmd_flow_director_ip_dst,
8109 (void *)&cmd_flow_director_port_dst,
8110 (void *)&cmd_flow_director_verify_tag,
8111 (void *)&cmd_flow_director_verify_tag_value,
8112 (void *)&cmd_flow_director_vlan,
8113 (void *)&cmd_flow_director_vlan_value,
8114 (void *)&cmd_flow_director_flexbytes,
8115 (void *)&cmd_flow_director_flexbytes_value,
8116 (void *)&cmd_flow_director_drop,
8117 (void *)&cmd_flow_director_queue,
8118 (void *)&cmd_flow_director_queue_id,
8119 (void *)&cmd_flow_director_fd_id,
8120 (void *)&cmd_flow_director_fd_id_value,
8125 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8126 .f = cmd_flow_director_filter_parsed,
8128 .help_str = "add or delete a L2 flow director entry on NIC",
8130 (void *)&cmd_flow_director_filter,
8131 (void *)&cmd_flow_director_port_id,
8132 (void *)&cmd_flow_director_ops,
8133 (void *)&cmd_flow_director_flow,
8134 (void *)&cmd_flow_director_flow_type,
8135 (void *)&cmd_flow_director_ether,
8136 (void *)&cmd_flow_director_ether_type,
8137 (void *)&cmd_flow_director_flexbytes,
8138 (void *)&cmd_flow_director_flexbytes_value,
8139 (void *)&cmd_flow_director_drop,
8140 (void *)&cmd_flow_director_queue,
8141 (void *)&cmd_flow_director_queue_id,
8142 (void *)&cmd_flow_director_fd_id,
8143 (void *)&cmd_flow_director_fd_id_value,
8148 struct cmd_flush_flow_director_result {
8149 cmdline_fixed_string_t flush_flow_director;
8153 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8154 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8155 flush_flow_director, "flush_flow_director");
8156 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8157 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8161 cmd_flush_flow_director_parsed(void *parsed_result,
8162 __attribute__((unused)) struct cmdline *cl,
8163 __attribute__((unused)) void *data)
8165 struct cmd_flow_director_result *res = parsed_result;
8168 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8170 printf("flow director is not supported on port %u.\n",
8175 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8176 RTE_ETH_FILTER_FLUSH, NULL);
8178 printf("flow director table flushing error: (%s)\n",
8182 cmdline_parse_inst_t cmd_flush_flow_director = {
8183 .f = cmd_flush_flow_director_parsed,
8185 .help_str = "flush all flow director entries of a device on NIC",
8187 (void *)&cmd_flush_flow_director_flush,
8188 (void *)&cmd_flush_flow_director_port_id,
8193 /* *** deal with flow director mask *** */
8194 struct cmd_flow_director_mask_result {
8195 cmdline_fixed_string_t flow_director_mask;
8197 cmdline_fixed_string_t vlan;
8198 uint16_t vlan_value;
8199 cmdline_fixed_string_t src_mask;
8200 cmdline_ipaddr_t ipv4_src;
8201 cmdline_ipaddr_t ipv6_src;
8203 cmdline_fixed_string_t dst_mask;
8204 cmdline_ipaddr_t ipv4_dst;
8205 cmdline_ipaddr_t ipv6_dst;
8210 cmd_flow_director_mask_parsed(void *parsed_result,
8211 __attribute__((unused)) struct cmdline *cl,
8212 __attribute__((unused)) void *data)
8214 struct cmd_flow_director_mask_result *res = parsed_result;
8215 struct rte_eth_fdir_masks *mask;
8216 struct rte_port *port;
8218 if (res->port_id > nb_ports) {
8219 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8223 port = &ports[res->port_id];
8224 /** Check if the port is not started **/
8225 if (port->port_status != RTE_PORT_STOPPED) {
8226 printf("Please stop port %d first\n", res->port_id);
8229 mask = &port->dev_conf.fdir_conf.mask;
8231 mask->vlan_tci_mask = res->vlan_value;
8232 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8233 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8234 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8235 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8236 mask->src_port_mask = res->port_src;
8237 mask->dst_port_mask = res->port_dst;
8239 cmd_reconfig_device_queue(res->port_id, 1, 1);
8242 cmdline_parse_token_string_t cmd_flow_director_mask =
8243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8244 flow_director_mask, "flow_director_mask");
8245 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8246 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8248 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8251 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8252 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8253 vlan_value, UINT16);
8254 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8256 src_mask, "src_mask");
8257 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8258 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8260 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8261 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8263 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8264 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8266 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8268 dst_mask, "dst_mask");
8269 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8270 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8272 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8273 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8275 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8276 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8278 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8279 .f = cmd_flow_director_mask_parsed,
8281 .help_str = "set flow director's mask on NIC",
8283 (void *)&cmd_flow_director_mask,
8284 (void *)&cmd_flow_director_mask_port_id,
8285 (void *)&cmd_flow_director_mask_vlan,
8286 (void *)&cmd_flow_director_mask_vlan_value,
8287 (void *)&cmd_flow_director_mask_src,
8288 (void *)&cmd_flow_director_mask_ipv4_src,
8289 (void *)&cmd_flow_director_mask_ipv6_src,
8290 (void *)&cmd_flow_director_mask_port_src,
8291 (void *)&cmd_flow_director_mask_dst,
8292 (void *)&cmd_flow_director_mask_ipv4_dst,
8293 (void *)&cmd_flow_director_mask_ipv6_dst,
8294 (void *)&cmd_flow_director_mask_port_dst,
8299 /* *** deal with flow director mask on flexible payload *** */
8300 struct cmd_flow_director_flex_mask_result {
8301 cmdline_fixed_string_t flow_director_flexmask;
8303 cmdline_fixed_string_t flow;
8304 cmdline_fixed_string_t flow_type;
8305 cmdline_fixed_string_t mask;
8309 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8310 __attribute__((unused)) struct cmdline *cl,
8311 __attribute__((unused)) void *data)
8313 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8314 struct rte_eth_fdir_info fdir_info;
8315 struct rte_eth_fdir_flex_mask flex_mask;
8316 struct rte_port *port;
8317 uint32_t flow_type_mask;
8321 if (res->port_id > nb_ports) {
8322 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8326 port = &ports[res->port_id];
8327 /** Check if the port is not started **/
8328 if (port->port_status != RTE_PORT_STOPPED) {
8329 printf("Please stop port %d first\n", res->port_id);
8333 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8334 ret = parse_flexbytes(res->mask,
8336 RTE_ETH_FDIR_MAX_FLEXLEN);
8338 printf("error: Cannot parse mask input.\n");
8342 memset(&fdir_info, 0, sizeof(fdir_info));
8343 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8344 RTE_ETH_FILTER_INFO, &fdir_info);
8346 printf("Cannot get FDir filter info\n");
8350 if (!strcmp(res->flow_type, "none")) {
8351 /* means don't specify the flow type */
8352 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8353 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8354 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8355 0, sizeof(struct rte_eth_fdir_flex_mask));
8356 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8357 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8359 sizeof(struct rte_eth_fdir_flex_mask));
8360 cmd_reconfig_device_queue(res->port_id, 1, 1);
8363 flow_type_mask = fdir_info.flow_types_mask[0];
8364 if (!strcmp(res->flow_type, "all")) {
8365 if (!flow_type_mask) {
8366 printf("No flow type supported\n");
8369 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8370 if (flow_type_mask & (1 << i)) {
8371 flex_mask.flow_type = i;
8372 fdir_set_flex_mask(res->port_id, &flex_mask);
8375 cmd_reconfig_device_queue(res->port_id, 1, 1);
8378 flex_mask.flow_type = str2flowtype(res->flow_type);
8379 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8380 printf("Flow type %s not supported on port %d\n",
8381 res->flow_type, res->port_id);
8384 fdir_set_flex_mask(res->port_id, &flex_mask);
8385 cmd_reconfig_device_queue(res->port_id, 1, 1);
8388 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8389 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8390 flow_director_flexmask,
8391 "flow_director_flex_mask");
8392 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8393 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8395 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8398 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8400 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8401 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8402 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8403 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8406 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8407 .f = cmd_flow_director_flex_mask_parsed,
8409 .help_str = "set flow director's flex mask on NIC",
8411 (void *)&cmd_flow_director_flexmask,
8412 (void *)&cmd_flow_director_flexmask_port_id,
8413 (void *)&cmd_flow_director_flexmask_flow,
8414 (void *)&cmd_flow_director_flexmask_flow_type,
8415 (void *)&cmd_flow_director_flexmask_mask,
8420 /* *** deal with flow director flexible payload configuration *** */
8421 struct cmd_flow_director_flexpayload_result {
8422 cmdline_fixed_string_t flow_director_flexpayload;
8424 cmdline_fixed_string_t payload_layer;
8425 cmdline_fixed_string_t payload_cfg;
8429 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8432 const char *p, *p0 = q_arg;
8434 unsigned long int_fld;
8435 char *str_fld[max_num];
8440 p = strchr(p0, '(');
8444 p0 = strchr(p, ')');
8449 if (size >= sizeof(s))
8452 snprintf(s, sizeof(s), "%.*s", size, p);
8453 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8454 if (ret < 0 || ret > max_num)
8456 for (i = 0; i < ret; i++) {
8458 int_fld = strtoul(str_fld[i], &end, 0);
8459 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8461 offsets[i] = (uint16_t)int_fld;
8467 cmd_flow_director_flxpld_parsed(void *parsed_result,
8468 __attribute__((unused)) struct cmdline *cl,
8469 __attribute__((unused)) void *data)
8471 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8472 struct rte_eth_flex_payload_cfg flex_cfg;
8473 struct rte_port *port;
8476 if (res->port_id > nb_ports) {
8477 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8481 port = &ports[res->port_id];
8482 /** Check if the port is not started **/
8483 if (port->port_status != RTE_PORT_STOPPED) {
8484 printf("Please stop port %d first\n", res->port_id);
8488 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8490 if (!strcmp(res->payload_layer, "raw"))
8491 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8492 else if (!strcmp(res->payload_layer, "l2"))
8493 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8494 else if (!strcmp(res->payload_layer, "l3"))
8495 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8496 else if (!strcmp(res->payload_layer, "l4"))
8497 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8499 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8500 RTE_ETH_FDIR_MAX_FLEXLEN);
8502 printf("error: Cannot parse flex payload input.\n");
8506 fdir_set_flex_payload(res->port_id, &flex_cfg);
8507 cmd_reconfig_device_queue(res->port_id, 1, 1);
8510 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8511 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8512 flow_director_flexpayload,
8513 "flow_director_flex_payload");
8514 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8515 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8517 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8519 payload_layer, "raw#l2#l3#l4");
8520 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8524 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8525 .f = cmd_flow_director_flxpld_parsed,
8527 .help_str = "set flow director's flex payload on NIC",
8529 (void *)&cmd_flow_director_flexpayload,
8530 (void *)&cmd_flow_director_flexpayload_port_id,
8531 (void *)&cmd_flow_director_flexpayload_payload_layer,
8532 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8537 /* *** Classification Filters Control *** */
8538 /* *** Get symmetric hash enable per port *** */
8539 struct cmd_get_sym_hash_ena_per_port_result {
8540 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8545 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8546 __rte_unused struct cmdline *cl,
8547 __rte_unused void *data)
8549 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8550 struct rte_eth_hash_filter_info info;
8553 if (rte_eth_dev_filter_supported(res->port_id,
8554 RTE_ETH_FILTER_HASH) < 0) {
8555 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8560 memset(&info, 0, sizeof(info));
8561 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8562 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8563 RTE_ETH_FILTER_GET, &info);
8566 printf("Cannot get symmetric hash enable per port "
8567 "on port %u\n", res->port_id);
8571 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8572 "enabled" : "disabled", res->port_id);
8575 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8576 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8577 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8578 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8579 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8582 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8583 .f = cmd_get_sym_hash_per_port_parsed,
8585 .help_str = "get_sym_hash_ena_per_port port_id",
8587 (void *)&cmd_get_sym_hash_ena_per_port_all,
8588 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8593 /* *** Set symmetric hash enable per port *** */
8594 struct cmd_set_sym_hash_ena_per_port_result {
8595 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8596 cmdline_fixed_string_t enable;
8601 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8602 __rte_unused struct cmdline *cl,
8603 __rte_unused void *data)
8605 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8606 struct rte_eth_hash_filter_info info;
8609 if (rte_eth_dev_filter_supported(res->port_id,
8610 RTE_ETH_FILTER_HASH) < 0) {
8611 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8616 memset(&info, 0, sizeof(info));
8617 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8618 if (!strcmp(res->enable, "enable"))
8619 info.info.enable = 1;
8620 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8621 RTE_ETH_FILTER_SET, &info);
8623 printf("Cannot set symmetric hash enable per port on "
8624 "port %u\n", res->port_id);
8627 printf("Symmetric hash has been set to %s on port %u\n",
8628 res->enable, res->port_id);
8631 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8632 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8633 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8634 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8635 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8637 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8638 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8639 enable, "enable#disable");
8641 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8642 .f = cmd_set_sym_hash_per_port_parsed,
8644 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8646 (void *)&cmd_set_sym_hash_ena_per_port_all,
8647 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8648 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8653 /* Get global config of hash function */
8654 struct cmd_get_hash_global_config_result {
8655 cmdline_fixed_string_t get_hash_global_config;
8660 flowtype_to_str(uint16_t ftype)
8667 {"ipv4", RTE_ETH_FLOW_IPV4},
8668 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8669 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8670 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8671 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8672 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8673 {"ipv6", RTE_ETH_FLOW_IPV6},
8674 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8675 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8676 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8677 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8678 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8679 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8682 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8683 if (ftype_table[i].ftype == ftype)
8684 return ftype_table[i].str;
8691 cmd_get_hash_global_config_parsed(void *parsed_result,
8692 __rte_unused struct cmdline *cl,
8693 __rte_unused void *data)
8695 struct cmd_get_hash_global_config_result *res = parsed_result;
8696 struct rte_eth_hash_filter_info info;
8697 uint32_t idx, offset;
8702 if (rte_eth_dev_filter_supported(res->port_id,
8703 RTE_ETH_FILTER_HASH) < 0) {
8704 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8709 memset(&info, 0, sizeof(info));
8710 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8711 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8712 RTE_ETH_FILTER_GET, &info);
8714 printf("Cannot get hash global configurations by port %d\n",
8719 switch (info.info.global_conf.hash_func) {
8720 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8721 printf("Hash function is Toeplitz\n");
8723 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8724 printf("Hash function is Simple XOR\n");
8727 printf("Unknown hash function\n");
8731 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
8732 idx = i / UINT32_BIT;
8733 offset = i % UINT32_BIT;
8734 if (!(info.info.global_conf.valid_bit_mask[idx] &
8737 str = flowtype_to_str(i);
8740 printf("Symmetric hash is %s globally for flow type %s "
8742 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8743 (1UL << offset)) ? "enabled" : "disabled"), str,
8748 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8749 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8750 get_hash_global_config, "get_hash_global_config");
8751 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8752 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8755 cmdline_parse_inst_t cmd_get_hash_global_config = {
8756 .f = cmd_get_hash_global_config_parsed,
8758 .help_str = "get_hash_global_config port_id",
8760 (void *)&cmd_get_hash_global_config_all,
8761 (void *)&cmd_get_hash_global_config_port_id,
8766 /* Set global config of hash function */
8767 struct cmd_set_hash_global_config_result {
8768 cmdline_fixed_string_t set_hash_global_config;
8770 cmdline_fixed_string_t hash_func;
8771 cmdline_fixed_string_t flow_type;
8772 cmdline_fixed_string_t enable;
8776 cmd_set_hash_global_config_parsed(void *parsed_result,
8777 __rte_unused struct cmdline *cl,
8778 __rte_unused void *data)
8780 struct cmd_set_hash_global_config_result *res = parsed_result;
8781 struct rte_eth_hash_filter_info info;
8782 uint32_t ftype, idx, offset;
8785 if (rte_eth_dev_filter_supported(res->port_id,
8786 RTE_ETH_FILTER_HASH) < 0) {
8787 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8791 memset(&info, 0, sizeof(info));
8792 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8793 if (!strcmp(res->hash_func, "toeplitz"))
8794 info.info.global_conf.hash_func =
8795 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8796 else if (!strcmp(res->hash_func, "simple_xor"))
8797 info.info.global_conf.hash_func =
8798 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8799 else if (!strcmp(res->hash_func, "default"))
8800 info.info.global_conf.hash_func =
8801 RTE_ETH_HASH_FUNCTION_DEFAULT;
8803 ftype = str2flowtype(res->flow_type);
8804 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8805 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8806 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8807 if (!strcmp(res->enable, "enable"))
8808 info.info.global_conf.sym_hash_enable_mask[idx] |=
8810 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8811 RTE_ETH_FILTER_SET, &info);
8813 printf("Cannot set global hash configurations by port %d\n",
8816 printf("Global hash configurations have been set "
8817 "succcessfully by port %d\n", res->port_id);
8820 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8821 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8822 set_hash_global_config, "set_hash_global_config");
8823 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8824 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8826 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8827 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8828 hash_func, "toeplitz#simple_xor#default");
8829 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8830 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8832 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
8833 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
8834 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8835 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8836 enable, "enable#disable");
8838 cmdline_parse_inst_t cmd_set_hash_global_config = {
8839 .f = cmd_set_hash_global_config_parsed,
8841 .help_str = "set_hash_global_config port_id "
8842 "toeplitz|simple_xor|default "
8843 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
8844 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
8847 (void *)&cmd_set_hash_global_config_all,
8848 (void *)&cmd_set_hash_global_config_port_id,
8849 (void *)&cmd_set_hash_global_config_hash_func,
8850 (void *)&cmd_set_hash_global_config_flow_type,
8851 (void *)&cmd_set_hash_global_config_enable,
8856 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
8857 struct cmd_mcast_addr_result {
8858 cmdline_fixed_string_t mcast_addr_cmd;
8859 cmdline_fixed_string_t what;
8861 struct ether_addr mc_addr;
8864 static void cmd_mcast_addr_parsed(void *parsed_result,
8865 __attribute__((unused)) struct cmdline *cl,
8866 __attribute__((unused)) void *data)
8868 struct cmd_mcast_addr_result *res = parsed_result;
8870 if (!is_multicast_ether_addr(&res->mc_addr)) {
8871 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
8872 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
8873 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
8874 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
8877 if (strcmp(res->what, "add") == 0)
8878 mcast_addr_add(res->port_num, &res->mc_addr);
8880 mcast_addr_remove(res->port_num, &res->mc_addr);
8883 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
8884 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8885 mcast_addr_cmd, "mcast_addr");
8886 cmdline_parse_token_string_t cmd_mcast_addr_what =
8887 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8889 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
8890 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
8891 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
8892 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8894 cmdline_parse_inst_t cmd_mcast_addr = {
8895 .f = cmd_mcast_addr_parsed,
8897 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
8899 (void *)&cmd_mcast_addr_cmd,
8900 (void *)&cmd_mcast_addr_what,
8901 (void *)&cmd_mcast_addr_portnum,
8902 (void *)&cmd_mcast_addr_addr,
8907 /* ******************************************************************************** */
8909 /* list of instructions */
8910 cmdline_parse_ctx_t main_ctx[] = {
8911 (cmdline_parse_inst_t *)&cmd_help_brief,
8912 (cmdline_parse_inst_t *)&cmd_help_long,
8913 (cmdline_parse_inst_t *)&cmd_quit,
8914 (cmdline_parse_inst_t *)&cmd_showport,
8915 (cmdline_parse_inst_t *)&cmd_showportall,
8916 (cmdline_parse_inst_t *)&cmd_showcfg,
8917 (cmdline_parse_inst_t *)&cmd_start,
8918 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8919 (cmdline_parse_inst_t *)&cmd_set_link_up,
8920 (cmdline_parse_inst_t *)&cmd_set_link_down,
8921 (cmdline_parse_inst_t *)&cmd_reset,
8922 (cmdline_parse_inst_t *)&cmd_set_numbers,
8923 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8924 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8925 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8926 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8927 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8928 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8929 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8930 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8931 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8932 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8933 (cmdline_parse_inst_t *)&cmd_set_link_check,
8934 #ifdef RTE_NIC_BYPASS
8935 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8936 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8937 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8938 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8940 #ifdef RTE_LIBRTE_PMD_BOND
8941 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8942 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8943 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8944 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8945 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8946 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8947 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8948 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8949 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8951 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8952 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8953 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8954 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8955 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8956 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
8957 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8958 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8959 (cmdline_parse_inst_t *)&cmd_csum_set,
8960 (cmdline_parse_inst_t *)&cmd_csum_show,
8961 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8962 (cmdline_parse_inst_t *)&cmd_tso_set,
8963 (cmdline_parse_inst_t *)&cmd_tso_show,
8964 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8965 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8966 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8967 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8968 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8969 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8970 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8971 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8972 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8973 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8974 (cmdline_parse_inst_t *)&cmd_config_dcb,
8975 (cmdline_parse_inst_t *)&cmd_read_reg,
8976 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8977 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8978 (cmdline_parse_inst_t *)&cmd_write_reg,
8979 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8980 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8981 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8982 (cmdline_parse_inst_t *)&cmd_stop,
8983 (cmdline_parse_inst_t *)&cmd_mac_addr,
8984 (cmdline_parse_inst_t *)&cmd_set_qmap,
8985 (cmdline_parse_inst_t *)&cmd_operate_port,
8986 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8987 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
8988 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
8989 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8990 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8991 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8992 (cmdline_parse_inst_t *)&cmd_config_mtu,
8993 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8994 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8995 (cmdline_parse_inst_t *)&cmd_config_rss,
8996 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8997 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8998 (cmdline_parse_inst_t *)&cmd_showport_reta,
8999 (cmdline_parse_inst_t *)&cmd_config_burst,
9000 (cmdline_parse_inst_t *)&cmd_config_thresh,
9001 (cmdline_parse_inst_t *)&cmd_config_threshold,
9002 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9003 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9004 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9005 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9006 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9007 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9008 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9009 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9010 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9011 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9012 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9013 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9014 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9015 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9016 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9017 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9018 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9019 (cmdline_parse_inst_t *)&cmd_dump,
9020 (cmdline_parse_inst_t *)&cmd_dump_one,
9021 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9022 (cmdline_parse_inst_t *)&cmd_syn_filter,
9023 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9024 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9025 (cmdline_parse_inst_t *)&cmd_flex_filter,
9026 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9027 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9028 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9029 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9030 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9031 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
9032 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9033 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9034 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9035 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9036 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9037 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9038 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9042 /* prompt function, called from main on MASTER lcore */
9048 /* initialize non-constant commands */
9049 cmd_set_fwd_mode_init();
9051 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9055 cmdline_interact(cl);
9056 cmdline_stdin_exit(cl);
9060 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9062 if (id == (portid_t)RTE_PORT_ALL) {
9065 FOREACH_PORT(pid, ports) {
9066 /* check if need_reconfig has been set to 1 */
9067 if (ports[pid].need_reconfig == 0)
9068 ports[pid].need_reconfig = dev;
9069 /* check if need_reconfig_queues has been set to 1 */
9070 if (ports[pid].need_reconfig_queues == 0)
9071 ports[pid].need_reconfig_queues = queue;
9073 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9074 /* check if need_reconfig has been set to 1 */
9075 if (ports[id].need_reconfig == 0)
9076 ports[id].need_reconfig = dev;
9077 /* check if need_reconfig_queues has been set to 1 */
9078 if (ports[id].need_reconfig_queues == 0)
9079 ports[id].need_reconfig_queues = queue;
9083 #ifdef RTE_NIC_BYPASS
9084 #include <rte_pci_dev_ids.h>
9086 bypass_is_supported(portid_t port_id)
9088 struct rte_port *port;
9089 struct rte_pci_id *pci_id;
9091 if (port_id_is_invalid(port_id, ENABLED_WARN))
9094 /* Get the device id. */
9095 port = &ports[port_id];
9096 pci_id = &port->dev_info.pci_dev->id;
9098 /* Check if NIC supports bypass. */
9099 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9103 printf("\tBypass not supported for port_id = %d.\n", port_id);