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>
64 #include <rte_tailq.h>
66 #include <rte_per_lcore.h>
67 #include <rte_lcore.h>
68 #include <rte_atomic.h>
69 #include <rte_branch_prediction.h>
71 #include <rte_mempool.h>
72 #include <rte_interrupts.h>
74 #include <rte_ether.h>
75 #include <rte_ethdev.h>
76 #include <rte_string_fns.h>
77 #include <rte_devargs.h>
78 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #include <rte_pci_dev_ids.h>
89 #ifdef RTE_LIBRTE_PMD_BOND
90 #include <rte_eth_bond.h>
95 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
98 uint8_t bypass_is_supported(portid_t port_id);
101 /* *** Help command with introduction. *** */
102 struct cmd_help_brief_result {
103 cmdline_fixed_string_t help;
106 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
108 __attribute__((unused)) void *data)
113 "Help is available for the following sections:\n\n"
114 " help control : Start and stop forwarding.\n"
115 " help display : Displaying port, stats and config "
117 " help config : Configuration information.\n"
118 " help ports : Configuring ports.\n"
119 " help registers : Reading and setting port registers.\n"
120 " help filters : Filters configuration help.\n"
121 " help all : All of the above sections.\n\n"
126 cmdline_parse_token_string_t cmd_help_brief_help =
127 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
129 cmdline_parse_inst_t cmd_help_brief = {
130 .f = cmd_help_brief_parsed,
132 .help_str = "show help",
134 (void *)&cmd_help_brief_help,
139 /* *** Help command with help sections. *** */
140 struct cmd_help_long_result {
141 cmdline_fixed_string_t help;
142 cmdline_fixed_string_t section;
145 static void cmd_help_long_parsed(void *parsed_result,
147 __attribute__((unused)) void *data)
150 struct cmd_help_long_result *res = parsed_result;
152 if (!strcmp(res->section, "all"))
155 if (show_all || !strcmp(res->section, "control")) {
160 "Control forwarding:\n"
161 "-------------------\n\n"
164 " Start packet forwarding with current configuration.\n\n"
167 " Start packet forwarding with current config"
168 " after sending one burst of packets.\n\n"
171 " Stop packet forwarding, and display accumulated"
175 " Quit to prompt.\n\n"
179 if (show_all || !strcmp(res->section, "display")) {
187 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
188 " Display information for port_id, or all.\n\n"
190 "show port X rss reta (size) (mask0,mask1,...)\n"
191 " Display the rss redirection table entry indicated"
192 " by masks on port X. size is used to indicate the"
193 " hardware supported reta size\n\n"
195 "show port rss-hash [key]\n"
196 " Display the RSS hash functions and RSS hash key"
199 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
200 " Clear information for port_id, or all.\n\n"
202 "show config (rxtx|cores|fwd)\n"
203 " Display the given configuration.\n\n"
205 "read rxd (port_id) (queue_id) (rxd_id)\n"
206 " Display an RX descriptor of a port RX queue.\n\n"
208 "read txd (port_id) (queue_id) (txd_id)\n"
209 " Display a TX descriptor of a port TX queue.\n\n"
213 if (show_all || !strcmp(res->section, "config")) {
219 "Configuration changes only become active when"
220 " forwarding is started/restarted.\n\n"
223 " Reset forwarding to the default configuration.\n\n"
225 "set verbose (level)\n"
226 " Set the debug verbosity level X.\n\n"
229 " Set number of ports.\n\n"
232 " Set number of cores.\n\n"
234 "set coremask (mask)\n"
235 " Set the forwarding cores hexadecimal mask.\n\n"
237 "set portmask (mask)\n"
238 " Set the forwarding ports hexadecimal mask.\n\n"
241 " Set number of packets per burst.\n\n"
243 "set burst tx delay (microseconds) retry (num)\n"
244 " Set the transmit delay time and number of retries"
245 " in mac_retry forwarding mode.\n\n"
247 "set txpkts (x[,y]*)\n"
248 " Set the length of each segment of TXONLY"
251 "set corelist (x[,y]*)\n"
252 " Set the list of forwarding cores.\n\n"
254 "set portlist (x[,y]*)\n"
255 " Set the list of forwarding ports.\n\n"
257 "vlan set strip (on|off) (port_id)\n"
258 " Set the VLAN strip on a port.\n\n"
260 "vlan set stripq (on|off) (port_id,queue_id)\n"
261 " Set the VLAN strip for a queue on a port.\n\n"
263 "vlan set filter (on|off) (port_id)\n"
264 " Set the VLAN filter on a port.\n\n"
266 "vlan set qinq (on|off) (port_id)\n"
267 " Set the VLAN QinQ (extended queue in queue)"
270 "vlan set tpid (value) (port_id)\n"
271 " Set the outer VLAN TPID for Packet Filtering on"
274 "rx_vlan add (vlan_id|all) (port_id)\n"
275 " Add a vlan_id, or all identifiers, to the set"
276 " of VLAN identifiers filtered by port_id.\n\n"
278 "rx_vlan rm (vlan_id|all) (port_id)\n"
279 " Remove a vlan_id, or all identifiers, from the set"
280 " of VLAN identifiers filtered by port_id.\n\n"
282 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
283 " Add a vlan_id, to the set of VLAN identifiers"
284 "filtered for VF(s) from port_id.\n\n"
286 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
287 " Remove a vlan_id, to the set of VLAN identifiers"
288 "filtered for VF(s) from port_id.\n\n"
290 "rx_vlan set tpid (value) (port_id)\n"
291 " Set the outer VLAN TPID for Packet Filtering on"
294 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
295 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
296 " add a tunnel filter of a port.\n\n"
298 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
299 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
300 " remove a tunnel filter of a port.\n\n"
302 "rx_vxlan_port add (udp_port) (port_id)\n"
303 " Add an UDP port for VXLAN packet filter on a port\n\n"
305 "rx_vxlan_port rm (udp_port) (port_id)\n"
306 " Remove an UDP port for VXLAN packet filter on a port\n\n"
308 "tx_vlan set vlan_id (port_id)\n"
309 " Set hardware insertion of VLAN ID in packets sent"
312 "tx_vlan set pvid port_id vlan_id (on|off)\n"
313 " Set port based TX VLAN insertion.\n\n"
315 "tx_vlan reset (port_id)\n"
316 " Disable hardware insertion of a VLAN header in"
317 " packets sent on a port.\n\n"
319 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
320 " Select hardware or software calculation of the"
321 " checksum with when transmitting a packet using the"
322 " csum forward engine.\n"
323 " ip|udp|tcp|sctp always concern the inner layer.\n"
324 " outer-ip concerns the outer IP layer in"
325 " case the packet is recognized as a tunnel packet by"
326 " the forward engine (vxlan, gre and ipip are supported)\n"
327 " Please check the NIC datasheet for HW limits.\n\n"
329 "csum parse-tunnel (on|off) (tx_port_id)\n"
330 " If disabled, treat tunnel packets as non-tunneled"
331 " packets (treat inner headers as payload). The port\n"
332 " argument is the port used for TX in csum forward"
335 "csum show (port_id)\n"
336 " Display tx checksum offload configuration\n\n"
338 "tso set (segsize) (portid)\n"
339 " Enable TCP Segmentation Offload in csum forward"
341 " Please check the NIC datasheet for HW limits.\n\n"
344 " Display the status of TCP Segmentation Offload.\n\n"
347 " Set packet forwarding mode.\n\n"
349 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
350 " Add a MAC address on port_id.\n\n"
352 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
353 " Remove a MAC address from port_id.\n\n"
355 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
356 " Add a MAC address for a VF on the port.\n\n"
358 "set port (port_id) uta (mac_address|all) (on|off)\n"
359 " Add/Remove a or all unicast hash filter(s)"
362 "set promisc (port_id|all) (on|off)\n"
363 " Set the promiscuous mode on port_id, or all.\n\n"
365 "set allmulti (port_id|all) (on|off)\n"
366 " Set the allmulti mode on port_id, or all.\n\n"
368 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
369 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
370 " (on|off) autoneg (on|off) (port_id)\n"
371 "set flow_ctrl rx (on|off) (portid)\n"
372 "set flow_ctrl tx (on|off) (portid)\n"
373 "set flow_ctrl high_water (high_water) (portid)\n"
374 "set flow_ctrl low_water (low_water) (portid)\n"
375 "set flow_ctrl pause_time (pause_time) (portid)\n"
376 "set flow_ctrl send_xon (send_xon) (portid)\n"
377 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
378 "set flow_ctrl autoneg (on|off) (port_id)\n"
379 " Set the link flow control parameter on a port.\n\n"
381 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
382 " (low_water) (pause_time) (priority) (port_id)\n"
383 " Set the priority flow control parameter on a"
386 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
387 " Set statistics mapping (qmapping 0..15) for RX/TX"
389 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
390 " on port 0 to mapping 5.\n\n"
392 "set port (port_id) vf (vf_id) rx|tx on|off\n"
393 " Enable/Disable a VF receive/tranmit from a port\n\n"
395 "set port (port_id) vf (vf_id) (mac_addr)"
396 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
397 " Add/Remove unicast or multicast MAC addr filter"
400 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
402 " AUPE:accepts untagged VLAN;"
403 "ROPE:accept unicast hash\n\n"
404 " BAM:accepts broadcast packets;"
405 "MPE:accepts all multicast packets\n\n"
406 " Enable/Disable a VF receive mode of a port\n\n"
408 "set port (port_id) queue (queue_id) rate (rate_num)\n"
409 " Set rate limit for a queue of a port\n\n"
411 "set port (port_id) vf (vf_id) rate (rate_num) "
412 "queue_mask (queue_mask_value)\n"
413 " Set rate limit for queues in VF of a port\n\n"
415 "set port (port_id) mirror-rule (rule_id)"
416 "(pool-mirror|vlan-mirror)\n"
417 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
418 " Set pool or vlan type mirror rule on a port.\n"
419 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
420 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
423 "set port (port_id) mirror-rule (rule_id)"
424 " (uplink-mirror|downlink-mirror) dst-pool"
425 " (pool_id) (on|off)\n"
426 " Set uplink or downlink type mirror rule on a port.\n"
427 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
428 " 0 on' enable mirror income traffic to pool 0.\n\n"
430 "reset port (port_id) mirror-rule (rule_id)\n"
431 " Reset a mirror rule.\n\n"
433 "set flush_rx (on|off)\n"
434 " Flush (default) or don't flush RX streams before"
435 " forwarding. Mainly used with PCAP drivers.\n\n"
437 #ifdef RTE_NIC_BYPASS
438 "set bypass mode (normal|bypass|isolate) (port_id)\n"
439 " Set the bypass mode for the lowest port on bypass enabled"
442 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
443 "mode (normal|bypass|isolate) (port_id)\n"
444 " Set the event required to initiate specified bypass mode for"
445 " the lowest port on a bypass enabled NIC where:\n"
446 " timeout = enable bypass after watchdog timeout.\n"
447 " os_on = enable bypass when OS/board is powered on.\n"
448 " os_off = enable bypass when OS/board is powered off.\n"
449 " power_on = enable bypass when power supply is turned on.\n"
450 " power_off = enable bypass when power supply is turned off."
453 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
454 " Set the bypass watchdog timeout to 'n' seconds"
455 " where 0 = instant.\n\n"
457 "show bypass config (port_id)\n"
458 " Show the bypass configuration for a bypass enabled NIC"
459 " using the lowest port on the NIC.\n\n"
461 #ifdef RTE_LIBRTE_PMD_BOND
462 "create bonded device (mode) (socket)\n"
463 " Create a new bonded device with specific bonding mode and socket.\n\n"
465 "add bonding slave (slave_id) (port_id)\n"
466 " Add a slave device to a bonded device.\n\n"
468 "remove bonding slave (slave_id) (port_id)\n"
469 " Remove a slave device from a bonded device.\n\n"
471 "set bonding mode (value) (port_id)\n"
472 " Set the bonding mode on a bonded device.\n\n"
474 "set bonding primary (slave_id) (port_id)\n"
475 " Set the primary slave for a bonded device.\n\n"
477 "show bonding config (port_id)\n"
478 " Show the bonding config for port_id.\n\n"
480 "set bonding mac_addr (port_id) (address)\n"
481 " Set the MAC address of a bonded device.\n\n"
483 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
484 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
486 "set bonding mon_period (port_id) (value)\n"
487 " Set the bonding link status monitoring polling period in ms.\n\n"
489 "set link-up port (port_id)\n"
490 " Set link up for a port.\n\n"
492 "set link-down port (port_id)\n"
493 " Set link down for a port.\n\n"
495 , list_pkt_forwarding_modes()
499 if (show_all || !strcmp(res->section, "ports")) {
505 "----------------\n\n"
507 "port start (port_id|all)\n"
508 " Start all ports or port_id.\n\n"
510 "port stop (port_id|all)\n"
511 " Stop all ports or port_id.\n\n"
513 "port close (port_id|all)\n"
514 " Close all ports or port_id.\n\n"
516 "port config (port_id|all)"
517 " speed (10|100|1000|10000|40000|auto)"
518 " duplex (half|full|auto)\n"
519 " Set speed and duplex for all ports or port_id\n\n"
521 "port config all (rxq|txq|rxd|txd) (value)\n"
522 " Set number for rxq/txq/rxd/txd.\n\n"
524 "port config all max-pkt-len (value)\n"
525 " Set the max packet length.\n\n"
527 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
529 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
532 "port config all rss (ip|udp|none)\n"
533 " Set the RSS mode.\n\n"
535 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
536 " Set the RSS redirection table.\n\n"
538 "port config (port_id) dcb vt (on|off) (traffic_class)"
540 " Set the DCB mode.\n\n"
542 "port config all burst (value)\n"
543 " Set the number of packets per burst.\n\n"
545 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
547 " Set the ring prefetch/host/writeback threshold"
548 " for tx/rx queue.\n\n"
550 "port config all (txfreet|txrst|rxfreet) (value)\n"
551 " Set free threshold for rx/tx, or set"
552 " tx rs bit threshold.\n\n"
553 "port config mtu X value\n"
554 " Set the MTU of port X to a given value\n\n"
556 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
557 " Start/stop a rx/tx queue of port X. Only take effect"
558 " when port X is started\n"
562 if (show_all || !strcmp(res->section, "registers")) {
570 "read reg (port_id) (address)\n"
571 " Display value of a port register.\n\n"
573 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
574 " Display a port register bit field.\n\n"
576 "read regbit (port_id) (address) (bit_x)\n"
577 " Display a single port register bit.\n\n"
579 "write reg (port_id) (address) (value)\n"
580 " Set value of a port register.\n\n"
582 "write regfield (port_id) (address) (bit_x) (bit_y)"
584 " Set bit field of a port register.\n\n"
586 "write regbit (port_id) (address) (bit_x) (value)\n"
587 " Set single bit value of a port register.\n\n"
590 if (show_all || !strcmp(res->section, "filters")) {
598 "ethertype_filter (port_id) (add|del)"
599 " (mac_addr|mac_ignr) (mac_address) ethertype"
600 " (ether_type) (drop|fwd) queue (queue_id)\n"
601 " Add/Del an ethertype filter.\n\n"
603 "2tuple_filter (port_id) (add|del)"
604 " dst_port (dst_port_value) protocol (protocol_value)"
605 " mask (mask_value) tcp_flags (tcp_flags_value)"
606 " priority (prio_value) queue (queue_id)\n"
607 " Add/Del a 2tuple filter.\n\n"
609 "5tuple_filter (port_id) (add|del)"
610 " dst_ip (dst_address) src_ip (src_address)"
611 " dst_port (dst_port_value) src_port (src_port_value)"
612 " protocol (protocol_value)"
613 " mask (mask_value) tcp_flags (tcp_flags_value)"
614 " priority (prio_value) queue (queue_id)\n"
615 " Add/Del a 5tuple filter.\n\n"
617 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
618 " Add/Del syn filter.\n\n"
620 "flex_filter (port_id) (add|del) len (len_value)"
621 " bytes (bytes_value) mask (mask_value)"
622 " priority (prio_value) queue (queue_id)\n"
623 " Add/Del a flex filter.\n\n"
625 "flow_director_filter (port_id) (add|del|update)"
626 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
627 " src (src_ip_address) dst (dst_ip_address)"
628 " vlan (vlan_value) flexbytes (flexbytes_value)"
629 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
630 " Add/Del an IP type flow director filter.\n\n"
632 "flow_director_filter (port_id) (add|del|update)"
633 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
634 " src (src_ip_address) (src_port)"
635 " dst (dst_ip_address) (dst_port)"
636 " vlan (vlan_value) flexbytes (flexbytes_value)"
637 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
638 " Add/Del an UDP/TCP type flow director filter.\n\n"
640 "flow_director_filter (port_id) (add|del|update)"
641 " flow (ipv4-sctp|ipv6-sctp)"
642 " src (src_ip_address) (src_port)"
643 " dst (dst_ip_address) (dst_port)"
644 " tag (verification_tag) vlan (vlan_value)"
645 " flexbytes (flexbytes_value) (drop|fwd)"
646 " queue (queue_id) fd_id (fd_id_value)\n"
647 " Add/Del a SCTP type flow director filter.\n\n"
649 "flush_flow_director (port_id)\n"
650 " Flush all flow director entries of a device.\n\n"
652 "flow_director_mask (port_id) vlan (vlan_value)"
653 " src_mask (ipv4_src) (ipv6_src) (src_port)"
654 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
655 " Set flow director mask.\n\n"
657 "flow_director_flex_mask (port_id)"
658 " flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
659 " flow (raw|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
660 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|all)"
662 " Configure mask of flex payload.\n\n"
664 "flow_director_flex_payload (port_id)"
665 " (raw|l2|l3|l4) (config)\n"
666 " Configure flex payload selection.\n\n"
668 "get_sym_hash_ena_per_port (port_id)\n"
669 " get symmetric hash enable configuration per port.\n\n"
671 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
672 " set symmetric hash enable configuration per port"
673 " to enable or disable.\n\n"
675 "get_hash_global_config (port_id)\n"
676 " Get the global configurations of hash filters.\n\n"
678 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
679 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
680 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
681 " (enable|disable)\n"
682 " Set the global configurations of hash filters.\n\n"
687 cmdline_parse_token_string_t cmd_help_long_help =
688 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
690 cmdline_parse_token_string_t cmd_help_long_section =
691 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
692 "all#control#display#config#"
693 "ports#registers#filters");
695 cmdline_parse_inst_t cmd_help_long = {
696 .f = cmd_help_long_parsed,
698 .help_str = "show help",
700 (void *)&cmd_help_long_help,
701 (void *)&cmd_help_long_section,
707 /* *** start/stop/close all ports *** */
708 struct cmd_operate_port_result {
709 cmdline_fixed_string_t keyword;
710 cmdline_fixed_string_t name;
711 cmdline_fixed_string_t value;
714 static void cmd_operate_port_parsed(void *parsed_result,
715 __attribute__((unused)) struct cmdline *cl,
716 __attribute__((unused)) void *data)
718 struct cmd_operate_port_result *res = parsed_result;
720 if (!strcmp(res->name, "start"))
721 start_port(RTE_PORT_ALL);
722 else if (!strcmp(res->name, "stop"))
723 stop_port(RTE_PORT_ALL);
724 else if (!strcmp(res->name, "close"))
725 close_port(RTE_PORT_ALL);
727 printf("Unknown parameter\n");
730 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
731 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
733 cmdline_parse_token_string_t cmd_operate_port_all_port =
734 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
736 cmdline_parse_token_string_t cmd_operate_port_all_all =
737 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
739 cmdline_parse_inst_t cmd_operate_port = {
740 .f = cmd_operate_port_parsed,
742 .help_str = "port start|stop|close all: start/stop/close all ports",
744 (void *)&cmd_operate_port_all_cmd,
745 (void *)&cmd_operate_port_all_port,
746 (void *)&cmd_operate_port_all_all,
751 /* *** start/stop/close specific port *** */
752 struct cmd_operate_specific_port_result {
753 cmdline_fixed_string_t keyword;
754 cmdline_fixed_string_t name;
758 static void cmd_operate_specific_port_parsed(void *parsed_result,
759 __attribute__((unused)) struct cmdline *cl,
760 __attribute__((unused)) void *data)
762 struct cmd_operate_specific_port_result *res = parsed_result;
764 if (!strcmp(res->name, "start"))
765 start_port(res->value);
766 else if (!strcmp(res->name, "stop"))
767 stop_port(res->value);
768 else if (!strcmp(res->name, "close"))
769 close_port(res->value);
771 printf("Unknown parameter\n");
774 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
775 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
777 cmdline_parse_token_string_t cmd_operate_specific_port_port =
778 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
779 name, "start#stop#close");
780 cmdline_parse_token_num_t cmd_operate_specific_port_id =
781 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
784 cmdline_parse_inst_t cmd_operate_specific_port = {
785 .f = cmd_operate_specific_port_parsed,
787 .help_str = "port start|stop|close X: start/stop/close port X",
789 (void *)&cmd_operate_specific_port_cmd,
790 (void *)&cmd_operate_specific_port_port,
791 (void *)&cmd_operate_specific_port_id,
796 /* *** configure speed for all ports *** */
797 struct cmd_config_speed_all {
798 cmdline_fixed_string_t port;
799 cmdline_fixed_string_t keyword;
800 cmdline_fixed_string_t all;
801 cmdline_fixed_string_t item1;
802 cmdline_fixed_string_t item2;
803 cmdline_fixed_string_t value1;
804 cmdline_fixed_string_t value2;
808 cmd_config_speed_all_parsed(void *parsed_result,
809 __attribute__((unused)) struct cmdline *cl,
810 __attribute__((unused)) void *data)
812 struct cmd_config_speed_all *res = parsed_result;
813 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
814 uint16_t link_duplex = 0;
817 if (!all_ports_stopped()) {
818 printf("Please stop all ports first\n");
822 if (!strcmp(res->value1, "10"))
823 link_speed = ETH_LINK_SPEED_10;
824 else if (!strcmp(res->value1, "100"))
825 link_speed = ETH_LINK_SPEED_100;
826 else if (!strcmp(res->value1, "1000"))
827 link_speed = ETH_LINK_SPEED_1000;
828 else if (!strcmp(res->value1, "10000"))
829 link_speed = ETH_LINK_SPEED_10G;
830 else if (!strcmp(res->value1, "40000"))
831 link_speed = ETH_LINK_SPEED_40G;
832 else if (!strcmp(res->value1, "auto"))
833 link_speed = ETH_LINK_SPEED_AUTONEG;
835 printf("Unknown parameter\n");
839 if (!strcmp(res->value2, "half"))
840 link_duplex = ETH_LINK_HALF_DUPLEX;
841 else if (!strcmp(res->value2, "full"))
842 link_duplex = ETH_LINK_FULL_DUPLEX;
843 else if (!strcmp(res->value2, "auto"))
844 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
846 printf("Unknown parameter\n");
850 for (pid = 0; pid < nb_ports; pid++) {
851 ports[pid].dev_conf.link_speed = link_speed;
852 ports[pid].dev_conf.link_duplex = link_duplex;
855 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
858 cmdline_parse_token_string_t cmd_config_speed_all_port =
859 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
860 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
861 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
863 cmdline_parse_token_string_t cmd_config_speed_all_all =
864 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
865 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
866 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
867 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
868 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
869 "10#100#1000#10000#40000#auto");
870 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
871 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
872 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
873 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
876 cmdline_parse_inst_t cmd_config_speed_all = {
877 .f = cmd_config_speed_all_parsed,
879 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
882 (void *)&cmd_config_speed_all_port,
883 (void *)&cmd_config_speed_all_keyword,
884 (void *)&cmd_config_speed_all_all,
885 (void *)&cmd_config_speed_all_item1,
886 (void *)&cmd_config_speed_all_value1,
887 (void *)&cmd_config_speed_all_item2,
888 (void *)&cmd_config_speed_all_value2,
893 /* *** configure speed for specific port *** */
894 struct cmd_config_speed_specific {
895 cmdline_fixed_string_t port;
896 cmdline_fixed_string_t keyword;
898 cmdline_fixed_string_t item1;
899 cmdline_fixed_string_t item2;
900 cmdline_fixed_string_t value1;
901 cmdline_fixed_string_t value2;
905 cmd_config_speed_specific_parsed(void *parsed_result,
906 __attribute__((unused)) struct cmdline *cl,
907 __attribute__((unused)) void *data)
909 struct cmd_config_speed_specific *res = parsed_result;
910 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
911 uint16_t link_duplex = 0;
913 if (!all_ports_stopped()) {
914 printf("Please stop all ports first\n");
918 if (res->id >= nb_ports) {
919 printf("Port id %d must be less than %d\n", res->id, nb_ports);
923 if (!strcmp(res->value1, "10"))
924 link_speed = ETH_LINK_SPEED_10;
925 else if (!strcmp(res->value1, "100"))
926 link_speed = ETH_LINK_SPEED_100;
927 else if (!strcmp(res->value1, "1000"))
928 link_speed = ETH_LINK_SPEED_1000;
929 else if (!strcmp(res->value1, "10000"))
930 link_speed = ETH_LINK_SPEED_10000;
931 else if (!strcmp(res->value1, "40000"))
932 link_speed = ETH_LINK_SPEED_40G;
933 else if (!strcmp(res->value1, "auto"))
934 link_speed = ETH_LINK_SPEED_AUTONEG;
936 printf("Unknown parameter\n");
940 if (!strcmp(res->value2, "half"))
941 link_duplex = ETH_LINK_HALF_DUPLEX;
942 else if (!strcmp(res->value2, "full"))
943 link_duplex = ETH_LINK_FULL_DUPLEX;
944 else if (!strcmp(res->value2, "auto"))
945 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
947 printf("Unknown parameter\n");
951 ports[res->id].dev_conf.link_speed = link_speed;
952 ports[res->id].dev_conf.link_duplex = link_duplex;
954 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
958 cmdline_parse_token_string_t cmd_config_speed_specific_port =
959 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
961 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
962 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
964 cmdline_parse_token_num_t cmd_config_speed_specific_id =
965 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
966 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
967 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
969 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
970 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
971 "10#100#1000#10000#40000#auto");
972 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
973 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
975 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
976 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
979 cmdline_parse_inst_t cmd_config_speed_specific = {
980 .f = cmd_config_speed_specific_parsed,
982 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
985 (void *)&cmd_config_speed_specific_port,
986 (void *)&cmd_config_speed_specific_keyword,
987 (void *)&cmd_config_speed_specific_id,
988 (void *)&cmd_config_speed_specific_item1,
989 (void *)&cmd_config_speed_specific_value1,
990 (void *)&cmd_config_speed_specific_item2,
991 (void *)&cmd_config_speed_specific_value2,
996 /* *** configure txq/rxq, txd/rxd *** */
997 struct cmd_config_rx_tx {
998 cmdline_fixed_string_t port;
999 cmdline_fixed_string_t keyword;
1000 cmdline_fixed_string_t all;
1001 cmdline_fixed_string_t name;
1006 cmd_config_rx_tx_parsed(void *parsed_result,
1007 __attribute__((unused)) struct cmdline *cl,
1008 __attribute__((unused)) void *data)
1010 struct cmd_config_rx_tx *res = parsed_result;
1012 if (!all_ports_stopped()) {
1013 printf("Please stop all ports first\n");
1017 if (!strcmp(res->name, "rxq")) {
1018 if (res->value <= 0) {
1019 printf("rxq %d invalid - must be > 0\n", res->value);
1022 nb_rxq = res->value;
1024 else if (!strcmp(res->name, "txq")) {
1025 if (res->value <= 0) {
1026 printf("txq %d invalid - must be > 0\n", res->value);
1029 nb_txq = res->value;
1031 else if (!strcmp(res->name, "rxd")) {
1032 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1033 printf("rxd %d invalid - must be > 0 && <= %d\n",
1034 res->value, RTE_TEST_RX_DESC_MAX);
1037 nb_rxd = res->value;
1038 } else if (!strcmp(res->name, "txd")) {
1039 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1040 printf("txd %d invalid - must be > 0 && <= %d\n",
1041 res->value, RTE_TEST_TX_DESC_MAX);
1044 nb_txd = res->value;
1046 printf("Unknown parameter\n");
1052 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1055 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1056 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1057 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1058 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1059 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1061 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1062 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1064 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1065 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1067 cmdline_parse_inst_t cmd_config_rx_tx = {
1068 .f = cmd_config_rx_tx_parsed,
1070 .help_str = "port config all rxq|txq|rxd|txd value",
1072 (void *)&cmd_config_rx_tx_port,
1073 (void *)&cmd_config_rx_tx_keyword,
1074 (void *)&cmd_config_rx_tx_all,
1075 (void *)&cmd_config_rx_tx_name,
1076 (void *)&cmd_config_rx_tx_value,
1081 /* *** config max packet length *** */
1082 struct cmd_config_max_pkt_len_result {
1083 cmdline_fixed_string_t port;
1084 cmdline_fixed_string_t keyword;
1085 cmdline_fixed_string_t all;
1086 cmdline_fixed_string_t name;
1091 cmd_config_max_pkt_len_parsed(void *parsed_result,
1092 __attribute__((unused)) struct cmdline *cl,
1093 __attribute__((unused)) void *data)
1095 struct cmd_config_max_pkt_len_result *res = parsed_result;
1097 if (!all_ports_stopped()) {
1098 printf("Please stop all ports first\n");
1102 if (!strcmp(res->name, "max-pkt-len")) {
1103 if (res->value < ETHER_MIN_LEN) {
1104 printf("max-pkt-len can not be less than %d\n",
1108 if (res->value == rx_mode.max_rx_pkt_len)
1111 rx_mode.max_rx_pkt_len = res->value;
1112 if (res->value > ETHER_MAX_LEN)
1113 rx_mode.jumbo_frame = 1;
1115 rx_mode.jumbo_frame = 0;
1117 printf("Unknown parameter\n");
1123 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1126 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1127 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1129 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1130 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1132 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1133 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1135 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1136 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1138 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1139 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1142 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1143 .f = cmd_config_max_pkt_len_parsed,
1145 .help_str = "port config all max-pkt-len value",
1147 (void *)&cmd_config_max_pkt_len_port,
1148 (void *)&cmd_config_max_pkt_len_keyword,
1149 (void *)&cmd_config_max_pkt_len_all,
1150 (void *)&cmd_config_max_pkt_len_name,
1151 (void *)&cmd_config_max_pkt_len_value,
1156 /* *** configure port MTU *** */
1157 struct cmd_config_mtu_result {
1158 cmdline_fixed_string_t port;
1159 cmdline_fixed_string_t keyword;
1160 cmdline_fixed_string_t mtu;
1166 cmd_config_mtu_parsed(void *parsed_result,
1167 __attribute__((unused)) struct cmdline *cl,
1168 __attribute__((unused)) void *data)
1170 struct cmd_config_mtu_result *res = parsed_result;
1172 if (res->value < ETHER_MIN_LEN) {
1173 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1176 port_mtu_set(res->port_id, res->value);
1179 cmdline_parse_token_string_t cmd_config_mtu_port =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1182 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1185 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1186 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1188 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1189 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1190 cmdline_parse_token_num_t cmd_config_mtu_value =
1191 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1193 cmdline_parse_inst_t cmd_config_mtu = {
1194 .f = cmd_config_mtu_parsed,
1196 .help_str = "port config mtu value",
1198 (void *)&cmd_config_mtu_port,
1199 (void *)&cmd_config_mtu_keyword,
1200 (void *)&cmd_config_mtu_mtu,
1201 (void *)&cmd_config_mtu_port_id,
1202 (void *)&cmd_config_mtu_value,
1207 /* *** configure rx mode *** */
1208 struct cmd_config_rx_mode_flag {
1209 cmdline_fixed_string_t port;
1210 cmdline_fixed_string_t keyword;
1211 cmdline_fixed_string_t all;
1212 cmdline_fixed_string_t name;
1213 cmdline_fixed_string_t value;
1217 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1218 __attribute__((unused)) struct cmdline *cl,
1219 __attribute__((unused)) void *data)
1221 struct cmd_config_rx_mode_flag *res = parsed_result;
1223 if (!all_ports_stopped()) {
1224 printf("Please stop all ports first\n");
1228 if (!strcmp(res->name, "crc-strip")) {
1229 if (!strcmp(res->value, "on"))
1230 rx_mode.hw_strip_crc = 1;
1231 else if (!strcmp(res->value, "off"))
1232 rx_mode.hw_strip_crc = 0;
1234 printf("Unknown parameter\n");
1237 } else if (!strcmp(res->name, "rx-cksum")) {
1238 if (!strcmp(res->value, "on"))
1239 rx_mode.hw_ip_checksum = 1;
1240 else if (!strcmp(res->value, "off"))
1241 rx_mode.hw_ip_checksum = 0;
1243 printf("Unknown parameter\n");
1246 } else if (!strcmp(res->name, "hw-vlan")) {
1247 if (!strcmp(res->value, "on")) {
1248 rx_mode.hw_vlan_filter = 1;
1249 rx_mode.hw_vlan_strip = 1;
1251 else if (!strcmp(res->value, "off")) {
1252 rx_mode.hw_vlan_filter = 0;
1253 rx_mode.hw_vlan_strip = 0;
1256 printf("Unknown parameter\n");
1259 } else if (!strcmp(res->name, "drop-en")) {
1260 if (!strcmp(res->value, "on"))
1262 else if (!strcmp(res->value, "off"))
1265 printf("Unknown parameter\n");
1269 printf("Unknown parameter\n");
1275 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1278 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1279 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1280 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1283 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1284 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1285 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1286 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1287 "crc-strip#rx-cksum#hw-vlan");
1288 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1289 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1292 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1293 .f = cmd_config_rx_mode_flag_parsed,
1295 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1297 (void *)&cmd_config_rx_mode_flag_port,
1298 (void *)&cmd_config_rx_mode_flag_keyword,
1299 (void *)&cmd_config_rx_mode_flag_all,
1300 (void *)&cmd_config_rx_mode_flag_name,
1301 (void *)&cmd_config_rx_mode_flag_value,
1306 /* *** configure rss *** */
1307 struct cmd_config_rss {
1308 cmdline_fixed_string_t port;
1309 cmdline_fixed_string_t keyword;
1310 cmdline_fixed_string_t all;
1311 cmdline_fixed_string_t name;
1312 cmdline_fixed_string_t value;
1316 cmd_config_rss_parsed(void *parsed_result,
1317 __attribute__((unused)) struct cmdline *cl,
1318 __attribute__((unused)) void *data)
1320 struct cmd_config_rss *res = parsed_result;
1321 struct rte_eth_rss_conf rss_conf;
1324 if (!strcmp(res->value, "ip"))
1325 rss_conf.rss_hf = ETH_RSS_IP;
1326 else if (!strcmp(res->value, "udp"))
1327 rss_conf.rss_hf = ETH_RSS_UDP;
1328 else if (!strcmp(res->value, "none"))
1329 rss_conf.rss_hf = 0;
1331 printf("Unknown parameter\n");
1334 rss_conf.rss_key = NULL;
1335 for (i = 0; i < rte_eth_dev_count(); i++)
1336 rte_eth_dev_rss_hash_update(i, &rss_conf);
1339 cmdline_parse_token_string_t cmd_config_rss_port =
1340 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1341 cmdline_parse_token_string_t cmd_config_rss_keyword =
1342 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1343 cmdline_parse_token_string_t cmd_config_rss_all =
1344 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1345 cmdline_parse_token_string_t cmd_config_rss_name =
1346 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1347 cmdline_parse_token_string_t cmd_config_rss_value =
1348 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1350 cmdline_parse_inst_t cmd_config_rss = {
1351 .f = cmd_config_rss_parsed,
1353 .help_str = "port config all rss ip|udp|none",
1355 (void *)&cmd_config_rss_port,
1356 (void *)&cmd_config_rss_keyword,
1357 (void *)&cmd_config_rss_all,
1358 (void *)&cmd_config_rss_name,
1359 (void *)&cmd_config_rss_value,
1364 /* *** configure rss hash key *** */
1365 struct cmd_config_rss_hash_key {
1366 cmdline_fixed_string_t port;
1367 cmdline_fixed_string_t config;
1369 cmdline_fixed_string_t rss_hash_key;
1370 cmdline_fixed_string_t key;
1373 #define RSS_HASH_KEY_LENGTH 40
1375 hexa_digit_to_value(char hexa_digit)
1377 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1378 return (uint8_t) (hexa_digit - '0');
1379 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1380 return (uint8_t) ((hexa_digit - 'a') + 10);
1381 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1382 return (uint8_t) ((hexa_digit - 'A') + 10);
1383 /* Invalid hexa digit */
1388 parse_and_check_key_hexa_digit(char *key, int idx)
1392 hexa_v = hexa_digit_to_value(key[idx]);
1394 printf("invalid key: character %c at position %d is not a "
1395 "valid hexa digit\n", key[idx], idx);
1400 cmd_config_rss_hash_key_parsed(void *parsed_result,
1401 __attribute__((unused)) struct cmdline *cl,
1402 __attribute__((unused)) void *data)
1404 struct cmd_config_rss_hash_key *res = parsed_result;
1405 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1410 /* Check the length of the RSS hash key */
1411 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1412 printf("key length: %d invalid - key must be a string of %d"
1413 "hexa-decimal numbers\n", (int) strlen(res->key),
1414 RSS_HASH_KEY_LENGTH * 2);
1417 /* Translate RSS hash key into binary representation */
1418 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1419 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1422 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1425 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1427 port_rss_hash_key_update(res->port_id, hash_key);
1430 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1432 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1433 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1435 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1436 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1437 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1438 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1439 rss_hash_key, "rss-hash-key");
1440 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1441 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1443 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1444 .f = cmd_config_rss_hash_key_parsed,
1446 .help_str = "port config X rss-hash-key 80 hexa digits",
1448 (void *)&cmd_config_rss_hash_key_port,
1449 (void *)&cmd_config_rss_hash_key_config,
1450 (void *)&cmd_config_rss_hash_key_port_id,
1451 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1452 (void *)&cmd_config_rss_hash_key_value,
1457 /* *** configure port rxq/txq start/stop *** */
1458 struct cmd_config_rxtx_queue {
1459 cmdline_fixed_string_t port;
1461 cmdline_fixed_string_t rxtxq;
1463 cmdline_fixed_string_t opname;
1467 cmd_config_rxtx_queue_parsed(void *parsed_result,
1468 __attribute__((unused)) struct cmdline *cl,
1469 __attribute__((unused)) void *data)
1471 struct cmd_config_rxtx_queue *res = parsed_result;
1476 if (test_done == 0) {
1477 printf("Please stop forwarding first\n");
1481 if (port_id_is_invalid(res->portid))
1484 if (port_is_started(res->portid) != 1) {
1485 printf("Please start port %u first\n", res->portid);
1489 if (!strcmp(res->rxtxq, "rxq"))
1491 else if (!strcmp(res->rxtxq, "txq"))
1494 printf("Unknown parameter\n");
1498 if (isrx && rx_queue_id_is_invalid(res->qid))
1500 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1503 if (!strcmp(res->opname, "start"))
1505 else if (!strcmp(res->opname, "stop"))
1508 printf("Unknown parameter\n");
1512 if (isstart && isrx)
1513 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1514 else if (!isstart && isrx)
1515 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1516 else if (isstart && !isrx)
1517 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1519 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1521 if (ret == -ENOTSUP)
1522 printf("Function not supported in PMD driver\n");
1525 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1526 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1527 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1528 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1529 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1530 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1531 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1532 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1533 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1534 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1537 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1538 .f = cmd_config_rxtx_queue_parsed,
1540 .help_str = "port X rxq|txq ID start|stop",
1542 (void *)&cmd_config_speed_all_port,
1543 (void *)&cmd_config_rxtx_queue_portid,
1544 (void *)&cmd_config_rxtx_queue_rxtxq,
1545 (void *)&cmd_config_rxtx_queue_qid,
1546 (void *)&cmd_config_rxtx_queue_opname,
1551 /* *** Configure RSS RETA *** */
1552 struct cmd_config_rss_reta {
1553 cmdline_fixed_string_t port;
1554 cmdline_fixed_string_t keyword;
1556 cmdline_fixed_string_t name;
1557 cmdline_fixed_string_t list_name;
1558 cmdline_fixed_string_t list_of_items;
1562 parse_reta_config(const char *str,
1563 struct rte_eth_rss_reta_entry64 *reta_conf,
1564 uint16_t nb_entries)
1568 uint16_t hash_index, idx, shift;
1571 const char *p, *p0 = str;
1578 unsigned long int_fld[_NUM_FLD];
1579 char *str_fld[_NUM_FLD];
1581 while ((p = strchr(p0,'(')) != NULL) {
1583 if((p0 = strchr(p,')')) == NULL)
1587 if(size >= sizeof(s))
1590 snprintf(s, sizeof(s), "%.*s", size, p);
1591 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1593 for (i = 0; i < _NUM_FLD; i++) {
1595 int_fld[i] = strtoul(str_fld[i], &end, 0);
1596 if (errno != 0 || end == str_fld[i] ||
1601 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1602 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1604 if (hash_index >= nb_entries) {
1605 printf("Invalid RETA hash index=%d\n", hash_index);
1609 idx = hash_index / RTE_RETA_GROUP_SIZE;
1610 shift = hash_index % RTE_RETA_GROUP_SIZE;
1611 reta_conf[idx].mask |= (1ULL << shift);
1612 reta_conf[idx].reta[shift] = nb_queue;
1619 cmd_set_rss_reta_parsed(void *parsed_result,
1620 __attribute__((unused)) struct cmdline *cl,
1621 __attribute__((unused)) void *data)
1624 struct rte_eth_dev_info dev_info;
1625 struct rte_eth_rss_reta_entry64 reta_conf[8];
1626 struct cmd_config_rss_reta *res = parsed_result;
1628 memset(&dev_info, 0, sizeof(dev_info));
1629 rte_eth_dev_info_get(res->port_id, &dev_info);
1630 if (dev_info.reta_size == 0) {
1631 printf("Redirection table size is 0 which is "
1632 "invalid for RSS\n");
1635 printf("The reta size of port %d is %u\n",
1636 res->port_id, dev_info.reta_size);
1637 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1638 printf("Currently do not support more than %u entries of "
1639 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1643 memset(reta_conf, 0, sizeof(reta_conf));
1644 if (!strcmp(res->list_name, "reta")) {
1645 if (parse_reta_config(res->list_of_items, reta_conf,
1646 dev_info.reta_size)) {
1647 printf("Invalid RSS Redirection Table "
1648 "config entered\n");
1651 ret = rte_eth_dev_rss_reta_update(res->port_id,
1652 reta_conf, dev_info.reta_size);
1654 printf("Bad redirection table parameter, "
1655 "return code = %d \n", ret);
1659 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1661 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1663 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1664 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1665 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1667 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1669 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1672 cmdline_parse_inst_t cmd_config_rss_reta = {
1673 .f = cmd_set_rss_reta_parsed,
1675 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1677 (void *)&cmd_config_rss_reta_port,
1678 (void *)&cmd_config_rss_reta_keyword,
1679 (void *)&cmd_config_rss_reta_port_id,
1680 (void *)&cmd_config_rss_reta_name,
1681 (void *)&cmd_config_rss_reta_list_name,
1682 (void *)&cmd_config_rss_reta_list_of_items,
1687 /* *** SHOW PORT RETA INFO *** */
1688 struct cmd_showport_reta {
1689 cmdline_fixed_string_t show;
1690 cmdline_fixed_string_t port;
1692 cmdline_fixed_string_t rss;
1693 cmdline_fixed_string_t reta;
1695 cmdline_fixed_string_t list_of_items;
1699 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1700 uint16_t nb_entries,
1704 const char *p, *p0 = str;
1708 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1711 p = strchr(p0, '(');
1715 p0 = strchr(p, ')');
1719 if (size >= sizeof(s)) {
1720 printf("The string size exceeds the internal buffer size\n");
1723 snprintf(s, sizeof(s), "%.*s", size, p);
1724 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1725 if (ret <= 0 || ret != num) {
1726 printf("The bits of masks do not match the number of "
1727 "reta entries: %u\n", num);
1730 for (i = 0; i < ret; i++)
1731 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1737 cmd_showport_reta_parsed(void *parsed_result,
1738 __attribute__((unused)) struct cmdline *cl,
1739 __attribute__((unused)) void *data)
1741 struct cmd_showport_reta *res = parsed_result;
1742 struct rte_eth_rss_reta_entry64 reta_conf[8];
1743 struct rte_eth_dev_info dev_info;
1745 memset(&dev_info, 0, sizeof(dev_info));
1746 rte_eth_dev_info_get(res->port_id, &dev_info);
1747 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1748 res->size > ETH_RSS_RETA_SIZE_512) {
1749 printf("Invalid redirection table size: %u\n", res->size);
1753 memset(reta_conf, 0, sizeof(reta_conf));
1754 if (showport_parse_reta_config(reta_conf, res->size,
1755 res->list_of_items) < 0) {
1756 printf("Invalid string: %s for reta masks\n",
1757 res->list_of_items);
1760 port_rss_reta_info(res->port_id, reta_conf, res->size);
1763 cmdline_parse_token_string_t cmd_showport_reta_show =
1764 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1765 cmdline_parse_token_string_t cmd_showport_reta_port =
1766 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1767 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1768 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1769 cmdline_parse_token_string_t cmd_showport_reta_rss =
1770 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1771 cmdline_parse_token_string_t cmd_showport_reta_reta =
1772 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1773 cmdline_parse_token_num_t cmd_showport_reta_size =
1774 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1775 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1776 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1777 list_of_items, NULL);
1779 cmdline_parse_inst_t cmd_showport_reta = {
1780 .f = cmd_showport_reta_parsed,
1782 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1784 (void *)&cmd_showport_reta_show,
1785 (void *)&cmd_showport_reta_port,
1786 (void *)&cmd_showport_reta_port_id,
1787 (void *)&cmd_showport_reta_rss,
1788 (void *)&cmd_showport_reta_reta,
1789 (void *)&cmd_showport_reta_size,
1790 (void *)&cmd_showport_reta_list_of_items,
1795 /* *** Show RSS hash configuration *** */
1796 struct cmd_showport_rss_hash {
1797 cmdline_fixed_string_t show;
1798 cmdline_fixed_string_t port;
1800 cmdline_fixed_string_t rss_hash;
1801 cmdline_fixed_string_t key; /* optional argument */
1804 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1805 __attribute__((unused)) struct cmdline *cl,
1808 struct cmd_showport_rss_hash *res = parsed_result;
1810 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1813 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1814 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1815 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1816 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1817 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1818 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1819 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1820 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1822 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1823 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1825 cmdline_parse_inst_t cmd_showport_rss_hash = {
1826 .f = cmd_showport_rss_hash_parsed,
1828 .help_str = "show port X rss-hash (X = port number)\n",
1830 (void *)&cmd_showport_rss_hash_show,
1831 (void *)&cmd_showport_rss_hash_port,
1832 (void *)&cmd_showport_rss_hash_port_id,
1833 (void *)&cmd_showport_rss_hash_rss_hash,
1838 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1839 .f = cmd_showport_rss_hash_parsed,
1841 .help_str = "show port X rss-hash key (X = port number)\n",
1843 (void *)&cmd_showport_rss_hash_show,
1844 (void *)&cmd_showport_rss_hash_port,
1845 (void *)&cmd_showport_rss_hash_port_id,
1846 (void *)&cmd_showport_rss_hash_rss_hash,
1847 (void *)&cmd_showport_rss_hash_rss_key,
1852 /* *** Configure DCB *** */
1853 struct cmd_config_dcb {
1854 cmdline_fixed_string_t port;
1855 cmdline_fixed_string_t config;
1857 cmdline_fixed_string_t dcb;
1858 cmdline_fixed_string_t vt;
1859 cmdline_fixed_string_t vt_en;
1861 cmdline_fixed_string_t pfc;
1862 cmdline_fixed_string_t pfc_en;
1866 cmd_config_dcb_parsed(void *parsed_result,
1867 __attribute__((unused)) struct cmdline *cl,
1868 __attribute__((unused)) void *data)
1870 struct cmd_config_dcb *res = parsed_result;
1871 struct dcb_config dcb_conf;
1872 portid_t port_id = res->port_id;
1873 struct rte_port *port;
1875 port = &ports[port_id];
1876 /** Check if the port is not started **/
1877 if (port->port_status != RTE_PORT_STOPPED) {
1878 printf("Please stop port %d first\n",port_id);
1882 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1883 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1884 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1888 /* DCB in VT mode */
1889 if (!strncmp(res->vt_en, "on",2))
1890 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1892 dcb_conf.dcb_mode = DCB_ENABLED;
1894 if (!strncmp(res->pfc_en, "on",2)) {
1895 dcb_conf.pfc_en = 1;
1898 dcb_conf.pfc_en = 0;
1900 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1901 printf("Cannot initialize network ports\n");
1905 cmd_reconfig_device_queue(port_id, 1, 1);
1908 cmdline_parse_token_string_t cmd_config_dcb_port =
1909 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1910 cmdline_parse_token_string_t cmd_config_dcb_config =
1911 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1912 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1913 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1914 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1916 cmdline_parse_token_string_t cmd_config_dcb_vt =
1917 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1918 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1919 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1920 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1921 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1922 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1923 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1924 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1925 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1927 cmdline_parse_inst_t cmd_config_dcb = {
1928 .f = cmd_config_dcb_parsed,
1930 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1932 (void *)&cmd_config_dcb_port,
1933 (void *)&cmd_config_dcb_config,
1934 (void *)&cmd_config_dcb_port_id,
1935 (void *)&cmd_config_dcb_dcb,
1936 (void *)&cmd_config_dcb_vt,
1937 (void *)&cmd_config_dcb_vt_en,
1938 (void *)&cmd_config_dcb_num_tcs,
1939 (void *)&cmd_config_dcb_pfc,
1940 (void *)&cmd_config_dcb_pfc_en,
1945 /* *** configure number of packets per burst *** */
1946 struct cmd_config_burst {
1947 cmdline_fixed_string_t port;
1948 cmdline_fixed_string_t keyword;
1949 cmdline_fixed_string_t all;
1950 cmdline_fixed_string_t name;
1955 cmd_config_burst_parsed(void *parsed_result,
1956 __attribute__((unused)) struct cmdline *cl,
1957 __attribute__((unused)) void *data)
1959 struct cmd_config_burst *res = parsed_result;
1961 if (!all_ports_stopped()) {
1962 printf("Please stop all ports first\n");
1966 if (!strcmp(res->name, "burst")) {
1967 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1968 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1971 nb_pkt_per_burst = res->value;
1973 printf("Unknown parameter\n");
1979 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1982 cmdline_parse_token_string_t cmd_config_burst_port =
1983 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1984 cmdline_parse_token_string_t cmd_config_burst_keyword =
1985 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1986 cmdline_parse_token_string_t cmd_config_burst_all =
1987 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1988 cmdline_parse_token_string_t cmd_config_burst_name =
1989 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1990 cmdline_parse_token_num_t cmd_config_burst_value =
1991 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1993 cmdline_parse_inst_t cmd_config_burst = {
1994 .f = cmd_config_burst_parsed,
1996 .help_str = "port config all burst value",
1998 (void *)&cmd_config_burst_port,
1999 (void *)&cmd_config_burst_keyword,
2000 (void *)&cmd_config_burst_all,
2001 (void *)&cmd_config_burst_name,
2002 (void *)&cmd_config_burst_value,
2007 /* *** configure rx/tx queues *** */
2008 struct cmd_config_thresh {
2009 cmdline_fixed_string_t port;
2010 cmdline_fixed_string_t keyword;
2011 cmdline_fixed_string_t all;
2012 cmdline_fixed_string_t name;
2017 cmd_config_thresh_parsed(void *parsed_result,
2018 __attribute__((unused)) struct cmdline *cl,
2019 __attribute__((unused)) void *data)
2021 struct cmd_config_thresh *res = parsed_result;
2023 if (!all_ports_stopped()) {
2024 printf("Please stop all ports first\n");
2028 if (!strcmp(res->name, "txpt"))
2029 tx_pthresh = res->value;
2030 else if(!strcmp(res->name, "txht"))
2031 tx_hthresh = res->value;
2032 else if(!strcmp(res->name, "txwt"))
2033 tx_wthresh = res->value;
2034 else if(!strcmp(res->name, "rxpt"))
2035 rx_pthresh = res->value;
2036 else if(!strcmp(res->name, "rxht"))
2037 rx_hthresh = res->value;
2038 else if(!strcmp(res->name, "rxwt"))
2039 rx_wthresh = res->value;
2041 printf("Unknown parameter\n");
2047 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2050 cmdline_parse_token_string_t cmd_config_thresh_port =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2052 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2054 cmdline_parse_token_string_t cmd_config_thresh_all =
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2056 cmdline_parse_token_string_t cmd_config_thresh_name =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2058 "txpt#txht#txwt#rxpt#rxht#rxwt");
2059 cmdline_parse_token_num_t cmd_config_thresh_value =
2060 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2062 cmdline_parse_inst_t cmd_config_thresh = {
2063 .f = cmd_config_thresh_parsed,
2065 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2067 (void *)&cmd_config_thresh_port,
2068 (void *)&cmd_config_thresh_keyword,
2069 (void *)&cmd_config_thresh_all,
2070 (void *)&cmd_config_thresh_name,
2071 (void *)&cmd_config_thresh_value,
2076 /* *** configure free/rs threshold *** */
2077 struct cmd_config_threshold {
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_threshold_parsed(void *parsed_result,
2087 __attribute__((unused)) struct cmdline *cl,
2088 __attribute__((unused)) void *data)
2090 struct cmd_config_threshold *res = parsed_result;
2092 if (!all_ports_stopped()) {
2093 printf("Please stop all ports first\n");
2097 if (!strcmp(res->name, "txfreet"))
2098 tx_free_thresh = res->value;
2099 else if (!strcmp(res->name, "txrst"))
2100 tx_rs_thresh = res->value;
2101 else if (!strcmp(res->name, "rxfreet"))
2102 rx_free_thresh = 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_threshold_port =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2115 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2116 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2118 cmdline_parse_token_string_t cmd_config_threshold_all =
2119 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2120 cmdline_parse_token_string_t cmd_config_threshold_name =
2121 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2122 "txfreet#txrst#rxfreet");
2123 cmdline_parse_token_num_t cmd_config_threshold_value =
2124 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2126 cmdline_parse_inst_t cmd_config_threshold = {
2127 .f = cmd_config_threshold_parsed,
2129 .help_str = "port config all txfreet|txrst|rxfreet value",
2131 (void *)&cmd_config_threshold_port,
2132 (void *)&cmd_config_threshold_keyword,
2133 (void *)&cmd_config_threshold_all,
2134 (void *)&cmd_config_threshold_name,
2135 (void *)&cmd_config_threshold_value,
2141 struct cmd_stop_result {
2142 cmdline_fixed_string_t stop;
2145 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2146 __attribute__((unused)) struct cmdline *cl,
2147 __attribute__((unused)) void *data)
2149 stop_packet_forwarding();
2152 cmdline_parse_token_string_t cmd_stop_stop =
2153 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2155 cmdline_parse_inst_t cmd_stop = {
2156 .f = cmd_stop_parsed,
2158 .help_str = "stop - stop packet forwarding",
2160 (void *)&cmd_stop_stop,
2165 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2168 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2169 unsigned int *parsed_items, int check_unique_values)
2171 unsigned int nb_item;
2179 * First parse all items in the list and store their value.
2184 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2186 if ((c >= '0') && (c <= '9')) {
2187 value = (unsigned int) (value * 10 + (c - '0'));
2192 printf("character %c is not a decimal digit\n", c);
2196 printf("No valid value before comma\n");
2199 if (nb_item < max_items) {
2200 parsed_items[nb_item] = value;
2206 if (nb_item >= max_items) {
2207 printf("Number of %s = %u > %u (maximum items)\n",
2208 item_name, nb_item + 1, max_items);
2211 parsed_items[nb_item++] = value;
2212 if (! check_unique_values)
2216 * Then, check that all values in the list are differents.
2217 * No optimization here...
2219 for (i = 0; i < nb_item; i++) {
2220 for (j = i + 1; j < nb_item; j++) {
2221 if (parsed_items[j] == parsed_items[i]) {
2222 printf("duplicated %s %u at index %u and %u\n",
2223 item_name, parsed_items[i], i, j);
2231 struct cmd_set_list_result {
2232 cmdline_fixed_string_t cmd_keyword;
2233 cmdline_fixed_string_t list_name;
2234 cmdline_fixed_string_t list_of_items;
2237 static void cmd_set_list_parsed(void *parsed_result,
2238 __attribute__((unused)) struct cmdline *cl,
2239 __attribute__((unused)) void *data)
2241 struct cmd_set_list_result *res;
2243 unsigned int lcorelist[RTE_MAX_LCORE];
2244 unsigned int portlist[RTE_MAX_ETHPORTS];
2246 unsigned int nb_item;
2248 if (test_done == 0) {
2249 printf("Please stop forwarding first\n");
2253 res = parsed_result;
2254 if (!strcmp(res->list_name, "corelist")) {
2255 nb_item = parse_item_list(res->list_of_items, "core",
2257 parsed_items.lcorelist, 1);
2259 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2262 if (!strcmp(res->list_name, "portlist")) {
2263 nb_item = parse_item_list(res->list_of_items, "port",
2265 parsed_items.portlist, 1);
2267 set_fwd_ports_list(parsed_items.portlist, nb_item);
2271 cmdline_parse_token_string_t cmd_set_list_keyword =
2272 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2274 cmdline_parse_token_string_t cmd_set_list_name =
2275 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2276 "corelist#portlist");
2277 cmdline_parse_token_string_t cmd_set_list_of_items =
2278 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2281 cmdline_parse_inst_t cmd_set_fwd_list = {
2282 .f = cmd_set_list_parsed,
2284 .help_str = "set corelist|portlist x[,y]*",
2286 (void *)&cmd_set_list_keyword,
2287 (void *)&cmd_set_list_name,
2288 (void *)&cmd_set_list_of_items,
2293 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2295 struct cmd_setmask_result {
2296 cmdline_fixed_string_t set;
2297 cmdline_fixed_string_t mask;
2301 static void cmd_set_mask_parsed(void *parsed_result,
2302 __attribute__((unused)) struct cmdline *cl,
2303 __attribute__((unused)) void *data)
2305 struct cmd_setmask_result *res = parsed_result;
2307 if (test_done == 0) {
2308 printf("Please stop forwarding first\n");
2311 if (!strcmp(res->mask, "coremask"))
2312 set_fwd_lcores_mask(res->hexavalue);
2313 else if (!strcmp(res->mask, "portmask"))
2314 set_fwd_ports_mask(res->hexavalue);
2317 cmdline_parse_token_string_t cmd_setmask_set =
2318 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2319 cmdline_parse_token_string_t cmd_setmask_mask =
2320 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2321 "coremask#portmask");
2322 cmdline_parse_token_num_t cmd_setmask_value =
2323 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2325 cmdline_parse_inst_t cmd_set_fwd_mask = {
2326 .f = cmd_set_mask_parsed,
2328 .help_str = "set coremask|portmask hexadecimal value",
2330 (void *)&cmd_setmask_set,
2331 (void *)&cmd_setmask_mask,
2332 (void *)&cmd_setmask_value,
2338 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2340 struct cmd_set_result {
2341 cmdline_fixed_string_t set;
2342 cmdline_fixed_string_t what;
2346 static void cmd_set_parsed(void *parsed_result,
2347 __attribute__((unused)) struct cmdline *cl,
2348 __attribute__((unused)) void *data)
2350 struct cmd_set_result *res = parsed_result;
2351 if (!strcmp(res->what, "nbport"))
2352 set_fwd_ports_number(res->value);
2353 else if (!strcmp(res->what, "nbcore"))
2354 set_fwd_lcores_number(res->value);
2355 else if (!strcmp(res->what, "burst"))
2356 set_nb_pkt_per_burst(res->value);
2357 else if (!strcmp(res->what, "verbose"))
2358 set_verbose_level(res->value);
2361 cmdline_parse_token_string_t cmd_set_set =
2362 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2363 cmdline_parse_token_string_t cmd_set_what =
2364 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2365 "nbport#nbcore#burst#verbose");
2366 cmdline_parse_token_num_t cmd_set_value =
2367 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2369 cmdline_parse_inst_t cmd_set_numbers = {
2370 .f = cmd_set_parsed,
2372 .help_str = "set nbport|nbcore|burst|verbose value",
2374 (void *)&cmd_set_set,
2375 (void *)&cmd_set_what,
2376 (void *)&cmd_set_value,
2381 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2383 struct cmd_set_txpkts_result {
2384 cmdline_fixed_string_t cmd_keyword;
2385 cmdline_fixed_string_t txpkts;
2386 cmdline_fixed_string_t seg_lengths;
2390 cmd_set_txpkts_parsed(void *parsed_result,
2391 __attribute__((unused)) struct cmdline *cl,
2392 __attribute__((unused)) void *data)
2394 struct cmd_set_txpkts_result *res;
2395 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2396 unsigned int nb_segs;
2398 res = parsed_result;
2399 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2400 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2402 set_tx_pkt_segments(seg_lengths, nb_segs);
2405 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2406 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2407 cmd_keyword, "set");
2408 cmdline_parse_token_string_t cmd_set_txpkts_name =
2409 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2411 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2412 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2415 cmdline_parse_inst_t cmd_set_txpkts = {
2416 .f = cmd_set_txpkts_parsed,
2418 .help_str = "set txpkts x[,y]*",
2420 (void *)&cmd_set_txpkts_keyword,
2421 (void *)&cmd_set_txpkts_name,
2422 (void *)&cmd_set_txpkts_lengths,
2427 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2428 struct cmd_rx_vlan_filter_all_result {
2429 cmdline_fixed_string_t rx_vlan;
2430 cmdline_fixed_string_t what;
2431 cmdline_fixed_string_t all;
2436 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2437 __attribute__((unused)) struct cmdline *cl,
2438 __attribute__((unused)) void *data)
2440 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2442 if (!strcmp(res->what, "add"))
2443 rx_vlan_all_filter_set(res->port_id, 1);
2445 rx_vlan_all_filter_set(res->port_id, 0);
2448 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2449 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2450 rx_vlan, "rx_vlan");
2451 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2452 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2454 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2455 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2457 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2458 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2461 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2462 .f = cmd_rx_vlan_filter_all_parsed,
2464 .help_str = "add/remove all identifiers to/from the set of VLAN "
2465 "Identifiers filtered by a port",
2467 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2468 (void *)&cmd_rx_vlan_filter_all_what,
2469 (void *)&cmd_rx_vlan_filter_all_all,
2470 (void *)&cmd_rx_vlan_filter_all_portid,
2475 /* *** VLAN OFFLOAD SET ON A PORT *** */
2476 struct cmd_vlan_offload_result {
2477 cmdline_fixed_string_t vlan;
2478 cmdline_fixed_string_t set;
2479 cmdline_fixed_string_t what;
2480 cmdline_fixed_string_t on;
2481 cmdline_fixed_string_t port_id;
2485 cmd_vlan_offload_parsed(void *parsed_result,
2486 __attribute__((unused)) struct cmdline *cl,
2487 __attribute__((unused)) void *data)
2490 struct cmd_vlan_offload_result *res = parsed_result;
2493 portid_t port_id = 0;
2497 len = strnlen(str, STR_TOKEN_SIZE);
2499 /* Get port_id first */
2507 tmp = strtoul(str, NULL, 0);
2508 /* If port_id greater that what portid_t can represent, return */
2509 if(tmp >= RTE_MAX_ETHPORTS)
2511 port_id = (portid_t)tmp;
2513 if (!strcmp(res->on, "on"))
2518 if (!strcmp(res->what, "strip"))
2519 rx_vlan_strip_set(port_id, on);
2520 else if(!strcmp(res->what, "stripq")){
2521 uint16_t queue_id = 0;
2523 /* No queue_id, return */
2525 printf("must specify (port,queue_id)\n");
2528 tmp = strtoul(str + i + 1, NULL, 0);
2529 /* If queue_id greater that what 16-bits can represent, return */
2533 queue_id = (uint16_t)tmp;
2534 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2536 else if (!strcmp(res->what, "filter"))
2537 rx_vlan_filter_set(port_id, on);
2539 vlan_extend_set(port_id, on);
2544 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2545 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2547 cmdline_parse_token_string_t cmd_vlan_offload_set =
2548 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2550 cmdline_parse_token_string_t cmd_vlan_offload_what =
2551 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2552 what, "strip#filter#qinq#stripq");
2553 cmdline_parse_token_string_t cmd_vlan_offload_on =
2554 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2556 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2557 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2560 cmdline_parse_inst_t cmd_vlan_offload = {
2561 .f = cmd_vlan_offload_parsed,
2563 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2564 " qinq(extended) for both rx/tx sides ",
2566 (void *)&cmd_vlan_offload_vlan,
2567 (void *)&cmd_vlan_offload_set,
2568 (void *)&cmd_vlan_offload_what,
2569 (void *)&cmd_vlan_offload_on,
2570 (void *)&cmd_vlan_offload_portid,
2575 /* *** VLAN TPID SET ON A PORT *** */
2576 struct cmd_vlan_tpid_result {
2577 cmdline_fixed_string_t vlan;
2578 cmdline_fixed_string_t set;
2579 cmdline_fixed_string_t what;
2585 cmd_vlan_tpid_parsed(void *parsed_result,
2586 __attribute__((unused)) struct cmdline *cl,
2587 __attribute__((unused)) void *data)
2589 struct cmd_vlan_tpid_result *res = parsed_result;
2590 vlan_tpid_set(res->port_id, res->tp_id);
2594 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2595 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2597 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2598 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2600 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2601 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2603 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2604 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2606 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2607 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2610 cmdline_parse_inst_t cmd_vlan_tpid = {
2611 .f = cmd_vlan_tpid_parsed,
2613 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2615 (void *)&cmd_vlan_tpid_vlan,
2616 (void *)&cmd_vlan_tpid_set,
2617 (void *)&cmd_vlan_tpid_what,
2618 (void *)&cmd_vlan_tpid_tpid,
2619 (void *)&cmd_vlan_tpid_portid,
2624 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2625 struct cmd_rx_vlan_filter_result {
2626 cmdline_fixed_string_t rx_vlan;
2627 cmdline_fixed_string_t what;
2633 cmd_rx_vlan_filter_parsed(void *parsed_result,
2634 __attribute__((unused)) struct cmdline *cl,
2635 __attribute__((unused)) void *data)
2637 struct cmd_rx_vlan_filter_result *res = parsed_result;
2639 if (!strcmp(res->what, "add"))
2640 rx_vft_set(res->port_id, res->vlan_id, 1);
2642 rx_vft_set(res->port_id, res->vlan_id, 0);
2645 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2646 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2647 rx_vlan, "rx_vlan");
2648 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2649 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2651 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2652 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2654 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2655 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2658 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2659 .f = cmd_rx_vlan_filter_parsed,
2661 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2662 "Identifiers filtered by a port",
2664 (void *)&cmd_rx_vlan_filter_rx_vlan,
2665 (void *)&cmd_rx_vlan_filter_what,
2666 (void *)&cmd_rx_vlan_filter_vlanid,
2667 (void *)&cmd_rx_vlan_filter_portid,
2672 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2673 struct cmd_tx_vlan_set_result {
2674 cmdline_fixed_string_t tx_vlan;
2675 cmdline_fixed_string_t set;
2681 cmd_tx_vlan_set_parsed(void *parsed_result,
2682 __attribute__((unused)) struct cmdline *cl,
2683 __attribute__((unused)) void *data)
2685 struct cmd_tx_vlan_set_result *res = parsed_result;
2686 tx_vlan_set(res->port_id, res->vlan_id);
2689 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2690 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2691 tx_vlan, "tx_vlan");
2692 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2693 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2695 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2696 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2698 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2699 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2702 cmdline_parse_inst_t cmd_tx_vlan_set = {
2703 .f = cmd_tx_vlan_set_parsed,
2705 .help_str = "enable hardware insertion of a VLAN header with a given "
2706 "TAG Identifier in packets sent on a port",
2708 (void *)&cmd_tx_vlan_set_tx_vlan,
2709 (void *)&cmd_tx_vlan_set_set,
2710 (void *)&cmd_tx_vlan_set_vlanid,
2711 (void *)&cmd_tx_vlan_set_portid,
2716 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2717 struct cmd_tx_vlan_set_pvid_result {
2718 cmdline_fixed_string_t tx_vlan;
2719 cmdline_fixed_string_t set;
2720 cmdline_fixed_string_t pvid;
2723 cmdline_fixed_string_t mode;
2727 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2728 __attribute__((unused)) struct cmdline *cl,
2729 __attribute__((unused)) void *data)
2731 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2733 if (strcmp(res->mode, "on") == 0)
2734 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2736 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2739 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2740 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2741 tx_vlan, "tx_vlan");
2742 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2743 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2745 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2746 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2748 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2749 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2751 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2752 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2754 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2755 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2758 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2759 .f = cmd_tx_vlan_set_pvid_parsed,
2761 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2763 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2764 (void *)&cmd_tx_vlan_set_pvid_set,
2765 (void *)&cmd_tx_vlan_set_pvid_pvid,
2766 (void *)&cmd_tx_vlan_set_pvid_port_id,
2767 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2768 (void *)&cmd_tx_vlan_set_pvid_mode,
2773 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2774 struct cmd_tx_vlan_reset_result {
2775 cmdline_fixed_string_t tx_vlan;
2776 cmdline_fixed_string_t reset;
2781 cmd_tx_vlan_reset_parsed(void *parsed_result,
2782 __attribute__((unused)) struct cmdline *cl,
2783 __attribute__((unused)) void *data)
2785 struct cmd_tx_vlan_reset_result *res = parsed_result;
2787 tx_vlan_reset(res->port_id);
2790 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2791 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2792 tx_vlan, "tx_vlan");
2793 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2794 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2796 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2797 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2800 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2801 .f = cmd_tx_vlan_reset_parsed,
2803 .help_str = "disable hardware insertion of a VLAN header in packets "
2806 (void *)&cmd_tx_vlan_reset_tx_vlan,
2807 (void *)&cmd_tx_vlan_reset_reset,
2808 (void *)&cmd_tx_vlan_reset_portid,
2814 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2815 struct cmd_csum_result {
2816 cmdline_fixed_string_t csum;
2817 cmdline_fixed_string_t mode;
2818 cmdline_fixed_string_t proto;
2819 cmdline_fixed_string_t hwsw;
2824 csum_show(int port_id)
2826 struct rte_eth_dev_info dev_info;
2829 ol_flags = ports[port_id].tx_ol_flags;
2830 printf("Parse tunnel is %s\n",
2831 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
2832 printf("IP checksum offload is %s\n",
2833 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2834 printf("UDP checksum offload is %s\n",
2835 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2836 printf("TCP checksum offload is %s\n",
2837 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2838 printf("SCTP checksum offload is %s\n",
2839 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2840 printf("Outer-Ip checksum offload is %s\n",
2841 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
2843 /* display warnings if configuration is not supported by the NIC */
2844 rte_eth_dev_info_get(port_id, &dev_info);
2845 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2846 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2847 printf("Warning: hardware IP checksum enabled but not "
2848 "supported by port %d\n", port_id);
2850 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2851 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2852 printf("Warning: hardware UDP checksum enabled but not "
2853 "supported by port %d\n", port_id);
2855 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2856 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2857 printf("Warning: hardware TCP checksum enabled but not "
2858 "supported by port %d\n", port_id);
2860 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2861 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2862 printf("Warning: hardware SCTP checksum enabled but not "
2863 "supported by port %d\n", port_id);
2865 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
2866 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
2867 printf("Warning: hardware outer IP checksum enabled but not "
2868 "supported by port %d\n", port_id);
2873 cmd_csum_parsed(void *parsed_result,
2874 __attribute__((unused)) struct cmdline *cl,
2875 __attribute__((unused)) void *data)
2877 struct cmd_csum_result *res = parsed_result;
2881 if (port_id_is_invalid(res->port_id)) {
2882 printf("invalid port %d\n", res->port_id);
2886 if (!strcmp(res->mode, "set")) {
2888 if (!strcmp(res->hwsw, "hw"))
2891 if (!strcmp(res->proto, "ip")) {
2892 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2893 } else if (!strcmp(res->proto, "udp")) {
2894 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2895 } else if (!strcmp(res->proto, "tcp")) {
2896 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2897 } else if (!strcmp(res->proto, "sctp")) {
2898 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2899 } else if (!strcmp(res->proto, "outer-ip")) {
2900 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
2904 ports[res->port_id].tx_ol_flags |= mask;
2906 ports[res->port_id].tx_ol_flags &= (~mask);
2908 csum_show(res->port_id);
2911 cmdline_parse_token_string_t cmd_csum_csum =
2912 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2914 cmdline_parse_token_string_t cmd_csum_mode =
2915 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2917 cmdline_parse_token_string_t cmd_csum_proto =
2918 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2919 proto, "ip#tcp#udp#sctp#outer-ip");
2920 cmdline_parse_token_string_t cmd_csum_hwsw =
2921 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2923 cmdline_parse_token_num_t cmd_csum_portid =
2924 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
2927 cmdline_parse_inst_t cmd_csum_set = {
2928 .f = cmd_csum_parsed,
2930 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2931 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
2933 (void *)&cmd_csum_csum,
2934 (void *)&cmd_csum_mode,
2935 (void *)&cmd_csum_proto,
2936 (void *)&cmd_csum_hwsw,
2937 (void *)&cmd_csum_portid,
2942 cmdline_parse_token_string_t cmd_csum_mode_show =
2943 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2946 cmdline_parse_inst_t cmd_csum_show = {
2947 .f = cmd_csum_parsed,
2949 .help_str = "show checksum offload configuration: csum show <port>",
2951 (void *)&cmd_csum_csum,
2952 (void *)&cmd_csum_mode_show,
2953 (void *)&cmd_csum_portid,
2958 /* Enable/disable tunnel parsing */
2959 struct cmd_csum_tunnel_result {
2960 cmdline_fixed_string_t csum;
2961 cmdline_fixed_string_t parse;
2962 cmdline_fixed_string_t onoff;
2967 cmd_csum_tunnel_parsed(void *parsed_result,
2968 __attribute__((unused)) struct cmdline *cl,
2969 __attribute__((unused)) void *data)
2971 struct cmd_csum_tunnel_result *res = parsed_result;
2973 if (port_id_is_invalid(res->port_id)) {
2974 printf("invalid port %d\n", res->port_id);
2978 if (!strcmp(res->onoff, "on"))
2979 ports[res->port_id].tx_ol_flags |=
2980 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
2982 ports[res->port_id].tx_ol_flags &=
2983 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
2985 csum_show(res->port_id);
2988 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
2989 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
2991 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
2992 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
2993 parse, "parse_tunnel");
2994 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
2995 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
2997 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
2998 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3001 cmdline_parse_inst_t cmd_csum_tunnel = {
3002 .f = cmd_csum_tunnel_parsed,
3004 .help_str = "enable/disable parsing of tunnels for csum engine: "
3005 "csum parse_tunnel on|off <tx-port>",
3007 (void *)&cmd_csum_tunnel_csum,
3008 (void *)&cmd_csum_tunnel_parse,
3009 (void *)&cmd_csum_tunnel_onoff,
3010 (void *)&cmd_csum_tunnel_portid,
3015 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3016 struct cmd_tso_set_result {
3017 cmdline_fixed_string_t tso;
3018 cmdline_fixed_string_t mode;
3024 cmd_tso_set_parsed(void *parsed_result,
3025 __attribute__((unused)) struct cmdline *cl,
3026 __attribute__((unused)) void *data)
3028 struct cmd_tso_set_result *res = parsed_result;
3029 struct rte_eth_dev_info dev_info;
3031 if (port_id_is_invalid(res->port_id))
3034 if (!strcmp(res->mode, "set"))
3035 ports[res->port_id].tso_segsz = res->tso_segsz;
3037 if (ports[res->port_id].tso_segsz == 0)
3038 printf("TSO is disabled\n");
3040 printf("TSO segment size is %d\n",
3041 ports[res->port_id].tso_segsz);
3043 /* display warnings if configuration is not supported by the NIC */
3044 rte_eth_dev_info_get(res->port_id, &dev_info);
3045 if ((ports[res->port_id].tso_segsz != 0) &&
3046 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3047 printf("Warning: TSO enabled but not "
3048 "supported by port %d\n", res->port_id);
3052 cmdline_parse_token_string_t cmd_tso_set_tso =
3053 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3055 cmdline_parse_token_string_t cmd_tso_set_mode =
3056 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3058 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3059 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3061 cmdline_parse_token_num_t cmd_tso_set_portid =
3062 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3065 cmdline_parse_inst_t cmd_tso_set = {
3066 .f = cmd_tso_set_parsed,
3068 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3069 "tso set <tso_segsz> <port>",
3071 (void *)&cmd_tso_set_tso,
3072 (void *)&cmd_tso_set_mode,
3073 (void *)&cmd_tso_set_tso_segsz,
3074 (void *)&cmd_tso_set_portid,
3079 cmdline_parse_token_string_t cmd_tso_show_mode =
3080 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3084 cmdline_parse_inst_t cmd_tso_show = {
3085 .f = cmd_tso_set_parsed,
3087 .help_str = "Show TSO segment size for csum engine: "
3090 (void *)&cmd_tso_set_tso,
3091 (void *)&cmd_tso_show_mode,
3092 (void *)&cmd_tso_set_portid,
3097 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3098 struct cmd_set_flush_rx {
3099 cmdline_fixed_string_t set;
3100 cmdline_fixed_string_t flush_rx;
3101 cmdline_fixed_string_t mode;
3105 cmd_set_flush_rx_parsed(void *parsed_result,
3106 __attribute__((unused)) struct cmdline *cl,
3107 __attribute__((unused)) void *data)
3109 struct cmd_set_flush_rx *res = parsed_result;
3110 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3113 cmdline_parse_token_string_t cmd_setflushrx_set =
3114 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3116 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3117 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3118 flush_rx, "flush_rx");
3119 cmdline_parse_token_string_t cmd_setflushrx_mode =
3120 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3124 cmdline_parse_inst_t cmd_set_flush_rx = {
3125 .f = cmd_set_flush_rx_parsed,
3126 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3129 (void *)&cmd_setflushrx_set,
3130 (void *)&cmd_setflushrx_flush_rx,
3131 (void *)&cmd_setflushrx_mode,
3136 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3137 struct cmd_set_link_check {
3138 cmdline_fixed_string_t set;
3139 cmdline_fixed_string_t link_check;
3140 cmdline_fixed_string_t mode;
3144 cmd_set_link_check_parsed(void *parsed_result,
3145 __attribute__((unused)) struct cmdline *cl,
3146 __attribute__((unused)) void *data)
3148 struct cmd_set_link_check *res = parsed_result;
3149 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3152 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3153 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3155 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3156 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3157 link_check, "link_check");
3158 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3159 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3163 cmdline_parse_inst_t cmd_set_link_check = {
3164 .f = cmd_set_link_check_parsed,
3165 .help_str = "set link_check on|off: enable/disable link status check "
3166 "when starting/stopping a port",
3169 (void *)&cmd_setlinkcheck_set,
3170 (void *)&cmd_setlinkcheck_link_check,
3171 (void *)&cmd_setlinkcheck_mode,
3176 #ifdef RTE_NIC_BYPASS
3177 /* *** SET NIC BYPASS MODE *** */
3178 struct cmd_set_bypass_mode_result {
3179 cmdline_fixed_string_t set;
3180 cmdline_fixed_string_t bypass;
3181 cmdline_fixed_string_t mode;
3182 cmdline_fixed_string_t value;
3187 cmd_set_bypass_mode_parsed(void *parsed_result,
3188 __attribute__((unused)) struct cmdline *cl,
3189 __attribute__((unused)) void *data)
3191 struct cmd_set_bypass_mode_result *res = parsed_result;
3192 portid_t port_id = res->port_id;
3193 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3195 if (!bypass_is_supported(port_id))
3198 if (!strcmp(res->value, "bypass"))
3199 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3200 else if (!strcmp(res->value, "isolate"))
3201 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3203 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3205 /* Set the bypass mode for the relevant port. */
3206 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3207 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3211 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3212 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3214 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3215 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3217 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3218 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3220 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3221 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3222 value, "normal#bypass#isolate");
3223 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3224 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3227 cmdline_parse_inst_t cmd_set_bypass_mode = {
3228 .f = cmd_set_bypass_mode_parsed,
3229 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3230 "Set the NIC bypass mode for port_id",
3233 (void *)&cmd_setbypass_mode_set,
3234 (void *)&cmd_setbypass_mode_bypass,
3235 (void *)&cmd_setbypass_mode_mode,
3236 (void *)&cmd_setbypass_mode_value,
3237 (void *)&cmd_setbypass_mode_port,
3242 /* *** SET NIC BYPASS EVENT *** */
3243 struct cmd_set_bypass_event_result {
3244 cmdline_fixed_string_t set;
3245 cmdline_fixed_string_t bypass;
3246 cmdline_fixed_string_t event;
3247 cmdline_fixed_string_t event_value;
3248 cmdline_fixed_string_t mode;
3249 cmdline_fixed_string_t mode_value;
3254 cmd_set_bypass_event_parsed(void *parsed_result,
3255 __attribute__((unused)) struct cmdline *cl,
3256 __attribute__((unused)) void *data)
3259 struct cmd_set_bypass_event_result *res = parsed_result;
3260 portid_t port_id = res->port_id;
3261 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3262 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3264 if (!bypass_is_supported(port_id))
3267 if (!strcmp(res->event_value, "timeout"))
3268 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3269 else if (!strcmp(res->event_value, "os_on"))
3270 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3271 else if (!strcmp(res->event_value, "os_off"))
3272 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3273 else if (!strcmp(res->event_value, "power_on"))
3274 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3275 else if (!strcmp(res->event_value, "power_off"))
3276 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3278 bypass_event = RTE_BYPASS_EVENT_NONE;
3280 if (!strcmp(res->mode_value, "bypass"))
3281 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3282 else if (!strcmp(res->mode_value, "isolate"))
3283 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3285 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3287 /* Set the watchdog timeout. */
3288 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3291 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3292 (rc = rte_eth_dev_wd_timeout_store(port_id,
3293 bypass_timeout)) != 0) {
3294 printf("Failed to set timeout value %u "
3295 "for port %d, errto code: %d.\n",
3296 bypass_timeout, port_id, rc);
3300 /* Set the bypass event to transition to bypass mode. */
3301 if (0 != rte_eth_dev_bypass_event_store(port_id,
3302 bypass_event, bypass_mode)) {
3303 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3308 cmdline_parse_token_string_t cmd_setbypass_event_set =
3309 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3311 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3312 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3314 cmdline_parse_token_string_t cmd_setbypass_event_event =
3315 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3317 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3318 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3319 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3320 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3321 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3323 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3324 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3325 mode_value, "normal#bypass#isolate");
3326 cmdline_parse_token_num_t cmd_setbypass_event_port =
3327 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3330 cmdline_parse_inst_t cmd_set_bypass_event = {
3331 .f = cmd_set_bypass_event_parsed,
3332 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3333 "mode (normal|bypass|isolate) (port_id): "
3334 "Set the NIC bypass event mode for port_id",
3337 (void *)&cmd_setbypass_event_set,
3338 (void *)&cmd_setbypass_event_bypass,
3339 (void *)&cmd_setbypass_event_event,
3340 (void *)&cmd_setbypass_event_event_value,
3341 (void *)&cmd_setbypass_event_mode,
3342 (void *)&cmd_setbypass_event_mode_value,
3343 (void *)&cmd_setbypass_event_port,
3349 /* *** SET NIC BYPASS TIMEOUT *** */
3350 struct cmd_set_bypass_timeout_result {
3351 cmdline_fixed_string_t set;
3352 cmdline_fixed_string_t bypass;
3353 cmdline_fixed_string_t timeout;
3354 cmdline_fixed_string_t value;
3358 cmd_set_bypass_timeout_parsed(void *parsed_result,
3359 __attribute__((unused)) struct cmdline *cl,
3360 __attribute__((unused)) void *data)
3362 struct cmd_set_bypass_timeout_result *res = parsed_result;
3364 if (!strcmp(res->value, "1.5"))
3365 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3366 else if (!strcmp(res->value, "2"))
3367 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3368 else if (!strcmp(res->value, "3"))
3369 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3370 else if (!strcmp(res->value, "4"))
3371 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3372 else if (!strcmp(res->value, "8"))
3373 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3374 else if (!strcmp(res->value, "16"))
3375 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3376 else if (!strcmp(res->value, "32"))
3377 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3379 bypass_timeout = RTE_BYPASS_TMT_OFF;
3382 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3383 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3385 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3386 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3388 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3389 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3390 timeout, "timeout");
3391 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3392 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3393 value, "0#1.5#2#3#4#8#16#32");
3395 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3396 .f = cmd_set_bypass_timeout_parsed,
3397 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3398 "Set the NIC bypass watchdog timeout",
3401 (void *)&cmd_setbypass_timeout_set,
3402 (void *)&cmd_setbypass_timeout_bypass,
3403 (void *)&cmd_setbypass_timeout_timeout,
3404 (void *)&cmd_setbypass_timeout_value,
3409 /* *** SHOW NIC BYPASS MODE *** */
3410 struct cmd_show_bypass_config_result {
3411 cmdline_fixed_string_t show;
3412 cmdline_fixed_string_t bypass;
3413 cmdline_fixed_string_t config;
3418 cmd_show_bypass_config_parsed(void *parsed_result,
3419 __attribute__((unused)) struct cmdline *cl,
3420 __attribute__((unused)) void *data)
3422 struct cmd_show_bypass_config_result *res = parsed_result;
3423 uint32_t event_mode;
3424 uint32_t bypass_mode;
3425 portid_t port_id = res->port_id;
3426 uint32_t timeout = bypass_timeout;
3429 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3430 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3431 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3432 {"UNKNOWN", "normal", "bypass", "isolate"};
3433 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3440 int num_events = (sizeof events) / (sizeof events[0]);
3442 if (!bypass_is_supported(port_id))
3445 /* Display the bypass mode.*/
3446 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3447 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3451 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3452 bypass_mode = RTE_BYPASS_MODE_NONE;
3454 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3457 /* Display the bypass timeout.*/
3458 if (!RTE_BYPASS_TMT_VALID(timeout))
3459 timeout = RTE_BYPASS_TMT_OFF;
3461 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3463 /* Display the bypass events and associated modes. */
3464 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3466 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3467 printf("\tFailed to get bypass mode for event = %s\n",
3470 if (!RTE_BYPASS_MODE_VALID(event_mode))
3471 event_mode = RTE_BYPASS_MODE_NONE;
3473 printf("\tbypass event: %-16s = %s\n", events[i],
3479 cmdline_parse_token_string_t cmd_showbypass_config_show =
3480 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3482 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3483 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3485 cmdline_parse_token_string_t cmd_showbypass_config_config =
3486 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3488 cmdline_parse_token_num_t cmd_showbypass_config_port =
3489 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3492 cmdline_parse_inst_t cmd_show_bypass_config = {
3493 .f = cmd_show_bypass_config_parsed,
3494 .help_str = "show bypass config (port_id): "
3495 "Show the NIC bypass config for port_id",
3498 (void *)&cmd_showbypass_config_show,
3499 (void *)&cmd_showbypass_config_bypass,
3500 (void *)&cmd_showbypass_config_config,
3501 (void *)&cmd_showbypass_config_port,
3507 #ifdef RTE_LIBRTE_PMD_BOND
3508 /* *** SET BONDING MODE *** */
3509 struct cmd_set_bonding_mode_result {
3510 cmdline_fixed_string_t set;
3511 cmdline_fixed_string_t bonding;
3512 cmdline_fixed_string_t mode;
3517 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3518 __attribute__((unused)) struct cmdline *cl,
3519 __attribute__((unused)) void *data)
3521 struct cmd_set_bonding_mode_result *res = parsed_result;
3522 portid_t port_id = res->port_id;
3524 /* Set the bonding mode for the relevant port. */
3525 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3526 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3529 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3530 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3532 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3533 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3534 bonding, "bonding");
3535 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3536 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3538 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3539 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3541 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3542 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3545 cmdline_parse_inst_t cmd_set_bonding_mode = {
3546 .f = cmd_set_bonding_mode_parsed,
3547 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3550 (void *) &cmd_setbonding_mode_set,
3551 (void *) &cmd_setbonding_mode_bonding,
3552 (void *) &cmd_setbonding_mode_mode,
3553 (void *) &cmd_setbonding_mode_value,
3554 (void *) &cmd_setbonding_mode_port,
3559 /* *** SET BALANCE XMIT POLICY *** */
3560 struct cmd_set_bonding_balance_xmit_policy_result {
3561 cmdline_fixed_string_t set;
3562 cmdline_fixed_string_t bonding;
3563 cmdline_fixed_string_t balance_xmit_policy;
3565 cmdline_fixed_string_t policy;
3568 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3569 __attribute__((unused)) struct cmdline *cl,
3570 __attribute__((unused)) void *data)
3572 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3573 portid_t port_id = res->port_id;
3576 if (!strcmp(res->policy, "l2")) {
3577 policy = BALANCE_XMIT_POLICY_LAYER2;
3578 } else if (!strcmp(res->policy, "l23")) {
3579 policy = BALANCE_XMIT_POLICY_LAYER23;
3580 } else if (!strcmp(res->policy, "l34")) {
3581 policy = BALANCE_XMIT_POLICY_LAYER34;
3583 printf("\t Invalid xmit policy selection");
3587 /* Set the bonding mode for the relevant port. */
3588 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3589 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3594 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3595 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3597 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3598 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3599 bonding, "bonding");
3600 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3601 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3602 balance_xmit_policy, "balance_xmit_policy");
3603 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3604 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3606 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3607 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3608 policy, "l2#l23#l34");
3610 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3611 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3612 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3615 (void *)&cmd_setbonding_balance_xmit_policy_set,
3616 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3617 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3618 (void *)&cmd_setbonding_balance_xmit_policy_port,
3619 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3624 /* *** SHOW NIC BONDING CONFIGURATION *** */
3625 struct cmd_show_bonding_config_result {
3626 cmdline_fixed_string_t show;
3627 cmdline_fixed_string_t bonding;
3628 cmdline_fixed_string_t config;
3632 static void cmd_show_bonding_config_parsed(void *parsed_result,
3633 __attribute__((unused)) struct cmdline *cl,
3634 __attribute__((unused)) void *data)
3636 struct cmd_show_bonding_config_result *res = parsed_result;
3638 uint8_t slaves[RTE_MAX_ETHPORTS];
3639 int num_slaves, num_active_slaves;
3642 portid_t port_id = res->port_id;
3644 /* Display the bonding mode.*/
3645 bonding_mode = rte_eth_bond_mode_get(port_id);
3646 if (bonding_mode < 0) {
3647 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3650 printf("\tBonding mode: %d\n", bonding_mode);
3652 if (bonding_mode == BONDING_MODE_BALANCE) {
3653 int balance_xmit_policy;
3655 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3656 if (balance_xmit_policy < 0) {
3657 printf("\tFailed to get balance xmit policy for port = %d\n",
3661 printf("\tBalance Xmit Policy: ");
3663 switch (balance_xmit_policy) {
3664 case BALANCE_XMIT_POLICY_LAYER2:
3665 printf("BALANCE_XMIT_POLICY_LAYER2");
3667 case BALANCE_XMIT_POLICY_LAYER23:
3668 printf("BALANCE_XMIT_POLICY_LAYER23");
3670 case BALANCE_XMIT_POLICY_LAYER34:
3671 printf("BALANCE_XMIT_POLICY_LAYER34");
3678 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3680 if (num_slaves < 0) {
3681 printf("\tFailed to get slave list for port = %d\n", port_id);
3684 if (num_slaves > 0) {
3685 printf("\tSlaves (%d): [", num_slaves);
3686 for (i = 0; i < num_slaves - 1; i++)
3687 printf("%d ", slaves[i]);
3689 printf("%d]\n", slaves[num_slaves - 1]);
3691 printf("\tSlaves: []\n");
3695 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3698 if (num_active_slaves < 0) {
3699 printf("\tFailed to get active slave list for port = %d\n", port_id);
3702 if (num_active_slaves > 0) {
3703 printf("\tActive Slaves (%d): [", num_active_slaves);
3704 for (i = 0; i < num_active_slaves - 1; i++)
3705 printf("%d ", slaves[i]);
3707 printf("%d]\n", slaves[num_active_slaves - 1]);
3710 printf("\tActive Slaves: []\n");
3714 primary_id = rte_eth_bond_primary_get(port_id);
3715 if (primary_id < 0) {
3716 printf("\tFailed to get primary slave for port = %d\n", port_id);
3719 printf("\tPrimary: [%d]\n", primary_id);
3723 cmdline_parse_token_string_t cmd_showbonding_config_show =
3724 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3726 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3727 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3728 bonding, "bonding");
3729 cmdline_parse_token_string_t cmd_showbonding_config_config =
3730 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3732 cmdline_parse_token_num_t cmd_showbonding_config_port =
3733 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3736 cmdline_parse_inst_t cmd_show_bonding_config = {
3737 .f = cmd_show_bonding_config_parsed,
3738 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3741 (void *)&cmd_showbonding_config_show,
3742 (void *)&cmd_showbonding_config_bonding,
3743 (void *)&cmd_showbonding_config_config,
3744 (void *)&cmd_showbonding_config_port,
3749 /* *** SET BONDING PRIMARY *** */
3750 struct cmd_set_bonding_primary_result {
3751 cmdline_fixed_string_t set;
3752 cmdline_fixed_string_t bonding;
3753 cmdline_fixed_string_t primary;
3758 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3759 __attribute__((unused)) struct cmdline *cl,
3760 __attribute__((unused)) void *data)
3762 struct cmd_set_bonding_primary_result *res = parsed_result;
3763 portid_t master_port_id = res->port_id;
3764 portid_t slave_port_id = res->slave_id;
3766 /* Set the primary slave for a bonded device. */
3767 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3768 printf("\t Failed to set primary slave for port = %d.\n",
3775 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3776 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3778 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3779 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3780 bonding, "bonding");
3781 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3782 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3783 primary, "primary");
3784 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3785 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3787 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3788 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3791 cmdline_parse_inst_t cmd_set_bonding_primary = {
3792 .f = cmd_set_bonding_primary_parsed,
3793 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3796 (void *)&cmd_setbonding_primary_set,
3797 (void *)&cmd_setbonding_primary_bonding,
3798 (void *)&cmd_setbonding_primary_primary,
3799 (void *)&cmd_setbonding_primary_slave,
3800 (void *)&cmd_setbonding_primary_port,
3805 /* *** ADD SLAVE *** */
3806 struct cmd_add_bonding_slave_result {
3807 cmdline_fixed_string_t add;
3808 cmdline_fixed_string_t bonding;
3809 cmdline_fixed_string_t slave;
3814 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3815 __attribute__((unused)) struct cmdline *cl,
3816 __attribute__((unused)) void *data)
3818 struct cmd_add_bonding_slave_result *res = parsed_result;
3819 portid_t master_port_id = res->port_id;
3820 portid_t slave_port_id = res->slave_id;
3822 /* Set the primary slave for a bonded device. */
3823 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3824 printf("\t Failed to add slave %d to master port = %d.\n",
3825 slave_port_id, master_port_id);
3831 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3832 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3834 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3835 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3836 bonding, "bonding");
3837 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3838 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3840 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3841 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3843 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3844 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3847 cmdline_parse_inst_t cmd_add_bonding_slave = {
3848 .f = cmd_add_bonding_slave_parsed,
3849 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3852 (void *)&cmd_addbonding_slave_add,
3853 (void *)&cmd_addbonding_slave_bonding,
3854 (void *)&cmd_addbonding_slave_slave,
3855 (void *)&cmd_addbonding_slave_slaveid,
3856 (void *)&cmd_addbonding_slave_port,
3861 /* *** REMOVE SLAVE *** */
3862 struct cmd_remove_bonding_slave_result {
3863 cmdline_fixed_string_t remove;
3864 cmdline_fixed_string_t bonding;
3865 cmdline_fixed_string_t slave;
3870 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3871 __attribute__((unused)) struct cmdline *cl,
3872 __attribute__((unused)) void *data)
3874 struct cmd_remove_bonding_slave_result *res = parsed_result;
3875 portid_t master_port_id = res->port_id;
3876 portid_t slave_port_id = res->slave_id;
3878 /* Set the primary slave for a bonded device. */
3879 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3880 printf("\t Failed to remove slave %d from master port = %d.\n",
3881 slave_port_id, master_port_id);
3887 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3888 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3890 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3891 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3892 bonding, "bonding");
3893 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3894 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3896 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3897 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3899 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3900 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3903 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3904 .f = cmd_remove_bonding_slave_parsed,
3905 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3908 (void *)&cmd_removebonding_slave_remove,
3909 (void *)&cmd_removebonding_slave_bonding,
3910 (void *)&cmd_removebonding_slave_slave,
3911 (void *)&cmd_removebonding_slave_slaveid,
3912 (void *)&cmd_removebonding_slave_port,
3917 /* *** CREATE BONDED DEVICE *** */
3918 struct cmd_create_bonded_device_result {
3919 cmdline_fixed_string_t create;
3920 cmdline_fixed_string_t bonded;
3921 cmdline_fixed_string_t device;
3926 static int bond_dev_num = 0;
3928 static void cmd_create_bonded_device_parsed(void *parsed_result,
3929 __attribute__((unused)) struct cmdline *cl,
3930 __attribute__((unused)) void *data)
3932 struct cmd_create_bonded_device_result *res = parsed_result;
3933 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3936 if (test_done == 0) {
3937 printf("Please stop forwarding first\n");
3941 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3944 /* Create a new bonded device. */
3945 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3947 printf("\t Failed to create bonded device.\n");
3950 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3953 /* Update number of ports */
3954 nb_ports = rte_eth_dev_count();
3955 reconfig(port_id, res->socket);
3956 rte_eth_promiscuous_enable(port_id);
3961 cmdline_parse_token_string_t cmd_createbonded_device_create =
3962 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3964 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3965 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3967 cmdline_parse_token_string_t cmd_createbonded_device_device =
3968 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3970 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3971 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3973 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3974 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3977 cmdline_parse_inst_t cmd_create_bonded_device = {
3978 .f = cmd_create_bonded_device_parsed,
3979 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3982 (void *)&cmd_createbonded_device_create,
3983 (void *)&cmd_createbonded_device_bonded,
3984 (void *)&cmd_createbonded_device_device,
3985 (void *)&cmd_createbonded_device_mode,
3986 (void *)&cmd_createbonded_device_socket,
3991 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3992 struct cmd_set_bond_mac_addr_result {
3993 cmdline_fixed_string_t set;
3994 cmdline_fixed_string_t bonding;
3995 cmdline_fixed_string_t mac_addr;
3997 struct ether_addr address;
4000 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4001 __attribute__((unused)) struct cmdline *cl,
4002 __attribute__((unused)) void *data)
4004 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4007 if (res->port_num >= nb_ports) {
4008 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4012 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4014 /* check the return value and print it if is < 0 */
4016 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4019 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4020 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4021 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4024 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4027 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4028 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4029 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4030 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4032 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4033 .f = cmd_set_bond_mac_addr_parsed,
4035 .help_str = "set bonding mac_addr (port_id) (address): ",
4037 (void *)&cmd_set_bond_mac_addr_set,
4038 (void *)&cmd_set_bond_mac_addr_bonding,
4039 (void *)&cmd_set_bond_mac_addr_mac,
4040 (void *)&cmd_set_bond_mac_addr_portnum,
4041 (void *)&cmd_set_bond_mac_addr_addr,
4047 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4048 struct cmd_set_bond_mon_period_result {
4049 cmdline_fixed_string_t set;
4050 cmdline_fixed_string_t bonding;
4051 cmdline_fixed_string_t mon_period;
4056 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4057 __attribute__((unused)) struct cmdline *cl,
4058 __attribute__((unused)) void *data)
4060 struct cmd_set_bond_mon_period_result *res = parsed_result;
4063 if (res->port_num >= nb_ports) {
4064 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4068 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4070 /* check the return value and print it if is < 0 */
4072 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4075 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4078 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4079 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4080 bonding, "bonding");
4081 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4082 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4083 mon_period, "mon_period");
4084 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4085 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4087 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4088 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4091 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4092 .f = cmd_set_bond_mon_period_parsed,
4094 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4096 (void *)&cmd_set_bond_mon_period_set,
4097 (void *)&cmd_set_bond_mon_period_bonding,
4098 (void *)&cmd_set_bond_mon_period_mon_period,
4099 (void *)&cmd_set_bond_mon_period_portnum,
4100 (void *)&cmd_set_bond_mon_period_period_ms,
4105 #endif /* RTE_LIBRTE_PMD_BOND */
4107 /* *** SET FORWARDING MODE *** */
4108 struct cmd_set_fwd_mode_result {
4109 cmdline_fixed_string_t set;
4110 cmdline_fixed_string_t fwd;
4111 cmdline_fixed_string_t mode;
4114 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4115 __attribute__((unused)) struct cmdline *cl,
4116 __attribute__((unused)) void *data)
4118 struct cmd_set_fwd_mode_result *res = parsed_result;
4120 set_pkt_forwarding_mode(res->mode);
4123 cmdline_parse_token_string_t cmd_setfwd_set =
4124 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4125 cmdline_parse_token_string_t cmd_setfwd_fwd =
4126 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4127 cmdline_parse_token_string_t cmd_setfwd_mode =
4128 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4129 "" /* defined at init */);
4131 cmdline_parse_inst_t cmd_set_fwd_mode = {
4132 .f = cmd_set_fwd_mode_parsed,
4134 .help_str = NULL, /* defined at init */
4136 (void *)&cmd_setfwd_set,
4137 (void *)&cmd_setfwd_fwd,
4138 (void *)&cmd_setfwd_mode,
4143 static void cmd_set_fwd_mode_init(void)
4146 static char token[128];
4147 static char help[256];
4148 cmdline_parse_token_string_t *token_struct;
4150 modes = list_pkt_forwarding_modes();
4151 snprintf(help, sizeof help, "set fwd %s - "
4152 "set packet forwarding mode", modes);
4153 cmd_set_fwd_mode.help_str = help;
4155 /* string token separator is # */
4156 for (c = token; *modes != '\0'; modes++)
4161 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4162 token_struct->string_data.str = token;
4165 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4166 struct cmd_set_burst_tx_retry_result {
4167 cmdline_fixed_string_t set;
4168 cmdline_fixed_string_t burst;
4169 cmdline_fixed_string_t tx;
4170 cmdline_fixed_string_t delay;
4172 cmdline_fixed_string_t retry;
4176 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4177 __attribute__((unused)) struct cmdline *cl,
4178 __attribute__((unused)) void *data)
4180 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4182 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4183 && !strcmp(res->tx, "tx")) {
4184 if (!strcmp(res->delay, "delay"))
4185 burst_tx_delay_time = res->time;
4186 if (!strcmp(res->retry, "retry"))
4187 burst_tx_retry_num = res->retry_num;
4192 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4193 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4194 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4195 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4197 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4198 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4199 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4200 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4201 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4202 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4203 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4204 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4205 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4206 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4208 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4209 .f = cmd_set_burst_tx_retry_parsed,
4210 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4212 (void *)&cmd_set_burst_tx_retry_set,
4213 (void *)&cmd_set_burst_tx_retry_burst,
4214 (void *)&cmd_set_burst_tx_retry_tx,
4215 (void *)&cmd_set_burst_tx_retry_delay,
4216 (void *)&cmd_set_burst_tx_retry_time,
4217 (void *)&cmd_set_burst_tx_retry_retry,
4218 (void *)&cmd_set_burst_tx_retry_retry_num,
4223 /* *** SET PROMISC MODE *** */
4224 struct cmd_set_promisc_mode_result {
4225 cmdline_fixed_string_t set;
4226 cmdline_fixed_string_t promisc;
4227 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4228 uint8_t port_num; /* valid if "allports" argument == 0 */
4229 cmdline_fixed_string_t mode;
4232 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4233 __attribute__((unused)) struct cmdline *cl,
4236 struct cmd_set_promisc_mode_result *res = parsed_result;
4240 if (!strcmp(res->mode, "on"))
4247 for (i = 0; i < nb_ports; i++) {
4249 rte_eth_promiscuous_enable(i);
4251 rte_eth_promiscuous_disable(i);
4256 rte_eth_promiscuous_enable(res->port_num);
4258 rte_eth_promiscuous_disable(res->port_num);
4262 cmdline_parse_token_string_t cmd_setpromisc_set =
4263 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4264 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4265 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4267 cmdline_parse_token_string_t cmd_setpromisc_portall =
4268 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4270 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4271 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4273 cmdline_parse_token_string_t cmd_setpromisc_mode =
4274 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4277 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4278 .f = cmd_set_promisc_mode_parsed,
4280 .help_str = "set promisc all on|off: set promisc mode for all ports",
4282 (void *)&cmd_setpromisc_set,
4283 (void *)&cmd_setpromisc_promisc,
4284 (void *)&cmd_setpromisc_portall,
4285 (void *)&cmd_setpromisc_mode,
4290 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4291 .f = cmd_set_promisc_mode_parsed,
4293 .help_str = "set promisc X on|off: set promisc mode on port X",
4295 (void *)&cmd_setpromisc_set,
4296 (void *)&cmd_setpromisc_promisc,
4297 (void *)&cmd_setpromisc_portnum,
4298 (void *)&cmd_setpromisc_mode,
4303 /* *** SET ALLMULTI MODE *** */
4304 struct cmd_set_allmulti_mode_result {
4305 cmdline_fixed_string_t set;
4306 cmdline_fixed_string_t allmulti;
4307 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4308 uint8_t port_num; /* valid if "allports" argument == 0 */
4309 cmdline_fixed_string_t mode;
4312 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4313 __attribute__((unused)) struct cmdline *cl,
4316 struct cmd_set_allmulti_mode_result *res = parsed_result;
4320 if (!strcmp(res->mode, "on"))
4327 for (i = 0; i < nb_ports; i++) {
4329 rte_eth_allmulticast_enable(i);
4331 rte_eth_allmulticast_disable(i);
4336 rte_eth_allmulticast_enable(res->port_num);
4338 rte_eth_allmulticast_disable(res->port_num);
4342 cmdline_parse_token_string_t cmd_setallmulti_set =
4343 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4344 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4345 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4347 cmdline_parse_token_string_t cmd_setallmulti_portall =
4348 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4350 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4351 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4353 cmdline_parse_token_string_t cmd_setallmulti_mode =
4354 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4357 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4358 .f = cmd_set_allmulti_mode_parsed,
4360 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4362 (void *)&cmd_setallmulti_set,
4363 (void *)&cmd_setallmulti_allmulti,
4364 (void *)&cmd_setallmulti_portall,
4365 (void *)&cmd_setallmulti_mode,
4370 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4371 .f = cmd_set_allmulti_mode_parsed,
4373 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4375 (void *)&cmd_setallmulti_set,
4376 (void *)&cmd_setallmulti_allmulti,
4377 (void *)&cmd_setallmulti_portnum,
4378 (void *)&cmd_setallmulti_mode,
4383 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4384 struct cmd_link_flow_ctrl_set_result {
4385 cmdline_fixed_string_t set;
4386 cmdline_fixed_string_t flow_ctrl;
4387 cmdline_fixed_string_t rx;
4388 cmdline_fixed_string_t rx_lfc_mode;
4389 cmdline_fixed_string_t tx;
4390 cmdline_fixed_string_t tx_lfc_mode;
4391 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4392 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4393 cmdline_fixed_string_t autoneg_str;
4394 cmdline_fixed_string_t autoneg;
4395 cmdline_fixed_string_t hw_str;
4396 uint32_t high_water;
4397 cmdline_fixed_string_t lw_str;
4399 cmdline_fixed_string_t pt_str;
4400 uint16_t pause_time;
4401 cmdline_fixed_string_t xon_str;
4406 cmdline_parse_token_string_t cmd_lfc_set_set =
4407 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4409 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4410 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4411 flow_ctrl, "flow_ctrl");
4412 cmdline_parse_token_string_t cmd_lfc_set_rx =
4413 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4415 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4417 rx_lfc_mode, "on#off");
4418 cmdline_parse_token_string_t cmd_lfc_set_tx =
4419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4421 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4423 tx_lfc_mode, "on#off");
4424 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4426 hw_str, "high_water");
4427 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4428 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4429 high_water, UINT32);
4430 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4432 lw_str, "low_water");
4433 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4434 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4436 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4437 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4438 pt_str, "pause_time");
4439 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4440 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4441 pause_time, UINT16);
4442 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4443 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4444 xon_str, "send_xon");
4445 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4446 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4448 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4449 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4450 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4451 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4452 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4453 mac_ctrl_frame_fwd_mode, "on#off");
4454 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4455 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4456 autoneg_str, "autoneg");
4457 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4458 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4460 cmdline_parse_token_num_t cmd_lfc_set_portid =
4461 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4464 /* forward declaration */
4466 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4469 cmdline_parse_inst_t cmd_link_flow_control_set = {
4470 .f = cmd_link_flow_ctrl_set_parsed,
4472 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4473 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4474 autoneg on|off port_id",
4476 (void *)&cmd_lfc_set_set,
4477 (void *)&cmd_lfc_set_flow_ctrl,
4478 (void *)&cmd_lfc_set_rx,
4479 (void *)&cmd_lfc_set_rx_mode,
4480 (void *)&cmd_lfc_set_tx,
4481 (void *)&cmd_lfc_set_tx_mode,
4482 (void *)&cmd_lfc_set_high_water,
4483 (void *)&cmd_lfc_set_low_water,
4484 (void *)&cmd_lfc_set_pause_time,
4485 (void *)&cmd_lfc_set_send_xon,
4486 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4487 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4488 (void *)&cmd_lfc_set_autoneg_str,
4489 (void *)&cmd_lfc_set_autoneg,
4490 (void *)&cmd_lfc_set_portid,
4495 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4496 .f = cmd_link_flow_ctrl_set_parsed,
4497 .data = (void *)&cmd_link_flow_control_set_rx,
4498 .help_str = "Change rx flow control parameter: set flow_ctrl "
4499 "rx on|off port_id",
4501 (void *)&cmd_lfc_set_set,
4502 (void *)&cmd_lfc_set_flow_ctrl,
4503 (void *)&cmd_lfc_set_rx,
4504 (void *)&cmd_lfc_set_rx_mode,
4505 (void *)&cmd_lfc_set_portid,
4510 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4511 .f = cmd_link_flow_ctrl_set_parsed,
4512 .data = (void *)&cmd_link_flow_control_set_tx,
4513 .help_str = "Change tx flow control parameter: set flow_ctrl "
4514 "tx on|off port_id",
4516 (void *)&cmd_lfc_set_set,
4517 (void *)&cmd_lfc_set_flow_ctrl,
4518 (void *)&cmd_lfc_set_tx,
4519 (void *)&cmd_lfc_set_tx_mode,
4520 (void *)&cmd_lfc_set_portid,
4525 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4526 .f = cmd_link_flow_ctrl_set_parsed,
4527 .data = (void *)&cmd_link_flow_control_set_hw,
4528 .help_str = "Change high water flow control parameter: set flow_ctrl "
4529 "high_water value port_id",
4531 (void *)&cmd_lfc_set_set,
4532 (void *)&cmd_lfc_set_flow_ctrl,
4533 (void *)&cmd_lfc_set_high_water_str,
4534 (void *)&cmd_lfc_set_high_water,
4535 (void *)&cmd_lfc_set_portid,
4540 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4541 .f = cmd_link_flow_ctrl_set_parsed,
4542 .data = (void *)&cmd_link_flow_control_set_lw,
4543 .help_str = "Change low water flow control parameter: set flow_ctrl "
4544 "low_water value port_id",
4546 (void *)&cmd_lfc_set_set,
4547 (void *)&cmd_lfc_set_flow_ctrl,
4548 (void *)&cmd_lfc_set_low_water_str,
4549 (void *)&cmd_lfc_set_low_water,
4550 (void *)&cmd_lfc_set_portid,
4555 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4556 .f = cmd_link_flow_ctrl_set_parsed,
4557 .data = (void *)&cmd_link_flow_control_set_pt,
4558 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4559 "pause_time value port_id",
4561 (void *)&cmd_lfc_set_set,
4562 (void *)&cmd_lfc_set_flow_ctrl,
4563 (void *)&cmd_lfc_set_pause_time_str,
4564 (void *)&cmd_lfc_set_pause_time,
4565 (void *)&cmd_lfc_set_portid,
4570 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4571 .f = cmd_link_flow_ctrl_set_parsed,
4572 .data = (void *)&cmd_link_flow_control_set_xon,
4573 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4574 "send_xon value port_id",
4576 (void *)&cmd_lfc_set_set,
4577 (void *)&cmd_lfc_set_flow_ctrl,
4578 (void *)&cmd_lfc_set_send_xon_str,
4579 (void *)&cmd_lfc_set_send_xon,
4580 (void *)&cmd_lfc_set_portid,
4585 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4586 .f = cmd_link_flow_ctrl_set_parsed,
4587 .data = (void *)&cmd_link_flow_control_set_macfwd,
4588 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4589 "mac_ctrl_frame_fwd on|off port_id",
4591 (void *)&cmd_lfc_set_set,
4592 (void *)&cmd_lfc_set_flow_ctrl,
4593 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4594 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4595 (void *)&cmd_lfc_set_portid,
4600 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4601 .f = cmd_link_flow_ctrl_set_parsed,
4602 .data = (void *)&cmd_link_flow_control_set_autoneg,
4603 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4604 "autoneg on|off port_id",
4606 (void *)&cmd_lfc_set_set,
4607 (void *)&cmd_lfc_set_flow_ctrl,
4608 (void *)&cmd_lfc_set_autoneg_str,
4609 (void *)&cmd_lfc_set_autoneg,
4610 (void *)&cmd_lfc_set_portid,
4616 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4617 __attribute__((unused)) struct cmdline *cl,
4620 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4621 cmdline_parse_inst_t *cmd = data;
4622 struct rte_eth_fc_conf fc_conf;
4623 int rx_fc_en, tx_fc_en = 0;
4627 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4628 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4629 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4630 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4632 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4633 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4636 /* Partial command line, retrieve current configuration */
4638 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4640 printf("cannot get current flow ctrl parameters, return"
4641 "code = %d\n", ret);
4645 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4646 (fc_conf.mode == RTE_FC_FULL))
4648 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4649 (fc_conf.mode == RTE_FC_FULL))
4653 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4654 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4656 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4657 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4659 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4661 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4662 fc_conf.high_water = res->high_water;
4664 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4665 fc_conf.low_water = res->low_water;
4667 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4668 fc_conf.pause_time = res->pause_time;
4670 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4671 fc_conf.send_xon = res->send_xon;
4673 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4674 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4675 fc_conf.mac_ctrl_frame_fwd = 1;
4677 fc_conf.mac_ctrl_frame_fwd = 0;
4680 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4681 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4683 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4685 printf("bad flow contrl parameter, return code = %d \n", ret);
4688 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4689 struct cmd_priority_flow_ctrl_set_result {
4690 cmdline_fixed_string_t set;
4691 cmdline_fixed_string_t pfc_ctrl;
4692 cmdline_fixed_string_t rx;
4693 cmdline_fixed_string_t rx_pfc_mode;
4694 cmdline_fixed_string_t tx;
4695 cmdline_fixed_string_t tx_pfc_mode;
4696 uint32_t high_water;
4698 uint16_t pause_time;
4704 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4705 __attribute__((unused)) struct cmdline *cl,
4706 __attribute__((unused)) void *data)
4708 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4709 struct rte_eth_pfc_conf pfc_conf;
4710 int rx_fc_enable, tx_fc_enable;
4714 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4715 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4716 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4717 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4719 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4720 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4723 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4724 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4725 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4726 pfc_conf.fc.high_water = res->high_water;
4727 pfc_conf.fc.low_water = res->low_water;
4728 pfc_conf.fc.pause_time = res->pause_time;
4729 pfc_conf.priority = res->priority;
4731 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4733 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4736 cmdline_parse_token_string_t cmd_pfc_set_set =
4737 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4739 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4740 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4741 pfc_ctrl, "pfc_ctrl");
4742 cmdline_parse_token_string_t cmd_pfc_set_rx =
4743 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4745 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4746 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4747 rx_pfc_mode, "on#off");
4748 cmdline_parse_token_string_t cmd_pfc_set_tx =
4749 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4751 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4752 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4753 tx_pfc_mode, "on#off");
4754 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4755 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4756 high_water, UINT32);
4757 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4758 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4760 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4761 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4762 pause_time, UINT16);
4763 cmdline_parse_token_num_t cmd_pfc_set_priority =
4764 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4766 cmdline_parse_token_num_t cmd_pfc_set_portid =
4767 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4770 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4771 .f = cmd_priority_flow_ctrl_set_parsed,
4773 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4774 tx on|off high_water low_water pause_time priority port_id",
4776 (void *)&cmd_pfc_set_set,
4777 (void *)&cmd_pfc_set_flow_ctrl,
4778 (void *)&cmd_pfc_set_rx,
4779 (void *)&cmd_pfc_set_rx_mode,
4780 (void *)&cmd_pfc_set_tx,
4781 (void *)&cmd_pfc_set_tx_mode,
4782 (void *)&cmd_pfc_set_high_water,
4783 (void *)&cmd_pfc_set_low_water,
4784 (void *)&cmd_pfc_set_pause_time,
4785 (void *)&cmd_pfc_set_priority,
4786 (void *)&cmd_pfc_set_portid,
4791 /* *** RESET CONFIGURATION *** */
4792 struct cmd_reset_result {
4793 cmdline_fixed_string_t reset;
4794 cmdline_fixed_string_t def;
4797 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4799 __attribute__((unused)) void *data)
4801 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4802 set_def_fwd_config();
4805 cmdline_parse_token_string_t cmd_reset_set =
4806 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4807 cmdline_parse_token_string_t cmd_reset_def =
4808 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4811 cmdline_parse_inst_t cmd_reset = {
4812 .f = cmd_reset_parsed,
4814 .help_str = "set default: reset default forwarding configuration",
4816 (void *)&cmd_reset_set,
4817 (void *)&cmd_reset_def,
4822 /* *** START FORWARDING *** */
4823 struct cmd_start_result {
4824 cmdline_fixed_string_t start;
4827 cmdline_parse_token_string_t cmd_start_start =
4828 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4830 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4831 __attribute__((unused)) struct cmdline *cl,
4832 __attribute__((unused)) void *data)
4834 start_packet_forwarding(0);
4837 cmdline_parse_inst_t cmd_start = {
4838 .f = cmd_start_parsed,
4840 .help_str = "start packet forwarding",
4842 (void *)&cmd_start_start,
4847 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4848 struct cmd_start_tx_first_result {
4849 cmdline_fixed_string_t start;
4850 cmdline_fixed_string_t tx_first;
4854 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4855 __attribute__((unused)) struct cmdline *cl,
4856 __attribute__((unused)) void *data)
4858 start_packet_forwarding(1);
4861 cmdline_parse_token_string_t cmd_start_tx_first_start =
4862 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4864 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4865 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4866 tx_first, "tx_first");
4868 cmdline_parse_inst_t cmd_start_tx_first = {
4869 .f = cmd_start_tx_first_parsed,
4871 .help_str = "start packet forwarding, after sending 1 burst of packets",
4873 (void *)&cmd_start_tx_first_start,
4874 (void *)&cmd_start_tx_first_tx_first,
4879 /* *** SET LINK UP *** */
4880 struct cmd_set_link_up_result {
4881 cmdline_fixed_string_t set;
4882 cmdline_fixed_string_t link_up;
4883 cmdline_fixed_string_t port;
4887 cmdline_parse_token_string_t cmd_set_link_up_set =
4888 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4889 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4890 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4892 cmdline_parse_token_string_t cmd_set_link_up_port =
4893 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4894 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4895 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4897 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4898 __attribute__((unused)) struct cmdline *cl,
4899 __attribute__((unused)) void *data)
4901 struct cmd_set_link_up_result *res = parsed_result;
4902 dev_set_link_up(res->port_id);
4905 cmdline_parse_inst_t cmd_set_link_up = {
4906 .f = cmd_set_link_up_parsed,
4908 .help_str = "set link-up port (port id)",
4910 (void *)&cmd_set_link_up_set,
4911 (void *)&cmd_set_link_up_link_up,
4912 (void *)&cmd_set_link_up_port,
4913 (void *)&cmd_set_link_up_port_id,
4918 /* *** SET LINK DOWN *** */
4919 struct cmd_set_link_down_result {
4920 cmdline_fixed_string_t set;
4921 cmdline_fixed_string_t link_down;
4922 cmdline_fixed_string_t port;
4926 cmdline_parse_token_string_t cmd_set_link_down_set =
4927 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4928 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4929 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4931 cmdline_parse_token_string_t cmd_set_link_down_port =
4932 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4933 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4934 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4936 static void cmd_set_link_down_parsed(
4937 __attribute__((unused)) void *parsed_result,
4938 __attribute__((unused)) struct cmdline *cl,
4939 __attribute__((unused)) void *data)
4941 struct cmd_set_link_down_result *res = parsed_result;
4942 dev_set_link_down(res->port_id);
4945 cmdline_parse_inst_t cmd_set_link_down = {
4946 .f = cmd_set_link_down_parsed,
4948 .help_str = "set link-down port (port id)",
4950 (void *)&cmd_set_link_down_set,
4951 (void *)&cmd_set_link_down_link_down,
4952 (void *)&cmd_set_link_down_port,
4953 (void *)&cmd_set_link_down_port_id,
4958 /* *** SHOW CFG *** */
4959 struct cmd_showcfg_result {
4960 cmdline_fixed_string_t show;
4961 cmdline_fixed_string_t cfg;
4962 cmdline_fixed_string_t what;
4965 static void cmd_showcfg_parsed(void *parsed_result,
4966 __attribute__((unused)) struct cmdline *cl,
4967 __attribute__((unused)) void *data)
4969 struct cmd_showcfg_result *res = parsed_result;
4970 if (!strcmp(res->what, "rxtx"))
4971 rxtx_config_display();
4972 else if (!strcmp(res->what, "cores"))
4973 fwd_lcores_config_display();
4974 else if (!strcmp(res->what, "fwd"))
4975 fwd_config_display();
4978 cmdline_parse_token_string_t cmd_showcfg_show =
4979 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4980 cmdline_parse_token_string_t cmd_showcfg_port =
4981 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4982 cmdline_parse_token_string_t cmd_showcfg_what =
4983 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4986 cmdline_parse_inst_t cmd_showcfg = {
4987 .f = cmd_showcfg_parsed,
4989 .help_str = "show config rxtx|cores|fwd",
4991 (void *)&cmd_showcfg_show,
4992 (void *)&cmd_showcfg_port,
4993 (void *)&cmd_showcfg_what,
4998 /* *** SHOW ALL PORT INFO *** */
4999 struct cmd_showportall_result {
5000 cmdline_fixed_string_t show;
5001 cmdline_fixed_string_t port;
5002 cmdline_fixed_string_t what;
5003 cmdline_fixed_string_t all;
5006 static void cmd_showportall_parsed(void *parsed_result,
5007 __attribute__((unused)) struct cmdline *cl,
5008 __attribute__((unused)) void *data)
5012 struct cmd_showportall_result *res = parsed_result;
5013 if (!strcmp(res->show, "clear")) {
5014 if (!strcmp(res->what, "stats"))
5015 for (i = 0; i < nb_ports; i++)
5017 else if (!strcmp(res->what, "xstats"))
5018 for (i = 0; i < nb_ports; i++)
5019 nic_xstats_clear(i);
5020 } else if (!strcmp(res->what, "info"))
5021 for (i = 0; i < nb_ports; i++)
5022 port_infos_display(i);
5023 else if (!strcmp(res->what, "stats"))
5024 for (i = 0; i < nb_ports; i++)
5025 nic_stats_display(i);
5026 else if (!strcmp(res->what, "xstats"))
5027 for (i = 0; i < nb_ports; i++)
5028 nic_xstats_display(i);
5029 else if (!strcmp(res->what, "fdir"))
5030 for (i = 0; i < nb_ports; i++)
5032 else if (!strcmp(res->what, "stat_qmap"))
5033 for (i = 0; i < nb_ports; i++)
5034 nic_stats_mapping_display(i);
5037 cmdline_parse_token_string_t cmd_showportall_show =
5038 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5040 cmdline_parse_token_string_t cmd_showportall_port =
5041 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5042 cmdline_parse_token_string_t cmd_showportall_what =
5043 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5044 "info#stats#xstats#fdir#stat_qmap");
5045 cmdline_parse_token_string_t cmd_showportall_all =
5046 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5047 cmdline_parse_inst_t cmd_showportall = {
5048 .f = cmd_showportall_parsed,
5050 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5052 (void *)&cmd_showportall_show,
5053 (void *)&cmd_showportall_port,
5054 (void *)&cmd_showportall_what,
5055 (void *)&cmd_showportall_all,
5060 /* *** SHOW PORT INFO *** */
5061 struct cmd_showport_result {
5062 cmdline_fixed_string_t show;
5063 cmdline_fixed_string_t port;
5064 cmdline_fixed_string_t what;
5068 static void cmd_showport_parsed(void *parsed_result,
5069 __attribute__((unused)) struct cmdline *cl,
5070 __attribute__((unused)) void *data)
5072 struct cmd_showport_result *res = parsed_result;
5073 if (!strcmp(res->show, "clear")) {
5074 if (!strcmp(res->what, "stats"))
5075 nic_stats_clear(res->portnum);
5076 else if (!strcmp(res->what, "xstats"))
5077 nic_xstats_clear(res->portnum);
5078 } else if (!strcmp(res->what, "info"))
5079 port_infos_display(res->portnum);
5080 else if (!strcmp(res->what, "stats"))
5081 nic_stats_display(res->portnum);
5082 else if (!strcmp(res->what, "xstats"))
5083 nic_xstats_display(res->portnum);
5084 else if (!strcmp(res->what, "fdir"))
5085 fdir_get_infos(res->portnum);
5086 else if (!strcmp(res->what, "stat_qmap"))
5087 nic_stats_mapping_display(res->portnum);
5090 cmdline_parse_token_string_t cmd_showport_show =
5091 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5093 cmdline_parse_token_string_t cmd_showport_port =
5094 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5095 cmdline_parse_token_string_t cmd_showport_what =
5096 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5097 "info#stats#xstats#fdir#stat_qmap");
5098 cmdline_parse_token_num_t cmd_showport_portnum =
5099 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5101 cmdline_parse_inst_t cmd_showport = {
5102 .f = cmd_showport_parsed,
5104 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5106 (void *)&cmd_showport_show,
5107 (void *)&cmd_showport_port,
5108 (void *)&cmd_showport_what,
5109 (void *)&cmd_showport_portnum,
5114 /* *** READ PORT REGISTER *** */
5115 struct cmd_read_reg_result {
5116 cmdline_fixed_string_t read;
5117 cmdline_fixed_string_t reg;
5123 cmd_read_reg_parsed(void *parsed_result,
5124 __attribute__((unused)) struct cmdline *cl,
5125 __attribute__((unused)) void *data)
5127 struct cmd_read_reg_result *res = parsed_result;
5128 port_reg_display(res->port_id, res->reg_off);
5131 cmdline_parse_token_string_t cmd_read_reg_read =
5132 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5133 cmdline_parse_token_string_t cmd_read_reg_reg =
5134 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5135 cmdline_parse_token_num_t cmd_read_reg_port_id =
5136 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5137 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5138 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5140 cmdline_parse_inst_t cmd_read_reg = {
5141 .f = cmd_read_reg_parsed,
5143 .help_str = "read reg port_id reg_off",
5145 (void *)&cmd_read_reg_read,
5146 (void *)&cmd_read_reg_reg,
5147 (void *)&cmd_read_reg_port_id,
5148 (void *)&cmd_read_reg_reg_off,
5153 /* *** READ PORT REGISTER BIT FIELD *** */
5154 struct cmd_read_reg_bit_field_result {
5155 cmdline_fixed_string_t read;
5156 cmdline_fixed_string_t regfield;
5164 cmd_read_reg_bit_field_parsed(void *parsed_result,
5165 __attribute__((unused)) struct cmdline *cl,
5166 __attribute__((unused)) void *data)
5168 struct cmd_read_reg_bit_field_result *res = parsed_result;
5169 port_reg_bit_field_display(res->port_id, res->reg_off,
5170 res->bit1_pos, res->bit2_pos);
5173 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5174 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5176 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5177 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5178 regfield, "regfield");
5179 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5180 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5182 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5183 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5185 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5186 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5188 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5189 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5192 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5193 .f = cmd_read_reg_bit_field_parsed,
5195 .help_str = "read regfield port_id reg_off bit_x bit_y "
5196 "(read register bit field between bit_x and bit_y included)",
5198 (void *)&cmd_read_reg_bit_field_read,
5199 (void *)&cmd_read_reg_bit_field_regfield,
5200 (void *)&cmd_read_reg_bit_field_port_id,
5201 (void *)&cmd_read_reg_bit_field_reg_off,
5202 (void *)&cmd_read_reg_bit_field_bit1_pos,
5203 (void *)&cmd_read_reg_bit_field_bit2_pos,
5208 /* *** READ PORT REGISTER BIT *** */
5209 struct cmd_read_reg_bit_result {
5210 cmdline_fixed_string_t read;
5211 cmdline_fixed_string_t regbit;
5218 cmd_read_reg_bit_parsed(void *parsed_result,
5219 __attribute__((unused)) struct cmdline *cl,
5220 __attribute__((unused)) void *data)
5222 struct cmd_read_reg_bit_result *res = parsed_result;
5223 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5226 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5227 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5228 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5229 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5231 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5232 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5233 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5234 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5235 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5236 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5238 cmdline_parse_inst_t cmd_read_reg_bit = {
5239 .f = cmd_read_reg_bit_parsed,
5241 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5243 (void *)&cmd_read_reg_bit_read,
5244 (void *)&cmd_read_reg_bit_regbit,
5245 (void *)&cmd_read_reg_bit_port_id,
5246 (void *)&cmd_read_reg_bit_reg_off,
5247 (void *)&cmd_read_reg_bit_bit_pos,
5252 /* *** WRITE PORT REGISTER *** */
5253 struct cmd_write_reg_result {
5254 cmdline_fixed_string_t write;
5255 cmdline_fixed_string_t reg;
5262 cmd_write_reg_parsed(void *parsed_result,
5263 __attribute__((unused)) struct cmdline *cl,
5264 __attribute__((unused)) void *data)
5266 struct cmd_write_reg_result *res = parsed_result;
5267 port_reg_set(res->port_id, res->reg_off, res->value);
5270 cmdline_parse_token_string_t cmd_write_reg_write =
5271 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5272 cmdline_parse_token_string_t cmd_write_reg_reg =
5273 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5274 cmdline_parse_token_num_t cmd_write_reg_port_id =
5275 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5276 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5277 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5278 cmdline_parse_token_num_t cmd_write_reg_value =
5279 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5281 cmdline_parse_inst_t cmd_write_reg = {
5282 .f = cmd_write_reg_parsed,
5284 .help_str = "write reg port_id reg_off reg_value",
5286 (void *)&cmd_write_reg_write,
5287 (void *)&cmd_write_reg_reg,
5288 (void *)&cmd_write_reg_port_id,
5289 (void *)&cmd_write_reg_reg_off,
5290 (void *)&cmd_write_reg_value,
5295 /* *** WRITE PORT REGISTER BIT FIELD *** */
5296 struct cmd_write_reg_bit_field_result {
5297 cmdline_fixed_string_t write;
5298 cmdline_fixed_string_t regfield;
5307 cmd_write_reg_bit_field_parsed(void *parsed_result,
5308 __attribute__((unused)) struct cmdline *cl,
5309 __attribute__((unused)) void *data)
5311 struct cmd_write_reg_bit_field_result *res = parsed_result;
5312 port_reg_bit_field_set(res->port_id, res->reg_off,
5313 res->bit1_pos, res->bit2_pos, res->value);
5316 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5317 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5319 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5320 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5321 regfield, "regfield");
5322 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5323 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5325 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5326 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5328 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5329 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5331 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5332 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5334 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5335 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5338 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5339 .f = cmd_write_reg_bit_field_parsed,
5341 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5342 "(set register bit field between bit_x and bit_y included)",
5344 (void *)&cmd_write_reg_bit_field_write,
5345 (void *)&cmd_write_reg_bit_field_regfield,
5346 (void *)&cmd_write_reg_bit_field_port_id,
5347 (void *)&cmd_write_reg_bit_field_reg_off,
5348 (void *)&cmd_write_reg_bit_field_bit1_pos,
5349 (void *)&cmd_write_reg_bit_field_bit2_pos,
5350 (void *)&cmd_write_reg_bit_field_value,
5355 /* *** WRITE PORT REGISTER BIT *** */
5356 struct cmd_write_reg_bit_result {
5357 cmdline_fixed_string_t write;
5358 cmdline_fixed_string_t regbit;
5366 cmd_write_reg_bit_parsed(void *parsed_result,
5367 __attribute__((unused)) struct cmdline *cl,
5368 __attribute__((unused)) void *data)
5370 struct cmd_write_reg_bit_result *res = parsed_result;
5371 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5374 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5375 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5377 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5378 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5380 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5381 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5382 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5383 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5384 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5385 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5386 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5387 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5389 cmdline_parse_inst_t cmd_write_reg_bit = {
5390 .f = cmd_write_reg_bit_parsed,
5392 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5394 (void *)&cmd_write_reg_bit_write,
5395 (void *)&cmd_write_reg_bit_regbit,
5396 (void *)&cmd_write_reg_bit_port_id,
5397 (void *)&cmd_write_reg_bit_reg_off,
5398 (void *)&cmd_write_reg_bit_bit_pos,
5399 (void *)&cmd_write_reg_bit_value,
5404 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5405 struct cmd_read_rxd_txd_result {
5406 cmdline_fixed_string_t read;
5407 cmdline_fixed_string_t rxd_txd;
5414 cmd_read_rxd_txd_parsed(void *parsed_result,
5415 __attribute__((unused)) struct cmdline *cl,
5416 __attribute__((unused)) void *data)
5418 struct cmd_read_rxd_txd_result *res = parsed_result;
5420 if (!strcmp(res->rxd_txd, "rxd"))
5421 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5422 else if (!strcmp(res->rxd_txd, "txd"))
5423 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5426 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5427 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5428 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5429 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5431 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5432 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5433 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5434 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5435 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5436 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5438 cmdline_parse_inst_t cmd_read_rxd_txd = {
5439 .f = cmd_read_rxd_txd_parsed,
5441 .help_str = "read rxd|txd port_id queue_id rxd_id",
5443 (void *)&cmd_read_rxd_txd_read,
5444 (void *)&cmd_read_rxd_txd_rxd_txd,
5445 (void *)&cmd_read_rxd_txd_port_id,
5446 (void *)&cmd_read_rxd_txd_queue_id,
5447 (void *)&cmd_read_rxd_txd_desc_id,
5453 struct cmd_quit_result {
5454 cmdline_fixed_string_t quit;
5457 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5459 __attribute__((unused)) void *data)
5465 cmdline_parse_token_string_t cmd_quit_quit =
5466 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5468 cmdline_parse_inst_t cmd_quit = {
5469 .f = cmd_quit_parsed,
5471 .help_str = "exit application",
5473 (void *)&cmd_quit_quit,
5478 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5479 struct cmd_mac_addr_result {
5480 cmdline_fixed_string_t mac_addr_cmd;
5481 cmdline_fixed_string_t what;
5483 struct ether_addr address;
5486 static void cmd_mac_addr_parsed(void *parsed_result,
5487 __attribute__((unused)) struct cmdline *cl,
5488 __attribute__((unused)) void *data)
5490 struct cmd_mac_addr_result *res = parsed_result;
5493 if (strcmp(res->what, "add") == 0)
5494 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5496 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5498 /* check the return value and print it if is < 0 */
5500 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5504 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5505 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5507 cmdline_parse_token_string_t cmd_mac_addr_what =
5508 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5510 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5511 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5512 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5513 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5515 cmdline_parse_inst_t cmd_mac_addr = {
5516 .f = cmd_mac_addr_parsed,
5518 .help_str = "mac_addr add|remove X <address>: "
5519 "add/remove MAC address on port X",
5521 (void *)&cmd_mac_addr_cmd,
5522 (void *)&cmd_mac_addr_what,
5523 (void *)&cmd_mac_addr_portnum,
5524 (void *)&cmd_mac_addr_addr,
5530 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5531 struct cmd_set_qmap_result {
5532 cmdline_fixed_string_t set;
5533 cmdline_fixed_string_t qmap;
5534 cmdline_fixed_string_t what;
5541 cmd_set_qmap_parsed(void *parsed_result,
5542 __attribute__((unused)) struct cmdline *cl,
5543 __attribute__((unused)) void *data)
5545 struct cmd_set_qmap_result *res = parsed_result;
5546 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5548 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5551 cmdline_parse_token_string_t cmd_setqmap_set =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5554 cmdline_parse_token_string_t cmd_setqmap_qmap =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5557 cmdline_parse_token_string_t cmd_setqmap_what =
5558 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5560 cmdline_parse_token_num_t cmd_setqmap_portid =
5561 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5563 cmdline_parse_token_num_t cmd_setqmap_queueid =
5564 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5566 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5567 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5570 cmdline_parse_inst_t cmd_set_qmap = {
5571 .f = cmd_set_qmap_parsed,
5573 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5575 (void *)&cmd_setqmap_set,
5576 (void *)&cmd_setqmap_qmap,
5577 (void *)&cmd_setqmap_what,
5578 (void *)&cmd_setqmap_portid,
5579 (void *)&cmd_setqmap_queueid,
5580 (void *)&cmd_setqmap_mapvalue,
5585 /* *** CONFIGURE UNICAST HASH TABLE *** */
5586 struct cmd_set_uc_hash_table {
5587 cmdline_fixed_string_t set;
5588 cmdline_fixed_string_t port;
5590 cmdline_fixed_string_t what;
5591 struct ether_addr address;
5592 cmdline_fixed_string_t mode;
5596 cmd_set_uc_hash_parsed(void *parsed_result,
5597 __attribute__((unused)) struct cmdline *cl,
5598 __attribute__((unused)) void *data)
5601 struct cmd_set_uc_hash_table *res = parsed_result;
5603 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5605 if (strcmp(res->what, "uta") == 0)
5606 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5607 &res->address,(uint8_t)is_on);
5609 printf("bad unicast hash table parameter, return code = %d \n", ret);
5613 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5616 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5617 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5619 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5620 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5622 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5623 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5625 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5626 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5628 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5632 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5633 .f = cmd_set_uc_hash_parsed,
5635 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5637 (void *)&cmd_set_uc_hash_set,
5638 (void *)&cmd_set_uc_hash_port,
5639 (void *)&cmd_set_uc_hash_portid,
5640 (void *)&cmd_set_uc_hash_what,
5641 (void *)&cmd_set_uc_hash_mac,
5642 (void *)&cmd_set_uc_hash_mode,
5647 struct cmd_set_uc_all_hash_table {
5648 cmdline_fixed_string_t set;
5649 cmdline_fixed_string_t port;
5651 cmdline_fixed_string_t what;
5652 cmdline_fixed_string_t value;
5653 cmdline_fixed_string_t mode;
5657 cmd_set_uc_all_hash_parsed(void *parsed_result,
5658 __attribute__((unused)) struct cmdline *cl,
5659 __attribute__((unused)) void *data)
5662 struct cmd_set_uc_all_hash_table *res = parsed_result;
5664 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5666 if ((strcmp(res->what, "uta") == 0) &&
5667 (strcmp(res->value, "all") == 0))
5668 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5670 printf("bad unicast hash table parameter,"
5671 "return code = %d \n", ret);
5674 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5675 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5677 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5680 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5681 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5683 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5686 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5689 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5693 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5694 .f = cmd_set_uc_all_hash_parsed,
5696 .help_str = "set port X uta all on|off (X = port number)",
5698 (void *)&cmd_set_uc_all_hash_set,
5699 (void *)&cmd_set_uc_all_hash_port,
5700 (void *)&cmd_set_uc_all_hash_portid,
5701 (void *)&cmd_set_uc_all_hash_what,
5702 (void *)&cmd_set_uc_all_hash_value,
5703 (void *)&cmd_set_uc_all_hash_mode,
5708 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5709 struct cmd_set_vf_macvlan_filter {
5710 cmdline_fixed_string_t set;
5711 cmdline_fixed_string_t port;
5713 cmdline_fixed_string_t vf;
5715 struct ether_addr address;
5716 cmdline_fixed_string_t filter_type;
5717 cmdline_fixed_string_t mode;
5721 cmd_set_vf_macvlan_parsed(void *parsed_result,
5722 __attribute__((unused)) struct cmdline *cl,
5723 __attribute__((unused)) void *data)
5726 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5727 struct rte_eth_mac_filter filter;
5729 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5731 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5733 /* set VF MAC filter */
5737 filter.dst_id = res->vf_id;
5739 if (!strcmp(res->filter_type, "exact-mac"))
5740 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5741 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5742 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5743 else if (!strcmp(res->filter_type, "hashmac"))
5744 filter.filter_type = RTE_MAC_HASH_MATCH;
5745 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5746 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5748 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5751 ret = rte_eth_dev_filter_ctrl(res->port_id,
5752 RTE_ETH_FILTER_MACVLAN,
5756 ret = rte_eth_dev_filter_ctrl(res->port_id,
5757 RTE_ETH_FILTER_MACVLAN,
5758 RTE_ETH_FILTER_DELETE,
5762 printf("bad set MAC hash parameter, return code = %d\n", ret);
5766 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5769 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5770 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5772 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5773 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5775 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5776 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5778 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5779 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5781 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5782 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5784 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5786 filter_type, "exact-mac#exact-mac-vlan"
5787 "#hashmac#hashmac-vlan");
5788 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5789 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5792 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5793 .f = cmd_set_vf_macvlan_parsed,
5795 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5796 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5798 "exact match rule:exact match of MAC or MAC and VLAN; "
5799 "hash match rule: hash match of MAC and exact match "
5802 (void *)&cmd_set_vf_macvlan_set,
5803 (void *)&cmd_set_vf_macvlan_port,
5804 (void *)&cmd_set_vf_macvlan_portid,
5805 (void *)&cmd_set_vf_macvlan_vf,
5806 (void *)&cmd_set_vf_macvlan_vf_id,
5807 (void *)&cmd_set_vf_macvlan_mac,
5808 (void *)&cmd_set_vf_macvlan_filter_type,
5809 (void *)&cmd_set_vf_macvlan_mode,
5814 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5815 struct cmd_set_vf_traffic {
5816 cmdline_fixed_string_t set;
5817 cmdline_fixed_string_t port;
5819 cmdline_fixed_string_t vf;
5821 cmdline_fixed_string_t what;
5822 cmdline_fixed_string_t mode;
5826 cmd_set_vf_traffic_parsed(void *parsed_result,
5827 __attribute__((unused)) struct cmdline *cl,
5828 __attribute__((unused)) void *data)
5830 struct cmd_set_vf_traffic *res = parsed_result;
5831 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5832 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5834 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5837 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5840 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5843 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5844 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5846 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5849 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5850 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5852 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5855 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5856 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5859 cmdline_parse_inst_t cmd_set_vf_traffic = {
5860 .f = cmd_set_vf_traffic_parsed,
5862 .help_str = "set port X vf Y rx|tx on|off"
5863 "(X = port number,Y = vf id)",
5865 (void *)&cmd_setvf_traffic_set,
5866 (void *)&cmd_setvf_traffic_port,
5867 (void *)&cmd_setvf_traffic_portid,
5868 (void *)&cmd_setvf_traffic_vf,
5869 (void *)&cmd_setvf_traffic_vfid,
5870 (void *)&cmd_setvf_traffic_what,
5871 (void *)&cmd_setvf_traffic_mode,
5876 /* *** CONFIGURE VF RECEIVE MODE *** */
5877 struct cmd_set_vf_rxmode {
5878 cmdline_fixed_string_t set;
5879 cmdline_fixed_string_t port;
5881 cmdline_fixed_string_t vf;
5883 cmdline_fixed_string_t what;
5884 cmdline_fixed_string_t mode;
5885 cmdline_fixed_string_t on;
5889 cmd_set_vf_rxmode_parsed(void *parsed_result,
5890 __attribute__((unused)) struct cmdline *cl,
5891 __attribute__((unused)) void *data)
5894 uint16_t rx_mode = 0;
5895 struct cmd_set_vf_rxmode *res = parsed_result;
5897 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5898 if (!strcmp(res->what,"rxmode")) {
5899 if (!strcmp(res->mode, "AUPE"))
5900 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5901 else if (!strcmp(res->mode, "ROPE"))
5902 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5903 else if (!strcmp(res->mode, "BAM"))
5904 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5905 else if (!strncmp(res->mode, "MPE",3))
5906 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5909 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5911 printf("bad VF receive mode parameter, return code = %d \n",
5915 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5916 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5918 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5919 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5921 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5922 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5924 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5925 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5927 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5928 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5930 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5933 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5935 mode, "AUPE#ROPE#BAM#MPE");
5936 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5937 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5940 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5941 .f = cmd_set_vf_rxmode_parsed,
5943 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5945 (void *)&cmd_set_vf_rxmode_set,
5946 (void *)&cmd_set_vf_rxmode_port,
5947 (void *)&cmd_set_vf_rxmode_portid,
5948 (void *)&cmd_set_vf_rxmode_vf,
5949 (void *)&cmd_set_vf_rxmode_vfid,
5950 (void *)&cmd_set_vf_rxmode_what,
5951 (void *)&cmd_set_vf_rxmode_mode,
5952 (void *)&cmd_set_vf_rxmode_on,
5957 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5958 struct cmd_vf_mac_addr_result {
5959 cmdline_fixed_string_t mac_addr_cmd;
5960 cmdline_fixed_string_t what;
5961 cmdline_fixed_string_t port;
5963 cmdline_fixed_string_t vf;
5965 struct ether_addr address;
5968 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5969 __attribute__((unused)) struct cmdline *cl,
5970 __attribute__((unused)) void *data)
5972 struct cmd_vf_mac_addr_result *res = parsed_result;
5975 if (strcmp(res->what, "add") == 0)
5976 ret = rte_eth_dev_mac_addr_add(res->port_num,
5977 &res->address, res->vf_num);
5979 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5983 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5984 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5985 mac_addr_cmd,"mac_addr");
5986 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5987 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5989 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5990 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5992 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5993 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5995 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5996 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5998 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5999 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6001 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6002 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6005 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6006 .f = cmd_vf_mac_addr_parsed,
6008 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6009 "Y = VF number)add MAC address filtering for a VF on port X",
6011 (void *)&cmd_vf_mac_addr_cmd,
6012 (void *)&cmd_vf_mac_addr_what,
6013 (void *)&cmd_vf_mac_addr_port,
6014 (void *)&cmd_vf_mac_addr_portnum,
6015 (void *)&cmd_vf_mac_addr_vf,
6016 (void *)&cmd_vf_mac_addr_vfnum,
6017 (void *)&cmd_vf_mac_addr_addr,
6022 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6023 struct cmd_vf_rx_vlan_filter {
6024 cmdline_fixed_string_t rx_vlan;
6025 cmdline_fixed_string_t what;
6027 cmdline_fixed_string_t port;
6029 cmdline_fixed_string_t vf;
6034 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6035 __attribute__((unused)) struct cmdline *cl,
6036 __attribute__((unused)) void *data)
6038 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6040 if (!strcmp(res->what, "add"))
6041 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6043 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6046 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6047 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6048 rx_vlan, "rx_vlan");
6049 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6050 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6052 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6053 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6055 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6056 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6058 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6059 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6061 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6062 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6064 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6065 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6068 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6069 .f = cmd_vf_rx_vlan_filter_parsed,
6071 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6072 "Y = port number,Z = hexadecimal VF mask)",
6074 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6075 (void *)&cmd_vf_rx_vlan_filter_what,
6076 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6077 (void *)&cmd_vf_rx_vlan_filter_port,
6078 (void *)&cmd_vf_rx_vlan_filter_portid,
6079 (void *)&cmd_vf_rx_vlan_filter_vf,
6080 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6085 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6086 struct cmd_queue_rate_limit_result {
6087 cmdline_fixed_string_t set;
6088 cmdline_fixed_string_t port;
6090 cmdline_fixed_string_t queue;
6092 cmdline_fixed_string_t rate;
6096 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6097 __attribute__((unused)) struct cmdline *cl,
6098 __attribute__((unused)) void *data)
6100 struct cmd_queue_rate_limit_result *res = parsed_result;
6103 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6104 && (strcmp(res->queue, "queue") == 0)
6105 && (strcmp(res->rate, "rate") == 0))
6106 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6109 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6113 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6114 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6116 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6117 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6119 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6120 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6122 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6123 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6125 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6126 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6128 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6129 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6131 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6132 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6135 cmdline_parse_inst_t cmd_queue_rate_limit = {
6136 .f = cmd_queue_rate_limit_parsed,
6138 .help_str = "set port X queue Y rate Z:(X = port number,"
6139 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6141 (void *)&cmd_queue_rate_limit_set,
6142 (void *)&cmd_queue_rate_limit_port,
6143 (void *)&cmd_queue_rate_limit_portnum,
6144 (void *)&cmd_queue_rate_limit_queue,
6145 (void *)&cmd_queue_rate_limit_queuenum,
6146 (void *)&cmd_queue_rate_limit_rate,
6147 (void *)&cmd_queue_rate_limit_ratenum,
6152 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6153 struct cmd_vf_rate_limit_result {
6154 cmdline_fixed_string_t set;
6155 cmdline_fixed_string_t port;
6157 cmdline_fixed_string_t vf;
6159 cmdline_fixed_string_t rate;
6161 cmdline_fixed_string_t q_msk;
6165 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6166 __attribute__((unused)) struct cmdline *cl,
6167 __attribute__((unused)) void *data)
6169 struct cmd_vf_rate_limit_result *res = parsed_result;
6172 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6173 && (strcmp(res->vf, "vf") == 0)
6174 && (strcmp(res->rate, "rate") == 0)
6175 && (strcmp(res->q_msk, "queue_mask") == 0))
6176 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6177 res->rate_num, res->q_msk_val);
6179 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6183 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6184 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6186 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6187 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6189 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6190 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6192 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6193 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6195 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6196 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6198 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6199 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6201 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6202 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6204 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6205 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6206 q_msk, "queue_mask");
6207 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6208 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6211 cmdline_parse_inst_t cmd_vf_rate_limit = {
6212 .f = cmd_vf_rate_limit_parsed,
6214 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6215 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6216 "for queues of VF on port X",
6218 (void *)&cmd_vf_rate_limit_set,
6219 (void *)&cmd_vf_rate_limit_port,
6220 (void *)&cmd_vf_rate_limit_portnum,
6221 (void *)&cmd_vf_rate_limit_vf,
6222 (void *)&cmd_vf_rate_limit_vfnum,
6223 (void *)&cmd_vf_rate_limit_rate,
6224 (void *)&cmd_vf_rate_limit_ratenum,
6225 (void *)&cmd_vf_rate_limit_q_msk,
6226 (void *)&cmd_vf_rate_limit_q_msk_val,
6231 /* *** ADD TUNNEL FILTER OF A PORT *** */
6232 struct cmd_tunnel_filter_result {
6233 cmdline_fixed_string_t cmd;
6234 cmdline_fixed_string_t what;
6236 struct ether_addr outer_mac;
6237 struct ether_addr inner_mac;
6238 cmdline_ipaddr_t ip_value;
6239 uint16_t inner_vlan;
6240 cmdline_fixed_string_t tunnel_type;
6241 cmdline_fixed_string_t filter_type;
6247 cmd_tunnel_filter_parsed(void *parsed_result,
6248 __attribute__((unused)) struct cmdline *cl,
6249 __attribute__((unused)) void *data)
6251 struct cmd_tunnel_filter_result *res = parsed_result;
6252 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6255 tunnel_filter_conf.outer_mac = &res->outer_mac;
6256 tunnel_filter_conf.inner_mac = &res->inner_mac;
6257 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6259 if (res->ip_value.family == AF_INET) {
6260 tunnel_filter_conf.ip_addr.ipv4_addr =
6261 res->ip_value.addr.ipv4.s_addr;
6262 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6264 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6265 &(res->ip_value.addr.ipv6),
6266 sizeof(struct in6_addr));
6267 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6270 if (!strcmp(res->filter_type, "imac-ivlan"))
6271 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6272 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6273 tunnel_filter_conf.filter_type =
6274 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6275 else if (!strcmp(res->filter_type, "imac-tenid"))
6276 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6277 else if (!strcmp(res->filter_type, "imac"))
6278 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6279 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6280 tunnel_filter_conf.filter_type =
6281 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6283 printf("The filter type is not supported");
6287 if (!strcmp(res->tunnel_type, "vxlan"))
6288 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6290 printf("Only VXLAN is supported now.\n");
6294 tunnel_filter_conf.tenant_id = res->tenant_id;
6295 tunnel_filter_conf.queue_id = res->queue_num;
6296 if (!strcmp(res->what, "add"))
6297 ret = rte_eth_dev_filter_ctrl(res->port_id,
6298 RTE_ETH_FILTER_TUNNEL,
6300 &tunnel_filter_conf);
6302 ret = rte_eth_dev_filter_ctrl(res->port_id,
6303 RTE_ETH_FILTER_TUNNEL,
6304 RTE_ETH_FILTER_DELETE,
6305 &tunnel_filter_conf);
6307 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6311 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6312 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6313 cmd, "tunnel_filter");
6314 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6315 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6317 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6318 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6320 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6321 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6323 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6324 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6326 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6327 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6328 inner_vlan, UINT16);
6329 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6330 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6332 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6333 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6334 tunnel_type, "vxlan");
6336 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6337 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6338 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6339 "imac#omac-imac-tenid");
6340 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6341 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6343 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6344 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6347 cmdline_parse_inst_t cmd_tunnel_filter = {
6348 .f = cmd_tunnel_filter_parsed,
6350 .help_str = "add/rm tunnel filter of a port: "
6351 "tunnel_filter add port_id outer_mac inner_mac ip "
6352 "inner_vlan tunnel_type(vxlan) filter_type "
6353 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6354 "imac|omac-imac-tenid) "
6355 "tenant_id queue_num",
6357 (void *)&cmd_tunnel_filter_cmd,
6358 (void *)&cmd_tunnel_filter_what,
6359 (void *)&cmd_tunnel_filter_port_id,
6360 (void *)&cmd_tunnel_filter_outer_mac,
6361 (void *)&cmd_tunnel_filter_inner_mac,
6362 (void *)&cmd_tunnel_filter_ip_value,
6363 (void *)&cmd_tunnel_filter_innner_vlan,
6364 (void *)&cmd_tunnel_filter_tunnel_type,
6365 (void *)&cmd_tunnel_filter_filter_type,
6366 (void *)&cmd_tunnel_filter_tenant_id,
6367 (void *)&cmd_tunnel_filter_queue_num,
6372 /* *** CONFIGURE TUNNEL UDP PORT *** */
6373 struct cmd_tunnel_udp_config {
6374 cmdline_fixed_string_t cmd;
6375 cmdline_fixed_string_t what;
6381 cmd_tunnel_udp_config_parsed(void *parsed_result,
6382 __attribute__((unused)) struct cmdline *cl,
6383 __attribute__((unused)) void *data)
6385 struct cmd_tunnel_udp_config *res = parsed_result;
6386 struct rte_eth_udp_tunnel tunnel_udp;
6389 tunnel_udp.udp_port = res->udp_port;
6391 if (!strcmp(res->cmd, "rx_vxlan_port"))
6392 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6394 if (!strcmp(res->what, "add"))
6395 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6397 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6400 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6403 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6404 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6405 cmd, "rx_vxlan_port");
6406 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6407 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6409 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6410 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6412 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6413 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6416 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6417 .f = cmd_tunnel_udp_config_parsed,
6419 .help_str = "add/rm an tunneling UDP port filter: "
6420 "rx_vxlan_port add udp_port port_id",
6422 (void *)&cmd_tunnel_udp_config_cmd,
6423 (void *)&cmd_tunnel_udp_config_what,
6424 (void *)&cmd_tunnel_udp_config_udp_port,
6425 (void *)&cmd_tunnel_udp_config_port_id,
6430 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6431 struct cmd_set_mirror_mask_result {
6432 cmdline_fixed_string_t set;
6433 cmdline_fixed_string_t port;
6435 cmdline_fixed_string_t mirror;
6437 cmdline_fixed_string_t what;
6438 cmdline_fixed_string_t value;
6439 cmdline_fixed_string_t dstpool;
6441 cmdline_fixed_string_t on;
6444 cmdline_parse_token_string_t cmd_mirror_mask_set =
6445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6447 cmdline_parse_token_string_t cmd_mirror_mask_port =
6448 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6450 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6451 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6453 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6454 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6455 mirror, "mirror-rule");
6456 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6457 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6459 cmdline_parse_token_string_t cmd_mirror_mask_what =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6461 what, "pool-mirror#vlan-mirror");
6462 cmdline_parse_token_string_t cmd_mirror_mask_value =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6465 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6467 dstpool, "dst-pool");
6468 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6469 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6471 cmdline_parse_token_string_t cmd_mirror_mask_on =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6476 cmd_set_mirror_mask_parsed(void *parsed_result,
6477 __attribute__((unused)) struct cmdline *cl,
6478 __attribute__((unused)) void *data)
6481 struct cmd_set_mirror_mask_result *res = parsed_result;
6482 struct rte_eth_vmdq_mirror_conf mr_conf;
6484 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6486 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6488 mr_conf.dst_pool = res->dstpool_id;
6490 if (!strcmp(res->what, "pool-mirror")) {
6491 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6492 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6493 } else if(!strcmp(res->what, "vlan-mirror")) {
6494 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6495 nb_item = parse_item_list(res->value, "core",
6496 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6500 for(i=0; i < nb_item; i++) {
6501 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6502 printf("Invalid vlan_id: must be < 4096\n");
6506 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6507 mr_conf.vlan.vlan_mask |= 1ULL << i;
6511 if(!strcmp(res->on, "on"))
6512 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6515 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6518 printf("mirror rule add error: (%s)\n", strerror(-ret));
6521 cmdline_parse_inst_t cmd_set_mirror_mask = {
6522 .f = cmd_set_mirror_mask_parsed,
6524 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6525 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6527 (void *)&cmd_mirror_mask_set,
6528 (void *)&cmd_mirror_mask_port,
6529 (void *)&cmd_mirror_mask_portid,
6530 (void *)&cmd_mirror_mask_mirror,
6531 (void *)&cmd_mirror_mask_ruleid,
6532 (void *)&cmd_mirror_mask_what,
6533 (void *)&cmd_mirror_mask_value,
6534 (void *)&cmd_mirror_mask_dstpool,
6535 (void *)&cmd_mirror_mask_poolid,
6536 (void *)&cmd_mirror_mask_on,
6541 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6542 struct cmd_set_mirror_link_result {
6543 cmdline_fixed_string_t set;
6544 cmdline_fixed_string_t port;
6546 cmdline_fixed_string_t mirror;
6548 cmdline_fixed_string_t what;
6549 cmdline_fixed_string_t dstpool;
6551 cmdline_fixed_string_t on;
6554 cmdline_parse_token_string_t cmd_mirror_link_set =
6555 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6557 cmdline_parse_token_string_t cmd_mirror_link_port =
6558 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6560 cmdline_parse_token_num_t cmd_mirror_link_portid =
6561 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6563 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6565 mirror, "mirror-rule");
6566 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6567 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6569 cmdline_parse_token_string_t cmd_mirror_link_what =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6571 what, "uplink-mirror#downlink-mirror");
6572 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6574 dstpool, "dst-pool");
6575 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6576 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6578 cmdline_parse_token_string_t cmd_mirror_link_on =
6579 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6583 cmd_set_mirror_link_parsed(void *parsed_result,
6584 __attribute__((unused)) struct cmdline *cl,
6585 __attribute__((unused)) void *data)
6588 struct cmd_set_mirror_link_result *res = parsed_result;
6589 struct rte_eth_vmdq_mirror_conf mr_conf;
6591 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6592 if(!strcmp(res->what, "uplink-mirror")) {
6593 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6594 }else if(!strcmp(res->what, "downlink-mirror"))
6595 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6597 mr_conf.dst_pool = res->dstpool_id;
6599 if(!strcmp(res->on, "on"))
6600 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6603 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6606 /* check the return value and print it if is < 0 */
6608 printf("mirror rule add error: (%s)\n", strerror(-ret));
6612 cmdline_parse_inst_t cmd_set_mirror_link = {
6613 .f = cmd_set_mirror_link_parsed,
6615 .help_str = "set port X mirror-rule Y uplink-mirror|"
6616 "downlink-mirror dst-pool Z on|off",
6618 (void *)&cmd_mirror_link_set,
6619 (void *)&cmd_mirror_link_port,
6620 (void *)&cmd_mirror_link_portid,
6621 (void *)&cmd_mirror_link_mirror,
6622 (void *)&cmd_mirror_link_ruleid,
6623 (void *)&cmd_mirror_link_what,
6624 (void *)&cmd_mirror_link_dstpool,
6625 (void *)&cmd_mirror_link_poolid,
6626 (void *)&cmd_mirror_link_on,
6631 /* *** RESET VM MIRROR RULE *** */
6632 struct cmd_rm_mirror_rule_result {
6633 cmdline_fixed_string_t reset;
6634 cmdline_fixed_string_t port;
6636 cmdline_fixed_string_t mirror;
6640 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6641 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6643 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6644 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6646 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6647 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6649 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6650 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6651 mirror, "mirror-rule");
6652 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6653 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6657 cmd_reset_mirror_rule_parsed(void *parsed_result,
6658 __attribute__((unused)) struct cmdline *cl,
6659 __attribute__((unused)) void *data)
6662 struct cmd_set_mirror_link_result *res = parsed_result;
6664 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6666 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6669 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6670 .f = cmd_reset_mirror_rule_parsed,
6672 .help_str = "reset port X mirror-rule Y",
6674 (void *)&cmd_rm_mirror_rule_reset,
6675 (void *)&cmd_rm_mirror_rule_port,
6676 (void *)&cmd_rm_mirror_rule_portid,
6677 (void *)&cmd_rm_mirror_rule_mirror,
6678 (void *)&cmd_rm_mirror_rule_ruleid,
6683 /* ******************************************************************************** */
6685 struct cmd_dump_result {
6686 cmdline_fixed_string_t dump;
6690 dump_struct_sizes(void)
6692 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6693 DUMP_SIZE(struct rte_mbuf);
6694 DUMP_SIZE(struct rte_mempool);
6695 DUMP_SIZE(struct rte_ring);
6699 static void cmd_dump_parsed(void *parsed_result,
6700 __attribute__((unused)) struct cmdline *cl,
6701 __attribute__((unused)) void *data)
6703 struct cmd_dump_result *res = parsed_result;
6705 if (!strcmp(res->dump, "dump_physmem"))
6706 rte_dump_physmem_layout(stdout);
6707 else if (!strcmp(res->dump, "dump_memzone"))
6708 rte_memzone_dump(stdout);
6709 else if (!strcmp(res->dump, "dump_log_history"))
6710 rte_log_dump_history(stdout);
6711 else if (!strcmp(res->dump, "dump_struct_sizes"))
6712 dump_struct_sizes();
6713 else if (!strcmp(res->dump, "dump_ring"))
6714 rte_ring_list_dump(stdout);
6715 else if (!strcmp(res->dump, "dump_mempool"))
6716 rte_mempool_list_dump(stdout);
6717 else if (!strcmp(res->dump, "dump_devargs"))
6718 rte_eal_devargs_dump(stdout);
6721 cmdline_parse_token_string_t cmd_dump_dump =
6722 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6726 "dump_struct_sizes#"
6731 cmdline_parse_inst_t cmd_dump = {
6732 .f = cmd_dump_parsed, /* function to call */
6733 .data = NULL, /* 2nd arg of func */
6734 .help_str = "dump status",
6735 .tokens = { /* token list, NULL terminated */
6736 (void *)&cmd_dump_dump,
6741 /* ******************************************************************************** */
6743 struct cmd_dump_one_result {
6744 cmdline_fixed_string_t dump;
6745 cmdline_fixed_string_t name;
6748 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6749 __attribute__((unused)) void *data)
6751 struct cmd_dump_one_result *res = parsed_result;
6753 if (!strcmp(res->dump, "dump_ring")) {
6755 r = rte_ring_lookup(res->name);
6757 cmdline_printf(cl, "Cannot find ring\n");
6760 rte_ring_dump(stdout, r);
6761 } else if (!strcmp(res->dump, "dump_mempool")) {
6762 struct rte_mempool *mp;
6763 mp = rte_mempool_lookup(res->name);
6765 cmdline_printf(cl, "Cannot find mempool\n");
6768 rte_mempool_dump(stdout, mp);
6772 cmdline_parse_token_string_t cmd_dump_one_dump =
6773 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6774 "dump_ring#dump_mempool");
6776 cmdline_parse_token_string_t cmd_dump_one_name =
6777 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6779 cmdline_parse_inst_t cmd_dump_one = {
6780 .f = cmd_dump_one_parsed, /* function to call */
6781 .data = NULL, /* 2nd arg of func */
6782 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6783 .tokens = { /* token list, NULL terminated */
6784 (void *)&cmd_dump_one_dump,
6785 (void *)&cmd_dump_one_name,
6790 /* *** Add/Del syn filter *** */
6791 struct cmd_syn_filter_result {
6792 cmdline_fixed_string_t filter;
6794 cmdline_fixed_string_t ops;
6795 cmdline_fixed_string_t priority;
6796 cmdline_fixed_string_t high;
6797 cmdline_fixed_string_t queue;
6802 cmd_syn_filter_parsed(void *parsed_result,
6803 __attribute__((unused)) struct cmdline *cl,
6804 __attribute__((unused)) void *data)
6806 struct cmd_syn_filter_result *res = parsed_result;
6807 struct rte_eth_syn_filter syn_filter;
6810 ret = rte_eth_dev_filter_supported(res->port_id,
6811 RTE_ETH_FILTER_SYN);
6813 printf("syn filter is not supported on port %u.\n",
6818 memset(&syn_filter, 0, sizeof(syn_filter));
6820 if (!strcmp(res->ops, "add")) {
6821 if (!strcmp(res->high, "high"))
6822 syn_filter.hig_pri = 1;
6824 syn_filter.hig_pri = 0;
6826 syn_filter.queue = res->queue_id;
6827 ret = rte_eth_dev_filter_ctrl(res->port_id,
6832 ret = rte_eth_dev_filter_ctrl(res->port_id,
6834 RTE_ETH_FILTER_DELETE,
6838 printf("syn filter programming error: (%s)\n",
6842 cmdline_parse_token_string_t cmd_syn_filter_filter =
6843 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6844 filter, "syn_filter");
6845 cmdline_parse_token_num_t cmd_syn_filter_port_id =
6846 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6848 cmdline_parse_token_string_t cmd_syn_filter_ops =
6849 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6851 cmdline_parse_token_string_t cmd_syn_filter_priority =
6852 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6853 priority, "priority");
6854 cmdline_parse_token_string_t cmd_syn_filter_high =
6855 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6857 cmdline_parse_token_string_t cmd_syn_filter_queue =
6858 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6860 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6861 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6864 cmdline_parse_inst_t cmd_syn_filter = {
6865 .f = cmd_syn_filter_parsed,
6867 .help_str = "add/delete syn filter",
6869 (void *)&cmd_syn_filter_filter,
6870 (void *)&cmd_syn_filter_port_id,
6871 (void *)&cmd_syn_filter_ops,
6872 (void *)&cmd_syn_filter_priority,
6873 (void *)&cmd_syn_filter_high,
6874 (void *)&cmd_syn_filter_queue,
6875 (void *)&cmd_syn_filter_queue_id,
6880 /* *** ADD/REMOVE A 2tuple FILTER *** */
6881 struct cmd_2tuple_filter_result {
6882 cmdline_fixed_string_t filter;
6884 cmdline_fixed_string_t ops;
6885 cmdline_fixed_string_t dst_port;
6886 uint16_t dst_port_value;
6887 cmdline_fixed_string_t protocol;
6888 uint8_t protocol_value;
6889 cmdline_fixed_string_t mask;
6891 cmdline_fixed_string_t tcp_flags;
6892 uint8_t tcp_flags_value;
6893 cmdline_fixed_string_t priority;
6894 uint8_t priority_value;
6895 cmdline_fixed_string_t queue;
6900 cmd_2tuple_filter_parsed(void *parsed_result,
6901 __attribute__((unused)) struct cmdline *cl,
6902 __attribute__((unused)) void *data)
6904 struct rte_eth_ntuple_filter filter;
6905 struct cmd_2tuple_filter_result *res = parsed_result;
6908 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
6910 printf("ntuple filter is not supported on port %u.\n",
6915 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
6917 filter.flags = RTE_2TUPLE_FLAGS;
6918 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
6919 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
6920 filter.proto = res->protocol_value;
6921 filter.priority = res->priority_value;
6922 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
6923 printf("nonzero tcp_flags is only meaningful"
6924 " when protocol is TCP.\n");
6927 if (res->tcp_flags_value > TCP_FLAG_ALL) {
6928 printf("invalid TCP flags.\n");
6932 if (res->tcp_flags_value != 0) {
6933 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
6934 filter.tcp_flags = res->tcp_flags_value;
6937 /* need convert to big endian. */
6938 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6939 filter.queue = res->queue_id;
6941 if (!strcmp(res->ops, "add"))
6942 ret = rte_eth_dev_filter_ctrl(res->port_id,
6943 RTE_ETH_FILTER_NTUPLE,
6947 ret = rte_eth_dev_filter_ctrl(res->port_id,
6948 RTE_ETH_FILTER_NTUPLE,
6949 RTE_ETH_FILTER_DELETE,
6952 printf("2tuple filter programming error: (%s)\n",
6957 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
6958 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6959 filter, "2tuple_filter");
6960 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6961 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6963 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
6964 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6966 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6967 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6968 dst_port, "dst_port");
6969 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6970 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6971 dst_port_value, UINT16);
6972 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6973 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6974 protocol, "protocol");
6975 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6976 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6977 protocol_value, UINT8);
6978 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
6979 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6981 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
6982 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6984 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
6985 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6986 tcp_flags, "tcp_flags");
6987 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
6988 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6989 tcp_flags_value, UINT8);
6990 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6991 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6992 priority, "priority");
6993 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6994 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6995 priority_value, UINT8);
6996 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6997 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6999 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7000 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7003 cmdline_parse_inst_t cmd_2tuple_filter = {
7004 .f = cmd_2tuple_filter_parsed,
7006 .help_str = "add a 2tuple filter",
7008 (void *)&cmd_2tuple_filter_filter,
7009 (void *)&cmd_2tuple_filter_port_id,
7010 (void *)&cmd_2tuple_filter_ops,
7011 (void *)&cmd_2tuple_filter_dst_port,
7012 (void *)&cmd_2tuple_filter_dst_port_value,
7013 (void *)&cmd_2tuple_filter_protocol,
7014 (void *)&cmd_2tuple_filter_protocol_value,
7015 (void *)&cmd_2tuple_filter_mask,
7016 (void *)&cmd_2tuple_filter_mask_value,
7017 (void *)&cmd_2tuple_filter_tcp_flags,
7018 (void *)&cmd_2tuple_filter_tcp_flags_value,
7019 (void *)&cmd_2tuple_filter_priority,
7020 (void *)&cmd_2tuple_filter_priority_value,
7021 (void *)&cmd_2tuple_filter_queue,
7022 (void *)&cmd_2tuple_filter_queue_id,
7027 /* *** ADD/REMOVE A 5tuple FILTER *** */
7028 struct cmd_5tuple_filter_result {
7029 cmdline_fixed_string_t filter;
7031 cmdline_fixed_string_t ops;
7032 cmdline_fixed_string_t dst_ip;
7033 cmdline_ipaddr_t dst_ip_value;
7034 cmdline_fixed_string_t src_ip;
7035 cmdline_ipaddr_t src_ip_value;
7036 cmdline_fixed_string_t dst_port;
7037 uint16_t dst_port_value;
7038 cmdline_fixed_string_t src_port;
7039 uint16_t src_port_value;
7040 cmdline_fixed_string_t protocol;
7041 uint8_t protocol_value;
7042 cmdline_fixed_string_t mask;
7044 cmdline_fixed_string_t tcp_flags;
7045 uint8_t tcp_flags_value;
7046 cmdline_fixed_string_t priority;
7047 uint8_t priority_value;
7048 cmdline_fixed_string_t queue;
7053 cmd_5tuple_filter_parsed(void *parsed_result,
7054 __attribute__((unused)) struct cmdline *cl,
7055 __attribute__((unused)) void *data)
7057 struct rte_eth_ntuple_filter filter;
7058 struct cmd_5tuple_filter_result *res = parsed_result;
7061 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7063 printf("ntuple filter is not supported on port %u.\n",
7068 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7070 filter.flags = RTE_5TUPLE_FLAGS;
7071 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7072 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7073 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7074 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7075 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7076 filter.proto = res->protocol_value;
7077 filter.priority = res->priority_value;
7078 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7079 printf("nonzero tcp_flags is only meaningful"
7080 " when protocol is TCP.\n");
7083 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7084 printf("invalid TCP flags.\n");
7088 if (res->tcp_flags_value != 0) {
7089 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7090 filter.tcp_flags = res->tcp_flags_value;
7093 if (res->dst_ip_value.family == AF_INET)
7094 /* no need to convert, already big endian. */
7095 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7097 if (filter.dst_ip_mask == 0) {
7098 printf("can not support ipv6 involved compare.\n");
7104 if (res->src_ip_value.family == AF_INET)
7105 /* no need to convert, already big endian. */
7106 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7108 if (filter.src_ip_mask == 0) {
7109 printf("can not support ipv6 involved compare.\n");
7114 /* need convert to big endian. */
7115 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7116 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7117 filter.queue = res->queue_id;
7119 if (!strcmp(res->ops, "add"))
7120 ret = rte_eth_dev_filter_ctrl(res->port_id,
7121 RTE_ETH_FILTER_NTUPLE,
7125 ret = rte_eth_dev_filter_ctrl(res->port_id,
7126 RTE_ETH_FILTER_NTUPLE,
7127 RTE_ETH_FILTER_DELETE,
7130 printf("5tuple filter programming error: (%s)\n",
7134 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7135 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7136 filter, "5tuple_filter");
7137 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7138 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7140 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7141 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7143 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7144 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7146 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7147 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7149 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7150 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7152 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7153 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7155 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7156 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7157 dst_port, "dst_port");
7158 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7159 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7160 dst_port_value, UINT16);
7161 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7162 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7163 src_port, "src_port");
7164 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7165 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7166 src_port_value, UINT16);
7167 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7168 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7169 protocol, "protocol");
7170 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7171 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7172 protocol_value, UINT8);
7173 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7174 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7176 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7177 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7179 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7180 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7181 tcp_flags, "tcp_flags");
7182 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7183 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7184 tcp_flags_value, UINT8);
7185 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7186 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7187 priority, "priority");
7188 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7189 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7190 priority_value, UINT8);
7191 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7192 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7194 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7195 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7198 cmdline_parse_inst_t cmd_5tuple_filter = {
7199 .f = cmd_5tuple_filter_parsed,
7201 .help_str = "add/del a 5tuple filter",
7203 (void *)&cmd_5tuple_filter_filter,
7204 (void *)&cmd_5tuple_filter_port_id,
7205 (void *)&cmd_5tuple_filter_ops,
7206 (void *)&cmd_5tuple_filter_dst_ip,
7207 (void *)&cmd_5tuple_filter_dst_ip_value,
7208 (void *)&cmd_5tuple_filter_src_ip,
7209 (void *)&cmd_5tuple_filter_src_ip_value,
7210 (void *)&cmd_5tuple_filter_dst_port,
7211 (void *)&cmd_5tuple_filter_dst_port_value,
7212 (void *)&cmd_5tuple_filter_src_port,
7213 (void *)&cmd_5tuple_filter_src_port_value,
7214 (void *)&cmd_5tuple_filter_protocol,
7215 (void *)&cmd_5tuple_filter_protocol_value,
7216 (void *)&cmd_5tuple_filter_mask,
7217 (void *)&cmd_5tuple_filter_mask_value,
7218 (void *)&cmd_5tuple_filter_tcp_flags,
7219 (void *)&cmd_5tuple_filter_tcp_flags_value,
7220 (void *)&cmd_5tuple_filter_priority,
7221 (void *)&cmd_5tuple_filter_priority_value,
7222 (void *)&cmd_5tuple_filter_queue,
7223 (void *)&cmd_5tuple_filter_queue_id,
7228 /* *** ADD/REMOVE A flex FILTER *** */
7229 struct cmd_flex_filter_result {
7230 cmdline_fixed_string_t filter;
7231 cmdline_fixed_string_t ops;
7233 cmdline_fixed_string_t len;
7235 cmdline_fixed_string_t bytes;
7236 cmdline_fixed_string_t bytes_value;
7237 cmdline_fixed_string_t mask;
7238 cmdline_fixed_string_t mask_value;
7239 cmdline_fixed_string_t priority;
7240 uint8_t priority_value;
7241 cmdline_fixed_string_t queue;
7245 static int xdigit2val(unsigned char c)
7250 else if (isupper(c))
7258 cmd_flex_filter_parsed(void *parsed_result,
7259 __attribute__((unused)) struct cmdline *cl,
7260 __attribute__((unused)) void *data)
7263 struct rte_eth_flex_filter filter;
7264 struct cmd_flex_filter_result *res = parsed_result;
7265 char *bytes_ptr, *mask_ptr;
7266 uint16_t len, i, j = 0;
7271 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7272 printf("the len exceed the max length 128\n");
7275 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7276 filter.len = res->len_value;
7277 filter.priority = res->priority_value;
7278 filter.queue = res->queue_id;
7279 bytes_ptr = res->bytes_value;
7280 mask_ptr = res->mask_value;
7282 /* translate bytes string to array. */
7283 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7284 (bytes_ptr[1] == 'X')))
7286 len = strnlen(bytes_ptr, res->len_value * 2);
7287 if (len == 0 || (len % 8 != 0)) {
7288 printf("please check len and bytes input\n");
7291 for (i = 0; i < len; i++) {
7293 if (isxdigit(c) == 0) {
7294 /* invalid characters. */
7295 printf("invalid input\n");
7298 val = xdigit2val(c);
7301 filter.bytes[j] = byte;
7302 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7309 /* translate mask string to uint8_t array. */
7310 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7311 (mask_ptr[1] == 'X')))
7313 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7315 printf("invalid input\n");
7320 for (i = 0; i < len; i++) {
7322 if (isxdigit(c) == 0) {
7323 /* invalid characters. */
7324 printf("invalid input\n");
7327 val = xdigit2val(c);
7330 filter.mask[j] = byte;
7331 printf("mask[%d]:%02x ", j, filter.mask[j]);
7339 if (!strcmp(res->ops, "add"))
7340 ret = rte_eth_dev_filter_ctrl(res->port_id,
7341 RTE_ETH_FILTER_FLEXIBLE,
7345 ret = rte_eth_dev_filter_ctrl(res->port_id,
7346 RTE_ETH_FILTER_FLEXIBLE,
7347 RTE_ETH_FILTER_DELETE,
7351 printf("flex filter setting error: (%s)\n", strerror(-ret));
7354 cmdline_parse_token_string_t cmd_flex_filter_filter =
7355 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7356 filter, "flex_filter");
7357 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7358 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7360 cmdline_parse_token_string_t cmd_flex_filter_ops =
7361 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7363 cmdline_parse_token_string_t cmd_flex_filter_len =
7364 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7366 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7367 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7369 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7370 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7372 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7373 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7375 cmdline_parse_token_string_t cmd_flex_filter_mask =
7376 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7378 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7379 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7381 cmdline_parse_token_string_t cmd_flex_filter_priority =
7382 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7383 priority, "priority");
7384 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7385 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7386 priority_value, UINT8);
7387 cmdline_parse_token_string_t cmd_flex_filter_queue =
7388 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7390 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7391 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7393 cmdline_parse_inst_t cmd_flex_filter = {
7394 .f = cmd_flex_filter_parsed,
7396 .help_str = "add/del a flex filter",
7398 (void *)&cmd_flex_filter_filter,
7399 (void *)&cmd_flex_filter_port_id,
7400 (void *)&cmd_flex_filter_ops,
7401 (void *)&cmd_flex_filter_len,
7402 (void *)&cmd_flex_filter_len_value,
7403 (void *)&cmd_flex_filter_bytes,
7404 (void *)&cmd_flex_filter_bytes_value,
7405 (void *)&cmd_flex_filter_mask,
7406 (void *)&cmd_flex_filter_mask_value,
7407 (void *)&cmd_flex_filter_priority,
7408 (void *)&cmd_flex_filter_priority_value,
7409 (void *)&cmd_flex_filter_queue,
7410 (void *)&cmd_flex_filter_queue_id,
7415 /* *** Filters Control *** */
7417 /* *** deal with ethertype filter *** */
7418 struct cmd_ethertype_filter_result {
7419 cmdline_fixed_string_t filter;
7421 cmdline_fixed_string_t ops;
7422 cmdline_fixed_string_t mac;
7423 struct ether_addr mac_addr;
7424 cmdline_fixed_string_t ethertype;
7425 uint16_t ethertype_value;
7426 cmdline_fixed_string_t drop;
7427 cmdline_fixed_string_t queue;
7431 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7432 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7433 filter, "ethertype_filter");
7434 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7435 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7437 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7438 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7440 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7441 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7442 mac, "mac_addr#mac_ignr");
7443 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7444 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7446 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7447 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7448 ethertype, "ethertype");
7449 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7450 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7451 ethertype_value, UINT16);
7452 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7453 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7455 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7456 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7458 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7459 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7463 cmd_ethertype_filter_parsed(void *parsed_result,
7464 __attribute__((unused)) struct cmdline *cl,
7465 __attribute__((unused)) void *data)
7467 struct cmd_ethertype_filter_result *res = parsed_result;
7468 struct rte_eth_ethertype_filter filter;
7471 ret = rte_eth_dev_filter_supported(res->port_id,
7472 RTE_ETH_FILTER_ETHERTYPE);
7474 printf("ethertype filter is not supported on port %u.\n",
7479 memset(&filter, 0, sizeof(filter));
7480 if (!strcmp(res->mac, "mac_addr")) {
7481 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7482 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7483 sizeof(struct ether_addr));
7485 if (!strcmp(res->drop, "drop"))
7486 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7487 filter.ether_type = res->ethertype_value;
7488 filter.queue = res->queue_id;
7490 if (!strcmp(res->ops, "add"))
7491 ret = rte_eth_dev_filter_ctrl(res->port_id,
7492 RTE_ETH_FILTER_ETHERTYPE,
7496 ret = rte_eth_dev_filter_ctrl(res->port_id,
7497 RTE_ETH_FILTER_ETHERTYPE,
7498 RTE_ETH_FILTER_DELETE,
7501 printf("ethertype filter programming error: (%s)\n",
7505 cmdline_parse_inst_t cmd_ethertype_filter = {
7506 .f = cmd_ethertype_filter_parsed,
7508 .help_str = "add or delete an ethertype filter entry",
7510 (void *)&cmd_ethertype_filter_filter,
7511 (void *)&cmd_ethertype_filter_port_id,
7512 (void *)&cmd_ethertype_filter_ops,
7513 (void *)&cmd_ethertype_filter_mac,
7514 (void *)&cmd_ethertype_filter_mac_addr,
7515 (void *)&cmd_ethertype_filter_ethertype,
7516 (void *)&cmd_ethertype_filter_ethertype_value,
7517 (void *)&cmd_ethertype_filter_drop,
7518 (void *)&cmd_ethertype_filter_queue,
7519 (void *)&cmd_ethertype_filter_queue_id,
7524 /* *** deal with flow director filter *** */
7525 struct cmd_flow_director_result {
7526 cmdline_fixed_string_t flow_director_filter;
7528 cmdline_fixed_string_t ops;
7529 cmdline_fixed_string_t flow;
7530 cmdline_fixed_string_t flow_type;
7531 cmdline_fixed_string_t src;
7532 cmdline_ipaddr_t ip_src;
7534 cmdline_fixed_string_t dst;
7535 cmdline_ipaddr_t ip_dst;
7537 cmdline_fixed_string_t verify_tag;
7538 uint32_t verify_tag_value;
7539 cmdline_fixed_string_t vlan;
7540 uint16_t vlan_value;
7541 cmdline_fixed_string_t flexbytes;
7542 cmdline_fixed_string_t flexbytes_value;
7543 cmdline_fixed_string_t drop;
7544 cmdline_fixed_string_t queue;
7546 cmdline_fixed_string_t fd_id;
7547 uint32_t fd_id_value;
7551 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7554 const char *p, *p0 = q_arg;
7556 unsigned long int_fld;
7557 char *str_fld[max_num];
7562 p = strchr(p0, '(');
7566 p0 = strchr(p, ')');
7571 if (size >= sizeof(s))
7574 snprintf(s, sizeof(s), "%.*s", size, p);
7575 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7576 if (ret < 0 || ret > max_num)
7578 for (i = 0; i < ret; i++) {
7580 int_fld = strtoul(str_fld[i], &end, 0);
7581 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7583 flexbytes[i] = (uint8_t)int_fld;
7589 str2flowtype(char *string)
7592 static const struct {
7595 } flowtype_str[] = {
7596 {"raw", RTE_ETH_FLOW_RAW},
7597 {"ipv4", RTE_ETH_FLOW_IPV4},
7598 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
7599 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
7600 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
7601 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
7602 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
7603 {"ipv6", RTE_ETH_FLOW_IPV6},
7604 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
7605 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
7606 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
7607 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
7608 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
7609 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
7612 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7613 if (!strcmp(flowtype_str[i].str, string))
7614 return flowtype_str[i].type;
7616 return RTE_ETH_FLOW_UNKNOWN;
7619 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7621 if ((ip_addr).family == AF_INET) \
7622 (ip) = (ip_addr).addr.ipv4.s_addr; \
7624 printf("invalid parameter.\n"); \
7629 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7631 if ((ip_addr).family == AF_INET6) \
7632 (void)rte_memcpy(&(ip), \
7633 &((ip_addr).addr.ipv6), \
7634 sizeof(struct in6_addr)); \
7636 printf("invalid parameter.\n"); \
7642 cmd_flow_director_filter_parsed(void *parsed_result,
7643 __attribute__((unused)) struct cmdline *cl,
7644 __attribute__((unused)) void *data)
7646 struct cmd_flow_director_result *res = parsed_result;
7647 struct rte_eth_fdir_filter entry;
7648 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7651 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7653 printf("flow director is not supported on port %u.\n",
7657 memset(flexbytes, 0, sizeof(flexbytes));
7658 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7659 ret = parse_flexbytes(res->flexbytes_value,
7661 RTE_ETH_FDIR_MAX_FLEXLEN);
7663 printf("error: Cannot parse flexbytes input.\n");
7667 entry.input.flow_type = str2flowtype(res->flow_type);
7668 switch (entry.input.flow_type) {
7669 case RTE_ETH_FLOW_FRAG_IPV4:
7670 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
7671 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
7672 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
7673 IPV4_ADDR_TO_UINT(res->ip_dst,
7674 entry.input.flow.ip4_flow.dst_ip);
7675 IPV4_ADDR_TO_UINT(res->ip_src,
7676 entry.input.flow.ip4_flow.src_ip);
7677 /* need convert to big endian. */
7678 entry.input.flow.udp4_flow.dst_port =
7679 rte_cpu_to_be_16(res->port_dst);
7680 entry.input.flow.udp4_flow.src_port =
7681 rte_cpu_to_be_16(res->port_src);
7683 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
7684 IPV4_ADDR_TO_UINT(res->ip_dst,
7685 entry.input.flow.sctp4_flow.ip.dst_ip);
7686 IPV4_ADDR_TO_UINT(res->ip_src,
7687 entry.input.flow.sctp4_flow.ip.src_ip);
7688 /* need convert to big endian. */
7689 entry.input.flow.sctp4_flow.verify_tag =
7690 rte_cpu_to_be_32(res->verify_tag_value);
7692 case RTE_ETH_FLOW_FRAG_IPV6:
7693 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
7694 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
7695 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
7696 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7697 entry.input.flow.ipv6_flow.dst_ip);
7698 IPV6_ADDR_TO_ARRAY(res->ip_src,
7699 entry.input.flow.ipv6_flow.src_ip);
7700 /* need convert to big endian. */
7701 entry.input.flow.udp6_flow.dst_port =
7702 rte_cpu_to_be_16(res->port_dst);
7703 entry.input.flow.udp6_flow.src_port =
7704 rte_cpu_to_be_16(res->port_src);
7706 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
7707 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7708 entry.input.flow.sctp6_flow.ip.dst_ip);
7709 IPV6_ADDR_TO_ARRAY(res->ip_src,
7710 entry.input.flow.sctp6_flow.ip.src_ip);
7711 /* need convert to big endian. */
7712 entry.input.flow.sctp6_flow.verify_tag =
7713 rte_cpu_to_be_32(res->verify_tag_value);
7716 printf("invalid parameter.\n");
7719 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7721 RTE_ETH_FDIR_MAX_FLEXLEN);
7723 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7725 entry.action.flex_off = 0; /*use 0 by default */
7726 if (!strcmp(res->drop, "drop"))
7727 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7729 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7730 /* set to report FD ID by default */
7731 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7732 entry.action.rx_queue = res->queue_id;
7733 entry.soft_id = res->fd_id_value;
7734 if (!strcmp(res->ops, "add"))
7735 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7736 RTE_ETH_FILTER_ADD, &entry);
7737 else if (!strcmp(res->ops, "del"))
7738 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7739 RTE_ETH_FILTER_DELETE, &entry);
7741 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7742 RTE_ETH_FILTER_UPDATE, &entry);
7744 printf("flow director programming error: (%s)\n",
7748 cmdline_parse_token_string_t cmd_flow_director_filter =
7749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7750 flow_director_filter, "flow_director_filter");
7751 cmdline_parse_token_num_t cmd_flow_director_port_id =
7752 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7754 cmdline_parse_token_string_t cmd_flow_director_ops =
7755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7756 ops, "add#del#update");
7757 cmdline_parse_token_string_t cmd_flow_director_flow =
7758 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7760 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7762 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
7763 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp");
7764 cmdline_parse_token_string_t cmd_flow_director_src =
7765 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7767 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7768 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7770 cmdline_parse_token_num_t cmd_flow_director_port_src =
7771 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7773 cmdline_parse_token_string_t cmd_flow_director_dst =
7774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7776 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
7777 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7779 cmdline_parse_token_num_t cmd_flow_director_port_dst =
7780 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7782 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
7783 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7784 verify_tag, "verify_tag");
7785 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
7786 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7787 verify_tag_value, UINT32);
7788 cmdline_parse_token_string_t cmd_flow_director_vlan =
7789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7791 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
7792 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7793 vlan_value, UINT16);
7794 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
7795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7796 flexbytes, "flexbytes");
7797 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
7798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7799 flexbytes_value, NULL);
7800 cmdline_parse_token_string_t cmd_flow_director_drop =
7801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7803 cmdline_parse_token_string_t cmd_flow_director_queue =
7804 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7806 cmdline_parse_token_num_t cmd_flow_director_queue_id =
7807 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7809 cmdline_parse_token_string_t cmd_flow_director_fd_id =
7810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7812 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
7813 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7814 fd_id_value, UINT32);
7816 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
7817 .f = cmd_flow_director_filter_parsed,
7819 .help_str = "add or delete an ip flow director entry on NIC",
7821 (void *)&cmd_flow_director_filter,
7822 (void *)&cmd_flow_director_port_id,
7823 (void *)&cmd_flow_director_ops,
7824 (void *)&cmd_flow_director_flow,
7825 (void *)&cmd_flow_director_flow_type,
7826 (void *)&cmd_flow_director_src,
7827 (void *)&cmd_flow_director_ip_src,
7828 (void *)&cmd_flow_director_dst,
7829 (void *)&cmd_flow_director_ip_dst,
7830 (void *)&cmd_flow_director_vlan,
7831 (void *)&cmd_flow_director_vlan_value,
7832 (void *)&cmd_flow_director_flexbytes,
7833 (void *)&cmd_flow_director_flexbytes_value,
7834 (void *)&cmd_flow_director_drop,
7835 (void *)&cmd_flow_director_queue,
7836 (void *)&cmd_flow_director_queue_id,
7837 (void *)&cmd_flow_director_fd_id,
7838 (void *)&cmd_flow_director_fd_id_value,
7843 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
7844 .f = cmd_flow_director_filter_parsed,
7846 .help_str = "add or delete an udp/tcp flow director entry on NIC",
7848 (void *)&cmd_flow_director_filter,
7849 (void *)&cmd_flow_director_port_id,
7850 (void *)&cmd_flow_director_ops,
7851 (void *)&cmd_flow_director_flow,
7852 (void *)&cmd_flow_director_flow_type,
7853 (void *)&cmd_flow_director_src,
7854 (void *)&cmd_flow_director_ip_src,
7855 (void *)&cmd_flow_director_port_src,
7856 (void *)&cmd_flow_director_dst,
7857 (void *)&cmd_flow_director_ip_dst,
7858 (void *)&cmd_flow_director_port_dst,
7859 (void *)&cmd_flow_director_vlan,
7860 (void *)&cmd_flow_director_vlan_value,
7861 (void *)&cmd_flow_director_flexbytes,
7862 (void *)&cmd_flow_director_flexbytes_value,
7863 (void *)&cmd_flow_director_drop,
7864 (void *)&cmd_flow_director_queue,
7865 (void *)&cmd_flow_director_queue_id,
7866 (void *)&cmd_flow_director_fd_id,
7867 (void *)&cmd_flow_director_fd_id_value,
7872 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
7873 .f = cmd_flow_director_filter_parsed,
7875 .help_str = "add or delete a sctp flow director entry on NIC",
7877 (void *)&cmd_flow_director_filter,
7878 (void *)&cmd_flow_director_port_id,
7879 (void *)&cmd_flow_director_ops,
7880 (void *)&cmd_flow_director_flow,
7881 (void *)&cmd_flow_director_flow_type,
7882 (void *)&cmd_flow_director_src,
7883 (void *)&cmd_flow_director_ip_src,
7884 (void *)&cmd_flow_director_port_dst,
7885 (void *)&cmd_flow_director_dst,
7886 (void *)&cmd_flow_director_ip_dst,
7887 (void *)&cmd_flow_director_port_dst,
7888 (void *)&cmd_flow_director_verify_tag,
7889 (void *)&cmd_flow_director_verify_tag_value,
7890 (void *)&cmd_flow_director_vlan,
7891 (void *)&cmd_flow_director_vlan_value,
7892 (void *)&cmd_flow_director_flexbytes,
7893 (void *)&cmd_flow_director_flexbytes_value,
7894 (void *)&cmd_flow_director_drop,
7895 (void *)&cmd_flow_director_queue,
7896 (void *)&cmd_flow_director_queue_id,
7897 (void *)&cmd_flow_director_fd_id,
7898 (void *)&cmd_flow_director_fd_id_value,
7903 struct cmd_flush_flow_director_result {
7904 cmdline_fixed_string_t flush_flow_director;
7908 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
7909 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
7910 flush_flow_director, "flush_flow_director");
7911 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
7912 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
7916 cmd_flush_flow_director_parsed(void *parsed_result,
7917 __attribute__((unused)) struct cmdline *cl,
7918 __attribute__((unused)) void *data)
7920 struct cmd_flow_director_result *res = parsed_result;
7923 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7925 printf("flow director is not supported on port %u.\n",
7930 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7931 RTE_ETH_FILTER_FLUSH, NULL);
7933 printf("flow director table flushing error: (%s)\n",
7937 cmdline_parse_inst_t cmd_flush_flow_director = {
7938 .f = cmd_flush_flow_director_parsed,
7940 .help_str = "flush all flow director entries of a device on NIC",
7942 (void *)&cmd_flush_flow_director_flush,
7943 (void *)&cmd_flush_flow_director_port_id,
7948 /* *** deal with flow director mask *** */
7949 struct cmd_flow_director_mask_result {
7950 cmdline_fixed_string_t flow_director_mask;
7952 cmdline_fixed_string_t vlan;
7953 uint16_t vlan_value;
7954 cmdline_fixed_string_t src_mask;
7955 cmdline_ipaddr_t ipv4_src;
7956 cmdline_ipaddr_t ipv6_src;
7958 cmdline_fixed_string_t dst_mask;
7959 cmdline_ipaddr_t ipv4_dst;
7960 cmdline_ipaddr_t ipv6_dst;
7965 cmd_flow_director_mask_parsed(void *parsed_result,
7966 __attribute__((unused)) struct cmdline *cl,
7967 __attribute__((unused)) void *data)
7969 struct cmd_flow_director_mask_result *res = parsed_result;
7970 struct rte_eth_fdir_masks *mask;
7971 struct rte_port *port;
7973 if (res->port_id > nb_ports) {
7974 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
7978 port = &ports[res->port_id];
7979 /** Check if the port is not started **/
7980 if (port->port_status != RTE_PORT_STOPPED) {
7981 printf("Please stop port %d first\n", res->port_id);
7984 mask = &port->dev_conf.fdir_conf.mask;
7986 mask->vlan_tci_mask = res->vlan_value;
7987 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
7988 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
7989 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
7990 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
7991 mask->src_port_mask = res->port_src;
7992 mask->dst_port_mask = res->port_dst;
7994 cmd_reconfig_device_queue(res->port_id, 1, 1);
7997 cmdline_parse_token_string_t cmd_flow_director_mask =
7998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
7999 flow_director_mask, "flow_director_mask");
8000 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8001 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8003 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8004 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8006 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8007 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8008 vlan_value, UINT16);
8009 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8010 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8011 src_mask, "src_mask");
8012 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8013 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8015 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8016 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8018 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8019 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8021 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8022 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8023 dst_mask, "dst_mask");
8024 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8025 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8027 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8028 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8030 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8031 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8033 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8034 .f = cmd_flow_director_mask_parsed,
8036 .help_str = "set flow director's mask on NIC",
8038 (void *)&cmd_flow_director_mask,
8039 (void *)&cmd_flow_director_mask_port_id,
8040 (void *)&cmd_flow_director_mask_vlan,
8041 (void *)&cmd_flow_director_mask_vlan_value,
8042 (void *)&cmd_flow_director_mask_src,
8043 (void *)&cmd_flow_director_mask_ipv4_src,
8044 (void *)&cmd_flow_director_mask_ipv6_src,
8045 (void *)&cmd_flow_director_mask_port_src,
8046 (void *)&cmd_flow_director_mask_dst,
8047 (void *)&cmd_flow_director_mask_ipv4_dst,
8048 (void *)&cmd_flow_director_mask_ipv6_dst,
8049 (void *)&cmd_flow_director_mask_port_dst,
8054 /* *** deal with flow director mask on flexible payload *** */
8055 struct cmd_flow_director_flex_mask_result {
8056 cmdline_fixed_string_t flow_director_flexmask;
8058 cmdline_fixed_string_t flow;
8059 cmdline_fixed_string_t flow_type;
8060 cmdline_fixed_string_t mask;
8064 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8065 __attribute__((unused)) struct cmdline *cl,
8066 __attribute__((unused)) void *data)
8068 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8069 struct rte_eth_fdir_info fdir_info;
8070 struct rte_eth_fdir_flex_mask flex_mask;
8071 struct rte_port *port;
8072 uint32_t flow_type_mask;
8076 if (res->port_id > nb_ports) {
8077 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8081 port = &ports[res->port_id];
8082 /** Check if the port is not started **/
8083 if (port->port_status != RTE_PORT_STOPPED) {
8084 printf("Please stop port %d first\n", res->port_id);
8088 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8089 ret = parse_flexbytes(res->mask,
8091 RTE_ETH_FDIR_MAX_FLEXLEN);
8093 printf("error: Cannot parse mask input.\n");
8097 memset(&fdir_info, 0, sizeof(fdir_info));
8098 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8099 RTE_ETH_FILTER_INFO, &fdir_info);
8101 printf("Cannot get FDir filter info\n");
8105 flow_type_mask = fdir_info.flow_types_mask[0];
8106 if (!strcmp(res->flow_type, "all")) {
8107 if (!flow_type_mask) {
8108 printf("No flow type supported\n");
8111 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8112 if (flow_type_mask & (1 << i)) {
8113 flex_mask.flow_type = i;
8114 fdir_set_flex_mask(res->port_id, &flex_mask);
8117 cmd_reconfig_device_queue(res->port_id, 1, 1);
8120 flex_mask.flow_type = str2flowtype(res->flow_type);
8121 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8122 printf("Flow type %s not supported on port %d\n",
8123 res->flow_type, res->port_id);
8126 fdir_set_flex_mask(res->port_id, &flex_mask);
8127 cmd_reconfig_device_queue(res->port_id, 1, 1);
8130 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8131 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8132 flow_director_flexmask,
8133 "flow_director_flex_mask");
8134 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8135 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8137 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8138 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8140 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8142 flow_type, "raw#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8143 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#all");
8144 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8145 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8148 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8149 .f = cmd_flow_director_flex_mask_parsed,
8151 .help_str = "set flow director's flex mask on NIC",
8153 (void *)&cmd_flow_director_flexmask,
8154 (void *)&cmd_flow_director_flexmask_port_id,
8155 (void *)&cmd_flow_director_flexmask_flow,
8156 (void *)&cmd_flow_director_flexmask_flow_type,
8157 (void *)&cmd_flow_director_flexmask_mask,
8162 /* *** deal with flow director flexible payload configuration *** */
8163 struct cmd_flow_director_flexpayload_result {
8164 cmdline_fixed_string_t flow_director_flexpayload;
8166 cmdline_fixed_string_t payload_layer;
8167 cmdline_fixed_string_t payload_cfg;
8171 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8174 const char *p, *p0 = q_arg;
8176 unsigned long int_fld;
8177 char *str_fld[max_num];
8182 p = strchr(p0, '(');
8186 p0 = strchr(p, ')');
8191 if (size >= sizeof(s))
8194 snprintf(s, sizeof(s), "%.*s", size, p);
8195 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8196 if (ret < 0 || ret > max_num)
8198 for (i = 0; i < ret; i++) {
8200 int_fld = strtoul(str_fld[i], &end, 0);
8201 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8203 offsets[i] = (uint16_t)int_fld;
8209 cmd_flow_director_flxpld_parsed(void *parsed_result,
8210 __attribute__((unused)) struct cmdline *cl,
8211 __attribute__((unused)) void *data)
8213 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8214 struct rte_eth_flex_payload_cfg flex_cfg;
8215 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);
8230 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8232 if (!strcmp(res->payload_layer, "raw"))
8233 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8234 else if (!strcmp(res->payload_layer, "l2"))
8235 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8236 else if (!strcmp(res->payload_layer, "l3"))
8237 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8238 else if (!strcmp(res->payload_layer, "l4"))
8239 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8241 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8242 RTE_ETH_FDIR_MAX_FLEXLEN);
8244 printf("error: Cannot parse flex payload input.\n");
8248 fdir_set_flex_payload(res->port_id, &flex_cfg);
8249 cmd_reconfig_device_queue(res->port_id, 1, 1);
8252 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8254 flow_director_flexpayload,
8255 "flow_director_flex_payload");
8256 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8257 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8259 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8261 payload_layer, "raw#l2#l3#l4");
8262 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8266 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8267 .f = cmd_flow_director_flxpld_parsed,
8269 .help_str = "set flow director's flex payload on NIC",
8271 (void *)&cmd_flow_director_flexpayload,
8272 (void *)&cmd_flow_director_flexpayload_port_id,
8273 (void *)&cmd_flow_director_flexpayload_payload_layer,
8274 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8279 /* *** Classification Filters Control *** */
8280 /* *** Get symmetric hash enable per port *** */
8281 struct cmd_get_sym_hash_ena_per_port_result {
8282 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8287 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8288 __rte_unused struct cmdline *cl,
8289 __rte_unused void *data)
8291 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8292 struct rte_eth_hash_filter_info info;
8295 if (rte_eth_dev_filter_supported(res->port_id,
8296 RTE_ETH_FILTER_HASH) < 0) {
8297 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8302 memset(&info, 0, sizeof(info));
8303 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8304 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8305 RTE_ETH_FILTER_GET, &info);
8308 printf("Cannot get symmetric hash enable per port "
8309 "on port %u\n", res->port_id);
8313 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8314 "enabled" : "disabled", res->port_id);
8317 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8318 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8319 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8320 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8321 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8324 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8325 .f = cmd_get_sym_hash_per_port_parsed,
8327 .help_str = "get_sym_hash_ena_per_port port_id",
8329 (void *)&cmd_get_sym_hash_ena_per_port_all,
8330 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8335 /* *** Set symmetric hash enable per port *** */
8336 struct cmd_set_sym_hash_ena_per_port_result {
8337 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8338 cmdline_fixed_string_t enable;
8343 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8344 __rte_unused struct cmdline *cl,
8345 __rte_unused void *data)
8347 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8348 struct rte_eth_hash_filter_info info;
8351 if (rte_eth_dev_filter_supported(res->port_id,
8352 RTE_ETH_FILTER_HASH) < 0) {
8353 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8358 memset(&info, 0, sizeof(info));
8359 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8360 if (!strcmp(res->enable, "enable"))
8361 info.info.enable = 1;
8362 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8363 RTE_ETH_FILTER_SET, &info);
8365 printf("Cannot set symmetric hash enable per port on "
8366 "port %u\n", res->port_id);
8369 printf("Symmetric hash has been set to %s on port %u\n",
8370 res->enable, res->port_id);
8373 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8374 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8375 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8376 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8377 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8379 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8380 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8381 enable, "enable#disable");
8383 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8384 .f = cmd_set_sym_hash_per_port_parsed,
8386 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8388 (void *)&cmd_set_sym_hash_ena_per_port_all,
8389 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8390 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8395 /* Get global config of hash function */
8396 struct cmd_get_hash_global_config_result {
8397 cmdline_fixed_string_t get_hash_global_config;
8402 flowtype_to_str(uint16_t ftype)
8409 {"ipv4", RTE_ETH_FLOW_IPV4},
8410 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8411 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8412 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8413 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8414 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8415 {"ipv6", RTE_ETH_FLOW_IPV6},
8416 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8417 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8418 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8419 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8420 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8421 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8424 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8425 if (ftype_table[i].ftype == ftype)
8426 return ftype_table[i].str;
8433 cmd_get_hash_global_config_parsed(void *parsed_result,
8434 __rte_unused struct cmdline *cl,
8435 __rte_unused void *data)
8437 struct cmd_get_hash_global_config_result *res = parsed_result;
8438 struct rte_eth_hash_filter_info info;
8439 uint32_t idx, offset;
8444 if (rte_eth_dev_filter_supported(res->port_id,
8445 RTE_ETH_FILTER_HASH) < 0) {
8446 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8451 memset(&info, 0, sizeof(info));
8452 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8453 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8454 RTE_ETH_FILTER_GET, &info);
8456 printf("Cannot get hash global configurations by port %d\n",
8461 switch (info.info.global_conf.hash_func) {
8462 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8463 printf("Hash function is Toeplitz\n");
8465 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8466 printf("Hash function is Simple XOR\n");
8469 printf("Unknown hash function\n");
8473 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
8474 idx = i / UINT32_BIT;
8475 offset = i % UINT32_BIT;
8476 if (!(info.info.global_conf.valid_bit_mask[idx] &
8479 str = flowtype_to_str(i);
8482 printf("Symmetric hash is %s globally for flow type %s "
8484 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8485 (1UL << offset)) ? "enabled" : "disabled"), str,
8490 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8491 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8492 get_hash_global_config, "get_hash_global_config");
8493 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8494 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8497 cmdline_parse_inst_t cmd_get_hash_global_config = {
8498 .f = cmd_get_hash_global_config_parsed,
8500 .help_str = "get_hash_global_config port_id",
8502 (void *)&cmd_get_hash_global_config_all,
8503 (void *)&cmd_get_hash_global_config_port_id,
8508 /* Set global config of hash function */
8509 struct cmd_set_hash_global_config_result {
8510 cmdline_fixed_string_t set_hash_global_config;
8512 cmdline_fixed_string_t hash_func;
8513 cmdline_fixed_string_t flow_type;
8514 cmdline_fixed_string_t enable;
8518 cmd_set_hash_global_config_parsed(void *parsed_result,
8519 __rte_unused struct cmdline *cl,
8520 __rte_unused void *data)
8522 struct cmd_set_hash_global_config_result *res = parsed_result;
8523 struct rte_eth_hash_filter_info info;
8524 uint32_t ftype, idx, offset;
8527 if (rte_eth_dev_filter_supported(res->port_id,
8528 RTE_ETH_FILTER_HASH) < 0) {
8529 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8533 memset(&info, 0, sizeof(info));
8534 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8535 if (!strcmp(res->hash_func, "toeplitz"))
8536 info.info.global_conf.hash_func =
8537 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8538 else if (!strcmp(res->hash_func, "simple_xor"))
8539 info.info.global_conf.hash_func =
8540 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8541 else if (!strcmp(res->hash_func, "default"))
8542 info.info.global_conf.hash_func =
8543 RTE_ETH_HASH_FUNCTION_DEFAULT;
8545 ftype = str2flowtype(res->flow_type);
8546 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8547 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8548 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8549 if (!strcmp(res->enable, "enable"))
8550 info.info.global_conf.sym_hash_enable_mask[idx] |=
8552 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8553 RTE_ETH_FILTER_SET, &info);
8555 printf("Cannot set global hash configurations by port %d\n",
8558 printf("Global hash configurations have been set "
8559 "succcessfully by port %d\n", res->port_id);
8562 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8563 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8564 set_hash_global_config, "set_hash_global_config");
8565 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8566 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8568 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8569 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8570 hash_func, "toeplitz#simple_xor#default");
8571 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8572 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8574 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
8575 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
8576 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8577 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8578 enable, "enable#disable");
8580 cmdline_parse_inst_t cmd_set_hash_global_config = {
8581 .f = cmd_set_hash_global_config_parsed,
8583 .help_str = "set_hash_global_config port_id "
8584 "toeplitz|simple_xor|default "
8585 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
8586 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
8589 (void *)&cmd_set_hash_global_config_all,
8590 (void *)&cmd_set_hash_global_config_port_id,
8591 (void *)&cmd_set_hash_global_config_hash_func,
8592 (void *)&cmd_set_hash_global_config_flow_type,
8593 (void *)&cmd_set_hash_global_config_enable,
8598 /* ******************************************************************************** */
8600 /* list of instructions */
8601 cmdline_parse_ctx_t main_ctx[] = {
8602 (cmdline_parse_inst_t *)&cmd_help_brief,
8603 (cmdline_parse_inst_t *)&cmd_help_long,
8604 (cmdline_parse_inst_t *)&cmd_quit,
8605 (cmdline_parse_inst_t *)&cmd_showport,
8606 (cmdline_parse_inst_t *)&cmd_showportall,
8607 (cmdline_parse_inst_t *)&cmd_showcfg,
8608 (cmdline_parse_inst_t *)&cmd_start,
8609 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8610 (cmdline_parse_inst_t *)&cmd_set_link_up,
8611 (cmdline_parse_inst_t *)&cmd_set_link_down,
8612 (cmdline_parse_inst_t *)&cmd_reset,
8613 (cmdline_parse_inst_t *)&cmd_set_numbers,
8614 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8615 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8616 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8617 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8618 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8619 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8620 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8621 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8622 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8623 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8624 (cmdline_parse_inst_t *)&cmd_set_link_check,
8625 #ifdef RTE_NIC_BYPASS
8626 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8627 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8628 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8629 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8631 #ifdef RTE_LIBRTE_PMD_BOND
8632 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8633 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8634 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8635 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8636 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8637 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8638 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8639 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8640 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8642 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8643 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8644 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8645 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8646 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8647 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8648 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8649 (cmdline_parse_inst_t *)&cmd_csum_set,
8650 (cmdline_parse_inst_t *)&cmd_csum_show,
8651 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8652 (cmdline_parse_inst_t *)&cmd_tso_set,
8653 (cmdline_parse_inst_t *)&cmd_tso_show,
8654 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8655 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8656 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8657 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8658 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8659 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8660 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8661 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8662 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8663 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8664 (cmdline_parse_inst_t *)&cmd_config_dcb,
8665 (cmdline_parse_inst_t *)&cmd_read_reg,
8666 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8667 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8668 (cmdline_parse_inst_t *)&cmd_write_reg,
8669 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8670 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8671 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8672 (cmdline_parse_inst_t *)&cmd_stop,
8673 (cmdline_parse_inst_t *)&cmd_mac_addr,
8674 (cmdline_parse_inst_t *)&cmd_set_qmap,
8675 (cmdline_parse_inst_t *)&cmd_operate_port,
8676 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8677 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8678 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8679 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8680 (cmdline_parse_inst_t *)&cmd_config_mtu,
8681 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8682 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8683 (cmdline_parse_inst_t *)&cmd_config_rss,
8684 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8685 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8686 (cmdline_parse_inst_t *)&cmd_showport_reta,
8687 (cmdline_parse_inst_t *)&cmd_config_burst,
8688 (cmdline_parse_inst_t *)&cmd_config_thresh,
8689 (cmdline_parse_inst_t *)&cmd_config_threshold,
8690 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8691 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8692 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8693 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8694 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8695 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8696 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8697 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8698 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8699 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8700 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8701 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8702 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8703 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8704 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8705 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8706 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8707 (cmdline_parse_inst_t *)&cmd_dump,
8708 (cmdline_parse_inst_t *)&cmd_dump_one,
8709 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
8710 (cmdline_parse_inst_t *)&cmd_syn_filter,
8711 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
8712 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
8713 (cmdline_parse_inst_t *)&cmd_flex_filter,
8714 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8715 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8716 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8717 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8718 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
8719 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8720 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8721 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
8722 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
8723 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
8724 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
8728 /* prompt function, called from main on MASTER lcore */
8734 /* initialize non-constant commands */
8735 cmd_set_fwd_mode_init();
8737 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8741 cmdline_interact(cl);
8742 cmdline_stdin_exit(cl);
8746 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8748 if (id < nb_ports) {
8749 /* check if need_reconfig has been set to 1 */
8750 if (ports[id].need_reconfig == 0)
8751 ports[id].need_reconfig = dev;
8752 /* check if need_reconfig_queues has been set to 1 */
8753 if (ports[id].need_reconfig_queues == 0)
8754 ports[id].need_reconfig_queues = queue;
8758 for (pid = 0; pid < nb_ports; pid++) {
8759 /* check if need_reconfig has been set to 1 */
8760 if (ports[pid].need_reconfig == 0)
8761 ports[pid].need_reconfig = dev;
8762 /* check if need_reconfig_queues has been set to 1 */
8763 if (ports[pid].need_reconfig_queues == 0)
8764 ports[pid].need_reconfig_queues = queue;
8769 #ifdef RTE_NIC_BYPASS
8771 bypass_is_supported(portid_t port_id)
8773 struct rte_port *port;
8774 struct rte_pci_id *pci_id;
8776 if (port_id >= nb_ports) {
8777 printf("\tPort id must be less than %d.\n", nb_ports);
8781 /* Get the device id. */
8782 port = &ports[port_id];
8783 pci_id = &port->dev_info.pci_dev->id;
8785 /* Check if NIC supports bypass. */
8786 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8790 printf("\tBypass not supported for port_id = %d.\n", port_id);