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 (ip4|ip4-frag|ip6|ip6-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 (udp4|tcp4|udp6|tcp6)"
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 (sctp4|sctp6)"
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)"
660 " Configure mask of flex payload.\n\n"
662 "flow_director_flex_payload (port_id)"
663 " (raw|l2|l3|l4) (config)\n"
664 " Configure flex payload selection.\n\n"
666 "get_sym_hash_ena_per_port (port_id)\n"
667 " get symmetric hash enable configuration per port.\n\n"
669 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
670 " set symmetric hash enable configuration per port"
671 " to enable or disable.\n\n"
673 "get_hash_global_config (port_id)\n"
674 " Get the global configurations of hash filters.\n\n"
676 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
677 " (ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6)"
678 " (enable|disable)\n"
679 " Set the global configurations of hash filters.\n\n"
684 cmdline_parse_token_string_t cmd_help_long_help =
685 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
687 cmdline_parse_token_string_t cmd_help_long_section =
688 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
689 "all#control#display#config#"
690 "ports#registers#filters");
692 cmdline_parse_inst_t cmd_help_long = {
693 .f = cmd_help_long_parsed,
695 .help_str = "show help",
697 (void *)&cmd_help_long_help,
698 (void *)&cmd_help_long_section,
704 /* *** start/stop/close all ports *** */
705 struct cmd_operate_port_result {
706 cmdline_fixed_string_t keyword;
707 cmdline_fixed_string_t name;
708 cmdline_fixed_string_t value;
711 static void cmd_operate_port_parsed(void *parsed_result,
712 __attribute__((unused)) struct cmdline *cl,
713 __attribute__((unused)) void *data)
715 struct cmd_operate_port_result *res = parsed_result;
717 if (!strcmp(res->name, "start"))
718 start_port(RTE_PORT_ALL);
719 else if (!strcmp(res->name, "stop"))
720 stop_port(RTE_PORT_ALL);
721 else if (!strcmp(res->name, "close"))
722 close_port(RTE_PORT_ALL);
724 printf("Unknown parameter\n");
727 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
728 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
730 cmdline_parse_token_string_t cmd_operate_port_all_port =
731 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
733 cmdline_parse_token_string_t cmd_operate_port_all_all =
734 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
736 cmdline_parse_inst_t cmd_operate_port = {
737 .f = cmd_operate_port_parsed,
739 .help_str = "port start|stop|close all: start/stop/close all ports",
741 (void *)&cmd_operate_port_all_cmd,
742 (void *)&cmd_operate_port_all_port,
743 (void *)&cmd_operate_port_all_all,
748 /* *** start/stop/close specific port *** */
749 struct cmd_operate_specific_port_result {
750 cmdline_fixed_string_t keyword;
751 cmdline_fixed_string_t name;
755 static void cmd_operate_specific_port_parsed(void *parsed_result,
756 __attribute__((unused)) struct cmdline *cl,
757 __attribute__((unused)) void *data)
759 struct cmd_operate_specific_port_result *res = parsed_result;
761 if (!strcmp(res->name, "start"))
762 start_port(res->value);
763 else if (!strcmp(res->name, "stop"))
764 stop_port(res->value);
765 else if (!strcmp(res->name, "close"))
766 close_port(res->value);
768 printf("Unknown parameter\n");
771 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
772 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
774 cmdline_parse_token_string_t cmd_operate_specific_port_port =
775 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
776 name, "start#stop#close");
777 cmdline_parse_token_num_t cmd_operate_specific_port_id =
778 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
781 cmdline_parse_inst_t cmd_operate_specific_port = {
782 .f = cmd_operate_specific_port_parsed,
784 .help_str = "port start|stop|close X: start/stop/close port X",
786 (void *)&cmd_operate_specific_port_cmd,
787 (void *)&cmd_operate_specific_port_port,
788 (void *)&cmd_operate_specific_port_id,
793 /* *** configure speed for all ports *** */
794 struct cmd_config_speed_all {
795 cmdline_fixed_string_t port;
796 cmdline_fixed_string_t keyword;
797 cmdline_fixed_string_t all;
798 cmdline_fixed_string_t item1;
799 cmdline_fixed_string_t item2;
800 cmdline_fixed_string_t value1;
801 cmdline_fixed_string_t value2;
805 cmd_config_speed_all_parsed(void *parsed_result,
806 __attribute__((unused)) struct cmdline *cl,
807 __attribute__((unused)) void *data)
809 struct cmd_config_speed_all *res = parsed_result;
810 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
811 uint16_t link_duplex = 0;
814 if (!all_ports_stopped()) {
815 printf("Please stop all ports first\n");
819 if (!strcmp(res->value1, "10"))
820 link_speed = ETH_LINK_SPEED_10;
821 else if (!strcmp(res->value1, "100"))
822 link_speed = ETH_LINK_SPEED_100;
823 else if (!strcmp(res->value1, "1000"))
824 link_speed = ETH_LINK_SPEED_1000;
825 else if (!strcmp(res->value1, "10000"))
826 link_speed = ETH_LINK_SPEED_10G;
827 else if (!strcmp(res->value1, "40000"))
828 link_speed = ETH_LINK_SPEED_40G;
829 else if (!strcmp(res->value1, "auto"))
830 link_speed = ETH_LINK_SPEED_AUTONEG;
832 printf("Unknown parameter\n");
836 if (!strcmp(res->value2, "half"))
837 link_duplex = ETH_LINK_HALF_DUPLEX;
838 else if (!strcmp(res->value2, "full"))
839 link_duplex = ETH_LINK_FULL_DUPLEX;
840 else if (!strcmp(res->value2, "auto"))
841 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
843 printf("Unknown parameter\n");
847 for (pid = 0; pid < nb_ports; pid++) {
848 ports[pid].dev_conf.link_speed = link_speed;
849 ports[pid].dev_conf.link_duplex = link_duplex;
852 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
855 cmdline_parse_token_string_t cmd_config_speed_all_port =
856 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
857 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
858 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
860 cmdline_parse_token_string_t cmd_config_speed_all_all =
861 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
862 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
863 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
864 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
865 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
866 "10#100#1000#10000#40000#auto");
867 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
868 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
869 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
870 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
873 cmdline_parse_inst_t cmd_config_speed_all = {
874 .f = cmd_config_speed_all_parsed,
876 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
879 (void *)&cmd_config_speed_all_port,
880 (void *)&cmd_config_speed_all_keyword,
881 (void *)&cmd_config_speed_all_all,
882 (void *)&cmd_config_speed_all_item1,
883 (void *)&cmd_config_speed_all_value1,
884 (void *)&cmd_config_speed_all_item2,
885 (void *)&cmd_config_speed_all_value2,
890 /* *** configure speed for specific port *** */
891 struct cmd_config_speed_specific {
892 cmdline_fixed_string_t port;
893 cmdline_fixed_string_t keyword;
895 cmdline_fixed_string_t item1;
896 cmdline_fixed_string_t item2;
897 cmdline_fixed_string_t value1;
898 cmdline_fixed_string_t value2;
902 cmd_config_speed_specific_parsed(void *parsed_result,
903 __attribute__((unused)) struct cmdline *cl,
904 __attribute__((unused)) void *data)
906 struct cmd_config_speed_specific *res = parsed_result;
907 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
908 uint16_t link_duplex = 0;
910 if (!all_ports_stopped()) {
911 printf("Please stop all ports first\n");
915 if (res->id >= nb_ports) {
916 printf("Port id %d must be less than %d\n", res->id, nb_ports);
920 if (!strcmp(res->value1, "10"))
921 link_speed = ETH_LINK_SPEED_10;
922 else if (!strcmp(res->value1, "100"))
923 link_speed = ETH_LINK_SPEED_100;
924 else if (!strcmp(res->value1, "1000"))
925 link_speed = ETH_LINK_SPEED_1000;
926 else if (!strcmp(res->value1, "10000"))
927 link_speed = ETH_LINK_SPEED_10000;
928 else if (!strcmp(res->value1, "40000"))
929 link_speed = ETH_LINK_SPEED_40G;
930 else if (!strcmp(res->value1, "auto"))
931 link_speed = ETH_LINK_SPEED_AUTONEG;
933 printf("Unknown parameter\n");
937 if (!strcmp(res->value2, "half"))
938 link_duplex = ETH_LINK_HALF_DUPLEX;
939 else if (!strcmp(res->value2, "full"))
940 link_duplex = ETH_LINK_FULL_DUPLEX;
941 else if (!strcmp(res->value2, "auto"))
942 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
944 printf("Unknown parameter\n");
948 ports[res->id].dev_conf.link_speed = link_speed;
949 ports[res->id].dev_conf.link_duplex = link_duplex;
951 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
955 cmdline_parse_token_string_t cmd_config_speed_specific_port =
956 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
958 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
959 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
961 cmdline_parse_token_num_t cmd_config_speed_specific_id =
962 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
963 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
964 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
966 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
967 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
968 "10#100#1000#10000#40000#auto");
969 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
970 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
972 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
973 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
976 cmdline_parse_inst_t cmd_config_speed_specific = {
977 .f = cmd_config_speed_specific_parsed,
979 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
982 (void *)&cmd_config_speed_specific_port,
983 (void *)&cmd_config_speed_specific_keyword,
984 (void *)&cmd_config_speed_specific_id,
985 (void *)&cmd_config_speed_specific_item1,
986 (void *)&cmd_config_speed_specific_value1,
987 (void *)&cmd_config_speed_specific_item2,
988 (void *)&cmd_config_speed_specific_value2,
993 /* *** configure txq/rxq, txd/rxd *** */
994 struct cmd_config_rx_tx {
995 cmdline_fixed_string_t port;
996 cmdline_fixed_string_t keyword;
997 cmdline_fixed_string_t all;
998 cmdline_fixed_string_t name;
1003 cmd_config_rx_tx_parsed(void *parsed_result,
1004 __attribute__((unused)) struct cmdline *cl,
1005 __attribute__((unused)) void *data)
1007 struct cmd_config_rx_tx *res = parsed_result;
1009 if (!all_ports_stopped()) {
1010 printf("Please stop all ports first\n");
1014 if (!strcmp(res->name, "rxq")) {
1015 if (res->value <= 0) {
1016 printf("rxq %d invalid - must be > 0\n", res->value);
1019 nb_rxq = res->value;
1021 else if (!strcmp(res->name, "txq")) {
1022 if (res->value <= 0) {
1023 printf("txq %d invalid - must be > 0\n", res->value);
1026 nb_txq = res->value;
1028 else if (!strcmp(res->name, "rxd")) {
1029 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1030 printf("rxd %d invalid - must be > 0 && <= %d\n",
1031 res->value, RTE_TEST_RX_DESC_MAX);
1034 nb_rxd = res->value;
1035 } else if (!strcmp(res->name, "txd")) {
1036 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1037 printf("txd %d invalid - must be > 0 && <= %d\n",
1038 res->value, RTE_TEST_TX_DESC_MAX);
1041 nb_txd = res->value;
1043 printf("Unknown parameter\n");
1049 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1052 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1053 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1054 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1055 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1056 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1057 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1058 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1059 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1061 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1062 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1064 cmdline_parse_inst_t cmd_config_rx_tx = {
1065 .f = cmd_config_rx_tx_parsed,
1067 .help_str = "port config all rxq|txq|rxd|txd value",
1069 (void *)&cmd_config_rx_tx_port,
1070 (void *)&cmd_config_rx_tx_keyword,
1071 (void *)&cmd_config_rx_tx_all,
1072 (void *)&cmd_config_rx_tx_name,
1073 (void *)&cmd_config_rx_tx_value,
1078 /* *** config max packet length *** */
1079 struct cmd_config_max_pkt_len_result {
1080 cmdline_fixed_string_t port;
1081 cmdline_fixed_string_t keyword;
1082 cmdline_fixed_string_t all;
1083 cmdline_fixed_string_t name;
1088 cmd_config_max_pkt_len_parsed(void *parsed_result,
1089 __attribute__((unused)) struct cmdline *cl,
1090 __attribute__((unused)) void *data)
1092 struct cmd_config_max_pkt_len_result *res = parsed_result;
1094 if (!all_ports_stopped()) {
1095 printf("Please stop all ports first\n");
1099 if (!strcmp(res->name, "max-pkt-len")) {
1100 if (res->value < ETHER_MIN_LEN) {
1101 printf("max-pkt-len can not be less than %d\n",
1105 if (res->value == rx_mode.max_rx_pkt_len)
1108 rx_mode.max_rx_pkt_len = res->value;
1109 if (res->value > ETHER_MAX_LEN)
1110 rx_mode.jumbo_frame = 1;
1112 rx_mode.jumbo_frame = 0;
1114 printf("Unknown parameter\n");
1120 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1123 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1124 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1126 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1127 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1129 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1130 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1132 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1133 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1135 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1136 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1139 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1140 .f = cmd_config_max_pkt_len_parsed,
1142 .help_str = "port config all max-pkt-len value",
1144 (void *)&cmd_config_max_pkt_len_port,
1145 (void *)&cmd_config_max_pkt_len_keyword,
1146 (void *)&cmd_config_max_pkt_len_all,
1147 (void *)&cmd_config_max_pkt_len_name,
1148 (void *)&cmd_config_max_pkt_len_value,
1153 /* *** configure port MTU *** */
1154 struct cmd_config_mtu_result {
1155 cmdline_fixed_string_t port;
1156 cmdline_fixed_string_t keyword;
1157 cmdline_fixed_string_t mtu;
1163 cmd_config_mtu_parsed(void *parsed_result,
1164 __attribute__((unused)) struct cmdline *cl,
1165 __attribute__((unused)) void *data)
1167 struct cmd_config_mtu_result *res = parsed_result;
1169 if (res->value < ETHER_MIN_LEN) {
1170 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1173 port_mtu_set(res->port_id, res->value);
1176 cmdline_parse_token_string_t cmd_config_mtu_port =
1177 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1179 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1182 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1185 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1186 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1187 cmdline_parse_token_num_t cmd_config_mtu_value =
1188 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1190 cmdline_parse_inst_t cmd_config_mtu = {
1191 .f = cmd_config_mtu_parsed,
1193 .help_str = "port config mtu value",
1195 (void *)&cmd_config_mtu_port,
1196 (void *)&cmd_config_mtu_keyword,
1197 (void *)&cmd_config_mtu_mtu,
1198 (void *)&cmd_config_mtu_port_id,
1199 (void *)&cmd_config_mtu_value,
1204 /* *** configure rx mode *** */
1205 struct cmd_config_rx_mode_flag {
1206 cmdline_fixed_string_t port;
1207 cmdline_fixed_string_t keyword;
1208 cmdline_fixed_string_t all;
1209 cmdline_fixed_string_t name;
1210 cmdline_fixed_string_t value;
1214 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1215 __attribute__((unused)) struct cmdline *cl,
1216 __attribute__((unused)) void *data)
1218 struct cmd_config_rx_mode_flag *res = parsed_result;
1220 if (!all_ports_stopped()) {
1221 printf("Please stop all ports first\n");
1225 if (!strcmp(res->name, "crc-strip")) {
1226 if (!strcmp(res->value, "on"))
1227 rx_mode.hw_strip_crc = 1;
1228 else if (!strcmp(res->value, "off"))
1229 rx_mode.hw_strip_crc = 0;
1231 printf("Unknown parameter\n");
1234 } else if (!strcmp(res->name, "rx-cksum")) {
1235 if (!strcmp(res->value, "on"))
1236 rx_mode.hw_ip_checksum = 1;
1237 else if (!strcmp(res->value, "off"))
1238 rx_mode.hw_ip_checksum = 0;
1240 printf("Unknown parameter\n");
1243 } else if (!strcmp(res->name, "hw-vlan")) {
1244 if (!strcmp(res->value, "on")) {
1245 rx_mode.hw_vlan_filter = 1;
1246 rx_mode.hw_vlan_strip = 1;
1248 else if (!strcmp(res->value, "off")) {
1249 rx_mode.hw_vlan_filter = 0;
1250 rx_mode.hw_vlan_strip = 0;
1253 printf("Unknown parameter\n");
1256 } else if (!strcmp(res->name, "drop-en")) {
1257 if (!strcmp(res->value, "on"))
1259 else if (!strcmp(res->value, "off"))
1262 printf("Unknown parameter\n");
1266 printf("Unknown parameter\n");
1272 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1275 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1276 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1277 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1278 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1280 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1282 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1283 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1284 "crc-strip#rx-cksum#hw-vlan");
1285 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1286 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1289 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1290 .f = cmd_config_rx_mode_flag_parsed,
1292 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1294 (void *)&cmd_config_rx_mode_flag_port,
1295 (void *)&cmd_config_rx_mode_flag_keyword,
1296 (void *)&cmd_config_rx_mode_flag_all,
1297 (void *)&cmd_config_rx_mode_flag_name,
1298 (void *)&cmd_config_rx_mode_flag_value,
1303 /* *** configure rss *** */
1304 struct cmd_config_rss {
1305 cmdline_fixed_string_t port;
1306 cmdline_fixed_string_t keyword;
1307 cmdline_fixed_string_t all;
1308 cmdline_fixed_string_t name;
1309 cmdline_fixed_string_t value;
1313 cmd_config_rss_parsed(void *parsed_result,
1314 __attribute__((unused)) struct cmdline *cl,
1315 __attribute__((unused)) void *data)
1317 struct cmd_config_rss *res = parsed_result;
1318 struct rte_eth_rss_conf rss_conf;
1321 if (!strcmp(res->value, "ip"))
1322 rss_conf.rss_hf = ETH_RSS_IP;
1323 else if (!strcmp(res->value, "udp"))
1324 rss_conf.rss_hf = ETH_RSS_UDP;
1325 else if (!strcmp(res->value, "none"))
1326 rss_conf.rss_hf = 0;
1328 printf("Unknown parameter\n");
1331 rss_conf.rss_key = NULL;
1332 for (i = 0; i < rte_eth_dev_count(); i++)
1333 rte_eth_dev_rss_hash_update(i, &rss_conf);
1336 cmdline_parse_token_string_t cmd_config_rss_port =
1337 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1338 cmdline_parse_token_string_t cmd_config_rss_keyword =
1339 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1340 cmdline_parse_token_string_t cmd_config_rss_all =
1341 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1342 cmdline_parse_token_string_t cmd_config_rss_name =
1343 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1344 cmdline_parse_token_string_t cmd_config_rss_value =
1345 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1347 cmdline_parse_inst_t cmd_config_rss = {
1348 .f = cmd_config_rss_parsed,
1350 .help_str = "port config all rss ip|udp|none",
1352 (void *)&cmd_config_rss_port,
1353 (void *)&cmd_config_rss_keyword,
1354 (void *)&cmd_config_rss_all,
1355 (void *)&cmd_config_rss_name,
1356 (void *)&cmd_config_rss_value,
1361 /* *** configure rss hash key *** */
1362 struct cmd_config_rss_hash_key {
1363 cmdline_fixed_string_t port;
1364 cmdline_fixed_string_t config;
1366 cmdline_fixed_string_t rss_hash_key;
1367 cmdline_fixed_string_t key;
1370 #define RSS_HASH_KEY_LENGTH 40
1372 hexa_digit_to_value(char hexa_digit)
1374 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1375 return (uint8_t) (hexa_digit - '0');
1376 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1377 return (uint8_t) ((hexa_digit - 'a') + 10);
1378 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1379 return (uint8_t) ((hexa_digit - 'A') + 10);
1380 /* Invalid hexa digit */
1385 parse_and_check_key_hexa_digit(char *key, int idx)
1389 hexa_v = hexa_digit_to_value(key[idx]);
1391 printf("invalid key: character %c at position %d is not a "
1392 "valid hexa digit\n", key[idx], idx);
1397 cmd_config_rss_hash_key_parsed(void *parsed_result,
1398 __attribute__((unused)) struct cmdline *cl,
1399 __attribute__((unused)) void *data)
1401 struct cmd_config_rss_hash_key *res = parsed_result;
1402 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1407 /* Check the length of the RSS hash key */
1408 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1409 printf("key length: %d invalid - key must be a string of %d"
1410 "hexa-decimal numbers\n", (int) strlen(res->key),
1411 RSS_HASH_KEY_LENGTH * 2);
1414 /* Translate RSS hash key into binary representation */
1415 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1416 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1419 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1422 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1424 port_rss_hash_key_update(res->port_id, hash_key);
1427 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1428 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1429 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1430 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1432 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1433 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1434 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1435 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1436 rss_hash_key, "rss-hash-key");
1437 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1438 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1440 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1441 .f = cmd_config_rss_hash_key_parsed,
1443 .help_str = "port config X rss-hash-key 80 hexa digits",
1445 (void *)&cmd_config_rss_hash_key_port,
1446 (void *)&cmd_config_rss_hash_key_config,
1447 (void *)&cmd_config_rss_hash_key_port_id,
1448 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1449 (void *)&cmd_config_rss_hash_key_value,
1454 /* *** configure port rxq/txq start/stop *** */
1455 struct cmd_config_rxtx_queue {
1456 cmdline_fixed_string_t port;
1458 cmdline_fixed_string_t rxtxq;
1460 cmdline_fixed_string_t opname;
1464 cmd_config_rxtx_queue_parsed(void *parsed_result,
1465 __attribute__((unused)) struct cmdline *cl,
1466 __attribute__((unused)) void *data)
1468 struct cmd_config_rxtx_queue *res = parsed_result;
1473 if (test_done == 0) {
1474 printf("Please stop forwarding first\n");
1478 if (port_id_is_invalid(res->portid))
1481 if (port_is_started(res->portid) != 1) {
1482 printf("Please start port %u first\n", res->portid);
1486 if (!strcmp(res->rxtxq, "rxq"))
1488 else if (!strcmp(res->rxtxq, "txq"))
1491 printf("Unknown parameter\n");
1495 if (isrx && rx_queue_id_is_invalid(res->qid))
1497 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1500 if (!strcmp(res->opname, "start"))
1502 else if (!strcmp(res->opname, "stop"))
1505 printf("Unknown parameter\n");
1509 if (isstart && isrx)
1510 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1511 else if (!isstart && isrx)
1512 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1513 else if (isstart && !isrx)
1514 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1516 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1518 if (ret == -ENOTSUP)
1519 printf("Function not supported in PMD driver\n");
1522 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1523 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1524 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1525 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1526 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1527 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1528 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1529 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1530 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1531 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1534 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1535 .f = cmd_config_rxtx_queue_parsed,
1537 .help_str = "port X rxq|txq ID start|stop",
1539 (void *)&cmd_config_speed_all_port,
1540 (void *)&cmd_config_rxtx_queue_portid,
1541 (void *)&cmd_config_rxtx_queue_rxtxq,
1542 (void *)&cmd_config_rxtx_queue_qid,
1543 (void *)&cmd_config_rxtx_queue_opname,
1548 /* *** Configure RSS RETA *** */
1549 struct cmd_config_rss_reta {
1550 cmdline_fixed_string_t port;
1551 cmdline_fixed_string_t keyword;
1553 cmdline_fixed_string_t name;
1554 cmdline_fixed_string_t list_name;
1555 cmdline_fixed_string_t list_of_items;
1559 parse_reta_config(const char *str,
1560 struct rte_eth_rss_reta_entry64 *reta_conf,
1561 uint16_t nb_entries)
1565 uint16_t hash_index, idx, shift;
1568 const char *p, *p0 = str;
1575 unsigned long int_fld[_NUM_FLD];
1576 char *str_fld[_NUM_FLD];
1578 while ((p = strchr(p0,'(')) != NULL) {
1580 if((p0 = strchr(p,')')) == NULL)
1584 if(size >= sizeof(s))
1587 snprintf(s, sizeof(s), "%.*s", size, p);
1588 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1590 for (i = 0; i < _NUM_FLD; i++) {
1592 int_fld[i] = strtoul(str_fld[i], &end, 0);
1593 if (errno != 0 || end == str_fld[i] ||
1598 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1599 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1601 if (hash_index >= nb_entries) {
1602 printf("Invalid RETA hash index=%d\n", hash_index);
1606 idx = hash_index / RTE_RETA_GROUP_SIZE;
1607 shift = hash_index % RTE_RETA_GROUP_SIZE;
1608 reta_conf[idx].mask |= (1ULL << shift);
1609 reta_conf[idx].reta[shift] = nb_queue;
1616 cmd_set_rss_reta_parsed(void *parsed_result,
1617 __attribute__((unused)) struct cmdline *cl,
1618 __attribute__((unused)) void *data)
1621 struct rte_eth_dev_info dev_info;
1622 struct rte_eth_rss_reta_entry64 reta_conf[8];
1623 struct cmd_config_rss_reta *res = parsed_result;
1625 memset(&dev_info, 0, sizeof(dev_info));
1626 rte_eth_dev_info_get(res->port_id, &dev_info);
1627 if (dev_info.reta_size == 0) {
1628 printf("Redirection table size is 0 which is "
1629 "invalid for RSS\n");
1632 printf("The reta size of port %d is %u\n",
1633 res->port_id, dev_info.reta_size);
1634 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1635 printf("Currently do not support more than %u entries of "
1636 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1640 memset(reta_conf, 0, sizeof(reta_conf));
1641 if (!strcmp(res->list_name, "reta")) {
1642 if (parse_reta_config(res->list_of_items, reta_conf,
1643 dev_info.reta_size)) {
1644 printf("Invalid RSS Redirection Table "
1645 "config entered\n");
1648 ret = rte_eth_dev_rss_reta_update(res->port_id,
1649 reta_conf, dev_info.reta_size);
1651 printf("Bad redirection table parameter, "
1652 "return code = %d \n", ret);
1656 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1658 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1660 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1661 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1662 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1663 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1664 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1666 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1669 cmdline_parse_inst_t cmd_config_rss_reta = {
1670 .f = cmd_set_rss_reta_parsed,
1672 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1674 (void *)&cmd_config_rss_reta_port,
1675 (void *)&cmd_config_rss_reta_keyword,
1676 (void *)&cmd_config_rss_reta_port_id,
1677 (void *)&cmd_config_rss_reta_name,
1678 (void *)&cmd_config_rss_reta_list_name,
1679 (void *)&cmd_config_rss_reta_list_of_items,
1684 /* *** SHOW PORT RETA INFO *** */
1685 struct cmd_showport_reta {
1686 cmdline_fixed_string_t show;
1687 cmdline_fixed_string_t port;
1689 cmdline_fixed_string_t rss;
1690 cmdline_fixed_string_t reta;
1692 cmdline_fixed_string_t list_of_items;
1696 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1697 uint16_t nb_entries,
1701 const char *p, *p0 = str;
1705 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1708 p = strchr(p0, '(');
1712 p0 = strchr(p, ')');
1716 if (size >= sizeof(s)) {
1717 printf("The string size exceeds the internal buffer size\n");
1720 snprintf(s, sizeof(s), "%.*s", size, p);
1721 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1722 if (ret <= 0 || ret != num) {
1723 printf("The bits of masks do not match the number of "
1724 "reta entries: %u\n", num);
1727 for (i = 0; i < ret; i++)
1728 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1734 cmd_showport_reta_parsed(void *parsed_result,
1735 __attribute__((unused)) struct cmdline *cl,
1736 __attribute__((unused)) void *data)
1738 struct cmd_showport_reta *res = parsed_result;
1739 struct rte_eth_rss_reta_entry64 reta_conf[8];
1740 struct rte_eth_dev_info dev_info;
1742 memset(&dev_info, 0, sizeof(dev_info));
1743 rte_eth_dev_info_get(res->port_id, &dev_info);
1744 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1745 res->size > ETH_RSS_RETA_SIZE_512) {
1746 printf("Invalid redirection table size: %u\n", res->size);
1750 memset(reta_conf, 0, sizeof(reta_conf));
1751 if (showport_parse_reta_config(reta_conf, res->size,
1752 res->list_of_items) < 0) {
1753 printf("Invalid string: %s for reta masks\n",
1754 res->list_of_items);
1757 port_rss_reta_info(res->port_id, reta_conf, res->size);
1760 cmdline_parse_token_string_t cmd_showport_reta_show =
1761 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1762 cmdline_parse_token_string_t cmd_showport_reta_port =
1763 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1764 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1765 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1766 cmdline_parse_token_string_t cmd_showport_reta_rss =
1767 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1768 cmdline_parse_token_string_t cmd_showport_reta_reta =
1769 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1770 cmdline_parse_token_num_t cmd_showport_reta_size =
1771 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1772 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1773 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1774 list_of_items, NULL);
1776 cmdline_parse_inst_t cmd_showport_reta = {
1777 .f = cmd_showport_reta_parsed,
1779 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1781 (void *)&cmd_showport_reta_show,
1782 (void *)&cmd_showport_reta_port,
1783 (void *)&cmd_showport_reta_port_id,
1784 (void *)&cmd_showport_reta_rss,
1785 (void *)&cmd_showport_reta_reta,
1786 (void *)&cmd_showport_reta_size,
1787 (void *)&cmd_showport_reta_list_of_items,
1792 /* *** Show RSS hash configuration *** */
1793 struct cmd_showport_rss_hash {
1794 cmdline_fixed_string_t show;
1795 cmdline_fixed_string_t port;
1797 cmdline_fixed_string_t rss_hash;
1798 cmdline_fixed_string_t key; /* optional argument */
1801 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1802 __attribute__((unused)) struct cmdline *cl,
1805 struct cmd_showport_rss_hash *res = parsed_result;
1807 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1810 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1811 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1812 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1813 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1814 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1815 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1816 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1817 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1819 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1820 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1822 cmdline_parse_inst_t cmd_showport_rss_hash = {
1823 .f = cmd_showport_rss_hash_parsed,
1825 .help_str = "show port X rss-hash (X = port number)\n",
1827 (void *)&cmd_showport_rss_hash_show,
1828 (void *)&cmd_showport_rss_hash_port,
1829 (void *)&cmd_showport_rss_hash_port_id,
1830 (void *)&cmd_showport_rss_hash_rss_hash,
1835 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1836 .f = cmd_showport_rss_hash_parsed,
1838 .help_str = "show port X rss-hash key (X = port number)\n",
1840 (void *)&cmd_showport_rss_hash_show,
1841 (void *)&cmd_showport_rss_hash_port,
1842 (void *)&cmd_showport_rss_hash_port_id,
1843 (void *)&cmd_showport_rss_hash_rss_hash,
1844 (void *)&cmd_showport_rss_hash_rss_key,
1849 /* *** Configure DCB *** */
1850 struct cmd_config_dcb {
1851 cmdline_fixed_string_t port;
1852 cmdline_fixed_string_t config;
1854 cmdline_fixed_string_t dcb;
1855 cmdline_fixed_string_t vt;
1856 cmdline_fixed_string_t vt_en;
1858 cmdline_fixed_string_t pfc;
1859 cmdline_fixed_string_t pfc_en;
1863 cmd_config_dcb_parsed(void *parsed_result,
1864 __attribute__((unused)) struct cmdline *cl,
1865 __attribute__((unused)) void *data)
1867 struct cmd_config_dcb *res = parsed_result;
1868 struct dcb_config dcb_conf;
1869 portid_t port_id = res->port_id;
1870 struct rte_port *port;
1872 port = &ports[port_id];
1873 /** Check if the port is not started **/
1874 if (port->port_status != RTE_PORT_STOPPED) {
1875 printf("Please stop port %d first\n",port_id);
1879 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1880 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1881 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1885 /* DCB in VT mode */
1886 if (!strncmp(res->vt_en, "on",2))
1887 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1889 dcb_conf.dcb_mode = DCB_ENABLED;
1891 if (!strncmp(res->pfc_en, "on",2)) {
1892 dcb_conf.pfc_en = 1;
1895 dcb_conf.pfc_en = 0;
1897 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1898 printf("Cannot initialize network ports\n");
1902 cmd_reconfig_device_queue(port_id, 1, 1);
1905 cmdline_parse_token_string_t cmd_config_dcb_port =
1906 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1907 cmdline_parse_token_string_t cmd_config_dcb_config =
1908 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1909 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1910 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1911 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1912 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1913 cmdline_parse_token_string_t cmd_config_dcb_vt =
1914 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1915 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1916 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1917 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1918 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1919 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1921 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1922 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1924 cmdline_parse_inst_t cmd_config_dcb = {
1925 .f = cmd_config_dcb_parsed,
1927 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1929 (void *)&cmd_config_dcb_port,
1930 (void *)&cmd_config_dcb_config,
1931 (void *)&cmd_config_dcb_port_id,
1932 (void *)&cmd_config_dcb_dcb,
1933 (void *)&cmd_config_dcb_vt,
1934 (void *)&cmd_config_dcb_vt_en,
1935 (void *)&cmd_config_dcb_num_tcs,
1936 (void *)&cmd_config_dcb_pfc,
1937 (void *)&cmd_config_dcb_pfc_en,
1942 /* *** configure number of packets per burst *** */
1943 struct cmd_config_burst {
1944 cmdline_fixed_string_t port;
1945 cmdline_fixed_string_t keyword;
1946 cmdline_fixed_string_t all;
1947 cmdline_fixed_string_t name;
1952 cmd_config_burst_parsed(void *parsed_result,
1953 __attribute__((unused)) struct cmdline *cl,
1954 __attribute__((unused)) void *data)
1956 struct cmd_config_burst *res = parsed_result;
1958 if (!all_ports_stopped()) {
1959 printf("Please stop all ports first\n");
1963 if (!strcmp(res->name, "burst")) {
1964 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1965 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1968 nb_pkt_per_burst = res->value;
1970 printf("Unknown parameter\n");
1976 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1979 cmdline_parse_token_string_t cmd_config_burst_port =
1980 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1981 cmdline_parse_token_string_t cmd_config_burst_keyword =
1982 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1983 cmdline_parse_token_string_t cmd_config_burst_all =
1984 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1985 cmdline_parse_token_string_t cmd_config_burst_name =
1986 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1987 cmdline_parse_token_num_t cmd_config_burst_value =
1988 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1990 cmdline_parse_inst_t cmd_config_burst = {
1991 .f = cmd_config_burst_parsed,
1993 .help_str = "port config all burst value",
1995 (void *)&cmd_config_burst_port,
1996 (void *)&cmd_config_burst_keyword,
1997 (void *)&cmd_config_burst_all,
1998 (void *)&cmd_config_burst_name,
1999 (void *)&cmd_config_burst_value,
2004 /* *** configure rx/tx queues *** */
2005 struct cmd_config_thresh {
2006 cmdline_fixed_string_t port;
2007 cmdline_fixed_string_t keyword;
2008 cmdline_fixed_string_t all;
2009 cmdline_fixed_string_t name;
2014 cmd_config_thresh_parsed(void *parsed_result,
2015 __attribute__((unused)) struct cmdline *cl,
2016 __attribute__((unused)) void *data)
2018 struct cmd_config_thresh *res = parsed_result;
2020 if (!all_ports_stopped()) {
2021 printf("Please stop all ports first\n");
2025 if (!strcmp(res->name, "txpt"))
2026 tx_pthresh = res->value;
2027 else if(!strcmp(res->name, "txht"))
2028 tx_hthresh = res->value;
2029 else if(!strcmp(res->name, "txwt"))
2030 tx_wthresh = res->value;
2031 else if(!strcmp(res->name, "rxpt"))
2032 rx_pthresh = res->value;
2033 else if(!strcmp(res->name, "rxht"))
2034 rx_hthresh = res->value;
2035 else if(!strcmp(res->name, "rxwt"))
2036 rx_wthresh = res->value;
2038 printf("Unknown parameter\n");
2044 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2047 cmdline_parse_token_string_t cmd_config_thresh_port =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2049 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2050 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2051 cmdline_parse_token_string_t cmd_config_thresh_all =
2052 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2053 cmdline_parse_token_string_t cmd_config_thresh_name =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2055 "txpt#txht#txwt#rxpt#rxht#rxwt");
2056 cmdline_parse_token_num_t cmd_config_thresh_value =
2057 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2059 cmdline_parse_inst_t cmd_config_thresh = {
2060 .f = cmd_config_thresh_parsed,
2062 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2064 (void *)&cmd_config_thresh_port,
2065 (void *)&cmd_config_thresh_keyword,
2066 (void *)&cmd_config_thresh_all,
2067 (void *)&cmd_config_thresh_name,
2068 (void *)&cmd_config_thresh_value,
2073 /* *** configure free/rs threshold *** */
2074 struct cmd_config_threshold {
2075 cmdline_fixed_string_t port;
2076 cmdline_fixed_string_t keyword;
2077 cmdline_fixed_string_t all;
2078 cmdline_fixed_string_t name;
2083 cmd_config_threshold_parsed(void *parsed_result,
2084 __attribute__((unused)) struct cmdline *cl,
2085 __attribute__((unused)) void *data)
2087 struct cmd_config_threshold *res = parsed_result;
2089 if (!all_ports_stopped()) {
2090 printf("Please stop all ports first\n");
2094 if (!strcmp(res->name, "txfreet"))
2095 tx_free_thresh = res->value;
2096 else if (!strcmp(res->name, "txrst"))
2097 tx_rs_thresh = res->value;
2098 else if (!strcmp(res->name, "rxfreet"))
2099 rx_free_thresh = res->value;
2101 printf("Unknown parameter\n");
2107 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2110 cmdline_parse_token_string_t cmd_config_threshold_port =
2111 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2112 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2115 cmdline_parse_token_string_t cmd_config_threshold_all =
2116 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2117 cmdline_parse_token_string_t cmd_config_threshold_name =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2119 "txfreet#txrst#rxfreet");
2120 cmdline_parse_token_num_t cmd_config_threshold_value =
2121 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2123 cmdline_parse_inst_t cmd_config_threshold = {
2124 .f = cmd_config_threshold_parsed,
2126 .help_str = "port config all txfreet|txrst|rxfreet value",
2128 (void *)&cmd_config_threshold_port,
2129 (void *)&cmd_config_threshold_keyword,
2130 (void *)&cmd_config_threshold_all,
2131 (void *)&cmd_config_threshold_name,
2132 (void *)&cmd_config_threshold_value,
2138 struct cmd_stop_result {
2139 cmdline_fixed_string_t stop;
2142 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2143 __attribute__((unused)) struct cmdline *cl,
2144 __attribute__((unused)) void *data)
2146 stop_packet_forwarding();
2149 cmdline_parse_token_string_t cmd_stop_stop =
2150 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2152 cmdline_parse_inst_t cmd_stop = {
2153 .f = cmd_stop_parsed,
2155 .help_str = "stop - stop packet forwarding",
2157 (void *)&cmd_stop_stop,
2162 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2165 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2166 unsigned int *parsed_items, int check_unique_values)
2168 unsigned int nb_item;
2176 * First parse all items in the list and store their value.
2181 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2183 if ((c >= '0') && (c <= '9')) {
2184 value = (unsigned int) (value * 10 + (c - '0'));
2189 printf("character %c is not a decimal digit\n", c);
2193 printf("No valid value before comma\n");
2196 if (nb_item < max_items) {
2197 parsed_items[nb_item] = value;
2203 if (nb_item >= max_items) {
2204 printf("Number of %s = %u > %u (maximum items)\n",
2205 item_name, nb_item + 1, max_items);
2208 parsed_items[nb_item++] = value;
2209 if (! check_unique_values)
2213 * Then, check that all values in the list are differents.
2214 * No optimization here...
2216 for (i = 0; i < nb_item; i++) {
2217 for (j = i + 1; j < nb_item; j++) {
2218 if (parsed_items[j] == parsed_items[i]) {
2219 printf("duplicated %s %u at index %u and %u\n",
2220 item_name, parsed_items[i], i, j);
2228 struct cmd_set_list_result {
2229 cmdline_fixed_string_t cmd_keyword;
2230 cmdline_fixed_string_t list_name;
2231 cmdline_fixed_string_t list_of_items;
2234 static void cmd_set_list_parsed(void *parsed_result,
2235 __attribute__((unused)) struct cmdline *cl,
2236 __attribute__((unused)) void *data)
2238 struct cmd_set_list_result *res;
2240 unsigned int lcorelist[RTE_MAX_LCORE];
2241 unsigned int portlist[RTE_MAX_ETHPORTS];
2243 unsigned int nb_item;
2245 if (test_done == 0) {
2246 printf("Please stop forwarding first\n");
2250 res = parsed_result;
2251 if (!strcmp(res->list_name, "corelist")) {
2252 nb_item = parse_item_list(res->list_of_items, "core",
2254 parsed_items.lcorelist, 1);
2256 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2259 if (!strcmp(res->list_name, "portlist")) {
2260 nb_item = parse_item_list(res->list_of_items, "port",
2262 parsed_items.portlist, 1);
2264 set_fwd_ports_list(parsed_items.portlist, nb_item);
2268 cmdline_parse_token_string_t cmd_set_list_keyword =
2269 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2271 cmdline_parse_token_string_t cmd_set_list_name =
2272 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2273 "corelist#portlist");
2274 cmdline_parse_token_string_t cmd_set_list_of_items =
2275 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2278 cmdline_parse_inst_t cmd_set_fwd_list = {
2279 .f = cmd_set_list_parsed,
2281 .help_str = "set corelist|portlist x[,y]*",
2283 (void *)&cmd_set_list_keyword,
2284 (void *)&cmd_set_list_name,
2285 (void *)&cmd_set_list_of_items,
2290 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2292 struct cmd_setmask_result {
2293 cmdline_fixed_string_t set;
2294 cmdline_fixed_string_t mask;
2298 static void cmd_set_mask_parsed(void *parsed_result,
2299 __attribute__((unused)) struct cmdline *cl,
2300 __attribute__((unused)) void *data)
2302 struct cmd_setmask_result *res = parsed_result;
2304 if (test_done == 0) {
2305 printf("Please stop forwarding first\n");
2308 if (!strcmp(res->mask, "coremask"))
2309 set_fwd_lcores_mask(res->hexavalue);
2310 else if (!strcmp(res->mask, "portmask"))
2311 set_fwd_ports_mask(res->hexavalue);
2314 cmdline_parse_token_string_t cmd_setmask_set =
2315 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2316 cmdline_parse_token_string_t cmd_setmask_mask =
2317 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2318 "coremask#portmask");
2319 cmdline_parse_token_num_t cmd_setmask_value =
2320 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2322 cmdline_parse_inst_t cmd_set_fwd_mask = {
2323 .f = cmd_set_mask_parsed,
2325 .help_str = "set coremask|portmask hexadecimal value",
2327 (void *)&cmd_setmask_set,
2328 (void *)&cmd_setmask_mask,
2329 (void *)&cmd_setmask_value,
2335 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2337 struct cmd_set_result {
2338 cmdline_fixed_string_t set;
2339 cmdline_fixed_string_t what;
2343 static void cmd_set_parsed(void *parsed_result,
2344 __attribute__((unused)) struct cmdline *cl,
2345 __attribute__((unused)) void *data)
2347 struct cmd_set_result *res = parsed_result;
2348 if (!strcmp(res->what, "nbport"))
2349 set_fwd_ports_number(res->value);
2350 else if (!strcmp(res->what, "nbcore"))
2351 set_fwd_lcores_number(res->value);
2352 else if (!strcmp(res->what, "burst"))
2353 set_nb_pkt_per_burst(res->value);
2354 else if (!strcmp(res->what, "verbose"))
2355 set_verbose_level(res->value);
2358 cmdline_parse_token_string_t cmd_set_set =
2359 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2360 cmdline_parse_token_string_t cmd_set_what =
2361 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2362 "nbport#nbcore#burst#verbose");
2363 cmdline_parse_token_num_t cmd_set_value =
2364 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2366 cmdline_parse_inst_t cmd_set_numbers = {
2367 .f = cmd_set_parsed,
2369 .help_str = "set nbport|nbcore|burst|verbose value",
2371 (void *)&cmd_set_set,
2372 (void *)&cmd_set_what,
2373 (void *)&cmd_set_value,
2378 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2380 struct cmd_set_txpkts_result {
2381 cmdline_fixed_string_t cmd_keyword;
2382 cmdline_fixed_string_t txpkts;
2383 cmdline_fixed_string_t seg_lengths;
2387 cmd_set_txpkts_parsed(void *parsed_result,
2388 __attribute__((unused)) struct cmdline *cl,
2389 __attribute__((unused)) void *data)
2391 struct cmd_set_txpkts_result *res;
2392 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2393 unsigned int nb_segs;
2395 res = parsed_result;
2396 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2397 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2399 set_tx_pkt_segments(seg_lengths, nb_segs);
2402 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2403 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2404 cmd_keyword, "set");
2405 cmdline_parse_token_string_t cmd_set_txpkts_name =
2406 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2408 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2409 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2412 cmdline_parse_inst_t cmd_set_txpkts = {
2413 .f = cmd_set_txpkts_parsed,
2415 .help_str = "set txpkts x[,y]*",
2417 (void *)&cmd_set_txpkts_keyword,
2418 (void *)&cmd_set_txpkts_name,
2419 (void *)&cmd_set_txpkts_lengths,
2424 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2425 struct cmd_rx_vlan_filter_all_result {
2426 cmdline_fixed_string_t rx_vlan;
2427 cmdline_fixed_string_t what;
2428 cmdline_fixed_string_t all;
2433 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2434 __attribute__((unused)) struct cmdline *cl,
2435 __attribute__((unused)) void *data)
2437 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2439 if (!strcmp(res->what, "add"))
2440 rx_vlan_all_filter_set(res->port_id, 1);
2442 rx_vlan_all_filter_set(res->port_id, 0);
2445 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2446 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2447 rx_vlan, "rx_vlan");
2448 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2449 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2451 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2452 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2454 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2455 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2458 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2459 .f = cmd_rx_vlan_filter_all_parsed,
2461 .help_str = "add/remove all identifiers to/from the set of VLAN "
2462 "Identifiers filtered by a port",
2464 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2465 (void *)&cmd_rx_vlan_filter_all_what,
2466 (void *)&cmd_rx_vlan_filter_all_all,
2467 (void *)&cmd_rx_vlan_filter_all_portid,
2472 /* *** VLAN OFFLOAD SET ON A PORT *** */
2473 struct cmd_vlan_offload_result {
2474 cmdline_fixed_string_t vlan;
2475 cmdline_fixed_string_t set;
2476 cmdline_fixed_string_t what;
2477 cmdline_fixed_string_t on;
2478 cmdline_fixed_string_t port_id;
2482 cmd_vlan_offload_parsed(void *parsed_result,
2483 __attribute__((unused)) struct cmdline *cl,
2484 __attribute__((unused)) void *data)
2487 struct cmd_vlan_offload_result *res = parsed_result;
2490 portid_t port_id = 0;
2494 len = strnlen(str, STR_TOKEN_SIZE);
2496 /* Get port_id first */
2504 tmp = strtoul(str, NULL, 0);
2505 /* If port_id greater that what portid_t can represent, return */
2506 if(tmp >= RTE_MAX_ETHPORTS)
2508 port_id = (portid_t)tmp;
2510 if (!strcmp(res->on, "on"))
2515 if (!strcmp(res->what, "strip"))
2516 rx_vlan_strip_set(port_id, on);
2517 else if(!strcmp(res->what, "stripq")){
2518 uint16_t queue_id = 0;
2520 /* No queue_id, return */
2522 printf("must specify (port,queue_id)\n");
2525 tmp = strtoul(str + i + 1, NULL, 0);
2526 /* If queue_id greater that what 16-bits can represent, return */
2530 queue_id = (uint16_t)tmp;
2531 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2533 else if (!strcmp(res->what, "filter"))
2534 rx_vlan_filter_set(port_id, on);
2536 vlan_extend_set(port_id, on);
2541 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2542 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2544 cmdline_parse_token_string_t cmd_vlan_offload_set =
2545 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2547 cmdline_parse_token_string_t cmd_vlan_offload_what =
2548 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2549 what, "strip#filter#qinq#stripq");
2550 cmdline_parse_token_string_t cmd_vlan_offload_on =
2551 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2553 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2554 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2557 cmdline_parse_inst_t cmd_vlan_offload = {
2558 .f = cmd_vlan_offload_parsed,
2560 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2561 " qinq(extended) for both rx/tx sides ",
2563 (void *)&cmd_vlan_offload_vlan,
2564 (void *)&cmd_vlan_offload_set,
2565 (void *)&cmd_vlan_offload_what,
2566 (void *)&cmd_vlan_offload_on,
2567 (void *)&cmd_vlan_offload_portid,
2572 /* *** VLAN TPID SET ON A PORT *** */
2573 struct cmd_vlan_tpid_result {
2574 cmdline_fixed_string_t vlan;
2575 cmdline_fixed_string_t set;
2576 cmdline_fixed_string_t what;
2582 cmd_vlan_tpid_parsed(void *parsed_result,
2583 __attribute__((unused)) struct cmdline *cl,
2584 __attribute__((unused)) void *data)
2586 struct cmd_vlan_tpid_result *res = parsed_result;
2587 vlan_tpid_set(res->port_id, res->tp_id);
2591 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2592 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2594 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2595 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2597 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2598 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2600 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2601 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2603 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2604 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2607 cmdline_parse_inst_t cmd_vlan_tpid = {
2608 .f = cmd_vlan_tpid_parsed,
2610 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2612 (void *)&cmd_vlan_tpid_vlan,
2613 (void *)&cmd_vlan_tpid_set,
2614 (void *)&cmd_vlan_tpid_what,
2615 (void *)&cmd_vlan_tpid_tpid,
2616 (void *)&cmd_vlan_tpid_portid,
2621 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2622 struct cmd_rx_vlan_filter_result {
2623 cmdline_fixed_string_t rx_vlan;
2624 cmdline_fixed_string_t what;
2630 cmd_rx_vlan_filter_parsed(void *parsed_result,
2631 __attribute__((unused)) struct cmdline *cl,
2632 __attribute__((unused)) void *data)
2634 struct cmd_rx_vlan_filter_result *res = parsed_result;
2636 if (!strcmp(res->what, "add"))
2637 rx_vft_set(res->port_id, res->vlan_id, 1);
2639 rx_vft_set(res->port_id, res->vlan_id, 0);
2642 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2643 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2644 rx_vlan, "rx_vlan");
2645 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2646 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2648 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2649 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2651 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2652 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2655 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2656 .f = cmd_rx_vlan_filter_parsed,
2658 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2659 "Identifiers filtered by a port",
2661 (void *)&cmd_rx_vlan_filter_rx_vlan,
2662 (void *)&cmd_rx_vlan_filter_what,
2663 (void *)&cmd_rx_vlan_filter_vlanid,
2664 (void *)&cmd_rx_vlan_filter_portid,
2669 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2670 struct cmd_tx_vlan_set_result {
2671 cmdline_fixed_string_t tx_vlan;
2672 cmdline_fixed_string_t set;
2678 cmd_tx_vlan_set_parsed(void *parsed_result,
2679 __attribute__((unused)) struct cmdline *cl,
2680 __attribute__((unused)) void *data)
2682 struct cmd_tx_vlan_set_result *res = parsed_result;
2683 tx_vlan_set(res->port_id, res->vlan_id);
2686 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2687 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2688 tx_vlan, "tx_vlan");
2689 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2690 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2692 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2693 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2695 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2696 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2699 cmdline_parse_inst_t cmd_tx_vlan_set = {
2700 .f = cmd_tx_vlan_set_parsed,
2702 .help_str = "enable hardware insertion of a VLAN header with a given "
2703 "TAG Identifier in packets sent on a port",
2705 (void *)&cmd_tx_vlan_set_tx_vlan,
2706 (void *)&cmd_tx_vlan_set_set,
2707 (void *)&cmd_tx_vlan_set_vlanid,
2708 (void *)&cmd_tx_vlan_set_portid,
2713 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2714 struct cmd_tx_vlan_set_pvid_result {
2715 cmdline_fixed_string_t tx_vlan;
2716 cmdline_fixed_string_t set;
2717 cmdline_fixed_string_t pvid;
2720 cmdline_fixed_string_t mode;
2724 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2725 __attribute__((unused)) struct cmdline *cl,
2726 __attribute__((unused)) void *data)
2728 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2730 if (strcmp(res->mode, "on") == 0)
2731 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2733 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2736 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2737 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2738 tx_vlan, "tx_vlan");
2739 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2740 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2742 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2743 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2745 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2746 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2748 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2749 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2751 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2752 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2755 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2756 .f = cmd_tx_vlan_set_pvid_parsed,
2758 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2760 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2761 (void *)&cmd_tx_vlan_set_pvid_set,
2762 (void *)&cmd_tx_vlan_set_pvid_pvid,
2763 (void *)&cmd_tx_vlan_set_pvid_port_id,
2764 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2765 (void *)&cmd_tx_vlan_set_pvid_mode,
2770 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2771 struct cmd_tx_vlan_reset_result {
2772 cmdline_fixed_string_t tx_vlan;
2773 cmdline_fixed_string_t reset;
2778 cmd_tx_vlan_reset_parsed(void *parsed_result,
2779 __attribute__((unused)) struct cmdline *cl,
2780 __attribute__((unused)) void *data)
2782 struct cmd_tx_vlan_reset_result *res = parsed_result;
2784 tx_vlan_reset(res->port_id);
2787 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2788 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2789 tx_vlan, "tx_vlan");
2790 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2791 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2793 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2794 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2797 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2798 .f = cmd_tx_vlan_reset_parsed,
2800 .help_str = "disable hardware insertion of a VLAN header in packets "
2803 (void *)&cmd_tx_vlan_reset_tx_vlan,
2804 (void *)&cmd_tx_vlan_reset_reset,
2805 (void *)&cmd_tx_vlan_reset_portid,
2811 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2812 struct cmd_csum_result {
2813 cmdline_fixed_string_t csum;
2814 cmdline_fixed_string_t mode;
2815 cmdline_fixed_string_t proto;
2816 cmdline_fixed_string_t hwsw;
2821 csum_show(int port_id)
2823 struct rte_eth_dev_info dev_info;
2826 ol_flags = ports[port_id].tx_ol_flags;
2827 printf("Parse tunnel is %s\n",
2828 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
2829 printf("IP checksum offload is %s\n",
2830 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
2831 printf("UDP checksum offload is %s\n",
2832 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
2833 printf("TCP checksum offload is %s\n",
2834 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
2835 printf("SCTP checksum offload is %s\n",
2836 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
2837 printf("Outer-Ip checksum offload is %s\n",
2838 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
2840 /* display warnings if configuration is not supported by the NIC */
2841 rte_eth_dev_info_get(port_id, &dev_info);
2842 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
2843 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
2844 printf("Warning: hardware IP checksum enabled but not "
2845 "supported by port %d\n", port_id);
2847 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
2848 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
2849 printf("Warning: hardware UDP checksum enabled but not "
2850 "supported by port %d\n", port_id);
2852 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
2853 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
2854 printf("Warning: hardware TCP checksum enabled but not "
2855 "supported by port %d\n", port_id);
2857 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
2858 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
2859 printf("Warning: hardware SCTP checksum enabled but not "
2860 "supported by port %d\n", port_id);
2862 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
2863 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
2864 printf("Warning: hardware outer IP checksum enabled but not "
2865 "supported by port %d\n", port_id);
2870 cmd_csum_parsed(void *parsed_result,
2871 __attribute__((unused)) struct cmdline *cl,
2872 __attribute__((unused)) void *data)
2874 struct cmd_csum_result *res = parsed_result;
2878 if (port_id_is_invalid(res->port_id)) {
2879 printf("invalid port %d\n", res->port_id);
2883 if (!strcmp(res->mode, "set")) {
2885 if (!strcmp(res->hwsw, "hw"))
2888 if (!strcmp(res->proto, "ip")) {
2889 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
2890 } else if (!strcmp(res->proto, "udp")) {
2891 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
2892 } else if (!strcmp(res->proto, "tcp")) {
2893 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
2894 } else if (!strcmp(res->proto, "sctp")) {
2895 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
2896 } else if (!strcmp(res->proto, "outer-ip")) {
2897 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
2901 ports[res->port_id].tx_ol_flags |= mask;
2903 ports[res->port_id].tx_ol_flags &= (~mask);
2905 csum_show(res->port_id);
2908 cmdline_parse_token_string_t cmd_csum_csum =
2909 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2911 cmdline_parse_token_string_t cmd_csum_mode =
2912 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2914 cmdline_parse_token_string_t cmd_csum_proto =
2915 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2916 proto, "ip#tcp#udp#sctp#outer-ip");
2917 cmdline_parse_token_string_t cmd_csum_hwsw =
2918 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2920 cmdline_parse_token_num_t cmd_csum_portid =
2921 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
2924 cmdline_parse_inst_t cmd_csum_set = {
2925 .f = cmd_csum_parsed,
2927 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
2928 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
2930 (void *)&cmd_csum_csum,
2931 (void *)&cmd_csum_mode,
2932 (void *)&cmd_csum_proto,
2933 (void *)&cmd_csum_hwsw,
2934 (void *)&cmd_csum_portid,
2939 cmdline_parse_token_string_t cmd_csum_mode_show =
2940 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
2943 cmdline_parse_inst_t cmd_csum_show = {
2944 .f = cmd_csum_parsed,
2946 .help_str = "show checksum offload configuration: csum show <port>",
2948 (void *)&cmd_csum_csum,
2949 (void *)&cmd_csum_mode_show,
2950 (void *)&cmd_csum_portid,
2955 /* Enable/disable tunnel parsing */
2956 struct cmd_csum_tunnel_result {
2957 cmdline_fixed_string_t csum;
2958 cmdline_fixed_string_t parse;
2959 cmdline_fixed_string_t onoff;
2964 cmd_csum_tunnel_parsed(void *parsed_result,
2965 __attribute__((unused)) struct cmdline *cl,
2966 __attribute__((unused)) void *data)
2968 struct cmd_csum_tunnel_result *res = parsed_result;
2970 if (port_id_is_invalid(res->port_id)) {
2971 printf("invalid port %d\n", res->port_id);
2975 if (!strcmp(res->onoff, "on"))
2976 ports[res->port_id].tx_ol_flags |=
2977 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
2979 ports[res->port_id].tx_ol_flags &=
2980 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
2982 csum_show(res->port_id);
2985 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
2986 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
2988 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
2989 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
2990 parse, "parse_tunnel");
2991 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
2992 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
2994 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
2995 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
2998 cmdline_parse_inst_t cmd_csum_tunnel = {
2999 .f = cmd_csum_tunnel_parsed,
3001 .help_str = "enable/disable parsing of tunnels for csum engine: "
3002 "csum parse_tunnel on|off <tx-port>",
3004 (void *)&cmd_csum_tunnel_csum,
3005 (void *)&cmd_csum_tunnel_parse,
3006 (void *)&cmd_csum_tunnel_onoff,
3007 (void *)&cmd_csum_tunnel_portid,
3012 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3013 struct cmd_tso_set_result {
3014 cmdline_fixed_string_t tso;
3015 cmdline_fixed_string_t mode;
3021 cmd_tso_set_parsed(void *parsed_result,
3022 __attribute__((unused)) struct cmdline *cl,
3023 __attribute__((unused)) void *data)
3025 struct cmd_tso_set_result *res = parsed_result;
3026 struct rte_eth_dev_info dev_info;
3028 if (port_id_is_invalid(res->port_id))
3031 if (!strcmp(res->mode, "set"))
3032 ports[res->port_id].tso_segsz = res->tso_segsz;
3034 if (ports[res->port_id].tso_segsz == 0)
3035 printf("TSO is disabled\n");
3037 printf("TSO segment size is %d\n",
3038 ports[res->port_id].tso_segsz);
3040 /* display warnings if configuration is not supported by the NIC */
3041 rte_eth_dev_info_get(res->port_id, &dev_info);
3042 if ((ports[res->port_id].tso_segsz != 0) &&
3043 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3044 printf("Warning: TSO enabled but not "
3045 "supported by port %d\n", res->port_id);
3049 cmdline_parse_token_string_t cmd_tso_set_tso =
3050 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3052 cmdline_parse_token_string_t cmd_tso_set_mode =
3053 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3055 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3056 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3058 cmdline_parse_token_num_t cmd_tso_set_portid =
3059 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3062 cmdline_parse_inst_t cmd_tso_set = {
3063 .f = cmd_tso_set_parsed,
3065 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3066 "tso set <tso_segsz> <port>",
3068 (void *)&cmd_tso_set_tso,
3069 (void *)&cmd_tso_set_mode,
3070 (void *)&cmd_tso_set_tso_segsz,
3071 (void *)&cmd_tso_set_portid,
3076 cmdline_parse_token_string_t cmd_tso_show_mode =
3077 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3081 cmdline_parse_inst_t cmd_tso_show = {
3082 .f = cmd_tso_set_parsed,
3084 .help_str = "Show TSO segment size for csum engine: "
3087 (void *)&cmd_tso_set_tso,
3088 (void *)&cmd_tso_show_mode,
3089 (void *)&cmd_tso_set_portid,
3094 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3095 struct cmd_set_flush_rx {
3096 cmdline_fixed_string_t set;
3097 cmdline_fixed_string_t flush_rx;
3098 cmdline_fixed_string_t mode;
3102 cmd_set_flush_rx_parsed(void *parsed_result,
3103 __attribute__((unused)) struct cmdline *cl,
3104 __attribute__((unused)) void *data)
3106 struct cmd_set_flush_rx *res = parsed_result;
3107 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3110 cmdline_parse_token_string_t cmd_setflushrx_set =
3111 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3113 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3114 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3115 flush_rx, "flush_rx");
3116 cmdline_parse_token_string_t cmd_setflushrx_mode =
3117 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3121 cmdline_parse_inst_t cmd_set_flush_rx = {
3122 .f = cmd_set_flush_rx_parsed,
3123 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3126 (void *)&cmd_setflushrx_set,
3127 (void *)&cmd_setflushrx_flush_rx,
3128 (void *)&cmd_setflushrx_mode,
3133 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3134 struct cmd_set_link_check {
3135 cmdline_fixed_string_t set;
3136 cmdline_fixed_string_t link_check;
3137 cmdline_fixed_string_t mode;
3141 cmd_set_link_check_parsed(void *parsed_result,
3142 __attribute__((unused)) struct cmdline *cl,
3143 __attribute__((unused)) void *data)
3145 struct cmd_set_link_check *res = parsed_result;
3146 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3149 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3150 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3152 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3153 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3154 link_check, "link_check");
3155 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3156 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3160 cmdline_parse_inst_t cmd_set_link_check = {
3161 .f = cmd_set_link_check_parsed,
3162 .help_str = "set link_check on|off: enable/disable link status check "
3163 "when starting/stopping a port",
3166 (void *)&cmd_setlinkcheck_set,
3167 (void *)&cmd_setlinkcheck_link_check,
3168 (void *)&cmd_setlinkcheck_mode,
3173 #ifdef RTE_NIC_BYPASS
3174 /* *** SET NIC BYPASS MODE *** */
3175 struct cmd_set_bypass_mode_result {
3176 cmdline_fixed_string_t set;
3177 cmdline_fixed_string_t bypass;
3178 cmdline_fixed_string_t mode;
3179 cmdline_fixed_string_t value;
3184 cmd_set_bypass_mode_parsed(void *parsed_result,
3185 __attribute__((unused)) struct cmdline *cl,
3186 __attribute__((unused)) void *data)
3188 struct cmd_set_bypass_mode_result *res = parsed_result;
3189 portid_t port_id = res->port_id;
3190 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3192 if (!bypass_is_supported(port_id))
3195 if (!strcmp(res->value, "bypass"))
3196 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3197 else if (!strcmp(res->value, "isolate"))
3198 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3200 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3202 /* Set the bypass mode for the relevant port. */
3203 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3204 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3208 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3209 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3211 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3212 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3214 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3215 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3217 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3218 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3219 value, "normal#bypass#isolate");
3220 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3221 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3224 cmdline_parse_inst_t cmd_set_bypass_mode = {
3225 .f = cmd_set_bypass_mode_parsed,
3226 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3227 "Set the NIC bypass mode for port_id",
3230 (void *)&cmd_setbypass_mode_set,
3231 (void *)&cmd_setbypass_mode_bypass,
3232 (void *)&cmd_setbypass_mode_mode,
3233 (void *)&cmd_setbypass_mode_value,
3234 (void *)&cmd_setbypass_mode_port,
3239 /* *** SET NIC BYPASS EVENT *** */
3240 struct cmd_set_bypass_event_result {
3241 cmdline_fixed_string_t set;
3242 cmdline_fixed_string_t bypass;
3243 cmdline_fixed_string_t event;
3244 cmdline_fixed_string_t event_value;
3245 cmdline_fixed_string_t mode;
3246 cmdline_fixed_string_t mode_value;
3251 cmd_set_bypass_event_parsed(void *parsed_result,
3252 __attribute__((unused)) struct cmdline *cl,
3253 __attribute__((unused)) void *data)
3256 struct cmd_set_bypass_event_result *res = parsed_result;
3257 portid_t port_id = res->port_id;
3258 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3259 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3261 if (!bypass_is_supported(port_id))
3264 if (!strcmp(res->event_value, "timeout"))
3265 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3266 else if (!strcmp(res->event_value, "os_on"))
3267 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3268 else if (!strcmp(res->event_value, "os_off"))
3269 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3270 else if (!strcmp(res->event_value, "power_on"))
3271 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3272 else if (!strcmp(res->event_value, "power_off"))
3273 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3275 bypass_event = RTE_BYPASS_EVENT_NONE;
3277 if (!strcmp(res->mode_value, "bypass"))
3278 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3279 else if (!strcmp(res->mode_value, "isolate"))
3280 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3282 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3284 /* Set the watchdog timeout. */
3285 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3288 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3289 (rc = rte_eth_dev_wd_timeout_store(port_id,
3290 bypass_timeout)) != 0) {
3291 printf("Failed to set timeout value %u "
3292 "for port %d, errto code: %d.\n",
3293 bypass_timeout, port_id, rc);
3297 /* Set the bypass event to transition to bypass mode. */
3298 if (0 != rte_eth_dev_bypass_event_store(port_id,
3299 bypass_event, bypass_mode)) {
3300 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3305 cmdline_parse_token_string_t cmd_setbypass_event_set =
3306 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3308 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3309 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3311 cmdline_parse_token_string_t cmd_setbypass_event_event =
3312 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3314 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3315 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3316 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3317 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3318 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3320 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3321 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3322 mode_value, "normal#bypass#isolate");
3323 cmdline_parse_token_num_t cmd_setbypass_event_port =
3324 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3327 cmdline_parse_inst_t cmd_set_bypass_event = {
3328 .f = cmd_set_bypass_event_parsed,
3329 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3330 "mode (normal|bypass|isolate) (port_id): "
3331 "Set the NIC bypass event mode for port_id",
3334 (void *)&cmd_setbypass_event_set,
3335 (void *)&cmd_setbypass_event_bypass,
3336 (void *)&cmd_setbypass_event_event,
3337 (void *)&cmd_setbypass_event_event_value,
3338 (void *)&cmd_setbypass_event_mode,
3339 (void *)&cmd_setbypass_event_mode_value,
3340 (void *)&cmd_setbypass_event_port,
3346 /* *** SET NIC BYPASS TIMEOUT *** */
3347 struct cmd_set_bypass_timeout_result {
3348 cmdline_fixed_string_t set;
3349 cmdline_fixed_string_t bypass;
3350 cmdline_fixed_string_t timeout;
3351 cmdline_fixed_string_t value;
3355 cmd_set_bypass_timeout_parsed(void *parsed_result,
3356 __attribute__((unused)) struct cmdline *cl,
3357 __attribute__((unused)) void *data)
3359 struct cmd_set_bypass_timeout_result *res = parsed_result;
3361 if (!strcmp(res->value, "1.5"))
3362 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3363 else if (!strcmp(res->value, "2"))
3364 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3365 else if (!strcmp(res->value, "3"))
3366 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3367 else if (!strcmp(res->value, "4"))
3368 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3369 else if (!strcmp(res->value, "8"))
3370 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3371 else if (!strcmp(res->value, "16"))
3372 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3373 else if (!strcmp(res->value, "32"))
3374 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3376 bypass_timeout = RTE_BYPASS_TMT_OFF;
3379 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3380 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3382 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3383 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3385 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3386 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3387 timeout, "timeout");
3388 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3389 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3390 value, "0#1.5#2#3#4#8#16#32");
3392 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3393 .f = cmd_set_bypass_timeout_parsed,
3394 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3395 "Set the NIC bypass watchdog timeout",
3398 (void *)&cmd_setbypass_timeout_set,
3399 (void *)&cmd_setbypass_timeout_bypass,
3400 (void *)&cmd_setbypass_timeout_timeout,
3401 (void *)&cmd_setbypass_timeout_value,
3406 /* *** SHOW NIC BYPASS MODE *** */
3407 struct cmd_show_bypass_config_result {
3408 cmdline_fixed_string_t show;
3409 cmdline_fixed_string_t bypass;
3410 cmdline_fixed_string_t config;
3415 cmd_show_bypass_config_parsed(void *parsed_result,
3416 __attribute__((unused)) struct cmdline *cl,
3417 __attribute__((unused)) void *data)
3419 struct cmd_show_bypass_config_result *res = parsed_result;
3420 uint32_t event_mode;
3421 uint32_t bypass_mode;
3422 portid_t port_id = res->port_id;
3423 uint32_t timeout = bypass_timeout;
3426 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3427 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3428 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3429 {"UNKNOWN", "normal", "bypass", "isolate"};
3430 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3437 int num_events = (sizeof events) / (sizeof events[0]);
3439 if (!bypass_is_supported(port_id))
3442 /* Display the bypass mode.*/
3443 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3444 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3448 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3449 bypass_mode = RTE_BYPASS_MODE_NONE;
3451 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3454 /* Display the bypass timeout.*/
3455 if (!RTE_BYPASS_TMT_VALID(timeout))
3456 timeout = RTE_BYPASS_TMT_OFF;
3458 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3460 /* Display the bypass events and associated modes. */
3461 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3463 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3464 printf("\tFailed to get bypass mode for event = %s\n",
3467 if (!RTE_BYPASS_MODE_VALID(event_mode))
3468 event_mode = RTE_BYPASS_MODE_NONE;
3470 printf("\tbypass event: %-16s = %s\n", events[i],
3476 cmdline_parse_token_string_t cmd_showbypass_config_show =
3477 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3479 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3480 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3482 cmdline_parse_token_string_t cmd_showbypass_config_config =
3483 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3485 cmdline_parse_token_num_t cmd_showbypass_config_port =
3486 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3489 cmdline_parse_inst_t cmd_show_bypass_config = {
3490 .f = cmd_show_bypass_config_parsed,
3491 .help_str = "show bypass config (port_id): "
3492 "Show the NIC bypass config for port_id",
3495 (void *)&cmd_showbypass_config_show,
3496 (void *)&cmd_showbypass_config_bypass,
3497 (void *)&cmd_showbypass_config_config,
3498 (void *)&cmd_showbypass_config_port,
3504 #ifdef RTE_LIBRTE_PMD_BOND
3505 /* *** SET BONDING MODE *** */
3506 struct cmd_set_bonding_mode_result {
3507 cmdline_fixed_string_t set;
3508 cmdline_fixed_string_t bonding;
3509 cmdline_fixed_string_t mode;
3514 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3515 __attribute__((unused)) struct cmdline *cl,
3516 __attribute__((unused)) void *data)
3518 struct cmd_set_bonding_mode_result *res = parsed_result;
3519 portid_t port_id = res->port_id;
3521 /* Set the bonding mode for the relevant port. */
3522 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3523 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3526 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3527 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3529 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3530 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3531 bonding, "bonding");
3532 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3533 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3535 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3536 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3538 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3539 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3542 cmdline_parse_inst_t cmd_set_bonding_mode = {
3543 .f = cmd_set_bonding_mode_parsed,
3544 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3547 (void *) &cmd_setbonding_mode_set,
3548 (void *) &cmd_setbonding_mode_bonding,
3549 (void *) &cmd_setbonding_mode_mode,
3550 (void *) &cmd_setbonding_mode_value,
3551 (void *) &cmd_setbonding_mode_port,
3556 /* *** SET BALANCE XMIT POLICY *** */
3557 struct cmd_set_bonding_balance_xmit_policy_result {
3558 cmdline_fixed_string_t set;
3559 cmdline_fixed_string_t bonding;
3560 cmdline_fixed_string_t balance_xmit_policy;
3562 cmdline_fixed_string_t policy;
3565 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3566 __attribute__((unused)) struct cmdline *cl,
3567 __attribute__((unused)) void *data)
3569 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3570 portid_t port_id = res->port_id;
3573 if (!strcmp(res->policy, "l2")) {
3574 policy = BALANCE_XMIT_POLICY_LAYER2;
3575 } else if (!strcmp(res->policy, "l23")) {
3576 policy = BALANCE_XMIT_POLICY_LAYER23;
3577 } else if (!strcmp(res->policy, "l34")) {
3578 policy = BALANCE_XMIT_POLICY_LAYER34;
3580 printf("\t Invalid xmit policy selection");
3584 /* Set the bonding mode for the relevant port. */
3585 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3586 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3591 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3592 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3594 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3595 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3596 bonding, "bonding");
3597 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3598 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3599 balance_xmit_policy, "balance_xmit_policy");
3600 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3601 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3603 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3604 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3605 policy, "l2#l23#l34");
3607 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3608 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3609 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3612 (void *)&cmd_setbonding_balance_xmit_policy_set,
3613 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3614 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3615 (void *)&cmd_setbonding_balance_xmit_policy_port,
3616 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3621 /* *** SHOW NIC BONDING CONFIGURATION *** */
3622 struct cmd_show_bonding_config_result {
3623 cmdline_fixed_string_t show;
3624 cmdline_fixed_string_t bonding;
3625 cmdline_fixed_string_t config;
3629 static void cmd_show_bonding_config_parsed(void *parsed_result,
3630 __attribute__((unused)) struct cmdline *cl,
3631 __attribute__((unused)) void *data)
3633 struct cmd_show_bonding_config_result *res = parsed_result;
3635 uint8_t slaves[RTE_MAX_ETHPORTS];
3636 int num_slaves, num_active_slaves;
3639 portid_t port_id = res->port_id;
3641 /* Display the bonding mode.*/
3642 bonding_mode = rte_eth_bond_mode_get(port_id);
3643 if (bonding_mode < 0) {
3644 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3647 printf("\tBonding mode: %d\n", bonding_mode);
3649 if (bonding_mode == BONDING_MODE_BALANCE) {
3650 int balance_xmit_policy;
3652 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3653 if (balance_xmit_policy < 0) {
3654 printf("\tFailed to get balance xmit policy for port = %d\n",
3658 printf("\tBalance Xmit Policy: ");
3660 switch (balance_xmit_policy) {
3661 case BALANCE_XMIT_POLICY_LAYER2:
3662 printf("BALANCE_XMIT_POLICY_LAYER2");
3664 case BALANCE_XMIT_POLICY_LAYER23:
3665 printf("BALANCE_XMIT_POLICY_LAYER23");
3667 case BALANCE_XMIT_POLICY_LAYER34:
3668 printf("BALANCE_XMIT_POLICY_LAYER34");
3675 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3677 if (num_slaves < 0) {
3678 printf("\tFailed to get slave list for port = %d\n", port_id);
3681 if (num_slaves > 0) {
3682 printf("\tSlaves (%d): [", num_slaves);
3683 for (i = 0; i < num_slaves - 1; i++)
3684 printf("%d ", slaves[i]);
3686 printf("%d]\n", slaves[num_slaves - 1]);
3688 printf("\tSlaves: []\n");
3692 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3695 if (num_active_slaves < 0) {
3696 printf("\tFailed to get active slave list for port = %d\n", port_id);
3699 if (num_active_slaves > 0) {
3700 printf("\tActive Slaves (%d): [", num_active_slaves);
3701 for (i = 0; i < num_active_slaves - 1; i++)
3702 printf("%d ", slaves[i]);
3704 printf("%d]\n", slaves[num_active_slaves - 1]);
3707 printf("\tActive Slaves: []\n");
3711 primary_id = rte_eth_bond_primary_get(port_id);
3712 if (primary_id < 0) {
3713 printf("\tFailed to get primary slave for port = %d\n", port_id);
3716 printf("\tPrimary: [%d]\n", primary_id);
3720 cmdline_parse_token_string_t cmd_showbonding_config_show =
3721 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3723 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3724 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3725 bonding, "bonding");
3726 cmdline_parse_token_string_t cmd_showbonding_config_config =
3727 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3729 cmdline_parse_token_num_t cmd_showbonding_config_port =
3730 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3733 cmdline_parse_inst_t cmd_show_bonding_config = {
3734 .f = cmd_show_bonding_config_parsed,
3735 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3738 (void *)&cmd_showbonding_config_show,
3739 (void *)&cmd_showbonding_config_bonding,
3740 (void *)&cmd_showbonding_config_config,
3741 (void *)&cmd_showbonding_config_port,
3746 /* *** SET BONDING PRIMARY *** */
3747 struct cmd_set_bonding_primary_result {
3748 cmdline_fixed_string_t set;
3749 cmdline_fixed_string_t bonding;
3750 cmdline_fixed_string_t primary;
3755 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3756 __attribute__((unused)) struct cmdline *cl,
3757 __attribute__((unused)) void *data)
3759 struct cmd_set_bonding_primary_result *res = parsed_result;
3760 portid_t master_port_id = res->port_id;
3761 portid_t slave_port_id = res->slave_id;
3763 /* Set the primary slave for a bonded device. */
3764 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3765 printf("\t Failed to set primary slave for port = %d.\n",
3772 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3773 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3775 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3776 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3777 bonding, "bonding");
3778 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3779 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3780 primary, "primary");
3781 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3782 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3784 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3785 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3788 cmdline_parse_inst_t cmd_set_bonding_primary = {
3789 .f = cmd_set_bonding_primary_parsed,
3790 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3793 (void *)&cmd_setbonding_primary_set,
3794 (void *)&cmd_setbonding_primary_bonding,
3795 (void *)&cmd_setbonding_primary_primary,
3796 (void *)&cmd_setbonding_primary_slave,
3797 (void *)&cmd_setbonding_primary_port,
3802 /* *** ADD SLAVE *** */
3803 struct cmd_add_bonding_slave_result {
3804 cmdline_fixed_string_t add;
3805 cmdline_fixed_string_t bonding;
3806 cmdline_fixed_string_t slave;
3811 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3812 __attribute__((unused)) struct cmdline *cl,
3813 __attribute__((unused)) void *data)
3815 struct cmd_add_bonding_slave_result *res = parsed_result;
3816 portid_t master_port_id = res->port_id;
3817 portid_t slave_port_id = res->slave_id;
3819 /* Set the primary slave for a bonded device. */
3820 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3821 printf("\t Failed to add slave %d to master port = %d.\n",
3822 slave_port_id, master_port_id);
3828 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3829 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3831 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3832 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3833 bonding, "bonding");
3834 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3835 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3837 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3838 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3840 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3841 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3844 cmdline_parse_inst_t cmd_add_bonding_slave = {
3845 .f = cmd_add_bonding_slave_parsed,
3846 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3849 (void *)&cmd_addbonding_slave_add,
3850 (void *)&cmd_addbonding_slave_bonding,
3851 (void *)&cmd_addbonding_slave_slave,
3852 (void *)&cmd_addbonding_slave_slaveid,
3853 (void *)&cmd_addbonding_slave_port,
3858 /* *** REMOVE SLAVE *** */
3859 struct cmd_remove_bonding_slave_result {
3860 cmdline_fixed_string_t remove;
3861 cmdline_fixed_string_t bonding;
3862 cmdline_fixed_string_t slave;
3867 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3868 __attribute__((unused)) struct cmdline *cl,
3869 __attribute__((unused)) void *data)
3871 struct cmd_remove_bonding_slave_result *res = parsed_result;
3872 portid_t master_port_id = res->port_id;
3873 portid_t slave_port_id = res->slave_id;
3875 /* Set the primary slave for a bonded device. */
3876 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3877 printf("\t Failed to remove slave %d from master port = %d.\n",
3878 slave_port_id, master_port_id);
3884 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3885 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3887 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3888 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3889 bonding, "bonding");
3890 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3891 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3893 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3894 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3896 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3897 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3900 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3901 .f = cmd_remove_bonding_slave_parsed,
3902 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3905 (void *)&cmd_removebonding_slave_remove,
3906 (void *)&cmd_removebonding_slave_bonding,
3907 (void *)&cmd_removebonding_slave_slave,
3908 (void *)&cmd_removebonding_slave_slaveid,
3909 (void *)&cmd_removebonding_slave_port,
3914 /* *** CREATE BONDED DEVICE *** */
3915 struct cmd_create_bonded_device_result {
3916 cmdline_fixed_string_t create;
3917 cmdline_fixed_string_t bonded;
3918 cmdline_fixed_string_t device;
3923 static int bond_dev_num = 0;
3925 static void cmd_create_bonded_device_parsed(void *parsed_result,
3926 __attribute__((unused)) struct cmdline *cl,
3927 __attribute__((unused)) void *data)
3929 struct cmd_create_bonded_device_result *res = parsed_result;
3930 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3933 if (test_done == 0) {
3934 printf("Please stop forwarding first\n");
3938 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3941 /* Create a new bonded device. */
3942 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3944 printf("\t Failed to create bonded device.\n");
3947 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3950 /* Update number of ports */
3951 nb_ports = rte_eth_dev_count();
3952 reconfig(port_id, res->socket);
3953 rte_eth_promiscuous_enable(port_id);
3958 cmdline_parse_token_string_t cmd_createbonded_device_create =
3959 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3961 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3962 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3964 cmdline_parse_token_string_t cmd_createbonded_device_device =
3965 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3967 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3968 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3970 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3971 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3974 cmdline_parse_inst_t cmd_create_bonded_device = {
3975 .f = cmd_create_bonded_device_parsed,
3976 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3979 (void *)&cmd_createbonded_device_create,
3980 (void *)&cmd_createbonded_device_bonded,
3981 (void *)&cmd_createbonded_device_device,
3982 (void *)&cmd_createbonded_device_mode,
3983 (void *)&cmd_createbonded_device_socket,
3988 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3989 struct cmd_set_bond_mac_addr_result {
3990 cmdline_fixed_string_t set;
3991 cmdline_fixed_string_t bonding;
3992 cmdline_fixed_string_t mac_addr;
3994 struct ether_addr address;
3997 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3998 __attribute__((unused)) struct cmdline *cl,
3999 __attribute__((unused)) void *data)
4001 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4004 if (res->port_num >= nb_ports) {
4005 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4009 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4011 /* check the return value and print it if is < 0 */
4013 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4016 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4017 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4018 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4019 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4021 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4024 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4025 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4026 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4027 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4029 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4030 .f = cmd_set_bond_mac_addr_parsed,
4032 .help_str = "set bonding mac_addr (port_id) (address): ",
4034 (void *)&cmd_set_bond_mac_addr_set,
4035 (void *)&cmd_set_bond_mac_addr_bonding,
4036 (void *)&cmd_set_bond_mac_addr_mac,
4037 (void *)&cmd_set_bond_mac_addr_portnum,
4038 (void *)&cmd_set_bond_mac_addr_addr,
4044 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4045 struct cmd_set_bond_mon_period_result {
4046 cmdline_fixed_string_t set;
4047 cmdline_fixed_string_t bonding;
4048 cmdline_fixed_string_t mon_period;
4053 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4054 __attribute__((unused)) struct cmdline *cl,
4055 __attribute__((unused)) void *data)
4057 struct cmd_set_bond_mon_period_result *res = parsed_result;
4060 if (res->port_num >= nb_ports) {
4061 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4065 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4067 /* check the return value and print it if is < 0 */
4069 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4072 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4073 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4075 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4077 bonding, "bonding");
4078 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4079 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4080 mon_period, "mon_period");
4081 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4082 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4084 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4085 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4088 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4089 .f = cmd_set_bond_mon_period_parsed,
4091 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4093 (void *)&cmd_set_bond_mon_period_set,
4094 (void *)&cmd_set_bond_mon_period_bonding,
4095 (void *)&cmd_set_bond_mon_period_mon_period,
4096 (void *)&cmd_set_bond_mon_period_portnum,
4097 (void *)&cmd_set_bond_mon_period_period_ms,
4102 #endif /* RTE_LIBRTE_PMD_BOND */
4104 /* *** SET FORWARDING MODE *** */
4105 struct cmd_set_fwd_mode_result {
4106 cmdline_fixed_string_t set;
4107 cmdline_fixed_string_t fwd;
4108 cmdline_fixed_string_t mode;
4111 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4112 __attribute__((unused)) struct cmdline *cl,
4113 __attribute__((unused)) void *data)
4115 struct cmd_set_fwd_mode_result *res = parsed_result;
4117 set_pkt_forwarding_mode(res->mode);
4120 cmdline_parse_token_string_t cmd_setfwd_set =
4121 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4122 cmdline_parse_token_string_t cmd_setfwd_fwd =
4123 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4124 cmdline_parse_token_string_t cmd_setfwd_mode =
4125 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4126 "" /* defined at init */);
4128 cmdline_parse_inst_t cmd_set_fwd_mode = {
4129 .f = cmd_set_fwd_mode_parsed,
4131 .help_str = NULL, /* defined at init */
4133 (void *)&cmd_setfwd_set,
4134 (void *)&cmd_setfwd_fwd,
4135 (void *)&cmd_setfwd_mode,
4140 static void cmd_set_fwd_mode_init(void)
4143 static char token[128];
4144 static char help[256];
4145 cmdline_parse_token_string_t *token_struct;
4147 modes = list_pkt_forwarding_modes();
4148 snprintf(help, sizeof help, "set fwd %s - "
4149 "set packet forwarding mode", modes);
4150 cmd_set_fwd_mode.help_str = help;
4152 /* string token separator is # */
4153 for (c = token; *modes != '\0'; modes++)
4158 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4159 token_struct->string_data.str = token;
4162 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4163 struct cmd_set_burst_tx_retry_result {
4164 cmdline_fixed_string_t set;
4165 cmdline_fixed_string_t burst;
4166 cmdline_fixed_string_t tx;
4167 cmdline_fixed_string_t delay;
4169 cmdline_fixed_string_t retry;
4173 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4174 __attribute__((unused)) struct cmdline *cl,
4175 __attribute__((unused)) void *data)
4177 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4179 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4180 && !strcmp(res->tx, "tx")) {
4181 if (!strcmp(res->delay, "delay"))
4182 burst_tx_delay_time = res->time;
4183 if (!strcmp(res->retry, "retry"))
4184 burst_tx_retry_num = res->retry_num;
4189 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4190 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4191 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4192 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4194 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4195 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4196 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4197 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4198 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4199 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4200 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4201 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4202 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4203 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4205 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4206 .f = cmd_set_burst_tx_retry_parsed,
4207 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4209 (void *)&cmd_set_burst_tx_retry_set,
4210 (void *)&cmd_set_burst_tx_retry_burst,
4211 (void *)&cmd_set_burst_tx_retry_tx,
4212 (void *)&cmd_set_burst_tx_retry_delay,
4213 (void *)&cmd_set_burst_tx_retry_time,
4214 (void *)&cmd_set_burst_tx_retry_retry,
4215 (void *)&cmd_set_burst_tx_retry_retry_num,
4220 /* *** SET PROMISC MODE *** */
4221 struct cmd_set_promisc_mode_result {
4222 cmdline_fixed_string_t set;
4223 cmdline_fixed_string_t promisc;
4224 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4225 uint8_t port_num; /* valid if "allports" argument == 0 */
4226 cmdline_fixed_string_t mode;
4229 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4230 __attribute__((unused)) struct cmdline *cl,
4233 struct cmd_set_promisc_mode_result *res = parsed_result;
4237 if (!strcmp(res->mode, "on"))
4244 for (i = 0; i < nb_ports; i++) {
4246 rte_eth_promiscuous_enable(i);
4248 rte_eth_promiscuous_disable(i);
4253 rte_eth_promiscuous_enable(res->port_num);
4255 rte_eth_promiscuous_disable(res->port_num);
4259 cmdline_parse_token_string_t cmd_setpromisc_set =
4260 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4261 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4262 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4264 cmdline_parse_token_string_t cmd_setpromisc_portall =
4265 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4267 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4268 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4270 cmdline_parse_token_string_t cmd_setpromisc_mode =
4271 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4274 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4275 .f = cmd_set_promisc_mode_parsed,
4277 .help_str = "set promisc all on|off: set promisc mode for all ports",
4279 (void *)&cmd_setpromisc_set,
4280 (void *)&cmd_setpromisc_promisc,
4281 (void *)&cmd_setpromisc_portall,
4282 (void *)&cmd_setpromisc_mode,
4287 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4288 .f = cmd_set_promisc_mode_parsed,
4290 .help_str = "set promisc X on|off: set promisc mode on port X",
4292 (void *)&cmd_setpromisc_set,
4293 (void *)&cmd_setpromisc_promisc,
4294 (void *)&cmd_setpromisc_portnum,
4295 (void *)&cmd_setpromisc_mode,
4300 /* *** SET ALLMULTI MODE *** */
4301 struct cmd_set_allmulti_mode_result {
4302 cmdline_fixed_string_t set;
4303 cmdline_fixed_string_t allmulti;
4304 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4305 uint8_t port_num; /* valid if "allports" argument == 0 */
4306 cmdline_fixed_string_t mode;
4309 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4310 __attribute__((unused)) struct cmdline *cl,
4313 struct cmd_set_allmulti_mode_result *res = parsed_result;
4317 if (!strcmp(res->mode, "on"))
4324 for (i = 0; i < nb_ports; i++) {
4326 rte_eth_allmulticast_enable(i);
4328 rte_eth_allmulticast_disable(i);
4333 rte_eth_allmulticast_enable(res->port_num);
4335 rte_eth_allmulticast_disable(res->port_num);
4339 cmdline_parse_token_string_t cmd_setallmulti_set =
4340 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4341 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4342 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4344 cmdline_parse_token_string_t cmd_setallmulti_portall =
4345 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4347 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4348 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4350 cmdline_parse_token_string_t cmd_setallmulti_mode =
4351 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4354 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4355 .f = cmd_set_allmulti_mode_parsed,
4357 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4359 (void *)&cmd_setallmulti_set,
4360 (void *)&cmd_setallmulti_allmulti,
4361 (void *)&cmd_setallmulti_portall,
4362 (void *)&cmd_setallmulti_mode,
4367 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4368 .f = cmd_set_allmulti_mode_parsed,
4370 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4372 (void *)&cmd_setallmulti_set,
4373 (void *)&cmd_setallmulti_allmulti,
4374 (void *)&cmd_setallmulti_portnum,
4375 (void *)&cmd_setallmulti_mode,
4380 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4381 struct cmd_link_flow_ctrl_set_result {
4382 cmdline_fixed_string_t set;
4383 cmdline_fixed_string_t flow_ctrl;
4384 cmdline_fixed_string_t rx;
4385 cmdline_fixed_string_t rx_lfc_mode;
4386 cmdline_fixed_string_t tx;
4387 cmdline_fixed_string_t tx_lfc_mode;
4388 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4389 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4390 cmdline_fixed_string_t autoneg_str;
4391 cmdline_fixed_string_t autoneg;
4392 cmdline_fixed_string_t hw_str;
4393 uint32_t high_water;
4394 cmdline_fixed_string_t lw_str;
4396 cmdline_fixed_string_t pt_str;
4397 uint16_t pause_time;
4398 cmdline_fixed_string_t xon_str;
4403 cmdline_parse_token_string_t cmd_lfc_set_set =
4404 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4406 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4407 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4408 flow_ctrl, "flow_ctrl");
4409 cmdline_parse_token_string_t cmd_lfc_set_rx =
4410 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4412 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4413 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4414 rx_lfc_mode, "on#off");
4415 cmdline_parse_token_string_t cmd_lfc_set_tx =
4416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4418 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4420 tx_lfc_mode, "on#off");
4421 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4423 hw_str, "high_water");
4424 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4425 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4426 high_water, UINT32);
4427 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4429 lw_str, "low_water");
4430 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4431 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4433 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4434 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4435 pt_str, "pause_time");
4436 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4437 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4438 pause_time, UINT16);
4439 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4440 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4441 xon_str, "send_xon");
4442 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4443 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4445 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4446 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4447 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4448 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4449 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4450 mac_ctrl_frame_fwd_mode, "on#off");
4451 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4452 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4453 autoneg_str, "autoneg");
4454 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4455 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4457 cmdline_parse_token_num_t cmd_lfc_set_portid =
4458 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4461 /* forward declaration */
4463 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4466 cmdline_parse_inst_t cmd_link_flow_control_set = {
4467 .f = cmd_link_flow_ctrl_set_parsed,
4469 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4470 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4471 autoneg on|off port_id",
4473 (void *)&cmd_lfc_set_set,
4474 (void *)&cmd_lfc_set_flow_ctrl,
4475 (void *)&cmd_lfc_set_rx,
4476 (void *)&cmd_lfc_set_rx_mode,
4477 (void *)&cmd_lfc_set_tx,
4478 (void *)&cmd_lfc_set_tx_mode,
4479 (void *)&cmd_lfc_set_high_water,
4480 (void *)&cmd_lfc_set_low_water,
4481 (void *)&cmd_lfc_set_pause_time,
4482 (void *)&cmd_lfc_set_send_xon,
4483 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4484 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4485 (void *)&cmd_lfc_set_autoneg_str,
4486 (void *)&cmd_lfc_set_autoneg,
4487 (void *)&cmd_lfc_set_portid,
4492 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4493 .f = cmd_link_flow_ctrl_set_parsed,
4494 .data = (void *)&cmd_link_flow_control_set_rx,
4495 .help_str = "Change rx flow control parameter: set flow_ctrl "
4496 "rx on|off port_id",
4498 (void *)&cmd_lfc_set_set,
4499 (void *)&cmd_lfc_set_flow_ctrl,
4500 (void *)&cmd_lfc_set_rx,
4501 (void *)&cmd_lfc_set_rx_mode,
4502 (void *)&cmd_lfc_set_portid,
4507 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4508 .f = cmd_link_flow_ctrl_set_parsed,
4509 .data = (void *)&cmd_link_flow_control_set_tx,
4510 .help_str = "Change tx flow control parameter: set flow_ctrl "
4511 "tx on|off port_id",
4513 (void *)&cmd_lfc_set_set,
4514 (void *)&cmd_lfc_set_flow_ctrl,
4515 (void *)&cmd_lfc_set_tx,
4516 (void *)&cmd_lfc_set_tx_mode,
4517 (void *)&cmd_lfc_set_portid,
4522 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4523 .f = cmd_link_flow_ctrl_set_parsed,
4524 .data = (void *)&cmd_link_flow_control_set_hw,
4525 .help_str = "Change high water flow control parameter: set flow_ctrl "
4526 "high_water value port_id",
4528 (void *)&cmd_lfc_set_set,
4529 (void *)&cmd_lfc_set_flow_ctrl,
4530 (void *)&cmd_lfc_set_high_water_str,
4531 (void *)&cmd_lfc_set_high_water,
4532 (void *)&cmd_lfc_set_portid,
4537 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4538 .f = cmd_link_flow_ctrl_set_parsed,
4539 .data = (void *)&cmd_link_flow_control_set_lw,
4540 .help_str = "Change low water flow control parameter: set flow_ctrl "
4541 "low_water value port_id",
4543 (void *)&cmd_lfc_set_set,
4544 (void *)&cmd_lfc_set_flow_ctrl,
4545 (void *)&cmd_lfc_set_low_water_str,
4546 (void *)&cmd_lfc_set_low_water,
4547 (void *)&cmd_lfc_set_portid,
4552 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4553 .f = cmd_link_flow_ctrl_set_parsed,
4554 .data = (void *)&cmd_link_flow_control_set_pt,
4555 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4556 "pause_time value port_id",
4558 (void *)&cmd_lfc_set_set,
4559 (void *)&cmd_lfc_set_flow_ctrl,
4560 (void *)&cmd_lfc_set_pause_time_str,
4561 (void *)&cmd_lfc_set_pause_time,
4562 (void *)&cmd_lfc_set_portid,
4567 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4568 .f = cmd_link_flow_ctrl_set_parsed,
4569 .data = (void *)&cmd_link_flow_control_set_xon,
4570 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4571 "send_xon value port_id",
4573 (void *)&cmd_lfc_set_set,
4574 (void *)&cmd_lfc_set_flow_ctrl,
4575 (void *)&cmd_lfc_set_send_xon_str,
4576 (void *)&cmd_lfc_set_send_xon,
4577 (void *)&cmd_lfc_set_portid,
4582 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4583 .f = cmd_link_flow_ctrl_set_parsed,
4584 .data = (void *)&cmd_link_flow_control_set_macfwd,
4585 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4586 "mac_ctrl_frame_fwd on|off port_id",
4588 (void *)&cmd_lfc_set_set,
4589 (void *)&cmd_lfc_set_flow_ctrl,
4590 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4591 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4592 (void *)&cmd_lfc_set_portid,
4597 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4598 .f = cmd_link_flow_ctrl_set_parsed,
4599 .data = (void *)&cmd_link_flow_control_set_autoneg,
4600 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4601 "autoneg on|off port_id",
4603 (void *)&cmd_lfc_set_set,
4604 (void *)&cmd_lfc_set_flow_ctrl,
4605 (void *)&cmd_lfc_set_autoneg_str,
4606 (void *)&cmd_lfc_set_autoneg,
4607 (void *)&cmd_lfc_set_portid,
4613 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4614 __attribute__((unused)) struct cmdline *cl,
4617 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4618 cmdline_parse_inst_t *cmd = data;
4619 struct rte_eth_fc_conf fc_conf;
4620 int rx_fc_en, tx_fc_en = 0;
4624 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4625 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4626 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4627 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4629 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4630 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4633 /* Partial command line, retrieve current configuration */
4635 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4637 printf("cannot get current flow ctrl parameters, return"
4638 "code = %d\n", ret);
4642 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4643 (fc_conf.mode == RTE_FC_FULL))
4645 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4646 (fc_conf.mode == RTE_FC_FULL))
4650 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4651 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4653 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4654 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4656 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4658 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4659 fc_conf.high_water = res->high_water;
4661 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4662 fc_conf.low_water = res->low_water;
4664 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4665 fc_conf.pause_time = res->pause_time;
4667 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4668 fc_conf.send_xon = res->send_xon;
4670 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4671 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4672 fc_conf.mac_ctrl_frame_fwd = 1;
4674 fc_conf.mac_ctrl_frame_fwd = 0;
4677 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4678 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4680 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4682 printf("bad flow contrl parameter, return code = %d \n", ret);
4685 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4686 struct cmd_priority_flow_ctrl_set_result {
4687 cmdline_fixed_string_t set;
4688 cmdline_fixed_string_t pfc_ctrl;
4689 cmdline_fixed_string_t rx;
4690 cmdline_fixed_string_t rx_pfc_mode;
4691 cmdline_fixed_string_t tx;
4692 cmdline_fixed_string_t tx_pfc_mode;
4693 uint32_t high_water;
4695 uint16_t pause_time;
4701 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4702 __attribute__((unused)) struct cmdline *cl,
4703 __attribute__((unused)) void *data)
4705 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4706 struct rte_eth_pfc_conf pfc_conf;
4707 int rx_fc_enable, tx_fc_enable;
4711 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4712 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4713 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4714 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4716 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4717 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4720 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4721 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4722 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4723 pfc_conf.fc.high_water = res->high_water;
4724 pfc_conf.fc.low_water = res->low_water;
4725 pfc_conf.fc.pause_time = res->pause_time;
4726 pfc_conf.priority = res->priority;
4728 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4730 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4733 cmdline_parse_token_string_t cmd_pfc_set_set =
4734 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4736 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4737 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4738 pfc_ctrl, "pfc_ctrl");
4739 cmdline_parse_token_string_t cmd_pfc_set_rx =
4740 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4742 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4743 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4744 rx_pfc_mode, "on#off");
4745 cmdline_parse_token_string_t cmd_pfc_set_tx =
4746 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4748 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4749 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4750 tx_pfc_mode, "on#off");
4751 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4752 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4753 high_water, UINT32);
4754 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4755 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4757 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4758 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4759 pause_time, UINT16);
4760 cmdline_parse_token_num_t cmd_pfc_set_priority =
4761 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4763 cmdline_parse_token_num_t cmd_pfc_set_portid =
4764 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4767 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4768 .f = cmd_priority_flow_ctrl_set_parsed,
4770 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4771 tx on|off high_water low_water pause_time priority port_id",
4773 (void *)&cmd_pfc_set_set,
4774 (void *)&cmd_pfc_set_flow_ctrl,
4775 (void *)&cmd_pfc_set_rx,
4776 (void *)&cmd_pfc_set_rx_mode,
4777 (void *)&cmd_pfc_set_tx,
4778 (void *)&cmd_pfc_set_tx_mode,
4779 (void *)&cmd_pfc_set_high_water,
4780 (void *)&cmd_pfc_set_low_water,
4781 (void *)&cmd_pfc_set_pause_time,
4782 (void *)&cmd_pfc_set_priority,
4783 (void *)&cmd_pfc_set_portid,
4788 /* *** RESET CONFIGURATION *** */
4789 struct cmd_reset_result {
4790 cmdline_fixed_string_t reset;
4791 cmdline_fixed_string_t def;
4794 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4796 __attribute__((unused)) void *data)
4798 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4799 set_def_fwd_config();
4802 cmdline_parse_token_string_t cmd_reset_set =
4803 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4804 cmdline_parse_token_string_t cmd_reset_def =
4805 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4808 cmdline_parse_inst_t cmd_reset = {
4809 .f = cmd_reset_parsed,
4811 .help_str = "set default: reset default forwarding configuration",
4813 (void *)&cmd_reset_set,
4814 (void *)&cmd_reset_def,
4819 /* *** START FORWARDING *** */
4820 struct cmd_start_result {
4821 cmdline_fixed_string_t start;
4824 cmdline_parse_token_string_t cmd_start_start =
4825 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4827 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4828 __attribute__((unused)) struct cmdline *cl,
4829 __attribute__((unused)) void *data)
4831 start_packet_forwarding(0);
4834 cmdline_parse_inst_t cmd_start = {
4835 .f = cmd_start_parsed,
4837 .help_str = "start packet forwarding",
4839 (void *)&cmd_start_start,
4844 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4845 struct cmd_start_tx_first_result {
4846 cmdline_fixed_string_t start;
4847 cmdline_fixed_string_t tx_first;
4851 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4852 __attribute__((unused)) struct cmdline *cl,
4853 __attribute__((unused)) void *data)
4855 start_packet_forwarding(1);
4858 cmdline_parse_token_string_t cmd_start_tx_first_start =
4859 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4861 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4862 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4863 tx_first, "tx_first");
4865 cmdline_parse_inst_t cmd_start_tx_first = {
4866 .f = cmd_start_tx_first_parsed,
4868 .help_str = "start packet forwarding, after sending 1 burst of packets",
4870 (void *)&cmd_start_tx_first_start,
4871 (void *)&cmd_start_tx_first_tx_first,
4876 /* *** SET LINK UP *** */
4877 struct cmd_set_link_up_result {
4878 cmdline_fixed_string_t set;
4879 cmdline_fixed_string_t link_up;
4880 cmdline_fixed_string_t port;
4884 cmdline_parse_token_string_t cmd_set_link_up_set =
4885 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4886 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4887 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4889 cmdline_parse_token_string_t cmd_set_link_up_port =
4890 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4891 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4892 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4894 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4895 __attribute__((unused)) struct cmdline *cl,
4896 __attribute__((unused)) void *data)
4898 struct cmd_set_link_up_result *res = parsed_result;
4899 dev_set_link_up(res->port_id);
4902 cmdline_parse_inst_t cmd_set_link_up = {
4903 .f = cmd_set_link_up_parsed,
4905 .help_str = "set link-up port (port id)",
4907 (void *)&cmd_set_link_up_set,
4908 (void *)&cmd_set_link_up_link_up,
4909 (void *)&cmd_set_link_up_port,
4910 (void *)&cmd_set_link_up_port_id,
4915 /* *** SET LINK DOWN *** */
4916 struct cmd_set_link_down_result {
4917 cmdline_fixed_string_t set;
4918 cmdline_fixed_string_t link_down;
4919 cmdline_fixed_string_t port;
4923 cmdline_parse_token_string_t cmd_set_link_down_set =
4924 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4925 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4928 cmdline_parse_token_string_t cmd_set_link_down_port =
4929 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4930 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4931 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4933 static void cmd_set_link_down_parsed(
4934 __attribute__((unused)) void *parsed_result,
4935 __attribute__((unused)) struct cmdline *cl,
4936 __attribute__((unused)) void *data)
4938 struct cmd_set_link_down_result *res = parsed_result;
4939 dev_set_link_down(res->port_id);
4942 cmdline_parse_inst_t cmd_set_link_down = {
4943 .f = cmd_set_link_down_parsed,
4945 .help_str = "set link-down port (port id)",
4947 (void *)&cmd_set_link_down_set,
4948 (void *)&cmd_set_link_down_link_down,
4949 (void *)&cmd_set_link_down_port,
4950 (void *)&cmd_set_link_down_port_id,
4955 /* *** SHOW CFG *** */
4956 struct cmd_showcfg_result {
4957 cmdline_fixed_string_t show;
4958 cmdline_fixed_string_t cfg;
4959 cmdline_fixed_string_t what;
4962 static void cmd_showcfg_parsed(void *parsed_result,
4963 __attribute__((unused)) struct cmdline *cl,
4964 __attribute__((unused)) void *data)
4966 struct cmd_showcfg_result *res = parsed_result;
4967 if (!strcmp(res->what, "rxtx"))
4968 rxtx_config_display();
4969 else if (!strcmp(res->what, "cores"))
4970 fwd_lcores_config_display();
4971 else if (!strcmp(res->what, "fwd"))
4972 fwd_config_display();
4975 cmdline_parse_token_string_t cmd_showcfg_show =
4976 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4977 cmdline_parse_token_string_t cmd_showcfg_port =
4978 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4979 cmdline_parse_token_string_t cmd_showcfg_what =
4980 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4983 cmdline_parse_inst_t cmd_showcfg = {
4984 .f = cmd_showcfg_parsed,
4986 .help_str = "show config rxtx|cores|fwd",
4988 (void *)&cmd_showcfg_show,
4989 (void *)&cmd_showcfg_port,
4990 (void *)&cmd_showcfg_what,
4995 /* *** SHOW ALL PORT INFO *** */
4996 struct cmd_showportall_result {
4997 cmdline_fixed_string_t show;
4998 cmdline_fixed_string_t port;
4999 cmdline_fixed_string_t what;
5000 cmdline_fixed_string_t all;
5003 static void cmd_showportall_parsed(void *parsed_result,
5004 __attribute__((unused)) struct cmdline *cl,
5005 __attribute__((unused)) void *data)
5009 struct cmd_showportall_result *res = parsed_result;
5010 if (!strcmp(res->show, "clear")) {
5011 if (!strcmp(res->what, "stats"))
5012 for (i = 0; i < nb_ports; i++)
5014 else if (!strcmp(res->what, "xstats"))
5015 for (i = 0; i < nb_ports; i++)
5016 nic_xstats_clear(i);
5017 } else if (!strcmp(res->what, "info"))
5018 for (i = 0; i < nb_ports; i++)
5019 port_infos_display(i);
5020 else if (!strcmp(res->what, "stats"))
5021 for (i = 0; i < nb_ports; i++)
5022 nic_stats_display(i);
5023 else if (!strcmp(res->what, "xstats"))
5024 for (i = 0; i < nb_ports; i++)
5025 nic_xstats_display(i);
5026 else if (!strcmp(res->what, "fdir"))
5027 for (i = 0; i < nb_ports; i++)
5029 else if (!strcmp(res->what, "stat_qmap"))
5030 for (i = 0; i < nb_ports; i++)
5031 nic_stats_mapping_display(i);
5034 cmdline_parse_token_string_t cmd_showportall_show =
5035 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5037 cmdline_parse_token_string_t cmd_showportall_port =
5038 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5039 cmdline_parse_token_string_t cmd_showportall_what =
5040 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5041 "info#stats#xstats#fdir#stat_qmap");
5042 cmdline_parse_token_string_t cmd_showportall_all =
5043 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5044 cmdline_parse_inst_t cmd_showportall = {
5045 .f = cmd_showportall_parsed,
5047 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5049 (void *)&cmd_showportall_show,
5050 (void *)&cmd_showportall_port,
5051 (void *)&cmd_showportall_what,
5052 (void *)&cmd_showportall_all,
5057 /* *** SHOW PORT INFO *** */
5058 struct cmd_showport_result {
5059 cmdline_fixed_string_t show;
5060 cmdline_fixed_string_t port;
5061 cmdline_fixed_string_t what;
5065 static void cmd_showport_parsed(void *parsed_result,
5066 __attribute__((unused)) struct cmdline *cl,
5067 __attribute__((unused)) void *data)
5069 struct cmd_showport_result *res = parsed_result;
5070 if (!strcmp(res->show, "clear")) {
5071 if (!strcmp(res->what, "stats"))
5072 nic_stats_clear(res->portnum);
5073 else if (!strcmp(res->what, "xstats"))
5074 nic_xstats_clear(res->portnum);
5075 } else if (!strcmp(res->what, "info"))
5076 port_infos_display(res->portnum);
5077 else if (!strcmp(res->what, "stats"))
5078 nic_stats_display(res->portnum);
5079 else if (!strcmp(res->what, "xstats"))
5080 nic_xstats_display(res->portnum);
5081 else if (!strcmp(res->what, "fdir"))
5082 fdir_get_infos(res->portnum);
5083 else if (!strcmp(res->what, "stat_qmap"))
5084 nic_stats_mapping_display(res->portnum);
5087 cmdline_parse_token_string_t cmd_showport_show =
5088 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5090 cmdline_parse_token_string_t cmd_showport_port =
5091 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5092 cmdline_parse_token_string_t cmd_showport_what =
5093 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5094 "info#stats#xstats#fdir#stat_qmap");
5095 cmdline_parse_token_num_t cmd_showport_portnum =
5096 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5098 cmdline_parse_inst_t cmd_showport = {
5099 .f = cmd_showport_parsed,
5101 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5103 (void *)&cmd_showport_show,
5104 (void *)&cmd_showport_port,
5105 (void *)&cmd_showport_what,
5106 (void *)&cmd_showport_portnum,
5111 /* *** READ PORT REGISTER *** */
5112 struct cmd_read_reg_result {
5113 cmdline_fixed_string_t read;
5114 cmdline_fixed_string_t reg;
5120 cmd_read_reg_parsed(void *parsed_result,
5121 __attribute__((unused)) struct cmdline *cl,
5122 __attribute__((unused)) void *data)
5124 struct cmd_read_reg_result *res = parsed_result;
5125 port_reg_display(res->port_id, res->reg_off);
5128 cmdline_parse_token_string_t cmd_read_reg_read =
5129 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5130 cmdline_parse_token_string_t cmd_read_reg_reg =
5131 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5132 cmdline_parse_token_num_t cmd_read_reg_port_id =
5133 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5134 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5135 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5137 cmdline_parse_inst_t cmd_read_reg = {
5138 .f = cmd_read_reg_parsed,
5140 .help_str = "read reg port_id reg_off",
5142 (void *)&cmd_read_reg_read,
5143 (void *)&cmd_read_reg_reg,
5144 (void *)&cmd_read_reg_port_id,
5145 (void *)&cmd_read_reg_reg_off,
5150 /* *** READ PORT REGISTER BIT FIELD *** */
5151 struct cmd_read_reg_bit_field_result {
5152 cmdline_fixed_string_t read;
5153 cmdline_fixed_string_t regfield;
5161 cmd_read_reg_bit_field_parsed(void *parsed_result,
5162 __attribute__((unused)) struct cmdline *cl,
5163 __attribute__((unused)) void *data)
5165 struct cmd_read_reg_bit_field_result *res = parsed_result;
5166 port_reg_bit_field_display(res->port_id, res->reg_off,
5167 res->bit1_pos, res->bit2_pos);
5170 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5171 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5173 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5174 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5175 regfield, "regfield");
5176 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5177 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5179 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5180 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5182 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5183 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5185 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5186 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5189 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5190 .f = cmd_read_reg_bit_field_parsed,
5192 .help_str = "read regfield port_id reg_off bit_x bit_y "
5193 "(read register bit field between bit_x and bit_y included)",
5195 (void *)&cmd_read_reg_bit_field_read,
5196 (void *)&cmd_read_reg_bit_field_regfield,
5197 (void *)&cmd_read_reg_bit_field_port_id,
5198 (void *)&cmd_read_reg_bit_field_reg_off,
5199 (void *)&cmd_read_reg_bit_field_bit1_pos,
5200 (void *)&cmd_read_reg_bit_field_bit2_pos,
5205 /* *** READ PORT REGISTER BIT *** */
5206 struct cmd_read_reg_bit_result {
5207 cmdline_fixed_string_t read;
5208 cmdline_fixed_string_t regbit;
5215 cmd_read_reg_bit_parsed(void *parsed_result,
5216 __attribute__((unused)) struct cmdline *cl,
5217 __attribute__((unused)) void *data)
5219 struct cmd_read_reg_bit_result *res = parsed_result;
5220 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5223 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5224 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5225 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5226 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5228 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5229 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5230 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5231 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5232 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5233 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5235 cmdline_parse_inst_t cmd_read_reg_bit = {
5236 .f = cmd_read_reg_bit_parsed,
5238 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5240 (void *)&cmd_read_reg_bit_read,
5241 (void *)&cmd_read_reg_bit_regbit,
5242 (void *)&cmd_read_reg_bit_port_id,
5243 (void *)&cmd_read_reg_bit_reg_off,
5244 (void *)&cmd_read_reg_bit_bit_pos,
5249 /* *** WRITE PORT REGISTER *** */
5250 struct cmd_write_reg_result {
5251 cmdline_fixed_string_t write;
5252 cmdline_fixed_string_t reg;
5259 cmd_write_reg_parsed(void *parsed_result,
5260 __attribute__((unused)) struct cmdline *cl,
5261 __attribute__((unused)) void *data)
5263 struct cmd_write_reg_result *res = parsed_result;
5264 port_reg_set(res->port_id, res->reg_off, res->value);
5267 cmdline_parse_token_string_t cmd_write_reg_write =
5268 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5269 cmdline_parse_token_string_t cmd_write_reg_reg =
5270 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5271 cmdline_parse_token_num_t cmd_write_reg_port_id =
5272 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5273 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5274 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5275 cmdline_parse_token_num_t cmd_write_reg_value =
5276 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5278 cmdline_parse_inst_t cmd_write_reg = {
5279 .f = cmd_write_reg_parsed,
5281 .help_str = "write reg port_id reg_off reg_value",
5283 (void *)&cmd_write_reg_write,
5284 (void *)&cmd_write_reg_reg,
5285 (void *)&cmd_write_reg_port_id,
5286 (void *)&cmd_write_reg_reg_off,
5287 (void *)&cmd_write_reg_value,
5292 /* *** WRITE PORT REGISTER BIT FIELD *** */
5293 struct cmd_write_reg_bit_field_result {
5294 cmdline_fixed_string_t write;
5295 cmdline_fixed_string_t regfield;
5304 cmd_write_reg_bit_field_parsed(void *parsed_result,
5305 __attribute__((unused)) struct cmdline *cl,
5306 __attribute__((unused)) void *data)
5308 struct cmd_write_reg_bit_field_result *res = parsed_result;
5309 port_reg_bit_field_set(res->port_id, res->reg_off,
5310 res->bit1_pos, res->bit2_pos, res->value);
5313 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5314 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5316 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5317 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5318 regfield, "regfield");
5319 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5320 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5322 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5323 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5325 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5326 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5328 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5329 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5331 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5332 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5335 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5336 .f = cmd_write_reg_bit_field_parsed,
5338 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5339 "(set register bit field between bit_x and bit_y included)",
5341 (void *)&cmd_write_reg_bit_field_write,
5342 (void *)&cmd_write_reg_bit_field_regfield,
5343 (void *)&cmd_write_reg_bit_field_port_id,
5344 (void *)&cmd_write_reg_bit_field_reg_off,
5345 (void *)&cmd_write_reg_bit_field_bit1_pos,
5346 (void *)&cmd_write_reg_bit_field_bit2_pos,
5347 (void *)&cmd_write_reg_bit_field_value,
5352 /* *** WRITE PORT REGISTER BIT *** */
5353 struct cmd_write_reg_bit_result {
5354 cmdline_fixed_string_t write;
5355 cmdline_fixed_string_t regbit;
5363 cmd_write_reg_bit_parsed(void *parsed_result,
5364 __attribute__((unused)) struct cmdline *cl,
5365 __attribute__((unused)) void *data)
5367 struct cmd_write_reg_bit_result *res = parsed_result;
5368 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5371 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5372 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5374 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5375 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5377 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5378 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5379 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5380 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5381 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5382 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5383 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5384 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5386 cmdline_parse_inst_t cmd_write_reg_bit = {
5387 .f = cmd_write_reg_bit_parsed,
5389 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5391 (void *)&cmd_write_reg_bit_write,
5392 (void *)&cmd_write_reg_bit_regbit,
5393 (void *)&cmd_write_reg_bit_port_id,
5394 (void *)&cmd_write_reg_bit_reg_off,
5395 (void *)&cmd_write_reg_bit_bit_pos,
5396 (void *)&cmd_write_reg_bit_value,
5401 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5402 struct cmd_read_rxd_txd_result {
5403 cmdline_fixed_string_t read;
5404 cmdline_fixed_string_t rxd_txd;
5411 cmd_read_rxd_txd_parsed(void *parsed_result,
5412 __attribute__((unused)) struct cmdline *cl,
5413 __attribute__((unused)) void *data)
5415 struct cmd_read_rxd_txd_result *res = parsed_result;
5417 if (!strcmp(res->rxd_txd, "rxd"))
5418 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5419 else if (!strcmp(res->rxd_txd, "txd"))
5420 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5423 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5424 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5425 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5426 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5428 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5429 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5430 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5431 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5432 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5433 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5435 cmdline_parse_inst_t cmd_read_rxd_txd = {
5436 .f = cmd_read_rxd_txd_parsed,
5438 .help_str = "read rxd|txd port_id queue_id rxd_id",
5440 (void *)&cmd_read_rxd_txd_read,
5441 (void *)&cmd_read_rxd_txd_rxd_txd,
5442 (void *)&cmd_read_rxd_txd_port_id,
5443 (void *)&cmd_read_rxd_txd_queue_id,
5444 (void *)&cmd_read_rxd_txd_desc_id,
5450 struct cmd_quit_result {
5451 cmdline_fixed_string_t quit;
5454 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5456 __attribute__((unused)) void *data)
5462 cmdline_parse_token_string_t cmd_quit_quit =
5463 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5465 cmdline_parse_inst_t cmd_quit = {
5466 .f = cmd_quit_parsed,
5468 .help_str = "exit application",
5470 (void *)&cmd_quit_quit,
5475 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5476 struct cmd_mac_addr_result {
5477 cmdline_fixed_string_t mac_addr_cmd;
5478 cmdline_fixed_string_t what;
5480 struct ether_addr address;
5483 static void cmd_mac_addr_parsed(void *parsed_result,
5484 __attribute__((unused)) struct cmdline *cl,
5485 __attribute__((unused)) void *data)
5487 struct cmd_mac_addr_result *res = parsed_result;
5490 if (strcmp(res->what, "add") == 0)
5491 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5493 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5495 /* check the return value and print it if is < 0 */
5497 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5501 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5502 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5504 cmdline_parse_token_string_t cmd_mac_addr_what =
5505 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5507 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5508 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5509 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5510 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5512 cmdline_parse_inst_t cmd_mac_addr = {
5513 .f = cmd_mac_addr_parsed,
5515 .help_str = "mac_addr add|remove X <address>: "
5516 "add/remove MAC address on port X",
5518 (void *)&cmd_mac_addr_cmd,
5519 (void *)&cmd_mac_addr_what,
5520 (void *)&cmd_mac_addr_portnum,
5521 (void *)&cmd_mac_addr_addr,
5527 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5528 struct cmd_set_qmap_result {
5529 cmdline_fixed_string_t set;
5530 cmdline_fixed_string_t qmap;
5531 cmdline_fixed_string_t what;
5538 cmd_set_qmap_parsed(void *parsed_result,
5539 __attribute__((unused)) struct cmdline *cl,
5540 __attribute__((unused)) void *data)
5542 struct cmd_set_qmap_result *res = parsed_result;
5543 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5545 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5548 cmdline_parse_token_string_t cmd_setqmap_set =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5551 cmdline_parse_token_string_t cmd_setqmap_qmap =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5554 cmdline_parse_token_string_t cmd_setqmap_what =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5557 cmdline_parse_token_num_t cmd_setqmap_portid =
5558 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5560 cmdline_parse_token_num_t cmd_setqmap_queueid =
5561 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5563 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5564 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5567 cmdline_parse_inst_t cmd_set_qmap = {
5568 .f = cmd_set_qmap_parsed,
5570 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5572 (void *)&cmd_setqmap_set,
5573 (void *)&cmd_setqmap_qmap,
5574 (void *)&cmd_setqmap_what,
5575 (void *)&cmd_setqmap_portid,
5576 (void *)&cmd_setqmap_queueid,
5577 (void *)&cmd_setqmap_mapvalue,
5582 /* *** CONFIGURE UNICAST HASH TABLE *** */
5583 struct cmd_set_uc_hash_table {
5584 cmdline_fixed_string_t set;
5585 cmdline_fixed_string_t port;
5587 cmdline_fixed_string_t what;
5588 struct ether_addr address;
5589 cmdline_fixed_string_t mode;
5593 cmd_set_uc_hash_parsed(void *parsed_result,
5594 __attribute__((unused)) struct cmdline *cl,
5595 __attribute__((unused)) void *data)
5598 struct cmd_set_uc_hash_table *res = parsed_result;
5600 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5602 if (strcmp(res->what, "uta") == 0)
5603 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5604 &res->address,(uint8_t)is_on);
5606 printf("bad unicast hash table parameter, return code = %d \n", ret);
5610 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5613 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5616 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5617 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5619 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5622 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5623 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5625 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5629 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5630 .f = cmd_set_uc_hash_parsed,
5632 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5634 (void *)&cmd_set_uc_hash_set,
5635 (void *)&cmd_set_uc_hash_port,
5636 (void *)&cmd_set_uc_hash_portid,
5637 (void *)&cmd_set_uc_hash_what,
5638 (void *)&cmd_set_uc_hash_mac,
5639 (void *)&cmd_set_uc_hash_mode,
5644 struct cmd_set_uc_all_hash_table {
5645 cmdline_fixed_string_t set;
5646 cmdline_fixed_string_t port;
5648 cmdline_fixed_string_t what;
5649 cmdline_fixed_string_t value;
5650 cmdline_fixed_string_t mode;
5654 cmd_set_uc_all_hash_parsed(void *parsed_result,
5655 __attribute__((unused)) struct cmdline *cl,
5656 __attribute__((unused)) void *data)
5659 struct cmd_set_uc_all_hash_table *res = parsed_result;
5661 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5663 if ((strcmp(res->what, "uta") == 0) &&
5664 (strcmp(res->value, "all") == 0))
5665 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5667 printf("bad unicast hash table parameter,"
5668 "return code = %d \n", ret);
5671 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5672 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5674 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5675 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5677 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5678 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5680 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5683 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5686 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5690 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5691 .f = cmd_set_uc_all_hash_parsed,
5693 .help_str = "set port X uta all on|off (X = port number)",
5695 (void *)&cmd_set_uc_all_hash_set,
5696 (void *)&cmd_set_uc_all_hash_port,
5697 (void *)&cmd_set_uc_all_hash_portid,
5698 (void *)&cmd_set_uc_all_hash_what,
5699 (void *)&cmd_set_uc_all_hash_value,
5700 (void *)&cmd_set_uc_all_hash_mode,
5705 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5706 struct cmd_set_vf_macvlan_filter {
5707 cmdline_fixed_string_t set;
5708 cmdline_fixed_string_t port;
5710 cmdline_fixed_string_t vf;
5712 struct ether_addr address;
5713 cmdline_fixed_string_t filter_type;
5714 cmdline_fixed_string_t mode;
5718 cmd_set_vf_macvlan_parsed(void *parsed_result,
5719 __attribute__((unused)) struct cmdline *cl,
5720 __attribute__((unused)) void *data)
5723 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5724 struct rte_eth_mac_filter filter;
5726 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5728 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5730 /* set VF MAC filter */
5734 filter.dst_id = res->vf_id;
5736 if (!strcmp(res->filter_type, "exact-mac"))
5737 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5738 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5739 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5740 else if (!strcmp(res->filter_type, "hashmac"))
5741 filter.filter_type = RTE_MAC_HASH_MATCH;
5742 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5743 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5745 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5748 ret = rte_eth_dev_filter_ctrl(res->port_id,
5749 RTE_ETH_FILTER_MACVLAN,
5753 ret = rte_eth_dev_filter_ctrl(res->port_id,
5754 RTE_ETH_FILTER_MACVLAN,
5755 RTE_ETH_FILTER_DELETE,
5759 printf("bad set MAC hash parameter, return code = %d\n", ret);
5763 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5766 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5769 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5772 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5773 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5775 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5776 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5778 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5779 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5781 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5783 filter_type, "exact-mac#exact-mac-vlan"
5784 "#hashmac#hashmac-vlan");
5785 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5789 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5790 .f = cmd_set_vf_macvlan_parsed,
5792 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5793 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5795 "exact match rule:exact match of MAC or MAC and VLAN; "
5796 "hash match rule: hash match of MAC and exact match "
5799 (void *)&cmd_set_vf_macvlan_set,
5800 (void *)&cmd_set_vf_macvlan_port,
5801 (void *)&cmd_set_vf_macvlan_portid,
5802 (void *)&cmd_set_vf_macvlan_vf,
5803 (void *)&cmd_set_vf_macvlan_vf_id,
5804 (void *)&cmd_set_vf_macvlan_mac,
5805 (void *)&cmd_set_vf_macvlan_filter_type,
5806 (void *)&cmd_set_vf_macvlan_mode,
5811 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5812 struct cmd_set_vf_traffic {
5813 cmdline_fixed_string_t set;
5814 cmdline_fixed_string_t port;
5816 cmdline_fixed_string_t vf;
5818 cmdline_fixed_string_t what;
5819 cmdline_fixed_string_t mode;
5823 cmd_set_vf_traffic_parsed(void *parsed_result,
5824 __attribute__((unused)) struct cmdline *cl,
5825 __attribute__((unused)) void *data)
5827 struct cmd_set_vf_traffic *res = parsed_result;
5828 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5829 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5831 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5834 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5835 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5837 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5840 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5841 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5843 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5846 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5847 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5849 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5852 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5856 cmdline_parse_inst_t cmd_set_vf_traffic = {
5857 .f = cmd_set_vf_traffic_parsed,
5859 .help_str = "set port X vf Y rx|tx on|off"
5860 "(X = port number,Y = vf id)",
5862 (void *)&cmd_setvf_traffic_set,
5863 (void *)&cmd_setvf_traffic_port,
5864 (void *)&cmd_setvf_traffic_portid,
5865 (void *)&cmd_setvf_traffic_vf,
5866 (void *)&cmd_setvf_traffic_vfid,
5867 (void *)&cmd_setvf_traffic_what,
5868 (void *)&cmd_setvf_traffic_mode,
5873 /* *** CONFIGURE VF RECEIVE MODE *** */
5874 struct cmd_set_vf_rxmode {
5875 cmdline_fixed_string_t set;
5876 cmdline_fixed_string_t port;
5878 cmdline_fixed_string_t vf;
5880 cmdline_fixed_string_t what;
5881 cmdline_fixed_string_t mode;
5882 cmdline_fixed_string_t on;
5886 cmd_set_vf_rxmode_parsed(void *parsed_result,
5887 __attribute__((unused)) struct cmdline *cl,
5888 __attribute__((unused)) void *data)
5891 uint16_t rx_mode = 0;
5892 struct cmd_set_vf_rxmode *res = parsed_result;
5894 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5895 if (!strcmp(res->what,"rxmode")) {
5896 if (!strcmp(res->mode, "AUPE"))
5897 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5898 else if (!strcmp(res->mode, "ROPE"))
5899 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5900 else if (!strcmp(res->mode, "BAM"))
5901 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5902 else if (!strncmp(res->mode, "MPE",3))
5903 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5906 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5908 printf("bad VF receive mode parameter, return code = %d \n",
5912 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5913 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5915 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5916 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5918 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5919 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5921 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5924 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5925 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5927 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5930 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5932 mode, "AUPE#ROPE#BAM#MPE");
5933 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5937 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5938 .f = cmd_set_vf_rxmode_parsed,
5940 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5942 (void *)&cmd_set_vf_rxmode_set,
5943 (void *)&cmd_set_vf_rxmode_port,
5944 (void *)&cmd_set_vf_rxmode_portid,
5945 (void *)&cmd_set_vf_rxmode_vf,
5946 (void *)&cmd_set_vf_rxmode_vfid,
5947 (void *)&cmd_set_vf_rxmode_what,
5948 (void *)&cmd_set_vf_rxmode_mode,
5949 (void *)&cmd_set_vf_rxmode_on,
5954 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5955 struct cmd_vf_mac_addr_result {
5956 cmdline_fixed_string_t mac_addr_cmd;
5957 cmdline_fixed_string_t what;
5958 cmdline_fixed_string_t port;
5960 cmdline_fixed_string_t vf;
5962 struct ether_addr address;
5965 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5966 __attribute__((unused)) struct cmdline *cl,
5967 __attribute__((unused)) void *data)
5969 struct cmd_vf_mac_addr_result *res = parsed_result;
5972 if (strcmp(res->what, "add") == 0)
5973 ret = rte_eth_dev_mac_addr_add(res->port_num,
5974 &res->address, res->vf_num);
5976 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5980 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5981 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5982 mac_addr_cmd,"mac_addr");
5983 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5984 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5986 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5987 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5989 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5990 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5992 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5993 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5995 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5996 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5998 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5999 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6002 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6003 .f = cmd_vf_mac_addr_parsed,
6005 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6006 "Y = VF number)add MAC address filtering for a VF on port X",
6008 (void *)&cmd_vf_mac_addr_cmd,
6009 (void *)&cmd_vf_mac_addr_what,
6010 (void *)&cmd_vf_mac_addr_port,
6011 (void *)&cmd_vf_mac_addr_portnum,
6012 (void *)&cmd_vf_mac_addr_vf,
6013 (void *)&cmd_vf_mac_addr_vfnum,
6014 (void *)&cmd_vf_mac_addr_addr,
6019 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6020 struct cmd_vf_rx_vlan_filter {
6021 cmdline_fixed_string_t rx_vlan;
6022 cmdline_fixed_string_t what;
6024 cmdline_fixed_string_t port;
6026 cmdline_fixed_string_t vf;
6031 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6032 __attribute__((unused)) struct cmdline *cl,
6033 __attribute__((unused)) void *data)
6035 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6037 if (!strcmp(res->what, "add"))
6038 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6040 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6043 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6044 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6045 rx_vlan, "rx_vlan");
6046 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6047 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6049 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6050 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6052 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6053 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6055 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6056 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6058 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6059 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6061 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6062 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6065 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6066 .f = cmd_vf_rx_vlan_filter_parsed,
6068 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6069 "Y = port number,Z = hexadecimal VF mask)",
6071 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6072 (void *)&cmd_vf_rx_vlan_filter_what,
6073 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6074 (void *)&cmd_vf_rx_vlan_filter_port,
6075 (void *)&cmd_vf_rx_vlan_filter_portid,
6076 (void *)&cmd_vf_rx_vlan_filter_vf,
6077 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6082 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6083 struct cmd_queue_rate_limit_result {
6084 cmdline_fixed_string_t set;
6085 cmdline_fixed_string_t port;
6087 cmdline_fixed_string_t queue;
6089 cmdline_fixed_string_t rate;
6093 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6094 __attribute__((unused)) struct cmdline *cl,
6095 __attribute__((unused)) void *data)
6097 struct cmd_queue_rate_limit_result *res = parsed_result;
6100 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6101 && (strcmp(res->queue, "queue") == 0)
6102 && (strcmp(res->rate, "rate") == 0))
6103 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6106 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6110 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6111 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6113 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6114 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6116 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6117 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6119 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6120 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6122 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6123 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6125 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6126 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6128 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6129 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6132 cmdline_parse_inst_t cmd_queue_rate_limit = {
6133 .f = cmd_queue_rate_limit_parsed,
6135 .help_str = "set port X queue Y rate Z:(X = port number,"
6136 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6138 (void *)&cmd_queue_rate_limit_set,
6139 (void *)&cmd_queue_rate_limit_port,
6140 (void *)&cmd_queue_rate_limit_portnum,
6141 (void *)&cmd_queue_rate_limit_queue,
6142 (void *)&cmd_queue_rate_limit_queuenum,
6143 (void *)&cmd_queue_rate_limit_rate,
6144 (void *)&cmd_queue_rate_limit_ratenum,
6149 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6150 struct cmd_vf_rate_limit_result {
6151 cmdline_fixed_string_t set;
6152 cmdline_fixed_string_t port;
6154 cmdline_fixed_string_t vf;
6156 cmdline_fixed_string_t rate;
6158 cmdline_fixed_string_t q_msk;
6162 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6163 __attribute__((unused)) struct cmdline *cl,
6164 __attribute__((unused)) void *data)
6166 struct cmd_vf_rate_limit_result *res = parsed_result;
6169 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6170 && (strcmp(res->vf, "vf") == 0)
6171 && (strcmp(res->rate, "rate") == 0)
6172 && (strcmp(res->q_msk, "queue_mask") == 0))
6173 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6174 res->rate_num, res->q_msk_val);
6176 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6180 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6181 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6183 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6184 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6186 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6187 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6189 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6190 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6192 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6193 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6195 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6196 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6198 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6199 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6201 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6202 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6203 q_msk, "queue_mask");
6204 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6205 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6208 cmdline_parse_inst_t cmd_vf_rate_limit = {
6209 .f = cmd_vf_rate_limit_parsed,
6211 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6212 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6213 "for queues of VF on port X",
6215 (void *)&cmd_vf_rate_limit_set,
6216 (void *)&cmd_vf_rate_limit_port,
6217 (void *)&cmd_vf_rate_limit_portnum,
6218 (void *)&cmd_vf_rate_limit_vf,
6219 (void *)&cmd_vf_rate_limit_vfnum,
6220 (void *)&cmd_vf_rate_limit_rate,
6221 (void *)&cmd_vf_rate_limit_ratenum,
6222 (void *)&cmd_vf_rate_limit_q_msk,
6223 (void *)&cmd_vf_rate_limit_q_msk_val,
6228 /* *** ADD TUNNEL FILTER OF A PORT *** */
6229 struct cmd_tunnel_filter_result {
6230 cmdline_fixed_string_t cmd;
6231 cmdline_fixed_string_t what;
6233 struct ether_addr outer_mac;
6234 struct ether_addr inner_mac;
6235 cmdline_ipaddr_t ip_value;
6236 uint16_t inner_vlan;
6237 cmdline_fixed_string_t tunnel_type;
6238 cmdline_fixed_string_t filter_type;
6244 cmd_tunnel_filter_parsed(void *parsed_result,
6245 __attribute__((unused)) struct cmdline *cl,
6246 __attribute__((unused)) void *data)
6248 struct cmd_tunnel_filter_result *res = parsed_result;
6249 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6252 tunnel_filter_conf.outer_mac = &res->outer_mac;
6253 tunnel_filter_conf.inner_mac = &res->inner_mac;
6254 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6256 if (res->ip_value.family == AF_INET) {
6257 tunnel_filter_conf.ip_addr.ipv4_addr =
6258 res->ip_value.addr.ipv4.s_addr;
6259 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6261 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6262 &(res->ip_value.addr.ipv6),
6263 sizeof(struct in6_addr));
6264 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6267 if (!strcmp(res->filter_type, "imac-ivlan"))
6268 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6269 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6270 tunnel_filter_conf.filter_type =
6271 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6272 else if (!strcmp(res->filter_type, "imac-tenid"))
6273 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6274 else if (!strcmp(res->filter_type, "imac"))
6275 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6276 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6277 tunnel_filter_conf.filter_type =
6278 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6280 printf("The filter type is not supported");
6284 if (!strcmp(res->tunnel_type, "vxlan"))
6285 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6287 printf("Only VXLAN is supported now.\n");
6291 tunnel_filter_conf.tenant_id = res->tenant_id;
6292 tunnel_filter_conf.queue_id = res->queue_num;
6293 if (!strcmp(res->what, "add"))
6294 ret = rte_eth_dev_filter_ctrl(res->port_id,
6295 RTE_ETH_FILTER_TUNNEL,
6297 &tunnel_filter_conf);
6299 ret = rte_eth_dev_filter_ctrl(res->port_id,
6300 RTE_ETH_FILTER_TUNNEL,
6301 RTE_ETH_FILTER_DELETE,
6302 &tunnel_filter_conf);
6304 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6308 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6309 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6310 cmd, "tunnel_filter");
6311 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6312 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6314 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6315 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6317 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6318 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6320 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6321 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6323 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6324 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6325 inner_vlan, UINT16);
6326 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6327 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6329 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6330 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6331 tunnel_type, "vxlan");
6333 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6334 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6335 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6336 "imac#omac-imac-tenid");
6337 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6338 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6340 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6341 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6344 cmdline_parse_inst_t cmd_tunnel_filter = {
6345 .f = cmd_tunnel_filter_parsed,
6347 .help_str = "add/rm tunnel filter of a port: "
6348 "tunnel_filter add port_id outer_mac inner_mac ip "
6349 "inner_vlan tunnel_type(vxlan) filter_type "
6350 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6351 "imac|omac-imac-tenid) "
6352 "tenant_id queue_num",
6354 (void *)&cmd_tunnel_filter_cmd,
6355 (void *)&cmd_tunnel_filter_what,
6356 (void *)&cmd_tunnel_filter_port_id,
6357 (void *)&cmd_tunnel_filter_outer_mac,
6358 (void *)&cmd_tunnel_filter_inner_mac,
6359 (void *)&cmd_tunnel_filter_ip_value,
6360 (void *)&cmd_tunnel_filter_innner_vlan,
6361 (void *)&cmd_tunnel_filter_tunnel_type,
6362 (void *)&cmd_tunnel_filter_filter_type,
6363 (void *)&cmd_tunnel_filter_tenant_id,
6364 (void *)&cmd_tunnel_filter_queue_num,
6369 /* *** CONFIGURE TUNNEL UDP PORT *** */
6370 struct cmd_tunnel_udp_config {
6371 cmdline_fixed_string_t cmd;
6372 cmdline_fixed_string_t what;
6378 cmd_tunnel_udp_config_parsed(void *parsed_result,
6379 __attribute__((unused)) struct cmdline *cl,
6380 __attribute__((unused)) void *data)
6382 struct cmd_tunnel_udp_config *res = parsed_result;
6383 struct rte_eth_udp_tunnel tunnel_udp;
6386 tunnel_udp.udp_port = res->udp_port;
6388 if (!strcmp(res->cmd, "rx_vxlan_port"))
6389 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6391 if (!strcmp(res->what, "add"))
6392 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6394 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6397 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6400 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6401 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6402 cmd, "rx_vxlan_port");
6403 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6404 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6406 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6407 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6409 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6410 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6413 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6414 .f = cmd_tunnel_udp_config_parsed,
6416 .help_str = "add/rm an tunneling UDP port filter: "
6417 "rx_vxlan_port add udp_port port_id",
6419 (void *)&cmd_tunnel_udp_config_cmd,
6420 (void *)&cmd_tunnel_udp_config_what,
6421 (void *)&cmd_tunnel_udp_config_udp_port,
6422 (void *)&cmd_tunnel_udp_config_port_id,
6427 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6428 struct cmd_set_mirror_mask_result {
6429 cmdline_fixed_string_t set;
6430 cmdline_fixed_string_t port;
6432 cmdline_fixed_string_t mirror;
6434 cmdline_fixed_string_t what;
6435 cmdline_fixed_string_t value;
6436 cmdline_fixed_string_t dstpool;
6438 cmdline_fixed_string_t on;
6441 cmdline_parse_token_string_t cmd_mirror_mask_set =
6442 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6444 cmdline_parse_token_string_t cmd_mirror_mask_port =
6445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6447 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6448 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6450 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6451 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6452 mirror, "mirror-rule");
6453 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6454 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6456 cmdline_parse_token_string_t cmd_mirror_mask_what =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6458 what, "pool-mirror#vlan-mirror");
6459 cmdline_parse_token_string_t cmd_mirror_mask_value =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6462 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6464 dstpool, "dst-pool");
6465 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6466 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6468 cmdline_parse_token_string_t cmd_mirror_mask_on =
6469 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6473 cmd_set_mirror_mask_parsed(void *parsed_result,
6474 __attribute__((unused)) struct cmdline *cl,
6475 __attribute__((unused)) void *data)
6478 struct cmd_set_mirror_mask_result *res = parsed_result;
6479 struct rte_eth_vmdq_mirror_conf mr_conf;
6481 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6483 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6485 mr_conf.dst_pool = res->dstpool_id;
6487 if (!strcmp(res->what, "pool-mirror")) {
6488 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6489 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6490 } else if(!strcmp(res->what, "vlan-mirror")) {
6491 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6492 nb_item = parse_item_list(res->value, "core",
6493 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6497 for(i=0; i < nb_item; i++) {
6498 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6499 printf("Invalid vlan_id: must be < 4096\n");
6503 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6504 mr_conf.vlan.vlan_mask |= 1ULL << i;
6508 if(!strcmp(res->on, "on"))
6509 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6512 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6515 printf("mirror rule add error: (%s)\n", strerror(-ret));
6518 cmdline_parse_inst_t cmd_set_mirror_mask = {
6519 .f = cmd_set_mirror_mask_parsed,
6521 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6522 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6524 (void *)&cmd_mirror_mask_set,
6525 (void *)&cmd_mirror_mask_port,
6526 (void *)&cmd_mirror_mask_portid,
6527 (void *)&cmd_mirror_mask_mirror,
6528 (void *)&cmd_mirror_mask_ruleid,
6529 (void *)&cmd_mirror_mask_what,
6530 (void *)&cmd_mirror_mask_value,
6531 (void *)&cmd_mirror_mask_dstpool,
6532 (void *)&cmd_mirror_mask_poolid,
6533 (void *)&cmd_mirror_mask_on,
6538 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6539 struct cmd_set_mirror_link_result {
6540 cmdline_fixed_string_t set;
6541 cmdline_fixed_string_t port;
6543 cmdline_fixed_string_t mirror;
6545 cmdline_fixed_string_t what;
6546 cmdline_fixed_string_t dstpool;
6548 cmdline_fixed_string_t on;
6551 cmdline_parse_token_string_t cmd_mirror_link_set =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6554 cmdline_parse_token_string_t cmd_mirror_link_port =
6555 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6557 cmdline_parse_token_num_t cmd_mirror_link_portid =
6558 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6560 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6561 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6562 mirror, "mirror-rule");
6563 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6564 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6566 cmdline_parse_token_string_t cmd_mirror_link_what =
6567 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6568 what, "uplink-mirror#downlink-mirror");
6569 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6571 dstpool, "dst-pool");
6572 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6573 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6575 cmdline_parse_token_string_t cmd_mirror_link_on =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6580 cmd_set_mirror_link_parsed(void *parsed_result,
6581 __attribute__((unused)) struct cmdline *cl,
6582 __attribute__((unused)) void *data)
6585 struct cmd_set_mirror_link_result *res = parsed_result;
6586 struct rte_eth_vmdq_mirror_conf mr_conf;
6588 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6589 if(!strcmp(res->what, "uplink-mirror")) {
6590 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6591 }else if(!strcmp(res->what, "downlink-mirror"))
6592 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6594 mr_conf.dst_pool = res->dstpool_id;
6596 if(!strcmp(res->on, "on"))
6597 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6600 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6603 /* check the return value and print it if is < 0 */
6605 printf("mirror rule add error: (%s)\n", strerror(-ret));
6609 cmdline_parse_inst_t cmd_set_mirror_link = {
6610 .f = cmd_set_mirror_link_parsed,
6612 .help_str = "set port X mirror-rule Y uplink-mirror|"
6613 "downlink-mirror dst-pool Z on|off",
6615 (void *)&cmd_mirror_link_set,
6616 (void *)&cmd_mirror_link_port,
6617 (void *)&cmd_mirror_link_portid,
6618 (void *)&cmd_mirror_link_mirror,
6619 (void *)&cmd_mirror_link_ruleid,
6620 (void *)&cmd_mirror_link_what,
6621 (void *)&cmd_mirror_link_dstpool,
6622 (void *)&cmd_mirror_link_poolid,
6623 (void *)&cmd_mirror_link_on,
6628 /* *** RESET VM MIRROR RULE *** */
6629 struct cmd_rm_mirror_rule_result {
6630 cmdline_fixed_string_t reset;
6631 cmdline_fixed_string_t port;
6633 cmdline_fixed_string_t mirror;
6637 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6638 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6640 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6641 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6643 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6644 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6646 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6647 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6648 mirror, "mirror-rule");
6649 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6650 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6654 cmd_reset_mirror_rule_parsed(void *parsed_result,
6655 __attribute__((unused)) struct cmdline *cl,
6656 __attribute__((unused)) void *data)
6659 struct cmd_set_mirror_link_result *res = parsed_result;
6661 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6663 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6666 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6667 .f = cmd_reset_mirror_rule_parsed,
6669 .help_str = "reset port X mirror-rule Y",
6671 (void *)&cmd_rm_mirror_rule_reset,
6672 (void *)&cmd_rm_mirror_rule_port,
6673 (void *)&cmd_rm_mirror_rule_portid,
6674 (void *)&cmd_rm_mirror_rule_mirror,
6675 (void *)&cmd_rm_mirror_rule_ruleid,
6680 /* ******************************************************************************** */
6682 struct cmd_dump_result {
6683 cmdline_fixed_string_t dump;
6687 dump_struct_sizes(void)
6689 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6690 DUMP_SIZE(struct rte_mbuf);
6691 DUMP_SIZE(struct rte_mempool);
6692 DUMP_SIZE(struct rte_ring);
6696 static void cmd_dump_parsed(void *parsed_result,
6697 __attribute__((unused)) struct cmdline *cl,
6698 __attribute__((unused)) void *data)
6700 struct cmd_dump_result *res = parsed_result;
6702 if (!strcmp(res->dump, "dump_physmem"))
6703 rte_dump_physmem_layout(stdout);
6704 else if (!strcmp(res->dump, "dump_memzone"))
6705 rte_memzone_dump(stdout);
6706 else if (!strcmp(res->dump, "dump_log_history"))
6707 rte_log_dump_history(stdout);
6708 else if (!strcmp(res->dump, "dump_struct_sizes"))
6709 dump_struct_sizes();
6710 else if (!strcmp(res->dump, "dump_ring"))
6711 rte_ring_list_dump(stdout);
6712 else if (!strcmp(res->dump, "dump_mempool"))
6713 rte_mempool_list_dump(stdout);
6714 else if (!strcmp(res->dump, "dump_devargs"))
6715 rte_eal_devargs_dump(stdout);
6718 cmdline_parse_token_string_t cmd_dump_dump =
6719 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6723 "dump_struct_sizes#"
6728 cmdline_parse_inst_t cmd_dump = {
6729 .f = cmd_dump_parsed, /* function to call */
6730 .data = NULL, /* 2nd arg of func */
6731 .help_str = "dump status",
6732 .tokens = { /* token list, NULL terminated */
6733 (void *)&cmd_dump_dump,
6738 /* ******************************************************************************** */
6740 struct cmd_dump_one_result {
6741 cmdline_fixed_string_t dump;
6742 cmdline_fixed_string_t name;
6745 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6746 __attribute__((unused)) void *data)
6748 struct cmd_dump_one_result *res = parsed_result;
6750 if (!strcmp(res->dump, "dump_ring")) {
6752 r = rte_ring_lookup(res->name);
6754 cmdline_printf(cl, "Cannot find ring\n");
6757 rte_ring_dump(stdout, r);
6758 } else if (!strcmp(res->dump, "dump_mempool")) {
6759 struct rte_mempool *mp;
6760 mp = rte_mempool_lookup(res->name);
6762 cmdline_printf(cl, "Cannot find mempool\n");
6765 rte_mempool_dump(stdout, mp);
6769 cmdline_parse_token_string_t cmd_dump_one_dump =
6770 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6771 "dump_ring#dump_mempool");
6773 cmdline_parse_token_string_t cmd_dump_one_name =
6774 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6776 cmdline_parse_inst_t cmd_dump_one = {
6777 .f = cmd_dump_one_parsed, /* function to call */
6778 .data = NULL, /* 2nd arg of func */
6779 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6780 .tokens = { /* token list, NULL terminated */
6781 (void *)&cmd_dump_one_dump,
6782 (void *)&cmd_dump_one_name,
6787 /* *** Add/Del syn filter *** */
6788 struct cmd_syn_filter_result {
6789 cmdline_fixed_string_t filter;
6791 cmdline_fixed_string_t ops;
6792 cmdline_fixed_string_t priority;
6793 cmdline_fixed_string_t high;
6794 cmdline_fixed_string_t queue;
6799 cmd_syn_filter_parsed(void *parsed_result,
6800 __attribute__((unused)) struct cmdline *cl,
6801 __attribute__((unused)) void *data)
6803 struct cmd_syn_filter_result *res = parsed_result;
6804 struct rte_eth_syn_filter syn_filter;
6807 ret = rte_eth_dev_filter_supported(res->port_id,
6808 RTE_ETH_FILTER_SYN);
6810 printf("syn filter is not supported on port %u.\n",
6815 memset(&syn_filter, 0, sizeof(syn_filter));
6817 if (!strcmp(res->ops, "add")) {
6818 if (!strcmp(res->high, "high"))
6819 syn_filter.hig_pri = 1;
6821 syn_filter.hig_pri = 0;
6823 syn_filter.queue = res->queue_id;
6824 ret = rte_eth_dev_filter_ctrl(res->port_id,
6829 ret = rte_eth_dev_filter_ctrl(res->port_id,
6831 RTE_ETH_FILTER_DELETE,
6835 printf("syn filter programming error: (%s)\n",
6839 cmdline_parse_token_string_t cmd_syn_filter_filter =
6840 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6841 filter, "syn_filter");
6842 cmdline_parse_token_num_t cmd_syn_filter_port_id =
6843 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6845 cmdline_parse_token_string_t cmd_syn_filter_ops =
6846 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6848 cmdline_parse_token_string_t cmd_syn_filter_priority =
6849 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6850 priority, "priority");
6851 cmdline_parse_token_string_t cmd_syn_filter_high =
6852 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6854 cmdline_parse_token_string_t cmd_syn_filter_queue =
6855 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
6857 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6858 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
6861 cmdline_parse_inst_t cmd_syn_filter = {
6862 .f = cmd_syn_filter_parsed,
6864 .help_str = "add/delete syn filter",
6866 (void *)&cmd_syn_filter_filter,
6867 (void *)&cmd_syn_filter_port_id,
6868 (void *)&cmd_syn_filter_ops,
6869 (void *)&cmd_syn_filter_priority,
6870 (void *)&cmd_syn_filter_high,
6871 (void *)&cmd_syn_filter_queue,
6872 (void *)&cmd_syn_filter_queue_id,
6877 /* *** ADD/REMOVE A 2tuple FILTER *** */
6878 struct cmd_2tuple_filter_result {
6879 cmdline_fixed_string_t filter;
6881 cmdline_fixed_string_t ops;
6882 cmdline_fixed_string_t dst_port;
6883 uint16_t dst_port_value;
6884 cmdline_fixed_string_t protocol;
6885 uint8_t protocol_value;
6886 cmdline_fixed_string_t mask;
6888 cmdline_fixed_string_t tcp_flags;
6889 uint8_t tcp_flags_value;
6890 cmdline_fixed_string_t priority;
6891 uint8_t priority_value;
6892 cmdline_fixed_string_t queue;
6897 cmd_2tuple_filter_parsed(void *parsed_result,
6898 __attribute__((unused)) struct cmdline *cl,
6899 __attribute__((unused)) void *data)
6901 struct rte_eth_ntuple_filter filter;
6902 struct cmd_2tuple_filter_result *res = parsed_result;
6905 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
6907 printf("ntuple filter is not supported on port %u.\n",
6912 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
6914 filter.flags = RTE_2TUPLE_FLAGS;
6915 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
6916 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
6917 filter.proto = res->protocol_value;
6918 filter.priority = res->priority_value;
6919 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
6920 printf("nonzero tcp_flags is only meaningful"
6921 " when protocol is TCP.\n");
6924 if (res->tcp_flags_value > TCP_FLAG_ALL) {
6925 printf("invalid TCP flags.\n");
6929 if (res->tcp_flags_value != 0) {
6930 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
6931 filter.tcp_flags = res->tcp_flags_value;
6934 /* need convert to big endian. */
6935 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6936 filter.queue = res->queue_id;
6938 if (!strcmp(res->ops, "add"))
6939 ret = rte_eth_dev_filter_ctrl(res->port_id,
6940 RTE_ETH_FILTER_NTUPLE,
6944 ret = rte_eth_dev_filter_ctrl(res->port_id,
6945 RTE_ETH_FILTER_NTUPLE,
6946 RTE_ETH_FILTER_DELETE,
6949 printf("2tuple filter programming error: (%s)\n",
6954 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
6955 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6956 filter, "2tuple_filter");
6957 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6958 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6960 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
6961 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6963 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6964 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6965 dst_port, "dst_port");
6966 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6967 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6968 dst_port_value, UINT16);
6969 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6970 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6971 protocol, "protocol");
6972 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6973 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6974 protocol_value, UINT8);
6975 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
6976 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6978 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
6979 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6981 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
6982 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6983 tcp_flags, "tcp_flags");
6984 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
6985 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6986 tcp_flags_value, UINT8);
6987 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6988 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6989 priority, "priority");
6990 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6991 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6992 priority_value, UINT8);
6993 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6994 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6996 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6997 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7000 cmdline_parse_inst_t cmd_2tuple_filter = {
7001 .f = cmd_2tuple_filter_parsed,
7003 .help_str = "add a 2tuple filter",
7005 (void *)&cmd_2tuple_filter_filter,
7006 (void *)&cmd_2tuple_filter_port_id,
7007 (void *)&cmd_2tuple_filter_ops,
7008 (void *)&cmd_2tuple_filter_dst_port,
7009 (void *)&cmd_2tuple_filter_dst_port_value,
7010 (void *)&cmd_2tuple_filter_protocol,
7011 (void *)&cmd_2tuple_filter_protocol_value,
7012 (void *)&cmd_2tuple_filter_mask,
7013 (void *)&cmd_2tuple_filter_mask_value,
7014 (void *)&cmd_2tuple_filter_tcp_flags,
7015 (void *)&cmd_2tuple_filter_tcp_flags_value,
7016 (void *)&cmd_2tuple_filter_priority,
7017 (void *)&cmd_2tuple_filter_priority_value,
7018 (void *)&cmd_2tuple_filter_queue,
7019 (void *)&cmd_2tuple_filter_queue_id,
7024 /* *** ADD/REMOVE A 5tuple FILTER *** */
7025 struct cmd_5tuple_filter_result {
7026 cmdline_fixed_string_t filter;
7028 cmdline_fixed_string_t ops;
7029 cmdline_fixed_string_t dst_ip;
7030 cmdline_ipaddr_t dst_ip_value;
7031 cmdline_fixed_string_t src_ip;
7032 cmdline_ipaddr_t src_ip_value;
7033 cmdline_fixed_string_t dst_port;
7034 uint16_t dst_port_value;
7035 cmdline_fixed_string_t src_port;
7036 uint16_t src_port_value;
7037 cmdline_fixed_string_t protocol;
7038 uint8_t protocol_value;
7039 cmdline_fixed_string_t mask;
7041 cmdline_fixed_string_t tcp_flags;
7042 uint8_t tcp_flags_value;
7043 cmdline_fixed_string_t priority;
7044 uint8_t priority_value;
7045 cmdline_fixed_string_t queue;
7050 cmd_5tuple_filter_parsed(void *parsed_result,
7051 __attribute__((unused)) struct cmdline *cl,
7052 __attribute__((unused)) void *data)
7054 struct rte_eth_ntuple_filter filter;
7055 struct cmd_5tuple_filter_result *res = parsed_result;
7058 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7060 printf("ntuple filter is not supported on port %u.\n",
7065 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7067 filter.flags = RTE_5TUPLE_FLAGS;
7068 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7069 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7070 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7071 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7072 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7073 filter.proto = res->protocol_value;
7074 filter.priority = res->priority_value;
7075 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7076 printf("nonzero tcp_flags is only meaningful"
7077 " when protocol is TCP.\n");
7080 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7081 printf("invalid TCP flags.\n");
7085 if (res->tcp_flags_value != 0) {
7086 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7087 filter.tcp_flags = res->tcp_flags_value;
7090 if (res->dst_ip_value.family == AF_INET)
7091 /* no need to convert, already big endian. */
7092 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7094 if (filter.dst_ip_mask == 0) {
7095 printf("can not support ipv6 involved compare.\n");
7101 if (res->src_ip_value.family == AF_INET)
7102 /* no need to convert, already big endian. */
7103 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7105 if (filter.src_ip_mask == 0) {
7106 printf("can not support ipv6 involved compare.\n");
7111 /* need convert to big endian. */
7112 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7113 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7114 filter.queue = res->queue_id;
7116 if (!strcmp(res->ops, "add"))
7117 ret = rte_eth_dev_filter_ctrl(res->port_id,
7118 RTE_ETH_FILTER_NTUPLE,
7122 ret = rte_eth_dev_filter_ctrl(res->port_id,
7123 RTE_ETH_FILTER_NTUPLE,
7124 RTE_ETH_FILTER_DELETE,
7127 printf("5tuple filter programming error: (%s)\n",
7131 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7132 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7133 filter, "5tuple_filter");
7134 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7135 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7137 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7138 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7140 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7141 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7143 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7144 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7146 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7147 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7149 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7150 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7152 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7153 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7154 dst_port, "dst_port");
7155 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7156 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7157 dst_port_value, UINT16);
7158 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7159 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7160 src_port, "src_port");
7161 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7162 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7163 src_port_value, UINT16);
7164 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7165 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7166 protocol, "protocol");
7167 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7168 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7169 protocol_value, UINT8);
7170 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7171 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7173 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7174 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7176 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7177 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7178 tcp_flags, "tcp_flags");
7179 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7180 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7181 tcp_flags_value, UINT8);
7182 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7183 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7184 priority, "priority");
7185 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7186 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7187 priority_value, UINT8);
7188 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7189 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7191 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7192 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7195 cmdline_parse_inst_t cmd_5tuple_filter = {
7196 .f = cmd_5tuple_filter_parsed,
7198 .help_str = "add/del a 5tuple filter",
7200 (void *)&cmd_5tuple_filter_filter,
7201 (void *)&cmd_5tuple_filter_port_id,
7202 (void *)&cmd_5tuple_filter_ops,
7203 (void *)&cmd_5tuple_filter_dst_ip,
7204 (void *)&cmd_5tuple_filter_dst_ip_value,
7205 (void *)&cmd_5tuple_filter_src_ip,
7206 (void *)&cmd_5tuple_filter_src_ip_value,
7207 (void *)&cmd_5tuple_filter_dst_port,
7208 (void *)&cmd_5tuple_filter_dst_port_value,
7209 (void *)&cmd_5tuple_filter_src_port,
7210 (void *)&cmd_5tuple_filter_src_port_value,
7211 (void *)&cmd_5tuple_filter_protocol,
7212 (void *)&cmd_5tuple_filter_protocol_value,
7213 (void *)&cmd_5tuple_filter_mask,
7214 (void *)&cmd_5tuple_filter_mask_value,
7215 (void *)&cmd_5tuple_filter_tcp_flags,
7216 (void *)&cmd_5tuple_filter_tcp_flags_value,
7217 (void *)&cmd_5tuple_filter_priority,
7218 (void *)&cmd_5tuple_filter_priority_value,
7219 (void *)&cmd_5tuple_filter_queue,
7220 (void *)&cmd_5tuple_filter_queue_id,
7225 /* *** ADD/REMOVE A flex FILTER *** */
7226 struct cmd_flex_filter_result {
7227 cmdline_fixed_string_t filter;
7228 cmdline_fixed_string_t ops;
7230 cmdline_fixed_string_t len;
7232 cmdline_fixed_string_t bytes;
7233 cmdline_fixed_string_t bytes_value;
7234 cmdline_fixed_string_t mask;
7235 cmdline_fixed_string_t mask_value;
7236 cmdline_fixed_string_t priority;
7237 uint8_t priority_value;
7238 cmdline_fixed_string_t queue;
7242 static int xdigit2val(unsigned char c)
7247 else if (isupper(c))
7255 cmd_flex_filter_parsed(void *parsed_result,
7256 __attribute__((unused)) struct cmdline *cl,
7257 __attribute__((unused)) void *data)
7260 struct rte_eth_flex_filter filter;
7261 struct cmd_flex_filter_result *res = parsed_result;
7262 char *bytes_ptr, *mask_ptr;
7263 uint16_t len, i, j = 0;
7268 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7269 printf("the len exceed the max length 128\n");
7272 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7273 filter.len = res->len_value;
7274 filter.priority = res->priority_value;
7275 filter.queue = res->queue_id;
7276 bytes_ptr = res->bytes_value;
7277 mask_ptr = res->mask_value;
7279 /* translate bytes string to array. */
7280 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7281 (bytes_ptr[1] == 'X')))
7283 len = strnlen(bytes_ptr, res->len_value * 2);
7284 if (len == 0 || (len % 8 != 0)) {
7285 printf("please check len and bytes input\n");
7288 for (i = 0; i < len; i++) {
7290 if (isxdigit(c) == 0) {
7291 /* invalid characters. */
7292 printf("invalid input\n");
7295 val = xdigit2val(c);
7298 filter.bytes[j] = byte;
7299 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7306 /* translate mask string to uint8_t array. */
7307 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7308 (mask_ptr[1] == 'X')))
7310 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7312 printf("invalid input\n");
7317 for (i = 0; i < len; i++) {
7319 if (isxdigit(c) == 0) {
7320 /* invalid characters. */
7321 printf("invalid input\n");
7324 val = xdigit2val(c);
7327 filter.mask[j] = byte;
7328 printf("mask[%d]:%02x ", j, filter.mask[j]);
7336 if (!strcmp(res->ops, "add"))
7337 ret = rte_eth_dev_filter_ctrl(res->port_id,
7338 RTE_ETH_FILTER_FLEXIBLE,
7342 ret = rte_eth_dev_filter_ctrl(res->port_id,
7343 RTE_ETH_FILTER_FLEXIBLE,
7344 RTE_ETH_FILTER_DELETE,
7348 printf("flex filter setting error: (%s)\n", strerror(-ret));
7351 cmdline_parse_token_string_t cmd_flex_filter_filter =
7352 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7353 filter, "flex_filter");
7354 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7355 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7357 cmdline_parse_token_string_t cmd_flex_filter_ops =
7358 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7360 cmdline_parse_token_string_t cmd_flex_filter_len =
7361 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7363 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7364 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7366 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7367 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7369 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7370 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7372 cmdline_parse_token_string_t cmd_flex_filter_mask =
7373 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7375 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7376 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7378 cmdline_parse_token_string_t cmd_flex_filter_priority =
7379 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7380 priority, "priority");
7381 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7382 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7383 priority_value, UINT8);
7384 cmdline_parse_token_string_t cmd_flex_filter_queue =
7385 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7387 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7388 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7390 cmdline_parse_inst_t cmd_flex_filter = {
7391 .f = cmd_flex_filter_parsed,
7393 .help_str = "add/del a flex filter",
7395 (void *)&cmd_flex_filter_filter,
7396 (void *)&cmd_flex_filter_port_id,
7397 (void *)&cmd_flex_filter_ops,
7398 (void *)&cmd_flex_filter_len,
7399 (void *)&cmd_flex_filter_len_value,
7400 (void *)&cmd_flex_filter_bytes,
7401 (void *)&cmd_flex_filter_bytes_value,
7402 (void *)&cmd_flex_filter_mask,
7403 (void *)&cmd_flex_filter_mask_value,
7404 (void *)&cmd_flex_filter_priority,
7405 (void *)&cmd_flex_filter_priority_value,
7406 (void *)&cmd_flex_filter_queue,
7407 (void *)&cmd_flex_filter_queue_id,
7412 /* *** Filters Control *** */
7414 /* *** deal with ethertype filter *** */
7415 struct cmd_ethertype_filter_result {
7416 cmdline_fixed_string_t filter;
7418 cmdline_fixed_string_t ops;
7419 cmdline_fixed_string_t mac;
7420 struct ether_addr mac_addr;
7421 cmdline_fixed_string_t ethertype;
7422 uint16_t ethertype_value;
7423 cmdline_fixed_string_t drop;
7424 cmdline_fixed_string_t queue;
7428 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7429 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7430 filter, "ethertype_filter");
7431 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7432 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7434 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7435 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7437 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7438 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7439 mac, "mac_addr#mac_ignr");
7440 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7441 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7443 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7444 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7445 ethertype, "ethertype");
7446 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7447 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7448 ethertype_value, UINT16);
7449 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7450 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7452 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7453 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7455 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7456 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7460 cmd_ethertype_filter_parsed(void *parsed_result,
7461 __attribute__((unused)) struct cmdline *cl,
7462 __attribute__((unused)) void *data)
7464 struct cmd_ethertype_filter_result *res = parsed_result;
7465 struct rte_eth_ethertype_filter filter;
7468 ret = rte_eth_dev_filter_supported(res->port_id,
7469 RTE_ETH_FILTER_ETHERTYPE);
7471 printf("ethertype filter is not supported on port %u.\n",
7476 memset(&filter, 0, sizeof(filter));
7477 if (!strcmp(res->mac, "mac_addr")) {
7478 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7479 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7480 sizeof(struct ether_addr));
7482 if (!strcmp(res->drop, "drop"))
7483 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7484 filter.ether_type = res->ethertype_value;
7485 filter.queue = res->queue_id;
7487 if (!strcmp(res->ops, "add"))
7488 ret = rte_eth_dev_filter_ctrl(res->port_id,
7489 RTE_ETH_FILTER_ETHERTYPE,
7493 ret = rte_eth_dev_filter_ctrl(res->port_id,
7494 RTE_ETH_FILTER_ETHERTYPE,
7495 RTE_ETH_FILTER_DELETE,
7498 printf("ethertype filter programming error: (%s)\n",
7502 cmdline_parse_inst_t cmd_ethertype_filter = {
7503 .f = cmd_ethertype_filter_parsed,
7505 .help_str = "add or delete an ethertype filter entry",
7507 (void *)&cmd_ethertype_filter_filter,
7508 (void *)&cmd_ethertype_filter_port_id,
7509 (void *)&cmd_ethertype_filter_ops,
7510 (void *)&cmd_ethertype_filter_mac,
7511 (void *)&cmd_ethertype_filter_mac_addr,
7512 (void *)&cmd_ethertype_filter_ethertype,
7513 (void *)&cmd_ethertype_filter_ethertype_value,
7514 (void *)&cmd_ethertype_filter_drop,
7515 (void *)&cmd_ethertype_filter_queue,
7516 (void *)&cmd_ethertype_filter_queue_id,
7521 /* *** deal with flow director filter *** */
7522 struct cmd_flow_director_result {
7523 cmdline_fixed_string_t flow_director_filter;
7525 cmdline_fixed_string_t ops;
7526 cmdline_fixed_string_t flow;
7527 cmdline_fixed_string_t flow_type;
7528 cmdline_fixed_string_t src;
7529 cmdline_ipaddr_t ip_src;
7531 cmdline_fixed_string_t dst;
7532 cmdline_ipaddr_t ip_dst;
7534 cmdline_fixed_string_t verify_tag;
7535 uint32_t verify_tag_value;
7536 cmdline_fixed_string_t vlan;
7537 uint16_t vlan_value;
7538 cmdline_fixed_string_t flexbytes;
7539 cmdline_fixed_string_t flexbytes_value;
7540 cmdline_fixed_string_t drop;
7541 cmdline_fixed_string_t queue;
7543 cmdline_fixed_string_t fd_id;
7544 uint32_t fd_id_value;
7548 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7551 const char *p, *p0 = q_arg;
7553 unsigned long int_fld;
7554 char *str_fld[max_num];
7559 p = strchr(p0, '(');
7563 p0 = strchr(p, ')');
7568 if (size >= sizeof(s))
7571 snprintf(s, sizeof(s), "%.*s", size, p);
7572 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7573 if (ret < 0 || ret > max_num)
7575 for (i = 0; i < ret; i++) {
7577 int_fld = strtoul(str_fld[i], &end, 0);
7578 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7580 flexbytes[i] = (uint8_t)int_fld;
7585 static enum rte_eth_flow_type
7586 str2flowtype(char *string)
7589 static const struct {
7591 enum rte_eth_flow_type type;
7592 } flowtype_str[] = {
7593 {"raw", RTE_ETH_FLOW_TYPE_RAW},
7594 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
7595 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
7596 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
7597 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
7598 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
7599 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
7600 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
7601 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
7602 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
7603 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
7606 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7607 if (!strcmp(flowtype_str[i].str, string))
7608 return flowtype_str[i].type;
7610 return RTE_ETH_FLOW_TYPE_NONE;
7613 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
7615 if ((ip_addr).family == AF_INET) \
7616 (ip) = (ip_addr).addr.ipv4.s_addr; \
7618 printf("invalid parameter.\n"); \
7623 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
7625 if ((ip_addr).family == AF_INET6) \
7626 (void)rte_memcpy(&(ip), \
7627 &((ip_addr).addr.ipv6), \
7628 sizeof(struct in6_addr)); \
7630 printf("invalid parameter.\n"); \
7636 cmd_flow_director_filter_parsed(void *parsed_result,
7637 __attribute__((unused)) struct cmdline *cl,
7638 __attribute__((unused)) void *data)
7640 struct cmd_flow_director_result *res = parsed_result;
7641 struct rte_eth_fdir_filter entry;
7642 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
7645 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7647 printf("flow director is not supported on port %u.\n",
7651 memset(flexbytes, 0, sizeof(flexbytes));
7652 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
7653 ret = parse_flexbytes(res->flexbytes_value,
7655 RTE_ETH_FDIR_MAX_FLEXLEN);
7657 printf("error: Cannot parse flexbytes input.\n");
7661 entry.input.flow_type = str2flowtype(res->flow_type);
7662 switch (entry.input.flow_type) {
7663 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
7664 case RTE_ETH_FLOW_TYPE_FRAG_IPV4:
7665 case RTE_ETH_FLOW_TYPE_UDPV4:
7666 case RTE_ETH_FLOW_TYPE_TCPV4:
7667 IPV4_ADDR_TO_UINT(res->ip_dst,
7668 entry.input.flow.ip4_flow.dst_ip);
7669 IPV4_ADDR_TO_UINT(res->ip_src,
7670 entry.input.flow.ip4_flow.src_ip);
7671 /* need convert to big endian. */
7672 entry.input.flow.udp4_flow.dst_port =
7673 rte_cpu_to_be_16(res->port_dst);
7674 entry.input.flow.udp4_flow.src_port =
7675 rte_cpu_to_be_16(res->port_src);
7677 case RTE_ETH_FLOW_TYPE_SCTPV4:
7678 IPV4_ADDR_TO_UINT(res->ip_dst,
7679 entry.input.flow.sctp4_flow.ip.dst_ip);
7680 IPV4_ADDR_TO_UINT(res->ip_src,
7681 entry.input.flow.sctp4_flow.ip.src_ip);
7682 /* need convert to big endian. */
7683 entry.input.flow.sctp4_flow.verify_tag =
7684 rte_cpu_to_be_32(res->verify_tag_value);
7686 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
7687 case RTE_ETH_FLOW_TYPE_FRAG_IPV6:
7688 case RTE_ETH_FLOW_TYPE_UDPV6:
7689 case RTE_ETH_FLOW_TYPE_TCPV6:
7690 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7691 entry.input.flow.ipv6_flow.dst_ip);
7692 IPV6_ADDR_TO_ARRAY(res->ip_src,
7693 entry.input.flow.ipv6_flow.src_ip);
7694 /* need convert to big endian. */
7695 entry.input.flow.udp6_flow.dst_port =
7696 rte_cpu_to_be_16(res->port_dst);
7697 entry.input.flow.udp6_flow.src_port =
7698 rte_cpu_to_be_16(res->port_src);
7700 case RTE_ETH_FLOW_TYPE_SCTPV6:
7701 IPV6_ADDR_TO_ARRAY(res->ip_dst,
7702 entry.input.flow.sctp6_flow.ip.dst_ip);
7703 IPV6_ADDR_TO_ARRAY(res->ip_src,
7704 entry.input.flow.sctp6_flow.ip.src_ip);
7705 /* need convert to big endian. */
7706 entry.input.flow.sctp6_flow.verify_tag =
7707 rte_cpu_to_be_32(res->verify_tag_value);
7710 printf("invalid parameter.\n");
7713 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
7715 RTE_ETH_FDIR_MAX_FLEXLEN);
7717 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
7719 entry.action.flex_off = 0; /*use 0 by default */
7720 if (!strcmp(res->drop, "drop"))
7721 entry.action.behavior = RTE_ETH_FDIR_REJECT;
7723 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
7724 /* set to report FD ID by default */
7725 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
7726 entry.action.rx_queue = res->queue_id;
7727 entry.soft_id = res->fd_id_value;
7728 if (!strcmp(res->ops, "add"))
7729 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7730 RTE_ETH_FILTER_ADD, &entry);
7731 else if (!strcmp(res->ops, "del"))
7732 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7733 RTE_ETH_FILTER_DELETE, &entry);
7735 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7736 RTE_ETH_FILTER_UPDATE, &entry);
7738 printf("flow director programming error: (%s)\n",
7742 cmdline_parse_token_string_t cmd_flow_director_filter =
7743 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7744 flow_director_filter, "flow_director_filter");
7745 cmdline_parse_token_num_t cmd_flow_director_port_id =
7746 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7748 cmdline_parse_token_string_t cmd_flow_director_ops =
7749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7750 ops, "add#del#update");
7751 cmdline_parse_token_string_t cmd_flow_director_flow =
7752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7754 cmdline_parse_token_string_t cmd_flow_director_flow_type =
7755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7757 "ip4#ip4-frag#tcp4#udp4#sctp4#"
7758 "ip6#ip6-frag#tcp6#udp6#sctp6");
7759 cmdline_parse_token_string_t cmd_flow_director_src =
7760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7762 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
7763 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7765 cmdline_parse_token_num_t cmd_flow_director_port_src =
7766 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7768 cmdline_parse_token_string_t cmd_flow_director_dst =
7769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7771 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
7772 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
7774 cmdline_parse_token_num_t cmd_flow_director_port_dst =
7775 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7777 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
7778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7779 verify_tag, "verify_tag");
7780 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
7781 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7782 verify_tag_value, UINT32);
7783 cmdline_parse_token_string_t cmd_flow_director_vlan =
7784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7786 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
7787 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7788 vlan_value, UINT16);
7789 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
7790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7791 flexbytes, "flexbytes");
7792 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
7793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7794 flexbytes_value, NULL);
7795 cmdline_parse_token_string_t cmd_flow_director_drop =
7796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7798 cmdline_parse_token_string_t cmd_flow_director_queue =
7799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7801 cmdline_parse_token_num_t cmd_flow_director_queue_id =
7802 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7804 cmdline_parse_token_string_t cmd_flow_director_fd_id =
7805 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
7807 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
7808 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
7809 fd_id_value, UINT32);
7811 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
7812 .f = cmd_flow_director_filter_parsed,
7814 .help_str = "add or delete an ip flow director entry on NIC",
7816 (void *)&cmd_flow_director_filter,
7817 (void *)&cmd_flow_director_port_id,
7818 (void *)&cmd_flow_director_ops,
7819 (void *)&cmd_flow_director_flow,
7820 (void *)&cmd_flow_director_flow_type,
7821 (void *)&cmd_flow_director_src,
7822 (void *)&cmd_flow_director_ip_src,
7823 (void *)&cmd_flow_director_dst,
7824 (void *)&cmd_flow_director_ip_dst,
7825 (void *)&cmd_flow_director_vlan,
7826 (void *)&cmd_flow_director_vlan_value,
7827 (void *)&cmd_flow_director_flexbytes,
7828 (void *)&cmd_flow_director_flexbytes_value,
7829 (void *)&cmd_flow_director_drop,
7830 (void *)&cmd_flow_director_queue,
7831 (void *)&cmd_flow_director_queue_id,
7832 (void *)&cmd_flow_director_fd_id,
7833 (void *)&cmd_flow_director_fd_id_value,
7838 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
7839 .f = cmd_flow_director_filter_parsed,
7841 .help_str = "add or delete an udp/tcp flow director entry on NIC",
7843 (void *)&cmd_flow_director_filter,
7844 (void *)&cmd_flow_director_port_id,
7845 (void *)&cmd_flow_director_ops,
7846 (void *)&cmd_flow_director_flow,
7847 (void *)&cmd_flow_director_flow_type,
7848 (void *)&cmd_flow_director_src,
7849 (void *)&cmd_flow_director_ip_src,
7850 (void *)&cmd_flow_director_port_src,
7851 (void *)&cmd_flow_director_dst,
7852 (void *)&cmd_flow_director_ip_dst,
7853 (void *)&cmd_flow_director_port_dst,
7854 (void *)&cmd_flow_director_vlan,
7855 (void *)&cmd_flow_director_vlan_value,
7856 (void *)&cmd_flow_director_flexbytes,
7857 (void *)&cmd_flow_director_flexbytes_value,
7858 (void *)&cmd_flow_director_drop,
7859 (void *)&cmd_flow_director_queue,
7860 (void *)&cmd_flow_director_queue_id,
7861 (void *)&cmd_flow_director_fd_id,
7862 (void *)&cmd_flow_director_fd_id_value,
7867 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
7868 .f = cmd_flow_director_filter_parsed,
7870 .help_str = "add or delete a sctp flow director entry on NIC",
7872 (void *)&cmd_flow_director_filter,
7873 (void *)&cmd_flow_director_port_id,
7874 (void *)&cmd_flow_director_ops,
7875 (void *)&cmd_flow_director_flow,
7876 (void *)&cmd_flow_director_flow_type,
7877 (void *)&cmd_flow_director_src,
7878 (void *)&cmd_flow_director_ip_src,
7879 (void *)&cmd_flow_director_port_dst,
7880 (void *)&cmd_flow_director_dst,
7881 (void *)&cmd_flow_director_ip_dst,
7882 (void *)&cmd_flow_director_port_dst,
7883 (void *)&cmd_flow_director_verify_tag,
7884 (void *)&cmd_flow_director_verify_tag_value,
7885 (void *)&cmd_flow_director_vlan,
7886 (void *)&cmd_flow_director_vlan_value,
7887 (void *)&cmd_flow_director_flexbytes,
7888 (void *)&cmd_flow_director_flexbytes_value,
7889 (void *)&cmd_flow_director_drop,
7890 (void *)&cmd_flow_director_queue,
7891 (void *)&cmd_flow_director_queue_id,
7892 (void *)&cmd_flow_director_fd_id,
7893 (void *)&cmd_flow_director_fd_id_value,
7898 struct cmd_flush_flow_director_result {
7899 cmdline_fixed_string_t flush_flow_director;
7903 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
7904 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
7905 flush_flow_director, "flush_flow_director");
7906 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
7907 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
7911 cmd_flush_flow_director_parsed(void *parsed_result,
7912 __attribute__((unused)) struct cmdline *cl,
7913 __attribute__((unused)) void *data)
7915 struct cmd_flow_director_result *res = parsed_result;
7918 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
7920 printf("flow director is not supported on port %u.\n",
7925 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
7926 RTE_ETH_FILTER_FLUSH, NULL);
7928 printf("flow director table flushing error: (%s)\n",
7932 cmdline_parse_inst_t cmd_flush_flow_director = {
7933 .f = cmd_flush_flow_director_parsed,
7935 .help_str = "flush all flow director entries of a device on NIC",
7937 (void *)&cmd_flush_flow_director_flush,
7938 (void *)&cmd_flush_flow_director_port_id,
7943 /* *** deal with flow director mask *** */
7944 struct cmd_flow_director_mask_result {
7945 cmdline_fixed_string_t flow_director_mask;
7947 cmdline_fixed_string_t vlan;
7948 uint16_t vlan_value;
7949 cmdline_fixed_string_t src_mask;
7950 cmdline_ipaddr_t ipv4_src;
7951 cmdline_ipaddr_t ipv6_src;
7953 cmdline_fixed_string_t dst_mask;
7954 cmdline_ipaddr_t ipv4_dst;
7955 cmdline_ipaddr_t ipv6_dst;
7960 cmd_flow_director_mask_parsed(void *parsed_result,
7961 __attribute__((unused)) struct cmdline *cl,
7962 __attribute__((unused)) void *data)
7964 struct cmd_flow_director_mask_result *res = parsed_result;
7965 struct rte_eth_fdir_masks *mask;
7966 struct rte_port *port;
7968 if (res->port_id > nb_ports) {
7969 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
7973 port = &ports[res->port_id];
7974 /** Check if the port is not started **/
7975 if (port->port_status != RTE_PORT_STOPPED) {
7976 printf("Please stop port %d first\n", res->port_id);
7979 mask = &port->dev_conf.fdir_conf.mask;
7981 mask->vlan_tci_mask = res->vlan_value;
7982 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
7983 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
7984 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
7985 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
7986 mask->src_port_mask = res->port_src;
7987 mask->dst_port_mask = res->port_dst;
7989 cmd_reconfig_device_queue(res->port_id, 1, 1);
7992 cmdline_parse_token_string_t cmd_flow_director_mask =
7993 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
7994 flow_director_mask, "flow_director_mask");
7995 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
7996 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
7998 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
7999 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8001 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8002 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8003 vlan_value, UINT16);
8004 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8005 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8006 src_mask, "src_mask");
8007 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8008 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8010 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8011 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8013 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8014 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8016 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8017 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8018 dst_mask, "dst_mask");
8019 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8020 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8022 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8023 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8025 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8026 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8028 cmdline_parse_inst_t cmd_set_flow_director_mask = {
8029 .f = cmd_flow_director_mask_parsed,
8031 .help_str = "set flow director's mask on NIC",
8033 (void *)&cmd_flow_director_mask,
8034 (void *)&cmd_flow_director_mask_port_id,
8035 (void *)&cmd_flow_director_mask_vlan,
8036 (void *)&cmd_flow_director_mask_vlan_value,
8037 (void *)&cmd_flow_director_mask_src,
8038 (void *)&cmd_flow_director_mask_ipv4_src,
8039 (void *)&cmd_flow_director_mask_ipv6_src,
8040 (void *)&cmd_flow_director_mask_port_src,
8041 (void *)&cmd_flow_director_mask_dst,
8042 (void *)&cmd_flow_director_mask_ipv4_dst,
8043 (void *)&cmd_flow_director_mask_ipv6_dst,
8044 (void *)&cmd_flow_director_mask_port_dst,
8049 /* *** deal with flow director mask on flexible payload *** */
8050 struct cmd_flow_director_flex_mask_result {
8051 cmdline_fixed_string_t flow_director_flexmask;
8053 cmdline_fixed_string_t flow;
8054 cmdline_fixed_string_t flow_type;
8055 cmdline_fixed_string_t mask;
8059 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8060 __attribute__((unused)) struct cmdline *cl,
8061 __attribute__((unused)) void *data)
8063 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8064 struct rte_eth_fdir_info fdir_info;
8065 struct rte_eth_fdir_flex_mask flex_mask;
8066 struct rte_port *port;
8067 enum rte_eth_flow_type i;
8070 if (res->port_id > nb_ports) {
8071 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8075 port = &ports[res->port_id];
8076 /** Check if the port is not started **/
8077 if (port->port_status != RTE_PORT_STOPPED) {
8078 printf("Please stop port %d first\n", res->port_id);
8082 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8083 ret = parse_flexbytes(res->mask,
8085 RTE_ETH_FDIR_MAX_FLEXLEN);
8087 printf("error: Cannot parse mask input.\n");
8091 if (!strcmp(res->flow_type, "all")) {
8092 memset(&fdir_info, 0, sizeof(fdir_info));
8093 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8094 RTE_ETH_FILTER_INFO, &fdir_info);
8095 for (i = RTE_ETH_FLOW_TYPE_RAW;
8096 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8098 if (fdir_info.flow_types_mask[0] & (1 << i)) {
8099 flex_mask.flow_type = i;
8100 fdir_set_flex_mask(res->port_id, &flex_mask);
8103 cmd_reconfig_device_queue(res->port_id, 1, 1);
8106 flex_mask.flow_type = str2flowtype(res->flow_type);
8107 fdir_set_flex_mask(res->port_id, &flex_mask);
8108 cmd_reconfig_device_queue(res->port_id, 1, 1);
8111 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8112 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8113 flow_director_flexmask,
8114 "flow_director_flex_mask");
8115 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8116 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8118 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8119 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8121 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8122 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8124 "raw#ip4#ip4-frag#tcp4#udp4#sctp4#"
8125 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8126 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8130 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8131 .f = cmd_flow_director_flex_mask_parsed,
8133 .help_str = "set flow director's flex mask on NIC",
8135 (void *)&cmd_flow_director_flexmask,
8136 (void *)&cmd_flow_director_flexmask_port_id,
8137 (void *)&cmd_flow_director_flexmask_flow,
8138 (void *)&cmd_flow_director_flexmask_flow_type,
8139 (void *)&cmd_flow_director_flexmask_mask,
8144 /* *** deal with flow director flexible payload configuration *** */
8145 struct cmd_flow_director_flexpayload_result {
8146 cmdline_fixed_string_t flow_director_flexpayload;
8148 cmdline_fixed_string_t payload_layer;
8149 cmdline_fixed_string_t payload_cfg;
8153 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8156 const char *p, *p0 = q_arg;
8158 unsigned long int_fld;
8159 char *str_fld[max_num];
8164 p = strchr(p0, '(');
8168 p0 = strchr(p, ')');
8173 if (size >= sizeof(s))
8176 snprintf(s, sizeof(s), "%.*s", size, p);
8177 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8178 if (ret < 0 || ret > max_num)
8180 for (i = 0; i < ret; i++) {
8182 int_fld = strtoul(str_fld[i], &end, 0);
8183 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8185 offsets[i] = (uint16_t)int_fld;
8191 cmd_flow_director_flxpld_parsed(void *parsed_result,
8192 __attribute__((unused)) struct cmdline *cl,
8193 __attribute__((unused)) void *data)
8195 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8196 struct rte_eth_flex_payload_cfg flex_cfg;
8197 struct rte_port *port;
8200 if (res->port_id > nb_ports) {
8201 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8205 port = &ports[res->port_id];
8206 /** Check if the port is not started **/
8207 if (port->port_status != RTE_PORT_STOPPED) {
8208 printf("Please stop port %d first\n", res->port_id);
8212 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8214 if (!strcmp(res->payload_layer, "raw"))
8215 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
8216 else if (!strcmp(res->payload_layer, "l2"))
8217 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8218 else if (!strcmp(res->payload_layer, "l3"))
8219 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8220 else if (!strcmp(res->payload_layer, "l4"))
8221 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8223 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8224 RTE_ETH_FDIR_MAX_FLEXLEN);
8226 printf("error: Cannot parse flex payload input.\n");
8230 fdir_set_flex_payload(res->port_id, &flex_cfg);
8231 cmd_reconfig_device_queue(res->port_id, 1, 1);
8234 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8235 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8236 flow_director_flexpayload,
8237 "flow_director_flex_payload");
8238 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8239 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8241 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8242 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8243 payload_layer, "raw#l2#l3#l4");
8244 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8248 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8249 .f = cmd_flow_director_flxpld_parsed,
8251 .help_str = "set flow director's flex payload on NIC",
8253 (void *)&cmd_flow_director_flexpayload,
8254 (void *)&cmd_flow_director_flexpayload_port_id,
8255 (void *)&cmd_flow_director_flexpayload_payload_layer,
8256 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8261 /* *** Classification Filters Control *** */
8262 /* *** Get symmetric hash enable per port *** */
8263 struct cmd_get_sym_hash_ena_per_port_result {
8264 cmdline_fixed_string_t get_sym_hash_ena_per_port;
8269 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
8270 __rte_unused struct cmdline *cl,
8271 __rte_unused void *data)
8273 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
8274 struct rte_eth_hash_filter_info info;
8277 if (rte_eth_dev_filter_supported(res->port_id,
8278 RTE_ETH_FILTER_HASH) < 0) {
8279 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8284 memset(&info, 0, sizeof(info));
8285 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8286 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8287 RTE_ETH_FILTER_GET, &info);
8290 printf("Cannot get symmetric hash enable per port "
8291 "on port %u\n", res->port_id);
8295 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
8296 "enabled" : "disabled", res->port_id);
8299 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
8300 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8301 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
8302 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
8303 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
8306 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
8307 .f = cmd_get_sym_hash_per_port_parsed,
8309 .help_str = "get_sym_hash_ena_per_port port_id",
8311 (void *)&cmd_get_sym_hash_ena_per_port_all,
8312 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
8317 /* *** Set symmetric hash enable per port *** */
8318 struct cmd_set_sym_hash_ena_per_port_result {
8319 cmdline_fixed_string_t set_sym_hash_ena_per_port;
8320 cmdline_fixed_string_t enable;
8325 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
8326 __rte_unused struct cmdline *cl,
8327 __rte_unused void *data)
8329 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
8330 struct rte_eth_hash_filter_info info;
8333 if (rte_eth_dev_filter_supported(res->port_id,
8334 RTE_ETH_FILTER_HASH) < 0) {
8335 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
8340 memset(&info, 0, sizeof(info));
8341 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
8342 if (!strcmp(res->enable, "enable"))
8343 info.info.enable = 1;
8344 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8345 RTE_ETH_FILTER_SET, &info);
8347 printf("Cannot set symmetric hash enable per port on "
8348 "port %u\n", res->port_id);
8351 printf("Symmetric hash has been set to %s on port %u\n",
8352 res->enable, res->port_id);
8355 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
8356 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8357 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
8358 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
8359 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8361 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
8362 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
8363 enable, "enable#disable");
8365 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
8366 .f = cmd_set_sym_hash_per_port_parsed,
8368 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
8370 (void *)&cmd_set_sym_hash_ena_per_port_all,
8371 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
8372 (void *)&cmd_set_sym_hash_ena_per_port_enable,
8377 /* Get global config of hash function */
8378 struct cmd_get_hash_global_config_result {
8379 cmdline_fixed_string_t get_hash_global_config;
8384 flowtype_to_str(enum rte_eth_flow_type ftype)
8389 enum rte_eth_flow_type ftype;
8391 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
8392 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
8393 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
8394 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8395 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8396 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8397 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8398 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8399 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8400 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8403 for (i = 0; i < RTE_DIM(ftype_table); i++) {
8404 if (ftype_table[i].ftype == ftype)
8405 return ftype_table[i].str;
8412 cmd_get_hash_global_config_parsed(void *parsed_result,
8413 __rte_unused struct cmdline *cl,
8414 __rte_unused void *data)
8416 struct cmd_get_hash_global_config_result *res = parsed_result;
8417 struct rte_eth_hash_filter_info info;
8418 uint32_t idx, offset, i;
8422 if (rte_eth_dev_filter_supported(res->port_id,
8423 RTE_ETH_FILTER_HASH) < 0) {
8424 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8429 memset(&info, 0, sizeof(info));
8430 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8431 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8432 RTE_ETH_FILTER_GET, &info);
8434 printf("Cannot get hash global configurations by port %d\n",
8439 switch (info.info.global_conf.hash_func) {
8440 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
8441 printf("Hash function is Toeplitz\n");
8443 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
8444 printf("Hash function is Simple XOR\n");
8447 printf("Unknown hash function\n");
8451 for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
8452 idx = i / UINT32_BIT;
8453 offset = i % UINT32_BIT;
8454 if (!(info.info.global_conf.valid_bit_mask[idx] &
8457 str = flowtype_to_str((enum rte_eth_flow_type)i);
8460 printf("Symmetric hash is %s globally for flow type %s "
8462 ((info.info.global_conf.sym_hash_enable_mask[idx] &
8463 (1UL << offset)) ? "enabled" : "disabled"), str,
8468 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
8469 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
8470 get_hash_global_config, "get_hash_global_config");
8471 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
8472 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
8475 cmdline_parse_inst_t cmd_get_hash_global_config = {
8476 .f = cmd_get_hash_global_config_parsed,
8478 .help_str = "get_hash_global_config port_id",
8480 (void *)&cmd_get_hash_global_config_all,
8481 (void *)&cmd_get_hash_global_config_port_id,
8486 /* Set global config of hash function */
8487 struct cmd_set_hash_global_config_result {
8488 cmdline_fixed_string_t set_hash_global_config;
8490 cmdline_fixed_string_t hash_func;
8491 cmdline_fixed_string_t flow_type;
8492 cmdline_fixed_string_t enable;
8496 cmd_set_hash_global_config_parsed(void *parsed_result,
8497 __rte_unused struct cmdline *cl,
8498 __rte_unused void *data)
8500 struct cmd_set_hash_global_config_result *res = parsed_result;
8501 struct rte_eth_hash_filter_info info;
8502 uint32_t ftype, idx, offset;
8505 if (rte_eth_dev_filter_supported(res->port_id,
8506 RTE_ETH_FILTER_HASH) < 0) {
8507 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
8511 memset(&info, 0, sizeof(info));
8512 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
8513 if (!strcmp(res->hash_func, "toeplitz"))
8514 info.info.global_conf.hash_func =
8515 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
8516 else if (!strcmp(res->hash_func, "simple_xor"))
8517 info.info.global_conf.hash_func =
8518 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
8519 else if (!strcmp(res->hash_func, "default"))
8520 info.info.global_conf.hash_func =
8521 RTE_ETH_HASH_FUNCTION_DEFAULT;
8523 ftype = str2flowtype(res->flow_type);
8524 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
8525 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
8526 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
8527 if (!strcmp(res->enable, "enable"))
8528 info.info.global_conf.sym_hash_enable_mask[idx] |=
8530 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
8531 RTE_ETH_FILTER_SET, &info);
8533 printf("Cannot set global hash configurations by port %d\n",
8536 printf("Global hash configurations have been set "
8537 "succcessfully by port %d\n", res->port_id);
8540 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
8541 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8542 set_hash_global_config, "set_hash_global_config");
8543 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
8544 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
8546 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
8547 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8548 hash_func, "toeplitz#simple_xor#default");
8549 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
8550 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8552 "ip4#ip4-frag#tcp4#udp4#sctp4#ip6#ip6-frag#tcp6#udp6#sctp6");
8553 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
8554 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
8555 enable, "enable#disable");
8557 cmdline_parse_inst_t cmd_set_hash_global_config = {
8558 .f = cmd_set_hash_global_config_parsed,
8560 .help_str = "set_hash_global_config port_id "
8561 "toeplitz|simple_xor|default "
8562 "ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6 "
8565 (void *)&cmd_set_hash_global_config_all,
8566 (void *)&cmd_set_hash_global_config_port_id,
8567 (void *)&cmd_set_hash_global_config_hash_func,
8568 (void *)&cmd_set_hash_global_config_flow_type,
8569 (void *)&cmd_set_hash_global_config_enable,
8574 /* ******************************************************************************** */
8576 /* list of instructions */
8577 cmdline_parse_ctx_t main_ctx[] = {
8578 (cmdline_parse_inst_t *)&cmd_help_brief,
8579 (cmdline_parse_inst_t *)&cmd_help_long,
8580 (cmdline_parse_inst_t *)&cmd_quit,
8581 (cmdline_parse_inst_t *)&cmd_showport,
8582 (cmdline_parse_inst_t *)&cmd_showportall,
8583 (cmdline_parse_inst_t *)&cmd_showcfg,
8584 (cmdline_parse_inst_t *)&cmd_start,
8585 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8586 (cmdline_parse_inst_t *)&cmd_set_link_up,
8587 (cmdline_parse_inst_t *)&cmd_set_link_down,
8588 (cmdline_parse_inst_t *)&cmd_reset,
8589 (cmdline_parse_inst_t *)&cmd_set_numbers,
8590 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8591 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8592 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8593 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8594 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8595 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8596 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8597 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8598 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8599 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8600 (cmdline_parse_inst_t *)&cmd_set_link_check,
8601 #ifdef RTE_NIC_BYPASS
8602 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8603 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8604 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8605 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8607 #ifdef RTE_LIBRTE_PMD_BOND
8608 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8609 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8610 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8611 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8612 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8613 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8614 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8615 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8616 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8618 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8619 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8620 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8621 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8622 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8623 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8624 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8625 (cmdline_parse_inst_t *)&cmd_csum_set,
8626 (cmdline_parse_inst_t *)&cmd_csum_show,
8627 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
8628 (cmdline_parse_inst_t *)&cmd_tso_set,
8629 (cmdline_parse_inst_t *)&cmd_tso_show,
8630 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8631 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8632 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8633 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8634 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8635 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8636 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8637 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8638 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8639 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8640 (cmdline_parse_inst_t *)&cmd_config_dcb,
8641 (cmdline_parse_inst_t *)&cmd_read_reg,
8642 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8643 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8644 (cmdline_parse_inst_t *)&cmd_write_reg,
8645 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8646 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8647 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8648 (cmdline_parse_inst_t *)&cmd_stop,
8649 (cmdline_parse_inst_t *)&cmd_mac_addr,
8650 (cmdline_parse_inst_t *)&cmd_set_qmap,
8651 (cmdline_parse_inst_t *)&cmd_operate_port,
8652 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8653 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8654 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8655 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8656 (cmdline_parse_inst_t *)&cmd_config_mtu,
8657 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8658 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8659 (cmdline_parse_inst_t *)&cmd_config_rss,
8660 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8661 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8662 (cmdline_parse_inst_t *)&cmd_showport_reta,
8663 (cmdline_parse_inst_t *)&cmd_config_burst,
8664 (cmdline_parse_inst_t *)&cmd_config_thresh,
8665 (cmdline_parse_inst_t *)&cmd_config_threshold,
8666 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8667 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8668 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8669 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8670 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8671 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8672 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8673 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8674 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8675 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8676 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8677 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8678 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8679 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8680 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8681 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8682 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8683 (cmdline_parse_inst_t *)&cmd_dump,
8684 (cmdline_parse_inst_t *)&cmd_dump_one,
8685 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
8686 (cmdline_parse_inst_t *)&cmd_syn_filter,
8687 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
8688 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
8689 (cmdline_parse_inst_t *)&cmd_flex_filter,
8690 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8691 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8692 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8693 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8694 (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
8695 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8696 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8697 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
8698 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
8699 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
8700 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
8704 /* prompt function, called from main on MASTER lcore */
8710 /* initialize non-constant commands */
8711 cmd_set_fwd_mode_init();
8713 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8717 cmdline_interact(cl);
8718 cmdline_stdin_exit(cl);
8722 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8724 if (id < nb_ports) {
8725 /* check if need_reconfig has been set to 1 */
8726 if (ports[id].need_reconfig == 0)
8727 ports[id].need_reconfig = dev;
8728 /* check if need_reconfig_queues has been set to 1 */
8729 if (ports[id].need_reconfig_queues == 0)
8730 ports[id].need_reconfig_queues = queue;
8734 for (pid = 0; pid < nb_ports; pid++) {
8735 /* check if need_reconfig has been set to 1 */
8736 if (ports[pid].need_reconfig == 0)
8737 ports[pid].need_reconfig = dev;
8738 /* check if need_reconfig_queues has been set to 1 */
8739 if (ports[pid].need_reconfig_queues == 0)
8740 ports[pid].need_reconfig_queues = queue;
8745 #ifdef RTE_NIC_BYPASS
8747 bypass_is_supported(portid_t port_id)
8749 struct rte_port *port;
8750 struct rte_pci_id *pci_id;
8752 if (port_id >= nb_ports) {
8753 printf("\tPort id must be less than %d.\n", nb_ports);
8757 /* Get the device id. */
8758 port = &ports[port_id];
8759 pci_id = &port->dev_info.pci_dev->id;
8761 /* Check if NIC supports bypass. */
8762 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8766 printf("\tBypass not supported for port_id = %d.\n", port_id);